customformCtrl.js 853 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. overwriteOk: true,
  85. name: "bootstrapLabel",
  86. templateUrl: "assets/views/customform/tpl/normal-label.html",
  87. });
  88. //流程图
  89. formlyConfigProvider.setType({
  90. name: "ui-process",
  91. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () { },
  96. refreshDelay: 0,
  97. },
  98. };
  99. },
  100. controller: [
  101. "$scope",
  102. "$modal",
  103. "SweetAlert",
  104. "api_bpm_domain",
  105. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. $scope.processdata = [];
  107. api_bpm_domain
  108. .flowTracing($scope.model.applicationForm.processInstanceId)
  109. .then(function (data) {
  110. console.log(data);
  111. $scope.processdata = data.data;
  112. });
  113. },
  114. ],
  115. });
  116. //出库单详情
  117. formlyConfigProvider.setType({
  118. name: "ui-getoutinform",
  119. extends: "radio",
  120. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  121. defaultOptions: function (options) {
  122. return {
  123. templateOptions: {
  124. refresh: function () { },
  125. refreshDelay: 0,
  126. },
  127. };
  128. },
  129. controller: [
  130. "$scope",
  131. "$modal",
  132. "SweetAlert",
  133. "api_bpm_domain",
  134. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  135. if (
  136. angular.isDefined($scope.model.type.id) &&
  137. !$scope.model.type.name
  138. ) {
  139. if (($scope.model.type.id = 0)) {
  140. $scope.model.type.name = "新资产入库";
  141. } else if (($scope.model.type.id = 1)) {
  142. $scope.model.type.name = "新设备领用出库";
  143. } else if (($scope.model.type.id = 2)) {
  144. $scope.model.type.name = "资产归还";
  145. } else if (($scope.model.type.id = 4)) {
  146. $scope.model.type.name = "设备更换";
  147. }
  148. }
  149. },
  150. ],
  151. });
  152. //多选框组件
  153. formlyConfigProvider.setType({
  154. name: "ui-checkboxmore",
  155. extends: "radio",
  156. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  157. defaultOptions: function (options) {
  158. return {
  159. templateOptions: {
  160. refresh: function () { },
  161. refreshDelay: 0,
  162. },
  163. };
  164. },
  165. controller: [
  166. "$scope",
  167. "$modal",
  168. "SweetAlert",
  169. "api_bpm_domain",
  170. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  171. $scope.options.initialValue = $scope.model[$scope.options.key];
  172. },
  173. ],
  174. });
  175. //入库单详情
  176. formlyConfigProvider.setType({
  177. name: "ui-getininform",
  178. extends: "radio",
  179. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  180. defaultOptions: function (options) {
  181. return {
  182. templateOptions: {
  183. refresh: function () { },
  184. refreshDelay: 0,
  185. },
  186. };
  187. },
  188. controller: [
  189. "$scope",
  190. "$modal",
  191. "SweetAlert",
  192. "api_bpm_domain",
  193. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  194. if (
  195. angular.isDefined($scope.model.type.id) &&
  196. !$scope.model.type.name
  197. ) {
  198. if (($scope.model.type.id = 0)) {
  199. $scope.model.type.name = "新资产入库";
  200. } else if (($scope.model.type.id = 1)) {
  201. $scope.model.type.name = "新设备领用出库";
  202. } else if (($scope.model.type.id = 2)) {
  203. $scope.model.type.name = "资产归还";
  204. } else if (($scope.model.type.id = 4)) {
  205. $scope.model.type.name = "设备更换";
  206. }
  207. }
  208. },
  209. ],
  210. });
  211. //申请人详情
  212. formlyConfigProvider.setType({
  213. name: "ui-requsterinfom",
  214. extends: "radio",
  215. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  216. defaultOptions: function (options) {
  217. return {
  218. templateOptions: {
  219. refresh: function () { },
  220. refreshDelay: 0,
  221. },
  222. };
  223. },
  224. });
  225. //设备耗材list组件
  226. formlyConfigProvider.setType({
  227. name: "ui-uplodchange",
  228. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  229. defaultOptions: function (options) {
  230. return {
  231. templateOptions: {
  232. refresh: function () { },
  233. refreshDelay: 0,
  234. view: function (APIService, contentId) {
  235. return APIService.downloadAttachment(contentId);
  236. },
  237. },
  238. };
  239. },
  240. controller: [
  241. "$scope",
  242. "$filter",
  243. "ngTableParams",
  244. "$rootScope",
  245. "Restangular",
  246. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  247. // var data = { "haodata": [], "shedata": [] };
  248. var haodata = [];
  249. var shedata = [];
  250. if ($scope.model.consumables) {
  251. if (angular.isArray($scope.model.consumables)) {
  252. haodata = $scope.model.consumables;
  253. } else {
  254. haodata = JSON.parse($scope.model.consumables);
  255. }
  256. $scope.model.consumables = haodata;
  257. angular.forEach(haodata, function (item, index) {
  258. haodata[index].item = index + 1;
  259. });
  260. }
  261. if ($scope.model.assets) {
  262. if (angular.isArray($scope.model.assets)) {
  263. shedata = $scope.model.assets;
  264. } else {
  265. shedata = JSON.parse($scope.model.assets);
  266. }
  267. $scope.model.assets = shedata;
  268. angular.forEach(shedata, function (item, index) {
  269. shedata[index].item = index + 1;
  270. });
  271. }
  272. $scope.tableParamshao = new ngTableParams(
  273. {
  274. page: 1,
  275. count: 5,
  276. },
  277. {
  278. total: haodata.length,
  279. getData: function ($defer, params) {
  280. var orderedData = params.sorting()
  281. ? $filter("orderBy")(haodata, params.orderBy())
  282. : haodata;
  283. $defer.resolve(
  284. orderedData.slice(
  285. (params.page() - 1) * params.count(),
  286. params.page() * params.count()
  287. )
  288. );
  289. },
  290. }
  291. );
  292. $scope.tableParamsshe = new ngTableParams(
  293. {
  294. page: 1,
  295. count: 5,
  296. },
  297. {
  298. total: shedata.length,
  299. getData: function ($defer, params) {
  300. var orderedData = params.sorting()
  301. ? $filter("orderBy")(shedata, params.orderBy())
  302. : shedata;
  303. $defer.resolve(
  304. orderedData.slice(
  305. (params.page() - 1) * params.count(),
  306. params.page() * params.count()
  307. )
  308. );
  309. },
  310. }
  311. );
  312. $scope.editId = -1;
  313. $scope.setEditId = function (pid) {
  314. $scope.editId = pid;
  315. };
  316. if (angular.isUndefined($scope.form.dropState)) {
  317. $scope.form.dropState = false;
  318. }
  319. var to = $scope.options.templateOptions;
  320. var bindId = $scope.model.processInstanceId;
  321. //获取附件列表
  322. $scope.listAttachmen = function () {
  323. to.ApiService.listAttachment(
  324. to.listAttachmentUrl,
  325. to.bindType,
  326. bindId
  327. ).then(function (result) {
  328. var myData = Restangular.stripRestangular(result);
  329. // $scope.listAttachmens = myData;
  330. $scope.attachments = myData.data;
  331. });
  332. };
  333. $scope.listAttachmen();
  334. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  335. // $scope.listAttachmen();
  336. // } else if (to.bindType && $scope.model[to.bindType].id) {
  337. // $scope.listAttachmen();
  338. // }
  339. //附件下载
  340. $scope.download = function (token, filename) {
  341. var downUrl = to.ApiService.downloadAttachment(
  342. to.downUrl,
  343. token
  344. ).getRequestedUrl();
  345. // window.open(downUrl);
  346. var a = document.createElement("a");
  347. a.href = downUrl;
  348. a.target = "_blank";
  349. a.download = filename;
  350. document.body.appendChild(a);
  351. a.click();
  352. };
  353. //附件预览
  354. $scope.view = function (id, previewUrl) {
  355. if (previewUrl) {
  356. window.open(previewUrl);
  357. }
  358. };
  359. },
  360. ],
  361. });
  362. //多选框组件
  363. formlyConfigProvider.setType({
  364. name: "ui-nodataimage",
  365. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  366. defaultOptions: function (options) {
  367. return {
  368. templateOptions: {
  369. refresh: function () { },
  370. refreshDelay: 0,
  371. },
  372. };
  373. },
  374. });
  375. //ui-grid list
  376. formlyConfigProvider.setType({
  377. name: "ui-gridtwolist",
  378. // extends: 'input',
  379. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  380. defaultOptions: function (options, $scope) {
  381. return {
  382. templateOptions: {},
  383. };
  384. },
  385. controller: [
  386. "$scope",
  387. "$modal",
  388. "i18nService",
  389. "SweetAlert",
  390. function ($scope, $modal, i18nService, SweetAlert) {
  391. //gridone
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = "zh-cn";
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions = {};
  396. $scope.gridOptions.data = "myDatagrid";
  397. $scope.gridOptions.enableColumnResizing = true;
  398. $scope.gridOptions.enableFiltering = true;
  399. $scope.gridOptions.enableGridMenu = false;
  400. $scope.gridOptions.enableRowSelection = true;
  401. $scope.gridOptions.showGridFooter = true;
  402. $scope.gridOptions.showColumnFooter = false;
  403. $scope.gridOptions.fastWatch = true;
  404. $scope.gridOptions.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  407. $scope.gridOptions.paginationPageSize = 10;
  408. $scope.gridOptions.multiSelect = false;
  409. $scope.myDatagrid = [];
  410. $scope.myDatagridall = [];
  411. $scope.selected = {
  412. item: {},
  413. };
  414. $scope.memoryfilterDatagrid = {
  415. idx: 0,
  416. sum: 10,
  417. };
  418. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  419. filterData = {
  420. idx: 0,
  421. sum: 10,
  422. };
  423. $scope.gridOptions.columnDefs =
  424. $scope.options.templateOptions.columnDefs;
  425. }
  426. $scope.gridOptions.rowIdentity = function (row) {
  427. return row.id;
  428. };
  429. $scope.gridOptions.getRowIdentity = function (row) {
  430. return row.id;
  431. };
  432. // $scope.gridOptions.columnDefs = items.columnDefs();
  433. $scope.interceptMydata = function (mydate, idx, sum) {
  434. return mydate.slice(idx * sum, (idx + 1) * sum);
  435. };
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged(
  439. $scope,
  440. function (newPage, pageSize) {
  441. $scope.memoryfilterDatagrid.idx = newPage - 1;
  442. $scope.memoryfilterDatagrid.sum = pageSize;
  443. $scope.myDatagrid = $scope.interceptMydata(
  444. $scope.myDatagridall,
  445. $scope.memoryfilterDatagrid.idx,
  446. 10
  447. );
  448. $scope.loadData({
  449. idx: newPage - 1,
  450. sum: pageSize,
  451. });
  452. }
  453. );
  454. gridApi.core.on.filterChanged($scope, function () { });
  455. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  456. $scope.selected.item = data.entity;
  457. //console.log(data);
  458. });
  459. };
  460. $scope.loadData = function (mydate, idx, sum) {
  461. angular.forEach($scope.myDatagrid, function (item, index) {
  462. $scope.myDatagrid[index].item = index;
  463. });
  464. $scope.gridOptions.totalItems = mydate.length;
  465. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  466. };
  467. if ($scope.model.assets) {
  468. $scope.myDatagridall = $scope.model.assets;
  469. $scope.loadData($scope.model.assets, 0, 10);
  470. }
  471. $scope.saveData = function (itemin) {
  472. event.preventDefault();
  473. var modalInstance = $modal.open({
  474. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  475. controller: function ($scope, $modalInstance, SweetAlert) {
  476. // $scope.consumptive = {};
  477. $scope.title = "填写领用设备信息";
  478. // if (items.name) {
  479. // $scope.consumptive.name = items.name.name;
  480. // }
  481. $scope.placechange = angular.copy(itemin);
  482. $scope.ok = function (item) {
  483. if (
  484. item.props &&
  485. item.props.hwnw_area &&
  486. item.props.hwnw_place &&
  487. item.props.hwnw_room &&
  488. item.props.hwnwswt_jiguihao &&
  489. item.props.hwnwswt_Ushu &&
  490. item.props.snnum
  491. ) {
  492. $modalInstance.close(item);
  493. } else {
  494. SweetAlert.swal({
  495. title: "数据填写不完整!",
  496. text: "请检查数据然后提交!",
  497. type: "error",
  498. });
  499. }
  500. };
  501. $scope.cancel = function () {
  502. $modalInstance.dismiss("cancel");
  503. };
  504. },
  505. resolve: {
  506. SweetAlert: function () {
  507. return SweetAlert;
  508. },
  509. },
  510. });
  511. modalInstance.result.then(function (selectedItem) {
  512. angular.forEach($scope.myDatagrid, function (item, index) {
  513. // $scope.myDatagrid[index].props.hw_state = "在线";
  514. if (item.id == selectedItem.id) {
  515. // $scope.myDatagrid[index] = selectedItem;
  516. angular.extend($scope.myDatagrid[index], selectedItem);
  517. }
  518. });
  519. // $scope.myData3.push(selectedItem);
  520. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  521. $scope.myDatagrid[i]["item"] =
  522. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  523. }
  524. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  525. $scope.myDatagridall;
  526. });
  527. };
  528. //gridtwo
  529. $scope.langs = i18nService.getAllLangs();
  530. $scope.lang = "zh-cn";
  531. i18nService.setCurrentLang($scope.lang);
  532. $scope.gridOptions2 = {};
  533. $scope.gridOptions2.data = "myDatagridold";
  534. $scope.gridOptions2.enableColumnResizing = true;
  535. $scope.gridOptions2.enableFiltering = true;
  536. $scope.gridOptions2.enableGridMenu = false;
  537. $scope.gridOptions2.enableRowSelection = true;
  538. $scope.gridOptions2.showGridFooter = true;
  539. $scope.gridOptions2.showColumnFooter = false;
  540. $scope.gridOptions2.fastWatch = true;
  541. $scope.gridOptions2.useExternalFiltering = false;
  542. $scope.gridOptions.useExternalPagination = true;
  543. $scope.gridOptions2.paginationPageSizes = [10];
  544. $scope.gridOptions2.paginationPageSize = 10;
  545. $scope.gridOptions2.multiSelect = false;
  546. $scope.myDatagridold = [];
  547. $scope.myDatagridoldall = [];
  548. $scope.selected = {
  549. item: {},
  550. };
  551. $scope.memoryfilterDatagridold = {
  552. idx: 0,
  553. sum: 10,
  554. };
  555. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  556. filterData = {
  557. idx: 0,
  558. sum: 10,
  559. };
  560. $scope.gridOptions2.columnDefs =
  561. $scope.options.templateOptions.columnDefstwo;
  562. }
  563. $scope.gridOptions2.rowIdentity = function (row) {
  564. return row.id;
  565. };
  566. $scope.gridOptions2.getRowIdentity = function (row) {
  567. return row.id;
  568. };
  569. // $scope.gridOptions.columnDefs = items.columnDefs();
  570. $scope.interceptMydata = function (mydate, idx, sum) {
  571. return mydate.slice(idx * sum, (idx + 1) * sum);
  572. };
  573. if ($scope.model.oldAssets) {
  574. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  575. $scope.myDatagridold = $scope.interceptMydata(
  576. $scope.myDatagridallold,
  577. $scope.memoryfilterDatagridold.idx,
  578. 10
  579. );
  580. }
  581. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  582. $scope.gridApi = gridApi;
  583. gridApi.pagination.on.paginationChanged(
  584. $scope,
  585. function (newPage, pageSize) {
  586. $scope.memoryfilterDatagridold.idx = newPage - 1;
  587. $scope.memoryfilterDatagridold.sum = pageSize;
  588. $scope.myDatagridold = $scope.interceptMydata(
  589. $scope.myDatagridallold,
  590. $scope.memoryfilterDatagridold.idx,
  591. 10
  592. );
  593. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  594. }
  595. );
  596. gridApi.core.on.filterChanged($scope, function () { });
  597. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  598. $scope.selected.item = data.entity;
  599. //console.log(data);
  600. });
  601. };
  602. // $scope.loadData = function(mydate, idx, sum) {
  603. // angular.forEach($scope.myDatagridold, function(item, index) {
  604. // $scope.myDatagridold[index].item = index;
  605. // })
  606. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  607. // }
  608. // if ($scope.model.assets) {
  609. // $scope.myDatagridallold = $scope.model.assets;
  610. // $scope.loadData($scope.model.assets, 0, 10)
  611. // }
  612. // $scope.addoldassets = function(itemin) {
  613. // event.preventDefault();
  614. // var modalInstance = $modal.open({
  615. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  616. // controller: function($scope, $modalInstance, SweetAlert) {
  617. // // $scope.consumptive = {};
  618. // $scope.title = "填写领用设备信息";
  619. // // if (items.name) {
  620. // // $scope.consumptive.name = items.name.name;
  621. // // }
  622. // $scope.placechange = itemin;
  623. // $scope.ok = function(item) {
  624. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  625. // $modalInstance.close(item);
  626. // } else {
  627. // SweetAlert.swal({
  628. // title: "数据填写不完整!",
  629. // text: "请检查数据然后提交!",
  630. // type: "error"
  631. // });
  632. // }
  633. // };
  634. // $scope.cancel = function() {
  635. // $modalInstance.dismiss('cancel');
  636. // };
  637. // },
  638. // resolve: {
  639. // SweetAlert: function() {
  640. // return SweetAlert;
  641. // }
  642. // }
  643. // });
  644. $scope.interceptMydata = function (mydate, idx, sum) {
  645. return mydate.slice(idx * sum, (idx + 1) * sum);
  646. };
  647. $scope.addshebei = function () {
  648. event.preventDefault();
  649. var modalInstance = $modal.open({
  650. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  651. controller: function (
  652. $scope,
  653. i18nService,
  654. $modalInstance,
  655. items,
  656. title,
  657. Restangular,
  658. APIService,
  659. onDataCallback,
  660. parentScope,
  661. api_configure_data,
  662. api_configure_form,
  663. api_cmdb
  664. ) {
  665. $scope.langs = i18nService.getAllLangs();
  666. $scope.lang = "zh-cn";
  667. i18nService.setCurrentLang($scope.lang);
  668. $scope.gridOptions = {};
  669. $scope.gridOptions.data = "myDatatwo";
  670. $scope.gridOptions.enableColumnResizing = true;
  671. $scope.gridOptions.enableFiltering = false;
  672. $scope.gridOptions.enableGridMenu = false;
  673. $scope.gridOptions.showGridFooter = true;
  674. $scope.gridOptions.showColumnFooter = false;
  675. $scope.gridOptions.fastWatch = true;
  676. $scope.gridOptions.useExternalFiltering = true;
  677. $scope.gridOptions.useExternalPagination = true;
  678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  679. $scope.gridOptions.paginationPageSize = 10;
  680. $scope.gridOptions.multiSelect = true;
  681. $scope.gridOptions.rowIdentity = function (row) {
  682. return row.id;
  683. };
  684. $scope.gridOptions.getRowIdentity = function (row) {
  685. return row.id;
  686. };
  687. $scope.gridOptions.columnDefs = [
  688. {
  689. name: "item",
  690. displayName: "序号",
  691. width: 80,
  692. enableFiltering: false,
  693. },
  694. {
  695. name: "uuid",
  696. displayName: "内部编号",
  697. width: 150,
  698. },
  699. {
  700. name: "props.hw_mingcheng",
  701. displayName: "资产名称",
  702. width: 100,
  703. },
  704. {
  705. name: "props.hw_cifilterClassic",
  706. displayName: "资产类型",
  707. width: 120,
  708. enableFiltering: false,
  709. },
  710. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  711. {
  712. name: "props.hw_state",
  713. displayName: "资产状态",
  714. width: 150,
  715. enableFiltering: false,
  716. },
  717. {
  718. name: "props.hwnw_area",
  719. displayName: "资产地点",
  720. width: 130,
  721. enableFiltering: false,
  722. },
  723. {
  724. name: "createtime",
  725. displayName: "申请时间",
  726. enableFiltering: false,
  727. },
  728. ];
  729. // $scope.selectButtonClick
  730. var defaultFilterData = {
  731. // "assignee":2,
  732. // "applicationForm": { "hw_state": "在线" },
  733. hw_state: "在线",
  734. idx: 0,
  735. sum: 10,
  736. };
  737. $scope.memoryfilterData = {
  738. // "assignee":2,
  739. // "applicationForm": { "hw_state": "在线" },
  740. hw_state: "在线",
  741. idx: 0,
  742. sum: 10,
  743. };
  744. $scope.refreshData = function (style, filterData) {
  745. if (angular.isUndefined(filterData)) {
  746. filterData = defaultFilterData;
  747. }
  748. $scope.myDatatwo = [];
  749. // $scope.gridOptions['sum']=filterData.sum;
  750. api_cmdb.query(filterData).then(
  751. function (data) {
  752. // $scope.callsPending--;
  753. var myDatatwo = Restangular.stripRestangular(data);
  754. $scope.gridOptions["totalItems"] = data.total;
  755. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  756. myDatatwo.data.node[i].createtime = moment(
  757. myDatatwo.data.node[i].createtime
  758. ).format("YYYY-MM-DD");
  759. }
  760. $scope.myDatatwo = myDatatwo.data.node;
  761. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  762. $scope.myDatatwo[i]["item"] =
  763. i + 1 + filterData.idx * filterData.sum;
  764. }
  765. },
  766. function () { }
  767. );
  768. };
  769. $scope.refreshData("expand-right", defaultFilterData);
  770. $scope.gridOptions.onRegisterApi = function (gridApi) {
  771. $scope.gridApi = gridApi;
  772. gridApi.pagination.on.paginationChanged(
  773. $scope,
  774. function (newPage, pageSize) {
  775. var filtersData = $scope.memoryfilterData;
  776. filtersData.idx = newPage - 1;
  777. filtersData.sum = pageSize;
  778. // $scope.loadData(filtersData);
  779. $scope.refreshData("expand-right", filtersData);
  780. //console.log(pageSize);
  781. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  782. }
  783. );
  784. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  785. // $scope.selected.items.push(data.entity);
  786. //console.log(data);
  787. gridApi.selection.on.rowSelectionChanged(
  788. $scope,
  789. function (scope, ect) {
  790. if (scope.isSelected) {
  791. scope.grid.appScope.selected.items.push(scope.entity);
  792. } else {
  793. for (
  794. var i = 0;
  795. i <= scope.grid.appScope.selected.items.length;
  796. i++
  797. ) {
  798. if (
  799. scope.grid.appScope.selected.items[i].id ==
  800. scope.entity.id
  801. ) {
  802. scope.grid.appScope.selected.items.splice(i, 1);
  803. break;
  804. }
  805. }
  806. }
  807. $scope.mySelectedRows =
  808. $scope.gridApi.selection.getSelectedRows();
  809. }
  810. );
  811. // });
  812. gridApi.selection.on.rowSelectionChangedBatch(
  813. $scope,
  814. function (rows) {
  815. // $scope.selected.items = data.entity;
  816. //console.log(data);
  817. var selectitem = [];
  818. selectitem = angular.copy($scope.selected.items);
  819. for (var j = 0; j < rows.length; j++) {
  820. if (rows[j].isSelected == true) {
  821. selectitem.push(rows[j].entity);
  822. } else {
  823. delete selectitem[j];
  824. // rows.splice(j, 1);
  825. }
  826. }
  827. $scope.selected.items = [];
  828. for (var i = 0; i < selectitem.length; i++) {
  829. if (selectitem[i]) {
  830. $scope.selected.items.push(selectitem[i]);
  831. }
  832. }
  833. }
  834. );
  835. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  836. // // if (row.entity.age > 45) {
  837. // row.grid.api.selection.selectRow(row.entity); // 选中行
  838. // // }
  839. // };
  840. gridApi.core.on.filterChanged($scope, function () {
  841. var grid = this.grid;
  842. var filtersData = {
  843. idx: 0,
  844. sum: 10,
  845. user: {
  846. roledata: {
  847. rolecode: "roleset",
  848. },
  849. selectType: "1",
  850. },
  851. };
  852. angular.forEach(grid.columns, function (item) {
  853. if (item.enableFiltering) {
  854. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  855. if (
  856. angular.isDefined(item.filters[0].term) &&
  857. item.filters[0].term != ""
  858. ) {
  859. if (angular.isUndefined(filtersData["user"])) {
  860. filtersData["user"] = {};
  861. }
  862. filtersData["user"][item.field] = item.filters[0].term;
  863. }
  864. }
  865. });
  866. $scope.memoryfilterData = filtersData;
  867. // $scope.loadData(filtersData);
  868. });
  869. };
  870. $scope.onDblClick = function (data, event) {
  871. // $scope.selected.items = data.entity;
  872. $scope.selectButtonClick(data, event);
  873. };
  874. $scope.title = title;
  875. //树形图
  876. var apple_selected, tree, treedata_avm, treedata_geography;
  877. $scope.my_tree_handler = function (branch) {
  878. //var _ref;
  879. var classify = ($scope.classify =
  880. branch.prefix.toLowerCase() + branch.sign);
  881. api_cmdb
  882. .query({
  883. sign: classify,
  884. })
  885. .then(function (data) {
  886. var myDatalingbei = Restangular.stripRestangular(data);
  887. // console.log(myData.data.node);
  888. if (myDatalingbei.data && myDatalingbei.status == 200) {
  889. var ret = myDatalingbei.data;
  890. redrawSvg(myDatalingbei);
  891. }
  892. });
  893. };
  894. $scope.my_data = [];
  895. function convertListToTree(data, treeMap) {
  896. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  897. var root = null; //Initially set our loop to null
  898. var parentNode = null;
  899. //loop over data
  900. for (var i = 0; i < data.length; i++) {
  901. var datum = data[i];
  902. //each node will have children, so let's give it a "children" poperty
  903. datum.children = [];
  904. //add an entry for this node to the map so that any future children can
  905. //lookup the parent
  906. idToNodeMap[datum.id] = datum;
  907. //Does this node have a parent?
  908. if (
  909. typeof datum.parent === "undefined" ||
  910. datum.parent == null
  911. ) {
  912. //Doesn't look like it, so this node is the root of the tree
  913. root = datum;
  914. treeMap[datum.id] = root;
  915. } else {
  916. //This node has a parent, so let's look it up using the id
  917. parentNode = idToNodeMap[datum.parent.id];
  918. //We don't need this property, so let's delete it.
  919. delete datum.parent;
  920. //Let's add the current node as a child of the parent node.
  921. parentNode.children.push(datum);
  922. }
  923. }
  924. return root;
  925. }
  926. function convertParentToChildList(data) {
  927. var treeMap = {};
  928. var list = [];
  929. convertListToTree(data, treeMap);
  930. angular.forEach(treeMap, function (item) {
  931. list.push(item);
  932. });
  933. return list;
  934. }
  935. $scope.my_tree = tree = {};
  936. $scope.try_async_load = function () {
  937. $scope.my_data = [];
  938. $scope.select_treedata = [];
  939. $scope.doing_async = true;
  940. api_configure_data
  941. .fetchDataList("ciclassify", {
  942. idx: 0,
  943. sum: 100,
  944. })
  945. .then(function (result) {
  946. //console.log(result['list']);
  947. $scope.select_treedata = $scope.my_data =
  948. convertParentToChildList(result["list"]);
  949. $scope.doing_async = false;
  950. // tree.expand_all();
  951. //console.log(treelist);
  952. });
  953. };
  954. $scope.select_treedata = [];
  955. $scope.propTypeOptions = [];
  956. $scope.try_async_load();
  957. $scope.onFilterremove = function (item) {
  958. console.log(item);
  959. };
  960. $scope.searchdata = {};
  961. $scope.clear = function () {
  962. $scope.searchdata = {};
  963. $scope.cifilter_classic = {};
  964. $scope.try_async_load();
  965. var fildata = {
  966. idx: 0,
  967. sum: 10,
  968. hw_state: "在线",
  969. };
  970. $scope.memoryfilterData = fildata;
  971. $scope.refreshData("expand-right", fildata);
  972. };
  973. $scope.chiceIncident = function (item) {
  974. var fildata = $scope.memoryfilterData;
  975. // fildata.applicationForm = {};
  976. // if (item.alltitle && item.alldata) {
  977. // fildata.applicationForm[item.alltitle.key] = item.alldata
  978. // }
  979. if (item && item.id) {
  980. var classify = item.prefix.toLowerCase() + item.sign;
  981. fildata.sign = classify;
  982. }
  983. $scope.gridOptions.paginationCurrentPage = 1;
  984. var transitiondata = angular.copy(item);
  985. $scope.refreshData("expand-right", fildata);
  986. };
  987. $scope.applicadata = [];
  988. $scope.onFilterCallback = function (item) {
  989. var tempclassify = item.prefix.toLowerCase() + item.sign;
  990. api_configure_form
  991. .renderTabForm(tempclassify)
  992. .then(function (data) {
  993. var myData = Restangular.stripRestangular(data);
  994. $scope.applicadata = myData[0].form.fields;
  995. });
  996. // }
  997. };
  998. // $scope.loadData({
  999. // idx: 0,
  1000. // sum: 10,
  1001. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1002. // });
  1003. $scope.selected = {
  1004. items: [],
  1005. };
  1006. $scope.ok = function () {
  1007. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1008. // onDataCallback($scope.selected.item, parentScope);
  1009. // }
  1010. $modalInstance.close($scope.selected.items);
  1011. };
  1012. $scope.cancel = function () {
  1013. $modalInstance.dismiss("cancel");
  1014. };
  1015. },
  1016. size: "lg",
  1017. resolve: {
  1018. items: function () {
  1019. return {
  1020. fetchItems: function (filterData, APIService) {
  1021. filterData = filterData || {};
  1022. if (
  1023. angular.isDefined(filterData.idx) &&
  1024. filterData.idx == null
  1025. ) {
  1026. filterData = {
  1027. idx: 0,
  1028. sum: 10,
  1029. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1030. };
  1031. }
  1032. return $scope.options.templateOptions.fetchItems(
  1033. filterData,
  1034. APIService
  1035. );
  1036. },
  1037. };
  1038. },
  1039. title: function () {
  1040. return $scope.options.templateOptions.label;
  1041. },
  1042. Restangular: function () {
  1043. return $scope.options.templateOptions.Restangular;
  1044. },
  1045. APIService: function () {
  1046. return $scope.options.templateOptions.ApiService;
  1047. },
  1048. onDataCallback: function () {
  1049. return $scope.options.templateOptions.callback;
  1050. },
  1051. parentScope: function () {
  1052. return $scope.options.templateOptions.that;
  1053. },
  1054. },
  1055. });
  1056. modalInstance.result.then(function (selectedItem) {
  1057. $scope.myDatagridoldall = selectedItem;
  1058. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1059. $scope.myDatagridoldall[i]["item"] =
  1060. i +
  1061. 1 +
  1062. $scope.memoryfilterDatagridold.idx *
  1063. $scope.memoryfilterDatagridold.sum;
  1064. }
  1065. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1066. $scope.myDatagridold = $scope.interceptMydata(
  1067. $scope.myDatagridoldall,
  1068. 0,
  1069. 10
  1070. );
  1071. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1072. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1073. $scope.myDatagridoldall;
  1074. $scope.options.initialValue = $scope.model.oldAssets;
  1075. });
  1076. // }
  1077. };
  1078. $scope.changestate = function (itemin) {
  1079. event.preventDefault();
  1080. var modalInstance = $modal.open({
  1081. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1082. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1083. $scope.title = "旧设备状态修改";
  1084. $scope.stateshe = [
  1085. {
  1086. id: 2,
  1087. name: "在库",
  1088. },
  1089. {
  1090. id: 4,
  1091. name: "报修",
  1092. },
  1093. {
  1094. id: 3,
  1095. name: "报废",
  1096. },
  1097. ];
  1098. $scope.hw_state = {};
  1099. $scope.ok = function (item) {
  1100. $modalInstance.close(item.id);
  1101. };
  1102. $scope.cancel = function () {
  1103. $modalInstance.dismiss("cancel");
  1104. };
  1105. },
  1106. size: "sm",
  1107. resolve: {
  1108. scope: function () {
  1109. return $scope;
  1110. },
  1111. },
  1112. });
  1113. modalInstance.result.then(function (selectedItem) {
  1114. if (selectedItem) {
  1115. angular.forEach($scope.myDatagridallold, function (item, index) {
  1116. if (item.id == itemin.id) {
  1117. $scope.myDatagridallold[index].props.hw_state =
  1118. selectedItem.name;
  1119. }
  1120. });
  1121. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1122. $scope.myDatagridallold[i]["item"] =
  1123. i +
  1124. 1 +
  1125. $scope.memoryfilterDatagridold.idx *
  1126. $scope.memoryfilterDatagridold.sum;
  1127. }
  1128. $scope.gridOptions2["totalItems"] =
  1129. $scope.myDatagridallold.length;
  1130. $scope.myDatagridold = $scope.interceptMydata(
  1131. $scope.myDatagridallold,
  1132. $scope.memoryfilterDatagridold.idx,
  1133. $scope.memoryfilterDatagridold.sum
  1134. );
  1135. // $scope.model.oldAssets = $scope.myDatagridallold;
  1136. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1137. $scope.myDatagridallold;
  1138. $scope.options.initialValue = $scope.model.oldAssets;
  1139. }
  1140. });
  1141. };
  1142. $scope.savedata = function (data) {
  1143. event.preventDefault();
  1144. var modalInstance = $modal.open({
  1145. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1146. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1147. $scope.title = "设备编辑";
  1148. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1149. $scope.ok = function (item) {
  1150. $modalInstance.close(item);
  1151. };
  1152. $scope.cancel = function () {
  1153. $modalInstance.dismiss("cancel");
  1154. };
  1155. },
  1156. size: "sm",
  1157. resolve: {
  1158. scope: function () {
  1159. return $scope;
  1160. },
  1161. },
  1162. });
  1163. modalInstance.result.then(function (selectedItem) {
  1164. if (selectedItem) {
  1165. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1166. if (item.id == data.id) {
  1167. $scope.myDatagridoldall[index].olddecription =
  1168. selectedItem.olddecription;
  1169. }
  1170. });
  1171. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1172. $scope.myDatagridoldall[i]["item"] =
  1173. i +
  1174. 1 +
  1175. $scope.memoryfilterDatagridold.idx *
  1176. $scope.memoryfilterDatagridold.sum;
  1177. }
  1178. $scope.gridOptions2["totalItems"] =
  1179. $scope.myDatagridoldall.length;
  1180. $scope.myDatagridold = $scope.interceptMydata(
  1181. $scope.myDatagridoldall,
  1182. 0,
  1183. 10
  1184. );
  1185. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1186. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1187. $scope.myDatagridoldall;
  1188. $scope.options.initialValue = $scope.model.oldAssets;
  1189. }
  1190. });
  1191. };
  1192. $scope.removeold = function (data) {
  1193. event.preventDefault();
  1194. var modalInstance = $modal.open({
  1195. templateUrl: "assets/views/delete.html",
  1196. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1197. $scope.title = "设备删除";
  1198. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1199. $scope.ok = function () {
  1200. $modalInstance.close(data);
  1201. };
  1202. $scope.cancel = function () {
  1203. $modalInstance.dismiss("cancel");
  1204. };
  1205. },
  1206. size: "sm",
  1207. resolve: {
  1208. scope: function () {
  1209. return $scope;
  1210. },
  1211. },
  1212. });
  1213. modalInstance.result.then(function (selectedItem) {
  1214. if (selectedItem) {
  1215. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1216. if (item.id == selectedItem.id) {
  1217. $scope.myDatagridoldall.splice(index, 1);
  1218. }
  1219. });
  1220. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1221. $scope.myDatagridoldall[i]["item"] =
  1222. i +
  1223. 1 +
  1224. $scope.memoryfilterDatagridold.idx *
  1225. $scope.memoryfilterDatagridold.sum;
  1226. }
  1227. $scope.gridOptions2["totalItems"] =
  1228. $scope.myDatagridoldall.length;
  1229. $scope.myDatagridold = $scope.interceptMydata(
  1230. $scope.myDatagridoldall,
  1231. 0,
  1232. 10
  1233. );
  1234. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1235. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1236. $scope.myDatagridoldall;
  1237. $scope.options.initialValue = $scope.model.oldAssets;
  1238. }
  1239. });
  1240. };
  1241. },
  1242. ],
  1243. });
  1244. //ui-grid list
  1245. formlyConfigProvider.setType({
  1246. name: "ui-gridlist",
  1247. extends: "input",
  1248. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1249. defaultOptions: function (options, $scope) {
  1250. return {
  1251. templateOptions: {},
  1252. };
  1253. },
  1254. controller: [
  1255. "$scope",
  1256. "$modal",
  1257. "i18nService",
  1258. "SweetAlert",
  1259. function ($scope, $modal, i18nService, SweetAlert) {
  1260. //gridone
  1261. $scope.langs = i18nService.getAllLangs();
  1262. $scope.lang = "zh-cn";
  1263. i18nService.setCurrentLang($scope.lang);
  1264. $scope.gridOptions = {};
  1265. $scope.gridOptions.data = "myDatagrid";
  1266. $scope.gridOptions.enableColumnResizing = true;
  1267. $scope.gridOptions.enableFiltering = true;
  1268. $scope.gridOptions.enableGridMenu = false;
  1269. $scope.gridOptions.enableRowSelection = true;
  1270. $scope.gridOptions.showGridFooter = true;
  1271. $scope.gridOptions.showColumnFooter = false;
  1272. $scope.gridOptions.fastWatch = true;
  1273. $scope.gridOptions.useExternalFiltering = false;
  1274. // $scope.gridOptions.useExternalPagination = true;
  1275. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1276. $scope.gridOptions.paginationPageSize = 10;
  1277. $scope.gridOptions.multiSelect = false;
  1278. $scope.myDatagrid = [];
  1279. $scope.myDatagridall = [];
  1280. $scope.selected = {
  1281. item: {},
  1282. };
  1283. $scope.memoryfilterDatagrid = {
  1284. idx: 0,
  1285. sum: 10,
  1286. };
  1287. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1288. filterData = {
  1289. idx: 0,
  1290. sum: 10,
  1291. };
  1292. $scope.gridOptions.columnDefs =
  1293. $scope.options.templateOptions.columnDefs;
  1294. }
  1295. $scope.gridOptions.rowIdentity = function (row) {
  1296. return row.id;
  1297. };
  1298. $scope.gridOptions.getRowIdentity = function (row) {
  1299. return row.id;
  1300. };
  1301. // $scope.gridOptions.columnDefs = items.columnDefs();
  1302. $scope.interceptMydata = function (mydate, idx, sum) {
  1303. return mydate.slice(idx * sum, (idx + 1) * sum);
  1304. };
  1305. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1306. $scope.gridApi = gridApi;
  1307. gridApi.pagination.on.paginationChanged(
  1308. $scope,
  1309. function (newPage, pageSize) {
  1310. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1311. $scope.memoryfilterDatagrid.sum = pageSize;
  1312. $scope.myDatagrid = $scope.interceptMydata(
  1313. $scope.myDatagridall,
  1314. $scope.memoryfilterDatagrid.idx,
  1315. 10
  1316. );
  1317. $scope.loadData({
  1318. idx: newPage - 1,
  1319. sum: pageSize,
  1320. });
  1321. }
  1322. );
  1323. gridApi.core.on.filterChanged($scope, function () { });
  1324. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1325. $scope.selected.item = data.entity;
  1326. //console.log(data);
  1327. });
  1328. };
  1329. $scope.loadData = function (mydate, idx, sum) {
  1330. angular.forEach($scope.myDatagrid, function (item, index) {
  1331. $scope.myDatagrid[index].item = index;
  1332. });
  1333. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1334. };
  1335. if ($scope.model.assets) {
  1336. $scope.myDatagridall = $scope.model.assets;
  1337. $scope.loadData($scope.model.assets, 0, 10);
  1338. }
  1339. $scope.saveData = function (itemin) {
  1340. event.preventDefault();
  1341. var modalInstance = $modal.open({
  1342. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1343. controller: function ($scope, $modalInstance, SweetAlert) {
  1344. // $scope.consumptive = {};
  1345. $scope.title = "填写领用设备信息";
  1346. // if (items.name) {
  1347. // $scope.consumptive.name = items.name.name;
  1348. // }
  1349. $scope.placechange = angular.copy(itemin);
  1350. $scope.ok = function (item) {
  1351. if (
  1352. item.props &&
  1353. item.props.hwnw_area &&
  1354. item.props.hwnw_place &&
  1355. item.props.hwnw_room &&
  1356. item.props.hwnwswt_jiguihao &&
  1357. item.props.hwnwswt_Ushu &&
  1358. item.props.snnum
  1359. ) {
  1360. $modalInstance.close(item);
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "数据填写不完整!",
  1364. text: "请检查数据然后提交!",
  1365. type: "error",
  1366. });
  1367. }
  1368. };
  1369. $scope.cancel = function () {
  1370. $modalInstance.dismiss("cancel");
  1371. };
  1372. },
  1373. resolve: {
  1374. SweetAlert: function () {
  1375. return SweetAlert;
  1376. },
  1377. },
  1378. });
  1379. modalInstance.result.then(function (selectedItem) {
  1380. angular.forEach($scope.myDatagrid, function (item, index) {
  1381. if (item.id == selectedItem.id) {
  1382. angular.extend($scope.myDatagrid[index], selectedItem);
  1383. }
  1384. });
  1385. // $scope.myData3.push(selectedItem);
  1386. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1387. $scope.myDatagrid[i]["item"] =
  1388. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1389. }
  1390. // $scope.model.assets = $scope.myDatagridall;
  1391. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1392. $scope.myDatagridall;
  1393. });
  1394. };
  1395. },
  1396. ],
  1397. });
  1398. //设备耗材list组件
  1399. formlyConfigProvider.setType({
  1400. name: "ui-shehaolist",
  1401. // extends: 'radio',
  1402. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1403. defaultOptions: function (options) {
  1404. return {
  1405. templateOptions: {
  1406. refresh: function () { },
  1407. refreshDelay: 0,
  1408. },
  1409. };
  1410. },
  1411. controller: [
  1412. "$scope",
  1413. "$filter",
  1414. "ngTableParams",
  1415. function ($scope, $filter, ngTableParams) {
  1416. // var data = { "haodata": [], "shedata": [] };
  1417. var haodata = [];
  1418. var shedata = [];
  1419. if ($scope.model.consumables) {
  1420. if (angular.isArray($scope.model.consumables)) {
  1421. haodata = $scope.model.consumables;
  1422. } else {
  1423. haodata = JSON.parse($scope.model.consumables);
  1424. }
  1425. $scope.model.consumables = haodata;
  1426. angular.forEach(haodata, function (item, index) {
  1427. haodata[index].item = index + 1;
  1428. });
  1429. }
  1430. if ($scope.model.assets) {
  1431. if (angular.isArray($scope.model.assets)) {
  1432. shedata = $scope.model.assets;
  1433. } else {
  1434. shedata = JSON.parse($scope.model.assets);
  1435. }
  1436. $scope.model.assets = shedata;
  1437. angular.forEach(shedata, function (item, index) {
  1438. shedata[index].item = index + 1;
  1439. });
  1440. }
  1441. $scope.tableParamshao = new ngTableParams(
  1442. {
  1443. page: 1,
  1444. count: 5,
  1445. },
  1446. {
  1447. total: haodata.length,
  1448. getData: function ($defer, params) {
  1449. var orderedData = params.sorting()
  1450. ? $filter("orderBy")(haodata, params.orderBy())
  1451. : haodata;
  1452. $defer.resolve(
  1453. orderedData.slice(
  1454. (params.page() - 1) * params.count(),
  1455. params.page() * params.count()
  1456. )
  1457. );
  1458. },
  1459. }
  1460. );
  1461. $scope.tableParamsshe = new ngTableParams(
  1462. {
  1463. page: 1,
  1464. count: 5,
  1465. },
  1466. {
  1467. total: shedata.length,
  1468. getData: function ($defer, params) {
  1469. var orderedData = params.sorting()
  1470. ? $filter("orderBy")(shedata, params.orderBy())
  1471. : shedata;
  1472. $defer.resolve(
  1473. orderedData.slice(
  1474. (params.page() - 1) * params.count(),
  1475. params.page() * params.count()
  1476. )
  1477. );
  1478. },
  1479. }
  1480. );
  1481. $scope.editId = -1;
  1482. $scope.setEditId = function (pid) {
  1483. $scope.editId = pid;
  1484. };
  1485. if (
  1486. $scope.$parent.$parent.$parent.model.isAgree &&
  1487. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1488. ) {
  1489. $scope.isAgree = "同意";
  1490. } else if (
  1491. $scope.$parent.$parent.$parent.model.isAgree &&
  1492. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1493. ) {
  1494. $scope.isAgree = "同意";
  1495. } else if (
  1496. $scope.$parent.$parent.$parent.model.isAgree &&
  1497. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1498. ) {
  1499. $scope.isAgree = "返回修改";
  1500. }
  1501. },
  1502. ],
  1503. });
  1504. //关联资产出库
  1505. formlyConfigProvider.setType({
  1506. name: "ui-meansmodelselect",
  1507. extends: "input",
  1508. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1509. defaultOptions: function (options) {
  1510. return {
  1511. templateOptions: {},
  1512. };
  1513. },
  1514. controller: [
  1515. "$scope",
  1516. "$modal",
  1517. function ($scope, $modal) {
  1518. $scope.openModal = function (size, options, modal) {
  1519. var modalInstance = $modal.open({
  1520. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1521. controller: function (
  1522. $scope,
  1523. $rootScope,
  1524. $modalInstance,
  1525. items,
  1526. title,
  1527. Restangular,
  1528. APIService,
  1529. api_user_data,
  1530. i18nService,
  1531. api_wechatfile
  1532. ) {
  1533. $scope.langs = i18nService.getAllLangs();
  1534. $scope.lang = "zh-cn";
  1535. i18nService.setCurrentLang($scope.lang);
  1536. $scope.gridOptions = {};
  1537. $scope.gridOptions.data = "myData";
  1538. $scope.gridOptions.enableColumnResizing = true;
  1539. $scope.gridOptions.enableFiltering = false;
  1540. $scope.gridOptions.enableGridMenu = false;
  1541. $scope.gridOptions.showGridFooter = true;
  1542. $scope.gridOptions.showColumnFooter = false;
  1543. $scope.gridOptions.fastWatch = true;
  1544. $scope.gridOptions.useExternalFiltering = true;
  1545. $scope.gridOptions.useExternalPagination = true;
  1546. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1547. $scope.gridOptions.paginationPageSize = 10;
  1548. $scope.gridOptions.multiSelect = false;
  1549. $scope.gridOptions.rowIdentity = function (row) {
  1550. return row.id;
  1551. };
  1552. $scope.gridOptions.getRowIdentity = function (row) {
  1553. return row.id;
  1554. };
  1555. // $scope.states = [{
  1556. // id: 0,
  1557. // name: '待批准'
  1558. // },
  1559. // {
  1560. // id: 1,
  1561. // name: '已驳回'
  1562. // },
  1563. // {
  1564. // id: 2,
  1565. // name: '待出库'
  1566. // },
  1567. // {
  1568. // id: 3,
  1569. // name: '信息更新'
  1570. // },
  1571. // {
  1572. // id: 4,
  1573. // name: '信息确认'
  1574. // },
  1575. // {
  1576. // id: 5,
  1577. // name: '已关闭'
  1578. // }
  1579. // ];
  1580. $scope.getStatesDictionary = function () {
  1581. var data = {
  1582. key: "applicationForm_status",
  1583. type: "list",
  1584. };
  1585. api_wechatfile.getDictionary(data).then(function (res) {
  1586. $scope.states = res;
  1587. });
  1588. };
  1589. $scope.getStatesDictionary();
  1590. $scope.type = [
  1591. {
  1592. id: 1,
  1593. name: "资产入库",
  1594. },
  1595. {
  1596. id: 2,
  1597. name: "资产归还",
  1598. },
  1599. {
  1600. id: 3,
  1601. name: "资产领用",
  1602. },
  1603. {
  1604. id: 4,
  1605. name: "资产更换",
  1606. },
  1607. ];
  1608. $scope.typedata = function (row) {
  1609. if (row.type == 0) {
  1610. return "资产入库";
  1611. } else if (row.type == 2) {
  1612. return "资产归还";
  1613. } else if (row.type == 1) {
  1614. return "资产领用";
  1615. } else if (row.type == 4) {
  1616. return "资产更换";
  1617. }
  1618. };
  1619. $scope.statedata = function (row) {
  1620. if (row.status == 0) {
  1621. return "待批准";
  1622. } else if (row.status == 1) {
  1623. return "已驳回";
  1624. } else if (row.status == 2) {
  1625. return "待出库";
  1626. } else if (row.status == 3) {
  1627. return "信息更新";
  1628. } else if (row.status == 4) {
  1629. return "信息确认";
  1630. } else if (row.status == 5) {
  1631. return "已关闭";
  1632. }
  1633. };
  1634. $scope.transferTime = function (time) {
  1635. return moment(time).format("YYYY-MM-DD HH:mm");
  1636. };
  1637. $scope.application = [
  1638. {
  1639. value: "serialNumbe",
  1640. name: "申请单编号",
  1641. },
  1642. // { value: "proposer", name: '申请人' },
  1643. {
  1644. value: "purpose",
  1645. name: "领用用途",
  1646. },
  1647. // { value: "cmdbsign", name: '设备编号' }
  1648. ];
  1649. $scope.parameters = null;
  1650. $scope.open = function ($event) {
  1651. $event.preventDefault();
  1652. $event.stopPropagation();
  1653. $scope.opened = !$scope.opened;
  1654. };
  1655. $scope.endOpen = function ($event) {
  1656. $event.preventDefault();
  1657. $event.stopPropagation();
  1658. $scope.startOpened = false;
  1659. $scope.endOpened = !$scope.endOpened;
  1660. };
  1661. $scope.startOpen = function ($event) {
  1662. $event.preventDefault();
  1663. $event.stopPropagation();
  1664. $scope.endOpened = false;
  1665. $scope.startOpened = !$scope.startOpened;
  1666. };
  1667. $scope.othcode = {};
  1668. $scope.searchkeys = {};
  1669. $scope.parameters = {};
  1670. $scope.memoryfilterData = {
  1671. assignee: $rootScope.user.id,
  1672. candidateGroups: $rootScope.user.group[0].id,
  1673. searchType: "todo",
  1674. idx: 0,
  1675. sum: 10,
  1676. };
  1677. $scope.clear = function () {
  1678. $scope.searchkeys = {};
  1679. // $scope.othcode = {};
  1680. $scope.parameters = {};
  1681. var fildata = {
  1682. assignee: $rootScope.user.id,
  1683. candidateGroups: $rootScope.user.group[0].id,
  1684. searchType: "todo",
  1685. idx: 0,
  1686. sum: 10,
  1687. };
  1688. $scope.memoryfilterData = fildata;
  1689. $scope.loadData(fildata);
  1690. };
  1691. $scope.chiceIncident = function (parameters, item, stateid) {
  1692. var fildata = {
  1693. assignee: $rootScope.user.id,
  1694. candidateGroups: 1,
  1695. searchType: "todo",
  1696. idx: 0,
  1697. sum: 10,
  1698. };
  1699. if (item) {
  1700. fildata.applicationForm = {};
  1701. if (item.alltitle && item.alldata) {
  1702. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1703. }
  1704. if (item.linkProposer) {
  1705. fildata.applicationForm.linkProposer = item.linkProposer;
  1706. }
  1707. if (item.proposer) {
  1708. fildata.applicationForm.proposer = item.proposer;
  1709. }
  1710. if (item.status) {
  1711. fildata.applicationForm["status"] = {
  1712. id: item.status.id,
  1713. };
  1714. }
  1715. if (item.type) {
  1716. fildata.applicationForm["type"] = {
  1717. id: item.type.id,
  1718. };
  1719. }
  1720. }
  1721. $scope.gridOptions.paginationCurrentPage = 1;
  1722. if (
  1723. parameters &&
  1724. parameters.paramDateFrom &&
  1725. parameters.paramDateTo
  1726. ) {
  1727. angular.extend(fildata, {
  1728. idx: 0,
  1729. sum: $scope.gridOptions.paginationPageSize,
  1730. });
  1731. angular.extend(fildata.applicationForm, {
  1732. startDate: moment(parameters.paramDateFrom).format(
  1733. "YYYY-MM-DD HH:mm:ss"
  1734. ),
  1735. endDate: moment(parameters.paramDateTo).format(
  1736. "YYYY-MM-DD 23:59:59"
  1737. ),
  1738. });
  1739. }
  1740. var transitiondata = angular.copy(item);
  1741. // angular.extend(fildata.applicationForm, transitiondata)
  1742. $scope.loadData(fildata);
  1743. };
  1744. $scope.key = {};
  1745. api_user_data
  1746. .fetchDataList("user", {
  1747. idx: 0,
  1748. sum: 1000,
  1749. flag: -1,
  1750. user: {
  1751. engineer: 1,
  1752. }
  1753. })
  1754. .then(function (data) {
  1755. $scope.handlingPersonnelUser = data.list;
  1756. });
  1757. $scope.gridOptions.columnDefs = items.columnDefs();
  1758. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1759. $scope.gridApi = gridApi;
  1760. gridApi.pagination.on.paginationChanged(
  1761. $scope,
  1762. function (newPage, pageSize) {
  1763. // console.log(newPage);
  1764. // console.log(pageSize);
  1765. $scope.loadData({
  1766. idx: newPage - 1,
  1767. sum: pageSize,
  1768. });
  1769. }
  1770. );
  1771. gridApi.core.on.filterChanged($scope, function () { });
  1772. gridApi.selection.on.rowSelectionChanged(
  1773. $scope,
  1774. function (data) {
  1775. $scope.selected.item = data.entity;
  1776. //console.log(data);
  1777. }
  1778. );
  1779. };
  1780. $scope.loadData = function (filterData) {
  1781. items.fetchItems(filterData, APIService).then(function (data) {
  1782. var myData = Restangular.stripRestangular(data);
  1783. $scope.gridOptions.totalItems = myData.totalNum;
  1784. $scope.myData = myData.list;
  1785. for (var i = 0; i < $scope.myData.length; i++) {
  1786. $scope.myData[i]["item"] =
  1787. i + 1 + filterData.idx * filterData.sum;
  1788. }
  1789. });
  1790. };
  1791. $scope.title = title;
  1792. $scope.loadData({
  1793. idx: 0,
  1794. sum: 10,
  1795. assignee: $rootScope.user.id,
  1796. candidateGroups: $rootScope.user.group[0].id,
  1797. searchType: "todo",
  1798. });
  1799. $scope.selected = {
  1800. item: {},
  1801. };
  1802. $scope.ok = function () {
  1803. //console.log($scope.selected.item);
  1804. $modalInstance.close($scope.selected.item);
  1805. };
  1806. $scope.cancel = function () {
  1807. $modalInstance.dismiss("cancel");
  1808. };
  1809. },
  1810. size: "lg",
  1811. resolve: {
  1812. items: function () {
  1813. return {
  1814. fetchItems: function (filterData, APIService) {
  1815. filterData = filterData || {};
  1816. // if(!filterData.idx){
  1817. if (
  1818. angular.isDefined(filterData.idx) &&
  1819. filterData.idx == null
  1820. ) {
  1821. filterData = {
  1822. idx: 0,
  1823. sum: 10,
  1824. };
  1825. }
  1826. return options.templateOptions.fetchItems(
  1827. filterData,
  1828. APIService,
  1829. options
  1830. );
  1831. },
  1832. columnDefs: function () {
  1833. return options.templateOptions.columnDefs;
  1834. },
  1835. };
  1836. },
  1837. title: function () {
  1838. return options.templateOptions.modalTitle;
  1839. },
  1840. Restangular: function () {
  1841. return options.templateOptions.Restangular;
  1842. },
  1843. APIService: function () {
  1844. return options.templateOptions.ApiService;
  1845. },
  1846. },
  1847. });
  1848. modalInstance.result.then(
  1849. function (selectedItem) {
  1850. var selectitem = {
  1851. title: selectedItem.title,
  1852. description: selectedItem.description,
  1853. };
  1854. if (options.key == "chuku") {
  1855. if (selectedItem.assets) {
  1856. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1857. selectedItem.assets;
  1858. }
  1859. if (selectedItem.consumables) {
  1860. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1861. selectedItem.consumables;
  1862. }
  1863. angular.extend(
  1864. $scope.$parent.$parent.$parent.model,
  1865. selectitem
  1866. );
  1867. options.value(selectedItem);
  1868. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1869. } else {
  1870. angular.extend(options.model, selectitem);
  1871. options.value(selectedItem);
  1872. }
  1873. },
  1874. function () {
  1875. //console.log('Modal dismissed at: ' + new Date());
  1876. }
  1877. );
  1878. };
  1879. },
  1880. ],
  1881. });
  1882. //文本框
  1883. formlyConfigProvider.setType({
  1884. name: "ui-textcmdb",
  1885. extends: "",
  1886. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1887. defaultOptions: function (options) {
  1888. return {
  1889. templateOptions: {
  1890. transform: function (model, value) {
  1891. return value;
  1892. },
  1893. },
  1894. validation: {
  1895. messages: {
  1896. maxlength: function (viewValue, modelValue, scope) {
  1897. if (viewValue != null) {
  1898. if (viewValue.length > scope.to.maxlength) {
  1899. return (
  1900. scope.to.label +
  1901. " 字数(" +
  1902. viewValue.length +
  1903. ")超限(" +
  1904. scope.to.maxlength +
  1905. ")"
  1906. );
  1907. } else {
  1908. return "";
  1909. }
  1910. }
  1911. },
  1912. },
  1913. },
  1914. };
  1915. },
  1916. controller: [
  1917. "$scope",
  1918. function ($scope) {
  1919. var value = $scope.model[$scope.options.key];
  1920. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1921. $scope.model[$scope.options.key] =
  1922. $scope.options.templateOptions.transform(
  1923. $scope.originalModel,
  1924. value
  1925. );
  1926. }
  1927. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1928. $scope.options.templateOptions.felditem($scope);
  1929. }
  1930. },
  1931. ],
  1932. });
  1933. //设备组件
  1934. formlyConfigProvider.setType({
  1935. name: "ui-applist",
  1936. extends: "radio",
  1937. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1938. defaultOptions: function (options) {
  1939. return {
  1940. templateOptions: {
  1941. refresh: function () { },
  1942. refreshDelay: 0,
  1943. },
  1944. };
  1945. },
  1946. controller: [
  1947. "$scope",
  1948. "$filter",
  1949. "ngTableParams",
  1950. function ($scope, $filter, ngTableParams) {
  1951. var data = [];
  1952. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1953. // data = JSON.parse($scope.model.consumables);
  1954. if (angular.isArray($scope.model.consumables)) {
  1955. data = $scope.model.consumables;
  1956. } else {
  1957. data = JSON.parse($scope.model.consumables);
  1958. }
  1959. $scope.model.consumables = data;
  1960. angular.forEach(data, function (item, index) {
  1961. data[index].item = index + 1;
  1962. });
  1963. }
  1964. if ($scope.model.assets && $scope.options.key == "assets") {
  1965. if (angular.isArray($scope.model.assets)) {
  1966. data = $scope.model.assets;
  1967. } else {
  1968. data = JSON.parse($scope.model.assets);
  1969. }
  1970. // data = JSON.parse($scope.model.assets);
  1971. $scope.model.assets = data;
  1972. angular.forEach(data, function (item, index) {
  1973. data[index].item = index + 1;
  1974. });
  1975. }
  1976. $scope.tableParams = new ngTableParams(
  1977. {
  1978. page: 1,
  1979. count: 5,
  1980. },
  1981. {
  1982. total: data.length,
  1983. getData: function ($defer, params) {
  1984. var orderedData = params.sorting()
  1985. ? $filter("orderBy")(data, params.orderBy())
  1986. : data;
  1987. $defer.resolve(
  1988. orderedData.slice(
  1989. (params.page() - 1) * params.count(),
  1990. params.page() * params.count()
  1991. )
  1992. );
  1993. },
  1994. }
  1995. );
  1996. $scope.editId = -1;
  1997. $scope.setEditId = function (pid) {
  1998. $scope.editId = pid;
  1999. };
  2000. },
  2001. ],
  2002. });
  2003. //list组件
  2004. formlyConfigProvider.setType({
  2005. name: "ui-gudinglist",
  2006. extends: "radio",
  2007. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2008. defaultOptions: function (options) {
  2009. return {
  2010. templateOptions: {
  2011. refresh: function () { },
  2012. refreshDelay: 0,
  2013. },
  2014. };
  2015. },
  2016. controller: [
  2017. "$scope",
  2018. "$filter",
  2019. "ngTableParams",
  2020. function ($scope, $filter, ngTableParams) {
  2021. var data = [];
  2022. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2023. // data = JSON.parse($scope.model.consumables);
  2024. if (angular.isArray($scope.model.consumables)) {
  2025. data = $scope.model.consumables;
  2026. } else {
  2027. data = JSON.parse($scope.model.consumables);
  2028. }
  2029. $scope.model.consumables = data;
  2030. angular.forEach(data, function (item, index) {
  2031. data[index].item = index + 1;
  2032. });
  2033. }
  2034. if ($scope.model.assets && $scope.options.key == "assets") {
  2035. if (angular.isArray($scope.model.assets)) {
  2036. data = $scope.model.assets;
  2037. } else {
  2038. data = JSON.parse($scope.model.assets);
  2039. }
  2040. // data = JSON.parse($scope.model.assets);
  2041. $scope.model.assets = data;
  2042. angular.forEach(data, function (item, index) {
  2043. data[index].item = index + 1;
  2044. });
  2045. }
  2046. $scope.tableParams = new ngTableParams(
  2047. {
  2048. page: 1,
  2049. count: 5,
  2050. },
  2051. {
  2052. total: data.length,
  2053. getData: function ($defer, params) {
  2054. var orderedData = params.sorting()
  2055. ? $filter("orderBy")(data, params.orderBy())
  2056. : data;
  2057. $defer.resolve(
  2058. orderedData.slice(
  2059. (params.page() - 1) * params.count(),
  2060. params.page() * params.count()
  2061. )
  2062. );
  2063. },
  2064. }
  2065. );
  2066. $scope.editId = -1;
  2067. $scope.setEditId = function (pid) {
  2068. $scope.editId = pid;
  2069. };
  2070. },
  2071. ],
  2072. });
  2073. //other list tab组件
  2074. formlyConfigProvider.setType({
  2075. name: "ui-otherlisttab",
  2076. extends: "",
  2077. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2078. defaultOptions: function (options) {
  2079. return {
  2080. templateOptions: {
  2081. refresh: function () { },
  2082. refreshDelay: 0,
  2083. },
  2084. };
  2085. },
  2086. controller: [
  2087. "$scope",
  2088. "$filter",
  2089. "ngTableParams",
  2090. function ($scope, $filter, ngTableParams) { },
  2091. ],
  2092. });
  2093. //审核查看组件
  2094. formlyConfigProvider.setType({
  2095. name: "ui-aprovelist",
  2096. extends: "",
  2097. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2098. defaultOptions: function (options) {
  2099. return {
  2100. templateOptions: {
  2101. refresh: function () { },
  2102. refreshDelay: 0,
  2103. },
  2104. };
  2105. },
  2106. controller: [
  2107. "$scope",
  2108. "$filter",
  2109. "ngTableParams",
  2110. function ($scope, $filter, ngTableParams) {
  2111. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2112. $scope.isAgree = "同意";
  2113. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2114. $scope.isAgree = "同意";
  2115. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2116. $scope.isAgree = "返回修改";
  2117. }
  2118. },
  2119. ],
  2120. });
  2121. //other list组件
  2122. formlyConfigProvider.setType({
  2123. name: "ui-otherlist",
  2124. extends: "",
  2125. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2126. defaultOptions: function (options) {
  2127. return {
  2128. templateOptions: {
  2129. refresh: function () { },
  2130. refreshDelay: 0,
  2131. },
  2132. };
  2133. },
  2134. controller: [
  2135. "$rootScope",
  2136. "$scope",
  2137. "$parse",
  2138. "$injector",
  2139. "$http",
  2140. "$q",
  2141. "$state",
  2142. "$stateParams",
  2143. "$modal",
  2144. "$timeout",
  2145. "$interval",
  2146. "i18nService",
  2147. "SweetAlert",
  2148. "FileUploader",
  2149. "Restangular",
  2150. "UserRestangular",
  2151. "BpmRestangular",
  2152. "api_configure_form",
  2153. "api_configure_data",
  2154. "api_bpm_domain",
  2155. "api_bpm_data",
  2156. "api_user_data",
  2157. "api_cmdb",
  2158. "api_sysinfo",
  2159. function (
  2160. $rootScope,
  2161. $scope,
  2162. $parse,
  2163. $injector,
  2164. $http,
  2165. $q,
  2166. $state,
  2167. $stateParams,
  2168. $modal,
  2169. $timeout,
  2170. $interval,
  2171. i18nService,
  2172. SweetAlert,
  2173. FileUploader,
  2174. Restangular,
  2175. UserRestangular,
  2176. BpmRestangular,
  2177. api_configure_form,
  2178. api_configure_data,
  2179. api_bpm_domain,
  2180. api_bpm_data,
  2181. api_user_data,
  2182. api_cmdb,
  2183. api_sysinfo
  2184. ) {
  2185. console.log("哈哈");
  2186. console.log($scope);
  2187. $scope.langs = i18nService.getAllLangs();
  2188. $scope.lang = "zh-cn";
  2189. i18nService.setCurrentLang($scope.lang);
  2190. var vm = this;
  2191. vm.options = {};
  2192. vm.exampleTitle = ["expressionProperties", "model property"];
  2193. vm.fields = [];
  2194. vm.models = {};
  2195. // vm.models["loginUser"] = $rootScope.user;
  2196. var that = $injector;
  2197. var parse = $parse;
  2198. var formKey = "";
  2199. var pdKey = "";
  2200. if (
  2201. angular.isDefined($state.current.pdKey) &&
  2202. $state.current.pdKey != ""
  2203. ) {
  2204. pdKey = $state.current.pdKey;
  2205. //console.log("pdKey::"+$state.current.pdKey);
  2206. }
  2207. if (
  2208. angular.isDefined($stateParams.formKey) &&
  2209. $stateParams.formKey != ""
  2210. ) {
  2211. formKey = $stateParams.formKey;
  2212. //console.log("formKey::"+$stateParams.formKey);
  2213. }
  2214. //用户测试数据,后续从header的auth中获取
  2215. var userId = 2;
  2216. userId = $rootScope.user.id;
  2217. //==============处理表单设计数据 开始====================
  2218. //处理组件加载后台数据选项的方法
  2219. function refreshSelectOptions(searchVal, field) {
  2220. if (field.templateOptions.optionsUrl) {
  2221. var process = BpmRestangular.all("");
  2222. if (field.templateOptions.ApiService) {
  2223. process = UserRestangular.all("");
  2224. }
  2225. process
  2226. .customPOST(
  2227. {
  2228. idx: 0,
  2229. sum: 1000,
  2230. },
  2231. field.templateOptions.optionsUrl
  2232. )
  2233. .then(function (result) {
  2234. if (!field.templateOptions.options) {
  2235. field.templateOptions.options = [];
  2236. }
  2237. if (field.templateOptions.optionsDataKey) {
  2238. field.templateOptions.options =
  2239. result[field.templateOptions.optionsDataKey];
  2240. } else {
  2241. field.templateOptions.options = result;
  2242. }
  2243. });
  2244. }
  2245. }
  2246. function decodeVMTabForm(model, tabs) {
  2247. var result = {
  2248. model: {},
  2249. tabs: [],
  2250. };
  2251. var mdata = angular.fromJson(model);
  2252. angular.extend(result.model, mdata);
  2253. angular.forEach(tabs, function (tab) {
  2254. tab.form.model = vm.models;
  2255. angular.forEach(tab.form.fields, function (field) {
  2256. if (field.key == "") {
  2257. delete field.key;
  2258. }
  2259. field.type = "ui-otherlisttab";
  2260. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2261. var extObj = angular.fromJson(field.extjson);
  2262. angular.extend(field.templateOptions, extObj.templateOptions);
  2263. delete extObj.templateOptions;
  2264. for (var prop in extObj) {
  2265. if (new RegExp("Expression").test(prop)) {
  2266. //var obj = $scope.$eval(extObj[prop]);
  2267. //extObj[prop] = $scope.$eval(extObj[prop]);
  2268. if (extObj[prop] != null) {
  2269. if (new RegExp("function").test(extObj[prop])) {
  2270. var propValue = eval(extObj[prop]);
  2271. extObj[prop] = propValue;
  2272. } else {
  2273. //console.log(extObj[prop]);
  2274. var obj = $scope.$eval(extObj[prop]);
  2275. extObj[prop] = obj;
  2276. //console.log(obj);
  2277. }
  2278. }
  2279. } else if (new RegExp("expressionProperties").test(prop)) {
  2280. for (var p in extObj[prop]) {
  2281. if (new RegExp("function").test(extObj[prop][p])) {
  2282. var propValue = eval(extObj[prop][p]);
  2283. extObj[prop][p] = propValue;
  2284. } else {
  2285. //if(p.indexOf("'")>=0){
  2286. // var obj = $scope.$eval(extObj[prop][p]);
  2287. // extObj[prop][$scope.$eval(p)]=obj;
  2288. //}
  2289. }
  2290. }
  2291. } else if ("watcher" == prop) {
  2292. if (angular.isArray(extObj[prop])) {
  2293. angular.forEach(extObj[prop], function (item, index) {
  2294. for (var p in item) {
  2295. if (new RegExp("function").test(item[p])) {
  2296. var propValue = eval(item[p]);
  2297. extObj[prop][index][p] = propValue;
  2298. }
  2299. }
  2300. });
  2301. } else if (angular.isObject(extObj[prop])) {
  2302. for (var p in extObj[prop]) {
  2303. if (new RegExp("function").test(extObj[prop][p])) {
  2304. var propValue = eval(extObj[prop][p]);
  2305. extObj[prop][p] = propValue;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. }
  2311. angular.extend(field, extObj);
  2312. delete field.extjson;
  2313. }
  2314. if (field.extjson == "") {
  2315. delete field.extjson;
  2316. }
  2317. if (angular.isDefined(field.templateOptions)) {
  2318. var templateOs = field.templateOptions;
  2319. for (var property in templateOs) {
  2320. //console.log(property);
  2321. if (
  2322. angular.isString(templateOs[property]) &&
  2323. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2324. ) {
  2325. if (new RegExp("function").test(templateOs[property])) {
  2326. var propValue = eval(templateOs[property]);
  2327. field.templateOptions[property] = propValue;
  2328. } else {
  2329. if (that.has(templateOs[property])) {
  2330. field.templateOptions[property] = that.get(
  2331. templateOs[property]
  2332. );
  2333. } else {
  2334. field.templateOptions[property] = templateOs[property];
  2335. }
  2336. }
  2337. } else if (templateOs[property] == null) {
  2338. //delete field.templateOptions[property];
  2339. } else {
  2340. }
  2341. }
  2342. }
  2343. if (
  2344. angular.isDefined(field.templateOptions) &&
  2345. angular.isDefined(field.templateOptions.extjson)
  2346. ) {
  2347. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2348. angular.extend(field.templateOptions, extObj);
  2349. delete field.templateOptions.extjson;
  2350. }
  2351. //...
  2352. if (field.templateOptions) {
  2353. //处理远程获取数据控件方法调用
  2354. if (field.templateOptions.optionsUrl) {
  2355. field.templateOptions.refresh = refreshSelectOptions;
  2356. }
  2357. //处理嵌套属性数据绑定/
  2358. if (field.templateOptions.pkey) {
  2359. var pmodel,
  2360. i = 0;
  2361. angular.forEach(
  2362. field.templateOptions.pkey.split("."),
  2363. function (p) {
  2364. if (i == 0) {
  2365. if (result.model[p] == null) {
  2366. result.model[p] = {};
  2367. }
  2368. pmodel = result.model[p];
  2369. i++;
  2370. } else {
  2371. if (pmodel[p] == null) {
  2372. pmodel[p] = {};
  2373. }
  2374. pmodel = pmodel[p];
  2375. }
  2376. }
  2377. );
  2378. if (pmodel != null) {
  2379. field.model = pmodel;
  2380. if (pmodel[field.key] == null) {
  2381. pmodel[field.key] = null;
  2382. }
  2383. }
  2384. } else {
  2385. if (result.model[field.key] == null) {
  2386. result.model[field.key] = null;
  2387. }
  2388. }
  2389. //处理弹出框组件初始化
  2390. if (field.type == "ui-input-selectmodal") {
  2391. field.templateOptions.modal = $modal;
  2392. //field.templateOptions.Restangular = Restangular;
  2393. } else if (field.type == "ui-userselect") {
  2394. field.templateOptions.modal = $modal;
  2395. //field.templateOptions.Restangular = Restangular;
  2396. } else if (field.type == "ui-multiuserselect") {
  2397. field.templateOptions.modal = $modal;
  2398. } else if (field.type == "ui-modelselect") {
  2399. field.templateOptions.modal = $modal;
  2400. //field.templateOptions.Restangular = Restangular;
  2401. } else if (field.type == "ui-cmdbuplode") {
  2402. $scope.fileUploader = field.templateOptions.fileUploader =
  2403. new FileUploader({
  2404. url: "/uploader",
  2405. queueLimit: 1, //文件个数
  2406. autoUpload: true,
  2407. });
  2408. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2409. } else if (field.type == "ui-dropfile") {
  2410. field.templateOptions.fileUploader = new FileUploader({
  2411. url: "/uploader",
  2412. });
  2413. field.templateOptions.taskId = $stateParams.taskId;
  2414. field.templateOptions.processInstanceId =
  2415. $stateParams.processInstanceId;
  2416. field.templateOptions.userId = $rootScope.user.id;
  2417. //field.ApiService=api_bpm_domain;
  2418. } else if (field.type == "ui-dropfiletable") {
  2419. if (field.templateOptions.processInstanceId) {
  2420. } else {
  2421. field.templateOptions.processInstanceId =
  2422. $stateParams.processInstanceId;
  2423. }
  2424. } else if (field.type == "ui-repeatSection") {
  2425. var repeatForm = {
  2426. model: {},
  2427. fields: field.templateOptions.fields,
  2428. };
  2429. repeatForm.model[field.key] = [];
  2430. decodeVMTabForm(repeatForm);
  2431. }
  2432. }
  2433. // console.log(field);
  2434. //field
  2435. //result.fields.push(field);
  2436. });
  2437. });
  2438. vm.originalTabs = angular.copy(vm.form);
  2439. }
  2440. //======================处理表单设计数据 结束========================
  2441. $scope.ldloading = {};
  2442. function filter(obj) {
  2443. angular.forEach(obj, function (key, value) {
  2444. if (value === "" || value === null) {
  2445. delete obj[key];
  2446. } else if (
  2447. Object.prototype.toString.call(value) === "[object Object]"
  2448. ) {
  2449. filter(value);
  2450. } else if (angular.isArray(value)) {
  2451. angular.forEach(value, function (item) {
  2452. filter(item);
  2453. });
  2454. }
  2455. });
  2456. }
  2457. function invokeOnAllFormOptions(fn) {
  2458. angular.forEach(vm.tabs, function (tab) {
  2459. if (tab.form.options && tab.form.options[fn]) {
  2460. tab.form.options[fn]();
  2461. }
  2462. });
  2463. }
  2464. function encodeCIData(data, ciId) {
  2465. /*
  2466. create/update state:未审核
  2467. create createtime:系统时间
  2468. create/update lastupdatetime : 系统时间
  2469. label:ci分类
  2470. */
  2471. if (ciId) {
  2472. var baseprop = [
  2473. "uuid",
  2474. "name",
  2475. "type",
  2476. "label",
  2477. "status",
  2478. "createtime",
  2479. "lastupdatetime",
  2480. "props",
  2481. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2482. var extraprop = "props";
  2483. data[extraprop] = {};
  2484. for (var key in data) {
  2485. console.log(data[key]);
  2486. if (_.indexOf(baseprop, key) >= 0) {
  2487. continue;
  2488. } else {
  2489. data[extraprop][key] = data[key];
  2490. delete data[key];
  2491. }
  2492. }
  2493. if ($rootScope.user) {
  2494. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2495. data[extraprop]["configperson"] = $rootScope.user.name;
  2496. var isCMAdminFlag = false;
  2497. angular.forEach($rootScope.user.role, function (roleItem) {
  2498. if (roleItem.rolecode == "cmdb charge") {
  2499. isCMAdminFlag = true;
  2500. }
  2501. });
  2502. if (!isCMAdminFlag) {
  2503. data[extraprop]["state"] = "1";
  2504. }
  2505. }
  2506. if (data.props.id) {
  2507. } else {
  2508. data.label = ciId;
  2509. }
  2510. return data;
  2511. }
  2512. return undefined;
  2513. }
  2514. function decodeCIModel(data) {
  2515. var extraprop = "props";
  2516. if (data[extraprop]) {
  2517. for (var key in data[extraprop]) {
  2518. data[key] = data[extraprop][key];
  2519. }
  2520. delete data[extraprop];
  2521. }
  2522. data["iscmadmin"] = false;
  2523. angular.forEach($rootScope.user.role, function (roleItem) {
  2524. if (roleItem.rolecode == "cmdb charge") {
  2525. data["iscmadmin"] = true;
  2526. }
  2527. });
  2528. return data;
  2529. }
  2530. function formValid() {
  2531. angular.forEach(vm.tabs, function (item) {
  2532. //item.
  2533. });
  2534. }
  2535. $scope.vm = vm;
  2536. $scope.refreshcmdbform = function (item) {
  2537. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2538. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2539. var myData = Restangular.stripRestangular(data);
  2540. $scope.propTypeOptions = myData;
  2541. $scope.templateProps = myData;
  2542. $scope.vm.tabs = myData;
  2543. if ($scope.model.assets) {
  2544. vm.models = JSON.parse($scope.model.assets);
  2545. }
  2546. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2547. if (vm.models.vtvmvtm_kaiji) {
  2548. vm.models.vtvmvtm_kaiji = "是";
  2549. } else {
  2550. vm.models.vtvmvtm_kaiji = "否";
  2551. }
  2552. }
  2553. decodeVMTabForm(vm.models, vm.tabs);
  2554. });
  2555. // }
  2556. };
  2557. var cifilterClassic = {};
  2558. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2559. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2560. $scope.refreshcmdbform(
  2561. $scope.$parent.$parent.$parent.model.cifilterClassic
  2562. );
  2563. // } else {}
  2564. },
  2565. ],
  2566. });
  2567. //固定资产下载
  2568. formlyConfigProvider.setType({
  2569. name: "ui-dropupload",
  2570. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2571. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2572. defaultOptions: function (options) {
  2573. return {
  2574. templateOptions: {
  2575. view: function (APIService, contentId) {
  2576. return APIService.downloadAttachment(contentId);
  2577. },
  2578. },
  2579. };
  2580. },
  2581. controller: [
  2582. "$scope",
  2583. "$rootScope",
  2584. "Restangular",
  2585. function ($scope, $rootScope, Restangular) {
  2586. if (angular.isUndefined($scope.form.dropState)) {
  2587. $scope.form.dropState = false;
  2588. }
  2589. var to = $scope.options.templateOptions;
  2590. var bindId = $scope.model[to.bindType].processInstanceId;
  2591. //获取附件列表
  2592. $scope.listAttachmen = function () {
  2593. to.ApiService.listAttachment(
  2594. to.listAttachmentUrl,
  2595. to.bindType,
  2596. bindId
  2597. ).then(function (result) {
  2598. var myData = Restangular.stripRestangular(result);
  2599. // $scope.listAttachmens = myData;
  2600. $scope.attachments = myData.data;
  2601. });
  2602. };
  2603. $scope.listAttachmen();
  2604. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2605. // $scope.listAttachmen();
  2606. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2607. // $scope.listAttachmen();
  2608. // }
  2609. //附件下载
  2610. $scope.download = function (token, filename) {
  2611. var downUrl = to.ApiService.downloadAttachment(
  2612. to.downUrl,
  2613. token
  2614. ).getRequestedUrl();
  2615. var a = document.createElement("a");
  2616. a.href = downUrl;
  2617. a.target = "_blank";
  2618. a.download = filename;
  2619. document.body.appendChild(a);
  2620. a.click();
  2621. };
  2622. //附件预览
  2623. $scope.view = function (id, previewUrl) {
  2624. if (previewUrl) {
  2625. window.open(previewUrl);
  2626. }
  2627. };
  2628. },
  2629. ],
  2630. });
  2631. formlyConfigProvider.setType({
  2632. name: "ui-form",
  2633. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2634. defaultOptions: function (options) {
  2635. return {
  2636. templateOptions: {
  2637. // link: function() {}
  2638. },
  2639. };
  2640. },
  2641. controller: [
  2642. "$rootScope",
  2643. "$scope",
  2644. "$parse",
  2645. "$injector",
  2646. "$http",
  2647. "$q",
  2648. "$state",
  2649. "$stateParams",
  2650. "$modal",
  2651. "$timeout",
  2652. "$interval",
  2653. "i18nService",
  2654. "SweetAlert",
  2655. "FileUploader",
  2656. "Restangular",
  2657. "UserRestangular",
  2658. "BpmRestangular",
  2659. "api_configure_form",
  2660. "api_configure_data",
  2661. "api_bpm_domain",
  2662. "api_bpm_data",
  2663. "api_user_data",
  2664. "api_cmdb",
  2665. "api_sysinfo",
  2666. function (
  2667. $rootScope,
  2668. $scope,
  2669. $parse,
  2670. $injector,
  2671. $http,
  2672. $q,
  2673. $state,
  2674. $stateParams,
  2675. $modal,
  2676. $timeout,
  2677. $interval,
  2678. i18nService,
  2679. SweetAlert,
  2680. FileUploader,
  2681. Restangular,
  2682. UserRestangular,
  2683. BpmRestangular,
  2684. api_configure_form,
  2685. api_configure_data,
  2686. api_bpm_domain,
  2687. api_bpm_data,
  2688. api_user_data,
  2689. api_cmdb,
  2690. api_sysinfo
  2691. ) {
  2692. $scope.langs = i18nService.getAllLangs();
  2693. $scope.lang = "zh-cn";
  2694. i18nService.setCurrentLang($scope.lang);
  2695. var vm = this;
  2696. vm.options = {};
  2697. vm.exampleTitle = ["expressionProperties", "model property"];
  2698. vm.fields = [];
  2699. vm.models = {};
  2700. // vm.models["loginUser"] = $rootScope.user;
  2701. var that = $injector;
  2702. var parse = $parse;
  2703. var formKey = "";
  2704. var pdKey = "";
  2705. if (
  2706. angular.isDefined($state.current.pdKey) &&
  2707. $state.current.pdKey != ""
  2708. ) {
  2709. pdKey = $state.current.pdKey;
  2710. //console.log("pdKey::"+$state.current.pdKey);
  2711. }
  2712. if (
  2713. angular.isDefined($stateParams.formKey) &&
  2714. $stateParams.formKey != ""
  2715. ) {
  2716. formKey = $stateParams.formKey;
  2717. //console.log("formKey::"+$stateParams.formKey);
  2718. }
  2719. //用户测试数据,后续从header的auth中获取
  2720. var userId = 2;
  2721. userId = $rootScope.user.id;
  2722. //==============处理表单设计数据 开始====================
  2723. //处理组件加载后台数据选项的方法
  2724. function refreshSelectOptions(searchVal, field) {
  2725. if (field.templateOptions.optionsUrl) {
  2726. var process = BpmRestangular.all("");
  2727. if (field.templateOptions.ApiService) {
  2728. process = UserRestangular.all("");
  2729. }
  2730. process
  2731. .customPOST(
  2732. {
  2733. idx: 0,
  2734. sum: 1000,
  2735. },
  2736. field.templateOptions.optionsUrl
  2737. )
  2738. .then(function (result) {
  2739. if (!field.templateOptions.options) {
  2740. field.templateOptions.options = [];
  2741. }
  2742. if (field.templateOptions.optionsDataKey) {
  2743. field.templateOptions.options =
  2744. result[field.templateOptions.optionsDataKey];
  2745. } else {
  2746. field.templateOptions.options = result;
  2747. }
  2748. });
  2749. }
  2750. }
  2751. function decodeVMTabForm(model, tabs) {
  2752. var result = {
  2753. model: {},
  2754. tabs: [],
  2755. };
  2756. var mdata = angular.fromJson(model);
  2757. angular.extend(result.model, mdata);
  2758. angular.forEach(tabs, function (tab) {
  2759. tab.form.model = vm.models;
  2760. angular.forEach(tab.form.fields, function (field) {
  2761. if (field.key == "") {
  2762. delete field.key;
  2763. }
  2764. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2765. var extObj = angular.fromJson(field.extjson);
  2766. angular.extend(field.templateOptions, extObj.templateOptions);
  2767. delete extObj.templateOptions;
  2768. for (var prop in extObj) {
  2769. if (new RegExp("Expression").test(prop)) {
  2770. //var obj = $scope.$eval(extObj[prop]);
  2771. //extObj[prop] = $scope.$eval(extObj[prop]);
  2772. if (extObj[prop] != null) {
  2773. if (new RegExp("function").test(extObj[prop])) {
  2774. var propValue = eval(extObj[prop]);
  2775. extObj[prop] = propValue;
  2776. } else {
  2777. //console.log(extObj[prop]);
  2778. var obj = $scope.$eval(extObj[prop]);
  2779. extObj[prop] = obj;
  2780. //console.log(obj);
  2781. }
  2782. }
  2783. } else if (new RegExp("expressionProperties").test(prop)) {
  2784. for (var p in extObj[prop]) {
  2785. if (new RegExp("function").test(extObj[prop][p])) {
  2786. var propValue = eval(extObj[prop][p]);
  2787. extObj[prop][p] = propValue;
  2788. } else {
  2789. //if(p.indexOf("'")>=0){
  2790. // var obj = $scope.$eval(extObj[prop][p]);
  2791. // extObj[prop][$scope.$eval(p)]=obj;
  2792. //}
  2793. }
  2794. }
  2795. } else if ("watcher" == prop) {
  2796. if (angular.isArray(extObj[prop])) {
  2797. angular.forEach(extObj[prop], function (item, index) {
  2798. for (var p in item) {
  2799. if (new RegExp("function").test(item[p])) {
  2800. var propValue = eval(item[p]);
  2801. extObj[prop][index][p] = propValue;
  2802. }
  2803. }
  2804. });
  2805. } else if (angular.isObject(extObj[prop])) {
  2806. for (var p in extObj[prop]) {
  2807. if (new RegExp("function").test(extObj[prop][p])) {
  2808. var propValue = eval(extObj[prop][p]);
  2809. extObj[prop][p] = propValue;
  2810. }
  2811. }
  2812. }
  2813. }
  2814. }
  2815. angular.extend(field, extObj);
  2816. delete field.extjson;
  2817. }
  2818. if (field.extjson == "") {
  2819. delete field.extjson;
  2820. }
  2821. if (angular.isDefined(field.templateOptions)) {
  2822. var templateOs = field.templateOptions;
  2823. for (var property in templateOs) {
  2824. //console.log(property);
  2825. if (
  2826. angular.isString(templateOs[property]) &&
  2827. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2828. ) {
  2829. if (new RegExp("function").test(templateOs[property])) {
  2830. var propValue = eval(templateOs[property]);
  2831. field.templateOptions[property] = propValue;
  2832. } else {
  2833. if (that.has(templateOs[property])) {
  2834. field.templateOptions[property] = that.get(
  2835. templateOs[property]
  2836. );
  2837. } else {
  2838. field.templateOptions[property] = templateOs[property];
  2839. }
  2840. }
  2841. } else if (templateOs[property] == null) {
  2842. //delete field.templateOptions[property];
  2843. } else {
  2844. }
  2845. }
  2846. }
  2847. if (
  2848. angular.isDefined(field.templateOptions) &&
  2849. angular.isDefined(field.templateOptions.extjson)
  2850. ) {
  2851. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2852. angular.extend(field.templateOptions, extObj);
  2853. delete field.templateOptions.extjson;
  2854. }
  2855. //...
  2856. if (field.templateOptions) {
  2857. //处理远程获取数据控件方法调用
  2858. if (field.templateOptions.optionsUrl) {
  2859. field.templateOptions.refresh = refreshSelectOptions;
  2860. }
  2861. //处理嵌套属性数据绑定/
  2862. if (field.templateOptions.pkey) {
  2863. var pmodel,
  2864. i = 0;
  2865. angular.forEach(
  2866. field.templateOptions.pkey.split("."),
  2867. function (p) {
  2868. if (i == 0) {
  2869. if (result.model[p] == null) {
  2870. result.model[p] = {};
  2871. }
  2872. pmodel = result.model[p];
  2873. i++;
  2874. } else {
  2875. if (pmodel[p] == null) {
  2876. pmodel[p] = {};
  2877. }
  2878. pmodel = pmodel[p];
  2879. }
  2880. }
  2881. );
  2882. if (pmodel != null) {
  2883. field.model = pmodel;
  2884. if (pmodel[field.key] == null) {
  2885. pmodel[field.key] = null;
  2886. }
  2887. }
  2888. } else {
  2889. if (result.model[field.key] == null) {
  2890. result.model[field.key] = null;
  2891. }
  2892. }
  2893. //处理弹出框组件初始化
  2894. if (field.type == "ui-input-selectmodal") {
  2895. field.templateOptions.modal = $modal;
  2896. //field.templateOptions.Restangular = Restangular;
  2897. } else if (field.type == "ui-userselect") {
  2898. field.templateOptions.modal = $modal;
  2899. //field.templateOptions.Restangular = Restangular;
  2900. } else if (field.type == "ui-multiuserselect") {
  2901. field.templateOptions.modal = $modal;
  2902. } else if (field.type == "ui-modelselect") {
  2903. field.templateOptions.modal = $modal;
  2904. //field.templateOptions.Restangular = Restangular;
  2905. } else if (field.type == "ui-dropfile") {
  2906. field.templateOptions.fileUploader = new FileUploader({
  2907. url: "/uploader",
  2908. });
  2909. field.templateOptions.taskId = $stateParams.taskId;
  2910. field.templateOptions.processInstanceId =
  2911. $stateParams.processInstanceId;
  2912. field.templateOptions.userId = $rootScope.user.id;
  2913. //field.ApiService=api_bpm_domain;
  2914. // }else if (field.type == "ui-uploadFile") {
  2915. // field.templateOptions.fileUploader = new FileUploader({
  2916. // url: '/uploader'
  2917. // });
  2918. // field.templateOptions.taskId = $stateParams.taskId;
  2919. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2920. // field.templateOptions.userId = $rootScope.user.id;
  2921. //field.ApiService=api_bpm_domain;
  2922. } else if (field.type == "ui-dropfiletable") {
  2923. if (field.templateOptions.processInstanceId) {
  2924. } else {
  2925. field.templateOptions.processInstanceId =
  2926. $stateParams.processInstanceId;
  2927. }
  2928. } else if (field.type == "ui-dropFiles") {
  2929. if (field.templateOptions.processInstanceId) {
  2930. } else {
  2931. field.templateOptions.processInstanceId =
  2932. $stateParams.processInstanceId;
  2933. }
  2934. } else if (field.type == "ui-showImgs") {
  2935. if (field.templateOptions.processInstanceId) {
  2936. } else {
  2937. field.templateOptions.processInstanceId =
  2938. $stateParams.processInstanceId;
  2939. }
  2940. } else if (field.type == "ui-repeatSection") {
  2941. var repeatForm = {
  2942. model: {},
  2943. fields: field.templateOptions.fields,
  2944. };
  2945. repeatForm.model[field.key] = [];
  2946. decodeVMTabForm(repeatForm);
  2947. }
  2948. }
  2949. // console.log(field);
  2950. //field
  2951. //result.fields.push(field);
  2952. });
  2953. });
  2954. vm.originalTabs = angular.copy(vm.form);
  2955. }
  2956. //解析自定义表单设计数据
  2957. function decodeVMForm(vmForm) {
  2958. var result = {
  2959. model: {},
  2960. tabs: [],
  2961. };
  2962. //设置模型实体数据 begin
  2963. // var mdata = vmForm.model;
  2964. //解析数据实体
  2965. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2966. angular.extend(result.model, mdata);
  2967. //设置模型实体数据 end
  2968. //解析设计数据生成表单项 begin
  2969. var fields = [];
  2970. //处理修改设计数据中展示设置
  2971. angular.forEach(vmForm.tabs, function (field) {
  2972. if (field.key == "") {
  2973. delete field.key;
  2974. }
  2975. if (angular.isDefined(field.extjson)) {
  2976. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2977. angular.extend(field.templateOptions, extObj.templateOptions);
  2978. delete extObj.templateOptions;
  2979. for (var prop in extObj) {
  2980. if (new RegExp("Expression").test(prop)) {
  2981. //var obj = $scope.$eval(extObj[prop]);
  2982. //extObj[prop] = $scope.$eval(extObj[prop]);
  2983. if (extObj[prop] != null) {
  2984. if (new RegExp("function").test(extObj[prop])) {
  2985. var propValue = eval(extObj[prop]);
  2986. extObj[prop] = propValue;
  2987. } else {
  2988. //console.log(extObj[prop]);
  2989. var obj = $scope.$eval(extObj[prop]);
  2990. extObj[prop] = obj;
  2991. //console.log(obj);
  2992. }
  2993. }
  2994. } else if (new RegExp("expressionProperties").test(prop)) {
  2995. for (var p in extObj[prop]) {
  2996. if (new RegExp("function").test(extObj[prop][p])) {
  2997. var propValue = eval(extObj[prop][p]);
  2998. extObj[prop][p] = propValue;
  2999. } else {
  3000. //if(p.indexOf("'")>=0){
  3001. // var obj = $scope.$eval(extObj[prop][p]);
  3002. // extObj[prop][$scope.$eval(p)]=obj;
  3003. //}
  3004. }
  3005. }
  3006. } else if ("watcher" == prop) {
  3007. if (angular.isArray(extObj[prop])) {
  3008. angular.forEach(extObj[prop], function (item, index) {
  3009. for (var p in item) {
  3010. if (new RegExp("function").test(item[p])) {
  3011. var propValue = eval(item[p]);
  3012. extObj[prop][index][p] = propValue;
  3013. }
  3014. }
  3015. });
  3016. } else if (angular.isObject(extObj[prop])) {
  3017. for (var p in extObj[prop]) {
  3018. if (new RegExp("function").test(extObj[prop][p])) {
  3019. var propValue = eval(extObj[prop][p]);
  3020. extObj[prop][p] = propValue;
  3021. }
  3022. }
  3023. }
  3024. }
  3025. }
  3026. angular.extend(field, extObj);
  3027. delete field.extjson;
  3028. }
  3029. if (angular.isDefined(field.templateOptions)) {
  3030. var templateOs = field.templateOptions;
  3031. for (var property in templateOs) {
  3032. //console.log(property);
  3033. if (
  3034. angular.isString(templateOs[property]) &&
  3035. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3036. ) {
  3037. if (new RegExp("function").test(templateOs[property])) {
  3038. var propValue = eval(templateOs[property]);
  3039. field.templateOptions[property] = propValue;
  3040. } else {
  3041. if (that.has(templateOs[property])) {
  3042. field.templateOptions[property] = that.get(
  3043. templateOs[property]
  3044. );
  3045. } else {
  3046. field.templateOptions[property] = templateOs[property];
  3047. }
  3048. }
  3049. } else if (templateOs[property] == null) {
  3050. //delete field.templateOptions[property];
  3051. } else {
  3052. }
  3053. }
  3054. }
  3055. if (
  3056. angular.isDefined(field.templateOptions) &&
  3057. angular.isDefined(field.templateOptions.extjson)
  3058. ) {
  3059. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3060. angular.extend(field.templateOptions, extObj);
  3061. delete field.templateOptions.extjson;
  3062. }
  3063. //...
  3064. if (field.templateOptions) {
  3065. //处理远程获取数据控件方法调用
  3066. if (field.templateOptions.optionsUrl) {
  3067. field.templateOptions.refresh = refreshSelectOptions;
  3068. }
  3069. //处理嵌套属性数据绑定/
  3070. if (field.templateOptions.pkey) {
  3071. var pmodel,
  3072. i = 0;
  3073. angular.forEach(
  3074. field.templateOptions.pkey.split("."),
  3075. function (p) {
  3076. if (i == 0) {
  3077. if (result.model[p] == null) {
  3078. result.model[p] = {};
  3079. }
  3080. pmodel = result.model[p];
  3081. i++;
  3082. } else {
  3083. if (pmodel[p] == null) {
  3084. pmodel[p] = {};
  3085. }
  3086. pmodel = pmodel[p];
  3087. }
  3088. }
  3089. );
  3090. if (pmodel != null) {
  3091. field.model = pmodel;
  3092. if (pmodel[field.key] == null) {
  3093. pmodel[field.key] = null;
  3094. }
  3095. }
  3096. } else {
  3097. if (result.model[field.key] == null) {
  3098. result.model[field.key] = null;
  3099. }
  3100. }
  3101. //处理弹出框组件初始化
  3102. if (field.type == "ui-input-selectmodal") {
  3103. field.templateOptions.modal = $modal;
  3104. //field.templateOptions.Restangular = Restangular;
  3105. } else if (field.type == "ui-userselect") {
  3106. field.templateOptions.modal = $modal;
  3107. //field.templateOptions.Restangular = Restangular;
  3108. } else if (field.type == "ui-multiuserselect") {
  3109. field.templateOptions.modal = $modal;
  3110. } else if (field.type == "ui-modelselect") {
  3111. field.templateOptions.modal = $modal;
  3112. //field.templateOptions.Restangular = Restangular;
  3113. } else if (field.type == "ui-dropfile") {
  3114. field.templateOptions.fileUploader = new FileUploader({
  3115. url: "/uploader",
  3116. });
  3117. field.templateOptions.taskId = $stateParams.taskId;
  3118. field.templateOptions.processInstanceId =
  3119. $stateParams.processInstanceId;
  3120. field.templateOptions.userId = $rootScope.user.id;
  3121. //field.ApiService=api_bpm_domain;
  3122. } else if (field.type == "ui-dropfiletable") {
  3123. if (field.templateOptions.processInstanceId) {
  3124. } else {
  3125. field.templateOptions.processInstanceId =
  3126. $stateParams.processInstanceId;
  3127. }
  3128. } else if (field.type == "ui-dropFiles") {
  3129. if (field.templateOptions.processInstanceId) {
  3130. } else {
  3131. field.templateOptions.processInstanceId =
  3132. $stateParams.processInstanceId;
  3133. }
  3134. } else if (field.type == "ui-showImgs") {
  3135. if (field.templateOptions.processInstanceId) {
  3136. } else {
  3137. field.templateOptions.processInstanceId =
  3138. $stateParams.processInstanceId;
  3139. }
  3140. } else if (field.type == "ui-repeatSection") {
  3141. var repeatForm = {
  3142. model: {},
  3143. fields: field.templateOptions.fields,
  3144. };
  3145. repeatForm.model[field.key] = [];
  3146. decodeVMForm(repeatForm);
  3147. }
  3148. }
  3149. // console.log(field);
  3150. result.fields.push(field);
  3151. });
  3152. angular.extend($scope.vm.fields, result.fields);
  3153. angular.extend($scope.vm.models, result.model);
  3154. $scope.formData = vmForm;
  3155. //console.log($scope.vm);
  3156. //解析设计数据生成表单项 end
  3157. return result;
  3158. }
  3159. //======================处理表单设计数据 结束========================
  3160. $scope.ldloading = {};
  3161. function filter(obj) {
  3162. angular.forEach(obj, function (key, value) {
  3163. if (value === "" || value === null) {
  3164. delete obj[key];
  3165. } else if (
  3166. Object.prototype.toString.call(value) === "[object Object]"
  3167. ) {
  3168. filter(value);
  3169. } else if (angular.isArray(value)) {
  3170. angular.forEach(value, function (item) {
  3171. filter(item);
  3172. });
  3173. }
  3174. });
  3175. }
  3176. function invokeOnAllFormOptions(fn) {
  3177. angular.forEach(vm.tabs, function (tab) {
  3178. if (tab.form.options && tab.form.options[fn]) {
  3179. tab.form.options[fn]();
  3180. }
  3181. });
  3182. }
  3183. function encodeCIData(data, ciId) {
  3184. /*
  3185. create/update state:未审核
  3186. create createtime:系统时间
  3187. create/update lastupdatetime : 系统时间
  3188. label:ci分类
  3189. */
  3190. if (ciId) {
  3191. var baseprop = [
  3192. "uuid",
  3193. "name",
  3194. "type",
  3195. "label",
  3196. "status",
  3197. "createtime",
  3198. "lastupdatetime",
  3199. "props",
  3200. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3201. var extraprop = "props";
  3202. data[extraprop] = {};
  3203. for (var key in data) {
  3204. console.log(data[key]);
  3205. if (_.indexOf(baseprop, key) >= 0) {
  3206. continue;
  3207. } else {
  3208. data[extraprop][key] = data[key];
  3209. delete data[key];
  3210. }
  3211. }
  3212. if ($rootScope.user) {
  3213. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3214. data[extraprop]["configperson"] = $rootScope.user.name;
  3215. var isCMAdminFlag = false;
  3216. angular.forEach($rootScope.user.role, function (roleItem) {
  3217. if (roleItem.rolecode == "cmdb charge") {
  3218. isCMAdminFlag = true;
  3219. }
  3220. });
  3221. if (!isCMAdminFlag) {
  3222. data[extraprop]["state"] = "1";
  3223. }
  3224. }
  3225. if (data.props.id) {
  3226. } else {
  3227. data.label = ciId;
  3228. }
  3229. return data;
  3230. }
  3231. return undefined;
  3232. }
  3233. function decodeCIModel(data) {
  3234. var extraprop = "props";
  3235. if (data[extraprop]) {
  3236. for (var key in data[extraprop]) {
  3237. data[key] = data[extraprop][key];
  3238. }
  3239. delete data[extraprop];
  3240. }
  3241. data["iscmadmin"] = false;
  3242. angular.forEach($rootScope.user.role, function (roleItem) {
  3243. if (roleItem.rolecode == "cmdb charge") {
  3244. data["iscmadmin"] = true;
  3245. }
  3246. });
  3247. return data;
  3248. }
  3249. vm.remove = function (data, style) {
  3250. $scope.ldloading[style.replace("-", "_")] = true;
  3251. var modalInstance = $modal.open({
  3252. templateUrl: "assets/views/delete.html",
  3253. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3254. var cidata = {
  3255. label: data.label,
  3256. id: data.id,
  3257. uuid: data.uuid,
  3258. name: data.name,
  3259. props: {},
  3260. };
  3261. if (cidata.id) {
  3262. cidata.props["removeflag"] = true;
  3263. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3264. $scope.ok = function () {
  3265. $modalInstance.close(cidata);
  3266. };
  3267. $scope.cancel = function () {
  3268. $modalInstance.dismiss("cancel");
  3269. };
  3270. }
  3271. },
  3272. size: "sm",
  3273. resolve: {
  3274. scope: function () {
  3275. return $scope;
  3276. },
  3277. },
  3278. });
  3279. modalInstance.result.then(function (selectedItem) {
  3280. if (selectedItem) {
  3281. // if (selectedItem.length > 0) {
  3282. api_cmdb
  3283. .put(selectedItem, selectedItem.id)
  3284. .then(function (response) {
  3285. if (response) {
  3286. var resData = Restangular.stripRestangular(response);
  3287. SweetAlert.swal(
  3288. {
  3289. title: "删除成功!",
  3290. confirmButtonColor: "#007AFF",
  3291. },
  3292. function () {
  3293. $state.go("app.means.list");
  3294. // $scope.refreshform();
  3295. // reinitTabForm($scope.classify);
  3296. }
  3297. );
  3298. } else {
  3299. SweetAlert.swal({
  3300. title: "系统错误",
  3301. text: "系统错误,请稍后重试!",
  3302. type: "error",
  3303. confirmButtonColor: "#DD6B55",
  3304. });
  3305. }
  3306. $scope.ldloading[style.replace("-", "_")] = false;
  3307. });
  3308. }
  3309. });
  3310. };
  3311. function formValid() {
  3312. angular.forEach(vm.tabs, function (item) {
  3313. //item.
  3314. });
  3315. }
  3316. $scope.closeModel = function () {
  3317. console.log($stateParams);
  3318. if (
  3319. angular.isDefined($stateParams.formKey) &&
  3320. $stateParams.formKey != ""
  3321. ) {
  3322. if (
  3323. $stateParams.formKey == "means_editor" ||
  3324. $stateParams.formKey == "means_edit"
  3325. ) {
  3326. $state.go("app.means.list", {});
  3327. }
  3328. event.preventDefault();
  3329. }
  3330. };
  3331. // setInterval(function() {
  3332. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3333. // cifilter_classic = $scope.model.cifilter_classic;
  3334. // $scope.refreshcmdbform(cifilter_classic);
  3335. // } else {}
  3336. // }, 100);
  3337. vm.models = (function filter(obj) {
  3338. var filtered = _.pick(obj, function (v) {
  3339. return (
  3340. angular.isDefined(v) &&
  3341. v !== null &&
  3342. (angular.isArray(v) ? v.length > 0 : true) &&
  3343. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3344. );
  3345. });
  3346. return _.cloneDeep(filtered, function (v) {
  3347. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3348. });
  3349. })(vm.models);
  3350. // setInterval(function() {
  3351. // if ($scope.model.type == 0) {
  3352. // $scope.model[$scope.options.key] = vm.models;
  3353. // }
  3354. // }, 100);
  3355. setInterval(function () {
  3356. if (vm.form && vm.form.$$parentForm.$valid) {
  3357. if (
  3358. $scope.$parent &&
  3359. $scope.$parent.$parent &&
  3360. $scope.$parent.$parent.$parent &&
  3361. $scope.$parent.$parent.$parent.model
  3362. ) {
  3363. vm.models.hw_cifilterClassic =
  3364. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3365. $scope.model[$scope.options.key] = vm.models;
  3366. }
  3367. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3368. // $scope.model[$scope.options.key] = vm.models;
  3369. }
  3370. }, 100);
  3371. vm.submit = function (data, ciId, templateitem, style) {
  3372. // $scope.ldloading[style.replace('-', '_')] = true;
  3373. console.log(vm.form.$$parentForm.$valid);
  3374. if (vm.form.$$parentForm.$valid) {
  3375. invokeOnAllFormOptions("updateInitialValue");
  3376. //alert(JSON.stringify(vm.model), null, 2);
  3377. //vm.options.updateInitialValue();
  3378. //console.log(vm.model);
  3379. var cidata = encodeCIData(vm.models, ciId);
  3380. if (cidata) {
  3381. //var cidata = ;
  3382. if (cidata.props.id) {
  3383. //修改
  3384. api_cmdb.put(cidata, ciId).then(function (response) {
  3385. if (response) {
  3386. var resData = Restangular.stripRestangular(response);
  3387. SweetAlert.swal(
  3388. {
  3389. title: "保存成功!",
  3390. confirmButtonColor: "#007AFF",
  3391. },
  3392. function () {
  3393. $scope.ldloading[style.replace("-", "_")] = false;
  3394. // $scope.refreshform();
  3395. $state.go("app.means.list");
  3396. }
  3397. );
  3398. } else {
  3399. SweetAlert.swal({
  3400. title: "系统错误",
  3401. text: "系统错误,请稍后重试!",
  3402. type: "error",
  3403. confirmButtonColor: "#DD6B55",
  3404. });
  3405. }
  3406. $scope.ldloading[style.replace("-", "_")] = false;
  3407. });
  3408. } else {
  3409. //新建
  3410. var type = 2;
  3411. api_sysinfo
  3412. .getSerialnumber(type, templateitem.id)
  3413. .then(function (data) {
  3414. if (data && data.status == 200) {
  3415. cidata.uuid = data.uuid;
  3416. api_cmdb.create(cidata).then(function (response) {
  3417. if (response) {
  3418. var resData = Restangular.stripRestangular(response);
  3419. SweetAlert.swal(
  3420. {
  3421. title: "保存成功!",
  3422. text: "内部编号:" + cidata.uuid,
  3423. confirmButtonColor: "#007AFF",
  3424. },
  3425. function () {
  3426. $state.go("app.means.list");
  3427. }
  3428. );
  3429. // if(resData.status){
  3430. // resData
  3431. // }
  3432. } else {
  3433. SweetAlert.swal({
  3434. title: "系统错误",
  3435. text: "系统错误,请稍后重试!",
  3436. type: "error",
  3437. confirmButtonColor: "#DD6B55",
  3438. });
  3439. }
  3440. $scope.ldloading[style.replace("-", "_")] = false;
  3441. });
  3442. } else {
  3443. SweetAlert.swal({
  3444. title: "系统错误",
  3445. text: "内部编号生成出错!",
  3446. type: "error",
  3447. confirmButtonColor: "#DD6B55",
  3448. });
  3449. }
  3450. });
  3451. }
  3452. } else {
  3453. SweetAlert.swal({
  3454. title: "错误",
  3455. text: "错误,请选择资产分类!",
  3456. type: "error",
  3457. confirmButtonColor: "#DD6B55",
  3458. });
  3459. }
  3460. //alert(JSON.stringify(cidata), null, 2);
  3461. $scope.ldloading[style.replace("-", "_")] = true;
  3462. return;
  3463. var _ = window._;
  3464. vm.models = (function filter(obj) {
  3465. var filtered = _.pick(obj, function (v) {
  3466. return (
  3467. angular.isDefined(v) &&
  3468. v !== null &&
  3469. (angular.isArray(v) ? v.length > 0 : true) &&
  3470. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3471. );
  3472. });
  3473. return _.cloneDeep(filtered, function (v) {
  3474. return v !== filtered && _.isPlainObject(v)
  3475. ? filter(v)
  3476. : undefined;
  3477. });
  3478. })(vm.models);
  3479. } else {
  3480. if (vm.form.$$parentForm.$error) {
  3481. SweetAlert.swal({
  3482. title: "校验错误",
  3483. text: "请填写必填项!",
  3484. type: "error",
  3485. confirmButtonColor: "#DD6B55",
  3486. });
  3487. angular.forEach(
  3488. vm.form.$$parentForm.$error.required,
  3489. function (item) {
  3490. angular.forEach(vm.tabs, function (tab) {
  3491. angular.forEach(tab.form.fields, function (f) {
  3492. if (f.name == item.$name) {
  3493. f.validation.show = true;
  3494. tab.active = true;
  3495. }
  3496. });
  3497. });
  3498. }
  3499. );
  3500. $scope.ldloading[style.replace("-", "_")] = false;
  3501. }
  3502. }
  3503. };
  3504. $scope.vm = vm;
  3505. $scope.refreshcmdbform = function (item) {
  3506. // if ($stateParams.model) {
  3507. // var modeldata = JSON.parse($stateParams.model)
  3508. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3509. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3510. var myData = Restangular.stripRestangular(data);
  3511. $scope.propTypeOptions = myData;
  3512. $scope.templateProps = myData;
  3513. $scope.vm.tabs = myData;
  3514. if ($scope.model.asset && $scope.model.asset.length != "") {
  3515. vm.models = JSON.parse($scope.model.asset);
  3516. }
  3517. decodeVMTabForm(vm.models, vm.tabs);
  3518. });
  3519. // }
  3520. };
  3521. var cifilterClassic = {};
  3522. setInterval(function () {
  3523. if (
  3524. $scope.$parent.$parent &&
  3525. $scope.$parent.$parent.$parent &&
  3526. $scope.$parent.$parent.$parent.model &&
  3527. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3528. cifilterClassic.id !=
  3529. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3530. ) {
  3531. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3532. cifilterClassic =
  3533. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3534. $scope.refreshcmdbform(cifilterClassic);
  3535. } else {
  3536. }
  3537. }, 100);
  3538. },
  3539. ],
  3540. });
  3541. //请求人信息
  3542. formlyConfigProvider.setType({
  3543. name: "ui-cmdbinformation",
  3544. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3545. wrapper: ["bootstrapHasError"],
  3546. defaultOptions: function (options, $scope) {
  3547. return {
  3548. templateOptions: {
  3549. // checkform: function(options) {
  3550. // if (options.model.requester) {
  3551. // options.value(options.model.requester);
  3552. // }
  3553. // },
  3554. },
  3555. };
  3556. },
  3557. controller: [
  3558. "$scope",
  3559. "api_user_data",
  3560. function ($scope, api_user_data) {
  3561. if ($scope.options.templateOptions.loginUser) {
  3562. if (
  3563. $scope.model[$scope.options.key] &&
  3564. $scope.model[$scope.options.key].id
  3565. ) {
  3566. } else {
  3567. $scope.model[$scope.options.key] =
  3568. $scope.options.templateOptions.loginUser;
  3569. }
  3570. $scope.options.initialValue = $scope.model[$scope.options.key];
  3571. }
  3572. },
  3573. ],
  3574. });
  3575. //资产属性
  3576. formlyConfigProvider.setType({
  3577. name: "ui-cmdbtype",
  3578. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3579. wrapper: ["bootstrapHasError"],
  3580. defaultOptions: function (options, $scope) {
  3581. return {
  3582. templateOptions: {
  3583. // checkform: function(options) {
  3584. // if (options.model.requester) {
  3585. // options.value(options.model.requester);
  3586. // }
  3587. // },
  3588. },
  3589. };
  3590. },
  3591. controller: [
  3592. "$scope",
  3593. "api_user_data",
  3594. function ($scope, api_user_data) {
  3595. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3596. $scope.property = {
  3597. hw_change: $scope.to.loginUser,
  3598. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3599. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3600. };
  3601. if ($scope.$parent.$parent.$parent.model.assets) {
  3602. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3603. }
  3604. },
  3605. ],
  3606. });
  3607. //申请单信息
  3608. formlyConfigProvider.setType({
  3609. name: "ui-cmdbformimform",
  3610. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3611. wrapper: ["bootstrapHasError"],
  3612. defaultOptions: function (options, $scope) {
  3613. return {
  3614. templateOptions: {
  3615. // checkform: function(options) {
  3616. // if (options.model.requester) {
  3617. // options.value(options.model.requester);
  3618. // }
  3619. // },
  3620. },
  3621. };
  3622. },
  3623. controller: [
  3624. "$scope",
  3625. "api_user_data",
  3626. function ($scope, api_user_data) {
  3627. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3628. $scope.getininform = {
  3629. serialNumbe:
  3630. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3631. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3632. };
  3633. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3634. $scope.getininform.types = "新资产入库";
  3635. } else if (
  3636. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3637. ) {
  3638. $scope.getininform.types = "资产归还";
  3639. }
  3640. },
  3641. ],
  3642. });
  3643. //出库单信息
  3644. formlyConfigProvider.setType({
  3645. name: "ui-outinformation",
  3646. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3647. wrapper: ["bootstrapHasError"],
  3648. defaultOptions: function (options, $scope) {
  3649. return {
  3650. templateOptions: {
  3651. // checkform: function(options) {
  3652. // if (options.model.requester) {
  3653. // options.value(options.model.requester);
  3654. // }
  3655. // },
  3656. },
  3657. };
  3658. },
  3659. controller: [
  3660. "$scope",
  3661. "api_user_data",
  3662. function ($scope, api_user_data) {
  3663. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3664. $scope.getininform = {
  3665. serialNumbe:
  3666. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3667. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3668. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3669. sourceId:
  3670. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3671. describe:
  3672. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3673. };
  3674. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3675. $scope.getininform.types = "新设备领用出库";
  3676. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3677. $scope.getininform.types = "设备更换";
  3678. }
  3679. $scope.getininform.source_id =
  3680. $scope.$parent.$parent.$parent.model.source.value;
  3681. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3682. $scope.getininform.source = "事件";
  3683. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3684. $scope.getininform.source = "变更";
  3685. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3686. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3687. $scope.getininform.source = "其它";
  3688. }
  3689. },
  3690. ],
  3691. });
  3692. //资产附件上传
  3693. formlyConfigProvider.setType({
  3694. name: "ui-cmdbuplode",
  3695. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3696. wrapper: ["bootstrapHasError"],
  3697. defaultOptions: function (options, $scope) {
  3698. return {
  3699. templateOptions: {
  3700. // checkform: function(options) {
  3701. // if (options.model.requester) {
  3702. // options.value(options.model.requester);
  3703. // }
  3704. // },
  3705. },
  3706. };
  3707. },
  3708. controller: [
  3709. "$scope",
  3710. "$rootScope",
  3711. "$http",
  3712. "SweetAlert",
  3713. "FileUploader",
  3714. "api_user_data",
  3715. "i18nService",
  3716. "$modal",
  3717. "Restangular",
  3718. "api_configure_data",
  3719. "api_cmdb",
  3720. "api_cmdb_new",
  3721. "api_wechatfile",
  3722. "api_sysinfo",
  3723. function (
  3724. $scope,
  3725. $rootScope,
  3726. $http,
  3727. SweetAlert,
  3728. FileUploader,
  3729. api_user_data,
  3730. i18nService,
  3731. $modal,
  3732. Restangular,
  3733. api_configure_data,
  3734. api_cmdb,
  3735. api_cmdb_new,
  3736. api_wechatfile,
  3737. api_sysinfo
  3738. ) {
  3739. $scope.state = 1;
  3740. $scope.myData3all = [];
  3741. $scope.myData3 = [];
  3742. $scope.memoryfilterDatahao = {
  3743. idx: 0,
  3744. sum: 10,
  3745. };
  3746. $scope.selected = {
  3747. items: [],
  3748. };
  3749. $scope.interceptMydata = function (mydate, idx, sum) {
  3750. return mydate.slice(idx * sum, (idx + 1) * sum);
  3751. };
  3752. // $scope.importnext = function() {
  3753. // $scope.state = 2;
  3754. // event.preventDefault();
  3755. // }
  3756. $scope.workspaces = [];
  3757. $scope.options.templateOptions.getpush = function (item) {
  3758. $scope.workspaces = [];
  3759. if (item.gu) {
  3760. $scope.workspaces.push({
  3761. id: 1,
  3762. name: "固定资产",
  3763. active: true,
  3764. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3765. });
  3766. }
  3767. if (item.hao) {
  3768. $scope.workspaces.push({
  3769. id: 2,
  3770. name: "耗材资产",
  3771. active: true,
  3772. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3773. });
  3774. }
  3775. };
  3776. //获取附件列表
  3777. $scope.listAttachmen = function () {
  3778. to.ApiService.listAttachment(
  3779. to.listAttachmentUrl,
  3780. to.bindType,
  3781. bindId
  3782. ).then(function (result) {
  3783. var myData = Restangular.stripRestangular(result);
  3784. // $scope.listAttachmens = myData;
  3785. $scope.attachments = myData.data;
  3786. });
  3787. };
  3788. //附件列表
  3789. if ($scope.options.templateOptions.bindType) {
  3790. if (angular.isUndefined($scope.form.dropState)) {
  3791. $scope.form.dropState = false;
  3792. }
  3793. var to = $scope.options.templateOptions;
  3794. var bindId = $scope.model[to.bindType].processInstanceId;
  3795. $scope.listAttachmen();
  3796. }
  3797. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3798. // $scope.listAttachmen();
  3799. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3800. // $scope.listAttachmen();
  3801. // }
  3802. //附件下载
  3803. $scope.download = function (token, filename) {
  3804. var downUrl = to.ApiService.downloadAttachment(
  3805. to.downUrl,
  3806. token
  3807. ).getRequestedUrl();
  3808. // window.open(downUrl);
  3809. var a = document.createElement("a");
  3810. a.href = downUrl;
  3811. a.target = "_blank";
  3812. a.download = filename;
  3813. document.body.appendChild(a);
  3814. a.click();
  3815. };
  3816. //附件预览
  3817. $scope.view = function (id, previewUrl) {
  3818. if (previewUrl) {
  3819. window.open(previewUrl);
  3820. }
  3821. };
  3822. //下载资产模版
  3823. $scope.filenum = 0;
  3824. $scope.openmeans = function () {
  3825. var modalInstance = $modal.open({
  3826. templateUrl: "assets/views/means/tpl/meansdown.html",
  3827. controller: function ($scope, scope, $modalInstance) {
  3828. $scope.item = {};
  3829. $scope.title = "选择下载模版";
  3830. $scope.lable = "资产模版下载";
  3831. function foreachdata(my_datas) {
  3832. // angular.forEach(my_datas, function(item, index) {
  3833. // if (item.children && item.children.length > 0) {
  3834. // foreachdata(item.children);
  3835. // } else {
  3836. // my_datas[index].checks = true;
  3837. // }
  3838. // })
  3839. for (var i = 0; i < my_datas.length; i++) {
  3840. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3841. foreachdata(my_datas[i].children);
  3842. console.log($scope);
  3843. } else {
  3844. my_datas[i].checks = true;
  3845. }
  3846. }
  3847. }
  3848. function foreachtree(data) {
  3849. angular.forEach(data, function (item) {
  3850. // if (item.checks != true) {
  3851. item.checks = true;
  3852. item.expanded = true;
  3853. if (item.children && item.children.length > 0) {
  3854. foreachtree(item.children);
  3855. } else {
  3856. $scope.getslowtree.push(item);
  3857. }
  3858. // }
  3859. });
  3860. }
  3861. $scope.getslowtree = [];
  3862. $scope.slowtree = function (tree) {
  3863. foreachtree(tree);
  3864. return $scope.getslowtree;
  3865. };
  3866. $scope.all = function (c, v) {
  3867. //全选
  3868. if (c == true) {
  3869. $scope.formdashboard($scope.slowtree(v));
  3870. } else {
  3871. $scope.my_data_after = [];
  3872. angular.forEach($scope.my_data, function (item, index) {
  3873. $scope.my_data[index].checks = false;
  3874. $scope.my_data[index].expanded = false;
  3875. if (item.children && item.children.length > 0) {
  3876. angular.forEach(
  3877. item.children,
  3878. function (itemone, indexone) {
  3879. $scope.my_data[index].children[
  3880. indexone
  3881. ].checks = false;
  3882. $scope.my_data[index].children[
  3883. indexone
  3884. ].expanded = false;
  3885. if (itemone.children && itemone.children.length > 0) {
  3886. angular.forEach(
  3887. itemone.children,
  3888. function (itemtwo, indextwo) {
  3889. $scope.my_data[index].children[
  3890. indexone
  3891. ].children[indextwo].checks = false;
  3892. }
  3893. );
  3894. } else {
  3895. }
  3896. }
  3897. );
  3898. } else {
  3899. }
  3900. });
  3901. $scope.mydatacate = [];
  3902. $scope.getslowtree = [];
  3903. // }
  3904. }
  3905. };
  3906. // $scope.searchone = function(search) {
  3907. // angular.forEach($scope.my_data, function(item) {
  3908. // if (item.indexOf(search) > 0) {
  3909. // }
  3910. // })
  3911. // }
  3912. $scope.checkall = function () {
  3913. angular.forEach($scope.my_data, function (item, index) {
  3914. scope.my_data[index].checks = true;
  3915. });
  3916. };
  3917. $scope.selectitem = [];
  3918. $scope.choiceitem = function (item) {
  3919. // if (item.checkeds) {
  3920. // item.checkeds = false;
  3921. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3922. // // if ($scope.selectitem[i].id == item.id) {
  3923. // // $scope.selectitem.splice(i, 1)
  3924. // // }
  3925. // // }
  3926. // for (var i = 0; i < $scope.my_data_after; i++) {
  3927. // if ($scope.my_data_after[i].id == item.id) {
  3928. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3929. // // $scope.selectitem.splice(i, 1)
  3930. // }
  3931. // }
  3932. // } else {
  3933. // item.checkeds = true;
  3934. // $scope.selectitem.push(item)
  3935. // }
  3936. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3937. if ($scope.my_data_after[i].id == item.id) {
  3938. $scope.my_data_after[i].checkeds
  3939. ? ($scope.my_data_after[i].checkeds = false)
  3940. : ($scope.my_data_after[i].checkeds = true);
  3941. }
  3942. }
  3943. };
  3944. $scope.remove = function (removeitem) {
  3945. var realdat = angular.copy($scope.my_data_after);
  3946. // angular.extend(realdat, $scope.selectitem);
  3947. $scope.my_data_after = [];
  3948. angular.forEach(realdat, function (item) {
  3949. if (!item.checkeds) {
  3950. $scope.my_data_after.push(item);
  3951. }
  3952. });
  3953. $scope.mydatacate = angular.copy($scope.my_data_after);
  3954. };
  3955. $scope.try_async_loads = function (item, search) {
  3956. var fildatas = {
  3957. idx: 0,
  3958. sum: 1000,
  3959. };
  3960. $scope.my_data = [];
  3961. // $scope.try_async_load = true;
  3962. if (item) {
  3963. angular.extend(fildatas, item);
  3964. }
  3965. api_configure_data
  3966. .fetchDataList("ciclassify", fildatas)
  3967. .then(function (response) {
  3968. if (response.status == 200) {
  3969. var data = response.list;
  3970. var objects = [];
  3971. for (var i = 0; i < data.length; i++) {
  3972. var object = {};
  3973. object.id = data[i].id;
  3974. if (search) {
  3975. delete data[i].parent;
  3976. } else {
  3977. if (data[i].parent && data[i].parent.id != 0) {
  3978. object.parent = data[i].parent.id;
  3979. }
  3980. }
  3981. angular.extend(object, data[i]);
  3982. objects.push(object);
  3983. }
  3984. $scope.my_data = convertParentToChildList(objects);
  3985. $scope.tree_data = angular.copy($scope.my_data);
  3986. if ($scope.my_data.length > 0) {
  3987. $scope.try_async_load = false;
  3988. }
  3989. } else {
  3990. SweetAlert.swal({
  3991. title: "系统错误!",
  3992. text: "请刷新重试!",
  3993. type: "error",
  3994. });
  3995. }
  3996. });
  3997. };
  3998. function convertListToTree(data, treeMap) {
  3999. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  4000. var root = null; //Initially set our loop to null
  4001. //loop over data
  4002. for (var i = 0; i < data.length; i++) {
  4003. var datum = data[i];
  4004. //each node will have children, so let's give it a "children" poperty
  4005. datum.children = [];
  4006. //add an entry for this node to the map so that any future children can
  4007. //lookup the parent
  4008. idToNodeMap[datum.id] = datum;
  4009. //Does this node have a parent?
  4010. // console.log("datum="+JSON.stringify(datum))
  4011. if (
  4012. typeof datum.parent === "undefined" ||
  4013. datum.parent === null
  4014. ) {
  4015. //Doesn't look like it, so this node is the root of the tree
  4016. root = datum;
  4017. treeMap[datum.id] = root;
  4018. } else {
  4019. //This node has a parent, so let's look it up using the id
  4020. parentNode = idToNodeMap[datum.parent.id];
  4021. //We don't need this property, so let's delete it.
  4022. // delete datum.parent;
  4023. //Let's add the current node as a child of the parent node.
  4024. parentNode.children.push(datum);
  4025. }
  4026. }
  4027. return root;
  4028. }
  4029. function convertParentToChildList(data) {
  4030. var treeMap = {};
  4031. var list = [];
  4032. convertListToTree(data, treeMap);
  4033. angular.forEach(treeMap, function (item) {
  4034. list.push(item);
  4035. });
  4036. return list;
  4037. }
  4038. function convertParentToChild(datato) {
  4039. var treeMapto = {};
  4040. var listto = [];
  4041. convertListToTree(datato, treeMapto);
  4042. angular.forEach(treeMapto, function (items) {
  4043. listto.push(items);
  4044. });
  4045. return listto;
  4046. }
  4047. $scope.try_async_loads();
  4048. $scope.searchdown = function (key) {
  4049. if (key && key != "") {
  4050. $scope.try_async_loads(
  4051. {
  4052. ciclassify: {
  4053. label: key,
  4054. },
  4055. },
  4056. "search"
  4057. );
  4058. } else {
  4059. $scope.try_async_loads();
  4060. }
  4061. // var mydatacatedown = angular.copy($scope.my_data);
  4062. // $scope.my_data = [];
  4063. // var objects = [];
  4064. // angular.forEach(mydatacatedown, function(item) {
  4065. // if (item.label.match(key)) {
  4066. // objects.push(item)
  4067. // } else {
  4068. // // $scope.my_data_after.push(item)
  4069. // }
  4070. // })
  4071. // $scope.my_data = convertParentToChildList(objects);
  4072. // $scope.tree_data = angular.copy($scope.my_data);
  4073. };
  4074. $scope.mydatacate = [];
  4075. $scope.searchup = function (key) {
  4076. // var mydatacate = angular.copy($scope.my_data_after);
  4077. $scope.my_data_after = [];
  4078. angular.forEach($scope.mydatacate, function (item) {
  4079. if (item.label.match(key)) {
  4080. $scope.my_data_after.push(item);
  4081. } else {
  4082. }
  4083. });
  4084. };
  4085. //角色树
  4086. $scope.my_tree = [];
  4087. $scope.tree_data_after = [];
  4088. $scope.my_data = [];
  4089. $scope.my_data_after = [];
  4090. $scope.formdashboard = function (item) {
  4091. $scope.my_data_after = [];
  4092. angular.forEach(item, function (infox) {
  4093. if (infox.children.length == 0) {
  4094. $scope.my_data_after.push(infox);
  4095. }
  4096. });
  4097. $scope.mydatacate = angular.copy($scope.my_data_after);
  4098. };
  4099. $scope.ok = function (item) {
  4100. $modalInstance.close(item);
  4101. };
  4102. $scope.cancel = function () {
  4103. $modalInstance.dismiss("cancel");
  4104. };
  4105. },
  4106. // size: 'sm',
  4107. resolve: {
  4108. scope: function () {
  4109. return $scope;
  4110. },
  4111. },
  4112. });
  4113. modalInstance.result.then(function (selectedItem) {
  4114. // $rootScope.isMask = true;
  4115. if (selectedItem) {
  4116. var type = 1;
  4117. var fildat = {
  4118. configure: selectedItem,
  4119. };
  4120. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4121. // // if (data.errno == 0) {
  4122. // var file = new Blob([data], {
  4123. // // 'Accept': '*/*'
  4124. // type: 'application/octet-stream'
  4125. // // type: 'application/vnd.ms-excel'
  4126. // });
  4127. // //trick to download store a file having its URL
  4128. // var fileURL = URL.createObjectURL(file);
  4129. // var a = document.createElement('a');
  4130. // a.href = fileURL;
  4131. // a.target = '_blank';
  4132. // a.download = "资产导入模版.xlsx";
  4133. // document.body.appendChild(a);
  4134. // a.click();
  4135. // // }
  4136. // })
  4137. $http({
  4138. url: api_configure_data
  4139. .downModels("export/cmdb", fildat)
  4140. .getRequestedUrl(),
  4141. method: "POST",
  4142. data: JSON.stringify(fildat),
  4143. headers: {
  4144. // 'Content-type': 'application/xls',
  4145. Accept: "*/*",
  4146. },
  4147. responseType: "arraybuffer",
  4148. })
  4149. .success(function (data, status, headers, config) {
  4150. $rootScope.isMask = false;
  4151. var file = new Blob([data], {
  4152. type: "application/octet-stream",
  4153. // type : 'application/vnd.ms-excel'
  4154. });
  4155. //trick to download store a file having its URL
  4156. var fileURL = URL.createObjectURL(file);
  4157. var a = document.createElement("a");
  4158. a.href = fileURL;
  4159. a.target = "_blank";
  4160. a.download = "资产导入模版.xlsx";
  4161. document.body.appendChild(a);
  4162. a.click();
  4163. })
  4164. .error(function (data, status, headers, config) {
  4165. // console.log(data);
  4166. $rootScope.isMask = false;
  4167. });
  4168. // break;
  4169. // }
  4170. // }
  4171. // }
  4172. // })
  4173. } else {
  4174. SweetAlert.swal(
  4175. {
  4176. title: "未选择资产分类!",
  4177. text: "请选择资产分类",
  4178. type: "error",
  4179. },
  4180. function () {
  4181. $rootScope.isMask = false;
  4182. }
  4183. );
  4184. }
  4185. // }
  4186. });
  4187. };
  4188. $scope.wrongdata = [];
  4189. var uploader = ($scope.uploader =
  4190. $scope.options.templateOptions.fileUploader);
  4191. var uploadermeans = ($scope.uploadermeans =
  4192. $scope.options.templateOptions.fileUploadermeans);
  4193. $scope.importopen = function () {
  4194. //导入触发事件
  4195. if (angular.isUndefined($scope.form.dropState)) {
  4196. $scope.form.dropState = false;
  4197. }
  4198. //附件上传数据
  4199. //$scope.options.templateOptions.uploader();
  4200. // FILTERS
  4201. uploader.filters.push({
  4202. name: "customFilter",
  4203. fn: function (item /*{File|FileLikeObject}*/, options) {
  4204. return this.queue.length < 2;
  4205. },
  4206. });
  4207. // CALLBACKS
  4208. uploader.onWhenAddingFileFailed = function (
  4209. item /*{File|FileLikeObject}*/,
  4210. filter,
  4211. options
  4212. ) {
  4213. console.info("onWhenAddingFileFailed", item, filter, options);
  4214. };
  4215. uploader.onAfterAddingFile = function (fileItem) {
  4216. console.info("onAfterAddingFile", fileItem);
  4217. };
  4218. uploader.onAfterAddingAll = function (addedFileItems) {
  4219. console.info("onAfterAddingAll", addedFileItems);
  4220. };
  4221. uploader.onBeforeUploadItem = function (item) {
  4222. console.info("onBeforeUploadItem", item);
  4223. };
  4224. uploader.onProgressItem = function (fileItem, progress) {
  4225. console.info("onProgressItem", fileItem, progress);
  4226. };
  4227. uploader.onProgressAll = function (progress) {
  4228. console.info("onProgressAll", progress);
  4229. };
  4230. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4231. // console.info('onSuccessItem', fileItem, response, status, headers);
  4232. // };
  4233. uploader.onErrorItem = function (
  4234. fileItem,
  4235. response,
  4236. status,
  4237. headers
  4238. ) {
  4239. console.info("onErrorItem", fileItem, response, status, headers);
  4240. };
  4241. uploader.onCancelItem = function (
  4242. fileItem,
  4243. response,
  4244. status,
  4245. headers
  4246. ) {
  4247. console.info("onCancelItem", fileItem, response, status, headers);
  4248. };
  4249. uploader.onCompleteItem = function (
  4250. fileItem,
  4251. response,
  4252. status,
  4253. headers
  4254. ) {
  4255. console.info("onCompleteItem", fileItem, response, status, headers);
  4256. };
  4257. uploader.onCompleteAll = function () {
  4258. console.info("onCompleteAll");
  4259. };
  4260. };
  4261. // $scope.importnext = function() {
  4262. // $scope.state = 2;
  4263. // event.preventDefault();
  4264. // }
  4265. $scope.importnext = function () {
  4266. event.preventDefault();
  4267. // $rootScope.isMask = true;
  4268. $rootScope.loading = true;
  4269. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4270. uploader.onBeforeUploadItem = function (item) {
  4271. angular.extend(item.headers, $rootScope.getSession());
  4272. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4273. // if (item.index > 1) {
  4274. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4275. // }
  4276. // item.index = 1;
  4277. item.formData = [
  4278. {
  4279. filename: item.file.name,
  4280. },
  4281. ];
  4282. console.info("onBeforeUploadItem", item);
  4283. };
  4284. uploader.uploadAll();
  4285. uploader.onSuccessItem = function (
  4286. fileItem,
  4287. response,
  4288. status,
  4289. headers
  4290. ) {
  4291. if (response.status == 200) {
  4292. $scope.wrongdata = [];
  4293. $rootScope.loading = false;
  4294. if (response.abnormal) {
  4295. $scope.state = 2;
  4296. angular.forEach(response.msg, function (item) {
  4297. $scope.wrongdata.push({
  4298. name: item.assetName,
  4299. line: item.row,
  4300. cmdbname: item.name,
  4301. errotip: [
  4302. {
  4303. label: item.msg,
  4304. },
  4305. ],
  4306. });
  4307. });
  4308. } else {
  4309. $scope.state = 3;
  4310. }
  4311. } else {
  4312. $rootScope.loading = false;
  4313. $scope.state = 2;
  4314. }
  4315. };
  4316. };
  4317. $scope.clearItems = function () {
  4318. //重新选择文件时,清空队列,达到覆盖文件的效果
  4319. uploader.clearQueue();
  4320. // uploader.remove();
  4321. // uploader.cancel();
  4322. // uploader.onChange();
  4323. };
  4324. uploader.onAfterAddingFile = function (fileItem) {
  4325. $scope.fileItem = fileItem._file;
  4326. // $scope.$apply();
  4327. // $scope.fileItem = filenum;
  4328. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4329. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4330. $scope.filenum++;
  4331. };
  4332. uploader.onSuccessItem = function (
  4333. fileItem,
  4334. response,
  4335. status,
  4336. headers
  4337. ) {
  4338. $scope.uploadStatus = true; //上传成功则把状态改为true
  4339. // alert(response.path);
  4340. };
  4341. $scope.importnext = function () {
  4342. event.preventDefault();
  4343. // uploader.onChange();
  4344. $rootScope.loading = true;
  4345. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4346. uploader.onBeforeUploadItem = function (item) {
  4347. angular.extend(item.headers, $rootScope.getSession());
  4348. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4349. // if (item.index > 1) {
  4350. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4351. // }
  4352. // item.index = 1;
  4353. item.formData = [
  4354. {
  4355. filename: item.file.name,
  4356. },
  4357. ];
  4358. console.info("onBeforeUploadItem", item);
  4359. };
  4360. uploader.uploadAll();
  4361. uploader.onSuccessItem = function (
  4362. fileItem,
  4363. response,
  4364. status,
  4365. headers
  4366. ) {
  4367. if (response.status == 200) {
  4368. $scope.wrongdata = [];
  4369. // uploader.queue = [];
  4370. $rootScope.loading = false;
  4371. if (response.abnormal) {
  4372. $scope.state = 2;
  4373. uploader.clearQueue();
  4374. angular.forEach(response.msg, function (item) {
  4375. $scope.wrongdata.push({
  4376. name: item.assetName,
  4377. line: item.row,
  4378. cmdbname: item.name,
  4379. errotip: [
  4380. {
  4381. label: item.msg,
  4382. },
  4383. ],
  4384. });
  4385. });
  4386. } else {
  4387. $scope.state = 3;
  4388. }
  4389. } else {
  4390. uploader.clearQueue();
  4391. $rootScope.loading = false;
  4392. $scope.state = 2;
  4393. }
  4394. };
  4395. };
  4396. var setAllInactive = function () {
  4397. angular.forEach($scope.workspaces, function (workspace) {
  4398. workspace.active = false;
  4399. });
  4400. };
  4401. //添加
  4402. var addNewWorkspace = function (name, contentUrl) {
  4403. var id = $scope.workspaces.length + 1;
  4404. $scope.workspaces.push({
  4405. id: id,
  4406. name: name,
  4407. active: true,
  4408. contentUrl: "main/html/content.html",
  4409. });
  4410. };
  4411. //关闭
  4412. $scope.closeopen = function (closedata) {
  4413. event.preventDefault();
  4414. angular.forEach($scope.workspaces, function (item, index) {
  4415. if (closedata.id == item.id) {
  4416. if (closedata.id == 1) {
  4417. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4418. } else {
  4419. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4420. }
  4421. $scope.workspaces.splice(index, 1);
  4422. }
  4423. });
  4424. };
  4425. // $scope.workspaces = [
  4426. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4427. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4428. // ];
  4429. $scope.addWorkspace = function (contentUrl, name) {
  4430. setAllInactive();
  4431. addNewWorkspace(name, contentUrl);
  4432. };
  4433. // $rootScope.addWorkspace = $scope.addWorkspace;
  4434. $scope.close = function (idNumber) {
  4435. var index = 0; //记录当前元素下标
  4436. angular.forEach($scope.workspaces, function (workspace) {
  4437. if (workspace.id === idNumber) {
  4438. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4439. }
  4440. index++;
  4441. });
  4442. };
  4443. //grid2
  4444. $scope.langs = i18nService.getAllLangs();
  4445. $scope.lang = "zh-cn";
  4446. i18nService.setCurrentLang($scope.lang);
  4447. $scope.gridOptions2 = {};
  4448. $scope.gridOptions2.data = "myData3";
  4449. $scope.gridOptions2.enableColumnResizing = true;
  4450. $scope.gridOptions2.enableFiltering = false;
  4451. $scope.gridOptions2.enableGridMenu = false;
  4452. $scope.gridOptions2.showGridFooter = true;
  4453. $scope.gridOptions2.showColumnFooter = false;
  4454. $scope.gridOptions2.fastWatch = true;
  4455. $scope.gridOptions2.useExternalFiltering = true;
  4456. $scope.gridOptions2.useExternalPagination = true;
  4457. $scope.gridOptions2.paginationPageSizes = [10];
  4458. $scope.gridOptions2.paginationPageSize = 10;
  4459. $scope.gridOptions2.multiSelect = false;
  4460. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4461. $scope.gridOptions2.columnDefs = [
  4462. {
  4463. name: "item",
  4464. displayName: "序号",
  4465. width: 120,
  4466. },
  4467. {
  4468. name: "name",
  4469. displayName: "耗材名称",
  4470. width: 80,
  4471. enableFiltering: false,
  4472. },
  4473. {
  4474. name: "model",
  4475. displayName: "品牌/型号",
  4476. width: 100,
  4477. enableFiltering: false,
  4478. },
  4479. {
  4480. name: "Specifications",
  4481. displayName: "规格",
  4482. width: 150,
  4483. enableFiltering: false,
  4484. },
  4485. {
  4486. name: "sum",
  4487. displayName: "数量",
  4488. enableFiltering: false,
  4489. },
  4490. {
  4491. name: "操作",
  4492. cellTemplate:
  4493. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4494. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4495. "</div></div>",
  4496. enableFiltering: false,
  4497. },
  4498. ];
  4499. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4500. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4501. $scope.myData3all = JSON.parse(
  4502. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4503. );
  4504. for (var i = 0; i < $scope.myData3all.length; i++) {
  4505. $scope.myData3all[i]["item"] =
  4506. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4507. }
  4508. // $scope.model.consumables = $scope.myDataone;
  4509. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4510. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4511. $scope.model.applicationForm.consumables = $scope.myData3all;
  4512. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4513. $scope.options.templateOptions.getpush({
  4514. hao: true,
  4515. gu: true,
  4516. });
  4517. } else {
  4518. $scope.options.templateOptions.getpush({
  4519. hao: true,
  4520. });
  4521. }
  4522. } else {
  4523. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4524. $scope.options.templateOptions.getpush({
  4525. gu: true,
  4526. });
  4527. }
  4528. }
  4529. }
  4530. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4531. $scope.changecai = function (item) {
  4532. event.preventDefault();
  4533. var modalInstance = $modal.open({
  4534. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4535. controller: function ($scope, $modalInstance) {
  4536. $scope.title = "修改耗材数量";
  4537. $scope.consumptive = angular.copy(item);
  4538. $scope.ok = function () {
  4539. $modalInstance.close($scope.consumptive);
  4540. };
  4541. $scope.cancel = function () {
  4542. $modalInstance.dismiss("cancel");
  4543. };
  4544. },
  4545. size: "sm",
  4546. });
  4547. modalInstance.result.then(function (selectedItem) {
  4548. // angular.forEach($scope.myData3, function(items, index) {
  4549. // if (items.id == selectedItem.id) {
  4550. // $scope.myData3[index] = selectedItem;
  4551. // }
  4552. // })
  4553. // // $scope.myData3.push(selectedItem);
  4554. // $scope.model.applicationForm.consumables = $scope.myData3;
  4555. angular.forEach($scope.myData3all, function (items, index) {
  4556. if (
  4557. items.modelid == selectedItem.modelid &&
  4558. items.nameid == selectedItem.nameid &&
  4559. items.Specificationsid == selectedItem.Specificationsid
  4560. ) {
  4561. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4562. angular.extend($scope.myData3all[index], selectedItem);
  4563. }
  4564. });
  4565. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4566. $scope.myData3 = $scope.interceptMydata(
  4567. $scope.myData3all,
  4568. $scope.memoryfilterDatahao.idx,
  4569. 10
  4570. );
  4571. $scope.model.applicationForm.consumables = $scope.myData3all;
  4572. });
  4573. };
  4574. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4575. $scope.gridApi = gridApi;
  4576. gridApi.pagination.on.paginationChanged(
  4577. $scope,
  4578. function (newPage, pageSize) {
  4579. // var filtersData = $scope.memoryfilterDatahao;
  4580. // filtersData.idx = newPage - 1;
  4581. // filtersData.sum = pageSize;
  4582. // $scope.loadData(filtersData);
  4583. $scope.memoryfilterDatahao.idx = newPage - 1;
  4584. $scope.memoryfilterDatahao.sum = pageSize;
  4585. $scope.myData3 = $scope.interceptMydata(
  4586. $scope.myData3all,
  4587. $scope.memoryfilterDatahao.idx,
  4588. 10
  4589. );
  4590. }
  4591. );
  4592. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4593. $scope.selected.items = data.entity;
  4594. //console.log(data);
  4595. });
  4596. gridApi.selection.on.rowSelectionChangedBatch(
  4597. $scope,
  4598. function (data) {
  4599. $scope.selected.items = data.entity;
  4600. //console.log(data);
  4601. }
  4602. );
  4603. gridApi.core.on.filterChanged($scope, function () {
  4604. var grid = this.grid;
  4605. var filtersData = {
  4606. idx: 0,
  4607. sum: 10,
  4608. };
  4609. $scope.memoryfilterDatahao = filtersData;
  4610. // $scope.loadData(filtersData);
  4611. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4612. // $scope.memoryfilterDatahao.sum = pageSize;
  4613. $scope.myData3 = $scope.interceptMydata(
  4614. $scope.myData3all,
  4615. $scope.memoryfilterDatahao.idx,
  4616. 10
  4617. );
  4618. });
  4619. };
  4620. $scope.haocaiopen = function (items) {
  4621. event.preventDefault();
  4622. var modalInstance = $modal.open({
  4623. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4624. controller: function ($scope, $modalInstance, SweetAlert) {
  4625. $scope.consumptive = {};
  4626. $scope.title = "新增耗材";
  4627. if (items.name) {
  4628. $scope.consumptive.name = items.name.name;
  4629. }
  4630. $scope.clearNoNum = function (obj, attr) {
  4631. //先把非数字的都替换掉,除了数字和.
  4632. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4633. //必须保证第一个为数字而不是.
  4634. obj[attr] = obj[attr].replace(/^\./g, "");
  4635. //保证只有出现一个.而没有多个.
  4636. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4637. //保证.只出现一次,而不能出现两次以上
  4638. obj[attr] = obj[attr]
  4639. .replace(".", "$#$")
  4640. .replace(/\./g, "")
  4641. .replace("$#$", ".");
  4642. //小于最大值
  4643. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4644. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4645. // obj[attr] = '';
  4646. // }
  4647. };
  4648. $scope.ok = function (item) {
  4649. // if (item.name && item.model && item.Specifications && item.sum) {
  4650. if (
  4651. item.name &&
  4652. item.model &&
  4653. JSON.stringify(item.model) != "{}" &&
  4654. item.Specifications &&
  4655. JSON.stringify(item.Specifications) != "{}" &&
  4656. item.sum
  4657. ) {
  4658. $modalInstance.close(item);
  4659. } else {
  4660. SweetAlert.swal({
  4661. title: "数据填写不完整!",
  4662. text: "请检查数据然后提交!",
  4663. type: "error",
  4664. });
  4665. }
  4666. };
  4667. $scope.cancel = function () {
  4668. $modalInstance.dismiss("cancel");
  4669. };
  4670. },
  4671. size: "sm",
  4672. resolve: {
  4673. SweetAlert: function () {
  4674. return SweetAlert;
  4675. },
  4676. },
  4677. });
  4678. modalInstance.result.then(function (selectedItem) {
  4679. api_sysinfo
  4680. .addData("dictionaryTree", {
  4681. // "type": "list",
  4682. key: "haocaifenlei",
  4683. name: selectedItem.name,
  4684. parent: selectedItem.id,
  4685. value: selectedItem.name,
  4686. deleted: false,
  4687. level: 1,
  4688. })
  4689. .then(function (data) {
  4690. // $scope.haocainame.name = data.list;
  4691. api_sysinfo
  4692. .addData("dictionaryTree", {
  4693. // "type": "list",
  4694. key: "pinpai",
  4695. name: selectedItem.model,
  4696. parent: data.id,
  4697. value: selectedItem.model,
  4698. deleted: false,
  4699. level: 2,
  4700. })
  4701. .then(function (data) {
  4702. // $scope.haocainame = data.list;
  4703. });
  4704. api_sysinfo
  4705. .addData({
  4706. // "type": "list",
  4707. key: "guige",
  4708. name: selectedItem.Specifications,
  4709. parent: data.id,
  4710. value: selectedItem.Specifications,
  4711. deleted: false,
  4712. level: 2,
  4713. })
  4714. .then(function (data) {
  4715. // $scope.haocainame = data.list;
  4716. });
  4717. });
  4718. // $scope.myData3.push(selectedItem);
  4719. // for (var i = 0; i < $scope.myData3.length; i++) {
  4720. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4721. // }
  4722. // $scope.model.applicationForm.consumables = $scope.myData3;
  4723. $scope.myData3all.push(selectedItem);
  4724. for (var i = 0; i < $scope.myData3all.length; i++) {
  4725. $scope.myData3all[i]["item"] = i + 1;
  4726. }
  4727. // $scope.model.consumables = $scope.myDataone;
  4728. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4729. $scope.myData3 = $scope.interceptMydata(
  4730. $scope.myData3all,
  4731. $scope.memoryfilterDatahao.idx,
  4732. 10
  4733. );
  4734. $scope.model.applicationForm.consumables = $scope.myData3all;
  4735. });
  4736. };
  4737. $scope.haocaiadd = function () {
  4738. event.preventDefault();
  4739. var modalInstance = $modal.open({
  4740. templateUrl:
  4741. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4742. controller: function (
  4743. $scope,
  4744. scope,
  4745. $modalInstance,
  4746. api_wechatfile,
  4747. SweetAlert,
  4748. api_cmdb3
  4749. ) {
  4750. $scope.haocainame = [];
  4751. $scope.pinpai = [];
  4752. $scope.guige = [];
  4753. $scope.consumptive = {};
  4754. $scope.consumpall = {};
  4755. $scope.title = "添加耗材";
  4756. api_wechatfile
  4757. .getDictionary({
  4758. key: "haocaifenlei",
  4759. type: "tree",
  4760. })
  4761. .then(function (data) {
  4762. $scope.haocainame = data;
  4763. });
  4764. $scope.clearNoNum = function (obj, attr) {
  4765. //先把非数字的都替换掉,除了数字和.
  4766. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4767. //必须保证第一个为数字而不是.
  4768. obj[attr] = obj[attr].replace(/^\./g, "");
  4769. //保证只有出现一个.而没有多个.
  4770. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4771. //保证.只出现一次,而不能出现两次以上
  4772. obj[attr] = obj[attr]
  4773. .replace(".", "$#$")
  4774. .replace(/\./g, "")
  4775. .replace("$#$", ".");
  4776. //小于最大值
  4777. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4778. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4779. // obj[attr] = '';
  4780. // }
  4781. };
  4782. $scope.onChange = function (parent) {
  4783. $scope.consumptive.model = {};
  4784. $scope.consumptive.Specifications = {};
  4785. api_wechatfile
  4786. .getDictionaryForList({
  4787. key: "pinpai",
  4788. parent: parent.id,
  4789. })
  4790. .then(function (data) {
  4791. $scope.pinpai = data;
  4792. });
  4793. api_wechatfile
  4794. .getDictionaryForList({
  4795. key: "guige",
  4796. parent: parent.id,
  4797. })
  4798. .then(function (data) {
  4799. $scope.guige = data;
  4800. });
  4801. };
  4802. $scope.addhaocai = function () {
  4803. $modalInstance.dismiss("cancel");
  4804. scope.haocaiopen($scope.consumptive);
  4805. };
  4806. $scope.ok = function (item) {
  4807. var items = {};
  4808. var submittrue = true;
  4809. if (
  4810. item.name &&
  4811. item.model &&
  4812. JSON.stringify(item.model) != "{}" &&
  4813. item.Specifications &&
  4814. JSON.stringify(item.Specifications) != "{}" &&
  4815. item.sum
  4816. ) {
  4817. items = {
  4818. modelid: item.model.id,
  4819. nameid: item.name.id,
  4820. Specificationsid: item.Specifications.id,
  4821. name: item.name.name,
  4822. model: item.model.name,
  4823. Specifications: item.Specifications.name,
  4824. sum: item.sum,
  4825. };
  4826. angular.forEach(scope.myData3all, function (itemsdata) {
  4827. if (
  4828. item.model.id == itemsdata.modelid &&
  4829. item.name.id == itemsdata.nameid &&
  4830. item.Specifications.id == itemsdata.Specificationsid
  4831. ) {
  4832. submittrue = false;
  4833. }
  4834. });
  4835. if (submittrue) {
  4836. $modalInstance.close(items);
  4837. } else {
  4838. SweetAlert.swal({
  4839. title: "该耗材已有添加",
  4840. text: "请检查数据然后提交!",
  4841. type: "error",
  4842. });
  4843. }
  4844. } else {
  4845. SweetAlert.swal({
  4846. title: "数据填写不完整!",
  4847. text: "请检查数据然后提交!",
  4848. type: "error",
  4849. });
  4850. }
  4851. // var isold = false;
  4852. // if (item.name && item.model && item.Specifications && item.sum) {
  4853. // for (var i = 0; i < scope.myData3all.length; i++) {
  4854. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4855. // isold = true;
  4856. // }
  4857. // }
  4858. // if (isold) {
  4859. // SweetAlert.swal({
  4860. // title: "该耗材已添加!",
  4861. // text: "请不要重复添加耗材!",
  4862. // type: "error"
  4863. // });
  4864. // } else {
  4865. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4866. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4867. // $scope.consumpall.sum = item.sum;
  4868. // delete $scope.consumpall.brandModel;
  4869. // delete $scope.consumpall.specification;
  4870. // $modalInstance.close($scope.consumpall);
  4871. // }
  4872. // } else {
  4873. // SweetAlert.swal({
  4874. // title: "数据填写不完整!",
  4875. // text: "请检查数据然后提交!",
  4876. // type: "error"
  4877. // });
  4878. // }
  4879. };
  4880. $scope.cancel = function () {
  4881. $modalInstance.dismiss("cancel");
  4882. };
  4883. },
  4884. size: "sm",
  4885. resolve: {
  4886. scope: function () {
  4887. return $scope;
  4888. },
  4889. },
  4890. });
  4891. modalInstance.result.then(function (selectedItem) {
  4892. $scope.myData3all.push(selectedItem);
  4893. for (var i = 0; i < $scope.myData3all.length; i++) {
  4894. $scope.myData3all[i]["item"] = i + 1;
  4895. }
  4896. // $scope.model.consumables = $scope.myDataone;
  4897. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4898. $scope.myData3 = $scope.interceptMydata(
  4899. $scope.myData3all,
  4900. $scope.memoryfilterDatahao.idx,
  4901. 10
  4902. );
  4903. $scope.model.applicationForm.consumables = $scope.myData3all;
  4904. });
  4905. };
  4906. $scope.onDblClick = function (data, event) {
  4907. $scope.selectButtonClick(data, event);
  4908. };
  4909. // $scope.memoryfilterDatahao = {
  4910. // "idx": 0,
  4911. // "sum": 10,
  4912. // }
  4913. // $scope.loadData = function(filterData) {};
  4914. // $scope.title = title;
  4915. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4916. $scope.options.templateOptions.transform(
  4917. $scope.options,
  4918. $rootScope,
  4919. $scope
  4920. );
  4921. }
  4922. },
  4923. ],
  4924. });
  4925. //归还设备耗材tab
  4926. formlyConfigProvider.setType({
  4927. name: "ui-cmdbreturntab",
  4928. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4929. wrapper: ["bootstrapHasError"],
  4930. defaultOptions: function (options, $scope) {
  4931. return {
  4932. templateOptions: {
  4933. // checkform: function(options) {
  4934. // if (options.model.requester) {
  4935. // options.value(options.model.requester);
  4936. // }
  4937. // },
  4938. },
  4939. };
  4940. },
  4941. controller: [
  4942. "$scope",
  4943. "$modal",
  4944. "api_user_data",
  4945. "i18nService",
  4946. "api_wechatfile",
  4947. "api_cmdb3",
  4948. function (
  4949. $scope,
  4950. $modal,
  4951. api_user_data,
  4952. i18nService,
  4953. api_wechatfile,
  4954. api_cmdb3
  4955. ) {
  4956. var setAllInactive = function () {
  4957. angular.forEach($scope.workspaces, function (workspace) {
  4958. workspace.active = false;
  4959. });
  4960. };
  4961. $scope.memoryfilterData = {
  4962. idx: 0,
  4963. sum: 10,
  4964. };
  4965. //添加
  4966. var addNewWorkspace = function (name, contentUrl) {
  4967. var id = $scope.workspaces.length + 1;
  4968. $scope.workspaces.push({
  4969. id: id,
  4970. name: name,
  4971. active: true,
  4972. contentUrl: "main/html/content.html",
  4973. });
  4974. };
  4975. $scope.workspaces = [
  4976. {
  4977. id: 1,
  4978. name: "归还设备",
  4979. active: true,
  4980. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4981. },
  4982. {
  4983. id: 2,
  4984. name: "归还耗材",
  4985. active: true,
  4986. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4987. },
  4988. ];
  4989. $scope.addWorkspace = function (contentUrl, name) {
  4990. setAllInactive();
  4991. addNewWorkspace(name, contentUrl);
  4992. };
  4993. // $rootScope.addWorkspace = $scope.addWorkspace;
  4994. $scope.close = function (idNumber) {
  4995. var index = 0; //记录当前元素下标
  4996. angular.forEach($scope.workspaces, function (workspace) {
  4997. if (workspace.id === idNumber) {
  4998. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4999. }
  5000. index++;
  5001. });
  5002. };
  5003. $scope.memoryfilterDataguishe = {
  5004. idx: 0,
  5005. sum: 10,
  5006. };
  5007. //grid1
  5008. $scope.langs = i18nService.getAllLangs();
  5009. $scope.lang = "zh-cn";
  5010. i18nService.setCurrentLang($scope.lang);
  5011. $scope.gridOptions1 = {};
  5012. $scope.gridOptions1.data = "myData1";
  5013. $scope.gridOptions1.enableColumnResizing = true;
  5014. $scope.gridOptions1.enableFiltering = false;
  5015. $scope.gridOptions1.enableGridMenu = false;
  5016. $scope.gridOptions1.showGridFooter = true;
  5017. $scope.gridOptions1.showColumnFooter = false;
  5018. $scope.gridOptions1.fastWatch = true;
  5019. $scope.gridOptions1.useExternalFiltering = true;
  5020. $scope.gridOptions1.useExternalPagination = true;
  5021. $scope.gridOptions1.paginationPageSizes = [10];
  5022. $scope.gridOptions1.paginationPageSize = 10;
  5023. $scope.gridOptions1.multiSelect = false;
  5024. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5025. $scope.gridOptions1.columnDefs = [
  5026. {
  5027. name: "item",
  5028. displayName: "序号",
  5029. width: 120,
  5030. },
  5031. {
  5032. name: "props.hw_cifilterClassic",
  5033. displayName: "设备类型",
  5034. width: 150,
  5035. enableFiltering: false,
  5036. },
  5037. {
  5038. name: "props.hw_mingcheng",
  5039. displayName: "设备名称",
  5040. width: 180,
  5041. enableFiltering: false,
  5042. },
  5043. {
  5044. name: "uuid",
  5045. displayName: "设备编号",
  5046. width: 180,
  5047. enableFiltering: false,
  5048. },
  5049. {
  5050. name: "props.hw_state",
  5051. width: 150,
  5052. displayName: "状态",
  5053. enableFiltering: false,
  5054. },
  5055. {
  5056. name: "操作",
  5057. cellTemplate:
  5058. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5059. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5060. "</div></div>",
  5061. enableFiltering: false,
  5062. },
  5063. ];
  5064. // $scope.selectButtonClick
  5065. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5066. $scope.gridApi = gridApi;
  5067. gridApi.pagination.on.paginationChanged(
  5068. $scope,
  5069. function (newPage, pageSize) {
  5070. // var filtersData = $scope.memoryfilterData;
  5071. // filtersData.idx = newPage - 1;
  5072. // filtersData.sum = pageSize;
  5073. // $scope.loadData(filtersData);
  5074. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5075. $scope.memoryfilterDataguishe.sum = pageSize;
  5076. $scope.myData1 = $scope.interceptMydata(
  5077. $scope.myData2all,
  5078. $scope.memoryfilterDataguishe.idx,
  5079. 10
  5080. );
  5081. }
  5082. );
  5083. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5084. $scope.selected.items = data.entity;
  5085. //console.log(data);
  5086. });
  5087. gridApi.selection.on.rowSelectionChangedBatch(
  5088. $scope,
  5089. function (data) {
  5090. $scope.selected.items = data.entity;
  5091. //console.log(data);
  5092. }
  5093. );
  5094. gridApi.core.on.filterChanged($scope, function () {
  5095. // var grid = this.grid;
  5096. // var filtersData = {
  5097. // idx: 0,
  5098. // sum: 20,
  5099. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5100. // };
  5101. // angular.forEach(grid.columns, function(item) {
  5102. // if (item.enableFiltering) {
  5103. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5104. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5105. // if (angular.isUndefined(filtersData['user'])) {
  5106. // filtersData['user'] = {};
  5107. // }
  5108. // filtersData['user'][item.field] = item.filters[0].term;
  5109. // }
  5110. // }
  5111. // });
  5112. // $scope.memoryfilterData = filtersData;
  5113. // $scope.loadData(filtersData);
  5114. });
  5115. };
  5116. $scope.changegu = function (item) {
  5117. event.preventDefault();
  5118. var modalInstance = $modal.open({
  5119. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5120. controller: function ($scope, $modalInstance) {
  5121. $scope.title = "修改设备状态";
  5122. $scope.hw_state = {};
  5123. if (item.status) {
  5124. $scope.hw_state.name = item.hw_state;
  5125. }
  5126. // $scope.consumptive = item;
  5127. $scope.stateshe = [
  5128. {
  5129. id: 2,
  5130. name: "在库",
  5131. },
  5132. {
  5133. id: 4,
  5134. name: "报修",
  5135. },
  5136. {
  5137. id: 3,
  5138. name: "报废",
  5139. },
  5140. ];
  5141. $scope.ok = function (item) {
  5142. $modalInstance.close($scope.hw_state);
  5143. };
  5144. $scope.cancel = function () {
  5145. $modalInstance.dismiss("cancel");
  5146. };
  5147. },
  5148. size: "sm",
  5149. });
  5150. modalInstance.result.then(function (selectedItem) {
  5151. angular.forEach($scope.myData1, function (items, index) {
  5152. if (items.id == item.id) {
  5153. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5154. }
  5155. });
  5156. $scope.model.assets = $scope.myData1;
  5157. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5158. $scope.model.assets;
  5159. });
  5160. };
  5161. $scope.onDblClick = function (data, event) {
  5162. $scope.selectButtonClick(data, event);
  5163. };
  5164. $scope.memoryfilterData = {
  5165. idx: 0,
  5166. sum: 10,
  5167. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5168. };
  5169. // $scope.myData = {};
  5170. $scope.loadData = function (filterData) { };
  5171. // $scope.title = title;
  5172. $scope.loadData({
  5173. idx: 0,
  5174. sum: 10,
  5175. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5176. });
  5177. $scope.selected = {
  5178. items: [],
  5179. };
  5180. $scope.myData2 = [];
  5181. $scope.consumptive = {};
  5182. $scope.myDataguibeiall = [];
  5183. $scope.haocaiopen = function (items) {
  5184. event.preventDefault();
  5185. var modalInstance = $modal.open({
  5186. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5187. controller: function (
  5188. $scope,
  5189. $modalInstance,
  5190. SweetAlert,
  5191. api_wechatfile,
  5192. api_sysinfo
  5193. ) {
  5194. $scope.consumptive = {};
  5195. $scope.title = "新增耗材";
  5196. if (items.name) {
  5197. $scope.consumptive.name = items.name.name;
  5198. }
  5199. $scope.ok = function (item) {
  5200. if (
  5201. item.name &&
  5202. item.model &&
  5203. JSON.stringify(item.model) != "{}" &&
  5204. item.Specifications &&
  5205. JSON.stringify(item.Specifications) != "{}" &&
  5206. item.sum
  5207. ) {
  5208. $modalInstance.close(item);
  5209. } else {
  5210. SweetAlert.swal({
  5211. title: "数据填写不完整!",
  5212. text: "请检查数据然后提交!",
  5213. type: "error",
  5214. });
  5215. }
  5216. };
  5217. $scope.cancel = function () {
  5218. $modalInstance.dismiss("cancel");
  5219. };
  5220. },
  5221. size: "sm",
  5222. });
  5223. modalInstance.result.then(function (selectedItem) {
  5224. api_sysinfo
  5225. .addData({
  5226. type: "list",
  5227. key: "haocaifenlei",
  5228. name: selectedItem.name,
  5229. parent: selectedItem.id,
  5230. value: "1",
  5231. })
  5232. .then(function (data) {
  5233. // $scope.haocainame.name = data.list;
  5234. api_wechatfile
  5235. .addDictionary({
  5236. type: "list",
  5237. key: "pinpai",
  5238. name: selectedItem.model,
  5239. parent: data.id,
  5240. value: "1",
  5241. })
  5242. .then(function (data) {
  5243. // $scope.haocainame = data.list;
  5244. });
  5245. api_wechatfile
  5246. .addDictionary({
  5247. type: "list",
  5248. key: "guige",
  5249. name: selectedItem.Specifications,
  5250. parent: data.id,
  5251. value: "1",
  5252. })
  5253. .then(function (data) {
  5254. // $scope.haocainame = data.list;
  5255. });
  5256. });
  5257. $scope.myData2.push(selectedItem);
  5258. for (var i = 0; i < $scope.myData2.length; i++) {
  5259. $scope.myData2[i]["item"] =
  5260. i + 1 + $scope.memoryfilterData.idx * 10;
  5261. }
  5262. // $scope.model.applicationForm.consumables = $scope.myData2;
  5263. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5264. if (items.id == selectedItem.id) {
  5265. $scope.myDataguibeiall.splice(index, 1);
  5266. }
  5267. });
  5268. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5269. $scope.model.consumables = $scope.myDataguibeiall;
  5270. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5271. $scope.model.consumables;
  5272. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5273. });
  5274. };
  5275. //grid2
  5276. $scope.langs = i18nService.getAllLangs();
  5277. $scope.lang = "zh-cn";
  5278. i18nService.setCurrentLang($scope.lang);
  5279. $scope.gridOptions2 = {};
  5280. $scope.gridOptions2.data = "myData2";
  5281. $scope.gridOptions2.enableColumnResizing = true;
  5282. $scope.gridOptions2.enableFiltering = false;
  5283. $scope.gridOptions2.enableGridMenu = false;
  5284. $scope.gridOptions2.showGridFooter = true;
  5285. $scope.gridOptions2.showColumnFooter = false;
  5286. $scope.gridOptions2.fastWatch = true;
  5287. $scope.gridOptions2.useExternalFiltering = true;
  5288. $scope.gridOptions2.useExternalPagination = true;
  5289. $scope.gridOptions2.paginationPageSizes = [10];
  5290. $scope.gridOptions2.paginationPageSize = 10;
  5291. $scope.gridOptions2.multiSelect = false;
  5292. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5293. $scope.modelcons = {};
  5294. $scope.modelass = {};
  5295. $scope.myData2all = [];
  5296. $scope.myData1all = [];
  5297. $scope.memoryfilterDatagui = {
  5298. idx: 0,
  5299. sum: 10,
  5300. };
  5301. setInterval(function () {
  5302. if ($scope.model.assets) {
  5303. if (
  5304. $scope.model.assets != $scope.modelass &&
  5305. typeof $scope.model.assets == "string"
  5306. ) {
  5307. $scope.modelass = $scope.model.assets;
  5308. if (JSON.stringify($scope.model.assets) == "{}") {
  5309. $scope.model.assets = [];
  5310. } else {
  5311. $scope.model.assets = JSON.parse($scope.model.assets);
  5312. }
  5313. // $scope.myData1 = $scope.model.assets;
  5314. // for (var i = 0; i < $scope.myData1.length; i++) {
  5315. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5316. // }
  5317. $scope.myData1all = $scope.model.assets;
  5318. for (var i = 0; i < $scope.myData1all.length; i++) {
  5319. $scope.myData1all[i]["item"] =
  5320. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5321. }
  5322. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5323. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5324. }
  5325. }
  5326. if ($scope.model.consumables) {
  5327. if (
  5328. $scope.model.consumables != $scope.modelcons &&
  5329. typeof $scope.model.consumables == "string"
  5330. ) {
  5331. $scope.modelass = $scope.model.consumables;
  5332. if (JSON.stringify($scope.model.consumables) == "{}") {
  5333. $scope.model.consumables = [];
  5334. } else {
  5335. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5336. }
  5337. // $scope.myData2 = $scope.model.consumables;
  5338. // for (var i = 0; i < $scope.myData2.length; i++) {
  5339. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5340. // }
  5341. $scope.myData2all = $scope.model.consumables;
  5342. for (var i = 0; i < $scope.myData2all.length; i++) {
  5343. $scope.myData2all[i]["item"] =
  5344. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5345. }
  5346. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5347. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5348. // $scope.model.consumables = $scope.myData2all;
  5349. }
  5350. }
  5351. }, 100);
  5352. $scope.gridOptions2.columnDefs = [
  5353. {
  5354. name: "item",
  5355. displayName: "序号",
  5356. width: 120,
  5357. },
  5358. {
  5359. name: "name",
  5360. displayName: "耗材名称",
  5361. width: 180,
  5362. enableFiltering: false,
  5363. },
  5364. {
  5365. name: "model",
  5366. displayName: "品牌/型号",
  5367. width: 180,
  5368. enableFiltering: false,
  5369. },
  5370. {
  5371. name: "Specifications",
  5372. displayName: "规格",
  5373. width: 150,
  5374. enableFiltering: false,
  5375. },
  5376. {
  5377. name: "sum",
  5378. width: 150,
  5379. displayName: "数量",
  5380. enableFiltering: false,
  5381. },
  5382. {
  5383. name: "操作",
  5384. cellTemplate:
  5385. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5386. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5387. "</div></div>",
  5388. enableFiltering: false,
  5389. },
  5390. ];
  5391. // $scope.selectButtonClick
  5392. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5393. $scope.gridApi = gridApi;
  5394. gridApi.pagination.on.paginationChanged(
  5395. $scope,
  5396. function (newPage, pageSize) {
  5397. // var filtersData = $scope.memoryfilterDatagui;
  5398. // filtersData.idx = newPage - 1;
  5399. // filtersData.sum = pageSize;
  5400. $scope.memoryfilterDatagui.idx = newPage - 1;
  5401. $scope.memoryfilterDatagui.sum = pageSize;
  5402. $scope.myData2 = $scope.interceptMydata(
  5403. $scope.myData2all,
  5404. $scope.memoryfilterDatagui.idx,
  5405. 10
  5406. );
  5407. }
  5408. );
  5409. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5410. $scope.selected.items = data.entity;
  5411. //console.log(data);
  5412. });
  5413. gridApi.selection.on.rowSelectionChangedBatch(
  5414. $scope,
  5415. function (data) {
  5416. $scope.selected.items = data.entity;
  5417. //console.log(data);
  5418. }
  5419. );
  5420. gridApi.core.on.filterChanged($scope, function () {
  5421. var grid = this.grid;
  5422. var filtersData = {
  5423. idx: 0,
  5424. sum: 10,
  5425. };
  5426. angular.forEach(grid.columns, function (item) {
  5427. if (item.enableFiltering) {
  5428. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5429. if (
  5430. angular.isDefined(item.filters[0].term) &&
  5431. item.filters[0].term != ""
  5432. ) {
  5433. if (angular.isUndefined(filtersData["user"])) {
  5434. filtersData["user"] = {};
  5435. }
  5436. filtersData["user"][item.field] = item.filters[0].term;
  5437. }
  5438. }
  5439. });
  5440. $scope.memoryfilterData = filtersData;
  5441. $scope.loadData(filtersData);
  5442. });
  5443. };
  5444. $scope.changecai = function (item) {
  5445. event.preventDefault();
  5446. var modalInstance = $modal.open({
  5447. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5448. controller: function ($scope, $modalInstance) {
  5449. $scope.title = "修改耗材数量";
  5450. $scope.consumptive = angular.copy(item);
  5451. // $scope.consumptive = item;
  5452. $scope.maxsum = item.inventoryNum;
  5453. $scope.clearNoNum = function (obj, attr) {
  5454. //先把非数字的都替换掉,除了数字和.
  5455. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5456. //必须保证第一个为数字而不是.
  5457. obj[attr] = obj[attr].replace(/^\./g, "");
  5458. //保证只有出现一个.而没有多个.
  5459. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5460. //保证.只出现一次,而不能出现两次以上
  5461. obj[attr] = obj[attr]
  5462. .replace(".", "$#$")
  5463. .replace(/\./g, "")
  5464. .replace("$#$", ".");
  5465. //小于最大值
  5466. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5467. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5468. // obj[attr] = '';
  5469. // }
  5470. };
  5471. $scope.ok = function () {
  5472. $modalInstance.close($scope.consumptive);
  5473. };
  5474. $scope.cancel = function () {
  5475. $modalInstance.dismiss("cancel");
  5476. };
  5477. },
  5478. size: "sm",
  5479. });
  5480. modalInstance.result.then(function (selectedItem) {
  5481. angular.forEach($scope.myData2all, function (items, index) {
  5482. // if (items.id == selectedItem.id) {
  5483. if (
  5484. items.modelid == selectedItem.modelid &&
  5485. items.nameid == selectedItem.nameid &&
  5486. items.Specificationsid == selectedItem.Specificationsid
  5487. ) {
  5488. angular.extend($scope.myData2all[index], selectedItem);
  5489. }
  5490. });
  5491. // $scope.model.consumables = $scope.myData2;
  5492. // $scope.myData2 = $scope.model.consumables;
  5493. // $scope.myData2all.push(selectedItem);
  5494. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5495. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5496. // }
  5497. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5498. $scope.myData2 = $scope.interceptMydata(
  5499. $scope.myData2all,
  5500. $scope.memoryfilterDatagui.idx,
  5501. 10
  5502. );
  5503. $scope.model.consumables = $scope.myData2all;
  5504. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5505. $scope.model.consumables;
  5506. });
  5507. };
  5508. $scope.interceptMydata = function (mydate, idx, sum) {
  5509. return mydate.slice(idx * sum, (idx + 1) * sum);
  5510. };
  5511. $scope.haocaiadd = function () {
  5512. event.preventDefault();
  5513. var modalInstance = $modal.open({
  5514. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5515. controller: function (
  5516. $scope,
  5517. scope,
  5518. $modalInstance,
  5519. api_wechatfile,
  5520. SweetAlert
  5521. ) {
  5522. $scope.haocainame = [];
  5523. $scope.pinpai = [];
  5524. $scope.guige = [];
  5525. $scope.consumptive = {};
  5526. $scope.consumptiveall = {};
  5527. $scope.title = "添加耗材";
  5528. api_wechatfile
  5529. .getDictionaryForList({
  5530. key: "haocaifenlei",
  5531. })
  5532. .then(function (data) {
  5533. $scope.haocainame = data;
  5534. });
  5535. $scope.clearNoNum = function (obj, attr) {
  5536. //先把非数字的都替换掉,除了数字和.
  5537. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5538. //必须保证第一个为数字而不是.
  5539. obj[attr] = obj[attr].replace(/^\./g, "");
  5540. //保证只有出现一个.而没有多个.
  5541. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5542. //保证.只出现一次,而不能出现两次以上
  5543. obj[attr] = obj[attr]
  5544. .replace(".", "$#$")
  5545. .replace(/\./g, "")
  5546. .replace("$#$", ".");
  5547. //小于最大值
  5548. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5549. alert(
  5550. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5551. );
  5552. obj[attr] = "";
  5553. }
  5554. };
  5555. $scope.onChange = function (parent) {
  5556. $scope.consumptive.model = {};
  5557. $scope.consumptive.Specifications = {};
  5558. api_wechatfile
  5559. .getDictionaryForList({
  5560. key: "pinpai",
  5561. parent: parent.id,
  5562. })
  5563. .then(function (data) {
  5564. $scope.pinpai = data;
  5565. });
  5566. api_wechatfile
  5567. .getDictionaryForList({
  5568. key: "guige",
  5569. parent: parent.id,
  5570. })
  5571. .then(function (data) {
  5572. $scope.guige = data;
  5573. });
  5574. };
  5575. // $scope.onChangesum = function(item) {
  5576. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5577. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5578. // $scope.consumptiveall = data1;
  5579. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5580. // // if (data.list && data.list.length != 0) {
  5581. // // var myData = data.list;
  5582. // // $scope.consumptiveall = myData[0];
  5583. // // $scope.maxsum = myData[0].inventoryNum;
  5584. // // } else if (data.list && data.list.length == 0) {
  5585. // // SweetAlert.swal({
  5586. // // title: "库存数据存在问题!",
  5587. // // text: "请检查库存数据!",
  5588. // // type: "error"
  5589. // // });
  5590. // // }
  5591. // // });
  5592. // }
  5593. // }
  5594. $scope.addhaocai = function () {
  5595. $modalInstance.dismiss("cancel");
  5596. scope.haocaiopen($scope.consumptive);
  5597. };
  5598. $scope.ok = function (item) {
  5599. var submittrue = true;
  5600. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5601. var data = {
  5602. modelid: item.model.id,
  5603. nameid: item.name.id,
  5604. Specificationsid: item.Specifications.id,
  5605. name: item.name.name,
  5606. model: item.model.name,
  5607. Specifications: item.Specifications.name,
  5608. sum: item.sum,
  5609. };
  5610. if (
  5611. item.name &&
  5612. item.model &&
  5613. JSON.stringify(item.model) != "{}" &&
  5614. item.Specifications &&
  5615. JSON.stringify(item.Specifications) != "{}" &&
  5616. item.sum
  5617. ) {
  5618. // $modalInstance.close(data);
  5619. angular.forEach(scope.myData2all, function (itemsdata) {
  5620. // if (item.model.id == itemsdata.id) {
  5621. if (
  5622. item.model.id == itemsdata.modelid &&
  5623. item.name.id == itemsdata.nameid &&
  5624. item.Specifications.id == itemsdata.Specificationsid
  5625. ) {
  5626. submittrue = false;
  5627. }
  5628. });
  5629. if (submittrue) {
  5630. $modalInstance.close(data);
  5631. } else {
  5632. SweetAlert.swal({
  5633. title: "该耗材已有添加",
  5634. text: "请检查数据然后提交!",
  5635. type: "error",
  5636. });
  5637. }
  5638. } else {
  5639. SweetAlert.swal({
  5640. title: "数据填写不完整!",
  5641. text: "请检查数据然后提交!",
  5642. type: "error",
  5643. });
  5644. }
  5645. };
  5646. $scope.cancel = function () {
  5647. $modalInstance.dismiss("cancel");
  5648. };
  5649. },
  5650. size: "sm",
  5651. resolve: {
  5652. scope: function () {
  5653. return $scope;
  5654. },
  5655. },
  5656. });
  5657. modalInstance.result.then(function (selectedItem) {
  5658. // $scope.myData2.push(selectedItem);
  5659. // for (var i = 0; i < $scope.myData2.length; i++) {
  5660. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5661. // }
  5662. // $scope.model.consumables = $scope.myData2;
  5663. $scope.myData2all.push(selectedItem);
  5664. for (var i = 0; i < $scope.myData2all.length; i++) {
  5665. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5666. $scope.myData2all[i]["item"] = i + 1;
  5667. }
  5668. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5669. $scope.myData2 = $scope.interceptMydata(
  5670. $scope.myData2all,
  5671. $scope.memoryfilterDatagui.idx,
  5672. 10
  5673. );
  5674. $scope.model.consumables = $scope.myData2all;
  5675. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5676. $scope.model.consumables;
  5677. });
  5678. };
  5679. $scope.onDblClick = function (data, event) {
  5680. $scope.selectButtonClick(data, event);
  5681. };
  5682. $scope.memoryfilterData = {
  5683. idx: 0,
  5684. sum: 20,
  5685. user: {
  5686. roledata: {
  5687. rolecode: "roleset",
  5688. },
  5689. selectType: "1",
  5690. },
  5691. };
  5692. $scope.myData = {};
  5693. $scope.loadData = function (filterData) { };
  5694. // $scope.title = title;
  5695. $scope.loadData({
  5696. idx: 0,
  5697. sum: 20,
  5698. user: {
  5699. roledata: {
  5700. rolecode: "roleset",
  5701. },
  5702. selectType: "1",
  5703. },
  5704. });
  5705. $scope.selected = {
  5706. items: {},
  5707. };
  5708. },
  5709. ],
  5710. });
  5711. //tab 列表
  5712. formlyConfigProvider.setType({
  5713. name: "ui-cmdbtab",
  5714. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5715. wrapper: ["bootstrapHasError"],
  5716. defaultOptions: function (options, $scope) {
  5717. return {
  5718. templateOptions: {},
  5719. };
  5720. },
  5721. controller: [
  5722. "$scope",
  5723. "api_user_data",
  5724. "i18nService",
  5725. "$modal",
  5726. "api_cmdb",
  5727. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5728. $scope.memoryfilterDatashe = {
  5729. idx: 0,
  5730. sum: 10,
  5731. };
  5732. $scope.myDataoneall = [];
  5733. var setAllInactive = function () {
  5734. angular.forEach($scope.workspaces, function (workspace) {
  5735. workspace.active = false;
  5736. });
  5737. };
  5738. //添加
  5739. var addNewWorkspace = function (name, contentUrl) {
  5740. var id = $scope.workspaces.length + 1;
  5741. $scope.workspaces.push({
  5742. id: id,
  5743. name: name,
  5744. active: true,
  5745. contentUrl: "main/html/content.html",
  5746. });
  5747. };
  5748. //关闭
  5749. $scope.remove = function (closedata) {
  5750. event.preventDefault();
  5751. angular.forEach($scope.workspaces, function (item, index) {
  5752. if (closedata.id == item.id) {
  5753. if (closedata.id == 1) {
  5754. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5755. } else {
  5756. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5757. }
  5758. $scope.workspaces.splice(index, 1);
  5759. }
  5760. });
  5761. };
  5762. $scope.workspaces = [];
  5763. $scope.options.templateOptions.getpush = function (item) {
  5764. $scope.workspaces = [];
  5765. if (item.gu) {
  5766. $scope.workspaces.push({
  5767. id: 1,
  5768. name: "领用设备",
  5769. active: true,
  5770. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5771. });
  5772. }
  5773. if (item.hao) {
  5774. $scope.workspaces.push({
  5775. id: 2,
  5776. name: "领用耗材",
  5777. active: true,
  5778. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5779. });
  5780. }
  5781. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5782. };
  5783. $scope.addWorkspace = function (contentUrl, name) {
  5784. setAllInactive();
  5785. addNewWorkspace(name, contentUrl);
  5786. };
  5787. // $rootScope.addWorkspace = $scope.addWorkspace;
  5788. // $scope.remove = function(idNumber) {
  5789. // var index = 0; //记录当前元素下标
  5790. // angular.forEach($scope.workspaces, function(workspace) {
  5791. // if (workspace.id === idNumber.id) {
  5792. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5793. // }
  5794. // index++;
  5795. // });
  5796. // };
  5797. // setInterval(function() {
  5798. // if ($scope.model.assets) {
  5799. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5800. // $scope.modelass = $scope.model.assets;
  5801. // if (JSON.stringify($scope.model.assets) == "{}") {
  5802. // $scope.model.assets = []
  5803. // } else {
  5804. // $scope.model.assets = JSON.parse($scope.model.assets);
  5805. // }
  5806. // $scope.myDatalingbeiall = $scope.model.assets;
  5807. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5808. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5809. // }
  5810. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5811. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5812. // }
  5813. // }
  5814. // if ($scope.model.consumables) {
  5815. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5816. // $scope.modelass = $scope.model.consumables;
  5817. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5818. // $scope.model.consumables = [];
  5819. // } else {
  5820. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5821. // }
  5822. // $scope.myDatalingbeiall = $scope.model.consumables;
  5823. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5824. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5825. // }
  5826. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5827. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5828. // // $scope.model.consumables = $scope.myData2all;
  5829. // }
  5830. // }
  5831. // }, 100);
  5832. //grid1
  5833. $scope.langs = i18nService.getAllLangs();
  5834. $scope.lang = "zh-cn";
  5835. i18nService.setCurrentLang($scope.lang);
  5836. $scope.gridOptions1 = {};
  5837. $scope.gridOptions1.data = "myDatalingbei";
  5838. $scope.gridOptions1.enableColumnResizing = true;
  5839. $scope.gridOptions1.enableFiltering = false;
  5840. $scope.gridOptions1.enableGridMenu = false;
  5841. $scope.gridOptions1.showGridFooter = true;
  5842. $scope.gridOptions1.showColumnFooter = false;
  5843. $scope.gridOptions1.fastWatch = true;
  5844. $scope.gridOptions1.useExternalFiltering = true;
  5845. $scope.gridOptions1.useExternalPagination = true;
  5846. $scope.gridOptions1.paginationPageSizes = [10];
  5847. $scope.gridOptions1.paginationPageSize = 10;
  5848. $scope.gridOptions1.multiSelect = false;
  5849. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5850. $scope.gridOptions1.columnDefs = [
  5851. {
  5852. name: "item",
  5853. displayName: "序号",
  5854. width: 120,
  5855. },
  5856. {
  5857. name: "props.hw_cifilterClassic",
  5858. displayName: "设备类型",
  5859. width: 150,
  5860. enableFiltering: false,
  5861. },
  5862. {
  5863. name: "props.hw_mingcheng",
  5864. displayName: "设备名称",
  5865. width: 100,
  5866. enableFiltering: false,
  5867. },
  5868. {
  5869. name: "uuid",
  5870. displayName: "设备编号",
  5871. enableFiltering: false,
  5872. },
  5873. ];
  5874. $scope.myDatalingbeiall = [];
  5875. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5876. $scope.gridApi = gridApi;
  5877. gridApi.pagination.on.paginationChanged(
  5878. $scope,
  5879. function (newPage, pageSize) {
  5880. // var filtersData = $scope.memoryfilterData;
  5881. // filtersData.idx = newPage - 1;
  5882. // filtersData.sum = pageSize;
  5883. // $scope.loadData(filtersData);
  5884. $scope.memoryfilterDatashe.idx = newPage - 1;
  5885. $scope.memoryfilterDatashe.sum = pageSize;
  5886. $scope.myDatalingbei = $scope.interceptMydata(
  5887. $scope.myDatalingbeiall,
  5888. $scope.memoryfilterDatashe.idx,
  5889. 10
  5890. );
  5891. }
  5892. );
  5893. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5894. $scope.selected.items = data.entity;
  5895. //console.log(data);
  5896. });
  5897. gridApi.selection.on.rowSelectionChangedBatch(
  5898. $scope,
  5899. function (data) {
  5900. $scope.selected.items = data.entity;
  5901. //console.log(data);
  5902. }
  5903. );
  5904. gridApi.core.on.filterChanged($scope, function () {
  5905. var grid = this.grid;
  5906. var filtersData = {
  5907. idx: 0,
  5908. sum: 20,
  5909. user: {
  5910. roledata: {
  5911. rolecode: "roleset",
  5912. },
  5913. selectType: "1",
  5914. },
  5915. };
  5916. angular.forEach(grid.columns, function (item) {
  5917. if (item.enableFiltering) {
  5918. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5919. if (
  5920. angular.isDefined(item.filters[0].term) &&
  5921. item.filters[0].term != ""
  5922. ) {
  5923. if (angular.isUndefined(filtersData["user"])) {
  5924. filtersData["user"] = {};
  5925. }
  5926. filtersData["user"][item.field] = item.filters[0].term;
  5927. }
  5928. }
  5929. });
  5930. $scope.memoryfilterDatashe = filtersData;
  5931. // $scope.loadData(filtersData);
  5932. });
  5933. };
  5934. $scope.interceptMydata = function (mydate, idx, sum) {
  5935. return mydate.slice(idx * sum, (idx + 1) * sum);
  5936. };
  5937. $scope.removeshebei = function (item) {
  5938. event.preventDefault();
  5939. var modalInstance = $modal.open({
  5940. templateUrl: "assets/views/delete.html",
  5941. controller: function ($scope, $modalInstance, scope) {
  5942. $scope.title = "设备移除";
  5943. $scope.connect = "确定要移除此设备?";
  5944. $scope.consumptive = scope.selected.items;
  5945. $scope.ok = function () {
  5946. $modalInstance.close($scope.consumptive);
  5947. };
  5948. $scope.cancel = function () {
  5949. $modalInstance.dismiss("cancel");
  5950. };
  5951. },
  5952. size: "sm",
  5953. resolve: {
  5954. scope: function () {
  5955. return $scope;
  5956. },
  5957. },
  5958. });
  5959. modalInstance.result.then(function (selectedItem) {
  5960. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5961. if (items.id == selectedItem.id) {
  5962. $scope.myDatalingbeiall.splice(index, 1);
  5963. }
  5964. });
  5965. // $scope.myData3.push(selectedItem);
  5966. $scope.model.consumables = $scope.myDatalingbeiall;
  5967. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5968. $scope.myDatalingbeiall;
  5969. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5970. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5971. $scope.myDatalingbeiall[i]["item"] =
  5972. i +
  5973. 1 +
  5974. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5975. }
  5976. $scope.myDatalingbei = $scope.interceptMydata(
  5977. $scope.myDatalingbeiall,
  5978. 0,
  5979. 10
  5980. );
  5981. });
  5982. };
  5983. $scope.addshebei = function () {
  5984. event.preventDefault();
  5985. var modalInstance = $modal.open({
  5986. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5987. controller: function (
  5988. $scope,
  5989. i18nService,
  5990. $modalInstance,
  5991. items,
  5992. title,
  5993. Restangular,
  5994. APIService,
  5995. onDataCallback,
  5996. parentScope,
  5997. api_configure_data,
  5998. api_configure_form
  5999. ) {
  6000. $scope.langs = i18nService.getAllLangs();
  6001. $scope.lang = "zh-cn";
  6002. i18nService.setCurrentLang($scope.lang);
  6003. $scope.gridOptions = {};
  6004. $scope.gridOptions.data = "myDatatwo";
  6005. $scope.gridOptions.enableColumnResizing = true;
  6006. $scope.gridOptions.enableFiltering = false;
  6007. $scope.gridOptions.enableGridMenu = false;
  6008. $scope.gridOptions.showGridFooter = true;
  6009. $scope.gridOptions.showColumnFooter = false;
  6010. $scope.gridOptions.fastWatch = true;
  6011. $scope.gridOptions.useExternalFiltering = true;
  6012. $scope.gridOptions.useExternalPagination = true;
  6013. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6014. $scope.gridOptions.paginationPageSize = 10;
  6015. $scope.gridOptions.multiSelect = true;
  6016. $scope.gridOptions.rowIdentity = function (row) {
  6017. return row.id;
  6018. };
  6019. $scope.gridOptions.getRowIdentity = function (row) {
  6020. return row.id;
  6021. };
  6022. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6023. $scope.gridOptions.columnDefs = [
  6024. {
  6025. name: "item",
  6026. displayName: "序号",
  6027. width: 80,
  6028. enableFiltering: false,
  6029. },
  6030. {
  6031. name: "uuid",
  6032. displayName: "内部编号",
  6033. width: 175,
  6034. },
  6035. {
  6036. name: "props.hw_mingcheng",
  6037. displayName: "资产名称",
  6038. width: 120,
  6039. },
  6040. {
  6041. name: "props.hw_cifilterClassic",
  6042. displayName: "资产类型",
  6043. width: 80,
  6044. enableFiltering: false,
  6045. },
  6046. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6047. {
  6048. name: "props.hw_state",
  6049. displayName: "资产状态",
  6050. width: 150,
  6051. enableFiltering: false,
  6052. },
  6053. {
  6054. name: "props.hwnw_area",
  6055. displayName: "资产地点",
  6056. width: 130,
  6057. enableFiltering: false,
  6058. },
  6059. {
  6060. name: "createtime",
  6061. displayName: "申请时间",
  6062. enableFiltering: false,
  6063. },
  6064. ];
  6065. // $scope.selectButtonClick
  6066. var defaultFilterData = {
  6067. // "assignee":2,
  6068. // "sign":"basehwitndl",
  6069. // "applicationForm": { "hw_state": "在线" },
  6070. hw_state: "在库",
  6071. idx: 0,
  6072. sum: 10,
  6073. };
  6074. $scope.memoryfilterData = {
  6075. // "assignee":2,
  6076. // "sign":"basehwitndl",
  6077. // "applicationForm": { "hw_state": "在线" },
  6078. hw_state: "在库",
  6079. idx: 0,
  6080. sum: 10,
  6081. };
  6082. $scope.refreshData = function (style, filterData) {
  6083. if (angular.isUndefined(filterData)) {
  6084. filterData = defaultFilterData;
  6085. }
  6086. $scope.myDatatwo = [];
  6087. // $scope.gridOptions['sum']=filterData.sum;
  6088. api_cmdb.query(filterData).then(
  6089. function (data) {
  6090. // $scope.callsPending--;
  6091. var filterData = $scope.memoryfilterData;
  6092. var myDatatwo = Restangular.stripRestangular(data);
  6093. $scope.gridOptions["totalItems"] = data.total;
  6094. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6095. myDatatwo.data.node[i].createtime = moment(
  6096. myDatatwo.data.node[i].createtime
  6097. ).format("YYYY-MM-DD");
  6098. }
  6099. $scope.myDatatwo = myDatatwo.data.node;
  6100. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6101. $scope.myDatatwo[i]["item"] =
  6102. i + 1 + filterData.idx * filterData.sum;
  6103. }
  6104. },
  6105. function () { }
  6106. );
  6107. };
  6108. $scope.refreshData("expand-right", defaultFilterData);
  6109. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6110. $scope.gridApi = gridApi;
  6111. gridApi.pagination.on.paginationChanged(
  6112. $scope,
  6113. function (newPage, pageSize) {
  6114. var filtersData = $scope.memoryfilterData;
  6115. filtersData.idx = newPage - 1;
  6116. filtersData.sum = pageSize;
  6117. // $scope.loadData(filtersData);
  6118. $scope.refreshData("expand-right", filtersData);
  6119. //console.log(pageSize);
  6120. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6121. }
  6122. );
  6123. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6124. // $scope.selected.items.push(data.entity);
  6125. //console.log(data);
  6126. gridApi.selection.on.rowSelectionChanged(
  6127. $scope,
  6128. function (scope, ect) {
  6129. if (scope.isSelected) {
  6130. scope.grid.appScope.selected.items.push(scope.entity);
  6131. } else {
  6132. for (
  6133. var i = 0;
  6134. i <= scope.grid.appScope.selected.items.length;
  6135. i++
  6136. ) {
  6137. if (
  6138. scope.grid.appScope.selected.items[i].id ==
  6139. scope.entity.id
  6140. ) {
  6141. scope.grid.appScope.selected.items.splice(i, 1);
  6142. break;
  6143. }
  6144. }
  6145. }
  6146. $scope.mySelectedRows =
  6147. $scope.gridApi.selection.getSelectedRows();
  6148. }
  6149. );
  6150. // });
  6151. gridApi.selection.on.rowSelectionChangedBatch(
  6152. $scope,
  6153. function (rows) {
  6154. // $scope.selected.items = data.entity;
  6155. //console.log(data);
  6156. var selectitem = [];
  6157. selectitem = angular.copy($scope.selected.items);
  6158. for (var j = 0; j < rows.length; j++) {
  6159. if (rows[j].isSelected == true) {
  6160. selectitem.push(rows[j].entity);
  6161. } else {
  6162. delete selectitem[j];
  6163. // rows.splice(j, 1);
  6164. }
  6165. }
  6166. $scope.selected.items = [];
  6167. for (var i = 0; i < selectitem.length; i++) {
  6168. if (selectitem[i]) {
  6169. $scope.selected.items.push(selectitem[i]);
  6170. }
  6171. }
  6172. }
  6173. );
  6174. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6175. // // if (row.entity.age > 45) {
  6176. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6177. // // }
  6178. // };
  6179. gridApi.core.on.filterChanged($scope, function () {
  6180. var grid = this.grid;
  6181. var filtersData = {
  6182. idx: 0,
  6183. sum: 10,
  6184. user: {
  6185. roledata: {
  6186. rolecode: "roleset",
  6187. },
  6188. selectType: "1",
  6189. },
  6190. };
  6191. angular.forEach(grid.columns, function (item) {
  6192. if (item.enableFiltering) {
  6193. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6194. if (
  6195. angular.isDefined(item.filters[0].term) &&
  6196. item.filters[0].term != ""
  6197. ) {
  6198. if (angular.isUndefined(filtersData["user"])) {
  6199. filtersData["user"] = {};
  6200. }
  6201. filtersData["user"][item.field] = item.filters[0].term;
  6202. }
  6203. }
  6204. });
  6205. $scope.memoryfilterData = filtersData;
  6206. // $scope.loadData(filtersData);
  6207. });
  6208. };
  6209. $scope.onDblClick = function (data, event) {
  6210. // $scope.selected.items = data.entity;
  6211. $scope.selectButtonClick(data, event);
  6212. };
  6213. // $scope.loadData = function(filterData) {
  6214. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6215. // items.fetchItems(filterData, APIService).then(function(data) {
  6216. // var myDatatwo = Restangular.stripRestangular(data);
  6217. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6218. // $scope.myDatatwo = myDatatwo.list;
  6219. // });
  6220. // };
  6221. $scope.title = title;
  6222. //树形图
  6223. var apple_selected, tree, treedata_avm, treedata_geography;
  6224. $scope.my_tree_handler = function (branch) {
  6225. //var _ref;
  6226. var classify = ($scope.classify =
  6227. branch.prefix.toLowerCase() + branch.sign);
  6228. api_cmdb
  6229. .query({
  6230. sign: classify,
  6231. })
  6232. .then(function (data) {
  6233. var myDatalingbei = Restangular.stripRestangular(data);
  6234. // console.log(myData.data.node);
  6235. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6236. var ret = myDatalingbei.data;
  6237. redrawSvg(myDatalingbei);
  6238. }
  6239. });
  6240. };
  6241. $scope.my_data = [];
  6242. function convertListToTree(data, treeMap) {
  6243. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6244. var root = null; //Initially set our loop to null
  6245. var parentNode = null;
  6246. //loop over data
  6247. for (var i = 0; i < data.length; i++) {
  6248. var datum = data[i];
  6249. //each node will have children, so let's give it a "children" poperty
  6250. datum.children = [];
  6251. //add an entry for this node to the map so that any future children can
  6252. //lookup the parent
  6253. idToNodeMap[datum.id] = datum;
  6254. //Does this node have a parent?
  6255. if (
  6256. typeof datum.parent === "undefined" ||
  6257. datum.parent == null
  6258. ) {
  6259. //Doesn't look like it, so this node is the root of the tree
  6260. root = datum;
  6261. treeMap[datum.id] = root;
  6262. } else {
  6263. //This node has a parent, so let's look it up using the id
  6264. parentNode = idToNodeMap[datum.parent.id];
  6265. //We don't need this property, so let's delete it.
  6266. delete datum.parent;
  6267. //Let's add the current node as a child of the parent node.
  6268. parentNode.children.push(datum);
  6269. }
  6270. }
  6271. return root;
  6272. }
  6273. function convertParentToChildList(data) {
  6274. var treeMap = {};
  6275. var list = [];
  6276. convertListToTree(data, treeMap);
  6277. angular.forEach(treeMap, function (item) {
  6278. list.push(item);
  6279. });
  6280. return list;
  6281. }
  6282. $scope.my_tree = tree = {};
  6283. $scope.try_async_load = function () {
  6284. $scope.my_data = [];
  6285. $scope.select_treedata = [];
  6286. $scope.doing_async = true;
  6287. api_configure_data
  6288. .fetchDataList("ciclassify", {
  6289. idx: 0,
  6290. sum: 100,
  6291. })
  6292. .then(function (result) {
  6293. //console.log(result['list']);
  6294. $scope.select_treedata = $scope.my_data =
  6295. convertParentToChildList(result["list"]);
  6296. $scope.doing_async = false;
  6297. // tree.expand_all();
  6298. //console.log(treelist);
  6299. });
  6300. };
  6301. $scope.select_treedata = [];
  6302. $scope.propTypeOptions = [];
  6303. $scope.try_async_load();
  6304. $scope.onFilterremove = function (item) {
  6305. console.log(item);
  6306. };
  6307. $scope.searchdata = {};
  6308. $scope.clear = function () {
  6309. $scope.searchdata = {};
  6310. $scope.cifilter_classic = {};
  6311. $scope.try_async_load();
  6312. var fildata = {
  6313. idx: 0,
  6314. sum: 10,
  6315. hw_state: "在库",
  6316. };
  6317. $scope.memoryfilterData = fildata;
  6318. $scope.refreshData("expand-right", fildata);
  6319. };
  6320. $scope.cifilter_classic = {};
  6321. $scope.chiceIncident = function (item) {
  6322. var fildata = defaultFilterData;
  6323. // fildata.applicationForm = {};
  6324. // sign: basehwnwswt
  6325. if (item && item.id) {
  6326. var classify = item.prefix.toLowerCase() + item.sign;
  6327. fildata.sign = classify;
  6328. } else {
  6329. delete fildata.sign;
  6330. }
  6331. $scope.gridOptions.paginationCurrentPage = 1;
  6332. var transitiondata = angular.copy(item);
  6333. $scope.refreshData("expand-right", fildata);
  6334. };
  6335. $scope.applicadata = [];
  6336. $scope.onFilterCallback = function (item) {
  6337. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6338. api_configure_form
  6339. .renderTabForm(tempclassify)
  6340. .then(function (data) {
  6341. var myData = Restangular.stripRestangular(data);
  6342. $scope.applicadata = myData[0].form.fields;
  6343. });
  6344. // }
  6345. };
  6346. // $scope.loadData({
  6347. // idx: 0,
  6348. // sum: 10,
  6349. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6350. // });
  6351. $scope.selected = {
  6352. items: [],
  6353. };
  6354. $scope.ok = function () {
  6355. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6356. // onDataCallback($scope.selected.item, parentScope);
  6357. // }
  6358. $modalInstance.close($scope.selected.items);
  6359. };
  6360. $scope.cancel = function () {
  6361. $modalInstance.dismiss("cancel");
  6362. };
  6363. },
  6364. size: "lg",
  6365. resolve: {
  6366. items: function () {
  6367. return {
  6368. fetchItems: function (filterData, APIService) {
  6369. filterData = filterData || {};
  6370. if (
  6371. angular.isDefined(filterData.idx) &&
  6372. filterData.idx == null
  6373. ) {
  6374. filterData = {
  6375. idx: 0,
  6376. sum: 10,
  6377. user: {
  6378. roledata: {
  6379. rolecode: "roleset",
  6380. },
  6381. selectType: "1",
  6382. },
  6383. };
  6384. }
  6385. return $scope.options.templateOptions.fetchItems(
  6386. filterData,
  6387. APIService
  6388. );
  6389. },
  6390. };
  6391. },
  6392. title: function () {
  6393. return $scope.options.templateOptions.label;
  6394. },
  6395. Restangular: function () {
  6396. return $scope.options.templateOptions.Restangular;
  6397. },
  6398. APIService: function () {
  6399. return $scope.options.templateOptions.ApiService;
  6400. },
  6401. onDataCallback: function () {
  6402. return $scope.options.templateOptions.callback;
  6403. },
  6404. parentScope: function () {
  6405. return $scope.options.templateOptions.that;
  6406. },
  6407. },
  6408. });
  6409. modalInstance.result.then(
  6410. function (selectedItem) {
  6411. // console.log(selectedItem);
  6412. // options.value(selectedItem);
  6413. var filterData = $scope.memoryfilterDatashe;
  6414. $scope.myDatalingbeiall = selectedItem;
  6415. $scope.gridOptions1["totalItems"] =
  6416. $scope.myDatalingbeiall.length;
  6417. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6418. $scope.myDatalingbeiall[i]["item"] =
  6419. i + 1 + filterData.idx * filterData.sum;
  6420. }
  6421. $scope.myDatalingbei = $scope.interceptMydata(
  6422. $scope.myDatalingbeiall,
  6423. 0,
  6424. 10
  6425. );
  6426. $scope.model.assets = $scope.myDatalingbeiall;
  6427. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6428. $scope.myDatalingbeiall;
  6429. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6430. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6431. // }
  6432. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6433. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6434. // }
  6435. },
  6436. function () {
  6437. //console.log('Modal dismissed at: ' + new Date());
  6438. }
  6439. );
  6440. };
  6441. $scope.onDblClick = function (data, event) {
  6442. $scope.selectButtonClick(data, event);
  6443. };
  6444. // $scope.loadData = function(filterData) {};
  6445. // $scope.title = title;
  6446. // $scope.loadData({
  6447. // idx: 0,
  6448. // sum: 20,
  6449. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6450. // });
  6451. $scope.selected = {
  6452. items: [],
  6453. };
  6454. //grid2
  6455. $scope.langs = i18nService.getAllLangs();
  6456. $scope.lang = "zh-cn";
  6457. i18nService.setCurrentLang($scope.lang);
  6458. $scope.gridOptions2 = {};
  6459. $scope.gridOptions2.data = "myDataone";
  6460. $scope.gridOptions2.enableColumnResizing = true;
  6461. $scope.gridOptions2.enableFiltering = false;
  6462. $scope.gridOptions2.enableGridMenu = false;
  6463. $scope.gridOptions2.showGridFooter = true;
  6464. $scope.gridOptions2.showColumnFooter = false;
  6465. $scope.gridOptions2.fastWatch = true;
  6466. $scope.gridOptions2.useExternalFiltering = true;
  6467. $scope.gridOptions2.useExternalPagination = true;
  6468. $scope.gridOptions2.paginationPageSizes = [10];
  6469. $scope.gridOptions2.paginationPageSize = 10;
  6470. $scope.gridOptions2.multiSelect = false;
  6471. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6472. $scope.gridOptions2.columnDefs = [
  6473. {
  6474. name: "item",
  6475. displayName: "序号",
  6476. width: 120,
  6477. },
  6478. {
  6479. name: "name",
  6480. displayName: "耗材名称",
  6481. width: 150,
  6482. enableFiltering: false,
  6483. },
  6484. {
  6485. name: "model",
  6486. displayName: "品牌/型号",
  6487. width: 100,
  6488. enableFiltering: false,
  6489. },
  6490. {
  6491. name: "Specifications",
  6492. displayName: "规格",
  6493. width: 150,
  6494. enableFiltering: false,
  6495. },
  6496. {
  6497. name: "sum",
  6498. displayName: "领用数量",
  6499. enableFiltering: false,
  6500. },
  6501. ];
  6502. // $scope.selectButtonClick
  6503. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6504. $scope.gridApi = gridApi;
  6505. gridApi.pagination.on.paginationChanged(
  6506. $scope,
  6507. function (newPage, pageSize) {
  6508. // var filtersData = $scope.memoryfilterData;
  6509. // filtersData.idx = newPage - 1;
  6510. // filtersData.sum = pageSize;
  6511. // $scope.loadData(filtersData);
  6512. $scope.memoryfilterDatahao.idx = newPage - 1;
  6513. $scope.memoryfilterDatahao.sum = pageSize;
  6514. $scope.myDataone = $scope.interceptMydata(
  6515. $scope.myDataoneall,
  6516. $scope.memoryfilterDatahao.idx,
  6517. 10
  6518. );
  6519. }
  6520. );
  6521. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6522. $scope.selected.items.push(data.entity);
  6523. //console.log(data);
  6524. });
  6525. gridApi.selection.on.rowSelectionChangedBatch(
  6526. $scope,
  6527. function (data) {
  6528. $scope.selected.items.push(data.entity);
  6529. //console.log(data);
  6530. }
  6531. );
  6532. gridApi.core.on.filterChanged($scope, function () {
  6533. var grid = this.grid;
  6534. var filtersData = {
  6535. idx: 0,
  6536. sum: 10,
  6537. user: {
  6538. roledata: {
  6539. rolecode: "roleset",
  6540. },
  6541. selectType: "1",
  6542. },
  6543. };
  6544. angular.forEach(grid.columns, function (item) {
  6545. if (item.enableFiltering) {
  6546. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6547. if (
  6548. angular.isDefined(item.filters[0].term) &&
  6549. item.filters[0].term != ""
  6550. ) {
  6551. if (angular.isUndefined(filtersData["user"])) {
  6552. filtersData["user"] = {};
  6553. }
  6554. filtersData["user"][item.field] = item.filters[0].term;
  6555. }
  6556. }
  6557. });
  6558. $scope.memoryfilterDatahao = filtersData;
  6559. $scope.loadData(filtersData);
  6560. });
  6561. };
  6562. $scope.removehaocai = function (item) {
  6563. event.preventDefault();
  6564. // var modalInstance = $modal.open({
  6565. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6566. // controller: function($scope, $modalInstance) {
  6567. // $scope.title = "修改耗材数量";
  6568. // $scope.consumptive = item;
  6569. // $scope.ok = function() {
  6570. // $modalInstance.close($scope.consumptive);
  6571. // };
  6572. // $scope.cancel = function() {
  6573. // $modalInstance.dismiss('cancel');
  6574. // };
  6575. // },
  6576. // size: 'sm'
  6577. // });
  6578. var modalInstance = $modal.open({
  6579. templateUrl: "assets/views/delete.html",
  6580. controller: function ($scope, $modalInstance, scope) {
  6581. $scope.title = "耗材移除";
  6582. $scope.connect = "确定要移除此设备?";
  6583. $scope.consumptive = scope.selected.items[0];
  6584. $scope.ok = function () {
  6585. $modalInstance.close($scope.consumptive);
  6586. };
  6587. $scope.cancel = function () {
  6588. $modalInstance.dismiss("cancel");
  6589. };
  6590. },
  6591. size: "sm",
  6592. resolve: {
  6593. scope: function () {
  6594. return $scope;
  6595. },
  6596. },
  6597. });
  6598. modalInstance.result.then(function (selectedItem) {
  6599. // angular.forEach($scope.myData3, function(items, index) {
  6600. // if (items.id == selectedItem.id) {
  6601. // $scope.myData3[index] = selectedItem;
  6602. // }
  6603. // })
  6604. // $scope.model.applicationForm.consumables = $scope.myData3;
  6605. angular.forEach($scope.myDataoneall, function (items, index) {
  6606. if (items.id == selectedItem.id) {
  6607. $scope.myDataoneall.splice(index, 1);
  6608. }
  6609. });
  6610. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6611. $scope.myDataoneall[i]["item"] =
  6612. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6613. }
  6614. $scope.myDataone = $scope.interceptMydata(
  6615. $scope.myDataoneall,
  6616. 0,
  6617. 10
  6618. );
  6619. $scope.model.consumables = $scope.myDataoneall;
  6620. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6621. $scope.myDataoneall;
  6622. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6623. $scope.selected = {
  6624. items: [],
  6625. };
  6626. });
  6627. };
  6628. $scope.haocaiadd = function () {
  6629. event.preventDefault();
  6630. var modalInstance = $modal.open({
  6631. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6632. controller: function (
  6633. $scope,
  6634. scope,
  6635. $modalInstance,
  6636. api_wechatfile,
  6637. SweetAlert,
  6638. api_cmdb3
  6639. ) {
  6640. $scope.haocainame = [];
  6641. $scope.pinpai = [];
  6642. $scope.guige = [];
  6643. $scope.consumptive = {};
  6644. $scope.consumpall = {};
  6645. $scope.title = "添加耗材";
  6646. api_wechatfile
  6647. .getDictionaryForList({
  6648. key: "haocaifenlei",
  6649. })
  6650. .then(function (data) {
  6651. $scope.haocainame = data;
  6652. });
  6653. $scope.clearNoNum = function (obj, attr) {
  6654. //先把非数字的都替换掉,除了数字和.
  6655. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6656. //必须保证第一个为数字而不是.
  6657. obj[attr] = obj[attr].replace(/^\./g, "");
  6658. //保证只有出现一个.而没有多个.
  6659. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6660. //保证.只出现一次,而不能出现两次以上
  6661. obj[attr] = obj[attr]
  6662. .replace(".", "$#$")
  6663. .replace(/\./g, "")
  6664. .replace("$#$", ".");
  6665. //小于最大值
  6666. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6667. alert(
  6668. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6669. );
  6670. obj[attr] = "";
  6671. }
  6672. };
  6673. $scope.onChange = function (parent) {
  6674. $scope.consumptive.model = {};
  6675. $scope.consumptive.Specifications = {};
  6676. api_wechatfile
  6677. .getDictionaryForList({
  6678. key: "pinpai",
  6679. parent: parent.id,
  6680. })
  6681. .then(function (data) {
  6682. $scope.pinpai = data;
  6683. });
  6684. api_wechatfile
  6685. .getDictionaryForList({
  6686. key: "guige",
  6687. parent: parent.id,
  6688. })
  6689. .then(function (data) {
  6690. $scope.guige = data;
  6691. });
  6692. };
  6693. $scope.onChangesum = function (item) {
  6694. if (item.name && item.model.id && item.Specifications.id) {
  6695. $scope.consumptive.sum = "";
  6696. var data1 = {
  6697. idx: 0,
  6698. sum: 10,
  6699. consumable: {
  6700. name: item.name.name,
  6701. brandModel: item.model.name,
  6702. specification: item.Specifications.name,
  6703. },
  6704. };
  6705. api_cmdb3
  6706. .fetchDataList("consumable", data1)
  6707. .then(function (data) {
  6708. if (data.status == 200 && data.list.length > 0) {
  6709. var myData = data.list;
  6710. $scope.consumpall = myData[0];
  6711. $scope.maxsum = myData[0].inventoryNum;
  6712. } else {
  6713. SweetAlert.swal({
  6714. title: "不存在该耗材",
  6715. text: "请检查库存后重新填写!",
  6716. type: "error",
  6717. });
  6718. }
  6719. });
  6720. }
  6721. };
  6722. $scope.addhaocai = function () {
  6723. $modalInstance.dismiss("cancel");
  6724. scope.haocaiopen($scope.consumptive);
  6725. };
  6726. $scope.ok = function (item) {
  6727. var items = {};
  6728. // if (item.name && item.model && item.Specifications && item.sum) {
  6729. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6730. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6731. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6732. // $scope.consumpall.sum = item.sum;
  6733. // delete $scope.consumpall.brandModel;
  6734. // delete $scope.consumpall.specification;
  6735. // $modalInstance.close($scope.consumpall);
  6736. // } else {
  6737. // SweetAlert.swal({
  6738. // title: "数据填写不完整!",
  6739. // text: "请检查数据然后提交!",
  6740. // type: "error"
  6741. // });
  6742. // }
  6743. var isold = false;
  6744. if (
  6745. item.name &&
  6746. item.model &&
  6747. JSON.stringify(item.model) != "{}" &&
  6748. item.Specifications &&
  6749. JSON.stringify(item.Specifications) != "{}" &&
  6750. item.sum
  6751. ) {
  6752. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6753. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6754. isold = true;
  6755. }
  6756. }
  6757. if (isold) {
  6758. SweetAlert.swal({
  6759. title: "该耗材已添加!",
  6760. text: "请不要重复添加耗材!",
  6761. type: "error",
  6762. });
  6763. } else {
  6764. $scope.consumpall.model = $scope.consumpall.brandModel;
  6765. $scope.consumpall.Specifications =
  6766. $scope.consumpall.specification;
  6767. $scope.consumpall.sum = item.sum;
  6768. delete $scope.consumpall.brandModel;
  6769. delete $scope.consumpall.specification;
  6770. $modalInstance.close($scope.consumpall);
  6771. }
  6772. } else {
  6773. SweetAlert.swal({
  6774. title: "数据填写不完整!",
  6775. text: "请检查数据然后提交!",
  6776. type: "error",
  6777. });
  6778. }
  6779. // $modalInstance.close(item);
  6780. };
  6781. $scope.cancel = function () {
  6782. $modalInstance.dismiss("cancel");
  6783. };
  6784. },
  6785. size: "sm",
  6786. resolve: {
  6787. scope: function () {
  6788. return $scope;
  6789. },
  6790. },
  6791. });
  6792. modalInstance.result.then(function (selectedItem) {
  6793. $scope.myDataoneall.push(selectedItem);
  6794. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6795. $scope.myDataoneall[i]["item"] =
  6796. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6797. }
  6798. // $scope.model.consumables = $scope.myDataone;
  6799. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6800. $scope.myDataone = $scope.interceptMydata(
  6801. $scope.myDataoneall,
  6802. 0,
  6803. 10
  6804. );
  6805. $scope.model.consumables = $scope.myDataoneall;
  6806. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6807. $scope.myDataoneall;
  6808. });
  6809. };
  6810. $scope.onDblClick = function (data, event) {
  6811. $scope.selectButtonClick(data, event);
  6812. };
  6813. $scope.memoryfilterDatahao = {
  6814. idx: 0,
  6815. sum: 10,
  6816. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6817. };
  6818. $scope.myDataone = [];
  6819. $scope.loadData = function (filterData) { };
  6820. // $scope.title = title;
  6821. $scope.ldloading = {};
  6822. $scope.selected = {
  6823. items: [],
  6824. };
  6825. if ($scope.$parent.$parent.$parent.model.gettype) {
  6826. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6827. if ($scope.model.assets) {
  6828. if (JSON.stringify($scope.model.assets) == "{}") {
  6829. $scope.model.assets = [];
  6830. } else {
  6831. $scope.model.assets = JSON.parse($scope.model.assets);
  6832. }
  6833. $scope.myDatalingbeiall = $scope.model.assets;
  6834. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6835. $scope.myDatalingbeiall[i]["item"] =
  6836. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6837. }
  6838. $scope.gridOptions1["totalItems"] =
  6839. $scope.myDatalingbeiall.length;
  6840. $scope.myDatalingbei = $scope.interceptMydata(
  6841. $scope.myDatalingbeiall,
  6842. 0,
  6843. 10
  6844. );
  6845. }
  6846. if ($scope.model.consumables) {
  6847. if (JSON.stringify($scope.model.consumables) == "{}") {
  6848. $scope.model.consumables = [];
  6849. } else {
  6850. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6851. }
  6852. $scope.myDataoneall = $scope.model.consumables;
  6853. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6854. $scope.myDataoneall[i]["item"] =
  6855. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6856. }
  6857. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6858. $scope.myDataone = $scope.interceptMydata(
  6859. $scope.myDataoneall,
  6860. 0,
  6861. 10
  6862. );
  6863. }
  6864. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6865. $scope.options.templateOptions.getpush({
  6866. hao: true,
  6867. gu: true,
  6868. });
  6869. } else {
  6870. $scope.options.templateOptions.getpush({
  6871. hao: true,
  6872. });
  6873. }
  6874. } else {
  6875. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6876. $scope.options.templateOptions.getpush({
  6877. gu: true,
  6878. });
  6879. }
  6880. }
  6881. }
  6882. },
  6883. ],
  6884. });
  6885. formlyConfigProvider.setType({
  6886. name: "ui-panel",
  6887. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6888. });
  6889. formlyConfigProvider.setType({
  6890. name: "ui-currentuser",
  6891. extends: "input",
  6892. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6893. defaultOptions: function (options) {
  6894. return {
  6895. templateOptions: {
  6896. // link: function() {}
  6897. },
  6898. };
  6899. },
  6900. controller: [
  6901. "$scope",
  6902. function ($scope) {
  6903. if ($scope.options.templateOptions.user) {
  6904. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6905. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6906. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6907. // }
  6908. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6909. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6910. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6911. }
  6912. $scope.model[$scope.options.key] =
  6913. $scope.options.templateOptions.user;
  6914. $scope.options.initialValue = $scope.model[$scope.options.key];
  6915. }
  6916. },
  6917. ],
  6918. });
  6919. //仪表盘
  6920. //待处理变更列表
  6921. formlyConfigProvider.setType({
  6922. name: "ui-ngpchangetable",
  6923. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6924. defaultOptions: function (options) {
  6925. return {
  6926. templateOptions: {
  6927. // relationAction: function() {
  6928. // options.hideExpression = true
  6929. // }
  6930. },
  6931. };
  6932. },
  6933. controller: [
  6934. "$scope",
  6935. "$modal",
  6936. "$timeout",
  6937. "SweetAlert",
  6938. "api_bpm_domain",
  6939. "$rootScope",
  6940. "ngTableParams",
  6941. "$filter",
  6942. "$state",
  6943. function (
  6944. $scope,
  6945. $modal,
  6946. $timeout,
  6947. SweetAlert,
  6948. api_bpm_domain,
  6949. $rootScope,
  6950. ngTableParams,
  6951. $filter,
  6952. $state
  6953. ) {
  6954. // var filterData = {
  6955. // "assignee": $rootScope.user.id,
  6956. // "searchtype": "all",
  6957. // "idx": "0",
  6958. // "sum": "10"
  6959. // };
  6960. var filterData = {
  6961. idx: "0",
  6962. sum: "10",
  6963. assignee: 2,
  6964. searchType: "todo",
  6965. };
  6966. $scope.incidentprocess = function (item) {
  6967. $state.go("app.wt_change.add", {
  6968. taskId: item.taskId,
  6969. processInstanceId: item.processInstanceId,
  6970. });
  6971. };
  6972. $scope.more = function () {
  6973. $state.go("app.wt_change.list", {});
  6974. };
  6975. api_bpm_domain
  6976. .fetchtask("bpm_change", filterData)
  6977. .then(function (data) {
  6978. if (data.data) {
  6979. $scope.myData = data.data;
  6980. } else {
  6981. SweetAlert.swal({
  6982. title: "操作异常!",
  6983. text: "系统异常,请稍后重试,或者联系管理员!",
  6984. type: "error",
  6985. });
  6986. }
  6987. });
  6988. $scope.removes = function () {
  6989. var modalInstance = $modal.open({
  6990. templateUrl: "assets/views/delete.html",
  6991. controller: function ($scope, $modalInstance) {
  6992. $scope.ok = function () {
  6993. $modalInstance.close();
  6994. };
  6995. $scope.cancel = function () {
  6996. $modalInstance.dismiss("cancel");
  6997. };
  6998. },
  6999. size: "sm",
  7000. });
  7001. modalInstance.result.then(function () {
  7002. console.log($scope.$parent.$parent.$parent.$parent);
  7003. for (
  7004. var i = 0;
  7005. i <
  7006. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7007. i++
  7008. ) {
  7009. if (
  7010. $scope.fields.type ==
  7011. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7012. .type
  7013. ) {
  7014. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7015. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7016. i,
  7017. 1
  7018. );
  7019. break;
  7020. }
  7021. }
  7022. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7023. if (vmForm) {
  7024. //console.log("vmForm>>>");//console.log(vmForm);
  7025. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7026. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7027. }
  7028. });
  7029. };
  7030. },
  7031. ],
  7032. });
  7033. //待处理问题列表
  7034. formlyConfigProvider.setType({
  7035. name: "ui-ngproblemtable",
  7036. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7037. defaultOptions: function (options) {
  7038. return {
  7039. templateOptions: {
  7040. // relationAction: function() {
  7041. // options.hideExpression = true
  7042. // }
  7043. },
  7044. };
  7045. },
  7046. controller: [
  7047. "$scope",
  7048. "$modal",
  7049. "$timeout",
  7050. "SweetAlert",
  7051. "api_bpm_data",
  7052. "$rootScope",
  7053. "ngTableParams",
  7054. "$filter",
  7055. "$state",
  7056. function (
  7057. $scope,
  7058. $modal,
  7059. $timeout,
  7060. SweetAlert,
  7061. api_bpm_data,
  7062. $rootScope,
  7063. ngTableParams,
  7064. $filter,
  7065. $state
  7066. ) {
  7067. var filterData = {
  7068. assignee: $rootScope.user.id,
  7069. candidateGroups: $rootScope.user.group[0].id,
  7070. searchtype: "todo",
  7071. idx: 0,
  7072. sum: 10,
  7073. };
  7074. $scope.incidentprocess = function (item) {
  7075. $state.go("app.wt_change.add", {
  7076. taskId: item.taskId,
  7077. processInstanceId: item.processInstanceId,
  7078. });
  7079. };
  7080. $scope.more = function () {
  7081. $state.go("app.wt_change.list", {});
  7082. };
  7083. api_bpm_data
  7084. .fetchDataList("changeclassify", filterData)
  7085. .then(function (data) {
  7086. if (data.data) {
  7087. $scope.myData = data.data;
  7088. } else {
  7089. SweetAlert.swal({
  7090. title: "操作异常!",
  7091. text: "系统异常,请稍后重试,或者联系管理员!",
  7092. type: "error",
  7093. });
  7094. }
  7095. });
  7096. $scope.removes = function () {
  7097. var modalInstance = $modal.open({
  7098. templateUrl: "assets/views/delete.html",
  7099. controller: function ($scope, $modalInstance) {
  7100. $scope.ok = function () {
  7101. $modalInstance.close();
  7102. };
  7103. $scope.cancel = function () {
  7104. $modalInstance.dismiss("cancel");
  7105. };
  7106. },
  7107. size: "sm",
  7108. });
  7109. modalInstance.result.then(function () {
  7110. console.log($scope.$parent.$parent.$parent.$parent);
  7111. for (
  7112. var i = 0;
  7113. i <
  7114. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7115. i++
  7116. ) {
  7117. if (
  7118. $scope.fields.type ==
  7119. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7120. .type
  7121. ) {
  7122. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7123. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7124. i,
  7125. 1
  7126. );
  7127. break;
  7128. }
  7129. }
  7130. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7131. if (vmForm) {
  7132. //console.log("vmForm>>>");//console.log(vmForm);
  7133. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7134. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7135. }
  7136. });
  7137. };
  7138. },
  7139. ],
  7140. });
  7141. //待处理工单列表
  7142. formlyConfigProvider.setType({
  7143. name: "ui-ngtable",
  7144. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7145. defaultOptions: function (options) {
  7146. return {
  7147. templateOptions: {
  7148. // relationAction: function() {
  7149. // options.hideExpression = true
  7150. // }
  7151. },
  7152. };
  7153. },
  7154. controller: [
  7155. "$scope",
  7156. "$modal",
  7157. "$timeout",
  7158. "SweetAlert",
  7159. "api_bpm_domain",
  7160. "$rootScope",
  7161. "ngTableParams",
  7162. "$filter",
  7163. "$state",
  7164. function (
  7165. $scope,
  7166. $modal,
  7167. $timeout,
  7168. SweetAlert,
  7169. api_bpm_domain,
  7170. $rootScope,
  7171. ngTableParams,
  7172. $filter,
  7173. $state
  7174. ) {
  7175. var filterData = {
  7176. assignee: $rootScope.user.id,
  7177. candidateGroups: $rootScope.user.group[0].id,
  7178. searchtype: "done",
  7179. idx: 0,
  7180. sum: 10,
  7181. };
  7182. $scope.incidentprocess = function (item) {
  7183. $state.go("app.incident.editor", {
  7184. taskId: item.taskId,
  7185. processInstanceId: item.processInstanceId,
  7186. });
  7187. };
  7188. $scope.more = function () {
  7189. $state.go("app.incident.list", {});
  7190. };
  7191. api_bpm_domain
  7192. .fetchtask("bpm_incident", filterData)
  7193. .then(function (data) {
  7194. if (data.data) {
  7195. $scope.myData = data.data;
  7196. } else {
  7197. SweetAlert.swal({
  7198. title: "操作异常!",
  7199. text: "系统异常,请稍后重试,或者联系管理员!",
  7200. type: "error",
  7201. });
  7202. }
  7203. });
  7204. $scope.removes = function () {
  7205. var modalInstance = $modal.open({
  7206. templateUrl: "assets/views/delete.html",
  7207. controller: function ($scope, $modalInstance) {
  7208. $scope.ok = function () {
  7209. $modalInstance.close();
  7210. };
  7211. $scope.cancel = function () {
  7212. $modalInstance.dismiss("cancel");
  7213. };
  7214. },
  7215. size: "sm",
  7216. });
  7217. modalInstance.result.then(function () {
  7218. console.log($scope.$parent.$parent.$parent.$parent);
  7219. for (
  7220. var i = 0;
  7221. i <
  7222. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7223. i++
  7224. ) {
  7225. if (
  7226. $scope.fields.type ==
  7227. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7228. .type
  7229. ) {
  7230. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7231. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7232. i,
  7233. 1
  7234. );
  7235. break;
  7236. }
  7237. }
  7238. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7239. if (vmForm) {
  7240. //console.log("vmForm>>>");//console.log(vmForm);
  7241. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7242. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7243. }
  7244. });
  7245. };
  7246. },
  7247. ],
  7248. });
  7249. //知识库列表
  7250. formlyConfigProvider.setType({
  7251. name: "ui-knowledge",
  7252. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7253. defaultOptions: function (options) {
  7254. return {
  7255. templateOptions: {
  7256. // relationAction: function() {
  7257. // options.hideExpression = true
  7258. // }
  7259. },
  7260. };
  7261. },
  7262. controller: [
  7263. "$scope",
  7264. "$modal",
  7265. "$timeout",
  7266. "api_solution",
  7267. "$rootScope",
  7268. "ngTableParams",
  7269. "$filter",
  7270. "$state",
  7271. function (
  7272. $scope,
  7273. $modal,
  7274. $timeout,
  7275. api_solution,
  7276. $rootScope,
  7277. ngTableParams,
  7278. $filter,
  7279. $state
  7280. ) {
  7281. var filterData = {
  7282. key: "null",
  7283. pageIndex: 0,
  7284. pageSum: 6,
  7285. status: 0,
  7286. userId: $rootScope.user.id,
  7287. };
  7288. $scope.model.removereport = false;
  7289. $scope.removes = function () {
  7290. $scope.model.removereport = true;
  7291. };
  7292. $scope.more = function () {
  7293. $state.go("app.knowledge.manager", {});
  7294. };
  7295. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7296. if (data.status == 200) {
  7297. $scope.myData = data.list;
  7298. }
  7299. });
  7300. $scope.removes = function () {
  7301. var modalInstance = $modal.open({
  7302. templateUrl: "assets/views/delete.html",
  7303. controller: function ($scope, $modalInstance) {
  7304. $scope.ok = function () {
  7305. $modalInstance.close();
  7306. };
  7307. $scope.cancel = function () {
  7308. $modalInstance.dismiss("cancel");
  7309. };
  7310. },
  7311. size: "sm",
  7312. });
  7313. modalInstance.result.then(function () {
  7314. for (
  7315. var i = 0;
  7316. i <
  7317. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7318. i++
  7319. ) {
  7320. if (
  7321. $scope.fields.type ==
  7322. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7323. .type
  7324. ) {
  7325. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7326. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7327. i,
  7328. 1
  7329. );
  7330. break;
  7331. }
  7332. }
  7333. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7334. if (vmForm) {
  7335. //console.log("vmForm>>>");//console.log(vmForm);
  7336. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7337. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7338. }
  7339. });
  7340. };
  7341. },
  7342. ],
  7343. });
  7344. //公告列表
  7345. formlyConfigProvider.setType({
  7346. name: "ui-ngnotice",
  7347. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7348. defaultOptions: function (options) {
  7349. return {
  7350. templateOptions: {
  7351. // relationAction: function() {
  7352. // options.hideExpression = true
  7353. // }
  7354. },
  7355. };
  7356. },
  7357. controller: [
  7358. "$scope",
  7359. "$modal",
  7360. "$timeout",
  7361. "SweetAlert",
  7362. "api_user_data",
  7363. "$rootScope",
  7364. "ngTableParams",
  7365. "$filter",
  7366. "$state",
  7367. function (
  7368. $scope,
  7369. $modal,
  7370. $timeout,
  7371. SweetAlert,
  7372. api_user_data,
  7373. $rootScope,
  7374. ngTableParams,
  7375. $filter,
  7376. $state
  7377. ) {
  7378. var filterData = {
  7379. idx: 0,
  7380. sum: 10,
  7381. };
  7382. // $scope.$scope.model.className = "col-xs-12";
  7383. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7384. if (data) {
  7385. $scope.myData = data.data;
  7386. } else {
  7387. SweetAlert.swal({
  7388. title: "操作异常!",
  7389. text: "系统异常,请稍后重试,或者联系管理员!",
  7390. type: "error",
  7391. });
  7392. }
  7393. });
  7394. $scope.more = function () {
  7395. $state.go("app.system.notice.list", {});
  7396. };
  7397. $scope.removes = function () {
  7398. var modalInstance = $modal.open({
  7399. templateUrl: "assets/views/delete.html",
  7400. controller: function ($scope, $modalInstance) {
  7401. $scope.ok = function () {
  7402. $modalInstance.close();
  7403. };
  7404. $scope.cancel = function () {
  7405. $modalInstance.dismiss("cancel");
  7406. };
  7407. },
  7408. size: "sm",
  7409. });
  7410. modalInstance.result.then(function () {
  7411. for (
  7412. var i = 0;
  7413. i <
  7414. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7415. i++
  7416. ) {
  7417. if (
  7418. $scope.fields.type ==
  7419. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7420. .type
  7421. ) {
  7422. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7423. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7424. i,
  7425. 1
  7426. );
  7427. break;
  7428. }
  7429. }
  7430. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7431. if (vmForm) {
  7432. //console.log("vmForm>>>");//console.log(vmForm);
  7433. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7434. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7435. }
  7436. });
  7437. };
  7438. },
  7439. ],
  7440. });
  7441. //事件统计图
  7442. formlyConfigProvider.setType({
  7443. name: "ui-incidentreport",
  7444. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7445. defaultOptions: function (options) {
  7446. return {
  7447. templateOptions: {
  7448. // relationAction: function() {
  7449. // options.hideExpression = true
  7450. // }
  7451. },
  7452. };
  7453. },
  7454. controller: [
  7455. "$scope",
  7456. "$modal",
  7457. "moment",
  7458. "api_report",
  7459. "$cookieStore",
  7460. function ($scope, $modal, moment, api_report, $cookieStore) {
  7461. api_report.getLicenseKey().then(function (response) {
  7462. $cookieStore.put("Auth-Token", response.token);
  7463. $scope.try_async_load();
  7464. });
  7465. $scope.try_async_load = function () {
  7466. $scope.my_data = [];
  7467. api_report.list().then(function (response) {
  7468. var dataList = response;
  7469. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7470. $scope.repoRoot.name = "事件报表";
  7471. convertRepoObject($scope.repoRoot);
  7472. $scope.my_data.push($scope.repoRoot);
  7473. });
  7474. };
  7475. var workspace = {};
  7476. $scope.repoRoot = null;
  7477. function getRepoRoot(repo, path) {
  7478. angular.forEach(repo, function (value, key) {
  7479. if (value.path == path) {
  7480. $scope.repoRoot = value;
  7481. } else {
  7482. if (
  7483. $scope.repoRoot == null &&
  7484. angular.isDefined(value.repoObjects)
  7485. ) {
  7486. getRepoRoot(value.repoObjects, path);
  7487. } else {
  7488. }
  7489. }
  7490. });
  7491. }
  7492. function convertRepoObject(repo) {
  7493. if (angular.isArray(repo)) {
  7494. angular.forEach(repo, function (value, key) {
  7495. convertRepoObject(value);
  7496. });
  7497. } else {
  7498. if (angular.isDefined(repo.name)) {
  7499. if (repo.name.indexOf(".") >= 0) {
  7500. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7501. } else {
  7502. repo.label = repo.name;
  7503. }
  7504. //delete repo.name;
  7505. }
  7506. if (angular.isDefined(repo.repoObjects)) {
  7507. repo.children = [];
  7508. repo.children = repo.repoObjects;
  7509. delete repo.repoObjects;
  7510. convertRepoObject(repo.children);
  7511. }
  7512. }
  7513. }
  7514. function parseDateParameter(parameters) {
  7515. var result = undefined;
  7516. if (angular.isArray(parameters)) {
  7517. // angular.forEach(parmeters,function(param){
  7518. // param.
  7519. // })
  7520. } else {
  7521. result = {};
  7522. for (var k in parameters) {
  7523. if (k.indexOf("Date") > 0) {
  7524. if (angular.isString(parameters[k])) {
  7525. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7526. "YYYY-MM-DD"
  7527. );
  7528. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7529. }
  7530. }
  7531. }
  7532. }
  7533. return result;
  7534. }
  7535. function ConvertDateParameter(parameters) {
  7536. var result = undefined;
  7537. if (angular.isArray(parameters)) {
  7538. //
  7539. } else {
  7540. result = {};
  7541. for (var k in parameters) {
  7542. if (k.indexOf("Date") > 0) {
  7543. if (angular.isDate(parameters[k])) {
  7544. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7545. } else if (angular.isString(parameters[k])) {
  7546. result[k] = parameters[k];
  7547. }
  7548. }
  7549. }
  7550. }
  7551. return result;
  7552. }
  7553. var incidentchart =
  7554. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7555. var queryUUID;
  7556. function genUUID() {
  7557. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7558. .replace(/[xy]/g, function (c) {
  7559. var r = (Math.random() * 16) | 0,
  7560. v = c == "x" ? r : (r & 0x3) | 0x8;
  7561. return v.toString(16);
  7562. })
  7563. .toUpperCase();
  7564. return uuid;
  7565. }
  7566. queryUUID = genUUID();
  7567. var pathincidenttimekey = [];
  7568. var incidenttime = {
  7569. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7570. "YYYYMMDD"
  7571. ),
  7572. endtimes: moment(new Date()).format("YYYYMMDD"),
  7573. };
  7574. var thisday = moment(new Date().getTime() + 86400000).format(
  7575. "YYYYMMDD"
  7576. );
  7577. var thisdaymine = Date.parse(
  7578. thisday.substr(4, 2) +
  7579. "/" +
  7580. thisday.substr(6, 2) +
  7581. "/" +
  7582. thisday.substr(0, 4)
  7583. );
  7584. var averages = [
  7585. [thisdaymine - 86400000 * 14, 0],
  7586. [thisdaymine - 86400000 * 13, 0],
  7587. [thisdaymine - 86400000 * 12, 0],
  7588. [thisdaymine - 86400000 * 11, 0],
  7589. [thisdaymine - 86400000 * 10, 0],
  7590. [thisdaymine - 86400000 * 9, 0],
  7591. [thisdaymine - 86400000 * 8, 0],
  7592. [thisdaymine - 86400000 * 7, 0],
  7593. [thisdaymine - 86400000 * 6, 0],
  7594. [thisdaymine - 86400000 * 5, 0],
  7595. [thisdaymine - 86400000 * 4, 0],
  7596. [thisdaymine - 86400000 * 3, 0],
  7597. [thisdaymine - 86400000 * 2, 0],
  7598. [thisdaymine - 86400000 * 1, 0],
  7599. [thisdaymine, 0],
  7600. ];
  7601. var getreportdata = function (incidenttime, path) {
  7602. api_report.getMdx(path, queryUUID).then(function (response) {
  7603. var mdxquery = response;
  7604. workspace.query = mdxquery;
  7605. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7606. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7607. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7608. weekuser(mdxquery);
  7609. });
  7610. };
  7611. getreportdata(incidenttime, incidentchart);
  7612. var weekuser = function (mdxquery) {
  7613. var key = [];
  7614. api_report.execute(mdxquery).then(function (data) {
  7615. $scope.rheaders = [];
  7616. $scope.rRows = [];
  7617. var reportData = data;
  7618. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7619. $scope.shows = true;
  7620. $scope.empty = "数据为空!";
  7621. } else {
  7622. angular.forEach(reportData.cellset, function (item, i) {
  7623. angular.forEach(averages, function (index, j) {
  7624. // angular.forEach(averages, function(item, index) {
  7625. if (item.length > 1 && i > 0 && item[1].value != "") {
  7626. if (
  7627. index[0] ==
  7628. Date.parse(
  7629. item[0].value.substr(4, 2) +
  7630. "/" +
  7631. item[0].value.substr(6, 2) +
  7632. "/" +
  7633. item[0].value.substr(0, 4)
  7634. ) +
  7635. 86400000
  7636. ) {
  7637. index[1] = Number(item[1].value);
  7638. }
  7639. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  7640. }
  7641. // })
  7642. });
  7643. });
  7644. incidentchartfun(averages);
  7645. }
  7646. });
  7647. };
  7648. var incidentchartfun = function (incidentchartkey) {
  7649. // $scope.isMaskincident = false;
  7650. Highcharts.chart("incidentchart", {
  7651. title: {
  7652. text: "事件近15天趋势图",
  7653. },
  7654. xAxis: {
  7655. type: "datetime",
  7656. labels: {
  7657. align: "left",
  7658. step: 1,
  7659. },
  7660. },
  7661. yAxis: {
  7662. title: {
  7663. text: null,
  7664. },
  7665. },
  7666. tooltip: {
  7667. crosshairs: true,
  7668. shared: true,
  7669. valueSuffix: "条",
  7670. },
  7671. legend: {},
  7672. series: [
  7673. {
  7674. name: "生成事件",
  7675. data: incidentchartkey,
  7676. zIndex: 1,
  7677. marker: {
  7678. fillColor: "white",
  7679. lineWidth: 2,
  7680. lineColor: Highcharts.getOptions().colors[0],
  7681. },
  7682. },
  7683. ],
  7684. });
  7685. };
  7686. $scope.data = {
  7687. labels: [
  7688. "1号",
  7689. "2号",
  7690. "3号",
  7691. "4号",
  7692. "5号",
  7693. "6号",
  7694. "7号",
  7695. "8号",
  7696. "9号",
  7697. "10号",
  7698. "11号",
  7699. "12号",
  7700. "13号",
  7701. "14号",
  7702. "15号",
  7703. ],
  7704. datasets: [
  7705. {
  7706. label: "新增事件数量",
  7707. fillColor: "rgba(220,220,220,0.2)",
  7708. strokeColor: "rgba(220,220,220,1)",
  7709. pointColor: "rgba(220,220,220,1)",
  7710. pointStrokeColor: "#fff",
  7711. pointHighlightFill: "#fff",
  7712. pointHighlightStroke: "rgba(220,220,220,1)",
  7713. data: [
  7714. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7715. ],
  7716. },
  7717. {
  7718. label: "已解决事件数量",
  7719. fillColor: "rgba(151,187,205,0.2)",
  7720. strokeColor: "rgba(151,187,205,1)",
  7721. pointColor: "rgba(151,187,205,1)",
  7722. pointStrokeColor: "#fff",
  7723. pointHighlightFill: "#fff",
  7724. pointHighlightStroke: "rgba(151,187,205,1)",
  7725. data: [
  7726. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7727. ],
  7728. },
  7729. ],
  7730. };
  7731. $scope.removes = function () {
  7732. var modalInstance = $modal.open({
  7733. templateUrl: "assets/views/delete.html",
  7734. controller: function ($scope, $modalInstance) {
  7735. $scope.ok = function () {
  7736. $modalInstance.close();
  7737. };
  7738. $scope.cancel = function () {
  7739. $modalInstance.dismiss("cancel");
  7740. };
  7741. },
  7742. size: "sm",
  7743. });
  7744. modalInstance.result.then(function () {
  7745. for (
  7746. var i = 0;
  7747. i <
  7748. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7749. i++
  7750. ) {
  7751. if (
  7752. $scope.fields.type ==
  7753. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7754. .type
  7755. ) {
  7756. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7757. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7758. i,
  7759. 1
  7760. );
  7761. break;
  7762. }
  7763. }
  7764. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7765. if (vmForm) {
  7766. //console.log("vmForm>>>");//console.log(vmForm);
  7767. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7768. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7769. }
  7770. });
  7771. };
  7772. var addDatas = 0;
  7773. var resolve = 0;
  7774. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7775. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7776. }
  7777. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7778. resolve = resolve + $scope.data.datasets[1].data[i];
  7779. }
  7780. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7781. $scope.opt = {
  7782. maintainAspectRatio: false,
  7783. // Sets the chart to be responsive
  7784. responsive: true,
  7785. ///Boolean - Whether grid lines are shown across the chart
  7786. scaleShowGridLines: true,
  7787. //String - Colour of the grid lines
  7788. scaleGridLineColor: "rgba(0,0,0,.05)",
  7789. //Number - Width of the grid lines
  7790. scaleGridLineWidth: 1,
  7791. //Boolean - Whether the line is curved between points
  7792. bezierCurve: false,
  7793. //Number - Tension of the bezier curve between points
  7794. bezierCurveTension: 0.4,
  7795. //Boolean - Whether to show a dot for each point
  7796. pointDot: true,
  7797. //Number - Radius of each point dot in pixels
  7798. pointDotRadius: 4,
  7799. //Number - Pixel width of point dot stroke
  7800. pointDotStrokeWidth: 1,
  7801. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7802. pointHitDetectionRadius: 20,
  7803. //Boolean - Whether to show a stroke for datasets
  7804. datasetStroke: true,
  7805. //Number - Pixel width of dataset stroke
  7806. datasetStrokeWidth: 2,
  7807. //Boolean - Whether to fill the dataset with a colour
  7808. datasetFill: true,
  7809. // Function - on animation progress
  7810. onAnimationProgress: function () { },
  7811. // Function - on animation complete
  7812. onAnimationComplete: function () { },
  7813. //String - A legend template
  7814. legendTemplate:
  7815. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7816. };
  7817. angular.extend($scope.options, $scope.opt);
  7818. $scope.datamonth = {
  7819. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7820. datasets: [
  7821. {
  7822. label: "新增事件数量",
  7823. fillColor: "rgba(220,220,220,0.5)",
  7824. strokeColor: "rgba(220,220,220,0.8)",
  7825. highlightFill: "rgba(220,220,220,0.75)",
  7826. highlightStroke: "rgba(220,220,220,1)",
  7827. data: [65, 59, 80, 81, 56, 55],
  7828. },
  7829. {
  7830. label: "已解决事件数量",
  7831. fillColor: "rgba(151,187,205,0.5)",
  7832. strokeColor: "rgba(151,187,205,0.8)",
  7833. highlightFill: "rgba(151,187,205,0.75)",
  7834. highlightStroke: "rgba(151,187,205,1)",
  7835. data: [28, 48, 40, 19, 86, 27],
  7836. },
  7837. ],
  7838. };
  7839. // Chart.js Options
  7840. $scope.taption = {
  7841. maintainAspectRatio: false,
  7842. // Sets the chart to be responsive
  7843. responsive: true,
  7844. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7845. scaleBeginAtZero: true,
  7846. //Boolean - Whether grid lines are shown across the chart
  7847. scaleShowGridLines: true,
  7848. //String - Colour of the grid lines
  7849. scaleGridLineColor: "rgba(0,0,0,.05)",
  7850. //Number - Width of the grid lines
  7851. scaleGridLineWidth: 1,
  7852. //Boolean - If there is a stroke on each bar
  7853. barShowStroke: true,
  7854. //Number - Pixel width of the bar stroke
  7855. barStrokeWidth: 2,
  7856. //Number - Spacing between each of the X value sets
  7857. barValueSpacing: 5,
  7858. //Number - Spacing between data sets within X values
  7859. barDatasetSpacing: 1,
  7860. //String - A legend template
  7861. legendTemplate:
  7862. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7863. };
  7864. },
  7865. ],
  7866. });
  7867. //排版日历
  7868. formlyConfigProvider.setType({
  7869. name: "ui-dashcalendar",
  7870. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7871. defaultOptions: function (options) {
  7872. return {
  7873. templateOptions: {
  7874. // relationAction: function() {
  7875. // options.hideExpression = true
  7876. // }
  7877. },
  7878. };
  7879. },
  7880. controller: [
  7881. "$rootScope",
  7882. "$scope",
  7883. "$modal",
  7884. "$aside",
  7885. "calendarConfig",
  7886. "moment",
  7887. "SweetAlert",
  7888. "Restangular",
  7889. "api_bpm_schedule",
  7890. "api_user_data",
  7891. "$state",
  7892. function (
  7893. $rootScope,
  7894. $scope,
  7895. $modal,
  7896. $aside,
  7897. calendarConfig,
  7898. moment,
  7899. SweetAlert,
  7900. Restangular,
  7901. api_bpm_schedule,
  7902. api_user_data,
  7903. $state
  7904. ) {
  7905. var loginUser = $rootScope.user;
  7906. calendarConfig.dateFormatter = "moment";
  7907. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7908. calendarConfig.i18nStrings.timeLabel = "时间";
  7909. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7910. calendarConfig.allDateFormats = {
  7911. angular: {
  7912. date: {
  7913. hour: "ha",
  7914. day: "d MMM",
  7915. month: "MMMM",
  7916. weekDay: "EEEE",
  7917. time: "HH:mm",
  7918. datetime: "MMM d, h:mm a",
  7919. },
  7920. title: {
  7921. day: "yyyy MMMM EEEE d",
  7922. week: "{year}年第{week}周",
  7923. month: "yyyy MMMM",
  7924. year: "yyyy",
  7925. },
  7926. },
  7927. moment: {
  7928. date: {
  7929. hour: "ha",
  7930. day: "MMMDD日",
  7931. month: "MMMM",
  7932. weekDay: "dddd",
  7933. time: "HH:mm",
  7934. datetime: "MMM D, h:mm a",
  7935. },
  7936. title: {
  7937. day: "YYYY年MMMMDD日, dddd ",
  7938. week: "{year}年第{week}周",
  7939. month: "YYYY年MMMM",
  7940. year: "YYYY",
  7941. },
  7942. },
  7943. };
  7944. moment.locale("zh_cn", {
  7945. months:
  7946. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7947. "_"
  7948. ),
  7949. monthsShort:
  7950. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7951. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7952. "_"
  7953. ),
  7954. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7955. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7956. longDateFormat: {
  7957. LT: "Ah点mm分",
  7958. LTS: "Ah点m分s秒",
  7959. L: "YYYY-MM-DD",
  7960. LL: "YYYY年MMMD日",
  7961. LLL: "YYYY年MMMD日Ah点mm分",
  7962. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7963. l: "YYYY-MM-DD",
  7964. ll: "YYYY年MMMD日",
  7965. lll: "YYYY年MMMD日Ah点mm分",
  7966. llll: "YYYY年MMMD日ddddAh点mm分",
  7967. },
  7968. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7969. meridiemHour: function (hour, meridiem) {
  7970. if (hour === 12) {
  7971. hour = 0;
  7972. }
  7973. if (
  7974. meridiem === "凌晨" ||
  7975. meridiem === "早上" ||
  7976. meridiem === "上午"
  7977. ) {
  7978. return hour;
  7979. } else if (meridiem === "下午" || meridiem === "晚上") {
  7980. return hour + 12;
  7981. } else {
  7982. // '中午'
  7983. return hour >= 11 ? hour : hour + 12;
  7984. }
  7985. },
  7986. meridiem: function (hour, minute, isLower) {
  7987. var hm = hour * 100 + minute;
  7988. if (hm < 600) {
  7989. return "凌晨";
  7990. } else if (hm < 900) {
  7991. return "早上";
  7992. } else if (hm < 1130) {
  7993. return "上午";
  7994. } else if (hm < 1230) {
  7995. return "中午";
  7996. } else if (hm < 1800) {
  7997. return "下午";
  7998. } else {
  7999. return "晚上";
  8000. }
  8001. },
  8002. calendar: {
  8003. sameDay: function () {
  8004. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8005. },
  8006. nextDay: function () {
  8007. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8008. },
  8009. lastDay: function () {
  8010. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8011. },
  8012. nextWeek: function () {
  8013. var startOfWeek, prefix;
  8014. startOfWeek = moment().startOf("week");
  8015. prefix =
  8016. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8017. ? "[下]"
  8018. : "[本]";
  8019. return this.minutes() === 0
  8020. ? prefix + "dddAh点整"
  8021. : prefix + "dddAh点mm";
  8022. },
  8023. lastWeek: function () {
  8024. var startOfWeek, prefix;
  8025. startOfWeek = moment().startOf("week");
  8026. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8027. return this.minutes() === 0
  8028. ? prefix + "dddAh点整"
  8029. : prefix + "dddAh点mm";
  8030. },
  8031. sameElse: "LL",
  8032. },
  8033. ordinalParse: /\d{1,2}(日|月|周)/,
  8034. ordinal: function (number, period) {
  8035. switch (period) {
  8036. case "d":
  8037. case "D":
  8038. case "DDD":
  8039. return number + "日";
  8040. case "M":
  8041. return number + "月";
  8042. case "w":
  8043. case "W":
  8044. return number + "周";
  8045. default:
  8046. return number;
  8047. }
  8048. },
  8049. relativeTime: {
  8050. future: "%s内",
  8051. past: "%s前",
  8052. s: "几秒",
  8053. m: "1 分钟",
  8054. mm: "%d 分钟",
  8055. h: "1 小时",
  8056. hh: "%d 小时",
  8057. d: "1 天",
  8058. dd: "%d 天",
  8059. M: "1 个月",
  8060. MM: "%d 个月",
  8061. y: "1 年",
  8062. yy: "%d 年",
  8063. },
  8064. week: {
  8065. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8066. dow: 1, // Monday is the first day of the week.
  8067. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8068. },
  8069. });
  8070. var date = new Date();
  8071. var d = date.getDate();
  8072. var m = date.getMonth();
  8073. var y = date.getFullYear();
  8074. var filterData = {
  8075. userId: loginUser.id,
  8076. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8077. "YYYY-MM-DD HH:mm:ss"
  8078. ),
  8079. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8080. "YYYY-MM-DD HH:mm:ss"
  8081. ),
  8082. };
  8083. var load = ($scope.load = function (filterData) {
  8084. api_bpm_schedule
  8085. .fetchSchedule(
  8086. filterData.userId,
  8087. filterData.startTime,
  8088. filterData.endTime
  8089. )
  8090. .then(function (response) {
  8091. if (response.status == 200) {
  8092. $scope.events = [];
  8093. var myData = response.list;
  8094. angular.forEach(myData, function (item) {
  8095. var eventTemp = {};
  8096. eventTemp.title = item.description;
  8097. eventTemp.type = item.scheduleClass.code;
  8098. eventTemp.startsAt = moment(
  8099. item["scheduleOrderDTO"].startTime
  8100. ).toDate();
  8101. eventTemp.endsAtTime = moment(
  8102. item["scheduleOrderDTO"].endTime
  8103. ).toDate();
  8104. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8105. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8106. //eventTemp.ends_at = moment(item.endTime).toDate();
  8107. eventTemp.id = item.id;
  8108. eventTemp.deletable = false;
  8109. eventTemp.user = item.user;
  8110. $scope.events.push(eventTemp);
  8111. });
  8112. }
  8113. });
  8114. });
  8115. // var load = $scope.load = function(filterData){
  8116. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8117. // console.log("response="+JSON.stringify(response));
  8118. // if(response.status==200){
  8119. // $scope.events = [];
  8120. // console.log(response.list);
  8121. // var myData = response.list;
  8122. // angular.forEach(myData,function(item){
  8123. // var eventTemp = {};
  8124. // eventTemp.title = item.description;
  8125. // eventTemp.type = item.scheduleClass.code;
  8126. // eventTemp.startsAt = moment(item.startTime).toDate();
  8127. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8128. // eventTemp.startTime = item.startTime;
  8129. // eventTemp.endTime = item.endTime;
  8130. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8131. // eventTemp.id = item.id;
  8132. // eventTemp.deletable = false;
  8133. // eventTemp.users = item.users;
  8134. // $scope.events.push(eventTemp);
  8135. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8136. // })
  8137. // }
  8138. // });
  8139. // }
  8140. $scope.scheduleClass = {};
  8141. var convertEvent = function (scheduleorder) {
  8142. var eventTemp = {};
  8143. eventTemp.title = scheduleorder.description;
  8144. eventTemp.type = scheduleorder.scheduleClass.code;
  8145. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8146. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8147. eventTemp.id = scheduleorder.id;
  8148. eventTemp.user = scheduleorder.user;
  8149. eventTemp.deletable = false;
  8150. return eventTemp;
  8151. };
  8152. // var convertEvent = function(scheduleorder){
  8153. // var eventTemp = {};
  8154. // eventTemp.title = scheduleorder.description;
  8155. // eventTemp.type = scheduleorder.scheduleClass.code;
  8156. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8157. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8158. // eventTemp.id = scheduleorder.id;
  8159. // eventTemp.users = scheduleorder.users;
  8160. // eventTemp.deletable = false;
  8161. // return eventTemp;
  8162. // }
  8163. api_bpm_schedule.getScheduleClass().then(function (response) {
  8164. if (response.status == 200) {
  8165. var scheduleClassList = response.list;
  8166. angular.forEach(scheduleClassList, function (item) {
  8167. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8168. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8169. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8170. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8171. $scope.scheduleClass[item["code"]] = item;
  8172. });
  8173. }
  8174. });
  8175. $scope.events = [];
  8176. $scope.calendarView = "month";
  8177. //$scope.calendarDay = new Date();
  8178. $scope.calendarDate = moment().startOf("month").toDate();
  8179. $scope.timeLabel = "时间";
  8180. $scope.eventLabel = "描述";
  8181. function showModal(action, event) {
  8182. // console.log("action="+JSON.stringify(action))
  8183. var modalInstance = $aside.open({
  8184. templateUrl: "scheduleEvent.html",
  8185. placement: "right",
  8186. size: "sm",
  8187. backdrop: true,
  8188. controller: function (
  8189. $scope,
  8190. $modalInstance,
  8191. scheduleClass,
  8192. APIService,
  8193. MementFormat
  8194. ) {
  8195. $scope.$modalInstance = $modalInstance;
  8196. $scope.action = action;
  8197. $scope.event = event;
  8198. $scope.scheduleClassic = scheduleClass;
  8199. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8200. // if(oldvalue == newvalue) return;
  8201. // if(scheduleClass[newvalue]){
  8202. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8203. var em = MementFormat(scheduleClass[newvalue].endTime);
  8204. console.log("sm=" + JSON.stringify(sm));
  8205. event.starts_at = MementFormat(event.startTime)
  8206. .startOf("day")
  8207. .add(sm.hour(), "hour")
  8208. .add(sm.minute(), "minute")
  8209. .add(sm.second(), "second")
  8210. .toDate();
  8211. console.log(
  8212. "event.starts_at=" + JSON.stringify(event.starts_at)
  8213. );
  8214. if (sm.hour() > em.hour()) {
  8215. event.ends_at = MementFormat(event.startTime)
  8216. .startOf("day")
  8217. .add(1, "day")
  8218. .add(em.hour(), "hour")
  8219. .add(em.minute(), "minute")
  8220. .add(em.second(), "second")
  8221. .toDate();
  8222. console.log(
  8223. "event.ends_at=" + JSON.stringify(event.starts_at)
  8224. );
  8225. } else {
  8226. event.ends_at = MementFormat(event.startTime)
  8227. .startOf("day")
  8228. .add(em.hour(), "hour")
  8229. .add(em.minute(), "minute")
  8230. .add(em.second(), "second")
  8231. .toDate();
  8232. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8233. }
  8234. // }
  8235. });
  8236. // $scope.ok = function (event) {
  8237. // console.log("event="+JSON.stringify(event))
  8238. // event.action = action;
  8239. // $modalInstance.close(event);
  8240. // };
  8241. $scope.cancel = function (event) {
  8242. $modalInstance.dismiss();
  8243. };
  8244. var acUserSelect = ($scope.refreshUser = function (key) {
  8245. //for test
  8246. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  8247. // return;
  8248. var data = {
  8249. idx: "0",
  8250. sum: "5",
  8251. user: {
  8252. engineer: 1,
  8253. }
  8254. };
  8255. if (key) {
  8256. data.user.name = key;
  8257. }
  8258. APIService.fetchDataList("user", data).then(function (
  8259. response
  8260. ) {
  8261. if (response) {
  8262. if ((response.status = 200)) {
  8263. $scope.users = response.list;
  8264. console.log($scope.users);
  8265. }
  8266. }
  8267. });
  8268. });
  8269. if (angular.isDefined(event.users) && event.users.length > 0) {
  8270. }
  8271. $scope.users = [event.user];
  8272. acUserSelect();
  8273. },
  8274. resolve: {
  8275. scheduleClass: function () {
  8276. return $scope.scheduleClass;
  8277. },
  8278. APIService: function () {
  8279. return api_user_data;
  8280. },
  8281. MementFormat: function () {
  8282. return moment;
  8283. },
  8284. },
  8285. });
  8286. modalInstance.result.then(function (selectedEvent) {
  8287. if (selectedEvent.action == "Clicked") {
  8288. // var data = {
  8289. // "scheduleorder":{
  8290. // "id":selectedEvent.id,
  8291. // "description":selectedEvent.title,
  8292. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8293. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8294. // "users":selectedEvent.users,
  8295. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8296. // }
  8297. // };
  8298. // api_bpm_schedule.update(data).then(function(response){
  8299. // if(response.status==200){
  8300. // SweetAlert.swal({
  8301. // title: "操作成功!",
  8302. // text: "排班更新成功!",
  8303. // type: "succes"
  8304. // });
  8305. // angular.forEach($scope.events,function(item){
  8306. // if(item.id==selectedEvent.id){
  8307. // item = selectedEvent;
  8308. // }
  8309. // })
  8310. // }else{
  8311. // SweetAlert.swal({
  8312. // title: "操作失败",
  8313. // text: "排班更新失败,请稍后重试!",
  8314. // type: "error"
  8315. // })
  8316. // }
  8317. // })
  8318. } else {
  8319. //
  8320. }
  8321. });
  8322. }
  8323. $scope.moment = function (string) {
  8324. return moment(string);
  8325. };
  8326. $scope.eventClicked = function (event) {
  8327. // console.log("event="+JSON.stringify(event))
  8328. showModal("Clicked", event);
  8329. };
  8330. $scope.eventEdited = function (event) {
  8331. showModal("Edited", event);
  8332. };
  8333. var updateView = function (newvalue, oldvalue) {
  8334. if (oldvalue == newvalue) return;
  8335. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8336. if ($scope.calendarView == "year") {
  8337. } else if ($scope.calendarView == "month") {
  8338. timeStart = moment(newvalue).startOf("month");
  8339. timeEnd = moment(newvalue).endOf("month");
  8340. } else if ($scope.calendarView == "week") {
  8341. timeStart = moment(newvalue).startOf("week");
  8342. timeEnd = moment(newvalue).endOf("week");
  8343. } else if ($scope.calendarView == "Day") {
  8344. timeStart = moment(newvalue).startOf("day");
  8345. timeEnd = moment(newvalue).endOf("day");
  8346. }
  8347. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8348. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8349. filterData["startTime"] = timeStartSpan;
  8350. filterData["endTime"] = timeEndSpan;
  8351. load(filterData);
  8352. };
  8353. $scope.$watch("calendarDate", updateView);
  8354. $scope.next = function () {
  8355. $scope.calendarControl.next();
  8356. };
  8357. $scope.prev = function () {
  8358. $scope.calendarControl.prev();
  8359. };
  8360. $scope.setCalendarToToday = function () {
  8361. $scope.calendarDay = new Date();
  8362. };
  8363. $scope.toggle = function ($event, field, event) {
  8364. $event.preventDefault();
  8365. $event.stopPropagation();
  8366. event[field] = !event[field];
  8367. };
  8368. $scope.load(filterData);
  8369. $scope.more = function () {
  8370. $state.go("app.scheduling.myscheduling", {});
  8371. };
  8372. $scope.removes = function () {
  8373. var modalInstance = $modal.open({
  8374. templateUrl: "assets/views/delete.html",
  8375. controller: function ($scope, $modalInstance) {
  8376. $scope.ok = function () {
  8377. $modalInstance.close();
  8378. };
  8379. $scope.cancel = function () {
  8380. $modalInstance.dismiss("cancel");
  8381. };
  8382. },
  8383. size: "sm",
  8384. });
  8385. modalInstance.result.then(function () {
  8386. for (
  8387. var i = 0;
  8388. i <
  8389. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8390. i++
  8391. ) {
  8392. if (
  8393. $scope.fields.type ==
  8394. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8395. .type
  8396. ) {
  8397. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8398. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8399. i,
  8400. 1
  8401. );
  8402. break;
  8403. }
  8404. }
  8405. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8406. if (vmForm) {
  8407. //console.log("vmForm>>>");//console.log(vmForm);
  8408. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8409. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8410. }
  8411. });
  8412. };
  8413. },
  8414. ],
  8415. });
  8416. //空格组件
  8417. formlyConfigProvider.setType({
  8418. name: "ui-black",
  8419. /*extends: 'input',*/
  8420. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8421. });
  8422. //请求人最近事件
  8423. formlyConfigProvider.setType({
  8424. name: "ui-recentIncident",
  8425. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8426. controller: [
  8427. "$scope",
  8428. "$modal",
  8429. "api_solution",
  8430. function ($scope, $modal, api_solution) {
  8431. var filterData = {
  8432. incident: {
  8433. requester: {
  8434. id: "",
  8435. },
  8436. },
  8437. idx: 0,
  8438. sum: 3,
  8439. };
  8440. setInterval(function () {
  8441. if (
  8442. filterData.incident.requester.id == "" ||
  8443. filterData.incident.requester.id != $scope.model.requester.id
  8444. ) {
  8445. var requester = $scope.model.requester;
  8446. if (requester != null && angular.isDefined(requester.id)) {
  8447. filterData.incident.requester.id = $scope.model.requester.id;
  8448. $scope.options.templateOptions
  8449. .getWorkernumber(
  8450. $scope.options.templateOptions.ApiService,
  8451. filterData
  8452. )
  8453. .then(function (result) {
  8454. var modelData =
  8455. $scope.options.templateOptions.Restangular.stripRestangular(
  8456. result
  8457. );
  8458. if (modelData.status == 200) {
  8459. $scope.lastrequst = modelData.list;
  8460. }
  8461. });
  8462. requester = null;
  8463. } else {
  8464. }
  8465. } else {
  8466. }
  8467. }, 1000);
  8468. $scope.detail = function (data) {
  8469. var modalInstance = $modal.open({
  8470. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8471. controller: function ($scope, $modalInstance) {
  8472. $scope.entity = {};
  8473. $scope.entity = data;
  8474. $scope.cancel = function () {
  8475. $modalInstance.dismiss("cancel");
  8476. };
  8477. },
  8478. size: "lg",
  8479. });
  8480. };
  8481. },
  8482. ],
  8483. });
  8484. //参数列表
  8485. formlyConfigProvider.setType({
  8486. name: "ui-listinput",
  8487. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8488. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8489. defaultOptions: function (options) {
  8490. return {
  8491. templateOptions: {},
  8492. };
  8493. },
  8494. controller: ["$scope", function ($scope) { }],
  8495. });
  8496. //时间段控件(分)
  8497. formlyConfigProvider.setType({
  8498. name: "ui-timeslot",
  8499. extends: "input",
  8500. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8501. controller: ["$scope", function ($scope) { }],
  8502. });
  8503. //优先级级联-逾期时间
  8504. formlyConfigProvider.setType({
  8505. name: "ui-overtime",
  8506. extends: "input",
  8507. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8508. controller: [
  8509. "$scope",
  8510. "api_bpm_domain",
  8511. function ($scope, api_bpm_domain) {
  8512. var filteData = {};
  8513. var datas = {};
  8514. setInterval(function () {
  8515. if (
  8516. $scope.model.priority &&
  8517. $scope.model.priority.id != null &&
  8518. filteData &&
  8519. datas != $scope.model.priority.id
  8520. ) {
  8521. filteData = "L" + $scope.model.priority.id;
  8522. datas = $scope.model.priority.id;
  8523. // console.log($scope.options.templateOptions)
  8524. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8525. // var overtime=requester.date;
  8526. if (requester.state == 200) {
  8527. // if($scope.options.key=="date"){
  8528. $scope.model[$scope.options.key] = requester.date;
  8529. // }
  8530. }
  8531. });
  8532. }
  8533. }, 1000);
  8534. },
  8535. ],
  8536. });
  8537. formlyConfigProvider.setType({
  8538. name: "ui-responsetime",
  8539. extends: "input",
  8540. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8541. controller: [
  8542. "$scope",
  8543. "api_bpm_domain",
  8544. function ($scope, api_bpm_domain) {
  8545. var filteData = {};
  8546. var datas = {};
  8547. setInterval(function () {
  8548. if (
  8549. $scope.model.priority &&
  8550. $scope.model.priority.id != null &&
  8551. filteData &&
  8552. datas != $scope.model.priority.id
  8553. ) {
  8554. filteData = "L" + $scope.model.priority.id;
  8555. datas = $scope.model.priority.id;
  8556. // console.log($scope.options.templateOptions)
  8557. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8558. // var overtime=requester.date;
  8559. if (requester.state == 200) {
  8560. var keyName = {};
  8561. // $scope.model.overdueTime = requester.date;
  8562. if ($scope.options.key == "expectIntroTime") {
  8563. keyName = "resolveTime";
  8564. } else if ($scope.options.key == "expectResponseTime") {
  8565. keyName = "responseTime";
  8566. }
  8567. $scope.model[$scope.options.key] =
  8568. requester.serviceLevelAgreement[keyName];
  8569. // }
  8570. console.log($scope.$parent.$parent.$parent.model);
  8571. }
  8572. if (requester.date1) {
  8573. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8574. requester.date;
  8575. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8576. requester.date1;
  8577. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8578. requester.serviceLevelAgreement.resolveTime;
  8579. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8580. requester.serviceLevelAgreement.responseTime;
  8581. }
  8582. });
  8583. }
  8584. }, 1000);
  8585. },
  8586. ],
  8587. });
  8588. //知识库按钮组件
  8589. formlyConfigProvider.setType({
  8590. name: "ui-discasecade",
  8591. extends: "input",
  8592. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8593. defaultOptions: function (options) {
  8594. return {
  8595. templateOptions: {
  8596. relationAction: function (fields, modelscope, item) { },
  8597. },
  8598. validators: {
  8599. required: {
  8600. expression: function (viewValue, modelValue) {
  8601. var value = modelValue || viewValue;
  8602. // return value = "true";
  8603. },
  8604. },
  8605. },
  8606. };
  8607. },
  8608. controller: [
  8609. "$scope",
  8610. "$rootScope",
  8611. "$modal",
  8612. "SweetAlert",
  8613. "api_bpm_data",
  8614. "api_solution",
  8615. "$aside",
  8616. "api_zsk",
  8617. "api_bpm_domain",
  8618. function (
  8619. $scope,
  8620. $rootScope,
  8621. $modal,
  8622. SweetAlert,
  8623. api_bpm_data,
  8624. api_solution,
  8625. $aside,
  8626. api_zsk,
  8627. api_bpm_domain
  8628. ) {
  8629. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8630. $scope.searchField = $scope.options.model[$scope.options.key];
  8631. $scope.searchData = "";
  8632. $scope.onChangeadd = function (searchData) {
  8633. $scope.searchKey = searchData.account;
  8634. // $scope.searchDataadd = searchData;
  8635. var requesdata = angular.copy(searchData);
  8636. $scope.requester = requesdata;
  8637. };
  8638. $scope.refreshUseradd = function (searchKey) {
  8639. //主题搜索
  8640. $scope.searchData = searchKey;
  8641. reashdata($scope.searchData);
  8642. };
  8643. $scope.getMydata = function (x) {
  8644. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8645. $scope.searchField = $scope.model[$scope.options.key];
  8646. };
  8647. $scope.getMydataone = function (x) {
  8648. $scope.model[$scope.options.key] = x;
  8649. $scope.searchField = $scope.model[$scope.options.key];
  8650. };
  8651. $scope.fildata = {
  8652. idx: 0,
  8653. sum: 10,
  8654. // 'incident': { 'tilte': item }
  8655. };
  8656. function reashdata(item) {
  8657. if (item && item != "") {
  8658. angular.extend($scope.fildata, {
  8659. incident: {
  8660. title: item,
  8661. },
  8662. });
  8663. } else {
  8664. delete $scope.fildata.incident;
  8665. }
  8666. api_bpm_data
  8667. .fetchDataList("incident", $scope.fildata)
  8668. .then(function (response) {
  8669. if (response) {
  8670. if ((response.status = 200)) {
  8671. var myData = response;
  8672. $scope.myData = myData.list;
  8673. }
  8674. }
  8675. });
  8676. }
  8677. function delHtmlTag(str) {
  8678. return str.replace(/<[^>]+>/g, "");
  8679. }
  8680. // reashdata();
  8681. var changedata = {};
  8682. setInterval(function () {
  8683. if (
  8684. $scope.model.category != null &&
  8685. $scope.model.category.id != changedata.id &&
  8686. $scope.model.titles != $scope.model.category
  8687. ) {
  8688. $scope.searchData = {};
  8689. changedata = angular.copy($scope.model.category);
  8690. if ($scope.options.key == "title") {
  8691. var filterData = {
  8692. idx: 0,
  8693. sum: 1000,
  8694. };
  8695. api_bpm_data
  8696. .fetchDataList("incidentcategory", filterData)
  8697. .then(function (data) {
  8698. var datalist = data.list;
  8699. angular.forEach(datalist, function (item) {
  8700. if (item.id == $scope.model.category.id) {
  8701. $scope.model[$scope.options.key] = item.category;
  8702. $scope.searchField =
  8703. $scope.options.model[$scope.options.key];
  8704. $scope.titles = item.category;
  8705. titles = $scope.model.category;
  8706. }
  8707. });
  8708. });
  8709. }
  8710. }
  8711. }, 1000);
  8712. $scope.open = function (key, options, fildata, $event, model) {
  8713. if (key && key.length > 1) {
  8714. api_zsk
  8715. .solutionData(
  8716. {
  8717. solution: {
  8718. searchWord: key,
  8719. },
  8720. idx: "0",
  8721. sum: "1000",
  8722. },
  8723. "solution"
  8724. )
  8725. .then(function (response) {
  8726. if (response && response.list.length > 0) {
  8727. $scope.dlideboxslide = true;
  8728. angular.forEach(response, function (item) {
  8729. console.log(response);
  8730. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8731. // if (response.status == 200) {
  8732. // var quote = { 'totalNum': response.totalNum }
  8733. // item = angular.extend(item, quote)
  8734. // }
  8735. // })
  8736. $scope.searchData = response.list;
  8737. console.log($scope.searchData);
  8738. });
  8739. $scope.changes = false;
  8740. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8741. // $scope.closepages = function(e) {
  8742. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8743. // event.preventDefault();
  8744. // };
  8745. $scope.shows = false;
  8746. $scope.tempData = {};
  8747. $scope.showpage = function (item) {
  8748. item.content = delHtmlTag(item.content);
  8749. $scope.shows = true;
  8750. $scope.tempData = item;
  8751. if (item.content != null) {
  8752. $scope.tempData.content = $scope.tempData.content
  8753. .replace("<p>", "")
  8754. .replace("</p>", "");
  8755. }
  8756. $scope.knowledgedata = item;
  8757. $scope.pageid = item.id;
  8758. $scope.changes = !$scope.changes;
  8759. api_bpm_domain
  8760. .listAttachments(item.id)
  8761. // api_solution.fetchDataList('file', {
  8762. // "file": {
  8763. // "solutionId": item.id
  8764. // },
  8765. // "idx": "0",
  8766. // "sum": "1000"
  8767. // })
  8768. .then(function (data) {
  8769. if (data) {
  8770. $scope.attachments = data.list;
  8771. $scope.view = function (attachmentId) {
  8772. for (
  8773. var i = 0;
  8774. i < $scope.attachments.length;
  8775. i++
  8776. ) {
  8777. if ($scope.attachments[i].id == attachmentId) {
  8778. window.open($scope.attachments[i].previewUrl);
  8779. }
  8780. }
  8781. };
  8782. $scope.download = function (contentId, filename) {
  8783. api_solution
  8784. .getSolutionDowpath(contentId)
  8785. .then(function (response) {
  8786. var file = new Blob([response], {
  8787. type: "application/octet-stream",
  8788. });
  8789. // var filename = filename;
  8790. var fileURL = URL.createObjectURL(file);
  8791. var a = document.createElement("a");
  8792. a.href = fileURL;
  8793. a.target = "_blank";
  8794. a.download = filename;
  8795. document.body.appendChild(a);
  8796. a.click();
  8797. });
  8798. };
  8799. }
  8800. });
  8801. };
  8802. $scope.related = function (item) {
  8803. if (item.content != null) {
  8804. item.content = item.content
  8805. .replace("<p>", "")
  8806. .replace("</p>", "");
  8807. }
  8808. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8809. options.model.handleDescription = item.content;
  8810. var data = {
  8811. solutionQuote: {
  8812. solutionId: item.id,
  8813. incidentsign: options.model.incidentsign,
  8814. },
  8815. };
  8816. api_zsk.solutionQuote(item.id).then(function (response) {
  8817. if (response.status == 200) {
  8818. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8819. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8820. "close";
  8821. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8822. } else {
  8823. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8824. }
  8825. });
  8826. };
  8827. $scope.close = function () {
  8828. $scope.changes = !$scope.changes;
  8829. event.preventDefault();
  8830. };
  8831. }
  8832. });
  8833. }
  8834. };
  8835. },
  8836. ],
  8837. });
  8838. //侧滑选择重复事件
  8839. formlyConfigProvider.setType({
  8840. name: "ui-repeatIncidentbtn",
  8841. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8842. defaultOptions: function (options) {
  8843. return {
  8844. templateOptions: {
  8845. relationAction: function (fields, modelscope, item) { },
  8846. },
  8847. validators: {
  8848. required: {
  8849. expression: function (viewValue, modelValue) {
  8850. // var value = modelValue || viewValue;
  8851. },
  8852. },
  8853. },
  8854. };
  8855. },
  8856. controller: [
  8857. "$scope",
  8858. "$rootScope",
  8859. "$modal",
  8860. "SweetAlert",
  8861. "api_bpm_data",
  8862. "api_solution",
  8863. "$aside",
  8864. "api_zsk",
  8865. "api_bpm_domain",
  8866. "api_webservice1",
  8867. function (
  8868. $scope,
  8869. $rootScope,
  8870. $modal,
  8871. SweetAlert,
  8872. api_bpm_data,
  8873. api_solution,
  8874. $aside,
  8875. api_zsk,
  8876. api_bpm_domain,
  8877. api_webservice1
  8878. ) {
  8879. console.log($scope);
  8880. $scope.selection = {
  8881. id: "",
  8882. };
  8883. //认证计费数据获取
  8884. $scope.sumInfo = {};
  8885. function getSumInfo() {
  8886. $scope.isHk = $rootScope.isHk;
  8887. if($rootScope.isHk){
  8888. //用户信息
  8889. api_webservice1.fetchDataList("queryUser", { "userId": $scope.model.incident.account }).then(function(response) {
  8890. // if (response.status == 200) {
  8891. if (response && response.data) {
  8892. angular.extend($scope.sumInfo, response.data[0]);
  8893. // $scope.sumInfo = response.data[0];
  8894. $scope.sumInfo.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  8895. $scope.sumInfo.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  8896. $scope.sumInfo.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  8897. } else if (response.err) {
  8898. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  8899. }
  8900. // }
  8901. })
  8902. //上网明细
  8903. api_webservice1.fetchDataList("queryOnlineDetail", { "userId": $scope.model.incident.account, "limit": "10", "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'), "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') }).then(function(response) {
  8904. // if (response.status == 200) {
  8905. if (response && response.data) {
  8906. angular.forEach(response.data, function(item, index) {
  8907. if (item.logoutTime) {
  8908. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  8909. }
  8910. if (item.loginTime) {
  8911. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  8912. }
  8913. })
  8914. $scope.logininform_sumInfo = response.data;
  8915. } else if (response.err) {
  8916. SweetAlert.swal("上网明细未取到", "该用户暂无上网明细", "error");
  8917. }
  8918. })
  8919. //黑名单
  8920. // $scope.sumInfo.blacklist = "否"
  8921. api_webservice1.fetchDataList("queryInhibit", { "userId": $scope.model.incident.account }).then(function(response) {
  8922. // if (response.status == 200) {
  8923. // $scope.loginsumInfo = response.data;
  8924. if (response) {
  8925. if (response.data || response.data != null) {
  8926. $scope.sumInfo.blacklist = "是"
  8927. } else {
  8928. if (response.err) {
  8929. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  8930. } else {
  8931. $scope.sumInfo.blacklist = "否"
  8932. }
  8933. }
  8934. }
  8935. // }
  8936. })
  8937. }else{
  8938. // api_bpm_data
  8939. // .sumInfo($scope.model.incident.account)
  8940. // .then(function (data) {
  8941. // console.log(data);
  8942. // if (data) {
  8943. // $scope.sumInfo = data.data || {};
  8944. // }
  8945. // });
  8946. // 取消sum
  8947. $scope.sumInfo = {};
  8948. }
  8949. }
  8950. getSumInfo();
  8951. // 收起重复事件侧滑框
  8952. function reashdata(item) {
  8953. var fildata = {
  8954. idx: 0,
  8955. incident: {
  8956. department: {
  8957. id: $scope.model.incident.department.id,
  8958. },
  8959. },
  8960. sum: 3,
  8961. };
  8962. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8963. console.log(data);
  8964. if (data) {
  8965. $scope.repeatData = data.list;
  8966. }
  8967. });
  8968. }
  8969. reashdata();
  8970. // 确认选中的重复事件
  8971. $scope.repeatIncidentOk = function () {
  8972. if ($scope.selection.id) {
  8973. $scope.model.incident.repeat = $scope.selection;
  8974. $scope.model.isRepeat = true; //隐藏处理信息
  8975. console.log($scope.model);
  8976. }
  8977. angular.element("#repeatIncident").removeClass("active");
  8978. };
  8979. // 取消选中的重复事件
  8980. $scope.repeatIncidentCancle = function () {
  8981. angular.element("#repeatIncident").removeClass("active");
  8982. return;
  8983. };
  8984. },
  8985. ],
  8986. });
  8987. //侧滑选择知识库查询
  8988. formlyConfigProvider.setType({
  8989. name: "ui-knowledgebtn",
  8990. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8991. defaultOptions: function (options) {
  8992. return {
  8993. templateOptions: {
  8994. relationAction: function (fields, modelscope, item) { },
  8995. },
  8996. validators: {
  8997. required: {
  8998. expression: function (viewValue, modelValue) {
  8999. // var value = modelValue || viewValue;
  9000. },
  9001. },
  9002. },
  9003. };
  9004. },
  9005. controller: [
  9006. "$scope",
  9007. "$rootScope",
  9008. "$modal",
  9009. "SweetAlert",
  9010. "api_bpm_data",
  9011. "api_solution",
  9012. "$aside",
  9013. "api_zsk",
  9014. "api_bpm_domain",
  9015. "api_wechatfile",
  9016. "up_down_file",
  9017. function (
  9018. $scope,
  9019. $rootScope,
  9020. $modal,
  9021. SweetAlert,
  9022. api_bpm_data,
  9023. api_solution,
  9024. $aside,
  9025. api_zsk,
  9026. api_bpm_domain,
  9027. api_wechatfile,
  9028. up_down_file
  9029. ) {
  9030. $scope.keypressModel = function (e, key) {
  9031. if (e.keyCode === 13) {
  9032. $scope.openModel(key);
  9033. }
  9034. };
  9035. // 引用知识库点击
  9036. $scope.searchKeyWord = "";
  9037. $scope.openModel = function (key) {
  9038. // alert(1)//重点
  9039. $scope.searchKeyWord = key;
  9040. if (key) {
  9041. api_zsk
  9042. .solutionData(
  9043. {
  9044. solution: {
  9045. threeSearch: key,
  9046. status: { id: 72 }, //已发布
  9047. selectType: "keySearch",
  9048. },
  9049. idx: "0",
  9050. sum: "1000",
  9051. },
  9052. "solution"
  9053. )
  9054. .then(function (response) {
  9055. $scope.searchData = response.list;
  9056. });
  9057. }
  9058. };
  9059. $scope.openModel($scope.model.incident.description);
  9060. // 展开/收起
  9061. $scope.showId = "";
  9062. $scope.ifshow = false;
  9063. $scope.showAll = function (id) {
  9064. $scope.attachments = [];
  9065. if ($scope.showId == id) {
  9066. $scope.ifshow = !$scope.ifshow;
  9067. } else {
  9068. $scope.ifshow = true;
  9069. }
  9070. $scope.showId = id;
  9071. // 获取附件
  9072. api_wechatfile
  9073. .listAttachments("knowledge", $scope.showId)
  9074. .then(function (data) {
  9075. $scope.attachments = data.data;
  9076. $scope.download = function (token, filename) {
  9077. var downUrl = up_down_file
  9078. .downloadAttachment("common/common/downloadAttachment", token)
  9079. .getRequestedUrl();
  9080. // window.open(downUrl);
  9081. var a = document.createElement("a");
  9082. a.href = downUrl;
  9083. a.target = "_blank";
  9084. a.download = filename;
  9085. document.body.appendChild(a);
  9086. a.click();
  9087. };
  9088. });
  9089. };
  9090. // 引用
  9091. $scope.related = function (item) {
  9092. console.log(item, "引用名");
  9093. if (item.content) {
  9094. item.content = item.content
  9095. .replace(/<p>/g, "")
  9096. .replace(/<\/p>/g, "")
  9097. .replace(/&nbsp;/g, "");
  9098. }
  9099. $scope.model.incident.handleDescription = item.content;
  9100. $scope.model.incident.title = $scope.model.incident.description =
  9101. item.title;
  9102. $scope.model.incident.category = item.category;
  9103. if (item.category) {
  9104. $scope.model.incident.priority.id = item.category.priority.id;
  9105. item.category.label = item.category.category;
  9106. }
  9107. var categoryId = item.category ? item.category.id : "";
  9108. // 引用知识库故障现象后,修改故障现象选中状态,故障现象列表重载
  9109. function getres(nodes) {
  9110. if (!nodes || nodes.length == 0) {
  9111. return;
  9112. }
  9113. nodes.forEach((e) => {
  9114. e.selected = false;
  9115. if (e.id == categoryId) {
  9116. e.selected = true;
  9117. return false;
  9118. }
  9119. getres(e.children);
  9120. });
  9121. }
  9122. var categorys = [];
  9123. $scope.fields.forEach((e, i) => {
  9124. if (e.key == "category") {
  9125. categorys = e.templateOptions.options;
  9126. if (categorys.length) {
  9127. getres(categorys);
  9128. $scope.fields[i].templateOptions.options = categorys;
  9129. $scope.$root.refreshSelectedItems();
  9130. }
  9131. return false;
  9132. }
  9133. });
  9134. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9135. $scope.model.candidateGroups = item.category
  9136. ? item.category.group
  9137. : {};
  9138. // 携带关联优先级,事件工单信息的时间
  9139. if (
  9140. $scope.model &&
  9141. $scope.model.incident &&
  9142. item.category &&
  9143. item.category.priority &&
  9144. item.category.priority.id
  9145. ) {
  9146. api_bpm_domain
  9147. .expectedTime("L" + (item.category.priority.id - 1559))
  9148. .then(function (res) {
  9149. $scope.model.incident.expectResponseTime =
  9150. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9151. res.serviceLevelAgreement.responseTime;
  9152. $scope.model.incident.expectIntroTime =
  9153. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9154. res.serviceLevelAgreement.resolveTime;
  9155. $scope.model.incident.overdueTime =
  9156. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9157. res.date;
  9158. });
  9159. }
  9160. api_zsk.solutionQuote(item.id).then(function (response) {
  9161. if (response.status == 200) {
  9162. $("#seachknowledge").removeClass("active");
  9163. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9164. $scope.$parent.$parent.$parent.model.start_code = "close";
  9165. $scope.$parent.$parent.$parent.model.directClose = 0;
  9166. console.log($scope.model);
  9167. } else {
  9168. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9169. }
  9170. });
  9171. };
  9172. },
  9173. ],
  9174. });
  9175. //下拉输入组件
  9176. formlyConfigProvider.setType({
  9177. name: "ui-selectinput",
  9178. extends: "input",
  9179. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9180. defaultOptions: function (options) {
  9181. return {
  9182. templateOptions: {
  9183. refresh: function () { },
  9184. refreshDelay: 0,
  9185. linkage: function (modelName, data) { },
  9186. },
  9187. };
  9188. },
  9189. controller: [
  9190. "$scope",
  9191. "$rootScope",
  9192. "$modal",
  9193. "SweetAlert",
  9194. "api_bpm_data",
  9195. "api_solution",
  9196. "$aside",
  9197. function (
  9198. $scope,
  9199. $rootScope,
  9200. $modal,
  9201. SweetAlert,
  9202. api_bpm_data,
  9203. api_solution,
  9204. $aside
  9205. ) {
  9206. $scope.searchData = "";
  9207. $scope.onChangeadd = function (searchData) {
  9208. // $scope.searchKey = searchData.account;
  9209. // var requesdata = angular.copy(searchData)
  9210. // $scope.requester = requesdata;
  9211. };
  9212. $scope.refreshUseradd = function (searchKey) {
  9213. //主题搜索
  9214. // $scope.searchData = searchKey;
  9215. // reashdata($scope.searchData);
  9216. };
  9217. $scope.getMydata = function (x) {
  9218. $scope.model[$scope.options.key] =
  9219. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9220. $scope.searchField = $scope.model[$scope.options.key];
  9221. };
  9222. $scope.getMydataone = function (x) {
  9223. $scope.model[$scope.options.key] = x;
  9224. $scope.searchField = $scope.model[$scope.options.key];
  9225. if (
  9226. $scope.model[$scope.options.key] &&
  9227. $scope.model[$scope.options.key] != ""
  9228. ) {
  9229. $scope.hidden = false;
  9230. } else {
  9231. $scope.hidden = true;
  9232. }
  9233. };
  9234. function reashdata(item) {
  9235. $scope.myData = $scope.options.templateOptions.mydata;
  9236. }
  9237. reashdata();
  9238. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9239. $scope.options.templateOptions.fetchItems($scope);
  9240. }
  9241. },
  9242. ],
  9243. });
  9244. //重构组件模板
  9245. //获取当前人
  9246. formlyConfigProvider.setType({
  9247. name: "ui-users",
  9248. extends: "input",
  9249. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9250. defaultOptions: function (options) {
  9251. return {
  9252. templateOptions: {
  9253. translate: "",
  9254. refreshDelay: 0,
  9255. },
  9256. };
  9257. },
  9258. controller: [
  9259. "$scope",
  9260. function ($scope) {
  9261. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9262. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9263. },
  9264. ],
  9265. });
  9266. //只读控件
  9267. formlyConfigProvider.setType({
  9268. name: "ui-label",
  9269. extends: "input",
  9270. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9271. defaultOptions: function (options) {
  9272. return {
  9273. templateOptions: {
  9274. translate: "",
  9275. refreshDelay: 0,
  9276. },
  9277. };
  9278. },
  9279. controller: [
  9280. "$scope",
  9281. "$rootScope",
  9282. function ($scope, $rootScope) {
  9283. // console.log($scope.options.templateOptions)
  9284. // console.log($scope.options,'options1122');
  9285. $scope.isSolutionLabel = false;
  9286. $scope.solutionLabelStr = "";
  9287. // console.log($scope.options.templateOptions.solotinLabel);
  9288. if ($scope.options.templateOptions.solotinLabel) {
  9289. $scope.isSolutionLabel = true;
  9290. if ($scope.model[$scope.options.key]) {
  9291. var solutionArr = $scope.model[$scope.options.key].split("/");
  9292. $scope.solutionLabelStr = solutionArr.join(" ");
  9293. }
  9294. }
  9295. var value = $scope.model[$scope.options.key];
  9296. // ----------------
  9297. // ----------------
  9298. // console.log(value, 'pppp')
  9299. function treeDesc(children, key, label) {
  9300. if (label == "") {
  9301. label = children[key];
  9302. } else {
  9303. label = children[key] + "-" + label;
  9304. }
  9305. if (angular.isDefined(children.parent)) {
  9306. treeDesc(children.parent, key, label);
  9307. } else {
  9308. return label;
  9309. }
  9310. }
  9311. if (angular.isArray(value)) {
  9312. var tempValue = "";
  9313. angular.forEach(value, function (item) {
  9314. if (tempValue != "") {
  9315. tempValue = tempValue + ",";
  9316. }
  9317. tempValue =
  9318. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9319. item;
  9320. });
  9321. $scope.options.templateOptions.translate = tempValue;
  9322. } else if (angular.isObject(value)) {
  9323. if (
  9324. angular.isDefined(value.children) ||
  9325. angular.isDefined(value.parent)
  9326. ) {
  9327. //tree
  9328. // console.log("value.parent="+JSON.stringify(value.parent))
  9329. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9330. nameLabel = treeDesc(
  9331. value.parent,
  9332. $scope.options.templateOptions.labelProp,
  9333. nameLabel
  9334. );
  9335. $scope.options.templateOptions.translate = nameLabel;
  9336. } else {
  9337. $scope.options.templateOptions.translate = value;
  9338. }
  9339. } else if (
  9340. angular.isString(value) &&
  9341. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9342. ) {
  9343. // console.log("value=" + value);
  9344. $scope.options.templateOptions.translate = value;
  9345. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9346. // console.log("value="+value);
  9347. // $scope.options.templateOptions.translate = value;
  9348. } else {
  9349. // var datasdf = JSON.parse(value);
  9350. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9351. $scope.options.templateOptions.translate = value;
  9352. }
  9353. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9354. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9355. $scope.options.templateOptions.translate =
  9356. $scope.options.templateOptions.transform(
  9357. $scope.originalModel,
  9358. value,
  9359. $rootScope,
  9360. $scope
  9361. );
  9362. }
  9363. // console.log($scope.options.templateOptions.translate,99999);
  9364. },
  9365. ],
  9366. });
  9367. //小标题组件
  9368. formlyConfigProvider.setType({
  9369. name: "ui-header",
  9370. template:
  9371. '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>',
  9372. });
  9373. //标题组件
  9374. formlyConfigProvider.setType({
  9375. name: "ui-title",
  9376. template:
  9377. '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>',
  9378. });
  9379. //标栏是否展示
  9380. formlyConfigProvider.setType({
  9381. name: "ui-orshow",
  9382. template:
  9383. '<div class="panel"><div class="panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix"><h3 class="pull-left panel-title text-head margin-left-10" ng-if="options.templateOptions.label">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
  9384. controller: [
  9385. "$scope",
  9386. function ($scope) {
  9387. $scope.clickshow = function (key) {
  9388. // $scope.model[$scope.options.key] != key;
  9389. if (key == false) {
  9390. $scope.model[$scope.options.key] = true;
  9391. } else {
  9392. $scope.model[$scope.options.key] = false;
  9393. }
  9394. };
  9395. },
  9396. ],
  9397. });
  9398. //按钮组
  9399. formlyConfigProvider.setType({
  9400. name: "ui-button",
  9401. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9402. defaultOptions: function (options) {
  9403. return {
  9404. noFormControl: true,
  9405. };
  9406. },
  9407. });
  9408. //3d组link
  9409. formlyConfigProvider.setType({
  9410. name: "ui-link",
  9411. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9412. defaultOptions: function (options) {
  9413. return {
  9414. noFormControl: true,
  9415. };
  9416. },
  9417. });
  9418. //隐藏域组件
  9419. formlyConfigProvider.setType({
  9420. name: "ui-hidden",
  9421. extends: "input",
  9422. template:
  9423. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9424. defaultOptions: function (options) {
  9425. return {
  9426. // noFormControl: true
  9427. };
  9428. },
  9429. });
  9430. //文本框组件
  9431. formlyConfigProvider.setType({
  9432. name: "ui-input",
  9433. extends: "input",
  9434. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9435. defaultOptions: function (options) {
  9436. return {
  9437. templateOptions: {
  9438. transform: function (value) { },
  9439. },
  9440. };
  9441. },
  9442. controller: [
  9443. "$scope",
  9444. "$timeout",
  9445. function ($scope, $timeout) {
  9446. // console.log($scope.model[$scope.options.key]);
  9447. // console.log($scope.options)
  9448. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9449. $scope.model[$scope.options.key] =
  9450. $scope.options.templateOptions.linkData($scope.model);
  9451. }
  9452. },
  9453. ],
  9454. });
  9455. //搜索下拉框-故障地点seimin
  9456. formlyConfigProvider.setType({
  9457. name: "ui-select-search",
  9458. extends: "input",
  9459. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9460. defaultOptions: function (options) {
  9461. return {
  9462. templateOptions: {
  9463. transform: function (value) { },
  9464. },
  9465. };
  9466. },
  9467. controller: [
  9468. "$scope",
  9469. "$rootScope",
  9470. "api_search_area",
  9471. function ($scope, $rootScope, api_search_area) {
  9472. // console.log($scope.options, $scope.model)
  9473. // ----------------分割线 start-----------------
  9474. // 故障地点下拉
  9475. $scope.address_arr = []; //故障地点所有数据
  9476. $scope.addressFlag = false; //默认下拉框列表隐藏
  9477. //点击文本框
  9478. $scope.AddressClickHandle = function () {
  9479. $scope.getDepartmentList();
  9480. angular.element("#bx_address_ul").scrollTop(0);
  9481. };
  9482. //修改文字,实时监听
  9483. $scope.ksChangeHandle = _.debounce(function () {
  9484. $scope.model[$scope.options.key] =
  9485. $scope.model[$scope.options.key] === undefined
  9486. ? ""
  9487. : $scope.model[$scope.options.key];
  9488. $scope.getDepartmentList();
  9489. angular.element("#bx_address_ul").scrollTop(0);
  9490. }, 500);
  9491. //获取故障地点seimin
  9492. $scope.getDepartmentList = function () {
  9493. $scope.model[$scope.options.key] =
  9494. $scope.model[$scope.options.key] === null
  9495. ? ""
  9496. : $scope.model[$scope.options.key];
  9497. api_search_area
  9498. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9499. .then((res) => {
  9500. if (res.state == 200) {
  9501. $scope.address_arr = res.result;
  9502. $scope.addressFlag = true; //显示
  9503. }
  9504. })
  9505. .catch((err) => {
  9506. console.log(err);
  9507. });
  9508. };
  9509. // $scope.getDepartmentList();
  9510. // console.log($scope.model[$scope.options.key])
  9511. //下拉框列表选中
  9512. $scope.addressItemClick = function (obj) {
  9513. $scope.addressFlag = false; //隐藏
  9514. $scope.model[$scope.options.key] = obj.place
  9515. ? obj.area.area + obj.place
  9516. : obj.area;
  9517. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9518. $scope.model.selecthouseNumber = obj;
  9519. console.log($scope, 77777);
  9520. $scope.$root.selecthouseNumber = obj;
  9521. };
  9522. //点击空白处隐藏
  9523. angular.element(document).on("click", function (e) {
  9524. if (e.target !== angular.element("#bx_address").get(0)) {
  9525. $scope.addressFlag = false; //隐藏
  9526. //模拟placeholder
  9527. // if ($('#bx_address').val() == '') {
  9528. // $('#bx_address').val('请选择报修科室');
  9529. // }
  9530. }
  9531. });
  9532. // -----------------分割线 end----------------
  9533. },
  9534. ],
  9535. });
  9536. //知识库关键字组件
  9537. formlyConfigProvider.setType({
  9538. name: "ui-knowledgeKeywords",
  9539. extends: "input",
  9540. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9541. defaultOptions: function (options) {
  9542. return {
  9543. templateOptions: {
  9544. transform: function (value) { },
  9545. },
  9546. };
  9547. },
  9548. controller: [
  9549. "$scope",
  9550. "$timeout",
  9551. "SweetAlert",
  9552. function ($scope, $timeout, SweetAlert) {
  9553. $scope.valueLength = [
  9554. {
  9555. value: "",
  9556. },
  9557. ];
  9558. $scope.valueAll = [];
  9559. if ($scope.model[$scope.options.key]) {
  9560. var valueArr = $scope.model[$scope.options.key].split("/");
  9561. $scope.valueLength = [];
  9562. for (var i = 0; i < valueArr.length; i++) {
  9563. $scope.valueLength.push({
  9564. value: valueArr[i],
  9565. });
  9566. }
  9567. }
  9568. $scope.addIpt = function () {
  9569. if ($scope.valueLength.length < 5) {
  9570. $scope.valueLength.push({
  9571. value: "",
  9572. });
  9573. } else {
  9574. SweetAlert.swal({
  9575. title: "添加失败",
  9576. text: "关键字不能超过5个!",
  9577. type: "error",
  9578. confirmButtonColor: "#DD6B55",
  9579. });
  9580. }
  9581. };
  9582. $scope.closeIpt = function (data) {
  9583. $scope.valueLength.splice(data, 1);
  9584. };
  9585. $scope.toOption = function () {
  9586. $scope.valueAll = [];
  9587. for (var i = 0; i < $scope.valueLength.length; i++) {
  9588. if ($scope.valueLength[i].value != "") {
  9589. $scope.valueAll.push($scope.valueLength[i].value);
  9590. }
  9591. }
  9592. $scope.model.label = $scope.valueAll.join("/");
  9593. };
  9594. },
  9595. ],
  9596. });
  9597. //文本框组件
  9598. formlyConfigProvider.setType({
  9599. name: "ui-num",
  9600. extends: "input",
  9601. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9602. defaultOptions: function (options) {
  9603. return {
  9604. templateOptions: {
  9605. transform: function (value) { },
  9606. },
  9607. };
  9608. },
  9609. controller: [
  9610. "$scope",
  9611. "$timeout",
  9612. function ($scope, $timeout) {
  9613. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9614. $scope.model[$scope.options.key] =
  9615. $scope.options.templateOptions.linkData($scope.model);
  9616. }
  9617. $scope.clearNoNum = function (obj, attr) {
  9618. //先把非数字的都替换掉,除了数字和.
  9619. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9620. //必须保证第一个为数字而不是.
  9621. obj[attr] = obj[attr].replace(/^\./g, "");
  9622. //保证只有出现一个.而没有多个.
  9623. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9624. //保证.只出现一次,而不能出现两次以上
  9625. obj[attr] = obj[attr]
  9626. .replace(".", "$#$")
  9627. .replace(/\./g, "")
  9628. .replace("$#$", ".");
  9629. //小于最大值
  9630. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9631. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9632. // obj[attr] = '';
  9633. // }
  9634. };
  9635. },
  9636. ],
  9637. });
  9638. // //关联请求人文本框组件
  9639. // formlyConfigProvider.setType({
  9640. // name: 'ui-requestinput',
  9641. // extends: 'input',
  9642. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9643. // defaultOptions: function(options) {
  9644. // return {
  9645. // templateOptions: {
  9646. // transform: function(value) {},
  9647. // linkData: function(options) {}
  9648. // }
  9649. // };
  9650. // }
  9651. // });
  9652. //只读文本
  9653. formlyConfigProvider.setType({
  9654. name: "ui-disableinput",
  9655. extends: "input",
  9656. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9657. defaultOptions: function (options) {
  9658. return {
  9659. templateOptions: {
  9660. transform: function (value) {
  9661. var ret = "";
  9662. if (value) {
  9663. ret = "已删除";
  9664. } else {
  9665. ret = "正常";
  9666. }
  9667. return ret;
  9668. },
  9669. },
  9670. };
  9671. },
  9672. });
  9673. formlyConfigProvider.setType({
  9674. name: "ui-disinput",
  9675. extends: "input",
  9676. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9677. defaultOptions: function (options) {
  9678. return {
  9679. templateOptions: {},
  9680. };
  9681. },
  9682. });
  9683. //数字组件
  9684. formlyConfigProvider.setType({
  9685. name: "ui-number",
  9686. extends: "input",
  9687. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9688. defaultOptions: function (options) {
  9689. return {
  9690. templateOptions: {},
  9691. };
  9692. },
  9693. controller: ["$scope", function ($scope) { }],
  9694. });
  9695. //含有周的日期
  9696. formlyConfigProvider.setType({
  9697. name: "ui-datepickerweek",
  9698. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9699. extends: "input",
  9700. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9701. defaultOptions: {
  9702. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9703. templateOptions: {
  9704. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9705. },
  9706. },
  9707. controller: [
  9708. "$scope",
  9709. "$filter",
  9710. function ($scope, $filter) {
  9711. $scope.mindata = new Date(
  9712. $scope.options.templateOptions.transform($scope.model).getTime() +
  9713. 5 * 60 * 1000
  9714. );
  9715. if ($scope.model[$scope.options.key]) {
  9716. } else {
  9717. $scope.model[$scope.options.key] = $filter("date")(
  9718. new Date(new Date().getTime()),
  9719. $scope.options.templateOptions.datepickerPopup
  9720. );
  9721. }
  9722. $scope.options.initialValue = $scope.model[$scope.options.key];
  9723. $scope.endOpen = true;
  9724. $scope.datepicker = {};
  9725. $scope.datepicker.opened = false;
  9726. $scope.datepicker.open = function ($event) {
  9727. $scope.datepicker.opened = true;
  9728. };
  9729. },
  9730. ],
  9731. });
  9732. //lmm
  9733. //分配任务列表
  9734. formlyConfigProvider.setType({
  9735. name: "jry_taskDistributionList",
  9736. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9737. wrapper: ["bootstrapHasError"],
  9738. defaultOptions: function (options, $scope) {
  9739. return {
  9740. templateOptions: {},
  9741. };
  9742. },
  9743. controller: function (
  9744. $rootScope,
  9745. $scope,
  9746. api_user_data,
  9747. $modal,
  9748. api_doc_data,
  9749. i18nService,
  9750. SweetAlert,
  9751. api_wechatfile
  9752. ) {
  9753. // 获取状态
  9754. $scope.stateListData = {};
  9755. $scope.getStateData = function () {
  9756. //lyl
  9757. var data = {
  9758. key: "task_sub_state",
  9759. type: "list",
  9760. };
  9761. api_wechatfile.getDictionary(data).then(function (res) {
  9762. angular.forEach(res, function (v, i) {
  9763. $scope.stateListData[v.value] = v.id;
  9764. });
  9765. });
  9766. };
  9767. $scope.getStateData();
  9768. var loginUser = $rootScope.user;
  9769. $scope.langs = i18nService.getAllLangs();
  9770. $scope.lang = "zh-cn";
  9771. i18nService.setCurrentLang($scope.lang);
  9772. $scope.gridOptions = {};
  9773. $scope.gridOptions.data = "myData";
  9774. $scope.gridOptions.enableColumnResizing = true;
  9775. $scope.gridOptions.enableGridMenu = false;
  9776. $scope.gridOptions.enableRowSelection = true;
  9777. $scope.gridOptions.showGridFooter = true;
  9778. $scope.gridOptions.showColumnFooter = false;
  9779. $scope.gridOptions.fastWatch = true;
  9780. $scope.gridOptions.useExternalFiltering = true;
  9781. $scope.gridOptions.useExternalPagination = true;
  9782. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9783. $scope.gridOptions.paginationPageSize = 10;
  9784. $scope.gridOptions.multiSelect = true;
  9785. $scope.gridOptions.rowIdentity = function (row) {
  9786. return row.id;
  9787. };
  9788. $scope.gridOptions.getRowIdentity = function (row) {
  9789. return row.id;
  9790. };
  9791. // console.log($scope.model);//lmmmm
  9792. $scope.gridOptions.columnDefs = [
  9793. {
  9794. name: "item",
  9795. displayName: "序号",
  9796. width: "10%",
  9797. cellTemplate:
  9798. "<div>" +
  9799. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9800. "</div>",
  9801. },
  9802. {
  9803. name: "taskDescribe",
  9804. displayName: "任务说明",
  9805. width: "25%",
  9806. enableFiltering: false,
  9807. cellTemplate:
  9808. "<div>" +
  9809. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9810. "</div>",
  9811. },
  9812. {
  9813. name: "assign.name",
  9814. displayName: "指派人",
  9815. width: "5%",
  9816. enableFiltering: false,
  9817. cellTemplate:
  9818. "<div>" +
  9819. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9820. "</div>",
  9821. },
  9822. {
  9823. name: "startTime",
  9824. displayName: "开始时间",
  9825. width: "13%",
  9826. enableFiltering: false,
  9827. cellTemplate:
  9828. "<div>" +
  9829. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9830. "</div>",
  9831. },
  9832. {
  9833. name: "endTime",
  9834. displayName: "结束时间",
  9835. width: "13%",
  9836. enableFiltering: false,
  9837. cellTemplate:
  9838. "<div>" +
  9839. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9840. "</div>",
  9841. },
  9842. {
  9843. name: "priority.name",
  9844. displayName: "优先级",
  9845. width: "5%",
  9846. enableFiltering: false,
  9847. cellTemplate:
  9848. "<div>" +
  9849. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9850. "</div>",
  9851. },
  9852. {
  9853. name: "state.name",
  9854. displayName: "状态",
  9855. width: "5%",
  9856. enableFiltering: false,
  9857. cellTemplate:
  9858. "<div>" +
  9859. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9860. "</div>",
  9861. },
  9862. {
  9863. name: "操作", //lmmm
  9864. cellTemplate:
  9865. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9866. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9867. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9868. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9869. '<a ng-click="grid.appScope.see(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[2]||row.entity.state.id==grid.appScope.stateListData[3]||grid.appScope.model.showSee">查看</a>' +
  9870. "</div></div>",
  9871. enableFiltering: false,
  9872. },
  9873. ];
  9874. // 查看
  9875. $scope.see = function (data) {
  9876. $scope.seeData = data;
  9877. var modalInstance = $modal.open({
  9878. backdrop: false,
  9879. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9880. controller: function (
  9881. $scope,
  9882. scope,
  9883. $modalInstance,
  9884. api_doc_data,
  9885. SweetAlert,
  9886. api_user_data,
  9887. api_wechatfile
  9888. ) {
  9889. $scope.personData = {}; //指派人
  9890. $scope.priorityData = {}; //优先级
  9891. $scope.personListData = {}; //指派人下拉数据
  9892. $scope.priorityListData = {}; //优先级下拉数据
  9893. $scope.startTime = ""; //开始时间
  9894. $scope.releaseShow = "no";
  9895. $scope.subShow = "no";
  9896. $scope.onlySee = "ok";
  9897. $scope.endTime = ""; //结束时间
  9898. $scope.taskDescribe = ""; //任务描述
  9899. $scope.taskDescribe = scope.seeData.taskDescribe;
  9900. $scope.personData.data = scope.seeData.assign;
  9901. $scope.priorityData.data = scope.seeData.priority;
  9902. $scope.startTime = scope.seeData.startTime;
  9903. $scope.endTime = scope.seeData.endTime;
  9904. $scope.done = scope.seeData.done;
  9905. $scope.feedback = scope.seeData.feedback;
  9906. $scope.cancel = function () {
  9907. $modalInstance.dismiss("cancel");
  9908. };
  9909. },
  9910. size: "sm",
  9911. resolve: {
  9912. scope: function () {
  9913. return $scope;
  9914. },
  9915. },
  9916. backdrop: true,
  9917. });
  9918. };
  9919. // 编辑
  9920. $scope.edit = function (data) {
  9921. $scope.editData = data;
  9922. var modalInstance = $modal.open({
  9923. backdrop: false,
  9924. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9925. controller: function (
  9926. $scope,
  9927. scope,
  9928. $modalInstance,
  9929. api_doc_data,
  9930. SweetAlert,
  9931. api_user_data,
  9932. api_wechatfile
  9933. ) {
  9934. console.log(scope.editData);
  9935. $scope.personData = {}; //指派人
  9936. $scope.priorityData = {}; //优先级
  9937. $scope.personListData = {}; //指派人下拉数据
  9938. $scope.priorityListData = {}; //优先级下拉数据
  9939. $scope.startTime = ""; //开始时间
  9940. $scope.releaseShow = "no";
  9941. $scope.endTime = ""; //结束时间
  9942. $scope.taskDescribe = ""; //任务描述
  9943. $scope.taskDescribe = scope.editData.taskDescribe;
  9944. $scope.personData.data = scope.editData.assign;
  9945. $scope.priorityData.data = scope.editData.priority;
  9946. $scope.startTime = scope.editData.startTime;
  9947. $scope.endTime = scope.editData.endTime;
  9948. // 指派人下拉框数据
  9949. $scope.getPersonData = function () {
  9950. var data = {
  9951. idx: 0,
  9952. sum: 1000,
  9953. user: {
  9954. engineer: 1,
  9955. "simple": true,
  9956. }
  9957. };
  9958. if($rootScope.user.duty){
  9959. // 当前的所属责任科室
  9960. data.user.duty = $rootScope.user.duty;
  9961. }else if($rootScope.user.branch){
  9962. // 当前的所属院区
  9963. data.user.branch = $rootScope.user.branch;
  9964. }
  9965. api_user_data.fetchDataList("user", data).then(function (res) {
  9966. $scope.personListData = res.list;
  9967. });
  9968. };
  9969. $scope.getPersonData();
  9970. //优先级下拉数据
  9971. $scope.getPriorityData = function () {
  9972. var data = {
  9973. key: "change_rick_level",
  9974. type: "list",
  9975. };
  9976. api_wechatfile.getDictionary(data).then(function (res) {
  9977. $scope.priorityListData = res;
  9978. });
  9979. };
  9980. $scope.getPriorityData();
  9981. // 获取状态-lmm
  9982. $scope.stateListData = {};
  9983. $scope.getStateData = function () {
  9984. //lyl
  9985. var data = {
  9986. key: "task_sub_state",
  9987. type: "list",
  9988. };
  9989. api_wechatfile.getDictionary(data).then(function (res) {
  9990. angular.forEach(res, function (v, i) {
  9991. $scope.stateListData[v.value] = v.id;
  9992. });
  9993. });
  9994. };
  9995. $scope.getStateData();
  9996. //时间控件
  9997. $scope.open = function ($event) {
  9998. $event.preventDefault();
  9999. $event.stopPropagation();
  10000. $scope.opened = !$scope.opened;
  10001. };
  10002. $scope.endOpen = function ($event) {
  10003. $event.preventDefault();
  10004. $event.stopPropagation();
  10005. $scope.startOpened = false;
  10006. $scope.endOpened = !$scope.endOpened;
  10007. };
  10008. $scope.startOpen = function ($event) {
  10009. $event.preventDefault();
  10010. $event.stopPropagation();
  10011. $scope.endOpened = false;
  10012. $scope.startOpened = !$scope.startOpened;
  10013. };
  10014. // 确定
  10015. $scope.ok = function (item) {
  10016. if (
  10017. $scope.taskDescribe &&
  10018. $scope.personData.data &&
  10019. $scope.priorityData.data &&
  10020. $scope.startTime &&
  10021. $scope.endTime
  10022. ) {
  10023. $scope.startTime = moment(
  10024. new Date($scope.startTime).getTime()
  10025. ).format("YYYY-MM-DD HH:mm:ss");
  10026. $scope.endTime = moment(
  10027. new Date($scope.endTime).getTime()
  10028. ).format("YYYY-MM-DD HH:mm:ss");
  10029. $scope.addData = {
  10030. taskSub: {
  10031. taskDescribe: $scope.taskDescribe,
  10032. assign: $scope.personData.data,
  10033. priority: $scope.priorityData.data,
  10034. startTime: $scope.startTime,
  10035. endTime: $scope.endTime,
  10036. taskMonth: {
  10037. id: scope.model.taskMonth.id,
  10038. },
  10039. id: scope.editData.id,
  10040. },
  10041. };
  10042. $scope.addData.taskSub["state"] = {
  10043. id: $scope.stateListData[1],
  10044. };
  10045. api_user_data
  10046. .updData("taskSub", $scope.addData)
  10047. .then(function (res) {
  10048. if (res.status == 200) {
  10049. SweetAlert.swal({
  10050. title: "修改成功!",
  10051. type: "success",
  10052. confirmButtonColor: "#007AFF",
  10053. });
  10054. scope.refreshData(scope.jry_filterdata);
  10055. $modalInstance.dismiss("cancel");
  10056. } else {
  10057. SweetAlert.swal({
  10058. title: "修改失败",
  10059. text: "系统错误,请重试!",
  10060. type: "error",
  10061. });
  10062. $modalInstance.dismiss("cancel");
  10063. }
  10064. });
  10065. } else {
  10066. SweetAlert.swal({
  10067. title: "修改失败",
  10068. text: "必填项不能为空!",
  10069. type: "error",
  10070. });
  10071. }
  10072. };
  10073. $scope.cancel = function () {
  10074. $modalInstance.dismiss("cancel");
  10075. };
  10076. },
  10077. size: "sm",
  10078. resolve: {
  10079. scope: function () {
  10080. return $scope;
  10081. },
  10082. },
  10083. backdrop: true,
  10084. });
  10085. };
  10086. // 发布
  10087. $scope.release = function (data) {
  10088. SweetAlert.swal(
  10089. {
  10090. title: "确认发布?",
  10091. text: "请确定发布操作!",
  10092. type: "warning",
  10093. showCancelButton: true,
  10094. confirmButtonColor: "#DD6B55",
  10095. confirmButtonText: "确定",
  10096. cancelButtonText: "取消",
  10097. closeOnConfirm: false,
  10098. closeOnCancel: false,
  10099. },
  10100. function (isConfirm) {
  10101. if (isConfirm) {
  10102. data.state.id = $scope.stateListData[2];
  10103. delete data.item;
  10104. api_user_data
  10105. .updData("taskSub", {
  10106. taskSub: data,
  10107. })
  10108. .then(function (res) {
  10109. if (res.status == 200) {
  10110. SweetAlert.swal({
  10111. title: "发布成功!",
  10112. type: "success",
  10113. confirmButtonColor: "#007AFF",
  10114. });
  10115. $scope.refreshData($scope.jry_filterdata);
  10116. } else {
  10117. SweetAlert.swal({
  10118. title: "删除失败",
  10119. text: "系统错误,请重试!",
  10120. type: "error",
  10121. });
  10122. }
  10123. });
  10124. } else {
  10125. SweetAlert.swal("操作取消", "发布取消", "error");
  10126. }
  10127. }
  10128. );
  10129. };
  10130. // 删除
  10131. $scope.remove = function (data) {
  10132. SweetAlert.swal(
  10133. {
  10134. title: "确认删除?",
  10135. text: "删除的数据不可恢复,请确认继续操作!",
  10136. type: "warning",
  10137. showCancelButton: true,
  10138. confirmButtonColor: "#DD6B55",
  10139. confirmButtonText: "继续删除",
  10140. cancelButtonText: "取消操作",
  10141. closeOnConfirm: false,
  10142. closeOnCancel: false,
  10143. },
  10144. function (isConfirm) {
  10145. if (isConfirm) {
  10146. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10147. if (res.status == 200) {
  10148. SweetAlert.swal({
  10149. title: "删除成功!",
  10150. type: "success",
  10151. confirmButtonColor: "#007AFF",
  10152. });
  10153. $scope.refreshData($scope.jry_filterdata);
  10154. } else {
  10155. SweetAlert.swal({
  10156. title: "删除失败",
  10157. text: "系统错误,请重试!",
  10158. type: "error",
  10159. });
  10160. }
  10161. });
  10162. } else {
  10163. SweetAlert.swal("操作取消", "数据安全", "error");
  10164. }
  10165. }
  10166. );
  10167. };
  10168. $scope.refreshData = function (filterData) {
  10169. // $scope.ldloading[style.replace('-', '_')] = true;
  10170. if (angular.isUndefined(filterData)) {
  10171. filterData = defaultFilterData;
  10172. }
  10173. $scope.myData = [];
  10174. $scope.memoryfilterData = filterData;
  10175. api_doc_data.fetchDataList("taskSub", filterData).then(
  10176. function (data) {
  10177. var myData = data;
  10178. $scope.gridOptions.totalItems = myData.totalNum;
  10179. $scope.removeFileNum = myData.totalNum;
  10180. if (angular.isArray(myData.list)) {
  10181. $scope.myData = myData.list;
  10182. for (var i = 0; i < $scope.myData.length; i++) {
  10183. //添加序号
  10184. $scope.myData[i]["item"] =
  10185. i + 1 + filterData.idx * filterData.sum;
  10186. $scope.myData[i].startTime = moment(
  10187. $scope.myData[i].startTime
  10188. ).format("YYYY-MM-DD HH:mm:ss");
  10189. $scope.myData[i].endTime = moment(
  10190. $scope.myData[i].endTime
  10191. ).format("YYYY-MM-DD HH:mm:ss");
  10192. }
  10193. }
  10194. },
  10195. function () {
  10196. // $scope.ldloading[style.replace('-', '_')] = false;
  10197. }
  10198. );
  10199. };
  10200. //分页控制
  10201. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10202. gridApi.pagination.on.paginationChanged(
  10203. $scope,
  10204. function (newPage, pageSize) {
  10205. $scope.jry_filterdata.idx = newPage - 1;
  10206. $scope.fenye = newPage - 1;
  10207. $scope.jry_filterdata.sum = pageSize;
  10208. $scope.refreshData($scope.jry_filterdata);
  10209. }
  10210. );
  10211. };
  10212. $scope.fenye = 0;
  10213. if ($scope.model.label == "分配任务") {
  10214. $scope.jry_filterdata = {
  10215. idx: $scope.fenye,
  10216. sum: 10,
  10217. taskSub: {
  10218. taskMonth: {
  10219. id: $scope.model.taskMonth.id,
  10220. },
  10221. userid: loginUser.id,
  10222. role: loginUser.role,
  10223. },
  10224. };
  10225. } else {
  10226. $scope.jry_filterdata = {
  10227. idx: $scope.fenye,
  10228. sum: 10,
  10229. taskSub: {
  10230. taskMonth: {
  10231. id: $scope.model.taskMonth.id,
  10232. },
  10233. userid: loginUser.id,
  10234. role: loginUser.role,
  10235. type: 1,
  10236. },
  10237. };
  10238. }
  10239. $scope.refreshData($scope.jry_filterdata);
  10240. //新增模态框
  10241. $scope.newDistribution = function () {
  10242. var modalInstance = $modal.open({
  10243. backdrop: false,
  10244. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10245. controller: function (
  10246. $scope,
  10247. scope,
  10248. $modalInstance,
  10249. api_doc_data,
  10250. SweetAlert,
  10251. api_user_data,
  10252. api_wechatfile
  10253. ) {
  10254. $scope.personData = {}; //指派人
  10255. $scope.priorityData = {}; //优先级
  10256. $scope.personListData = {}; //指派人下拉数据
  10257. $scope.priorityListData = {}; //优先级下拉数据
  10258. $scope.startTime = ""; //开始时间
  10259. $scope.endTime = ""; //结束时间
  10260. $scope.taskDescribe = ""; //任务描述
  10261. $scope.motaikuang = "";
  10262. $scope.shijian = "哈哈";
  10263. // 指派人下拉框数据
  10264. $scope.getPersonData = function () {
  10265. var data = {
  10266. idx: 0,
  10267. sum: 1000,
  10268. user: {
  10269. engineer: 1,
  10270. "simple": true,
  10271. }
  10272. };
  10273. if($rootScope.user.duty){
  10274. // 当前的所属责任科室
  10275. data.user.duty = $rootScope.user.duty;
  10276. }else if($rootScope.user.branch){
  10277. // 当前的所属院区
  10278. data.user.branch = $rootScope.user.branch;
  10279. }
  10280. api_user_data.fetchDataList("user", data).then(function (res) {
  10281. $scope.personListData = res.list;
  10282. });
  10283. };
  10284. $scope.getPersonData();
  10285. //优先级下拉数据
  10286. $scope.getPriorityData = function () {
  10287. var data = {
  10288. key: "change_rick_level",
  10289. type: "list",
  10290. };
  10291. api_wechatfile.getDictionary(data).then(function (res) {
  10292. $scope.priorityListData = res;
  10293. });
  10294. };
  10295. // 控制结束时间的最大时间
  10296. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10297. // 控制结束时间的最小时间
  10298. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10299. $scope.$watch("startTime", function (n, o) {
  10300. if (n) {
  10301. if (n > scope.model.taskMonth.startTime) {
  10302. $scope.jryEndMinTime = n;
  10303. }
  10304. }
  10305. });
  10306. // 控制开始时间的最小时间
  10307. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10308. // 控制开始时间的最大时间
  10309. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10310. $scope.$watch("endTime", function (n, o) {
  10311. if (n) {
  10312. if (n < scope.model.taskMonth.endTime) {
  10313. $scope.jryStartMaxTime = n;
  10314. }
  10315. }
  10316. });
  10317. $scope.getPriorityData();
  10318. //时间控件
  10319. $scope.open = function ($event) {
  10320. $event.preventDefault();
  10321. $event.stopPropagation();
  10322. $scope.opened = !$scope.opened;
  10323. };
  10324. $scope.endOpen = function ($event) {
  10325. $event.preventDefault();
  10326. $event.stopPropagation();
  10327. $scope.startOpened = false;
  10328. $scope.endOpened = !$scope.endOpened;
  10329. };
  10330. $scope.startOpen = function ($event) {
  10331. $event.preventDefault();
  10332. $event.stopPropagation();
  10333. $scope.endOpened = false;
  10334. $scope.startOpened = !$scope.startOpened;
  10335. };
  10336. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10337. // 获取状态-lmm
  10338. $scope.stateListData = {};
  10339. $scope.getStateData = function () {
  10340. //lyl
  10341. var data = {
  10342. key: "task_sub_state",
  10343. type: "list",
  10344. };
  10345. api_wechatfile.getDictionary(data).then(function (res) {
  10346. angular.forEach(res, function (v, i) {
  10347. $scope.stateListData[v.value] = v.id;
  10348. });
  10349. });
  10350. };
  10351. $scope.getStateData();
  10352. // 草稿保存
  10353. $scope.ok = function (item) {
  10354. if (
  10355. $scope.taskDescribe &&
  10356. $scope.personData.data &&
  10357. $scope.priorityData.data &&
  10358. $scope.startTime &&
  10359. $scope.endTime
  10360. ) {
  10361. $scope.startTime = moment(
  10362. new Date($scope.startTime).getTime()
  10363. ).format("YYYY-MM-DD HH:mm:ss");
  10364. $scope.endTime = moment(
  10365. new Date($scope.endTime).getTime()
  10366. ).format("YYYY-MM-DD HH:mm:ss");
  10367. $scope.addData = {
  10368. taskSub: {
  10369. taskDescribe: $scope.taskDescribe,
  10370. assign: $scope.personData.data,
  10371. priority: $scope.priorityData.data,
  10372. startTime: $scope.startTime,
  10373. endTime: $scope.endTime,
  10374. taskMonth: {
  10375. id: scope.model.taskMonth.id,
  10376. },
  10377. },
  10378. };
  10379. $scope.addData.taskSub["state"] = {
  10380. id: $scope.stateListData[1],
  10381. };
  10382. api_user_data
  10383. .addData("taskSub", $scope.addData)
  10384. .then(function (res) {
  10385. if (res.status == 200) {
  10386. SweetAlert.swal({
  10387. title: "保存成功!",
  10388. type: "success",
  10389. confirmButtonColor: "#007AFF",
  10390. });
  10391. scope.refreshData(scope.jry_filterdata);
  10392. $modalInstance.dismiss("cancel");
  10393. } else {
  10394. SweetAlert.swal({
  10395. title: "保存失败",
  10396. text: "系统错误,请重试!",
  10397. type: "error",
  10398. });
  10399. $modalInstance.dismiss("cancel");
  10400. }
  10401. });
  10402. } else {
  10403. SweetAlert.swal({
  10404. title: "保存失败",
  10405. text: "必填项不能为空!",
  10406. type: "error",
  10407. });
  10408. }
  10409. };
  10410. // 发布
  10411. $scope.release = function () {
  10412. if (
  10413. $scope.taskDescribe &&
  10414. $scope.personData.data &&
  10415. $scope.priorityData.data &&
  10416. $scope.startTime &&
  10417. $scope.endTime
  10418. ) {
  10419. $scope.startTime = moment(
  10420. new Date($scope.startTime).getTime()
  10421. ).format("YYYY-MM-DD HH:mm:ss");
  10422. $scope.endTime = moment(
  10423. new Date($scope.endTime).getTime()
  10424. ).format("YYYY-MM-DD HH:mm:ss");
  10425. $scope.addData = {
  10426. taskSub: {
  10427. taskDescribe: $scope.taskDescribe,
  10428. assign: $scope.personData.data,
  10429. priority: $scope.priorityData.data,
  10430. startTime: $scope.startTime,
  10431. endTime: $scope.endTime,
  10432. taskMonth: {
  10433. id: scope.model.taskMonth.id,
  10434. },
  10435. },
  10436. };
  10437. $scope.addData.taskSub["state"] = {
  10438. id: $scope.stateListData[1],
  10439. };
  10440. api_user_data
  10441. .addData("taskSub", $scope.addData)
  10442. .then(function (res) {
  10443. if (res.status == 200) {
  10444. SweetAlert.swal({
  10445. title: "保存成功!",
  10446. type: "success",
  10447. confirmButtonColor: "#007AFF",
  10448. });
  10449. scope.refreshData(scope.jry_filterdata);
  10450. $modalInstance.dismiss("cancel");
  10451. } else {
  10452. SweetAlert.swal({
  10453. title: "保存失败",
  10454. text: "系统错误,请重试!",
  10455. type: "error",
  10456. });
  10457. $modalInstance.dismiss("cancel");
  10458. }
  10459. });
  10460. } else {
  10461. SweetAlert.swal({
  10462. title: "保存失败",
  10463. text: "必填项不能为空!",
  10464. type: "error",
  10465. });
  10466. }
  10467. };
  10468. $scope.cancel = function () {
  10469. $modalInstance.dismiss("cancel");
  10470. };
  10471. },
  10472. size: "sm",
  10473. resolve: {
  10474. scope: function () {
  10475. return $scope;
  10476. },
  10477. },
  10478. backdrop: true,
  10479. });
  10480. };
  10481. },
  10482. });
  10483. // 多次反馈文本域组件--jry
  10484. formlyConfigProvider.setType({
  10485. name: "ui-feedbacktTextarea",
  10486. extends: "textarea",
  10487. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10488. defaultOptions: function (options) {
  10489. return {
  10490. templateOptions: {
  10491. transform: function (model, value) {
  10492. return value;
  10493. },
  10494. },
  10495. validation: {
  10496. messages: {
  10497. maxlength: function (viewValue, modelValue, scope) {
  10498. if (viewValue != null) {
  10499. if (viewValue.length > scope.to.maxlength) {
  10500. return (
  10501. scope.to.label +
  10502. " 字数(" +
  10503. viewValue.length +
  10504. ")超限(" +
  10505. scope.to.maxlength +
  10506. ")"
  10507. );
  10508. } else {
  10509. return "";
  10510. }
  10511. }
  10512. },
  10513. },
  10514. },
  10515. };
  10516. },
  10517. controller: [
  10518. "$scope",
  10519. "moment",
  10520. function ($scope, moment) {
  10521. // console.log($scope);
  10522. var timeKey = $scope.options.templateOptions.time;
  10523. $scope.time = moment($scope.model[timeKey]).format(
  10524. "YYYY-MM-DD HH:mm:ss"
  10525. );
  10526. var value = $scope.model[$scope.options.key];
  10527. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10528. $scope.model[$scope.options.key] =
  10529. $scope.options.templateOptions.transform(
  10530. $scope.originalModel,
  10531. value
  10532. );
  10533. }
  10534. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10535. $scope.options.templateOptions.felditem($scope);
  10536. }
  10537. },
  10538. ],
  10539. });
  10540. //任务管理开始时间--jry
  10541. formlyConfigProvider.setType({
  10542. name: "ui-jryStartdatepicker",
  10543. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10544. extends: "input",
  10545. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10546. defaultOptions: {
  10547. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10548. templateOptions: {
  10549. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10550. },
  10551. },
  10552. controller: [
  10553. "$scope",
  10554. "$filter",
  10555. function ($scope, $filter) {
  10556. // console.log($scope.model[$scope.options.key],'lmm');
  10557. $scope.mindata = new Date(
  10558. $scope.options.templateOptions.transform($scope.model).getTime() +
  10559. 5 * 60 * 1000
  10560. );
  10561. if ($scope.model[$scope.options.key]) {
  10562. $scope.model[$scope.options.key] = $filter("date")(
  10563. $scope.model[$scope.options.key],
  10564. $scope.options.templateOptions.datepickerPopup
  10565. );
  10566. }
  10567. // console.log($scope.model[$scope.options.key],'lmm');
  10568. // console.log($scope.model,'lmm',$scope.options.key);
  10569. $scope.options.initialValue = $scope.model[$scope.options.key];
  10570. $scope.endOpen = true;
  10571. $scope.datepicker = {};
  10572. $scope.datepicker.opened = false;
  10573. $scope.datepicker.open = function ($event) {
  10574. $scope.datepicker.opened = true;
  10575. };
  10576. },
  10577. ],
  10578. });
  10579. //任务管理结束时间--jry
  10580. formlyConfigProvider.setType({
  10581. name: "ui-jryEnddatepicker",
  10582. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10583. extends: "input",
  10584. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10585. defaultOptions: {
  10586. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10587. templateOptions: {
  10588. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10589. },
  10590. },
  10591. controller: [
  10592. "$scope",
  10593. "$filter",
  10594. function ($scope, $filter) {
  10595. $scope.mindata = new Date(
  10596. $scope.options.templateOptions.transform($scope.model).getTime() +
  10597. 5 * 60 * 1000
  10598. );
  10599. if ($scope.model[$scope.options.key]) {
  10600. $scope.model[$scope.options.key] = $filter("date")(
  10601. $scope.model[$scope.options.key],
  10602. $scope.options.templateOptions.datepickerPopup
  10603. );
  10604. }
  10605. $scope.options.initialValue = $scope.model[$scope.options.key];
  10606. $scope.endOpen = true;
  10607. $scope.datepicker = {};
  10608. $scope.datepicker.opened = false;
  10609. $scope.datepicker.open = function ($event) {
  10610. $scope.datepicker.opened = true;
  10611. };
  10612. },
  10613. ],
  10614. });
  10615. //下拉多选框灵活组件--jry
  10616. formlyConfigProvider.setType({
  10617. name: "ui-jry_multiselectplus",
  10618. extends: "multiCheckbox",
  10619. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10620. defaultOptions: function (options) {
  10621. return {
  10622. templateOptions: {
  10623. refreshData: function (search, options, model, that) {
  10624. // var process = options.templateOptions.ApiService.all("");
  10625. if (search) {
  10626. } else {
  10627. }
  10628. var postData = options.templateOptions.optionsPostData;
  10629. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10630. postData = options.templateOptions.optionsPostData(
  10631. options,
  10632. model,
  10633. that
  10634. );
  10635. }
  10636. options.templateOptions.ApiService.fetchDataList(
  10637. options.templateOptions.optionsUrl,
  10638. options.templateOptions.optionsPostData
  10639. ).then(function (result) {
  10640. // if (!options.templateOptions.options) {
  10641. // options.templateOptions.options = [];
  10642. // }
  10643. if (options.templateOptions.optionsDataKey) {
  10644. options.templateOptions.options =
  10645. result[options.templateOptions.optionsDataKey];
  10646. } else {
  10647. options.templateOptions.options = result;
  10648. }
  10649. if (options.templateOptions.optionsChecked) {
  10650. // return options.value = null;
  10651. options.value(options.model[options.key]);
  10652. }
  10653. });
  10654. },
  10655. refreshDelay: 0,
  10656. // },
  10657. validators: {
  10658. required: {
  10659. expression: function (viewValue, modelValue) {
  10660. var value = modelValue || viewValue;
  10661. return value != null;
  10662. // return value.length>=1;
  10663. // if (modelValue && viewValue) {
  10664. // return value != null;
  10665. // } else {
  10666. // var value = modelValue || viewValue;
  10667. // return value.length > 0;
  10668. // }
  10669. },
  10670. },
  10671. },
  10672. },
  10673. };
  10674. },
  10675. controller: [
  10676. "$scope",
  10677. function ($scope) {
  10678. console.log($scope.to);
  10679. if (angular.isArray($scope.model[$scope.options.key])) {
  10680. } else {
  10681. $scope.model[$scope.options.key] = [];
  10682. }
  10683. },
  10684. ],
  10685. });
  10686. //下拉框组件
  10687. formlyConfigProvider.setType({
  10688. name: "ui-select",
  10689. extends: "select",
  10690. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10691. defaultOptions: function (options, scope) {
  10692. return {
  10693. templateOptions: {
  10694. // refresh: function() {},
  10695. getScope: function () {
  10696. return scope;
  10697. },
  10698. refreshDelay: 0,
  10699. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10700. //POST
  10701. console.log(model, "model");
  10702. angular.extend(data, {
  10703. idx: 0,
  10704. sum: 1000,
  10705. });
  10706. options.templateOptions.APIService.fetchDataList(
  10707. modelName,
  10708. data
  10709. ).then(function (response) {
  10710. var myData =
  10711. options.templateOptions.Restangular.stripRestangular(response);
  10712. var list = myData.list;
  10713. console.log(myData);
  10714. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10715. // console.log('balabalabala');
  10716. // console.log(res);
  10717. // })
  10718. if (list.length == 1) {
  10719. if (options.templateOptions.APIport) {
  10720. options.templateOptions.APIport.expectedTime(
  10721. "L" + list[0][key].id
  10722. ).then(function (response) {
  10723. if (response.state == "200") {
  10724. // if (model.$parent.model && model.$parent.model.incident) {
  10725. // } else {
  10726. // model.$parent.model = { 'incident': {} };
  10727. // }
  10728. var myDatas = response.serviceLevelAgreement;
  10729. //逾期
  10730. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10731. response.date;
  10732. //解决
  10733. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10734. myDatas.resolveTime;
  10735. //响应
  10736. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10737. myDatas.responseTime;
  10738. } else {
  10739. }
  10740. });
  10741. }
  10742. angular.forEach(model.fields, function (item) {
  10743. angular.forEach(model.fields, function (item) {
  10744. if (item.templateOptions.pkey == modelKey + "." + key) {
  10745. item.model.id = "";
  10746. if (key == "place") {
  10747. item.templateOptions.options = list;
  10748. } else if (key == "placeDTO") {
  10749. item.templateOptions.options = list;
  10750. } else if (key == "requester") {
  10751. } else {
  10752. item.value(list[0][key][item.key]);
  10753. }
  10754. }
  10755. });
  10756. });
  10757. } else {
  10758. if (model.fields) {
  10759. angular.forEach(model.fields, function (item) {
  10760. angular.forEach(model.fields, function (item) {
  10761. if (item.templateOptions.pkey == modelKey + "." + key) {
  10762. item.model.id = "";
  10763. if (key == "place") {
  10764. item.templateOptions.isnosearch = true;
  10765. item.templateOptions.options = list;
  10766. }
  10767. if (key == "placeDTO") {
  10768. item.templateOptions.options = list;
  10769. }
  10770. if (key == "requester") {
  10771. }
  10772. if (key == "room") {
  10773. item.templateOptions.options = list;
  10774. }
  10775. }
  10776. });
  10777. });
  10778. } else {
  10779. angular.forEach(
  10780. scope.$parent.$parent.$parent.fields,
  10781. function (item) {
  10782. angular.forEach(
  10783. scope.$parent.$parent.$parent.fields,
  10784. function (item) {
  10785. if (
  10786. item.templateOptions.pkey ==
  10787. modelKey + "." + key
  10788. ) {
  10789. if (key == "place") {
  10790. item.templateOptions.isnosearch = true;
  10791. item.templateOptions.options = list;
  10792. scope.$parent.$parent.$parent.model.incident.place =
  10793. model.incident.place;
  10794. }
  10795. if (key == "placeDTO") {
  10796. item.templateOptions.options = list;
  10797. }
  10798. if (key == "requester") {
  10799. }
  10800. }
  10801. }
  10802. );
  10803. }
  10804. );
  10805. }
  10806. }
  10807. console.log(key);
  10808. //报修科室
  10809. if (key == "dept") {
  10810. // 报修科室单选
  10811. scope.$parent.$parent.$parent.model.incident.department =
  10812. response.list[0];
  10813. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10814. response.list[0].phone;
  10815. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10816. // 选择重复事件侧滑框
  10817. scope.$parent.$parent.$parent.model[
  10818. "repeatIncidentShow"
  10819. ] = false;
  10820. setTimeout(() => {
  10821. scope.$parent.$parent.$parent.model[
  10822. "repeatIncidentShow"
  10823. ] = true;
  10824. }, 500);
  10825. }
  10826. // 报修人
  10827. if (key == "requester") {
  10828. // 报修人单选
  10829. scope.$parent.$parent.$parent.model.incident.requester =
  10830. response.list[0];
  10831. console.log(scope.$parent.$parent.$parent.model);
  10832. scope.$parent.$parent.$parent.model.incident.account =
  10833. response.list[0].account;
  10834. var selectedItem = response.list[0];
  10835. var data = {
  10836. requester: selectedItem,
  10837. };
  10838. scope.$parent.$parent.$parent.model["requestershow"] =
  10839. selectedItem;
  10840. console.log(selectedItem, "----------------------");
  10841. // if (selectedItem.dept.place.place) {
  10842. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10843. // }
  10844. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10845. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10846. scope.$parent.$parent.$parent.model.incident.area.id =
  10847. selectedItem.place ? selectedItem.place.area.id : null;
  10848. scope.$parent.$parent.$parent.model.incident.place.id =
  10849. selectedItem.place ? selectedItem.place.id : null;
  10850. if(scope.$parent.$parent.$parent.model.incident.area.id){
  10851. options.templateOptions.APIService.fetchDataList(
  10852. 'place',
  10853. {"place":{"areaId":scope.$parent.$parent.$parent.model.incident.area.id},"idx":0,"sum":1000}
  10854. ).then(function (response1) {
  10855. for (var i = 0; i < scope.fields.length; i++) {
  10856. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10857. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10858. }
  10859. }
  10860. })
  10861. }
  10862. console.log(scope, 89898998);
  10863. // console.log(scope.formData,'接单页面');
  10864. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10865. scope.model.selecthouseNumber = selectedItem.place
  10866. ? selectedItem.place
  10867. : {};
  10868. scope.$root.selecthouseNumber = selectedItem.place
  10869. ? selectedItem.place
  10870. : {};
  10871. // options.templateOptions.ApiService.addData(
  10872. // "requester",
  10873. // data
  10874. // ).then(function (response) {
  10875. // if (response.status == 200) {
  10876. if (scope.$parent.$parent.$parent) {
  10877. if (scope.$parent.$parent.$parent.place) {
  10878. scope.$parent.$parent.$parent.place.id = "";
  10879. }
  10880. if (scope.$parent.$parent.$parent.area) {
  10881. scope.$parent.$parent.$parent.area.id = "";
  10882. }
  10883. scope.$parent.$parent.$parent.model.incident.contacts =
  10884. selectedItem.name;
  10885. if (
  10886. selectedItem.phone &&
  10887. selectedItem.phone != null &&
  10888. selectedItem.phone != ""
  10889. ) {
  10890. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10891. selectedItem.phone;
  10892. } else {
  10893. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10894. selectedItem.telephone;
  10895. }
  10896. if (
  10897. selectedItem.requesterTypeDTO &&
  10898. selectedItem.requesterTypeDTO.id == 2
  10899. ) {
  10900. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10901. }
  10902. }
  10903. // if (!response.data.id) {
  10904. // response.data.id = selectedItem.id;
  10905. // }
  10906. console.log(scope);
  10907. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10908. // if (selectedItem.place && selectedItem.place.id) {
  10909. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10910. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10911. // };
  10912. // } else {
  10913. // if (selectedItem.place && selectedItem.place.id) {
  10914. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10915. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10916. // };
  10917. // }
  10918. // if(scope.$parent.$parent.$parent.model.incident.area){
  10919. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10920. // }
  10921. if (selectedItem.id) {
  10922. scope.$parent.$parent.$parent.model.incident.account =
  10923. selectedItem.account;
  10924. }
  10925. // 选择重复事件侧滑框
  10926. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10927. scope.$parent.$parent.$parent.model[
  10928. "repeatIncidentShow"
  10929. ] = false;
  10930. setTimeout(() => {
  10931. scope.$parent.$parent.$parent.model[
  10932. "repeatIncidentShow"
  10933. ] = true;
  10934. }, 500);
  10935. // }
  10936. // }
  10937. // });
  10938. }
  10939. //新建事件,选择派单,选择工作组查找处理人baba
  10940. if (key == "handlerUser") {
  10941. model.fields.forEach(function (v) {
  10942. if (v.templateOptions.pkey == "incident.handlerUser") {
  10943. v.templateOptions.options = list;
  10944. if (model.model.incident.handlerUser) {
  10945. if (model.model.incident.handlerUser.id) {
  10946. var flag = list.some(function (v) {
  10947. return v.id == model.model.incident.handlerUser.id;
  10948. });
  10949. if (flag) {
  10950. v.model.id = model.model.incident.handlerUser.id;
  10951. }
  10952. }
  10953. }
  10954. }
  10955. });
  10956. }
  10957. });
  10958. },
  10959. validators: {
  10960. required: {
  10961. expression: function (viewValue, modelValue) {
  10962. var value = modelValue || viewValue;
  10963. return value != null;
  10964. // return value.length>=1;
  10965. // if (modelValue && viewValue) {
  10966. // return value != null;
  10967. // } else {
  10968. // var value = modelValue || viewValue;
  10969. // return value.length > 0;
  10970. // }
  10971. },
  10972. },
  10973. },
  10974. },
  10975. controller: [
  10976. "$scope",
  10977. "$rootScope",
  10978. "api_bpm_domain",
  10979. "$stateParams",
  10980. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10981. // $scope.myFilter = function(item) {
  10982. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10983. // }
  10984. console.log($scope, "风浪");
  10985. if($scope.to.onlyKey === 'inspection.dictionary'){
  10986. //巡检列表-新增-巡检类型baba
  10987. console.log(location)
  10988. var loc = location.href.split('api_bpm_data')[1] || '';
  10989. if(loc.length <= 2){
  10990. // 新增轮询计划的时候
  10991. $scope.model.id = 1715;//默认系统默认
  10992. }
  10993. }
  10994. //工作组添加全部选项
  10995. // if($scope.options.templateOptions.label == '工作组'){
  10996. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10997. // $scope.model._group = 0;
  10998. // }
  10999. if (
  11000. $scope.options.templateOptions.pkey &&
  11001. $scope.options.templateOptions.pkey == "incident.place"
  11002. ) {
  11003. if (
  11004. $scope.$parent &&
  11005. $scope.$parent.$parent.$parent.model &&
  11006. $scope.$parent.$parent.$parent.model.incident.area &&
  11007. $scope.$parent.$parent.$parent.model.incident.area.id
  11008. ) {
  11009. $scope.options.templateOptions.linkage(
  11010. "place",
  11011. {
  11012. place: {
  11013. areaId:
  11014. $scope.$parent.$parent.$parent.model.incident.area.id,
  11015. // area:{
  11016. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  11017. // }
  11018. },
  11019. },
  11020. $scope.$parent.$parent.$parent.model,
  11021. "incident",
  11022. "place"
  11023. );
  11024. }
  11025. }
  11026. $scope.myFilter = $scope;
  11027. // console.log($scope.options.templateOptions)
  11028. console.log($scope, 77777);
  11029. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  11030. var paramsModel = JSON.parse($stateParams.model)
  11031. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  11032. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  11033. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  11034. }
  11035. }
  11036. //处理人根据故障现象自动带入baba
  11037. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  11038. console.log($scope.options.templateOptions.pkey);
  11039. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  11040. if (
  11041. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  11042. ) {
  11043. $scope.$parent.$parent.$parent.model.assignee =
  11044. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11045. $scope.options.model.id =
  11046. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11047. }
  11048. }
  11049. }
  11050. // 关闭事件页面满意度评价下拉框处理
  11051. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  11052. $scope.model.id =
  11053. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  11054. }
  11055. if ($scope.options.templateOptions.initData == 1) {
  11056. $scope.options.templateOptions.onChange(
  11057. $scope.model.id,
  11058. $scope.options,
  11059. $scope
  11060. );
  11061. }
  11062. if ($scope.options.templateOptions.transform) {
  11063. $scope.options.templateOptions.onChange(
  11064. $scope.model.id,
  11065. $scope.options,
  11066. $scope
  11067. );
  11068. }
  11069. if (angular.isFunction($scope.options.templateOptions.translate)) {
  11070. $scope.model[$scope.options.key] =
  11071. $scope.options.templateOptions.translate(
  11072. $scope.options,
  11073. $rootScope,
  11074. $scope
  11075. );
  11076. }
  11077. if (
  11078. angular.isFunction($scope.options.templateOptions.translatefunc)
  11079. ) {
  11080. $scope.model[$scope.options.key] =
  11081. $scope.options.templateOptions.translatefunc(
  11082. $scope.options,
  11083. $rootScope,
  11084. $scope
  11085. );
  11086. }
  11087. if (
  11088. angular.isFunction($scope.options.templateOptions.onlyfunction)
  11089. ) {
  11090. $scope.options.templateOptions.onlyfunction(
  11091. $scope.options,
  11092. $rootScope,
  11093. $scope
  11094. );
  11095. }
  11096. },
  11097. ],
  11098. };
  11099. },
  11100. });
  11101. //下拉框组件(巡检计划-查看)
  11102. formlyConfigProvider.setType({
  11103. name: "ui-select-xj",
  11104. extends: "select",
  11105. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11106. defaultOptions: function (options, scope) {
  11107. return {
  11108. templateOptions: {
  11109. getScope: function () {
  11110. return scope;
  11111. },
  11112. refreshDelay: 0,
  11113. validators: {
  11114. required: {
  11115. expression: function (viewValue, modelValue) {
  11116. var value = modelValue || viewValue;
  11117. return value != null;
  11118. },
  11119. },
  11120. },
  11121. },
  11122. controller: [
  11123. "$scope",
  11124. "$rootScope",
  11125. "api_bpm_domain",
  11126. "$stateParams",
  11127. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11128. $scope.model[$scope.options.key] = '0';//默认全部
  11129. var arr = [];
  11130. if($scope.model.inspection.batchNos){
  11131. arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
  11132. }
  11133. arr.unshift({value:'0',name:'全部'});
  11134. $scope.options.templateOptions.options = arr;
  11135. console.log($scope)
  11136. // ts.$parent.fields.forEach(v=>{
  11137. // if(v.templateOptions.onlyKey === "batchNos"){
  11138. // //巡检计划-批次号
  11139. // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
  11140. // v.templateOptions.getScope().refreshData(batchNos)
  11141. // }
  11142. // })
  11143. // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
  11144. // console.log($scope.options)
  11145. // console.log($scope.model)
  11146. },
  11147. ],
  11148. };
  11149. },
  11150. });
  11151. //下拉多选框组件
  11152. formlyConfigProvider.setType({
  11153. name: "ui-multiselect",
  11154. extends: "select",
  11155. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11156. defaultOptions: function (options, $scope) {
  11157. return {
  11158. templateOptions: {
  11159. getLoginUser: function () {
  11160. return $scope.$root.user;
  11161. },
  11162. refresh: function () { },
  11163. refreshDelay: 1000,
  11164. },
  11165. };
  11166. },
  11167. controller: [
  11168. "$scope",
  11169. function ($scope) {
  11170. $scope.model[$scope.options.key] = [];
  11171. },
  11172. ],
  11173. });
  11174. //下拉多选全选组件
  11175. formlyConfigProvider.setType({
  11176. name: "ui-isteven",
  11177. extends: "select",
  11178. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11179. defaultOptions: function (options,$scope) {
  11180. return {
  11181. templateOptions: {
  11182. refresh: function () {
  11183. console.log(options)
  11184. options.templateOptions
  11185. .refreshData(options.templateOptions.APIService)
  11186. .then(function (result) {
  11187. if(result.status == 200){
  11188. console.log(result.list)
  11189. //树形结构转换
  11190. function formatDataTree2(json){
  11191. var _json = JSON.parse(JSON.stringify(json));
  11192. return _json.filter(p=>{
  11193. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11194. _arr.length && (p.children = _arr);
  11195. return !p.parent;
  11196. })
  11197. }
  11198. console.log(result.list)
  11199. var list = formatDataTree2(result.list);
  11200. console.log(list)
  11201. // $scope.treeList = angular.copy(list);
  11202. var resultList = [];
  11203. //转换数据
  11204. function trasData(list,obj){
  11205. if(obj){
  11206. //有父级
  11207. list.forEach(v=>{
  11208. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11209. var i = resultList.findIndex(c=>c.type == type);
  11210. if(v.children){
  11211. resultList.splice(i+1,0,{
  11212. type: "<strong>"+ v.type +"</strong>",
  11213. msId: v.id,
  11214. msGroup: true,
  11215. },{msGroup: false})
  11216. trasData(v.children,v);
  11217. }else{
  11218. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11219. }
  11220. })
  11221. }else{
  11222. //顶级
  11223. list.forEach(v=>{
  11224. if(v.children){
  11225. resultList.push({
  11226. type: "<strong>"+ v.type +"</strong>",
  11227. msId: v.id,
  11228. msGroup: true,
  11229. },{msGroup: false})
  11230. trasData(v.children,v);
  11231. }else{
  11232. resultList.push(...v,...{ticked:false});
  11233. }
  11234. })
  11235. }
  11236. return resultList;
  11237. }
  11238. var __arr = trasData(list,null);
  11239. // console.log(__arr,options.model.typeIds.split(','))
  11240. if(options.model.typeIds){
  11241. //有巡检类型,则需要回显
  11242. __arr.forEach(w=>{
  11243. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11244. })
  11245. }
  11246. $scope.webBrowsersGrouped = __arr;
  11247. console.log($scope.webBrowsersGrouped);
  11248. }
  11249. })
  11250. },
  11251. refreshDelay: 1000,
  11252. },
  11253. };
  11254. },
  11255. controller: [
  11256. "$scope",
  11257. function ($scope) {
  11258. console.log($scope)
  11259. $scope.to.refresh();//获取列表数据
  11260. // $scope.model[$scope.options.key] = [];
  11261. //单项点击或菜单
  11262. $scope.fClick = function(data){
  11263. console.log($scope.outputBrowsers)
  11264. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11265. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11266. // if(data.id){
  11267. // //单项点击
  11268. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11269. // //有巡检类型
  11270. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11271. // if(data.ticked){
  11272. // arr.push(data.id);
  11273. // }else{
  11274. // arr = arr.filter(v=>v != data.id);
  11275. // }
  11276. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11277. // }else{
  11278. // //无巡检类型
  11279. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11280. // if(data.ticked){
  11281. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11282. // }else{
  11283. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11284. // }
  11285. // }
  11286. // }else{
  11287. // // 菜单点击
  11288. // console.log($scope.webBrowsersGrouped,data.msId);
  11289. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11290. // return v.parent?v.parent.id == data.msId:false;
  11291. // })
  11292. // if(treeResultArr.every(v=>v.ticked)){
  11293. // //全部都是true的情况下,需要移除,否则增加
  11294. // }
  11295. // console.log(treeResultArr)
  11296. // // --------------------------------------
  11297. // // var treeArr = [];
  11298. // // function findParent(treeList){
  11299. // // treeList.forEach(v=>{
  11300. // // if(v.id == data.msId){
  11301. // // treeArr = v.children;
  11302. // // }else{
  11303. // // if(v.children){
  11304. // // findParent(v.children);
  11305. // // }
  11306. // // }
  11307. // // })
  11308. // // return treeArr;
  11309. // // }
  11310. // // var treeResultArr = findParent($scope.treeList);
  11311. // // console.log(treeResultArr)
  11312. // // -----------------------------------
  11313. // }
  11314. }
  11315. // 全选
  11316. $scope.fSelectAll = function(){
  11317. // console.log($scope.webBrowsersGrouped)
  11318. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11319. // console.log(arr);
  11320. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11321. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11322. }
  11323. // 全不选
  11324. $scope.fSelectNone = function(){
  11325. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11326. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11327. }
  11328. // 配置信息
  11329. $scope.outputBrowsers = [];
  11330. $scope.localLang = {
  11331. selectAll: "全选",
  11332. selectNone: "全不选",
  11333. nothingSelected: "请选择"
  11334. }
  11335. },
  11336. ],
  11337. });
  11338. //下拉多选框灵活组件
  11339. formlyConfigProvider.setType({
  11340. name: "ui-multiselectplus",
  11341. extends: "multiCheckbox",
  11342. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11343. defaultOptions: function (options, $scope) {
  11344. return {
  11345. templateOptions: {
  11346. getLoginUser: function () {
  11347. return $scope.$root.user;
  11348. },
  11349. refreshData: function (search, options, model, that) {
  11350. console.log(search, options, model, that)
  11351. var process = options.templateOptions.ApiService.all("");
  11352. if (search) {
  11353. } else {
  11354. }
  11355. var postData = options.templateOptions.optionsPostData;
  11356. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11357. postData = options.templateOptions.optionsPostData(
  11358. options,
  11359. model,
  11360. that
  11361. );
  11362. }
  11363. if (options.templateOptions.modelreasondata) {
  11364. postData = options.templateOptions.modelreasondata;
  11365. }
  11366. if (options.templateOptions.isnosearch) {
  11367. return;
  11368. }
  11369. process
  11370. .customPOST(postData, options.templateOptions.optionsUrl)
  11371. .then(function (result) {
  11372. // if (!options.templateOptions.options) {
  11373. // options.templateOptions.options = [];
  11374. // }
  11375. // 过滤下拉列表已选择的值
  11376. var modelVal = $scope.model[$scope.options.key];
  11377. var ides = [];
  11378. var rList = result.list || result;
  11379. if ($scope.options.key == "serviceTypeIds") {
  11380. modelVal = modelVal.map(function (v) {
  11381. if (typeof v !== 'object') {
  11382. return { id: v };
  11383. } else {
  11384. return v;
  11385. }
  11386. })
  11387. }
  11388. for (var i = 0; i < modelVal.length; i++) {
  11389. for (var j = 0; j < rList.length; j++) {
  11390. if (rList[j].id == modelVal[i].id) {
  11391. ides.push(rList[j].id);
  11392. }
  11393. }
  11394. }
  11395. ides.forEach(function (v1) {
  11396. rList.forEach(function (v2) {
  11397. if (v1 == v2.id) {
  11398. rList = rList.filter(v => v.id != v2.id);
  11399. }
  11400. })
  11401. })
  11402. options.templateOptions.options = rList;
  11403. // if (options.templateOptions.optionsDataKey) {
  11404. // options.templateOptions.options =
  11405. // result[options.templateOptions.optionsDataKey];
  11406. // } else {
  11407. // options.templateOptions.options = result;
  11408. // }
  11409. if (options.templateOptions.optionsChecked) {
  11410. // return options.value = null;
  11411. options.value(options.model[options.key]);
  11412. }
  11413. });
  11414. },
  11415. refreshDelay: 0,
  11416. // },
  11417. // validators: {
  11418. // required: {
  11419. // expression: function(viewValue, modelValue) {
  11420. // var value = modelValue || viewValue;
  11421. // // return value.length>=1;
  11422. // // if (modelValue && viewValue) {
  11423. // // return value != null;
  11424. // // } else {
  11425. // // var value = modelValue || viewValue;
  11426. // // return value.length > 0;
  11427. // // }
  11428. // }
  11429. // }
  11430. },
  11431. };
  11432. },
  11433. controller: [
  11434. "$scope",
  11435. function ($scope) {
  11436. if (angular.isArray($scope.model[$scope.options.key])) {
  11437. } else {
  11438. $scope.model[$scope.options.key] = [];
  11439. }
  11440. },
  11441. ],
  11442. });
  11443. //下拉树形多选组件
  11444. formlyConfigProvider.setType({
  11445. name: "ui-multiselect-tree",
  11446. extends: "multiCheckbox",
  11447. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11448. defaultOptions: function (options) {
  11449. return {
  11450. templateOptions: {
  11451. linkage: function (modelName, data, model, modelKey, key) {
  11452. angular.extend(data, {
  11453. idx: 0,
  11454. sum: 10,
  11455. });
  11456. options.templateOptions.APIService.fetchDataList(
  11457. modelName,
  11458. data
  11459. ).then(function (response) {
  11460. var myData =
  11461. options.templateOptions.Restangular.stripRestangular(response);
  11462. var list = myData.list;
  11463. if (list.length == 1) {
  11464. angular.forEach(model.fields, function (item) {
  11465. angular.forEach(model.fields, function (item) {
  11466. if (item.templateOptions.pkey == modelKey + "." + key) {
  11467. item.model.id = "";
  11468. if (key == "place") {
  11469. item.templateOptions.options = list;
  11470. } else {
  11471. item.value(list[0][key][item.key]);
  11472. }
  11473. }
  11474. });
  11475. });
  11476. }
  11477. });
  11478. },
  11479. // my_tree_handler : function(items) {
  11480. // },
  11481. // onFilterCallback : function(items) {
  11482. // },
  11483. // onFilterCallback : function(items) {
  11484. // },
  11485. refresh: function (items) {
  11486. var treedata = [];
  11487. function convertListToTree(data, treeMap) {
  11488. treedata = data;
  11489. for (var i = 0; i < data.length; i++) {
  11490. for (var j = 0; j < data.length; j++) {
  11491. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11492. if (data[i].pid == data[j].id) {
  11493. data[i].parent = data[j];
  11494. }
  11495. }
  11496. }
  11497. }
  11498. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11499. var root = null; //Initially set our loop to null
  11500. //loop over data
  11501. for (var i = 0; i < data.length; i++) {
  11502. var datum = data[i];
  11503. //each node will have children, so let's give it a "children" poperty
  11504. datum.children = [];
  11505. //add an entry for this node to the map so that any future children can
  11506. //lookup the parent
  11507. idToNodeMap[datum.id] = datum;
  11508. //Does this node have a parent?
  11509. if (
  11510. typeof datum.parent === "undefined" ||
  11511. datum.parent === null
  11512. ) {
  11513. //Doesn't look like it, so this node is the root of the tree
  11514. root = datum;
  11515. treeMap[datum.id] = root;
  11516. } else {
  11517. //This node has a parent, so let's look it up using the id
  11518. parentNode = idToNodeMap[datum.parent.id];
  11519. //We don't need this property, so let's delete it.
  11520. delete datum.parent;
  11521. //Let's add the current node as a child of the parent node.
  11522. parentNode.children.push(datum);
  11523. }
  11524. }
  11525. return root;
  11526. }
  11527. function convertParentToChildList(data) {
  11528. // console.log("data="+JSON.stringify(data))
  11529. var treeMap = {};
  11530. var list = [];
  11531. convertListToTree(data, treeMap);
  11532. angular.forEach(treeMap, function (item) {
  11533. list.push(item);
  11534. });
  11535. return list;
  11536. }
  11537. function selectItem(pmodel, childrens) {
  11538. if (angular.isArray(pmodel)) {
  11539. angular.forEach(pmodel, function (index) {
  11540. if (index && index.id) {
  11541. angular.forEach(childrens, function (item) {
  11542. if (item.id == index.id) {
  11543. item.selected = true;
  11544. }
  11545. if (item && item.children) {
  11546. selectItem(pmodel, item.children);
  11547. }
  11548. });
  11549. }
  11550. });
  11551. } else {
  11552. if (pmodel && pmodel.id) {
  11553. angular.forEach(childrens, function (item) {
  11554. if (item.id == pmodel.id) {
  11555. item.selected = true;
  11556. }
  11557. if (item && item.children) {
  11558. selectItem(pmodel, item.children);
  11559. }
  11560. });
  11561. }
  11562. }
  11563. }
  11564. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11565. options.templateOptions
  11566. .refreshData(options.templateOptions.APIService)
  11567. .then(function (result) {
  11568. if (result.status == 200) {
  11569. if (!options.templateOptions.options) {
  11570. options.templateOptions.options = [];
  11571. }
  11572. if (options.templateOptions.optionsDataKey) {
  11573. options.templateOptions.options = convertParentToChildList(
  11574. result[options.templateOptions.optionsDataKey]
  11575. );
  11576. } else {
  11577. options.templateOptions.options =
  11578. convertParentToChildList(result);
  11579. }
  11580. //set default value
  11581. var pmodel,
  11582. i = 0;
  11583. if (options.templateOptions.pkey) {
  11584. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11585. angular.forEach(
  11586. options.templateOptions.pkey.split("."),
  11587. function (p) {
  11588. if (i == 0) {
  11589. if (options.model[p] == null) {
  11590. options.model[p] = {};
  11591. }
  11592. pmodel = options.model[p];
  11593. i++;
  11594. } else {
  11595. if (pmodel[p] == null) {
  11596. pmodel[p] = {};
  11597. }
  11598. pmodel = pmodel[p];
  11599. }
  11600. }
  11601. );
  11602. } else {
  11603. pmodel = options.model;
  11604. }
  11605. }
  11606. if (pmodel) {
  11607. pmodel = pmodel[options.key];
  11608. } else if (options.model) {
  11609. pmodel = options.model[options.key];
  11610. } else {
  11611. pmodel = options.templateOptions.options;
  11612. }
  11613. if (angular.isArray(pmodel)) {
  11614. if (pmodel) {
  11615. // if(options.templateOptions.isMultiSelect==true){
  11616. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11617. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11618. // })
  11619. // }else{
  11620. selectItem(pmodel, options.templateOptions.options);
  11621. // }
  11622. }
  11623. } else {
  11624. if (pmodel && pmodel.id) {
  11625. selectItem(pmodel, options.templateOptions.options);
  11626. }
  11627. }
  11628. items.inputModel = options.templateOptions.options;
  11629. }
  11630. });
  11631. },
  11632. },
  11633. validators: {
  11634. required: {
  11635. expression: function (viewValue, modelValue) {
  11636. var value = modelValue || viewValue;
  11637. if (angular.isArray(value)) {
  11638. for (var i = 0; i < value.length; i++) {
  11639. value[i] = {
  11640. id: value[i].id,
  11641. };
  11642. }
  11643. return value.length > 0;
  11644. } else {
  11645. // console.log(options)
  11646. // return value = "true";
  11647. return value != null;
  11648. }
  11649. },
  11650. },
  11651. },
  11652. };
  11653. },
  11654. controller: [
  11655. "$scope",
  11656. "api_configure_form",
  11657. function ($scope, api_configure_form) {
  11658. if ($scope.options.templateOptions.isMultiSelect) {
  11659. // console.log($scope);
  11660. } else {
  11661. if ($scope.model[$scope.options.key]) {
  11662. }
  11663. }
  11664. },
  11665. ],
  11666. });
  11667. //多选下拉框组件
  11668. formlyConfigProvider.setType({
  11669. name: "ui-multi-select-tree",
  11670. extends: "input",
  11671. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11672. defaultOptions: function (options,scope) {
  11673. return {
  11674. templateOptions: {
  11675. linkage: function (modelName, data, model, modelKey, key) {
  11676. angular.extend(data, {
  11677. idx: 0,
  11678. sum: 10,
  11679. });
  11680. options.templateOptions.APIService.fetchDataList(
  11681. modelName,
  11682. data
  11683. ).then(function (response) {
  11684. var myData =
  11685. options.templateOptions.Restangular.stripRestangular(response);
  11686. var list = myData.list;
  11687. if (list.length == 1) {
  11688. angular.forEach(model.fields, function (item) {
  11689. angular.forEach(model.fields, function (item) {
  11690. if (item.templateOptions.pkey == modelKey + "." + key) {
  11691. item.model.id = "";
  11692. if (key == "place") {
  11693. item.templateOptions.options = list;
  11694. } else {
  11695. item.value(list[0][key][item.key]);
  11696. }
  11697. }
  11698. });
  11699. });
  11700. }
  11701. });
  11702. },
  11703. getparentdata: function (items) {
  11704. // console.log(items)
  11705. },
  11706. refresh: function (items, search, fn) {
  11707. console.log(items, options);
  11708. var treedata = [];
  11709. function convertListToTree(data, treeMap) {
  11710. console.log(data, treeMap)
  11711. treedata = data;
  11712. for (var i = 0; i < data.length; i++) {
  11713. for (var j = 0; j < data.length; j++) {
  11714. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11715. if (data[i].pid == data[j].id) {
  11716. data[i].parent = data[j];
  11717. }
  11718. }
  11719. // if (data[i].id) {
  11720. // if (data[i].id== data[j].id) {
  11721. // data[i].parent = data[j];
  11722. // }
  11723. // }
  11724. }
  11725. }
  11726. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11727. var root = []; //Initially set our loop to null
  11728. if (search == "search" && items.filterKeyword) {
  11729. function transform(nodes) {
  11730. var treeConverter = {
  11731. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11732. attributeName: "id", //节点唯一标识符
  11733. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11734. transform: function (node) {
  11735. //转化递归函数,参数:一个待插入节点
  11736. if (node.parent != null) {
  11737. //该节点有父节点
  11738. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11739. if (this.needFind) {
  11740. for (var i = 0; i < newNode.children.length; i++) {
  11741. //查找要插入的node子节点是否在newNode这个父节点中存在
  11742. if (
  11743. newNode.children[i][this.attributeName] ===
  11744. node[this.attributeName]
  11745. ) {
  11746. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11747. }
  11748. }
  11749. }
  11750. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11751. // delete node.parent; //删除该节点的parent属性,如果有的话
  11752. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11753. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11754. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11755. } else if (node.parent == null) {
  11756. //该叶节点没有父节点,即为根节点
  11757. // delete node.parent; //删除该节点的parent属性,如果有的话
  11758. if (this.result == null) {
  11759. //根节点不存在
  11760. node.children = []; //给该节点增加children:[]属性
  11761. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11762. } else {
  11763. node.children = [];
  11764. // 顶级去重
  11765. for (
  11766. var i = 0;
  11767. i < this.result.children.length;
  11768. i++
  11769. ) {
  11770. if (
  11771. this.result.children[i][this.attributeName] ===
  11772. node[this.attributeName]
  11773. ) {
  11774. return this.result.children[i];
  11775. }
  11776. }
  11777. this.result.children.push(node);
  11778. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11779. }
  11780. }
  11781. },
  11782. getWhole: function (nodes, attributeName) {
  11783. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11784. var _node = {};
  11785. _node.children = [];
  11786. this.result = _node; //重置根节点
  11787. this.attributeName =
  11788. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11789. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11790. nodes.forEach((item) => {
  11791. //循环调用转化方法
  11792. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11793. this.transform(item);
  11794. });
  11795. return this.result; //返回根节点
  11796. },
  11797. };
  11798. var result = treeConverter.getWhole(nodes); //调用
  11799. return result;
  11800. }
  11801. var li = transform(data).children;
  11802. // li=[...new Set(li)]
  11803. console.log(li);
  11804. treeMap = li;
  11805. fn(li);
  11806. return li;
  11807. } else {
  11808. //loop over data
  11809. for (var i = 0; i < data.length; i++) {
  11810. var datum = data[i];
  11811. //each node will have children, so let's give it a "children" poperty
  11812. datum.children = [];
  11813. //add an entry for this node to the map so that any future children can
  11814. //lookup the parent
  11815. idToNodeMap[datum.id] = datum;
  11816. //Does this node have a parent?
  11817. if (
  11818. typeof datum.parent === "undefined" ||
  11819. datum.parent === null
  11820. ) {
  11821. //Doesn't look like it, so this node is the root of the tree
  11822. root = datum;
  11823. treeMap[datum.id] = root;
  11824. } else {
  11825. //This node has a parent, so let's look it up using the id
  11826. parentNode = idToNodeMap[datum.parent.id];
  11827. //We don't need this property, so let's delete it.
  11828. // delete datum.parent;
  11829. //Let's add the current node as a child of the parent node.
  11830. parentNode.children.push(datum);
  11831. }
  11832. }
  11833. }
  11834. console.log(root);
  11835. return root;
  11836. }
  11837. function convertParentToChildList(data) {
  11838. var treeMap = {};
  11839. var list = [];
  11840. if (search == "search" && items.filterKeyword) {
  11841. var lis = convertListToTree(data, treeMap);
  11842. return lis;
  11843. } else {
  11844. if (data[0] && data[0].orders) {
  11845. list = data;
  11846. } else {
  11847. convertListToTree(data, treeMap);
  11848. angular.forEach(treeMap, function (item) {
  11849. // console.log("item="+JSON.stringify(item))
  11850. list.push(item);
  11851. });
  11852. }
  11853. console.log(list);
  11854. return list;
  11855. }
  11856. }
  11857. function selectItem(pmodel, childrens) {
  11858. if (angular.isArray(pmodel)) {
  11859. angular.forEach(pmodel, function (index) {
  11860. if (index && index.id) {
  11861. angular.forEach(childrens, function (item) {
  11862. if (item.id == index.id) {
  11863. item.selected = true;
  11864. }
  11865. if (item && item.children) {
  11866. selectItem(pmodel, item.children);
  11867. }
  11868. });
  11869. // angular.forEach(treedata,function(parentdata){
  11870. // if(parentdata.id == index.id){
  11871. // if(parentdata.parent&&parentdata.parent.id){
  11872. // parentdata.parent.$
  11873. // }
  11874. // item.selected = true;
  11875. // }
  11876. // if (item && item.children) {
  11877. // selectItem(pmodel ,item.children);
  11878. // }
  11879. // });
  11880. }
  11881. });
  11882. } else {
  11883. if (pmodel && pmodel.id) {
  11884. angular.forEach(childrens, function (item, index) {
  11885. if (item.id == pmodel.id) {
  11886. item.selected = true;
  11887. // delete item.children;
  11888. }
  11889. if (item && item.children) {
  11890. selectItem(pmodel, item.children);
  11891. }
  11892. });
  11893. }
  11894. }
  11895. }
  11896. function selectItemchild(pmodel, childrens) {
  11897. if (angular.isArray(pmodel)) {
  11898. angular.forEach(pmodel, function (index) {
  11899. if (index && index.id) {
  11900. angular.forEach(childrens, function (item) {
  11901. if (item.id == index.id) {
  11902. item.selected = true;
  11903. }
  11904. if (item && item.children) {
  11905. selectItem(pmodel, item.children);
  11906. }
  11907. });
  11908. }
  11909. });
  11910. } else {
  11911. if (pmodel && pmodel.id) {
  11912. angular.forEach(childrens, function (item, index) {
  11913. if (item.id == pmodel.id) {
  11914. item.selected = true;
  11915. childrens[index].selected = true;
  11916. }
  11917. if (item && item.children) {
  11918. selectItem(pmodel, item.children);
  11919. }
  11920. });
  11921. }
  11922. }
  11923. }
  11924. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11925. if (search === "search" && items.filterKeyword) {
  11926. // bala:树形模糊搜索
  11927. options.templateOptions
  11928. .bala(options.templateOptions.APIService, items.filterKeyword)
  11929. .then(function (result) {
  11930. result.list = [...new Set(result.list)]; //去重
  11931. if (!options.templateOptions.options) {
  11932. options.templateOptions.options = [];
  11933. }
  11934. if (options.templateOptions.optionsDataKey) {
  11935. options.templateOptions.options = convertParentToChildList(
  11936. result[options.templateOptions.optionsDataKey]
  11937. );
  11938. } else {
  11939. options.templateOptions.options =
  11940. convertParentToChildList(result);
  11941. }
  11942. //set default value
  11943. var pmodel,
  11944. i = 0;
  11945. if (
  11946. options.templateOptions.pkey ||
  11947. options.templateOptions.pkey != ""
  11948. ) {
  11949. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11950. angular.forEach(
  11951. options.templateOptions.pkey.split("."),
  11952. function (p) {
  11953. if (i == 0) {
  11954. if (options.model[p] == null) {
  11955. options.model[p] = {};
  11956. }
  11957. pmodel = options.model[p];
  11958. i++;
  11959. } else {
  11960. if (pmodel[p] == null) {
  11961. pmodel[p] = {};
  11962. }
  11963. pmodel = pmodel[p];
  11964. }
  11965. }
  11966. );
  11967. } else {
  11968. pmodel = options.model;
  11969. }
  11970. }
  11971. var topdata = angular.copy(options.templateOptions.options);
  11972. if (pmodel) {
  11973. pmodel = pmodel[options.key];
  11974. } else if (options.model) {
  11975. pmodel = options.model[options.key];
  11976. }
  11977. if (angular.isArray(pmodel)) {
  11978. if (pmodel) {
  11979. items.inputModel = angular.copy(
  11980. options.templateOptions.options
  11981. );
  11982. selectItem(pmodel, options.templateOptions.options);
  11983. }
  11984. } else {
  11985. if (pmodel && pmodel.id) {
  11986. items.inputModel = angular.copy(
  11987. options.templateOptions.options
  11988. );
  11989. selectItem(pmodel, options.templateOptions.options);
  11990. } else {
  11991. // items.inputModel = options.templateOptions.options;
  11992. }
  11993. }
  11994. // items.inputModel = options.templateOptions.options;
  11995. items.selectModel = options.templateOptions.options;
  11996. // 可在此展开
  11997. if (!items.inputModel) {
  11998. items.inputModel = items.selectModel;
  11999. } else {
  12000. selectItemchild(pmodel, items.inputModel);
  12001. // for (var i = 0; i < items.inputModel.length; i++) {
  12002. // items.inputModel[i].
  12003. // for (var j = 0; j < items.selectModel.length; j++) {
  12004. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12005. // items.inputModel[i].selected = true;
  12006. // }
  12007. // }
  12008. // }
  12009. }
  12010. return items.inputModel;
  12011. // options.templateOptions.options = angular.copy(topdata);
  12012. // console.log(model);
  12013. // console.log(options);
  12014. });
  12015. } else {
  12016. options.templateOptions
  12017. .refreshData(options.templateOptions.APIService,scope.$root.user)
  12018. .then(function (result) {
  12019. //回显故障现象,带出绑定的人或组start caocao
  12020. if (options.templateOptions.onlyKey == 'cate_start' && items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  12021. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  12022. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  12023. return v.id == items.$parent.originalModel.incident.category.id;
  12024. })
  12025. console.log(item)//11615
  12026. if (item) {
  12027. items.$parent.originalModel.incident.branchType = item.branchType;
  12028. if(item.branchType == 0){
  12029. if (item.userOrGroupType === 1) {
  12030. items.$parent.originalModel.start_code = 'assignment';
  12031. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  12032. items.$parent.originalModel.directClose = true;
  12033. items.$parent.originalModel.isHandlerUser = false;
  12034. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  12035. } else if (item.userOrGroupType === 2) {
  12036. items.$parent.originalModel.start_code = 'assignment';
  12037. items.$parent.originalModel.candidateGroups = item.group;
  12038. items.$parent.originalModel.directClose = true;
  12039. items.$parent.originalModel.isHandlerUser = false;
  12040. } else {
  12041. items.$parent.originalModel.start_code = 'close';
  12042. items.$parent.originalModel.directClose = false;
  12043. items.$parent.originalModel.isHandlerUser = false;
  12044. delete items.$parent.originalModel.candidateGroups;
  12045. delete items.$parent.originalModel.incident.handlerUser
  12046. }
  12047. }else if(item.branchType == 1){
  12048. items.$parent.originalModel.incident.branchUserGroups = item.branchUserGroups;
  12049. // items.$parent.originalModel.incident.area.id
  12050. options.templateOptions.APIService.fetchData('area',items.$parent.originalModel.incident.area.id).then(res=>{
  12051. console.log(res)
  12052. if(res.status == 200){
  12053. items.$parent.originalModel.incident.branchId = res.data.branch;
  12054. // res.data.branch
  12055. var branchUserGroup=item.branchUserGroups.find(v=>v.branchId==res.data.branch)||{};
  12056. if(branchUserGroup.branchUserOrGroupType==1){
  12057. items.$parent.originalModel.start_code='assignment';
  12058. items.$parent.originalModel.incident.handlerUser={id:branchUserGroup.userId?branchUserGroup.userId:undefined};
  12059. items.$parent.originalModel.directClose=true;
  12060. items.$parent.originalModel.isHandlerUser=false;
  12061. setTimeout(function(){items.$parent.originalModel.isHandlerUser=true;},0)
  12062. }else if(branchUserGroup.branchUserOrGroupType===2){
  12063. items.$parent.originalModel.start_code='assignment';
  12064. items.$parent.originalModel.candidateGroups=branchUserGroup.groupId?branchUserGroup.groupId:undefined;
  12065. items.$parent.originalModel.directClose=true;
  12066. items.$parent.originalModel.isHandlerUser=false;
  12067. }else{
  12068. items.$parent.originalModel.start_code='close';
  12069. items.$parent.originalModel.directClose=false;
  12070. items.$parent.originalModel.isHandlerUser=false;
  12071. delete items.$parent.originalModel.candidateGroups;
  12072. delete items.$parent.originalModel.incident.handlerUser
  12073. }
  12074. }
  12075. })
  12076. }
  12077. }
  12078. }
  12079. //回显故障现象,带出绑定的人或组end
  12080. if (!options.templateOptions.options) {
  12081. options.templateOptions.options = [];
  12082. }
  12083. if(options.templateOptions.uuKey == 'knowledge_leve.dutyDepartment'){
  12084. let data = result[options.templateOptions.optionsDataKey];
  12085. for (var i = 0; i < data.length; i++) {
  12086. data[i].parent = {id: -data[i].branch, name: data[i].branchName};
  12087. data[i].name = data[i].dept;
  12088. }
  12089. var parentList = []
  12090. var idToNodeMap = {}
  12091. for (var i = 0; i < data.length; i++) {
  12092. idToNodeMap[data[i].parent.id] = [];
  12093. parentList.push(data[i].parent);
  12094. }
  12095. let map = new Map();
  12096. for (let item of parentList) {
  12097. if (!map.has(item.id)) {
  12098. map.set(item.id, item);
  12099. };
  12100. };
  12101. parentList = [...map.values()];
  12102. // console.log(parentList);
  12103. console.log(data);
  12104. //loop over data
  12105. for (var i = 0; i < data.length; i++) {
  12106. var datum = data[i];
  12107. //each node will have children, so let's give it a "children" poperty
  12108. datum.children = [];
  12109. //add an entry for this node to the map so that any future children can
  12110. //lookup the parent
  12111. if(idToNodeMap[datum.parent.id]){
  12112. idToNodeMap[datum.parent.id].push(JSON.parse(JSON.stringify(datum)));
  12113. }
  12114. //Does this node have a parent?
  12115. }
  12116. for (let key in idToNodeMap) {
  12117. let index = parentList.findIndex(v => v.id == key);
  12118. if (index > -1) {
  12119. parentList[index].children = idToNodeMap[key];
  12120. };
  12121. };
  12122. console.log(parentList)
  12123. options.templateOptions.options = parentList;
  12124. }else{
  12125. if (options.templateOptions.optionsDataKey) {
  12126. options.templateOptions.options = convertParentToChildList(
  12127. result[options.templateOptions.optionsDataKey]
  12128. );
  12129. } else {
  12130. options.templateOptions.options =
  12131. convertParentToChildList(result);
  12132. }
  12133. }
  12134. //set default value
  12135. var pmodel,
  12136. i = 0;
  12137. if (
  12138. options.templateOptions.pkey ||
  12139. options.templateOptions.pkey != ""
  12140. ) {
  12141. if (options.templateOptions.pkey.indexOf(".") > 0) {
  12142. angular.forEach(
  12143. options.templateOptions.pkey.split("."),
  12144. function (p) {
  12145. if (i == 0) {
  12146. if (options.model[p] == null) {
  12147. options.model[p] = {};
  12148. }
  12149. pmodel = options.model[p];
  12150. i++;
  12151. } else {
  12152. if (pmodel[p] == null) {
  12153. pmodel[p] = {};
  12154. }
  12155. pmodel = pmodel[p];
  12156. }
  12157. }
  12158. );
  12159. } else {
  12160. pmodel = options.model;
  12161. }
  12162. }
  12163. var topdata = angular.copy(options.templateOptions.options);
  12164. if (pmodel) {
  12165. pmodel = pmodel[options.key];
  12166. } else if (options.model) {
  12167. pmodel = options.model[options.key];
  12168. }
  12169. if (angular.isArray(pmodel)) {
  12170. if (pmodel) {
  12171. items.inputModel = angular.copy(
  12172. options.templateOptions.options
  12173. );
  12174. selectItem(pmodel, options.templateOptions.options);
  12175. }
  12176. } else {
  12177. if (pmodel && pmodel.id) {
  12178. items.inputModel = angular.copy(
  12179. options.templateOptions.options
  12180. );
  12181. selectItem(pmodel, options.templateOptions.options);//baba
  12182. } else {
  12183. // items.inputModel = options.templateOptions.options;
  12184. }
  12185. }
  12186. // items.inputModel = options.templateOptions.options;
  12187. items.selectModel = options.templateOptions.options;
  12188. if (!items.inputModel) {
  12189. items.inputModel = items.selectModel;
  12190. } else {
  12191. selectItemchild(pmodel, items.inputModel);
  12192. // for (var i = 0; i < items.inputModel.length; i++) {
  12193. // for (var j = 0; j < items.selectModel.length; j++) {
  12194. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12195. // items.inputModel[i].selected = true;
  12196. // }
  12197. // }
  12198. // }
  12199. }
  12200. // options.templateOptions.options = angular.copy(topdata);
  12201. // console.log(model);
  12202. // console.log(options);
  12203. });
  12204. }
  12205. },
  12206. },
  12207. validators: {
  12208. required: {
  12209. expression: function (viewValue, modelValue) {
  12210. var value = modelValue || viewValue;
  12211. if (angular.isArray(value)) {
  12212. return value.length > 0;
  12213. } else {
  12214. // console.log(options)
  12215. if (options.templateOptions.required && !value) {
  12216. // return value != null;
  12217. } else {
  12218. return value;
  12219. }
  12220. // return value = "true";
  12221. }
  12222. },
  12223. },
  12224. },
  12225. };
  12226. },
  12227. controller: [
  12228. "$scope",
  12229. "$rootScope",
  12230. "api_configure_form",
  12231. "api_bpm_domain",
  12232. "api_category",
  12233. function ($scope, $rootScope, api_configure_form, api_bpm_domain, api_category) {
  12234. // // 知识库-责任科室
  12235. // if ($scope.to.uuKey === 'knowledge_leve.dutyDepartment') {
  12236. // //处理远程获取数据控件方法调用
  12237. // $scope.to.refresh = function(searchVal){
  12238. // api_category.getOwnDuty({}).then(function(res){
  12239. // if (!$scope.to.options) {
  12240. // $scope.to.options = res.data || [];
  12241. // }
  12242. // })
  12243. // };
  12244. // }
  12245. $rootScope.checkClicked = function (item) {
  12246. angular.forEach($scope.to.options, function (itemone) {
  12247. if (!item.parent) {
  12248. if (item.id == itemone.id) {
  12249. // itemone.isExpanded = true;
  12250. } else {
  12251. itemone.isExpanded = false;
  12252. }
  12253. } else {
  12254. if (item.parent.id == itemone.id) {
  12255. angular.forEach(itemone.children, function (itemtwo) {
  12256. if (item.id == itemtwo.id) {
  12257. } else {
  12258. itemtwo.isExpanded = false;
  12259. }
  12260. });
  12261. }
  12262. }
  12263. });
  12264. // 故障现象带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12265. console.log($scope, "gsm");
  12266. if (
  12267. $scope.originalModel &&
  12268. $scope.originalModel.incident &&
  12269. item.category &&
  12270. (!item.children || !item.children.length) &&
  12271. item.priority &&
  12272. item.priority.id
  12273. ) {
  12274. api_bpm_domain
  12275. .expectedTime("L" + (item.priority.id - 1559))
  12276. .then(function (res) {
  12277. $scope.originalModel.incident.expectResponseTime =
  12278. res.serviceLevelAgreement.responseTime;
  12279. $scope.originalModel.incident.expectIntroTime =
  12280. res.serviceLevelAgreement.resolveTime;
  12281. $scope.originalModel.incident.overdueTime = res.date;
  12282. });
  12283. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12284. // setTimeout(() => {
  12285. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12286. // }, 500);
  12287. // console.log($scope.$parent.$parent.$parent)
  12288. }
  12289. };
  12290. if ($scope.options.templateOptions.isMultiSelect) {
  12291. // console.log($scope);
  12292. } else {
  12293. if ($scope.model[$scope.options.key]) {
  12294. }
  12295. }
  12296. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12297. // console.log(item)
  12298. // // if(){
  12299. // // }
  12300. // // $scope.model[$scope.options.key]=item.id;
  12301. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12302. // $scope.propTypeOptions = data;
  12303. // });
  12304. // }
  12305. // $scope.model[$scope.options.key]=[];
  12306. // $scope.fn
  12307. $rootScope.bala1 = function (items, fn) {
  12308. // $scope.fn = fn;
  12309. console.log(items);
  12310. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12311. $scope.options.templateOptions.refresh(items, "search", fn);
  12312. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12313. // // return res.list;
  12314. // console.log(666)
  12315. // fn(res.list)
  12316. // })
  12317. };
  12318. },
  12319. ],
  12320. });
  12321. //勾选组件
  12322. formlyConfigProvider.setType({
  12323. name: "ui-checkbox",
  12324. extends: "checkbox",
  12325. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12326. controller: [
  12327. "$scope",
  12328. function ($scope) {
  12329. console.log($scope)
  12330. if($scope.options.templateOptions.isTrue){
  12331. //是否默认打开
  12332. $scope.model[$scope.options.key] = true;
  12333. }
  12334. // 巡检生成事件,默认派单
  12335. if ($scope.model.isInspection) {
  12336. $scope.model[$scope.options.key] = true;
  12337. }
  12338. if ($scope.model[$scope.options.key] == "true") {
  12339. $scope.model[$scope.options.key] = true;
  12340. }
  12341. if ($scope.model[$scope.options.key] == "false") {
  12342. $scope.model[$scope.options.key] = false;
  12343. }
  12344. },
  12345. ],
  12346. });
  12347. //勾选组件(禁用)--yeye
  12348. formlyConfigProvider.setType({
  12349. name: "ui-checkbox-disabled",
  12350. extends: "checkbox",
  12351. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12352. controller: [
  12353. "$scope",
  12354. function ($scope) {
  12355. // 巡检生成事件,默认派单
  12356. // if ($scope.model.isInspection) {
  12357. // $scope.model[$scope.options.key] = true;
  12358. // }
  12359. // if ($scope.model[$scope.options.key] == "true") {
  12360. // $scope.model[$scope.options.key] = true;
  12361. // }
  12362. // if ($scope.model[$scope.options.key] == "false") {
  12363. // $scope.model[$scope.options.key] = false;
  12364. // }
  12365. },
  12366. ],
  12367. });
  12368. //换行组件
  12369. formlyConfigProvider.setType({
  12370. name: "ui-nextLine",
  12371. /*extends: 'input',*/
  12372. template: "<div></div>",
  12373. });
  12374. //多选框组件
  12375. formlyConfigProvider.setType({
  12376. name: "ui-checklist",
  12377. extends: "multiCheckbox",
  12378. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12379. defaultOptions: function (options) {
  12380. return {
  12381. templateOptions: {
  12382. refresh: function () { },
  12383. refreshDelay: 0,
  12384. },
  12385. };
  12386. },
  12387. });
  12388. //单选框组件
  12389. formlyConfigProvider.setType({
  12390. name: "ui-radio",
  12391. extends: "radio",
  12392. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12393. defaultOptions: function (options) {
  12394. return {
  12395. templateOptions: {
  12396. refresh: function () {},
  12397. refreshDelay: 0,
  12398. },
  12399. };
  12400. },
  12401. controller: [
  12402. "$scope",
  12403. "api_wechatfile",
  12404. function ($scope,api_wechatfile) {
  12405. // 新增巡检计划-巡检方式baba
  12406. if($scope.to.onlyKey === 'onlineType'){
  12407. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12408. $scope.to.options = result;
  12409. if(!$scope.model[$scope.options.key]){
  12410. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12411. }
  12412. });
  12413. }
  12414. // 巡检生成事件,默认派单
  12415. if ($scope.model.isInspection) {
  12416. $scope.model[$scope.options.key] = true;
  12417. // $scope.model.isHandlerUser=true;
  12418. $scope.model.start_code = "assignment";
  12419. console.log($scope.model);
  12420. }
  12421. //多次暂存配置
  12422. // console.log($scope);
  12423. if ($scope.model.saveAgain) {
  12424. if (
  12425. $scope.model.directClose == "1" ||
  12426. $scope.model.directClose == true
  12427. ) {
  12428. $scope.model[$scope.options.key] = true;
  12429. // if($scope.model.incident.handlingPersonnelUser){
  12430. // delete $scope.model.incident.handlingPersonnelUser;
  12431. // };
  12432. if ($scope.model.incident.handleDescription) {
  12433. delete $scope.model.incident.handleDescription;
  12434. }
  12435. if ($scope.model.incident.closecode) {
  12436. delete $scope.model.incident.closecode;
  12437. }
  12438. if ($scope.model.incident.degree) {
  12439. delete $scope.model.incident.degree;
  12440. }
  12441. } else {
  12442. $scope.model.incident.handlingPersonnelUser =
  12443. $scope.model.incident.acceptUser;
  12444. $scope.model[$scope.options.key] = false;
  12445. }
  12446. }
  12447. },
  12448. ],
  12449. });
  12450. //文本域组件
  12451. formlyConfigProvider.setWrapper({
  12452. name: "validation",
  12453. types: ["ui-textarea"],
  12454. template:
  12455. '<formly-transclude></formly-transclude><div class="has-error" ng-messages="fc.$error" ng-if="options.formControl.$touched"><div class="error" ng-message="{{::name}}" ng-repeat="(name, message) in ::options.validation.messages">{{message(fc.$viewValue, fc.$modelValue, this)}}</div></div>',
  12456. });
  12457. formlyConfigProvider.setType({
  12458. name: "ui-textarea",
  12459. extends: "textarea",
  12460. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12461. defaultOptions: function (options) {
  12462. return {
  12463. templateOptions: {
  12464. transform: function (model, value) {
  12465. return value;
  12466. },
  12467. },
  12468. validation: {
  12469. messages: {
  12470. maxlength: function (viewValue, modelValue, scope) {
  12471. if (viewValue != null) {
  12472. if (viewValue.length > scope.to.maxlength) {
  12473. return (
  12474. scope.to.label +
  12475. " 字数(" +
  12476. viewValue.length +
  12477. ")超限(" +
  12478. scope.to.maxlength +
  12479. ")"
  12480. );
  12481. } else {
  12482. return "";
  12483. }
  12484. }
  12485. },
  12486. },
  12487. },
  12488. };
  12489. },
  12490. controller: [
  12491. "$scope",
  12492. function ($scope) {
  12493. var value = $scope.model[$scope.options.key];
  12494. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12495. $scope.model[$scope.options.key] =
  12496. $scope.options.templateOptions.transform(
  12497. $scope.originalModel,
  12498. value
  12499. );
  12500. }
  12501. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12502. $scope.options.templateOptions.felditem($scope);
  12503. }
  12504. },
  12505. ],
  12506. });
  12507. // div版的textarea(展示富文本框内容用)
  12508. formlyConfigProvider.setType({
  12509. name: "ui-divTextarea",
  12510. extends: "textarea",
  12511. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12512. defaultOptions: function (options) {
  12513. return {
  12514. templateOptions: {
  12515. transform: function (model, value) {
  12516. return value;
  12517. },
  12518. },
  12519. validation: {
  12520. messages: {
  12521. // maxlength: function (viewValue, modelValue, scope) {
  12522. // if (viewValue != null) {
  12523. // if (viewValue.length > scope.to.maxlength) {
  12524. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12525. // } else {
  12526. // return "";
  12527. // }
  12528. // }
  12529. // },
  12530. },
  12531. },
  12532. };
  12533. },
  12534. controller: [
  12535. "$scope",
  12536. function ($scope) {
  12537. var value = $scope.model[$scope.options.key];
  12538. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12539. $scope.model[$scope.options.key] =
  12540. $scope.options.templateOptions.transform(
  12541. $scope.originalModel,
  12542. value
  12543. );
  12544. }
  12545. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12546. $scope.options.templateOptions.felditem($scope);
  12547. }
  12548. },
  12549. ],
  12550. });
  12551. // 带有知识库引用的textarea
  12552. formlyConfigProvider.setType({
  12553. name: "ui-textAreaKnowledge",
  12554. // extends: 'textarea',
  12555. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12556. defaultOptions: function (options) {
  12557. return {
  12558. templateOptions: {
  12559. transform: function (model, value) {
  12560. return value;
  12561. },
  12562. },
  12563. validation: {
  12564. messages: {
  12565. maxlength: function (viewValue, modelValue, scope) {
  12566. if (viewValue != null) {
  12567. if (viewValue.length > scope.to.maxlength) {
  12568. return (
  12569. scope.to.label +
  12570. " 字数(" +
  12571. viewValue.length +
  12572. ")超限(" +
  12573. scope.to.maxlength +
  12574. ")"
  12575. );
  12576. } else {
  12577. return "";
  12578. }
  12579. }
  12580. },
  12581. },
  12582. },
  12583. };
  12584. },
  12585. controller: [
  12586. "$scope",
  12587. "$rootScope",
  12588. "$modal",
  12589. "SweetAlert",
  12590. "api_bpm_data",
  12591. "api_bpm_domain",
  12592. "api_solution",
  12593. "$aside",
  12594. "api_zsk",
  12595. "up_down_file",
  12596. "api_wechatfile",
  12597. function (
  12598. $scope,
  12599. $rootScope,
  12600. $modal,
  12601. SweetAlert,
  12602. api_bpm_data,
  12603. api_bpm_domain,
  12604. api_solution,
  12605. $aside,
  12606. api_zsk,
  12607. up_down_file,
  12608. api_wechatfile
  12609. ) {
  12610. // console.log($scope);
  12611. var value = $scope.model[$scope.options.key];
  12612. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12613. $scope.model[$scope.options.key] =
  12614. $scope.options.templateOptions.transform(
  12615. $scope.originalModel,
  12616. value
  12617. );
  12618. }
  12619. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12620. $scope.options.templateOptions.felditem($scope);
  12621. }
  12622. // 引用知识库点击
  12623. $scope.openSolution = function () {
  12624. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12625. setTimeout(() => {
  12626. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12627. }, 100);
  12628. };
  12629. },
  12630. ],
  12631. });
  12632. //常用语句选择textarea
  12633. formlyConfigProvider.setType({
  12634. name: "ui-textselect",
  12635. extends: "textarea",
  12636. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12637. defaultOptions: function (options) {
  12638. return {
  12639. templateOptions: {
  12640. transform: function (model, value) {
  12641. return value;
  12642. },
  12643. },
  12644. validation: {
  12645. messages: {
  12646. maxlength: function (viewValue, modelValue, scope) {
  12647. if (viewValue != null) {
  12648. if (viewValue.length > scope.to.maxlength) {
  12649. return (
  12650. scope.to.label +
  12651. " 字数(" +
  12652. viewValue.length +
  12653. ")超限(" +
  12654. scope.to.maxlength +
  12655. ")"
  12656. );
  12657. } else {
  12658. return "";
  12659. }
  12660. }
  12661. },
  12662. },
  12663. },
  12664. };
  12665. },
  12666. controller: [
  12667. "$scope",
  12668. function ($scope) {
  12669. var value = $scope.model[$scope.options.key];
  12670. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12671. $scope.model[$scope.options.key] =
  12672. $scope.options.templateOptions.transform(
  12673. $scope.originalModel,
  12674. value
  12675. );
  12676. }
  12677. },
  12678. ],
  12679. });
  12680. //改动的组件 ckeditor封装后的组件
  12681. formlyConfigProvider.setType({
  12682. name: "ui-text-check",
  12683. extends: "textarea",
  12684. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12685. defaultOptions: function (options) {
  12686. return {
  12687. templateOptions: {
  12688. extraPlugins: "uploadimage",
  12689. uploadimageConfig: {
  12690. backend: "basic",
  12691. settings: {
  12692. uploadUrl:
  12693. options.templateOptions.APIService.upload().getRequestedUrl(),
  12694. headers: "",
  12695. downloadUrl:
  12696. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12697. },
  12698. },
  12699. refresh: function (APIService, contentId, data) {
  12700. return APIService.fetchDataList(contentId, data);
  12701. },
  12702. downloadUri: function (APIService, contentId) {
  12703. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12704. },
  12705. upload: function (APIService, contentId) {
  12706. return APIService.getSolutionDowpath(contentId);
  12707. },
  12708. view: function (attachmentId) {
  12709. // return APIService.attachmentsPreviewUrl(contentId);
  12710. },
  12711. refreshDelay: 0,
  12712. transform: function (model, value) {
  12713. return value;
  12714. },
  12715. },
  12716. validation: {
  12717. messages: {
  12718. maxlength: function (viewValue, modelValue, scope) {
  12719. if (viewValue != null) {
  12720. if (viewValue.length > scope.to.maxlength) {
  12721. return (
  12722. scope.to.label +
  12723. " 字数(" +
  12724. viewValue.length +
  12725. ")超限(" +
  12726. scope.to.maxlength +
  12727. ")"
  12728. );
  12729. } else {
  12730. return "";
  12731. }
  12732. }
  12733. },
  12734. },
  12735. },
  12736. };
  12737. },
  12738. controller: [
  12739. "$scope",
  12740. "$rootScope",
  12741. function ($scope, $rootScope) {
  12742. var value = $scope.model[$scope.options.key];
  12743. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12744. $scope.model[$scope.options.key] =
  12745. $scope.options.templateOptions.transform(
  12746. $scope.originalModel,
  12747. value
  12748. );
  12749. }
  12750. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12751. $rootScope.getSession();
  12752. //var expiry={'expiry':14804244006};
  12753. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12754. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12755. $scope.upload = function (contentId, filename) {
  12756. var filename = filename;
  12757. $scope.options.templateOptions
  12758. .upload($scope.options.templateOptions.ApiService, contentId)
  12759. .then(function (response) {
  12760. var file = new Blob([response], {
  12761. type: "application/octet-stream",
  12762. });
  12763. // var filename = filename;
  12764. var fileURL = URL.createObjectURL(file);
  12765. var a = document.createElement("a");
  12766. a.href = fileURL;
  12767. a.target = "_blank";
  12768. a.download = filename;
  12769. document.body.appendChild(a);
  12770. a.click();
  12771. });
  12772. };
  12773. },
  12774. ],
  12775. });
  12776. //改动的组件 ckeditor封装后的附文本组件
  12777. formlyConfigProvider.setType({
  12778. name: "ui-fuwenben",
  12779. extends: "textarea",
  12780. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12781. defaultOptions: function (options) {
  12782. return {
  12783. templateOptions: {
  12784. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12785. extraPlugins: "uploadimage",
  12786. uploadimageConfig: {
  12787. backend: "basic",
  12788. settings: {
  12789. uploadUrl:
  12790. options.templateOptions.APIService.upload(
  12791. -110
  12792. ).getRequestedUrl(),
  12793. headers: "",
  12794. downloadUrl:
  12795. options.templateOptions.APIService.uploadResponseUri(),
  12796. },
  12797. },
  12798. refresh: function (APIService, contentId, data) {
  12799. return APIService.fetchDataList(-110, data);
  12800. },
  12801. downloadUri: function (APIService, contentId) {
  12802. return APIService.downloadAttachment(-110).getRequestedUrl();
  12803. },
  12804. upload: function (APIService, contentId) {
  12805. return APIService.getSolutionDowpath(-110);
  12806. },
  12807. view: function (attachmentId) {
  12808. // return APIService.attachmentsPreviewUrl(contentId);
  12809. },
  12810. refreshDelay: 0,
  12811. transform: function (model, value) {
  12812. return value;
  12813. },
  12814. },
  12815. validation: {
  12816. messages: {
  12817. maxlength: function (viewValue, modelValue, scope) {
  12818. if (viewValue != null) {
  12819. if (viewValue.length > scope.to.maxlength) {
  12820. return (
  12821. scope.to.label +
  12822. " 字数(" +
  12823. viewValue.length +
  12824. ")超限(" +
  12825. scope.to.maxlength +
  12826. ")"
  12827. );
  12828. } else {
  12829. return "";
  12830. }
  12831. }
  12832. },
  12833. },
  12834. },
  12835. };
  12836. },
  12837. controller: [
  12838. "$scope",
  12839. "$rootScope",
  12840. function ($scope, $rootScope) {
  12841. var value = $scope.model[$scope.options.key];
  12842. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12843. $scope.model[$scope.options.key] =
  12844. $scope.options.templateOptions.transform(
  12845. $scope.originalModel,
  12846. value
  12847. );
  12848. }
  12849. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12850. $rootScope.getSession();
  12851. //var expiry={'expiry':14804244006};
  12852. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12853. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12854. $scope.upload = function (contentId, filename) {
  12855. var filename = filename;
  12856. $scope.options.templateOptions
  12857. .upload($scope.options.templateOptions.ApiService, -110)
  12858. .then(function (response) {
  12859. var file = new Blob([response], {
  12860. type: "application/octet-stream",
  12861. });
  12862. // var filename = filename;
  12863. var fileURL = URL.createObjectURL(file);
  12864. var a = document.createElement("a");
  12865. a.href = fileURL;
  12866. a.target = "_blank";
  12867. a.download = filename;
  12868. document.body.appendChild(a);
  12869. a.click();
  12870. });
  12871. };
  12872. },
  12873. ],
  12874. });
  12875. //ui-grid展示控件
  12876. formlyConfigProvider.setType({
  12877. name: "ui-grid-show",
  12878. extends: "multiCheckbox",
  12879. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12880. defaultOptions: function (options,scope) {
  12881. return {
  12882. templateOptions: {
  12883. linkage: function () { },
  12884. getScope: function () {
  12885. return scope;
  12886. },
  12887. },
  12888. };
  12889. },
  12890. controller: function (
  12891. $scope,
  12892. $rootScope,
  12893. i18nService,
  12894. Restangular,
  12895. api_bpm_data
  12896. ) {
  12897. var loginUser = $rootScope.user;
  12898. $scope.langs = i18nService.getAllLangs();
  12899. $scope.lang = "zh-cn";
  12900. i18nService.setCurrentLang($scope.lang);
  12901. $scope.gridOptions = {};
  12902. $scope.gridOptions.data = "myData";
  12903. $scope.gridOptions.enableColumnResizing = true;
  12904. // $scope.gridOptions.enableFiltering = true;
  12905. $scope.gridOptions.enableGridMenu = false;
  12906. $scope.gridOptions.enableRowSelection = true;
  12907. $scope.gridOptions.showGridFooter = true;
  12908. $scope.gridOptions.showColumnFooter = false;
  12909. $scope.gridOptions.fastWatch = true;
  12910. $scope.gridOptions.useExternalFiltering = true;
  12911. $scope.gridOptions.useExternalPagination = true;
  12912. $scope.gridOptions.paginationPageSizes = [10];
  12913. $scope.gridOptions.paginationPageSize = 10;
  12914. $scope.gridOptions.multiSelect = true;
  12915. $scope.gridOptions.rowIdentity = function (row) {
  12916. return row.id;
  12917. };
  12918. $scope.gridOptions.getRowIdentity = function (row) {
  12919. return row.id;
  12920. };
  12921. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12922. $scope.gridOptions.columnDefs = [
  12923. // { name:'id', width:80, enableFiltering:false},
  12924. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12925. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12926. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12927. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12928. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12929. {
  12930. name: "inspection.title",
  12931. displayName: "计划主题",
  12932. width: 120,
  12933. enableFiltering: false,
  12934. },
  12935. {
  12936. name: "sign",
  12937. displayName: "单号",
  12938. width: 140,
  12939. enableFiltering: false,
  12940. },
  12941. {
  12942. name: "inspectionType.type",
  12943. displayName: "巡检分类",
  12944. width: 200,
  12945. enableFiltering: false,
  12946. cellTemplate: '<div>' +
  12947. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12948. '</div>'
  12949. },
  12950. {
  12951. name: "stateName",
  12952. displayName: "状态",
  12953. width: 80,
  12954. enableFiltering: false,
  12955. },
  12956. {
  12957. name: "processUser.name",
  12958. displayName: "处理人/组",
  12959. width: 120,
  12960. enableFiltering: false,
  12961. cellTemplate: '<div>' +
  12962. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12963. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12964. '</div>'
  12965. },
  12966. {
  12967. name: "startDate",
  12968. displayName: "开始时间",
  12969. width: 160,
  12970. enableFiltering: false,
  12971. },
  12972. {
  12973. name: "endTime",
  12974. displayName: "结束时间",
  12975. width: 160,
  12976. enableFiltering: false,
  12977. cellTemplate: '<div>' +
  12978. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12979. '</div>'
  12980. },
  12981. // {
  12982. // name: "batchNo",
  12983. // displayName: "批次号",
  12984. // width: 160,
  12985. // enableFiltering: false,
  12986. // },
  12987. ];
  12988. var defaultFilterData = {
  12989. idx: 0,
  12990. sum: 10,
  12991. };
  12992. $scope.transferTime = function (time) {
  12993. return moment(time).format("YYYY-MM-DD HH:mm");
  12994. };
  12995. //分页控制
  12996. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12997. gridApi.pagination.on.paginationChanged(
  12998. $scope,
  12999. function (newPage, pageSize) {
  13000. var filtersData = $scope.memoryfilterData;
  13001. filtersData.idx = newPage - 1;
  13002. filtersData.sum = pageSize;
  13003. $scope.refreshData("expand-right", filtersData);
  13004. }
  13005. );
  13006. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13007. data.grid.appScope.selected.items = data.entity;
  13008. });
  13009. };
  13010. //页面获取数据
  13011. $scope.refreshData = function (style, filterData) {
  13012. // $scope.ldloading[style.replace('-', '_')] = true;
  13013. console.log(angular.isUndefined(filterData))
  13014. if (angular.isUndefined(filterData)) {
  13015. filterData = defaultFilterData;
  13016. }
  13017. $scope.myData = [];
  13018. console.log(filterData)
  13019. if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
  13020. filterData.inspectionProcessActual = {
  13021. inspectionid: $scope.model.id,
  13022. batchNo:filterData.inspectionProcessActual.batchNo
  13023. }
  13024. }else{
  13025. filterData.inspectionProcessActual = {
  13026. inspectionid: $scope.model.id
  13027. }
  13028. }
  13029. // angular.extend(filterData, {
  13030. // inspectionProcessActual: {
  13031. // inspectionid: $scope.model.id,
  13032. // },
  13033. // });
  13034. console.log(filterData)
  13035. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  13036. function (data) {
  13037. var myData = Restangular.stripRestangular(data);
  13038. $scope.gridOptions.totalItems = myData.totalNum;
  13039. $scope.myData = myData.list;
  13040. for (var i = 0; i < $scope.myData.length; i++) {
  13041. //添加序号
  13042. $scope.myData[i]["item"] =
  13043. i + 1 + filterData.idx * filterData.sum;
  13044. }
  13045. // $scope.ldloading[style.replace('-', '_')] = false;
  13046. },
  13047. function () {
  13048. // $scope.ldloading[style.replace('-', '_')] = false;
  13049. }
  13050. );
  13051. };
  13052. $scope.refreshData("expand-right", defaultFilterData);
  13053. },
  13054. });
  13055. //文本框自定义选择面板组件
  13056. formlyConfigProvider.setType({
  13057. name: "ui-input-selectmodal",
  13058. extends: "input",
  13059. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  13060. defaultOptions: function (options) {
  13061. return {
  13062. templateOptions: {
  13063. openModal: function (size, options, modal) {
  13064. var modalInstance = modal.open({
  13065. templateUrl: "assets/views/customform/tpl/modal-content.html",
  13066. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  13067. size: size,
  13068. resolve: options.templateOptions.modalParam,
  13069. });
  13070. modalInstance.result.then(
  13071. function (selectedItem) {
  13072. options.value(selectedItem);
  13073. },
  13074. function () {
  13075. //console.log('Modal dismissed at: ' + new Date());
  13076. }
  13077. );
  13078. },
  13079. },
  13080. };
  13081. },
  13082. });
  13083. //日期控件
  13084. var datepicker_attr = [
  13085. "date-disabled",
  13086. "custom-class",
  13087. "show-weeks",
  13088. "starting-day",
  13089. "init-date",
  13090. "min-mode",
  13091. "max-mode",
  13092. "format-day",
  13093. "format-month",
  13094. "format-year",
  13095. "format-day-header",
  13096. "format-day-title",
  13097. "format-month-title",
  13098. "year-range",
  13099. "shortcut-propagation",
  13100. "datepicker-popup",
  13101. "show-button-bar",
  13102. "current-text",
  13103. "clear-text",
  13104. "close-text",
  13105. "close-on-date-selection",
  13106. "datepicker-append-to-body",
  13107. ];
  13108. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  13109. formlyConfigProvider.setType({
  13110. name: "ui-datetime",
  13111. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  13112. extends: "input",
  13113. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13114. defaultOptions: {
  13115. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13116. templateOptions: {
  13117. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13118. },
  13119. },
  13120. controller: [
  13121. "$scope",
  13122. "$filter",
  13123. function ($scope, $filter) {
  13124. $scope.model[$scope.options.key] = $filter("date")(
  13125. new Date(),
  13126. $scope.options.templateOptions.datepickerPopup
  13127. );
  13128. $scope.options.initialValue = $scope.model[$scope.options.key];
  13129. },
  13130. ],
  13131. });
  13132. //日期控件
  13133. formlyConfigProvider.setType({
  13134. name: "ui-datepicker",
  13135. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  13136. extends: "input",
  13137. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13138. defaultOptions: {
  13139. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13140. templateOptions: {
  13141. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13142. },
  13143. },
  13144. controller: [
  13145. "$scope",
  13146. "$filter",
  13147. function ($scope, $filter) {
  13148. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  13149. if ($scope.model[$scope.options.key]) {
  13150. } else {
  13151. $scope.model[$scope.options.key] = $filter("date")(
  13152. new Date(),
  13153. $scope.options.templateOptions.datepickerPopup
  13154. );
  13155. }
  13156. $scope.options.initialValue = $scope.model[$scope.options.key];
  13157. $scope.endOpen = true;
  13158. $scope.datepicker = {};
  13159. $scope.datepicker.opened = false;
  13160. $scope.datepicker.open = function ($event) {
  13161. $scope.datepicker.opened = true;
  13162. };
  13163. },
  13164. ],
  13165. });
  13166. //时分控件
  13167. formlyConfigProvider.setType({
  13168. name: "ui-datehourtime",
  13169. extends: "input",
  13170. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  13171. defaultOptions: function (options) {
  13172. return {
  13173. noFormControl: true,
  13174. // validators:{
  13175. // required:{
  13176. // expression:function(viewValue, modelValue){
  13177. // console.log(options)
  13178. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13179. // // var value = modelValue.getHours() || viewValue.getHours();
  13180. // return value.length>=1;
  13181. // }
  13182. // }
  13183. // }
  13184. };
  13185. },
  13186. controller: [
  13187. "$scope",
  13188. "$log",
  13189. function ($scope, $log) {
  13190. $scope.hstep = new Date(
  13191. Date.parse($scope.model[$scope.options.key])
  13192. ).getHours();
  13193. $scope.minutes = new Date(
  13194. Date.parse($scope.model[$scope.options.key])
  13195. ).getMinutes();
  13196. $scope.model[$scope.options.key] = new Date(
  13197. Date.parse($scope.model[$scope.options.key])
  13198. );
  13199. },
  13200. ],
  13201. });
  13202. //状态追踪
  13203. formlyConfigProvider.setType({
  13204. name: "ui-followStatus",
  13205. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13206. controller: [
  13207. "$scope",
  13208. "api_bpm_data",
  13209. "Restangular",
  13210. function ($scope, api_bpm_data, Restangular) {
  13211. setTimeout(function () {
  13212. var pkey = $scope.options.templateOptions.pkey;
  13213. var dataId = $scope.model.id;
  13214. if (dataId) {
  13215. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13216. if (response) {
  13217. var myData = Restangular.stripRestangular(response);
  13218. var processInstanceId = myData.data.processInstanceId;
  13219. $scope.options.templateOptions
  13220. .getData(
  13221. $scope.model,
  13222. $scope.options.templateOptions.ApiService,
  13223. processInstanceId
  13224. )
  13225. .then(function (result) {
  13226. if (result.status == 200) {
  13227. var newData = Restangular.stripRestangular(result);
  13228. $scope.followData = newData.data;
  13229. }
  13230. });
  13231. }
  13232. });
  13233. }
  13234. }, 10);
  13235. },
  13236. ],
  13237. });
  13238. //状态追踪2-事件id
  13239. formlyConfigProvider.setType({
  13240. name: "ui-followStatus2",
  13241. templateUrl: "assets/views/customform/tpl/ui-followStatus2.html",
  13242. controller: [
  13243. "$scope",
  13244. "api_bpm_data",
  13245. "Restangular",
  13246. function ($scope, api_bpm_data, Restangular) {
  13247. setTimeout(function () {
  13248. var pkey = $scope.options.templateOptions.pkey;
  13249. var dataId = $scope.model.id;
  13250. if (dataId) {
  13251. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13252. if (response) {
  13253. var myData = Restangular.stripRestangular(response);
  13254. var incidentId = myData.data.id;
  13255. $scope.options.templateOptions
  13256. .getData(
  13257. $scope.model,
  13258. $scope.options.templateOptions.ApiService,
  13259. incidentId
  13260. )
  13261. .then(function (result) {
  13262. if (result.status == 200) {
  13263. var newData = Restangular.stripRestangular(result);
  13264. $scope.followData = newData.list || [];
  13265. }
  13266. });
  13267. }
  13268. });
  13269. }
  13270. }, 10);
  13271. },
  13272. ],
  13273. });
  13274. //维修记录
  13275. formlyConfigProvider.setType({
  13276. name: "ui-handlerLog",
  13277. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13278. controller: [
  13279. "$scope",
  13280. "api_bpm_data",
  13281. "Restangular",
  13282. function ($scope, api_bpm_data, Restangular) {
  13283. console.log($scope, 'ui-handlerLog')
  13284. },
  13285. ],
  13286. });
  13287. //资产
  13288. formlyConfigProvider.setType({
  13289. name: "ui-zc",
  13290. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13291. controller: [
  13292. "$scope",
  13293. "api_bpm_data",
  13294. "Restangular",
  13295. function ($scope, api_bpm_data, Restangular) {
  13296. console.log($scope, 'ui-zc');
  13297. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13298. },
  13299. ],
  13300. });
  13301. //绑定的耗材
  13302. formlyConfigProvider.setType({
  13303. name: "ui-hc",
  13304. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13305. controller: [
  13306. "$scope",
  13307. "api_cmdb2",
  13308. "Restangular",
  13309. function ($scope, api_cmdb2, Restangular) {
  13310. console.log($scope, 'ui-hc')
  13311. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13312. $scope.list = [];
  13313. var sjId = $scope.model.incident.id;
  13314. api_cmdb2.getHc(sjId).then(function (response) {
  13315. console.log(response)
  13316. if (response.status == 200) {
  13317. $scope.list = response.data;
  13318. }
  13319. })
  13320. },
  13321. ],
  13322. });
  13323. //历史记录
  13324. formlyConfigProvider.setType({
  13325. name: "ui-history",
  13326. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13327. controller: [
  13328. "$scope",
  13329. "api_bpm_data",
  13330. "Restangular",
  13331. function ($scope, api_bpm_data, Restangular) {
  13332. setTimeout(function () {
  13333. var pkey = $scope.options.templateOptions.pkey;
  13334. var dataId = $scope.model.id;
  13335. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13336. if (response) {
  13337. var myData = Restangular.stripRestangular(response);
  13338. var processInstanceId = myData.data.processInstanceId;
  13339. $scope.options.templateOptions
  13340. .getData(
  13341. $scope.model,
  13342. $scope.options.templateOptions.ApiService,
  13343. processInstanceId
  13344. )
  13345. .then(function (result) {
  13346. if (result.status == 200) {
  13347. var newData = Restangular.stripRestangular(result);
  13348. var long = newData.data.length - 1;
  13349. $scope.followData = newData.data[long];
  13350. }
  13351. });
  13352. }
  13353. });
  13354. }, 10);
  13355. },
  13356. ],
  13357. });
  13358. // //请求人信息显示
  13359. // formlyConfigProvider.setType({
  13360. // name: "ui-disrequester",
  13361. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13362. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13363. // defaultOptions: function(options) {
  13364. // return {
  13365. // templateOptions: {}
  13366. // };
  13367. // },
  13368. // controller: ['$scope', function($scope) {
  13369. // $scope.options.templateOptions.that = $scope;
  13370. // }]
  13371. // });
  13372. //退回人信息显示
  13373. formlyConfigProvider.setType({
  13374. name: "ui-returnperson",
  13375. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13376. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13377. defaultOptions: function (options) {
  13378. return {
  13379. templateOptions: {},
  13380. };
  13381. },
  13382. controller: [
  13383. "$scope",
  13384. function ($scope) {
  13385. $scope.group = "";
  13386. $scope.role = "";
  13387. if (
  13388. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13389. $scope.model.handlingPersonnelUser.group.length == 1
  13390. ) {
  13391. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13392. } else {
  13393. for (
  13394. var i = 0;
  13395. i < $scope.model.handlingPersonnelUser.group.length;
  13396. i++
  13397. ) {
  13398. $scope.group +=
  13399. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13400. }
  13401. }
  13402. if (
  13403. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13404. $scope.model.handlingPersonnelUser.role.length == 1
  13405. ) {
  13406. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13407. } else {
  13408. for (
  13409. var i = 0;
  13410. i < $scope.model.handlingPersonnelUser.role.length;
  13411. i++
  13412. ) {
  13413. $scope.role +=
  13414. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13415. }
  13416. }
  13417. $scope.options.templateOptions.that = $scope;
  13418. $scope.options.templateOptions.that = $scope;
  13419. },
  13420. ],
  13421. });
  13422. //退回人信息显示(去掉工作组&角色)
  13423. formlyConfigProvider.setType({
  13424. name: "ui-returnpersonNoGroup",
  13425. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13426. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13427. defaultOptions: function (options) {
  13428. return {
  13429. templateOptions: {},
  13430. };
  13431. },
  13432. controller: [
  13433. "$scope",
  13434. function ($scope) {
  13435. $scope.group = "";
  13436. $scope.role = "";
  13437. if (
  13438. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13439. $scope.model.handlingPersonnelUser.group.length == 1
  13440. ) {
  13441. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13442. } else {
  13443. for (
  13444. var i = 0;
  13445. i < $scope.model.handlingPersonnelUser.group.length;
  13446. i++
  13447. ) {
  13448. $scope.group +=
  13449. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13450. }
  13451. }
  13452. if (
  13453. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13454. $scope.model.handlingPersonnelUser.role.length == 1
  13455. ) {
  13456. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13457. } else {
  13458. for (
  13459. var i = 0;
  13460. i < $scope.model.handlingPersonnelUser.role.length;
  13461. i++
  13462. ) {
  13463. $scope.role +=
  13464. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13465. }
  13466. }
  13467. $scope.options.templateOptions.that = $scope;
  13468. $scope.options.templateOptions.that = $scope;
  13469. },
  13470. ],
  13471. });
  13472. //指派技术人员
  13473. formlyConfigProvider.setType({
  13474. name: "ui-apiontperson",
  13475. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13476. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13477. defaultOptions: function (options) {
  13478. return {
  13479. templateOptions: {
  13480. transtlara: function (value, $scope) { },
  13481. },
  13482. };
  13483. },
  13484. controller: [
  13485. "$scope",
  13486. "api_user_data",
  13487. "Restangular",
  13488. function ($scope, api_user_data, Restangular) {
  13489. var filterData = {
  13490. idx: 0,
  13491. sum: 1000,
  13492. };
  13493. api_user_data
  13494. .fetchDataList("group", filterData)
  13495. .then(function (response) {
  13496. if (response.status == 200) {
  13497. $scope.select = {};
  13498. $scope.multipleDemo = {};
  13499. $scope.userdata = {};
  13500. var data = response.list;
  13501. var item = [];
  13502. $scope.multipleDemo = data;
  13503. $scope.multipleDemo;
  13504. }
  13505. });
  13506. $scope.options.templateOptions.onChange = function (
  13507. id,
  13508. options,
  13509. groupdata,
  13510. $event,
  13511. model
  13512. ) {
  13513. if (groupdata.option) {
  13514. $scope.model[$scope.options.key] = {};
  13515. var fildate = {
  13516. idx: 0,
  13517. sum: 1000,
  13518. user: {
  13519. roledata: {
  13520. rolecode: model.currentRole,
  13521. },
  13522. selectType: "1",
  13523. groupdata: {
  13524. id: groupdata.option.id,
  13525. },
  13526. engineer: 1,
  13527. },
  13528. };
  13529. api_user_data
  13530. .fetchDataList("user", fildate)
  13531. .then(function (response) {
  13532. if (response.status == 200) {
  13533. $scope.userdata = {};
  13534. $scope.userdata = response.list;
  13535. }
  13536. });
  13537. } else {
  13538. $scope.model[$scope.options.key] = {
  13539. id: groupdata.id.id,
  13540. };
  13541. $scope.options.templateOptions.transtlara(
  13542. $scope.model[$scope.options.key],
  13543. $scope
  13544. );
  13545. }
  13546. };
  13547. // }
  13548. },
  13549. ],
  13550. });
  13551. //请求科室信息(小蓝框) lmm
  13552. formlyConfigProvider.setType({
  13553. name: "ui-deptinformation",
  13554. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13555. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13556. return {
  13557. templateOptions: {
  13558. checkform: function (options) { },
  13559. },
  13560. };
  13561. },
  13562. controller: [
  13563. "$scope",
  13564. "api_statistic",
  13565. function ($scope, api_statistic) {
  13566. // console.log($scope)
  13567. },
  13568. ],
  13569. });
  13570. //请求人信息
  13571. formlyConfigProvider.setType({
  13572. name: "ui-requesterinformation",
  13573. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13574. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13575. return {
  13576. templateOptions: {
  13577. checkform: function (options) {
  13578. if (options.model.requester) {
  13579. options.value(options.model.requester);
  13580. }
  13581. },
  13582. addRequeter: function (size, options, modal, e) {
  13583. if (e) {
  13584. if (e.clientX === 0) {
  13585. return;
  13586. }
  13587. e.preventDefault();
  13588. }
  13589. var modalInstance = modal.open({
  13590. templateUrl:
  13591. "assets/views/customform/tpl/modal-add-callrequester.html",
  13592. controller: function (
  13593. $scope,
  13594. sco,
  13595. $rootScope,
  13596. $modalInstance,
  13597. items,
  13598. SweetAlert,
  13599. title,
  13600. Restangular,
  13601. APIService,
  13602. UserService,
  13603. api_user_data,
  13604. api_statistic,
  13605. api_wechatfile,
  13606. $stateParams
  13607. ) {
  13608. $modalInstance.SweetAlert = SweetAlert;
  13609. $scope.title = "新增报修人";
  13610. $scope.requester = {};
  13611. $scope.searchData = {};
  13612. $scope.isRoom = sessionStorage.getItem('ifRoom') == 1;
  13613. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13614. var paramsModel = JSON.parse($stateParams.model)
  13615. //来电-添加报修人-回显电话
  13616. if (paramsModel.model.incident.requester.hjzxPhone) {
  13617. $scope.requester.phone = paramsModel.model.incident.requester.hjzxPhone;
  13618. }
  13619. }
  13620. $scope.onChangeadd = function (searchData) {
  13621. $scope.searchKey = searchData.account;
  13622. // $scope.searchDataadd = searchData;
  13623. var requesdata = angular.copy(searchData);
  13624. if (requesdata.phone) {
  13625. delete requesdata.phone;
  13626. }
  13627. $scope.requester = requesdata;
  13628. console.log($scope.requester);
  13629. };
  13630. $scope.refreshUseradd = function (searchKey) {
  13631. //请求人搜索
  13632. $scope.requester.account = searchKey;
  13633. $scope.searchData = searchKey;
  13634. serchdataadd(searchKey);
  13635. };
  13636. $scope.getMydata = function (x) {
  13637. $scope.searchField = JSON.parse(x[0]).account;
  13638. $scope.requester = JSON.parse(x[0]);
  13639. console.log($scope.requester);
  13640. };
  13641. $scope.getMydataone = function (x) {
  13642. $scope.searchField = x;
  13643. $scope.requester.account = x;
  13644. };
  13645. serchdataadd();
  13646. api_wechatfile
  13647. .getDictionary({
  13648. type: "list",
  13649. key: "male",
  13650. })
  13651. .then(function (data) {
  13652. if (data.status == 200) {
  13653. requester.gender = data.list;
  13654. }
  13655. });
  13656. function serchdataadd(searchKey) {
  13657. if (searchKey) {
  13658. var filterData = {
  13659. user: {
  13660. name: searchKey,
  13661. selectType: "pinyin_all",
  13662. engineer: undefined,
  13663. },
  13664. idx: 0,
  13665. sum: 10,
  13666. };
  13667. } else {
  13668. var filterData = {
  13669. idx: 0,
  13670. sum: 10,
  13671. user: {
  13672. engineer: undefined,
  13673. },
  13674. };
  13675. }
  13676. api_user_data
  13677. .fetchDataList("user", filterData)
  13678. .then(function (response) {
  13679. var myData = response;
  13680. $scope.myData = myData.list;
  13681. });
  13682. }
  13683. api_user_data
  13684. .fetchDataList("area", {
  13685. idx: 0,
  13686. sum: 1000,
  13687. })
  13688. .then(function (response) {
  13689. if (response.status == 200) {
  13690. $scope.areas = response.list;
  13691. }
  13692. });
  13693. api_wechatfile
  13694. .getDictionary(
  13695. {
  13696. key: "requester_type",
  13697. type: "list",
  13698. },
  13699. {
  13700. idx: 0,
  13701. sum: 100,
  13702. }
  13703. )
  13704. .then(function (response) {
  13705. if (response) {
  13706. $scope.networktypes = response;
  13707. }
  13708. });
  13709. $scope.requesterAreaid = "";
  13710. $scope.onChange = function (item) {
  13711. $scope.requesterAreaid = item.id;
  13712. api_user_data
  13713. .fetchDataList("place", {
  13714. place: {
  13715. area: {
  13716. id: item.id,
  13717. },
  13718. },
  13719. idx: 0,
  13720. sum: 1000,
  13721. })
  13722. .then(function (response) {
  13723. if (response.status == 200) {
  13724. $scope.places = response.list;
  13725. delete $scope.requester.placeDTO;
  13726. }
  13727. });
  13728. };
  13729. // 修改地点
  13730. $scope.requesterPlaceid = "";
  13731. $scope.onChangePlace = function (item) {
  13732. $scope.requesterPlaceid = item.id;
  13733. api_user_data
  13734. .fetchDataList("room", {
  13735. room: {
  13736. place: {
  13737. id: item.id,
  13738. },
  13739. },
  13740. idx: 0,
  13741. sum: 1000,
  13742. })
  13743. .then(function (response) {
  13744. if (response.status == 200) {
  13745. $scope.rooms = response.list;
  13746. }
  13747. });
  13748. };
  13749. $scope.refresh = function (searchVal) {
  13750. var faildata = {};
  13751. if ($scope.requesterAreaid) {
  13752. faildata = {
  13753. idx: 0,
  13754. sum: 1000,
  13755. place: {
  13756. areaId: $scope.requesterAreaid,
  13757. place: searchVal,
  13758. selectType: "pinyin_qs",
  13759. },
  13760. };
  13761. } else {
  13762. faildata = {
  13763. idx: 0,
  13764. sum: 1000,
  13765. place: {
  13766. place: searchVal,
  13767. selectType: "pinyin_qs",
  13768. },
  13769. };
  13770. }
  13771. api_user_data
  13772. .fetchDataList("place", faildata)
  13773. .then(function (response) {
  13774. $scope.places = response.list;
  13775. delete $scope.requester.placeDTO;
  13776. });
  13777. };
  13778. // 初始化房间号
  13779. $scope.refreshPlace = function () {
  13780. var faildata = {};
  13781. if ($scope.requesterPlaceid) {
  13782. faildata = {
  13783. idx: 0,
  13784. sum: 1000,
  13785. room: {
  13786. place: {id:$scope.requesterPlaceid},
  13787. },
  13788. };
  13789. } else {
  13790. faildata = {
  13791. idx: 0,
  13792. sum: 1000,
  13793. room: {
  13794. place: {id:$scope.requesterPlaceid},
  13795. },
  13796. };
  13797. }
  13798. api_user_data
  13799. .fetchDataList("room", faildata)
  13800. .then(function (response) {
  13801. $scope.rooms = response.list;
  13802. });
  13803. };
  13804. $scope.refreshDepts = function (key) {
  13805. var filterData = {
  13806. idx: 0,
  13807. sum: 5,
  13808. dept: {
  13809. name: key,
  13810. },
  13811. };
  13812. UserService.fetchDataList("department", filterData).then(
  13813. function (response) {
  13814. if (response.status == 200) {
  13815. $scope.depts = response.list;
  13816. }
  13817. }
  13818. );
  13819. };
  13820. $scope.ok = function () {
  13821. if (
  13822. angular.isUndefined($scope.requester.account) ||
  13823. $scope.requester.account == null ||
  13824. $scope.requester.account == ""
  13825. ) {
  13826. SweetAlert.swal(
  13827. "报修人员编号未填!",
  13828. "请填写报修人员编号",
  13829. "error"
  13830. );
  13831. } else if (
  13832. angular.isUndefined($scope.requester.name) ||
  13833. $scope.requester.name == null ||
  13834. $scope.requester.name == ""
  13835. ) {
  13836. SweetAlert.swal(
  13837. "报修人姓名未填!",
  13838. "请填写报修人姓名",
  13839. "error"
  13840. );
  13841. } else if (
  13842. angular.isUndefined($scope.requester.requesterType) ||
  13843. $scope.requester.requesterType == null ||
  13844. $scope.requester.requesterTypeDTO == ""
  13845. ) {
  13846. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13847. } else if (
  13848. angular.isUndefined($scope.requester.phone) ||
  13849. $scope.requester.phone == null ||
  13850. $scope.requester.phone == ""
  13851. ) {
  13852. SweetAlert.swal(
  13853. "报修人联系电话未填!",
  13854. "请填写报修人联系电话",
  13855. "error"
  13856. );
  13857. } else {
  13858. $scope.requesterId = $scope.requester.id;
  13859. var data = {
  13860. incident: {
  13861. requester: {
  13862. id: $scope.requesterId,
  13863. },
  13864. },
  13865. idx: 0,
  13866. sum: 3,
  13867. };
  13868. api_statistic
  13869. .tableData(data, "incident")
  13870. .then(function (data) {
  13871. sco.$parent.$parent.$parent.model.incident.tableList =
  13872. data.list;
  13873. });
  13874. $scope.$watch(
  13875. sco.$parent.$parent.$parent.model.incident.tableList,
  13876. function (oldObj, newObj) {
  13877. if (newObj != oldObj) {
  13878. sco.$parent.$parent.$parent.model.incident.tableList =
  13879. newObj;
  13880. }
  13881. }
  13882. );
  13883. console.log($scope.requester);
  13884. $modalInstance.close($scope.requester);
  13885. }
  13886. };
  13887. $scope.cancel = function () {
  13888. $modalInstance.dismiss("cancel");
  13889. };
  13890. },
  13891. resolve: {
  13892. items: function () {
  13893. return {
  13894. fetchItems: function (filterData, APIService) {
  13895. filterData = filterData || {};
  13896. if (!filterData.idx) {
  13897. filterData = {
  13898. idx: 0,
  13899. sum: 10,
  13900. };
  13901. }
  13902. return options.templateOptions.fetchItems(
  13903. filterData,
  13904. APIService
  13905. );
  13906. },
  13907. };
  13908. },
  13909. title: function () {
  13910. return options.templateOptions.modalTitle;
  13911. },
  13912. Restangular: function () {
  13913. return options.templateOptions.Restangular;
  13914. },
  13915. APIService: function () {
  13916. return options.templateOptions.ApiService;
  13917. },
  13918. UserService: function () {
  13919. return options.templateOptions.UserService;
  13920. },
  13921. sco: function () {
  13922. return $scope;
  13923. },
  13924. },
  13925. });
  13926. modalInstance.result.then(
  13927. function (selectedItem) {
  13928. console.log(selectedItem);
  13929. if (selectedItem) {
  13930. var data = {
  13931. requester: selectedItem,
  13932. };
  13933. $scope.searchKey = selectedItem.account;
  13934. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13935. // if (selectedItem.place && selectedItem.place.place) {
  13936. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13937. // }
  13938. options.templateOptions.UserService.addData(
  13939. "requester",
  13940. data
  13941. ).then(function (response) {
  13942. if (response.status == 200) {
  13943. if (options.model) {
  13944. options.model.requester = response.data;
  13945. $scope.$parent.$parent.$parent.model.incident.requester =
  13946. response.data;
  13947. $scope.$parent.$parent.$parent.model.requestershow =
  13948. response.data;
  13949. if (options.model.place) {
  13950. options.model.place.id = "";
  13951. }
  13952. if (options.model.area) {
  13953. options.model.area.id = "";
  13954. }
  13955. options.model.contacts = selectedItem.name;
  13956. if (
  13957. selectedItem.phone &&
  13958. selectedItem.phone != null &&
  13959. selectedItem.phone != ""
  13960. ) {
  13961. options.model.contactsInformation =
  13962. selectedItem.phone;
  13963. } else {
  13964. options.model.contactsInformation =
  13965. selectedItem.telephone;
  13966. }
  13967. if (
  13968. selectedItem.requesterTypeDTO &&
  13969. selectedItem.requesterTypeDTO.id == 2
  13970. ) {
  13971. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13972. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13973. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13974. }
  13975. }
  13976. if (!response.data.id) {
  13977. response.data.id = selectedItem.id;
  13978. }
  13979. options.value(response.data);
  13980. options.value(response.data);
  13981. console.log($scope, "0000000");
  13982. //新增报修人带入区域地点2020年4月23日19:48:15
  13983. $scope.model.selecthouseNumber = selectedItem.place
  13984. ? selectedItem.place
  13985. : {};
  13986. $scope.$root.selecthouseNumber = selectedItem.place
  13987. ? selectedItem.place
  13988. : {};
  13989. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13990. if (selectedItem.place && selectedItem.place.id) {
  13991. options.model.place.id = selectedItem.place.id;
  13992. options.model.place.area.id =
  13993. selectedItem.place.area.id;
  13994. }
  13995. } else {
  13996. if (selectedItem.place && selectedItem.place.id) {
  13997. options.model.place.id = selectedItem.place.id;
  13998. options.model.area.id = selectedItem.place.area.id;
  13999. }
  14000. }
  14001. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  14002. // options.model.area.id = selectedItem.place.area.id
  14003. // }
  14004. if (selectedItem.houseNumber) {
  14005. options.model.houseNumber = selectedItem.houseNumber;
  14006. }
  14007. if (selectedItem.room) {
  14008. options.model.room.id = selectedItem.room.id;
  14009. }
  14010. // if (selectedItem.id) {
  14011. options.model.account = selectedItem.account;
  14012. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  14013. var baoxiuFields =
  14014. $scope.$parent.$parent.$parent.$parent.$parent.vm
  14015. .fields[1].fields;
  14016. var baoxiurenTo;
  14017. baoxiuFields.forEach((e, i) => {
  14018. if (e.key == "account") {
  14019. baoxiurenTo = e.templateOptions;
  14020. baoxiurenTo.APIService.fetchDataList("user", {
  14021. idx: 0,
  14022. sum: 20,
  14023. user: {
  14024. name: selectedItem.account,
  14025. selectType: "pinyin_all",
  14026. engineer: undefined,
  14027. },
  14028. }).then((res) => {
  14029. baoxiurenTo.options = res.list;
  14030. options.model.account = selectedItem.account;
  14031. });
  14032. }
  14033. });
  14034. // }
  14035. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  14036. // 选择重复事件侧滑框
  14037. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  14038. $scope.$parent.$parent.$parent.model[
  14039. "repeatIncidentShow"
  14040. ] = false;
  14041. setTimeout(() => {
  14042. $scope.$parent.$parent.$parent.model[
  14043. "repeatIncidentShow"
  14044. ] = true;
  14045. }, 500);
  14046. // }
  14047. } else {
  14048. modalInstance.SweetAlert.swal({
  14049. title: "系统错误",
  14050. text: "账号重复!",
  14051. type: "error",
  14052. });
  14053. }
  14054. });
  14055. }
  14056. },
  14057. function () { }
  14058. );
  14059. },
  14060. changeRequeter: function (
  14061. size,
  14062. options,
  14063. modal,
  14064. modeldata,
  14065. $rootScope
  14066. ) {
  14067. var modalInstance = modal.open({
  14068. templateUrl:
  14069. "assets/views/customform/tpl/modal-change-requester.html",
  14070. controller: function (
  14071. $scope,
  14072. $modalInstance,
  14073. items,
  14074. SweetAlert,
  14075. title,
  14076. Restangular,
  14077. APIService,
  14078. UserService,
  14079. api_user_data,
  14080. $rootScope
  14081. ) {
  14082. $scope.title = "修改报修人";
  14083. $scope.requester = {
  14084. id: modeldata.requester.id,
  14085. account: modeldata.requester.account,
  14086. name: modeldata.requester.name,
  14087. gender: modeldata.requester.gender,
  14088. email: modeldata.requester.email,
  14089. deptName: modeldata.requester.deptName,
  14090. phone: modeldata.requester.phone,
  14091. telephone: modeldata.requester.telephone,
  14092. studentNo: modeldata.requester.studentNo,
  14093. areaDTO: modeldata.requester.areaDTO,
  14094. placeDTO: modeldata.requester.placeDTO,
  14095. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  14096. };
  14097. $scope.onChangeadd = function (searchData) {
  14098. console.log(searchData);
  14099. $scope.searchKey = searchData.account;
  14100. var requesdata = angular.copy(searchData);
  14101. if (requesdata.phone) {
  14102. delete requesdata.phone;
  14103. }
  14104. $scope.requester = requesdata;
  14105. };
  14106. $scope.refreshUseradd = function (searchKey) {
  14107. //请求人搜索
  14108. $scope.requester.account = searchKey;
  14109. $scope.searchData = searchKey;
  14110. serchdataadd(searchKey);
  14111. };
  14112. $scope.getMydata = function (x) {
  14113. $scope.searchField = JSON.parse(x[0]).account;
  14114. $scope.requester = JSON.parse(x[0]);
  14115. };
  14116. $scope.getMydataone = function (x) {
  14117. $scope.searchField = x;
  14118. $scope.requester.account = x;
  14119. };
  14120. serchdataadd();
  14121. function serchdataadd(searchKey) {
  14122. if (searchKey) {
  14123. var filterData = {
  14124. user: {
  14125. name: searchKey,
  14126. selectType: "pinyin_all",
  14127. engineer: undefined,
  14128. },
  14129. idx: 0,
  14130. sum: 10,
  14131. };
  14132. } else {
  14133. var filterData = {
  14134. idx: 0,
  14135. sum: 10,
  14136. user:{
  14137. engineer: undefined,
  14138. }
  14139. };
  14140. }
  14141. api_user_data
  14142. .fetchDataList("user", filterData)
  14143. .then(function (response) {
  14144. var myData = response;
  14145. $scope.myData = myData.list;
  14146. });
  14147. }
  14148. api_user_data
  14149. .fetchDataList("area", {
  14150. idx: 0,
  14151. sum: 1000,
  14152. })
  14153. .then(function (response) {
  14154. if (response.status == 200) {
  14155. $scope.areas = response.list;
  14156. }
  14157. });
  14158. api_user_data
  14159. .fetchDataList("requesterType", {
  14160. idx: 0,
  14161. sum: 100,
  14162. })
  14163. .then(function (response) {
  14164. if (response.status == 200) {
  14165. $scope.networktypes = response.list;
  14166. }
  14167. });
  14168. if (
  14169. $scope.requester.areaDTO &&
  14170. $scope.requester.areaDTO.id &&
  14171. $scope.requester.areaDTO.id != ""
  14172. ) {
  14173. api_user_data
  14174. .fetchDataList("place", {
  14175. place: {
  14176. areaId: $scope.requester.areaDTO.id,
  14177. },
  14178. idx: 0,
  14179. sum: 1000,
  14180. })
  14181. .then(function (response) {
  14182. if (response.status == 200) {
  14183. $scope.places = response.list;
  14184. }
  14185. });
  14186. }
  14187. $scope.onChange = function (item) {
  14188. $scope.requester.placeDTO = {};
  14189. api_user_data
  14190. .fetchDataList("place", {
  14191. place: {
  14192. areaId: item.id,
  14193. },
  14194. idx: 0,
  14195. sum: 1000,
  14196. })
  14197. .then(function (response) {
  14198. if (response.status == 200) {
  14199. $scope.places = response.list;
  14200. }
  14201. });
  14202. };
  14203. $scope.refreshDepts = function (key) {
  14204. var filterData = {
  14205. idx: 0,
  14206. sum: 5,
  14207. dept: {
  14208. name: key,
  14209. },
  14210. };
  14211. UserService.fetchDataList("department", filterData).then(
  14212. function (response) {
  14213. if (response.status == 200) {
  14214. $scope.depts = response.list;
  14215. }
  14216. }
  14217. );
  14218. };
  14219. $scope.ok = function () {
  14220. if (
  14221. $scope.requester.account == "" ||
  14222. $scope.requester.name == ""
  14223. ) {
  14224. SweetAlert.swal(
  14225. "报修人姓名或人员编号号未填!",
  14226. "请补全报修人信息",
  14227. "error"
  14228. );
  14229. } else {
  14230. $modalInstance.close($scope.requester);
  14231. }
  14232. };
  14233. $scope.cancel = function () {
  14234. $modalInstance.dismiss("cancel");
  14235. };
  14236. },
  14237. resolve: {
  14238. items: function () {
  14239. return {
  14240. fetchItems: function (filterData, APIService) {
  14241. filterData = filterData || {};
  14242. if (!filterData.idx) {
  14243. filterData = {
  14244. idx: 0,
  14245. sum: 10,
  14246. };
  14247. }
  14248. return options.templateOptions.fetchItems(
  14249. filterData,
  14250. APIService
  14251. );
  14252. },
  14253. };
  14254. },
  14255. title: function () {
  14256. return options.templateOptions.modalTitle;
  14257. },
  14258. Restangular: function () {
  14259. return options.templateOptions.Restangular;
  14260. },
  14261. APIService: function () {
  14262. return options.templateOptions.ApiService;
  14263. },
  14264. UserService: function () {
  14265. return options.templateOptions.UserService;
  14266. },
  14267. },
  14268. });
  14269. modalInstance.result.then(
  14270. function (selectedItem) {
  14271. console.log(selectedItem);
  14272. if (selectedItem) {
  14273. if (options.model) {
  14274. if (options.model.place) {
  14275. options.model.place.id = "";
  14276. }
  14277. if (options.model.area) {
  14278. options.model.area.id = "";
  14279. }
  14280. options.model.contacts = selectedItem.name;
  14281. if (
  14282. selectedItem.phone &&
  14283. selectedItem.phone != null &&
  14284. selectedItem.phone != ""
  14285. ) {
  14286. options.model.contactsInformation = selectedItem.phone;
  14287. } else {
  14288. options.model.contactsInformation =
  14289. selectedItem.telephone;
  14290. }
  14291. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14292. options.model.place.id = selectedItem.placeDTO.id;
  14293. }
  14294. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14295. options.model.area.id = selectedItem.areaDTO.id;
  14296. }
  14297. if (
  14298. selectedItem.requesterTypeDTO &&
  14299. selectedItem.requesterTypeDTO.id == 2
  14300. ) {
  14301. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14302. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14303. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14304. }
  14305. }
  14306. var data = {
  14307. requester: selectedItem,
  14308. };
  14309. options.templateOptions.UserService.addData(
  14310. "requester",
  14311. data
  14312. ).then(function (response) {
  14313. if (response.status == 200) {
  14314. $scope.$parent.$parent.$parent.model["requestershow"] =
  14315. selectedItem;
  14316. options.value(response.data);
  14317. } else {
  14318. }
  14319. });
  14320. }
  14321. },
  14322. function () { }
  14323. );
  14324. event.preventDefault();
  14325. },
  14326. },
  14327. };
  14328. },
  14329. controller: [
  14330. "$scope",
  14331. "api_user_data",
  14332. "api_statistic",
  14333. "$stateParams",
  14334. "api_bpm_data",
  14335. function ($scope, api_user_data, api_statistic, $stateParams,api_bpm_data) {
  14336. console.log($stateParams)
  14337. // 一键复制
  14338. $scope.quickCopy = function(model){
  14339. // 姓名,工号,来电电话,地点,详细地址,故障描述 liaomingming
  14340. console.log(model);
  14341. var text = '';
  14342. if(model.place.id){
  14343. api_bpm_data.fetchData("place", model.place.id)
  14344. .then(function (response) {
  14345. if (response.status == 200) {
  14346. text = `姓名:${model.requester?model.requester.name:''}\r\n工号:${model.requester?model.requester.account:''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${response.data.place||''}\r\n详细地址:${model.houseNumber||''}\r\n故障描述:${model.description||''}`;
  14347. var textarea = document.createElement('textarea');
  14348. document.body.appendChild(textarea);
  14349. // 隐藏此输入框
  14350. textarea.style.position = 'fixed';
  14351. textarea.style.clip = 'rect(0 0 0 0)';
  14352. textarea.style.top = '10px';
  14353. // 赋值
  14354. textarea.value = text;
  14355. // 选中
  14356. textarea.select();
  14357. // 复制
  14358. document.execCommand('copy', true);
  14359. // 移除输入框
  14360. document.body.removeChild(textarea);
  14361. }
  14362. });
  14363. }else{
  14364. text = `姓名:${model.contacts||''}\r\n工号:${model.account||''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${''}\r\n详细地址:${model.houseNumber||''}\r\n故障描述:${model.description||''}`;
  14365. var textarea = document.createElement('textarea');
  14366. document.body.appendChild(textarea);
  14367. // 隐藏此输入框
  14368. textarea.style.position = 'fixed';
  14369. textarea.style.clip = 'rect(0 0 0 0)';
  14370. textarea.style.top = '10px';
  14371. // 赋值
  14372. textarea.value = text;
  14373. // 选中
  14374. textarea.select();
  14375. // 复制
  14376. document.execCommand('copy', true);
  14377. // 移除输入框
  14378. document.body.removeChild(textarea);
  14379. }
  14380. event.preventDefault();
  14381. //提示
  14382. alert('复制成功');
  14383. }
  14384. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14385. var paramsModel = JSON.parse($stateParams.model)
  14386. //来电-添加报修人
  14387. if (paramsModel.model.incident.requester.hjzxPhone) {
  14388. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14389. }
  14390. }
  14391. $scope.options.initialValue = $scope.model[$scope.options.key];
  14392. $scope.saveReqPlace = false;
  14393. $scope.model.saveReqPlace = false;
  14394. $scope.selectGradeBox = function () {
  14395. $scope.saveReqPlace = !$scope.saveReqPlace;
  14396. console.log($scope);
  14397. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14398. };
  14399. if (
  14400. $scope.model.requester &&
  14401. $scope.model.requester.requesterTypeDTO &&
  14402. $scope.model.requester.requesterTypeDTO.id == 2
  14403. ) {
  14404. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14405. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14406. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14407. }
  14408. },
  14409. ],
  14410. });
  14411. // 请求人选控件
  14412. formlyConfigProvider.setType({
  14413. name: "ui-requesterselect",
  14414. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14415. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14416. defaultOptions: function (options, $scope) {
  14417. return {
  14418. templateOptions: {
  14419. // checkform: function(options) {
  14420. // if (options.model.requestershow) {
  14421. // options.value(options.model.requestershow);
  14422. // }
  14423. // },
  14424. validators: {
  14425. required: {
  14426. expression: function (viewValue, modelValue) {
  14427. var value = modelValue || viewValue;
  14428. return value.length >= 1;
  14429. },
  14430. },
  14431. },
  14432. openModal: function (size, options, modal) {
  14433. //查找弹出框
  14434. var modelObject = options.value();
  14435. var searchModal = function (filterSearchData) {
  14436. var modalInstance = modal.open({
  14437. templateUrl:
  14438. "assets/views/customform/tpl/checktable-modal-content.html",
  14439. controller: function (
  14440. $scope,
  14441. scope,
  14442. i18nService,
  14443. $modalInstance,
  14444. items,
  14445. title,
  14446. Restangular,
  14447. APIService,
  14448. language,
  14449. searchDatas,
  14450. api_bpm_data
  14451. ) {
  14452. $scope.langs = i18nService.getAllLangs();
  14453. $scope.lang = "zh-cn";
  14454. i18nService.setCurrentLang($scope.lang);
  14455. $scope.gridOptions = {};
  14456. $scope.gridOptions.data = "myData";
  14457. $scope.gridOptions.enableColumnResizing = true;
  14458. $scope.gridOptions.enableFiltering = true;
  14459. $scope.gridOptions.enableGridMenu = false;
  14460. $scope.gridOptions.enableRowSelection = true;
  14461. $scope.gridOptions.showGridFooter = true;
  14462. $scope.gridOptions.showColumnFooter = false;
  14463. $scope.gridOptions.fastWatch = true;
  14464. $scope.gridOptions.useExternalFiltering = true;
  14465. $scope.gridOptions.useExternalPagination = true;
  14466. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14467. $scope.gridOptions.paginationPageSize = 10;
  14468. $scope.gridOptions.multiSelect = false;
  14469. $scope.gridOptions.rowIdentity = function (row) {
  14470. return row.id;
  14471. };
  14472. $scope.gridOptions.getRowIdentity = function (row) {
  14473. return row.id;
  14474. };
  14475. $scope.gridOptions.columnDefs = [
  14476. {
  14477. name: "account",
  14478. displayName: "人员编号",
  14479. width: 140,
  14480. },
  14481. {
  14482. name: "name",
  14483. displayName: "姓名",
  14484. width: 100,
  14485. },
  14486. {
  14487. name: "gender.name",
  14488. displayName: "性别",
  14489. width: 80,
  14490. enableFiltering: false,
  14491. },
  14492. {
  14493. name: "phone",
  14494. displayName: "电话",
  14495. width: 100,
  14496. enableFiltering: false,
  14497. },
  14498. {
  14499. name: "email",
  14500. displayName: "邮件",
  14501. width: 100,
  14502. },
  14503. {
  14504. name: "areaDTO.area",
  14505. displayName: "区域",
  14506. width: 100,
  14507. enableFiltering: false,
  14508. },
  14509. {
  14510. name: "placeDTO.place",
  14511. displayName: "地点",
  14512. enableFiltering: false,
  14513. },
  14514. ];
  14515. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14516. $scope.gridApi = gridApi;
  14517. // var filtersData = $scope.memoryfilterData;
  14518. // filtersData.idx = newPage - 1;
  14519. // filtersData.sum = pageSize;
  14520. gridApi.pagination.on.paginationChanged(
  14521. $scope,
  14522. function (newPage, pageSize) {
  14523. var filtersData = $scope.memoryfilterData;
  14524. filtersData.idx = newPage - 1;
  14525. filtersData.sum = pageSize;
  14526. $scope.loadData(filtersData);
  14527. }
  14528. );
  14529. gridApi.selection.on.rowSelectionChanged(
  14530. $scope,
  14531. function (data) {
  14532. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14533. $scope.selected.item = data.entity;
  14534. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14535. }
  14536. );
  14537. gridApi.core.on.filterChanged($scope, function () {
  14538. var grid = this.grid;
  14539. var filtersData = {
  14540. idx: 0,
  14541. sum: 10,
  14542. // 'requester': { 'userType': 1 }
  14543. };
  14544. angular.forEach(grid.columns, function (item) {
  14545. if (item.enableFiltering) {
  14546. if (
  14547. angular.isDefined(item.filters[0].term) &&
  14548. item.filters[0].term != ""
  14549. ) {
  14550. if (angular.isUndefined(filtersData["requester"])) {
  14551. filtersData["requester"] = {};
  14552. }
  14553. filtersData["requester"][item.field] =
  14554. item.filters[0].term;
  14555. }
  14556. }
  14557. });
  14558. $scope.memoryfilterData = filtersData;
  14559. $scope.loadData(filtersData);
  14560. });
  14561. };
  14562. $scope.memoryfilterData = defaultFilterData = {
  14563. idx: 0,
  14564. sum: 10,
  14565. };
  14566. $scope.loadData = function (filterData) {
  14567. if (!filterData.requester) {
  14568. filterData.requester = {};
  14569. }
  14570. if (scope.roleidcode) {
  14571. angular.extend(filterData["requester"], {
  14572. userType: 1,
  14573. });
  14574. }
  14575. items
  14576. .fetchItems(filterData, APIService)
  14577. .then(function (data) {
  14578. var myData = Restangular.stripRestangular(data);
  14579. $scope.gridOptions.totalItems = myData.totalNum;
  14580. $scope.myData = myData.list;
  14581. });
  14582. };
  14583. // $scope.title = title;
  14584. if (searchDatas) {
  14585. $scope.loadData(searchDatas);
  14586. } else {
  14587. $scope.loadData({
  14588. idx: 0,
  14589. sum: 10,
  14590. });
  14591. }
  14592. $scope.selected = {
  14593. item: {},
  14594. };
  14595. $scope.ok = function () {
  14596. $modalInstance.close($scope.selected.item);
  14597. };
  14598. $scope.cancel = function () {
  14599. $modalInstance.dismiss("cancel");
  14600. };
  14601. },
  14602. size: size,
  14603. resolve: {
  14604. items: function () {
  14605. return {
  14606. fetchItems: function (filterData, APIService) {
  14607. filterData = filterData || {};
  14608. if (
  14609. angular.isUndefined(filterData.idx) ||
  14610. filterData.idx == null
  14611. ) {
  14612. filterData = {
  14613. idx: 0,
  14614. sum: 10,
  14615. };
  14616. }
  14617. return options.templateOptions.fetchItems(
  14618. filterData,
  14619. APIService
  14620. );
  14621. },
  14622. };
  14623. },
  14624. title: function () {
  14625. return options.templateOptions.modalTitle;
  14626. },
  14627. Restangular: function () {
  14628. return options.templateOptions.Restangular;
  14629. },
  14630. APIService: function () {
  14631. return options.templateOptions.ApiService;
  14632. },
  14633. language: function () {
  14634. return options.templateOptions.language;
  14635. },
  14636. searchDatas: function () {
  14637. return filterSearchData;
  14638. },
  14639. scope: function () {
  14640. return $scope;
  14641. },
  14642. },
  14643. });
  14644. modalInstance.result.then(
  14645. function (selectedItem) {
  14646. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14647. selectedItem.telephone =
  14648. $scope.model.incident.contactsInformation;
  14649. }
  14650. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14651. selectedItem;
  14652. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14653. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14654. if ($scope.model) {
  14655. if ($scope.model.incident.place) {
  14656. $scope.model.incident.place.id = "";
  14657. }
  14658. if ($scope.model.area) {
  14659. $scope.model.incident.area.id = "";
  14660. }
  14661. $scope.model.incident.contacts = selectedItem.name;
  14662. if (
  14663. selectedItem.phone &&
  14664. selectedItem.phone != null &&
  14665. selectedItem.phone != ""
  14666. ) {
  14667. $scope.model.incident.contactsInformation =
  14668. selectedItem.phone;
  14669. } else {
  14670. $scope.model.incident.contactsInformation =
  14671. selectedItem.telephone;
  14672. }
  14673. $scope.model.incident.houseNumber = "";
  14674. if (
  14675. selectedItem.requesterTypeDTO &&
  14676. selectedItem.requesterTypeDTO.id == 2
  14677. ) {
  14678. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14679. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14680. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14681. }
  14682. }
  14683. $scope.options.value(selectedItem);
  14684. $scope.searchData = selectedItem.account;
  14685. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14686. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14687. }
  14688. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14689. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14690. }
  14691. if (selectedItem.houseNumber) {
  14692. $scope.model.incident.houseNumber =
  14693. selectedItem.houseNumber;
  14694. }
  14695. if (
  14696. selectedItem.requesterTypeDTO &&
  14697. selectedItem.requesterTypeDTO.id == 2
  14698. ) {
  14699. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14700. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14701. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14702. }
  14703. if (
  14704. options.templateOptions.callback &&
  14705. angular.isFunction(options.templateOptions.callback)
  14706. ) {
  14707. options.templateOptions.callback(selectedItem, options);
  14708. }
  14709. if (!$scope.roleidcode) {
  14710. $scope.charging(selectedItem, modal);
  14711. }
  14712. $scope.recentlyincident(selectedItem);
  14713. },
  14714. function () {
  14715. //console.log('Modal dismissed at: ' + new Date());
  14716. }
  14717. );
  14718. };
  14719. searchModal();
  14720. // }
  14721. },
  14722. },
  14723. };
  14724. },
  14725. controller: [
  14726. "$rootScope",
  14727. "$scope",
  14728. "ngTableParams",
  14729. "$filter",
  14730. "SweetAlert",
  14731. "moment",
  14732. function (
  14733. $rootScope,
  14734. $scope,
  14735. ngTableParams,
  14736. $filter,
  14737. SweetAlert,
  14738. moment
  14739. ) {
  14740. $scope.isHk = $rootScope.isHk;
  14741. $scope.roleidcode = true;
  14742. // $scope.options.initialValue = undefined;
  14743. if ($rootScope.user && $rootScope.user.role) {
  14744. angular.forEach($rootScope.user.role, function (item) {
  14745. if (item.rolecode == "call center") {
  14746. $scope.roleidcode = false;
  14747. }
  14748. });
  14749. }
  14750. $scope.recently = false;
  14751. $scope.recentlyincident = function (key, model) {
  14752. //关联事件
  14753. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14754. idx: 0,
  14755. sum: 4,
  14756. incident: {
  14757. requester: {
  14758. id: key.id,
  14759. },
  14760. },
  14761. }).then(function (response) {
  14762. if (response.status == 200) {
  14763. $scope.recently = true;
  14764. $scope.recentincident = response.list;
  14765. } else {
  14766. $scope.recently = false;
  14767. }
  14768. });
  14769. $scope.bodyHeight = window.innerHeight - 100;
  14770. $(window).resize(function () {
  14771. $scope.bodyHeight = window.innerHeight - 100;
  14772. });
  14773. // $scope.shows = false;
  14774. $scope.tempData = {};
  14775. $scope.close = function () {
  14776. $scope.changes = !$scope.changes;
  14777. event.preventDefault();
  14778. };
  14779. };
  14780. $scope.charging = function (key, model) {
  14781. //计费弹出框
  14782. //用户信息
  14783. $scope.information = {};
  14784. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14785. userId: key.account,
  14786. }).then(function (response) {
  14787. // if (response.status == 200) {
  14788. if (response && response.data) {
  14789. angular.extend($scope.information, response.data[0]);
  14790. // $scope.information = response.data[0];
  14791. $scope.information.autologicDestroyTime = moment(
  14792. response.data[0].autologicDestroyTime
  14793. ).format("YYYY-MM-DD");
  14794. $scope.information.periodStartTime = moment(
  14795. response.data[0].periodStartTime
  14796. ).format("YYYY-MM-DD");
  14797. $scope.information.nextBillingTime = moment(
  14798. response.data[0].nextBillingTime
  14799. ).format("YYYY-MM-DD");
  14800. } else if (response.err) {
  14801. SweetAlert.swal(
  14802. "系统错误!",
  14803. "用户信息未取到,请刷新重试",
  14804. "error"
  14805. );
  14806. }
  14807. // }
  14808. });
  14809. //上网明细
  14810. $scope.options.templateOptions.ApiSer.fetchDataList(
  14811. "queryOnlineDetail",
  14812. {
  14813. userId: key.account,
  14814. limit: "10",
  14815. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14816. "YYYY-MM-DD HH:mm:ss"
  14817. ),
  14818. toLogoutTime: moment(new Date().getTime()).format(
  14819. "YYYY-MM-DD HH:mm:ss"
  14820. ),
  14821. }
  14822. ).then(function (response) {
  14823. // if (response.status == 200) {
  14824. if (response && response.data) {
  14825. angular.forEach(response.data, function (item, index) {
  14826. if (item.logoutTime) {
  14827. response.data[index].logoutTime = moment(
  14828. item.logoutTime
  14829. ).format("YYYY-MM-DD HH:mm:ss");
  14830. }
  14831. if (item.loginTime) {
  14832. response.data[index].loginTime = moment(
  14833. item.loginTime
  14834. ).format("YYYY-MM-DD HH:mm:ss");
  14835. }
  14836. });
  14837. $scope.logininform = response.data;
  14838. } else if (response.err) {
  14839. SweetAlert.swal(
  14840. "系统错误!",
  14841. "上网明细未取到,请刷新重试",
  14842. "error"
  14843. );
  14844. }
  14845. });
  14846. //黑名单
  14847. // $scope.information.blacklist = "否"
  14848. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14849. userId: key.account,
  14850. }).then(function (response) {
  14851. // if (response.status == 200) {
  14852. // $scope.logininformation = response.data;
  14853. if (response) {
  14854. if (response.data || response.data != null) {
  14855. $scope.information.blacklist = "是";
  14856. } else {
  14857. if (response.err) {
  14858. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14859. } else {
  14860. $scope.information.blacklist = "否";
  14861. }
  14862. }
  14863. }
  14864. // }
  14865. });
  14866. $scope.bodyHeight = window.innerHeight - 100;
  14867. $(window).resize(function () {
  14868. $scope.bodyHeight = window.innerHeight - 100;
  14869. });
  14870. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14871. // $scope.closepages = function(e) {
  14872. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14873. // event.preventDefault();
  14874. // };
  14875. // $scope.shows = false;
  14876. $scope.tempData = {};
  14877. $scope.close = function () {
  14878. $scope.changes = !$scope.changes;
  14879. event.preventDefault();
  14880. };
  14881. };
  14882. $scope.options.templateOptions.ApiService.fetchDataList(
  14883. "requesterType",
  14884. {
  14885. idx: 0,
  14886. sum: 100,
  14887. }
  14888. ).then(function (response) {
  14889. if (response.status == 200) {
  14890. $scope.networktypes = response.list;
  14891. } else {
  14892. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14893. }
  14894. });
  14895. function serchdata(searchKey) {
  14896. if (searchKey) {
  14897. var filterData = {
  14898. requester: {
  14899. searchKey: searchKey,
  14900. // 'userType': 1
  14901. },
  14902. idx: 0,
  14903. sum: 10,
  14904. };
  14905. } else {
  14906. var filterData = {
  14907. idx: 0,
  14908. requester: {},
  14909. sum: 10,
  14910. };
  14911. }
  14912. if (
  14913. $scope.model.requester &&
  14914. $scope.model.requester.requesterTypeDTO
  14915. ) {
  14916. angular.extend(filterData.requester, {
  14917. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14918. });
  14919. if (!$scope.options.model.contactsInformation) {
  14920. $scope.options.model.contactsInformation =
  14921. $scope.model.requester.phone;
  14922. }
  14923. }
  14924. if ($scope.roleidcode) {
  14925. angular.extend(filterData["requester"], {
  14926. userType: 1,
  14927. });
  14928. }
  14929. $scope.options.templateOptions.ApiService.fetchDataList(
  14930. "requester",
  14931. filterData
  14932. ).then(function (response) {
  14933. var myData = response;
  14934. $scope.myData = myData.list;
  14935. });
  14936. }
  14937. $scope.searchData = {};
  14938. $scope.refreshUser = function (searchKey) {
  14939. //请求人搜索
  14940. if (searchKey && searchKey != "") {
  14941. serchdata(searchKey);
  14942. }
  14943. };
  14944. if (
  14945. $scope.$parent.$parent.$parent.model.incident.callID ||
  14946. $scope.$parent.$parent.$parent.model.requestershow
  14947. ) {
  14948. if (!$scope.roleidcode) {
  14949. $scope.charging(
  14950. $scope.$parent.$parent.$parent.model.incident.requester
  14951. );
  14952. }
  14953. $scope.recentlyincident(
  14954. $scope.$parent.$parent.$parent.model.incident.requester
  14955. );
  14956. }
  14957. $scope.onChange = function (searchData) {
  14958. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14959. searchData.telephone = $scope.model.incident.contactsInformation;
  14960. }
  14961. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14962. searchData;
  14963. if (!$scope.roleidcode) {
  14964. $scope.charging(searchData);
  14965. }
  14966. $scope.recentlyincident(searchData);
  14967. $scope.accountshow = false;
  14968. if ($scope.model.incident) {
  14969. if ($scope.model.incident.place) {
  14970. $scope.model.incident.place.id = "";
  14971. }
  14972. if ($scope.model.incident.area) {
  14973. $scope.model.incident.area.id = "";
  14974. }
  14975. $scope.model.incident.contacts = searchData.name;
  14976. if (
  14977. searchData.phone &&
  14978. searchData.phone != null &&
  14979. searchData.phone != ""
  14980. ) {
  14981. $scope.model.incident.contactsInformation = searchData.phone;
  14982. } else {
  14983. $scope.model.incident.contactsInformation = searchData.telephone;
  14984. }
  14985. $scope.model.incident.houseNumber = "";
  14986. if (
  14987. searchData.requesterTypeDTO &&
  14988. searchData.requesterTypeDTO.id == 2
  14989. ) {
  14990. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14991. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14992. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14993. }
  14994. }
  14995. $scope.options.value(searchData);
  14996. $scope.searchKey = searchData.account;
  14997. if (searchData.placeDTO && searchData.placeDTO.id) {
  14998. $scope.model.incident.place.id = searchData.placeDTO.id;
  14999. }
  15000. if (searchData.areaDTO && searchData.areaDTO.id) {
  15001. $scope.model.incident.area.id = searchData.areaDTO.id;
  15002. }
  15003. if (searchData.houseNumber) {
  15004. $scope.model.incident.houseNumber = searchData.houseNumber;
  15005. }
  15006. if (
  15007. searchData.requesterTypeDTO &&
  15008. searchData.requesterTypeDTO.id == 2
  15009. ) {
  15010. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  15011. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  15012. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  15013. }
  15014. };
  15015. },
  15016. ],
  15017. });
  15018. //ui-grid-table展示控件
  15019. formlyConfigProvider.setType({
  15020. name: "ui-grid-table",
  15021. // extends: 'multiCheckbox',//去掉冒号
  15022. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  15023. defaultOptions: function (options) {
  15024. return {
  15025. templateOptions: {
  15026. linkage: function () { },
  15027. },
  15028. };
  15029. },
  15030. controller: function (
  15031. $scope,
  15032. $rootScope,
  15033. i18nService,
  15034. Restangular,
  15035. api_bpm_data,
  15036. api_statistic,
  15037. $rootScope
  15038. ) {
  15039. var loginUser = $rootScope.user;
  15040. $scope.langs = i18nService.getAllLangs();
  15041. $scope.lang = "zh-cn";
  15042. i18nService.setCurrentLang($scope.lang);
  15043. $scope.gridOptions = {};
  15044. $scope.gridOptions.data = "myData";
  15045. $scope.gridOptions.enableColumnResizing = true;
  15046. $scope.gridOptions.enableGridMenu = false;
  15047. $scope.gridOptions.enableRowSelection = true;
  15048. $scope.gridOptions.showGridFooter = false;
  15049. $scope.gridOptions.showColumnFooter = false;
  15050. $scope.gridOptions.fastWatch = true;
  15051. $scope.gridOptions.useExternalFiltering = true;
  15052. $scope.gridOptions.useExternalPagination = false;
  15053. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15054. $scope.gridOptions.paginationPageSize = 3;
  15055. $scope.gridOptions.multiSelect = false;
  15056. $scope.gridOptions.rowIdentity = function (row) {
  15057. return row.id;
  15058. };
  15059. $scope.gridOptions.getRowIdentity = function (row) {
  15060. return row.id;
  15061. };
  15062. $scope.gridOptions.columnDefs = [
  15063. {
  15064. name: "item",
  15065. displayName: "序号",
  15066. width: 80,
  15067. enableFiltering: false,
  15068. },
  15069. {
  15070. name: "incidentsign",
  15071. displayName: "单号",
  15072. width: 80,
  15073. enableFiltering: false,
  15074. },
  15075. {
  15076. name: "description",
  15077. displayName: "主题",
  15078. width: 80,
  15079. enableFiltering: false,
  15080. },
  15081. {
  15082. name: "state.name",
  15083. displayName: "状态",
  15084. width: 110,
  15085. enableFiltering: false,
  15086. },
  15087. {
  15088. name: "acceptDate",
  15089. displayName: "创建时间",
  15090. width: 160,
  15091. enableFiltering: false,
  15092. },
  15093. {
  15094. name: "requester.name",
  15095. displayName: "请求人",
  15096. width: 80,
  15097. enableFiltering: false,
  15098. },
  15099. {
  15100. name: "handlingPersonnelUser.name",
  15101. displayName: "处理人",
  15102. width: 160,
  15103. enableFiltering: false,
  15104. },
  15105. {
  15106. name: "place.place",
  15107. displayName: "区域地点",
  15108. width: 160,
  15109. enableFiltering: false,
  15110. },
  15111. ];
  15112. // var defaultFilterData = {
  15113. // "idx": 0,
  15114. // "sum": 3
  15115. // };
  15116. // // //分页控制
  15117. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15118. gridApi.pagination.on.paginationChanged(
  15119. $scope,
  15120. function (newPage, pageSize) {
  15121. var filtersData = $scope.memoryfilterData;
  15122. filtersData.idx = newPage - 1;
  15123. filtersData.sum = pageSize;
  15124. $scope.refreshData("expand-right", filtersData);
  15125. }
  15126. );
  15127. // 表格单选事件
  15128. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  15129. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  15130. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  15131. data.entity;
  15132. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  15133. data.entity.id;
  15134. var str =
  15135. data.grid.appScope.$parent.$parent.$parent.model.incident
  15136. .description || "";
  15137. str = str.split("").reverse().join("");
  15138. var del = addstr.split("").reverse().join("");
  15139. // console.log(del);
  15140. var reg = new RegExp(del);
  15141. str = str.replace(reg, "");
  15142. str = str.split("").reverse().join("");
  15143. if (
  15144. data.grid.appScope.$parent.$parent.$parent.model.incident
  15145. .associationType == "事件补充"
  15146. ) {
  15147. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  15148. null;
  15149. str += data.entity.description;
  15150. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15151. data.entity.description;
  15152. } else if (
  15153. data.grid.appScope.$parent.$parent.$parent.model.incident
  15154. .associationType == "事件已解决"
  15155. ) {
  15156. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  15157. "close";
  15158. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15159. "";
  15160. }
  15161. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  15162. str;
  15163. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  15164. data.entity.id;
  15165. });
  15166. };
  15167. // 刷新表格
  15168. setInterval(function () {
  15169. // console.log($scope.myData);
  15170. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  15171. // console.log($scope.myData);
  15172. if ($scope.myData != null) {
  15173. for (var i = 0; i < $scope.myData.length; i++) {
  15174. //添加序号
  15175. $scope.myData[i]["item"] = i + 1;
  15176. }
  15177. }
  15178. }, 1000);
  15179. },
  15180. });
  15181. //处理人信息
  15182. formlyConfigProvider.setType({
  15183. name: "ui-userinformation",
  15184. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  15185. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15186. defaultOptions: function (options) {
  15187. return {
  15188. templateOptions: {},
  15189. };
  15190. },
  15191. controller: [
  15192. "$scope",
  15193. function ($scope) {
  15194. $scope.group = "";
  15195. $scope.role = "";
  15196. if (
  15197. angular.isDefined($scope.model.handlingPersonnelUser) &&
  15198. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15199. $scope.model.handlingPersonnelUser.group.length == 1
  15200. ) {
  15201. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15202. } else {
  15203. for (
  15204. var i = 0;
  15205. i < $scope.model.handlingPersonnelUser.group.length;
  15206. i++
  15207. ) {
  15208. $scope.group +=
  15209. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15210. }
  15211. }
  15212. if (
  15213. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  15214. $scope.model.handlingPersonnelUser.role.length == 1
  15215. ) {
  15216. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  15217. } else {
  15218. for (
  15219. var i = 0;
  15220. i < $scope.model.handlingPersonnelUser.role.length;
  15221. i++
  15222. ) {
  15223. $scope.role +=
  15224. $scope.model.handlingPersonnelUser.role[i].role + ",";
  15225. }
  15226. }
  15227. $scope.options.templateOptions.that = $scope;
  15228. },
  15229. ],
  15230. });
  15231. //处理界面处理人信息
  15232. formlyConfigProvider.setType({
  15233. name: "ui-handler",
  15234. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  15235. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15236. defaultOptions: function (options) {
  15237. return {
  15238. templateOptions: {},
  15239. };
  15240. },
  15241. controller: [
  15242. "$scope",
  15243. function ($scope) {
  15244. $scope.group = "";
  15245. // $scope.role="";
  15246. if (
  15247. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15248. $scope.model.handlingPersonnelUser.group.length == 1
  15249. ) {
  15250. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15251. } else {
  15252. for (
  15253. var i = 0;
  15254. i < $scope.model.handlingPersonnelUser.group.length;
  15255. i++
  15256. ) {
  15257. $scope.group +=
  15258. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15259. }
  15260. }
  15261. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  15262. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  15263. // }else{
  15264. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  15265. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  15266. // }
  15267. // }
  15268. $scope.options.templateOptions.that = $scope;
  15269. },
  15270. ],
  15271. });
  15272. //微信事件流程
  15273. formlyConfigProvider.setType({
  15274. name: "ui-wxIncidentProcess",
  15275. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  15276. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15277. defaultOptions: function (options) {
  15278. return {
  15279. templateOptions: {},
  15280. };
  15281. },
  15282. controller: [
  15283. "$scope",
  15284. function ($scope) {
  15285. console.log($scope.model);
  15286. $scope.pingjia = false;
  15287. $scope.jiejue = false;
  15288. if ($scope.model.incidentState.value == "3") {
  15289. $scope.pingjia = true;
  15290. } else if ($scope.model.incidentState.value == "4") {
  15291. $scope.jiejue = true;
  15292. }
  15293. },
  15294. ],
  15295. });
  15296. //打电话
  15297. formlyConfigProvider.setType({
  15298. name: "ui-inputcall",
  15299. extends: "input",
  15300. templateUrl: "assets/views/customform/tpl/inputcall.html",
  15301. defaultOptions: function (options) {
  15302. return {
  15303. templateOptions: {
  15304. transform: function (value) { },
  15305. },
  15306. };
  15307. },
  15308. controller: [
  15309. "$scope",
  15310. "$rootScope",
  15311. "api_text",
  15312. "SweetAlert",
  15313. function ($scope, $rootScope, api_text, SweetAlert) {
  15314. $scope.dialout = function (teleno) {
  15315. // var gid = "@0";
  15316. // var telephone = "9" + teleno;
  15317. $rootScope.callout = 2;
  15318. // var agcount = tlwsa.tlaGetagentcount();
  15319. // var agcountFlag = false;
  15320. // console.log(teleno)
  15321. // // 查询当前话机是否签入
  15322. // for (var i = 0; i < agcount; i++) {
  15323. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15324. // agcountFlag = true;
  15325. // }
  15326. // }
  15327. if (localStorage.getItem('fenjiNumber')) {
  15328. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15329. // console.log(sessionStorage.getItem('phones'))
  15330. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15331. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15332. // console.log(isHuajihao)
  15333. // if(isHuajihao){
  15334. // tlwsa.tlaCallagc(teleno);
  15335. // }else{
  15336. // tlwsa.tlaCallout(teleno, caller, 0);
  15337. // }
  15338. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15339. $rootScope.toggle('off-sidebar');
  15340. // tlwsa.tlaCallout(teleno, caller, 0);
  15341. }else if(localStorage.getItem('hk_phone')){
  15342. var gid = "@0"
  15343. var telephone = '9' + teleno
  15344. $rootScope.callout = 2;
  15345. if ($rootScope.takes) {
  15346. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  15347. if (data.errno == 0) {
  15348. $rootScope.status = 6;
  15349. }
  15350. })
  15351. } else {
  15352. SweetAlert.swal({
  15353. title: "呼叫失败",
  15354. text: "请先签入呼叫中心!",
  15355. type: "error",
  15356. confirmButtonColor: "#DD6B55"
  15357. });
  15358. }
  15359. } else {
  15360. SweetAlert.swal({
  15361. title: "呼叫失败",
  15362. text: "请先签入呼叫中心!",
  15363. type: "error",
  15364. confirmButtonColor: "#DD6B55",
  15365. });
  15366. }
  15367. };
  15368. $scope.options.templateOptions.that = $scope;
  15369. },
  15370. ],
  15371. });
  15372. //关闭界面处理人信息
  15373. formlyConfigProvider.setType({
  15374. name: "ui-closehandler",
  15375. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15376. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15377. defaultOptions: function (options) {
  15378. return {
  15379. templateOptions: {},
  15380. };
  15381. },
  15382. controller: [
  15383. "$scope",
  15384. "$rootScope",
  15385. "api_text",
  15386. function ($scope, $rootScope, api_text) {
  15387. $scope.dialout = function (teleno) {
  15388. var gid = "@0";
  15389. var telephone = "9" + teleno;
  15390. api_text
  15391. .dialout($rootScope.takes, gid, telephone)
  15392. .then(function (data) {
  15393. if (data.errno == 0) {
  15394. $rootScope.status = 6;
  15395. }
  15396. });
  15397. };
  15398. $scope.options.templateOptions.that = $scope;
  15399. },
  15400. ],
  15401. });
  15402. //用户单选控件
  15403. formlyConfigProvider.setType({
  15404. name: "ui-userselect",
  15405. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15406. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15407. defaultOptions: function (options) {
  15408. return {
  15409. templateOptions: {
  15410. openModal: function (size, options, modal) {
  15411. var modalInstance = modal.open({
  15412. templateUrl:
  15413. "assets/views/customform/tpl/checktable-modal-content.html",
  15414. controller: function (
  15415. $scope,
  15416. $rootScope,
  15417. i18nService,
  15418. $modalInstance,
  15419. items,
  15420. title,
  15421. Restangular,
  15422. APIService,
  15423. onDataCallback,
  15424. parentScope,
  15425. api_category,
  15426. api_user_data
  15427. ) {
  15428. $scope.isAssign = options.templateOptions.departmentDispatchesOrders;
  15429. $scope.langs = i18nService.getAllLangs();
  15430. $scope.lang = "zh-cn";
  15431. i18nService.setCurrentLang($scope.lang);
  15432. $scope.gridOptions = {};
  15433. $scope.gridOptions.data = "myData";
  15434. $scope.gridOptions.enableColumnResizing = true;
  15435. $scope.gridOptions.enableFiltering = true;
  15436. $scope.gridOptions.enableGridMenu = false;
  15437. $scope.gridOptions.showGridFooter = true;
  15438. $scope.gridOptions.showColumnFooter = false;
  15439. $scope.gridOptions.fastWatch = true;
  15440. $scope.gridOptions.useExternalFiltering = true;
  15441. $scope.gridOptions.useExternalPagination = true;
  15442. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15443. $scope.gridOptions.paginationPageSize = 10;
  15444. $scope.gridOptions.multiSelect = false;
  15445. $scope.searchModel = {
  15446. type:1,//默认科室内转派
  15447. }
  15448. $scope.hospitalList = [];
  15449. $scope.dutyDeptList = [];
  15450. // 修改转派模式
  15451. $scope.changeType = function(type){
  15452. console.log($scope.searchModel.type)
  15453. $scope.gridOptions.totalItems = 0;
  15454. $scope.myData = [];
  15455. $scope.searchModel.department = undefined;
  15456. $scope.searchModel.branch = undefined;
  15457. $scope.dutyDeptList = [];
  15458. if($scope.searchModel.type == 2){
  15459. //跨科室转派
  15460. api_user_data.fetchDataList('branch', {
  15461. "idx": 0,
  15462. "sum": 100
  15463. }).then(function (data) {
  15464. if(data.status == 200){
  15465. $scope.hospitalList = data.list;
  15466. if($rootScope.user.duty){
  15467. // 当前的所属责任科室
  15468. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  15469. // $scope.changeBranch();
  15470. }else if($rootScope.user.branch){
  15471. // 当前的所属院区
  15472. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  15473. // $scope.changeBranch();
  15474. }
  15475. }else{
  15476. SweetAlert.swal({
  15477. title: "系统错误!",
  15478. text: "请刷新重试!",
  15479. type: "error"
  15480. });
  15481. }
  15482. })
  15483. }else if($scope.searchModel.type == 1){
  15484. //科室内转派
  15485. var postData = {
  15486. idx: 0,
  15487. sum: 10,
  15488. user: {
  15489. roledata: {
  15490. rolecode: "first-line support",
  15491. },
  15492. selectType: "1",
  15493. },
  15494. }
  15495. // 判断当前是责任科室还是院区
  15496. if ($rootScope.user.duty) {
  15497. // 当前的所属责任科室
  15498. postData.user.currentDuty = $rootScope.user.duty.id;
  15499. } else if ($rootScope.user.branch) {
  15500. // 当前的所属院区
  15501. $scope.myData = [];
  15502. return;
  15503. }
  15504. $scope.loadData(postData);
  15505. }
  15506. }
  15507. // 修改院区
  15508. $scope.changeBranch = function(keyword=''){
  15509. if(!$scope.searchModel.branch){
  15510. return;
  15511. }
  15512. $scope.searchModel.department = undefined;
  15513. $scope.dutyDeptList = [];
  15514. api_user_data.fetchDataList('dutyDepartment', {
  15515. "idx": 0,
  15516. "sum": 100,
  15517. "dutyDepartment":{
  15518. branch:$scope.searchModel.branch.id,
  15519. dept:keyword,
  15520. selectType: "pinyin_qs"
  15521. }
  15522. }).then(function (data) {
  15523. if(data.status == 200){
  15524. $scope.dutyDeptList = data.list;
  15525. }else{
  15526. SweetAlert.swal({
  15527. title: "系统错误!",
  15528. text: "请刷新重试!",
  15529. type: "error"
  15530. });
  15531. }
  15532. })
  15533. }
  15534. // 修改责任科室
  15535. $scope.changeDutyDept = function(){
  15536. $scope.loadData({
  15537. idx: 0,
  15538. sum: 10,
  15539. user: {
  15540. duty:$scope.searchModel.department,
  15541. roledata: {
  15542. rolecode: "first-line support",
  15543. },
  15544. selectType: "1",
  15545. },
  15546. });
  15547. }
  15548. $scope.gridOptions.rowIdentity = function (row) {
  15549. return row.id;
  15550. };
  15551. $scope.gridOptions.getRowIdentity = function (row) {
  15552. return row.id;
  15553. };
  15554. $scope.gridOptions.rowTemplate =
  15555. '<div ng-dblclick="grid.appScope.pdList.onDblClick(row,$event)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
  15556. $scope.gridOptions.columnDefs = [
  15557. {
  15558. name: "account",
  15559. displayName: "人员编号",
  15560. width: 120,
  15561. },
  15562. {
  15563. name: "name",
  15564. displayName: "姓名",
  15565. width: 100,
  15566. cellTemplate:
  15567. "<div>" +
  15568. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15569. "</div>",
  15570. },
  15571. // {
  15572. // name: 'gender.name',
  15573. // displayName: '性别',
  15574. // width: 80,
  15575. // enableFiltering: false
  15576. // },
  15577. {
  15578. name: "phone",
  15579. displayName: "电话",
  15580. width: 230,
  15581. enableFiltering: false,
  15582. },
  15583. {
  15584. name: "email",
  15585. displayName: "邮箱",
  15586. width: 180,
  15587. enableFiltering: false,
  15588. },
  15589. {
  15590. name: "dept.dept",
  15591. displayName: "科室",
  15592. width: 130,
  15593. enableFiltering: false,
  15594. },
  15595. // {
  15596. // name: "taskCount",
  15597. // displayName: "处理中事件数",
  15598. // enableFiltering: false,
  15599. // },
  15600. ];
  15601. // $scope.selectButtonClick
  15602. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15603. $scope.gridApi = gridApi;
  15604. gridApi.pagination.on.paginationChanged(
  15605. $scope,
  15606. function (newPage, pageSize) {
  15607. var postData = {
  15608. idx: newPage - 1,
  15609. sum: pageSize,
  15610. user: {
  15611. roledata: {
  15612. rolecode: "first-line support",
  15613. },
  15614. selectType: "1",
  15615. },
  15616. }
  15617. if($scope.isAssign){
  15618. if($scope.searchModel.type == 1){
  15619. // 判断当前是责任科室还是院区
  15620. if ($rootScope.user.duty) {
  15621. // 当前的所属责任科室
  15622. postData.user.currentDuty = $rootScope.user.duty.id;
  15623. } else if ($rootScope.user.branch) {
  15624. // 当前的所属院区
  15625. $scope.myData = [];
  15626. return;
  15627. }
  15628. }else if($scope.searchModel.type == 2){
  15629. // 跨科室转派
  15630. postData.user.duty = $scope.searchModel.department;
  15631. }
  15632. }
  15633. $scope.loadData(postData);
  15634. }
  15635. );
  15636. gridApi.selection.on.rowSelectionChanged(
  15637. $scope,
  15638. function (data) {
  15639. $scope.selected.items = data.entity;
  15640. //console.log(data);
  15641. }
  15642. );
  15643. gridApi.selection.on.rowSelectionChangedBatch(
  15644. $scope,
  15645. function (data) {
  15646. $scope.selected.items = data.entity;
  15647. //console.log(data);
  15648. }
  15649. );
  15650. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15651. // // if (row.entity.age > 45) {
  15652. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15653. // // }
  15654. // };
  15655. gridApi.core.on.filterChanged($scope, function () {
  15656. var grid = this.grid;
  15657. var filtersData = {
  15658. idx: 0,
  15659. sum: 10,
  15660. user: {
  15661. roledata: {
  15662. rolecode: "roleset",
  15663. },
  15664. selectType: "1",
  15665. },
  15666. };
  15667. angular.forEach(grid.columns, function (item) {
  15668. if (item.enableFiltering) {
  15669. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15670. if (
  15671. angular.isDefined(item.filters[0].term) &&
  15672. item.filters[0].term != ""
  15673. ) {
  15674. if (angular.isUndefined(filtersData["user"])) {
  15675. filtersData["user"] = {};
  15676. }
  15677. filtersData["user"][item.field] =
  15678. item.filters[0].term;
  15679. }
  15680. }
  15681. });
  15682. if($scope.isAssign){
  15683. if($scope.searchModel.type == 1){
  15684. // 判断当前是责任科室还是院区
  15685. if ($rootScope.user.duty) {
  15686. // 当前的所属责任科室
  15687. filtersData.user.currentDuty = $rootScope.user.duty.id;
  15688. } else if ($rootScope.user.branch) {
  15689. // 当前的所属院区
  15690. $scope.myData = [];
  15691. return;
  15692. }
  15693. }else if($scope.searchModel.type == 2){
  15694. // 跨科室转派
  15695. filtersData.user.duty = $scope.searchModel.department;
  15696. }
  15697. }
  15698. // $scope.memoryfilterData = filtersData;
  15699. $scope.loadData(filtersData);
  15700. });
  15701. };
  15702. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15703. // if (row.entity.age > 45) {
  15704. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15705. // }
  15706. // },
  15707. $scope.onDblClick = function (data, event) {
  15708. // $scope.selected.items = data.entity;
  15709. $scope.selectButtonClick(data, event);
  15710. };
  15711. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15712. // $scope.selected.items = data.entity;
  15713. // })
  15714. // };
  15715. $scope.memoryfilterData = {
  15716. idx: 0,
  15717. sum: 10,
  15718. user: {
  15719. roledata: {
  15720. rolecode: "roleset",
  15721. },
  15722. selectType: "1",
  15723. },
  15724. };
  15725. $scope.loadData = function (filterData) {
  15726. // console.log("filtersData=111" + JSON.stringify(filterData))
  15727. items
  15728. .fetchItems(filterData, APIService)
  15729. .then(function (data) {
  15730. var myData = Restangular.stripRestangular(data);
  15731. $scope.gridOptions.totalItems = myData.totalNum;
  15732. $scope.myData = myData.list;
  15733. });
  15734. };
  15735. $scope.title = title;
  15736. $scope.selected = {
  15737. items: {},
  15738. };
  15739. $scope.ok = function () {
  15740. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15741. // onDataCallback($scope.selected.item, parentScope);
  15742. // }
  15743. $modalInstance.close($scope.selected.items);
  15744. };
  15745. $scope.cancel = function () {
  15746. $modalInstance.dismiss("cancel");
  15747. };
  15748. // 初始化
  15749. var postData = {
  15750. idx: 0,
  15751. sum: 10,
  15752. user: {
  15753. roledata: {
  15754. rolecode: "first-line support",
  15755. },
  15756. selectType: "1",
  15757. },
  15758. }
  15759. if($scope.isAssign){
  15760. if($scope.searchModel.type == 1){
  15761. // 判断当前是责任科室还是院区
  15762. if ($rootScope.user.duty) {
  15763. // 当前的所属责任科室
  15764. postData.user.currentDuty = $rootScope.user.duty.id;
  15765. } else if ($rootScope.user.branch) {
  15766. // 当前的所属院区
  15767. $scope.myData = [];
  15768. return;
  15769. }
  15770. }else if($scope.searchModel.type == 2){
  15771. // 跨科室转派
  15772. postData.user.duty = $scope.searchModel.department;
  15773. }
  15774. }
  15775. $scope.loadData(postData);
  15776. },
  15777. size: size,
  15778. resolve: {
  15779. items: function () {
  15780. return {
  15781. fetchItems: function (filterData, APIService) {
  15782. filterData = filterData || {};
  15783. if (
  15784. angular.isDefined(filterData.idx) &&
  15785. filterData.idx == null
  15786. ) {
  15787. filterData = {
  15788. idx: 0,
  15789. sum: 10,
  15790. user: {
  15791. roledata: {
  15792. rolecode: "roleset",
  15793. },
  15794. selectType: "1",
  15795. },
  15796. };
  15797. }
  15798. return options.templateOptions.fetchItems(
  15799. filterData,
  15800. APIService
  15801. );
  15802. },
  15803. };
  15804. },
  15805. title: function () {
  15806. return options.templateOptions.label;
  15807. },
  15808. Restangular: function () {
  15809. return options.templateOptions.Restangular;
  15810. },
  15811. APIService: function () {
  15812. return options.templateOptions.ApiService;
  15813. },
  15814. onDataCallback: function () {
  15815. return options.templateOptions.callback;
  15816. },
  15817. parentScope: function () {
  15818. return options.templateOptions.that;
  15819. },
  15820. },
  15821. });
  15822. modalInstance.result.then(
  15823. function (selectedItem) {
  15824. // console.log(selectedItem);
  15825. options.value(selectedItem);
  15826. if (
  15827. options.templateOptions.callback &&
  15828. angular.isFunction(options.templateOptions.callback)
  15829. ) {
  15830. options.templateOptions.callback(
  15831. selectedItem,
  15832. options.templateOptions.that
  15833. );
  15834. }
  15835. if (
  15836. options.templateOptions.linkData &&
  15837. angular.isFunction(options.templateOptions.linkData)
  15838. ) {
  15839. options.templateOptions.linkData(
  15840. selectedItem,
  15841. options.templateOptions.that
  15842. );
  15843. }
  15844. },
  15845. function () {
  15846. //console.log('Modal dismissed at: ' + new Date());
  15847. }
  15848. );
  15849. },
  15850. },
  15851. };
  15852. },
  15853. controller: [
  15854. "$scope",
  15855. function ($scope) {
  15856. $scope.options.templateOptions.that = $scope;
  15857. // $scope.options.model[$scope.options.key] = {}
  15858. },
  15859. ],
  15860. });
  15861. //用户单选控件(dd 单选input带搜索)liaomingming
  15862. formlyConfigProvider.setType({
  15863. name: "ui-userselectSearch",
  15864. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15865. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15866. defaultOptions: function (options) {
  15867. return {
  15868. templateOptions: {
  15869. openModal: function (size, options, modal) {
  15870. var modalInstance = modal.open({
  15871. templateUrl:
  15872. "assets/views/customform/tpl/checktable-modal-content.html",
  15873. controller: function (
  15874. $scope,
  15875. $rootScope,
  15876. i18nService,
  15877. $modalInstance,
  15878. items,
  15879. title,
  15880. Restangular,
  15881. APIService,
  15882. onDataCallback,
  15883. parentScope,
  15884. api_category,
  15885. api_user_data
  15886. ) {
  15887. $scope.isAssign = options.templateOptions.departmentDispatchesOrders;
  15888. $scope.langs = i18nService.getAllLangs();
  15889. $scope.lang = "zh-cn";
  15890. i18nService.setCurrentLang($scope.lang);
  15891. $scope.gridOptions = {};
  15892. $scope.gridOptions.data = "myData";
  15893. $scope.gridOptions.enableColumnResizing = true;
  15894. $scope.gridOptions.enableFiltering = true;
  15895. $scope.gridOptions.enableGridMenu = false;
  15896. $scope.gridOptions.showGridFooter = true;
  15897. $scope.gridOptions.showColumnFooter = false;
  15898. $scope.gridOptions.fastWatch = true;
  15899. $scope.gridOptions.useExternalFiltering = true;
  15900. $scope.gridOptions.useExternalPagination = true;
  15901. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15902. $scope.gridOptions.paginationPageSize = 10;
  15903. $scope.gridOptions.multiSelect = false;
  15904. $scope.searchModel = {
  15905. type:1,//默认科室内转派
  15906. }
  15907. $scope.hospitalList = [];
  15908. $scope.dutyDeptList = [];
  15909. // 修改转派模式
  15910. $scope.changeType = function(type){
  15911. console.log($scope.searchModel.type)
  15912. $scope.gridOptions.totalItems = 0;
  15913. $scope.myData = [];
  15914. $scope.searchModel.department = undefined;
  15915. $scope.searchModel.branch = undefined;
  15916. $scope.dutyDeptList = [];
  15917. if($scope.searchModel.type == 2){
  15918. //跨科室转派
  15919. api_user_data.fetchDataList('branch', {
  15920. "idx": 0,
  15921. "sum": 100
  15922. }).then(function (data) {
  15923. if(data.status == 200){
  15924. $scope.hospitalList = data.list;
  15925. if($rootScope.user.duty){
  15926. // 当前的所属责任科室
  15927. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  15928. // $scope.changeBranch();
  15929. }else if($rootScope.user.branch){
  15930. // 当前的所属院区
  15931. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  15932. // $scope.changeBranch();
  15933. }
  15934. }else{
  15935. SweetAlert.swal({
  15936. title: "系统错误!",
  15937. text: "请刷新重试!",
  15938. type: "error"
  15939. });
  15940. }
  15941. })
  15942. }else if($scope.searchModel.type == 1){
  15943. //科室内转派
  15944. var postData = {
  15945. idx: 0,
  15946. sum: 10,
  15947. user: {
  15948. roledata: {
  15949. rolecode: "first-line support",
  15950. },
  15951. selectType: "1",
  15952. },
  15953. }
  15954. // 判断当前是责任科室还是院区
  15955. if ($rootScope.user.duty) {
  15956. // 当前的所属责任科室
  15957. postData.user.currentDuty = $rootScope.user.duty.id;
  15958. } else if ($rootScope.user.branch) {
  15959. // 当前的所属院区
  15960. $scope.myData = [];
  15961. return;
  15962. }
  15963. $scope.loadData(postData);
  15964. }
  15965. }
  15966. // 修改院区
  15967. $scope.changeBranch = function(keyword=''){
  15968. if(!$scope.searchModel.branch){
  15969. return;
  15970. }
  15971. $scope.searchModel.department = undefined;
  15972. $scope.dutyDeptList = [];
  15973. api_user_data.fetchDataList('dutyDepartment', {
  15974. "idx": 0,
  15975. "sum": 100,
  15976. "dutyDepartment":{
  15977. branch:$scope.searchModel.branch.id,
  15978. dept:keyword,
  15979. selectType: "pinyin_qs"
  15980. }
  15981. }).then(function (data) {
  15982. if(data.status == 200){
  15983. $scope.dutyDeptList = data.list;
  15984. }else{
  15985. SweetAlert.swal({
  15986. title: "系统错误!",
  15987. text: "请刷新重试!",
  15988. type: "error"
  15989. });
  15990. }
  15991. })
  15992. }
  15993. // 修改责任科室
  15994. $scope.changeDutyDept = function(){
  15995. $scope.loadData({
  15996. idx: 0,
  15997. sum: 10,
  15998. user: {
  15999. duty:$scope.searchModel.department,
  16000. roledata: {
  16001. rolecode: "first-line support",
  16002. },
  16003. selectType: "1",
  16004. },
  16005. });
  16006. }
  16007. $scope.gridOptions.rowIdentity = function (row) {
  16008. return row.id;
  16009. };
  16010. $scope.gridOptions.getRowIdentity = function (row) {
  16011. return row.id;
  16012. };
  16013. $scope.gridOptions.rowTemplate =
  16014. '<div ng-dblclick="grid.appScope.pdList.onDblClick(row,$event)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
  16015. $scope.gridOptions.columnDefs = [
  16016. {
  16017. name: "account",
  16018. displayName: "人员编号",
  16019. width: 120,
  16020. },
  16021. {
  16022. name: "name",
  16023. displayName: "姓名",
  16024. width: 100,
  16025. cellTemplate:
  16026. "<div>" +
  16027. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  16028. "</div>",
  16029. },
  16030. // {
  16031. // name: 'gender.name',
  16032. // displayName: '性别',
  16033. // width: 80,
  16034. // enableFiltering: false
  16035. // },
  16036. {
  16037. name: "phone",
  16038. displayName: "电话",
  16039. width: 230,
  16040. enableFiltering: false,
  16041. },
  16042. {
  16043. name: "email",
  16044. displayName: "邮箱",
  16045. width: 180,
  16046. enableFiltering: false,
  16047. },
  16048. {
  16049. name: "dept.dept",
  16050. displayName: "科室",
  16051. width: 130,
  16052. enableFiltering: false,
  16053. },
  16054. // {
  16055. // name: "taskCount",
  16056. // displayName: "处理中事件数",
  16057. // enableFiltering: false,
  16058. // },
  16059. ];
  16060. // $scope.selectButtonClick
  16061. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16062. $scope.gridApi = gridApi;
  16063. gridApi.pagination.on.paginationChanged(
  16064. $scope,
  16065. function (newPage, pageSize) {
  16066. var postData = {
  16067. idx: newPage - 1,
  16068. sum: pageSize,
  16069. user: {
  16070. roledata: {
  16071. rolecode: "first-line support",
  16072. },
  16073. selectType: "1",
  16074. },
  16075. }
  16076. if($scope.isAssign){
  16077. if($scope.searchModel.type == 1){
  16078. // 判断当前是责任科室还是院区
  16079. if ($rootScope.user.duty) {
  16080. // 当前的所属责任科室
  16081. postData.user.currentDuty = $rootScope.user.duty.id;
  16082. } else if ($rootScope.user.branch) {
  16083. // 当前的所属院区
  16084. $scope.myData = [];
  16085. return;
  16086. }
  16087. }else if($scope.searchModel.type == 2){
  16088. // 跨科室转派
  16089. postData.user.duty = $scope.searchModel.department;
  16090. }
  16091. }
  16092. $scope.loadData(postData);
  16093. }
  16094. );
  16095. gridApi.selection.on.rowSelectionChanged(
  16096. $scope,
  16097. function (data) {
  16098. $scope.selected.items = data.entity;
  16099. //console.log(data);
  16100. }
  16101. );
  16102. gridApi.selection.on.rowSelectionChangedBatch(
  16103. $scope,
  16104. function (data) {
  16105. $scope.selected.items = data.entity;
  16106. //console.log(data);
  16107. }
  16108. );
  16109. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  16110. // // if (row.entity.age > 45) {
  16111. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16112. // // }
  16113. // };
  16114. gridApi.core.on.filterChanged($scope, function () {
  16115. var grid = this.grid;
  16116. var filtersData = {
  16117. idx: 0,
  16118. sum: 10,
  16119. user: {
  16120. roledata: {
  16121. rolecode: "first-line support",
  16122. },
  16123. selectType: "1",
  16124. },
  16125. };
  16126. angular.forEach(grid.columns, function (item) {
  16127. if (item.enableFiltering) {
  16128. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  16129. if (
  16130. angular.isDefined(item.filters[0].term) &&
  16131. item.filters[0].term != ""
  16132. ) {
  16133. if (angular.isUndefined(filtersData["user"])) {
  16134. filtersData["user"] = {};
  16135. }
  16136. filtersData["user"][item.field] =
  16137. item.filters[0].term;
  16138. }
  16139. }
  16140. });
  16141. if($scope.isAssign){
  16142. if($scope.searchModel.type == 1){
  16143. // 判断当前是责任科室还是院区
  16144. if ($rootScope.user.duty) {
  16145. // 当前的所属责任科室
  16146. filtersData.user.currentDuty = $rootScope.user.duty.id;
  16147. } else if ($rootScope.user.branch) {
  16148. // 当前的所属院区
  16149. $scope.myData = [];
  16150. return;
  16151. }
  16152. }else if($scope.searchModel.type == 2){
  16153. // 跨科室转派
  16154. filtersData.user.duty = $scope.searchModel.department;
  16155. }
  16156. }
  16157. // $scope.memoryfilterData = filtersData;
  16158. $scope.loadData(filtersData);
  16159. });
  16160. };
  16161. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  16162. // if (row.entity.age > 45) {
  16163. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16164. // }
  16165. // },
  16166. $scope.onDblClick = function (data, event) {
  16167. // $scope.selected.items = data.entity;
  16168. $scope.selectButtonClick(data, event);
  16169. };
  16170. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  16171. // $scope.selected.items = data.entity;
  16172. // })
  16173. // };
  16174. $scope.memoryfilterData = {
  16175. idx: 0,
  16176. sum: 10,
  16177. user: {
  16178. roledata: {
  16179. rolecode: "first-line support",
  16180. },
  16181. selectType: "1",
  16182. },
  16183. };
  16184. $scope.loadData = function (filterData) {
  16185. // console.log("filtersData=111" + JSON.stringify(filterData))
  16186. items
  16187. .fetchItems(filterData, APIService)
  16188. .then(function (data) {
  16189. if(($scope.searchModel.type == 1 && filterData.user.duty) || ($scope.searchModel.type == 2 && !filterData.user.duty)){
  16190. $scope.gridOptions.totalItems = 0;
  16191. $scope.myData = [];
  16192. }else{
  16193. var myData = Restangular.stripRestangular(data);
  16194. $scope.gridOptions.totalItems = myData.totalNum;
  16195. $scope.myData = myData.list;
  16196. }
  16197. });
  16198. };
  16199. $scope.title = title;
  16200. $scope.selected = {
  16201. items: {},
  16202. };
  16203. $scope.ok = function () {
  16204. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  16205. // onDataCallback($scope.selected.item, parentScope);
  16206. // }
  16207. $modalInstance.close($scope.selected.items);
  16208. };
  16209. $scope.cancel = function () {
  16210. $modalInstance.dismiss("cancel");
  16211. };
  16212. // 初始化
  16213. var postData = {
  16214. idx: 0,
  16215. sum: 10,
  16216. user: {
  16217. roledata: {
  16218. rolecode: "first-line support",
  16219. },
  16220. selectType: "1",
  16221. },
  16222. }
  16223. if($scope.isAssign){
  16224. if($scope.searchModel.type == 1){
  16225. // 判断当前是责任科室还是院区
  16226. if ($rootScope.user.duty) {
  16227. // 当前的所属责任科室
  16228. postData.user.currentDuty = $rootScope.user.duty.id;
  16229. } else if ($rootScope.user.branch) {
  16230. // 当前的所属院区
  16231. $scope.myData = [];
  16232. return;
  16233. }
  16234. }else if($scope.searchModel.type == 2){
  16235. // 跨科室转派
  16236. postData.user.duty = $scope.searchModel.department;
  16237. }
  16238. }
  16239. $scope.loadData(postData);
  16240. },
  16241. size: size,
  16242. resolve: {
  16243. items: function () {
  16244. return {
  16245. fetchItems: function (filterData, APIService) {
  16246. filterData = filterData || {};
  16247. if (
  16248. angular.isDefined(filterData.idx) &&
  16249. filterData.idx == null
  16250. ) {
  16251. filterData = {
  16252. idx: 0,
  16253. sum: 10,
  16254. user: {
  16255. roledata: {
  16256. rolecode: "first-line support",
  16257. },
  16258. selectType: "1",
  16259. },
  16260. };
  16261. }
  16262. return options.templateOptions.fetchItems(
  16263. filterData,
  16264. APIService
  16265. );
  16266. },
  16267. };
  16268. },
  16269. title: function () {
  16270. return options.templateOptions.label;
  16271. },
  16272. Restangular: function () {
  16273. return options.templateOptions.Restangular;
  16274. },
  16275. APIService: function () {
  16276. return options.templateOptions.ApiService;
  16277. },
  16278. onDataCallback: function () {
  16279. return options.templateOptions.callback;
  16280. },
  16281. parentScope: function () {
  16282. return options.templateOptions.that;
  16283. }
  16284. },
  16285. });
  16286. modalInstance.result.then(
  16287. function (selectedItem) {
  16288. // console.log(selectedItem);
  16289. options.value(selectedItem);
  16290. if (
  16291. options.templateOptions.callback &&
  16292. angular.isFunction(options.templateOptions.callback)
  16293. ) {
  16294. options.templateOptions.callback(
  16295. selectedItem,
  16296. options.templateOptions.that
  16297. );
  16298. }
  16299. if (
  16300. options.templateOptions.linkData &&
  16301. angular.isFunction(options.templateOptions.linkData)
  16302. ) {
  16303. options.templateOptions.linkData(
  16304. selectedItem,
  16305. options.templateOptions.that
  16306. );
  16307. }
  16308. },
  16309. function () {
  16310. //console.log('Modal dismissed at: ' + new Date());
  16311. }
  16312. );
  16313. },
  16314. },
  16315. };
  16316. },
  16317. controller: [
  16318. "$scope",
  16319. function ($scope) {
  16320. $scope.options.templateOptions.that = $scope;
  16321. },
  16322. ],
  16323. });
  16324. //用户多选控件
  16325. formlyConfigProvider.setType({
  16326. name: "ui-multiuserselect",
  16327. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  16328. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16329. defaultOptions: function (options) {
  16330. return {
  16331. templateOptions: {
  16332. openModal: function (size, options, modal, model) {
  16333. var modalInstance = modal.open({
  16334. templateUrl:
  16335. "assets/views/customform/tpl/checktable-modal-content.html",
  16336. controller: function (
  16337. $scope,
  16338. $modalInstance,
  16339. i18nService,
  16340. $timeout,
  16341. items,
  16342. title,
  16343. Restangular,
  16344. APIService,
  16345. selectItems
  16346. ) {
  16347. $scope.langs = i18nService.getAllLangs();
  16348. $scope.lang = "zh-cn";
  16349. i18nService.setCurrentLang($scope.lang);
  16350. $scope.gridOptions = {};
  16351. $scope.gridOptions.data = "myData";
  16352. $scope.gridOptions.enableColumnResizing = true;
  16353. $scope.gridOptions.enableFiltering = true;
  16354. $scope.gridOptions.enableGridMenu = true;
  16355. $scope.gridOptions.showGridFooter = true;
  16356. $scope.gridOptions.showColumnFooter = true;
  16357. $scope.gridOptions.fastWatch = true;
  16358. $scope.gridOptions.useExternalFiltering = true;
  16359. $scope.gridOptions.useExternalPagination = true;
  16360. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16361. $scope.gridOptions.paginationPageSize = 10;
  16362. $scope.gridOptions.multiSelect = true;
  16363. $scope.gridOptions.rowIdentity = function (row) {
  16364. return row.id;
  16365. };
  16366. $scope.gridOptions.getRowIdentity = function (row) {
  16367. return row.id;
  16368. };
  16369. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  16370. $scope.gridOptions.columnDefs = [
  16371. // { name:'id', width:80, enableFiltering:false},
  16372. {
  16373. name: "account",
  16374. displayName: "账号",
  16375. width: 140,
  16376. },
  16377. {
  16378. name: "name",
  16379. displayName: "名称",
  16380. width: 100,
  16381. },
  16382. {
  16383. name: "gender.name",
  16384. displayName: "性别",
  16385. width: 140,
  16386. enableFiltering: false,
  16387. },
  16388. {
  16389. name: "phone",
  16390. displayName: "电话",
  16391. width: 100,
  16392. enableFiltering: false,
  16393. },
  16394. {
  16395. name: "email",
  16396. displayName: "邮件",
  16397. width: 100,
  16398. enableFiltering: false,
  16399. },
  16400. {
  16401. name: "dept.dept",
  16402. displayName: "科室",
  16403. width: 100,
  16404. enableFiltering: false,
  16405. },
  16406. {
  16407. name: "group[0].groupName",
  16408. displayName: "职位",
  16409. width: 100,
  16410. enableFiltering: false,
  16411. },
  16412. ];
  16413. $scope.selected = {
  16414. items: selectItems,
  16415. };
  16416. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16417. $scope.gridApi = gridApi;
  16418. gridApi.pagination.on.paginationChanged(
  16419. $scope,
  16420. function (newPage, pageSize) {
  16421. var filtersData = $scope.memoryfilterData;
  16422. filtersData.idx = newPage - 1;
  16423. filtersData.sum = pageSize;
  16424. $scope.loadData(filtersData);
  16425. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  16426. }
  16427. );
  16428. gridApi.selection.on.rowSelectionChanged(
  16429. $scope,
  16430. function (scope) {
  16431. var j = 0;
  16432. for (
  16433. var i = 0;
  16434. i <= scope.grid.appScope.selected.items.length;
  16435. i++
  16436. ) {
  16437. if (
  16438. scope.grid.appScope.selected.items[i] == scope.entity
  16439. ) {
  16440. j++;
  16441. break;
  16442. }
  16443. }
  16444. if (j == 1) {
  16445. scope.grid.appScope.selected.items.splice(i, 1);
  16446. } else {
  16447. scope.grid.appScope.selected.items.push(scope.entity);
  16448. for (
  16449. var i = 0;
  16450. i < scope.grid.appScope.selected.items.length;
  16451. i++
  16452. ) {
  16453. for (
  16454. var z = 0;
  16455. z < scope.grid.appScope.selected.items.length;
  16456. z++
  16457. ) {
  16458. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  16459. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  16460. if (
  16461. angular.isDefined(
  16462. scope.grid.appScope.selected.items
  16463. ) &&
  16464. scope.grid.appScope.selected.items[i].id ==
  16465. scope.grid.appScope.selected.items[z].id &&
  16466. i != z
  16467. ) {
  16468. scope.grid.appScope.selected.items.splice(i, 1);
  16469. }
  16470. }
  16471. }
  16472. }
  16473. }
  16474. );
  16475. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  16476. // $scope.grid.appScope.selected.items.push($scope.entity);
  16477. // });
  16478. gridApi.core.on.filterChanged($scope, function () {
  16479. var grid = this.grid;
  16480. var filtersData = {
  16481. idx: 0,
  16482. sum: 10,
  16483. user: {
  16484. roledata: {
  16485. rolecode: options.model.currentRole,
  16486. },
  16487. selectType: "1",
  16488. },
  16489. };
  16490. angular.forEach(grid.columns, function (item) {
  16491. if (item.enableFiltering) {
  16492. //console.log("filtersData="+JSON.stringify(filtersData))
  16493. if (
  16494. angular.isDefined(item.filters[0].term) &&
  16495. item.filters[0].term != ""
  16496. ) {
  16497. if (angular.isUndefined(filtersData["user"])) {
  16498. filtersData["user"] = {};
  16499. }
  16500. filtersData["user"][item.field] =
  16501. item.filters[0].term;
  16502. }
  16503. }
  16504. });
  16505. $scope.memoryfilterData = filtersData;
  16506. $scope.loadData(filtersData);
  16507. });
  16508. };
  16509. if (!options.model) {
  16510. var mouse = {
  16511. model: {
  16512. currentRole: "",
  16513. },
  16514. };
  16515. angular.extend(options, mouse);
  16516. }
  16517. $scope.memoryfilterData = {
  16518. idx: 0,
  16519. sum: 10,
  16520. user: {
  16521. roledata: {
  16522. rolecode: options.model.currentRole,
  16523. },
  16524. selectType: "1",
  16525. },
  16526. };
  16527. $scope.loadData = function (filterData) {
  16528. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  16529. items
  16530. .fetchItems(filterData, APIService)
  16531. .then(function (data) {
  16532. var myData = Restangular.stripRestangular(data);
  16533. $scope.gridOptions.totalItems = myData.totalNum;
  16534. $scope.myData = myData.list;
  16535. //console.log($scope.gridOptions.pagination.getTotalPages());
  16536. // if($scope.selected.items){
  16537. // angular.forEach($scope.selected.items,function(selectItem){
  16538. // $scope.gridApi.selection.selectRow(selectItem);
  16539. // });
  16540. // }
  16541. });
  16542. };
  16543. // $scope.title = title;
  16544. $scope.loadData({
  16545. idx: 0,
  16546. sum: 10,
  16547. user: {
  16548. roledata: {
  16549. rolecode: options.model.currentRole,
  16550. },
  16551. selectType: "1",
  16552. },
  16553. });
  16554. // $timeout(function(){
  16555. // if($scope.selected.items){
  16556. // angular.forEach($scope.selected.items,function(selectItem){
  16557. // $scope.gridApi.selection.selectRow(selectItem);
  16558. // });
  16559. // }
  16560. // },2000)
  16561. $scope.ok = function () {
  16562. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  16563. $modalInstance.close($scope.selected.items);
  16564. };
  16565. $scope.cancel = function () {
  16566. $modalInstance.dismiss("cancel");
  16567. };
  16568. },
  16569. size: size,
  16570. resolve: {
  16571. items: function () {
  16572. return {
  16573. fetchItems: function (filterData, APIService) {
  16574. filterData = filterData || {};
  16575. if (
  16576. angular.isDefined(filterData.idx) &&
  16577. filterData.idx == null
  16578. ) {
  16579. filterData = {
  16580. idx: 0,
  16581. sum: 10,
  16582. user: {
  16583. roledata: {
  16584. rolecode: options.model.incident.currentRole,
  16585. },
  16586. selectType: "1",
  16587. },
  16588. };
  16589. }
  16590. return options.templateOptions.fetchItems(
  16591. filterData,
  16592. APIService
  16593. );
  16594. },
  16595. };
  16596. },
  16597. title: function () {
  16598. return options.templateOptions.modalTitle;
  16599. },
  16600. Restangular: function () {
  16601. return options.templateOptions.Restangular;
  16602. },
  16603. APIService: function () {
  16604. return options.templateOptions.ApiService;
  16605. },
  16606. selectItems: function () {
  16607. return model || [];
  16608. },
  16609. },
  16610. });
  16611. modalInstance.result.then(
  16612. function (selectedItem) {
  16613. options.value(selectedItem);
  16614. options.formControl.$validate();
  16615. },
  16616. function () {
  16617. //console.log('Modal dismissed at: ' + new Date());
  16618. }
  16619. );
  16620. },
  16621. },
  16622. validators: {
  16623. required: {
  16624. expression: function (viewValue, modelValue) {
  16625. var value = modelValue || viewValue;
  16626. return value.length >= 1;
  16627. },
  16628. },
  16629. },
  16630. };
  16631. },
  16632. controller: [
  16633. "$scope",
  16634. function ($scope) {
  16635. $scope.model[$scope.options.key] = [];
  16636. $scope.remove = function (itemId) {
  16637. angular.forEach(
  16638. $scope.model[$scope.options.key],
  16639. function (entry, index) {
  16640. if (entry.id == itemId) {
  16641. $scope.model[$scope.options.key].splice(index, 1);
  16642. // console.log($scope.options.formControl)
  16643. $scope.options.formControl.$validate();
  16644. } else {
  16645. }
  16646. }
  16647. );
  16648. };
  16649. },
  16650. ],
  16651. });
  16652. //用户多选控件-字符串展示
  16653. formlyConfigProvider.setType({
  16654. name: "ui-stringuserselect",
  16655. extends: "input",
  16656. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  16657. defaultOptions: function (options) {
  16658. return {
  16659. templateOptions: {
  16660. translate: "",
  16661. refreshDelay: 0,
  16662. },
  16663. };
  16664. },
  16665. controller: [
  16666. "$scope",
  16667. function ($scope) {
  16668. var keydata = "";
  16669. if (angular.isArray($scope.model)) {
  16670. angular.forEach($scope.model, function (item) {
  16671. keydata = keydata + "," + item.name;
  16672. });
  16673. }
  16674. // $scope.model[$scope.options.key] = [];
  16675. },
  16676. ],
  16677. });
  16678. //重复事件
  16679. formlyConfigProvider.setType({
  16680. name: "ui-incidentmodelselect",
  16681. extends: "input",
  16682. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16683. defaultOptions: function (options) {
  16684. return {
  16685. templateOptions: {
  16686. openModal: function (size, options, modal) {
  16687. var modalInstance = modal.open({
  16688. templateUrl:
  16689. "assets/views/customform/tpl/checktable-modal-content.html",
  16690. controller: function (
  16691. $scope,
  16692. $rootScope,
  16693. $modalInstance,
  16694. items,
  16695. title,
  16696. Restangular,
  16697. APIService,
  16698. i18nService,
  16699. api_configure_data,
  16700. api_user_data,
  16701. api_bpm_data
  16702. ) {
  16703. $scope.langs = i18nService.getAllLangs();
  16704. $scope.lang = "zh-cn";
  16705. i18nService.setCurrentLang($scope.lang);
  16706. $scope.gridOptions = {};
  16707. $scope.gridOptions.data = "myData";
  16708. $scope.gridOptions.enableColumnResizing = true;
  16709. $scope.gridOptions.enableFiltering = true;
  16710. $scope.gridOptions.enableGridMenu = false;
  16711. $scope.gridOptions.enableRowSelection = true;
  16712. $scope.gridOptions.showGridFooter = true;
  16713. $scope.gridOptions.showColumnFooter = false;
  16714. $scope.gridOptions.fastWatch = true;
  16715. $scope.gridOptions.useExternalFiltering = true;
  16716. $scope.gridOptions.useExternalPagination = true;
  16717. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16718. $scope.gridOptions.paginationPageSize = 10;
  16719. $scope.gridOptions.multiSelect = false;
  16720. var mun = $scope.gridOptions.paginationPageSize;
  16721. $scope.gridOptions.rowIdentity = function (row) {
  16722. return row.id;
  16723. };
  16724. $scope.gridOptions.getRowIdentity = function (row) {
  16725. return row.id;
  16726. };
  16727. $scope.gridOptions.columnDefs = items.columnDefs();
  16728. $scope.transferTime = function (time) {
  16729. return moment(time).format("YYYY-MM-DD HH:mm");
  16730. };
  16731. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16732. $scope.gridApi = gridApi;
  16733. gridApi.pagination.on.paginationChanged(
  16734. $scope,
  16735. function (newPage, pageSize) {
  16736. // console.log(newPage);
  16737. // console.log(pageSize);
  16738. $scope.loadData({
  16739. idx: newPage - 1,
  16740. sum: pageSize,
  16741. });
  16742. }
  16743. );
  16744. gridApi.core.on.filterChanged($scope, function () {
  16745. var grid = this.grid;
  16746. var filtersData = {
  16747. idx: 0,
  16748. sum: 100,
  16749. };
  16750. angular.forEach(grid.columns, function (item) {
  16751. if (item.enableFiltering) {
  16752. if (
  16753. angular.isDefined(item.filters[0].term) &&
  16754. item.filters[0].term != ""
  16755. ) {
  16756. // console.log("filtersData="+JSON.stringify(filtersData))
  16757. if (angular.isUndefined(filtersData["incident"])) {
  16758. filtersData["incident"] = {};
  16759. }
  16760. filtersData["incident"][item.field] =
  16761. item.filters[0].term;
  16762. if (angular.isUndefined(filtersData["problem"])) {
  16763. filtersData["problem"] = {};
  16764. }
  16765. filtersData["problem"][item.field] =
  16766. item.filters[0].term;
  16767. if (angular.isUndefined(filtersData["change"])) {
  16768. filtersData["change"] = {};
  16769. }
  16770. filtersData["change"][item.field] =
  16771. item.filters[0].term;
  16772. if (angular.isUndefined(filtersData["release"])) {
  16773. filtersData["release"] = {};
  16774. }
  16775. filtersData["release"][item.field] =
  16776. item.filters[0].term;
  16777. }
  16778. }
  16779. });
  16780. $scope.loadData(filtersData);
  16781. });
  16782. gridApi.selection.on.rowSelectionChanged(
  16783. $scope,
  16784. function (data) {
  16785. $scope.selected.item = data.entity;
  16786. //console.log(data);
  16787. }
  16788. );
  16789. };
  16790. //资产
  16791. $scope.cmdb = {};
  16792. //资产状态
  16793. $scope.state_data = [
  16794. {
  16795. name: "全部状态",
  16796. value: "",
  16797. },
  16798. {
  16799. name: "在库",
  16800. value: "1",
  16801. },
  16802. {
  16803. name: "在线",
  16804. value: "2",
  16805. },
  16806. {
  16807. name: "借出",
  16808. value: "3",
  16809. },
  16810. {
  16811. name: "报修",
  16812. value: "4",
  16813. },
  16814. {
  16815. name: "报废",
  16816. value: "5",
  16817. },
  16818. {
  16819. name: "备用",
  16820. value: "6",
  16821. },
  16822. ];
  16823. //资产类型
  16824. $scope.wt_zcfl = function () {
  16825. api_configure_data
  16826. .fetchDataList("ciclassify", {
  16827. idx: 0,
  16828. sum: 100,
  16829. })
  16830. .then(function (data) {
  16831. console.log(data);
  16832. // $scope.wt_zclx = data.list;
  16833. console.log(data);
  16834. $scope.wtData = [];
  16835. if (data.status == 200) {
  16836. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16837. var root = null; //Initially set our loop to null
  16838. var parentNode = null;
  16839. //loop over data
  16840. // $scope.wtData=data.list;
  16841. data = data.list;
  16842. //知识库分类数据三级处理
  16843. for (var i = 0; i < data.length; i++) {
  16844. // console.log(data[i])
  16845. var datum = data[i];
  16846. //each node will have children, so let's give it a "children" poperty
  16847. // console.log(datum);
  16848. datum.children = [];
  16849. if (!datum.parent) {
  16850. $scope.wtData.push(datum);
  16851. // console.log($scope.wtData)
  16852. } else {
  16853. if ($scope.wtData[0]) {
  16854. if ($scope.wtData[0].id == datum.parent.id) {
  16855. $scope.wtData[0].children.push(datum);
  16856. }
  16857. for (
  16858. var j = 0;
  16859. j < $scope.wtData[0].children.length;
  16860. j++
  16861. ) {
  16862. if (
  16863. $scope.wtData[0].children[j].id ==
  16864. datum.parent.id
  16865. ) {
  16866. $scope.wtData[0].children[j].children.push(
  16867. datum
  16868. );
  16869. }
  16870. }
  16871. }
  16872. if ($scope.wtData[1]) {
  16873. if ($scope.wtData[1].id == datum.parent.id) {
  16874. $scope.wtData[1].children.push(datum);
  16875. }
  16876. for (
  16877. var j = 0;
  16878. j < $scope.wtData[1].children.length;
  16879. j++
  16880. ) {
  16881. if (
  16882. $scope.wtData[1].children[j].id ==
  16883. datum.parent.id
  16884. ) {
  16885. $scope.wtData[1].children[j].children.push(
  16886. datum
  16887. );
  16888. }
  16889. }
  16890. }
  16891. if ($scope.wtData[2]) {
  16892. if ($scope.wtData[2].id == datum.parent.id) {
  16893. $scope.wtData[2].children.push(datum);
  16894. }
  16895. for (
  16896. var j = 0;
  16897. j < $scope.wtData[2].children.length;
  16898. j++
  16899. ) {
  16900. if (
  16901. $scope.wtData[2].children[j].id ==
  16902. datum.parent.id
  16903. ) {
  16904. $scope.wtData[2].children[j].children.push(
  16905. datum
  16906. );
  16907. }
  16908. }
  16909. }
  16910. }
  16911. // console.log($scope.wtData)
  16912. idToNodeMap[datum.id] = datum;
  16913. root = datum;
  16914. // treeMap[datum.id] = root;
  16915. }
  16916. }
  16917. });
  16918. };
  16919. $scope.wt_zcfl();
  16920. //事件
  16921. //受理人,处理人
  16922. $scope.searchkeys = {};
  16923. var fieldata = {
  16924. idx: 0,
  16925. sum: 100,
  16926. flag: -1,
  16927. user: {
  16928. engineer: 1,
  16929. }
  16930. };
  16931. getUser(fieldata, 3);
  16932. function getUser(fieldatas, it) {
  16933. api_user_data
  16934. .fetchDataList("user", fieldatas)
  16935. .then(function (data) {
  16936. if (it == 1) {
  16937. $scope.acceptUser = data.list;
  16938. } else if (it == 2) {
  16939. $scope.handlingPersonnelUser = data.list;
  16940. } else if (it == 3) {
  16941. $scope.acceptUser = data.list;
  16942. $scope.handlingPersonnelUser = data.list;
  16943. }
  16944. });
  16945. }
  16946. //状态
  16947. $scope.othcode = {};
  16948. api_bpm_data
  16949. .fetchDataList("incidentstatus", {
  16950. idx: 0,
  16951. sum: 100,
  16952. })
  16953. .then(function (response) {
  16954. if (response) {
  16955. if ((response.status = 200)) {
  16956. $scope.state = response.list;
  16957. }
  16958. }
  16959. });
  16960. var defaultFilterData = {
  16961. assignee: $rootScope.user.id,
  16962. searchType: "todo",
  16963. idx: 0,
  16964. sum: mun,
  16965. };
  16966. var defaultFilterData1 = {
  16967. // "searchType": "todo",
  16968. idx: 0,
  16969. sum: mun,
  16970. };
  16971. //搜索
  16972. $scope.chiceIncident = function (parameters, item, stateid) {
  16973. console.log(item, stateid);
  16974. console.log($scope);
  16975. if ($scope.title == "关联资产编号") {
  16976. // alert('222222222222');
  16977. var fildata = defaultFilterData1;
  16978. $scope.gridOptions.paginationCurrentPage = 1;
  16979. var transitiondata = angular.copy(item);
  16980. angular.extend(fildata, transitiondata);
  16981. if (fildata.hw_state) {
  16982. fildata.hw_state = fildata.hw_state.name;
  16983. }
  16984. if (fildata.sign) {
  16985. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16986. fildata.sign = fildata.sign.split(";");
  16987. fildata.sign = fildata.sign.join("");
  16988. fildata.sign = fildata.sign.toLowerCase();
  16989. }
  16990. if (fildata.keys) {
  16991. fildata["searchCriteria"] = "uuid";
  16992. }
  16993. console.log(fildata);
  16994. $scope.loadData(fildata);
  16995. }
  16996. if ($scope.title == "关联事件工单") {
  16997. // alert('3333333333333333')
  16998. if (stateid && stateid.code) {
  16999. item.statusId = stateid.code;
  17000. }
  17001. var fildata = defaultFilterData;
  17002. // $scope.memoryfilterData = fildata;
  17003. if (!fildata.incident) {
  17004. fildata["incident"] = {};
  17005. }
  17006. $scope.gridOptions.paginationCurrentPage = 1;
  17007. var transitiondata = angular.copy(item);
  17008. angular.extend(fildata.incident, transitiondata);
  17009. console.log(fildata);
  17010. // $scope.loadData(fildata);
  17011. api_bpm_data
  17012. .fetchDataList("incident", fildata)
  17013. .then(function (data) {
  17014. console.log(data);
  17015. if (data) {
  17016. $scope.myData = data.list;
  17017. $scope.gridOptions.totalItems = data.totalNum;
  17018. }
  17019. });
  17020. }
  17021. };
  17022. //重置
  17023. $scope.replacement = function (
  17024. parameters,
  17025. searchkeys,
  17026. othcode
  17027. ) {
  17028. // console.log(parameters, searchkeys, othcode);
  17029. delete defaultFilterData.incident;
  17030. console.log(defaultFilterData);
  17031. $scope.parameters = null;
  17032. $scope.searchkeys = {};
  17033. $scope.othcode = {};
  17034. $scope.wt_zcfl();
  17035. };
  17036. $scope.loadData = function (filterData) {
  17037. items
  17038. .fetchItems(filterData, APIService, $rootScope)
  17039. .then(function (data) {
  17040. var myData = Restangular.stripRestangular(data);
  17041. if (myData.data && myData.data.node) {
  17042. $scope.gridOptions.totalItems = myData.total;
  17043. $scope.myData = myData.data.node;
  17044. } else {
  17045. if (myData.resultCount) {
  17046. $scope.gridOptions["totalItems"] = myData.resultCount;
  17047. } else {
  17048. $scope.gridOptions.totalItems = myData.totalNum;
  17049. }
  17050. if (myData.list) {
  17051. $scope.myData = myData.list;
  17052. } else {
  17053. $scope.myData = myData.data;
  17054. }
  17055. }
  17056. });
  17057. };
  17058. $scope.title = title;
  17059. $scope.loadData({
  17060. idx: 0,
  17061. sum: 10,
  17062. });
  17063. $scope.selected = {
  17064. item: {},
  17065. };
  17066. $scope.ok = function () {
  17067. //console.log($scope.selected.item);
  17068. $modalInstance.close($scope.selected.item);
  17069. };
  17070. $scope.cancel = function () {
  17071. $modalInstance.dismiss("cancel");
  17072. };
  17073. },
  17074. size: size,
  17075. resolve: {
  17076. items: function () {
  17077. return {
  17078. fetchItems: function (filterData, APIService, $rootScope) {
  17079. filterData = filterData || {};
  17080. // if(!filterData.idx){
  17081. if (
  17082. angular.isDefined(filterData.idx) &&
  17083. filterData.idx == null
  17084. ) {
  17085. filterData = {
  17086. idx: 0,
  17087. sum: 10,
  17088. };
  17089. }
  17090. return options.templateOptions.fetchItems(
  17091. filterData,
  17092. APIService,
  17093. $rootScope
  17094. );
  17095. },
  17096. columnDefs: function () {
  17097. return options.templateOptions.columnDefs;
  17098. },
  17099. };
  17100. },
  17101. title: function () {
  17102. return options.templateOptions.modalTitle;
  17103. },
  17104. Restangular: function () {
  17105. return options.templateOptions.Restangular;
  17106. },
  17107. APIService: function () {
  17108. return options.templateOptions.ApiService;
  17109. },
  17110. },
  17111. });
  17112. modalInstance.result.then(
  17113. function (selectedItem) {
  17114. var selectitem = {
  17115. title: selectedItem.title,
  17116. description: selectedItem.description,
  17117. };
  17118. if (options.key == "chuku") {
  17119. if (selectedItem.assets) {
  17120. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  17121. selectedItem.assets;
  17122. }
  17123. if (selectedItem.consumables) {
  17124. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  17125. selectedItem.consumables;
  17126. }
  17127. angular.extend(
  17128. $scope.$parent.$parent.$parent.model,
  17129. selectitem
  17130. );
  17131. options.value(selectedItem);
  17132. // options.model.consumables = JSON.parse(consumables);
  17133. } else if (options.templateOptions.pkey == "change") {
  17134. console.log(options);
  17135. angular.extend(options.model);
  17136. options.value(selectedItem);
  17137. } else if (options.key == "cmdbCode") {
  17138. var zc_selectitem = selectedItem.uuid;
  17139. // angular.extend(options.model,zc_selectitem);
  17140. options.model.cmdbCode = zc_selectitem;
  17141. // angular.extend(options.model,zc_selectitem);
  17142. // options.templateOptions.displayName=zc_selectitem;
  17143. options.value(selectedItem);
  17144. console.log(options.model);
  17145. } else {
  17146. angular.extend(options.model, selectitem);
  17147. options.value(selectedItem);
  17148. }
  17149. },
  17150. function () {
  17151. //console.log('Modal dismissed at: ' + new Date());
  17152. }
  17153. );
  17154. },
  17155. },
  17156. };
  17157. },
  17158. });
  17159. //选项选择控件
  17160. formlyConfigProvider.setType({
  17161. name: "ui-modelselect",
  17162. extends: "input",
  17163. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  17164. defaultOptions: function (options) {
  17165. return {
  17166. templateOptions: {
  17167. openModal: function (size, options, modal) {
  17168. var modalInstance = modal.open({
  17169. templateUrl:
  17170. "assets/views/customform/tpl/checktable-modal-content.html",
  17171. controller: function (
  17172. $scope,
  17173. $modalInstance,
  17174. items,
  17175. title,
  17176. Restangular,
  17177. APIService,
  17178. i18nService
  17179. ) {
  17180. $scope.langs = i18nService.getAllLangs();
  17181. $scope.lang = "zh-cn";
  17182. i18nService.setCurrentLang($scope.lang);
  17183. $scope.gridOptions = {};
  17184. $scope.gridOptions.data = "myData";
  17185. $scope.gridOptions.enableColumnResizing = true;
  17186. $scope.gridOptions.enableFiltering = true;
  17187. $scope.gridOptions.enableGridMenu = false;
  17188. $scope.gridOptions.enableRowSelection = true;
  17189. $scope.gridOptions.showGridFooter = true;
  17190. $scope.gridOptions.showColumnFooter = true;
  17191. $scope.gridOptions.fastWatch = true;
  17192. $scope.gridOptions.useExternalFiltering = true;
  17193. $scope.gridOptions.useExternalPagination = true;
  17194. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  17195. $scope.gridOptions.paginationPageSize = 10;
  17196. $scope.gridOptions.multiSelect = false;
  17197. $scope.gridOptions.rowIdentity = function (row) {
  17198. return row.id;
  17199. };
  17200. $scope.gridOptions.getRowIdentity = function (row) {
  17201. return row.id;
  17202. };
  17203. $scope.gridOptions.columnDefs = items.columnDefs();
  17204. $scope.gridOptions.onRegisterApi = function (gridApi) {
  17205. $scope.gridApi = gridApi;
  17206. gridApi.pagination.on.paginationChanged(
  17207. $scope,
  17208. function (newPage, pageSize) {
  17209. // console.log(newPage);
  17210. // console.log(pageSize);
  17211. $scope.loadData({
  17212. idx: newPage - 1,
  17213. sum: pageSize,
  17214. });
  17215. }
  17216. );
  17217. gridApi.core.on.filterChanged($scope, function () {
  17218. var grid = this.grid;
  17219. var filtersData = {
  17220. idx: 0,
  17221. sum: 10,
  17222. };
  17223. angular.forEach(grid.columns, function (item) {
  17224. if (item.enableFiltering) {
  17225. if (
  17226. angular.isDefined(item.filters[0].term) &&
  17227. item.filters[0].term != ""
  17228. ) {
  17229. // console.log("filtersData="+JSON.stringify(filtersData))
  17230. if (angular.isUndefined(filtersData["incident"])) {
  17231. filtersData["incident"] = {};
  17232. }
  17233. filtersData["incident"][item.field] =
  17234. item.filters[0].term;
  17235. if (angular.isUndefined(filtersData["problem"])) {
  17236. filtersData["problem"] = {};
  17237. }
  17238. filtersData["problem"][item.field] =
  17239. item.filters[0].term;
  17240. if (angular.isUndefined(filtersData["change"])) {
  17241. filtersData["change"] = {};
  17242. }
  17243. filtersData["change"][item.field] =
  17244. item.filters[0].term;
  17245. if (angular.isUndefined(filtersData["release"])) {
  17246. filtersData["release"] = {};
  17247. }
  17248. filtersData["release"][item.field] =
  17249. item.filters[0].term;
  17250. }
  17251. }
  17252. });
  17253. $scope.loadData(filtersData);
  17254. });
  17255. gridApi.selection.on.rowSelectionChanged(
  17256. $scope,
  17257. function (data) {
  17258. $scope.selected.item = data.entity;
  17259. //console.log(data);
  17260. }
  17261. );
  17262. };
  17263. $scope.loadData = function (filterData) {
  17264. items
  17265. .fetchItems(filterData, APIService)
  17266. .then(function (data) {
  17267. var myData = Restangular.stripRestangular(data);
  17268. $scope.gridOptions.totalItems = myData.totalNum;
  17269. $scope.myData = myData.list;
  17270. });
  17271. };
  17272. $scope.title = title;
  17273. $scope.loadData({
  17274. idx: 0,
  17275. sum: 10,
  17276. });
  17277. $scope.selected = {
  17278. item: {},
  17279. };
  17280. $scope.ok = function () {
  17281. if ($scope.selected.item.scheduleOrder) {
  17282. $scope.selected.item.descriptionData =
  17283. "日期:" +
  17284. $scope.selected.item.watchTime +
  17285. ";" +
  17286. "班次:" +
  17287. $scope.selected.item.scheduleOrder.description +
  17288. ";" +
  17289. "值班人:" +
  17290. $scope.selected.item.scheduleOrder.users[0].name;
  17291. }
  17292. //console.log($scope.selected.item);
  17293. $modalInstance.close($scope.selected.item);
  17294. };
  17295. $scope.cancel = function () {
  17296. $modalInstance.dismiss("cancel");
  17297. };
  17298. },
  17299. size: size,
  17300. resolve: {
  17301. items: function () {
  17302. return {
  17303. fetchItems: function (filterData, APIService) {
  17304. filterData = filterData || {};
  17305. // if(!filterData.idx){
  17306. if (
  17307. angular.isDefined(filterData.idx) &&
  17308. filterData.idx == null
  17309. ) {
  17310. filterData = {
  17311. idx: 0,
  17312. sum: 10,
  17313. };
  17314. }
  17315. return options.templateOptions.fetchItems(
  17316. filterData,
  17317. APIService,
  17318. options
  17319. );
  17320. },
  17321. columnDefs: function () {
  17322. return options.templateOptions.columnDefs;
  17323. },
  17324. };
  17325. },
  17326. title: function () {
  17327. return options.templateOptions.modalTitle;
  17328. },
  17329. Restangular: function () {
  17330. return options.templateOptions.Restangular;
  17331. },
  17332. APIService: function () {
  17333. return options.templateOptions.ApiService;
  17334. },
  17335. },
  17336. });
  17337. modalInstance.result.then(
  17338. function (selectedItem) {
  17339. options.value(selectedItem);
  17340. },
  17341. function () {
  17342. //console.log('Modal dismissed at: ' + new Date());
  17343. }
  17344. );
  17345. },
  17346. },
  17347. };
  17348. },
  17349. });
  17350. formlyConfigProvider.setType({
  17351. name: "ui-requestform",
  17352. extends: "input",
  17353. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  17354. controller: [
  17355. "$scope",
  17356. function ($scope) {
  17357. setTimeout(function () {
  17358. var filterData = {
  17359. idx: 0,
  17360. sum: 5,
  17361. incident: {
  17362. requester: {
  17363. id: "",
  17364. },
  17365. },
  17366. };
  17367. $scope.options.templateOptions
  17368. .getWorkernumber(
  17369. $scope.options.templateOptions.ApiService,
  17370. filterData
  17371. )
  17372. .then(function (result) {
  17373. var modelData =
  17374. $scope.options.templateOptions.Restangular.stripRestangular(
  17375. result
  17376. );
  17377. });
  17378. }, 1000);
  17379. },
  17380. ],
  17381. });
  17382. //报修图片展示
  17383. formlyConfigProvider.setType({
  17384. name: "ui-repair-photos",
  17385. // extends: 'label',
  17386. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  17387. controller: [
  17388. "$scope",
  17389. "$rootScope",
  17390. "$modal",
  17391. "api_wechatfile",
  17392. "$stateParams",
  17393. function ($scope, $rootScope, $modal, api_wechatfile, $stateParams) {
  17394. console.log($scope);
  17395. $scope.imgs = [];
  17396. $scope.attachmentAddressSplicing = $rootScope.attachmentAddressSplicing;
  17397. if ($scope.model.wxFile) {
  17398. api_wechatfile
  17399. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  17400. .then(function (res) {
  17401. $scope.imgs = res.data;
  17402. });
  17403. }
  17404. console.log($stateParams);
  17405. if (
  17406. $stateParams &&
  17407. $stateParams.model &&
  17408. JSON.parse($stateParams.model) &&
  17409. JSON.parse($stateParams.model).model &&
  17410. JSON.parse($stateParams.model).model.flow
  17411. ) {
  17412. api_wechatfile
  17413. .listAttachment(
  17414. "wechatRequesterIncident",
  17415. JSON.parse($stateParams.model).model.flow
  17416. )
  17417. .then(function (res) {
  17418. $scope.imgs = res.data;
  17419. });
  17420. }
  17421. if ($scope.model.incident && $scope.model.incident.wxIncidentId) {
  17422. api_wechatfile
  17423. .listAttachment(
  17424. "wechatRequesterIncident",
  17425. $scope.model.incident.wxIncidentId
  17426. )
  17427. .then(function (res) {
  17428. $scope.imgs = res.data;
  17429. });
  17430. }
  17431. // if ($scope.model.flow) {
  17432. // api_wechatfile
  17433. // .listAttachment("wechatRequesterIncident", $scope.model.flow)
  17434. // .then(function (res) {
  17435. // $scope.imgs = res.data;
  17436. // });
  17437. // }
  17438. // 加载事件图片
  17439. // if($scope.model.incident){
  17440. // api_wechatfile
  17441. // .listAttachment("incident", $scope.model.incident.processInstanceId)
  17442. // .then(function (res) {
  17443. // $scope.imgs = res.data;
  17444. // });
  17445. // }
  17446. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  17447. // // setTimeout(function () {
  17448. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  17449. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  17450. // // if (modelData.status == 200) {
  17451. // // $scope.model[$scope.options.key] = modelData.data;
  17452. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  17453. // // }
  17454. // // });
  17455. // // }, 1000);
  17456. // }
  17457. $scope.preview = function (url, idx) {
  17458. var title = $scope.imgs[idx].title;
  17459. $modal.open({
  17460. backdrop: false,
  17461. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17462. controller: function ($scope, $rootScope, scope, $modalInstance) {
  17463. $scope.title = title;
  17464. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  17465. $scope.cancel = function () {
  17466. $modalInstance.dismiss("cancel");
  17467. };
  17468. },
  17469. resolve: {
  17470. scope: function () {
  17471. return $scope;
  17472. },
  17473. },
  17474. });
  17475. };
  17476. },
  17477. ],
  17478. });
  17479. //图片展示
  17480. formlyConfigProvider.setType({
  17481. name: "ui-showImgs",
  17482. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  17483. defaultOptions: function (options) {
  17484. return {
  17485. templateOptions: {
  17486. refresh: function (APIService, processInstanceId, data) {
  17487. return APIService.listAttachments(processInstanceId);
  17488. },
  17489. downloadUri: function (APIService, contentId) {
  17490. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17491. },
  17492. view: function (APIService, contentId) {
  17493. return APIService.attachmentsPreviewUrl(contentId);
  17494. },
  17495. download: function (APIService, contentId, item) {
  17496. var item = {
  17497. url: APIService.download(contentId),
  17498. headers: headers,
  17499. };
  17500. return item;
  17501. },
  17502. refreshDelay: 0,
  17503. },
  17504. };
  17505. },
  17506. controller: [
  17507. "$scope",
  17508. "$timeout",
  17509. "$modal",
  17510. "$rootScope",
  17511. "$http",
  17512. "up_down_file",
  17513. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17514. $scope.attachmentAddressSplicing = $rootScope.attachmentAddressSplicing;
  17515. var _refreshDelayPromise;
  17516. /**
  17517. * refresh
  17518. */
  17519. $scope._refresh = function (refreshAttr) {
  17520. $scope.attachments = [];
  17521. if (refreshAttr !== undefined) {
  17522. if (_refreshDelayPromise) {
  17523. $timeout.cancel(_refreshDelayPromise);
  17524. }
  17525. _refreshDelayPromise = $timeout(function () {
  17526. // 暂存附件
  17527. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17528. $scope.options.templateOptions
  17529. .refresh(
  17530. $scope.options.templateOptions.ApiService,
  17531. $scope.options.templateOptions.processInstanceId,
  17532. {
  17533. idx: 0,
  17534. sum: 1000,
  17535. }
  17536. )
  17537. .then(function (response) {
  17538. var myData =
  17539. $scope.options.templateOptions.Restangular.stripRestangular(
  17540. response
  17541. );
  17542. if (myData) {
  17543. for (var i = 0; i < myData.data.length; i++) {
  17544. $scope.attachments.push(myData.data[i]);
  17545. }
  17546. }
  17547. $scope.options.templateOptions
  17548. .refresh(
  17549. $scope.options.templateOptions.ApiService,
  17550. $scope.$parent.$parent.$parent.model.save_fileId,
  17551. {
  17552. idx: 0,
  17553. sum: 1000,
  17554. }
  17555. )
  17556. .then(function (response2) {
  17557. var myData2 =
  17558. $scope.options.templateOptions.Restangular.stripRestangular(
  17559. response2
  17560. );
  17561. if (myData2) {
  17562. for (var i = 0; i < myData2.data.length; i++) {
  17563. $scope.attachments.push(myData2.data[i]);
  17564. }
  17565. }
  17566. console.log($scope.attachments);
  17567. });
  17568. });
  17569. // 正常附件
  17570. } else {
  17571. $scope.options.templateOptions
  17572. .refresh(
  17573. $scope.options.templateOptions.ApiService,
  17574. $scope.options.templateOptions.processInstanceId,
  17575. {
  17576. idx: 0,
  17577. sum: 1000,
  17578. }
  17579. )
  17580. .then(function (response) {
  17581. var myData =
  17582. $scope.options.templateOptions.Restangular.stripRestangular(
  17583. response
  17584. );
  17585. if (myData) {
  17586. $scope.attachments = [];
  17587. $scope.imgs = [];
  17588. myData.data.forEach((e) => {
  17589. // if (
  17590. // e.suffix == "jpeg" ||
  17591. // e.suffix == "jpg" ||
  17592. // e.suffix == "svg" ||
  17593. // e.suffix == "png" ||
  17594. // e.suffix == "bmp" ||
  17595. // e.suffix == "gif" ||
  17596. // e.suffix == "tif"
  17597. // ) {
  17598. // $scope.imgs.push(e);
  17599. // }
  17600. $scope.imgs.push(e);
  17601. });
  17602. $scope.imgs = $scope.imgs;
  17603. console.log($scope.imgs);
  17604. }
  17605. });
  17606. }
  17607. }, $scope.options.templateOptions.refreshDelay);
  17608. }
  17609. };
  17610. $scope._refresh({});
  17611. // $scope.attachments = $scope.model[$scope.options.key]
  17612. // 预览
  17613. $scope.preview = function (url, idx) {
  17614. var title = $scope.imgs[idx].title;
  17615. $modal.open({
  17616. backdrop: false,
  17617. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17618. controller: function ($scope, $rootScope, scope, $modalInstance) {
  17619. $scope.title = title;
  17620. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  17621. $scope.cancel = function () {
  17622. $modalInstance.dismiss("cancel");
  17623. };
  17624. },
  17625. resolve: {
  17626. scope: function () {
  17627. return $scope;
  17628. },
  17629. },
  17630. });
  17631. };
  17632. },
  17633. ],
  17634. });
  17635. //工单/受理人控件
  17636. formlyConfigProvider.setType({
  17637. name: "ui-workernumbersign",
  17638. // extends: 'label',
  17639. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  17640. controller: [
  17641. "$scope",
  17642. function ($scope) {
  17643. // 2020年4月24日13:20:40
  17644. console.log($scope, "docu");
  17645. // 左侧事件工单区域地点填充
  17646. $scope.model.selecthouseNumber = $scope.model.place;
  17647. if (
  17648. angular.isUndefined($scope.model[$scope.options.key]) ||
  17649. $scope.model[$scope.options.key] == null
  17650. ) {
  17651. setTimeout(function () {
  17652. $scope.options.templateOptions
  17653. .getWorkernumber($scope.options.templateOptions.ApiService)
  17654. .then(function (result) {
  17655. var modelData =
  17656. $scope.options.templateOptions.Restangular.stripRestangular(
  17657. result
  17658. );
  17659. if (modelData.status == 200) {
  17660. $scope.model[$scope.options.key] = modelData.data;
  17661. $scope.options.initialValue =
  17662. $scope.model[$scope.options.key];
  17663. }
  17664. });
  17665. }, 1000);
  17666. }
  17667. if (
  17668. $scope.options.templateOptions.user &&
  17669. (angular.isUndefined($scope.model.acceptUser) ||
  17670. $scope.model.acceptUser == null)
  17671. ) {
  17672. if (angular.isFunction($scope.options.templateOptions.transform)) {
  17673. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  17674. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  17675. // }
  17676. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17677. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17678. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  17679. }
  17680. $scope.model.acceptUser = $scope.options.templateOptions.user;
  17681. // $scope.options.initialValue = $scope.model.acceptUser;
  17682. }
  17683. },
  17684. ],
  17685. });
  17686. //工单控件-only number
  17687. formlyConfigProvider.setType({
  17688. name: "ui-workernumber",
  17689. extends: "input",
  17690. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17691. controller: [
  17692. "$scope",
  17693. function ($scope) {
  17694. if (
  17695. angular.isUndefined($scope.model[$scope.options.key]) ||
  17696. $scope.model[$scope.options.key] == null
  17697. ) {
  17698. setTimeout(function () {
  17699. $scope.options.templateOptions
  17700. .getWorkernumber($scope.options.templateOptions.ApiService)
  17701. .then(function (result) {
  17702. var modelData =
  17703. $scope.options.templateOptions.Restangular.stripRestangular(
  17704. result
  17705. );
  17706. if (modelData.status == 200) {
  17707. $scope.model[$scope.options.key] = modelData.data;
  17708. $scope.options.initialValue =
  17709. $scope.model[$scope.options.key];
  17710. }
  17711. });
  17712. }, 1000);
  17713. }
  17714. },
  17715. ],
  17716. });
  17717. //cmdb工单
  17718. formlyConfigProvider.setType({
  17719. name: "ui-cmdbworkernumber",
  17720. extends: "input",
  17721. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17722. controller: [
  17723. "$scope",
  17724. function ($scope) {
  17725. if (
  17726. angular.isUndefined($scope.model[$scope.options.key]) ||
  17727. $scope.model[$scope.options.key] == null
  17728. ) {
  17729. setTimeout(function () {
  17730. $scope.options.templateOptions
  17731. .getWorkernumber(
  17732. $scope.options.templateOptions.ApiService,
  17733. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17734. .cifilter_classics.id
  17735. )
  17736. .then(function (result) {
  17737. var modelData =
  17738. $scope.options.templateOptions.Restangular.stripRestangular(
  17739. result
  17740. );
  17741. // if(modelData.status==200){
  17742. $scope.model[$scope.options.key] =
  17743. modelData[$scope.options.key];
  17744. $scope.options.initialValue = $scope.model[$scope.options.key];
  17745. // }
  17746. });
  17747. }, 1000);
  17748. }
  17749. },
  17750. ],
  17751. });
  17752. //简易上传图片组件
  17753. formlyConfigProvider.setType({
  17754. name: "ui-uploadImgs",
  17755. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17756. wrapper: ["bootstrapHasError"],
  17757. controller: [
  17758. "$scope",
  17759. "fileReader",
  17760. "$parse",
  17761. "$modal",
  17762. function ($scope, fileReader, $parse, $modal) {
  17763. $scope.imgshows = [];
  17764. $scope.uploadimgs = [];
  17765. var model = $parse("upload_img");
  17766. var modelSetter = model.assign;
  17767. var uploader = ($scope.uploader =
  17768. $scope.options.templateOptions.fileUploader);
  17769. uploader.filters.push({
  17770. name: "customFilter",
  17771. fn: function (item /*{File|FileLikeObject}*/, options) {
  17772. return this.queue.length < 10;
  17773. },
  17774. });
  17775. // 添加
  17776. $scope.change = function (event) {
  17777. var element = $(".upinp");
  17778. modelSetter($scope, element[0].files[0]);
  17779. //附件预览
  17780. $scope.imgupload = event.files[0];
  17781. getFile($scope.imgupload, $scope);
  17782. //获得预览图地址并且把file对象放入上传合集内
  17783. function getFile(imgupload, $scope) {
  17784. if (!imgupload) {
  17785. return;
  17786. }
  17787. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17788. $scope.imgshows.push(result);
  17789. var file = document.querySelector("input[type=file]").files[0];
  17790. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17791. console.log($scope.imgshows, $scope.uploadimgs);
  17792. if ($scope.imgshows.length < 3) {
  17793. $("#upup").show();
  17794. } else {
  17795. $("#upup").hide();
  17796. }
  17797. });
  17798. }
  17799. };
  17800. // 删除
  17801. $scope.uploadimg_del = function (index, imgs) {
  17802. console.log(index, imgs);
  17803. $scope.imgshows.splice(index, 1);
  17804. $scope.uploadimgs.splice(index, 1);
  17805. if ($scope.imgshows.length < 3) {
  17806. $("#upup").show();
  17807. } else {
  17808. $("#upup").hide();
  17809. }
  17810. };
  17811. // 预览
  17812. $scope.preview = function (url, idx) {
  17813. var name = $scope.uploadimgs[idx].name;
  17814. $modal.open({
  17815. backdrop: false,
  17816. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17817. controller: function ($scope, scope, $modalInstance) {
  17818. $scope.title = name;
  17819. $scope.imageurl = url;
  17820. $scope.cancel = function () {
  17821. $modalInstance.dismiss("cancel");
  17822. };
  17823. },
  17824. resolve: {
  17825. scope: function () {
  17826. return $scope;
  17827. },
  17828. },
  17829. });
  17830. };
  17831. if (uploader) {
  17832. uploader.onWhenAddingFileFailed = function (
  17833. item /*{File|FileLikeObject}*/,
  17834. filter,
  17835. options
  17836. ) {
  17837. console.info("onWhenAddingFileFailed", item, filter, options);
  17838. };
  17839. uploader.onAfterAddingFile = function (fileItem) {
  17840. console.info("onAfterAddingFile", fileItem);
  17841. };
  17842. uploader.onAfterAddingAll = function (addedFileItems) {
  17843. console.info("onAfterAddingAll", addedFileItems);
  17844. };
  17845. uploader.onBeforeUploadItem = function (item) {
  17846. console.info("onBeforeUploadItem", item);
  17847. };
  17848. uploader.onProgressItem = function (fileItem, progress) {
  17849. console.info("onProgressItem", fileItem, progress);
  17850. };
  17851. uploader.onProgressAll = function (progress) {
  17852. console.info("onProgressAll", progress);
  17853. };
  17854. uploader.onSuccessItem = function (
  17855. fileItem,
  17856. response,
  17857. status,
  17858. headers
  17859. ) {
  17860. console.info("onSuccessItem", fileItem, response, status, headers);
  17861. };
  17862. uploader.onErrorItem = function (
  17863. fileItem,
  17864. response,
  17865. status,
  17866. headers
  17867. ) {
  17868. console.info("onErrorItem", fileItem, response, status, headers);
  17869. };
  17870. uploader.onCancelItem = function (
  17871. fileItem,
  17872. response,
  17873. status,
  17874. headers
  17875. ) {
  17876. console.info("onCancelItem", fileItem, response, status, headers);
  17877. };
  17878. uploader.onCompleteItem = function (
  17879. fileItem,
  17880. response,
  17881. status,
  17882. headers
  17883. ) {
  17884. console.info("onCompleteItem", fileItem, response, status, headers);
  17885. };
  17886. uploader.onCompleteAll = function () {
  17887. console.info("onCompleteAll");
  17888. };
  17889. }
  17890. // console.log(modelSetter)
  17891. },
  17892. ],
  17893. });
  17894. //jry-上传下载一体
  17895. formlyConfigProvider.setType({
  17896. name: "ui-upDropFile",
  17897. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17898. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17899. defaultOptions: function (options) {
  17900. return {
  17901. templateOptions: {
  17902. view: function (APIService, contentId) {
  17903. return APIService.downloadAttachment(contentId);
  17904. },
  17905. // ApiService: 'api_wechatfile',
  17906. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17907. // upUrl: 'common/common/uploadAttachment',
  17908. // listAttachmentUrl: 'common/common/listAttachment',
  17909. // downUrl: 'common/common/downloadAttachment',
  17910. // bindType: 'incident',
  17911. // bindId: 2323
  17912. },
  17913. // validators: {
  17914. // required: {
  17915. // expression: function(viewValue, modelValue) {
  17916. // var value = modelValue || viewValue;
  17917. // return value.length >= 1;
  17918. // }
  17919. // }
  17920. // }
  17921. };
  17922. },
  17923. controller: [
  17924. "$scope",
  17925. "$rootScope",
  17926. "Restangular",
  17927. "up_down_file",
  17928. "$http",
  17929. "api_bpm",
  17930. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17931. console.log($scope);
  17932. $scope.showFileUp = true;
  17933. if ($scope.model.isKnowledge_detail) {
  17934. $scope.showFileUp = false;
  17935. }
  17936. if (angular.isUndefined($scope.form.dropState)) {
  17937. $scope.form.dropState = false;
  17938. }
  17939. if ($scope.model.incident) {
  17940. if ($scope.model.incident.alarm) {
  17941. console.log($scope);
  17942. if ($scope.model.incident.alarm) {
  17943. if ($scope.model.incident.alarm.alarmExtension) {
  17944. $scope.model.incident.alarm.alarmExtension =
  17945. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17946. $scope.model.incident.alarm.alarmExtension =
  17947. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17948. $scope.model.incident.description =
  17949. $scope.model.incident.alarm.alarmExtension;
  17950. console.log($scope.model.incident.description);
  17951. $scope.model.incident.description =
  17952. '"' +
  17953. "告警名称" +
  17954. '":' +
  17955. '"' +
  17956. $scope.model.incident.alarm.alarmSystem +
  17957. '",' +
  17958. '"' +
  17959. "告警状态" +
  17960. '":' +
  17961. '"' +
  17962. $scope.model.incident.alarm.alarmStatus +
  17963. '",' +
  17964. '"' +
  17965. "告警内容" +
  17966. '":' +
  17967. '"' +
  17968. $scope.model.incident.alarm.alarmContent +
  17969. '",' +
  17970. $scope.model.incident.description;
  17971. } else {
  17972. $scope.model.incident.description =
  17973. '"' +
  17974. "告警名称" +
  17975. '":' +
  17976. '"' +
  17977. $scope.model.incident.alarm.alarmSystem +
  17978. '",' +
  17979. '"' +
  17980. "告警状态" +
  17981. '":' +
  17982. '"' +
  17983. $scope.model.incident.alarm.alarmStatus +
  17984. '",' +
  17985. '"' +
  17986. "告警内容" +
  17987. '":' +
  17988. '"' +
  17989. $scope.model.incident.alarm.alarmContent +
  17990. '",';
  17991. }
  17992. $scope.model.incident.description =
  17993. $scope.model.incident.description.replace(/,/g, "\n");
  17994. console.log($scope.model.incident.description);
  17995. }
  17996. }
  17997. api_bpm
  17998. .tellCategory($scope.model.incident.category.id)
  17999. .then(function (wt_data) {
  18000. console.log(wt_data);
  18001. if (wt_data) {
  18002. $rootScope.wt_category = wt_data.data;
  18003. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  18004. $rootScope.wt_child = wt_data.child;
  18005. }
  18006. });
  18007. if ($scope.model.titleName == "接单") {
  18008. $scope.model.receive_code = "handler";
  18009. if (
  18010. $scope.model.incident.groupLeader &&
  18011. !$scope.model.incident.repeat
  18012. ) {
  18013. $scope.model.isHandlerUser = true;
  18014. }
  18015. }
  18016. if ($scope.model.titleName == "事件处理") {
  18017. console.log($scope.model.cmdbCode);
  18018. if ($scope.model.cmdbCode) {
  18019. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  18020. }
  18021. }
  18022. } else {
  18023. $rootScope.wt_category = "";
  18024. }
  18025. //附件上传数据
  18026. if ($scope.options.templateOptions.fileUploader) {
  18027. var uploader = ($scope.uploader =
  18028. $scope.options.templateOptions.fileUploader);
  18029. //$scope.options.templateOptions.uploader();
  18030. console.log(uploader);
  18031. // FILTERS
  18032. uploader.filters.push({
  18033. name: "customFilter",
  18034. fn: function (item /*{File|FileLikeObject}*/, options) {
  18035. return this.queue.length < 10;
  18036. },
  18037. });
  18038. }
  18039. var to = $scope.options.templateOptions;
  18040. // var bindType = $scope.model.bindType;
  18041. if (to.bindType == "incident") {
  18042. var bindId = $scope.model[to.bindType].processInstanceId;
  18043. } else if (to.bindType == "change") {
  18044. var bindId = $scope.model[to.bindType].processInstanceId;
  18045. } else {
  18046. var bindId = $scope.model[to.bindType].id;
  18047. }
  18048. //获取附件列表
  18049. $scope.listAttachmen = function () {
  18050. to.ApiService.listAttachment(
  18051. to.listAttachmentUrl,
  18052. to.bindType,
  18053. bindId
  18054. ).then(function (result) {
  18055. var myData = Restangular.stripRestangular(result);
  18056. // $scope.listAttachmens = myData;
  18057. $scope.attachments = myData.data;
  18058. });
  18059. };
  18060. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  18061. $scope.listAttachmen();
  18062. } else if (to.bindType && $scope.model[to.bindType].id) {
  18063. $scope.listAttachmen();
  18064. }
  18065. //附件上传
  18066. $scope.isUpfload = to.isUpfload;
  18067. $scope.dropfile = function (
  18068. APIService,
  18069. processInstanceId,
  18070. taskId,
  18071. userId
  18072. ) {
  18073. uploader.onBeforeUploadItem = function (item) {
  18074. angular.extend(item.headers, $rootScope.getSession());
  18075. item.url = to.ApiService.saveAttachments(
  18076. to.uploadUrl,
  18077. to.bindType,
  18078. bindId
  18079. ).getRequestedUrl();
  18080. item.formData.push({
  18081. filename: item.file.name,
  18082. });
  18083. };
  18084. uploader.uploadAll();
  18085. };
  18086. //附件下载
  18087. $scope.download = function (token, filename) {
  18088. var downUrl = to.ApiService.downloadAttachment(
  18089. to.downUrl,
  18090. token
  18091. ).getRequestedUrl();
  18092. // window.open(downUrl);
  18093. var a = document.createElement("a");
  18094. a.href = downUrl;
  18095. a.target = "_blank";
  18096. a.download = filename;
  18097. document.body.appendChild(a);
  18098. a.click();
  18099. };
  18100. //附件预览
  18101. $scope.view = function (id, previewUrl) {
  18102. if (previewUrl) {
  18103. window.open(previewUrl);
  18104. }
  18105. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  18106. // if (response.state == 200) {
  18107. // window.open(response.previewUrl);
  18108. // }
  18109. // })
  18110. };
  18111. // CALLBACKS
  18112. if (uploader) {
  18113. uploader.onWhenAddingFileFailed = function (
  18114. item /*{File|FileLikeObject}*/,
  18115. filter,
  18116. options
  18117. ) {
  18118. console.info("onWhenAddingFileFailed", item, filter, options);
  18119. };
  18120. uploader.onAfterAddingFile = function (fileItem) {
  18121. console.info("onAfterAddingFile", fileItem);
  18122. };
  18123. uploader.onAfterAddingAll = function (addedFileItems) {
  18124. console.info("onAfterAddingAll", addedFileItems);
  18125. };
  18126. uploader.onBeforeUploadItem = function (item) {
  18127. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18128. // // $scope.uploader.options.url();
  18129. // $scope.uploader.onBeforeUploadItem = function(item) {
  18130. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18131. // console.info('onBeforeUploadItem', item);
  18132. // };
  18133. // $scope.uploader.uploadAll();
  18134. // }
  18135. console.info("onBeforeUploadItem", item);
  18136. };
  18137. uploader.onProgressItem = function (fileItem, progress) {
  18138. console.info("onProgressItem", fileItem, progress);
  18139. };
  18140. uploader.onProgressAll = function (progress) {
  18141. console.info("onProgressAll", progress);
  18142. };
  18143. uploader.onSuccessItem = function (
  18144. fileItem,
  18145. response,
  18146. status,
  18147. headers
  18148. ) {
  18149. console.info("onSuccessItem", fileItem, response, status, headers);
  18150. if (response.status == 200) {
  18151. $scope.listAttachmen();
  18152. }
  18153. };
  18154. uploader.onErrorItem = function (
  18155. fileItem,
  18156. response,
  18157. status,
  18158. headers
  18159. ) {
  18160. console.info("onErrorItem", fileItem, response, status, headers);
  18161. };
  18162. uploader.onCancelItem = function (
  18163. fileItem,
  18164. response,
  18165. status,
  18166. headers
  18167. ) {
  18168. console.info("onCancelItem", fileItem, response, status, headers);
  18169. };
  18170. uploader.onCompleteItem = function (
  18171. fileItem,
  18172. response,
  18173. status,
  18174. headers
  18175. ) {
  18176. console.info("onCompleteItem", fileItem, response, status, headers);
  18177. };
  18178. uploader.onCompleteAll = function () {
  18179. console.info("onCompleteAll");
  18180. };
  18181. }
  18182. },
  18183. ],
  18184. });
  18185. //简易上传下载附件组件
  18186. formlyConfigProvider.setType({
  18187. name: "ui-upDownFiles",
  18188. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  18189. wrapper: ["bootstrapHasError"],
  18190. defaultOptions: function (options) {
  18191. return {
  18192. templateOptions: {
  18193. refresh: function (APIService, processInstanceId, data) {
  18194. return APIService.listAttachments(processInstanceId);
  18195. },
  18196. downloadUri: function (APIService, contentId) {
  18197. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18198. },
  18199. view: function (APIService, contentId) {
  18200. return APIService.attachmentsPreviewUrl(contentId);
  18201. },
  18202. download: function (APIService, contentId, item) {
  18203. var item = {
  18204. url: APIService.download(contentId),
  18205. headers: headers,
  18206. };
  18207. return item;
  18208. },
  18209. refreshDelay: 0,
  18210. },
  18211. };
  18212. },
  18213. controller: [
  18214. "$scope",
  18215. "$timeout",
  18216. "$modal",
  18217. "$rootScope",
  18218. "$http",
  18219. "up_down_file",
  18220. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18221. if (angular.isUndefined($scope.form.dropState)) {
  18222. $scope.form.dropState = false;
  18223. }
  18224. //附件上传数据
  18225. var uploader = ($scope.uploader =
  18226. $scope.options.templateOptions.fileUploader);
  18227. //$scope.options.templateOptions.uploader();
  18228. // FILTERS
  18229. uploader.filters.push({
  18230. name: "customFilter",
  18231. fn: function (item /*{File|FileLikeObject}*/, options) {
  18232. return this.queue.length < 10;
  18233. },
  18234. });
  18235. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  18236. // uploader.onBeforeUploadItem = function (item) {
  18237. // angular.extend(item.headers, $rootScope.getSession());
  18238. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  18239. // item.formData.push({
  18240. // 'fileName': item.file.name
  18241. // });
  18242. // console.info('onBeforeUploadItem', item);
  18243. // };
  18244. // }
  18245. // CALLBACKS
  18246. uploader.onWhenAddingFileFailed = function (
  18247. item /*{File|FileLikeObject}*/,
  18248. filter,
  18249. options
  18250. ) {
  18251. console.info("onWhenAddingFileFailed", item, filter, options);
  18252. };
  18253. uploader.onAfterAddingFile = function (fileItem) {
  18254. console.info("onAfterAddingFile", fileItem);
  18255. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18256. alert("文件过大");
  18257. fileItem.uploader.queue.pop();
  18258. console.log($scope);
  18259. }
  18260. };
  18261. uploader.onAfterAddingAll = function (addedFileItems) {
  18262. // console.info('onAfterAddingAll', addedFileItems);
  18263. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18264. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18265. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18266. // console.log(123)
  18267. };
  18268. uploader.onBeforeUploadItem = function (item) {
  18269. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18270. // // $scope.uploader.options.url();
  18271. // $scope.uploader.onBeforeUploadItem = function(item) {
  18272. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18273. // console.info('onBeforeUploadItem', item);
  18274. // };
  18275. // $scope.uploader.uploadAll();
  18276. // }
  18277. console.info("onBeforeUploadItem", item);
  18278. };
  18279. uploader.onProgressItem = function (fileItem, progress) {
  18280. console.info("onProgressItem", fileItem, progress);
  18281. };
  18282. uploader.onProgressAll = function (progress) {
  18283. console.info("onProgressAll", progress);
  18284. };
  18285. uploader.onSuccessItem = function (
  18286. fileItem,
  18287. response,
  18288. status,
  18289. headers
  18290. ) {
  18291. console.info("onSuccessItem", fileItem, response, status, headers);
  18292. };
  18293. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18294. console.info("onErrorItem", fileItem, response, status, headers);
  18295. };
  18296. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18297. console.info("onCancelItem", fileItem, response, status, headers);
  18298. };
  18299. uploader.onCompleteItem = function (
  18300. fileItem,
  18301. response,
  18302. status,
  18303. headers
  18304. ) {
  18305. console.info("onCompleteItem", fileItem, response, status, headers);
  18306. };
  18307. uploader.onCompleteAll = function () {
  18308. console.info("onCompleteAll");
  18309. };
  18310. var _refreshDelayPromise;
  18311. // 下载
  18312. $scope.download = function (contentId, filename, token) {
  18313. // console.log(contentId, filename, token)
  18314. //附件下载
  18315. var downUrl = up_down_file
  18316. .downloadAttachment("common/common/downloadAttachment", token)
  18317. .getRequestedUrl();
  18318. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18319. // console.log(downUrl)
  18320. var a = document.createElement("a");
  18321. a.href = downUrl;
  18322. a.target = "_blank";
  18323. a.download = filename;
  18324. document.body.appendChild(a);
  18325. a.click();
  18326. };
  18327. $scope._refresh = function (refreshAttr) {
  18328. $scope.attachments = [];
  18329. if (refreshAttr !== undefined) {
  18330. if (_refreshDelayPromise) {
  18331. $timeout.cancel(_refreshDelayPromise);
  18332. }
  18333. _refreshDelayPromise = $timeout(function () {
  18334. // 暂存附件
  18335. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18336. $scope.options.templateOptions
  18337. .refresh(
  18338. $scope.options.templateOptions.ApiService,
  18339. $scope.options.templateOptions.processInstanceId,
  18340. {
  18341. idx: 0,
  18342. sum: 1000,
  18343. }
  18344. )
  18345. .then(function (response) {
  18346. var myData =
  18347. $scope.options.templateOptions.Restangular.stripRestangular(
  18348. response
  18349. );
  18350. if (myData) {
  18351. for (var i = 0; i < myData.data.length; i++) {
  18352. $scope.attachments.push(myData.data[i]);
  18353. }
  18354. }
  18355. $scope.options.templateOptions
  18356. .refresh(
  18357. $scope.options.templateOptions.ApiService,
  18358. $scope.$parent.$parent.$parent.model.save_fileId,
  18359. {
  18360. idx: 0,
  18361. sum: 1000,
  18362. }
  18363. )
  18364. .then(function (response2) {
  18365. var myData2 =
  18366. $scope.options.templateOptions.Restangular.stripRestangular(
  18367. response2
  18368. );
  18369. if (myData2) {
  18370. for (var i = 0; i < myData2.data.length; i++) {
  18371. $scope.attachments.push(myData2.data[i]);
  18372. }
  18373. // 只展示除图片以外的附件
  18374. var a = [];
  18375. $scope.attachments.forEach((e) => {
  18376. if (
  18377. e.suffix == "jpeg" ||
  18378. e.suffix == "jpg" ||
  18379. e.suffix == "svg" ||
  18380. e.suffix == "png" ||
  18381. e.suffix == "bmp" ||
  18382. e.suffix == "gif" ||
  18383. e.suffix == "tif"
  18384. ) {
  18385. // $scope.imgs.push(e)
  18386. } else {
  18387. a.push(e);
  18388. }
  18389. });
  18390. $scope.attachments = a;
  18391. }
  18392. console.log($scope.attachments);
  18393. });
  18394. });
  18395. // 正常附件
  18396. } else {
  18397. $scope.options.templateOptions
  18398. .refresh(
  18399. $scope.options.templateOptions.ApiService,
  18400. $scope.options.templateOptions.processInstanceId,
  18401. {
  18402. idx: 0,
  18403. sum: 1000,
  18404. }
  18405. )
  18406. .then(function (response) {
  18407. var myData =
  18408. $scope.options.templateOptions.Restangular.stripRestangular(
  18409. response
  18410. );
  18411. if (myData) {
  18412. $scope.attachments = myData.data;
  18413. // 只展示除图片以外的附件
  18414. var a = [];
  18415. $scope.attachments.forEach((e) => {
  18416. if (
  18417. e.suffix == "jpeg" ||
  18418. e.suffix == "jpg" ||
  18419. e.suffix == "svg" ||
  18420. e.suffix == "png" ||
  18421. e.suffix == "bmp" ||
  18422. e.suffix == "gif" ||
  18423. e.suffix == "tif"
  18424. ) {
  18425. // $scope.imgs.push(e)
  18426. } else {
  18427. a.push(e);
  18428. }
  18429. });
  18430. $scope.attachments = a;
  18431. }
  18432. });
  18433. }
  18434. }, $scope.options.templateOptions.refreshDelay);
  18435. }
  18436. };
  18437. $scope._refresh({});
  18438. },
  18439. ],
  18440. });
  18441. //简易上传附件组件
  18442. formlyConfigProvider.setType({
  18443. name: "ui-uploadFiles",
  18444. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  18445. wrapper: ["bootstrapHasError"],
  18446. controller: [
  18447. "$scope",
  18448. function ($scope) {
  18449. if (angular.isUndefined($scope.form.dropState)) {
  18450. $scope.form.dropState = false;
  18451. }
  18452. //附件上传数据
  18453. var uploader = ($scope.uploader =
  18454. $scope.options.templateOptions.fileUploader);
  18455. //$scope.options.templateOptions.uploader();
  18456. // FILTERS
  18457. uploader.filters.push({
  18458. name: "customFilter",
  18459. fn: function (item /*{File|FileLikeObject}*/, options) {
  18460. return this.queue.length < 10;
  18461. },
  18462. });
  18463. $scope.dropfile = function (
  18464. APIService,
  18465. processInstanceId,
  18466. taskId,
  18467. userId
  18468. ) {
  18469. uploader.onBeforeUploadItem = function (item) {
  18470. angular.extend(item.headers, $rootScope.getSession());
  18471. item.url = APIService.saveAttachments(
  18472. processInstanceId,
  18473. taskId,
  18474. userId
  18475. ).getRequestedUrl();
  18476. item.formData.push({
  18477. fileName: item.file.name,
  18478. });
  18479. console.info("onBeforeUploadItem", item);
  18480. };
  18481. };
  18482. // CALLBACKS
  18483. uploader.onWhenAddingFileFailed = function (
  18484. item /*{File|FileLikeObject}*/,
  18485. filter,
  18486. options
  18487. ) {
  18488. console.info("onWhenAddingFileFailed", item, filter, options);
  18489. };
  18490. uploader.onAfterAddingFile = function (fileItem) {
  18491. console.info("onAfterAddingFile", fileItem);
  18492. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18493. alert("文件过大");
  18494. fileItem.uploader.queue.pop();
  18495. console.log($scope);
  18496. }
  18497. };
  18498. uploader.onAfterAddingAll = function (addedFileItems) {
  18499. // console.info('onAfterAddingAll', addedFileItems);
  18500. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18501. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18502. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18503. // console.log(123)
  18504. };
  18505. uploader.onBeforeUploadItem = function (item) {
  18506. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18507. // // $scope.uploader.options.url();
  18508. // $scope.uploader.onBeforeUploadItem = function(item) {
  18509. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18510. // console.info('onBeforeUploadItem', item);
  18511. // };
  18512. // $scope.uploader.uploadAll();
  18513. // }
  18514. console.info("onBeforeUploadItem", item);
  18515. };
  18516. uploader.onProgressItem = function (fileItem, progress) {
  18517. console.info("onProgressItem", fileItem, progress);
  18518. };
  18519. uploader.onProgressAll = function (progress) {
  18520. console.info("onProgressAll", progress);
  18521. };
  18522. uploader.onSuccessItem = function (
  18523. fileItem,
  18524. response,
  18525. status,
  18526. headers
  18527. ) {
  18528. console.info("onSuccessItem", fileItem, response, status, headers);
  18529. };
  18530. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18531. console.info("onErrorItem", fileItem, response, status, headers);
  18532. };
  18533. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18534. console.info("onCancelItem", fileItem, response, status, headers);
  18535. };
  18536. uploader.onCompleteItem = function (
  18537. fileItem,
  18538. response,
  18539. status,
  18540. headers
  18541. ) {
  18542. console.info("onCompleteItem", fileItem, response, status, headers);
  18543. };
  18544. uploader.onCompleteAll = function () {
  18545. console.info("onCompleteAll");
  18546. };
  18547. },
  18548. ],
  18549. });
  18550. //无上传按钮附件上传组件
  18551. formlyConfigProvider.setType({
  18552. name: "ui-dropfilenotup",
  18553. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18554. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18555. controller: [
  18556. "$scope",
  18557. function ($scope) {
  18558. if (angular.isUndefined($scope.form.dropState)) {
  18559. $scope.form.dropState = false;
  18560. }
  18561. //附件上传数据
  18562. var uploader = ($scope.uploader =
  18563. $scope.options.templateOptions.fileUploader);
  18564. //$scope.options.templateOptions.uploader();
  18565. // FILTERS
  18566. uploader.filters.push({
  18567. name: "customFilter",
  18568. fn: function (item /*{File|FileLikeObject}*/, options) {
  18569. return this.queue.length < 10;
  18570. },
  18571. });
  18572. $scope.dropfile = function (
  18573. APIService,
  18574. processInstanceId,
  18575. taskId,
  18576. userId
  18577. ) {
  18578. uploader.onBeforeUploadItem = function (item) {
  18579. angular.extend(item.headers, $rootScope.getSession());
  18580. item.url = APIService.saveAttachments(
  18581. processInstanceId,
  18582. taskId,
  18583. userId
  18584. ).getRequestedUrl();
  18585. item.formData.push({
  18586. fileName: item.file.name,
  18587. });
  18588. console.info("onBeforeUploadItem", item);
  18589. };
  18590. uploader.uploadAll();
  18591. };
  18592. // CALLBACKS
  18593. uploader.onWhenAddingFileFailed = function (
  18594. item /*{File|FileLikeObject}*/,
  18595. filter,
  18596. options
  18597. ) {
  18598. console.info("onWhenAddingFileFailed", item, filter, options);
  18599. };
  18600. uploader.onAfterAddingFile = function (fileItem) {
  18601. console.info("onAfterAddingFile", fileItem);
  18602. };
  18603. uploader.onAfterAddingAll = function (addedFileItems) {
  18604. console.info("onAfterAddingAll", addedFileItems);
  18605. };
  18606. uploader.onBeforeUploadItem = function (item) {
  18607. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18608. // // $scope.uploader.options.url();
  18609. // $scope.uploader.onBeforeUploadItem = function(item) {
  18610. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18611. // console.info('onBeforeUploadItem', item);
  18612. // };
  18613. // $scope.uploader.uploadAll();
  18614. // }
  18615. console.info("onBeforeUploadItem", item);
  18616. };
  18617. uploader.onProgressItem = function (fileItem, progress) {
  18618. console.info("onProgressItem", fileItem, progress);
  18619. };
  18620. uploader.onProgressAll = function (progress) {
  18621. console.info("onProgressAll", progress);
  18622. };
  18623. uploader.onSuccessItem = function (
  18624. fileItem,
  18625. response,
  18626. status,
  18627. headers
  18628. ) {
  18629. console.info("onSuccessItem", fileItem, response, status, headers);
  18630. };
  18631. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18632. console.info("onErrorItem", fileItem, response, status, headers);
  18633. };
  18634. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18635. console.info("onCancelItem", fileItem, response, status, headers);
  18636. };
  18637. uploader.onCompleteItem = function (
  18638. fileItem,
  18639. response,
  18640. status,
  18641. headers
  18642. ) {
  18643. console.info("onCompleteItem", fileItem, response, status, headers);
  18644. };
  18645. uploader.onCompleteAll = function () {
  18646. console.info("onCompleteAll");
  18647. };
  18648. },
  18649. ],
  18650. });
  18651. //无按钮知识库上传
  18652. formlyConfigProvider.setType({
  18653. name: "ui-dropfielkn",
  18654. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18655. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18656. controller: [
  18657. "$scope",
  18658. function ($scope) {
  18659. if (angular.isUndefined($scope.form.dropState)) {
  18660. $scope.form.dropState = false;
  18661. }
  18662. //附件上传数据
  18663. var uploader = ($scope.uploader =
  18664. $scope.options.templateOptions.fileUploader);
  18665. //$scope.options.templateOptions.uploader();
  18666. // FILTERS
  18667. uploader.filters.push({
  18668. name: "customFilter",
  18669. fn: function (item /*{File|FileLikeObject}*/, options) {
  18670. return this.queue.length < 10;
  18671. },
  18672. });
  18673. $scope.dropfile = function (
  18674. APIService,
  18675. processInstanceId,
  18676. taskId,
  18677. userId
  18678. ) {
  18679. uploader.onBeforeUploadItem = function (item) {
  18680. angular.extend(item.headers, $rootScope.getSession());
  18681. item.url = APIService.addFile(
  18682. processInstanceId,
  18683. taskId,
  18684. userId
  18685. ).getRequestedUrl();
  18686. item.formData.push({
  18687. fileName: item.file.name,
  18688. });
  18689. console.info("onBeforeUploadItem", item);
  18690. };
  18691. uploader.uploadAll();
  18692. };
  18693. // CALLBACKS
  18694. uploader.onWhenAddingFileFailed = function (
  18695. item /*{File|FileLikeObject}*/,
  18696. filter,
  18697. options
  18698. ) {
  18699. console.info("onWhenAddingFileFailed", item, filter, options);
  18700. };
  18701. uploader.onAfterAddingFile = function (fileItem) {
  18702. console.info("onAfterAddingFile", fileItem);
  18703. };
  18704. uploader.onAfterAddingAll = function (addedFileItems) {
  18705. console.info("onAfterAddingAll", addedFileItems);
  18706. };
  18707. uploader.onBeforeUploadItem = function (item) {
  18708. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18709. // // $scope.uploader.options.url();
  18710. // $scope.uploader.onBeforeUploadItem = function(item) {
  18711. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18712. // console.info('onBeforeUploadItem', item);
  18713. // };
  18714. // $scope.uploader.uploadAll();
  18715. // }
  18716. console.info("onBeforeUploadItem", item);
  18717. };
  18718. uploader.onProgressItem = function (fileItem, progress) {
  18719. console.info("onProgressItem", fileItem, progress);
  18720. };
  18721. uploader.onProgressAll = function (progress) {
  18722. console.info("onProgressAll", progress);
  18723. };
  18724. uploader.onSuccessItem = function (
  18725. fileItem,
  18726. response,
  18727. status,
  18728. headers
  18729. ) {
  18730. console.info("onSuccessItem", fileItem, response, status, headers);
  18731. };
  18732. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18733. console.info("onErrorItem", fileItem, response, status, headers);
  18734. };
  18735. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18736. console.info("onCancelItem", fileItem, response, status, headers);
  18737. };
  18738. uploader.onCompleteItem = function (
  18739. fileItem,
  18740. response,
  18741. status,
  18742. headers
  18743. ) {
  18744. console.info("onCompleteItem", fileItem, response, status, headers);
  18745. };
  18746. uploader.onCompleteAll = function () {
  18747. console.info("onCompleteAll");
  18748. };
  18749. },
  18750. ],
  18751. });
  18752. //附件上传列表组件
  18753. formlyConfigProvider.setType({
  18754. name: "ui-dropfile",
  18755. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18756. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18757. controller: [
  18758. "$scope",
  18759. "$rootScope",
  18760. function ($scope, $rootScope) {
  18761. if (angular.isUndefined($scope.form.dropState)) {
  18762. $scope.form.dropState = false;
  18763. }
  18764. //附件上传数据
  18765. var uploader = ($scope.uploader =
  18766. $scope.options.templateOptions.fileUploader);
  18767. //$scope.options.templateOptions.uploader();
  18768. // FILTERS
  18769. uploader.filters.push({
  18770. name: "customFilter",
  18771. fn: function (item /*{File|FileLikeObject}*/, options) {
  18772. return this.queue.length < 10;
  18773. },
  18774. });
  18775. $scope.dropfile = function (
  18776. APIService,
  18777. processInstanceId,
  18778. taskId,
  18779. userId
  18780. ) {
  18781. uploader.onBeforeUploadItem = function (item) {
  18782. angular.extend(item.headers, $rootScope.getSession());
  18783. if (
  18784. $scope.options.templateOptions.upservice &&
  18785. $scope.options.templateOptions.formname
  18786. ) {
  18787. // if ($scope.options.templateOptions.formket) {
  18788. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18789. // } else {
  18790. item.url = APIService[$scope.options.templateOptions.upservice](
  18791. $scope.model[$scope.options.templateOptions.formname].id,
  18792. taskId,
  18793. userId
  18794. ).getRequestedUrl();
  18795. // }
  18796. } else {
  18797. item.url = APIService.saveAttachments(
  18798. processInstanceId,
  18799. taskId,
  18800. userId
  18801. ).getRequestedUrl();
  18802. }
  18803. item.formData.push({
  18804. filename: item.file.name,
  18805. });
  18806. console.info("onBeforeUploadItem", item);
  18807. };
  18808. uploader.uploadAll();
  18809. };
  18810. // CALLBACKS
  18811. uploader.onWhenAddingFileFailed = function (
  18812. item /*{File|FileLikeObject}*/,
  18813. filter,
  18814. options
  18815. ) {
  18816. console.info("onWhenAddingFileFailed", item, filter, options);
  18817. };
  18818. uploader.onAfterAddingFile = function (fileItem) {
  18819. console.info("onAfterAddingFile", fileItem);
  18820. };
  18821. uploader.onAfterAddingAll = function (addedFileItems) {
  18822. console.info("onAfterAddingAll", addedFileItems);
  18823. };
  18824. uploader.onBeforeUploadItem = function (item) {
  18825. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18826. // // $scope.uploader.options.url();
  18827. // $scope.uploader.onBeforeUploadItem = function(item) {
  18828. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18829. // console.info('onBeforeUploadItem', item);
  18830. // };
  18831. // $scope.uploader.uploadAll();
  18832. // }
  18833. console.info("onBeforeUploadItem", item);
  18834. };
  18835. uploader.onProgressItem = function (fileItem, progress) {
  18836. console.info("onProgressItem", fileItem, progress);
  18837. };
  18838. uploader.onProgressAll = function (progress) {
  18839. console.info("onProgressAll", progress);
  18840. };
  18841. uploader.onSuccessItem = function (
  18842. fileItem,
  18843. response,
  18844. status,
  18845. headers
  18846. ) {
  18847. console.info("onSuccessItem", fileItem, response, status, headers);
  18848. };
  18849. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18850. console.info("onErrorItem", fileItem, response, status, headers);
  18851. };
  18852. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18853. console.info("onCancelItem", fileItem, response, status, headers);
  18854. };
  18855. uploader.onCompleteItem = function (
  18856. fileItem,
  18857. response,
  18858. status,
  18859. headers
  18860. ) {
  18861. console.info("onCompleteItem", fileItem, response, status, headers);
  18862. };
  18863. uploader.onCompleteAll = function () {
  18864. console.info("onCompleteAll");
  18865. };
  18866. },
  18867. ],
  18868. });
  18869. //简易附件展示下载列表组件
  18870. formlyConfigProvider.setType({
  18871. name: "ui-dropFiles",
  18872. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18873. defaultOptions: function (options) {
  18874. return {
  18875. templateOptions: {
  18876. refresh: function (APIService, processInstanceId, data) {
  18877. return APIService.listAttachments(processInstanceId);
  18878. },
  18879. downloadUri: function (APIService, contentId) {
  18880. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18881. },
  18882. view: function (APIService, contentId) {
  18883. return APIService.attachmentsPreviewUrl(contentId);
  18884. },
  18885. download: function (APIService, contentId, item) {
  18886. var item = {
  18887. url: APIService.download(contentId),
  18888. headers: headers,
  18889. };
  18890. return item;
  18891. },
  18892. refreshDelay: 0,
  18893. },
  18894. };
  18895. },
  18896. controller: [
  18897. "$scope",
  18898. "$timeout",
  18899. "$modal",
  18900. "$rootScope",
  18901. "$http",
  18902. "up_down_file",
  18903. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18904. var _refreshDelayPromise;
  18905. // $scope.downloadUrl = function(contentId){
  18906. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18907. // };
  18908. $scope.download = function (contentId, filename, token) {
  18909. // console.log(contentId, filename, token)
  18910. //附件下载
  18911. var downUrl = up_down_file
  18912. .downloadAttachment("common/common/downloadAttachment", token)
  18913. .getRequestedUrl();
  18914. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18915. // console.log(downUrl)
  18916. var a = document.createElement("a");
  18917. a.href = downUrl;
  18918. a.target = "_blank";
  18919. a.download = filename;
  18920. document.body.appendChild(a);
  18921. a.click();
  18922. };
  18923. $scope.view = function (contentId, token, filename, type) {
  18924. $scope.options.templateOptions
  18925. .view($scope.options.templateOptions.ApiService, contentId)
  18926. .then(function (response) {
  18927. if (response.state == 200) {
  18928. window.open(response.previewUrl);
  18929. }
  18930. });
  18931. };
  18932. /**
  18933. * refresh
  18934. */
  18935. $scope._refresh = function (refreshAttr) {
  18936. $scope.attachments = [];
  18937. if (refreshAttr !== undefined) {
  18938. if (_refreshDelayPromise) {
  18939. $timeout.cancel(_refreshDelayPromise);
  18940. }
  18941. _refreshDelayPromise = $timeout(function () {
  18942. // 暂存附件
  18943. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18944. $scope.options.templateOptions
  18945. .refresh(
  18946. $scope.options.templateOptions.ApiService,
  18947. $scope.options.templateOptions.processInstanceId,
  18948. {
  18949. idx: 0,
  18950. sum: 1000,
  18951. }
  18952. )
  18953. .then(function (response) {
  18954. var myData =
  18955. $scope.options.templateOptions.Restangular.stripRestangular(
  18956. response
  18957. );
  18958. if (myData) {
  18959. for (var i = 0; i < myData.data.length; i++) {
  18960. $scope.attachments.push(myData.data[i]);
  18961. }
  18962. }
  18963. $scope.options.templateOptions
  18964. .refresh(
  18965. $scope.options.templateOptions.ApiService,
  18966. $scope.$parent.$parent.$parent.model.save_fileId,
  18967. {
  18968. idx: 0,
  18969. sum: 1000,
  18970. }
  18971. )
  18972. .then(function (response2) {
  18973. var myData2 =
  18974. $scope.options.templateOptions.Restangular.stripRestangular(
  18975. response2
  18976. );
  18977. if (myData2) {
  18978. for (var i = 0; i < myData2.data.length; i++) {
  18979. $scope.attachments.push(myData2.data[i]);
  18980. }
  18981. // 只展示除图片以外的附件
  18982. var a = [];
  18983. $scope.attachments.forEach((e) => {
  18984. if (
  18985. e.suffix == "jpeg" ||
  18986. e.suffix == "jpg" ||
  18987. e.suffix == "svg" ||
  18988. e.suffix == "png" ||
  18989. e.suffix == "bmp" ||
  18990. e.suffix == "gif" ||
  18991. e.suffix == "tif"
  18992. ) {
  18993. // $scope.imgs.push(e)
  18994. } else {
  18995. a.push(e);
  18996. }
  18997. });
  18998. $scope.attachments = a;
  18999. }
  19000. console.log($scope.attachments);
  19001. });
  19002. });
  19003. // 正常附件
  19004. } else {
  19005. $scope.options.templateOptions
  19006. .refresh(
  19007. $scope.options.templateOptions.ApiService,
  19008. $scope.options.templateOptions.processInstanceId,
  19009. {
  19010. idx: 0,
  19011. sum: 1000,
  19012. }
  19013. )
  19014. .then(function (response) {
  19015. var myData =
  19016. $scope.options.templateOptions.Restangular.stripRestangular(
  19017. response
  19018. );
  19019. if (myData) {
  19020. $scope.attachments = myData.data;
  19021. // 只展示除图片以外的附件
  19022. var a = [];
  19023. $scope.attachments.forEach((e) => {
  19024. if (
  19025. e.suffix == "jpeg" ||
  19026. e.suffix == "jpg" ||
  19027. e.suffix == "svg" ||
  19028. e.suffix == "png" ||
  19029. e.suffix == "bmp" ||
  19030. e.suffix == "gif" ||
  19031. e.suffix == "tif"
  19032. ) {
  19033. // $scope.imgs.push(e)
  19034. } else {
  19035. a.push(e);
  19036. }
  19037. });
  19038. $scope.attachments = a;
  19039. console.log($scope.attachments);
  19040. }
  19041. });
  19042. }
  19043. }, $scope.options.templateOptions.refreshDelay);
  19044. }
  19045. };
  19046. $scope._refresh({});
  19047. // $scope.attachments = $scope.model[$scope.options.key]
  19048. },
  19049. ],
  19050. });
  19051. //知识库附件上传
  19052. formlyConfigProvider.setType({
  19053. name: "ui-dropfielknow",
  19054. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  19055. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  19056. controller: [
  19057. "$scope",
  19058. "$rootScope",
  19059. function ($scope, $rootScope) {
  19060. if (angular.isUndefined($scope.form.dropState)) {
  19061. $scope.form.dropState = false;
  19062. }
  19063. //附件上传数据
  19064. var uploader = ($scope.uploader =
  19065. $scope.options.templateOptions.fileUploader);
  19066. //$scope.options.templateOptions.uploader();
  19067. // FILTERS
  19068. uploader.filters.push({
  19069. name: "customFilter",
  19070. fn: function (item /*{File|FileLikeObject}*/, options) {
  19071. return this.queue.length < 10;
  19072. },
  19073. });
  19074. $scope.dropfile = function (
  19075. APIService,
  19076. processInstanceId,
  19077. taskId,
  19078. userId
  19079. ) {
  19080. uploader.onBeforeUploadItem = function (item) {
  19081. angular.extend(item.headers, $rootScope.getSession());
  19082. item.url = APIService.upload(
  19083. processInstanceId,
  19084. taskId,
  19085. userId
  19086. ).getRequestedUrl();
  19087. item.formData.push({
  19088. fileName: item.file.name,
  19089. type: "solution",
  19090. solutionId: $scope.model.knowledge.id,
  19091. });
  19092. console.info("onBeforeUploadItem", item);
  19093. };
  19094. uploader.uploadAll();
  19095. };
  19096. // CALLBACKS
  19097. uploader.onWhenAddingFileFailed = function (
  19098. item /*{File|FileLikeObject}*/,
  19099. filter,
  19100. options
  19101. ) {
  19102. console.info("onWhenAddingFileFailed", item, filter, options);
  19103. };
  19104. uploader.onAfterAddingFile = function (fileItem) {
  19105. console.info("onAfterAddingFile", fileItem);
  19106. };
  19107. uploader.onAfterAddingAll = function (addedFileItems) {
  19108. console.info("onAfterAddingAll", addedFileItems);
  19109. };
  19110. uploader.onBeforeUploadItem = function (item) {
  19111. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  19112. // // $scope.uploader.options.url();
  19113. // $scope.uploader.onBeforeUploadItem = function(item) {
  19114. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  19115. // console.info('onBeforeUploadItem', item);
  19116. // };
  19117. // $scope.uploader.uploadAll();
  19118. // }
  19119. console.info("onBeforeUploadItem", item);
  19120. };
  19121. uploader.onProgressItem = function (fileItem, progress) {
  19122. console.info("onProgressItem", fileItem, progress);
  19123. };
  19124. uploader.onProgressAll = function (progress) {
  19125. console.info("onProgressAll", progress);
  19126. };
  19127. uploader.onSuccessItem = function (
  19128. fileItem,
  19129. response,
  19130. status,
  19131. headers
  19132. ) {
  19133. console.info("onSuccessItem", fileItem, response, status, headers);
  19134. };
  19135. uploader.onErrorItem = function (fileItem, response, status, headers) {
  19136. console.info("onErrorItem", fileItem, response, status, headers);
  19137. };
  19138. uploader.onCancelItem = function (fileItem, response, status, headers) {
  19139. console.info("onCancelItem", fileItem, response, status, headers);
  19140. };
  19141. uploader.onCompleteItem = function (
  19142. fileItem,
  19143. response,
  19144. status,
  19145. headers
  19146. ) {
  19147. console.info("onCompleteItem", fileItem, response, status, headers);
  19148. };
  19149. uploader.onCompleteAll = function () {
  19150. console.info("onCompleteAll");
  19151. };
  19152. },
  19153. ],
  19154. });
  19155. //知识库附件下载列表
  19156. formlyConfigProvider.setType({
  19157. name: "ui-dropfileknowledge",
  19158. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  19159. defaultOptions: function (options) {
  19160. return {
  19161. templateOptions: {
  19162. refresh: function (APIService, contentId, data) {
  19163. return APIService.fetchDataList(contentId, data);
  19164. },
  19165. downloadUri: function (APIService, contentId) {
  19166. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19167. },
  19168. download: function (APIService, contentId) {
  19169. return APIService.getSolutionDowpath(contentId);
  19170. },
  19171. view: function (attachmentId) {
  19172. // return APIService.attachmentsPreviewUrl(contentId);
  19173. },
  19174. refreshDelay: 0,
  19175. },
  19176. };
  19177. },
  19178. controller: [
  19179. "$scope",
  19180. "$timeout",
  19181. "$modal",
  19182. "$rootScope",
  19183. "api_solution",
  19184. "$http",
  19185. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  19186. var _refreshDelayPromise;
  19187. $scope.attachments = [];
  19188. $scope.downloadUrl = function (contentId) {
  19189. return (
  19190. $scope.options.templateOptions.downloadUri(
  19191. $scope.options.templateOptions.ApiService,
  19192. contentId
  19193. ) || "#"
  19194. );
  19195. };
  19196. $scope.download = function (contentId, filename) {
  19197. $http({
  19198. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  19199. contentId
  19200. ).getRequestedUrl(),
  19201. method: "GET",
  19202. headers: {
  19203. //'Content-type' : 'application/xls',
  19204. Accept: "*/*",
  19205. },
  19206. responseType: "arraybuffer",
  19207. })
  19208. .success(function (data, status, headers, config) {
  19209. var file = new Blob([data], {
  19210. type: "application/octet-stream",
  19211. });
  19212. //trick to download store a file having its URL
  19213. var fileURL = URL.createObjectURL(file);
  19214. var a = document.createElement("a");
  19215. a.href = fileURL;
  19216. a.target = "_blank";
  19217. a.download = filename;
  19218. document.body.appendChild(a);
  19219. a.click();
  19220. })
  19221. .error(function (data, status, headers, config) {
  19222. // console.log(data);
  19223. });
  19224. };
  19225. $scope.view = function (contentId, filename, attachment) {
  19226. var index = filename.indexOf(".");
  19227. var type = filename.substring(index + 1);
  19228. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19229. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  19230. // var modalInstance = $modal.open({
  19231. // backdrop: false,
  19232. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19233. // controller: function($scope, scope, $modalInstance, filename) {
  19234. // $scope.title = filename;
  19235. // $scope.imageurl = scope.imageurl;
  19236. // $scope.cancel = function() {
  19237. // $modalInstance.dismiss('cancel');
  19238. // }
  19239. // },
  19240. // resolve: {
  19241. // scope: function() {
  19242. // return $scope;
  19243. // },
  19244. // filename: function() {
  19245. // return filename;
  19246. // }
  19247. // }
  19248. // });
  19249. // event.preventDefault();
  19250. // } else {
  19251. // for (var i = 0; i < $scope.attachments.length; i++) {
  19252. // if ($scope.attachments[i].id == attachmentId) {
  19253. window.open(attachment.previewUrl);
  19254. // }
  19255. // }
  19256. // }
  19257. };
  19258. $scope._refresh = function (refreshAttr) {
  19259. if (refreshAttr !== undefined) {
  19260. if (_refreshDelayPromise) {
  19261. $timeout.cancel(_refreshDelayPromise);
  19262. }
  19263. _refreshDelayPromise = $timeout(function () {
  19264. $scope.options.templateOptions
  19265. .refresh($scope.options.templateOptions.ApiService, "file", {
  19266. file: {
  19267. solutionId: $scope.model.knowledge.id,
  19268. },
  19269. idx: "0",
  19270. sum: "1000",
  19271. })
  19272. .then(function (response) {
  19273. var myData =
  19274. $scope.options.templateOptions.Restangular.stripRestangular(
  19275. response
  19276. );
  19277. if (myData) {
  19278. $scope.attachments = myData.list;
  19279. // $scope.view = function(attachmentId) {
  19280. // for (var i = 0; i < $scope.attachments.length; i++) {
  19281. // if ($scope.attachments[i].id == attachmentId) {
  19282. // window.open($scope.attachments[i].previewUrl);
  19283. // // var modalInstance = $modal.open({
  19284. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  19285. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  19286. // // }
  19287. // // });
  19288. // }
  19289. // }
  19290. // };
  19291. }
  19292. });
  19293. }, $scope.options.templateOptions.refreshDelay);
  19294. }
  19295. };
  19296. $scope._refresh({});
  19297. // $scope.attachments = $scope.model[$scope.options.key]
  19298. },
  19299. ],
  19300. });
  19301. //附件图片下载
  19302. formlyConfigProvider.setType({
  19303. name: "ui-downimage",
  19304. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  19305. defaultOptions: function (options) {
  19306. return {
  19307. templateOptions: {
  19308. refresh: function (APIService, processInstanceId, data) {
  19309. return APIService.listAttachments(processInstanceId, data);
  19310. },
  19311. downloadUri: function (APIService, contentId) {
  19312. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19313. },
  19314. view: function (APIService, contentId) {
  19315. return APIService.attachmentsPreviewUrl(contentId);
  19316. },
  19317. download: function (APIService, contentId, item) {
  19318. var item = {
  19319. url: APIService.download(contentId),
  19320. headers: headers,
  19321. };
  19322. return item;
  19323. },
  19324. refreshDelay: 0,
  19325. },
  19326. };
  19327. },
  19328. controller: [
  19329. "$scope",
  19330. "$timeout",
  19331. "$rootScope",
  19332. "$http",
  19333. function ($scope, $timeout, $rootScope, $http) {
  19334. var _refreshDelayPromise;
  19335. // $scope.downloadUrl = function(contentId){
  19336. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19337. // };
  19338. $scope.download = function (contentId, filename) {
  19339. // var headers=
  19340. $http({
  19341. url: $scope.options.templateOptions.ApiService.download(
  19342. contentId
  19343. ).getRequestedUrl(),
  19344. method: "GET",
  19345. headers: {
  19346. //'Content-type' : 'application/xls',
  19347. Accept: "*/*",
  19348. },
  19349. responseType: "arraybuffer",
  19350. })
  19351. .success(function (data, status, headers, config) {
  19352. var file = new Blob([data], {
  19353. type: "application/octet-stream",
  19354. });
  19355. //trick to download store a file having its URL
  19356. var fileURL = URL.createObjectURL(file);
  19357. var a = document.createElement("a");
  19358. a.href = fileURL;
  19359. a.target = "_blank";
  19360. a.download = filename;
  19361. document.body.appendChild(a);
  19362. a.click();
  19363. })
  19364. .error(function (data, status, headers, config) {
  19365. // console.log(data);
  19366. });
  19367. };
  19368. $scope.view = function (contentId) {
  19369. $scope.imageurl =
  19370. $scope.options.templateOptions.ApiService.download(
  19371. contentId
  19372. ).getRequestedUrl();
  19373. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  19374. // if (response.state == 200) {
  19375. // window.open(response.previewUrl);
  19376. // }
  19377. // })
  19378. };
  19379. /**
  19380. * refresh
  19381. */
  19382. $scope._refresh = function (refreshAttr) {
  19383. if (refreshAttr !== undefined) {
  19384. if (_refreshDelayPromise) {
  19385. $timeout.cancel(_refreshDelayPromise);
  19386. }
  19387. _refreshDelayPromise = $timeout(function () {
  19388. $scope.options.templateOptions
  19389. .refresh(
  19390. $scope.options.templateOptions.ApiService,
  19391. $scope.options.templateOptions.processInstanceId,
  19392. {
  19393. idx: 0,
  19394. sum: 1000,
  19395. }
  19396. )
  19397. .then(function (response) {
  19398. var myData =
  19399. $scope.options.templateOptions.Restangular.stripRestangular(
  19400. response
  19401. );
  19402. if (myData) {
  19403. $scope.attachments = myData.data;
  19404. }
  19405. });
  19406. }, $scope.options.templateOptions.refreshDelay);
  19407. }
  19408. };
  19409. $scope._refresh({});
  19410. // $scope.attachments = $scope.model[$scope.options.key]
  19411. },
  19412. ],
  19413. });
  19414. //附件下载列表组件
  19415. formlyConfigProvider.setType({
  19416. name: "ui-dropfiletable",
  19417. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  19418. defaultOptions: function (options) {
  19419. return {
  19420. templateOptions: {
  19421. refresh: function (APIService, processInstanceId, data) {
  19422. return APIService.listAttachments(processInstanceId, data);
  19423. },
  19424. downloadUri: function (APIService, contentId) {
  19425. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19426. },
  19427. view: function (APIService, contentId) {
  19428. return APIService.attachmentsPreviewUrl(contentId);
  19429. },
  19430. download: function (APIService, contentId, item) {
  19431. var item = {
  19432. url: APIService.download(contentId),
  19433. headers: headers,
  19434. };
  19435. return item;
  19436. },
  19437. refreshDelay: 0,
  19438. },
  19439. };
  19440. },
  19441. controller: [
  19442. "$scope",
  19443. "$timeout",
  19444. "$modal",
  19445. "$rootScope",
  19446. "$http",
  19447. function ($scope, $timeout, $modal, $rootScope, $http) {
  19448. var _refreshDelayPromise;
  19449. // $scope.downloadUrl = function(contentId){
  19450. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19451. // };
  19452. $scope.download = function (contentId, filename) {
  19453. // var headers=
  19454. $http({
  19455. url: $scope.options.templateOptions.ApiService.download(
  19456. contentId
  19457. ).getRequestedUrl(),
  19458. method: "GET",
  19459. headers: {
  19460. //'Content-type' : 'application/xls',
  19461. Accept: "*/*",
  19462. },
  19463. responseType: "arraybuffer",
  19464. })
  19465. .success(function (data, status, headers, config) {
  19466. var file = new Blob([data], {
  19467. type: "application/octet-stream",
  19468. });
  19469. //trick to download store a file having its URL
  19470. var fileURL = URL.createObjectURL(file);
  19471. var a = document.createElement("a");
  19472. a.href = fileURL;
  19473. a.target = "_blank";
  19474. a.download = filename;
  19475. document.body.appendChild(a);
  19476. a.click();
  19477. })
  19478. .error(function (data, status, headers, config) {
  19479. // console.log(data);
  19480. });
  19481. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  19482. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  19483. // var file = new Blob([response], {
  19484. // type : 'application/octet-stream'
  19485. // });
  19486. // // var filename = filename;
  19487. // //var file = new Blob([response], {type: 'application/pdf'});
  19488. // var fileURL = URL.createObjectURL(file);
  19489. // var a = document.createElement('a');
  19490. // a.href = fileURL;
  19491. // a.target = '_blank';
  19492. // a.download = filename ;
  19493. // document.body.appendChild(a);
  19494. // a.click();
  19495. // })
  19496. };
  19497. $scope.view = function (contentId, token, filename, type) {
  19498. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19499. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  19500. // var modalInstance = $modal.open({
  19501. // backdrop: false,
  19502. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19503. // controller: function($scope, scope, $modalInstance, filename) {
  19504. // $scope.title = filename;
  19505. // $scope.imageurl = scope.imageurl;
  19506. // $scope.cancel = function() {
  19507. // $modalInstance.dismiss('cancel');
  19508. // }
  19509. // },
  19510. // resolve: {
  19511. // scope: function() {
  19512. // return $scope;
  19513. // },
  19514. // filename: function() {
  19515. // return filename;
  19516. // }
  19517. // }
  19518. // });
  19519. // event.preventDefault();
  19520. // } else {
  19521. $scope.options.templateOptions
  19522. .view($scope.options.templateOptions.ApiService, contentId)
  19523. .then(function (response) {
  19524. if (response.state == 200) {
  19525. window.open(response.previewUrl);
  19526. }
  19527. });
  19528. // }
  19529. };
  19530. /**
  19531. * refresh
  19532. */
  19533. $scope._refresh = function (refreshAttr) {
  19534. if (refreshAttr !== undefined) {
  19535. if (_refreshDelayPromise) {
  19536. $timeout.cancel(_refreshDelayPromise);
  19537. }
  19538. _refreshDelayPromise = $timeout(function () {
  19539. $scope.options.templateOptions
  19540. .refresh(
  19541. $scope.options.templateOptions.ApiService,
  19542. $scope.options.templateOptions.processInstanceId,
  19543. {
  19544. idx: 0,
  19545. sum: 1000,
  19546. }
  19547. )
  19548. .then(function (response) {
  19549. var myData =
  19550. $scope.options.templateOptions.Restangular.stripRestangular(
  19551. response
  19552. );
  19553. if (myData) {
  19554. $scope.attachments = myData.data;
  19555. }
  19556. });
  19557. }, $scope.options.templateOptions.refreshDelay);
  19558. }
  19559. };
  19560. $scope._refresh({});
  19561. // $scope.attachments = $scope.model[$scope.options.key]
  19562. },
  19563. ],
  19564. });
  19565. //微信附件下载列表组件
  19566. formlyConfigProvider.setType({
  19567. name: "ui-dropfilewechat",
  19568. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  19569. defaultOptions: function (options) {
  19570. return {
  19571. templateOptions: {
  19572. // refresh: function(APIService, processInstanceId, data) {
  19573. // return APIService.listAttachments(processInstanceId, data);
  19574. // },
  19575. // downloadUri: function(APIService, contentId) {
  19576. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  19577. // },
  19578. view: function (APIService, contentId) {
  19579. // return APIService.attachmentsPreviewUrl(contentId);
  19580. return APIService.attachmentsPreviewUrl(contentId);
  19581. },
  19582. download: function (APIService, contentId, item) {
  19583. var item = {
  19584. url: APIService.download(contentId),
  19585. headers: headers,
  19586. };
  19587. return item;
  19588. },
  19589. // download: function(APIService, contentId, item) {
  19590. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  19591. // return item;
  19592. // },
  19593. refreshDelay: 0,
  19594. },
  19595. };
  19596. },
  19597. controller: [
  19598. "$scope",
  19599. "$timeout",
  19600. "$modal",
  19601. "$stateParams",
  19602. "$rootScope",
  19603. "$http",
  19604. "api_wechatfile",
  19605. function (
  19606. $scope,
  19607. $timeout,
  19608. $modal,
  19609. $stateParams,
  19610. $rootScope,
  19611. $http,
  19612. api_wechatfile
  19613. ) {
  19614. var _refreshDelayPromise;
  19615. // $scope.downloadUrl = function(contentId){
  19616. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19617. // };
  19618. $scope.attachments = {};
  19619. $scope.previewUrl = "";
  19620. $scope.download = function (token, filename) {
  19621. // var headers=
  19622. console.log($scope);
  19623. $http({
  19624. url: $scope.options.templateOptions.ApiService.jry_download(
  19625. token
  19626. ).getRequestedUrl(),
  19627. method: "GET",
  19628. headers: {
  19629. //'Content-type' : 'application/xls',
  19630. Accept: "*/*",
  19631. },
  19632. responseType: "arraybuffer",
  19633. })
  19634. .success(function (data, status, headers, config) {
  19635. var file = new Blob([data], {
  19636. type: "application/octet-stream",
  19637. });
  19638. //trick to download store a file having its URL
  19639. var fileURL = URL.createObjectURL(file);
  19640. var a = document.createElement("a");
  19641. a.href = fileURL;
  19642. a.target = "_blank";
  19643. a.download = filename;
  19644. document.body.appendChild(a);
  19645. a.click();
  19646. })
  19647. .error(function (data, status, headers, config) {
  19648. // console.log(data);
  19649. });
  19650. };
  19651. $scope.view = function (contentId, token, filename, type, previewUrl) {
  19652. // if (type) {
  19653. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  19654. // var modalInstance = $modal.open({
  19655. // backdrop: false,
  19656. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19657. // controller: function($scope, scope, $modalInstance, filename) {
  19658. // $scope.title = filename;
  19659. // $scope.imageurl = scope.imageurl;
  19660. // $scope.cancel = function() {
  19661. // $modalInstance.dismiss('cancel');
  19662. // }
  19663. // },
  19664. // resolve: {
  19665. // scope: function() {
  19666. // return $scope;
  19667. // },
  19668. // filename: function() {
  19669. // return filename;
  19670. // }
  19671. // }
  19672. // });
  19673. // event.preventDefault();
  19674. // } else {
  19675. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  19676. // if (response.state == 200) {
  19677. // window.open(response.previewUrl);
  19678. // }
  19679. // })
  19680. window.open(previewUrl);
  19681. // }
  19682. };
  19683. /**
  19684. * refresh
  19685. */
  19686. $scope._refresh = function (refreshAttr) {
  19687. if (refreshAttr !== undefined) {
  19688. if (_refreshDelayPromise) {
  19689. $timeout.cancel(_refreshDelayPromise);
  19690. }
  19691. _refreshDelayPromise = $timeout(function () {
  19692. // console.log(JSON.parse($stateParams.model))
  19693. var incidentChart = {};
  19694. if ($stateParams.model) {
  19695. incidentChart = JSON.parse($stateParams.model).model;
  19696. }
  19697. $scope.options.templateOptions
  19698. .refresh(
  19699. $scope.options.templateOptions.ApiService,
  19700. $scope.model
  19701. )
  19702. .then(function (response) {
  19703. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19704. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19705. var myData =
  19706. $scope.options.templateOptions.Restangular.stripRestangular(
  19707. response
  19708. );
  19709. if (myData) {
  19710. $scope.attachments = myData.data;
  19711. }
  19712. });
  19713. }, $scope.options.templateOptions.refreshDelay);
  19714. }
  19715. };
  19716. $scope._refresh({});
  19717. // $scope.attachments = $scope.model[$scope.options.key]
  19718. },
  19719. ],
  19720. });
  19721. formlyConfigProvider.setType({
  19722. name: "ui-paralleltask",
  19723. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19724. defaultOptions: function (options) {
  19725. return {
  19726. templateOptions: {
  19727. refresh: function (APIService, processInstanceId, data) {
  19728. //return APIService.listAttachments(processInstanceId, data);
  19729. },
  19730. refreshDelay: 0,
  19731. },
  19732. };
  19733. },
  19734. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19735. });
  19736. //repeatSection
  19737. //
  19738. formlyConfigProvider.setType({
  19739. name: "ui-repeatSection",
  19740. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19741. defaultOptions: function (options) {
  19742. return {
  19743. templateOptions: {
  19744. unique: 1,
  19745. initDisplay: false,
  19746. },
  19747. };
  19748. },
  19749. controller: function ($scope) {
  19750. //$scope.options.templateOptions.unique;
  19751. $scope.formOptions = {
  19752. formState: $scope.formState,
  19753. };
  19754. $scope.addNew = addNew;
  19755. $scope.copyFields = copyFields;
  19756. function copyFields(fields) {
  19757. fields = angular.copy(fields);
  19758. addRandomIds(fields);
  19759. return fields;
  19760. }
  19761. function addNew() {
  19762. $scope.model[$scope.options.key] =
  19763. $scope.model[$scope.options.key] || [];
  19764. var repeatsection = $scope.model[$scope.options.key];
  19765. var lastSection = repeatsection[repeatsection.length - 1];
  19766. var newsection = {};
  19767. repeatsection.push(newsection);
  19768. }
  19769. function addRandomIds(fields) {
  19770. $scope.options.templateOptions.unique++;
  19771. angular.forEach(fields, function (field, index) {
  19772. if (field.fieldGroup) {
  19773. addRandomIds(field.fieldGroup);
  19774. return; // fieldGroups don't need an ID
  19775. }
  19776. if (field.templateOptions && field.templateOptions.fields) {
  19777. addRandomIds(field.templateOptions.fields);
  19778. }
  19779. field.id =
  19780. field.id ||
  19781. field.key +
  19782. "_" +
  19783. index +
  19784. "_" +
  19785. $scope.options.templateOptions.unique +
  19786. getRandomInt(0, 9999);
  19787. });
  19788. }
  19789. function getRandomInt(min, max) {
  19790. return Math.floor(Math.random() * (max - min)) + min;
  19791. }
  19792. if ($scope.options.templateOptions.initDisplay) {
  19793. addNew();
  19794. }
  19795. },
  19796. });
  19797. //时间轴任务列表组件
  19798. //cmdb控件
  19799. formlyConfigProvider.setType({
  19800. name: "ui-cmdb",
  19801. extends: "input",
  19802. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19803. defaultOptions: function (options) {
  19804. return {
  19805. templateOptions: {
  19806. onClick: function (size, options, modal, event, model) {
  19807. var modalInstance = modal.open({
  19808. templateUrl:
  19809. "assets/views/customform/tpl/cmdb-modal-content.html",
  19810. controller: function (
  19811. $scope,
  19812. $modalInstance,
  19813. title,
  19814. Restangular,
  19815. APIService,
  19816. ConfigDataService,
  19817. ConfigFormService,
  19818. SweetAlert,
  19819. Toaster,
  19820. api_wechatfile
  19821. ) {
  19822. var width = ($scope.width = 600);
  19823. var height = ($scope.height = 400);
  19824. var tree;
  19825. var d3 = window.d3;
  19826. $scope.my_tree_handler = function (branch) {
  19827. //var _ref;
  19828. var classify = ($scope.classify =
  19829. branch.prefix.toLowerCase() + branch.sign);
  19830. APIService.query({
  19831. sign: classify,
  19832. }).then(function (data) {
  19833. var myData = Restangular.stripRestangular(data);
  19834. // console.log(myData.data.node);
  19835. if (myData.data && myData.status == 200) {
  19836. var ret = myData.data;
  19837. redrawSvg(myData);
  19838. }
  19839. });
  19840. };
  19841. $scope.my_data = [];
  19842. function convertListToTree(data, treeMap) {
  19843. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19844. var root = null; //Initially set our loop to null
  19845. var parentNode = null;
  19846. //loop over data
  19847. for (var i = 0; i < data.length; i++) {
  19848. var datum = data[i];
  19849. //each node will have children, so let's give it a "children" poperty
  19850. datum.children = [];
  19851. //add an entry for this node to the map so that any future children can
  19852. //lookup the parent
  19853. idToNodeMap[datum.id] = datum;
  19854. //Does this node have a parent?
  19855. if (
  19856. typeof datum.parent === "undefined" ||
  19857. datum.parent == null
  19858. ) {
  19859. //Doesn't look like it, so this node is the root of the tree
  19860. root = datum;
  19861. treeMap[datum.id] = root;
  19862. } else {
  19863. //This node has a parent, so let's look it up using the id
  19864. parentNode = idToNodeMap[datum.parent.id];
  19865. //We don't need this property, so let's delete it.
  19866. delete datum.parent;
  19867. //Let's add the current node as a child of the parent node.
  19868. parentNode.children.push(datum);
  19869. }
  19870. }
  19871. return root;
  19872. }
  19873. function convertParentToChildList(data) {
  19874. var treeMap = {};
  19875. var list = [];
  19876. convertListToTree(data, treeMap);
  19877. angular.forEach(treeMap, function (item) {
  19878. list.push(item);
  19879. });
  19880. return list;
  19881. }
  19882. $scope.my_tree = tree = {};
  19883. $scope.try_async_load = function () {
  19884. $scope.my_data = [];
  19885. $scope.select_treedata = [];
  19886. $scope.doing_async = true;
  19887. ConfigDataService.fetchDataList("ciclassify", {
  19888. idx: 0,
  19889. sum: 100,
  19890. }).then(function (result) {
  19891. $scope.select_treedata = $scope.my_data =
  19892. convertParentToChildList(result["list"]);
  19893. $scope.doing_async = false;
  19894. });
  19895. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19896. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19897. // $scope.doing_async = false;
  19898. // });
  19899. };
  19900. $scope.select_treedata = [];
  19901. $scope.propTypeOptions = [];
  19902. $scope.try_async_load();
  19903. $scope.onFilterCallback = function (item) {
  19904. //console.log(item);
  19905. if (
  19906. angular.isDefined(item.children) &&
  19907. item.children.length >= 1
  19908. ) {
  19909. //not valid
  19910. } else {
  19911. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19912. $scope.cifilter_classic = tempclassify;
  19913. ConfigFormService.renderTabForm(tempclassify).then(
  19914. function (data) {
  19915. var myData = Restangular.stripRestangular(data);
  19916. $scope.propTypeOptions = myData;
  19917. }
  19918. );
  19919. }
  19920. };
  19921. $scope.onPropTypeChange = function (form) {
  19922. $scope.propOptions = form.fields;
  19923. };
  19924. $scope.onPropChange = function (prop) {
  19925. $scope.cifilter_prop = prop;
  19926. };
  19927. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19928. //if(searchKey!=null&&searchKey.length>1){
  19929. var searchData = {};
  19930. if (angular.isUndefined(propObj)) {
  19931. propObj = $scope.cifilter_prop;
  19932. }
  19933. if (angular.isUndefined(ciclassify)) {
  19934. ciclassify = $scope.cifilter_classic;
  19935. }
  19936. searchData["sign"] = ciclassify;
  19937. if (angular.isDefined(propObj)) {
  19938. searchData[propObj.key] = searchKey;
  19939. }
  19940. APIService.query(searchData).then(function (response) {
  19941. var data = Restangular.stripRestangular(response);
  19942. //此处不清空nodes
  19943. var node = data.data.node;
  19944. var tempNode = [];
  19945. //nodes 或者links 要去重
  19946. for (var i = 0; i < node.length; i++) {
  19947. var tmp = 0;
  19948. for (var j = 0; j < nodes.length; j++) {
  19949. if (node[i].uuid == nodes[j].uuid) {
  19950. tmp++;
  19951. break;
  19952. }
  19953. }
  19954. if (tmp == 0) {
  19955. tempNode.push(node[i]);
  19956. }
  19957. }
  19958. for (var i = 0; i < tempNode.length; i++) {
  19959. //nodes 不清空
  19960. nodes.push(tempNode[i]);
  19961. }
  19962. restart();
  19963. });
  19964. };
  19965. $scope.refresh = function () {
  19966. nodes.length = 0;
  19967. links.length = 0;
  19968. restart();
  19969. };
  19970. $scope.traversal = function () {
  19971. if ($scope.selected_node == null) {
  19972. SweetAlert.swal({
  19973. title: "错误的操作!",
  19974. text: "没有配置项被选中!",
  19975. type: "error",
  19976. });
  19977. } else {
  19978. var uuid = $scope.selected_node.uuid;
  19979. APIService.traversal(uuid).then(function (response) {
  19980. var d = response.data;
  19981. var node = d.node;
  19982. var link = d.edge;
  19983. var tempNode = [];
  19984. var tempLink = [];
  19985. //nodes 或者links 要去重
  19986. for (var i = 0; i < node.length; i++) {
  19987. var tmp = 0;
  19988. for (var j = 0; j < nodes.length; j++) {
  19989. if (node[i].id == nodes[j].id) {
  19990. tmp++;
  19991. break;
  19992. }
  19993. }
  19994. if (tmp == 0) {
  19995. tempNode.push(node[i]);
  19996. }
  19997. }
  19998. for (var i = 0; i < link.length; i++) {
  19999. var tmp = 0;
  20000. for (var j = 0; j < links.length; j++) {
  20001. if (link[i].id == links[j].id) {
  20002. tmp++;
  20003. break;
  20004. }
  20005. }
  20006. if (tmp == 0) {
  20007. tempLink.push(link[i]);
  20008. }
  20009. }
  20010. //数据写入页面
  20011. for (var i = 0; i < tempNode.length; i++) {
  20012. //nodes 不清空
  20013. nodes.push(tempNode[i]);
  20014. }
  20015. for (var i = 0; i < tempLink.length; i++) {
  20016. //link 不清空
  20017. links.push(tempLink[i]);
  20018. }
  20019. //links转换
  20020. for (var i = 0; i < links.length; i++) {
  20021. for (var j = 0; j < nodes.length; j++) {
  20022. if (links[i].source == nodes[j].id) {
  20023. links[i].source = nodes[j];
  20024. }
  20025. if (links[i].target == nodes[j].id) {
  20026. links[i].target = nodes[j];
  20027. }
  20028. }
  20029. }
  20030. restart();
  20031. });
  20032. }
  20033. };
  20034. var svg;
  20035. var force;
  20036. var drag_line, path, circle;
  20037. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  20038. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  20039. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  20040. var nodes = [],
  20041. links = [];
  20042. var treeNodes = [];
  20043. //读取labels (node)
  20044. var labels = [];
  20045. function redrawSvg(json) {
  20046. nodes.length = 0; //先清空
  20047. links.length = 0;
  20048. var data = json.data;
  20049. for (var i = 0; i < data.node.length; i++) {
  20050. nodes.push(data.node[i]);
  20051. }
  20052. restart();
  20053. }
  20054. //读取status (节点 连线)
  20055. var statuses = [];
  20056. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  20057. // if (result && result.status == 200) {
  20058. // d3.select('#nodeStatus').selectAll('option')
  20059. // .data(statuses).enter()
  20060. // .append('option')
  20061. // .attr('value', function(d) { return d.code; })
  20062. // .html(function(d) { return d.desc; });
  20063. // } else {
  20064. // SweetAlert.swal({
  20065. // title: "提示!",
  20066. // text: "服务器请求异常!",
  20067. // type: "error"
  20068. // });
  20069. // }
  20070. // });
  20071. api_wechatfile
  20072. .getDictionary({
  20073. key: "cmdb_status",
  20074. type: "list",
  20075. })
  20076. .then(function (result) {
  20077. if (result) {
  20078. d3.select("#nodeStatus")
  20079. .selectAll("option")
  20080. .data(statuses)
  20081. .enter()
  20082. .append("option")
  20083. .attr("value", function (d) {
  20084. return d.code;
  20085. })
  20086. .html(function (d) {
  20087. return d.desc;
  20088. });
  20089. } else {
  20090. SweetAlert.swal({
  20091. title: "提示!",
  20092. text: "服务器请求异常!",
  20093. type: "error",
  20094. });
  20095. }
  20096. });
  20097. //查询relationship_type表 name 为表里的type,label为显示值
  20098. var linkType = [];
  20099. function fetchEdgeTypes() {
  20100. ConfigDataService.fetchDataList("ciedgetype", {
  20101. idx: 0,
  20102. sum: 100,
  20103. }).then(function (response) {
  20104. if (response) {
  20105. if (response["list"]) {
  20106. linkType = response["list"];
  20107. // d3.select('#linkName').selectAll('option')
  20108. // .data(linkType).enter()
  20109. // .append('option')
  20110. // .attr('value',function(d){return d.type;})
  20111. // .html(function(d){ return d.label;});
  20112. } else {
  20113. SweetAlert.swal({
  20114. title: "提示!",
  20115. text: "服务器请求异常!",
  20116. type: "error",
  20117. });
  20118. }
  20119. } else {
  20120. SweetAlert.swal({
  20121. title: "提示!",
  20122. text: "服务器请求异常!",
  20123. type: "error",
  20124. });
  20125. }
  20126. });
  20127. }
  20128. // fetchEdgeTypes();
  20129. /*
  20130. // init D3 force layout
  20131. var force = d3.layout.force()
  20132. .nodes(nodes)
  20133. .links(links)
  20134. .size([width, height])
  20135. .gravity(.05)
  20136. .linkDistance(150)
  20137. .linkStrength(2)
  20138. .charge(-500)
  20139. .on('tick', tick);
  20140. // define arrow markers for graph links
  20141. svg.append('svg:defs').append('svg:marker')
  20142. .attr('id', 'end-arrow')
  20143. .attr('viewBox', '0 -5 10 10')
  20144. .attr('refX', 6)
  20145. .attr('markerWidth', 3)
  20146. .attr('markerHeight', 3)
  20147. .attr('orient', 'auto')
  20148. .append('svg:path')
  20149. .attr('d', 'M0,-5L10,0L0,5')
  20150. .attr('fill', '#000');
  20151. svg.append('svg:defs').append('svg:marker')
  20152. .attr('id', 'start-arrow')
  20153. .attr('viewBox', '0 -5 10 10')
  20154. .attr('refX', 4)
  20155. .attr('markerWidth', 3)
  20156. .attr('markerHeight', 3)
  20157. .attr('orient', 'auto')
  20158. .append('svg:path')
  20159. .attr('d', 'M10,-5L0,0L10,5')
  20160. .attr('fill', '#000');
  20161. // line displayed when dragging new nodes
  20162. var drag_line = svg.append('svg:path')
  20163. .attr('class', 'link dragline hidden')
  20164. .attr('d', 'M0,0L0,0');
  20165. // handles to link and node element groups
  20166. //(1)var path = svg.append('svg:g').selectAll('g')
  20167. var path = svg.append('svg:g').selectAll('g'),
  20168. circle = svg.append('svg:g').selectAll('g');
  20169. */
  20170. // mouse event vars
  20171. var selected_node = null,
  20172. selected_link = null,
  20173. mousedown_link = null,
  20174. mousedown_node = null,
  20175. mouseup_node = null;
  20176. function resetMouseVars() {
  20177. mousedown_node = null;
  20178. mouseup_node = null;
  20179. mousedown_link = null;
  20180. }
  20181. // update force layout (called automatically each iteration)
  20182. function tick() {
  20183. // draw directed edges with proper padding from node centers
  20184. path.selectAll("path").attr("d", function (d) {
  20185. var deltaX = d.target.x - d.source.x,
  20186. deltaY = d.target.y - d.source.y,
  20187. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  20188. normX = deltaX / dist,
  20189. normY = deltaY / dist,
  20190. sourcePadding = d.left ? 27 : 22,
  20191. targetPadding = d.right ? 27 : 22,
  20192. sourceX = d.source.x + sourcePadding * normX,
  20193. sourceY = d.source.y + sourcePadding * normY,
  20194. targetX = d.target.x - targetPadding * normX,
  20195. targetY = d.target.y - targetPadding * normY;
  20196. return (
  20197. "M" +
  20198. sourceX +
  20199. "," +
  20200. sourceY +
  20201. "L" +
  20202. targetX +
  20203. "," +
  20204. targetY
  20205. );
  20206. });
  20207. circle.attr("transform", function (d) {
  20208. return "translate(" + d.x + "," + d.y + ")";
  20209. });
  20210. }
  20211. // update graph (called when needed)
  20212. function restart() {
  20213. //绑定link 数据
  20214. path.datum(links);
  20215. // path (link) group
  20216. path = path.data(links, function (d) {
  20217. return d.id;
  20218. });
  20219. var p = path.enter().append("svg:g");
  20220. //update existing links
  20221. path
  20222. .selectAll("path")
  20223. .classed("selected", function (d) {
  20224. return d === selected_link;
  20225. })
  20226. .style("marker-start", function (d) {
  20227. return d.left ? "url(#start-arrow)" : "";
  20228. })
  20229. .style("marker-end", function (d) {
  20230. return d.right ? "url(#end-arrow)" : "";
  20231. });
  20232. // add new links
  20233. p.append("svg:path")
  20234. .attr("class", "link")
  20235. .attr("id", function (d) {
  20236. return "path_" + d.id;
  20237. })
  20238. // .attr('startOffset', '0%')
  20239. .classed("selected", function (d) {
  20240. return d === selected_link;
  20241. })
  20242. .style("marker-start", function (d) {
  20243. return d.left ? "url(#start-arrow)" : "";
  20244. })
  20245. .style("marker-end", function (d) {
  20246. return d.right ? "url(#end-arrow)" : "";
  20247. })
  20248. .on("mousedown", function (d) {
  20249. if (d3.event.ctrlKey) return;
  20250. //去除没有提交的连线
  20251. for (var i = 0; i < links.length; i++) {
  20252. if (links[i].id == -1 && d.id != -1) {
  20253. links.splice(i, 1);
  20254. }
  20255. }
  20256. // select link
  20257. mousedown_link = d;
  20258. if (mousedown_link === selected_link) {
  20259. selected_link = $scope.selected_link = null;
  20260. selected_node = $scope.selected_node = null;
  20261. // d3.select("#linkDetail").attr('style','display:none');
  20262. //hideLinkForm(true);//return ;
  20263. } else {
  20264. selected_link = $scope.selected_link = mousedown_link;
  20265. selected_node = $scope.selected_node = null;
  20266. }
  20267. selected_node = $scope.selected_node = null;
  20268. restart();
  20269. });
  20270. p.append("svg:text")
  20271. .attr("x", 30)
  20272. .attr("y", 20)
  20273. .attr("class", "fontM")
  20274. .append("textPath")
  20275. .attr("xlink:xlink:href", function (d, i) {
  20276. return "#path_" + d.id;
  20277. })
  20278. .html(function (d) {
  20279. for (var i = 0; i < linkType.length; i++) {
  20280. if (linkType[i].type == d.name) {
  20281. return linkType[i].label;
  20282. }
  20283. }
  20284. });
  20285. // remove old links
  20286. path.exit().remove();
  20287. // circle (node) group
  20288. // NB: the function arg is crucial here! nodes are known by id, not by index!
  20289. circle.datum(nodes);
  20290. circle = circle.data(nodes, function (d) {
  20291. return d.id;
  20292. });
  20293. // update existing nodes (reflexive & selected visual states)
  20294. circle
  20295. .selectAll("circle")
  20296. .style("fill", function (d) {
  20297. return d === selected_node
  20298. ? d3.rgb(colors(d.label)).brighter().toString()
  20299. : colors(d.label);
  20300. })
  20301. .style("fill-opacity", 0.75) // add by xi
  20302. .classed("reflexive", function (d) {
  20303. return d.reflexive;
  20304. });
  20305. // add new nodes
  20306. var g = circle.enter().append("svg:g");
  20307. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  20308. //g.append('svg:circle').attr('r',24).style('fill','rgb(255,255,255)').style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); }).style('stroke-width','2');
  20309. g.append("svg:circle")
  20310. .attr("r", 24)
  20311. .style("fill", function (d) {
  20312. return d === selected_node
  20313. ? "rgb(153,153,153)"
  20314. : "rgb(255,255,255)";
  20315. })
  20316. .style("stroke", function (d) {
  20317. return d3.rgb(colors(d.label)).darker().toString();
  20318. })
  20319. .style("stroke-width", "2");
  20320. g.append("svg:circle")
  20321. .attr("class", "node")
  20322. .attr("r", 18)
  20323. .style("fill", function (d) {
  20324. return d === selected_node
  20325. ? d3.rgb(colors(d.label)).brighter().toString()
  20326. : colors(d.label);
  20327. })
  20328. .style("stroke", function (d) {
  20329. return d3.rgb(colors(d.label)).darker().toString();
  20330. })
  20331. .style("fill-opacity", 0.25) //add by xj
  20332. .style("stroke-opacity", 0.5) //add by xj
  20333. .classed("reflexive", function (d) {
  20334. return d.reflexive;
  20335. });
  20336. g.on("mouseover", function (d) {
  20337. //if(!mousedown_node || d === mousedown_node) return;
  20338. // enlarge target node
  20339. //d3.select(this).attr('transform', 'scale(1.1)');
  20340. })
  20341. .on("mouseout", function (d) {
  20342. //if(!mousedown_node || d === mousedown_node) return;
  20343. // unenlarge target node
  20344. //d3.select(this).attr('transform', '');
  20345. })
  20346. .on("mousedown", function (d) {
  20347. if (d3.event.ctrlKey) return;
  20348. //hideLinkForm(true);
  20349. //去除没有提交的连线
  20350. for (var i = 0; i < links.length; i++) {
  20351. if (links[i].id == -1) {
  20352. links.splice(i, 1);
  20353. }
  20354. }
  20355. // select node
  20356. mousedown_node = d;
  20357. if (mousedown_node === selected_node) {
  20358. selected_node = $scope.selected_node = null;
  20359. } else {
  20360. selected_node = $scope.selected_node = mousedown_node;
  20361. selected_link = $scope.selected_link = null;
  20362. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  20363. APIService.findRefById(selected_node.id).then(function (
  20364. result
  20365. ) {
  20366. var d = result.data;
  20367. var node = d.node;
  20368. var link = d.edge;
  20369. var tempNode = [];
  20370. var tempLink = [];
  20371. //nodes 或者links 要去重
  20372. for (var i = 0; i < node.length; i++) {
  20373. var tmp = 0;
  20374. for (var j = 0; j < nodes.length; j++) {
  20375. if (node[i].id == nodes[j].id) {
  20376. tmp++;
  20377. break;
  20378. }
  20379. }
  20380. if (tmp == 0) {
  20381. tempNode.push(node[i]);
  20382. }
  20383. }
  20384. for (var i = 0; i < link.length; i++) {
  20385. var tmp = 0;
  20386. for (var j = 0; j < links.length; j++) {
  20387. if (link[i].id == links[j].id) {
  20388. tmp++;
  20389. break;
  20390. }
  20391. }
  20392. if (tmp == 0) {
  20393. tempLink.push(link[i]);
  20394. }
  20395. }
  20396. //数据写入页面
  20397. for (var i = 0; i < tempNode.length; i++) {
  20398. //nodes 不清空
  20399. nodes.push(tempNode[i]);
  20400. }
  20401. for (var i = 0; i < tempLink.length; i++) {
  20402. //link 不清空
  20403. links.push(tempLink[i]);
  20404. }
  20405. //links转换
  20406. for (var i = 0; i < links.length; i++) {
  20407. for (var j = 0; j < nodes.length; j++) {
  20408. if (links[i].source == nodes[j].id) {
  20409. links[i].source = nodes[j];
  20410. }
  20411. if (links[i].target == nodes[j].id) {
  20412. links[i].target = nodes[j];
  20413. }
  20414. }
  20415. }
  20416. restart();
  20417. });
  20418. }
  20419. // reposition drag line
  20420. drag_line
  20421. .style("marker-end", "url(#end-arrow)")
  20422. .classed("hidden", false)
  20423. .attr(
  20424. "d",
  20425. "M" +
  20426. mousedown_node.x +
  20427. "," +
  20428. mousedown_node.y +
  20429. "L" +
  20430. mousedown_node.x +
  20431. "," +
  20432. mousedown_node.y
  20433. );
  20434. restart();
  20435. })
  20436. .on("mouseup", function (d) {
  20437. if (!mousedown_node) return;
  20438. });
  20439. // show node name
  20440. g.append("svg:text")
  20441. .attr("x", 0)
  20442. .attr("y", 34)
  20443. .attr("class", "id")
  20444. .text(function (d) {
  20445. return d.name;
  20446. }); //TODO 改为 d.name
  20447. //设置图片
  20448. g.append("svg:foreignObject")
  20449. .attr("width", 32)
  20450. .attr("height", 32)
  20451. .attr("x", "-16px")
  20452. .attr("y", "-11px")
  20453. .html(function (d) {
  20454. for (var i = 0; i < labels.length; i++) {
  20455. if (d.label == labels[i].sign) {
  20456. return (
  20457. '<i class="icon iconfont">' +
  20458. labels[i].iconname +
  20459. "</i>"
  20460. );
  20461. }
  20462. }
  20463. });
  20464. // remove old nodes
  20465. circle.exit().remove();
  20466. // set the graph in motion
  20467. force.start();
  20468. }
  20469. function mousedown() {
  20470. // prevent I-bar on drag
  20471. //d3.event.preventDefault();
  20472. // because :active only works in WebKit?
  20473. svg.classed("active", true);
  20474. if (mousedown_node) {
  20475. viewNode(mousedown_node);
  20476. }
  20477. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  20478. return;
  20479. restart();
  20480. }
  20481. function mousemove() {
  20482. if (!mousedown_node) return;
  20483. // update drag line
  20484. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  20485. //restart();
  20486. }
  20487. function mouseup() {
  20488. if (mousedown_node) {
  20489. // hide drag line
  20490. drag_line.classed("hidden", true).style("marker-end", "");
  20491. }
  20492. // because :active only works in WebKit?
  20493. svg.classed("active", false);
  20494. // clear mouse event vars
  20495. resetMouseVars();
  20496. }
  20497. function spliceLinksForNode(node) {
  20498. var toSplice = links.filter(function (l) {
  20499. return l.source === node || l.target === node;
  20500. });
  20501. toSplice.map(function (l) {
  20502. links.splice(links.indexOf(l), 1);
  20503. });
  20504. }
  20505. // only respond once per keydown
  20506. var lastKeyDown = -1;
  20507. function keydown() {
  20508. //d3.event.preventDefault();
  20509. if (lastKeyDown !== -1) return;
  20510. lastKeyDown = d3.event.keyCode;
  20511. // ctrl
  20512. if (d3.event.keyCode === 17) {
  20513. circle.call(force.drag);
  20514. svg.classed("ctrl", true);
  20515. }
  20516. if (!selected_node && !selected_link) return;
  20517. switch (d3.event.keyCode) {
  20518. case 8: // backspace
  20519. case 66: // B
  20520. if (selected_link) {
  20521. // set link direction to both left and right
  20522. selected_link.left = true;
  20523. selected_link.right = true;
  20524. }
  20525. restart();
  20526. break;
  20527. case 76: // L
  20528. if (selected_link) {
  20529. // set link direction to left only
  20530. selected_link.left = true;
  20531. selected_link.right = false;
  20532. }
  20533. restart();
  20534. break;
  20535. case 82: // R
  20536. if (selected_node) {
  20537. // toggle node reflexivity
  20538. selected_node.reflexive = !selected_node.reflexive;
  20539. } else if (selected_link) {
  20540. // set link direction to right only
  20541. selected_link.left = false;
  20542. selected_link.right = true;
  20543. }
  20544. restart();
  20545. break;
  20546. }
  20547. }
  20548. function keyup() {
  20549. lastKeyDown = -1;
  20550. // ctrl
  20551. if (d3.event.keyCode === 17) {
  20552. circle
  20553. .on("mousedown.drag", null)
  20554. .on("touchstart.drag", null);
  20555. svg.classed("ctrl", false);
  20556. }
  20557. }
  20558. function viewNode(node) {
  20559. // console.log(svg.attr('left'));
  20560. //var el = angular.element('div.modal-dialog')[0];
  20561. var title =
  20562. $scope.selected_node.name +
  20563. "-[" +
  20564. $scope.selected_node.uuid +
  20565. "]";
  20566. if (!$scope.selected_node.props.state) {
  20567. $scope.selected_node.props.state = "空";
  20568. } else if ($scope.selected_node.props.state) {
  20569. if ($scope.selected_node.props.state == "1") {
  20570. $scope.selected_node.props.state = "未审核";
  20571. } else if ($scope.selected_node.props.state == "2") {
  20572. $scope.selected_node.props.state = "已审核";
  20573. } else if ($scope.selected_node.props.state == "3") {
  20574. $scope.selected_node.props.state = "不匹配";
  20575. } else if ($scope.selected_node.props.state == "4") {
  20576. $scope.selected_node.props.state = "丢失";
  20577. }
  20578. }
  20579. if (!$scope.selected_node.name) {
  20580. $scope.selected_node.name = "空";
  20581. }
  20582. if (!$scope.selected_node.status) {
  20583. $scope.selected_node.statu = "空";
  20584. }
  20585. if (!$scope.selected_node.props.useradmin) {
  20586. $scope.selected_node.props.useradmin = "空";
  20587. }
  20588. Toaster.pop({
  20589. // type: 'info',
  20590. // title: title,
  20591. body:
  20592. "<br/><p>搜索代码:" +
  20593. $scope.selected_node.uuid +
  20594. "</p>" +
  20595. "<p>配置标题:" +
  20596. $scope.selected_node.name +
  20597. "</p>" +
  20598. "<p>状态:" +
  20599. $scope.selected_node.status +
  20600. "</p>" +
  20601. "<p>审核状态:" +
  20602. $scope.selected_node.props.state +
  20603. "</p>" +
  20604. "<p>维护人员:" +
  20605. $scope.selected_node.props.useradmin +
  20606. "</p>",
  20607. bodyOutputType: "trustedHtml",
  20608. timeout: 3000,
  20609. });
  20610. }
  20611. //GT 颜色与数值对照表
  20612. function colors(sign) {
  20613. //num=num>20?num%20:parseInt(num);
  20614. for (var i = 0; i < labels.length; i++) {
  20615. var entity = labels[i];
  20616. if (sign == entity.sign) {
  20617. return entity.color;
  20618. }
  20619. if (i == labels.length - 1 && sign != entity.sign) {
  20620. return "#ffeeee";
  20621. }
  20622. }
  20623. }
  20624. $scope.init = function () {
  20625. svg = d3
  20626. .select("#cmdbSVG")
  20627. .append("svg")
  20628. .attr("width", width)
  20629. .attr("height", height);
  20630. // init D3 force layout
  20631. force = d3.layout
  20632. .force()
  20633. .nodes(nodes)
  20634. .links(links)
  20635. .size([width, height])
  20636. .gravity(0.05)
  20637. .linkDistance(150)
  20638. .linkStrength(2)
  20639. .charge(-500)
  20640. .on("tick", tick);
  20641. // define arrow markers for graph links
  20642. svg
  20643. .append("svg:defs")
  20644. .append("svg:marker")
  20645. .attr("id", "end-arrow")
  20646. .attr("viewBox", "0 -5 10 10")
  20647. .attr("refX", 6)
  20648. .attr("markerWidth", 3)
  20649. .attr("markerHeight", 3)
  20650. .attr("orient", "auto")
  20651. .append("svg:path")
  20652. .attr("d", "M0,-5L10,0L0,5")
  20653. .attr("fill", "#000");
  20654. svg
  20655. .append("svg:defs")
  20656. .append("svg:marker")
  20657. .attr("id", "start-arrow")
  20658. .attr("viewBox", "0 -5 10 10")
  20659. .attr("refX", 4)
  20660. .attr("markerWidth", 3)
  20661. .attr("markerHeight", 3)
  20662. .attr("orient", "auto")
  20663. .append("svg:path")
  20664. .attr("d", "M10,-5L0,0L10,5")
  20665. .attr("fill", "#000");
  20666. // line displayed when dragging new nodes
  20667. drag_line = svg
  20668. .append("svg:path")
  20669. .attr("class", "link dragline hidden")
  20670. .attr("d", "M0,0L0,0");
  20671. // handles to link and node element groups
  20672. //(1)var path = svg.append('svg:g').selectAll('g')
  20673. path = svg.append("svg:g").selectAll("g");
  20674. circle = svg.append("svg:g").selectAll("g");
  20675. svg
  20676. .on("mousedown", mousedown)
  20677. .on("mousemove", mousemove)
  20678. .on("mouseup", mouseup);
  20679. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  20680. };
  20681. var CI = {};
  20682. window.CI = CI;
  20683. $scope.ok = function () {
  20684. $modalInstance.close($scope.selected_node);
  20685. };
  20686. $scope.cancel = function () {
  20687. $modalInstance.dismiss("cancel");
  20688. };
  20689. },
  20690. size: size,
  20691. resolve: {
  20692. title: function () {
  20693. return options.templateOptions.title;
  20694. },
  20695. Restangular: function () {
  20696. return options.templateOptions.Restangular;
  20697. },
  20698. APIService: function () {
  20699. return options.templateOptions.ApiService;
  20700. },
  20701. ConfigDataService: function () {
  20702. return options.templateOptions.ConfigDataService;
  20703. },
  20704. ConfigFormService: function () {
  20705. return options.templateOptions.ConfigFormService;
  20706. },
  20707. SweetAlert: function () {
  20708. return options.templateOptions.Alert;
  20709. },
  20710. Toaster: function () {
  20711. return options.templateOptions.toaster;
  20712. },
  20713. },
  20714. });
  20715. modalInstance.result.then(
  20716. function (selectedItem) {
  20717. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20718. },
  20719. function () {
  20720. //console.log('Modal dismissed at: ' + new Date());
  20721. }
  20722. );
  20723. },
  20724. },
  20725. };
  20726. },
  20727. controller: [
  20728. "$scope",
  20729. function ($scope) {
  20730. // setTimeout(function(){
  20731. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20732. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20733. // if(modelData.status==200){
  20734. // $scope.model[$scope.options.key] = modelData.data;
  20735. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20736. // }
  20737. // });
  20738. // },1000);
  20739. },
  20740. ],
  20741. });
  20742. });
  20743. appFormly.run(function (formlyConfig, $parse) {
  20744. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20745. var removeOnHideTransformer = function (fields, model) {
  20746. return fields.map(function (field) {
  20747. if (
  20748. field.hideExpression &&
  20749. (!field.data || !field.data.dontRemoveOnHidden)
  20750. ) {
  20751. addFieldRemoveOnHideWatcher(field);
  20752. }
  20753. if (field.type == "ui-title") {
  20754. addFieldRemoveOnHideWatcher(field);
  20755. }
  20756. return field;
  20757. });
  20758. };
  20759. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20760. function addFieldRemoveOnHideWatcher(field) {
  20761. var watcher = getWatcher();
  20762. if (field.watcher) {
  20763. if (!angular.isArray(field.watcher)) {
  20764. field.watcher = [field.watcher];
  20765. }
  20766. field.watcher.push(watcher);
  20767. } else {
  20768. field.watcher = watcher;
  20769. }
  20770. }
  20771. function getWatcher() {
  20772. return {
  20773. expression: function (field) {
  20774. return field.hide;
  20775. },
  20776. listener: function (field, newHide, oldHide, scope) {
  20777. if (field.hide) {
  20778. if (field.templateOptions.pkey) {
  20779. if (field.key == "transferuser") {
  20780. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20781. scope.model,
  20782. undefined
  20783. );
  20784. }
  20785. } else if(typeof field.key =='string') {
  20786. $parse(field.key).assign(scope.model, undefined);
  20787. }
  20788. }
  20789. if (field.type == "ui-title") {
  20790. $parse(field.key).assign(scope.model, undefined);
  20791. }
  20792. },
  20793. };
  20794. }
  20795. });
  20796. appFormly.controller("CustomformCtrl", [
  20797. "$rootScope",
  20798. "$scope",
  20799. "$parse",
  20800. "$injector",
  20801. "$http",
  20802. "$q",
  20803. "$state",
  20804. "$stateParams",
  20805. "$modal",
  20806. "$timeout",
  20807. "$interval",
  20808. "SweetAlert",
  20809. "FileUploader",
  20810. "i18nService",
  20811. "Restangular",
  20812. "UserRestangular",
  20813. "BpmRestangular",
  20814. "SimpleRestangular",
  20815. "WechatRestangular",
  20816. "api_configure_form",
  20817. "api_bpm_domain",
  20818. "api_bpm_domain1",
  20819. "api_simple",
  20820. "api_bpm",
  20821. "api_bpm_data",
  20822. "api_user_data",
  20823. "api_statistic",
  20824. "up_down_file",
  20825. "fileReader",
  20826. "api_wechatfile",
  20827. "api_category",
  20828. function (
  20829. $rootScope,
  20830. $scope,
  20831. $parse,
  20832. $injector,
  20833. $http,
  20834. $q,
  20835. $state,
  20836. $stateParams,
  20837. $modal,
  20838. $timeout,
  20839. $interval,
  20840. SweetAlert,
  20841. FileUploader,
  20842. i18nService,
  20843. Restangular,
  20844. UserRestangular,
  20845. BpmRestangular,
  20846. SimpleRestangular,
  20847. WechatRestangular,
  20848. api_configure_form,
  20849. api_bpm_domain,
  20850. api_bpm_domain1,
  20851. api_simple,
  20852. api_bpm,
  20853. api_bpm_data,
  20854. api_user_data,
  20855. api_statistic,
  20856. up_down_file,
  20857. fileReader,
  20858. api_wechatfile,
  20859. api_category
  20860. ) {
  20861. //console.log($parse('Restangular')($scope));
  20862. //console.log($injector.get('Restangular'));
  20863. //console.log($stateParams);
  20864. //保存报修主体
  20865. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20866. $scope.imgUrlList = [];
  20867. $scope.uploadimg_del = function () {
  20868. console.log(123);
  20869. };
  20870. var vm = this;
  20871. vm.options = {};
  20872. vm.exampleTitle = ["expressionProperties", "model property"];
  20873. vm.fields = [];
  20874. vm.model = {};
  20875. $scope.langs = i18nService.getAllLangs();
  20876. $scope.lang = "zh-cn";
  20877. i18nService.setCurrentLang($scope.lang);
  20878. //alert($rootScope.user.id,null,2);
  20879. vm.model["loginUser"] = $rootScope.user;
  20880. var loginUser = $rootScope.user;
  20881. // console.log(vm);
  20882. var that = $injector;
  20883. var parse = $parse;
  20884. var formKey = "";
  20885. var pdKey = "";
  20886. var modelWatch = "";
  20887. // 房间号是否显示
  20888. vm.model.isRoom = sessionStorage.getItem('ifRoom') == 1;
  20889. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20890. modelWatch = JSON.parse($stateParams.model);
  20891. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20892. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20893. console.log(modelWatch, $rootScope);
  20894. // if(modelWatch.model.incident){
  20895. // if(modelWatch.model.incident.place){
  20896. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20897. // }else{
  20898. // $rootScope.selecthouseNumber = undefined;
  20899. // }
  20900. // }
  20901. // 初始化的时候判断是否是简单处理
  20902. if(modelWatch.model && modelWatch.model.incident && modelWatch.model.incident.category){
  20903. if (modelWatch.model.incident.category.hasSimple == 1) {
  20904. vm.model.isHasSimple = true;
  20905. }else{
  20906. vm.model.isHasSimple = false;
  20907. }
  20908. }
  20909. }
  20910. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20911. pdKey = $state.current.pdKey;
  20912. } else if ($stateParams.pdKey) {
  20913. pdKey = $stateParams.pdKey;
  20914. }
  20915. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20916. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20917. formKey = $stateParams.formKey;
  20918. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20919. }
  20920. if (angular.isDefined($stateParams.model)) {
  20921. var formModel = $stateParams.model;
  20922. }
  20923. //用户测试数据,后续从header的auth中获取
  20924. var userId = 2;
  20925. userId = $rootScope.user.id;
  20926. //==============处理表单设计数据 开始====================
  20927. //处理组件加载后台数据选项的方法
  20928. function refreshSelectOptions(searchVal, field) {
  20929. if (
  20930. field.templateOptions.optionsUrl &&
  20931. !field.templateOptions.isnosearch
  20932. ) {
  20933. var process = BpmRestangular.all("");
  20934. if (field.templateOptions.ApiService) {
  20935. process = UserRestangular.all("");
  20936. }
  20937. if (field.templateOptions.Apicommon) {
  20938. process = WechatRestangular.all("");
  20939. }
  20940. var datakey = {
  20941. idx: 0,
  20942. sum: 1000,
  20943. };
  20944. if (field.templateOptions.modelreasondata) {
  20945. datakey = field.templateOptions.modelreasondata;
  20946. }
  20947. process
  20948. .customPOST(datakey, field.templateOptions.optionsUrl)
  20949. .then(function (result) {
  20950. if (!field.templateOptions.options) {
  20951. field.templateOptions.options = [];
  20952. }
  20953. if (field.templateOptions.optionsDataKey) {
  20954. field.templateOptions.options =
  20955. result[field.templateOptions.optionsDataKey];
  20956. } else {
  20957. field.templateOptions.options = result;
  20958. }
  20959. });
  20960. }
  20961. }
  20962. //获取表单后数据处理
  20963. function formfield(field, result) {
  20964. // angular.forEach(fields.fields, function(field) {
  20965. if (field.key == "") {
  20966. delete field.key;
  20967. }
  20968. if (angular.isDefined(field.extjson)) {
  20969. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20970. angular.extend(field.templateOptions, extObj.templateOptions);
  20971. delete extObj.templateOptions;
  20972. for (var prop in extObj) {
  20973. if (new RegExp("Expression").test(prop)) {
  20974. //var obj = $scope.$eval(extObj[prop]);
  20975. //extObj[prop] = $scope.$eval(extObj[prop]);
  20976. if (extObj[prop] != null) {
  20977. if (new RegExp("function").test(extObj[prop])) {
  20978. var propValue = eval(extObj[prop]);
  20979. extObj[prop] = propValue;
  20980. } else {
  20981. //console.log(extObj[prop]);
  20982. var obj = $scope.$eval(extObj[prop]);
  20983. extObj[prop] = obj;
  20984. //console.log(obj);
  20985. }
  20986. }
  20987. } else if (new RegExp("expressionProperties").test(prop)) {
  20988. for (var p in extObj[prop]) {
  20989. if (new RegExp("function").test(extObj[prop][p])) {
  20990. var propValue = eval(extObj[prop][p]);
  20991. extObj[prop][p] = propValue;
  20992. } else {
  20993. //if(p.indexOf("'")>=0){
  20994. // var obj = $scope.$eval(extObj[prop][p]);
  20995. // extObj[prop][$scope.$eval(p)]=obj;
  20996. //}
  20997. }
  20998. }
  20999. } else if ("watcher" == prop) {
  21000. if (angular.isArray(extObj[prop])) {
  21001. angular.forEach(extObj[prop], function (item, index) {
  21002. for (var p in item) {
  21003. if (new RegExp("function").test(item[p])) {
  21004. var propValue = eval(item[p]);
  21005. extObj[prop][index][p] = propValue;
  21006. }
  21007. }
  21008. });
  21009. } else if (angular.isObject(extObj[prop])) {
  21010. for (var p in extObj[prop]) {
  21011. if (new RegExp("function").test(extObj[prop][p])) {
  21012. var propValue = eval(extObj[prop][p]);
  21013. extObj[prop][p] = propValue;
  21014. }
  21015. }
  21016. }
  21017. }
  21018. }
  21019. angular.extend(field, extObj);
  21020. delete field.extjson;
  21021. }
  21022. if (angular.isDefined(field.templateOptions)) {
  21023. var templateOs = field.templateOptions;
  21024. // console.log(templateOs,'come')
  21025. for (var property in templateOs) {
  21026. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  21027. if (angular.isString(templateOs[property])) {
  21028. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  21029. if (new RegExp("function").test(templateOs[property])) {
  21030. var propValue = eval(templateOs[property]);
  21031. field.templateOptions[property] = propValue;
  21032. } else {
  21033. if (that.has(templateOs[property])) {
  21034. field.templateOptions[property] = that.get(
  21035. templateOs[property]
  21036. );
  21037. } else {
  21038. field.templateOptions[property] = templateOs[property];
  21039. }
  21040. }
  21041. } else if (templateOs[property] == null) {
  21042. //delete field.templateOptions[property];
  21043. } else {
  21044. }
  21045. }
  21046. }
  21047. if (
  21048. angular.isDefined(field.templateOptions) &&
  21049. angular.isDefined(field.templateOptions.extjson)
  21050. ) {
  21051. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  21052. angular.extend(field.templateOptions, extObj);
  21053. delete field.templateOptions.extjson;
  21054. }
  21055. // ...
  21056. if (field.templateOptions) {
  21057. //处理远程获取数据控件方法调用
  21058. if (
  21059. field.templateOptions.optionsUrl &&
  21060. !field.templateOptions.refresh
  21061. ) {
  21062. // if (!field.templateOptions.isnoreash) {
  21063. field.templateOptions.refresh = refreshSelectOptions;
  21064. // }
  21065. }
  21066. //处理嵌套属性数据绑定/
  21067. if (field.templateOptions.pkey) {
  21068. var pmodel,
  21069. i = 0;
  21070. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  21071. if (i == 0) {
  21072. if (result.model[p] == null) {
  21073. result.model[p] = {};
  21074. }
  21075. pmodel = result.model[p];
  21076. i++;
  21077. } else {
  21078. if (pmodel[p] == null) {
  21079. pmodel[p] = {};
  21080. }
  21081. pmodel = pmodel[p];
  21082. }
  21083. });
  21084. if (pmodel != null) {
  21085. field.model = pmodel;
  21086. if (pmodel[field.key] == null) {
  21087. pmodel[field.key] = null;
  21088. }
  21089. }
  21090. } else {
  21091. if (result.model[field.key] == null) {
  21092. result.model[field.key] = null;
  21093. }
  21094. }
  21095. //处理弹出框组件初始化
  21096. if (field.type == "ui-input-selectmodal") {
  21097. field.templateOptions.modal = $modal;
  21098. //field.templateOptions.Restangular = Restangular;
  21099. } else if (field.type == "ui-requesterselect") {
  21100. //field.templateOptions.language = $scope.lang;
  21101. field.templateOptions.modal = $modal;
  21102. field.templateOptions.UserService = api_user_data;
  21103. } else if (field.type == "ui-deptinformation") {
  21104. field.templateOptions.modal = $modal;
  21105. field.templateOptions.UserService = api_user_data;
  21106. } else if (field.type == "ui-requesterinformation") {
  21107. field.templateOptions.modal = $modal;
  21108. field.templateOptions.UserService = api_user_data;
  21109. } else if (field.type == "ui-userselect") {
  21110. field.templateOptions.modal = $modal;
  21111. //field.templateOptions.Restangular = Restangular;
  21112. } else if (field.type == "ui-userselectSearch") {
  21113. field.templateOptions.modal = $modal;
  21114. //field.templateOptions.Restangular = Restangular;
  21115. } else if (field.type == "ui-multiuserselect") {
  21116. field.templateOptions.modal = $modal;
  21117. } else if (field.type == "ui-stringuserselect") {
  21118. field.templateOptions.modal = $modal;
  21119. } else if (field.type == "ui-search") {
  21120. field.templateOptions.modal = $modal;
  21121. } else if (field.type == "ui-modelselect") {
  21122. field.templateOptions.modal = $modal;
  21123. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  21124. field.templateOptions.loginUser = $rootScope.user;
  21125. //field.templateOptions.Restangular = Restangular;
  21126. } else if (field.type == "ui-incidentmodelselect") {
  21127. field.templateOptions.modal = $modal;
  21128. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  21129. field.templateOptions.loginUser = $rootScope.user;
  21130. //field.templateOptions.Restangular = Restangular;
  21131. } else if (field.type == "ui-dropfile") {
  21132. $scope.fileUploader = field.templateOptions.fileUploader =
  21133. new FileUploader({
  21134. url: "/uploader",
  21135. });
  21136. field.templateOptions.taskId = $stateParams.taskId;
  21137. field.templateOptions.processInstanceId =
  21138. $stateParams.processInstanceId;
  21139. field.templateOptions.userId = $rootScope.user.id;
  21140. } else if (field.type == "ui-dropfielknow") {
  21141. $scope.fileUploader = field.templateOptions.fileUploader =
  21142. new FileUploader({
  21143. url: "/uploader",
  21144. });
  21145. field.templateOptions.taskId = $stateParams.taskId;
  21146. field.templateOptions.processInstanceId =
  21147. $stateParams.processInstanceId;
  21148. field.templateOptions.userId = $rootScope.user.id;
  21149. } else if (field.type == "ui-upDropFile") {
  21150. $scope.fileUploader = field.templateOptions.fileUploader =
  21151. new FileUploader({
  21152. url: "/uploader",
  21153. });
  21154. field.templateOptions.taskId = $stateParams.taskId;
  21155. field.templateOptions.processInstanceId =
  21156. $stateParams.processInstanceId;
  21157. field.templateOptions.userId = $rootScope.user.id;
  21158. } else if (field.type == "ui-dropfilenotup") {
  21159. $scope.fileUploader = field.templateOptions.fileUploader =
  21160. new FileUploader({
  21161. url: "/uploader",
  21162. });
  21163. field.templateOptions.taskId = $stateParams.taskId;
  21164. field.templateOptions.processInstanceId =
  21165. $stateParams.processInstanceId;
  21166. field.templateOptions.userId = $rootScope.user.id;
  21167. //field.ApiService=api_bpm_domain;
  21168. } else if (field.type == "ui-uploadFiles") {
  21169. $scope.fileUploader = field.templateOptions.fileUploader =
  21170. new FileUploader({
  21171. url: "/uploader",
  21172. });
  21173. field.templateOptions.taskId = $stateParams.taskId;
  21174. field.templateOptions.processInstanceId =
  21175. $stateParams.processInstanceId;
  21176. field.templateOptions.userId = $rootScope.user.id;
  21177. //field.ApiService=api_bpm_domain;
  21178. } else if (field.type == "ui-upDownFiles") {
  21179. $scope.fileUploader = field.templateOptions.fileUploader =
  21180. new FileUploader({
  21181. url: "/uploader",
  21182. });
  21183. field.templateOptions.taskId = $stateParams.taskId;
  21184. field.templateOptions.processInstanceId =
  21185. $stateParams.processInstanceId;
  21186. field.templateOptions.userId = $rootScope.user.id;
  21187. //field.ApiService=api_bpm_domain;
  21188. } else if (field.type == "ui-uploadImgs") {
  21189. $scope.fileUploader = field.templateOptions.fileUploader =
  21190. new FileUploader({
  21191. url: "/uploader",
  21192. });
  21193. field.templateOptions.taskId = $stateParams.taskId;
  21194. field.templateOptions.processInstanceId =
  21195. $stateParams.processInstanceId;
  21196. field.templateOptions.userId = $rootScope.user.id;
  21197. //field.ApiService=api_bpm_domain;
  21198. } else if (field.type == "ui-dropfiletable") {
  21199. if (field.templateOptions.processInstanceId) {
  21200. } else {
  21201. field.templateOptions.processInstanceId =
  21202. $stateParams.processInstanceId;
  21203. }
  21204. } else if (field.type == "ui-dropFiles") {
  21205. if (field.templateOptions.processInstanceId) {
  21206. } else {
  21207. field.templateOptions.processInstanceId =
  21208. $stateParams.processInstanceId;
  21209. }
  21210. } else if (field.type == "ui-showImgs") {
  21211. if (field.templateOptions.processInstanceId) {
  21212. } else {
  21213. field.templateOptions.processInstanceId =
  21214. $stateParams.processInstanceId;
  21215. }
  21216. } else if (field.type == "ui-repeatSection") {
  21217. var repeatForm = {
  21218. model: {},
  21219. fields: field.templateOptions.fields,
  21220. };
  21221. repeatForm.model[field.key] = [];
  21222. decodeVMForm(repeatForm);
  21223. } else if (field.type == "ui-currentuser") {
  21224. field.templateOptions.user = vm.model["loginUser"];
  21225. } else if (field.type == "ui-workernumbersign") {
  21226. field.templateOptions.user = vm.model["loginUser"];
  21227. } else if (field.type == "ui-repair-photos") {
  21228. field.templateOptions.user = vm.model["loginUser"];
  21229. }
  21230. }
  21231. }
  21232. //解析自定义表单设计数据
  21233. $scope.oldfromtype = true;
  21234. function decodeVMForm(vmForm) {
  21235. if (vmForm.formType == "1") {
  21236. $scope.oldfromtype = false;
  21237. } else {
  21238. $scope.oldfromtype = true;
  21239. }
  21240. var result = {
  21241. model: {},
  21242. fields: [],
  21243. };
  21244. //设置模型实体数据 begin
  21245. // var mdata = vmForm.model;
  21246. //解析数据实体
  21247. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  21248. angular.extend(result.model, mdata);
  21249. if (modelWatch != null && modelWatch != "") {
  21250. //angular.extend(result.model.incident,modelWatch.incident);
  21251. //result.model.alarmType = modelWatch.alarmType;
  21252. // vmForm.cancelUrl = modelWatch.cancelUrl;
  21253. // console.log(modelWatch.cancelUrl)
  21254. for (var index in modelWatch.model) {
  21255. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  21256. if (result.model[index] != null) {
  21257. angular.extend(result.model[index], modelWatch.model[index]);
  21258. } else {
  21259. result.model[index] = modelWatch.model[index];
  21260. }
  21261. }
  21262. }
  21263. //设置模型实体数据 end
  21264. //解析设计数据生成表单项 begin
  21265. var fields = [];
  21266. //处理修改设计数据中展示设置
  21267. angular.forEach(vmForm.fields, function (fields) {
  21268. if (vmForm.formType == "1") {
  21269. angular.forEach(fields.fields, function (field) {
  21270. formfield(field, result);
  21271. });
  21272. } else {
  21273. formfield(fields, result);
  21274. }
  21275. // console.log(field);
  21276. result.fields.push(fields);
  21277. });
  21278. angular.extend($scope.vm.fields, result.fields);
  21279. angular.extend($scope.vm.model, result.model);
  21280. vm.model["loginUser"] = $rootScope.user;
  21281. //增加识别报修主体seimin
  21282. vm.model.repairType = $scope.repairMain.valueconfig;
  21283. if (vm.model.incident) {
  21284. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  21285. }
  21286. console.log(vm, "repairType"); //lmm
  21287. if (
  21288. modelWatch != null &&
  21289. modelWatch != "" &&
  21290. modelWatch.cancelUrl != null &&
  21291. modelWatch.cancelUrl != ""
  21292. ) {
  21293. vmForm.cancelUrl = modelWatch.cancelUrl;
  21294. }
  21295. $scope.formData = vmForm;
  21296. console.log($scope.formData, 4444444);
  21297. // console.log($scope.formData.url);
  21298. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  21299. if ($scope.formData.url == "start") {
  21300. $scope.Reset = true;
  21301. $scope.close = true;
  21302. $rootScope.isMask = false;
  21303. } else if ($scope.formData.url == "complete") {
  21304. $scope.Reset = false;
  21305. $scope.close = true;
  21306. }
  21307. //解析设计数据生成表单项 end
  21308. return result;
  21309. }
  21310. //======================处理表单设计数据 结束========================
  21311. $scope.ldloading = {};
  21312. function filter(obj) {
  21313. angular.forEach(obj, function (key, value) {
  21314. if (value === "" || value === null) {
  21315. delete obj[key];
  21316. } else if (
  21317. Object.prototype.toString.call(value) === "[object Object]"
  21318. ) {
  21319. filter(value);
  21320. } else if (angular.isArray(value)) {
  21321. angular.forEach(value, function (item) {
  21322. filter(item);
  21323. });
  21324. }
  21325. });
  21326. }
  21327. $scope.closeModel = function () {
  21328. // console.log($stateParams);
  21329. $state.go($scope.formData.cancelUrl, {});
  21330. event.preventDefault();
  21331. };
  21332. // console.log(vm);
  21333. // 暂存
  21334. $scope.save = function (data) {
  21335. console.log(vm);
  21336. if (vm.model.startSave) {
  21337. vm.model["initUser"] = $rootScope.user.id;
  21338. vm.model.start_code = "temporary";
  21339. //处理请求数据0327
  21340. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21341. delete data0327.repairType;
  21342. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  21343. if (
  21344. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21345. .selecthouseNumber
  21346. ) {
  21347. data0327.incident.place = {
  21348. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21349. .selecthouseNumber.id,
  21350. };
  21351. }
  21352. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  21353. if (response) {
  21354. var resData = Restangular.stripRestangular(response);
  21355. if (resData) {
  21356. if (
  21357. $scope.fileUploader != null &&
  21358. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  21359. resData.id
  21360. ) {
  21361. $scope.fileUploader.onBeforeUploadItem = function (item) {
  21362. angular.extend(item.headers, $rootScope.getSession());
  21363. item.url = api_bpm_domain
  21364. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  21365. .getRequestedUrl();
  21366. item.formData.push({
  21367. fileName: item.file.name,
  21368. });
  21369. //console.log();
  21370. };
  21371. $scope.fileUploader.uploadAll();
  21372. }
  21373. }
  21374. SweetAlert.swal(
  21375. {
  21376. title: "提交成功!",
  21377. type: "success",
  21378. confirmButtonColor: "#007AFF",
  21379. },
  21380. function () {
  21381. $state.go($scope.formData.cancelUrl);
  21382. }
  21383. );
  21384. } else {
  21385. SweetAlert.swal({
  21386. title: "系统错误",
  21387. text: "系统错误,请稍后重试!",
  21388. type: "error",
  21389. confirmButtonColor: "#DD6B55",
  21390. });
  21391. }
  21392. $scope.ldloading[style.replace("-", "_")] = false;
  21393. });
  21394. event.preventDefault();
  21395. } else if (vm.model.saveAgain) {
  21396. var toData = {
  21397. incident: vm.model.incident,
  21398. };
  21399. api_user_data.updData("incident", toData).then(function (response) {
  21400. if (response) {
  21401. var resData = Restangular.stripRestangular(response);
  21402. SweetAlert.swal(
  21403. {
  21404. title: "提交成功!",
  21405. type: "success",
  21406. confirmButtonColor: "#007AFF",
  21407. },
  21408. function () {
  21409. $state.go($scope.formData.cancelUrl);
  21410. }
  21411. );
  21412. } else {
  21413. SweetAlert.swal({
  21414. title: "系统错误",
  21415. text: "系统错误,请稍后重试!",
  21416. type: "error",
  21417. confirmButtonColor: "#DD6B55",
  21418. });
  21419. }
  21420. $scope.ldloading[style.replace("-", "_")] = false;
  21421. });
  21422. event.preventDefault();
  21423. } else {
  21424. SweetAlert.swal({
  21425. title: "系统错误",
  21426. text: "系统错误,请稍后重试!",
  21427. type: "error",
  21428. confirmButtonColor: "#DD6B55",
  21429. });
  21430. }
  21431. };
  21432. // 巡检生成事件
  21433. $scope.inspectionToIncident = function () {
  21434. var userData = {
  21435. idx: 0,
  21436. sum: 10,
  21437. user: {
  21438. name: loginUser.name,
  21439. engineer: undefined,
  21440. },
  21441. };
  21442. api_user_data.fetchDataList("user", userData).then(function (res) {
  21443. console.log(res);
  21444. var toUser = {};
  21445. if (res.list.length > 0) {
  21446. toUser = res.list[0];
  21447. } else {
  21448. toUser = loginUser;
  21449. }
  21450. console.log(vm);
  21451. var incidentDescription = "";
  21452. console.log($stateParams.formUiEdit);
  21453. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  21454. var fields = vm.fields
  21455. .filter((v) => {
  21456. v.key = (v.key || "").toString();
  21457. return v.key.indexOf("sdCheckEnable") > -1;
  21458. })
  21459. .map((v) => ({
  21460. key: v.key,
  21461. name: v.templateOptions.label,
  21462. value: vm.model[v.key],
  21463. }));
  21464. fields.forEach(v=>{
  21465. if (vm.model[v.key]) {
  21466. incidentDescription =
  21467. incidentDescription.concat(v.name);
  21468. }
  21469. })
  21470. if (vm.model.descriptionTextarea) {
  21471. incidentDescription = incidentDescription.concat(
  21472. " " + "整改意见:" + vm.model.descriptionTextarea
  21473. );
  21474. }
  21475. }
  21476. // console.log(incidentDescription)
  21477. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  21478. var formdata = {
  21479. model: {
  21480. // 'isInspection': true,
  21481. // 'start_code':'assignment',
  21482. // 'isHandlerUser':false,
  21483. incident: {
  21484. requester: bxr,
  21485. area: bxr.place.area,
  21486. place: bxr.place,
  21487. houseNumber: bxr.houseNumber,
  21488. contacts: bxr.name,
  21489. contactsInformation: bxr.phone,
  21490. // 'category': data.wxIncidentClassifyDTO.category,
  21491. description: incidentDescription,
  21492. source: {
  21493. id: 1552,
  21494. },
  21495. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  21496. // 'sourceType': data.incident.sourceType,
  21497. // 'fileUrl': data.incident.fileUrl
  21498. },
  21499. // 'requestershow': toUser,//2020年4月27日22:29:15
  21500. // 'flow': data.incident.id
  21501. // 'assignee': loginUser.id//2020年4月27日22:29:25
  21502. },
  21503. };
  21504. // console.log(formdata,toUser,'1111');
  21505. console.log(formdata, "1111");
  21506. // return;
  21507. $state.go("app.incident.chart", {
  21508. model: JSON.stringify(formdata),
  21509. });
  21510. });
  21511. // var formdata = {
  21512. // model:$rootScope.login_requester
  21513. // };
  21514. // console.log(formdata,'00000')
  21515. // return;
  21516. // $state.go("app.incident.chart", {
  21517. // 'model': JSON.stringify(formdata)
  21518. // });
  21519. event.preventDefault();
  21520. };
  21521. // console.log(vm);
  21522. // 创建事件seimin
  21523. vm.submit = function (data, style) {
  21524. console.log(vm, 22222);
  21525. // return;
  21526. if (vm.model.handler_code == undefined) {
  21527. vm.model.handler_code = "resolve";
  21528. }
  21529. if (
  21530. vm.model.change &&
  21531. vm.model.change.requestingPerson &&
  21532. vm.model.change.requestingPerson.menu
  21533. ) {
  21534. delete vm.model.change.requestingPerson.menu;
  21535. }
  21536. // var pdKey = $stateParams.pdKey;
  21537. if (vm.form.$valid) {
  21538. if (data.incident && data.incident.synergetic) {
  21539. console.log(data.incident.synergetic);
  21540. var synergetic = [];
  21541. for (var i = 0; i < data.incident.synergetic.length; i++) {
  21542. synergetic.push({
  21543. id: data.incident.synergetic[i],
  21544. });
  21545. }
  21546. data.incident.synergetic = synergetic;
  21547. vm.model.incident.synergetic = synergetic;
  21548. }
  21549. $scope.ldloading[style.replace("-", "_")] = true;
  21550. var startsub = true;
  21551. if (pdKey == "bpm_incident") {
  21552. angular.forEach(vm.fields, function (item) {
  21553. angular.forEach(item.fields, function (index) {
  21554. if (index.templateOptions.required && !index.hide) {
  21555. if (index.model) {
  21556. if(Object.prototype.toString.call(index.model[index.key]).slice(8, -1).toLowerCase() === 'object' && !index.model[index.key].id){
  21557. startsub = false;
  21558. $scope.ldloading.expand_right = false;
  21559. console.log(vm);
  21560. SweetAlert.swal({
  21561. title: index.templateOptions.label + "未填",
  21562. text: "请填写此项!",
  21563. type: "error",
  21564. confirmButtonColor: "#DD6B55",
  21565. });
  21566. }else if (
  21567. angular.isDefined(index.model[index.key]) &&
  21568. index.model[index.key] != null
  21569. ) {
  21570. if (
  21571. index.model[index.key].id &&
  21572. index.model[index.key].id == ""
  21573. ) {
  21574. startsub = false;
  21575. $scope.ldloading.expand_right = false;
  21576. SweetAlert.swal({
  21577. title: index.templateOptions.label + "未填",
  21578. text: "请填写此项!",
  21579. type: "error",
  21580. confirmButtonColor: "#DD6B55",
  21581. });
  21582. } else {
  21583. }
  21584. } else {
  21585. startsub = false;
  21586. $scope.ldloading.expand_right = false;
  21587. console.log(vm);
  21588. SweetAlert.swal({
  21589. title: index.templateOptions.label + "未填",
  21590. text: "请填写此项!",
  21591. type: "error",
  21592. confirmButtonColor: "#DD6B55",
  21593. });
  21594. }
  21595. } else {
  21596. if (
  21597. data[index.key] &&
  21598. data[index.key] != "" &&
  21599. data[index.key] != null
  21600. ) {
  21601. } else {
  21602. startsub = false;
  21603. $scope.ldloading.expand_right = false;
  21604. SweetAlert.swal({
  21605. title: index.templateOptions.label + "未填",
  21606. text: "请填写此项!",
  21607. type: "error",
  21608. confirmButtonColor: "#DD6B55",
  21609. });
  21610. }
  21611. }
  21612. }
  21613. });
  21614. });
  21615. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  21616. // startsub = false;
  21617. // $scope.ldloading.expand_right = false;
  21618. // SweetAlert.swal({
  21619. // title: '保修人未填',
  21620. // text: "请填写此项!",
  21621. // type: "error",
  21622. // confirmButtonColor: "#DD6B55"
  21623. // });
  21624. // }
  21625. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  21626. // } else {
  21627. // startsub = false;
  21628. // $scope.ldloading.expand_right = false;
  21629. // SweetAlert.swal({
  21630. // title: '故障现象未填',
  21631. // text: "请填写此项!",
  21632. // type: "error",
  21633. // confirmButtonColor: "#DD6B55"
  21634. // });
  21635. // }
  21636. }
  21637. if (startsub) {
  21638. $scope.ldloading[style.replace("-", "_")] = true;
  21639. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  21640. // console.log("vm.options:"+ JSON.stringify(vm.options));
  21641. vm.options.updateInitialValue();
  21642. // console.log("dfjkasdhfkhskjf ")
  21643. var _ = window._;
  21644. vm.model = (function filter(obj) {
  21645. var dateTransKeys = [];
  21646. var filtered = _.pick(obj, function (v, k, obj) {
  21647. if (_.isDate(v)) {
  21648. dateTransKeys.push(k);
  21649. }
  21650. return (
  21651. angular.isDefined(v) &&
  21652. v !== null &&
  21653. (angular.isArray(v) ? v.length > 0 : true) &&
  21654. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  21655. );
  21656. });
  21657. return _.cloneDeep(filtered, function (v, index, object) {
  21658. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  21659. angular.forEach(dateTransKeys, function (item) {
  21660. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  21661. });
  21662. dateTransKey = [];
  21663. return v;
  21664. }
  21665. return !_.isEmpty(filtered) &&
  21666. v !== filtered &&
  21667. _.isPlainObject(v)
  21668. ? filter(v)
  21669. : undefined;
  21670. });
  21671. })(vm.model);
  21672. if (pdKey != "") {
  21673. if ($scope.oprcode == "save") {
  21674. //保存
  21675. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  21676. if (response) {
  21677. var resData = Restangular.stripRestangular(response);
  21678. SweetAlert.swal(
  21679. {
  21680. title: "保存成功!",
  21681. confirmButtonColor: "#007AFF",
  21682. },
  21683. function () {
  21684. $state.go($scope.formData.cancelUri);
  21685. }
  21686. );
  21687. // if(resData.status){
  21688. // resData
  21689. // }
  21690. } else {
  21691. SweetAlert.swal({
  21692. title: "系统错误",
  21693. text: "系统错误,请稍后重试!",
  21694. type: "error",
  21695. confirmButtonColor: "#DD6B55",
  21696. });
  21697. }
  21698. $scope.ldloading[style.replace("-", "_")] = false;
  21699. });
  21700. } else {
  21701. console.log($scope.formData.url, "zzzz");
  21702. var integralMechanism = sessionStorage.getItem('integralMechanism');
  21703. switch ($scope.formData.url) {
  21704. case "start":
  21705. vm.model["initUser"] = $rootScope.user.id;
  21706. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  21707. } else {
  21708. vm.model["assignee"] = $rootScope.user.id;
  21709. }
  21710. if (
  21711. vm.model["candidateGroups"] &&
  21712. vm.model.candidateGroups.id
  21713. ) {
  21714. vm.model.candidateGroups = vm.model.candidateGroups.id;
  21715. }
  21716. if (pdKey == "bpm_service_request") {
  21717. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  21718. angular.extend(vm.model.serviceCatalogueProcessActual, {
  21719. category: {
  21720. id: $stateParams.userId,
  21721. },
  21722. });
  21723. }
  21724. if (vm.model.schedule && vm.model.schedule.initUser) {
  21725. delete vm.model.schedule.initUser.menu;
  21726. }
  21727. if (
  21728. vm.model.isHandlerUser == "true" ||
  21729. vm.model.isHandlerUser == true
  21730. ) {
  21731. delete vm.model.candidateGroups;
  21732. }
  21733. if (vm.model.start_code == "close") {
  21734. // 直接处理
  21735. vm.model.incident.handlingPersonnelUser =
  21736. vm.model.incident.acceptUser;
  21737. delete vm.model.incident.handlerUser;
  21738. delete vm.model.candidateGroups;
  21739. } else if (vm.model.start_code == "assignment") {
  21740. // 派单
  21741. delete vm.model.incident.handlingPersonnelUser;
  21742. }
  21743. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21744. $scope.jry_processInstanceId =
  21745. $stateParams.processInstanceId;
  21746. }
  21747. if ($scope.jry_processInstanceId) {
  21748. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21749. }
  21750. //事件暂存判断
  21751. if (vm.model.saveAgain) {
  21752. if (
  21753. vm.model.directClose == "1" ||
  21754. vm.model.directClose == true
  21755. ) {
  21756. vm.model.start_code = "assignment";
  21757. vm.model.temporary_code = "assignment";
  21758. } else {
  21759. vm.model.start_code = "close";
  21760. vm.model.temporary_code = "close";
  21761. }
  21762. if (
  21763. vm.model.isHandlerUser == "true" ||
  21764. vm.model.isHandlerUser == true
  21765. ) {
  21766. delete vm.model.candidateGroups;
  21767. }
  21768. }
  21769. //处理请求数据0327
  21770. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21771. delete data0327.repairType;
  21772. if (data0327.start_code == "close") {
  21773. data0327.incident.directProcess = 1;
  21774. }
  21775. console.log(vm);
  21776. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21777. var paramsModel = JSON.parse($stateParams.model)
  21778. //来电-传话机id
  21779. if (paramsModel.model.incident.sockid) {
  21780. data0327.incident.callID = paramsModel.model.incident.sockid;
  21781. }
  21782. }
  21783. // --------------------------- start----------------------------------------
  21784. // 积分机制,直接处理
  21785. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21786. $modal.open({
  21787. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21788. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21789. console.log(incidentData,currentUserId);
  21790. $scope.flag = false;
  21791. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21792. $scope.complexityFn = function(category){
  21793. if(category.complexity){
  21794. return category.complexity.value;
  21795. }else if(category.parent){
  21796. return $scope.complexityFn(category.parent);
  21797. }else{
  21798. return $scope.list[0]?$scope.list[0].value:1;
  21799. }
  21800. }
  21801. $scope.list = [];
  21802. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21803. $scope.list = res;
  21804. if(incidentData.category && incidentData.category.id){
  21805. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21806. if(result.status == 200){
  21807. $scope.complexity = $scope.complexityFn(result.data);
  21808. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21809. }
  21810. })
  21811. }
  21812. })
  21813. $scope.onChangeComplexity = function(item){
  21814. }
  21815. $scope.ok = function () {
  21816. if (!$scope.complexityConfirm.complexity){
  21817. Alert.swal({
  21818. title: "操作失败",
  21819. text: "请选择工时!",
  21820. type: "error"
  21821. });
  21822. return;
  21823. }
  21824. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21825. Alert.swal({
  21826. title: "操作失败",
  21827. text: "请填写升级原因!",
  21828. type: "error"
  21829. });
  21830. return;
  21831. }
  21832. $modalInstance.close('success');
  21833. handlerStart();
  21834. scope.complexity = $scope.complexity;
  21835. scope.complexityConfirm = $scope.complexityConfirm;
  21836. // 暂存--后面直接处理后调用积分接口
  21837. }
  21838. $scope.cancel = function () {
  21839. scope.ldloading.expand_right = false;
  21840. $modalInstance.dismiss('cancel');
  21841. }
  21842. },
  21843. size: 'sm',
  21844. resolve: {
  21845. scope: function () {
  21846. return $scope;
  21847. },
  21848. api_bpm: function () {
  21849. return api_bpm;
  21850. },
  21851. incidentData: function () {
  21852. return data0327.incident;
  21853. },
  21854. currentUserId: function () {
  21855. return loginUser.id;
  21856. },
  21857. Alert: function () {
  21858. return SweetAlert;
  21859. },
  21860. api_user_data: function () {
  21861. return api_user_data;
  21862. },
  21863. api_wechatfile: function () {
  21864. return api_wechatfile;
  21865. }
  21866. }
  21867. });
  21868. }else{
  21869. handlerStart();
  21870. }
  21871. // -------------------------------end------------------------------------
  21872. function handlerStart(){
  21873. api_bpm_domain
  21874. .start(pdKey, data0327)
  21875. .then(function (response) {
  21876. if (response) {
  21877. var resData = Restangular.stripRestangular(response);
  21878. if (resData) {
  21879. if (resData) {
  21880. if (
  21881. $scope.fileUploader != null &&
  21882. $scope.fileUploader.getNotUploadedItems().length >
  21883. 0 &&
  21884. resData.id
  21885. ) {
  21886. $scope.fileUploader.onBeforeUploadItem =
  21887. function (item) {
  21888. angular.extend(
  21889. item.headers,
  21890. $rootScope.getSession()
  21891. );
  21892. item.url = api_bpm_domain
  21893. .uploadAttachment(
  21894. resData.id,
  21895. "00000",
  21896. $rootScope.user.id
  21897. )
  21898. .getRequestedUrl();
  21899. item.formData.push({
  21900. fileName: item.file.name,
  21901. });
  21902. //console.log();
  21903. };
  21904. $scope.fileUploader.uploadAll();
  21905. }
  21906. }
  21907. }
  21908. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21909. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21910. var auditState = res.find(v=>v.value == 0);
  21911. var postData = {
  21912. incidentIntegral: {
  21913. incidentId:resData.bussId,
  21914. auditState:auditState,
  21915. handlerUser:$rootScope.user.id,
  21916. handlerUserName:$rootScope.user.name,
  21917. sourceScore:$scope.complexity,
  21918. currentScore:$scope.complexityConfirm.complexity.value,
  21919. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21920. }
  21921. }
  21922. console.log(postData)
  21923. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21924. console.log(response)
  21925. if (response.status == 200) {
  21926. SweetAlert.swal(
  21927. {
  21928. title: "提交成功!",
  21929. type: "success",
  21930. confirmButtonColor: "#007AFF",
  21931. },
  21932. function () {
  21933. if (
  21934. vm.model.incident &&
  21935. vm.model.incident.callID &&
  21936. vm.model.incident.callID != ""
  21937. ) {
  21938. $rootScope.app.layout.isSidebarClosed = false;
  21939. if ($scope.login && !$rootScope.busy) {
  21940. $rootScope.setidle();
  21941. }
  21942. }
  21943. $state.go($scope.formData.cancelUrl);
  21944. }
  21945. );
  21946. } else {
  21947. Alert.swal({
  21948. title: "操作失败",
  21949. text: "操作失败, 请稍后再试!",
  21950. type: "error"
  21951. });
  21952. }
  21953. });
  21954. })
  21955. }else{
  21956. SweetAlert.swal(
  21957. {
  21958. title: "提交成功!",
  21959. type: "success",
  21960. confirmButtonColor: "#007AFF",
  21961. },
  21962. function () {
  21963. if (
  21964. vm.model.incident &&
  21965. vm.model.incident.callID &&
  21966. vm.model.incident.callID != ""
  21967. ) {
  21968. $rootScope.app.layout.isSidebarClosed = false;
  21969. if ($scope.login && !$rootScope.busy) {
  21970. $rootScope.setidle();
  21971. }
  21972. }
  21973. $state.go($scope.formData.cancelUrl);
  21974. }
  21975. );
  21976. }
  21977. } else {
  21978. SweetAlert.swal({
  21979. title: "系统错误",
  21980. text: "系统错误,请稍后重试!",
  21981. type: "error",
  21982. confirmButtonColor: "#DD6B55",
  21983. });
  21984. }
  21985. $scope.ldloading[style.replace("-", "_")] = false;
  21986. });
  21987. }
  21988. break;
  21989. case "complete":
  21990. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21991. //console.log("complete taskId::"+$stateParams.taskId);
  21992. if (
  21993. $scope.formData.name == "transferform" &&
  21994. vm.model.ishandlers &&
  21995. !vm.model.incident.handlerUser
  21996. ) {
  21997. SweetAlert.swal({
  21998. title: "处理人未填",
  21999. text: "请填写此项!",
  22000. type: "error",
  22001. confirmButtonColor: "#DD6B55",
  22002. });
  22003. return;
  22004. }
  22005. console.log(vm);
  22006. // 积分机制,事件状态是“处理中”
  22007. if($scope.formData.name === 'handlerform'&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  22008. $modal.open({
  22009. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  22010. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  22011. console.log(incidentData,currentUserId);
  22012. $scope.flag = true;
  22013. $scope.complexityConfirm = {complexity:null,updateReason:''};
  22014. $scope.complexityFn = function(category){
  22015. if(category.complexity){
  22016. return category.complexity.value;
  22017. }else if(category.parent){
  22018. return $scope.complexityFn(category.parent);
  22019. }else{
  22020. return $scope.list[0]?$scope.list[0].value:1;
  22021. }
  22022. }
  22023. $scope.list = [];
  22024. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  22025. $scope.list = res;
  22026. if(incidentData.category && incidentData.category.id){
  22027. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  22028. if(result.status == 200){
  22029. $scope.complexity = $scope.complexityFn(result.data);
  22030. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  22031. }
  22032. })
  22033. }
  22034. })
  22035. $scope.onChangeComplexity = function(item){
  22036. if($scope.complexityConfirm.complexity.value == $scope.complexity){
  22037. $scope.complexityConfirm.updateReason = '';
  22038. }
  22039. }
  22040. $scope.ok = function () {
  22041. if (!$scope.complexityConfirm.complexity){
  22042. Alert.swal({
  22043. title: "操作失败",
  22044. text: "请选择工时!",
  22045. type: "error"
  22046. });
  22047. return;
  22048. }
  22049. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  22050. Alert.swal({
  22051. title: "操作失败",
  22052. text: "请填写升级原因!",
  22053. type: "error"
  22054. });
  22055. return;
  22056. }
  22057. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  22058. // var auditState = $scope.complexityConfirm.complexity.value == $scope.complexity?res.find(v=>v.value == 1):res.find(v=>v.value == 0);
  22059. var auditState = res.find(v=>v.value == 0);
  22060. var postData = {
  22061. incidentIntegral: {
  22062. incidentId:incidentData.id,
  22063. auditState:auditState,
  22064. handlerUser:$rootScope.user.id,
  22065. handlerUserName:$rootScope.user.name,
  22066. sourceScore:$scope.complexity,
  22067. currentScore:$scope.complexityConfirm.complexity.value,
  22068. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  22069. }
  22070. }
  22071. console.log(postData)
  22072. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  22073. console.log(response)
  22074. if (response.status == 200) {
  22075. $modalInstance.close('success');
  22076. handlerLogFn();
  22077. } else {
  22078. Alert.swal({
  22079. title: "操作失败",
  22080. text: "操作失败, 请稍后再试!",
  22081. type: "error"
  22082. });
  22083. }
  22084. });
  22085. })
  22086. }
  22087. $scope.cancel = function () {
  22088. scope.ldloading.expand_right = false;
  22089. $modalInstance.dismiss('cancel');
  22090. }
  22091. },
  22092. size: 'sm',
  22093. resolve: {
  22094. scope: function () {
  22095. return $scope;
  22096. },
  22097. api_bpm: function () {
  22098. return api_bpm;
  22099. },
  22100. incidentData: function () {
  22101. return $scope.formData.model.incident;
  22102. },
  22103. currentUserId: function () {
  22104. return loginUser.id;
  22105. },
  22106. Alert: function () {
  22107. return SweetAlert;
  22108. },
  22109. api_user_data: function () {
  22110. return api_user_data;
  22111. },
  22112. api_wechatfile: function () {
  22113. return api_wechatfile;
  22114. }
  22115. }
  22116. });
  22117. }else{
  22118. handlerLogFn();
  22119. }
  22120. function handlerLogFn(){
  22121. //维修记录
  22122. // 维修记录不为空并且事件是处理中状态
  22123. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  22124. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  22125. baseHandler();
  22126. })
  22127. } else {
  22128. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  22129. //巡检计划
  22130. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  22131. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  22132. if (response.status == 200) {
  22133. baseHandler();
  22134. } else {
  22135. Alert.swal({
  22136. title: "操作失败",
  22137. text: "操作失败, 请稍后再试!",
  22138. type: "error"
  22139. });
  22140. }
  22141. });
  22142. }else{
  22143. baseHandler();
  22144. }
  22145. }else{
  22146. baseHandler();
  22147. }
  22148. }
  22149. }
  22150. // return;
  22151. function baseHandler() {
  22152. api_bpm_domain
  22153. .complete($stateParams.taskId, userId, vm.model)
  22154. .then(function (response) {
  22155. if (response) {
  22156. var resData = Restangular.stripRestangular(response);
  22157. SweetAlert.swal(
  22158. {
  22159. title: "提交成功!",
  22160. type: "success",
  22161. confirmButtonColor: "#007AFF",
  22162. },
  22163. function () {
  22164. if (
  22165. $scope.fileUploader != null &&
  22166. $scope.fileUploader.getNotUploadedItems().length >
  22167. 0
  22168. ) {
  22169. console.log(vm);
  22170. if (vm.model.incident) {
  22171. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  22172. // angular.extend(item.headers, $rootScope.getSession());
  22173. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  22174. // item.formData.push({
  22175. // 'fileName': item.file.name
  22176. // });
  22177. // };
  22178. // $scope.fileUploader.uploadAll();
  22179. $scope.fileUploader.onBeforeUploadItem =
  22180. function (item) {
  22181. angular.extend(
  22182. item.headers,
  22183. $rootScope.getSession()
  22184. );
  22185. item.url = api_bpm_domain
  22186. .uploadAttachment(
  22187. vm.model.incident.processInstanceId,
  22188. "00000",
  22189. $rootScope.user.id
  22190. )
  22191. .getRequestedUrl();
  22192. item.formData.push({
  22193. fileName: item.file.name,
  22194. });
  22195. //console.log();
  22196. };
  22197. $scope.fileUploader.uploadAll();
  22198. } else if (vm.model.problem) {
  22199. $scope.fileUploader.onBeforeUploadItem =
  22200. function (item) {
  22201. angular.extend(
  22202. item.headers,
  22203. $rootScope.getSession()
  22204. );
  22205. item.url = api_bpm_domain
  22206. .uploadAttachmentJryModel(
  22207. "problem",
  22208. vm.model.problem.id,
  22209. "00000",
  22210. $rootScope.user.id
  22211. )
  22212. .getRequestedUrl();
  22213. item.formData.push({
  22214. fileName: item.file.name,
  22215. });
  22216. };
  22217. $scope.fileUploader.uploadAll();
  22218. } else if (vm.model.change) {
  22219. }else if(vm.model.inspectionProcessActual){
  22220. //巡检图片上传yeye
  22221. $scope.fileUploader.onBeforeUploadItem =
  22222. function (item) {
  22223. angular.extend(
  22224. item.headers,
  22225. $rootScope.getSession()
  22226. );
  22227. item.url = api_bpm_domain1
  22228. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  22229. .getRequestedUrl();
  22230. item.formData.push({
  22231. fileName: item.file.name,
  22232. });
  22233. //console.log();
  22234. };
  22235. $scope.fileUploader.uploadAll();
  22236. }
  22237. }
  22238. $state.go($scope.formData.cancelUrl);
  22239. }
  22240. );
  22241. } else {
  22242. SweetAlert.swal({
  22243. title: "系统错误",
  22244. text: "系统错误,请稍后重试!",
  22245. type: "error",
  22246. confirmButtonColor: "#DD6B55",
  22247. });
  22248. }
  22249. $scope.ldloading[style.replace("-", "_")] = false;
  22250. });
  22251. }
  22252. break;
  22253. case "back":
  22254. $state.go($scope.formData.cancelUrl);
  22255. break;
  22256. default:
  22257. $scope.ldloading[style.replace("-", "_")] = false;
  22258. break;
  22259. }
  22260. }
  22261. // var submitFunc = api_bpm_domain[$scope.formData.url]
  22262. // if(anuglar.isFunction(submitFunc)){
  22263. // submitFunc.apply(null, pdKey)
  22264. // }
  22265. }
  22266. }
  22267. } else {
  22268. // console.log(data)
  22269. // angular.forEach(vm.form.$error.required, function(item){
  22270. // var i=(item.$name).substring(item.$name.length-2)
  22271. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  22272. // for(var i=0;i<vm.fields.length;i++){
  22273. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  22274. SweetAlert.swal({
  22275. title: vm.fields[i].templateOptions.label + "未填",
  22276. text: "请填写此项!",
  22277. type: "error",
  22278. confirmButtonColor: "#DD6B55",
  22279. });
  22280. }
  22281. // }
  22282. // angular.forEach(vm.fields,function(f){
  22283. // if(f.name == item.$name){
  22284. // f.validation.show = true;
  22285. // SweetAlert.swal({
  22286. // title: f.templateOptions.label+'未填',
  22287. // text: "请填写此项!",
  22288. // type: "error",
  22289. // confirmButtonColor: "#DD6B55"
  22290. // });
  22291. // }
  22292. // });
  22293. // })
  22294. }
  22295. };
  22296. $scope.vm = vm;
  22297. console.log($stateParams, pdKey, 88888);
  22298. console.log($scope.vm, "assdfsdf");
  22299. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  22300. var processInstanceId = $stateParams.processInstanceId;
  22301. var itemId = $stateParams.dataId;
  22302. console.log($stateParams);
  22303. if (
  22304. angular.isDefined($stateParams.pdKey) &&
  22305. $stateParams.pdKey == "bpm_inspection"
  22306. ) {
  22307. api_configure_form
  22308. .renderForm(
  22309. $stateParams.formUiEdit,
  22310. userId,
  22311. processInstanceId,
  22312. itemId
  22313. )
  22314. .then(function (responseData) {
  22315. if (responseData) {
  22316. //console.log("responseData>>>");//console.log(responseData);
  22317. var vmForm = Restangular.stripRestangular(responseData);
  22318. if (vmForm) {
  22319. //console.log("vmForm>>>");//console.log(vmForm);
  22320. decodeVMForm(vmForm);
  22321. }
  22322. }
  22323. });
  22324. } else if (
  22325. angular.isDefined($stateParams.pdKey) &&
  22326. $stateParams.pdKey == "bpm_service_request"
  22327. ) {
  22328. api_configure_form
  22329. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  22330. .then(function (responseData) {
  22331. if (responseData) {
  22332. //console.log("responseData>>>");//console.log(responseData);
  22333. var vmForm = Restangular.stripRestangular(responseData);
  22334. if (vmForm) {
  22335. //console.log("vmForm>>>");//console.log(vmForm);
  22336. decodeVMForm(vmForm);
  22337. }
  22338. }
  22339. });
  22340. } else {
  22341. api_bpm_domain
  22342. .taskformkey($stateParams.taskId)
  22343. .then(function (response) {
  22344. if (response) {
  22345. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  22346. api_configure_form
  22347. .renderForm(myData.data, userId, processInstanceId, itemId)
  22348. .then(function (responseData) {
  22349. if (responseData) {
  22350. //console.log("responseData>>>");//console.log(responseData);
  22351. var vmForm = Restangular.stripRestangular(responseData);
  22352. if (vmForm) {
  22353. //console.log("vmForm>>>");//console.log(vmForm);
  22354. decodeVMForm(vmForm);
  22355. console.log(vmForm, 111111);
  22356. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  22357. console.log($scope, "今天"); //2020年4月24日11:40:55
  22358. }
  22359. }
  22360. });
  22361. }
  22362. });
  22363. }
  22364. } else {
  22365. // create process instance
  22366. if (pdKey != "") {
  22367. //for process
  22368. if (pdKey == "bpm_service_request") {
  22369. api_configure_form
  22370. .renderForm($stateParams.formUiStart, userId)
  22371. .then(function (responseData) {
  22372. if (responseData) {
  22373. var vmForm = Restangular.stripRestangular(responseData);
  22374. if (vmForm) {
  22375. decodeVMForm(vmForm);
  22376. }
  22377. }
  22378. });
  22379. } else {
  22380. api_bpm_domain.startformkey(pdKey).then(function (response) {
  22381. if (response) {
  22382. var myData = Restangular.stripRestangular(response);
  22383. //myData.data = "arrangeform";
  22384. api_configure_form
  22385. .renderForm(myData.data, userId)
  22386. .then(function (responseData) {
  22387. if (responseData) {
  22388. var vmForm = Restangular.stripRestangular(responseData);
  22389. if (vmForm) {
  22390. decodeVMForm(vmForm);
  22391. }
  22392. }
  22393. });
  22394. }
  22395. });
  22396. }
  22397. } else {
  22398. //for form
  22399. //TODO
  22400. //测试数据 开始
  22401. var testJson = {
  22402. fields: [
  22403. {
  22404. fields: [
  22405. {
  22406. className: "col-xs-12",
  22407. noFormControl: true,
  22408. key: "formtitle",
  22409. templateOptions: {
  22410. readOnly: false,
  22411. placeholder: "新建事件单",
  22412. hidden: false,
  22413. label: "事件工单",
  22414. required: false,
  22415. },
  22416. type: "ui-title",
  22417. },
  22418. ],
  22419. },
  22420. {
  22421. fields: [
  22422. {
  22423. key: "selectUser",
  22424. type: "ui-deptinformation",
  22425. className: "col-xs-12",
  22426. templateOptions: {
  22427. label: "请求人信息",
  22428. modalTitle: "请求人列表",
  22429. fetchItems: function (filterData, APIService) {
  22430. return APIService.fetchDataList("requester", filterData);
  22431. },
  22432. Restangular: Restangular,
  22433. ApiService: api_user_data,
  22434. // onClick:function(val, options, field, event , model){
  22435. // console.log(options);
  22436. // }
  22437. },
  22438. },
  22439. ],
  22440. },
  22441. {
  22442. fields: [
  22443. {
  22444. key: "first",
  22445. type: "ui-workernumber",
  22446. className: "col-xs-12",
  22447. templateOptions: {
  22448. type: "input",
  22449. label: "事件单号",
  22450. pkey: "name",
  22451. },
  22452. },
  22453. ],
  22454. },
  22455. {
  22456. fields: [
  22457. {
  22458. type: "ui-header",
  22459. key: "title",
  22460. className: "col-xs-12",
  22461. templateOptions: {
  22462. label: "报修人",
  22463. pkey: "change",
  22464. },
  22465. },
  22466. {
  22467. type: "ui-input",
  22468. key: "title",
  22469. className: "col-xs-4",
  22470. templateOptions: {
  22471. label: "报修人",
  22472. pkey: "change",
  22473. },
  22474. },
  22475. {
  22476. type: "ui-input",
  22477. key: "title",
  22478. className: "col-xs-4",
  22479. templateOptions: {
  22480. label: "联系人",
  22481. pkey: "change",
  22482. },
  22483. },
  22484. {
  22485. type: "ui-input",
  22486. key: "title",
  22487. className: "col-xs-4",
  22488. templateOptions: {
  22489. label: "联系电话",
  22490. pkey: "change",
  22491. },
  22492. },
  22493. ],
  22494. },
  22495. {
  22496. fields: [
  22497. {
  22498. type: "ui-header",
  22499. key: "title1",
  22500. className: "col-xs-12",
  22501. templateOptions: {
  22502. label: "报修人",
  22503. pkey: "change",
  22504. },
  22505. },
  22506. {
  22507. type: "ui-input",
  22508. key: "title2",
  22509. className: "col-xs-4",
  22510. templateOptions: {
  22511. label: "报修人",
  22512. pkey: "change",
  22513. },
  22514. },
  22515. {
  22516. type: "ui-input",
  22517. key: "title3",
  22518. className: "col-xs-4",
  22519. templateOptions: {
  22520. label: "联系人",
  22521. pkey: "change",
  22522. },
  22523. },
  22524. {
  22525. type: "ui-input",
  22526. key: "title4",
  22527. className: "col-xs-4",
  22528. templateOptions: {
  22529. label: "联系电话",
  22530. pkey: "change",
  22531. },
  22532. },
  22533. ],
  22534. },
  22535. ],
  22536. model: [
  22537. {
  22538. username: "robin lau",
  22539. password: "123456",
  22540. chkme: false,
  22541. start_code: 0,
  22542. formtitle: "Hey!I am title value!",
  22543. name: {
  22544. first: "robin",
  22545. last: "lau",
  22546. },
  22547. multiselectItem: [],
  22548. //date:"2015-09-15 00:00:00"
  22549. },
  22550. ],
  22551. // }
  22552. };
  22553. setTimeout(function () {
  22554. decodeVMForm(testJson);
  22555. $scope.$apply();
  22556. }, 500);
  22557. //测试数据结束
  22558. }
  22559. }
  22560. //console.log("end decode");
  22561. },
  22562. ]);