customformCtrl.js 806 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979
  1. var appFormly = angular.module('formlyExample', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlyExample');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. appFormly.config(
  10. function config(formlyConfigProvider) {
  11. //格式转换方法 XXX-XXX转驼峰命名
  12. function camelize(string) {
  13. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  14. return chr ? chr.toUpperCase() : '';
  15. });
  16. // Ensure 1st char is always lowercase
  17. return string.replace(/^([A-Z])/, function (match, chr) {
  18. return chr ? chr.toLowerCase() : '';
  19. });
  20. }
  21. //获取ngModelAttr对象设置
  22. function getNgModelAttr(attrs, bindings) {
  23. var ngModelAttrs = {};
  24. angular.forEach(attrs, function (attr) {
  25. ngModelAttrs[camelize(attr)] = {
  26. attribute: attr
  27. };
  28. });
  29. angular.forEach(bindings, function (binding) {
  30. ngModelAttrs[camelize(binding)] = {
  31. bound: binding
  32. };
  33. });
  34. return ngModelAttrs;
  35. }
  36. formlyConfigProvider.setWrapper({
  37. name: 'bootstrapLabel',
  38. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  39. });
  40. //流程图
  41. formlyConfigProvider.setType({
  42. name: 'ui-process',
  43. templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
  44. defaultOptions: function (options) {
  45. return {
  46. templateOptions: {
  47. refresh: function () {},
  48. refreshDelay: 0
  49. }
  50. };
  51. },
  52. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  53. $scope.processdata = [];
  54. api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function (data) {
  55. console.log(data)
  56. $scope.processdata = data.data;
  57. })
  58. }]
  59. });
  60. //出库单详情
  61. formlyConfigProvider.setType({
  62. name: 'ui-getoutinform',
  63. extends: 'radio',
  64. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
  65. defaultOptions: function (options) {
  66. return {
  67. templateOptions: {
  68. refresh: function () {},
  69. refreshDelay: 0
  70. }
  71. };
  72. },
  73. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  74. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  75. if ($scope.model.type.id = 0) {
  76. $scope.model.type.name = "新资产入库";
  77. } else if ($scope.model.type.id = 1) {
  78. $scope.model.type.name = "新设备领用出库";
  79. } else if ($scope.model.type.id = 2) {
  80. $scope.model.type.name = "资产归还";
  81. } else if ($scope.model.type.id = 4) {
  82. $scope.model.type.name = "设备更换";
  83. }
  84. }
  85. }]
  86. });
  87. //多选框组件
  88. formlyConfigProvider.setType({
  89. name: 'ui-checkboxmore',
  90. extends: 'radio',
  91. templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () {},
  96. refreshDelay: 0
  97. }
  98. };
  99. },
  100. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  101. $scope.options.initialValue = $scope.model[$scope.options.key];
  102. }]
  103. });
  104. //入库单详情
  105. formlyConfigProvider.setType({
  106. name: 'ui-getininform',
  107. extends: 'radio',
  108. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
  109. defaultOptions: function (options) {
  110. return {
  111. templateOptions: {
  112. refresh: function () {},
  113. refreshDelay: 0
  114. }
  115. };
  116. },
  117. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  118. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  119. if ($scope.model.type.id = 0) {
  120. $scope.model.type.name = "新资产入库";
  121. } else if ($scope.model.type.id = 1) {
  122. $scope.model.type.name = "新设备领用出库";
  123. } else if ($scope.model.type.id = 2) {
  124. $scope.model.type.name = "资产归还";
  125. } else if ($scope.model.type.id = 4) {
  126. $scope.model.type.name = "设备更换";
  127. }
  128. }
  129. }]
  130. });
  131. //申请人详情
  132. formlyConfigProvider.setType({
  133. name: 'ui-requsterinfom',
  134. extends: 'radio',
  135. templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
  136. defaultOptions: function (options) {
  137. return {
  138. templateOptions: {
  139. refresh: function () {},
  140. refreshDelay: 0
  141. }
  142. };
  143. }
  144. });
  145. //设备耗材list组件
  146. formlyConfigProvider.setType({
  147. name: 'ui-uplodchange',
  148. templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
  149. defaultOptions: function (options) {
  150. return {
  151. templateOptions: {
  152. refresh: function () {},
  153. refreshDelay: 0,
  154. view: function (APIService, contentId) {
  155. return APIService.downloadAttachment(contentId);
  156. }
  157. }
  158. };
  159. },
  160. controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  161. // var data = { "haodata": [], "shedata": [] };
  162. var haodata = [];
  163. var shedata = [];
  164. if ($scope.model.consumables) {
  165. if (angular.isArray($scope.model.consumables)) {
  166. haodata = $scope.model.consumables;
  167. } else {
  168. haodata = JSON.parse($scope.model.consumables);
  169. }
  170. $scope.model.consumables = haodata;
  171. angular.forEach(haodata, function (item, index) {
  172. haodata[index].item = index + 1;
  173. })
  174. }
  175. if ($scope.model.assets) {
  176. if (angular.isArray($scope.model.assets)) {
  177. shedata = $scope.model.assets;
  178. } else {
  179. shedata = JSON.parse($scope.model.assets);
  180. }
  181. $scope.model.assets = shedata;
  182. angular.forEach(shedata, function (item, index) {
  183. shedata[index].item = index + 1;
  184. })
  185. }
  186. $scope.tableParamshao = new ngTableParams({
  187. page: 1,
  188. count: 5
  189. }, {
  190. total: haodata.length,
  191. getData: function ($defer, params) {
  192. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  193. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  194. }
  195. });
  196. $scope.tableParamsshe = new ngTableParams({
  197. page: 1,
  198. count: 5
  199. }, {
  200. total: shedata.length,
  201. getData: function ($defer, params) {
  202. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  203. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  204. }
  205. });
  206. $scope.editId = -1;
  207. $scope.setEditId = function (pid) {
  208. $scope.editId = pid;
  209. };
  210. if (angular.isUndefined($scope.form.dropState)) {
  211. $scope.form.dropState = false;
  212. }
  213. var to = $scope.options.templateOptions;
  214. var bindId = $scope.model.processInstanceId;
  215. //获取附件列表
  216. $scope.listAttachmen = function () {
  217. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  218. var myData = Restangular.stripRestangular(result);
  219. // $scope.listAttachmens = myData;
  220. $scope.attachments = myData.data;
  221. });
  222. };
  223. $scope.listAttachmen();
  224. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  225. // $scope.listAttachmen();
  226. // } else if (to.bindType && $scope.model[to.bindType].id) {
  227. // $scope.listAttachmen();
  228. // }
  229. //附件下载
  230. $scope.download = function (token, filename) {
  231. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  232. // window.open(downUrl);
  233. var a = document.createElement('a');
  234. a.href = downUrl;
  235. a.target = '_blank';
  236. a.download = filename;
  237. document.body.appendChild(a);
  238. a.click();
  239. };
  240. //附件预览
  241. $scope.view = function (id, previewUrl) {
  242. if (previewUrl) {
  243. window.open(previewUrl);
  244. }
  245. };
  246. }]
  247. });
  248. //多选框组件
  249. formlyConfigProvider.setType({
  250. name: 'ui-nodataimage',
  251. templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
  252. defaultOptions: function (options) {
  253. return {
  254. templateOptions: {
  255. refresh: function () {},
  256. refreshDelay: 0
  257. }
  258. };
  259. }
  260. });
  261. //ui-grid list
  262. formlyConfigProvider.setType({
  263. name: "ui-gridtwolist",
  264. // extends: 'input',
  265. templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
  266. defaultOptions: function (options, $scope) {
  267. return {
  268. templateOptions: {}
  269. };
  270. },
  271. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  272. //gridone
  273. $scope.langs = i18nService.getAllLangs();
  274. $scope.lang = 'zh-cn';
  275. i18nService.setCurrentLang($scope.lang);
  276. $scope.gridOptions = {};
  277. $scope.gridOptions.data = 'myDatagrid';
  278. $scope.gridOptions.enableColumnResizing = true;
  279. $scope.gridOptions.enableFiltering = true;
  280. $scope.gridOptions.enableGridMenu = false;
  281. $scope.gridOptions.enableRowSelection = true;
  282. $scope.gridOptions.showGridFooter = true;
  283. $scope.gridOptions.showColumnFooter = false;
  284. $scope.gridOptions.fastWatch = true;
  285. $scope.gridOptions.useExternalFiltering = false;
  286. $scope.gridOptions.useExternalPagination = true;
  287. $scope.gridOptions.paginationPageSizes = [10];
  288. $scope.gridOptions.paginationPageSize = 10;
  289. $scope.gridOptions.multiSelect = false;
  290. $scope.myDatagrid = [];
  291. $scope.myDatagridall = [];
  292. $scope.selected = {
  293. item: {}
  294. };
  295. $scope.memoryfilterDatagrid = {
  296. idx: 0,
  297. sum: 10
  298. }
  299. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  300. filterData = {
  301. idx: 0,
  302. sum: 10
  303. };
  304. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  305. }
  306. $scope.gridOptions.rowIdentity = function (row) {
  307. return row.id;
  308. };
  309. $scope.gridOptions.getRowIdentity = function (row) {
  310. return row.id;
  311. };
  312. // $scope.gridOptions.columnDefs = items.columnDefs();
  313. $scope.interceptMydata = function (mydate, idx, sum) {
  314. return mydate.slice(idx * sum, (idx + 1) * sum)
  315. }
  316. $scope.gridOptions.onRegisterApi = function (gridApi) {
  317. $scope.gridApi = gridApi;
  318. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  319. $scope.memoryfilterDatagrid.idx = newPage - 1;
  320. $scope.memoryfilterDatagrid.sum = pageSize;
  321. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  322. $scope.loadData({
  323. "idx": newPage - 1,
  324. "sum": pageSize
  325. });
  326. });
  327. gridApi.core.on.filterChanged($scope, function () {});
  328. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  329. $scope.selected.item = data.entity;
  330. //console.log(data);
  331. });
  332. };
  333. $scope.loadData = function (mydate, idx, sum) {
  334. angular.forEach($scope.myDatagrid, function (item, index) {
  335. $scope.myDatagrid[index].item = index;
  336. })
  337. $scope.gridOptions.totalItems = mydate.length;
  338. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  339. }
  340. if ($scope.model.assets) {
  341. $scope.myDatagridall = $scope.model.assets;
  342. $scope.loadData($scope.model.assets, 0, 10)
  343. }
  344. $scope.saveData = function (itemin) {
  345. event.preventDefault();
  346. var modalInstance = $modal.open({
  347. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  348. controller: function ($scope, $modalInstance, SweetAlert) {
  349. // $scope.consumptive = {};
  350. $scope.title = "填写领用设备信息";
  351. // if (items.name) {
  352. // $scope.consumptive.name = items.name.name;
  353. // }
  354. $scope.placechange = angular.copy(itemin);
  355. $scope.ok = function (item) {
  356. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  357. $modalInstance.close(item);
  358. } else {
  359. SweetAlert.swal({
  360. title: "数据填写不完整!",
  361. text: "请检查数据然后提交!",
  362. type: "error"
  363. });
  364. }
  365. };
  366. $scope.cancel = function () {
  367. $modalInstance.dismiss('cancel');
  368. };
  369. },
  370. resolve: {
  371. SweetAlert: function () {
  372. return SweetAlert;
  373. }
  374. }
  375. });
  376. modalInstance.result.then(function (selectedItem) {
  377. angular.forEach($scope.myDatagrid, function (item, index) {
  378. // $scope.myDatagrid[index].props.hw_state = "在线";
  379. if (item.id == selectedItem.id) {
  380. // $scope.myDatagrid[index] = selectedItem;
  381. angular.extend($scope.myDatagrid[index], selectedItem)
  382. }
  383. })
  384. // $scope.myData3.push(selectedItem);
  385. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  386. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  387. }
  388. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  389. })
  390. }
  391. //gridtwo
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = 'zh-cn';
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions2 = {};
  396. $scope.gridOptions2.data = 'myDatagridold';
  397. $scope.gridOptions2.enableColumnResizing = true;
  398. $scope.gridOptions2.enableFiltering = true;
  399. $scope.gridOptions2.enableGridMenu = false;
  400. $scope.gridOptions2.enableRowSelection = true;
  401. $scope.gridOptions2.showGridFooter = true;
  402. $scope.gridOptions2.showColumnFooter = false;
  403. $scope.gridOptions2.fastWatch = true;
  404. $scope.gridOptions2.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions2.paginationPageSizes = [10];
  407. $scope.gridOptions2.paginationPageSize = 10;
  408. $scope.gridOptions2.multiSelect = false;
  409. $scope.myDatagridold = [];
  410. $scope.myDatagridoldall = [];
  411. $scope.selected = {
  412. item: {}
  413. };
  414. $scope.memoryfilterDatagridold = {
  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.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
  424. }
  425. $scope.gridOptions2.rowIdentity = function (row) {
  426. return row.id;
  427. };
  428. $scope.gridOptions2.getRowIdentity = function (row) {
  429. return row.id;
  430. };
  431. // $scope.gridOptions.columnDefs = items.columnDefs();
  432. $scope.interceptMydata = function (mydate, idx, sum) {
  433. return mydate.slice(idx * sum, (idx + 1) * sum)
  434. }
  435. if ($scope.model.oldAssets) {
  436. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  437. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
  438. }
  439. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  440. $scope.gridApi = gridApi;
  441. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  442. $scope.memoryfilterDatagridold.idx = newPage - 1;
  443. $scope.memoryfilterDatagridold.sum = pageSize;
  444. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
  445. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  446. });
  447. gridApi.core.on.filterChanged($scope, function () {});
  448. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  449. $scope.selected.item = data.entity;
  450. //console.log(data);
  451. });
  452. };
  453. // $scope.loadData = function(mydate, idx, sum) {
  454. // angular.forEach($scope.myDatagridold, function(item, index) {
  455. // $scope.myDatagridold[index].item = index;
  456. // })
  457. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  458. // }
  459. // if ($scope.model.assets) {
  460. // $scope.myDatagridallold = $scope.model.assets;
  461. // $scope.loadData($scope.model.assets, 0, 10)
  462. // }
  463. // $scope.addoldassets = function(itemin) {
  464. // event.preventDefault();
  465. // var modalInstance = $modal.open({
  466. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  467. // controller: function($scope, $modalInstance, SweetAlert) {
  468. // // $scope.consumptive = {};
  469. // $scope.title = "填写领用设备信息";
  470. // // if (items.name) {
  471. // // $scope.consumptive.name = items.name.name;
  472. // // }
  473. // $scope.placechange = itemin;
  474. // $scope.ok = function(item) {
  475. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  476. // $modalInstance.close(item);
  477. // } else {
  478. // SweetAlert.swal({
  479. // title: "数据填写不完整!",
  480. // text: "请检查数据然后提交!",
  481. // type: "error"
  482. // });
  483. // }
  484. // };
  485. // $scope.cancel = function() {
  486. // $modalInstance.dismiss('cancel');
  487. // };
  488. // },
  489. // resolve: {
  490. // SweetAlert: function() {
  491. // return SweetAlert;
  492. // }
  493. // }
  494. // });
  495. $scope.interceptMydata = function (mydate, idx, sum) {
  496. return mydate.slice(idx * sum, (idx + 1) * sum)
  497. }
  498. $scope.addshebei = function () {
  499. event.preventDefault();
  500. var modalInstance = $modal.open({
  501. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  502. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
  503. $scope.langs = i18nService.getAllLangs();
  504. $scope.lang = 'zh-cn';
  505. i18nService.setCurrentLang($scope.lang);
  506. $scope.gridOptions = {};
  507. $scope.gridOptions.data = 'myDatatwo';
  508. $scope.gridOptions.enableColumnResizing = true;
  509. $scope.gridOptions.enableFiltering = false;
  510. $scope.gridOptions.enableGridMenu = false;
  511. $scope.gridOptions.showGridFooter = true;
  512. $scope.gridOptions.showColumnFooter = false;
  513. $scope.gridOptions.fastWatch = true;
  514. $scope.gridOptions.useExternalFiltering = true;
  515. $scope.gridOptions.useExternalPagination = true;
  516. $scope.gridOptions.paginationPageSizes = [10];
  517. $scope.gridOptions.paginationPageSize = 10;
  518. $scope.gridOptions.multiSelect = true;
  519. $scope.gridOptions.rowIdentity = function (row) {
  520. return row.id;
  521. };
  522. $scope.gridOptions.getRowIdentity = function (row) {
  523. return row.id;
  524. };
  525. $scope.gridOptions.columnDefs = [{
  526. name: 'item',
  527. displayName: '序号',
  528. width: 80,
  529. enableFiltering: false
  530. },
  531. {
  532. name: 'uuid',
  533. displayName: '内部编号',
  534. width: 120
  535. },
  536. {
  537. name: 'props.hw_mingcheng',
  538. displayName: '资产名称',
  539. width: 100
  540. },
  541. {
  542. name: 'props.hw_cifilterClassic',
  543. displayName: '资产类型',
  544. width: 120,
  545. enableFiltering: false
  546. },
  547. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  548. {
  549. name: 'props.hw_state',
  550. displayName: '资产状态',
  551. width: 150,
  552. enableFiltering: false
  553. },
  554. {
  555. name: 'props.hwnw_area',
  556. displayName: '资产地点',
  557. width: 130,
  558. enableFiltering: false
  559. },
  560. {
  561. name: 'createtime',
  562. displayName: '申请时间',
  563. enableFiltering: false
  564. }
  565. ];
  566. // $scope.selectButtonClick
  567. var defaultFilterData = {
  568. // "assignee":2,
  569. // "applicationForm": { "hw_state": "在线" },
  570. "hw_state": "在线",
  571. "idx": 0,
  572. "sum": 10
  573. };
  574. $scope.memoryfilterData = {
  575. // "assignee":2,
  576. // "applicationForm": { "hw_state": "在线" },
  577. "hw_state": "在线",
  578. "idx": 0,
  579. "sum": 10
  580. }
  581. $scope.refreshData = function (style, filterData) {
  582. if (angular.isUndefined(filterData)) {
  583. filterData = defaultFilterData;
  584. }
  585. $scope.myDatatwo = [];
  586. // $scope.gridOptions['sum']=filterData.sum;
  587. api_cmdb.query(filterData).then(function (data) {
  588. // $scope.callsPending--;
  589. var myDatatwo = Restangular.stripRestangular(data);
  590. $scope.gridOptions['totalItems'] = data.total;
  591. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  592. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  593. }
  594. $scope.myDatatwo = myDatatwo.data.node;
  595. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  596. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  597. }
  598. }, function () {});
  599. };
  600. $scope.refreshData('expand-right', defaultFilterData);
  601. $scope.gridOptions.onRegisterApi = function (gridApi) {
  602. $scope.gridApi = gridApi;
  603. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  604. var filtersData = $scope.memoryfilterData;
  605. filtersData.idx = newPage - 1;
  606. filtersData.sum = pageSize;
  607. // $scope.loadData(filtersData);
  608. $scope.refreshData('expand-right', filtersData);
  609. //console.log(pageSize);
  610. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  611. });
  612. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  613. // $scope.selected.items.push(data.entity);
  614. //console.log(data);
  615. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  616. if (scope.isSelected) {
  617. scope.grid.appScope.selected.items.push(scope.entity)
  618. } else {
  619. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  620. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  621. scope.grid.appScope.selected.items.splice(i, 1);
  622. break;
  623. }
  624. }
  625. }
  626. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  627. });
  628. // });
  629. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  630. // $scope.selected.items = data.entity;
  631. //console.log(data);
  632. var selectitem = [];
  633. selectitem = angular.copy($scope.selected.items);
  634. for (var j = 0; j < rows.length; j++) {
  635. if (rows[j].isSelected == true) {
  636. selectitem.push(rows[j].entity);
  637. } else {
  638. delete selectitem[j];
  639. // rows.splice(j, 1);
  640. }
  641. }
  642. $scope.selected.items = [];
  643. for (var i = 0; i < selectitem.length; i++) {
  644. if (selectitem[i]) {
  645. $scope.selected.items.push(selectitem[i]);
  646. }
  647. }
  648. });
  649. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  650. // // if (row.entity.age > 45) {
  651. // row.grid.api.selection.selectRow(row.entity); // 选中行
  652. // // }
  653. // };
  654. gridApi.core.on.filterChanged($scope, function () {
  655. var grid = this.grid;
  656. var filtersData = {
  657. idx: 0,
  658. sum: 10,
  659. "user": {
  660. "roledata": {
  661. "rolecode": "roleset"
  662. },
  663. "selectType": "1"
  664. }
  665. };
  666. angular.forEach(grid.columns, function (item) {
  667. if (item.enableFiltering) {
  668. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  669. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  670. if (angular.isUndefined(filtersData['user'])) {
  671. filtersData['user'] = {};
  672. }
  673. filtersData['user'][item.field] = item.filters[0].term;
  674. }
  675. }
  676. });
  677. $scope.memoryfilterData = filtersData;
  678. // $scope.loadData(filtersData);
  679. });
  680. };
  681. $scope.onDblClick = function (data, event) {
  682. // $scope.selected.items = data.entity;
  683. $scope.selectButtonClick(data, event);
  684. };
  685. $scope.title = title;
  686. //树形图
  687. var apple_selected, tree, treedata_avm, treedata_geography;
  688. $scope.my_tree_handler = function (branch) {
  689. //var _ref;
  690. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  691. api_cmdb.query({
  692. 'sign': classify
  693. }).then(function (data) {
  694. var myDatalingbei = Restangular.stripRestangular(data);
  695. // console.log(myData.data.node);
  696. if (myDatalingbei.data && myDatalingbei.status == 200) {
  697. var ret = myDatalingbei.data;
  698. redrawSvg(myDatalingbei);
  699. }
  700. });
  701. };
  702. $scope.my_data = [];
  703. function convertListToTree(data, treeMap) {
  704. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  705. var root = null; //Initially set our loop to null
  706. var parentNode = null;
  707. //loop over data
  708. for (var i = 0; i < data.length; i++) {
  709. var datum = data[i];
  710. //each node will have children, so let's give it a "children" poperty
  711. datum.children = [];
  712. //add an entry for this node to the map so that any future children can
  713. //lookup the parent
  714. idToNodeMap[datum.id] = datum;
  715. //Does this node have a parent?
  716. if (typeof datum.parent === "undefined" || datum.parent == null) {
  717. //Doesn't look like it, so this node is the root of the tree
  718. root = datum;
  719. treeMap[datum.id] = root;
  720. } else {
  721. //This node has a parent, so let's look it up using the id
  722. parentNode = idToNodeMap[datum.parent.id];
  723. //We don't need this property, so let's delete it.
  724. delete datum.parent;
  725. //Let's add the current node as a child of the parent node.
  726. parentNode.children.push(datum);
  727. }
  728. }
  729. return root;
  730. }
  731. function convertParentToChildList(data) {
  732. var treeMap = {};
  733. var list = [];
  734. convertListToTree(data, treeMap);
  735. angular.forEach(treeMap, function (item) {
  736. list.push(item);
  737. });
  738. return list;
  739. }
  740. $scope.my_tree = tree = {};
  741. $scope.try_async_load = function () {
  742. $scope.my_data = [];
  743. $scope.select_treedata = [];
  744. $scope.doing_async = true;
  745. api_configure_data.fetchDataList('ciclassify', {
  746. 'idx': 0,
  747. 'sum': 100
  748. }).then(function (result) {
  749. //console.log(result['list']);
  750. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  751. $scope.doing_async = false;
  752. // tree.expand_all();
  753. //console.log(treelist);
  754. });
  755. };
  756. $scope.select_treedata = [];
  757. $scope.propTypeOptions = [];
  758. $scope.try_async_load();
  759. $scope.onFilterremove = function (item) {
  760. console.log(item)
  761. }
  762. $scope.searchdata = {};
  763. $scope.clear = function () {
  764. $scope.searchdata = {};
  765. $scope.cifilter_classic = {};
  766. $scope.try_async_load();
  767. var fildata = {
  768. idx: 0,
  769. sum: 10,
  770. 'hw_state': '在线'
  771. }
  772. $scope.memoryfilterData = fildata;
  773. $scope.refreshData('expand-right', fildata);
  774. }
  775. $scope.chiceIncident = function (item) {
  776. var fildata = $scope.memoryfilterData;
  777. // fildata.applicationForm = {};
  778. // if (item.alltitle && item.alldata) {
  779. // fildata.applicationForm[item.alltitle.key] = item.alldata
  780. // }
  781. if (item && item.id) {
  782. var classify = item.prefix.toLowerCase() + item.sign;
  783. fildata.sign = classify
  784. }
  785. $scope.gridOptions.paginationCurrentPage = 1;
  786. var transitiondata = angular.copy(item);
  787. $scope.refreshData('expand-right', fildata);
  788. }
  789. $scope.applicadata = [];
  790. $scope.onFilterCallback = function (item) {
  791. var tempclassify = item.prefix.toLowerCase() + item.sign;
  792. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  793. var myData = Restangular.stripRestangular(data);
  794. $scope.applicadata = myData[0].form.fields;
  795. });
  796. // }
  797. }
  798. // $scope.loadData({
  799. // idx: 0,
  800. // sum: 10,
  801. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  802. // });
  803. $scope.selected = {
  804. items: []
  805. };
  806. $scope.ok = function () {
  807. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  808. // onDataCallback($scope.selected.item, parentScope);
  809. // }
  810. $modalInstance.close($scope.selected.items);
  811. };
  812. $scope.cancel = function () {
  813. $modalInstance.dismiss('cancel');
  814. };
  815. },
  816. size: 'lg',
  817. resolve: {
  818. items: function () {
  819. return {
  820. fetchItems: function (filterData, APIService) {
  821. filterData = filterData || {};
  822. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  823. filterData = {
  824. idx: 0,
  825. sum: 10,
  826. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  827. };
  828. }
  829. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  830. }
  831. };
  832. },
  833. title: function () {
  834. return $scope.options.templateOptions.label;
  835. },
  836. Restangular: function () {
  837. return $scope.options.templateOptions.Restangular;
  838. },
  839. APIService: function () {
  840. return $scope.options.templateOptions.ApiService;
  841. },
  842. onDataCallback: function () {
  843. return $scope.options.templateOptions.callback;
  844. },
  845. parentScope: function () {
  846. return $scope.options.templateOptions.that;
  847. }
  848. }
  849. });
  850. modalInstance.result.then(function (selectedItem) {
  851. $scope.myDatagridoldall = selectedItem;
  852. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  853. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  854. }
  855. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  856. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  857. // $scope.model.oldAssets = $scope.myDatagridoldall;
  858. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  859. $scope.options.initialValue = $scope.model.oldAssets;
  860. });
  861. // }
  862. }
  863. $scope.changestate = function (itemin) {
  864. event.preventDefault();
  865. var modalInstance = $modal.open({
  866. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
  867. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  868. $scope.title = '旧设备状态修改';
  869. $scope.stateshe = [{
  870. "id": 2,
  871. "name": "在库"
  872. }, {
  873. "id": 4,
  874. "name": "报修"
  875. }, {
  876. "id": 3,
  877. "name": "报废"
  878. }];
  879. $scope.hw_state = {};
  880. $scope.ok = function (item) {
  881. $modalInstance.close(item.id);
  882. };
  883. $scope.cancel = function () {
  884. $modalInstance.dismiss('cancel');
  885. };
  886. },
  887. size: 'sm',
  888. resolve: {
  889. scope: function () {
  890. return $scope;
  891. }
  892. }
  893. });
  894. modalInstance.result.then(function (selectedItem) {
  895. if (selectedItem) {
  896. angular.forEach($scope.myDatagridallold, function (item, index) {
  897. if (item.id == itemin.id) {
  898. $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
  899. }
  900. })
  901. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  902. $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  903. }
  904. $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
  905. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
  906. // $scope.model.oldAssets = $scope.myDatagridallold;
  907. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
  908. $scope.options.initialValue = $scope.model.oldAssets;
  909. }
  910. })
  911. }
  912. $scope.savedata = function (data) {
  913. event.preventDefault();
  914. var modalInstance = $modal.open({
  915. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
  916. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  917. $scope.title = '设备编辑';
  918. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  919. $scope.ok = function (item) {
  920. $modalInstance.close(item);
  921. };
  922. $scope.cancel = function () {
  923. $modalInstance.dismiss('cancel');
  924. };
  925. },
  926. size: 'sm',
  927. resolve: {
  928. scope: function () {
  929. return $scope;
  930. }
  931. }
  932. });
  933. modalInstance.result.then(function (selectedItem) {
  934. if (selectedItem) {
  935. angular.forEach($scope.myDatagridoldall, function (item, index) {
  936. if (item.id == data.id) {
  937. $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
  938. }
  939. })
  940. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  941. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  942. }
  943. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  944. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  945. // $scope.model.oldAssets = $scope.myDatagridoldall;
  946. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  947. $scope.options.initialValue = $scope.model.oldAssets;
  948. }
  949. })
  950. }
  951. $scope.removeold = function (data) {
  952. event.preventDefault();
  953. var modalInstance = $modal.open({
  954. templateUrl: 'assets/views/delete.html',
  955. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  956. $scope.title = '设备删除';
  957. $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  958. $scope.ok = function () {
  959. $modalInstance.close(data);
  960. };
  961. $scope.cancel = function () {
  962. $modalInstance.dismiss('cancel');
  963. };
  964. },
  965. size: 'sm',
  966. resolve: {
  967. scope: function () {
  968. return $scope;
  969. }
  970. }
  971. });
  972. modalInstance.result.then(function (selectedItem) {
  973. if (selectedItem) {
  974. angular.forEach($scope.myDatagridoldall, function (item, index) {
  975. if (item.id == selectedItem.id) {
  976. $scope.myDatagridoldall.splice(index, 1);
  977. }
  978. })
  979. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  980. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  981. }
  982. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  983. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  984. // $scope.model.oldAssets = $scope.myDatagridoldall;
  985. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  986. $scope.options.initialValue = $scope.model.oldAssets;
  987. }
  988. })
  989. }
  990. }]
  991. });
  992. //ui-grid list
  993. formlyConfigProvider.setType({
  994. name: "ui-gridlist",
  995. extends: 'input',
  996. templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
  997. defaultOptions: function (options, $scope) {
  998. return {
  999. templateOptions: {}
  1000. };
  1001. },
  1002. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  1003. //gridone
  1004. $scope.langs = i18nService.getAllLangs();
  1005. $scope.lang = 'zh-cn';
  1006. i18nService.setCurrentLang($scope.lang);
  1007. $scope.gridOptions = {};
  1008. $scope.gridOptions.data = 'myDatagrid';
  1009. $scope.gridOptions.enableColumnResizing = true;
  1010. $scope.gridOptions.enableFiltering = true;
  1011. $scope.gridOptions.enableGridMenu = false;
  1012. $scope.gridOptions.enableRowSelection = true;
  1013. $scope.gridOptions.showGridFooter = true;
  1014. $scope.gridOptions.showColumnFooter = false;
  1015. $scope.gridOptions.fastWatch = true;
  1016. $scope.gridOptions.useExternalFiltering = false;
  1017. // $scope.gridOptions.useExternalPagination = true;
  1018. $scope.gridOptions.paginationPageSizes = [10];
  1019. $scope.gridOptions.paginationPageSize = 10;
  1020. $scope.gridOptions.multiSelect = false;
  1021. $scope.myDatagrid = [];
  1022. $scope.myDatagridall = [];
  1023. $scope.selected = {
  1024. item: {}
  1025. };
  1026. $scope.memoryfilterDatagrid = {
  1027. idx: 0,
  1028. sum: 10
  1029. }
  1030. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1031. filterData = {
  1032. idx: 0,
  1033. sum: 10
  1034. };
  1035. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  1036. }
  1037. $scope.gridOptions.rowIdentity = function (row) {
  1038. return row.id;
  1039. };
  1040. $scope.gridOptions.getRowIdentity = function (row) {
  1041. return row.id;
  1042. };
  1043. // $scope.gridOptions.columnDefs = items.columnDefs();
  1044. $scope.interceptMydata = function (mydate, idx, sum) {
  1045. return mydate.slice(idx * sum, (idx + 1) * sum)
  1046. }
  1047. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1048. $scope.gridApi = gridApi;
  1049. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1050. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1051. $scope.memoryfilterDatagrid.sum = pageSize;
  1052. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  1053. $scope.loadData({
  1054. "idx": newPage - 1,
  1055. "sum": pageSize
  1056. });
  1057. });
  1058. gridApi.core.on.filterChanged($scope, function () {});
  1059. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1060. $scope.selected.item = data.entity;
  1061. //console.log(data);
  1062. });
  1063. };
  1064. $scope.loadData = function (mydate, idx, sum) {
  1065. angular.forEach($scope.myDatagrid, function (item, index) {
  1066. $scope.myDatagrid[index].item = index;
  1067. })
  1068. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  1069. }
  1070. if ($scope.model.assets) {
  1071. $scope.myDatagridall = $scope.model.assets;
  1072. $scope.loadData($scope.model.assets, 0, 10)
  1073. }
  1074. $scope.saveData = function (itemin) {
  1075. event.preventDefault();
  1076. var modalInstance = $modal.open({
  1077. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  1078. controller: function ($scope, $modalInstance, SweetAlert) {
  1079. // $scope.consumptive = {};
  1080. $scope.title = "填写领用设备信息";
  1081. // if (items.name) {
  1082. // $scope.consumptive.name = items.name.name;
  1083. // }
  1084. $scope.placechange = angular.copy(itemin);
  1085. $scope.ok = function (item) {
  1086. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  1087. $modalInstance.close(item);
  1088. } else {
  1089. SweetAlert.swal({
  1090. title: "数据填写不完整!",
  1091. text: "请检查数据然后提交!",
  1092. type: "error"
  1093. });
  1094. }
  1095. };
  1096. $scope.cancel = function () {
  1097. $modalInstance.dismiss('cancel');
  1098. };
  1099. },
  1100. resolve: {
  1101. SweetAlert: function () {
  1102. return SweetAlert;
  1103. }
  1104. }
  1105. });
  1106. modalInstance.result.then(function (selectedItem) {
  1107. angular.forEach($scope.myDatagrid, function (item, index) {
  1108. if (item.id == selectedItem.id) {
  1109. angular.extend($scope.myDatagrid[index], selectedItem)
  1110. }
  1111. })
  1112. // $scope.myData3.push(selectedItem);
  1113. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1114. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  1115. }
  1116. // $scope.model.assets = $scope.myDatagridall;
  1117. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  1118. })
  1119. }
  1120. }]
  1121. });
  1122. //设备耗材list组件
  1123. formlyConfigProvider.setType({
  1124. name: 'ui-shehaolist',
  1125. // extends: 'radio',
  1126. templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
  1127. defaultOptions: function (options) {
  1128. return {
  1129. templateOptions: {
  1130. refresh: function () {},
  1131. refreshDelay: 0
  1132. }
  1133. };
  1134. },
  1135. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1136. // var data = { "haodata": [], "shedata": [] };
  1137. var haodata = [];
  1138. var shedata = [];
  1139. if ($scope.model.consumables) {
  1140. if (angular.isArray($scope.model.consumables)) {
  1141. haodata = $scope.model.consumables;
  1142. } else {
  1143. haodata = JSON.parse($scope.model.consumables);
  1144. }
  1145. $scope.model.consumables = haodata;
  1146. angular.forEach(haodata, function (item, index) {
  1147. haodata[index].item = index + 1;
  1148. })
  1149. }
  1150. if ($scope.model.assets) {
  1151. if (angular.isArray($scope.model.assets)) {
  1152. shedata = $scope.model.assets;
  1153. } else {
  1154. shedata = JSON.parse($scope.model.assets);
  1155. }
  1156. $scope.model.assets = shedata;
  1157. angular.forEach(shedata, function (item, index) {
  1158. shedata[index].item = index + 1;
  1159. })
  1160. }
  1161. $scope.tableParamshao = new ngTableParams({
  1162. page: 1,
  1163. count: 5
  1164. }, {
  1165. total: haodata.length,
  1166. getData: function ($defer, params) {
  1167. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  1168. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1169. }
  1170. });
  1171. $scope.tableParamsshe = new ngTableParams({
  1172. page: 1,
  1173. count: 5
  1174. }, {
  1175. total: shedata.length,
  1176. getData: function ($defer, params) {
  1177. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  1178. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1179. }
  1180. });
  1181. $scope.editId = -1;
  1182. $scope.setEditId = function (pid) {
  1183. $scope.editId = pid;
  1184. };
  1185. if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
  1186. $scope.isAgree = "同意";
  1187. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
  1188. $scope.isAgree = "同意";
  1189. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
  1190. $scope.isAgree = "返回修改";
  1191. }
  1192. }]
  1193. });
  1194. //关联资产出库
  1195. formlyConfigProvider.setType({
  1196. name: "ui-meansmodelselect",
  1197. extends: 'input',
  1198. templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
  1199. defaultOptions: function (options) {
  1200. return {
  1201. templateOptions: {}
  1202. };
  1203. },
  1204. controller: ['$scope', '$modal', function ($scope, $modal) {
  1205. $scope.openModal = function (size, options, modal) {
  1206. var modalInstance = $modal.open({
  1207. templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
  1208. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService) {
  1209. $scope.langs = i18nService.getAllLangs();
  1210. $scope.lang = 'zh-cn';
  1211. i18nService.setCurrentLang($scope.lang);
  1212. $scope.gridOptions = {};
  1213. $scope.gridOptions.data = 'myData';
  1214. $scope.gridOptions.enableColumnResizing = true;
  1215. $scope.gridOptions.enableFiltering = false;
  1216. $scope.gridOptions.enableGridMenu = false;
  1217. $scope.gridOptions.showGridFooter = true;
  1218. $scope.gridOptions.showColumnFooter = false;
  1219. $scope.gridOptions.fastWatch = true;
  1220. $scope.gridOptions.useExternalFiltering = true;
  1221. $scope.gridOptions.useExternalPagination = true;
  1222. $scope.gridOptions.paginationPageSizes = [10];
  1223. $scope.gridOptions.paginationPageSize = 10;
  1224. $scope.gridOptions.multiSelect = false;
  1225. $scope.gridOptions.rowIdentity = function (row) {
  1226. return row.id;
  1227. };
  1228. $scope.gridOptions.getRowIdentity = function (row) {
  1229. return row.id;
  1230. };
  1231. $scope.states = [{
  1232. id: 0,
  1233. name: '待批准'
  1234. },
  1235. {
  1236. id: 1,
  1237. name: '已驳回'
  1238. },
  1239. {
  1240. id: 2,
  1241. name: '待出库'
  1242. },
  1243. {
  1244. id: 3,
  1245. name: '信息更新'
  1246. },
  1247. {
  1248. id: 4,
  1249. name: '信息确认'
  1250. },
  1251. {
  1252. id: 5,
  1253. name: '已关闭'
  1254. }
  1255. ];
  1256. $scope.type = [{
  1257. id: 1,
  1258. name: '资产入库'
  1259. },
  1260. {
  1261. id: 2,
  1262. name: '资产归还'
  1263. },
  1264. {
  1265. id: 3,
  1266. name: '资产领用'
  1267. },
  1268. {
  1269. id: 4,
  1270. name: '资产更换'
  1271. }
  1272. ];
  1273. $scope.typedata = function (row) {
  1274. if (row.type == 0) {
  1275. return "资产入库";
  1276. } else if (row.type == 2) {
  1277. return "资产归还";
  1278. } else if (row.type == 1) {
  1279. return "资产领用";
  1280. } else if (row.type == 4) {
  1281. return "资产更换";
  1282. }
  1283. };
  1284. $scope.statedata = function (row) {
  1285. if (row.status == 0) {
  1286. return "待批准";
  1287. } else if (row.status == 1) {
  1288. return "已驳回";
  1289. } else if (row.status == 2) {
  1290. return "待出库";
  1291. } else if (row.status == 3) {
  1292. return "信息更新";
  1293. } else if (row.status == 4) {
  1294. return "信息确认";
  1295. } else if (row.status == 5) {
  1296. return "已关闭";
  1297. }
  1298. };
  1299. $scope.application = [{
  1300. value: "serialNumbe",
  1301. name: '申请单编号'
  1302. },
  1303. // { value: "proposer", name: '申请人' },
  1304. {
  1305. value: "purpose",
  1306. name: '领用用途'
  1307. },
  1308. // { value: "cmdbsign", name: '设备编号' }
  1309. ];
  1310. $scope.parameters = null;
  1311. $scope.open = function ($event) {
  1312. $event.preventDefault();
  1313. $event.stopPropagation();
  1314. $scope.opened = !$scope.opened;
  1315. };
  1316. $scope.endOpen = function ($event) {
  1317. $event.preventDefault();
  1318. $event.stopPropagation();
  1319. $scope.startOpened = false;
  1320. $scope.endOpened = !$scope.endOpened;
  1321. };
  1322. $scope.startOpen = function ($event) {
  1323. $event.preventDefault();
  1324. $event.stopPropagation();
  1325. $scope.endOpened = false;
  1326. $scope.startOpened = !$scope.startOpened;
  1327. };
  1328. $scope.othcode = {};
  1329. $scope.searchkeys = {};
  1330. $scope.parameters = {};
  1331. $scope.memoryfilterData = {
  1332. "assignee": $rootScope.user.id,
  1333. "candidateGroups": $rootScope.user.group[0].id,
  1334. "searchType": "todo",
  1335. idx: 0,
  1336. sum: 10
  1337. }
  1338. $scope.clear = function () {
  1339. $scope.searchkeys = {};
  1340. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1341. // $scope.othcode = {};
  1342. $scope.parameters = {};
  1343. var fildata = {
  1344. "assignee": $rootScope.user.id,
  1345. "candidateGroups": $rootScope.user.group[0].id,
  1346. "searchType": "todo",
  1347. idx: 0,
  1348. sum: 10
  1349. }
  1350. // sessionStorage.removeItem("searchincident");
  1351. $scope.memoryfilterData = fildata;
  1352. $scope.loadData(fildata);
  1353. }
  1354. $scope.chiceIncident = function (parameters, item, stateid) {
  1355. var fildata = {
  1356. "assignee": $rootScope.user.id,
  1357. "candidateGroups": 1,
  1358. "searchType": "todo",
  1359. "idx": 0,
  1360. "sum": 10
  1361. };
  1362. if (item) {
  1363. fildata.applicationForm = {};
  1364. if (item.alltitle && item.alldata) {
  1365. fildata.applicationForm[item.alltitle.value] = item.alldata
  1366. }
  1367. if (item.linkProposer) {
  1368. fildata.applicationForm.linkProposer = item.linkProposer
  1369. }
  1370. if (item.proposer) {
  1371. fildata.applicationForm.proposer = item.proposer
  1372. }
  1373. if (item.status) {
  1374. fildata.applicationForm['status'] = item.status.id;
  1375. }
  1376. if (item.type) {
  1377. fildata.applicationForm['type'] = item.type.id;
  1378. }
  1379. }
  1380. $scope.gridOptions.paginationCurrentPage = 1;
  1381. if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
  1382. angular.extend(fildata, {
  1383. 'idx': 0,
  1384. 'sum': $scope.gridOptions.paginationPageSize
  1385. })
  1386. angular.extend(fildata.applicationForm, {
  1387. 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'),
  1388. 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59')
  1389. })
  1390. }
  1391. var transitiondata = angular.copy(item);
  1392. // angular.extend(fildata.applicationForm, transitiondata)
  1393. $scope.loadData(fildata);
  1394. }
  1395. $scope.key = {};
  1396. api_user_data.fetchDataList('user', {
  1397. "idx": 0,
  1398. "sum": 1000,
  1399. "flag": -1
  1400. }).then(function (data) {
  1401. $scope.handlingPersonnelUser = data.list;
  1402. });
  1403. $scope.gridOptions.columnDefs = items.columnDefs();
  1404. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1405. $scope.gridApi = gridApi;
  1406. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1407. // console.log(newPage);
  1408. // console.log(pageSize);
  1409. $scope.loadData({
  1410. "idx": newPage - 1,
  1411. "sum": pageSize
  1412. });
  1413. });
  1414. gridApi.core.on.filterChanged($scope, function () {
  1415. });
  1416. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1417. $scope.selected.item = data.entity;
  1418. //console.log(data);
  1419. });
  1420. };
  1421. $scope.loadData = function (filterData) {
  1422. items.fetchItems(filterData, APIService).then(function (data) {
  1423. var myData = Restangular.stripRestangular(data);
  1424. $scope.gridOptions.totalItems = myData.totalNum;
  1425. $scope.myData = myData.list;
  1426. for (var i = 0; i < $scope.myData.length; i++) {
  1427. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  1428. }
  1429. });
  1430. };
  1431. $scope.title = title;
  1432. $scope.loadData({
  1433. idx: 0,
  1434. sum: 10,
  1435. "assignee": $rootScope.user.id,
  1436. "candidateGroups": $rootScope.user.group[0].id,
  1437. "searchType": "todo",
  1438. });
  1439. $scope.selected = {
  1440. item: {}
  1441. };
  1442. $scope.ok = function () {
  1443. //console.log($scope.selected.item);
  1444. $modalInstance.close($scope.selected.item);
  1445. };
  1446. $scope.cancel = function () {
  1447. $modalInstance.dismiss('cancel');
  1448. };
  1449. },
  1450. size: 'lg',
  1451. resolve: {
  1452. items: function () {
  1453. return {
  1454. fetchItems: function (filterData, APIService) {
  1455. filterData = filterData || {};
  1456. // if(!filterData.idx){
  1457. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  1458. filterData = {
  1459. idx: 0,
  1460. sum: 10
  1461. };
  1462. }
  1463. return options.templateOptions.fetchItems(filterData, APIService, options);
  1464. },
  1465. columnDefs: function () {
  1466. return options.templateOptions.columnDefs;
  1467. }
  1468. };
  1469. },
  1470. title: function () {
  1471. return options.templateOptions.modalTitle;
  1472. },
  1473. Restangular: function () {
  1474. return options.templateOptions.Restangular;
  1475. },
  1476. APIService: function () {
  1477. return options.templateOptions.ApiService;
  1478. }
  1479. }
  1480. });
  1481. modalInstance.result.then(function (selectedItem) {
  1482. var selectitem = {
  1483. title: selectedItem.title,
  1484. description: selectedItem.description
  1485. }
  1486. if (options.key == "chuku") {
  1487. if (selectedItem.assets) {
  1488. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  1489. }
  1490. if (selectedItem.consumables) {
  1491. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  1492. }
  1493. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  1494. options.value(selectedItem);
  1495. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1496. } else {
  1497. angular.extend(options.model, selectitem);
  1498. options.value(selectedItem);
  1499. }
  1500. }, function () {
  1501. //console.log('Modal dismissed at: ' + new Date());
  1502. });
  1503. }
  1504. }]
  1505. });
  1506. //文本框
  1507. formlyConfigProvider.setType({
  1508. name: 'ui-textcmdb',
  1509. extends: '',
  1510. templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
  1511. defaultOptions: function (options) {
  1512. return {
  1513. templateOptions: {
  1514. transform: function (model, value) {
  1515. return value;
  1516. },
  1517. },
  1518. validation: {
  1519. messages: {
  1520. maxlength: function (viewValue, modelValue, scope) {
  1521. if (viewValue != null) {
  1522. if (viewValue.length > scope.to.maxlength) {
  1523. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1524. } else {
  1525. return "";
  1526. }
  1527. }
  1528. },
  1529. }
  1530. }
  1531. }
  1532. },
  1533. controller: ['$scope', function ($scope) {
  1534. var value = $scope.model[$scope.options.key];
  1535. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1536. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1537. }
  1538. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1539. $scope.options.templateOptions.felditem($scope);
  1540. }
  1541. }]
  1542. });
  1543. //设备组件
  1544. formlyConfigProvider.setType({
  1545. name: 'ui-applist',
  1546. extends: 'radio',
  1547. templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
  1548. defaultOptions: function (options) {
  1549. return {
  1550. templateOptions: {
  1551. refresh: function () {},
  1552. refreshDelay: 0
  1553. }
  1554. };
  1555. },
  1556. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1557. var data = [];
  1558. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1559. // data = JSON.parse($scope.model.consumables);
  1560. if (angular.isArray($scope.model.consumables)) {
  1561. data = $scope.model.consumables;
  1562. } else {
  1563. data = JSON.parse($scope.model.consumables);
  1564. }
  1565. $scope.model.consumables = data;
  1566. angular.forEach(data, function (item, index) {
  1567. data[index].item = index + 1;
  1568. })
  1569. }
  1570. if ($scope.model.assets && $scope.options.key == "assets") {
  1571. if (angular.isArray($scope.model.assets)) {
  1572. data = $scope.model.assets;
  1573. } else {
  1574. data = JSON.parse($scope.model.assets);
  1575. }
  1576. // data = JSON.parse($scope.model.assets);
  1577. $scope.model.assets = data;
  1578. angular.forEach(data, function (item, index) {
  1579. data[index].item = index + 1;
  1580. })
  1581. }
  1582. $scope.tableParams = new ngTableParams({
  1583. page: 1,
  1584. count: 5
  1585. }, {
  1586. total: data.length,
  1587. getData: function ($defer, params) {
  1588. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1589. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1590. }
  1591. });
  1592. $scope.editId = -1;
  1593. $scope.setEditId = function (pid) {
  1594. $scope.editId = pid;
  1595. };
  1596. }]
  1597. });
  1598. //list组件
  1599. formlyConfigProvider.setType({
  1600. name: 'ui-gudinglist',
  1601. extends: 'radio',
  1602. templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
  1603. defaultOptions: function (options) {
  1604. return {
  1605. templateOptions: {
  1606. refresh: function () {},
  1607. refreshDelay: 0
  1608. }
  1609. };
  1610. },
  1611. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1612. var data = [];
  1613. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1614. // data = JSON.parse($scope.model.consumables);
  1615. if (angular.isArray($scope.model.consumables)) {
  1616. data = $scope.model.consumables;
  1617. } else {
  1618. data = JSON.parse($scope.model.consumables);
  1619. }
  1620. $scope.model.consumables = data;
  1621. angular.forEach(data, function (item, index) {
  1622. data[index].item = index + 1;
  1623. })
  1624. }
  1625. if ($scope.model.assets && $scope.options.key == "assets") {
  1626. if (angular.isArray($scope.model.assets)) {
  1627. data = $scope.model.assets;
  1628. } else {
  1629. data = JSON.parse($scope.model.assets);
  1630. }
  1631. // data = JSON.parse($scope.model.assets);
  1632. $scope.model.assets = data;
  1633. angular.forEach(data, function (item, index) {
  1634. data[index].item = index + 1;
  1635. })
  1636. }
  1637. $scope.tableParams = new ngTableParams({
  1638. page: 1,
  1639. count: 5
  1640. }, {
  1641. total: data.length,
  1642. getData: function ($defer, params) {
  1643. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1644. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1645. }
  1646. });
  1647. $scope.editId = -1;
  1648. $scope.setEditId = function (pid) {
  1649. $scope.editId = pid;
  1650. };
  1651. }]
  1652. });
  1653. //other list tab组件
  1654. formlyConfigProvider.setType({
  1655. name: 'ui-otherlisttab',
  1656. extends: '',
  1657. templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
  1658. defaultOptions: function (options) {
  1659. return {
  1660. templateOptions: {
  1661. refresh: function () {},
  1662. refreshDelay: 0
  1663. }
  1664. };
  1665. },
  1666. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1667. }]
  1668. });
  1669. //审核查看组件
  1670. formlyConfigProvider.setType({
  1671. name: 'ui-aprovelist',
  1672. extends: '',
  1673. templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
  1674. defaultOptions: function (options) {
  1675. return {
  1676. templateOptions: {
  1677. refresh: function () {},
  1678. refreshDelay: 0
  1679. }
  1680. };
  1681. },
  1682. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1683. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  1684. $scope.isAgree = "同意";
  1685. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  1686. $scope.isAgree = "同意";
  1687. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  1688. $scope.isAgree = "返回修改";
  1689. }
  1690. }]
  1691. });
  1692. //other list组件
  1693. formlyConfigProvider.setType({
  1694. name: 'ui-otherlist',
  1695. extends: '',
  1696. templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
  1697. defaultOptions: function (options) {
  1698. return {
  1699. templateOptions: {
  1700. refresh: function () {},
  1701. refreshDelay: 0
  1702. }
  1703. };
  1704. },
  1705. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  1706. $scope.langs = i18nService.getAllLangs();
  1707. $scope.lang = 'zh-cn';
  1708. i18nService.setCurrentLang($scope.lang);
  1709. var vm = this;
  1710. vm.options = {};
  1711. vm.exampleTitle = ['expressionProperties', 'model property'];
  1712. vm.fields = [];
  1713. vm.models = {};
  1714. // vm.models["loginUser"] = $rootScope.user;
  1715. var that = $injector;
  1716. var parse = $parse;
  1717. var formKey = "";
  1718. var pdKey = "";
  1719. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1720. pdKey = $state.current.pdKey;
  1721. //console.log("pdKey::"+$state.current.pdKey);
  1722. }
  1723. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1724. formKey = $stateParams.formKey;
  1725. //console.log("formKey::"+$stateParams.formKey);
  1726. }
  1727. //用户测试数据,后续从header的auth中获取
  1728. var userId = 2;
  1729. userId = $rootScope.user.id;
  1730. //==============处理表单设计数据 开始====================
  1731. //处理组件加载后台数据选项的方法
  1732. function refreshSelectOptions(searchVal, field) {
  1733. if (field.templateOptions.optionsUrl) {
  1734. var process = BpmRestangular.all("");
  1735. if (field.templateOptions.ApiService) {
  1736. process = UserRestangular.all("");
  1737. }
  1738. process.customPOST({
  1739. "idx": 0,
  1740. "sum": 1000
  1741. }, field.templateOptions.optionsUrl).then(function (result) {
  1742. if (!field.templateOptions.options) {
  1743. field.templateOptions.options = [];
  1744. }
  1745. if (field.templateOptions.optionsDataKey) {
  1746. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  1747. } else {
  1748. field.templateOptions.options = result;
  1749. }
  1750. });
  1751. }
  1752. }
  1753. function decodeVMTabForm(model, tabs) {
  1754. var result = {
  1755. model: {},
  1756. tabs: []
  1757. };
  1758. var mdata = angular.fromJson(model);
  1759. angular.extend(result.model, mdata);
  1760. angular.forEach(tabs, function (tab) {
  1761. tab.form.model = vm.models;
  1762. angular.forEach(tab.form.fields, function (field) {
  1763. if (field.key == "") {
  1764. delete field.key;
  1765. }
  1766. field.type = "ui-otherlisttab";
  1767. if (angular.isDefined(field.extjson) && field.extjson != "") {
  1768. var extObj = angular.fromJson(field.extjson);
  1769. angular.extend(field.templateOptions, extObj.templateOptions);
  1770. delete extObj.templateOptions;
  1771. for (var prop in extObj) {
  1772. if (new RegExp("Expression").test(prop)) {
  1773. //var obj = $scope.$eval(extObj[prop]);
  1774. //extObj[prop] = $scope.$eval(extObj[prop]);
  1775. if (extObj[prop] != null) {
  1776. if (new RegExp("function").test(extObj[prop])) {
  1777. var propValue = eval(extObj[prop]);
  1778. extObj[prop] = propValue;
  1779. } else {
  1780. //console.log(extObj[prop]);
  1781. var obj = $scope.$eval(extObj[prop]);
  1782. extObj[prop] = obj;
  1783. //console.log(obj);
  1784. }
  1785. }
  1786. } else if (new RegExp("expressionProperties").test(prop)) {
  1787. for (var p in extObj[prop]) {
  1788. if (new RegExp("function").test(extObj[prop][p])) {
  1789. var propValue = eval(extObj[prop][p]);
  1790. extObj[prop][p] = propValue;
  1791. } else {
  1792. //if(p.indexOf("'")>=0){
  1793. // var obj = $scope.$eval(extObj[prop][p]);
  1794. // extObj[prop][$scope.$eval(p)]=obj;
  1795. //}
  1796. }
  1797. }
  1798. } else if ("watcher" == prop) {
  1799. if (angular.isArray(extObj[prop])) {
  1800. angular.forEach(extObj[prop], function (item, index) {
  1801. for (var p in item) {
  1802. if (new RegExp("function").test(item[p])) {
  1803. var propValue = eval(item[p]);
  1804. extObj[prop][index][p] = propValue;
  1805. }
  1806. }
  1807. });
  1808. } else if (angular.isObject(extObj[prop])) {
  1809. for (var p in extObj[prop]) {
  1810. if (new RegExp("function").test(extObj[prop][p])) {
  1811. var propValue = eval(extObj[prop][p]);
  1812. extObj[prop][p] = propValue;
  1813. }
  1814. }
  1815. }
  1816. }
  1817. }
  1818. angular.extend(field, extObj);
  1819. delete field.extjson;
  1820. }
  1821. if (field.extjson == "") {
  1822. delete field.extjson;
  1823. }
  1824. if (angular.isDefined(field.templateOptions)) {
  1825. var templateOs = field.templateOptions;
  1826. for (var property in templateOs) {
  1827. //console.log(property);
  1828. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  1829. if (new RegExp("function").test(templateOs[property])) {
  1830. var propValue = eval(templateOs[property]);
  1831. field.templateOptions[property] = propValue;
  1832. } else {
  1833. if (that.has(templateOs[property])) {
  1834. field.templateOptions[property] = that.get(templateOs[property]);
  1835. } else {
  1836. field.templateOptions[property] = templateOs[property];
  1837. }
  1838. }
  1839. } else if (templateOs[property] == null) {
  1840. //delete field.templateOptions[property];
  1841. } else {}
  1842. }
  1843. }
  1844. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  1845. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  1846. angular.extend(field.templateOptions, extObj);
  1847. delete field.templateOptions.extjson;
  1848. }
  1849. //...
  1850. if (field.templateOptions) {
  1851. //处理远程获取数据控件方法调用
  1852. if (field.templateOptions.optionsUrl) {
  1853. field.templateOptions.refresh = refreshSelectOptions;
  1854. }
  1855. //处理嵌套属性数据绑定/
  1856. if (field.templateOptions.pkey) {
  1857. var pmodel, i = 0;
  1858. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  1859. if (i == 0) {
  1860. if (result.model[p] == null) {
  1861. result.model[p] = {};
  1862. }
  1863. pmodel = result.model[p];
  1864. i++;
  1865. } else {
  1866. if (pmodel[p] == null) {
  1867. pmodel[p] = {};
  1868. }
  1869. pmodel = pmodel[p];
  1870. }
  1871. });
  1872. if (pmodel != null) {
  1873. field.model = pmodel;
  1874. if (pmodel[field.key] == null) {
  1875. pmodel[field.key] = null;
  1876. }
  1877. }
  1878. } else {
  1879. if (result.model[field.key] == null) {
  1880. result.model[field.key] = null;
  1881. }
  1882. }
  1883. //处理弹出框组件初始化
  1884. if (field.type == "ui-input-selectmodal") {
  1885. field.templateOptions.modal = $modal;
  1886. //field.templateOptions.Restangular = Restangular;
  1887. } else if (field.type == "ui-userselect") {
  1888. field.templateOptions.modal = $modal;
  1889. //field.templateOptions.Restangular = Restangular;
  1890. } else if (field.type == "ui-multiuserselect") {
  1891. field.templateOptions.modal = $modal;
  1892. } else if (field.type == "ui-modelselect") {
  1893. field.templateOptions.modal = $modal;
  1894. //field.templateOptions.Restangular = Restangular;
  1895. } else if (field.type == "ui-cmdbuplode") {
  1896. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  1897. url: '/uploader',
  1898. queueLimit: 1, //文件个数
  1899. autoUpload: true
  1900. });
  1901. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  1902. } else if (field.type == "ui-dropfile") {
  1903. field.templateOptions.fileUploader = new FileUploader({
  1904. url: '/uploader'
  1905. });
  1906. field.templateOptions.taskId = $stateParams.taskId;
  1907. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1908. field.templateOptions.userId = $rootScope.user.id;
  1909. //field.ApiService=api_bpm_domain;
  1910. } else if (field.type == "ui-dropfiletable") {
  1911. if (field.templateOptions.processInstanceId) {
  1912. } else {
  1913. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1914. }
  1915. } else if (field.type == "ui-repeatSection") {
  1916. var repeatForm = {
  1917. model: {
  1918. },
  1919. fields: field.templateOptions.fields
  1920. };
  1921. repeatForm.model[field.key] = [];
  1922. decodeVMTabForm(repeatForm);
  1923. }
  1924. }
  1925. // console.log(field);
  1926. //field
  1927. //result.fields.push(field);
  1928. })
  1929. });
  1930. vm.originalTabs = angular.copy(vm.form);
  1931. }
  1932. //======================处理表单设计数据 结束========================
  1933. $scope.ldloading = {};
  1934. function filter(obj) {
  1935. angular.forEach(obj, function (key, value) {
  1936. if (value === "" || value === null) {
  1937. delete obj[key];
  1938. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1939. filter(value);
  1940. } else if (angular.isArray(value)) {
  1941. angular.forEach(value, function (item) {
  1942. filter(item);
  1943. });
  1944. }
  1945. });
  1946. }
  1947. function invokeOnAllFormOptions(fn) {
  1948. angular.forEach(vm.tabs, function (tab) {
  1949. if (tab.form.options && tab.form.options[fn]) {
  1950. tab.form.options[fn]();
  1951. }
  1952. });
  1953. }
  1954. function encodeCIData(data, ciId) {
  1955. /*
  1956. create/update state:未审核
  1957. create createtime:系统时间
  1958. create/update lastupdatetime : 系统时间
  1959. label:ci分类
  1960. */
  1961. if (ciId) {
  1962. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  1963. var extraprop = 'props';
  1964. data[extraprop] = {};
  1965. for (var key in data) {
  1966. console.log(data[key]);
  1967. if (_.indexOf(baseprop, key) >= 0) {
  1968. continue;
  1969. } else {
  1970. data[extraprop][key] = data[key];
  1971. delete data[key];
  1972. }
  1973. }
  1974. if ($rootScope.user) {
  1975. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  1976. data[extraprop]['configperson'] = $rootScope.user.name;
  1977. var isCMAdminFlag = false;
  1978. angular.forEach($rootScope.user.role, function (roleItem) {
  1979. if (roleItem.rolecode == "cmdb charge") {
  1980. isCMAdminFlag = true;
  1981. }
  1982. })
  1983. if (!isCMAdminFlag) {
  1984. data[extraprop]['state'] = '1';
  1985. }
  1986. }
  1987. if (data.props.id) {
  1988. } else {
  1989. data.label = ciId;
  1990. }
  1991. return data;
  1992. }
  1993. return undefined;
  1994. }
  1995. function decodeCIModel(data) {
  1996. var extraprop = 'props';
  1997. if (data[extraprop]) {
  1998. for (var key in data[extraprop]) {
  1999. data[key] = data[extraprop][key];
  2000. }
  2001. delete data[extraprop];
  2002. }
  2003. data['iscmadmin'] = false;
  2004. angular.forEach($rootScope.user.role, function (roleItem) {
  2005. if (roleItem.rolecode == "cmdb charge") {
  2006. data['iscmadmin'] = true;
  2007. }
  2008. })
  2009. return data;
  2010. }
  2011. function formValid() {
  2012. angular.forEach(vm.tabs, function (item) {
  2013. //item.
  2014. })
  2015. }
  2016. $scope.vm = vm;
  2017. $scope.refreshcmdbform = function (item) {
  2018. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2019. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2020. var myData = Restangular.stripRestangular(data);
  2021. $scope.propTypeOptions = myData;
  2022. $scope.templateProps = myData;
  2023. $scope.vm.tabs = myData;
  2024. if ($scope.model.assets) {
  2025. vm.models = JSON.parse($scope.model.assets);
  2026. }
  2027. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2028. if (vm.models.vtvmvtm_kaiji) {
  2029. vm.models.vtvmvtm_kaiji = "是";
  2030. } else {
  2031. vm.models.vtvmvtm_kaiji = "否";
  2032. }
  2033. }
  2034. decodeVMTabForm(vm.models, vm.tabs);
  2035. });
  2036. // }
  2037. }
  2038. var cifilterClassic = {};
  2039. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2040. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2041. $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
  2042. // } else {}
  2043. }]
  2044. });
  2045. //固定资产下载
  2046. formlyConfigProvider.setType({
  2047. name: 'ui-dropupload',
  2048. templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
  2049. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2050. defaultOptions: function (options) {
  2051. return {
  2052. templateOptions: {
  2053. view: function (APIService, contentId) {
  2054. return APIService.downloadAttachment(contentId);
  2055. },
  2056. },
  2057. };
  2058. },
  2059. controller: ['$scope', '$rootScope', 'Restangular', function ($scope, $rootScope, Restangular) {
  2060. if (angular.isUndefined($scope.form.dropState)) {
  2061. $scope.form.dropState = false;
  2062. }
  2063. var to = $scope.options.templateOptions;
  2064. var bindId = $scope.model[to.bindType].processInstanceId;
  2065. //获取附件列表
  2066. $scope.listAttachmen = function () {
  2067. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  2068. var myData = Restangular.stripRestangular(result);
  2069. // $scope.listAttachmens = myData;
  2070. $scope.attachments = myData.data;
  2071. });
  2072. };
  2073. $scope.listAttachmen();
  2074. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2075. // $scope.listAttachmen();
  2076. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2077. // $scope.listAttachmen();
  2078. // }
  2079. //附件下载
  2080. $scope.download = function (token, filename) {
  2081. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  2082. var a = document.createElement('a');
  2083. a.href = downUrl;
  2084. a.target = '_blank';
  2085. a.download = filename;
  2086. document.body.appendChild(a);
  2087. a.click();
  2088. };
  2089. //附件预览
  2090. $scope.view = function (id, previewUrl) {
  2091. if (previewUrl) {
  2092. window.open(previewUrl);
  2093. }
  2094. };
  2095. }]
  2096. });
  2097. formlyConfigProvider.setType({
  2098. name: 'ui-form',
  2099. templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
  2100. defaultOptions: function (options) {
  2101. return {
  2102. templateOptions: {
  2103. // link: function() {}
  2104. }
  2105. };
  2106. },
  2107. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  2108. $scope.langs = i18nService.getAllLangs();
  2109. $scope.lang = 'zh-cn';
  2110. i18nService.setCurrentLang($scope.lang);
  2111. var vm = this;
  2112. vm.options = {};
  2113. vm.exampleTitle = ['expressionProperties', 'model property'];
  2114. vm.fields = [];
  2115. vm.models = {};
  2116. // vm.models["loginUser"] = $rootScope.user;
  2117. var that = $injector;
  2118. var parse = $parse;
  2119. var formKey = "";
  2120. var pdKey = "";
  2121. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  2122. pdKey = $state.current.pdKey;
  2123. //console.log("pdKey::"+$state.current.pdKey);
  2124. }
  2125. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2126. formKey = $stateParams.formKey;
  2127. //console.log("formKey::"+$stateParams.formKey);
  2128. }
  2129. //用户测试数据,后续从header的auth中获取
  2130. var userId = 2;
  2131. userId = $rootScope.user.id;
  2132. //==============处理表单设计数据 开始====================
  2133. //处理组件加载后台数据选项的方法
  2134. function refreshSelectOptions(searchVal, field) {
  2135. if (field.templateOptions.optionsUrl) {
  2136. var process = BpmRestangular.all("");
  2137. if (field.templateOptions.ApiService) {
  2138. process = UserRestangular.all("");
  2139. }
  2140. process.customPOST({
  2141. "idx": 0,
  2142. "sum": 1000
  2143. }, field.templateOptions.optionsUrl).then(function (result) {
  2144. if (!field.templateOptions.options) {
  2145. field.templateOptions.options = [];
  2146. }
  2147. if (field.templateOptions.optionsDataKey) {
  2148. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  2149. } else {
  2150. field.templateOptions.options = result;
  2151. }
  2152. });
  2153. }
  2154. }
  2155. function decodeVMTabForm(model, tabs) {
  2156. var result = {
  2157. model: {},
  2158. tabs: []
  2159. };
  2160. var mdata = angular.fromJson(model);
  2161. angular.extend(result.model, mdata);
  2162. angular.forEach(tabs, function (tab) {
  2163. tab.form.model = vm.models;
  2164. angular.forEach(tab.form.fields, function (field) {
  2165. if (field.key == "") {
  2166. delete field.key;
  2167. }
  2168. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2169. var extObj = angular.fromJson(field.extjson);
  2170. angular.extend(field.templateOptions, extObj.templateOptions);
  2171. delete extObj.templateOptions;
  2172. for (var prop in extObj) {
  2173. if (new RegExp("Expression").test(prop)) {
  2174. //var obj = $scope.$eval(extObj[prop]);
  2175. //extObj[prop] = $scope.$eval(extObj[prop]);
  2176. if (extObj[prop] != null) {
  2177. if (new RegExp("function").test(extObj[prop])) {
  2178. var propValue = eval(extObj[prop]);
  2179. extObj[prop] = propValue;
  2180. } else {
  2181. //console.log(extObj[prop]);
  2182. var obj = $scope.$eval(extObj[prop]);
  2183. extObj[prop] = obj;
  2184. //console.log(obj);
  2185. }
  2186. }
  2187. } else if (new RegExp("expressionProperties").test(prop)) {
  2188. for (var p in extObj[prop]) {
  2189. if (new RegExp("function").test(extObj[prop][p])) {
  2190. var propValue = eval(extObj[prop][p]);
  2191. extObj[prop][p] = propValue;
  2192. } else {
  2193. //if(p.indexOf("'")>=0){
  2194. // var obj = $scope.$eval(extObj[prop][p]);
  2195. // extObj[prop][$scope.$eval(p)]=obj;
  2196. //}
  2197. }
  2198. }
  2199. } else if ("watcher" == prop) {
  2200. if (angular.isArray(extObj[prop])) {
  2201. angular.forEach(extObj[prop], function (item, index) {
  2202. for (var p in item) {
  2203. if (new RegExp("function").test(item[p])) {
  2204. var propValue = eval(item[p]);
  2205. extObj[prop][index][p] = propValue;
  2206. }
  2207. }
  2208. });
  2209. } else if (angular.isObject(extObj[prop])) {
  2210. for (var p in extObj[prop]) {
  2211. if (new RegExp("function").test(extObj[prop][p])) {
  2212. var propValue = eval(extObj[prop][p]);
  2213. extObj[prop][p] = propValue;
  2214. }
  2215. }
  2216. }
  2217. }
  2218. }
  2219. angular.extend(field, extObj);
  2220. delete field.extjson;
  2221. }
  2222. if (field.extjson == "") {
  2223. delete field.extjson;
  2224. }
  2225. if (angular.isDefined(field.templateOptions)) {
  2226. var templateOs = field.templateOptions;
  2227. for (var property in templateOs) {
  2228. //console.log(property);
  2229. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2230. if (new RegExp("function").test(templateOs[property])) {
  2231. var propValue = eval(templateOs[property]);
  2232. field.templateOptions[property] = propValue;
  2233. } else {
  2234. if (that.has(templateOs[property])) {
  2235. field.templateOptions[property] = that.get(templateOs[property]);
  2236. } else {
  2237. field.templateOptions[property] = templateOs[property];
  2238. }
  2239. }
  2240. } else if (templateOs[property] == null) {
  2241. //delete field.templateOptions[property];
  2242. } else {}
  2243. }
  2244. }
  2245. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2246. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2247. angular.extend(field.templateOptions, extObj);
  2248. delete field.templateOptions.extjson;
  2249. }
  2250. //...
  2251. if (field.templateOptions) {
  2252. //处理远程获取数据控件方法调用
  2253. if (field.templateOptions.optionsUrl) {
  2254. field.templateOptions.refresh = refreshSelectOptions;
  2255. }
  2256. //处理嵌套属性数据绑定/
  2257. if (field.templateOptions.pkey) {
  2258. var pmodel, i = 0;
  2259. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2260. if (i == 0) {
  2261. if (result.model[p] == null) {
  2262. result.model[p] = {};
  2263. }
  2264. pmodel = result.model[p];
  2265. i++;
  2266. } else {
  2267. if (pmodel[p] == null) {
  2268. pmodel[p] = {};
  2269. }
  2270. pmodel = pmodel[p];
  2271. }
  2272. });
  2273. if (pmodel != null) {
  2274. field.model = pmodel;
  2275. if (pmodel[field.key] == null) {
  2276. pmodel[field.key] = null;
  2277. }
  2278. }
  2279. } else {
  2280. if (result.model[field.key] == null) {
  2281. result.model[field.key] = null;
  2282. }
  2283. }
  2284. //处理弹出框组件初始化
  2285. if (field.type == "ui-input-selectmodal") {
  2286. field.templateOptions.modal = $modal;
  2287. //field.templateOptions.Restangular = Restangular;
  2288. } else if (field.type == "ui-userselect") {
  2289. field.templateOptions.modal = $modal;
  2290. //field.templateOptions.Restangular = Restangular;
  2291. } else if (field.type == "ui-multiuserselect") {
  2292. field.templateOptions.modal = $modal;
  2293. } else if (field.type == "ui-modelselect") {
  2294. field.templateOptions.modal = $modal;
  2295. //field.templateOptions.Restangular = Restangular;
  2296. } else if (field.type == "ui-dropfile") {
  2297. field.templateOptions.fileUploader = new FileUploader({
  2298. url: '/uploader'
  2299. });
  2300. field.templateOptions.taskId = $stateParams.taskId;
  2301. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2302. field.templateOptions.userId = $rootScope.user.id;
  2303. //field.ApiService=api_bpm_domain;
  2304. } else if (field.type == "ui-dropfiletable") {
  2305. if (field.templateOptions.processInstanceId) {
  2306. } else {
  2307. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2308. }
  2309. } else if (field.type == "ui-repeatSection") {
  2310. var repeatForm = {
  2311. model: {
  2312. },
  2313. fields: field.templateOptions.fields
  2314. };
  2315. repeatForm.model[field.key] = [];
  2316. decodeVMTabForm(repeatForm);
  2317. }
  2318. }
  2319. // console.log(field);
  2320. //field
  2321. //result.fields.push(field);
  2322. })
  2323. });
  2324. vm.originalTabs = angular.copy(vm.form);
  2325. }
  2326. //解析自定义表单设计数据
  2327. function decodeVMForm(vmForm) {
  2328. var result = {
  2329. model: {},
  2330. tabs: []
  2331. };
  2332. //设置模型实体数据 begin
  2333. // var mdata = vmForm.model;
  2334. //解析数据实体
  2335. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2336. angular.extend(result.model, mdata);
  2337. //设置模型实体数据 end
  2338. //解析设计数据生成表单项 begin
  2339. var fields = [];
  2340. //处理修改设计数据中展示设置
  2341. angular.forEach(vmForm.tabs, function (field) {
  2342. if (field.key == "") {
  2343. delete field.key;
  2344. }
  2345. if (angular.isDefined(field.extjson)) {
  2346. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2347. angular.extend(field.templateOptions, extObj.templateOptions);
  2348. delete extObj.templateOptions;
  2349. for (var prop in extObj) {
  2350. if (new RegExp("Expression").test(prop)) {
  2351. //var obj = $scope.$eval(extObj[prop]);
  2352. //extObj[prop] = $scope.$eval(extObj[prop]);
  2353. if (extObj[prop] != null) {
  2354. if (new RegExp("function").test(extObj[prop])) {
  2355. var propValue = eval(extObj[prop]);
  2356. extObj[prop] = propValue;
  2357. } else {
  2358. //console.log(extObj[prop]);
  2359. var obj = $scope.$eval(extObj[prop]);
  2360. extObj[prop] = obj;
  2361. //console.log(obj);
  2362. }
  2363. }
  2364. } else if (new RegExp("expressionProperties").test(prop)) {
  2365. for (var p in extObj[prop]) {
  2366. if (new RegExp("function").test(extObj[prop][p])) {
  2367. var propValue = eval(extObj[prop][p]);
  2368. extObj[prop][p] = propValue;
  2369. } else {
  2370. //if(p.indexOf("'")>=0){
  2371. // var obj = $scope.$eval(extObj[prop][p]);
  2372. // extObj[prop][$scope.$eval(p)]=obj;
  2373. //}
  2374. }
  2375. }
  2376. } else if ("watcher" == prop) {
  2377. if (angular.isArray(extObj[prop])) {
  2378. angular.forEach(extObj[prop], function (item, index) {
  2379. for (var p in item) {
  2380. if (new RegExp("function").test(item[p])) {
  2381. var propValue = eval(item[p]);
  2382. extObj[prop][index][p] = propValue;
  2383. }
  2384. }
  2385. });
  2386. } else if (angular.isObject(extObj[prop])) {
  2387. for (var p in extObj[prop]) {
  2388. if (new RegExp("function").test(extObj[prop][p])) {
  2389. var propValue = eval(extObj[prop][p]);
  2390. extObj[prop][p] = propValue;
  2391. }
  2392. }
  2393. }
  2394. }
  2395. }
  2396. angular.extend(field, extObj);
  2397. delete field.extjson;
  2398. }
  2399. if (angular.isDefined(field.templateOptions)) {
  2400. var templateOs = field.templateOptions;
  2401. for (var property in templateOs) {
  2402. //console.log(property);
  2403. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2404. if (new RegExp("function").test(templateOs[property])) {
  2405. var propValue = eval(templateOs[property]);
  2406. field.templateOptions[property] = propValue;
  2407. } else {
  2408. if (that.has(templateOs[property])) {
  2409. field.templateOptions[property] = that.get(templateOs[property]);
  2410. } else {
  2411. field.templateOptions[property] = templateOs[property];
  2412. }
  2413. }
  2414. } else if (templateOs[property] == null) {
  2415. //delete field.templateOptions[property];
  2416. } else {}
  2417. }
  2418. }
  2419. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2420. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2421. angular.extend(field.templateOptions, extObj);
  2422. delete field.templateOptions.extjson;
  2423. }
  2424. //...
  2425. if (field.templateOptions) {
  2426. //处理远程获取数据控件方法调用
  2427. if (field.templateOptions.optionsUrl) {
  2428. field.templateOptions.refresh = refreshSelectOptions;
  2429. }
  2430. //处理嵌套属性数据绑定/
  2431. if (field.templateOptions.pkey) {
  2432. var pmodel, i = 0;
  2433. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2434. if (i == 0) {
  2435. if (result.model[p] == null) {
  2436. result.model[p] = {};
  2437. }
  2438. pmodel = result.model[p];
  2439. i++;
  2440. } else {
  2441. if (pmodel[p] == null) {
  2442. pmodel[p] = {};
  2443. }
  2444. pmodel = pmodel[p];
  2445. }
  2446. });
  2447. if (pmodel != null) {
  2448. field.model = pmodel;
  2449. if (pmodel[field.key] == null) {
  2450. pmodel[field.key] = null;
  2451. }
  2452. }
  2453. } else {
  2454. if (result.model[field.key] == null) {
  2455. result.model[field.key] = null;
  2456. }
  2457. }
  2458. //处理弹出框组件初始化
  2459. if (field.type == "ui-input-selectmodal") {
  2460. field.templateOptions.modal = $modal;
  2461. //field.templateOptions.Restangular = Restangular;
  2462. } else if (field.type == "ui-userselect") {
  2463. field.templateOptions.modal = $modal;
  2464. //field.templateOptions.Restangular = Restangular;
  2465. } else if (field.type == "ui-multiuserselect") {
  2466. field.templateOptions.modal = $modal;
  2467. } else if (field.type == "ui-modelselect") {
  2468. field.templateOptions.modal = $modal;
  2469. //field.templateOptions.Restangular = Restangular;
  2470. } else if (field.type == "ui-dropfile") {
  2471. field.templateOptions.fileUploader = new FileUploader({
  2472. url: '/uploader'
  2473. });
  2474. field.templateOptions.taskId = $stateParams.taskId;
  2475. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2476. field.templateOptions.userId = $rootScope.user.id;
  2477. //field.ApiService=api_bpm_domain;
  2478. } else if (field.type == "ui-dropfiletable") {
  2479. if (field.templateOptions.processInstanceId) {
  2480. } else {
  2481. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2482. }
  2483. } else if (field.type == "ui-repeatSection") {
  2484. var repeatForm = {
  2485. model: {
  2486. },
  2487. fields: field.templateOptions.fields
  2488. };
  2489. repeatForm.model[field.key] = [];
  2490. decodeVMForm(repeatForm);
  2491. }
  2492. }
  2493. // console.log(field);
  2494. result.fields.push(field);
  2495. });
  2496. angular.extend($scope.vm.fields, result.fields);
  2497. angular.extend($scope.vm.models, result.model);
  2498. $scope.formData = vmForm;
  2499. //console.log($scope.vm);
  2500. //解析设计数据生成表单项 end
  2501. return result;
  2502. }
  2503. //======================处理表单设计数据 结束========================
  2504. $scope.ldloading = {};
  2505. function filter(obj) {
  2506. angular.forEach(obj, function (key, value) {
  2507. if (value === "" || value === null) {
  2508. delete obj[key];
  2509. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  2510. filter(value);
  2511. } else if (angular.isArray(value)) {
  2512. angular.forEach(value, function (item) {
  2513. filter(item);
  2514. });
  2515. }
  2516. });
  2517. }
  2518. function invokeOnAllFormOptions(fn) {
  2519. angular.forEach(vm.tabs, function (tab) {
  2520. if (tab.form.options && tab.form.options[fn]) {
  2521. tab.form.options[fn]();
  2522. }
  2523. });
  2524. }
  2525. function encodeCIData(data, ciId) {
  2526. /*
  2527. create/update state:未审核
  2528. create createtime:系统时间
  2529. create/update lastupdatetime : 系统时间
  2530. label:ci分类
  2531. */
  2532. if (ciId) {
  2533. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2534. var extraprop = 'props';
  2535. data[extraprop] = {};
  2536. for (var key in data) {
  2537. console.log(data[key]);
  2538. if (_.indexOf(baseprop, key) >= 0) {
  2539. continue;
  2540. } else {
  2541. data[extraprop][key] = data[key];
  2542. delete data[key];
  2543. }
  2544. }
  2545. if ($rootScope.user) {
  2546. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2547. data[extraprop]['configperson'] = $rootScope.user.name;
  2548. var isCMAdminFlag = false;
  2549. angular.forEach($rootScope.user.role, function (roleItem) {
  2550. if (roleItem.rolecode == "cmdb charge") {
  2551. isCMAdminFlag = true;
  2552. }
  2553. })
  2554. if (!isCMAdminFlag) {
  2555. data[extraprop]['state'] = '1';
  2556. }
  2557. }
  2558. if (data.props.id) {
  2559. } else {
  2560. data.label = ciId;
  2561. }
  2562. return data;
  2563. }
  2564. return undefined;
  2565. }
  2566. function decodeCIModel(data) {
  2567. var extraprop = 'props';
  2568. if (data[extraprop]) {
  2569. for (var key in data[extraprop]) {
  2570. data[key] = data[extraprop][key];
  2571. }
  2572. delete data[extraprop];
  2573. }
  2574. data['iscmadmin'] = false;
  2575. angular.forEach($rootScope.user.role, function (roleItem) {
  2576. if (roleItem.rolecode == "cmdb charge") {
  2577. data['iscmadmin'] = true;
  2578. }
  2579. })
  2580. return data;
  2581. }
  2582. vm.remove = function (data, style) {
  2583. $scope.ldloading[style.replace('-', '_')] = true;
  2584. var modalInstance = $modal.open({
  2585. templateUrl: 'assets/views/delete.html',
  2586. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  2587. var cidata = {
  2588. label: data.label,
  2589. id: data.id,
  2590. uuid: data.uuid,
  2591. name: data.name,
  2592. props: {}
  2593. };
  2594. if (cidata.id) {
  2595. cidata.props['removeflag'] = true;
  2596. cidata.props['lastupdateperson'] = vm.models.loginUser;
  2597. $scope.ok = function () {
  2598. $modalInstance.close(cidata);
  2599. };
  2600. $scope.cancel = function () {
  2601. $modalInstance.dismiss('cancel');
  2602. };
  2603. }
  2604. },
  2605. size: 'sm',
  2606. resolve: {
  2607. scope: function () {
  2608. return $scope;
  2609. }
  2610. }
  2611. });
  2612. modalInstance.result.then(function (selectedItem) {
  2613. if (selectedItem) {
  2614. // if (selectedItem.length > 0) {
  2615. api_cmdb.put(selectedItem, selectedItem.id).then(function (response) {
  2616. if (response) {
  2617. var resData = Restangular.stripRestangular(response);
  2618. SweetAlert.swal({
  2619. title: "删除成功!",
  2620. confirmButtonColor: "#007AFF"
  2621. }, function () {
  2622. $state.go("app.means.list");
  2623. // $scope.refreshform();
  2624. // reinitTabForm($scope.classify);
  2625. });
  2626. } else {
  2627. SweetAlert.swal({
  2628. title: "系统错误",
  2629. text: "系统错误,请稍后重试!",
  2630. type: "error",
  2631. confirmButtonColor: "#DD6B55"
  2632. });
  2633. }
  2634. $scope.ldloading[style.replace('-', '_')] = false;
  2635. });
  2636. }
  2637. })
  2638. }
  2639. function formValid() {
  2640. angular.forEach(vm.tabs, function (item) {
  2641. //item.
  2642. })
  2643. }
  2644. $scope.closeModel = function () {
  2645. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2646. if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
  2647. $state.go('app.means.list', {});
  2648. }
  2649. event.preventDefault();
  2650. }
  2651. }
  2652. // setInterval(function() {
  2653. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  2654. // cifilter_classic = $scope.model.cifilter_classic;
  2655. // $scope.refreshcmdbform(cifilter_classic);
  2656. // } else {}
  2657. // }, 100);
  2658. vm.models = (function filter(obj) {
  2659. var filtered = _.pick(obj, function (v) {
  2660. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2661. });
  2662. return _.cloneDeep(filtered, function (v) {
  2663. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2664. });
  2665. })(vm.models);
  2666. // setInterval(function() {
  2667. // if ($scope.model.type == 0) {
  2668. // $scope.model[$scope.options.key] = vm.models;
  2669. // }
  2670. // }, 100);
  2671. setInterval(function () {
  2672. if (vm.form && vm.form.$$parentForm.$valid) {
  2673. if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
  2674. vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2675. $scope.model[$scope.options.key] = vm.models;
  2676. }
  2677. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2678. // $scope.model[$scope.options.key] = vm.models;
  2679. }
  2680. }, 100);
  2681. vm.submit = function (data, ciId, templateitem, style) {
  2682. // $scope.ldloading[style.replace('-', '_')] = true;
  2683. console.log(vm.form.$$parentForm.$valid);
  2684. if (vm.form.$$parentForm.$valid) {
  2685. invokeOnAllFormOptions('updateInitialValue');
  2686. //alert(JSON.stringify(vm.model), null, 2);
  2687. //vm.options.updateInitialValue();
  2688. //console.log(vm.model);
  2689. var cidata = encodeCIData(vm.models, ciId);
  2690. if (cidata) {
  2691. //var cidata = ;
  2692. if (cidata.props.id) {
  2693. //修改
  2694. api_cmdb.put(cidata, ciId).then(function (response) {
  2695. if (response) {
  2696. var resData = Restangular.stripRestangular(response);
  2697. SweetAlert.swal({
  2698. title: "保存成功!",
  2699. confirmButtonColor: "#007AFF"
  2700. }, function () {
  2701. $scope.ldloading[style.replace('-', '_')] = false;
  2702. // $scope.refreshform();
  2703. $state.go("app.means.list");
  2704. });
  2705. } else {
  2706. SweetAlert.swal({
  2707. title: "系统错误",
  2708. text: "系统错误,请稍后重试!",
  2709. type: "error",
  2710. confirmButtonColor: "#DD6B55"
  2711. });
  2712. }
  2713. $scope.ldloading[style.replace('-', '_')] = false;
  2714. });
  2715. } else {
  2716. //新建
  2717. var type = 2;
  2718. api_sysinfo.getSerialnumber(type, templateitem.id).then(function (data) {
  2719. if (data && data.status == 200) {
  2720. cidata.uuid = data.uuid;
  2721. api_cmdb.create(cidata).then(function (response) {
  2722. if (response) {
  2723. var resData = Restangular.stripRestangular(response);
  2724. SweetAlert.swal({
  2725. title: "保存成功!",
  2726. text: "内部编号:" + cidata.uuid,
  2727. confirmButtonColor: "#007AFF"
  2728. }, function () {
  2729. $state.go("app.means.list");
  2730. });
  2731. // if(resData.status){
  2732. // resData
  2733. // }
  2734. } else {
  2735. SweetAlert.swal({
  2736. title: "系统错误",
  2737. text: "系统错误,请稍后重试!",
  2738. type: "error",
  2739. confirmButtonColor: "#DD6B55"
  2740. });
  2741. }
  2742. $scope.ldloading[style.replace('-', '_')] = false;
  2743. });
  2744. } else {
  2745. SweetAlert.swal({
  2746. title: "系统错误",
  2747. text: "内部编号生成出错!",
  2748. type: "error",
  2749. confirmButtonColor: "#DD6B55"
  2750. });
  2751. }
  2752. })
  2753. }
  2754. } else {
  2755. SweetAlert.swal({
  2756. title: "错误",
  2757. text: "错误,请选择资产分类!",
  2758. type: "error",
  2759. confirmButtonColor: "#DD6B55"
  2760. });
  2761. }
  2762. //alert(JSON.stringify(cidata), null, 2);
  2763. $scope.ldloading[style.replace('-', '_')] = true;
  2764. return;
  2765. var _ = window._;
  2766. vm.models = (function filter(obj) {
  2767. var filtered = _.pick(obj, function (v) {
  2768. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2769. });
  2770. return _.cloneDeep(filtered, function (v) {
  2771. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2772. });
  2773. })(vm.models);
  2774. } else {
  2775. if (vm.form.$$parentForm.$error) {
  2776. SweetAlert.swal({
  2777. title: "校验错误",
  2778. text: "请填写必填项!",
  2779. type: "error",
  2780. confirmButtonColor: "#DD6B55"
  2781. });
  2782. angular.forEach(vm.form.$$parentForm.$error.required, function (item) {
  2783. angular.forEach(vm.tabs, function (tab) {
  2784. angular.forEach(tab.form.fields, function (f) {
  2785. if (f.name == item.$name) {
  2786. f.validation.show = true;
  2787. tab.active = true;
  2788. }
  2789. })
  2790. })
  2791. });
  2792. $scope.ldloading[style.replace('-', '_')] = false;
  2793. }
  2794. }
  2795. };
  2796. $scope.vm = vm;
  2797. $scope.refreshcmdbform = function (item) {
  2798. // if ($stateParams.model) {
  2799. // var modeldata = JSON.parse($stateParams.model)
  2800. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2801. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2802. var myData = Restangular.stripRestangular(data);
  2803. $scope.propTypeOptions = myData;
  2804. $scope.templateProps = myData;
  2805. $scope.vm.tabs = myData;
  2806. if ($scope.model.asset && $scope.model.asset.length != "") {
  2807. vm.models = JSON.parse($scope.model.asset);
  2808. }
  2809. decodeVMTabForm(vm.models, vm.tabs);
  2810. });
  2811. // }
  2812. }
  2813. var cifilterClassic = {};
  2814. setInterval(function () {
  2815. if ($scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2816. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  2817. cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2818. $scope.refreshcmdbform(cifilterClassic);
  2819. } else {}
  2820. }, 100);
  2821. }]
  2822. });
  2823. //请求人信息
  2824. formlyConfigProvider.setType({
  2825. name: 'ui-cmdbinformation',
  2826. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
  2827. wrapper: ['bootstrapHasError'],
  2828. defaultOptions: function (options, $scope) {
  2829. return {
  2830. templateOptions: {
  2831. // checkform: function(options) {
  2832. // if (options.model.requester) {
  2833. // options.value(options.model.requester);
  2834. // }
  2835. // },
  2836. }
  2837. };
  2838. },
  2839. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2840. if ($scope.options.templateOptions.loginUser) {
  2841. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
  2842. } else {
  2843. $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
  2844. }
  2845. $scope.options.initialValue = $scope.model[$scope.options.key];
  2846. }
  2847. }]
  2848. });
  2849. //资产属性
  2850. formlyConfigProvider.setType({
  2851. name: 'ui-cmdbtype',
  2852. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
  2853. wrapper: ['bootstrapHasError'],
  2854. defaultOptions: function (options, $scope) {
  2855. return {
  2856. templateOptions: {
  2857. // checkform: function(options) {
  2858. // if (options.model.requester) {
  2859. // options.value(options.model.requester);
  2860. // }
  2861. // },
  2862. }
  2863. };
  2864. },
  2865. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2866. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2867. $scope.property = {
  2868. 'hw_change': $scope.to.loginUser,
  2869. 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
  2870. 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
  2871. }
  2872. if ($scope.$parent.$parent.$parent.model.assets) {
  2873. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  2874. }
  2875. }]
  2876. });
  2877. //申请单信息
  2878. formlyConfigProvider.setType({
  2879. name: 'ui-cmdbformimform',
  2880. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
  2881. wrapper: ['bootstrapHasError'],
  2882. defaultOptions: function (options, $scope) {
  2883. return {
  2884. templateOptions: {
  2885. // checkform: function(options) {
  2886. // if (options.model.requester) {
  2887. // options.value(options.model.requester);
  2888. // }
  2889. // },
  2890. }
  2891. };
  2892. },
  2893. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2894. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2895. $scope.getininform = {
  2896. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2897. time: $scope.$parent.$parent.$parent.model.applicationForm.time
  2898. };
  2899. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  2900. $scope.getininform.types = "新资产入库";
  2901. } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
  2902. $scope.getininform.types = "资产归还";
  2903. }
  2904. }]
  2905. });
  2906. //出库单信息
  2907. formlyConfigProvider.setType({
  2908. name: 'ui-outinformation',
  2909. templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
  2910. wrapper: ['bootstrapHasError'],
  2911. defaultOptions: function (options, $scope) {
  2912. return {
  2913. templateOptions: {
  2914. // checkform: function(options) {
  2915. // if (options.model.requester) {
  2916. // options.value(options.model.requester);
  2917. // }
  2918. // },
  2919. }
  2920. };
  2921. },
  2922. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2923. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2924. $scope.getininform = {
  2925. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2926. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  2927. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  2928. sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  2929. describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
  2930. };
  2931. if ($scope.$parent.$parent.$parent.model.type.id == 1) {
  2932. $scope.getininform.types = "新设备领用出库";
  2933. } else if ($scope.$parent.$parent.$parent.model.type.id == 4) {
  2934. $scope.getininform.types = "设备更换";
  2935. }
  2936. $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.id;
  2937. if ($scope.$parent.$parent.$parent.model.source.id == 1) {
  2938. $scope.getininform.source = "事件";
  2939. } else if ($scope.$parent.$parent.$parent.model.source.id == 2) {
  2940. $scope.getininform.source = "变更";
  2941. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  2942. } else if ($scope.$parent.$parent.$parent.model.source.id == 3) {
  2943. $scope.getininform.source = "其它";
  2944. }
  2945. }]
  2946. });
  2947. //资产附件上传
  2948. formlyConfigProvider.setType({
  2949. name: 'ui-cmdbuplode',
  2950. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
  2951. wrapper: ['bootstrapHasError'],
  2952. defaultOptions: function (options, $scope) {
  2953. return {
  2954. templateOptions: {
  2955. // checkform: function(options) {
  2956. // if (options.model.requester) {
  2957. // options.value(options.model.requester);
  2958. // }
  2959. // },
  2960. }
  2961. };
  2962. },
  2963. controller: ['$scope', '$rootScope', '$http', 'SweetAlert', 'FileUploader', 'api_user_data', 'i18nService', '$modal', 'Restangular', 'api_configure_data', 'api_cmdb', 'api_cmdb_new', 'api_wechatfile', 'api_sysinfo', function ($scope, $rootScope, $http, SweetAlert, FileUploader, api_user_data, i18nService, $modal, Restangular, api_configure_data, api_cmdb, api_cmdb_new, api_wechatfile, api_sysinfo) {
  2964. $scope.state = 1;
  2965. $scope.myData3all = [];
  2966. $scope.myData3 = [];
  2967. $scope.memoryfilterDatahao = {
  2968. "idx": 0,
  2969. "sum": 10,
  2970. }
  2971. $scope.selected = {
  2972. items: []
  2973. };
  2974. $scope.interceptMydata = function (mydate, idx, sum) {
  2975. return mydate.slice(idx * sum, (idx + 1) * sum)
  2976. }
  2977. // $scope.importnext = function() {
  2978. // $scope.state = 2;
  2979. // event.preventDefault();
  2980. // }
  2981. $scope.workspaces = [];
  2982. $scope.options.templateOptions.getpush = function (item) {
  2983. $scope.workspaces = [];
  2984. if (item.gu) {
  2985. $scope.workspaces.push({
  2986. id: 1,
  2987. name: "固定资产",
  2988. active: true,
  2989. contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html'
  2990. })
  2991. }
  2992. if (item.hao) {
  2993. $scope.workspaces.push({
  2994. id: 2,
  2995. name: "耗材资产",
  2996. active: true,
  2997. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  2998. })
  2999. }
  3000. };
  3001. //获取附件列表
  3002. $scope.listAttachmen = function () {
  3003. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  3004. var myData = Restangular.stripRestangular(result);
  3005. // $scope.listAttachmens = myData;
  3006. $scope.attachments = myData.data;
  3007. });
  3008. };
  3009. //附件列表
  3010. if ($scope.options.templateOptions.bindType) {
  3011. if (angular.isUndefined($scope.form.dropState)) {
  3012. $scope.form.dropState = false;
  3013. }
  3014. var to = $scope.options.templateOptions;
  3015. var bindId = $scope.model[to.bindType].processInstanceId;
  3016. $scope.listAttachmen();
  3017. }
  3018. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3019. // $scope.listAttachmen();
  3020. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3021. // $scope.listAttachmen();
  3022. // }
  3023. //附件下载
  3024. $scope.download = function (token, filename) {
  3025. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  3026. // window.open(downUrl);
  3027. var a = document.createElement('a');
  3028. a.href = downUrl;
  3029. a.target = '_blank';
  3030. a.download = filename;
  3031. document.body.appendChild(a);
  3032. a.click();
  3033. };
  3034. //附件预览
  3035. $scope.view = function (id, previewUrl) {
  3036. if (previewUrl) {
  3037. window.open(previewUrl);
  3038. }
  3039. };
  3040. //下载资产模版
  3041. $scope.filenum = 0;
  3042. $scope.openmeans = function () {
  3043. var modalInstance = $modal.open({
  3044. templateUrl: 'assets/views/means/tpl/meansdown.html',
  3045. controller: function ($scope, scope, $modalInstance) {
  3046. $scope.item = {};
  3047. $scope.title = "选择下载模版";
  3048. $scope.lable = "资产模版下载";
  3049. function foreachdata(my_datas) {
  3050. // angular.forEach(my_datas, function(item, index) {
  3051. // if (item.children && item.children.length > 0) {
  3052. // foreachdata(item.children);
  3053. // } else {
  3054. // my_datas[index].checks = true;
  3055. // }
  3056. // })
  3057. for (var i = 0; i < my_datas.length; i++) {
  3058. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3059. foreachdata(my_datas[i].children);
  3060. console.log($scope);
  3061. } else {
  3062. my_datas[i].checks = true;
  3063. }
  3064. }
  3065. }
  3066. function foreachtree(data) {
  3067. angular.forEach(data, function (item) {
  3068. // if (item.checks != true) {
  3069. item.checks = true;
  3070. item.expanded = true;
  3071. if (item.children && item.children.length > 0) {
  3072. foreachtree(item.children)
  3073. } else {
  3074. $scope.getslowtree.push(item)
  3075. }
  3076. // }
  3077. })
  3078. }
  3079. $scope.getslowtree = [];
  3080. $scope.slowtree = function (tree) {
  3081. foreachtree(tree)
  3082. return $scope.getslowtree
  3083. }
  3084. $scope.all = function (c, v) { //全选
  3085. if (c == true) {
  3086. $scope.formdashboard($scope.slowtree(v));
  3087. } else {
  3088. $scope.my_data_after = [];
  3089. angular.forEach($scope.my_data, function (item, index) {
  3090. $scope.my_data[index].checks = false;
  3091. $scope.my_data[index].expanded = false;
  3092. if (item.children && item.children.length > 0) {
  3093. angular.forEach(item.children, function (itemone, indexone) {
  3094. $scope.my_data[index].children[indexone].checks = false;
  3095. $scope.my_data[index].children[indexone].expanded = false;
  3096. if (itemone.children && itemone.children.length > 0) {
  3097. angular.forEach(itemone.children, function (itemtwo, indextwo) {
  3098. $scope.my_data[index].children[indexone].children[indextwo].checks = false;
  3099. })
  3100. } else {}
  3101. })
  3102. } else {}
  3103. })
  3104. $scope.mydatacate = [];
  3105. $scope.getslowtree = [];
  3106. // }
  3107. }
  3108. };
  3109. // $scope.searchone = function(search) {
  3110. // angular.forEach($scope.my_data, function(item) {
  3111. // if (item.indexOf(search) > 0) {
  3112. // }
  3113. // })
  3114. // }
  3115. $scope.checkall = function () {
  3116. angular.forEach($scope.my_data, function (item, index) {
  3117. scope.my_data[index].checks = true;
  3118. })
  3119. }
  3120. $scope.selectitem = [];
  3121. $scope.choiceitem = function (item) {
  3122. // if (item.checkeds) {
  3123. // item.checkeds = false;
  3124. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3125. // // if ($scope.selectitem[i].id == item.id) {
  3126. // // $scope.selectitem.splice(i, 1)
  3127. // // }
  3128. // // }
  3129. // for (var i = 0; i < $scope.my_data_after; i++) {
  3130. // if ($scope.my_data_after[i].id == item.id) {
  3131. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3132. // // $scope.selectitem.splice(i, 1)
  3133. // }
  3134. // }
  3135. // } else {
  3136. // item.checkeds = true;
  3137. // $scope.selectitem.push(item)
  3138. // }
  3139. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3140. if ($scope.my_data_after[i].id == item.id) {
  3141. $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3142. }
  3143. }
  3144. }
  3145. $scope.remove = function (removeitem) {
  3146. var realdat = angular.copy($scope.my_data_after)
  3147. // angular.extend(realdat, $scope.selectitem);
  3148. $scope.my_data_after = [];
  3149. angular.forEach(realdat, function (item) {
  3150. if (!item.checkeds) {
  3151. $scope.my_data_after.push(item)
  3152. }
  3153. })
  3154. $scope.mydatacate = angular.copy($scope.my_data_after);
  3155. }
  3156. $scope.try_async_loads = function (item, search) {
  3157. var fildatas = {
  3158. 'idx': 0,
  3159. 'sum': 1000
  3160. };
  3161. $scope.my_data = [];
  3162. // $scope.try_async_load = true;
  3163. if (item) {
  3164. angular.extend(fildatas, item)
  3165. }
  3166. api_configure_data.fetchDataList('ciclassify', fildatas).then(function (response) {
  3167. if (response.status == 200) {
  3168. var data = response.list;
  3169. var objects = [];
  3170. for (var i = 0; i < data.length; i++) {
  3171. var object = {};
  3172. object.id = data[i].id;
  3173. if (search) {
  3174. delete data[i].parent
  3175. } else {
  3176. if (data[i].parent && data[i].parent.id != 0) {
  3177. object.parent = data[i].parent.id;
  3178. }
  3179. }
  3180. angular.extend(object, data[i]);
  3181. objects.push(object);
  3182. }
  3183. $scope.my_data = convertParentToChildList(objects);
  3184. $scope.tree_data = angular.copy($scope.my_data);
  3185. if ($scope.my_data.length > 0) {
  3186. $scope.try_async_load = false;
  3187. }
  3188. } else {
  3189. SweetAlert.swal({
  3190. title: "系统错误!",
  3191. text: "请刷新重试!",
  3192. type: "error"
  3193. });
  3194. }
  3195. });
  3196. };
  3197. function convertListToTree(data, treeMap) {
  3198. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3199. var root = null; //Initially set our loop to null
  3200. //loop over data
  3201. for (var i = 0; i < data.length; i++) {
  3202. var datum = data[i];
  3203. //each node will have children, so let's give it a "children" poperty
  3204. datum.children = [];
  3205. //add an entry for this node to the map so that any future children can
  3206. //lookup the parent
  3207. idToNodeMap[datum.id] = datum;
  3208. //Does this node have a parent?
  3209. // console.log("datum="+JSON.stringify(datum))
  3210. if (typeof datum.parent === "undefined" || datum.parent === null) {
  3211. //Doesn't look like it, so this node is the root of the tree
  3212. root = datum;
  3213. treeMap[datum.id] = root;
  3214. } else {
  3215. //This node has a parent, so let's look it up using the id
  3216. parentNode = idToNodeMap[datum.parent.id];
  3217. //We don't need this property, so let's delete it.
  3218. // delete datum.parent;
  3219. //Let's add the current node as a child of the parent node.
  3220. parentNode.children.push(datum);
  3221. }
  3222. }
  3223. return root;
  3224. }
  3225. function convertParentToChildList(data) {
  3226. var treeMap = {};
  3227. var list = [];
  3228. convertListToTree(data, treeMap);
  3229. angular.forEach(treeMap, function (item) {
  3230. list.push(item);
  3231. });
  3232. return list;
  3233. }
  3234. function convertParentToChild(datato) {
  3235. var treeMapto = {};
  3236. var listto = [];
  3237. convertListToTree(datato, treeMapto);
  3238. angular.forEach(treeMapto, function (items) {
  3239. listto.push(items);
  3240. });
  3241. return listto;
  3242. }
  3243. $scope.try_async_loads();
  3244. $scope.searchdown = function (key) {
  3245. if (key && key != '') {
  3246. $scope.try_async_loads({
  3247. 'ciclassify': {
  3248. "label": key
  3249. }
  3250. }, 'search')
  3251. } else {
  3252. $scope.try_async_loads()
  3253. }
  3254. // var mydatacatedown = angular.copy($scope.my_data);
  3255. // $scope.my_data = [];
  3256. // var objects = [];
  3257. // angular.forEach(mydatacatedown, function(item) {
  3258. // if (item.label.match(key)) {
  3259. // objects.push(item)
  3260. // } else {
  3261. // // $scope.my_data_after.push(item)
  3262. // }
  3263. // })
  3264. // $scope.my_data = convertParentToChildList(objects);
  3265. // $scope.tree_data = angular.copy($scope.my_data);
  3266. }
  3267. $scope.mydatacate = [];
  3268. $scope.searchup = function (key) {
  3269. // var mydatacate = angular.copy($scope.my_data_after);
  3270. $scope.my_data_after = [];
  3271. angular.forEach($scope.mydatacate, function (item) {
  3272. if (item.label.match(key)) {
  3273. $scope.my_data_after.push(item)
  3274. } else {}
  3275. })
  3276. }
  3277. //角色树
  3278. $scope.my_tree = [];
  3279. $scope.tree_data_after = [];
  3280. $scope.my_data = [];
  3281. $scope.my_data_after = [];
  3282. $scope.formdashboard = function (item) {
  3283. $scope.my_data_after = [];
  3284. angular.forEach(item, function (infox) {
  3285. if (infox.children.length == 0) {
  3286. $scope.my_data_after.push(infox);
  3287. }
  3288. })
  3289. $scope.mydatacate = angular.copy($scope.my_data_after);
  3290. }
  3291. $scope.ok = function (item) {
  3292. $modalInstance.close(item);
  3293. };
  3294. $scope.cancel = function () {
  3295. $modalInstance.dismiss('cancel');
  3296. };
  3297. },
  3298. // size: 'sm',
  3299. resolve: {
  3300. scope: function () {
  3301. return $scope;
  3302. }
  3303. }
  3304. });
  3305. modalInstance.result.then(function (selectedItem) {
  3306. // $rootScope.isMask = true;
  3307. if (selectedItem) {
  3308. var type = 1;
  3309. var fildat = {
  3310. 'configure': selectedItem
  3311. };
  3312. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  3313. // // if (data.errno == 0) {
  3314. // var file = new Blob([data], {
  3315. // // 'Accept': '*/*'
  3316. // type: 'application/octet-stream'
  3317. // // type: 'application/vnd.ms-excel'
  3318. // });
  3319. // //trick to download store a file having its URL
  3320. // var fileURL = URL.createObjectURL(file);
  3321. // var a = document.createElement('a');
  3322. // a.href = fileURL;
  3323. // a.target = '_blank';
  3324. // a.download = "资产导入模版.xlsx";
  3325. // document.body.appendChild(a);
  3326. // a.click();
  3327. // // }
  3328. // })
  3329. $http({
  3330. url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
  3331. method: 'POST',
  3332. data: JSON.stringify(fildat),
  3333. headers: {
  3334. // 'Content-type': 'application/xls',
  3335. 'Accept': '*/*'
  3336. },
  3337. responseType: 'arraybuffer'
  3338. }).success(function (data, status, headers, config) {
  3339. $rootScope.isMask = false;
  3340. var file = new Blob([data], {
  3341. type: 'application/octet-stream'
  3342. // type : 'application/vnd.ms-excel'
  3343. });
  3344. //trick to download store a file having its URL
  3345. var fileURL = URL.createObjectURL(file);
  3346. var a = document.createElement('a');
  3347. a.href = fileURL;
  3348. a.target = '_blank';
  3349. a.download = "资产导入模版.xlsx";
  3350. document.body.appendChild(a);
  3351. a.click();
  3352. }).error(function (data, status, headers, config) {
  3353. // console.log(data);
  3354. $rootScope.isMask = false;
  3355. });
  3356. // break;
  3357. // }
  3358. // }
  3359. // }
  3360. // })
  3361. } else {
  3362. SweetAlert.swal({
  3363. title: "未选择资产分类!",
  3364. text: "请选择资产分类",
  3365. type: "error"
  3366. }, function () {
  3367. $rootScope.isMask = false;
  3368. });
  3369. }
  3370. // }
  3371. });
  3372. }
  3373. $scope.wrongdata = [];
  3374. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3375. var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
  3376. $scope.importopen = function () { //导入触发事件
  3377. if (angular.isUndefined($scope.form.dropState)) {
  3378. $scope.form.dropState = false;
  3379. }
  3380. //附件上传数据
  3381. //$scope.options.templateOptions.uploader();
  3382. // FILTERS
  3383. uploader.filters.push({
  3384. name: 'customFilter',
  3385. fn: function (item /*{File|FileLikeObject}*/ , options) {
  3386. return this.queue.length < 2;
  3387. }
  3388. });
  3389. // CALLBACKS
  3390. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  3391. console.info('onWhenAddingFileFailed', item, filter, options);
  3392. };
  3393. uploader.onAfterAddingFile = function (fileItem) {
  3394. console.info('onAfterAddingFile', fileItem);
  3395. };
  3396. uploader.onAfterAddingAll = function (addedFileItems) {
  3397. console.info('onAfterAddingAll', addedFileItems);
  3398. };
  3399. uploader.onBeforeUploadItem = function (item) {
  3400. console.info('onBeforeUploadItem', item);
  3401. };
  3402. uploader.onProgressItem = function (fileItem, progress) {
  3403. console.info('onProgressItem', fileItem, progress);
  3404. };
  3405. uploader.onProgressAll = function (progress) {
  3406. console.info('onProgressAll', progress);
  3407. };
  3408. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3409. // console.info('onSuccessItem', fileItem, response, status, headers);
  3410. // };
  3411. uploader.onErrorItem = function (fileItem, response, status, headers) {
  3412. console.info('onErrorItem', fileItem, response, status, headers);
  3413. };
  3414. uploader.onCancelItem = function (fileItem, response, status, headers) {
  3415. console.info('onCancelItem', fileItem, response, status, headers);
  3416. };
  3417. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  3418. console.info('onCompleteItem', fileItem, response, status, headers);
  3419. };
  3420. uploader.onCompleteAll = function () {
  3421. console.info('onCompleteAll');
  3422. };
  3423. }
  3424. // $scope.importnext = function() {
  3425. // $scope.state = 2;
  3426. // event.preventDefault();
  3427. // }
  3428. $scope.importnext = function () {
  3429. event.preventDefault();
  3430. // $rootScope.isMask = true;
  3431. $rootScope.loading = true;
  3432. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3433. uploader.onBeforeUploadItem = function (item) {
  3434. angular.extend(item.headers, $rootScope.getSession());
  3435. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3436. // if (item.index > 1) {
  3437. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3438. // }
  3439. // item.index = 1;
  3440. item.formData = [{
  3441. 'filename': item.file.name
  3442. }];
  3443. console.info('onBeforeUploadItem', item);
  3444. };
  3445. uploader.uploadAll();
  3446. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3447. if (response.status == 200) {
  3448. $scope.wrongdata = [];
  3449. $rootScope.loading = false;
  3450. if (response.abnormal) {
  3451. $scope.state = 2;
  3452. angular.forEach(response.msg, function (item) {
  3453. $scope.wrongdata.push({
  3454. 'name': item.assetName,
  3455. 'line': item.row,
  3456. 'cmdbname': item.name,
  3457. 'errotip': [{
  3458. 'label': item.msg
  3459. }]
  3460. })
  3461. })
  3462. } else {
  3463. $scope.state = 3;
  3464. }
  3465. } else {
  3466. $rootScope.loading = false;
  3467. $scope.state = 2;
  3468. }
  3469. }
  3470. }
  3471. $scope.clearItems = function () { //重新选择文件时,清空队列,达到覆盖文件的效果
  3472. uploader.clearQueue();
  3473. // uploader.remove();
  3474. // uploader.cancel();
  3475. // uploader.onChange();
  3476. }
  3477. uploader.onAfterAddingFile = function (fileItem) {
  3478. $scope.fileItem = fileItem._file;
  3479. // $scope.$apply();
  3480. // $scope.fileItem = filenum;
  3481. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  3482. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  3483. $scope.filenum++;
  3484. };
  3485. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3486. $scope.uploadStatus = true; //上传成功则把状态改为true
  3487. // alert(response.path);
  3488. };
  3489. $scope.importnext = function () {
  3490. event.preventDefault();
  3491. // uploader.onChange();
  3492. $rootScope.loading = true;
  3493. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3494. uploader.onBeforeUploadItem = function (item) {
  3495. angular.extend(item.headers, $rootScope.getSession());
  3496. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3497. // if (item.index > 1) {
  3498. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3499. // }
  3500. // item.index = 1;
  3501. item.formData = [{
  3502. 'filename': item.file.name
  3503. }];
  3504. console.info('onBeforeUploadItem', item);
  3505. };
  3506. uploader.uploadAll();
  3507. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3508. if (response.status == 200) {
  3509. $scope.wrongdata = [];
  3510. // uploader.queue = [];
  3511. $rootScope.loading = false;
  3512. if (response.abnormal) {
  3513. $scope.state = 2;
  3514. uploader.clearQueue();
  3515. angular.forEach(response.msg, function (item) {
  3516. $scope.wrongdata.push({
  3517. 'name': item.assetName,
  3518. 'line': item.row,
  3519. 'cmdbname': item.name,
  3520. 'errotip': [{
  3521. 'label': item.msg
  3522. }]
  3523. })
  3524. })
  3525. } else {
  3526. $scope.state = 3;
  3527. }
  3528. } else {
  3529. uploader.clearQueue();
  3530. $rootScope.loading = false;
  3531. $scope.state = 2;
  3532. }
  3533. }
  3534. }
  3535. var setAllInactive = function () {
  3536. angular.forEach($scope.workspaces, function (workspace) {
  3537. workspace.active = false;
  3538. });
  3539. };
  3540. //添加
  3541. var addNewWorkspace = function (name, contentUrl) {
  3542. var id = $scope.workspaces.length + 1;
  3543. $scope.workspaces.push({
  3544. id: id,
  3545. name: name,
  3546. active: true,
  3547. contentUrl: 'main/html/content.html'
  3548. });
  3549. };
  3550. //关闭
  3551. $scope.closeopen = function (closedata) {
  3552. event.preventDefault();
  3553. angular.forEach($scope.workspaces, function (item, index) {
  3554. if (closedata.id == item.id) {
  3555. if (closedata.id == 1) {
  3556. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  3557. } else {
  3558. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  3559. }
  3560. $scope.workspaces.splice(index, 1);
  3561. }
  3562. })
  3563. }
  3564. // $scope.workspaces = [
  3565. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  3566. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3567. // ];
  3568. $scope.addWorkspace = function (contentUrl, name) {
  3569. setAllInactive();
  3570. addNewWorkspace(name, contentUrl);
  3571. };
  3572. // $rootScope.addWorkspace = $scope.addWorkspace;
  3573. $scope.close = function (idNumber) {
  3574. var index = 0; //记录当前元素下标
  3575. angular.forEach($scope.workspaces, function (workspace) {
  3576. if (workspace.id === idNumber) {
  3577. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3578. }
  3579. index++;
  3580. });
  3581. };
  3582. //grid2
  3583. $scope.langs = i18nService.getAllLangs();
  3584. $scope.lang = 'zh-cn';
  3585. i18nService.setCurrentLang($scope.lang);
  3586. $scope.gridOptions2 = {};
  3587. $scope.gridOptions2.data = 'myData3';
  3588. $scope.gridOptions2.enableColumnResizing = true;
  3589. $scope.gridOptions2.enableFiltering = false;
  3590. $scope.gridOptions2.enableGridMenu = false;
  3591. $scope.gridOptions2.showGridFooter = true;
  3592. $scope.gridOptions2.showColumnFooter = false;
  3593. $scope.gridOptions2.fastWatch = true;
  3594. $scope.gridOptions2.useExternalFiltering = true;
  3595. $scope.gridOptions2.useExternalPagination = true;
  3596. $scope.gridOptions2.paginationPageSizes = [10];
  3597. $scope.gridOptions2.paginationPageSize = 10;
  3598. $scope.gridOptions2.multiSelect = false;
  3599. // $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>";
  3600. $scope.gridOptions2.columnDefs = [{
  3601. name: 'item',
  3602. displayName: '序号',
  3603. width: 120
  3604. },
  3605. {
  3606. name: 'name',
  3607. displayName: '耗材名称',
  3608. width: 80,
  3609. enableFiltering: false
  3610. },
  3611. {
  3612. name: 'model',
  3613. displayName: '品牌/型号',
  3614. width: 100,
  3615. enableFiltering: false
  3616. },
  3617. {
  3618. name: 'Specifications',
  3619. displayName: '规格',
  3620. width: 150,
  3621. enableFiltering: false
  3622. },
  3623. {
  3624. name: 'sum',
  3625. displayName: '数量',
  3626. enableFiltering: false
  3627. },
  3628. {
  3629. name: '操作',
  3630. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3631. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  3632. '</div></div>',
  3633. enableFiltering: false
  3634. },
  3635. ];
  3636. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  3637. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  3638. $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
  3639. for (var i = 0; i < $scope.myData3all.length; i++) {
  3640. $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  3641. }
  3642. // $scope.model.consumables = $scope.myDataone;
  3643. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3644. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
  3645. $scope.model.applicationForm.consumables = $scope.myData3all;
  3646. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3647. $scope.options.templateOptions.getpush({
  3648. "hao": true,
  3649. "gu": true
  3650. });
  3651. } else {
  3652. $scope.options.templateOptions.getpush({
  3653. "hao": true
  3654. });
  3655. }
  3656. } else {
  3657. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3658. $scope.options.templateOptions.getpush({
  3659. "gu": true
  3660. });
  3661. }
  3662. }
  3663. }
  3664. $scope.options.templateOptions.workspaces = $scope.workspaces;
  3665. $scope.changecai = function (item) {
  3666. event.preventDefault();
  3667. var modalInstance = $modal.open({
  3668. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  3669. controller: function ($scope, $modalInstance) {
  3670. $scope.title = "修改耗材数量";
  3671. $scope.consumptive = angular.copy(item);
  3672. $scope.ok = function () {
  3673. $modalInstance.close($scope.consumptive);
  3674. };
  3675. $scope.cancel = function () {
  3676. $modalInstance.dismiss('cancel');
  3677. };
  3678. },
  3679. size: 'sm'
  3680. });
  3681. modalInstance.result.then(function (selectedItem) {
  3682. // angular.forEach($scope.myData3, function(items, index) {
  3683. // if (items.id == selectedItem.id) {
  3684. // $scope.myData3[index] = selectedItem;
  3685. // }
  3686. // })
  3687. // // $scope.myData3.push(selectedItem);
  3688. // $scope.model.applicationForm.consumables = $scope.myData3;
  3689. angular.forEach($scope.myData3all, function (items, index) {
  3690. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  3691. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  3692. angular.extend($scope.myData3all[index], selectedItem)
  3693. }
  3694. })
  3695. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3696. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3697. $scope.model.applicationForm.consumables = $scope.myData3all;
  3698. })
  3699. }
  3700. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  3701. $scope.gridApi = gridApi;
  3702. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  3703. // var filtersData = $scope.memoryfilterDatahao;
  3704. // filtersData.idx = newPage - 1;
  3705. // filtersData.sum = pageSize;
  3706. // $scope.loadData(filtersData);
  3707. $scope.memoryfilterDatahao.idx = newPage - 1;
  3708. $scope.memoryfilterDatahao.sum = pageSize;
  3709. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
  3710. });
  3711. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  3712. $scope.selected.items = data.entity;
  3713. //console.log(data);
  3714. });
  3715. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  3716. $scope.selected.items = data.entity;
  3717. //console.log(data);
  3718. });
  3719. gridApi.core.on.filterChanged($scope, function () {
  3720. var grid = this.grid;
  3721. var filtersData = {
  3722. idx: 0,
  3723. sum: 10,
  3724. };
  3725. $scope.memoryfilterDatahao = filtersData;
  3726. // $scope.loadData(filtersData);
  3727. // $scope.memoryfilterDatahao.idx = newPage - 1;
  3728. // $scope.memoryfilterDatahao.sum = pageSize;
  3729. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3730. });
  3731. };
  3732. $scope.haocaiopen = function (items) {
  3733. event.preventDefault();
  3734. var modalInstance = $modal.open({
  3735. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3736. controller: function ($scope, $modalInstance, SweetAlert) {
  3737. $scope.consumptive = {};
  3738. $scope.title = "新增耗材";
  3739. if (items.name) {
  3740. $scope.consumptive.name = items.name.name;
  3741. }
  3742. $scope.clearNoNum = function (obj, attr) {
  3743. //先把非数字的都替换掉,除了数字和.
  3744. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3745. //必须保证第一个为数字而不是.
  3746. obj[attr] = obj[attr].replace(/^\./g, "");
  3747. //保证只有出现一个.而没有多个.
  3748. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3749. //保证.只出现一次,而不能出现两次以上
  3750. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3751. //小于最大值
  3752. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3753. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3754. // obj[attr] = '';
  3755. // }
  3756. }
  3757. $scope.ok = function (item) {
  3758. // if (item.name && item.model && item.Specifications && item.sum) {
  3759. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3760. $modalInstance.close(item);
  3761. } else {
  3762. SweetAlert.swal({
  3763. title: "数据填写不完整!",
  3764. text: "请检查数据然后提交!",
  3765. type: "error"
  3766. });
  3767. }
  3768. };
  3769. $scope.cancel = function () {
  3770. $modalInstance.dismiss('cancel');
  3771. };
  3772. },
  3773. size: 'sm',
  3774. resolve: {
  3775. SweetAlert: function () {
  3776. return SweetAlert;
  3777. }
  3778. }
  3779. });
  3780. modalInstance.result.then(function (selectedItem) {
  3781. api_sysinfo.addData('dictionaryTree', {
  3782. // "type": "list",
  3783. "key": "haocaifenlei",
  3784. "name": selectedItem.name,
  3785. "parent": selectedItem.id,
  3786. "value": selectedItem.name,
  3787. "deleted": false,
  3788. "level": 1
  3789. }).then(function (data) {
  3790. // $scope.haocainame.name = data.list;
  3791. api_sysinfo.addData('dictionaryTree', {
  3792. // "type": "list",
  3793. "key": "pinpai",
  3794. "name": selectedItem.model,
  3795. "parent": data.id,
  3796. "value": selectedItem.model,
  3797. "deleted": false,
  3798. "level": 2
  3799. }).then(function (data) {
  3800. // $scope.haocainame = data.list;
  3801. })
  3802. api_sysinfo.addData({
  3803. // "type": "list",
  3804. "key": "guige",
  3805. "name": selectedItem.Specifications,
  3806. "parent": data.id,
  3807. "value": selectedItem.Specifications,
  3808. "deleted": false,
  3809. "level": 2
  3810. }).then(function (data) {
  3811. // $scope.haocainame = data.list;
  3812. })
  3813. })
  3814. // $scope.myData3.push(selectedItem);
  3815. // for (var i = 0; i < $scope.myData3.length; i++) {
  3816. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3817. // }
  3818. // $scope.model.applicationForm.consumables = $scope.myData3;
  3819. $scope.myData3all.push(selectedItem);
  3820. for (var i = 0; i < $scope.myData3all.length; i++) {
  3821. $scope.myData3all[i]['item'] = i + 1
  3822. }
  3823. // $scope.model.consumables = $scope.myDataone;
  3824. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3825. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3826. $scope.model.applicationForm.consumables = $scope.myData3all;
  3827. })
  3828. }
  3829. $scope.haocaiadd = function () {
  3830. event.preventDefault();
  3831. var modalInstance = $modal.open({
  3832. templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
  3833. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  3834. $scope.haocainame = [];
  3835. $scope.pinpai = [];
  3836. $scope.guige = [];
  3837. $scope.consumptive = {};
  3838. $scope.consumpall = {};
  3839. $scope.title = "添加耗材";
  3840. api_wechatfile.getDictionary({
  3841. "key": "haocaifenlei",
  3842. "type": "tree"
  3843. }).then(function (data) {
  3844. $scope.haocainame = data;
  3845. })
  3846. $scope.clearNoNum = function (obj, attr) {
  3847. //先把非数字的都替换掉,除了数字和.
  3848. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3849. //必须保证第一个为数字而不是.
  3850. obj[attr] = obj[attr].replace(/^\./g, "");
  3851. //保证只有出现一个.而没有多个.
  3852. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3853. //保证.只出现一次,而不能出现两次以上
  3854. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3855. //小于最大值
  3856. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3857. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3858. // obj[attr] = '';
  3859. // }
  3860. }
  3861. $scope.onChange = function (parent) {
  3862. $scope.consumptive.model = {};
  3863. $scope.consumptive.Specifications = {};
  3864. api_wechatfile.getDictionaryForList({
  3865. "key": "pinpai",
  3866. "parent": parent.id
  3867. }).then(function (data) {
  3868. $scope.pinpai = data;
  3869. })
  3870. api_wechatfile.getDictionaryForList({
  3871. "key": "guige",
  3872. "parent": parent.id
  3873. }).then(function (data) {
  3874. $scope.guige = data;
  3875. })
  3876. }
  3877. $scope.addhaocai = function () {
  3878. $modalInstance.dismiss('cancel');
  3879. scope.haocaiopen($scope.consumptive);
  3880. }
  3881. $scope.ok = function (item) {
  3882. var items = {};
  3883. var submittrue = true;
  3884. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3885. items = {
  3886. "modelid": item.model.id,
  3887. "nameid": item.name.id,
  3888. "Specificationsid": item.Specifications.id,
  3889. "name": item.name.name,
  3890. "model": item.model.name,
  3891. "Specifications": item.Specifications.name,
  3892. "sum": item.sum
  3893. }
  3894. angular.forEach(scope.myData3all, function (itemsdata) {
  3895. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  3896. submittrue = false;
  3897. }
  3898. })
  3899. if (submittrue) {
  3900. $modalInstance.close(items);
  3901. } else {
  3902. SweetAlert.swal({
  3903. title: "该耗材已有添加",
  3904. text: "请检查数据然后提交!",
  3905. type: "error"
  3906. });
  3907. }
  3908. } else {
  3909. SweetAlert.swal({
  3910. title: "数据填写不完整!",
  3911. text: "请检查数据然后提交!",
  3912. type: "error"
  3913. });
  3914. }
  3915. // var isold = false;
  3916. // if (item.name && item.model && item.Specifications && item.sum) {
  3917. // for (var i = 0; i < scope.myData3all.length; i++) {
  3918. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  3919. // isold = true;
  3920. // }
  3921. // }
  3922. // if (isold) {
  3923. // SweetAlert.swal({
  3924. // title: "该耗材已添加!",
  3925. // text: "请不要重复添加耗材!",
  3926. // type: "error"
  3927. // });
  3928. // } else {
  3929. // $scope.consumpall.model = $scope.consumpall.brandModel;
  3930. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  3931. // $scope.consumpall.sum = item.sum;
  3932. // delete $scope.consumpall.brandModel;
  3933. // delete $scope.consumpall.specification;
  3934. // $modalInstance.close($scope.consumpall);
  3935. // }
  3936. // } else {
  3937. // SweetAlert.swal({
  3938. // title: "数据填写不完整!",
  3939. // text: "请检查数据然后提交!",
  3940. // type: "error"
  3941. // });
  3942. // }
  3943. };
  3944. $scope.cancel = function () {
  3945. $modalInstance.dismiss('cancel');
  3946. };
  3947. },
  3948. size: 'sm',
  3949. resolve: {
  3950. scope: function () {
  3951. return $scope;
  3952. }
  3953. }
  3954. });
  3955. modalInstance.result.then(function (selectedItem) {
  3956. $scope.myData3all.push(selectedItem);
  3957. for (var i = 0; i < $scope.myData3all.length; i++) {
  3958. $scope.myData3all[i]['item'] = i + 1
  3959. }
  3960. // $scope.model.consumables = $scope.myDataone;
  3961. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3962. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3963. $scope.model.applicationForm.consumables = $scope.myData3all;
  3964. })
  3965. }
  3966. $scope.onDblClick = function (data, event) {
  3967. $scope.selectButtonClick(data, event);
  3968. };
  3969. // $scope.memoryfilterDatahao = {
  3970. // "idx": 0,
  3971. // "sum": 10,
  3972. // }
  3973. // $scope.loadData = function(filterData) {};
  3974. // $scope.title = title;
  3975. if (angular.isFunction($scope.options.templateOptions.transform)) {
  3976. $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
  3977. }
  3978. }]
  3979. });
  3980. //归还设备耗材tab
  3981. formlyConfigProvider.setType({
  3982. name: 'ui-cmdbreturntab',
  3983. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
  3984. wrapper: ['bootstrapHasError'],
  3985. defaultOptions: function (options, $scope) {
  3986. return {
  3987. templateOptions: {
  3988. // checkform: function(options) {
  3989. // if (options.model.requester) {
  3990. // options.value(options.model.requester);
  3991. // }
  3992. // },
  3993. }
  3994. };
  3995. },
  3996. controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function ($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
  3997. var setAllInactive = function () {
  3998. angular.forEach($scope.workspaces, function (workspace) {
  3999. workspace.active = false;
  4000. });
  4001. };
  4002. $scope.memoryfilterData = {
  4003. "idx": 0,
  4004. "sum": 10,
  4005. }
  4006. //添加
  4007. var addNewWorkspace = function (name, contentUrl) {
  4008. var id = $scope.workspaces.length + 1;
  4009. $scope.workspaces.push({
  4010. id: id,
  4011. name: name,
  4012. active: true,
  4013. contentUrl: 'main/html/content.html'
  4014. });
  4015. };
  4016. $scope.workspaces = [{
  4017. id: 1,
  4018. name: "归还设备",
  4019. active: true,
  4020. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4021. },
  4022. {
  4023. id: 2,
  4024. name: "归还耗材",
  4025. active: true,
  4026. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4027. }
  4028. ];
  4029. $scope.addWorkspace = function (contentUrl, name) {
  4030. setAllInactive();
  4031. addNewWorkspace(name, contentUrl);
  4032. };
  4033. // $rootScope.addWorkspace = $scope.addWorkspace;
  4034. $scope.close = function (idNumber) {
  4035. var index = 0; //记录当前元素下标
  4036. angular.forEach($scope.workspaces, function (workspace) {
  4037. if (workspace.id === idNumber) {
  4038. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4039. }
  4040. index++;
  4041. });
  4042. };
  4043. $scope.memoryfilterDataguishe = {
  4044. "idx": 0,
  4045. "sum": 10,
  4046. }
  4047. //grid1
  4048. $scope.langs = i18nService.getAllLangs();
  4049. $scope.lang = 'zh-cn';
  4050. i18nService.setCurrentLang($scope.lang);
  4051. $scope.gridOptions1 = {};
  4052. $scope.gridOptions1.data = 'myData1';
  4053. $scope.gridOptions1.enableColumnResizing = true;
  4054. $scope.gridOptions1.enableFiltering = false;
  4055. $scope.gridOptions1.enableGridMenu = false;
  4056. $scope.gridOptions1.showGridFooter = true;
  4057. $scope.gridOptions1.showColumnFooter = false;
  4058. $scope.gridOptions1.fastWatch = true;
  4059. $scope.gridOptions1.useExternalFiltering = true;
  4060. $scope.gridOptions1.useExternalPagination = true;
  4061. $scope.gridOptions1.paginationPageSizes = [10];
  4062. $scope.gridOptions1.paginationPageSize = 10;
  4063. $scope.gridOptions1.multiSelect = false;
  4064. // $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>";
  4065. $scope.gridOptions1.columnDefs = [{
  4066. name: 'item',
  4067. displayName: '序号',
  4068. width: 120
  4069. },
  4070. {
  4071. name: 'props.hw_cifilterClassic',
  4072. displayName: '设备类型',
  4073. width: 150,
  4074. enableFiltering: false
  4075. },
  4076. {
  4077. name: 'props.hw_mingcheng',
  4078. displayName: '设备名称',
  4079. width: 180,
  4080. enableFiltering: false
  4081. },
  4082. {
  4083. name: 'uuid',
  4084. displayName: '设备编号',
  4085. width: 180,
  4086. enableFiltering: false
  4087. },
  4088. {
  4089. name: 'props.hw_state',
  4090. width: 150,
  4091. displayName: '状态',
  4092. enableFiltering: false
  4093. },
  4094. {
  4095. name: '操作',
  4096. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4097. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  4098. '</div></div>',
  4099. enableFiltering: false
  4100. },
  4101. ];
  4102. // $scope.selectButtonClick
  4103. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4104. $scope.gridApi = gridApi;
  4105. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4106. // var filtersData = $scope.memoryfilterData;
  4107. // filtersData.idx = newPage - 1;
  4108. // filtersData.sum = pageSize;
  4109. // $scope.loadData(filtersData);
  4110. $scope.memoryfilterDataguishe.idx = newPage - 1;
  4111. $scope.memoryfilterDataguishe.sum = pageSize;
  4112. $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
  4113. });
  4114. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4115. $scope.selected.items = data.entity;
  4116. //console.log(data);
  4117. });
  4118. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4119. $scope.selected.items = data.entity;
  4120. //console.log(data);
  4121. });
  4122. gridApi.core.on.filterChanged($scope, function () {
  4123. // var grid = this.grid;
  4124. // var filtersData = {
  4125. // idx: 0,
  4126. // sum: 20,
  4127. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4128. // };
  4129. // angular.forEach(grid.columns, function(item) {
  4130. // if (item.enableFiltering) {
  4131. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4132. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4133. // if (angular.isUndefined(filtersData['user'])) {
  4134. // filtersData['user'] = {};
  4135. // }
  4136. // filtersData['user'][item.field] = item.filters[0].term;
  4137. // }
  4138. // }
  4139. // });
  4140. // $scope.memoryfilterData = filtersData;
  4141. // $scope.loadData(filtersData);
  4142. });
  4143. };
  4144. $scope.changegu = function (item) {
  4145. event.preventDefault();
  4146. var modalInstance = $modal.open({
  4147. templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
  4148. controller: function ($scope, $modalInstance) {
  4149. $scope.title = "修改设备状态";
  4150. $scope.hw_state = {};;
  4151. if (item.status) {
  4152. $scope.hw_state.name = item.hw_state;
  4153. }
  4154. // $scope.consumptive = item;
  4155. $scope.stateshe = [{
  4156. "id": 2,
  4157. "name": "在库"
  4158. }, {
  4159. "id": 4,
  4160. "name": "报修"
  4161. }, {
  4162. "id": 3,
  4163. "name": "报废"
  4164. }]
  4165. $scope.ok = function (item) {
  4166. $modalInstance.close($scope.hw_state);
  4167. };
  4168. $scope.cancel = function () {
  4169. $modalInstance.dismiss('cancel');
  4170. };
  4171. },
  4172. size: 'sm'
  4173. });
  4174. modalInstance.result.then(function (selectedItem) {
  4175. angular.forEach($scope.myData1, function (items, index) {
  4176. if (items.id == item.id) {
  4177. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  4178. }
  4179. })
  4180. $scope.model.assets = $scope.myData1;
  4181. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
  4182. })
  4183. }
  4184. $scope.onDblClick = function (data, event) {
  4185. $scope.selectButtonClick(data, event);
  4186. };
  4187. $scope.memoryfilterData = {
  4188. "idx": 0,
  4189. "sum": 10,
  4190. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4191. }
  4192. // $scope.myData = {};
  4193. $scope.loadData = function (filterData) {};
  4194. // $scope.title = title;
  4195. $scope.loadData({
  4196. idx: 0,
  4197. sum: 10,
  4198. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4199. });
  4200. $scope.selected = {
  4201. items: []
  4202. };
  4203. $scope.myData2 = [];
  4204. $scope.consumptive = {};
  4205. $scope.myDataguibeiall = [];
  4206. $scope.haocaiopen = function (items) {
  4207. event.preventDefault();
  4208. var modalInstance = $modal.open({
  4209. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  4210. controller: function ($scope, $modalInstance, SweetAlert, api_wechatfile, api_sysinfo) {
  4211. $scope.consumptive = {};
  4212. $scope.title = "新增耗材";
  4213. if (items.name) {
  4214. $scope.consumptive.name = items.name.name;
  4215. }
  4216. $scope.ok = function (item) {
  4217. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4218. $modalInstance.close(item);
  4219. } else {
  4220. SweetAlert.swal({
  4221. title: "数据填写不完整!",
  4222. text: "请检查数据然后提交!",
  4223. type: "error"
  4224. });
  4225. }
  4226. };
  4227. $scope.cancel = function () {
  4228. $modalInstance.dismiss('cancel');
  4229. };
  4230. },
  4231. size: 'sm'
  4232. });
  4233. modalInstance.result.then(function (selectedItem) {
  4234. api_sysinfo.addData({
  4235. "type": "list",
  4236. "key": "haocaifenlei",
  4237. "name": selectedItem.name,
  4238. "parent": selectedItem.id,
  4239. "value": "1"
  4240. }).then(function (data) {
  4241. // $scope.haocainame.name = data.list;
  4242. api_wechatfile.addDictionary({
  4243. "type": "list",
  4244. "key": "pinpai",
  4245. "name": selectedItem.model,
  4246. "parent": data.id,
  4247. "value": "1"
  4248. }).then(function (data) {
  4249. // $scope.haocainame = data.list;
  4250. })
  4251. api_wechatfile.addDictionary({
  4252. "type": "list",
  4253. "key": "guige",
  4254. "name": selectedItem.Specifications,
  4255. "parent": data.id,
  4256. "value": "1"
  4257. }).then(function (data) {
  4258. // $scope.haocainame = data.list;
  4259. })
  4260. })
  4261. $scope.myData2.push(selectedItem);
  4262. for (var i = 0; i < $scope.myData2.length; i++) {
  4263. $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4264. }
  4265. // $scope.model.applicationForm.consumables = $scope.myData2;
  4266. angular.forEach($scope.myDataguibeiall, function (items, index) {
  4267. if (items.id == selectedItem.id) {
  4268. $scope.myDataguibeiall.splice(index, 1);
  4269. }
  4270. })
  4271. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
  4272. $scope.model.consumables = $scope.myDataguibeiall;
  4273. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4274. $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
  4275. })
  4276. }
  4277. //grid2
  4278. $scope.langs = i18nService.getAllLangs();
  4279. $scope.lang = 'zh-cn';
  4280. i18nService.setCurrentLang($scope.lang);
  4281. $scope.gridOptions2 = {};
  4282. $scope.gridOptions2.data = 'myData2';
  4283. $scope.gridOptions2.enableColumnResizing = true;
  4284. $scope.gridOptions2.enableFiltering = false;
  4285. $scope.gridOptions2.enableGridMenu = false;
  4286. $scope.gridOptions2.showGridFooter = true;
  4287. $scope.gridOptions2.showColumnFooter = false;
  4288. $scope.gridOptions2.fastWatch = true;
  4289. $scope.gridOptions2.useExternalFiltering = true;
  4290. $scope.gridOptions2.useExternalPagination = true;
  4291. $scope.gridOptions2.paginationPageSizes = [10];
  4292. $scope.gridOptions2.paginationPageSize = 10;
  4293. $scope.gridOptions2.multiSelect = false;
  4294. // $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>";
  4295. $scope.modelcons = {};
  4296. $scope.modelass = {};
  4297. $scope.myData2all = [];
  4298. $scope.myData1all = [];
  4299. $scope.memoryfilterDatagui = {
  4300. "idx": 0,
  4301. "sum": 10
  4302. }
  4303. setInterval(function () {
  4304. if ($scope.model.assets) {
  4305. if ($scope.model.assets != $scope.modelass && typeof ($scope.model.assets) == 'string') {
  4306. $scope.modelass = $scope.model.assets;
  4307. if (JSON.stringify($scope.model.assets) == "{}") {
  4308. $scope.model.assets = []
  4309. } else {
  4310. $scope.model.assets = JSON.parse($scope.model.assets);
  4311. }
  4312. // $scope.myData1 = $scope.model.assets;
  4313. // for (var i = 0; i < $scope.myData1.length; i++) {
  4314. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4315. // }
  4316. $scope.myData1all = $scope.model.assets;
  4317. for (var i = 0; i < $scope.myData1all.length; i++) {
  4318. $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4319. }
  4320. $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
  4321. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
  4322. }
  4323. }
  4324. if ($scope.model.consumables) {
  4325. if ($scope.model.consumables != $scope.modelcons && typeof ($scope.model.consumables) == 'string') {
  4326. $scope.modelass = $scope.model.consumables;
  4327. if (JSON.stringify($scope.model.consumables) == "{}") {
  4328. $scope.model.consumables = [];
  4329. } else {
  4330. $scope.model.consumables = JSON.parse($scope.model.consumables);
  4331. }
  4332. // $scope.myData2 = $scope.model.consumables;
  4333. // for (var i = 0; i < $scope.myData2.length; i++) {
  4334. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4335. // }
  4336. $scope.myData2all = $scope.model.consumables;
  4337. for (var i = 0; i < $scope.myData2all.length; i++) {
  4338. $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4339. }
  4340. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4341. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
  4342. // $scope.model.consumables = $scope.myData2all;
  4343. }
  4344. }
  4345. }, 100);
  4346. $scope.gridOptions2.columnDefs = [{
  4347. name: 'item',
  4348. displayName: '序号',
  4349. width: 120
  4350. },
  4351. {
  4352. name: 'name',
  4353. displayName: '耗材名称',
  4354. width: 180,
  4355. enableFiltering: false
  4356. },
  4357. {
  4358. name: 'model',
  4359. displayName: '品牌/型号',
  4360. width: 180,
  4361. enableFiltering: false
  4362. },
  4363. {
  4364. name: 'Specifications',
  4365. displayName: '规格',
  4366. width: 150,
  4367. enableFiltering: false
  4368. },
  4369. {
  4370. name: 'sum',
  4371. width: 150,
  4372. displayName: '数量',
  4373. enableFiltering: false
  4374. },
  4375. {
  4376. name: '操作',
  4377. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4378. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4379. '</div></div>',
  4380. enableFiltering: false
  4381. },
  4382. ];
  4383. // $scope.selectButtonClick
  4384. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4385. $scope.gridApi = gridApi;
  4386. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4387. // var filtersData = $scope.memoryfilterDatagui;
  4388. // filtersData.idx = newPage - 1;
  4389. // filtersData.sum = pageSize;
  4390. $scope.memoryfilterDatagui.idx = newPage - 1;
  4391. $scope.memoryfilterDatagui.sum = pageSize;
  4392. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4393. });
  4394. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4395. $scope.selected.items = data.entity;
  4396. //console.log(data);
  4397. });
  4398. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4399. $scope.selected.items = data.entity;
  4400. //console.log(data);
  4401. });
  4402. gridApi.core.on.filterChanged($scope, function () {
  4403. var grid = this.grid;
  4404. var filtersData = {
  4405. idx: 0,
  4406. sum: 10,
  4407. };
  4408. angular.forEach(grid.columns, function (item) {
  4409. if (item.enableFiltering) {
  4410. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4411. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4412. if (angular.isUndefined(filtersData['user'])) {
  4413. filtersData['user'] = {};
  4414. }
  4415. filtersData['user'][item.field] = item.filters[0].term;
  4416. }
  4417. }
  4418. });
  4419. $scope.memoryfilterData = filtersData;
  4420. $scope.loadData(filtersData);
  4421. });
  4422. };
  4423. $scope.changecai = function (item) {
  4424. event.preventDefault();
  4425. var modalInstance = $modal.open({
  4426. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4427. controller: function ($scope, $modalInstance) {
  4428. $scope.title = "修改耗材数量";
  4429. $scope.consumptive = angular.copy(item);
  4430. // $scope.consumptive = item;
  4431. $scope.maxsum = item.inventoryNum;
  4432. $scope.clearNoNum = function (obj, attr) {
  4433. //先把非数字的都替换掉,除了数字和.
  4434. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4435. //必须保证第一个为数字而不是.
  4436. obj[attr] = obj[attr].replace(/^\./g, "");
  4437. //保证只有出现一个.而没有多个.
  4438. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4439. //保证.只出现一次,而不能出现两次以上
  4440. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4441. //小于最大值
  4442. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4443. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4444. // obj[attr] = '';
  4445. // }
  4446. }
  4447. $scope.ok = function () {
  4448. $modalInstance.close($scope.consumptive);
  4449. };
  4450. $scope.cancel = function () {
  4451. $modalInstance.dismiss('cancel');
  4452. };
  4453. },
  4454. size: 'sm'
  4455. });
  4456. modalInstance.result.then(function (selectedItem) {
  4457. angular.forEach($scope.myData2all, function (items, index) {
  4458. // if (items.id == selectedItem.id) {
  4459. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  4460. angular.extend($scope.myData2all[index], selectedItem)
  4461. }
  4462. })
  4463. // $scope.model.consumables = $scope.myData2;
  4464. // $scope.myData2 = $scope.model.consumables;
  4465. // $scope.myData2all.push(selectedItem);
  4466. // for (var i = 0; i < $scope.myData2all.length; i++) {
  4467. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4468. // }
  4469. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4470. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4471. $scope.model.consumables = $scope.myData2all;
  4472. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4473. })
  4474. }
  4475. $scope.interceptMydata = function (mydate, idx, sum) {
  4476. return mydate.slice(idx * sum, (idx + 1) * sum)
  4477. }
  4478. $scope.haocaiadd = function () {
  4479. event.preventDefault();
  4480. var modalInstance = $modal.open({
  4481. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  4482. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
  4483. $scope.haocainame = [];
  4484. $scope.pinpai = [];
  4485. $scope.guige = [];
  4486. $scope.consumptive = {};
  4487. $scope.consumptiveall = {};
  4488. $scope.title = "添加耗材";
  4489. api_wechatfile.getDictionaryForList({
  4490. "key": "haocaifenlei"
  4491. }).then(function (data) {
  4492. $scope.haocainame = data;
  4493. })
  4494. $scope.clearNoNum = function (obj, attr) {
  4495. //先把非数字的都替换掉,除了数字和.
  4496. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4497. //必须保证第一个为数字而不是.
  4498. obj[attr] = obj[attr].replace(/^\./g, "");
  4499. //保证只有出现一个.而没有多个.
  4500. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4501. //保证.只出现一次,而不能出现两次以上
  4502. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4503. //小于最大值
  4504. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4505. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4506. obj[attr] = '';
  4507. }
  4508. }
  4509. $scope.onChange = function (parent) {
  4510. $scope.consumptive.model = {};
  4511. $scope.consumptive.Specifications = {};
  4512. api_wechatfile.getDictionaryForList({
  4513. "key": "pinpai",
  4514. "parent": parent.id
  4515. }).then(function (data) {
  4516. $scope.pinpai = data;
  4517. })
  4518. api_wechatfile.getDictionaryForList({
  4519. "key": "guige",
  4520. "parent": parent.id
  4521. }).then(function (data) {
  4522. $scope.guige = data;
  4523. })
  4524. }
  4525. // $scope.onChangesum = function(item) {
  4526. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  4527. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  4528. // $scope.consumptiveall = data1;
  4529. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  4530. // // if (data.list && data.list.length != 0) {
  4531. // // var myData = data.list;
  4532. // // $scope.consumptiveall = myData[0];
  4533. // // $scope.maxsum = myData[0].inventoryNum;
  4534. // // } else if (data.list && data.list.length == 0) {
  4535. // // SweetAlert.swal({
  4536. // // title: "库存数据存在问题!",
  4537. // // text: "请检查库存数据!",
  4538. // // type: "error"
  4539. // // });
  4540. // // }
  4541. // // });
  4542. // }
  4543. // }
  4544. $scope.addhaocai = function () {
  4545. $modalInstance.dismiss('cancel');
  4546. scope.haocaiopen($scope.consumptive);
  4547. }
  4548. $scope.ok = function (item) {
  4549. var submittrue = true;
  4550. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4551. var data = {
  4552. "modelid": item.model.id,
  4553. "nameid": item.name.id,
  4554. "Specificationsid": item.Specifications.id,
  4555. "name": item.name.name,
  4556. "model": item.model.name,
  4557. "Specifications": item.Specifications.name,
  4558. "sum": item.sum
  4559. }
  4560. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4561. // $modalInstance.close(data);
  4562. angular.forEach(scope.myData2all, function (itemsdata) {
  4563. // if (item.model.id == itemsdata.id) {
  4564. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  4565. submittrue = false;
  4566. }
  4567. })
  4568. if (submittrue) {
  4569. $modalInstance.close(data);
  4570. } else {
  4571. SweetAlert.swal({
  4572. title: "该耗材已有添加",
  4573. text: "请检查数据然后提交!",
  4574. type: "error"
  4575. });
  4576. }
  4577. } else {
  4578. SweetAlert.swal({
  4579. title: "数据填写不完整!",
  4580. text: "请检查数据然后提交!",
  4581. type: "error"
  4582. });
  4583. }
  4584. };
  4585. $scope.cancel = function () {
  4586. $modalInstance.dismiss('cancel');
  4587. };
  4588. },
  4589. size: 'sm',
  4590. resolve: {
  4591. scope: function () {
  4592. return $scope;
  4593. }
  4594. }
  4595. });
  4596. modalInstance.result.then(function (selectedItem) {
  4597. // $scope.myData2.push(selectedItem);
  4598. // for (var i = 0; i < $scope.myData2.length; i++) {
  4599. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4600. // }
  4601. // $scope.model.consumables = $scope.myData2;
  4602. $scope.myData2all.push(selectedItem);
  4603. for (var i = 0; i < $scope.myData2all.length; i++) {
  4604. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4605. $scope.myData2all[i]['item'] = i + 1
  4606. }
  4607. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4608. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4609. $scope.model.consumables = $scope.myData2all;
  4610. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4611. })
  4612. }
  4613. $scope.onDblClick = function (data, event) {
  4614. $scope.selectButtonClick(data, event);
  4615. };
  4616. $scope.memoryfilterData = {
  4617. "idx": 0,
  4618. "sum": 20,
  4619. "user": {
  4620. "roledata": {
  4621. "rolecode": "roleset"
  4622. },
  4623. "selectType": "1"
  4624. }
  4625. }
  4626. $scope.myData = {};
  4627. $scope.loadData = function (filterData) {};
  4628. // $scope.title = title;
  4629. $scope.loadData({
  4630. idx: 0,
  4631. sum: 20,
  4632. "user": {
  4633. "roledata": {
  4634. "rolecode": "roleset"
  4635. },
  4636. "selectType": "1"
  4637. }
  4638. });
  4639. $scope.selected = {
  4640. items: {}
  4641. };
  4642. }]
  4643. });
  4644. //tab 列表
  4645. formlyConfigProvider.setType({
  4646. name: 'ui-cmdbtab',
  4647. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
  4648. wrapper: ['bootstrapHasError'],
  4649. defaultOptions: function (options, $scope) {
  4650. return {
  4651. templateOptions: {}
  4652. };
  4653. },
  4654. controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  4655. $scope.memoryfilterDatashe = {
  4656. "idx": 0,
  4657. "sum": 10
  4658. }
  4659. $scope.myDataoneall = [];
  4660. var setAllInactive = function () {
  4661. angular.forEach($scope.workspaces, function (workspace) {
  4662. workspace.active = false;
  4663. });
  4664. };
  4665. //添加
  4666. var addNewWorkspace = function (name, contentUrl) {
  4667. var id = $scope.workspaces.length + 1;
  4668. $scope.workspaces.push({
  4669. id: id,
  4670. name: name,
  4671. active: true,
  4672. contentUrl: 'main/html/content.html'
  4673. });
  4674. };
  4675. //关闭
  4676. $scope.remove = function (closedata) {
  4677. event.preventDefault();
  4678. angular.forEach($scope.workspaces, function (item, index) {
  4679. if (closedata.id == item.id) {
  4680. if (closedata.id == 1) {
  4681. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  4682. } else {
  4683. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  4684. }
  4685. $scope.workspaces.splice(index, 1);
  4686. }
  4687. })
  4688. }
  4689. $scope.workspaces = [];
  4690. $scope.options.templateOptions.getpush = function (item) {
  4691. $scope.workspaces = [];
  4692. if (item.gu) {
  4693. $scope.workspaces.push({
  4694. id: 1,
  4695. name: "领用设备",
  4696. active: true,
  4697. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4698. })
  4699. }
  4700. if (item.hao) {
  4701. $scope.workspaces.push({
  4702. id: 2,
  4703. name: "领用耗材",
  4704. active: true,
  4705. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4706. })
  4707. }
  4708. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4709. };
  4710. $scope.addWorkspace = function (contentUrl, name) {
  4711. setAllInactive();
  4712. addNewWorkspace(name, contentUrl);
  4713. };
  4714. // $rootScope.addWorkspace = $scope.addWorkspace;
  4715. // $scope.remove = function(idNumber) {
  4716. // var index = 0; //记录当前元素下标
  4717. // angular.forEach($scope.workspaces, function(workspace) {
  4718. // if (workspace.id === idNumber.id) {
  4719. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4720. // }
  4721. // index++;
  4722. // });
  4723. // };
  4724. // setInterval(function() {
  4725. // if ($scope.model.assets) {
  4726. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4727. // $scope.modelass = $scope.model.assets;
  4728. // if (JSON.stringify($scope.model.assets) == "{}") {
  4729. // $scope.model.assets = []
  4730. // } else {
  4731. // $scope.model.assets = JSON.parse($scope.model.assets);
  4732. // }
  4733. // $scope.myDatalingbeiall = $scope.model.assets;
  4734. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4735. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4736. // }
  4737. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4738. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4739. // }
  4740. // }
  4741. // if ($scope.model.consumables) {
  4742. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4743. // $scope.modelass = $scope.model.consumables;
  4744. // if (JSON.stringify($scope.model.consumables) == "{}") {
  4745. // $scope.model.consumables = [];
  4746. // } else {
  4747. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  4748. // }
  4749. // $scope.myDatalingbeiall = $scope.model.consumables;
  4750. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4751. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4752. // }
  4753. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  4754. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4755. // // $scope.model.consumables = $scope.myData2all;
  4756. // }
  4757. // }
  4758. // }, 100);
  4759. //grid1
  4760. $scope.langs = i18nService.getAllLangs();
  4761. $scope.lang = 'zh-cn';
  4762. i18nService.setCurrentLang($scope.lang);
  4763. $scope.gridOptions1 = {};
  4764. $scope.gridOptions1.data = 'myDatalingbei';
  4765. $scope.gridOptions1.enableColumnResizing = true;
  4766. $scope.gridOptions1.enableFiltering = false;
  4767. $scope.gridOptions1.enableGridMenu = false;
  4768. $scope.gridOptions1.showGridFooter = true;
  4769. $scope.gridOptions1.showColumnFooter = false;
  4770. $scope.gridOptions1.fastWatch = true;
  4771. $scope.gridOptions1.useExternalFiltering = true;
  4772. $scope.gridOptions1.useExternalPagination = true;
  4773. $scope.gridOptions1.paginationPageSizes = [10];
  4774. $scope.gridOptions1.paginationPageSize = 10;
  4775. $scope.gridOptions1.multiSelect = false;
  4776. // $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>";
  4777. $scope.gridOptions1.columnDefs = [{
  4778. name: 'item',
  4779. displayName: '序号',
  4780. width: 120
  4781. },
  4782. {
  4783. name: 'props.hw_cifilterClassic',
  4784. displayName: '设备类型',
  4785. width: 150,
  4786. enableFiltering: false
  4787. },
  4788. {
  4789. name: 'props.hw_mingcheng',
  4790. displayName: '设备名称',
  4791. width: 100,
  4792. enableFiltering: false
  4793. },
  4794. {
  4795. name: 'uuid',
  4796. displayName: '设备编号',
  4797. enableFiltering: false
  4798. }
  4799. ];
  4800. $scope.myDatalingbeiall = [];
  4801. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4802. $scope.gridApi = gridApi;
  4803. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4804. // var filtersData = $scope.memoryfilterData;
  4805. // filtersData.idx = newPage - 1;
  4806. // filtersData.sum = pageSize;
  4807. // $scope.loadData(filtersData);
  4808. $scope.memoryfilterDatashe.idx = newPage - 1;
  4809. $scope.memoryfilterDatashe.sum = pageSize;
  4810. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
  4811. });
  4812. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4813. $scope.selected.items = data.entity;
  4814. //console.log(data);
  4815. });
  4816. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4817. $scope.selected.items = data.entity;
  4818. //console.log(data);
  4819. });
  4820. gridApi.core.on.filterChanged($scope, function () {
  4821. var grid = this.grid;
  4822. var filtersData = {
  4823. idx: 0,
  4824. sum: 20,
  4825. "user": {
  4826. "roledata": {
  4827. "rolecode": "roleset"
  4828. },
  4829. "selectType": "1"
  4830. }
  4831. };
  4832. angular.forEach(grid.columns, function (item) {
  4833. if (item.enableFiltering) {
  4834. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4835. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4836. if (angular.isUndefined(filtersData['user'])) {
  4837. filtersData['user'] = {};
  4838. }
  4839. filtersData['user'][item.field] = item.filters[0].term;
  4840. }
  4841. }
  4842. });
  4843. $scope.memoryfilterDatashe = filtersData;
  4844. // $scope.loadData(filtersData);
  4845. });
  4846. };
  4847. $scope.interceptMydata = function (mydate, idx, sum) {
  4848. return mydate.slice(idx * sum, (idx + 1) * sum)
  4849. }
  4850. $scope.removeshebei = function (item) {
  4851. event.preventDefault();
  4852. var modalInstance = $modal.open({
  4853. templateUrl: 'assets/views/delete.html',
  4854. controller: function ($scope, $modalInstance, scope) {
  4855. $scope.title = '设备移除';
  4856. $scope.connect = '确定要移除此设备?';
  4857. $scope.consumptive = scope.selected.items;
  4858. $scope.ok = function () {
  4859. $modalInstance.close($scope.consumptive);
  4860. };
  4861. $scope.cancel = function () {
  4862. $modalInstance.dismiss('cancel');
  4863. };
  4864. },
  4865. size: 'sm',
  4866. resolve: {
  4867. scope: function () {
  4868. return $scope;
  4869. },
  4870. }
  4871. });
  4872. modalInstance.result.then(function (selectedItem) {
  4873. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  4874. if (items.id == selectedItem.id) {
  4875. $scope.myDatalingbeiall.splice(index, 1);
  4876. }
  4877. })
  4878. // $scope.myData3.push(selectedItem);
  4879. $scope.model.consumables = $scope.myDatalingbeiall;
  4880. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
  4881. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4882. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4883. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
  4884. }
  4885. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4886. })
  4887. }
  4888. $scope.addshebei = function () {
  4889. event.preventDefault();
  4890. var modalInstance = $modal.open({
  4891. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  4892. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
  4893. $scope.langs = i18nService.getAllLangs();
  4894. $scope.lang = 'zh-cn';
  4895. i18nService.setCurrentLang($scope.lang);
  4896. $scope.gridOptions = {};
  4897. $scope.gridOptions.data = 'myDatatwo';
  4898. $scope.gridOptions.enableColumnResizing = true;
  4899. $scope.gridOptions.enableFiltering = false;
  4900. $scope.gridOptions.enableGridMenu = false;
  4901. $scope.gridOptions.showGridFooter = true;
  4902. $scope.gridOptions.showColumnFooter = false;
  4903. $scope.gridOptions.fastWatch = true;
  4904. $scope.gridOptions.useExternalFiltering = true;
  4905. $scope.gridOptions.useExternalPagination = true;
  4906. $scope.gridOptions.paginationPageSizes = [10];
  4907. $scope.gridOptions.paginationPageSize = 10;
  4908. $scope.gridOptions.multiSelect = true;
  4909. $scope.gridOptions.rowIdentity = function (row) {
  4910. return row.id;
  4911. };
  4912. $scope.gridOptions.getRowIdentity = function (row) {
  4913. return row.id;
  4914. };
  4915. // $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>";
  4916. $scope.gridOptions.columnDefs = [{
  4917. name: 'item',
  4918. displayName: '序号',
  4919. width: 80,
  4920. enableFiltering: false
  4921. },
  4922. {
  4923. name: 'uuid',
  4924. displayName: '内部编号',
  4925. width: 120
  4926. },
  4927. {
  4928. name: 'props.hw_mingcheng',
  4929. displayName: '资产名称',
  4930. width: 100
  4931. },
  4932. {
  4933. name: 'props.hw_cifilterClassic',
  4934. displayName: '资产类型',
  4935. width: 80,
  4936. enableFiltering: false
  4937. },
  4938. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  4939. {
  4940. name: 'props.hw_state',
  4941. displayName: '资产状态',
  4942. width: 150,
  4943. enableFiltering: false
  4944. },
  4945. {
  4946. name: 'props.hwnw_area',
  4947. displayName: '资产地点',
  4948. width: 130,
  4949. enableFiltering: false
  4950. },
  4951. {
  4952. name: 'createtime',
  4953. displayName: '申请时间',
  4954. enableFiltering: false
  4955. }
  4956. ];
  4957. // $scope.selectButtonClick
  4958. var defaultFilterData = {
  4959. // "assignee":2,
  4960. // "sign":"basehwitndl",
  4961. // "applicationForm": { "hw_state": "在线" },
  4962. "hw_state": "在库",
  4963. "idx": 0,
  4964. "sum": 10
  4965. };
  4966. $scope.memoryfilterData = {
  4967. // "assignee":2,
  4968. // "sign":"basehwitndl",
  4969. // "applicationForm": { "hw_state": "在线" },
  4970. "hw_state": "在库",
  4971. "idx": 0,
  4972. "sum": 10
  4973. }
  4974. $scope.refreshData = function (style, filterData) {
  4975. if (angular.isUndefined(filterData)) {
  4976. filterData = defaultFilterData;
  4977. }
  4978. $scope.myDatatwo = [];
  4979. // $scope.gridOptions['sum']=filterData.sum;
  4980. api_cmdb.query(filterData).then(function (data) {
  4981. // $scope.callsPending--;
  4982. var filterData = $scope.memoryfilterData;
  4983. var myDatatwo = Restangular.stripRestangular(data);
  4984. $scope.gridOptions['totalItems'] = data.total;
  4985. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  4986. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  4987. }
  4988. $scope.myDatatwo = myDatatwo.data.node;
  4989. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  4990. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  4991. }
  4992. }, function () {});
  4993. };
  4994. $scope.refreshData('expand-right', defaultFilterData);
  4995. $scope.gridOptions.onRegisterApi = function (gridApi) {
  4996. $scope.gridApi = gridApi;
  4997. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4998. var filtersData = $scope.memoryfilterData;
  4999. filtersData.idx = newPage - 1;
  5000. filtersData.sum = pageSize;
  5001. // $scope.loadData(filtersData);
  5002. $scope.refreshData('expand-right', filtersData);
  5003. //console.log(pageSize);
  5004. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  5005. });
  5006. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  5007. // $scope.selected.items.push(data.entity);
  5008. //console.log(data);
  5009. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  5010. if (scope.isSelected) {
  5011. scope.grid.appScope.selected.items.push(scope.entity)
  5012. } else {
  5013. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  5014. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  5015. scope.grid.appScope.selected.items.splice(i, 1);
  5016. break;
  5017. }
  5018. }
  5019. }
  5020. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  5021. });
  5022. // });
  5023. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  5024. // $scope.selected.items = data.entity;
  5025. //console.log(data);
  5026. var selectitem = [];
  5027. selectitem = angular.copy($scope.selected.items);
  5028. for (var j = 0; j < rows.length; j++) {
  5029. if (rows[j].isSelected == true) {
  5030. selectitem.push(rows[j].entity);
  5031. } else {
  5032. delete selectitem[j];
  5033. // rows.splice(j, 1);
  5034. }
  5035. }
  5036. $scope.selected.items = [];
  5037. for (var i = 0; i < selectitem.length; i++) {
  5038. if (selectitem[i]) {
  5039. $scope.selected.items.push(selectitem[i]);
  5040. }
  5041. }
  5042. });
  5043. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  5044. // // if (row.entity.age > 45) {
  5045. // row.grid.api.selection.selectRow(row.entity); // 选中行
  5046. // // }
  5047. // };
  5048. gridApi.core.on.filterChanged($scope, function () {
  5049. var grid = this.grid;
  5050. var filtersData = {
  5051. idx: 0,
  5052. sum: 10,
  5053. "user": {
  5054. "roledata": {
  5055. "rolecode": "roleset"
  5056. },
  5057. "selectType": "1"
  5058. }
  5059. };
  5060. angular.forEach(grid.columns, function (item) {
  5061. if (item.enableFiltering) {
  5062. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5063. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5064. if (angular.isUndefined(filtersData['user'])) {
  5065. filtersData['user'] = {};
  5066. }
  5067. filtersData['user'][item.field] = item.filters[0].term;
  5068. }
  5069. }
  5070. });
  5071. $scope.memoryfilterData = filtersData;
  5072. // $scope.loadData(filtersData);
  5073. });
  5074. };
  5075. $scope.onDblClick = function (data, event) {
  5076. // $scope.selected.items = data.entity;
  5077. $scope.selectButtonClick(data, event);
  5078. };
  5079. // $scope.loadData = function(filterData) {
  5080. // // console.log("filtersData=111" + JSON.stringify(filterData))
  5081. // items.fetchItems(filterData, APIService).then(function(data) {
  5082. // var myDatatwo = Restangular.stripRestangular(data);
  5083. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  5084. // $scope.myDatatwo = myDatatwo.list;
  5085. // });
  5086. // };
  5087. $scope.title = title;
  5088. //树形图
  5089. var apple_selected, tree, treedata_avm, treedata_geography;
  5090. $scope.my_tree_handler = function (branch) {
  5091. //var _ref;
  5092. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  5093. api_cmdb.query({
  5094. 'sign': classify
  5095. }).then(function (data) {
  5096. var myDatalingbei = Restangular.stripRestangular(data);
  5097. // console.log(myData.data.node);
  5098. if (myDatalingbei.data && myDatalingbei.status == 200) {
  5099. var ret = myDatalingbei.data;
  5100. redrawSvg(myDatalingbei);
  5101. }
  5102. });
  5103. };
  5104. $scope.my_data = [];
  5105. function convertListToTree(data, treeMap) {
  5106. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  5107. var root = null; //Initially set our loop to null
  5108. var parentNode = null;
  5109. //loop over data
  5110. for (var i = 0; i < data.length; i++) {
  5111. var datum = data[i];
  5112. //each node will have children, so let's give it a "children" poperty
  5113. datum.children = [];
  5114. //add an entry for this node to the map so that any future children can
  5115. //lookup the parent
  5116. idToNodeMap[datum.id] = datum;
  5117. //Does this node have a parent?
  5118. if (typeof datum.parent === "undefined" || datum.parent == null) {
  5119. //Doesn't look like it, so this node is the root of the tree
  5120. root = datum;
  5121. treeMap[datum.id] = root;
  5122. } else {
  5123. //This node has a parent, so let's look it up using the id
  5124. parentNode = idToNodeMap[datum.parent.id];
  5125. //We don't need this property, so let's delete it.
  5126. delete datum.parent;
  5127. //Let's add the current node as a child of the parent node.
  5128. parentNode.children.push(datum);
  5129. }
  5130. }
  5131. return root;
  5132. }
  5133. function convertParentToChildList(data) {
  5134. var treeMap = {};
  5135. var list = [];
  5136. convertListToTree(data, treeMap);
  5137. angular.forEach(treeMap, function (item) {
  5138. list.push(item);
  5139. });
  5140. return list;
  5141. }
  5142. $scope.my_tree = tree = {};
  5143. $scope.try_async_load = function () {
  5144. $scope.my_data = [];
  5145. $scope.select_treedata = [];
  5146. $scope.doing_async = true;
  5147. api_configure_data.fetchDataList('ciclassify', {
  5148. 'idx': 0,
  5149. 'sum': 100
  5150. }).then(function (result) {
  5151. //console.log(result['list']);
  5152. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  5153. $scope.doing_async = false;
  5154. // tree.expand_all();
  5155. //console.log(treelist);
  5156. });
  5157. };
  5158. $scope.select_treedata = [];
  5159. $scope.propTypeOptions = [];
  5160. $scope.try_async_load();
  5161. $scope.onFilterremove = function (item) {
  5162. console.log(item)
  5163. }
  5164. $scope.searchdata = {};
  5165. $scope.clear = function () {
  5166. $scope.searchdata = {};
  5167. $scope.cifilter_classic = {};
  5168. $scope.try_async_load();
  5169. var fildata = {
  5170. idx: 0,
  5171. sum: 10,
  5172. 'hw_state': '在库'
  5173. }
  5174. $scope.memoryfilterData = fildata;
  5175. $scope.refreshData('expand-right', fildata);
  5176. }
  5177. $scope.cifilter_classic = {};
  5178. $scope.chiceIncident = function (item) {
  5179. var fildata = defaultFilterData;
  5180. // fildata.applicationForm = {};
  5181. // sign: basehwnwswt
  5182. if (item && item.id) {
  5183. var classify = item.prefix.toLowerCase() + item.sign;
  5184. fildata.sign = classify
  5185. }
  5186. $scope.gridOptions.paginationCurrentPage = 1;
  5187. var transitiondata = angular.copy(item);
  5188. $scope.refreshData('expand-right', fildata);
  5189. }
  5190. $scope.applicadata = [];
  5191. $scope.onFilterCallback = function (item) {
  5192. var tempclassify = item.prefix.toLowerCase() + item.sign;
  5193. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  5194. var myData = Restangular.stripRestangular(data);
  5195. $scope.applicadata = myData[0].form.fields;
  5196. });
  5197. // }
  5198. }
  5199. // $scope.loadData({
  5200. // idx: 0,
  5201. // sum: 10,
  5202. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5203. // });
  5204. $scope.selected = {
  5205. items: []
  5206. };
  5207. $scope.ok = function () {
  5208. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  5209. // onDataCallback($scope.selected.item, parentScope);
  5210. // }
  5211. $modalInstance.close($scope.selected.items);
  5212. };
  5213. $scope.cancel = function () {
  5214. $modalInstance.dismiss('cancel');
  5215. };
  5216. },
  5217. size: 'lg',
  5218. resolve: {
  5219. items: function () {
  5220. return {
  5221. fetchItems: function (filterData, APIService) {
  5222. filterData = filterData || {};
  5223. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  5224. filterData = {
  5225. idx: 0,
  5226. sum: 10,
  5227. "user": {
  5228. "roledata": {
  5229. "rolecode": "roleset"
  5230. },
  5231. "selectType": "1"
  5232. }
  5233. };
  5234. }
  5235. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  5236. }
  5237. };
  5238. },
  5239. title: function () {
  5240. return $scope.options.templateOptions.label;
  5241. },
  5242. Restangular: function () {
  5243. return $scope.options.templateOptions.Restangular;
  5244. },
  5245. APIService: function () {
  5246. return $scope.options.templateOptions.ApiService;
  5247. },
  5248. onDataCallback: function () {
  5249. return $scope.options.templateOptions.callback;
  5250. },
  5251. parentScope: function () {
  5252. return $scope.options.templateOptions.that;
  5253. }
  5254. }
  5255. });
  5256. modalInstance.result.then(function (selectedItem) {
  5257. // console.log(selectedItem);
  5258. // options.value(selectedItem);
  5259. var filterData = $scope.memoryfilterDatashe;
  5260. $scope.myDatalingbeiall = selectedItem;
  5261. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5262. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5263. $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5264. }
  5265. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5266. $scope.model.assets = $scope.myDatalingbeiall;
  5267. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
  5268. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  5269. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  5270. // }
  5271. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  5272. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  5273. // }
  5274. }, function () {
  5275. //console.log('Modal dismissed at: ' + new Date());
  5276. });
  5277. }
  5278. $scope.onDblClick = function (data, event) {
  5279. $scope.selectButtonClick(data, event);
  5280. };
  5281. // $scope.loadData = function(filterData) {};
  5282. // $scope.title = title;
  5283. // $scope.loadData({
  5284. // idx: 0,
  5285. // sum: 20,
  5286. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5287. // });
  5288. $scope.selected = {
  5289. items: []
  5290. };
  5291. //grid2
  5292. $scope.langs = i18nService.getAllLangs();
  5293. $scope.lang = 'zh-cn';
  5294. i18nService.setCurrentLang($scope.lang);
  5295. $scope.gridOptions2 = {};
  5296. $scope.gridOptions2.data = 'myDataone';
  5297. $scope.gridOptions2.enableColumnResizing = true;
  5298. $scope.gridOptions2.enableFiltering = false;
  5299. $scope.gridOptions2.enableGridMenu = false;
  5300. $scope.gridOptions2.showGridFooter = true;
  5301. $scope.gridOptions2.showColumnFooter = false;
  5302. $scope.gridOptions2.fastWatch = true;
  5303. $scope.gridOptions2.useExternalFiltering = true;
  5304. $scope.gridOptions2.useExternalPagination = true;
  5305. $scope.gridOptions2.paginationPageSizes = [10];
  5306. $scope.gridOptions2.paginationPageSize = 10;
  5307. $scope.gridOptions2.multiSelect = false;
  5308. // $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>";
  5309. $scope.gridOptions2.columnDefs = [{
  5310. name: 'item',
  5311. displayName: '序号',
  5312. width: 120
  5313. },
  5314. {
  5315. name: 'name',
  5316. displayName: '耗材名称',
  5317. width: 150,
  5318. enableFiltering: false
  5319. },
  5320. {
  5321. name: 'model',
  5322. displayName: '品牌/型号',
  5323. width: 100,
  5324. enableFiltering: false
  5325. },
  5326. {
  5327. name: 'Specifications',
  5328. displayName: '规格',
  5329. width: 150,
  5330. enableFiltering: false
  5331. },
  5332. {
  5333. name: 'sum',
  5334. displayName: '领用数量',
  5335. enableFiltering: false
  5336. }
  5337. ];
  5338. // $scope.selectButtonClick
  5339. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5340. $scope.gridApi = gridApi;
  5341. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5342. // var filtersData = $scope.memoryfilterData;
  5343. // filtersData.idx = newPage - 1;
  5344. // filtersData.sum = pageSize;
  5345. // $scope.loadData(filtersData);
  5346. $scope.memoryfilterDatahao.idx = newPage - 1;
  5347. $scope.memoryfilterDatahao.sum = pageSize;
  5348. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
  5349. });
  5350. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5351. $scope.selected.items.push(data.entity);
  5352. //console.log(data);
  5353. });
  5354. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  5355. $scope.selected.items.push(data.entity);
  5356. //console.log(data);
  5357. });
  5358. gridApi.core.on.filterChanged($scope, function () {
  5359. var grid = this.grid;
  5360. var filtersData = {
  5361. idx: 0,
  5362. sum: 10,
  5363. "user": {
  5364. "roledata": {
  5365. "rolecode": "roleset"
  5366. },
  5367. "selectType": "1"
  5368. }
  5369. };
  5370. angular.forEach(grid.columns, function (item) {
  5371. if (item.enableFiltering) {
  5372. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5373. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5374. if (angular.isUndefined(filtersData['user'])) {
  5375. filtersData['user'] = {};
  5376. }
  5377. filtersData['user'][item.field] = item.filters[0].term;
  5378. }
  5379. }
  5380. });
  5381. $scope.memoryfilterDatahao = filtersData;
  5382. $scope.loadData(filtersData);
  5383. });
  5384. };
  5385. $scope.removehaocai = function (item) {
  5386. event.preventDefault();
  5387. // var modalInstance = $modal.open({
  5388. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  5389. // controller: function($scope, $modalInstance) {
  5390. // $scope.title = "修改耗材数量";
  5391. // $scope.consumptive = item;
  5392. // $scope.ok = function() {
  5393. // $modalInstance.close($scope.consumptive);
  5394. // };
  5395. // $scope.cancel = function() {
  5396. // $modalInstance.dismiss('cancel');
  5397. // };
  5398. // },
  5399. // size: 'sm'
  5400. // });
  5401. var modalInstance = $modal.open({
  5402. templateUrl: 'assets/views/delete.html',
  5403. controller: function ($scope, $modalInstance, scope) {
  5404. $scope.title = '耗材移除';
  5405. $scope.connect = '确定要移除此设备?';
  5406. $scope.consumptive = scope.selected.items[0];
  5407. $scope.ok = function () {
  5408. $modalInstance.close($scope.consumptive);
  5409. };
  5410. $scope.cancel = function () {
  5411. $modalInstance.dismiss('cancel');
  5412. };
  5413. },
  5414. size: 'sm',
  5415. resolve: {
  5416. scope: function () {
  5417. return $scope;
  5418. },
  5419. }
  5420. });
  5421. modalInstance.result.then(function (selectedItem) {
  5422. // angular.forEach($scope.myData3, function(items, index) {
  5423. // if (items.id == selectedItem.id) {
  5424. // $scope.myData3[index] = selectedItem;
  5425. // }
  5426. // })
  5427. // $scope.model.applicationForm.consumables = $scope.myData3;
  5428. angular.forEach($scope.myDataoneall, function (items, index) {
  5429. if (items.id == selectedItem.id) {
  5430. $scope.myDataoneall.splice(index, 1);
  5431. }
  5432. })
  5433. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5434. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5435. }
  5436. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5437. $scope.model.consumables = $scope.myDataoneall;
  5438. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5439. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5440. $scope.selected = {
  5441. items: []
  5442. };
  5443. })
  5444. }
  5445. $scope.haocaiadd = function () {
  5446. event.preventDefault();
  5447. var modalInstance = $modal.open({
  5448. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  5449. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  5450. $scope.haocainame = [];
  5451. $scope.pinpai = [];
  5452. $scope.guige = [];
  5453. $scope.consumptive = {};
  5454. $scope.consumpall = {};
  5455. $scope.title = "添加耗材";
  5456. api_wechatfile.getDictionaryForList({
  5457. "key": "haocaifenlei"
  5458. }).then(function (data) {
  5459. $scope.haocainame = data;
  5460. })
  5461. $scope.clearNoNum = function (obj, attr) {
  5462. //先把非数字的都替换掉,除了数字和.
  5463. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5464. //必须保证第一个为数字而不是.
  5465. obj[attr] = obj[attr].replace(/^\./g, "");
  5466. //保证只有出现一个.而没有多个.
  5467. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5468. //保证.只出现一次,而不能出现两次以上
  5469. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  5470. //小于最大值
  5471. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5472. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5473. obj[attr] = '';
  5474. }
  5475. }
  5476. $scope.onChange = function (parent) {
  5477. $scope.consumptive.model = {};
  5478. $scope.consumptive.Specifications = {};
  5479. api_wechatfile.getDictionaryForList({
  5480. "key": "pinpai",
  5481. "parent": parent.id
  5482. }).then(function (data) {
  5483. $scope.pinpai = data;
  5484. })
  5485. api_wechatfile.getDictionaryForList({
  5486. "key": "guige",
  5487. "parent": parent.id
  5488. }).then(function (data) {
  5489. $scope.guige = data;
  5490. })
  5491. }
  5492. $scope.onChangesum = function (item) {
  5493. if (item.name && item.model.id && item.Specifications.id) {
  5494. $scope.consumptive.sum = "";
  5495. var data1 = {
  5496. "idx": 0,
  5497. "sum": 10,
  5498. "consumable": {
  5499. "name": item.name.name,
  5500. "brandModel": item.model.name,
  5501. "specification": item.Specifications.name
  5502. }
  5503. }
  5504. api_cmdb3.fetchDataList('consumable', data1).then(function (data) {
  5505. if (data.status == 200 && data.list.length > 0) {
  5506. var myData = data.list;
  5507. $scope.consumpall = myData[0];
  5508. $scope.maxsum = myData[0].inventoryNum;
  5509. } else {
  5510. SweetAlert.swal({
  5511. title: "不存在该耗材",
  5512. text: "请检查库存后重新填写!",
  5513. type: "error"
  5514. });
  5515. }
  5516. });
  5517. }
  5518. }
  5519. $scope.addhaocai = function () {
  5520. $modalInstance.dismiss('cancel');
  5521. scope.haocaiopen($scope.consumptive);
  5522. }
  5523. $scope.ok = function (item) {
  5524. var items = {};
  5525. // if (item.name && item.model && item.Specifications && item.sum) {
  5526. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5527. // $scope.consumpall.model = $scope.consumpall.brandModel;
  5528. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  5529. // $scope.consumpall.sum = item.sum;
  5530. // delete $scope.consumpall.brandModel;
  5531. // delete $scope.consumpall.specification;
  5532. // $modalInstance.close($scope.consumpall);
  5533. // } else {
  5534. // SweetAlert.swal({
  5535. // title: "数据填写不完整!",
  5536. // text: "请检查数据然后提交!",
  5537. // type: "error"
  5538. // });
  5539. // }
  5540. var isold = false;
  5541. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  5542. for (var i = 0; i < scope.myDataoneall.length; i++) {
  5543. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  5544. isold = true;
  5545. }
  5546. }
  5547. if (isold) {
  5548. SweetAlert.swal({
  5549. title: "该耗材已添加!",
  5550. text: "请不要重复添加耗材!",
  5551. type: "error"
  5552. });
  5553. } else {
  5554. $scope.consumpall.model = $scope.consumpall.brandModel;
  5555. $scope.consumpall.Specifications = $scope.consumpall.specification;
  5556. $scope.consumpall.sum = item.sum;
  5557. delete $scope.consumpall.brandModel;
  5558. delete $scope.consumpall.specification;
  5559. $modalInstance.close($scope.consumpall);
  5560. }
  5561. } else {
  5562. SweetAlert.swal({
  5563. title: "数据填写不完整!",
  5564. text: "请检查数据然后提交!",
  5565. type: "error"
  5566. });
  5567. }
  5568. // $modalInstance.close(item);
  5569. };
  5570. $scope.cancel = function () {
  5571. $modalInstance.dismiss('cancel');
  5572. };
  5573. },
  5574. size: 'sm',
  5575. resolve: {
  5576. scope: function () {
  5577. return $scope;
  5578. }
  5579. }
  5580. });
  5581. modalInstance.result.then(function (selectedItem) {
  5582. $scope.myDataoneall.push(selectedItem);
  5583. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5584. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5585. }
  5586. // $scope.model.consumables = $scope.myDataone;
  5587. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5588. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5589. $scope.model.consumables = $scope.myDataoneall;
  5590. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5591. })
  5592. }
  5593. $scope.onDblClick = function (data, event) {
  5594. $scope.selectButtonClick(data, event);
  5595. };
  5596. $scope.memoryfilterDatahao = {
  5597. "idx": 0,
  5598. "sum": 10,
  5599. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5600. }
  5601. $scope.myDataone = [];
  5602. $scope.loadData = function (filterData) {};
  5603. // $scope.title = title;
  5604. $scope.ldloading = {};
  5605. $scope.selected = {
  5606. items: []
  5607. };
  5608. if ($scope.$parent.$parent.$parent.model.gettype) {
  5609. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  5610. if ($scope.model.assets) {
  5611. if (JSON.stringify($scope.model.assets) == "{}") {
  5612. $scope.model.assets = []
  5613. } else {
  5614. $scope.model.assets = JSON.parse($scope.model.assets);
  5615. }
  5616. $scope.myDatalingbeiall = $scope.model.assets;
  5617. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5618. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
  5619. }
  5620. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5621. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5622. }
  5623. if ($scope.model.consumables) {
  5624. if (JSON.stringify($scope.model.consumables) == "{}") {
  5625. $scope.model.consumables = []
  5626. } else {
  5627. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5628. }
  5629. $scope.myDataoneall = $scope.model.consumables;
  5630. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5631. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5632. }
  5633. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5634. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5635. }
  5636. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5637. $scope.options.templateOptions.getpush({
  5638. "hao": true,
  5639. "gu": true
  5640. });
  5641. } else {
  5642. $scope.options.templateOptions.getpush({
  5643. "hao": true
  5644. });
  5645. }
  5646. } else {
  5647. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5648. $scope.options.templateOptions.getpush({
  5649. "gu": true
  5650. });
  5651. }
  5652. }
  5653. }
  5654. }]
  5655. });
  5656. formlyConfigProvider.setType({
  5657. name: 'ui-panel',
  5658. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  5659. });
  5660. formlyConfigProvider.setType({
  5661. name: 'ui-currentuser',
  5662. extends: 'input',
  5663. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  5664. defaultOptions: function (options) {
  5665. return {
  5666. templateOptions: {
  5667. // link: function() {}
  5668. }
  5669. };
  5670. },
  5671. controller: ['$scope', function ($scope) {
  5672. if ($scope.options.templateOptions.user) {
  5673. if (angular.isFunction($scope.options.templateOptions.transform)) {
  5674. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  5675. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  5676. // }
  5677. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5678. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5679. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  5680. }
  5681. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  5682. $scope.options.initialValue = $scope.model[$scope.options.key];
  5683. }
  5684. }]
  5685. });
  5686. //仪表盘
  5687. //待处理变更列表
  5688. formlyConfigProvider.setType({
  5689. name: 'ui-ngpchangetable',
  5690. templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
  5691. defaultOptions: function (options) {
  5692. return {
  5693. templateOptions: {
  5694. // relationAction: function() {
  5695. // options.hideExpression = true
  5696. // }
  5697. }
  5698. };
  5699. },
  5700. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5701. // var filterData = {
  5702. // "assignee": $rootScope.user.id,
  5703. // "searchtype": "all",
  5704. // "idx": "0",
  5705. // "sum": "10"
  5706. // };
  5707. var filterData = {
  5708. "idx": "0",
  5709. "sum": "10",
  5710. "assignee": 2,
  5711. "searchType": "todo"
  5712. }
  5713. $scope.incidentprocess = function (item) {
  5714. $state.go('app.wt_change.add', {
  5715. taskId: item.taskId,
  5716. processInstanceId: item.processInstanceId
  5717. });
  5718. }
  5719. $scope.more = function () {
  5720. $state.go('app.wt_change.list', {})
  5721. }
  5722. api_bpm_domain.fetchtask('bpm_change', filterData).then(function (data) {
  5723. if (data.data) {
  5724. $scope.myData = data.data;
  5725. } else {
  5726. SweetAlert.swal({
  5727. title: "操作异常!",
  5728. text: "系统异常,请稍后重试,或者联系管理员!",
  5729. type: "error"
  5730. });
  5731. }
  5732. })
  5733. $scope.removes = function () {
  5734. var modalInstance = $modal.open({
  5735. templateUrl: 'assets/views/delete.html',
  5736. controller: function ($scope, $modalInstance) {
  5737. $scope.ok = function () {
  5738. $modalInstance.close();
  5739. };
  5740. $scope.cancel = function () {
  5741. $modalInstance.dismiss('cancel');
  5742. };
  5743. },
  5744. size: 'sm'
  5745. });
  5746. modalInstance.result.then(function () {
  5747. console.log($scope.$parent.$parent.$parent.$parent)
  5748. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5749. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5750. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5751. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5752. break;
  5753. }
  5754. }
  5755. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5756. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5757. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5758. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5759. }
  5760. })
  5761. }
  5762. }]
  5763. });
  5764. //待处理问题列表
  5765. formlyConfigProvider.setType({
  5766. name: 'ui-ngproblemtable',
  5767. templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
  5768. defaultOptions: function (options) {
  5769. return {
  5770. templateOptions: {
  5771. // relationAction: function() {
  5772. // options.hideExpression = true
  5773. // }
  5774. }
  5775. };
  5776. },
  5777. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
  5778. var filterData = {
  5779. "assignee": $rootScope.user.id,
  5780. "candidateGroups": $rootScope.user.group[0].id,
  5781. "searchtype": "todo",
  5782. "idx": 0,
  5783. "sum": 10
  5784. };
  5785. $scope.incidentprocess = function (item) {
  5786. $state.go('app.wt_change.add', {
  5787. taskId: item.taskId,
  5788. processInstanceId: item.processInstanceId
  5789. });
  5790. }
  5791. $scope.more = function () {
  5792. $state.go('app.wt_change.list', {})
  5793. }
  5794. api_bpm_data.fetchDataList('changeclassify', filterData).then(function (data) {
  5795. if (data.data) {
  5796. $scope.myData = data.data;
  5797. } else {
  5798. SweetAlert.swal({
  5799. title: "操作异常!",
  5800. text: "系统异常,请稍后重试,或者联系管理员!",
  5801. type: "error"
  5802. });
  5803. }
  5804. })
  5805. $scope.removes = function () {
  5806. var modalInstance = $modal.open({
  5807. templateUrl: 'assets/views/delete.html',
  5808. controller: function ($scope, $modalInstance) {
  5809. $scope.ok = function () {
  5810. $modalInstance.close();
  5811. };
  5812. $scope.cancel = function () {
  5813. $modalInstance.dismiss('cancel');
  5814. };
  5815. },
  5816. size: 'sm'
  5817. });
  5818. modalInstance.result.then(function () {
  5819. console.log($scope.$parent.$parent.$parent.$parent)
  5820. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5821. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5822. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5823. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5824. break;
  5825. }
  5826. }
  5827. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5828. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5829. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5830. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5831. }
  5832. })
  5833. }
  5834. }]
  5835. });
  5836. //待处理事件列表
  5837. formlyConfigProvider.setType({
  5838. name: 'ui-ngtable',
  5839. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  5840. defaultOptions: function (options) {
  5841. return {
  5842. templateOptions: {
  5843. // relationAction: function() {
  5844. // options.hideExpression = true
  5845. // }
  5846. }
  5847. };
  5848. },
  5849. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5850. var filterData = {
  5851. "assignee": $rootScope.user.id,
  5852. "candidateGroups": $rootScope.user.group[0].id,
  5853. "searchtype": "done",
  5854. "idx": 0,
  5855. "sum": 10
  5856. };
  5857. $scope.incidentprocess = function (item) {
  5858. $state.go('app.incident.editor', {
  5859. taskId: item.taskId,
  5860. processInstanceId: item.processInstanceId
  5861. });
  5862. }
  5863. $scope.more = function () {
  5864. $state.go('app.incident.list', {})
  5865. }
  5866. api_bpm_domain.fetchtask('bpm_incident', filterData).then(function (data) {
  5867. if (data.data) {
  5868. $scope.myData = data.data;
  5869. } else {
  5870. SweetAlert.swal({
  5871. title: "操作异常!",
  5872. text: "系统异常,请稍后重试,或者联系管理员!",
  5873. type: "error"
  5874. });
  5875. }
  5876. })
  5877. $scope.removes = function () {
  5878. var modalInstance = $modal.open({
  5879. templateUrl: 'assets/views/delete.html',
  5880. controller: function ($scope, $modalInstance) {
  5881. $scope.ok = function () {
  5882. $modalInstance.close();
  5883. };
  5884. $scope.cancel = function () {
  5885. $modalInstance.dismiss('cancel');
  5886. };
  5887. },
  5888. size: 'sm'
  5889. });
  5890. modalInstance.result.then(function () {
  5891. console.log($scope.$parent.$parent.$parent.$parent)
  5892. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5893. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5894. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5895. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5896. break;
  5897. }
  5898. }
  5899. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5900. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5901. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5902. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5903. }
  5904. })
  5905. }
  5906. }]
  5907. });
  5908. //知识库列表
  5909. formlyConfigProvider.setType({
  5910. name: 'ui-knowledge',
  5911. templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
  5912. defaultOptions: function (options) {
  5913. return {
  5914. templateOptions: {
  5915. // relationAction: function() {
  5916. // options.hideExpression = true
  5917. // }
  5918. }
  5919. };
  5920. },
  5921. controller: ['$scope', '$modal', '$timeout', 'api_solution', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, api_solution, $rootScope, ngTableParams, $filter, $state) {
  5922. var filterData = {
  5923. "key": "null",
  5924. "pageIndex": 0,
  5925. "pageSum": 6,
  5926. "status": 0,
  5927. "userId": $rootScope.user.id
  5928. };
  5929. $scope.model.removereport = false;
  5930. $scope.removes = function () {
  5931. $scope.model.removereport = true;
  5932. }
  5933. $scope.more = function () {
  5934. $state.go('app.knowledge.manager', {});
  5935. }
  5936. api_solution.findSolutionByKeys(filterData).then(function (data) {
  5937. if (data.status == 200) {
  5938. $scope.myData = data.list
  5939. }
  5940. })
  5941. $scope.removes = function () {
  5942. var modalInstance = $modal.open({
  5943. templateUrl: 'assets/views/delete.html',
  5944. controller: function ($scope, $modalInstance) {
  5945. $scope.ok = function () {
  5946. $modalInstance.close();
  5947. };
  5948. $scope.cancel = function () {
  5949. $modalInstance.dismiss('cancel');
  5950. };
  5951. },
  5952. size: 'sm'
  5953. });
  5954. modalInstance.result.then(function () {
  5955. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5956. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5957. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5958. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5959. break;
  5960. }
  5961. }
  5962. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5963. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5964. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5965. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5966. }
  5967. })
  5968. }
  5969. }]
  5970. });
  5971. //公告列表
  5972. formlyConfigProvider.setType({
  5973. name: 'ui-ngnotice',
  5974. templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
  5975. defaultOptions: function (options) {
  5976. return {
  5977. templateOptions: {
  5978. // relationAction: function() {
  5979. // options.hideExpression = true
  5980. // }
  5981. }
  5982. };
  5983. },
  5984. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
  5985. var filterData = {
  5986. "idx": 0,
  5987. "sum": 10
  5988. };
  5989. // $scope.$scope.model.className = "col-xs-12";
  5990. api_user_data.fetchDataList('notice', filterData).then(function (data) {
  5991. if (data) {
  5992. $scope.myData = data.data;
  5993. } else {
  5994. SweetAlert.swal({
  5995. title: "操作异常!",
  5996. text: "系统异常,请稍后重试,或者联系管理员!",
  5997. type: "error"
  5998. });
  5999. }
  6000. })
  6001. $scope.more = function () {
  6002. $state.go('app.system.notice.list', {});
  6003. }
  6004. $scope.removes = function () {
  6005. var modalInstance = $modal.open({
  6006. templateUrl: 'assets/views/delete.html',
  6007. controller: function ($scope, $modalInstance) {
  6008. $scope.ok = function () {
  6009. $modalInstance.close();
  6010. };
  6011. $scope.cancel = function () {
  6012. $modalInstance.dismiss('cancel');
  6013. };
  6014. },
  6015. size: 'sm'
  6016. });
  6017. modalInstance.result.then(function () {
  6018. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6019. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6020. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6021. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6022. break;
  6023. }
  6024. }
  6025. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6026. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6027. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6028. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6029. }
  6030. })
  6031. }
  6032. }]
  6033. });
  6034. //事件统计图
  6035. formlyConfigProvider.setType({
  6036. name: 'ui-incidentreport',
  6037. templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
  6038. defaultOptions: function (options) {
  6039. return {
  6040. templateOptions: {
  6041. // relationAction: function() {
  6042. // options.hideExpression = true
  6043. // }
  6044. }
  6045. };
  6046. },
  6047. controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function ($scope, $modal, moment, api_report, $cookieStore) {
  6048. api_report.getLicenseKey().then(function (response) {
  6049. $cookieStore.put('Auth-Token', response.token);
  6050. $scope.try_async_load();
  6051. });
  6052. $scope.try_async_load = function () {
  6053. $scope.my_data = [];
  6054. api_report.list().then(function (response) {
  6055. var dataList = response;
  6056. getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
  6057. $scope.repoRoot.name = "事件报表"
  6058. convertRepoObject($scope.repoRoot);
  6059. $scope.my_data.push($scope.repoRoot);
  6060. });
  6061. };
  6062. var workspace = {};
  6063. $scope.repoRoot = null;
  6064. function getRepoRoot(repo, path) {
  6065. angular.forEach(repo, function (value, key) {
  6066. if (value.path == path) {
  6067. $scope.repoRoot = value;
  6068. } else {
  6069. if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
  6070. getRepoRoot(value.repoObjects, path);
  6071. } else {
  6072. }
  6073. }
  6074. });
  6075. }
  6076. function convertRepoObject(repo) {
  6077. if (angular.isArray(repo)) {
  6078. angular.forEach(repo, function (value, key) {
  6079. convertRepoObject(value);
  6080. })
  6081. } else {
  6082. if (angular.isDefined(repo.name)) {
  6083. if (repo.name.indexOf(".") >= 0) {
  6084. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  6085. } else {
  6086. repo.label = repo.name;
  6087. }
  6088. //delete repo.name;
  6089. }
  6090. if (angular.isDefined(repo.repoObjects)) {
  6091. repo.children = [];
  6092. repo.children = repo.repoObjects;
  6093. delete repo.repoObjects;
  6094. convertRepoObject(repo.children);
  6095. }
  6096. }
  6097. }
  6098. function parseDateParameter(parameters) {
  6099. var result = undefined;
  6100. if (angular.isArray(parameters)) {
  6101. // angular.forEach(parmeters,function(param){
  6102. // param.
  6103. // })
  6104. } else {
  6105. result = {};
  6106. for (var k in parameters) {
  6107. if (k.indexOf("Date") > 0) {
  6108. if (angular.isString(parameters[k])) {
  6109. result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
  6110. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  6111. }
  6112. }
  6113. }
  6114. }
  6115. return result;
  6116. }
  6117. function ConvertDateParameter(parameters) {
  6118. var result = undefined;
  6119. if (angular.isArray(parameters)) {
  6120. //
  6121. } else {
  6122. result = {};
  6123. for (var k in parameters) {
  6124. if (k.indexOf("Date") > 0) {
  6125. if (angular.isDate(parameters[k])) {
  6126. result[k] = moment(parameters[k]).format("YYYYMMDD");
  6127. } else if (angular.isString(parameters[k])) {
  6128. result[k] = parameters[k];
  6129. }
  6130. }
  6131. }
  6132. }
  6133. return result;
  6134. }
  6135. var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  6136. var queryUUID;
  6137. function genUUID() {
  6138. var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
  6139. function (c) {
  6140. var r = Math.random() * 16 | 0,
  6141. v = c == 'x' ? r : (r & 0x3 | 0x8);
  6142. return v.toString(16);
  6143. }).toUpperCase();
  6144. return uuid;
  6145. }
  6146. queryUUID = genUUID();
  6147. var pathincidenttimekey = [];
  6148. var incidenttime = {
  6149. 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
  6150. 'endtimes': moment(new Date()).format('YYYYMMDD')
  6151. };
  6152. var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
  6153. var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
  6154. var averages = [
  6155. [thisdaymine - 86400000 * 14, 0],
  6156. [thisdaymine - 86400000 * 13, 0],
  6157. [thisdaymine - 86400000 * 12, 0],
  6158. [thisdaymine - 86400000 * 11, 0],
  6159. [thisdaymine - 86400000 * 10, 0],
  6160. [thisdaymine - 86400000 * 9, 0],
  6161. [thisdaymine - 86400000 * 8, 0],
  6162. [thisdaymine - 86400000 * 7, 0],
  6163. [thisdaymine - 86400000 * 6, 0],
  6164. [thisdaymine - 86400000 * 5, 0],
  6165. [thisdaymine - 86400000 * 4, 0],
  6166. [thisdaymine - 86400000 * 3, 0],
  6167. [thisdaymine - 86400000 * 2, 0],
  6168. [thisdaymine - 86400000 * 1, 0],
  6169. [thisdaymine, 0]
  6170. ];
  6171. var getreportdata = function (incidenttime, path) {
  6172. api_report.getMdx(path, queryUUID).then(function (response) {
  6173. var mdxquery = response;
  6174. workspace.query = mdxquery;
  6175. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  6176. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  6177. $scope.parameters = parseDateParameter(workspace.query.parameters);
  6178. weekuser(mdxquery);
  6179. });
  6180. }
  6181. getreportdata(incidenttime, incidentchart);
  6182. var weekuser = function (mdxquery) {
  6183. var key = [];
  6184. api_report.execute(mdxquery).then(function (data) {
  6185. $scope.rheaders = [];
  6186. $scope.rRows = [];
  6187. var reportData = data;
  6188. if (reportData.cellset == null || reportData.cellset.length == 0) {
  6189. $scope.shows = true;
  6190. $scope.empty = "数据为空!"
  6191. } else {
  6192. angular.forEach(reportData.cellset, function (item, i) {
  6193. angular.forEach(averages, function (index, j) {
  6194. // angular.forEach(averages, function(item, index) {
  6195. if (item.length > 1 && i > 0 && item[1].value != '') {
  6196. if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
  6197. index[1] = Number(item[1].value);
  6198. }
  6199. // 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)]);
  6200. }
  6201. // })
  6202. })
  6203. })
  6204. incidentchartfun(averages);
  6205. }
  6206. })
  6207. }
  6208. var incidentchartfun = function (incidentchartkey) {
  6209. // $scope.isMaskincident = false;
  6210. Highcharts.chart('incidentchart', {
  6211. title: {
  6212. text: '事件近15天趋势图'
  6213. },
  6214. xAxis: {
  6215. type: 'datetime',
  6216. labels: {
  6217. align: 'left',
  6218. step: 1
  6219. }
  6220. },
  6221. yAxis: {
  6222. title: {
  6223. text: null
  6224. }
  6225. },
  6226. tooltip: {
  6227. crosshairs: true,
  6228. shared: true,
  6229. valueSuffix: '条'
  6230. },
  6231. legend: {},
  6232. series: [{
  6233. name: '生成事件',
  6234. data: incidentchartkey,
  6235. zIndex: 1,
  6236. marker: {
  6237. fillColor: 'white',
  6238. lineWidth: 2,
  6239. lineColor: Highcharts.getOptions().colors[0]
  6240. }
  6241. }]
  6242. });
  6243. }
  6244. $scope.data = {
  6245. labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
  6246. datasets: [{
  6247. label: '新增事件数量',
  6248. fillColor: 'rgba(220,220,220,0.2)',
  6249. strokeColor: 'rgba(220,220,220,1)',
  6250. pointColor: 'rgba(220,220,220,1)',
  6251. pointStrokeColor: '#fff',
  6252. pointHighlightFill: '#fff',
  6253. pointHighlightStroke: 'rgba(220,220,220,1)',
  6254. data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
  6255. },
  6256. {
  6257. label: '已解决事件数量',
  6258. fillColor: 'rgba(151,187,205,0.2)',
  6259. strokeColor: 'rgba(151,187,205,1)',
  6260. pointColor: 'rgba(151,187,205,1)',
  6261. pointStrokeColor: '#fff',
  6262. pointHighlightFill: '#fff',
  6263. pointHighlightStroke: 'rgba(151,187,205,1)',
  6264. data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
  6265. }
  6266. ]
  6267. };
  6268. $scope.removes = function () {
  6269. var modalInstance = $modal.open({
  6270. templateUrl: 'assets/views/delete.html',
  6271. controller: function ($scope, $modalInstance) {
  6272. $scope.ok = function () {
  6273. $modalInstance.close();
  6274. };
  6275. $scope.cancel = function () {
  6276. $modalInstance.dismiss('cancel');
  6277. };
  6278. },
  6279. size: 'sm'
  6280. });
  6281. modalInstance.result.then(function () {
  6282. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6283. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6284. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6285. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6286. break;
  6287. }
  6288. }
  6289. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6290. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6291. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6292. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6293. }
  6294. })
  6295. }
  6296. var addDatas = 0;
  6297. var resolve = 0;
  6298. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  6299. addDatas = addDatas + $scope.data.datasets[0].data[i];
  6300. }
  6301. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  6302. resolve = resolve + $scope.data.datasets[1].data[i];
  6303. }
  6304. $scope.resolution = (resolve / addDatas * 100).toFixed(2);
  6305. $scope.opt = {
  6306. maintainAspectRatio: false,
  6307. // Sets the chart to be responsive
  6308. responsive: true,
  6309. ///Boolean - Whether grid lines are shown across the chart
  6310. scaleShowGridLines: true,
  6311. //String - Colour of the grid lines
  6312. scaleGridLineColor: 'rgba(0,0,0,.05)',
  6313. //Number - Width of the grid lines
  6314. scaleGridLineWidth: 1,
  6315. //Boolean - Whether the line is curved between points
  6316. bezierCurve: false,
  6317. //Number - Tension of the bezier curve between points
  6318. bezierCurveTension: 0.4,
  6319. //Boolean - Whether to show a dot for each point
  6320. pointDot: true,
  6321. //Number - Radius of each point dot in pixels
  6322. pointDotRadius: 4,
  6323. //Number - Pixel width of point dot stroke
  6324. pointDotStrokeWidth: 1,
  6325. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  6326. pointHitDetectionRadius: 20,
  6327. //Boolean - Whether to show a stroke for datasets
  6328. datasetStroke: true,
  6329. //Number - Pixel width of dataset stroke
  6330. datasetStrokeWidth: 2,
  6331. //Boolean - Whether to fill the dataset with a colour
  6332. datasetFill: true,
  6333. // Function - on animation progress
  6334. onAnimationProgress: function () {},
  6335. // Function - on animation complete
  6336. onAnimationComplete: function () {},
  6337. //String - A legend template
  6338. legendTemplate: '<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>'
  6339. };
  6340. angular.extend($scope.options, $scope.opt)
  6341. $scope.datamonth = {
  6342. labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
  6343. datasets: [{
  6344. label: '新增事件数量',
  6345. fillColor: 'rgba(220,220,220,0.5)',
  6346. strokeColor: 'rgba(220,220,220,0.8)',
  6347. highlightFill: 'rgba(220,220,220,0.75)',
  6348. highlightStroke: 'rgba(220,220,220,1)',
  6349. data: [65, 59, 80, 81, 56, 55]
  6350. },
  6351. {
  6352. label: '已解决事件数量',
  6353. fillColor: 'rgba(151,187,205,0.5)',
  6354. strokeColor: 'rgba(151,187,205,0.8)',
  6355. highlightFill: 'rgba(151,187,205,0.75)',
  6356. highlightStroke: 'rgba(151,187,205,1)',
  6357. data: [28, 48, 40, 19, 86, 27]
  6358. }
  6359. ]
  6360. };
  6361. // Chart.js Options
  6362. $scope.taption = {
  6363. maintainAspectRatio: false,
  6364. // Sets the chart to be responsive
  6365. responsive: true,
  6366. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  6367. scaleBeginAtZero: true,
  6368. //Boolean - Whether grid lines are shown across the chart
  6369. scaleShowGridLines: true,
  6370. //String - Colour of the grid lines
  6371. scaleGridLineColor: "rgba(0,0,0,.05)",
  6372. //Number - Width of the grid lines
  6373. scaleGridLineWidth: 1,
  6374. //Boolean - If there is a stroke on each bar
  6375. barShowStroke: true,
  6376. //Number - Pixel width of the bar stroke
  6377. barStrokeWidth: 2,
  6378. //Number - Spacing between each of the X value sets
  6379. barValueSpacing: 5,
  6380. //Number - Spacing between data sets within X values
  6381. barDatasetSpacing: 1,
  6382. //String - A legend template
  6383. legendTemplate: '<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>'
  6384. };
  6385. }]
  6386. });
  6387. //排版日历
  6388. formlyConfigProvider.setType({
  6389. name: 'ui-dashcalendar',
  6390. templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
  6391. defaultOptions: function (options) {
  6392. return {
  6393. templateOptions: {
  6394. // relationAction: function() {
  6395. // options.hideExpression = true
  6396. // }
  6397. }
  6398. };
  6399. },
  6400. controller: ["$rootScope", "$scope", "$modal", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", "$state", function ($rootScope, $scope, $modal, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data, $state) {
  6401. var loginUser = $rootScope.user;
  6402. calendarConfig.dateFormatter = 'moment';
  6403. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  6404. calendarConfig.i18nStrings.timeLabel = '时间';
  6405. calendarConfig.i18nStrings.weekNumber = '{week}周';
  6406. calendarConfig.allDateFormats = {
  6407. angular: {
  6408. date: {
  6409. hour: 'ha',
  6410. day: 'd MMM',
  6411. month: 'MMMM',
  6412. weekDay: 'EEEE',
  6413. time: 'HH:mm',
  6414. datetime: 'MMM d, h:mm a'
  6415. },
  6416. title: {
  6417. day: 'yyyy MMMM EEEE d',
  6418. week: '{year}年第{week}周',
  6419. month: 'yyyy MMMM',
  6420. year: 'yyyy'
  6421. }
  6422. },
  6423. moment: {
  6424. date: {
  6425. hour: 'ha',
  6426. day: 'MMMDD日',
  6427. month: 'MMMM',
  6428. weekDay: 'dddd',
  6429. time: 'HH:mm',
  6430. datetime: 'MMM D, h:mm a'
  6431. },
  6432. title: {
  6433. day: 'YYYY年MMMMDD日, dddd ',
  6434. week: '{year}年第{week}周',
  6435. month: 'YYYY年MMMM',
  6436. year: 'YYYY'
  6437. }
  6438. }
  6439. };
  6440. moment.locale('zh_cn', {
  6441. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  6442. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  6443. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6444. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6445. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6446. longDateFormat: {
  6447. LT: 'Ah点mm分',
  6448. LTS: 'Ah点m分s秒',
  6449. L: 'YYYY-MM-DD',
  6450. LL: 'YYYY年MMMD日',
  6451. LLL: 'YYYY年MMMD日Ah点mm分',
  6452. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  6453. l: 'YYYY-MM-DD',
  6454. ll: 'YYYY年MMMD日',
  6455. lll: 'YYYY年MMMD日Ah点mm分',
  6456. llll: 'YYYY年MMMD日ddddAh点mm分'
  6457. },
  6458. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6459. meridiemHour: function (hour, meridiem) {
  6460. if (hour === 12) {
  6461. hour = 0;
  6462. }
  6463. if (meridiem === '凌晨' || meridiem === '早上' ||
  6464. meridiem === '上午') {
  6465. return hour;
  6466. } else if (meridiem === '下午' || meridiem === '晚上') {
  6467. return hour + 12;
  6468. } else {
  6469. // '中午'
  6470. return hour >= 11 ? hour : hour + 12;
  6471. }
  6472. },
  6473. meridiem: function (hour, minute, isLower) {
  6474. var hm = hour * 100 + minute;
  6475. if (hm < 600) {
  6476. return '凌晨';
  6477. } else if (hm < 900) {
  6478. return '早上';
  6479. } else if (hm < 1130) {
  6480. return '上午';
  6481. } else if (hm < 1230) {
  6482. return '中午';
  6483. } else if (hm < 1800) {
  6484. return '下午';
  6485. } else {
  6486. return '晚上';
  6487. }
  6488. },
  6489. calendar: {
  6490. sameDay: function () {
  6491. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  6492. },
  6493. nextDay: function () {
  6494. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  6495. },
  6496. lastDay: function () {
  6497. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  6498. },
  6499. nextWeek: function () {
  6500. var startOfWeek, prefix;
  6501. startOfWeek = moment().startOf('week');
  6502. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  6503. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6504. },
  6505. lastWeek: function () {
  6506. var startOfWeek, prefix;
  6507. startOfWeek = moment().startOf('week');
  6508. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  6509. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6510. },
  6511. sameElse: 'LL'
  6512. },
  6513. ordinalParse: /\d{1,2}(日|月|周)/,
  6514. ordinal: function (number, period) {
  6515. switch (period) {
  6516. case 'd':
  6517. case 'D':
  6518. case 'DDD':
  6519. return number + '日';
  6520. case 'M':
  6521. return number + '月';
  6522. case 'w':
  6523. case 'W':
  6524. return number + '周';
  6525. default:
  6526. return number;
  6527. }
  6528. },
  6529. relativeTime: {
  6530. future: '%s内',
  6531. past: '%s前',
  6532. s: '几秒',
  6533. m: '1 分钟',
  6534. mm: '%d 分钟',
  6535. h: '1 小时',
  6536. hh: '%d 小时',
  6537. d: '1 天',
  6538. dd: '%d 天',
  6539. M: '1 个月',
  6540. MM: '%d 个月',
  6541. y: '1 年',
  6542. yy: '%d 年'
  6543. },
  6544. week: {
  6545. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6546. dow: 1, // Monday is the first day of the week.
  6547. doy: 4 // The week that contains Jan 4th is the first week of the year.
  6548. }
  6549. });
  6550. var date = new Date();
  6551. var d = date.getDate();
  6552. var m = date.getMonth();
  6553. var y = date.getFullYear();
  6554. var filterData = {
  6555. "userId": loginUser.id,
  6556. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  6557. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  6558. };
  6559. var load = $scope.load = function (filterData) {
  6560. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function (response) {
  6561. if (response.status == 200) {
  6562. $scope.events = [];
  6563. var myData = response.list;
  6564. angular.forEach(myData, function (item) {
  6565. var eventTemp = {};
  6566. eventTemp.title = item.description;
  6567. eventTemp.type = item.scheduleClass.code;
  6568. eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
  6569. eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
  6570. eventTemp.startTime = item['scheduleOrderDTO'].startTime;
  6571. eventTemp.endTime = item['scheduleOrderDTO'].endTime;
  6572. //eventTemp.ends_at = moment(item.endTime).toDate();
  6573. eventTemp.id = item.id;
  6574. eventTemp.deletable = false;
  6575. eventTemp.user = item.user;
  6576. $scope.events.push(eventTemp);
  6577. })
  6578. }
  6579. });
  6580. }
  6581. // var load = $scope.load = function(filterData){
  6582. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  6583. // console.log("response="+JSON.stringify(response));
  6584. // if(response.status==200){
  6585. // $scope.events = [];
  6586. // console.log(response.list);
  6587. // var myData = response.list;
  6588. // angular.forEach(myData,function(item){
  6589. // var eventTemp = {};
  6590. // eventTemp.title = item.description;
  6591. // eventTemp.type = item.scheduleClass.code;
  6592. // eventTemp.startsAt = moment(item.startTime).toDate();
  6593. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  6594. // eventTemp.startTime = item.startTime;
  6595. // eventTemp.endTime = item.endTime;
  6596. // //eventTemp.ends_at = moment(item.endTime).toDate();
  6597. // eventTemp.id = item.id;
  6598. // eventTemp.deletable = false;
  6599. // eventTemp.users = item.users;
  6600. // $scope.events.push(eventTemp);
  6601. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  6602. // })
  6603. // }
  6604. // });
  6605. // }
  6606. $scope.scheduleClass = {};
  6607. var convertEvent = function (scheduleorder) {
  6608. var eventTemp = {};
  6609. eventTemp.title = scheduleorder.description;
  6610. eventTemp.type = scheduleorder.scheduleClass.code;
  6611. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  6612. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  6613. eventTemp.id = scheduleorder.id;
  6614. eventTemp.user = scheduleorder.user;
  6615. eventTemp.deletable = false;
  6616. return eventTemp;
  6617. }
  6618. // var convertEvent = function(scheduleorder){
  6619. // var eventTemp = {};
  6620. // eventTemp.title = scheduleorder.description;
  6621. // eventTemp.type = scheduleorder.scheduleClass.code;
  6622. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  6623. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  6624. // eventTemp.id = scheduleorder.id;
  6625. // eventTemp.users = scheduleorder.users;
  6626. // eventTemp.deletable = false;
  6627. // return eventTemp;
  6628. // }
  6629. api_bpm_schedule.getScheduleClass().then(function (response) {
  6630. if (response.status == 200) {
  6631. var scheduleClassList = response.list;
  6632. angular.forEach(scheduleClassList, function (item) {
  6633. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  6634. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  6635. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  6636. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  6637. $scope.scheduleClass[item['code']] = item;
  6638. })
  6639. }
  6640. })
  6641. $scope.events = [];
  6642. $scope.calendarView = 'month';
  6643. //$scope.calendarDay = new Date();
  6644. $scope.calendarDate = moment().startOf('month').toDate();
  6645. $scope.timeLabel = "时间";
  6646. $scope.eventLabel = "描述";
  6647. function showModal(action, event) {
  6648. // console.log("action="+JSON.stringify(action))
  6649. var modalInstance = $aside.open({
  6650. templateUrl: 'scheduleEvent.html',
  6651. placement: 'right',
  6652. size: 'sm',
  6653. backdrop: true,
  6654. controller: function ($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  6655. $scope.$modalInstance = $modalInstance;
  6656. $scope.action = action;
  6657. $scope.event = event;
  6658. $scope.scheduleClassic = scheduleClass;
  6659. $scope.$watch('event.type', function (newvalue, oldvalue) {
  6660. // if(oldvalue == newvalue) return;
  6661. // if(scheduleClass[newvalue]){
  6662. var sm = MementFormat(scheduleClass[newvalue].startTime);
  6663. var em = MementFormat(scheduleClass[newvalue].endTime);
  6664. console.log("sm=" + JSON.stringify(sm))
  6665. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  6666. console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  6667. if (sm.hour() > em.hour()) {
  6668. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6669. console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  6670. } else {
  6671. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6672. console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  6673. }
  6674. // }
  6675. });
  6676. // $scope.ok = function (event) {
  6677. // console.log("event="+JSON.stringify(event))
  6678. // event.action = action;
  6679. // $modalInstance.close(event);
  6680. // };
  6681. $scope.cancel = function (event) {
  6682. $modalInstance.dismiss();
  6683. };
  6684. var acUserSelect = $scope.refreshUser = function (key) {
  6685. //for test
  6686. // $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":"管理层"}]}];
  6687. // return;
  6688. var data = {
  6689. "idx": "0",
  6690. "sum": "5"
  6691. };
  6692. if (key) {
  6693. data['user'] = {
  6694. 'name': key
  6695. };
  6696. }
  6697. APIService.fetchDataList('user', data).then(function (response) {
  6698. if (response) {
  6699. if (response.status = 200) {
  6700. $scope.users = response.list;
  6701. console.log($scope.users);
  6702. }
  6703. }
  6704. })
  6705. };
  6706. if (angular.isDefined(event.users) && event.users.length > 0) {
  6707. }
  6708. $scope.users = [event.user];
  6709. acUserSelect();
  6710. },
  6711. resolve: {
  6712. scheduleClass: function () {
  6713. return $scope.scheduleClass;
  6714. },
  6715. APIService: function () {
  6716. return api_user_data;
  6717. },
  6718. MementFormat: function () {
  6719. return moment;
  6720. }
  6721. }
  6722. });
  6723. modalInstance.result.then(function (selectedEvent) {
  6724. if (selectedEvent.action == 'Clicked') {
  6725. // var data = {
  6726. // "scheduleorder":{
  6727. // "id":selectedEvent.id,
  6728. // "description":selectedEvent.title,
  6729. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  6730. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  6731. // "users":selectedEvent.users,
  6732. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  6733. // }
  6734. // };
  6735. // api_bpm_schedule.update(data).then(function(response){
  6736. // if(response.status==200){
  6737. // SweetAlert.swal({
  6738. // title: "操作成功!",
  6739. // text: "排班更新成功!",
  6740. // type: "succes"
  6741. // });
  6742. // angular.forEach($scope.events,function(item){
  6743. // if(item.id==selectedEvent.id){
  6744. // item = selectedEvent;
  6745. // }
  6746. // })
  6747. // }else{
  6748. // SweetAlert.swal({
  6749. // title: "操作失败",
  6750. // text: "排班更新失败,请稍后重试!",
  6751. // type: "error"
  6752. // })
  6753. // }
  6754. // })
  6755. } else {
  6756. //
  6757. }
  6758. });
  6759. }
  6760. $scope.moment = function (string) {
  6761. return moment(string);
  6762. }
  6763. $scope.eventClicked = function (event) {
  6764. // console.log("event="+JSON.stringify(event))
  6765. showModal('Clicked', event);
  6766. };
  6767. $scope.eventEdited = function (event) {
  6768. showModal('Edited', event);
  6769. };
  6770. var updateView = function (newvalue, oldvalue) {
  6771. if (oldvalue == newvalue) return;
  6772. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  6773. if ($scope.calendarView == "year") {
  6774. } else if ($scope.calendarView == "month") {
  6775. timeStart = moment(newvalue).startOf('month');
  6776. timeEnd = moment(newvalue).endOf('month');
  6777. } else if ($scope.calendarView == "week") {
  6778. timeStart = moment(newvalue).startOf('week');
  6779. timeEnd = moment(newvalue).endOf('week');
  6780. } else if ($scope.calendarView == "Day") {
  6781. timeStart = moment(newvalue).startOf('day');
  6782. timeEnd = moment(newvalue).endOf('day');
  6783. }
  6784. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  6785. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  6786. filterData["startTime"] = timeStartSpan;
  6787. filterData["endTime"] = timeEndSpan;
  6788. load(filterData);
  6789. }
  6790. $scope.$watch('calendarDate', updateView)
  6791. $scope.next = function () {
  6792. $scope.calendarControl.next();
  6793. }
  6794. $scope.prev = function () {
  6795. $scope.calendarControl.prev();
  6796. }
  6797. $scope.setCalendarToToday = function () {
  6798. $scope.calendarDay = new Date();
  6799. };
  6800. $scope.toggle = function ($event, field, event) {
  6801. $event.preventDefault();
  6802. $event.stopPropagation();
  6803. event[field] = !event[field];
  6804. };
  6805. $scope.load(filterData);
  6806. $scope.more = function () {
  6807. $state.go('app.scheduling.myscheduling', {});
  6808. }
  6809. $scope.removes = function () {
  6810. var modalInstance = $modal.open({
  6811. templateUrl: 'assets/views/delete.html',
  6812. controller: function ($scope, $modalInstance) {
  6813. $scope.ok = function () {
  6814. $modalInstance.close();
  6815. };
  6816. $scope.cancel = function () {
  6817. $modalInstance.dismiss('cancel');
  6818. };
  6819. },
  6820. size: 'sm'
  6821. });
  6822. modalInstance.result.then(function () {
  6823. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6824. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6825. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6826. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6827. break;
  6828. }
  6829. }
  6830. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6831. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6832. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6833. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6834. }
  6835. })
  6836. }
  6837. }]
  6838. });
  6839. //空格组件
  6840. formlyConfigProvider.setType({
  6841. name: 'ui-black',
  6842. /*extends: 'input',*/
  6843. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  6844. });
  6845. //请求人最近事件
  6846. formlyConfigProvider.setType({
  6847. name: 'ui-recentIncident',
  6848. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  6849. controller: ['$scope', '$modal', 'api_solution', function ($scope, $modal, api_solution) {
  6850. var filterData = {
  6851. 'incident': {
  6852. 'requester': {
  6853. 'id': ''
  6854. }
  6855. },
  6856. idx: 0,
  6857. sum: 3
  6858. };
  6859. setInterval(function () {
  6860. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  6861. var requester = $scope.model.requester;
  6862. if (requester != null && angular.isDefined(requester.id)) {
  6863. filterData.incident.requester.id = $scope.model.requester.id;
  6864. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  6865. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  6866. if (modelData.status == 200) {
  6867. $scope.lastrequst = modelData.list;
  6868. }
  6869. });
  6870. requester = null
  6871. } else {}
  6872. } else {}
  6873. }, 1000);
  6874. $scope.detail = function (data) {
  6875. var modalInstance = $modal.open({
  6876. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  6877. controller: function ($scope, $modalInstance) {
  6878. $scope.entity = {};
  6879. $scope.entity = data;
  6880. $scope.cancel = function () {
  6881. $modalInstance.dismiss('cancel');
  6882. };
  6883. },
  6884. size: 'lg',
  6885. });
  6886. }
  6887. }]
  6888. });
  6889. //参数列表
  6890. formlyConfigProvider.setType({
  6891. name: "ui-listinput",
  6892. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  6893. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6894. defaultOptions: function (options) {
  6895. return {
  6896. templateOptions: {}
  6897. };
  6898. },
  6899. controller: ['$scope', function ($scope) {
  6900. }]
  6901. });
  6902. //时间段控件(分)
  6903. formlyConfigProvider.setType({
  6904. name: 'ui-timeslot',
  6905. extends: 'input',
  6906. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6907. controller: ['$scope', function ($scope) {}]
  6908. });
  6909. //优先级级联-逾期时间
  6910. formlyConfigProvider.setType({
  6911. name: 'ui-overtime',
  6912. extends: 'input',
  6913. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  6914. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  6915. var filteData = {};
  6916. var datas = {}
  6917. setInterval(function () {
  6918. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  6919. filteData = "L" + $scope.model.priority.id;
  6920. datas = $scope.model.priority.id;
  6921. // console.log($scope.options.templateOptions)
  6922. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  6923. // var overtime=requester.date;
  6924. if (requester.state == 200) {
  6925. // if($scope.options.key=="date"){
  6926. $scope.model[$scope.options.key] = requester.date
  6927. // }
  6928. }
  6929. })
  6930. }
  6931. }, 1000);
  6932. }]
  6933. });
  6934. formlyConfigProvider.setType({
  6935. name: 'ui-responsetime',
  6936. extends: 'input',
  6937. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6938. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  6939. var filteData = {};
  6940. var datas = {}
  6941. setInterval(function () {
  6942. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  6943. filteData = "L" + $scope.model.priority.id;
  6944. datas = $scope.model.priority.id;
  6945. // console.log($scope.options.templateOptions)
  6946. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  6947. // var overtime=requester.date;
  6948. if (requester.state == 200) {
  6949. var keyName = {};
  6950. // $scope.model.overdueTime = requester.date;
  6951. if ($scope.options.key == "expectIntroTime") {
  6952. keyName = "resolveTime";
  6953. } else if ($scope.options.key == "expectResponseTime") {
  6954. keyName = "responseTime";
  6955. }
  6956. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  6957. // }
  6958. console.log($scope.$parent.$parent.$parent.model)
  6959. }
  6960. if (requester.date1) {
  6961. $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
  6962. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
  6963. $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
  6964. $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
  6965. }
  6966. })
  6967. }
  6968. }, 1000);
  6969. }]
  6970. });
  6971. //知识库按钮组件
  6972. formlyConfigProvider.setType({
  6973. name: 'ui-discasecade',
  6974. extends: 'input',
  6975. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  6976. defaultOptions: function (options) {
  6977. return {
  6978. templateOptions: {
  6979. relationAction: function (fields, modelscope, item) {}
  6980. },
  6981. validators: {
  6982. required: {
  6983. expression: function (viewValue, modelValue) {
  6984. var value = modelValue || viewValue;
  6985. // return value = "true";
  6986. }
  6987. }
  6988. }
  6989. }
  6990. },
  6991. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk','api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk,api_bpm_domain) {
  6992. // $scope.options.initialValue = $scope.model[$scope.options.key];
  6993. $scope.searchField = $scope.options.model[$scope.options.key];
  6994. $scope.searchData = "";
  6995. $scope.onChangeadd = function (searchData) {
  6996. $scope.searchKey = searchData.account;
  6997. // $scope.searchDataadd = searchData;
  6998. var requesdata = angular.copy(searchData)
  6999. $scope.requester = requesdata;
  7000. }
  7001. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7002. $scope.searchData = searchKey;
  7003. reashdata($scope.searchData);
  7004. }
  7005. $scope.getMydata = function (x) {
  7006. $scope.model[$scope.options.key] = JSON.parse(x).title;
  7007. $scope.searchField = $scope.model[$scope.options.key];
  7008. }
  7009. $scope.getMydataone = function (x) {
  7010. $scope.model[$scope.options.key] = x;
  7011. $scope.searchField = $scope.model[$scope.options.key];
  7012. }
  7013. $scope.fildata = {
  7014. "idx": 0,
  7015. "sum": 10
  7016. // 'incident': { 'tilte': item }
  7017. }
  7018. function reashdata(item) {
  7019. if (item && item != "") {
  7020. angular.extend($scope.fildata, {
  7021. 'incident': {
  7022. 'title': item
  7023. }
  7024. })
  7025. } else {
  7026. delete $scope.fildata.incident;
  7027. }
  7028. api_bpm_data.fetchDataList('incident', $scope.fildata).then(function (response) {
  7029. if (response) {
  7030. if (response.status = 200) {
  7031. var myData = response;
  7032. $scope.myData = myData.list;
  7033. }
  7034. }
  7035. })
  7036. }
  7037. function delHtmlTag(str) {
  7038. return str.replace(/<[^>]+>/g, "");
  7039. }
  7040. reashdata();
  7041. var changedata = {};
  7042. setInterval(function () {
  7043. if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
  7044. $scope.searchData = {};
  7045. changedata = angular.copy($scope.model.category);
  7046. if ($scope.options.key == "title") {
  7047. var filterData = {
  7048. "idx": 0,
  7049. "sum": 1000
  7050. };
  7051. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function (data) {
  7052. var datalist = data.list;
  7053. angular.forEach(datalist, function (item) {
  7054. if (item.id == $scope.model.category.id) {
  7055. $scope.model[$scope.options.key] = item.category;
  7056. $scope.searchField = $scope.options.model[$scope.options.key];
  7057. $scope.titles = item.category;
  7058. // }
  7059. // })
  7060. // })
  7061. // }
  7062. titles = $scope.model.category;
  7063. }
  7064. })
  7065. })
  7066. }
  7067. }
  7068. }, 1000);
  7069. $scope.open = function (key, options, fildata, $event, model) {
  7070. if (key && key.length > 1) {
  7071. api_zsk.solutionData({
  7072. "solution": {
  7073. "searchWord": key
  7074. },
  7075. "idx": "0",
  7076. "sum": "1000"
  7077. }, 'solution').then(function (response) {
  7078. if (response && response.list.length > 0) {
  7079. $scope.dlideboxslide = true
  7080. angular.forEach(response, function (item) {
  7081. console.log(response)
  7082. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  7083. // if (response.status == 200) {
  7084. // var quote = { 'totalNum': response.totalNum }
  7085. // item = angular.extend(item, quote)
  7086. // }
  7087. // })
  7088. $scope.searchData = response.list;
  7089. console.log($scope.searchData)
  7090. })
  7091. $scope.changes = false;
  7092. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  7093. // $scope.closepages = function(e) {
  7094. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  7095. // event.preventDefault();
  7096. // };
  7097. $scope.shows = false;
  7098. $scope.tempData = {};
  7099. $scope.showpage = function (item) {
  7100. item.content = delHtmlTag(item.content);
  7101. $scope.shows = true;
  7102. $scope.tempData = item;
  7103. if (item.content != null) {
  7104. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  7105. }
  7106. $scope.knowledgedata = item;
  7107. $scope.pageid = item.id;
  7108. $scope.changes = !$scope.changes;
  7109. api_bpm_domain.listAttachments(item.id)
  7110. // api_solution.fetchDataList('file', {
  7111. // "file": {
  7112. // "solutionId": item.id
  7113. // },
  7114. // "idx": "0",
  7115. // "sum": "1000"
  7116. // })
  7117. .then(function (data) {
  7118. if (data) {
  7119. $scope.attachments = data.list;
  7120. $scope.view = function (attachmentId) {
  7121. for (var i = 0; i < $scope.attachments.length; i++) {
  7122. if ($scope.attachments[i].id == attachmentId) {
  7123. window.open($scope.attachments[i].previewUrl);
  7124. }
  7125. }
  7126. };
  7127. $scope.download = function (contentId, filename) {
  7128. api_solution.getSolutionDowpath(contentId).then(function (response) {
  7129. var file = new Blob([response], {
  7130. type: 'application/octet-stream'
  7131. });
  7132. // var filename = filename;
  7133. var fileURL = URL.createObjectURL(file);
  7134. var a = document.createElement('a');
  7135. a.href = fileURL;
  7136. a.target = '_blank';
  7137. a.download = filename;
  7138. document.body.appendChild(a);
  7139. a.click();
  7140. })
  7141. };
  7142. }
  7143. })
  7144. }
  7145. $scope.related = function (item) {
  7146. if (item.content != null) {
  7147. item.content = item.content.replace("<p>", "").replace("</p>", "")
  7148. }
  7149. // fildata.$parent.$parent.$parent.model.directClose = 0;
  7150. options.model.handleDescription = item.content;
  7151. var data = {
  7152. 'solutionQuote': {
  7153. 'solutionId': item.id,
  7154. 'incidentsign': options.model.incidentsign
  7155. }
  7156. };
  7157. api_zsk.solutionQuote(item.id).then(function (response) {
  7158. if (response.status == 200) {
  7159. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7160. } else {
  7161. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7162. };
  7163. })
  7164. }
  7165. $scope.close = function () {
  7166. $scope.changes = !$scope.changes;
  7167. event.preventDefault();
  7168. }
  7169. } else {
  7170. SweetAlert.swal("没有可引用的知识");
  7171. }
  7172. });
  7173. }
  7174. };
  7175. }]
  7176. });
  7177. //下拉输入组件
  7178. formlyConfigProvider.setType({
  7179. name: 'ui-selectinput',
  7180. extends: 'input',
  7181. templateUrl: 'assets/views/customform/tpl/selectinput.html',
  7182. defaultOptions: function (options) {
  7183. return {
  7184. templateOptions: {
  7185. refresh: function () {},
  7186. refreshDelay: 0,
  7187. linkage: function (modelName, data) {
  7188. }
  7189. },
  7190. }
  7191. },
  7192. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  7193. $scope.searchData = "";
  7194. $scope.onChangeadd = function (searchData) {
  7195. // $scope.searchKey = searchData.account;
  7196. // var requesdata = angular.copy(searchData)
  7197. // $scope.requester = requesdata;
  7198. }
  7199. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7200. // $scope.searchData = searchKey;
  7201. // reashdata($scope.searchData);
  7202. }
  7203. $scope.getMydata = function (x) {
  7204. $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
  7205. $scope.searchField = $scope.model[$scope.options.key];
  7206. }
  7207. $scope.getMydataone = function (x) {
  7208. $scope.model[$scope.options.key] = x;
  7209. $scope.searchField = $scope.model[$scope.options.key];
  7210. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
  7211. $scope.hidden = false;
  7212. } else {
  7213. $scope.hidden = true;
  7214. }
  7215. }
  7216. function reashdata(item) {
  7217. $scope.myData = $scope.options.templateOptions.mydata;
  7218. }
  7219. reashdata()
  7220. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  7221. $scope.options.templateOptions.fetchItems($scope);
  7222. }
  7223. }]
  7224. });
  7225. //重构组件模板
  7226. //获取当前人
  7227. formlyConfigProvider.setType({
  7228. name: 'ui-users',
  7229. extends: 'input',
  7230. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7231. defaultOptions: function (options) {
  7232. return {
  7233. templateOptions: {
  7234. translate: '',
  7235. refreshDelay: 0
  7236. }
  7237. }
  7238. },
  7239. controller: ['$scope', function ($scope) {
  7240. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  7241. $scope.options.templateOptions.translate = $scope.$root.user.name;
  7242. }]
  7243. });
  7244. //只读控件
  7245. formlyConfigProvider.setType({
  7246. name: 'ui-label',
  7247. extends: 'input',
  7248. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7249. defaultOptions: function (options) {
  7250. return {
  7251. templateOptions: {
  7252. translate: '',
  7253. refreshDelay: 0
  7254. }
  7255. }
  7256. },
  7257. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  7258. // console.log($scope.options.templateOptions)
  7259. var value = $scope.model[$scope.options.key];
  7260. function treeDesc(children, key, label) {
  7261. if (label == "") {
  7262. label = children[key];
  7263. } else {
  7264. label = children[key] + "-" + label;
  7265. }
  7266. if (angular.isDefined(children.parent)) {
  7267. treeDesc(children.parent, key, label);
  7268. } else {
  7269. return label;
  7270. }
  7271. }
  7272. if (angular.isArray(value)) {
  7273. var tempValue = "";
  7274. angular.forEach(value, function (item) {
  7275. if (tempValue != "") {
  7276. tempValue = tempValue + ",";
  7277. }
  7278. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  7279. });
  7280. $scope.options.templateOptions.translate = tempValue;
  7281. } else if (angular.isObject(value)) {
  7282. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  7283. //tree
  7284. // console.log("value.parent="+JSON.stringify(value.parent))
  7285. var nameLabel = value[$scope.options.templateOptions.labelProp];
  7286. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  7287. $scope.options.templateOptions.translate = nameLabel;
  7288. } else {
  7289. $scope.options.templateOptions.translate = value;
  7290. }
  7291. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  7292. // console.log("value=" + value);
  7293. $scope.options.templateOptions.translate = value;
  7294. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  7295. // console.log("value="+value);
  7296. // $scope.options.templateOptions.translate = value;
  7297. } else {
  7298. // var datasdf = JSON.parse(value);
  7299. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  7300. $scope.options.templateOptions.translate = value;
  7301. }
  7302. if (angular.isFunction($scope.options.templateOptions.transform)) {
  7303. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  7304. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
  7305. }
  7306. }]
  7307. });
  7308. //小标题组件
  7309. formlyConfigProvider.setType({
  7310. name: 'ui-header',
  7311. template: '<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>'
  7312. });
  7313. //标题组件
  7314. formlyConfigProvider.setType({
  7315. name: 'ui-title',
  7316. template: '<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>'
  7317. });
  7318. //标栏是否展示
  7319. formlyConfigProvider.setType({
  7320. name: 'ui-orshow',
  7321. template: '<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>',
  7322. controller: ['$scope', function ($scope) {
  7323. $scope.clickshow = function (key) {
  7324. // $scope.model[$scope.options.key] != key;
  7325. if (key == false) {
  7326. $scope.model[$scope.options.key] = true
  7327. } else {
  7328. $scope.model[$scope.options.key] = false
  7329. }
  7330. }
  7331. }]
  7332. });
  7333. //按钮组
  7334. formlyConfigProvider.setType({
  7335. name: 'ui-button',
  7336. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  7337. defaultOptions: function (options) {
  7338. return {
  7339. noFormControl: true
  7340. }
  7341. }
  7342. });
  7343. //3d组link
  7344. formlyConfigProvider.setType({
  7345. name: 'ui-link',
  7346. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  7347. defaultOptions: function (options) {
  7348. return {
  7349. noFormControl: true
  7350. }
  7351. }
  7352. });
  7353. //隐藏域组件
  7354. formlyConfigProvider.setType({
  7355. name: 'ui-hidden',
  7356. extends: 'input',
  7357. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  7358. defaultOptions: function (options) {
  7359. return {
  7360. // noFormControl: true
  7361. };
  7362. }
  7363. });
  7364. //文本框组件
  7365. formlyConfigProvider.setType({
  7366. name: 'ui-input',
  7367. extends: 'input',
  7368. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7369. defaultOptions: function (options) {
  7370. return {
  7371. templateOptions: {
  7372. transform: function (value) {}
  7373. }
  7374. };
  7375. },
  7376. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7377. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7378. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7379. }
  7380. }]
  7381. });
  7382. //文本框组件
  7383. formlyConfigProvider.setType({
  7384. name: 'ui-num',
  7385. extends: 'input',
  7386. templateUrl: 'assets/views/customform/tpl/ui-num.html',
  7387. defaultOptions: function (options) {
  7388. return {
  7389. templateOptions: {
  7390. transform: function (value) {}
  7391. }
  7392. };
  7393. },
  7394. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7395. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7396. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7397. }
  7398. $scope.clearNoNum = function (obj, attr) {
  7399. //先把非数字的都替换掉,除了数字和.
  7400. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  7401. //必须保证第一个为数字而不是.
  7402. obj[attr] = obj[attr].replace(/^\./g, "");
  7403. //保证只有出现一个.而没有多个.
  7404. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  7405. //保证.只出现一次,而不能出现两次以上
  7406. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  7407. //小于最大值
  7408. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  7409. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  7410. // obj[attr] = '';
  7411. // }
  7412. }
  7413. }]
  7414. });
  7415. // //关联请求人文本框组件
  7416. // formlyConfigProvider.setType({
  7417. // name: 'ui-requestinput',
  7418. // extends: 'input',
  7419. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7420. // defaultOptions: function(options) {
  7421. // return {
  7422. // templateOptions: {
  7423. // transform: function(value) {},
  7424. // linkData: function(options) {}
  7425. // }
  7426. // };
  7427. // }
  7428. // });
  7429. //只读文本
  7430. formlyConfigProvider.setType({
  7431. name: 'ui-disableinput',
  7432. extends: 'input',
  7433. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  7434. defaultOptions: function (options) {
  7435. return {
  7436. templateOptions: {
  7437. transform: function (value) {
  7438. var ret = "";
  7439. if (value) {
  7440. ret = "已删除";
  7441. } else {
  7442. ret = "正常";
  7443. }
  7444. return ret;
  7445. }
  7446. }
  7447. };
  7448. }
  7449. });
  7450. formlyConfigProvider.setType({
  7451. name: 'ui-disinput',
  7452. extends: 'input',
  7453. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  7454. defaultOptions: function (options) {
  7455. return {
  7456. templateOptions: {}
  7457. };
  7458. }
  7459. });
  7460. //数字组件
  7461. formlyConfigProvider.setType({
  7462. name: 'ui-number',
  7463. extends: 'input',
  7464. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  7465. defaultOptions: function (options) {
  7466. return {
  7467. templateOptions: {}
  7468. };
  7469. },
  7470. controller: ['$scope', function ($scope) {}]
  7471. });
  7472. //含有周的日期
  7473. formlyConfigProvider.setType({
  7474. name: 'ui-datepickerweek',
  7475. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  7476. extends: 'input',
  7477. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  7478. defaultOptions: {
  7479. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  7480. templateOptions: {
  7481. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  7482. }
  7483. },
  7484. controller: ['$scope', '$filter', function ($scope, $filter) {
  7485. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  7486. if ($scope.model[$scope.options.key]) {
  7487. } else {
  7488. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  7489. }
  7490. $scope.options.initialValue = $scope.model[$scope.options.key];
  7491. $scope.endOpen = true;
  7492. $scope.datepicker = {};
  7493. $scope.datepicker.opened = false;
  7494. $scope.datepicker.open = function ($event) {
  7495. $scope.datepicker.opened = true;
  7496. };
  7497. }]
  7498. });
  7499. //下拉框组件
  7500. formlyConfigProvider.setType({
  7501. name: 'ui-select',
  7502. extends: 'select',
  7503. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  7504. defaultOptions: function (options, scope) {
  7505. return {
  7506. templateOptions: {
  7507. // refresh: function() {},
  7508. refreshDelay: 0,
  7509. linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
  7510. angular.extend(data, {
  7511. "idx": 0,
  7512. "sum": 1000
  7513. });
  7514. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  7515. var myData = options.templateOptions.Restangular.stripRestangular(response);
  7516. var list = myData.list;
  7517. // console.log(myData)
  7518. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  7519. // console.log('balabalabala');
  7520. // console.log(res);
  7521. // })
  7522. if (list.length == 1) {
  7523. if (options.templateOptions.APIport) {
  7524. options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
  7525. if (response.state == "200") {
  7526. // if (model.$parent.model && model.$parent.model.incident) {
  7527. // } else {
  7528. // model.$parent.model = { 'incident': {} };
  7529. // }
  7530. var myDatas = response.serviceLevelAgreement;
  7531. //逾期
  7532. scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
  7533. //解决
  7534. scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
  7535. //响应
  7536. scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
  7537. } else {
  7538. }
  7539. });
  7540. }
  7541. angular.forEach(model.fields, function (item) {
  7542. angular.forEach(model.fields, function (item) {
  7543. if (item.templateOptions.pkey == modelKey + "." + key) {
  7544. item.model.id = "";
  7545. if (key == "place") {
  7546. item.templateOptions.options = list;
  7547. } else if (key == "placeDTO") {
  7548. item.templateOptions.options = list;
  7549. } else {
  7550. item.value(list[0][key][item.key]);
  7551. }
  7552. }
  7553. })
  7554. })
  7555. } else {
  7556. if (model.fields) {
  7557. angular.forEach(model.fields, function (item) {
  7558. angular.forEach(model.fields, function (item) {
  7559. if (item.templateOptions.pkey == modelKey + "." + key) {
  7560. item.model.id = "";
  7561. if (key == "place") {
  7562. item.templateOptions.isnosearch = true;
  7563. item.templateOptions.options = list;
  7564. }
  7565. if (key == "placeDTO") {
  7566. item.templateOptions.options = list;
  7567. }
  7568. }
  7569. })
  7570. })
  7571. } else {
  7572. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  7573. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  7574. if (item.templateOptions.pkey == modelKey + "." + key) {
  7575. if (key == "place") {
  7576. item.templateOptions.isnosearch = true;
  7577. item.templateOptions.options = list;
  7578. scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
  7579. }
  7580. if (key == "placeDTO") {
  7581. item.templateOptions.options = list;
  7582. }
  7583. }
  7584. })
  7585. })
  7586. }
  7587. }
  7588. });
  7589. },
  7590. validators: {
  7591. required: {
  7592. expression: function (viewValue, modelValue) {
  7593. var value = modelValue || viewValue;
  7594. return value != null;
  7595. // return value.length>=1;
  7596. // if (modelValue && viewValue) {
  7597. // return value != null;
  7598. // } else {
  7599. // var value = modelValue || viewValue;
  7600. // return value.length > 0;
  7601. // }
  7602. }
  7603. }
  7604. }
  7605. },
  7606. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  7607. // $scope.myFilter = function(item) {
  7608. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  7609. // }
  7610. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  7611. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  7612. $scope.options.templateOptions.linkage("place", {
  7613. "place": {
  7614. "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
  7615. }
  7616. }, $scope.$parent.$parent.$parent.model, "incident", "place");
  7617. }
  7618. }
  7619. $scope.myFilter = $scope;
  7620. if ($scope.options.templateOptions.transform) {
  7621. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  7622. }
  7623. if (angular.isFunction($scope.options.templateOptions.translate)) {
  7624. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  7625. }
  7626. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  7627. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  7628. }
  7629. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  7630. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  7631. }
  7632. }]
  7633. };
  7634. }
  7635. });
  7636. //下拉多选框组件
  7637. formlyConfigProvider.setType({
  7638. name: 'ui-multiselect',
  7639. extends: 'select',
  7640. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  7641. defaultOptions: function (options) {
  7642. return {
  7643. templateOptions: {
  7644. refresh: function () {},
  7645. refreshDelay: 0
  7646. }
  7647. };
  7648. },
  7649. controller: ['$scope', function ($scope) {
  7650. $scope.model[$scope.options.key] = [];
  7651. }]
  7652. });
  7653. //下拉多选框灵活组件
  7654. formlyConfigProvider.setType({
  7655. name: 'ui-multiselectplus',
  7656. extends: 'multiCheckbox',
  7657. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  7658. defaultOptions: function (options) {
  7659. return {
  7660. templateOptions: {
  7661. refreshData: function (search, options, model, that) {
  7662. var process = options.templateOptions.ApiService.all("");
  7663. if (search) {
  7664. } else {
  7665. }
  7666. var postData = options.templateOptions.optionsPostData;
  7667. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  7668. postData = options.templateOptions.optionsPostData(options, model, that);
  7669. }
  7670. process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
  7671. // if (!options.templateOptions.options) {
  7672. // options.templateOptions.options = [];
  7673. // }
  7674. if (options.templateOptions.optionsDataKey) {
  7675. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  7676. } else {
  7677. options.templateOptions.options = result;
  7678. }
  7679. if (options.templateOptions.optionsChecked) {
  7680. // return options.value = null;
  7681. options.value(options.model[options.key]);
  7682. }
  7683. });
  7684. },
  7685. refreshDelay: 0,
  7686. // },
  7687. // validators: {
  7688. // required: {
  7689. // expression: function(viewValue, modelValue) {
  7690. // var value = modelValue || viewValue;
  7691. // // return value.length>=1;
  7692. // // if (modelValue && viewValue) {
  7693. // // return value != null;
  7694. // // } else {
  7695. // // var value = modelValue || viewValue;
  7696. // // return value.length > 0;
  7697. // // }
  7698. // }
  7699. // }
  7700. }
  7701. };
  7702. },
  7703. controller: ['$scope', function ($scope) {
  7704. if (angular.isArray($scope.model[$scope.options.key])) {
  7705. } else {
  7706. $scope.model[$scope.options.key] = [];
  7707. }
  7708. }]
  7709. });
  7710. //jry-上传下载一体
  7711. formlyConfigProvider.setType({
  7712. name: 'ui-upDropFile',
  7713. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  7714. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  7715. defaultOptions: function (options) {
  7716. return {
  7717. templateOptions: {
  7718. view: function (APIService, contentId) {
  7719. return APIService.downloadAttachment(contentId);
  7720. },
  7721. // ApiService: 'api_wechatfile',
  7722. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  7723. // upUrl: 'common/common/uploadAttachment',
  7724. // listAttachmentUrl: 'common/common/listAttachment',
  7725. // downUrl: 'common/common/downloadAttachment',
  7726. // bindType: 'incident',
  7727. // bindId: 2323
  7728. },
  7729. // validators: {
  7730. // required: {
  7731. // expression: function(viewValue, modelValue) {
  7732. // var value = modelValue || viewValue;
  7733. // return value.length >= 1;
  7734. // }
  7735. // }
  7736. // }
  7737. };
  7738. },
  7739. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  7740. if (angular.isUndefined($scope.form.dropState)) {
  7741. $scope.form.dropState = false;
  7742. }
  7743. if ($scope.model.incident) {
  7744. if ($scope.model.incident.alarm) {
  7745. console.log($scope)
  7746. if ($scope.model.incident.alarm) {
  7747. if ($scope.model.incident.alarm.alarmExtension) {
  7748. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  7749. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  7750. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  7751. console.log($scope.model.incident.description)
  7752. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  7753. } else {
  7754. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  7755. }
  7756. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  7757. console.log($scope.model.incident.description)
  7758. };
  7759. }
  7760. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  7761. console.log(wt_data);
  7762. if (wt_data) {
  7763. $rootScope.wt_category = wt_data.data;
  7764. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  7765. $rootScope.wt_child = wt_data.child
  7766. }
  7767. })
  7768. if ($scope.model.titleName == '接单') {
  7769. $scope.model.receive_code = 'handler'
  7770. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  7771. $scope.model.isHandlerUser = true;
  7772. }
  7773. }
  7774. if ($scope.model.titleName == '事件处理') {
  7775. console.log($scope.model.cmdbCode)
  7776. if ($scope.model.cmdbCode) {
  7777. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  7778. }
  7779. }
  7780. } else {
  7781. $rootScope.wt_category = '';
  7782. }
  7783. //附件上传数据
  7784. if ($scope.options.templateOptions.fileUploader) {
  7785. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  7786. //$scope.options.templateOptions.uploader();
  7787. console.log(uploader)
  7788. // FILTERS
  7789. uploader.filters.push({
  7790. name: 'customFilter',
  7791. fn: function (item /*{File|FileLikeObject}*/ , options) {
  7792. return this.queue.length < 10;
  7793. }
  7794. });
  7795. }
  7796. var to = $scope.options.templateOptions;
  7797. // var bindType = $scope.model.bindType;
  7798. if (to.bindType == 'incident') {
  7799. var bindId = $scope.model[to.bindType].processInstanceId;
  7800. } else if (to.bindType == 'change') {
  7801. var bindId = $scope.model[to.bindType].processInstanceId;
  7802. } else {
  7803. var bindId = $scope.model[to.bindType].id;
  7804. }
  7805. //获取附件列表
  7806. $scope.listAttachmen = function () {
  7807. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  7808. var myData = Restangular.stripRestangular(result);
  7809. // $scope.listAttachmens = myData;
  7810. $scope.attachments = myData.data;
  7811. });
  7812. };
  7813. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  7814. $scope.listAttachmen();
  7815. } else if (to.bindType && $scope.model[to.bindType].id) {
  7816. $scope.listAttachmen();
  7817. }
  7818. //附件上传
  7819. $scope.isUpfload = to.isUpfload;
  7820. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  7821. uploader.onBeforeUploadItem = function (item) {
  7822. angular.extend(item.headers, $rootScope.getSession());
  7823. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  7824. item.formData.push({
  7825. 'filename': item.file.name
  7826. });
  7827. };
  7828. uploader.uploadAll();
  7829. }
  7830. //附件下载
  7831. $scope.download = function (token, filename) {
  7832. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  7833. // window.open(downUrl);
  7834. var a = document.createElement('a');
  7835. a.href = downUrl;
  7836. a.target = '_blank';
  7837. a.download = filename;
  7838. document.body.appendChild(a);
  7839. a.click();
  7840. };
  7841. //附件预览
  7842. $scope.view = function (id, previewUrl) {
  7843. if (previewUrl) {
  7844. window.open(previewUrl);
  7845. }
  7846. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  7847. // if (response.state == 200) {
  7848. // window.open(response.previewUrl);
  7849. // }
  7850. // })
  7851. };
  7852. // CALLBACKS
  7853. if (uploader) {
  7854. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  7855. console.info('onWhenAddingFileFailed', item, filter, options);
  7856. };
  7857. uploader.onAfterAddingFile = function (fileItem) {
  7858. console.info('onAfterAddingFile', fileItem);
  7859. };
  7860. uploader.onAfterAddingAll = function (addedFileItems) {
  7861. console.info('onAfterAddingAll', addedFileItems);
  7862. };
  7863. uploader.onBeforeUploadItem = function (item) {
  7864. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  7865. // // $scope.uploader.options.url();
  7866. // $scope.uploader.onBeforeUploadItem = function(item) {
  7867. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  7868. // console.info('onBeforeUploadItem', item);
  7869. // };
  7870. // $scope.uploader.uploadAll();
  7871. // }
  7872. console.info('onBeforeUploadItem', item);
  7873. };
  7874. uploader.onProgressItem = function (fileItem, progress) {
  7875. console.info('onProgressItem', fileItem, progress);
  7876. };
  7877. uploader.onProgressAll = function (progress) {
  7878. console.info('onProgressAll', progress);
  7879. };
  7880. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  7881. console.info('onSuccessItem', fileItem, response, status, headers);
  7882. if (response.status == 200) {
  7883. $scope.listAttachmen();
  7884. }
  7885. };
  7886. uploader.onErrorItem = function (fileItem, response, status, headers) {
  7887. console.info('onErrorItem', fileItem, response, status, headers);
  7888. };
  7889. uploader.onCancelItem = function (fileItem, response, status, headers) {
  7890. console.info('onCancelItem', fileItem, response, status, headers);
  7891. };
  7892. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  7893. console.info('onCompleteItem', fileItem, response, status, headers);
  7894. };
  7895. uploader.onCompleteAll = function () {
  7896. console.info('onCompleteAll');
  7897. };
  7898. }
  7899. }]
  7900. });
  7901. //下拉树形多选组件
  7902. formlyConfigProvider.setType({
  7903. name: 'ui-multiselect-tree',
  7904. extends: 'multiCheckbox',
  7905. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  7906. defaultOptions: function (options) {
  7907. return {
  7908. templateOptions: {
  7909. linkage: function (modelName, data, model, modelKey, key) {
  7910. angular.extend(data, {
  7911. "idx": 0,
  7912. "sum": 10
  7913. });
  7914. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  7915. var myData = options.templateOptions.Restangular.stripRestangular(response);
  7916. var list = myData.list;
  7917. if (list.length == 1) {
  7918. angular.forEach(model.fields, function (item) {
  7919. angular.forEach(model.fields, function (item) {
  7920. if (item.templateOptions.pkey == modelKey + "." + key) {
  7921. item.model.id = "";
  7922. if (key == "place") {
  7923. item.templateOptions.options = list;
  7924. } else {
  7925. item.value(list[0][key][item.key]);
  7926. }
  7927. }
  7928. })
  7929. })
  7930. }
  7931. });
  7932. },
  7933. // my_tree_handler : function(items) {
  7934. // },
  7935. // onFilterCallback : function(items) {
  7936. // },
  7937. // onFilterCallback : function(items) {
  7938. // },
  7939. refresh: function (items) {
  7940. var treedata = [];
  7941. function convertListToTree(data, treeMap) {
  7942. treedata = data;
  7943. for (var i = 0; i < data.length; i++) {
  7944. for (var j = 0; j < data.length; j++) {
  7945. if (data[i].pid && data[i].id && data[i].pid != 0) {
  7946. if (data[i].pid == data[j].id) {
  7947. data[i].parent = data[j];
  7948. }
  7949. }
  7950. }
  7951. }
  7952. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  7953. var root = null; //Initially set our loop to null
  7954. //loop over data
  7955. for (var i = 0; i < data.length; i++) {
  7956. var datum = data[i];
  7957. //each node will have children, so let's give it a "children" poperty
  7958. datum.children = [];
  7959. //add an entry for this node to the map so that any future children can
  7960. //lookup the parent
  7961. idToNodeMap[datum.id] = datum;
  7962. //Does this node have a parent?
  7963. if (typeof datum.parent === "undefined" || datum.parent === null) {
  7964. //Doesn't look like it, so this node is the root of the tree
  7965. root = datum;
  7966. treeMap[datum.id] = root;
  7967. } else {
  7968. //This node has a parent, so let's look it up using the id
  7969. parentNode = idToNodeMap[datum.parent.id];
  7970. //We don't need this property, so let's delete it.
  7971. delete datum.parent;
  7972. //Let's add the current node as a child of the parent node.
  7973. parentNode.children.push(datum);
  7974. }
  7975. }
  7976. return root;
  7977. }
  7978. function convertParentToChildList(data) {
  7979. // console.log("data="+JSON.stringify(data))
  7980. var treeMap = {};
  7981. var list = [];
  7982. convertListToTree(data, treeMap);
  7983. angular.forEach(treeMap, function (item) {
  7984. list.push(item);
  7985. });
  7986. return list;
  7987. }
  7988. function selectItem(pmodel, childrens) {
  7989. if (angular.isArray(pmodel)) {
  7990. angular.forEach(pmodel, function (index) {
  7991. if (index && index.id) {
  7992. angular.forEach(childrens, function (item) {
  7993. if (item.id == index.id) {
  7994. item.selected = true;
  7995. }
  7996. if (item && item.children) {
  7997. selectItem(pmodel, item.children);
  7998. }
  7999. });
  8000. }
  8001. })
  8002. } else {
  8003. if (pmodel && pmodel.id) {
  8004. angular.forEach(childrens, function (item) {
  8005. if (item.id == pmodel.id) {
  8006. item.selected = true;
  8007. }
  8008. if (item && item.children) {
  8009. selectItem(pmodel, item.children);
  8010. }
  8011. });
  8012. }
  8013. }
  8014. }
  8015. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  8016. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  8017. if (result.status == 200) {
  8018. if (!options.templateOptions.options) {
  8019. options.templateOptions.options = [];
  8020. }
  8021. if (options.templateOptions.optionsDataKey) {
  8022. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  8023. } else {
  8024. options.templateOptions.options = convertParentToChildList(result);
  8025. }
  8026. //set default value
  8027. var pmodel, i = 0;
  8028. if (options.templateOptions.pkey) {
  8029. if (options.templateOptions.pkey.indexOf(".") > 0) {
  8030. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  8031. if (i == 0) {
  8032. if (options.model[p] == null) {
  8033. options.model[p] = {};
  8034. }
  8035. pmodel = options.model[p];
  8036. i++;
  8037. } else {
  8038. if (pmodel[p] == null) {
  8039. pmodel[p] = {};
  8040. }
  8041. pmodel = pmodel[p];
  8042. }
  8043. });
  8044. } else {
  8045. pmodel = options.model;
  8046. }
  8047. }
  8048. if (pmodel) {
  8049. pmodel = pmodel[options.key];
  8050. } else if (options.model) {
  8051. pmodel = options.model[options.key];
  8052. } else {
  8053. pmodel = options.templateOptions.options;
  8054. }
  8055. if (angular.isArray(pmodel)) {
  8056. if (pmodel) {
  8057. // if(options.templateOptions.isMultiSelect==true){
  8058. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  8059. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  8060. // })
  8061. // }else{
  8062. selectItem(pmodel, options.templateOptions.options);
  8063. // }
  8064. }
  8065. } else {
  8066. if (pmodel && pmodel.id) {
  8067. selectItem(pmodel, options.templateOptions.options);
  8068. }
  8069. }
  8070. items.inputModel = options.templateOptions.options;
  8071. }
  8072. });
  8073. }
  8074. },
  8075. validators: {
  8076. required: {
  8077. expression: function (viewValue, modelValue) {
  8078. var value = modelValue || viewValue;
  8079. if (angular.isArray(value)) {
  8080. for (var i = 0; i < value.length; i++) {
  8081. value[i] = {
  8082. id: value[i].id
  8083. }
  8084. }
  8085. return value.length > 0
  8086. } else {
  8087. // console.log(options)
  8088. // return value = "true";
  8089. return value != null;
  8090. }
  8091. }
  8092. }
  8093. }
  8094. }
  8095. },
  8096. controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
  8097. if ($scope.options.templateOptions.isMultiSelect) {
  8098. // console.log($scope);
  8099. } else {
  8100. if ($scope.model[$scope.options.key]) {
  8101. }
  8102. }
  8103. }]
  8104. });
  8105. //多选下拉框组件
  8106. formlyConfigProvider.setType({
  8107. name: 'ui-multi-select-tree',
  8108. extends: 'input',
  8109. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  8110. defaultOptions: function (options) {
  8111. return {
  8112. templateOptions: {
  8113. linkage: function (modelName, data, model, modelKey, key) {
  8114. angular.extend(data, {
  8115. "idx": 0,
  8116. "sum": 10
  8117. });
  8118. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  8119. var myData = options.templateOptions.Restangular.stripRestangular(response);
  8120. var list = myData.list;
  8121. if (list.length == 1) {
  8122. angular.forEach(model.fields, function (item) {
  8123. angular.forEach(model.fields, function (item) {
  8124. if (item.templateOptions.pkey == modelKey + "." + key) {
  8125. item.model.id = "";
  8126. if (key == "place") {
  8127. item.templateOptions.options = list;
  8128. } else {
  8129. item.value(list[0][key][item.key]);
  8130. }
  8131. }
  8132. })
  8133. })
  8134. }
  8135. });
  8136. },
  8137. getparentdata: function (items) {
  8138. // console.log(items)
  8139. },
  8140. refresh: function (items) {
  8141. //console.log(items);
  8142. var treedata = [];
  8143. function convertListToTree(data, treeMap) {
  8144. // console.log(data)
  8145. treedata = data;
  8146. for (var i = 0; i < data.length; i++) {
  8147. for (var j = 0; j < data.length; j++) {
  8148. if (data[i].pid && data[i].id && data[i].pid != 0) {
  8149. if (data[i].pid == data[j].id) {
  8150. data[i].parent = data[j];
  8151. }
  8152. }
  8153. // if (data[i].id) {
  8154. // if (data[i].id== data[j].id) {
  8155. // data[i].parent = data[j];
  8156. // }
  8157. // }
  8158. }
  8159. }
  8160. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  8161. var root = null; //Initially set our loop to null
  8162. //loop over data
  8163. for (var i = 0; i < data.length; i++) {
  8164. var datum = data[i];
  8165. //each node will have children, so let's give it a "children" poperty
  8166. datum.children = [];
  8167. //add an entry for this node to the map so that any future children can
  8168. //lookup the parent
  8169. idToNodeMap[datum.id] = datum;
  8170. //Does this node have a parent?
  8171. // console.log("datum="+JSON.stringify(datum))
  8172. if (typeof datum.parent === "undefined" || datum.parent === null) {
  8173. //Doesn't look like it, so this node is the root of the tree
  8174. root = datum;
  8175. treeMap[datum.id] = root;
  8176. } else {
  8177. //This node has a parent, so let's look it up using the id
  8178. parentNode = idToNodeMap[datum.parent.id];
  8179. //We don't need this property, so let's delete it.
  8180. // delete datum.parent;
  8181. //Let's add the current node as a child of the parent node.
  8182. parentNode.children.push(datum);
  8183. }
  8184. }
  8185. return root;
  8186. }
  8187. function convertParentToChildList(data) {
  8188. // console.log("data="+JSON.stringify(data))
  8189. var treeMap = {};
  8190. var list = [];
  8191. if (data[0] && data[0].orders) {
  8192. list = data;
  8193. } else {
  8194. convertListToTree(data, treeMap);
  8195. angular.forEach(treeMap, function (item) {
  8196. // console.log("item="+JSON.stringify(item))
  8197. list.push(item);
  8198. });
  8199. }
  8200. return list;
  8201. }
  8202. function selectItem(pmodel, childrens) {
  8203. if (angular.isArray(pmodel)) {
  8204. angular.forEach(pmodel, function (index) {
  8205. if (index && index.id) {
  8206. angular.forEach(childrens, function (item) {
  8207. if (item.id == index.id) {
  8208. item.selected = true;
  8209. }
  8210. if (item && item.children) {
  8211. selectItem(pmodel, item.children);
  8212. }
  8213. });
  8214. // angular.forEach(treedata,function(parentdata){
  8215. // if(parentdata.id == index.id){
  8216. // if(parentdata.parent&&parentdata.parent.id){
  8217. // parentdata.parent.$
  8218. // }
  8219. // item.selected = true;
  8220. // }
  8221. // if (item && item.children) {
  8222. // selectItem(pmodel ,item.children);
  8223. // }
  8224. // });
  8225. }
  8226. })
  8227. } else {
  8228. if (pmodel && pmodel.id) {
  8229. angular.forEach(childrens, function (item, index) {
  8230. if (item.id == pmodel.id) {
  8231. item.selected = true;
  8232. delete item.children;
  8233. }
  8234. if (item && item.children) {
  8235. selectItem(pmodel, item.children);
  8236. }
  8237. });
  8238. }
  8239. }
  8240. }
  8241. function selectItemchild(pmodel, childrens) {
  8242. if (angular.isArray(pmodel)) {
  8243. angular.forEach(pmodel, function (index) {
  8244. if (index && index.id) {
  8245. angular.forEach(childrens, function (item) {
  8246. if (item.id == index.id) {
  8247. item.selected = true;
  8248. }
  8249. if (item && item.children) {
  8250. selectItem(pmodel, item.children);
  8251. }
  8252. });
  8253. }
  8254. })
  8255. } else {
  8256. if (pmodel && pmodel.id) {
  8257. angular.forEach(childrens, function (item, index) {
  8258. if (item.id == pmodel.id) {
  8259. item.selected = true;
  8260. childrens[index].selected = true;
  8261. }
  8262. if (item && item.children) {
  8263. selectItem(pmodel, item.children);
  8264. }
  8265. });
  8266. }
  8267. }
  8268. }
  8269. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  8270. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  8271. if (!options.templateOptions.options) {
  8272. options.templateOptions.options = [];
  8273. }
  8274. if (options.templateOptions.optionsDataKey) {
  8275. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  8276. } else {
  8277. options.templateOptions.options = convertParentToChildList(result);
  8278. }
  8279. //set default value
  8280. var pmodel, i = 0;
  8281. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  8282. if (options.templateOptions.pkey.indexOf(".") > 0) {
  8283. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  8284. if (i == 0) {
  8285. if (options.model[p] == null) {
  8286. options.model[p] = {};
  8287. }
  8288. pmodel = options.model[p];
  8289. i++;
  8290. } else {
  8291. if (pmodel[p] == null) {
  8292. pmodel[p] = {};
  8293. }
  8294. pmodel = pmodel[p];
  8295. }
  8296. });
  8297. } else {
  8298. pmodel = options.model;
  8299. }
  8300. }
  8301. var topdata = angular.copy(options.templateOptions.options);
  8302. if (pmodel) {
  8303. pmodel = pmodel[options.key];
  8304. } else if (options.model) {
  8305. pmodel = options.model[options.key];
  8306. }
  8307. if (angular.isArray(pmodel)) {
  8308. if (pmodel) {
  8309. items.inputModel = angular.copy(options.templateOptions.options);
  8310. selectItem(pmodel, options.templateOptions.options);
  8311. }
  8312. } else {
  8313. if (pmodel && pmodel.id) {
  8314. items.inputModel = angular.copy(options.templateOptions.options);
  8315. selectItem(pmodel, options.templateOptions.options);
  8316. } else {
  8317. // items.inputModel = options.templateOptions.options;
  8318. }
  8319. }
  8320. // items.inputModel = options.templateOptions.options;
  8321. items.selectModel = options.templateOptions.options;
  8322. if (!items.inputModel) {
  8323. items.inputModel = items.selectModel;
  8324. } else {
  8325. selectItemchild(pmodel, items.inputModel);
  8326. // for (var i = 0; i < items.inputModel.length; i++) {
  8327. // for (var j = 0; j < items.selectModel.length; j++) {
  8328. // if (items.selectModel[j].id == items.inputModel[i].id) {
  8329. // items.inputModel[i].selected = true;
  8330. // }
  8331. // }
  8332. // }
  8333. }
  8334. // options.templateOptions.options = angular.copy(topdata);
  8335. // console.log(model);
  8336. // console.log(options);
  8337. });
  8338. }
  8339. },
  8340. validators: {
  8341. required: {
  8342. expression: function (viewValue, modelValue) {
  8343. var value = modelValue || viewValue;
  8344. if (angular.isArray(value)) {
  8345. return value.length > 0
  8346. } else {
  8347. // console.log(options)
  8348. if (options.templateOptions.required && !value) {
  8349. // return value != null;
  8350. } else {
  8351. return value;
  8352. }
  8353. // return value = "true";
  8354. }
  8355. }
  8356. }
  8357. }
  8358. }
  8359. },
  8360. controller: ['$scope', '$rootScope', 'api_configure_form', function ($scope, $rootScope, api_configure_form) {
  8361. $rootScope.checkClicked = function (item) {
  8362. angular.forEach($scope.to.options, function (itemone) {
  8363. if (!item.parent) {
  8364. if (item.id == itemone.id) {
  8365. // itemone.isExpanded = true;
  8366. } else {
  8367. itemone.isExpanded = false;
  8368. }
  8369. } else {
  8370. if (item.parent.id == itemone.id) {
  8371. angular.forEach(itemone.children, function (itemtwo) {
  8372. if (item.id == itemtwo.id) {} else {
  8373. itemtwo.isExpanded = false;
  8374. }
  8375. })
  8376. }
  8377. }
  8378. })
  8379. }
  8380. if ($scope.options.templateOptions.isMultiSelect) {
  8381. // console.log($scope);
  8382. } else {
  8383. if ($scope.model[$scope.options.key]) {
  8384. }
  8385. }
  8386. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  8387. // console.log(item)
  8388. // // if(){
  8389. // // }
  8390. // // $scope.model[$scope.options.key]=item.id;
  8391. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  8392. // $scope.propTypeOptions = data;
  8393. // });
  8394. // }
  8395. // $scope.model[$scope.options.key]=[];
  8396. }]
  8397. });
  8398. //勾选组件
  8399. formlyConfigProvider.setType({
  8400. name: 'ui-checkbox',
  8401. extends: 'checkbox',
  8402. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html'
  8403. });
  8404. //换行组件
  8405. formlyConfigProvider.setType({
  8406. name: 'ui-nextLine',
  8407. /*extends: 'input',*/
  8408. template: '<div></div>',
  8409. });
  8410. //多选框组件
  8411. formlyConfigProvider.setType({
  8412. name: 'ui-checklist',
  8413. extends: 'multiCheckbox',
  8414. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  8415. defaultOptions: function (options) {
  8416. return {
  8417. templateOptions: {
  8418. refresh: function () {},
  8419. refreshDelay: 0
  8420. }
  8421. };
  8422. }
  8423. });
  8424. //单选框组件
  8425. formlyConfigProvider.setType({
  8426. name: 'ui-radio',
  8427. extends: 'radio',
  8428. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  8429. defaultOptions: function (options) {
  8430. return {
  8431. templateOptions: {
  8432. refresh: function () {},
  8433. refreshDelay: 0
  8434. }
  8435. };
  8436. }
  8437. });
  8438. //文本域组件
  8439. formlyConfigProvider.setWrapper({
  8440. name: 'validation',
  8441. types: ['ui-textarea'],
  8442. template: "<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>"
  8443. });
  8444. formlyConfigProvider.setType({
  8445. name: 'ui-textarea',
  8446. extends: 'textarea',
  8447. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  8448. defaultOptions: function (options) {
  8449. return {
  8450. templateOptions: {
  8451. transform: function (model, value) {
  8452. return value;
  8453. },
  8454. },
  8455. validation: {
  8456. messages: {
  8457. maxlength: function (viewValue, modelValue, scope) {
  8458. if (viewValue != null) {
  8459. if (viewValue.length > scope.to.maxlength) {
  8460. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8461. } else {
  8462. return "";
  8463. }
  8464. }
  8465. },
  8466. }
  8467. }
  8468. }
  8469. },
  8470. controller: ['$scope', function ($scope) {
  8471. var value = $scope.model[$scope.options.key];
  8472. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8473. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8474. }
  8475. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  8476. $scope.options.templateOptions.felditem($scope);
  8477. }
  8478. }]
  8479. });
  8480. //常用语句选择textarea
  8481. formlyConfigProvider.setType({
  8482. name: 'ui-textselect',
  8483. extends: 'textarea',
  8484. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  8485. defaultOptions: function (options) {
  8486. return {
  8487. templateOptions: {
  8488. transform: function (model, value) {
  8489. return value;
  8490. },
  8491. },
  8492. validation: {
  8493. messages: {
  8494. maxlength: function (viewValue, modelValue, scope) {
  8495. if (viewValue != null) {
  8496. if (viewValue.length > scope.to.maxlength) {
  8497. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8498. } else {
  8499. return "";
  8500. }
  8501. }
  8502. },
  8503. }
  8504. }
  8505. }
  8506. },
  8507. controller: ['$scope', function ($scope) {
  8508. var value = $scope.model[$scope.options.key];
  8509. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8510. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8511. }
  8512. }]
  8513. });
  8514. //改动的组件 ckeditor封装后的组件
  8515. formlyConfigProvider.setType({
  8516. name: 'ui-text-check',
  8517. extends: 'textarea',
  8518. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  8519. defaultOptions: function (options) {
  8520. return {
  8521. templateOptions: {
  8522. extraPlugins: 'uploadimage',
  8523. uploadimageConfig: {
  8524. backend: 'basic',
  8525. settings: {
  8526. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  8527. headers: '',
  8528. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  8529. }
  8530. },
  8531. refresh: function (APIService, contentId, data) {
  8532. return APIService.fetchDataList(contentId, data);
  8533. },
  8534. downloadUri: function (APIService, contentId) {
  8535. return APIService.downloadAttachment(contentId).getRequestedUrl();
  8536. },
  8537. upload: function (APIService, contentId) {
  8538. return APIService.getSolutionDowpath(contentId);
  8539. },
  8540. view: function (attachmentId) {
  8541. // return APIService.attachmentsPreviewUrl(contentId);
  8542. },
  8543. refreshDelay: 0,
  8544. transform: function (model, value) {
  8545. return value;
  8546. },
  8547. },
  8548. validation: {
  8549. messages: {
  8550. maxlength: function (viewValue, modelValue, scope) {
  8551. if (viewValue != null) {
  8552. if (viewValue.length > scope.to.maxlength) {
  8553. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8554. } else {
  8555. return "";
  8556. }
  8557. }
  8558. },
  8559. }
  8560. }
  8561. }
  8562. },
  8563. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  8564. var value = $scope.model[$scope.options.key];
  8565. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8566. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8567. }
  8568. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  8569. //var expiry={'expiry':14804244006};
  8570. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  8571. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  8572. $scope.upload = function (contentId, filename) {
  8573. var filename = filename;
  8574. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  8575. var file = new Blob([response], {
  8576. type: 'application/octet-stream'
  8577. });
  8578. // var filename = filename;
  8579. var fileURL = URL.createObjectURL(file);
  8580. var a = document.createElement('a');
  8581. a.href = fileURL;
  8582. a.target = '_blank';
  8583. a.download = filename;
  8584. document.body.appendChild(a);
  8585. a.click();
  8586. })
  8587. };
  8588. }]
  8589. });
  8590. //ui-grid展示控件
  8591. formlyConfigProvider.setType({
  8592. name: 'ui-grid-show',
  8593. extends: 'multiCheckbox',
  8594. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  8595. defaultOptions: function (options) {
  8596. return {
  8597. templateOptions: {
  8598. linkage: function () {
  8599. },
  8600. },
  8601. };
  8602. },
  8603. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  8604. var loginUser = $rootScope.user;
  8605. $scope.langs = i18nService.getAllLangs();
  8606. $scope.lang = 'zh-cn';
  8607. i18nService.setCurrentLang($scope.lang);
  8608. $scope.gridOptions = {};
  8609. $scope.gridOptions.data = 'myData';
  8610. $scope.gridOptions.enableColumnResizing = true;
  8611. // $scope.gridOptions.enableFiltering = true;
  8612. $scope.gridOptions.enableGridMenu = false;
  8613. $scope.gridOptions.enableRowSelection = true;
  8614. $scope.gridOptions.showGridFooter = true;
  8615. $scope.gridOptions.showColumnFooter = false;
  8616. $scope.gridOptions.fastWatch = true;
  8617. $scope.gridOptions.useExternalFiltering = true;
  8618. $scope.gridOptions.useExternalPagination = true;
  8619. $scope.gridOptions.paginationPageSizes = [10];
  8620. $scope.gridOptions.paginationPageSize = 10;
  8621. $scope.gridOptions.multiSelect = true;
  8622. $scope.gridOptions.rowIdentity = function (row) {
  8623. return row.id;
  8624. };
  8625. $scope.gridOptions.getRowIdentity = function (row) {
  8626. return row.id;
  8627. };
  8628. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  8629. $scope.gridOptions.columnDefs = [
  8630. // { name:'id', width:80, enableFiltering:false},
  8631. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  8632. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  8633. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  8634. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  8635. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  8636. {
  8637. name: 'inspection.title',
  8638. displayName: '计划主题',
  8639. width: 120,
  8640. enableFiltering: false
  8641. },
  8642. {
  8643. name: 'stateName',
  8644. displayName: '状态',
  8645. width: 80,
  8646. enableFiltering: false
  8647. },
  8648. {
  8649. name: 'processUser.name',
  8650. displayName: '处理人',
  8651. width: 80,
  8652. enableFiltering: false
  8653. },
  8654. {
  8655. name: 'startDate',
  8656. displayName: '开始时间',
  8657. width: 160,
  8658. enableFiltering: false
  8659. },
  8660. {
  8661. name: 'overdueTime',
  8662. displayName: '逾期时间',
  8663. width: 160,
  8664. enableFiltering: false
  8665. },
  8666. ];
  8667. var defaultFilterData = {
  8668. "idx": 0,
  8669. "sum": 10
  8670. };
  8671. //分页控制
  8672. $scope.gridOptions.onRegisterApi = function (gridApi) {
  8673. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  8674. var filtersData = $scope.memoryfilterData;
  8675. filtersData.idx = newPage - 1;
  8676. filtersData.sum = pageSize;
  8677. $scope.refreshData('expand-right', filtersData);
  8678. });
  8679. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  8680. data.grid.appScope.selected.items = data.entity
  8681. });
  8682. };
  8683. //页面获取数据
  8684. $scope.refreshData = function (style, filterData) {
  8685. // $scope.ldloading[style.replace('-', '_')] = true;
  8686. if (angular.isUndefined(filterData)) {
  8687. filterData = defaultFilterData;
  8688. }
  8689. $scope.myData = [];
  8690. angular.extend(filterData, {
  8691. inspectionProcessActual: {
  8692. "inspectionid": $scope.model.id
  8693. }
  8694. })
  8695. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
  8696. var myData = Restangular.stripRestangular(data);
  8697. $scope.gridOptions.totalItems = myData.totalNum;
  8698. $scope.myData = myData.list;
  8699. for (var i = 0; i < $scope.myData.length; i++) {
  8700. //添加序号
  8701. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  8702. }
  8703. // $scope.ldloading[style.replace('-', '_')] = false;
  8704. }, function () {
  8705. // $scope.ldloading[style.replace('-', '_')] = false;
  8706. });
  8707. };
  8708. $scope.refreshData('expand-right', defaultFilterData);
  8709. }
  8710. });
  8711. //文本框自定义选择面板组件
  8712. formlyConfigProvider.setType({
  8713. name: 'ui-input-selectmodal',
  8714. extends: 'input',
  8715. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  8716. defaultOptions: function (options) {
  8717. return {
  8718. templateOptions: {
  8719. openModal: function (size, options, modal) {
  8720. var modalInstance = modal.open({
  8721. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  8722. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  8723. size: size,
  8724. resolve: options.templateOptions.modalParam
  8725. });
  8726. modalInstance.result.then(function (selectedItem) {
  8727. options.value(selectedItem);
  8728. }, function () {
  8729. //console.log('Modal dismissed at: ' + new Date());
  8730. });
  8731. }
  8732. }
  8733. };
  8734. }
  8735. });
  8736. //日期控件
  8737. var datepicker_attr = [
  8738. 'date-disabled',
  8739. 'custom-class',
  8740. 'show-weeks',
  8741. 'starting-day',
  8742. 'init-date',
  8743. 'min-mode',
  8744. 'max-mode',
  8745. 'format-day',
  8746. 'format-month',
  8747. 'format-year',
  8748. 'format-day-header',
  8749. 'format-day-title',
  8750. 'format-month-title',
  8751. 'year-range',
  8752. 'shortcut-propagation',
  8753. 'datepicker-popup',
  8754. 'show-button-bar',
  8755. 'current-text',
  8756. 'clear-text',
  8757. 'close-text',
  8758. 'close-on-date-selection',
  8759. 'datepicker-append-to-body'
  8760. ];
  8761. var datepicker_bindings = [
  8762. 'datepicker-mode',
  8763. 'min-date',
  8764. 'max-date'
  8765. ];
  8766. formlyConfigProvider.setType({
  8767. name: 'ui-datetime',
  8768. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  8769. extends: 'input',
  8770. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8771. defaultOptions: {
  8772. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8773. templateOptions: {
  8774. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8775. }
  8776. },
  8777. controller: ['$scope', '$filter', function ($scope, $filter) {
  8778. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  8779. $scope.options.initialValue = $scope.model[$scope.options.key];
  8780. }]
  8781. });
  8782. //日期控件
  8783. formlyConfigProvider.setType({
  8784. name: 'ui-datepicker',
  8785. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  8786. extends: 'input',
  8787. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8788. defaultOptions: {
  8789. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8790. templateOptions: {
  8791. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8792. }
  8793. },
  8794. controller: ['$scope', '$filter', function ($scope, $filter) {
  8795. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  8796. if ($scope.model[$scope.options.key]) {
  8797. } else {
  8798. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  8799. }
  8800. $scope.options.initialValue = $scope.model[$scope.options.key];
  8801. $scope.endOpen = true;
  8802. $scope.datepicker = {};
  8803. $scope.datepicker.opened = false;
  8804. $scope.datepicker.open = function ($event) {
  8805. $scope.datepicker.opened = true;
  8806. };
  8807. }]
  8808. });
  8809. //时分控件
  8810. formlyConfigProvider.setType({
  8811. name: 'ui-datehourtime',
  8812. extends: 'input',
  8813. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  8814. defaultOptions: function (options) {
  8815. return {
  8816. noFormControl: true,
  8817. // validators:{
  8818. // required:{
  8819. // expression:function(viewValue, modelValue){
  8820. // console.log(options)
  8821. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  8822. // // var value = modelValue.getHours() || viewValue.getHours();
  8823. // return value.length>=1;
  8824. // }
  8825. // }
  8826. // }
  8827. }
  8828. },
  8829. controller: ['$scope', '$log', function ($scope, $log) {
  8830. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  8831. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  8832. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  8833. }]
  8834. });
  8835. //状态追踪
  8836. formlyConfigProvider.setType({
  8837. name: 'ui-followStatus',
  8838. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  8839. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  8840. setTimeout(function () {
  8841. var pkey = $scope.options.templateOptions.pkey;
  8842. var dataId = $scope.model.id;
  8843. if (dataId) {
  8844. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  8845. if (response) {
  8846. var myData = Restangular.stripRestangular(response);
  8847. var processInstanceId = myData.data.processInstanceId;
  8848. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  8849. if (result.status == 200) {
  8850. var newData = Restangular.stripRestangular(result);
  8851. $scope.followData = newData.data;
  8852. }
  8853. });
  8854. }
  8855. })
  8856. }
  8857. }, 10);
  8858. }]
  8859. });
  8860. //历史记录
  8861. formlyConfigProvider.setType({
  8862. name: 'ui-history',
  8863. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  8864. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  8865. setTimeout(function () {
  8866. var pkey = $scope.options.templateOptions.pkey;
  8867. var dataId = $scope.model.id;
  8868. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  8869. if (response) {
  8870. var myData = Restangular.stripRestangular(response);
  8871. var processInstanceId = myData.data.processInstanceId;
  8872. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  8873. if (result.status == 200) {
  8874. var newData = Restangular.stripRestangular(result);
  8875. var long = newData.data.length - 1;
  8876. $scope.followData = newData.data[long];
  8877. }
  8878. });
  8879. }
  8880. })
  8881. }, 10);
  8882. }]
  8883. });
  8884. // //请求人信息显示
  8885. // formlyConfigProvider.setType({
  8886. // name: "ui-disrequester",
  8887. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  8888. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8889. // defaultOptions: function(options) {
  8890. // return {
  8891. // templateOptions: {}
  8892. // };
  8893. // },
  8894. // controller: ['$scope', function($scope) {
  8895. // $scope.options.templateOptions.that = $scope;
  8896. // }]
  8897. // });
  8898. //退回人信息显示
  8899. formlyConfigProvider.setType({
  8900. name: "ui-returnperson",
  8901. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  8902. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8903. defaultOptions: function (options) {
  8904. return {
  8905. templateOptions: {}
  8906. };
  8907. },
  8908. controller: ['$scope', function ($scope) {
  8909. $scope.group = "";
  8910. $scope.role = "";
  8911. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  8912. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  8913. } else {
  8914. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  8915. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  8916. }
  8917. }
  8918. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  8919. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  8920. } else {
  8921. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  8922. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  8923. }
  8924. }
  8925. $scope.options.templateOptions.that = $scope;
  8926. $scope.options.templateOptions.that = $scope;
  8927. }]
  8928. });
  8929. //指派技术人员
  8930. formlyConfigProvider.setType({
  8931. name: "ui-apiontperson",
  8932. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  8933. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8934. defaultOptions: function (options) {
  8935. return {
  8936. templateOptions: {
  8937. transtlara: function (value, $scope) {}
  8938. }
  8939. };
  8940. },
  8941. controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
  8942. var filterData = {
  8943. "idx": 0,
  8944. "sum": 1000
  8945. }
  8946. api_user_data.fetchDataList('group', filterData).then(function (response) {
  8947. if (response.status == 200) {
  8948. $scope.select = {};
  8949. $scope.multipleDemo = {};
  8950. $scope.userdata = {};
  8951. var data = response.list;
  8952. var item = [];
  8953. $scope.multipleDemo = data;
  8954. $scope.multipleDemo;
  8955. }
  8956. })
  8957. $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
  8958. if (groupdata.option) {
  8959. $scope.model[$scope.options.key] = {};
  8960. var fildate = {
  8961. "idx": 0,
  8962. "sum": 1000,
  8963. "user": {
  8964. "roledata": {
  8965. "rolecode": model.currentRole
  8966. },
  8967. "selectType": "1",
  8968. "groupdata": {
  8969. "id": groupdata.option.id
  8970. }
  8971. }
  8972. }
  8973. api_user_data.fetchDataList('user', fildate).then(function (response) {
  8974. if (response.status == 200) {
  8975. $scope.userdata = {};
  8976. $scope.userdata = response.list;
  8977. }
  8978. })
  8979. } else {
  8980. $scope.model[$scope.options.key] = {
  8981. id: groupdata.id.id
  8982. }
  8983. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  8984. }
  8985. }
  8986. // }
  8987. }]
  8988. });
  8989. //请求人信息
  8990. formlyConfigProvider.setType({
  8991. name: 'ui-requesterinformation',
  8992. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  8993. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  8994. return {
  8995. templateOptions: {
  8996. checkform: function (options) {
  8997. if (options.model.requester) {
  8998. options.value(options.model.requester);
  8999. }
  9000. },
  9001. addRequeter: function (size, options, modal) {
  9002. event.preventDefault();
  9003. var modalInstance = modal.open({
  9004. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  9005. controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
  9006. $scope.title = "新增报修人";
  9007. $scope.requester = {};
  9008. $scope.searchData = {};
  9009. $scope.onChangeadd = function (searchData) {
  9010. $scope.searchKey = searchData.account;
  9011. // $scope.searchDataadd = searchData;
  9012. var requesdata = angular.copy(searchData)
  9013. if (requesdata.mphone) {
  9014. delete requesdata.mphone;
  9015. }
  9016. $scope.requester = requesdata;
  9017. }
  9018. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  9019. $scope.requester.account = searchKey;
  9020. $scope.searchData = searchKey;
  9021. serchdataadd(searchKey);
  9022. }
  9023. $scope.getMydata = function (x) {
  9024. $scope.searchField = JSON.parse(x[0]).account;
  9025. $scope.requester = JSON.parse(x[0]);
  9026. }
  9027. $scope.getMydataone = function (x) {
  9028. $scope.searchField = x;
  9029. $scope.requester.account = x;
  9030. }
  9031. serchdataadd();
  9032. api_wechatfile.getDictionary({
  9033. "type": "list",
  9034. "key": "male"
  9035. }).then(function (data) {
  9036. if (data.status == 200) {
  9037. requester.gender = data.list;
  9038. }
  9039. })
  9040. function serchdataadd(searchKey) {
  9041. if (searchKey) {
  9042. var filterData = {
  9043. 'requester': {
  9044. 'searchKey': searchKey,
  9045. },
  9046. idx: 0,
  9047. sum: 10
  9048. };
  9049. } else {
  9050. var filterData = {
  9051. idx: 0,
  9052. sum: 10
  9053. };
  9054. }
  9055. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  9056. var myData = response;
  9057. $scope.myData = myData.list;
  9058. });
  9059. }
  9060. api_user_data.fetchDataList('area', {
  9061. idx: 0,
  9062. sum: 1000
  9063. }).then(function (response) {
  9064. if (response.status == 200) {
  9065. $scope.areas = response.list;
  9066. }
  9067. })
  9068. api_user_data.fetchDataList('requesterType', {
  9069. idx: 0,
  9070. sum: 100
  9071. }).then(function (response) {
  9072. if (response.status == 200) {
  9073. $scope.networktypes = response.list;
  9074. }
  9075. })
  9076. $scope.requesterAreaid = "";
  9077. $scope.onChange = function (item) {
  9078. $scope.requesterAreaid = item.id;
  9079. api_user_data.fetchDataList('place', {
  9080. place: {
  9081. areaId: item.id
  9082. },
  9083. idx: 0,
  9084. sum: 1000
  9085. }).then(function (response) {
  9086. if (response.status == 200) {
  9087. $scope.places = response.list;
  9088. delete $scope.requester.placeDTO;
  9089. }
  9090. })
  9091. }
  9092. $scope.refresh = function (searchVal) {
  9093. var faildata = {};
  9094. if ($scope.requesterAreaid) {
  9095. faildata = {
  9096. 'idx': 0,
  9097. 'sum': 1000,
  9098. 'place': {
  9099. 'areaId': $scope.requesterAreaid,
  9100. 'place': searchVal,
  9101. 'selectType': 'pinyin_qs'
  9102. }
  9103. }
  9104. } else {
  9105. faildata = {
  9106. 'idx': 0,
  9107. 'sum': 1000,
  9108. 'place': {
  9109. 'place': searchVal,
  9110. 'selectType': 'pinyin_qs'
  9111. }
  9112. }
  9113. }
  9114. api_user_data.fetchDataList('place', faildata).then(function (response) {
  9115. $scope.places = response.list;
  9116. delete $scope.requester.placeDTO;
  9117. })
  9118. }
  9119. $scope.refreshDepts = function (key) {
  9120. var filterData = {
  9121. 'idx': 0,
  9122. 'sum': 5,
  9123. 'dept': {
  9124. 'name': key
  9125. }
  9126. };
  9127. UserService.fetchDataList('department', filterData).then(function (response) {
  9128. if (response.status == 200) {
  9129. $scope.depts = response.list;
  9130. }
  9131. })
  9132. }
  9133. $scope.ok = function () {
  9134. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  9135. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  9136. // } else if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  9137. // SweetAlert.swal("请求人学工号未填!", "请填写请求人学工号", "error");
  9138. // } else if (angular.isUndefined($scope.requester.requesterTypeDTO) || $scope.requester.requesterTypeDTO == null || $scope.requester.requesterTypeDTO == "") {
  9139. // SweetAlert.swal("请求人职务未填!", "请填写请求人职务", "error");
  9140. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  9141. SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
  9142. } else {
  9143. $scope.requesterId = $scope.requester.id;
  9144. var data = {
  9145. incident: {
  9146. requester: {
  9147. id: $scope.requesterId
  9148. }
  9149. },
  9150. idx: 0,
  9151. sum: 3
  9152. };
  9153. api_statistic.tableData(data, 'incident').then(function (data) {
  9154. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  9155. })
  9156. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  9157. if (newObj != oldObj) {
  9158. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  9159. }
  9160. })
  9161. $modalInstance.close($scope.requester);
  9162. }
  9163. };
  9164. $scope.cancel = function () {
  9165. $modalInstance.dismiss('cancel');
  9166. };
  9167. },
  9168. resolve: {
  9169. items: function () {
  9170. return {
  9171. fetchItems: function (filterData, APIService) {
  9172. filterData = filterData || {};
  9173. if (!filterData.idx) {
  9174. filterData = {
  9175. idx: 0,
  9176. sum: 10
  9177. };
  9178. }
  9179. return options.templateOptions.fetchItems(filterData, APIService);
  9180. }
  9181. };
  9182. },
  9183. title: function () {
  9184. return options.templateOptions.modalTitle;
  9185. },
  9186. Restangular: function () {
  9187. return options.templateOptions.Restangular;
  9188. },
  9189. APIService: function () {
  9190. return options.templateOptions.ApiService;
  9191. },
  9192. UserService: function () {
  9193. return options.templateOptions.UserService;
  9194. },
  9195. sco: function () {
  9196. return $scope;
  9197. }
  9198. }
  9199. });
  9200. modalInstance.result.then(function (selectedItem) {
  9201. console.log(selectedItem)
  9202. if (selectedItem) {
  9203. var data = {
  9204. 'requester': selectedItem
  9205. };
  9206. $scope.searchKey = selectedItem.account;
  9207. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  9208. if(selectedItem.place.place){
  9209. $scope.$parent.$parent.$parent.model.incident.faultLocation=selectedItem.place.area.area+selectedItem.place.place
  9210. }
  9211. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  9212. if (response.status == 200) {
  9213. if (options.model) {
  9214. if (options.model.place) {
  9215. options.model.place.id = '';
  9216. }
  9217. if (options.model.area) {
  9218. options.model.area.id = '';
  9219. }
  9220. if(options.model.place.place){
  9221. options.model.faultLocation=options.model.place.area.area+options.model.place.place
  9222. }
  9223. options.model.contacts = selectedItem.name;
  9224. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  9225. options.model.contactsInformation = selectedItem.mphone;
  9226. } else {
  9227. options.model.contactsInformation = selectedItem.telephone;
  9228. }
  9229. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9230. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9231. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9232. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9233. }
  9234. }
  9235. if (!response.data.id) {
  9236. response.data.id = selectedItem.id
  9237. }
  9238. options.value(response.data);
  9239. options.value(response.data);
  9240. if (selectedItem.place && selectedItem.place.id) {
  9241. options.model.place.id = selectedItem.place.id
  9242. options.model.area.id = selectedItem.place.area.id
  9243. }
  9244. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  9245. // options.model.area.id = selectedItem.place.area.id
  9246. // }
  9247. if (selectedItem.houseNumber) {
  9248. options.model.houseNumber = selectedItem.houseNumber
  9249. }
  9250. if (selectedItem.id) {
  9251. $scope.$parent.$parent.$parent.model.xxx = selectedItem.id;
  9252. options.model.account = selectedItem.account;
  9253. }
  9254. }
  9255. })
  9256. }
  9257. }, function () {});
  9258. },
  9259. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  9260. var modalInstance = modal.open({
  9261. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  9262. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  9263. $scope.title = "修改报修人";
  9264. $scope.requester = {
  9265. id: modeldata.requester.id,
  9266. account: modeldata.requester.account,
  9267. name: modeldata.requester.name,
  9268. gender: modeldata.requester.gender,
  9269. email: modeldata.requester.email,
  9270. deptName: modeldata.requester.deptName,
  9271. mphone: modeldata.requester.mphone,
  9272. telephone: modeldata.requester.telephone,
  9273. studentNo: modeldata.requester.studentNo,
  9274. areaDTO: modeldata.requester.areaDTO,
  9275. placeDTO: modeldata.requester.placeDTO,
  9276. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  9277. };
  9278. $scope.onChangeadd = function (searchData) {
  9279. $scope.searchKey = searchData.account;
  9280. var requesdata = angular.copy(searchData)
  9281. if (requesdata.mphone) {
  9282. delete requesdata.mphone;
  9283. }
  9284. $scope.requester = requesdata;
  9285. }
  9286. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  9287. $scope.requester.account = searchKey;
  9288. $scope.searchData = searchKey;
  9289. serchdataadd(searchKey);
  9290. }
  9291. $scope.getMydata = function (x) {
  9292. $scope.searchField = JSON.parse(x[0]).account;
  9293. $scope.requester = JSON.parse(x[0]);
  9294. }
  9295. $scope.getMydataone = function (x) {
  9296. $scope.searchField = x;
  9297. $scope.requester.account = x;
  9298. }
  9299. serchdataadd();
  9300. function serchdataadd(searchKey) {
  9301. if (searchKey) {
  9302. var filterData = {
  9303. 'requester': {
  9304. 'searchKey': searchKey,
  9305. },
  9306. idx: 0,
  9307. sum: 10
  9308. };
  9309. } else {
  9310. var filterData = {
  9311. idx: 0,
  9312. sum: 10
  9313. };
  9314. }
  9315. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  9316. var myData = response;
  9317. $scope.myData = myData.list;
  9318. });
  9319. }
  9320. api_user_data.fetchDataList('area', {
  9321. idx: 0,
  9322. sum: 1000
  9323. }).then(function (response) {
  9324. if (response.status == 200) {
  9325. $scope.areas = response.list;
  9326. }
  9327. })
  9328. api_user_data.fetchDataList('requesterType', {
  9329. idx: 0,
  9330. sum: 100
  9331. }).then(function (response) {
  9332. if (response.status == 200) {
  9333. $scope.networktypes = response.list;
  9334. }
  9335. })
  9336. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  9337. api_user_data.fetchDataList('place', {
  9338. place: {
  9339. areaId: $scope.requester.areaDTO.id
  9340. },
  9341. idx: 0,
  9342. sum: 1000
  9343. }).then(function (response) {
  9344. if (response.status == 200) {
  9345. $scope.places = response.list;
  9346. }
  9347. })
  9348. }
  9349. $scope.onChange = function (item) {
  9350. $scope.requester.placeDTO = {};
  9351. api_user_data.fetchDataList('place', {
  9352. place: {
  9353. areaId: item.id
  9354. },
  9355. idx: 0,
  9356. sum: 1000
  9357. }).then(function (response) {
  9358. if (response.status == 200) {
  9359. $scope.places = response.list;
  9360. }
  9361. })
  9362. }
  9363. $scope.refreshDepts = function (key) {
  9364. var filterData = {
  9365. 'idx': 0,
  9366. 'sum': 5,
  9367. 'dept': {
  9368. 'name': key
  9369. }
  9370. };
  9371. UserService.fetchDataList('department', filterData).then(function (response) {
  9372. if (response.status == 200) {
  9373. $scope.depts = response.list;
  9374. }
  9375. })
  9376. }
  9377. $scope.ok = function () {
  9378. if ($scope.requester.account == "" || $scope.requester.name == "") {
  9379. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  9380. } else {
  9381. $modalInstance.close($scope.requester);
  9382. }
  9383. };
  9384. $scope.cancel = function () {
  9385. $modalInstance.dismiss('cancel');
  9386. };
  9387. },
  9388. resolve: {
  9389. items: function () {
  9390. return {
  9391. fetchItems: function (filterData, APIService) {
  9392. filterData = filterData || {};
  9393. if (!filterData.idx) {
  9394. filterData = {
  9395. idx: 0,
  9396. sum: 10
  9397. };
  9398. }
  9399. return options.templateOptions.fetchItems(filterData, APIService);
  9400. }
  9401. };
  9402. },
  9403. title: function () {
  9404. return options.templateOptions.modalTitle;
  9405. },
  9406. Restangular: function () {
  9407. return options.templateOptions.Restangular;
  9408. },
  9409. APIService: function () {
  9410. return options.templateOptions.ApiService;
  9411. },
  9412. UserService: function () {
  9413. return options.templateOptions.UserService;
  9414. }
  9415. }
  9416. });
  9417. modalInstance.result.then(function (selectedItem) {
  9418. console.log(selectedItem)
  9419. if (selectedItem) {
  9420. if (options.model) {
  9421. if (options.model.place) {
  9422. options.model.place.id = '';
  9423. }
  9424. if (options.model.area) {
  9425. options.model.area.id = '';
  9426. }
  9427. options.model.contacts = selectedItem.name;
  9428. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  9429. options.model.contactsInformation = selectedItem.mphone;
  9430. } else {
  9431. options.model.contactsInformation = selectedItem.telephone;
  9432. }
  9433. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  9434. options.model.place.id = selectedItem.placeDTO.id
  9435. }
  9436. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  9437. options.model.area.id = selectedItem.areaDTO.id
  9438. }
  9439. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9440. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9441. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9442. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9443. }
  9444. }
  9445. var data = {
  9446. 'requester': selectedItem
  9447. };
  9448. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  9449. if (response.status == 200) {
  9450. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  9451. options.value(response.data);
  9452. } else {}
  9453. })
  9454. }
  9455. }, function () {});
  9456. event.preventDefault();
  9457. }
  9458. }
  9459. };
  9460. },
  9461. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  9462. $scope.options.initialValue = $scope.model[$scope.options.key];
  9463. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  9464. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9465. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9466. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9467. }
  9468. }]
  9469. });
  9470. // 请求人选控件
  9471. formlyConfigProvider.setType({
  9472. name: "ui-requesterselect",
  9473. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  9474. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  9475. defaultOptions: function (options, $scope) {
  9476. return {
  9477. templateOptions: {
  9478. // checkform: function(options) {
  9479. // if (options.model.requestershow) {
  9480. // options.value(options.model.requestershow);
  9481. // }
  9482. // },
  9483. validators: {
  9484. required: {
  9485. expression: function (viewValue, modelValue) {
  9486. var value = modelValue || viewValue;
  9487. return value.length >= 1;
  9488. }
  9489. }
  9490. },
  9491. openModal: function (size, options, modal) { //查找弹出框
  9492. var modelObject = options.value();
  9493. var searchModal = function (filterSearchData) {
  9494. var modalInstance = modal.open({
  9495. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  9496. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  9497. $scope.langs = i18nService.getAllLangs();
  9498. $scope.lang = 'zh-cn';
  9499. i18nService.setCurrentLang($scope.lang);
  9500. $scope.gridOptions = {};
  9501. $scope.gridOptions.data = 'myData';
  9502. $scope.gridOptions.enableColumnResizing = true;
  9503. $scope.gridOptions.enableFiltering = true;
  9504. $scope.gridOptions.enableGridMenu = false;
  9505. $scope.gridOptions.enableRowSelection = true;
  9506. $scope.gridOptions.showGridFooter = true;
  9507. $scope.gridOptions.showColumnFooter = false;
  9508. $scope.gridOptions.fastWatch = true;
  9509. $scope.gridOptions.useExternalFiltering = true;
  9510. $scope.gridOptions.useExternalPagination = true;
  9511. $scope.gridOptions.paginationPageSizes = [10];
  9512. $scope.gridOptions.paginationPageSize = 10;
  9513. $scope.gridOptions.multiSelect = false;
  9514. $scope.gridOptions.rowIdentity = function (row) {
  9515. return row.id;
  9516. };
  9517. $scope.gridOptions.getRowIdentity = function (row) {
  9518. return row.id;
  9519. };
  9520. $scope.gridOptions.columnDefs = [{
  9521. name: 'account',
  9522. displayName: '人员编号',
  9523. width: 140
  9524. },
  9525. {
  9526. name: 'name',
  9527. displayName: '姓名',
  9528. width: 100
  9529. },
  9530. {
  9531. name: 'gender.name',
  9532. displayName: '性别',
  9533. width: 80,
  9534. enableFiltering: false
  9535. },
  9536. {
  9537. name: 'mphone',
  9538. displayName: '电话',
  9539. width: 100,
  9540. enableFiltering: false
  9541. },
  9542. {
  9543. name: 'email',
  9544. displayName: '邮件',
  9545. width: 100
  9546. },
  9547. {
  9548. name: 'areaDTO.area',
  9549. displayName: '区域',
  9550. width: 100,
  9551. enableFiltering: false
  9552. },
  9553. {
  9554. name: 'placeDTO.place',
  9555. displayName: '地点',
  9556. enableFiltering: false
  9557. }
  9558. ];
  9559. $scope.gridOptions.onRegisterApi = function (gridApi) {
  9560. $scope.gridApi = gridApi;
  9561. // var filtersData = $scope.memoryfilterData;
  9562. // filtersData.idx = newPage - 1;
  9563. // filtersData.sum = pageSize;
  9564. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  9565. var filtersData = $scope.memoryfilterData;
  9566. filtersData.idx = newPage - 1;
  9567. filtersData.sum = pageSize;
  9568. $scope.loadData(filtersData);
  9569. });
  9570. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  9571. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  9572. $scope.selected.item = data.entity;
  9573. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  9574. });
  9575. gridApi.core.on.filterChanged($scope, function () {
  9576. var grid = this.grid;
  9577. var filtersData = {
  9578. idx: 0,
  9579. sum: 10
  9580. // 'requester': { 'userType': 1 }
  9581. };
  9582. angular.forEach(grid.columns, function (item) {
  9583. if (item.enableFiltering) {
  9584. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  9585. if (angular.isUndefined(filtersData['requester'])) {
  9586. filtersData['requester'] = {};
  9587. }
  9588. filtersData['requester'][item.field] = item.filters[0].term;
  9589. }
  9590. }
  9591. });
  9592. $scope.memoryfilterData = filtersData;
  9593. $scope.loadData(filtersData);
  9594. });
  9595. };
  9596. $scope.memoryfilterData = defaultFilterData = {
  9597. "idx": 0,
  9598. "sum": 10
  9599. };
  9600. $scope.loadData = function (filterData) {
  9601. if (!filterData.requester) {
  9602. filterData.requester = {};
  9603. }
  9604. if (scope.roleidcode) {
  9605. angular.extend(filterData['requester'], {
  9606. 'userType': 1
  9607. });
  9608. }
  9609. items.fetchItems(filterData, APIService).then(function (data) {
  9610. var myData = Restangular.stripRestangular(data);
  9611. $scope.gridOptions.totalItems = myData.totalNum;
  9612. $scope.myData = myData.list;
  9613. });
  9614. };
  9615. // $scope.title = title;
  9616. if (searchDatas) {
  9617. $scope.loadData(searchDatas);
  9618. } else {
  9619. $scope.loadData({
  9620. idx: 0,
  9621. sum: 10,
  9622. });
  9623. }
  9624. $scope.selected = {
  9625. item: {}
  9626. };
  9627. $scope.ok = function () {
  9628. $modalInstance.close($scope.selected.item);
  9629. };
  9630. $scope.cancel = function () {
  9631. $modalInstance.dismiss('cancel');
  9632. };
  9633. },
  9634. size: size,
  9635. resolve: {
  9636. items: function () {
  9637. return {
  9638. fetchItems: function (filterData, APIService) {
  9639. filterData = filterData || {};
  9640. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  9641. filterData = {
  9642. idx: 0,
  9643. sum: 10
  9644. };
  9645. }
  9646. return options.templateOptions.fetchItems(filterData, APIService);
  9647. }
  9648. };
  9649. },
  9650. title: function () {
  9651. return options.templateOptions.modalTitle;
  9652. },
  9653. Restangular: function () {
  9654. return options.templateOptions.Restangular;
  9655. },
  9656. APIService: function () {
  9657. return options.templateOptions.ApiService;
  9658. },
  9659. language: function () {
  9660. return options.templateOptions.language;
  9661. },
  9662. searchDatas: function () {
  9663. return filterSearchData;
  9664. },
  9665. scope: function () {
  9666. return $scope;
  9667. }
  9668. }
  9669. });
  9670. modalInstance.result.then(function (selectedItem) {
  9671. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  9672. selectedItem.telephone = $scope.model.incident.contactsInformation;
  9673. }
  9674. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  9675. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  9676. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  9677. if ($scope.model) {
  9678. if ($scope.model.incident.place) {
  9679. $scope.model.incident.place.id = '';
  9680. }
  9681. if ($scope.model.area) {
  9682. $scope.model.incident.area.id = '';
  9683. }
  9684. $scope.model.incident.contacts = selectedItem.name;
  9685. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  9686. $scope.model.incident.contactsInformation = selectedItem.mphone;
  9687. } else {
  9688. $scope.model.incident.contactsInformation = selectedItem.telephone;
  9689. }
  9690. $scope.model.incident.houseNumber = '';
  9691. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9692. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9693. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9694. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9695. }
  9696. }
  9697. $scope.options.value(selectedItem);
  9698. $scope.searchData = selectedItem.account;
  9699. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  9700. $scope.model.incident.place.id = selectedItem.placeDTO.id
  9701. }
  9702. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  9703. $scope.model.incident.area.id = selectedItem.areaDTO.id
  9704. }
  9705. if (selectedItem.houseNumber) {
  9706. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  9707. }
  9708. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9709. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9710. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9711. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9712. }
  9713. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  9714. options.templateOptions.callback(selectedItem, options);
  9715. }
  9716. if (!$scope.roleidcode) {
  9717. $scope.charging(selectedItem, modal)
  9718. }
  9719. $scope.recentlyincident(selectedItem);
  9720. }, function () {
  9721. //console.log('Modal dismissed at: ' + new Date());
  9722. });
  9723. }
  9724. searchModal();
  9725. // }
  9726. }
  9727. }
  9728. };
  9729. },
  9730. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  9731. $scope.roleidcode = true;
  9732. // $scope.options.initialValue = undefined;
  9733. if ($rootScope.user && $rootScope.user.role) {
  9734. angular.forEach($rootScope.user.role, function (item) {
  9735. if (item.rolecode == "call center") {
  9736. $scope.roleidcode = false;
  9737. }
  9738. })
  9739. }
  9740. $scope.recently = false;
  9741. $scope.recentlyincident = function (key, model) { //关联事件
  9742. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  9743. "idx": 0,
  9744. "sum": 4,
  9745. incident: {
  9746. requester: {
  9747. id: key.id
  9748. }
  9749. }
  9750. }).then(function (response) {
  9751. if (response.status == 200) {
  9752. $scope.recently = true;
  9753. $scope.recentincident = response.list;
  9754. } else {
  9755. $scope.recently = false;
  9756. }
  9757. })
  9758. $scope.bodyHeight = window.innerHeight - 100;
  9759. $(window).resize(function () {
  9760. $scope.bodyHeight = window.innerHeight - 100;
  9761. });
  9762. // $scope.shows = false;
  9763. $scope.tempData = {};
  9764. $scope.close = function () {
  9765. $scope.changes = !$scope.changes;
  9766. event.preventDefault();
  9767. }
  9768. }
  9769. $scope.charging = function (key, model) { //计费弹出框
  9770. //用户信息
  9771. $scope.information = {};
  9772. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  9773. "userId": key.account
  9774. }).then(function (response) {
  9775. // if (response.status == 200) {
  9776. if (response && response.data) {
  9777. angular.extend($scope.information, response.data[0]);
  9778. // $scope.information = response.data[0];
  9779. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  9780. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  9781. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  9782. } else if (response.err) {
  9783. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  9784. }
  9785. // }
  9786. })
  9787. //上网明细
  9788. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  9789. "userId": key.account,
  9790. "limit": "10",
  9791. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  9792. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  9793. }).then(function (response) {
  9794. // if (response.status == 200) {
  9795. if (response && response.data) {
  9796. angular.forEach(response.data, function (item, index) {
  9797. if (item.logoutTime) {
  9798. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  9799. }
  9800. if (item.loginTime) {
  9801. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  9802. }
  9803. })
  9804. $scope.logininform = response.data;
  9805. } else if (response.err) {
  9806. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  9807. }
  9808. })
  9809. //黑名单
  9810. // $scope.information.blacklist = "否"
  9811. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  9812. "userId": key.account
  9813. }).then(function (response) {
  9814. // if (response.status == 200) {
  9815. // $scope.logininformation = response.data;
  9816. if (response) {
  9817. if (response.data || response.data != null) {
  9818. $scope.information.blacklist = "是"
  9819. } else {
  9820. if (response.err) {
  9821. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  9822. } else {
  9823. $scope.information.blacklist = "否"
  9824. }
  9825. }
  9826. }
  9827. // }
  9828. })
  9829. $scope.bodyHeight = window.innerHeight - 100;
  9830. $(window).resize(function () {
  9831. $scope.bodyHeight = window.innerHeight - 100;
  9832. });
  9833. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  9834. // $scope.closepages = function(e) {
  9835. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  9836. // event.preventDefault();
  9837. // };
  9838. // $scope.shows = false;
  9839. $scope.tempData = {};
  9840. $scope.close = function () {
  9841. $scope.changes = !$scope.changes;
  9842. event.preventDefault();
  9843. }
  9844. }
  9845. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  9846. idx: 0,
  9847. sum: 100
  9848. }).then(function (response) {
  9849. if (response.status == 200) {
  9850. $scope.networktypes = response.list;
  9851. } else {
  9852. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  9853. }
  9854. })
  9855. function serchdata(searchKey) {
  9856. if (searchKey) {
  9857. var filterData = {
  9858. 'requester': {
  9859. 'searchKey': searchKey
  9860. // 'userType': 1
  9861. },
  9862. idx: 0,
  9863. sum: 10
  9864. };
  9865. } else {
  9866. var filterData = {
  9867. 'idx': 0,
  9868. 'requester': {},
  9869. 'sum': 10
  9870. };
  9871. }
  9872. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  9873. angular.extend(filterData.requester, {
  9874. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  9875. });
  9876. if (!$scope.options.model.contactsInformation) {
  9877. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  9878. }
  9879. }
  9880. if ($scope.roleidcode) {
  9881. angular.extend(filterData['requester'], {
  9882. 'userType': 1
  9883. });
  9884. }
  9885. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  9886. var myData = response;
  9887. $scope.myData = myData.list;
  9888. });
  9889. }
  9890. $scope.searchData = {};
  9891. $scope.refreshUser = function (searchKey) { //请求人搜索
  9892. if (searchKey && searchKey != "") {
  9893. serchdata(searchKey);
  9894. }
  9895. }
  9896. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  9897. if (!$scope.roleidcode) {
  9898. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  9899. }
  9900. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  9901. }
  9902. $scope.onChange = function (searchData) {
  9903. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  9904. searchData.telephone = $scope.model.incident.contactsInformation;;
  9905. }
  9906. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  9907. if (!$scope.roleidcode) {
  9908. $scope.charging(searchData);
  9909. }
  9910. $scope.recentlyincident(searchData);
  9911. $scope.accountshow = false;
  9912. if ($scope.model.incident) {
  9913. if ($scope.model.incident.place) {
  9914. $scope.model.incident.place.id = '';
  9915. }
  9916. if ($scope.model.incident.area) {
  9917. $scope.model.incident.area.id = '';
  9918. }
  9919. $scope.model.incident.contacts = searchData.name;
  9920. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  9921. $scope.model.incident.contactsInformation = searchData.mphone;
  9922. } else {
  9923. $scope.model.incident.contactsInformation = searchData.telephone;
  9924. }
  9925. $scope.model.incident.houseNumber = '';
  9926. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  9927. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9928. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9929. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  9930. }
  9931. }
  9932. $scope.options.value(searchData);
  9933. $scope.searchKey = searchData.account;
  9934. if (searchData.placeDTO && searchData.placeDTO.id) {
  9935. $scope.model.incident.place.id = searchData.placeDTO.id
  9936. }
  9937. if (searchData.areaDTO && searchData.areaDTO.id) {
  9938. $scope.model.incident.area.id = searchData.areaDTO.id
  9939. }
  9940. if (searchData.houseNumber) {
  9941. $scope.model.incident.houseNumber = searchData.houseNumber;
  9942. }
  9943. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  9944. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9945. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9946. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  9947. }
  9948. }
  9949. }]
  9950. });
  9951. //ui-grid-table展示控件
  9952. formlyConfigProvider.setType({
  9953. name: 'ui-grid-table',
  9954. // extends: 'multiCheckbox',//去掉冒号
  9955. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  9956. defaultOptions: function (options) {
  9957. return {
  9958. templateOptions: {
  9959. linkage: function () {},
  9960. },
  9961. };
  9962. },
  9963. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  9964. var loginUser = $rootScope.user;
  9965. $scope.langs = i18nService.getAllLangs();
  9966. $scope.lang = 'zh-cn';
  9967. i18nService.setCurrentLang($scope.lang);
  9968. $scope.gridOptions = {};
  9969. $scope.gridOptions.data = 'myData';
  9970. $scope.gridOptions.enableColumnResizing = true;
  9971. $scope.gridOptions.enableGridMenu = false;
  9972. $scope.gridOptions.enableRowSelection = true;
  9973. $scope.gridOptions.showGridFooter = false;
  9974. $scope.gridOptions.showColumnFooter = false;
  9975. $scope.gridOptions.fastWatch = true;
  9976. $scope.gridOptions.useExternalFiltering = true;
  9977. $scope.gridOptions.useExternalPagination = false;
  9978. $scope.gridOptions.paginationPageSizes = [10];
  9979. $scope.gridOptions.paginationPageSize = 3;
  9980. $scope.gridOptions.multiSelect = false;
  9981. $scope.gridOptions.rowIdentity = function (row) {
  9982. return row.id;
  9983. };
  9984. $scope.gridOptions.getRowIdentity = function (row) {
  9985. return row.id;
  9986. };
  9987. $scope.gridOptions.columnDefs = [{
  9988. name: 'item',
  9989. displayName: '序号',
  9990. width: 80,
  9991. enableFiltering: false
  9992. },
  9993. {
  9994. name: 'incidentsign',
  9995. displayName: '单号',
  9996. width: 80,
  9997. enableFiltering: false
  9998. },
  9999. {
  10000. name: 'description',
  10001. displayName: '主题',
  10002. width: 80,
  10003. enableFiltering: false
  10004. },
  10005. {
  10006. name: 'state.name',
  10007. displayName: '状态',
  10008. width: 110,
  10009. enableFiltering: false
  10010. },
  10011. {
  10012. name: 'acceptDate',
  10013. displayName: '创建时间',
  10014. width: 160,
  10015. enableFiltering: false
  10016. },
  10017. {
  10018. name: 'requester.name',
  10019. displayName: '请求人',
  10020. width: 80,
  10021. enableFiltering: false
  10022. },
  10023. {
  10024. name: 'handlingPersonnelUser.name',
  10025. displayName: '处理人',
  10026. width: 160,
  10027. enableFiltering: false
  10028. },
  10029. {
  10030. name: 'place.place',
  10031. displayName: '区域地点',
  10032. width: 160,
  10033. enableFiltering: false
  10034. },
  10035. ];
  10036. // var defaultFilterData = {
  10037. // "idx": 0,
  10038. // "sum": 3
  10039. // };
  10040. // // //分页控制
  10041. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10042. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10043. var filtersData = $scope.memoryfilterData;
  10044. filtersData.idx = newPage - 1;
  10045. filtersData.sum = pageSize;
  10046. $scope.refreshData('expand-right', filtersData);
  10047. });
  10048. // 表格单选事件
  10049. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10050. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  10051. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  10052. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  10053. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  10054. str = str.split("").reverse().join("");
  10055. var del = addstr.split("").reverse().join("");
  10056. // console.log(del);
  10057. var reg = new RegExp(del);
  10058. str = str.replace(reg, '');
  10059. str = str.split("").reverse().join("")
  10060. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  10061. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  10062. str += data.entity.description;
  10063. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  10064. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  10065. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  10066. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  10067. }
  10068. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  10069. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  10070. });
  10071. };
  10072. // 刷新表格
  10073. setInterval(function () {
  10074. // console.log($scope.myData);
  10075. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  10076. // console.log($scope.myData);
  10077. if ($scope.myData != null) {
  10078. for (var i = 0; i < $scope.myData.length; i++) {
  10079. //添加序号
  10080. $scope.myData[i]['item'] = i + 1;
  10081. }
  10082. }
  10083. }, 1000)
  10084. }
  10085. });
  10086. //处理人信息
  10087. formlyConfigProvider.setType({
  10088. name: "ui-userinformation",
  10089. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  10090. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10091. defaultOptions: function (options) {
  10092. return {
  10093. templateOptions: {}
  10094. };
  10095. },
  10096. controller: ['$scope', function ($scope) {
  10097. $scope.group = "";
  10098. $scope.role = "";
  10099. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10100. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10101. } else {
  10102. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10103. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10104. }
  10105. }
  10106. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10107. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10108. } else {
  10109. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10110. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10111. }
  10112. }
  10113. $scope.options.templateOptions.that = $scope;
  10114. }]
  10115. });
  10116. //处理界面处理人信息
  10117. formlyConfigProvider.setType({
  10118. name: "ui-handler",
  10119. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  10120. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10121. defaultOptions: function (options) {
  10122. return {
  10123. templateOptions: {}
  10124. };
  10125. },
  10126. controller: ['$scope', function ($scope) {
  10127. $scope.group = "";
  10128. // $scope.role="";
  10129. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10130. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10131. } else {
  10132. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10133. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10134. }
  10135. }
  10136. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  10137. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  10138. // }else{
  10139. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  10140. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  10141. // }
  10142. // }
  10143. $scope.options.templateOptions.that = $scope;
  10144. }]
  10145. });
  10146. //打电话
  10147. formlyConfigProvider.setType({
  10148. name: "ui-inputcall",
  10149. extends: 'input',
  10150. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  10151. defaultOptions: function (options) {
  10152. return {
  10153. templateOptions: {
  10154. transform: function (value) {}
  10155. }
  10156. };
  10157. },
  10158. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  10159. $scope.dialout = function (teleno) {
  10160. var gid = "@0"
  10161. var telephone = '9' + teleno
  10162. $rootScope.callout = 2;
  10163. if ($rootScope.takes) {
  10164. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  10165. if (data.errno == 0) {
  10166. $rootScope.status = 6;
  10167. }
  10168. })
  10169. } else {
  10170. SweetAlert.swal({
  10171. title: "呼叫失败",
  10172. text: "请先签入呼叫中心!",
  10173. type: "error",
  10174. confirmButtonColor: "#DD6B55"
  10175. });
  10176. }
  10177. }
  10178. $scope.options.templateOptions.that = $scope;
  10179. }]
  10180. });
  10181. //关闭界面处理人信息
  10182. formlyConfigProvider.setType({
  10183. name: "ui-closehandler",
  10184. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  10185. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10186. defaultOptions: function (options) {
  10187. return {
  10188. templateOptions: {}
  10189. };
  10190. },
  10191. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  10192. $scope.dialout = function (teleno) {
  10193. var gid = "@0"
  10194. var telephone = '9' + teleno
  10195. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  10196. if (data.errno == 0) {
  10197. $rootScope.status = 6;
  10198. }
  10199. })
  10200. }
  10201. $scope.options.templateOptions.that = $scope;
  10202. }]
  10203. });
  10204. //用户单选控件
  10205. formlyConfigProvider.setType({
  10206. name: "ui-userselect",
  10207. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  10208. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10209. defaultOptions: function (options) {
  10210. return {
  10211. templateOptions: {
  10212. openModal: function (size, options, modal) {
  10213. var modalInstance = modal.open({
  10214. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10215. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  10216. $scope.langs = i18nService.getAllLangs();
  10217. $scope.lang = 'zh-cn';
  10218. i18nService.setCurrentLang($scope.lang);
  10219. $scope.gridOptions = {};
  10220. $scope.gridOptions.data = 'myData';
  10221. $scope.gridOptions.enableColumnResizing = true;
  10222. $scope.gridOptions.enableFiltering = true;
  10223. $scope.gridOptions.enableGridMenu = false;
  10224. $scope.gridOptions.showGridFooter = true;
  10225. $scope.gridOptions.showColumnFooter = false;
  10226. $scope.gridOptions.fastWatch = true;
  10227. $scope.gridOptions.useExternalFiltering = true;
  10228. $scope.gridOptions.useExternalPagination = true;
  10229. $scope.gridOptions.paginationPageSizes = [20];
  10230. $scope.gridOptions.paginationPageSize = 20;
  10231. $scope.gridOptions.multiSelect = false;
  10232. $scope.gridOptions.rowIdentity = function (row) {
  10233. return row.id;
  10234. };
  10235. $scope.gridOptions.getRowIdentity = function (row) {
  10236. return row.id;
  10237. };
  10238. $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>";
  10239. $scope.gridOptions.columnDefs = [{
  10240. name: 'account',
  10241. displayName: '人员编号',
  10242. width: 120
  10243. },
  10244. {
  10245. name: 'name',
  10246. displayName: '姓名',
  10247. width: 100,
  10248. cellTemplate: '<div>' +
  10249. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  10250. '</div>'
  10251. },
  10252. {
  10253. name: 'gender.name',
  10254. displayName: '性别',
  10255. width: 80,
  10256. enableFiltering: false
  10257. },
  10258. {
  10259. name: 'phone',
  10260. displayName: '电话',
  10261. width: 100,
  10262. enableFiltering: false
  10263. },
  10264. {
  10265. name: 'email',
  10266. displayName: '邮箱',
  10267. width: 150,
  10268. enableFiltering: false
  10269. },
  10270. {
  10271. name: 'dept.dept',
  10272. displayName: '部门',
  10273. width: 130,
  10274. enableFiltering: false
  10275. },
  10276. {
  10277. name: 'taskCount',
  10278. displayName: '处理中事件数',
  10279. enableFiltering: false
  10280. }
  10281. ];
  10282. // $scope.selectButtonClick
  10283. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10284. $scope.gridApi = gridApi;
  10285. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10286. var filtersData = $scope.memoryfilterData;
  10287. filtersData.idx = newPage - 1;
  10288. filtersData.sum = pageSize;
  10289. $scope.loadData(filtersData);
  10290. //console.log(pageSize);
  10291. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  10292. });
  10293. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10294. $scope.selected.items = data.entity;
  10295. //console.log(data);
  10296. });
  10297. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  10298. $scope.selected.items = data.entity;
  10299. //console.log(data);
  10300. });
  10301. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  10302. // // if (row.entity.age > 45) {
  10303. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10304. // // }
  10305. // };
  10306. gridApi.core.on.filterChanged($scope, function () {
  10307. var grid = this.grid;
  10308. var filtersData = {
  10309. idx: 0,
  10310. sum: 20,
  10311. "user": {
  10312. "roledata": {
  10313. "rolecode": "roleset"
  10314. },
  10315. "selectType": "1"
  10316. }
  10317. };
  10318. angular.forEach(grid.columns, function (item) {
  10319. if (item.enableFiltering) {
  10320. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  10321. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10322. if (angular.isUndefined(filtersData['user'])) {
  10323. filtersData['user'] = {};
  10324. }
  10325. filtersData['user'][item.field] = item.filters[0].term;
  10326. }
  10327. }
  10328. });
  10329. $scope.memoryfilterData = filtersData;
  10330. $scope.loadData(filtersData);
  10331. });
  10332. };
  10333. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  10334. // if (row.entity.age > 45) {
  10335. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10336. // }
  10337. // },
  10338. $scope.onDblClick = function (data, event) {
  10339. // $scope.selected.items = data.entity;
  10340. $scope.selectButtonClick(data, event);
  10341. };
  10342. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  10343. // $scope.selected.items = data.entity;
  10344. // })
  10345. // };
  10346. $scope.memoryfilterData = {
  10347. "idx": 0,
  10348. "sum": 20,
  10349. "user": {
  10350. "roledata": {
  10351. "rolecode": "roleset"
  10352. },
  10353. "selectType": "1"
  10354. }
  10355. }
  10356. $scope.loadData = function (filterData) {
  10357. // console.log("filtersData=111" + JSON.stringify(filterData))
  10358. items.fetchItems(filterData, APIService).then(function (data) {
  10359. var myData = Restangular.stripRestangular(data);
  10360. $scope.gridOptions.totalItems = myData.totalNum;
  10361. $scope.myData = myData.list;
  10362. });
  10363. };
  10364. // $scope.title = title;
  10365. $scope.loadData({
  10366. idx: 0,
  10367. sum: 20,
  10368. "user": {
  10369. "roledata": {
  10370. "rolecode": "roleset"
  10371. },
  10372. "selectType": "1"
  10373. }
  10374. });
  10375. $scope.selected = {
  10376. items: {}
  10377. };
  10378. $scope.ok = function () {
  10379. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  10380. // onDataCallback($scope.selected.item, parentScope);
  10381. // }
  10382. $modalInstance.close($scope.selected.items);
  10383. };
  10384. $scope.cancel = function () {
  10385. $modalInstance.dismiss('cancel');
  10386. };
  10387. },
  10388. size: size,
  10389. resolve: {
  10390. items: function () {
  10391. return {
  10392. fetchItems: function (filterData, APIService) {
  10393. filterData = filterData || {};
  10394. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10395. filterData = {
  10396. idx: 0,
  10397. sum: 20,
  10398. "user": {
  10399. "roledata": {
  10400. "rolecode": "roleset"
  10401. },
  10402. "selectType": "1"
  10403. }
  10404. };
  10405. }
  10406. return options.templateOptions.fetchItems(filterData, APIService);
  10407. }
  10408. };
  10409. },
  10410. title: function () {
  10411. return options.templateOptions.label;
  10412. },
  10413. Restangular: function () {
  10414. return options.templateOptions.Restangular;
  10415. },
  10416. APIService: function () {
  10417. return options.templateOptions.ApiService;
  10418. },
  10419. onDataCallback: function () {
  10420. return options.templateOptions.callback;
  10421. },
  10422. parentScope: function () {
  10423. return options.templateOptions.that;
  10424. }
  10425. }
  10426. });
  10427. modalInstance.result.then(function (selectedItem) {
  10428. // console.log(selectedItem);
  10429. options.value(selectedItem);
  10430. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  10431. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  10432. }
  10433. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  10434. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  10435. }
  10436. }, function () {
  10437. //console.log('Modal dismissed at: ' + new Date());
  10438. });
  10439. }
  10440. }
  10441. };
  10442. },
  10443. controller: ['$scope', function ($scope) {
  10444. $scope.options.templateOptions.that = $scope;
  10445. }]
  10446. });
  10447. //用户单选控件(dd 单选input带搜索)
  10448. formlyConfigProvider.setType({
  10449. name: "ui-userselectSearch",
  10450. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  10451. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10452. defaultOptions: function (options) {
  10453. return {
  10454. templateOptions: {
  10455. openModal: function (size, options, modal) {
  10456. var modalInstance = modal.open({
  10457. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10458. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  10459. $scope.langs = i18nService.getAllLangs();
  10460. $scope.lang = 'zh-cn';
  10461. i18nService.setCurrentLang($scope.lang);
  10462. $scope.gridOptions = {};
  10463. $scope.gridOptions.data = 'myData';
  10464. $scope.gridOptions.enableColumnResizing = true;
  10465. $scope.gridOptions.enableFiltering = true;
  10466. $scope.gridOptions.enableGridMenu = false;
  10467. $scope.gridOptions.showGridFooter = true;
  10468. $scope.gridOptions.showColumnFooter = false;
  10469. $scope.gridOptions.fastWatch = true;
  10470. $scope.gridOptions.useExternalFiltering = true;
  10471. $scope.gridOptions.useExternalPagination = true;
  10472. $scope.gridOptions.paginationPageSizes = [20];
  10473. $scope.gridOptions.paginationPageSize = 20;
  10474. $scope.gridOptions.multiSelect = false;
  10475. $scope.gridOptions.rowIdentity = function (row) {
  10476. return row.id;
  10477. };
  10478. $scope.gridOptions.getRowIdentity = function (row) {
  10479. return row.id;
  10480. };
  10481. $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>";
  10482. $scope.gridOptions.columnDefs = [{
  10483. name: 'account',
  10484. displayName: '人员编号',
  10485. width: 120
  10486. },
  10487. {
  10488. name: 'name',
  10489. displayName: '姓名',
  10490. width: 100,
  10491. cellTemplate: '<div>' +
  10492. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  10493. '</div>'
  10494. },
  10495. {
  10496. name: 'gender.name',
  10497. displayName: '性别',
  10498. width: 80,
  10499. enableFiltering: false
  10500. },
  10501. {
  10502. name: 'phone',
  10503. displayName: '电话',
  10504. width: 100,
  10505. enableFiltering: false
  10506. },
  10507. {
  10508. name: 'email',
  10509. displayName: '邮箱',
  10510. width: 150,
  10511. enableFiltering: false
  10512. },
  10513. {
  10514. name: 'dept.dept',
  10515. displayName: '部门',
  10516. width: 130,
  10517. enableFiltering: false
  10518. },
  10519. {
  10520. name: 'taskCount',
  10521. displayName: '处理中事件数',
  10522. enableFiltering: false
  10523. }
  10524. ];
  10525. // $scope.selectButtonClick
  10526. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10527. $scope.gridApi = gridApi;
  10528. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10529. var filtersData = $scope.memoryfilterData;
  10530. filtersData.idx = newPage - 1;
  10531. filtersData.sum = pageSize;
  10532. $scope.loadData(filtersData);
  10533. //console.log(pageSize);
  10534. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  10535. });
  10536. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10537. $scope.selected.items = data.entity;
  10538. //console.log(data);
  10539. });
  10540. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  10541. $scope.selected.items = data.entity;
  10542. //console.log(data);
  10543. });
  10544. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  10545. // // if (row.entity.age > 45) {
  10546. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10547. // // }
  10548. // };
  10549. gridApi.core.on.filterChanged($scope, function () {
  10550. var grid = this.grid;
  10551. var filtersData = {
  10552. idx: 0,
  10553. sum: 1000,
  10554. user: {
  10555. roledata: {
  10556. rolecode: "first-line support"
  10557. },
  10558. selectType: "1"
  10559. }
  10560. };
  10561. angular.forEach(grid.columns, function (item) {
  10562. if (item.enableFiltering) {
  10563. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  10564. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10565. if (angular.isUndefined(filtersData['user'])) {
  10566. filtersData['user'] = {};
  10567. }
  10568. filtersData['user'][item.field] = item.filters[0].term;
  10569. }
  10570. }
  10571. });
  10572. $scope.memoryfilterData = filtersData;
  10573. $scope.loadData(filtersData);
  10574. });
  10575. };
  10576. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  10577. // if (row.entity.age > 45) {
  10578. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10579. // }
  10580. // },
  10581. $scope.onDblClick = function (data, event) {
  10582. // $scope.selected.items = data.entity;
  10583. $scope.selectButtonClick(data, event);
  10584. };
  10585. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  10586. // $scope.selected.items = data.entity;
  10587. // })
  10588. // };
  10589. $scope.memoryfilterData = {
  10590. idx: 0,
  10591. sum: 1000,
  10592. user: {
  10593. roledata: {
  10594. rolecode: "first-line support"
  10595. },
  10596. selectType: "1"
  10597. }
  10598. }
  10599. $scope.loadData = function (filterData) {
  10600. // console.log("filtersData=111" + JSON.stringify(filterData))
  10601. items.fetchItems(filterData, APIService).then(function (data) {
  10602. var myData = Restangular.stripRestangular(data);
  10603. $scope.gridOptions.totalItems = myData.totalNum;
  10604. $scope.myData = myData.list;
  10605. });
  10606. };
  10607. $scope.title = title;
  10608. $scope.loadData({
  10609. idx: 0,
  10610. sum: 1000,
  10611. user: {
  10612. roledata: {
  10613. rolecode: "first-line support"
  10614. },
  10615. selectType: "1"
  10616. }
  10617. });
  10618. $scope.selected = {
  10619. items: {}
  10620. };
  10621. $scope.ok = function () {
  10622. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  10623. // onDataCallback($scope.selected.item, parentScope);
  10624. // }
  10625. $modalInstance.close($scope.selected.items);
  10626. };
  10627. $scope.cancel = function () {
  10628. $modalInstance.dismiss('cancel');
  10629. };
  10630. },
  10631. size: size,
  10632. resolve: {
  10633. items: function () {
  10634. return {
  10635. fetchItems: function (filterData, APIService) {
  10636. filterData = filterData || {};
  10637. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10638. filterData = {
  10639. idx: 0,
  10640. sum: 1000,
  10641. user: {
  10642. roledata: {
  10643. rolecode: "first-line support"
  10644. },
  10645. selectType: "1"
  10646. }
  10647. };
  10648. }
  10649. return options.templateOptions.fetchItems(filterData, APIService);
  10650. }
  10651. };
  10652. },
  10653. title: function () {
  10654. return options.templateOptions.label;
  10655. },
  10656. Restangular: function () {
  10657. return options.templateOptions.Restangular;
  10658. },
  10659. APIService: function () {
  10660. return options.templateOptions.ApiService;
  10661. },
  10662. onDataCallback: function () {
  10663. return options.templateOptions.callback;
  10664. },
  10665. parentScope: function () {
  10666. return options.templateOptions.that;
  10667. }
  10668. }
  10669. });
  10670. modalInstance.result.then(function (selectedItem) {
  10671. // console.log(selectedItem);
  10672. options.value(selectedItem);
  10673. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  10674. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  10675. }
  10676. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  10677. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  10678. }
  10679. }, function () {
  10680. //console.log('Modal dismissed at: ' + new Date());
  10681. });
  10682. }
  10683. }
  10684. };
  10685. },
  10686. controller: ['$scope', function ($scope) {
  10687. $scope.options.templateOptions.that = $scope;
  10688. }]
  10689. });
  10690. //用户多选控件
  10691. formlyConfigProvider.setType({
  10692. name: "ui-multiuserselect",
  10693. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  10694. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10695. defaultOptions: function (options) {
  10696. return {
  10697. templateOptions: {
  10698. openModal: function (size, options, modal, model) {
  10699. var modalInstance = modal.open({
  10700. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10701. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  10702. $scope.langs = i18nService.getAllLangs();
  10703. $scope.lang = 'zh-cn';
  10704. i18nService.setCurrentLang($scope.lang);
  10705. $scope.gridOptions = {};
  10706. $scope.gridOptions.data = 'myData';
  10707. $scope.gridOptions.enableColumnResizing = true;
  10708. $scope.gridOptions.enableFiltering = true;
  10709. $scope.gridOptions.enableGridMenu = true;
  10710. $scope.gridOptions.showGridFooter = true;
  10711. $scope.gridOptions.showColumnFooter = true;
  10712. $scope.gridOptions.fastWatch = true;
  10713. $scope.gridOptions.useExternalFiltering = true;
  10714. $scope.gridOptions.useExternalPagination = true;
  10715. $scope.gridOptions.paginationPageSizes = [10];
  10716. $scope.gridOptions.paginationPageSize = 10;
  10717. $scope.gridOptions.multiSelect = true;
  10718. $scope.gridOptions.rowIdentity = function (row) {
  10719. return row.id;
  10720. };
  10721. $scope.gridOptions.getRowIdentity = function (row) {
  10722. return row.id;
  10723. };
  10724. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10725. $scope.gridOptions.columnDefs = [
  10726. // { name:'id', width:80, enableFiltering:false},
  10727. {
  10728. name: 'account',
  10729. displayName: '账号',
  10730. width: 140
  10731. },
  10732. {
  10733. name: 'name',
  10734. displayName: '名称',
  10735. width: 100
  10736. },
  10737. {
  10738. name: 'gender.name',
  10739. displayName: '性别',
  10740. width: 140,
  10741. enableFiltering: false
  10742. },
  10743. {
  10744. name: 'phone',
  10745. displayName: '电话',
  10746. width: 100,
  10747. enableFiltering: false
  10748. },
  10749. {
  10750. name: 'email',
  10751. displayName: '邮件',
  10752. width: 100,
  10753. enableFiltering: false
  10754. },
  10755. {
  10756. name: 'dept.dept',
  10757. displayName: '部门',
  10758. width: 100,
  10759. enableFiltering: false
  10760. },
  10761. {
  10762. name: 'group[0].groupName',
  10763. displayName: '职位',
  10764. width: 100,
  10765. enableFiltering: false
  10766. }
  10767. ];
  10768. $scope.selected = {
  10769. items: selectItems
  10770. };
  10771. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10772. $scope.gridApi = gridApi;
  10773. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10774. var filtersData = $scope.memoryfilterData;
  10775. filtersData.idx = newPage - 1;
  10776. filtersData.sum = pageSize;
  10777. $scope.loadData(filtersData);
  10778. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  10779. });
  10780. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  10781. var j = 0;
  10782. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  10783. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  10784. j++;
  10785. break;
  10786. }
  10787. }
  10788. if (j == 1) {
  10789. scope.grid.appScope.selected.items.splice(i, 1);
  10790. } else {
  10791. scope.grid.appScope.selected.items.push(scope.entity)
  10792. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  10793. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  10794. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  10795. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  10796. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  10797. scope.grid.appScope.selected.items.splice(i, 1);
  10798. }
  10799. }
  10800. }
  10801. }
  10802. });
  10803. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  10804. // $scope.grid.appScope.selected.items.push($scope.entity);
  10805. // });
  10806. gridApi.core.on.filterChanged($scope, function () {
  10807. var grid = this.grid;
  10808. var filtersData = {
  10809. idx: 0,
  10810. sum: 10,
  10811. "user": {
  10812. "roledata": {
  10813. "rolecode": options.model.currentRole
  10814. },
  10815. "selectType": "1"
  10816. }
  10817. };
  10818. angular.forEach(grid.columns, function (item) {
  10819. if (item.enableFiltering) {
  10820. //console.log("filtersData="+JSON.stringify(filtersData))
  10821. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10822. if (angular.isUndefined(filtersData['user'])) {
  10823. filtersData['user'] = {};
  10824. }
  10825. filtersData['user'][item.field] = item.filters[0].term;
  10826. }
  10827. }
  10828. });
  10829. $scope.memoryfilterData = filtersData;
  10830. $scope.loadData(filtersData);
  10831. });
  10832. };
  10833. if (!options.model) {
  10834. var mouse = {
  10835. "model": {
  10836. "currentRole": ""
  10837. }
  10838. };
  10839. angular.extend(options, mouse);
  10840. }
  10841. $scope.memoryfilterData = {
  10842. "idx": 0,
  10843. "sum": 10,
  10844. "user": {
  10845. "roledata": {
  10846. "rolecode": options.model.currentRole
  10847. },
  10848. "selectType": "1"
  10849. }
  10850. }
  10851. $scope.loadData = function (filterData) {
  10852. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  10853. items.fetchItems(filterData, APIService).then(function (data) {
  10854. var myData = Restangular.stripRestangular(data);
  10855. $scope.gridOptions.totalItems = myData.totalNum;
  10856. $scope.myData = myData.list;
  10857. //console.log($scope.gridOptions.pagination.getTotalPages());
  10858. // if($scope.selected.items){
  10859. // angular.forEach($scope.selected.items,function(selectItem){
  10860. // $scope.gridApi.selection.selectRow(selectItem);
  10861. // });
  10862. // }
  10863. });
  10864. };
  10865. // $scope.title = title;
  10866. $scope.loadData({
  10867. idx: 0,
  10868. sum: 10,
  10869. "user": {
  10870. "roledata": {
  10871. "rolecode": options.model.currentRole
  10872. },
  10873. "selectType": "1"
  10874. }
  10875. });
  10876. // $timeout(function(){
  10877. // if($scope.selected.items){
  10878. // angular.forEach($scope.selected.items,function(selectItem){
  10879. // $scope.gridApi.selection.selectRow(selectItem);
  10880. // });
  10881. // }
  10882. // },2000)
  10883. $scope.ok = function () {
  10884. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  10885. $modalInstance.close($scope.selected.items);
  10886. };
  10887. $scope.cancel = function () {
  10888. $modalInstance.dismiss('cancel');
  10889. };
  10890. },
  10891. size: size,
  10892. resolve: {
  10893. items: function () {
  10894. return {
  10895. fetchItems: function (filterData, APIService) {
  10896. filterData = filterData || {};
  10897. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10898. filterData = {
  10899. idx: 0,
  10900. sum: 10,
  10901. "user": {
  10902. "roledata": {
  10903. "rolecode": options.model.incident.currentRole
  10904. },
  10905. "selectType": "1"
  10906. }
  10907. };
  10908. }
  10909. return options.templateOptions.fetchItems(filterData, APIService);
  10910. }
  10911. };
  10912. },
  10913. title: function () {
  10914. return options.templateOptions.modalTitle;
  10915. },
  10916. Restangular: function () {
  10917. return options.templateOptions.Restangular;
  10918. },
  10919. APIService: function () {
  10920. return options.templateOptions.ApiService;
  10921. },
  10922. selectItems: function () {
  10923. return model || [];
  10924. }
  10925. }
  10926. });
  10927. modalInstance.result.then(function (selectedItem) {
  10928. options.value(selectedItem);
  10929. options.formControl.$validate();
  10930. }, function () {
  10931. //console.log('Modal dismissed at: ' + new Date());
  10932. });
  10933. }
  10934. },
  10935. validators: {
  10936. required: {
  10937. expression: function (viewValue, modelValue) {
  10938. var value = modelValue || viewValue;
  10939. return value.length >= 1;
  10940. }
  10941. }
  10942. }
  10943. };
  10944. },
  10945. controller: ['$scope', function ($scope) {
  10946. $scope.model[$scope.options.key] = [];
  10947. $scope.remove = function (itemId) {
  10948. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  10949. if (entry.id == itemId) {
  10950. $scope.model[$scope.options.key].splice(index, 1);
  10951. // console.log($scope.options.formControl)
  10952. $scope.options.formControl.$validate();
  10953. } else {
  10954. }
  10955. });
  10956. }
  10957. }]
  10958. });
  10959. //用户多选控件-字符串展示
  10960. formlyConfigProvider.setType({
  10961. name: 'ui-stringuserselect',
  10962. extends: 'input',
  10963. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  10964. defaultOptions: function (options) {
  10965. return {
  10966. templateOptions: {
  10967. translate: '',
  10968. refreshDelay: 0
  10969. }
  10970. }
  10971. },
  10972. controller: ['$scope', function ($scope) {
  10973. var keydata = "";
  10974. if (angular.isArray($scope.model)) {
  10975. angular.forEach($scope.model, function (item) {
  10976. keydata = keydata + "," + item.name;
  10977. })
  10978. }
  10979. // $scope.model[$scope.options.key] = [];
  10980. }]
  10981. });
  10982. //重复事件
  10983. formlyConfigProvider.setType({
  10984. name: "ui-incidentmodelselect",
  10985. extends: 'input',
  10986. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  10987. defaultOptions: function (options) {
  10988. return {
  10989. templateOptions: {
  10990. openModal: function (size, options, modal) {
  10991. var modalInstance = modal.open({
  10992. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10993. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  10994. $scope.langs = i18nService.getAllLangs();
  10995. $scope.lang = 'zh-cn';
  10996. i18nService.setCurrentLang($scope.lang);
  10997. $scope.gridOptions = {};
  10998. $scope.gridOptions.data = 'myData';
  10999. $scope.gridOptions.enableColumnResizing = true;
  11000. $scope.gridOptions.enableFiltering = true;
  11001. $scope.gridOptions.enableGridMenu = false;
  11002. $scope.gridOptions.enableRowSelection = true;
  11003. $scope.gridOptions.showGridFooter = true;
  11004. $scope.gridOptions.showColumnFooter = false;
  11005. $scope.gridOptions.fastWatch = true;
  11006. $scope.gridOptions.useExternalFiltering = true;
  11007. $scope.gridOptions.useExternalPagination = true;
  11008. $scope.gridOptions.paginationPageSizes = [10];
  11009. $scope.gridOptions.paginationPageSize = 10;
  11010. $scope.gridOptions.multiSelect = false;
  11011. var mun = $scope.gridOptions.paginationPageSize;
  11012. $scope.gridOptions.rowIdentity = function (row) {
  11013. return row.id;
  11014. };
  11015. $scope.gridOptions.getRowIdentity = function (row) {
  11016. return row.id;
  11017. };
  11018. $scope.gridOptions.columnDefs = items.columnDefs();
  11019. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11020. $scope.gridApi = gridApi;
  11021. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11022. // console.log(newPage);
  11023. // console.log(pageSize);
  11024. $scope.loadData({
  11025. "idx": newPage - 1,
  11026. "sum": pageSize
  11027. });
  11028. });
  11029. gridApi.core.on.filterChanged($scope, function () {
  11030. var grid = this.grid;
  11031. var filtersData = {
  11032. idx: 0,
  11033. sum: 100
  11034. };
  11035. angular.forEach(grid.columns, function (item) {
  11036. if (item.enableFiltering) {
  11037. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11038. // console.log("filtersData="+JSON.stringify(filtersData))
  11039. if (angular.isUndefined(filtersData['incident'])) {
  11040. filtersData['incident'] = {};
  11041. }
  11042. filtersData['incident'][item.field] = item.filters[0].term;
  11043. if (angular.isUndefined(filtersData['problem'])) {
  11044. filtersData['problem'] = {};
  11045. }
  11046. filtersData['problem'][item.field] = item.filters[0].term;
  11047. if (angular.isUndefined(filtersData['change'])) {
  11048. filtersData['change'] = {};
  11049. }
  11050. filtersData['change'][item.field] = item.filters[0].term;
  11051. if (angular.isUndefined(filtersData['release'])) {
  11052. filtersData['release'] = {};
  11053. }
  11054. filtersData['release'][item.field] = item.filters[0].term;
  11055. }
  11056. }
  11057. });
  11058. $scope.loadData(filtersData);
  11059. });
  11060. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11061. $scope.selected.item = data.entity;
  11062. //console.log(data);
  11063. });
  11064. };
  11065. //资产
  11066. $scope.cmdb = {}
  11067. //资产状态
  11068. $scope.state_data = [{
  11069. "name": "全部状态",
  11070. "value": ""
  11071. },
  11072. {
  11073. "name": "在库",
  11074. "value": "1"
  11075. },
  11076. {
  11077. "name": "在线",
  11078. "value": "2"
  11079. },
  11080. {
  11081. "name": "借出",
  11082. "value": "3"
  11083. },
  11084. {
  11085. "name": "报修",
  11086. "value": "4"
  11087. },
  11088. {
  11089. "name": "报废",
  11090. "value": "5"
  11091. },
  11092. {
  11093. "name": "备用",
  11094. "value": "6"
  11095. },
  11096. ]
  11097. //资产类型
  11098. $scope.wt_zcfl = function () {
  11099. api_configure_data.fetchDataList('ciclassify', {
  11100. idx: 0,
  11101. sum: 100
  11102. }).then(function (data) {
  11103. console.log(data);
  11104. // $scope.wt_zclx = data.list;
  11105. console.log(data);
  11106. $scope.wtData = []
  11107. if (data.status == 200) {
  11108. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11109. var root = null; //Initially set our loop to null
  11110. var parentNode = null;
  11111. //loop over data
  11112. // $scope.wtData=data.list;
  11113. data = data.list;
  11114. //知识库分类数据三级处理
  11115. for (var i = 0; i < data.length; i++) {
  11116. // console.log(data[i])
  11117. var datum = data[i];
  11118. //each node will have children, so let's give it a "children" poperty
  11119. // console.log(datum);
  11120. datum.children = [];
  11121. if (!datum.parent) {
  11122. $scope.wtData.push(datum);
  11123. // console.log($scope.wtData)
  11124. } else {
  11125. if ($scope.wtData[0]) {
  11126. if ($scope.wtData[0].id == datum.parent.id) {
  11127. $scope.wtData[0].children.push(datum);
  11128. }
  11129. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  11130. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  11131. $scope.wtData[0].children[j].children.push(datum);
  11132. }
  11133. };
  11134. }
  11135. if ($scope.wtData[1]) {
  11136. if ($scope.wtData[1].id == datum.parent.id) {
  11137. $scope.wtData[1].children.push(datum);
  11138. }
  11139. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  11140. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  11141. $scope.wtData[1].children[j].children.push(datum);
  11142. }
  11143. };
  11144. }
  11145. if ($scope.wtData[2]) {
  11146. if ($scope.wtData[2].id == datum.parent.id) {
  11147. $scope.wtData[2].children.push(datum);
  11148. }
  11149. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  11150. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  11151. $scope.wtData[2].children[j].children.push(datum);
  11152. }
  11153. };
  11154. }
  11155. }
  11156. // console.log($scope.wtData)
  11157. idToNodeMap[datum.id] = datum;
  11158. root = datum;
  11159. // treeMap[datum.id] = root;
  11160. }
  11161. }
  11162. });
  11163. }
  11164. $scope.wt_zcfl();
  11165. //事件
  11166. //受理人,处理人
  11167. $scope.searchkeys = {};
  11168. var fieldata = {
  11169. "idx": 0,
  11170. "sum": 100,
  11171. "flag": -1
  11172. };
  11173. getUser(fieldata, 3);
  11174. function getUser(fieldatas, it) {
  11175. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  11176. if (it == 1) {
  11177. $scope.acceptUser = data.list;
  11178. } else if (it == 2) {
  11179. $scope.handlingPersonnelUser = data.list;
  11180. } else if (it == 3) {
  11181. $scope.acceptUser = data.list;
  11182. $scope.handlingPersonnelUser = data.list;
  11183. }
  11184. });
  11185. }
  11186. //状态
  11187. $scope.othcode = {};
  11188. api_bpm_data.fetchDataList('incidentstatus', {
  11189. "idx": 0,
  11190. "sum": 100
  11191. }).then(function (response) {
  11192. if (response) {
  11193. if (response.status = 200) {
  11194. $scope.state = response.list;
  11195. }
  11196. }
  11197. })
  11198. var defaultFilterData = {
  11199. "assignee": $rootScope.user.id,
  11200. "searchType": "todo",
  11201. "idx": 0,
  11202. "sum": mun
  11203. };
  11204. var defaultFilterData1 = {
  11205. // "searchType": "todo",
  11206. "idx": 0,
  11207. "sum": mun
  11208. };
  11209. //搜索
  11210. $scope.chiceIncident = function (parameters, item, stateid) {
  11211. console.log(item, stateid);
  11212. console.log($scope);
  11213. if ($scope.title == '关联资产编号') {
  11214. // alert('222222222222');
  11215. var fildata = defaultFilterData1;
  11216. $scope.gridOptions.paginationCurrentPage = 1;
  11217. var transitiondata = angular.copy(item);
  11218. angular.extend(fildata, transitiondata);
  11219. if (fildata.hw_state) {
  11220. fildata.hw_state = fildata.hw_state.name;
  11221. }
  11222. if (fildata.sign) {
  11223. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  11224. fildata.sign = fildata.sign.split(';');
  11225. fildata.sign = fildata.sign.join('');
  11226. fildata.sign = fildata.sign.toLowerCase()
  11227. }
  11228. if (fildata.keys) {
  11229. fildata['searchCriteria'] = 'uuid';
  11230. }
  11231. console.log(fildata);
  11232. $scope.loadData(fildata);
  11233. }
  11234. if ($scope.title == '关联事件工单') {
  11235. // alert('3333333333333333')
  11236. if (stateid && stateid.code) {
  11237. item.statusId = stateid.code;
  11238. }
  11239. var fildata = defaultFilterData;
  11240. // $scope.memoryfilterData = fildata;
  11241. if (!fildata.incident) {
  11242. fildata['incident'] = {};
  11243. }
  11244. $scope.gridOptions.paginationCurrentPage = 1;
  11245. var transitiondata = angular.copy(item);
  11246. angular.extend(fildata.incident, transitiondata);
  11247. console.log(fildata)
  11248. // $scope.loadData(fildata);
  11249. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  11250. console.log(data)
  11251. if (data) {
  11252. $scope.myData = data.list;
  11253. $scope.gridOptions.totalItems = data.totalNum;
  11254. }
  11255. })
  11256. }
  11257. }
  11258. //重置
  11259. $scope.replacement = function (parameters, searchkeys, othcode) {
  11260. // console.log(parameters, searchkeys, othcode);
  11261. delete(defaultFilterData.incident);
  11262. console.log(defaultFilterData)
  11263. $scope.parameters = null;
  11264. $scope.searchkeys = {};
  11265. $scope.othcode = {};
  11266. $scope.wt_zcfl();
  11267. }
  11268. $scope.loadData = function (filterData) {
  11269. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  11270. var myData = Restangular.stripRestangular(data);
  11271. if (myData.data && myData.data.node) {
  11272. $scope.gridOptions.totalItems = myData.total;
  11273. $scope.myData = myData.data.node;
  11274. } else {
  11275. if (myData.resultCount) {
  11276. $scope.gridOptions['totalItems'] = myData.resultCount;
  11277. } else {
  11278. $scope.gridOptions.totalItems = myData.totalNum;
  11279. }
  11280. if (myData.list) {
  11281. $scope.myData = myData.list;
  11282. } else {
  11283. $scope.myData = myData.data;
  11284. }
  11285. }
  11286. });
  11287. };
  11288. $scope.title = title;
  11289. $scope.loadData({
  11290. idx: 0,
  11291. sum: 10
  11292. });
  11293. $scope.selected = {
  11294. item: {}
  11295. };
  11296. $scope.ok = function () {
  11297. //console.log($scope.selected.item);
  11298. $modalInstance.close($scope.selected.item);
  11299. };
  11300. $scope.cancel = function () {
  11301. $modalInstance.dismiss('cancel');
  11302. };
  11303. },
  11304. size: size,
  11305. resolve: {
  11306. items: function () {
  11307. return {
  11308. fetchItems: function (filterData, APIService, $rootScope) {
  11309. filterData = filterData || {};
  11310. // if(!filterData.idx){
  11311. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  11312. filterData = {
  11313. idx: 0,
  11314. sum: 10
  11315. };
  11316. }
  11317. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  11318. },
  11319. columnDefs: function () {
  11320. return options.templateOptions.columnDefs;
  11321. }
  11322. };
  11323. },
  11324. title: function () {
  11325. return options.templateOptions.modalTitle;
  11326. },
  11327. Restangular: function () {
  11328. return options.templateOptions.Restangular;
  11329. },
  11330. APIService: function () {
  11331. return options.templateOptions.ApiService;
  11332. }
  11333. }
  11334. });
  11335. modalInstance.result.then(function (selectedItem) {
  11336. var selectitem = {
  11337. title: selectedItem.title,
  11338. description: selectedItem.description
  11339. }
  11340. if (options.key == "chuku") {
  11341. if (selectedItem.assets) {
  11342. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  11343. }
  11344. if (selectedItem.consumables) {
  11345. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  11346. }
  11347. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  11348. options.value(selectedItem);
  11349. // options.model.consumables = JSON.parse(consumables);
  11350. } else if (options.templateOptions.pkey == "change") {
  11351. console.log(options)
  11352. angular.extend(options.model);
  11353. options.value(selectedItem);
  11354. } else if (options.key == "cmdbCode") {
  11355. var zc_selectitem = selectedItem.uuid;
  11356. // angular.extend(options.model,zc_selectitem);
  11357. options.model.cmdbCode = zc_selectitem;
  11358. // angular.extend(options.model,zc_selectitem);
  11359. // options.templateOptions.displayName=zc_selectitem;
  11360. options.value(selectedItem);
  11361. console.log(options.model)
  11362. } else {
  11363. angular.extend(options.model, selectitem);
  11364. options.value(selectedItem);
  11365. }
  11366. }, function () {
  11367. //console.log('Modal dismissed at: ' + new Date());
  11368. });
  11369. }
  11370. }
  11371. };
  11372. }
  11373. });
  11374. //选项选择控件
  11375. formlyConfigProvider.setType({
  11376. name: "ui-modelselect",
  11377. extends: 'input',
  11378. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  11379. defaultOptions: function (options) {
  11380. return {
  11381. templateOptions: {
  11382. openModal: function (size, options, modal) {
  11383. var modalInstance = modal.open({
  11384. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11385. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  11386. $scope.langs = i18nService.getAllLangs();
  11387. $scope.lang = 'zh-cn';
  11388. i18nService.setCurrentLang($scope.lang);
  11389. $scope.gridOptions = {};
  11390. $scope.gridOptions.data = 'myData';
  11391. $scope.gridOptions.enableColumnResizing = true;
  11392. $scope.gridOptions.enableFiltering = true;
  11393. $scope.gridOptions.enableGridMenu = false;
  11394. $scope.gridOptions.enableRowSelection = true;
  11395. $scope.gridOptions.showGridFooter = true;
  11396. $scope.gridOptions.showColumnFooter = true;
  11397. $scope.gridOptions.fastWatch = true;
  11398. $scope.gridOptions.useExternalFiltering = true;
  11399. $scope.gridOptions.useExternalPagination = true;
  11400. $scope.gridOptions.paginationPageSizes = [10];
  11401. $scope.gridOptions.paginationPageSize = 10;
  11402. $scope.gridOptions.multiSelect = false;
  11403. $scope.gridOptions.rowIdentity = function (row) {
  11404. return row.id;
  11405. };
  11406. $scope.gridOptions.getRowIdentity = function (row) {
  11407. return row.id;
  11408. };
  11409. $scope.gridOptions.columnDefs = items.columnDefs();
  11410. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11411. $scope.gridApi = gridApi;
  11412. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11413. // console.log(newPage);
  11414. // console.log(pageSize);
  11415. $scope.loadData({
  11416. "idx": newPage - 1,
  11417. "sum": pageSize
  11418. });
  11419. });
  11420. gridApi.core.on.filterChanged($scope, function () {
  11421. var grid = this.grid;
  11422. var filtersData = {
  11423. idx: 0,
  11424. sum: 10
  11425. };
  11426. angular.forEach(grid.columns, function (item) {
  11427. if (item.enableFiltering) {
  11428. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11429. // console.log("filtersData="+JSON.stringify(filtersData))
  11430. if (angular.isUndefined(filtersData['incident'])) {
  11431. filtersData['incident'] = {};
  11432. }
  11433. filtersData['incident'][item.field] = item.filters[0].term;
  11434. if (angular.isUndefined(filtersData['problem'])) {
  11435. filtersData['problem'] = {};
  11436. }
  11437. filtersData['problem'][item.field] = item.filters[0].term;
  11438. if (angular.isUndefined(filtersData['change'])) {
  11439. filtersData['change'] = {};
  11440. }
  11441. filtersData['change'][item.field] = item.filters[0].term;
  11442. if (angular.isUndefined(filtersData['release'])) {
  11443. filtersData['release'] = {};
  11444. }
  11445. filtersData['release'][item.field] = item.filters[0].term;
  11446. }
  11447. }
  11448. });
  11449. $scope.loadData(filtersData);
  11450. });
  11451. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11452. $scope.selected.item = data.entity;
  11453. //console.log(data);
  11454. });
  11455. };
  11456. $scope.loadData = function (filterData) {
  11457. items.fetchItems(filterData, APIService).then(function (data) {
  11458. var myData = Restangular.stripRestangular(data);
  11459. $scope.gridOptions.totalItems = myData.totalNum;
  11460. $scope.myData = myData.list;
  11461. });
  11462. };
  11463. $scope.title = title;
  11464. $scope.loadData({
  11465. idx: 0,
  11466. sum: 10
  11467. });
  11468. $scope.selected = {
  11469. item: {}
  11470. };
  11471. $scope.ok = function () {
  11472. if ($scope.selected.item.scheduleOrder) {
  11473. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  11474. }
  11475. //console.log($scope.selected.item);
  11476. $modalInstance.close($scope.selected.item);
  11477. };
  11478. $scope.cancel = function () {
  11479. $modalInstance.dismiss('cancel');
  11480. };
  11481. },
  11482. size: size,
  11483. resolve: {
  11484. items: function () {
  11485. return {
  11486. fetchItems: function (filterData, APIService) {
  11487. filterData = filterData || {};
  11488. // if(!filterData.idx){
  11489. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  11490. filterData = {
  11491. idx: 0,
  11492. sum: 10
  11493. };
  11494. }
  11495. return options.templateOptions.fetchItems(filterData, APIService, options);
  11496. },
  11497. columnDefs: function () {
  11498. return options.templateOptions.columnDefs;
  11499. }
  11500. };
  11501. },
  11502. title: function () {
  11503. return options.templateOptions.modalTitle;
  11504. },
  11505. Restangular: function () {
  11506. return options.templateOptions.Restangular;
  11507. },
  11508. APIService: function () {
  11509. return options.templateOptions.ApiService;
  11510. }
  11511. }
  11512. });
  11513. modalInstance.result.then(function (selectedItem) {
  11514. options.value(selectedItem);
  11515. }, function () {
  11516. //console.log('Modal dismissed at: ' + new Date());
  11517. });
  11518. }
  11519. }
  11520. };
  11521. }
  11522. });
  11523. formlyConfigProvider.setType({
  11524. name: 'ui-requestform',
  11525. extends: 'input',
  11526. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  11527. controller: ['$scope', function ($scope) {
  11528. setTimeout(function () {
  11529. var filterData = {
  11530. "idx": 0,
  11531. "sum": 5,
  11532. "incident": {
  11533. "requester": {
  11534. "id": ""
  11535. }
  11536. }
  11537. }
  11538. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  11539. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11540. });
  11541. }, 1000);
  11542. }]
  11543. });
  11544. //工单/受理人控件
  11545. formlyConfigProvider.setType({
  11546. name: 'ui-workernumbersign',
  11547. // extends: 'label',
  11548. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  11549. controller: ['$scope', function ($scope) {
  11550. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  11551. setTimeout(function () {
  11552. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  11553. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11554. if (modelData.status == 200) {
  11555. $scope.model[$scope.options.key] = modelData.data;
  11556. $scope.options.initialValue = $scope.model[$scope.options.key];
  11557. }
  11558. });
  11559. }, 1000);
  11560. }
  11561. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  11562. if (angular.isFunction($scope.options.templateOptions.transform)) {
  11563. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  11564. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  11565. // }
  11566. $scope.$parent.$parent.$parent.model['directClose'] = false;
  11567. $scope.$parent.$parent.$parent.model['directClose'] = false;
  11568. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  11569. }
  11570. $scope.model.acceptUser = $scope.options.templateOptions.user;
  11571. // $scope.options.initialValue = $scope.model.acceptUser;
  11572. }
  11573. }]
  11574. });
  11575. //工单控件-only number
  11576. formlyConfigProvider.setType({
  11577. name: 'ui-workernumber',
  11578. extends: 'input',
  11579. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  11580. controller: ['$scope', function ($scope) {
  11581. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  11582. setTimeout(function () {
  11583. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  11584. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11585. if (modelData.status == 200) {
  11586. $scope.model[$scope.options.key] = modelData.data;
  11587. $scope.options.initialValue = $scope.model[$scope.options.key];
  11588. }
  11589. });
  11590. }, 1000);
  11591. }
  11592. }]
  11593. });
  11594. //cmdb工单
  11595. formlyConfigProvider.setType({
  11596. name: 'ui-cmdbworkernumber',
  11597. extends: 'input',
  11598. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  11599. controller: ['$scope', function ($scope) {
  11600. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  11601. setTimeout(function () {
  11602. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  11603. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11604. // if(modelData.status==200){
  11605. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  11606. $scope.options.initialValue = $scope.model[$scope.options.key];
  11607. // }
  11608. });
  11609. }, 1000);
  11610. }
  11611. }]
  11612. });
  11613. //简易上传附件组件
  11614. formlyConfigProvider.setType({
  11615. name: 'ui-uploadFile',
  11616. templateUrl: 'assets/views/customform/tpl/ui-uploadFile.html',
  11617. wrapper: ['bootstrapHasError'],
  11618. controller: ['$scope', function ($scope) {
  11619. if (angular.isUndefined($scope.form.dropState)) {
  11620. $scope.form.dropState = false;
  11621. }
  11622. //附件上传数据
  11623. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11624. //$scope.options.templateOptions.uploader();
  11625. // FILTERS
  11626. uploader.filters.push({
  11627. name: 'customFilter',
  11628. fn: function (item /*{File|FileLikeObject}*/ , options) {
  11629. return this.queue.length < 10;
  11630. }
  11631. });
  11632. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11633. uploader.onBeforeUploadItem = function (item) {
  11634. angular.extend(item.headers, $rootScope.getSession());
  11635. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  11636. item.formData.push({
  11637. 'fileName': item.file.name
  11638. });
  11639. console.info('onBeforeUploadItem', item);
  11640. };
  11641. uploader.uploadAll();
  11642. }
  11643. // CALLBACKS
  11644. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  11645. console.info('onWhenAddingFileFailed', item, filter, options);
  11646. };
  11647. uploader.onAfterAddingFile = function (fileItem) {
  11648. console.info('onAfterAddingFile', fileItem);
  11649. };
  11650. uploader.onAfterAddingAll = function (addedFileItems) {
  11651. console.info('onAfterAddingAll', addedFileItems);
  11652. };
  11653. uploader.onBeforeUploadItem = function (item) {
  11654. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11655. // // $scope.uploader.options.url();
  11656. // $scope.uploader.onBeforeUploadItem = function(item) {
  11657. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11658. // console.info('onBeforeUploadItem', item);
  11659. // };
  11660. // $scope.uploader.uploadAll();
  11661. // }
  11662. console.info('onBeforeUploadItem', item);
  11663. };
  11664. uploader.onProgressItem = function (fileItem, progress) {
  11665. console.info('onProgressItem', fileItem, progress);
  11666. };
  11667. uploader.onProgressAll = function (progress) {
  11668. console.info('onProgressAll', progress);
  11669. };
  11670. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11671. console.info('onSuccessItem', fileItem, response, status, headers);
  11672. };
  11673. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11674. console.info('onErrorItem', fileItem, response, status, headers);
  11675. };
  11676. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11677. console.info('onCancelItem', fileItem, response, status, headers);
  11678. };
  11679. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11680. console.info('onCompleteItem', fileItem, response, status, headers);
  11681. };
  11682. uploader.onCompleteAll = function () {
  11683. console.info('onCompleteAll');
  11684. };
  11685. }]
  11686. });
  11687. //无上传按钮附件上传组件
  11688. formlyConfigProvider.setType({
  11689. name: 'ui-dropfilenotup',
  11690. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  11691. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11692. controller: ['$scope', function ($scope) {
  11693. if (angular.isUndefined($scope.form.dropState)) {
  11694. $scope.form.dropState = false;
  11695. }
  11696. //附件上传数据
  11697. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11698. //$scope.options.templateOptions.uploader();
  11699. // FILTERS
  11700. uploader.filters.push({
  11701. name: 'customFilter',
  11702. fn: function (item /*{File|FileLikeObject}*/ , options) {
  11703. return this.queue.length < 10;
  11704. }
  11705. });
  11706. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11707. uploader.onBeforeUploadItem = function (item) {
  11708. angular.extend(item.headers, $rootScope.getSession());
  11709. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  11710. item.formData.push({
  11711. 'fileName': item.file.name
  11712. });
  11713. console.info('onBeforeUploadItem', item);
  11714. };
  11715. uploader.uploadAll();
  11716. }
  11717. // CALLBACKS
  11718. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  11719. console.info('onWhenAddingFileFailed', item, filter, options);
  11720. };
  11721. uploader.onAfterAddingFile = function (fileItem) {
  11722. console.info('onAfterAddingFile', fileItem);
  11723. };
  11724. uploader.onAfterAddingAll = function (addedFileItems) {
  11725. console.info('onAfterAddingAll', addedFileItems);
  11726. };
  11727. uploader.onBeforeUploadItem = function (item) {
  11728. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11729. // // $scope.uploader.options.url();
  11730. // $scope.uploader.onBeforeUploadItem = function(item) {
  11731. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11732. // console.info('onBeforeUploadItem', item);
  11733. // };
  11734. // $scope.uploader.uploadAll();
  11735. // }
  11736. console.info('onBeforeUploadItem', item);
  11737. };
  11738. uploader.onProgressItem = function (fileItem, progress) {
  11739. console.info('onProgressItem', fileItem, progress);
  11740. };
  11741. uploader.onProgressAll = function (progress) {
  11742. console.info('onProgressAll', progress);
  11743. };
  11744. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11745. console.info('onSuccessItem', fileItem, response, status, headers);
  11746. };
  11747. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11748. console.info('onErrorItem', fileItem, response, status, headers);
  11749. };
  11750. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11751. console.info('onCancelItem', fileItem, response, status, headers);
  11752. };
  11753. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11754. console.info('onCompleteItem', fileItem, response, status, headers);
  11755. };
  11756. uploader.onCompleteAll = function () {
  11757. console.info('onCompleteAll');
  11758. };
  11759. }]
  11760. });
  11761. //无按钮知识库上传
  11762. formlyConfigProvider.setType({
  11763. name: 'ui-dropfielkn',
  11764. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  11765. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11766. controller: ['$scope', function ($scope) {
  11767. if (angular.isUndefined($scope.form.dropState)) {
  11768. $scope.form.dropState = false;
  11769. }
  11770. //附件上传数据
  11771. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11772. //$scope.options.templateOptions.uploader();
  11773. // FILTERS
  11774. uploader.filters.push({
  11775. name: 'customFilter',
  11776. fn: function (item /*{File|FileLikeObject}*/ , options) {
  11777. return this.queue.length < 10;
  11778. }
  11779. });
  11780. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11781. uploader.onBeforeUploadItem = function (item) {
  11782. angular.extend(item.headers, $rootScope.getSession());
  11783. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  11784. item.formData.push({
  11785. 'fileName': item.file.name
  11786. });
  11787. console.info('onBeforeUploadItem', item);
  11788. };
  11789. uploader.uploadAll();
  11790. }
  11791. // CALLBACKS
  11792. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  11793. console.info('onWhenAddingFileFailed', item, filter, options);
  11794. };
  11795. uploader.onAfterAddingFile = function (fileItem) {
  11796. console.info('onAfterAddingFile', fileItem);
  11797. };
  11798. uploader.onAfterAddingAll = function (addedFileItems) {
  11799. console.info('onAfterAddingAll', addedFileItems);
  11800. };
  11801. uploader.onBeforeUploadItem = function (item) {
  11802. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11803. // // $scope.uploader.options.url();
  11804. // $scope.uploader.onBeforeUploadItem = function(item) {
  11805. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11806. // console.info('onBeforeUploadItem', item);
  11807. // };
  11808. // $scope.uploader.uploadAll();
  11809. // }
  11810. console.info('onBeforeUploadItem', item);
  11811. };
  11812. uploader.onProgressItem = function (fileItem, progress) {
  11813. console.info('onProgressItem', fileItem, progress);
  11814. };
  11815. uploader.onProgressAll = function (progress) {
  11816. console.info('onProgressAll', progress);
  11817. };
  11818. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11819. console.info('onSuccessItem', fileItem, response, status, headers);
  11820. };
  11821. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11822. console.info('onErrorItem', fileItem, response, status, headers);
  11823. };
  11824. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11825. console.info('onCancelItem', fileItem, response, status, headers);
  11826. };
  11827. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11828. console.info('onCompleteItem', fileItem, response, status, headers);
  11829. };
  11830. uploader.onCompleteAll = function () {
  11831. console.info('onCompleteAll');
  11832. };
  11833. }]
  11834. });
  11835. //附件上传列表组件
  11836. formlyConfigProvider.setType({
  11837. name: 'ui-dropfile',
  11838. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  11839. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11840. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  11841. if (angular.isUndefined($scope.form.dropState)) {
  11842. $scope.form.dropState = false;
  11843. }
  11844. //附件上传数据
  11845. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11846. //$scope.options.templateOptions.uploader();
  11847. // FILTERS
  11848. uploader.filters.push({
  11849. name: 'customFilter',
  11850. fn: function (item /*{File|FileLikeObject}*/ , options) {
  11851. return this.queue.length < 10;
  11852. }
  11853. });
  11854. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11855. uploader.onBeforeUploadItem = function (item) {
  11856. angular.extend(item.headers, $rootScope.getSession());
  11857. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  11858. // if ($scope.options.templateOptions.formket) {
  11859. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  11860. // } else {
  11861. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  11862. // }
  11863. } else {
  11864. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  11865. }
  11866. item.formData.push({
  11867. 'filename': item.file.name
  11868. });
  11869. console.info('onBeforeUploadItem', item);
  11870. };
  11871. uploader.uploadAll();
  11872. }
  11873. // CALLBACKS
  11874. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  11875. console.info('onWhenAddingFileFailed', item, filter, options);
  11876. };
  11877. uploader.onAfterAddingFile = function (fileItem) {
  11878. console.info('onAfterAddingFile', fileItem);
  11879. };
  11880. uploader.onAfterAddingAll = function (addedFileItems) {
  11881. console.info('onAfterAddingAll', addedFileItems);
  11882. };
  11883. uploader.onBeforeUploadItem = function (item) {
  11884. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11885. // // $scope.uploader.options.url();
  11886. // $scope.uploader.onBeforeUploadItem = function(item) {
  11887. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11888. // console.info('onBeforeUploadItem', item);
  11889. // };
  11890. // $scope.uploader.uploadAll();
  11891. // }
  11892. console.info('onBeforeUploadItem', item);
  11893. };
  11894. uploader.onProgressItem = function (fileItem, progress) {
  11895. console.info('onProgressItem', fileItem, progress);
  11896. };
  11897. uploader.onProgressAll = function (progress) {
  11898. console.info('onProgressAll', progress);
  11899. };
  11900. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11901. console.info('onSuccessItem', fileItem, response, status, headers);
  11902. };
  11903. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11904. console.info('onErrorItem', fileItem, response, status, headers);
  11905. };
  11906. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11907. console.info('onCancelItem', fileItem, response, status, headers);
  11908. };
  11909. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11910. console.info('onCompleteItem', fileItem, response, status, headers);
  11911. };
  11912. uploader.onCompleteAll = function () {
  11913. console.info('onCompleteAll');
  11914. };
  11915. }]
  11916. });
  11917. //知识库附件上传
  11918. formlyConfigProvider.setType({
  11919. name: 'ui-dropfielknow',
  11920. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  11921. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11922. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  11923. if (angular.isUndefined($scope.form.dropState)) {
  11924. $scope.form.dropState = false;
  11925. }
  11926. //附件上传数据
  11927. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11928. //$scope.options.templateOptions.uploader();
  11929. // FILTERS
  11930. uploader.filters.push({
  11931. name: 'customFilter',
  11932. fn: function (item /*{File|FileLikeObject}*/ , options) {
  11933. return this.queue.length < 10;
  11934. }
  11935. });
  11936. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11937. uploader.onBeforeUploadItem = function (item) {
  11938. angular.extend(item.headers, $rootScope.getSession());
  11939. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  11940. item.formData.push({
  11941. 'fileName': item.file.name,
  11942. 'type': 'solution',
  11943. 'solutionId': $scope.model.knowledge.id
  11944. });
  11945. console.info('onBeforeUploadItem', item);
  11946. };
  11947. uploader.uploadAll();
  11948. }
  11949. // CALLBACKS
  11950. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  11951. console.info('onWhenAddingFileFailed', item, filter, options);
  11952. };
  11953. uploader.onAfterAddingFile = function (fileItem) {
  11954. console.info('onAfterAddingFile', fileItem);
  11955. };
  11956. uploader.onAfterAddingAll = function (addedFileItems) {
  11957. console.info('onAfterAddingAll', addedFileItems);
  11958. };
  11959. uploader.onBeforeUploadItem = function (item) {
  11960. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11961. // // $scope.uploader.options.url();
  11962. // $scope.uploader.onBeforeUploadItem = function(item) {
  11963. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11964. // console.info('onBeforeUploadItem', item);
  11965. // };
  11966. // $scope.uploader.uploadAll();
  11967. // }
  11968. console.info('onBeforeUploadItem', item);
  11969. };
  11970. uploader.onProgressItem = function (fileItem, progress) {
  11971. console.info('onProgressItem', fileItem, progress);
  11972. };
  11973. uploader.onProgressAll = function (progress) {
  11974. console.info('onProgressAll', progress);
  11975. };
  11976. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11977. console.info('onSuccessItem', fileItem, response, status, headers);
  11978. };
  11979. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11980. console.info('onErrorItem', fileItem, response, status, headers);
  11981. };
  11982. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11983. console.info('onCancelItem', fileItem, response, status, headers);
  11984. };
  11985. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11986. console.info('onCompleteItem', fileItem, response, status, headers);
  11987. };
  11988. uploader.onCompleteAll = function () {
  11989. console.info('onCompleteAll');
  11990. };
  11991. }]
  11992. });
  11993. //知识库附件下载列表
  11994. formlyConfigProvider.setType({
  11995. name: 'ui-dropfileknowledge',
  11996. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  11997. defaultOptions: function (options) {
  11998. return {
  11999. templateOptions: {
  12000. refresh: function (APIService, contentId, data) {
  12001. return APIService.fetchDataList(contentId, data);
  12002. },
  12003. downloadUri: function (APIService, contentId) {
  12004. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12005. },
  12006. download: function (APIService, contentId) {
  12007. return APIService.getSolutionDowpath(contentId);
  12008. },
  12009. view: function (attachmentId) {
  12010. // return APIService.attachmentsPreviewUrl(contentId);
  12011. },
  12012. refreshDelay: 0
  12013. }
  12014. };
  12015. },
  12016. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  12017. var _refreshDelayPromise;
  12018. $scope.attachments = [];
  12019. $scope.downloadUrl = function (contentId) {
  12020. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  12021. };
  12022. $scope.download = function (contentId, filename) {
  12023. $http({
  12024. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  12025. method: 'GET',
  12026. headers: {
  12027. //'Content-type' : 'application/xls',
  12028. 'Accept': '*/*'
  12029. },
  12030. responseType: 'arraybuffer'
  12031. }).success(function (data, status, headers, config) {
  12032. var file = new Blob([data], {
  12033. type: 'application/octet-stream'
  12034. });
  12035. //trick to download store a file having its URL
  12036. var fileURL = URL.createObjectURL(file);
  12037. var a = document.createElement('a');
  12038. a.href = fileURL;
  12039. a.target = '_blank';
  12040. a.download = filename;
  12041. document.body.appendChild(a);
  12042. a.click();
  12043. }).error(function (data, status, headers, config) {
  12044. // console.log(data);
  12045. });
  12046. }
  12047. $scope.view = function (contentId, filename, attachment) {
  12048. var index = filename.indexOf(".");
  12049. var type = filename.substring(index + 1);
  12050. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  12051. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  12052. // var modalInstance = $modal.open({
  12053. // backdrop: false,
  12054. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  12055. // controller: function($scope, scope, $modalInstance, filename) {
  12056. // $scope.title = filename;
  12057. // $scope.imageurl = scope.imageurl;
  12058. // $scope.cancel = function() {
  12059. // $modalInstance.dismiss('cancel');
  12060. // }
  12061. // },
  12062. // resolve: {
  12063. // scope: function() {
  12064. // return $scope;
  12065. // },
  12066. // filename: function() {
  12067. // return filename;
  12068. // }
  12069. // }
  12070. // });
  12071. // event.preventDefault();
  12072. // } else {
  12073. // for (var i = 0; i < $scope.attachments.length; i++) {
  12074. // if ($scope.attachments[i].id == attachmentId) {
  12075. window.open(attachment.previewUrl);
  12076. // }
  12077. // }
  12078. // }
  12079. };
  12080. $scope._refresh = function (refreshAttr) {
  12081. if (refreshAttr !== undefined) {
  12082. if (_refreshDelayPromise) {
  12083. $timeout.cancel(_refreshDelayPromise);
  12084. }
  12085. _refreshDelayPromise = $timeout(function () {
  12086. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  12087. 'file', {
  12088. "file": {
  12089. "solutionId": $scope.model.knowledge.id
  12090. },
  12091. "idx": "0",
  12092. "sum": "1000"
  12093. }).then(function (response) {
  12094. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  12095. if (myData) {
  12096. $scope.attachments = myData.list;
  12097. // $scope.view = function(attachmentId) {
  12098. // for (var i = 0; i < $scope.attachments.length; i++) {
  12099. // if ($scope.attachments[i].id == attachmentId) {
  12100. // window.open($scope.attachments[i].previewUrl);
  12101. // // var modalInstance = $modal.open({
  12102. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  12103. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  12104. // // }
  12105. // // });
  12106. // }
  12107. // }
  12108. // };
  12109. }
  12110. });
  12111. }, $scope.options.templateOptions.refreshDelay);
  12112. }
  12113. }
  12114. $scope._refresh({});
  12115. // $scope.attachments = $scope.model[$scope.options.key]
  12116. }]
  12117. });
  12118. //附件图片下载
  12119. formlyConfigProvider.setType({
  12120. name: 'ui-downimage',
  12121. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  12122. defaultOptions: function (options) {
  12123. return {
  12124. templateOptions: {
  12125. refresh: function (APIService, processInstanceId, data) {
  12126. return APIService.listAttachments(processInstanceId, data);
  12127. },
  12128. downloadUri: function (APIService, contentId) {
  12129. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12130. },
  12131. view: function (APIService, contentId) {
  12132. return APIService.attachmentsPreviewUrl(contentId);
  12133. },
  12134. download: function (APIService, contentId, item) {
  12135. var item = {
  12136. 'url': APIService.download(contentId),
  12137. 'headers': headers
  12138. };
  12139. return item;
  12140. },
  12141. refreshDelay: 0
  12142. }
  12143. };
  12144. },
  12145. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  12146. var _refreshDelayPromise;
  12147. // $scope.downloadUrl = function(contentId){
  12148. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  12149. // };
  12150. $scope.download = function (contentId, filename) {
  12151. // var headers=
  12152. $http({
  12153. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  12154. method: 'GET',
  12155. headers: {
  12156. //'Content-type' : 'application/xls',
  12157. 'Accept': '*/*'
  12158. },
  12159. responseType: 'arraybuffer'
  12160. }).success(function (data, status, headers, config) {
  12161. var file = new Blob([data], {
  12162. type: 'application/octet-stream'
  12163. });
  12164. //trick to download store a file having its URL
  12165. var fileURL = URL.createObjectURL(file);
  12166. var a = document.createElement('a');
  12167. a.href = fileURL;
  12168. a.target = '_blank';
  12169. a.download = filename;
  12170. document.body.appendChild(a);
  12171. a.click();
  12172. }).error(function (data, status, headers, config) {
  12173. // console.log(data);
  12174. });
  12175. };
  12176. $scope.view = function (contentId) {
  12177. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  12178. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  12179. // if (response.state == 200) {
  12180. // window.open(response.previewUrl);
  12181. // }
  12182. // })
  12183. };
  12184. /**
  12185. * refresh
  12186. */
  12187. $scope._refresh = function (refreshAttr) {
  12188. if (refreshAttr !== undefined) {
  12189. if (_refreshDelayPromise) {
  12190. $timeout.cancel(_refreshDelayPromise);
  12191. }
  12192. _refreshDelayPromise = $timeout(function () {
  12193. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  12194. $scope.options.templateOptions.processInstanceId, {
  12195. 'idx': 0,
  12196. 'sum': 1000
  12197. }).then(function (response) {
  12198. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  12199. if (myData) {
  12200. $scope.attachments = myData.data;
  12201. }
  12202. });
  12203. }, $scope.options.templateOptions.refreshDelay);
  12204. }
  12205. }
  12206. $scope._refresh({});
  12207. // $scope.attachments = $scope.model[$scope.options.key]
  12208. }]
  12209. });
  12210. //附件下载列表组件
  12211. formlyConfigProvider.setType({
  12212. name: 'ui-dropfiletable',
  12213. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  12214. defaultOptions: function (options) {
  12215. return {
  12216. templateOptions: {
  12217. refresh: function (APIService, processInstanceId, data) {
  12218. return APIService.listAttachments(processInstanceId, data);
  12219. },
  12220. downloadUri: function (APIService, contentId) {
  12221. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12222. },
  12223. view: function (APIService, contentId) {
  12224. return APIService.attachmentsPreviewUrl(contentId);
  12225. },
  12226. download: function (APIService, contentId, item) {
  12227. var item = {
  12228. 'url': APIService.download(contentId),
  12229. 'headers': headers
  12230. };
  12231. return item;
  12232. },
  12233. refreshDelay: 0
  12234. }
  12235. };
  12236. },
  12237. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  12238. var _refreshDelayPromise;
  12239. // $scope.downloadUrl = function(contentId){
  12240. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  12241. // };
  12242. $scope.download = function (contentId, filename) {
  12243. // var headers=
  12244. $http({
  12245. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  12246. method: 'GET',
  12247. headers: {
  12248. //'Content-type' : 'application/xls',
  12249. 'Accept': '*/*'
  12250. },
  12251. responseType: 'arraybuffer'
  12252. }).success(function (data, status, headers, config) {
  12253. var file = new Blob([data], {
  12254. type: 'application/octet-stream'
  12255. });
  12256. //trick to download store a file having its URL
  12257. var fileURL = URL.createObjectURL(file);
  12258. var a = document.createElement('a');
  12259. a.href = fileURL;
  12260. a.target = '_blank';
  12261. a.download = filename;
  12262. document.body.appendChild(a);
  12263. a.click();
  12264. }).error(function (data, status, headers, config) {
  12265. // console.log(data);
  12266. });
  12267. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  12268. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  12269. // var file = new Blob([response], {
  12270. // type : 'application/octet-stream'
  12271. // });
  12272. // // var filename = filename;
  12273. // //var file = new Blob([response], {type: 'application/pdf'});
  12274. // var fileURL = URL.createObjectURL(file);
  12275. // var a = document.createElement('a');
  12276. // a.href = fileURL;
  12277. // a.target = '_blank';
  12278. // a.download = filename ;
  12279. // document.body.appendChild(a);
  12280. // a.click();
  12281. // })
  12282. };
  12283. $scope.view = function (contentId, token, filename, type) {
  12284. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  12285. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  12286. // var modalInstance = $modal.open({
  12287. // backdrop: false,
  12288. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  12289. // controller: function($scope, scope, $modalInstance, filename) {
  12290. // $scope.title = filename;
  12291. // $scope.imageurl = scope.imageurl;
  12292. // $scope.cancel = function() {
  12293. // $modalInstance.dismiss('cancel');
  12294. // }
  12295. // },
  12296. // resolve: {
  12297. // scope: function() {
  12298. // return $scope;
  12299. // },
  12300. // filename: function() {
  12301. // return filename;
  12302. // }
  12303. // }
  12304. // });
  12305. // event.preventDefault();
  12306. // } else {
  12307. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  12308. if (response.state == 200) {
  12309. window.open(response.previewUrl);
  12310. }
  12311. })
  12312. // }
  12313. };
  12314. /**
  12315. * refresh
  12316. */
  12317. $scope._refresh = function (refreshAttr) {
  12318. if (refreshAttr !== undefined) {
  12319. if (_refreshDelayPromise) {
  12320. $timeout.cancel(_refreshDelayPromise);
  12321. }
  12322. _refreshDelayPromise = $timeout(function () {
  12323. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  12324. $scope.options.templateOptions.processInstanceId, {
  12325. 'idx': 0,
  12326. 'sum': 1000
  12327. }).then(function (response) {
  12328. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  12329. if (myData) {
  12330. $scope.attachments = myData.data;
  12331. }
  12332. });
  12333. }, $scope.options.templateOptions.refreshDelay);
  12334. }
  12335. }
  12336. $scope._refresh({});
  12337. // $scope.attachments = $scope.model[$scope.options.key]
  12338. }]
  12339. });
  12340. //微信附件下载列表组件
  12341. formlyConfigProvider.setType({
  12342. name: 'ui-dropfilewechat',
  12343. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  12344. defaultOptions: function (options) {
  12345. return {
  12346. templateOptions: {
  12347. // refresh: function(APIService, processInstanceId, data) {
  12348. // return APIService.listAttachments(processInstanceId, data);
  12349. // },
  12350. // downloadUri: function(APIService, contentId) {
  12351. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  12352. // },
  12353. view: function (APIService, contentId) {
  12354. // return APIService.attachmentsPreviewUrl(contentId);
  12355. return APIService.attachmentsPreviewUrl(contentId);
  12356. },
  12357. download: function (APIService, contentId, item) {
  12358. var item = {
  12359. 'url': APIService.download(contentId),
  12360. 'headers': headers
  12361. };
  12362. return item;
  12363. },
  12364. // download: function(APIService, contentId, item) {
  12365. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  12366. // return item;
  12367. // },
  12368. refreshDelay: 0
  12369. }
  12370. };
  12371. },
  12372. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  12373. var _refreshDelayPromise;
  12374. // $scope.downloadUrl = function(contentId){
  12375. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  12376. // };
  12377. $scope.attachments = {};
  12378. $scope.previewUrl = '';
  12379. $scope.download = function (token, filename) {
  12380. // var headers=
  12381. $http({
  12382. url: $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl(),
  12383. method: 'GET',
  12384. headers: {
  12385. //'Content-type' : 'application/xls',
  12386. 'Accept': '*/*'
  12387. },
  12388. responseType: 'arraybuffer'
  12389. }).success(function (data, status, headers, config) {
  12390. var file = new Blob([data], {
  12391. type: 'application/octet-stream'
  12392. });
  12393. //trick to download store a file having its URL
  12394. var fileURL = URL.createObjectURL(file);
  12395. var a = document.createElement('a');
  12396. a.href = fileURL;
  12397. a.target = '_blank';
  12398. a.download = filename;
  12399. document.body.appendChild(a);
  12400. a.click();
  12401. }).error(function (data, status, headers, config) {
  12402. // console.log(data);
  12403. });
  12404. };
  12405. $scope.view = function (contentId, token, filename, type, previewUrl) {
  12406. // if (type) {
  12407. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  12408. // var modalInstance = $modal.open({
  12409. // backdrop: false,
  12410. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  12411. // controller: function($scope, scope, $modalInstance, filename) {
  12412. // $scope.title = filename;
  12413. // $scope.imageurl = scope.imageurl;
  12414. // $scope.cancel = function() {
  12415. // $modalInstance.dismiss('cancel');
  12416. // }
  12417. // },
  12418. // resolve: {
  12419. // scope: function() {
  12420. // return $scope;
  12421. // },
  12422. // filename: function() {
  12423. // return filename;
  12424. // }
  12425. // }
  12426. // });
  12427. // event.preventDefault();
  12428. // } else {
  12429. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  12430. // if (response.state == 200) {
  12431. // window.open(response.previewUrl);
  12432. // }
  12433. // })
  12434. window.open(previewUrl);
  12435. // }
  12436. };
  12437. /**
  12438. * refresh
  12439. */
  12440. $scope._refresh = function (refreshAttr) {
  12441. if (refreshAttr !== undefined) {
  12442. if (_refreshDelayPromise) {
  12443. $timeout.cancel(_refreshDelayPromise);
  12444. }
  12445. _refreshDelayPromise = $timeout(function () {
  12446. // console.log(JSON.parse($stateParams.model))
  12447. var incidentChart = {};
  12448. if ($stateParams.model) {
  12449. incidentChart = JSON.parse($stateParams.model).model;
  12450. }
  12451. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  12452. $scope.model).then(function (response) {
  12453. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  12454. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  12455. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  12456. if (myData) {
  12457. $scope.attachments = myData.data;
  12458. }
  12459. });
  12460. }, $scope.options.templateOptions.refreshDelay);
  12461. }
  12462. }
  12463. $scope._refresh({});
  12464. // $scope.attachments = $scope.model[$scope.options.key]
  12465. }]
  12466. });
  12467. formlyConfigProvider.setType({
  12468. name: 'ui-paralleltask',
  12469. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  12470. defaultOptions: function (options) {
  12471. return {
  12472. templateOptions: {
  12473. refresh: function (APIService, processInstanceId, data) {
  12474. //return APIService.listAttachments(processInstanceId, data);
  12475. },
  12476. refreshDelay: 0
  12477. }
  12478. };
  12479. },
  12480. controller: ['$scope', '$timeout', function ($scope, $timeout) {}]
  12481. });
  12482. //repeatSection
  12483. //
  12484. formlyConfigProvider.setType({
  12485. name: 'ui-repeatSection',
  12486. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  12487. defaultOptions: function (options) {
  12488. return {
  12489. templateOptions: {
  12490. unique: 1,
  12491. initDisplay: false
  12492. }
  12493. };
  12494. },
  12495. controller: function ($scope) {
  12496. //$scope.options.templateOptions.unique;
  12497. $scope.formOptions = {
  12498. formState: $scope.formState
  12499. };
  12500. $scope.addNew = addNew;
  12501. $scope.copyFields = copyFields;
  12502. function copyFields(fields) {
  12503. fields = angular.copy(fields);
  12504. addRandomIds(fields);
  12505. return fields;
  12506. }
  12507. function addNew() {
  12508. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  12509. var repeatsection = $scope.model[$scope.options.key];
  12510. var lastSection = repeatsection[repeatsection.length - 1];
  12511. var newsection = {};
  12512. repeatsection.push(newsection);
  12513. }
  12514. function addRandomIds(fields) {
  12515. $scope.options.templateOptions.unique++;
  12516. angular.forEach(fields, function (field, index) {
  12517. if (field.fieldGroup) {
  12518. addRandomIds(field.fieldGroup);
  12519. return; // fieldGroups don't need an ID
  12520. }
  12521. if (field.templateOptions && field.templateOptions.fields) {
  12522. addRandomIds(field.templateOptions.fields);
  12523. }
  12524. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  12525. });
  12526. }
  12527. function getRandomInt(min, max) {
  12528. return Math.floor(Math.random() * (max - min)) + min;
  12529. }
  12530. if ($scope.options.templateOptions.initDisplay) {
  12531. addNew();
  12532. }
  12533. }
  12534. });
  12535. //时间轴任务列表组件
  12536. //cmdb控件
  12537. formlyConfigProvider.setType({
  12538. name: 'ui-cmdb',
  12539. extends: 'input',
  12540. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  12541. defaultOptions: function (options) {
  12542. return {
  12543. templateOptions: {
  12544. onClick: function (size, options, modal, event, model) {
  12545. var modalInstance = modal.open({
  12546. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  12547. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  12548. var width = $scope.width = 600;
  12549. var height = $scope.height = 400;
  12550. var tree;
  12551. var d3 = window.d3;
  12552. $scope.my_tree_handler = function (branch) {
  12553. //var _ref;
  12554. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  12555. APIService.query({
  12556. 'sign': classify
  12557. }).then(function (data) {
  12558. var myData = Restangular.stripRestangular(data);
  12559. // console.log(myData.data.node);
  12560. if (myData.data && myData.status == 200) {
  12561. var ret = myData.data;
  12562. redrawSvg(myData);
  12563. }
  12564. });
  12565. };
  12566. $scope.my_data = [];
  12567. function convertListToTree(data, treeMap) {
  12568. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12569. var root = null; //Initially set our loop to null
  12570. var parentNode = null;
  12571. //loop over data
  12572. for (var i = 0; i < data.length; i++) {
  12573. var datum = data[i];
  12574. //each node will have children, so let's give it a "children" poperty
  12575. datum.children = [];
  12576. //add an entry for this node to the map so that any future children can
  12577. //lookup the parent
  12578. idToNodeMap[datum.id] = datum;
  12579. //Does this node have a parent?
  12580. if (typeof datum.parent === "undefined" || datum.parent == null) {
  12581. //Doesn't look like it, so this node is the root of the tree
  12582. root = datum;
  12583. treeMap[datum.id] = root;
  12584. } else {
  12585. //This node has a parent, so let's look it up using the id
  12586. parentNode = idToNodeMap[datum.parent.id];
  12587. //We don't need this property, so let's delete it.
  12588. delete datum.parent;
  12589. //Let's add the current node as a child of the parent node.
  12590. parentNode.children.push(datum);
  12591. }
  12592. }
  12593. return root;
  12594. }
  12595. function convertParentToChildList(data) {
  12596. var treeMap = {};
  12597. var list = [];
  12598. convertListToTree(data, treeMap);
  12599. angular.forEach(treeMap, function (item) {
  12600. list.push(item);
  12601. });
  12602. return list;
  12603. }
  12604. $scope.my_tree = tree = {};
  12605. $scope.try_async_load = function () {
  12606. $scope.my_data = [];
  12607. $scope.select_treedata = [];
  12608. $scope.doing_async = true;
  12609. ConfigDataService.fetchDataList('ciclassify', {
  12610. 'idx': 0,
  12611. 'sum': 100
  12612. }).then(function (result) {
  12613. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  12614. $scope.doing_async = false;
  12615. });
  12616. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  12617. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  12618. // $scope.doing_async = false;
  12619. // });
  12620. };
  12621. $scope.select_treedata = [];
  12622. $scope.propTypeOptions = [];
  12623. $scope.try_async_load();
  12624. $scope.onFilterCallback = function (item) {
  12625. //console.log(item);
  12626. if (angular.isDefined(item.children) && item.children.length >= 1) {
  12627. //not valid
  12628. } else {
  12629. var tempclassify = item.prefix.toLowerCase() + item.sign;
  12630. $scope.cifilter_classic = tempclassify;
  12631. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  12632. var myData = Restangular.stripRestangular(data);
  12633. $scope.propTypeOptions = myData;
  12634. });
  12635. }
  12636. }
  12637. $scope.onPropTypeChange = function (form) {
  12638. $scope.propOptions = form.fields;
  12639. }
  12640. $scope.onPropChange = function (prop) {
  12641. $scope.cifilter_prop = prop;
  12642. }
  12643. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  12644. //if(searchKey!=null&&searchKey.length>1){
  12645. var searchData = {};
  12646. if (angular.isUndefined(propObj)) {
  12647. propObj = $scope.cifilter_prop;
  12648. }
  12649. if (angular.isUndefined(ciclassify)) {
  12650. ciclassify = $scope.cifilter_classic;
  12651. }
  12652. searchData['sign'] = ciclassify;
  12653. if (angular.isDefined(propObj)) {
  12654. searchData[propObj.key] = searchKey;
  12655. }
  12656. APIService.query(searchData).then(function (response) {
  12657. var data = Restangular.stripRestangular(response);
  12658. //此处不清空nodes
  12659. var node = data.data.node;
  12660. var tempNode = [];
  12661. //nodes 或者links 要去重
  12662. for (var i = 0; i < node.length; i++) {
  12663. var tmp = 0;
  12664. for (var j = 0; j < nodes.length; j++) {
  12665. if (node[i].uuid == nodes[j].uuid) {
  12666. tmp++;
  12667. break;
  12668. }
  12669. }
  12670. if (tmp == 0) {
  12671. tempNode.push(node[i]);
  12672. }
  12673. }
  12674. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  12675. nodes.push(tempNode[i]);
  12676. }
  12677. restart();
  12678. })
  12679. }
  12680. $scope.refresh = function () {
  12681. nodes.length = 0;
  12682. links.length = 0;
  12683. restart();
  12684. }
  12685. $scope.traversal = function () {
  12686. if ($scope.selected_node == null) {
  12687. SweetAlert.swal({
  12688. title: "错误的操作!",
  12689. text: "没有配置项被选中!",
  12690. type: "error"
  12691. });
  12692. } else {
  12693. var uuid = $scope.selected_node.uuid;
  12694. APIService.traversal(uuid).then(function (response) {
  12695. var d = response.data;
  12696. var node = d.node;
  12697. var link = d.edge;
  12698. var tempNode = [];
  12699. var tempLink = [];
  12700. //nodes 或者links 要去重
  12701. for (var i = 0; i < node.length; i++) {
  12702. var tmp = 0;
  12703. for (var j = 0; j < nodes.length; j++) {
  12704. if (node[i].id == nodes[j].id) {
  12705. tmp++;
  12706. break;
  12707. }
  12708. }
  12709. if (tmp == 0) {
  12710. tempNode.push(node[i]);
  12711. }
  12712. }
  12713. for (var i = 0; i < link.length; i++) {
  12714. var tmp = 0;
  12715. for (var j = 0; j < links.length; j++) {
  12716. if (link[i].id == links[j].id) {
  12717. tmp++;
  12718. break;
  12719. }
  12720. }
  12721. if (tmp == 0) {
  12722. tempLink.push(link[i]);
  12723. }
  12724. }
  12725. //数据写入页面
  12726. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  12727. nodes.push(tempNode[i]);
  12728. }
  12729. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  12730. links.push(tempLink[i]);
  12731. }
  12732. //links转换
  12733. for (var i = 0; i < links.length; i++) {
  12734. for (var j = 0; j < nodes.length; j++) {
  12735. if (links[i].source == nodes[j].id) {
  12736. links[i].source = nodes[j];
  12737. }
  12738. if (links[i].target == nodes[j].id) {
  12739. links[i].target = nodes[j];
  12740. }
  12741. }
  12742. }
  12743. restart();
  12744. })
  12745. }
  12746. }
  12747. var svg;
  12748. var force;
  12749. var drag_line, path, circle;
  12750. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  12751. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  12752. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  12753. var nodes = [],
  12754. links = [];
  12755. var treeNodes = [];
  12756. //读取labels (node)
  12757. var labels = [];
  12758. function redrawSvg(json) {
  12759. nodes.length = 0; //先清空
  12760. links.length = 0;
  12761. var data = json.data;
  12762. for (var i = 0; i < data.node.length; i++) {
  12763. nodes.push(data.node[i]);
  12764. }
  12765. restart();
  12766. }
  12767. //读取status (节点 连线)
  12768. var statuses = [];
  12769. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  12770. // if (result && result.status == 200) {
  12771. // d3.select('#nodeStatus').selectAll('option')
  12772. // .data(statuses).enter()
  12773. // .append('option')
  12774. // .attr('value', function(d) { return d.code; })
  12775. // .html(function(d) { return d.desc; });
  12776. // } else {
  12777. // SweetAlert.swal({
  12778. // title: "提示!",
  12779. // text: "服务器请求异常!",
  12780. // type: "error"
  12781. // });
  12782. // }
  12783. // });
  12784. api_wechatfile.getDictionary({
  12785. 'key': 'cmdb_status',
  12786. 'type': 'list'
  12787. }).then(function (result) {
  12788. if (result && result.status == 200) {
  12789. d3.select('#nodeStatus').selectAll('option')
  12790. .data(statuses).enter()
  12791. .append('option')
  12792. .attr('value', function (d) {
  12793. return d.code;
  12794. })
  12795. .html(function (d) {
  12796. return d.desc;
  12797. });
  12798. } else {
  12799. SweetAlert.swal({
  12800. title: "提示!",
  12801. text: "服务器请求异常!",
  12802. type: "error"
  12803. });
  12804. }
  12805. });
  12806. //查询relationship_type表 name 为表里的type,label为显示值
  12807. var linkType = [];
  12808. function fetchEdgeTypes() {
  12809. ConfigDataService.fetchDataList('ciedgetype', {
  12810. 'idx': 0,
  12811. 'sum': 100
  12812. }).then(function (response) {
  12813. if (response) {
  12814. if (response['list']) {
  12815. linkType = response['list'];
  12816. // d3.select('#linkName').selectAll('option')
  12817. // .data(linkType).enter()
  12818. // .append('option')
  12819. // .attr('value',function(d){return d.type;})
  12820. // .html(function(d){ return d.label;});
  12821. } else {
  12822. SweetAlert.swal({
  12823. title: "提示!",
  12824. text: "服务器请求异常!",
  12825. type: "error"
  12826. });
  12827. }
  12828. } else {
  12829. SweetAlert.swal({
  12830. title: "提示!",
  12831. text: "服务器请求异常!",
  12832. type: "error"
  12833. });
  12834. }
  12835. })
  12836. }
  12837. fetchEdgeTypes();
  12838. /*
  12839. // init D3 force layout
  12840. var force = d3.layout.force()
  12841. .nodes(nodes)
  12842. .links(links)
  12843. .size([width, height])
  12844. .gravity(.05)
  12845. .linkDistance(150)
  12846. .linkStrength(2)
  12847. .charge(-500)
  12848. .on('tick', tick);
  12849. // define arrow markers for graph links
  12850. svg.append('svg:defs').append('svg:marker')
  12851. .attr('id', 'end-arrow')
  12852. .attr('viewBox', '0 -5 10 10')
  12853. .attr('refX', 6)
  12854. .attr('markerWidth', 3)
  12855. .attr('markerHeight', 3)
  12856. .attr('orient', 'auto')
  12857. .append('svg:path')
  12858. .attr('d', 'M0,-5L10,0L0,5')
  12859. .attr('fill', '#000');
  12860. svg.append('svg:defs').append('svg:marker')
  12861. .attr('id', 'start-arrow')
  12862. .attr('viewBox', '0 -5 10 10')
  12863. .attr('refX', 4)
  12864. .attr('markerWidth', 3)
  12865. .attr('markerHeight', 3)
  12866. .attr('orient', 'auto')
  12867. .append('svg:path')
  12868. .attr('d', 'M10,-5L0,0L10,5')
  12869. .attr('fill', '#000');
  12870. // line displayed when dragging new nodes
  12871. var drag_line = svg.append('svg:path')
  12872. .attr('class', 'link dragline hidden')
  12873. .attr('d', 'M0,0L0,0');
  12874. // handles to link and node element groups
  12875. //(1)var path = svg.append('svg:g').selectAll('g')
  12876. var path = svg.append('svg:g').selectAll('g'),
  12877. circle = svg.append('svg:g').selectAll('g');
  12878. */
  12879. // mouse event vars
  12880. var selected_node = null,
  12881. selected_link = null,
  12882. mousedown_link = null,
  12883. mousedown_node = null,
  12884. mouseup_node = null;
  12885. function resetMouseVars() {
  12886. mousedown_node = null;
  12887. mouseup_node = null;
  12888. mousedown_link = null;
  12889. }
  12890. // update force layout (called automatically each iteration)
  12891. function tick() {
  12892. // draw directed edges with proper padding from node centers
  12893. path.selectAll('path').attr('d', function (d) {
  12894. var deltaX = d.target.x - d.source.x,
  12895. deltaY = d.target.y - d.source.y,
  12896. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  12897. normX = deltaX / dist,
  12898. normY = deltaY / dist,
  12899. sourcePadding = d.left ? 27 : 22,
  12900. targetPadding = d.right ? 27 : 22,
  12901. sourceX = d.source.x + (sourcePadding * normX),
  12902. sourceY = d.source.y + (sourcePadding * normY),
  12903. targetX = d.target.x - (targetPadding * normX),
  12904. targetY = d.target.y - (targetPadding * normY);
  12905. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  12906. });
  12907. circle.attr('transform', function (d) {
  12908. return 'translate(' + d.x + ',' + d.y + ')';
  12909. });
  12910. }
  12911. // update graph (called when needed)
  12912. function restart() {
  12913. //绑定link 数据
  12914. path.datum(links);
  12915. // path (link) group
  12916. path = path.data(links, function (d) {
  12917. return d.id;
  12918. });
  12919. var p = path.enter().append('svg:g');
  12920. //update existing links
  12921. path.selectAll('path').classed('selected', function (d) {
  12922. return d === selected_link;
  12923. })
  12924. .style('marker-start', function (d) {
  12925. return d.left ? 'url(#start-arrow)' : '';
  12926. })
  12927. .style('marker-end', function (d) {
  12928. return d.right ? 'url(#end-arrow)' : '';
  12929. });
  12930. // add new links
  12931. p.append('svg:path')
  12932. .attr('class', 'link')
  12933. .attr('id', function (d) {
  12934. return "path_" + d.id;
  12935. })
  12936. // .attr('startOffset', '0%')
  12937. .classed('selected', function (d) {
  12938. return d === selected_link;
  12939. })
  12940. .style('marker-start', function (d) {
  12941. return d.left ? 'url(#start-arrow)' : '';
  12942. })
  12943. .style('marker-end', function (d) {
  12944. return d.right ? 'url(#end-arrow)' : '';
  12945. })
  12946. .on('mousedown', function (d) {
  12947. if (d3.event.ctrlKey) return;
  12948. //去除没有提交的连线
  12949. for (var i = 0; i < links.length; i++) {
  12950. if (links[i].id == -1 && d.id != -1) {
  12951. links.splice(i, 1);
  12952. }
  12953. }
  12954. // select link
  12955. mousedown_link = d;
  12956. if (mousedown_link === selected_link) {
  12957. selected_link = $scope.selected_link = null;
  12958. selected_node = $scope.selected_node = null;
  12959. // d3.select("#linkDetail").attr('style','display:none');
  12960. //hideLinkForm(true);//return ;
  12961. } else {
  12962. selected_link = $scope.selected_link = mousedown_link;
  12963. selected_node = $scope.selected_node = null;
  12964. }
  12965. selected_node = $scope.selected_node = null;
  12966. restart();
  12967. });
  12968. p.append('svg:text')
  12969. .attr('x', 30)
  12970. .attr('y', 20)
  12971. .attr('class', 'fontM')
  12972. .append('textPath')
  12973. .attr('xlink:xlink:href', function (d, i) {
  12974. return "#path_" + d.id;
  12975. })
  12976. .html(function (d) {
  12977. for (var i = 0; i < linkType.length; i++) {
  12978. if (linkType[i].type == d.name) {
  12979. return linkType[i].label;
  12980. }
  12981. }
  12982. });
  12983. // remove old links
  12984. path.exit().remove();
  12985. // circle (node) group
  12986. // NB: the function arg is crucial here! nodes are known by id, not by index!
  12987. circle.datum(nodes);
  12988. circle = circle.data(nodes, function (d) {
  12989. return d.id;
  12990. });
  12991. // update existing nodes (reflexive & selected visual states)
  12992. circle.selectAll('circle')
  12993. .style('fill', function (d) {
  12994. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  12995. })
  12996. .style('fill-opacity', 0.75) // add by xi
  12997. .classed('reflexive', function (d) {
  12998. return d.reflexive;
  12999. });
  13000. // add new nodes
  13001. var g = circle.enter().append('svg:g');
  13002. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  13003. //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');
  13004. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  13005. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  13006. }).style('stroke', function (d) {
  13007. return d3.rgb(colors(d.label)).darker().toString();
  13008. }).style('stroke-width', '2');
  13009. g.append('svg:circle')
  13010. .attr('class', 'node')
  13011. .attr('r', 18)
  13012. .style('fill', function (d) {
  13013. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  13014. })
  13015. .style('stroke', function (d) {
  13016. return d3.rgb(colors(d.label)).darker().toString();
  13017. })
  13018. .style('fill-opacity', 0.25) //add by xj
  13019. .style('stroke-opacity', 0.5) //add by xj
  13020. .classed('reflexive', function (d) {
  13021. return d.reflexive;
  13022. });
  13023. g.on('mouseover', function (d) {
  13024. //if(!mousedown_node || d === mousedown_node) return;
  13025. // enlarge target node
  13026. //d3.select(this).attr('transform', 'scale(1.1)');
  13027. })
  13028. .on('mouseout', function (d) {
  13029. //if(!mousedown_node || d === mousedown_node) return;
  13030. // unenlarge target node
  13031. //d3.select(this).attr('transform', '');
  13032. })
  13033. .on('mousedown', function (d) {
  13034. if (d3.event.ctrlKey) return;
  13035. //hideLinkForm(true);
  13036. //去除没有提交的连线
  13037. for (var i = 0; i < links.length; i++) {
  13038. if (links[i].id == -1) {
  13039. links.splice(i, 1);
  13040. }
  13041. }
  13042. // select node
  13043. mousedown_node = d;
  13044. if (mousedown_node === selected_node) {
  13045. selected_node = $scope.selected_node = null;
  13046. } else {
  13047. selected_node = $scope.selected_node = mousedown_node;
  13048. selected_link = $scope.selected_link = null;
  13049. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  13050. APIService.findRefById(selected_node.id).then(function (result) {
  13051. var d = result.data;
  13052. var node = d.node;
  13053. var link = d.edge;
  13054. var tempNode = [];
  13055. var tempLink = [];
  13056. //nodes 或者links 要去重
  13057. for (var i = 0; i < node.length; i++) {
  13058. var tmp = 0;
  13059. for (var j = 0; j < nodes.length; j++) {
  13060. if (node[i].id == nodes[j].id) {
  13061. tmp++;
  13062. break;
  13063. }
  13064. }
  13065. if (tmp == 0) {
  13066. tempNode.push(node[i]);
  13067. }
  13068. }
  13069. for (var i = 0; i < link.length; i++) {
  13070. var tmp = 0;
  13071. for (var j = 0; j < links.length; j++) {
  13072. if (link[i].id == links[j].id) {
  13073. tmp++;
  13074. break;
  13075. }
  13076. }
  13077. if (tmp == 0) {
  13078. tempLink.push(link[i]);
  13079. }
  13080. }
  13081. //数据写入页面
  13082. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  13083. nodes.push(tempNode[i]);
  13084. }
  13085. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  13086. links.push(tempLink[i]);
  13087. }
  13088. //links转换
  13089. for (var i = 0; i < links.length; i++) {
  13090. for (var j = 0; j < nodes.length; j++) {
  13091. if (links[i].source == nodes[j].id) {
  13092. links[i].source = nodes[j];
  13093. }
  13094. if (links[i].target == nodes[j].id) {
  13095. links[i].target = nodes[j];
  13096. }
  13097. }
  13098. }
  13099. restart();
  13100. });
  13101. }
  13102. // reposition drag line
  13103. drag_line
  13104. .style('marker-end', 'url(#end-arrow)')
  13105. .classed('hidden', false)
  13106. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  13107. restart();
  13108. })
  13109. .on('mouseup', function (d) {
  13110. if (!mousedown_node) return;
  13111. });
  13112. // show node name
  13113. g.append('svg:text')
  13114. .attr('x', 0)
  13115. .attr('y', 34)
  13116. .attr('class', 'id')
  13117. .text(function (d) {
  13118. return d.name;
  13119. }); //TODO 改为 d.name
  13120. //设置图片
  13121. g.append('svg:foreignObject')
  13122. .attr("width", 32)
  13123. .attr("height", 32)
  13124. .attr('x', "-16px")
  13125. .attr('y', "-11px")
  13126. .html(function (d) {
  13127. for (var i = 0; i < labels.length; i++) {
  13128. if (d.label == labels[i].sign) {
  13129. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  13130. }
  13131. }
  13132. });
  13133. // remove old nodes
  13134. circle.exit().remove();
  13135. // set the graph in motion
  13136. force.start();
  13137. }
  13138. function mousedown() {
  13139. // prevent I-bar on drag
  13140. //d3.event.preventDefault();
  13141. // because :active only works in WebKit?
  13142. svg.classed('active', true);
  13143. if (mousedown_node) {
  13144. viewNode(mousedown_node);
  13145. }
  13146. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  13147. restart();
  13148. }
  13149. function mousemove() {
  13150. if (!mousedown_node) return;
  13151. // update drag line
  13152. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  13153. //restart();
  13154. }
  13155. function mouseup() {
  13156. if (mousedown_node) {
  13157. // hide drag line
  13158. drag_line
  13159. .classed('hidden', true)
  13160. .style('marker-end', '');
  13161. }
  13162. // because :active only works in WebKit?
  13163. svg.classed('active', false);
  13164. // clear mouse event vars
  13165. resetMouseVars();
  13166. }
  13167. function spliceLinksForNode(node) {
  13168. var toSplice = links.filter(function (l) {
  13169. return (l.source === node || l.target === node);
  13170. });
  13171. toSplice.map(function (l) {
  13172. links.splice(links.indexOf(l), 1);
  13173. });
  13174. }
  13175. // only respond once per keydown
  13176. var lastKeyDown = -1;
  13177. function keydown() {
  13178. //d3.event.preventDefault();
  13179. if (lastKeyDown !== -1) return;
  13180. lastKeyDown = d3.event.keyCode;
  13181. // ctrl
  13182. if (d3.event.keyCode === 17) {
  13183. circle.call(force.drag);
  13184. svg.classed('ctrl', true);
  13185. }
  13186. if (!selected_node && !selected_link) return;
  13187. switch (d3.event.keyCode) {
  13188. case 8: // backspace
  13189. case 66: // B
  13190. if (selected_link) {
  13191. // set link direction to both left and right
  13192. selected_link.left = true;
  13193. selected_link.right = true;
  13194. }
  13195. restart();
  13196. break;
  13197. case 76: // L
  13198. if (selected_link) {
  13199. // set link direction to left only
  13200. selected_link.left = true;
  13201. selected_link.right = false;
  13202. }
  13203. restart();
  13204. break;
  13205. case 82: // R
  13206. if (selected_node) {
  13207. // toggle node reflexivity
  13208. selected_node.reflexive = !selected_node.reflexive;
  13209. } else if (selected_link) {
  13210. // set link direction to right only
  13211. selected_link.left = false;
  13212. selected_link.right = true;
  13213. }
  13214. restart();
  13215. break;
  13216. }
  13217. }
  13218. function keyup() {
  13219. lastKeyDown = -1;
  13220. // ctrl
  13221. if (d3.event.keyCode === 17) {
  13222. circle
  13223. .on('mousedown.drag', null)
  13224. .on('touchstart.drag', null);
  13225. svg.classed('ctrl', false);
  13226. }
  13227. }
  13228. function viewNode(node) {
  13229. // console.log(svg.attr('left'));
  13230. //var el = angular.element('div.modal-dialog')[0];
  13231. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  13232. if (!$scope.selected_node.props.state) {
  13233. $scope.selected_node.props.state = "空"
  13234. } else if ($scope.selected_node.props.state) {
  13235. if ($scope.selected_node.props.state == "1") {
  13236. $scope.selected_node.props.state = "未审核"
  13237. } else if ($scope.selected_node.props.state == "2") {
  13238. $scope.selected_node.props.state = "已审核"
  13239. } else if ($scope.selected_node.props.state == "3") {
  13240. $scope.selected_node.props.state = "不匹配"
  13241. } else if ($scope.selected_node.props.state == "4") {
  13242. $scope.selected_node.props.state = "丢失"
  13243. }
  13244. };
  13245. if (!$scope.selected_node.name) {
  13246. $scope.selected_node.name = "空"
  13247. }
  13248. if (!$scope.selected_node.status) {
  13249. $scope.selected_node.statu = "空"
  13250. }
  13251. if (!$scope.selected_node.props.useradmin) {
  13252. $scope.selected_node.props.useradmin = "空"
  13253. }
  13254. Toaster.pop({
  13255. // type: 'info',
  13256. // title: title,
  13257. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  13258. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  13259. '<p>状态:' + $scope.selected_node.status + '</p>' +
  13260. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  13261. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  13262. bodyOutputType: 'trustedHtml',
  13263. timeout: 3000
  13264. })
  13265. }
  13266. //GT 颜色与数值对照表
  13267. function colors(sign) {
  13268. //num=num>20?num%20:parseInt(num);
  13269. for (var i = 0; i < labels.length; i++) {
  13270. var entity = labels[i];
  13271. if (sign == entity.sign) {
  13272. return entity.color;
  13273. }
  13274. if (i == labels.length - 1 && sign != entity.sign) {
  13275. return '#ffeeee';
  13276. }
  13277. }
  13278. }
  13279. $scope.init = function () {
  13280. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  13281. // init D3 force layout
  13282. force = d3.layout.force()
  13283. .nodes(nodes)
  13284. .links(links)
  13285. .size([width, height])
  13286. .gravity(.05)
  13287. .linkDistance(150)
  13288. .linkStrength(2)
  13289. .charge(-500)
  13290. .on('tick', tick);
  13291. // define arrow markers for graph links
  13292. svg.append('svg:defs').append('svg:marker')
  13293. .attr('id', 'end-arrow')
  13294. .attr('viewBox', '0 -5 10 10')
  13295. .attr('refX', 6)
  13296. .attr('markerWidth', 3)
  13297. .attr('markerHeight', 3)
  13298. .attr('orient', 'auto')
  13299. .append('svg:path')
  13300. .attr('d', 'M0,-5L10,0L0,5')
  13301. .attr('fill', '#000');
  13302. svg.append('svg:defs').append('svg:marker')
  13303. .attr('id', 'start-arrow')
  13304. .attr('viewBox', '0 -5 10 10')
  13305. .attr('refX', 4)
  13306. .attr('markerWidth', 3)
  13307. .attr('markerHeight', 3)
  13308. .attr('orient', 'auto')
  13309. .append('svg:path')
  13310. .attr('d', 'M10,-5L0,0L10,5')
  13311. .attr('fill', '#000');
  13312. // line displayed when dragging new nodes
  13313. drag_line = svg.append('svg:path')
  13314. .attr('class', 'link dragline hidden')
  13315. .attr('d', 'M0,0L0,0');
  13316. // handles to link and node element groups
  13317. //(1)var path = svg.append('svg:g').selectAll('g')
  13318. path = svg.append('svg:g').selectAll('g');
  13319. circle = svg.append('svg:g').selectAll('g');
  13320. svg.on('mousedown', mousedown)
  13321. .on('mousemove', mousemove)
  13322. .on('mouseup', mouseup);
  13323. d3.select(window)
  13324. .on('keydown', keydown)
  13325. .on('keyup', keyup);
  13326. }
  13327. var CI = {};
  13328. window.CI = CI;
  13329. $scope.ok = function () {
  13330. $modalInstance.close($scope.selected_node);
  13331. };
  13332. $scope.cancel = function () {
  13333. $modalInstance.dismiss('cancel');
  13334. };
  13335. },
  13336. size: size,
  13337. resolve: {
  13338. title: function () {
  13339. return options.templateOptions.title;
  13340. },
  13341. Restangular: function () {
  13342. return options.templateOptions.Restangular;
  13343. },
  13344. APIService: function () {
  13345. return options.templateOptions.ApiService;
  13346. },
  13347. ConfigDataService: function () {
  13348. return options.templateOptions.ConfigDataService;
  13349. },
  13350. ConfigFormService: function () {
  13351. return options.templateOptions.ConfigFormService;
  13352. },
  13353. SweetAlert: function () {
  13354. return options.templateOptions.Alert;
  13355. },
  13356. Toaster: function () {
  13357. return options.templateOptions.toaster;
  13358. }
  13359. }
  13360. });
  13361. modalInstance.result.then(function (selectedItem) {
  13362. options.value(selectedItem.name + '-' + selectedItem.uuid);
  13363. }, function () {
  13364. //console.log('Modal dismissed at: ' + new Date());
  13365. });
  13366. }
  13367. }
  13368. }
  13369. },
  13370. controller: ['$scope', function ($scope) {
  13371. // setTimeout(function(){
  13372. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  13373. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13374. // if(modelData.status==200){
  13375. // $scope.model[$scope.options.key] = modelData.data;
  13376. // $scope.options.initialValue = $scope.model[$scope.options.key];
  13377. // }
  13378. // });
  13379. // },1000);
  13380. }]
  13381. });
  13382. });
  13383. appFormly.run(function (formlyConfig, $parse) {
  13384. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  13385. var removeOnHideTransformer = function (fields, model) {
  13386. return fields.map(function (field) {
  13387. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  13388. addFieldRemoveOnHideWatcher(field);
  13389. }
  13390. if (field.type == "ui-title") {
  13391. addFieldRemoveOnHideWatcher(field);
  13392. }
  13393. return field;
  13394. });
  13395. };
  13396. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  13397. function addFieldRemoveOnHideWatcher(field) {
  13398. var watcher = getWatcher();
  13399. if (field.watcher) {
  13400. if (!angular.isArray(field.watcher)) {
  13401. field.watcher = [field.watcher];
  13402. }
  13403. field.watcher.push(watcher);
  13404. } else {
  13405. field.watcher = watcher;
  13406. }
  13407. }
  13408. function getWatcher() {
  13409. return {
  13410. expression: function (field) {
  13411. return field.hide;
  13412. },
  13413. listener: function (field, newHide, oldHide, scope) {
  13414. if (field.hide) {
  13415. if (field.templateOptions.pkey) {
  13416. if (field.key == 'transferuser') {
  13417. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  13418. }
  13419. } else {
  13420. $parse(field.key).assign(scope.model, undefined);
  13421. }
  13422. }
  13423. if (field.type == "ui-title") {
  13424. $parse(field.key).assign(scope.model, undefined);
  13425. }
  13426. }
  13427. };
  13428. }
  13429. });
  13430. appFormly.controller('CustomformCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'Restangular', 'UserRestangular', 'BpmRestangular', 'WechatRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_statistic', 'up_down_file',
  13431. function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, Restangular, UserRestangular, BpmRestangular, WechatRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, api_statistic, up_down_file) {
  13432. //console.log($parse('Restangular')($scope));
  13433. //console.log($injector.get('Restangular'));
  13434. //console.log($stateParams);
  13435. var vm = this;
  13436. vm.options = {};
  13437. vm.exampleTitle = ['expressionProperties', 'model property'];
  13438. vm.fields = [];
  13439. vm.model = {};
  13440. $scope.langs = i18nService.getAllLangs();
  13441. $scope.lang = 'zh-cn';
  13442. i18nService.setCurrentLang($scope.lang);
  13443. //alert($rootScope.user.id,null,2);
  13444. vm.model["loginUser"] = $rootScope.user;
  13445. var that = $injector;
  13446. var parse = $parse;
  13447. var formKey = "";
  13448. var pdKey = "";
  13449. var modelWatch = "";
  13450. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13451. modelWatch = JSON.parse($stateParams.model);
  13452. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  13453. }
  13454. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  13455. pdKey = $state.current.pdKey;
  13456. } else if ($stateParams.pdKey) {
  13457. pdKey = $stateParams.pdKey;
  13458. }
  13459. // console.log("pdKey::" + JSON.stringify($state.current.title));
  13460. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  13461. formKey = $stateParams.formKey;
  13462. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  13463. }
  13464. if (angular.isDefined($stateParams.model)) {
  13465. var formModel = $stateParams.model;
  13466. }
  13467. //用户测试数据,后续从header的auth中获取
  13468. var userId = 2;
  13469. userId = $rootScope.user.id;
  13470. //==============处理表单设计数据 开始====================
  13471. //处理组件加载后台数据选项的方法
  13472. function refreshSelectOptions(searchVal, field) {
  13473. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  13474. var process = BpmRestangular.all("");
  13475. if (field.templateOptions.ApiService) {
  13476. process = UserRestangular.all("");
  13477. }
  13478. if (field.templateOptions.Apicommon) {
  13479. process = WechatRestangular.all("");
  13480. }
  13481. var datakey = {
  13482. "idx": 0,
  13483. "sum": 1000
  13484. };
  13485. if (field.templateOptions.modelreasondata) {
  13486. datakey = field.templateOptions.modelreasondata
  13487. }
  13488. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  13489. if (!field.templateOptions.options) {
  13490. field.templateOptions.options = [];
  13491. }
  13492. if (field.templateOptions.optionsDataKey) {
  13493. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  13494. } else {
  13495. field.templateOptions.options = result;
  13496. }
  13497. });
  13498. }
  13499. }
  13500. //获取表单后数据处理
  13501. function formfield(field, result) {
  13502. // angular.forEach(fields.fields, function(field) {
  13503. if (field.key == "") {
  13504. delete field.key;
  13505. }
  13506. if (angular.isDefined(field.extjson)) {
  13507. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  13508. angular.extend(field.templateOptions, extObj.templateOptions);
  13509. delete extObj.templateOptions;
  13510. for (var prop in extObj) {
  13511. if (new RegExp("Expression").test(prop)) {
  13512. //var obj = $scope.$eval(extObj[prop]);
  13513. //extObj[prop] = $scope.$eval(extObj[prop]);
  13514. if (extObj[prop] != null) {
  13515. if (new RegExp("function").test(extObj[prop])) {
  13516. var propValue = eval(extObj[prop]);
  13517. extObj[prop] = propValue;
  13518. } else {
  13519. //console.log(extObj[prop]);
  13520. var obj = $scope.$eval(extObj[prop]);
  13521. extObj[prop] = obj;
  13522. //console.log(obj);
  13523. }
  13524. }
  13525. } else if (new RegExp("expressionProperties").test(prop)) {
  13526. for (var p in extObj[prop]) {
  13527. if (new RegExp("function").test(extObj[prop][p])) {
  13528. var propValue = eval(extObj[prop][p]);
  13529. extObj[prop][p] = propValue;
  13530. } else {
  13531. //if(p.indexOf("'")>=0){
  13532. // var obj = $scope.$eval(extObj[prop][p]);
  13533. // extObj[prop][$scope.$eval(p)]=obj;
  13534. //}
  13535. }
  13536. }
  13537. } else if ("watcher" == prop) {
  13538. if (angular.isArray(extObj[prop])) {
  13539. angular.forEach(extObj[prop], function (item, index) {
  13540. for (var p in item) {
  13541. if (new RegExp("function").test(item[p])) {
  13542. var propValue = eval(item[p]);
  13543. extObj[prop][index][p] = propValue;
  13544. }
  13545. }
  13546. });
  13547. } else if (angular.isObject(extObj[prop])) {
  13548. for (var p in extObj[prop]) {
  13549. if (new RegExp("function").test(extObj[prop][p])) {
  13550. var propValue = eval(extObj[prop][p]);
  13551. extObj[prop][p] = propValue;
  13552. }
  13553. }
  13554. }
  13555. }
  13556. }
  13557. angular.extend(field, extObj);
  13558. delete field.extjson;
  13559. }
  13560. if (angular.isDefined(field.templateOptions)) {
  13561. var templateOs = field.templateOptions;
  13562. for (var property in templateOs) {
  13563. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  13564. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  13565. if (new RegExp("function").test(templateOs[property])) {
  13566. var propValue = eval(templateOs[property]);
  13567. field.templateOptions[property] = propValue;
  13568. } else {
  13569. if (that.has(templateOs[property])) {
  13570. field.templateOptions[property] = that.get(templateOs[property]);
  13571. } else {
  13572. field.templateOptions[property] = templateOs[property];
  13573. }
  13574. }
  13575. } else if (templateOs[property] == null) {
  13576. //delete field.templateOptions[property];
  13577. } else {}
  13578. }
  13579. }
  13580. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  13581. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  13582. angular.extend(field.templateOptions, extObj);
  13583. delete field.templateOptions.extjson;
  13584. }
  13585. // ...
  13586. if (field.templateOptions) {
  13587. //处理远程获取数据控件方法调用
  13588. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  13589. // if (!field.templateOptions.isnoreash) {
  13590. field.templateOptions.refresh = refreshSelectOptions;
  13591. // }
  13592. }
  13593. //处理嵌套属性数据绑定/
  13594. if (field.templateOptions.pkey) {
  13595. var pmodel, i = 0;
  13596. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  13597. if (i == 0) {
  13598. if (result.model[p] == null) {
  13599. result.model[p] = {};
  13600. }
  13601. pmodel = result.model[p];
  13602. i++;
  13603. } else {
  13604. if (pmodel[p] == null) {
  13605. pmodel[p] = {};
  13606. }
  13607. pmodel = pmodel[p];
  13608. }
  13609. });
  13610. if (pmodel != null) {
  13611. field.model = pmodel;
  13612. if (pmodel[field.key] == null) {
  13613. pmodel[field.key] = null;
  13614. }
  13615. }
  13616. } else {
  13617. if (result.model[field.key] == null) {
  13618. result.model[field.key] = null;
  13619. }
  13620. }
  13621. //处理弹出框组件初始化
  13622. if (field.type == "ui-input-selectmodal") {
  13623. field.templateOptions.modal = $modal;
  13624. //field.templateOptions.Restangular = Restangular;
  13625. } else if (field.type == "ui-requesterselect") {
  13626. //field.templateOptions.language = $scope.lang;
  13627. field.templateOptions.modal = $modal;
  13628. field.templateOptions.UserService = api_user_data;
  13629. } else if (field.type == "ui-requesterinformation") {
  13630. field.templateOptions.modal = $modal;
  13631. field.templateOptions.UserService = api_user_data;
  13632. } else if (field.type == "ui-userselect") {
  13633. field.templateOptions.modal = $modal;
  13634. //field.templateOptions.Restangular = Restangular;
  13635. } else if (field.type == "ui-userselectSearch") {
  13636. field.templateOptions.modal = $modal;
  13637. //field.templateOptions.Restangular = Restangular;
  13638. } else if (field.type == "ui-multiuserselect") {
  13639. field.templateOptions.modal = $modal;
  13640. } else if (field.type == "ui-stringuserselect") {
  13641. field.templateOptions.modal = $modal;
  13642. } else if (field.type == "ui-search") {
  13643. field.templateOptions.modal = $modal;
  13644. } else if (field.type == "ui-modelselect") {
  13645. field.templateOptions.modal = $modal;
  13646. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  13647. field.templateOptions.loginUser = $rootScope.user;
  13648. //field.templateOptions.Restangular = Restangular;
  13649. } else if (field.type == "ui-incidentmodelselect") {
  13650. field.templateOptions.modal = $modal;
  13651. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  13652. field.templateOptions.loginUser = $rootScope.user;
  13653. //field.templateOptions.Restangular = Restangular;
  13654. } else if (field.type == "ui-dropfile") {
  13655. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13656. url: '/uploader'
  13657. });
  13658. field.templateOptions.taskId = $stateParams.taskId;
  13659. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13660. field.templateOptions.userId = $rootScope.user.id;
  13661. } else if (field.type == "ui-dropfielknow") {
  13662. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13663. url: '/uploader'
  13664. });
  13665. field.templateOptions.taskId = $stateParams.taskId;
  13666. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13667. field.templateOptions.userId = $rootScope.user.id;
  13668. } else if (field.type == "ui-upDropFile") {
  13669. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13670. url: '/uploader'
  13671. });
  13672. field.templateOptions.taskId = $stateParams.taskId;
  13673. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13674. field.templateOptions.userId = $rootScope.user.id;
  13675. } else if (field.type == "ui-dropfilenotup") {
  13676. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13677. url: '/uploader'
  13678. });
  13679. field.templateOptions.taskId = $stateParams.taskId;
  13680. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13681. field.templateOptions.userId = $rootScope.user.id;
  13682. //field.ApiService=api_bpm_domain;
  13683. }else if (field.type == "ui-uploadFile") {
  13684. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13685. url: '/uploader'
  13686. });
  13687. field.templateOptions.taskId = $stateParams.taskId;
  13688. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13689. field.templateOptions.userId = $rootScope.user.id;
  13690. //field.ApiService=api_bpm_domain;
  13691. } else if (field.type == "ui-dropfiletable") {
  13692. if (field.templateOptions.processInstanceId) {
  13693. } else {
  13694. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13695. }
  13696. } else if (field.type == "ui-repeatSection") {
  13697. var repeatForm = {
  13698. model: {
  13699. },
  13700. fields: field.templateOptions.fields
  13701. };
  13702. repeatForm.model[field.key] = [];
  13703. decodeVMForm(repeatForm);
  13704. } else if (field.type == "ui-currentuser") {
  13705. field.templateOptions.user = vm.model["loginUser"];
  13706. } else if (field.type == "ui-workernumbersign") {
  13707. field.templateOptions.user = vm.model["loginUser"];
  13708. }
  13709. }
  13710. }
  13711. //解析自定义表单设计数据
  13712. $scope.oldfromtype = true;
  13713. function decodeVMForm(vmForm) {
  13714. if (vmForm.formType == "1") {
  13715. $scope.oldfromtype = false;
  13716. } else {
  13717. $scope.oldfromtype = true;
  13718. }
  13719. var result = {
  13720. model: {},
  13721. fields: []
  13722. };
  13723. //设置模型实体数据 begin
  13724. // var mdata = vmForm.model;
  13725. //解析数据实体
  13726. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  13727. angular.extend(result.model, mdata);
  13728. if (modelWatch != null && modelWatch != '') {
  13729. //angular.extend(result.model.incident,modelWatch.incident);
  13730. //result.model.alarmType = modelWatch.alarmType;
  13731. // vmForm.cancelUrl = modelWatch.cancelUrl;
  13732. // console.log(modelWatch.cancelUrl)
  13733. for (var index in modelWatch.model) {
  13734. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  13735. if (result.model[index] != null) {
  13736. angular.extend(result.model[index], modelWatch.model[index]);
  13737. } else {
  13738. result.model[index] = modelWatch.model[index];
  13739. }
  13740. }
  13741. }
  13742. //设置模型实体数据 end
  13743. //解析设计数据生成表单项 begin
  13744. var fields = [];
  13745. //处理修改设计数据中展示设置
  13746. angular.forEach(vmForm.fields, function (fields) {
  13747. if (vmForm.formType == "1") {
  13748. angular.forEach(fields.fields, function (field) {
  13749. formfield(field, result);
  13750. });
  13751. } else {
  13752. formfield(fields, result);
  13753. }
  13754. // console.log(field);
  13755. result.fields.push(fields);
  13756. });
  13757. angular.extend($scope.vm.fields, result.fields);
  13758. angular.extend($scope.vm.model, result.model);
  13759. vm.model["loginUser"] = $rootScope.user;
  13760. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  13761. vmForm.cancelUrl = modelWatch.cancelUrl;
  13762. }
  13763. $scope.formData = vmForm;
  13764. console.log($scope.formData.url);
  13765. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  13766. if ($scope.formData.url == "start") {
  13767. $scope.Reset = true;
  13768. $scope.close = true;
  13769. $rootScope.isMask = false;
  13770. } else if ($scope.formData.url == "complete") {
  13771. $scope.Reset = false;
  13772. $scope.close = true;
  13773. }
  13774. //解析设计数据生成表单项 end
  13775. return result;
  13776. }
  13777. //======================处理表单设计数据 结束========================
  13778. $scope.ldloading = {};
  13779. function filter(obj) {
  13780. angular.forEach(obj, function (key, value) {
  13781. if (value === "" || value === null) {
  13782. delete obj[key];
  13783. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  13784. filter(value);
  13785. } else if (angular.isArray(value)) {
  13786. angular.forEach(value, function (item) {
  13787. filter(item);
  13788. });
  13789. }
  13790. });
  13791. }
  13792. $scope.closeModel = function () {
  13793. $state.go($scope.formData.cancelUrl, {});
  13794. event.preventDefault();
  13795. };
  13796. $scope.save = function (data) {
  13797. api_bpm_domain.save($stateParams.taskId, data).then(function (response) {
  13798. if (response) {
  13799. var resData = Restangular.stripRestangular(response);
  13800. SweetAlert.swal({
  13801. title: "暂存成功!",
  13802. confirmButtonColor: "#007AFF"
  13803. }, function () {
  13804. $state.go($scope.formData.cancelUrl);
  13805. });
  13806. } else {
  13807. SweetAlert.swal({
  13808. title: "系统错误",
  13809. text: "系统错误,请稍后重试!",
  13810. type: "error",
  13811. confirmButtonColor: "#DD6B55"
  13812. });
  13813. }
  13814. });
  13815. event.preventDefault();
  13816. }
  13817. vm.submit = function (data, style) {
  13818. // var pdKey = $stateParams.pdKey;
  13819. if (vm.form.$valid) {
  13820. if (data.incident && data.incident.synergetic) {
  13821. console.log(data.incident.synergetic);
  13822. var synergetic = [];
  13823. for (var i = 0; i < data.incident.synergetic.length; i++) {
  13824. synergetic.push({
  13825. id: data.incident.synergetic[i]
  13826. });
  13827. }
  13828. data.incident.synergetic = synergetic;
  13829. vm.model.incident.synergetic = synergetic;
  13830. }
  13831. $scope.ldloading[style.replace('-', '_')] = true;
  13832. var startsub = true;
  13833. if (pdKey == 'bpm_incident') {
  13834. angular.forEach(vm.fields, function (item) {
  13835. angular.forEach(item.fields, function (index) {
  13836. if (index.templateOptions.required && !index.hide) {
  13837. if (index.model) {
  13838. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  13839. if (index.model[index.key].id && index.model[index.key].id == '') {
  13840. startsub = false;
  13841. $scope.ldloading.expand_right = false;
  13842. SweetAlert.swal({
  13843. title: index.templateOptions.label + '未填',
  13844. text: "请填写此项!",
  13845. type: "error",
  13846. confirmButtonColor: "#DD6B55"
  13847. });
  13848. } else {}
  13849. } else {
  13850. startsub = false;
  13851. $scope.ldloading.expand_right = false;
  13852. SweetAlert.swal({
  13853. title: index.templateOptions.label + '未填',
  13854. text: "请填写此项!",
  13855. type: "error",
  13856. confirmButtonColor: "#DD6B55"
  13857. });
  13858. }
  13859. } else {
  13860. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  13861. } else {
  13862. startsub = false;
  13863. $scope.ldloading.expand_right = false;
  13864. SweetAlert.swal({
  13865. title: index.templateOptions.label + '未填',
  13866. text: "请填写此项!",
  13867. type: "error",
  13868. confirmButtonColor: "#DD6B55"
  13869. });
  13870. }
  13871. }
  13872. }
  13873. })
  13874. })
  13875. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  13876. // startsub = false;
  13877. // $scope.ldloading.expand_right = false;
  13878. // SweetAlert.swal({
  13879. // title: '保修人未填',
  13880. // text: "请填写此项!",
  13881. // type: "error",
  13882. // confirmButtonColor: "#DD6B55"
  13883. // });
  13884. // }
  13885. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  13886. // } else {
  13887. // startsub = false;
  13888. // $scope.ldloading.expand_right = false;
  13889. // SweetAlert.swal({
  13890. // title: '事件分类未填',
  13891. // text: "请填写此项!",
  13892. // type: "error",
  13893. // confirmButtonColor: "#DD6B55"
  13894. // });
  13895. // }
  13896. }
  13897. if (startsub) {
  13898. $scope.ldloading[style.replace('-', '_')] = true;
  13899. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  13900. // console.log("vm.options:"+ JSON.stringify(vm.options));
  13901. vm.options.updateInitialValue();
  13902. // console.log("dfjkasdhfkhskjf ")
  13903. var _ = window._;
  13904. vm.model = (function filter(obj) {
  13905. var dateTransKeys = [];
  13906. var filtered = _.pick(obj, function (v, k, obj) {
  13907. if (_.isDate(v)) {
  13908. dateTransKeys.push(k);
  13909. }
  13910. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  13911. });
  13912. return _.cloneDeep(filtered, function (v, index, object) {
  13913. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  13914. angular.forEach(dateTransKeys, function (item) {
  13915. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  13916. })
  13917. dateTransKey = [];
  13918. return v;
  13919. }
  13920. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  13921. });
  13922. })(vm.model);
  13923. if (pdKey != "") {
  13924. if ($scope.oprcode == "save") { //保存
  13925. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  13926. if (response) {
  13927. var resData = Restangular.stripRestangular(response);
  13928. SweetAlert.swal({
  13929. title: "保存成功!",
  13930. confirmButtonColor: "#007AFF"
  13931. }, function () {
  13932. $state.go($scope.formData.cancelUri);
  13933. });
  13934. // if(resData.status){
  13935. // resData
  13936. // }
  13937. } else {
  13938. SweetAlert.swal({
  13939. title: "系统错误",
  13940. text: "系统错误,请稍后重试!",
  13941. type: "error",
  13942. confirmButtonColor: "#DD6B55"
  13943. });
  13944. }
  13945. $scope.ldloading[style.replace('-', '_')] = false;
  13946. });
  13947. } else {
  13948. switch ($scope.formData.url) {
  13949. case "start":
  13950. vm.model["initUser"] = $rootScope.user.id;
  13951. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  13952. } else {
  13953. vm.model["assignee"] = $rootScope.user.id;
  13954. }
  13955. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  13956. vm.model.candidateGroups = vm.model.candidateGroups.id;
  13957. }
  13958. if (pdKey == 'bpm_service_request') {
  13959. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  13960. angular.extend(vm.model.serviceCatalogueProcessActual, {
  13961. 'category': {
  13962. 'id': $stateParams.userId
  13963. }
  13964. });
  13965. }
  13966. if (vm.model.schedule && vm.model.schedule.initUser) {
  13967. delete vm.model.schedule.initUser.menu
  13968. }
  13969. api_bpm_domain.start(pdKey, vm.model).then(function (response) {
  13970. // console.log("response="+JSON.stringify(response));
  13971. if (response) {
  13972. var resData = Restangular.stripRestangular(response);
  13973. if (resData) {
  13974. // if (resData) {
  13975. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  13976. $scope.fileUploader.onBeforeUploadItem = function (item) {
  13977. angular.extend(item.headers, $rootScope.getSession());
  13978. item.url = up_down_file.saveAttachments('common/common/uploadAttachment', "incident", resData.id).getRequestedUrl();
  13979. if (vm.model.change) {
  13980. item.url = up_down_file.saveAttachments('common/common/uploadAttachment', "change", resData.id).getRequestedUrl();
  13981. }
  13982. item.formData.push({
  13983. 'fileName': item.file.name
  13984. });
  13985. //console.log();
  13986. };
  13987. $scope.fileUploader.uploadAll();
  13988. }
  13989. // } else {
  13990. // }
  13991. }
  13992. SweetAlert.swal({
  13993. title: "提交成功!",
  13994. type: "success",
  13995. confirmButtonColor: "#007AFF"
  13996. }, function () {
  13997. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  13998. $rootScope.app.layout.isSidebarClosed = false;
  13999. if ($scope.login && !$rootScope.busy) {
  14000. $rootScope.setidle();
  14001. }
  14002. }
  14003. $state.go($scope.formData.cancelUrl);
  14004. });
  14005. } else {
  14006. SweetAlert.swal({
  14007. title: "系统错误",
  14008. text: "系统错误,请稍后重试!",
  14009. type: "error",
  14010. confirmButtonColor: "#DD6B55"
  14011. });
  14012. }
  14013. $scope.ldloading[style.replace('-', '_')] = false;
  14014. });
  14015. break;
  14016. case "complete":
  14017. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  14018. //console.log("complete taskId::"+$stateParams.taskId);
  14019. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  14020. if (response) {
  14021. var resData = Restangular.stripRestangular(response);
  14022. SweetAlert.swal({
  14023. title: "提交成功!",
  14024. type: "success",
  14025. confirmButtonColor: "#007AFF"
  14026. }, function () {
  14027. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14028. // // $scope.uploader.options.url();
  14029. // $scope.uploader.onBeforeUploadItem = function(item) {
  14030. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14031. // console.info('onBeforeUploadItem', item);
  14032. // };
  14033. // $scope.uploader.uploadAll();
  14034. // }
  14035. $state.go($scope.formData.cancelUrl);
  14036. });
  14037. } else {
  14038. SweetAlert.swal({
  14039. title: "系统错误",
  14040. text: "系统错误,请稍后重试!",
  14041. type: "error",
  14042. confirmButtonColor: "#DD6B55"
  14043. });
  14044. }
  14045. $scope.ldloading[style.replace('-', '_')] = false;
  14046. });
  14047. break;
  14048. case "back":
  14049. $state.go($scope.formData.cancelUrl);
  14050. break;
  14051. default:
  14052. $scope.ldloading[style.replace('-', '_')] = false;
  14053. break;
  14054. }
  14055. }
  14056. // var submitFunc = api_bpm_domain[$scope.formData.url]
  14057. // if(anuglar.isFunction(submitFunc)){
  14058. // submitFunc.apply(null, pdKey)
  14059. // }
  14060. }
  14061. }
  14062. } else {
  14063. // console.log(data)
  14064. // angular.forEach(vm.form.$error.required, function(item){
  14065. // var i=(item.$name).substring(item.$name.length-2)
  14066. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  14067. // for(var i=0;i<vm.fields.length;i++){
  14068. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  14069. SweetAlert.swal({
  14070. title: vm.fields[i].templateOptions.label + '未填',
  14071. text: "请填写此项!",
  14072. type: "error",
  14073. confirmButtonColor: "#DD6B55"
  14074. });
  14075. }
  14076. // }
  14077. // angular.forEach(vm.fields,function(f){
  14078. // if(f.name == item.$name){
  14079. // f.validation.show = true;
  14080. // SweetAlert.swal({
  14081. // title: f.templateOptions.label+'未填',
  14082. // text: "请填写此项!",
  14083. // type: "error",
  14084. // confirmButtonColor: "#DD6B55"
  14085. // });
  14086. // }
  14087. // });
  14088. // })
  14089. }
  14090. };
  14091. $scope.vm = vm;
  14092. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  14093. var processInstanceId = $stateParams.processInstanceId;
  14094. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  14095. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  14096. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  14097. var vmForm = Restangular.stripRestangular(responseData);
  14098. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  14099. decodeVMForm(vmForm);
  14100. }
  14101. }
  14102. });
  14103. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  14104. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  14105. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  14106. var vmForm = Restangular.stripRestangular(responseData);
  14107. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  14108. decodeVMForm(vmForm);
  14109. }
  14110. }
  14111. });
  14112. } else {
  14113. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  14114. if (response) {
  14115. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  14116. api_configure_form.renderForm(myData.data, userId, processInstanceId).then(function (responseData) {
  14117. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  14118. var vmForm = Restangular.stripRestangular(responseData);
  14119. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  14120. decodeVMForm(vmForm);
  14121. }
  14122. }
  14123. });
  14124. }
  14125. })
  14126. }
  14127. } else {
  14128. // create process instance
  14129. if (pdKey != "") { //for process
  14130. if (pdKey == 'bpm_service_request') {
  14131. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  14132. if (responseData) {
  14133. var vmForm = Restangular.stripRestangular(responseData);
  14134. if (vmForm) {
  14135. decodeVMForm(vmForm);
  14136. }
  14137. }
  14138. });
  14139. } else {
  14140. api_bpm_domain.startformkey(pdKey).then(function (response) {
  14141. if (response) {
  14142. var myData = Restangular.stripRestangular(response);
  14143. //myData.data = "arrangeform";
  14144. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  14145. if (responseData) {
  14146. var vmForm = Restangular.stripRestangular(responseData);
  14147. if (vmForm) {
  14148. decodeVMForm(vmForm);
  14149. }
  14150. }
  14151. });
  14152. }
  14153. });
  14154. }
  14155. } else { //for form
  14156. //TODO
  14157. //测试数据 开始
  14158. var testJson = {
  14159. fields: [{
  14160. fields: [{
  14161. className: "col-xs-12",
  14162. noFormControl: true,
  14163. key: "formtitle",
  14164. templateOptions: {
  14165. readOnly: false,
  14166. placeholder: "新建事件单",
  14167. hidden: false,
  14168. label: "事件工单",
  14169. required: false
  14170. },
  14171. type: "ui-title"
  14172. }]
  14173. }, {
  14174. fields: [{
  14175. key: 'selectUser',
  14176. type: 'ui-requesterinformation',
  14177. className: 'col-xs-12',
  14178. templateOptions: {
  14179. label: '请求人信息',
  14180. modalTitle: '请求人列表',
  14181. fetchItems: function (filterData, APIService) {
  14182. return APIService.fetchDataList('requester', filterData);
  14183. },
  14184. Restangular: Restangular,
  14185. ApiService: api_user_data
  14186. // onClick:function(val, options, field, event , model){
  14187. // console.log(options);
  14188. // }
  14189. }
  14190. }]
  14191. }, {
  14192. fields: [{
  14193. key: 'first',
  14194. type: 'ui-workernumber',
  14195. className: 'col-xs-12',
  14196. templateOptions: {
  14197. type: 'input',
  14198. label: '事件单号',
  14199. pkey: 'name'
  14200. }
  14201. }]
  14202. }, {
  14203. fields: [{
  14204. type: 'ui-header',
  14205. key: 'title',
  14206. className: 'col-xs-12',
  14207. templateOptions: {
  14208. label: '报修人',
  14209. pkey: 'change'
  14210. }
  14211. }, {
  14212. type: 'ui-input',
  14213. key: 'title',
  14214. className: 'col-xs-4',
  14215. templateOptions: {
  14216. label: '报修人',
  14217. pkey: 'change'
  14218. }
  14219. }, {
  14220. type: 'ui-input',
  14221. key: 'title',
  14222. className: 'col-xs-4',
  14223. templateOptions: {
  14224. label: '联系人',
  14225. pkey: 'change'
  14226. }
  14227. }, {
  14228. type: 'ui-input',
  14229. key: 'title',
  14230. className: 'col-xs-4',
  14231. templateOptions: {
  14232. label: '联系电话',
  14233. pkey: 'change'
  14234. }
  14235. }]
  14236. }, {
  14237. fields: [{
  14238. type: 'ui-header',
  14239. key: 'title1',
  14240. className: 'col-xs-12',
  14241. templateOptions: {
  14242. label: '报修人',
  14243. pkey: 'change'
  14244. }
  14245. }, {
  14246. type: 'ui-input',
  14247. key: 'title2',
  14248. className: 'col-xs-4',
  14249. templateOptions: {
  14250. label: '报修人',
  14251. pkey: 'change'
  14252. }
  14253. }, {
  14254. type: 'ui-input',
  14255. key: 'title3',
  14256. className: 'col-xs-4',
  14257. templateOptions: {
  14258. label: '联系人',
  14259. pkey: 'change'
  14260. }
  14261. }, {
  14262. type: 'ui-input',
  14263. key: 'title4',
  14264. className: 'col-xs-4',
  14265. templateOptions: {
  14266. label: '联系电话',
  14267. pkey: 'change'
  14268. }
  14269. }]
  14270. }],
  14271. model: [{
  14272. username: "robin lau",
  14273. password: "123456",
  14274. chkme: false,
  14275. start_code: 0,
  14276. formtitle: "Hey!I am title value!",
  14277. name: {
  14278. first: "robin",
  14279. last: "lau"
  14280. },
  14281. multiselectItem: []
  14282. //date:"2015-09-15 00:00:00"
  14283. }]
  14284. // }
  14285. };
  14286. setTimeout(function () {
  14287. decodeVMForm(testJson);
  14288. $scope.$apply();
  14289. }, 500);
  14290. //测试数据结束
  14291. }
  14292. }
  14293. //console.log("end decode");
  14294. }
  14295. ]);