123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684 |
- var appFormly = angular.module('formlyExample', ['formly', 'formlyBootstrap', 'ui.bootstrap']);
- app.requires.push('formlyExample');
- appFormly.config(
- function config(formlyConfigProvider) {
- //格式转换方法 XXX-XXX转驼峰命名
- function camelize(string) {
- string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) {
- return chr ? chr.toUpperCase() : '';
- });
- // Ensure 1st char is always lowercase
- return string.replace(/^([A-Z])/, function(match, chr) {
- return chr ? chr.toLowerCase() : '';
- });
- }
- //获取ngModelAttr对象设置
- function getNgModelAttr(attrs, bindings) {
- var ngModelAttrs = {};
- angular.forEach(attrs, function(attr) {
- ngModelAttrs[camelize(attr)] = { attribute: attr };
- });
- angular.forEach(bindings, function(binding) {
- ngModelAttrs[camelize(binding)] = { bound: binding };
- });
- return ngModelAttrs;
- }
- formlyConfigProvider.setWrapper({
- name: 'bootstrapLabel',
- templateUrl: 'assets/views/customform/tpl/normal-label.html'
- });
- formlyConfigProvider.setType({
- name: 'ui-panel',
- templateUrl: 'assets/views/customform/tpl/ui-panel.html'
- });
- formlyConfigProvider.setType({
- name: 'ui-currentuser',
- // extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-username.html',
- controller: ['$scope', function($scope) {
- if ($scope.options.templateOptions.user) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
- $scope.options.initialValue = $scope.model[$scope.options.key];
- } else {
- $scope.model[$scope.options.key] = $scope.$root.user;
- }
- }]
- });
- //仪表盘
- formlyConfigProvider.setType({
- name: 'ui-assess',
- // extends: 'input',
- templateUrl: 'assets/views/customform/tpl/assess.html',
- controller: ['$scope', function($scope) {
- // if ($scope.options.templateOptions.user) {
- // $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- // } else {
- // $scope.model[$scope.options.key] = $scope.$root.user;
- // }
- }]
- });
- //待处理事件列表
- formlyConfigProvider.setType({
- name: 'ui-areaplace',
- templateUrl: 'assets/views/customform/tpl/ui-inputright.html',
- // templateUrl: 'assets/views/customform/tpl/areaplace.html',
- // template: '<div class="contain"><div class="fixWidth"><div class="demo"><div id="trigger" class="trigger" style="cursor: pointer;">地区选择-级联</div></div> </div></div>',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- // transform: function(model, modelKey) {
- // if (model[modelKey]) {
- // // return {
- // // value: model.name,
- // // id: model[modelKey]
- // // }
- // // return model[modelKey]
- // }
- // },
- // getlistdata: function($scope, key) {
- // if (options.templateOptions.optionsUrl) {
- // // if (options.templateOptions.ApiService) {
- // var process = {};
- // // }
- // var datakey = { "idx": 0, "sum": 1000 };
- // if (options.templateOptions.Restangular) {
- // var process = options.templateOptions.Restangular.all("");
- // }
- // if (key) {
- // angular.extend(datakey, { place: { areaId: $scope.$parent.$parent.$parent.model.incident.area.id, place: key, selectType: "pinyin_qs" } });
- // }
- // process.customPOST(datakey, options.templateOptions.optionsUrl).then(function(result) {
- // if (!options.templateOptions.options) {
- // $scope.to.options = [];
- // }
- // if (options.templateOptions.optionsDataKey) {
- // $scope.to.options = result[options.templateOptions.optionsDataKey];
- // } else {
- // $scope.to.options = result;
- // }
- // });
- // }
- // }
- }
- };
- },
- controller: ['$scope', '$aside', 'BpmRestangular', 'UserRestangular', 'WechatRestangular', 'api_user_data', function($scope, $aside, BpmRestangular, UserRestangular, WechatRestangular, api_user_data) {
- $scope.MobileSelect = {
- trigger: '#trigger',
- title: '地区选择',
- wheels: [{
- data: [{
- id: '1',
- value: '附近',
- childs: [{
- id: '1',
- value: '1000米'
- }, {
- id: '2',
- value: '2000米'
- }, {
- id: '3',
- value: '3000米'
- }, {
- id: '4',
- value: '5000米'
- }, {
- id: '5',
- value: '10000米'
- }]
- }, {
- id: '2',
- value: '上城区'
- }, {
- id: '3',
- value: '下城区'
- }, {
- id: '4',
- value: '江干区'
- }, {
- id: '5',
- value: '拱墅区'
- }, {
- id: '6',
- value: '西湖区'
- }]
- }],
- transitionEnd: function(indexArr, data) {
- console.log(data);
- },
- callback: function(indexArr, data) {
- console.log(data);
- }
- }
- }]
- });
- //待处理事件列表
- formlyConfigProvider.setType({
- name: 'ui-ngtable',
- templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$timeout', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', function($scope, $timeout, api_bpm_data, $rootScope, ngTableParams, $filter) {
- var filterData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchtype": "done",
- "idx": 0,
- "sum": 10
- };
- api_bpm_data.fetchDataList('incident', filterData).then(function(data) {
- if (data.status == 200) {
- $scope.myData = data.list
- }
- })
- }]
- });
- //报表列表
- formlyConfigProvider.setType({
- name: 'ui-ngreport',
- templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$timeout', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', function($scope, $timeout, api_bpm_data, $rootScope, ngTableParams, $filter) {
- var filterData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchtype": "done",
- "idx": 0,
- "sum": 10
- };
- // $scope.options.hideExpression = false;
- $scope.model.removereport = false;
- $scope.removes = function() {
- $scope.model.removereport = true;
- // $scope.options.templateOptions.relationAction();
- // $scope.palnes = false;
- // $scope.fields = {};
- }
- api_bpm_data.fetchDataList('incident', filterData).then(function(data) {
- if (data.status == 200) {
- $scope.myData = data.list
- }
- })
- }]
- });
- //请求人最近事件
- formlyConfigProvider.setType({
- name: 'ui-recentIncident',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
- controller: ['$scope', 'api_solution', function($scope, api_solution) {
- var filterData = {
- 'incident': {
- 'requester': {
- 'id': ''
- }
- },
- idx: 0,
- sum: 3
- };
- setInterval(function() {
- if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
- var requester = $scope.model.requester;
- if (requester != null && angular.isDefined(requester.id)) {
- filterData.incident.requester.id = $scope.model.requester.id;
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- if (modelData.status == 200) {
- $scope.lastrequst = modelData.list;
- }
- });
- requester = null
- } else {}
- } else {}
- }, 1000);
- $scope.detail = function(data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/detailincident.html',
- controller: function($scope, $modalInstance) {
- $scope.entity = {};
- $scope.entity = data;
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg',
- });
- }
- }]
- });
- //参数列表
- formlyConfigProvider.setType({
- name: "ui-listinput",
- templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function($scope) {
- }]
- });
- //时间段控件(分)
- formlyConfigProvider.setType({
- name: 'ui-timeslot',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
- controller: ['$scope', function($scope) {}]
- });
- //优先级级联可编辑控件
- formlyConfigProvider.setType({
- name: 'ui-overtime',
- // extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
- controller: ['$scope', 'api_bpm_domain', function($scope, api_bpm_domain) {
- var filteData = {};
- var datas = {}
- setInterval(function() {
- if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
- filteData = "L" + $scope.model.priority.id;
- datas = $scope.model.priority.id;
- // console.log($scope.options.templateOptions)
- api_bpm_domain.expectedTime(filteData).then(function(requester) {
- // var overtime=requester.date;
- if (requester.state == 200) {
- // if($scope.options.key=="date"){
- $scope.model[$scope.options.key] = requester.date
- // }
- }
- })
- }
- }, 1000);
- }]
- });
- formlyConfigProvider.setType({
- name: 'ui-responsetime',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
- controller: ['$scope', 'api_bpm_domain', function($scope, api_bpm_domain) {
- var filteData = {};
- var datas = {}
- setInterval(function() {
- if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
- filteData = "L" + $scope.model.priority.id;
- datas = $scope.model.priority.id;
- // console.log($scope.options.templateOptions)
- api_bpm_domain.expectedTime(filteData).then(function(requester) {
- // var overtime=requester.date;
- if (requester.state == 200) {
- var keyName = {};
- if ($scope.options.key == "expectIntroTime") {
- keyName = "resolveTime";
- } else if ($scope.options.key == "expectResponseTime") { keyName = "responseTime"; }
- $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
- // }
- }
- })
- }
- }, 1000);
- }]
- });
- //知识库按钮组件
- formlyConfigProvider.setType({
- name: 'ui-discasecade',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- relationAction: function(fields, modelscope, item) {}
- }
- }
- },
- controller: ['$scope', '$rootScope', 'api_bpm_data', 'api_solution', function($scope, $rootScope, api_bpm_data, api_solution) {
- var titles = {}
- setInterval(function() {
- if ($scope.model.category != null && titles != $scope.model.category) {
- $scope.searchData = {};
- if ($scope.options.key == "title") {
- var filterData = { "idx": 0, "sum": 1000 };
- api_bpm_data.fetchDataList('incidentcategory', filterData).then(function(data) {
- var datalist = data.list;
- angular.forEach(datalist, function(item) {
- if (item.id == $scope.model.category.id) {
- $scope.model[$scope.options.key] = item.category
- $scope.titles = item.category;
- titles = $scope.model.category;
- }
- })
- })
- }
- }
- }, 1000);
- }]
- });
- // formlyConfigProvider.setType({
- // name: 'ui-discasecade',
- // extends: 'input',
- // templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
- // defaultOptions:function(options){
- // return{
- // templateOptions: {
- // refresh:function(){},
- // refreshDelay: 0,
- // linkage:function(modelName, data, model, modelKey, key){
- // console.log(model)
- // }
- // }
- // };
- // }
- // });
- //重构组件模板
- //获取当前人
- formlyConfigProvider.setType({
- name: 'ui-users',
- // extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-label.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- translate: '',
- refreshDelay: 0
- }
- }
- },
- controller: ['$scope', function($scope) {
- // $scope.model[$scope.options.key]=$scope.$root.user.name;
- $scope.options.templateOptions.translate = $scope.$root.user.name;
- }]
- });
- //只读控件
- formlyConfigProvider.setType({
- name: 'ui-label',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-label.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- translate: '',
- refreshDelay: 0
- }
- }
- },
- controller: ['$scope', function($scope) {
- console.log($scope.options.templateOptions)
- var value = $scope.model[$scope.options.key];
- function treeDesc(children, key, label) {
- if (label == "") {
- label = children[key];
- } else {
- label = children[key] + "-" + label;
- }
- if (angular.isDefined(children.parent)) {
- treeDesc(children.parent, key, label);
- } else {
- return label;
- }
- }
- if (angular.isArray(value)) {
- var tempValue = "";
- angular.forEach(value, function(item) {
- if (tempValue != "") {
- tempValue = tempValue + ",";
- }
- tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
- });
- $scope.options.templateOptions.translate = tempValue;
- } else if (angular.isObject(value)) {
- if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
- //tree
- // console.log("value.parent="+JSON.stringify(value.parent))
- var nameLabel = value[$scope.options.templateOptions.labelProp];
- nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
- $scope.options.templateOptions.translate = nameLabel;
- } else {
- $scope.options.templateOptions.translate = value;
- }
- } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
- console.log("value=" + value);
- $scope.options.templateOptions.translate = value;
- // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
- // console.log("value="+value);
- // $scope.options.templateOptions.translate = value;
- } else {
- // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
- $scope.options.templateOptions.translate = value;
- }
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
- if ($scope.options.templateOptions.isSubmit) {
- if ($scope.options.templateOptions.transform($scope.$root.user, value).id) {
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value).value;
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value).id
- console.log($scope.options.templateOptions.transform($scope.$root.user, value));
- } else {
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value);
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value);
- console.log($scope.options.templateOptions.transform($scope.$root.user, value));
- }
- } else {
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- // var transform = function(model, value) {
- // if (model.account) {
- // return { value: model.name, id: model.account }
- // }
- // }
- }
- }]
- });
- //标题组件
- formlyConfigProvider.setType({
- name: 'ui-title',
- template: '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h4 class="mainTitle" style="font-weight:bold">{{options.templateOptions.label}}</h1><span class="mainDescription">{{options.templateOptions.placeholder}}</span></div></div></section>'
- });
- //分类标题组件
- formlyConfigProvider.setType({
- name: 'ui-typeTitle',
- templateUrl: 'assets/views/customform/tpl/ui-typeTitle.html'
- });
- //按钮组
- formlyConfigProvider.setType({
- name: 'ui-button',
- templateUrl: 'assets/views/customform/tpl/ui-button.html',
- defaultOptions: function(options) {
- return {
- noFormControl: true
- }
- }
- });
- //3d组link
- formlyConfigProvider.setType({
- name: 'ui-link',
- templateUrl: 'assets/views/customform/tpl/ui-link.html',
- defaultOptions: function(options) {
- return {
- noFormControl: true
- }
- }
- });
- //隐藏域组件
- formlyConfigProvider.setType({
- name: 'ui-hidden',
- extends: 'input',
- template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
- defaultOptions: function(options) {
- return {
- // noFormControl: true
- };
- }
- });
- //文本框组件
- formlyConfigProvider.setType({
- name: 'ui-input',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-input.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- transform: function(model, modelKey) {
- if (model[modelKey]) {
- // return {
- // value: model.name,
- // id: model[modelKey]
- // }
- return model[modelKey]
- }
- }
- }
- };
- },
- controller: ['$scope', function($scope) {
- if (angular.isFunction($scope.options.templateOptions.linkData)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
- }
- //赋值和别名转化
- if ($scope.options.templateOptions.modelKey) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, $scope.options.templateOptions.modelKey);
- }
- }]
- });
- //无html结构显示控件
- formlyConfigProvider.setType({
- name: 'ui-noTemplate',
- // templateUrl: 'assets/views/customform/tpl/ui-input.html',
- template: '<div ng-model="model[options.key]" style="display: none;"></div>',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- transform: function(model, modelKey) {
- if (model[modelKey]) {
- // return {
- // value: model.name,
- // id: model[modelKey]
- // }
- return model[modelKey]
- }
- }
- }
- };
- },
- controller: ['$scope', function($scope) {
- console.log($scope.options.templateOptions)
- var value = $scope.model[$scope.options.key];
- function treeDesc(children, key, label) {
- if (label == "") {
- label = children[key];
- } else {
- label = children[key] + "-" + label;
- }
- if (angular.isDefined(children.parent)) {
- treeDesc(children.parent, key, label);
- } else {
- return label;
- }
- }
- if (angular.isArray(value)) {
- var tempValue = "";
- angular.forEach(value, function(item) {
- if (tempValue != "") {
- tempValue = tempValue + ",";
- }
- tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
- });
- $scope.options.templateOptions.translate = tempValue;
- } else if (angular.isObject(value)) {
- if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
- //tree
- // console.log("value.parent="+JSON.stringify(value.parent))
- var nameLabel = value[$scope.options.templateOptions.labelProp];
- nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
- $scope.options.templateOptions.translate = nameLabel;
- } else {
- $scope.options.templateOptions.translate = value;
- }
- } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
- console.log("value=" + value);
- $scope.options.templateOptions.translate = value;
- // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
- // console.log("value="+value);
- // $scope.options.templateOptions.translate = value;
- } else {
- // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
- $scope.options.templateOptions.translate = value;
- }
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
- if ($scope.options.templateOptions.isSubmit) {
- if ($scope.options.templateOptions.transform($scope.$root.user, value).id) {
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value).value;
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value).id
- console.log($scope.options.templateOptions.transform($scope.$root.user, value));
- } else {
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value);
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value);
- console.log($scope.options.templateOptions.transform($scope.$root.user, value));
- }
- } else {
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- // var transform = function(model, value) {
- // if (model.account) {
- // return { value: model.name, id: model.account }
- // }
- // }
- }
- }]
- });
- //只读文本
- formlyConfigProvider.setType({
- name: 'ui-disableinput',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- transform: function(value) {
- var ret = "";
- if (value) {
- ret = "已删除";
- } else {
- ret = "正常";
- }
- return ret;
- }
- }
- };
- }
- });
- formlyConfigProvider.setType({
- name: 'ui-disinput',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- }
- });
- //数字组件
- formlyConfigProvider.setType({
- name: 'ui-number',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-number.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function($scope) {
- console.log($scope.model[$scope.options.key]);
- }]
- });
- //普通下拉框
- // formlyConfigProvider.setType({
- // name: 'ui-select-prototype',
- // // extends: 'input',
- // templateUrl: 'assets/views/customform/tpl/ui-number.html',
- // defaultOptions: function(options) {
- // return {
- // templateOptions: {
- // // key: 'multiselectItem',
- // // type: 'ui-multi-select-tree',
- // // className: 'col-xs-6',
- // templateOptions: {
- // label: 'multiSelect',
- // placeholder: '请选择...',
- // isMultiSelect: false,
- // selLeafs: false, //只选叶子节点
- // refreshData: function(APIService) {
- // return APIService.fetchDataList('changeclassify', { 'idx': 0, 'sum': 100 });
- // },
- // APIService: api_bpm_data,
- // optionsDataKey: 'list',
- // refreshDelay: 1000,
- // onDataCallback: function(item, selectItems, options, field, model) {
- // model[options.key] = { id: item.id };
- // // console.log("item="+JSON.stringify(model))
- // }
- // }
- // }
- // };
- // },
- // controller: ['$scope', function($scope) {
- // console.log($scope.model[$scope.options.key]);
- // }]
- // });
- //下拉搜索框
- formlyConfigProvider.setType({
- name: 'ui-inputright',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-inputright.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- transform: function(model, modelKey) {
- if (model[modelKey]) {
- // return {
- // value: model.name,
- // id: model[modelKey]
- // }
- // return model[modelKey]
- }
- },
- getlistdata: function($scope, key) {
- if (options.templateOptions.optionsUrl) {
- // if (options.templateOptions.ApiService) {
- var process = {};
- // }
- var datakey = { "idx": 0, "sum": 1000 };
- if (options.templateOptions.Restangular) {
- var process = options.templateOptions.Restangular.all("");
- }
- if (key) {
- angular.extend(datakey, { place: { areaId: $scope.$parent.$parent.$parent.model.incident.area.id, place: key, selectType: "pinyin_qs" } });
- }
- process.customPOST(datakey, options.templateOptions.optionsUrl).then(function(result) {
- if (!options.templateOptions.options) {
- $scope.to.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- $scope.to.options = result[options.templateOptions.optionsDataKey];
- } else {
- $scope.to.options = result;
- }
- });
- }
- }
- }
- };
- },
- controller: ['$scope', '$aside', 'BpmRestangular', 'UserRestangular', 'WechatRestangular', function($scope, $aside, BpmRestangular, UserRestangular, WechatRestangular) {
- $scope.inputclick = function() {
- var modalInstance = $aside.open({
- templateUrl: 'assets/views/customform/tpl/searchright.html',
- placement: 'right',
- backdrop: false,
- controller: function($scope, $modalInstance, scope) {
- $scope.search = {};
- $scope.options = scope.to.options;
- $scope.valueProp = scope.to.valueProp;
- $scope.labelProp = scope.to.labelProp;
- $scope.placeholder = scope.to.placeholder;
- $scope.ok = function(item) {
- $modalInstance.close(item);
- if (scope.options.templateOptions.translate) {
- scope.options.templateOptions.translate(item, scope);
- }
- }
- pushHistory();
- window.addEventListener("popstate", function(e) {
- // window.location = 'http://www.baidu.com';
- }, false);
- function pushHistory() {
- var state = {
- title: "title",
- url: "#"
- };
- window.history.pushState(state, "title", "#");
- }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- }
- $scope.onChange = function(key) {
- if (scope.options.templateOptions.change) {
- scope.options.templateOptions.change($scope, scope, key);
- }
- }
- },
- size: 'lg',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- angular.extend($scope.model, selectedItem);
- $scope.model[$scope.options.key] = $scope.model[$scope.options.key];
- });
- }
- $scope.options.templateOptions.getlistdata($scope);
- }]
- });
- //下拉框组件
- formlyConfigProvider.setType({
- name: 'ui-select',
- extends: 'select',
- templateUrl: 'assets/views/customform/tpl/ui-select.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- // refresh: function() {},
- // refreshDelay: 0,
- linkage: function(modelName, data, model, modelKey, key) {
- angular.extend(data, { "idx": 0, "sum": 1000 });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- if (list.length == 1) {
- angular.forEach(model.fields, function(item) {
- angular.forEach(model.fields, function(item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = '';
- item.model.place = '';
- if (key == "place") {
- item.templateOptions.options = list;
- } else if (key == "placeDTO") {
- item.templateOptions.options = list;
- } else { item.value(list[0][key][item.key]); }
- }
- })
- })
- } else {
- angular.forEach(model.fields, function(item) {
- angular.forEach(model.fields, function(item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = '';
- item.model.place = '';
- if (key == "place") { item.templateOptions.options = list; }
- if (key == "placeDTO") { item.templateOptions.options = list; }
- }
- })
- })
- }
- });
- }
- },
- };
- },
- controller: ['$scope', '$rootScope', function($scope, $rootScope) {
- if ($scope.options.templateOptions.transform) {
- $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
- }
- if (angular.isFunction($scope.options.templateOptions.translate)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.model, $rootScope);
- }
- }]
- });
- //可修改下拉框组件
- formlyConfigProvider.setType({
- name: 'ui-selectchange',
- extends: 'select',
- templateUrl: 'assets/views/customform/tpl/ui-selectchange.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function() {},
- refreshDelay: 0,
- linkage: function(modelName, data, model, modelKey, key) {
- angular.extend(data, { "idx": 0, "sum": 1000 });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- if (list.length == 1) {
- angular.forEach(model.fields, function(item) {
- angular.forEach(model.fields, function(item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- } else { item.value(list[0][key][item.key]); }
- }
- })
- })
- } else {
- angular.forEach(model.fields, function(item) {
- angular.forEach(model.fields, function(item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- }
- }
- })
- })
- }
- });
- }
- },
- controller: ['$scope', function($scope) {
- if (angular.isArray($scope.model[$scope.options.key])) {
- } else {
- $scope.model[$scope.options.key] = [];
- }
- }]
- };
- }
- });
- //下拉多选框组件
- formlyConfigProvider.setType({
- name: 'ui-multiselect',
- extends: 'select',
- templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function() {},
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', function($scope) {
- $scope.model[$scope.options.key] = [];
- }]
- });
- //下拉多选框灵活组件
- formlyConfigProvider.setType({
- name: 'ui-multiselectplus',
- extends: 'select',
- templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refreshData: function(search, options, model, that) {
- var process = options.templateOptions.ApiService.all("");
- if (search) {
- } else {
- }
- var postData = options.templateOptions.optionsPostData;
- if (angular.isFunction(options.templateOptions.optionsPostData)) {
- postData = options.templateOptions.optionsPostData(options, model, that);
- }
- process.customPOST(postData, options.templateOptions.optionsUrl).then(function(result) {
- if (!options.templateOptions.options) {
- options.templateOptions.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = result[options.templateOptions.optionsDataKey];
- } else {
- options.templateOptions.options = result;
- }
- if (options.templateOptions.optionsChecked) {
- options.value(options.templateOptions.options);
- }
- });
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', function($scope) {
- if (angular.isArray($scope.model[$scope.options.key])) {
- } else {
- $scope.model[$scope.options.key] = [];
- }
- }]
- });
- //下拉树形多选组件
- formlyConfigProvider.setType({
- name: 'ui-multiselect-tree',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- linkage: function(modelName, data, model, modelKey, key) {
- angular.extend(data, { "idx": 0, "sum": 10 });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- if (list.length == 1) {
- angular.forEach(model.fields, function(item) {
- angular.forEach(model.fields, function(item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- } else { item.value(list[0][key][item.key]); }
- }
- })
- })
- }
- });
- },
- // my_tree_handler : function(items) {
- // console.log('erytuiyewrutyuweyrutewru')
- // },
- // onFilterCallback : function(items) {
- // console.log('1341341234123')
- // },
- // onFilterCallback : function(items) {
- // console.log('134134weafaesesd')
- // },
- refresh: function(items) {
- var treedata = [];
- function convertListToTree(data, treeMap) {
- treedata = data;
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < data.length; j++) {
- if (data[i].pid && data[i].id && data[i].pid != 0) {
- if (data[i].pid == data[j].id) {
- data[i].parent = data[j];
- }
- }
- }
- }
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- // console.log("datum="+JSON.stringify(datum))
- if (typeof datum.parent === "undefined" || datum.parent === null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- // console.log("data="+JSON.stringify(data))
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function(item) {
- list.push(item);
- });
- return list;
- }
- function selectItem(pmodel, childrens) {
- if (angular.isArray(pmodel)) {
- angular.forEach(pmodel, function(index) {
- if (index && index.id) {
- angular.forEach(childrens, function(item) {
- if (item.id == index.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- })
- } else {
- if (pmodel && pmodel.id) {
- angular.forEach(childrens, function(item) {
- if (item.id == pmodel.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- }
- }
- // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
- options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
- if (!options.templateOptions.options) {
- options.templateOptions.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
- } else {
- options.templateOptions.options = convertParentToChildList(result);
- }
- //set default value
- var pmodel, i = 0;
- if (options.templateOptions.pkey) {
- if (options.templateOptions.pkey.indexOf(".") > 0) {
- angular.forEach(options.templateOptions.pkey.split("."), function(p) {
- if (i == 0) {
- if (options.model[p] == null) {
- options.model[p] = {};
- }
- pmodel = options.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- } else {
- pmodel = options.model;
- }
- }
- if (pmodel) {
- pmodel = pmodel[options.key];
- } else if (options.model) {
- pmodel = options.model[options.key];
- } else {
- pmodel = options.templateOptions.options;
- }
- if (angular.isArray(pmodel)) {
- if (pmodel) {
- // if(options.templateOptions.isMultiSelect==true){
- // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
- // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
- // })
- // }else{
- selectItem(pmodel, options.templateOptions.options);
- // }
- }
- } else {
- if (pmodel && pmodel.id) {
- selectItem(pmodel, options.templateOptions.options);
- }
- }
- // for(var i=0;i<options.templateOptions.options.length;i++){
- // options.templateOptions.options[i]={'id':options.templateOptions.options[i].id,'recate':options.templateOptions.options[i].recate}
- // }
- items.inputModel = options.templateOptions.options;
- // console.log(model);
- // console.log(options);
- });
- }
- },
- validators: {
- required: {
- expression: function(viewValue, modelValue) {
- var value = modelValue || viewValue;
- if (angular.isArray(value)) {
- for (var i = 0; i < value.length; i++) {
- value[i] = { id: value[i].id }
- }
- return value.length > 0
- } else {
- // console.log(options)
- return value = "true";
- // return value != null;
- }
- }
- }
- }
- }
- },
- controller: ['$scope', 'api_configure_form', function($scope, api_configure_form) {
- if ($scope.options.templateOptions.isMultiSelect) {
- // console.log($scope);
- } else {
- if ($scope.model[$scope.options.key]) {
- }
- }
- }]
- });
- //多选下拉框组件
- formlyConfigProvider.setType({
- name: 'ui-multi-select-tree',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- linkage: function(modelName, data, model, modelKey, key) {
- angular.extend(data, { "idx": 0, "sum": 10 });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- if (list.length == 1) {
- angular.forEach(model.fields, function(item) {
- angular.forEach(model.fields, function(item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- } else { item.value(list[0][key][item.key]); }
- }
- })
- })
- }
- });
- },
- getparentdata: function(items) {
- console.log(items)
- },
- refresh: function(items) {
- //console.log(items);
- var treedata = [];
- function convertListToTree(data, treeMap) {
- treedata = data;
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < data.length; j++) {
- if (data[i].pid && data[i].id && data[i].pid != 0) {
- if (data[i].pid == data[j].id) {
- data[i].parent = data[j];
- }
- }
- }
- }
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- // console.log("datum="+JSON.stringify(datum))
- if (typeof datum.parent === "undefined" || datum.parent === null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- // console.log("data="+JSON.stringify(data))
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function(item) {
- // console.log("item="+JSON.stringify(item))
- list.push(item);
- });
- return list;
- }
- function selectItem(pmodel, childrens) {
- if (angular.isArray(pmodel)) {
- angular.forEach(pmodel, function(index) {
- if (index && index.id) {
- angular.forEach(childrens, function(item) {
- if (item.id == index.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- // angular.forEach(treedata,function(parentdata){
- // if(parentdata.id == index.id){
- // if(parentdata.parent&&parentdata.parent.id){
- // parentdata.parent.$
- // }
- // item.selected = true;
- // }
- // if (item && item.children) {
- // selectItem(pmodel ,item.children);
- // }
- // });
- }
- })
- } else {
- if (pmodel && pmodel.id) {
- angular.forEach(childrens, function(item) {
- if (item.id == pmodel.id) {
- item.selected = true;
- delete item.children;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- }
- }
- // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
- options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
- if (!options.templateOptions.options) {
- options.templateOptions.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
- } else {
- options.templateOptions.options = convertParentToChildList(result);
- }
- //set default value
- var pmodel, i = 0;
- if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
- if (options.templateOptions.pkey.indexOf(".") > 0) {
- angular.forEach(options.templateOptions.pkey.split("."), function(p) {
- if (i == 0) {
- if (options.model[p] == null) {
- options.model[p] = {};
- }
- pmodel = options.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- } else {
- pmodel = options.model;
- }
- }
- if (pmodel) {
- pmodel = pmodel[options.key];
- } else if (options.model) {
- pmodel = options.model[options.key];
- }
- // else if ($stateParams.model) {
- // pmodel = $stateParams.model[options.key];
- // }
- if (angular.isArray(pmodel)) {
- if (pmodel) {
- selectItem(pmodel, options.templateOptions.options);
- }
- } else {
- if (pmodel && pmodel.id) {
- selectItem(pmodel, options.templateOptions.options);
- }
- }
- // for(var i=0;i<options.templateOptions.options.length;i++){
- // options.templateOptions.options[i]={'id':options.templateOptions.options[i].id,'recate':options.templateOptions.options[i].recate}
- // }
- items.inputModel = options.templateOptions.options;
- // console.log(model);
- // console.log(options);
- });
- }
- },
- validators: {
- required: {
- expression: function(viewValue, modelValue) {
- var value = modelValue || viewValue;
- if (angular.isArray(value)) {
- return value.length > 0
- } else {
- console.log(options)
- if (options.templateOptions.required) {
- return value != null;
- } else {
- return value = "true";
- }
- // return value = "true";
- }
- }
- }
- }
- }
- },
- controller: ['$scope', 'api_configure_form', function($scope, api_configure_form) {
- if ($scope.options.templateOptions.isMultiSelect) {
- // console.log($scope);
- } else {
- if ($scope.model[$scope.options.key]) {
- }
- }
- // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
- // console.log(item)
- // // if(){
- // // }
- // // $scope.model[$scope.options.key]=item.id;
- // api_configure_form.renderTabForm(item.prefix).then(function(data){
- // $scope.propTypeOptions = data;
- // });
- // }
- // $scope.model[$scope.options.key]=[];
- }]
- });
- //勾选组件
- formlyConfigProvider.setType({
- name: 'ui-checkbox',
- extends: 'checkbox',
- templateUrl: 'assets/views/customform/tpl/ui-checkbox.html'
- });
- //没有边框的勾选组件
- formlyConfigProvider.setType({
- name: 'ui-checkbox-noBorder',
- // extends: 'checkbox',
- templateUrl: 'assets/views/customform/tpl/ui-checkbox-noBorder.html',
- controller: ['$scope', function($scope) {
- if ($scope.model[$scope.options.key] == true) {
- $scope.checkIconfont = 'dsit-dui fontGreen';
- } else {
- $scope.checkIconfont = 'dsit-false-circle fontRed';
- }
- $scope.checked = function() {
- $scope.model[$scope.options.key] = !$scope.model[$scope.options.key];
- if ($scope.model[$scope.options.key] == true) {
- $scope.checkIconfont = 'dsit-dui fontGreen';
- } else {
- $scope.checkIconfont = 'dsit-false-circle fontRed';
- }
- }
- }]
- });
- //换行组件
- formlyConfigProvider.setType({
- name: 'ui-nextLine',
- /*extends: 'input',*/
- template: '<div></div>',
- });
- //多选框组件
- formlyConfigProvider.setType({
- name: 'ui-checklist',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function() {},
- refreshDelay: 0
- }
- };
- }
- });
- //单选框组件
- formlyConfigProvider.setType({
- name: 'ui-radio',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/ui-radio.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function() {},
- refreshDelay: 0
- }
- };
- }
- });
- //文本域组件
- formlyConfigProvider.setWrapper({
- name: 'validation',
- types: ['ui-textarea'],
- 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>"
- });
- formlyConfigProvider.setType({
- name: 'ui-textarea',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- transform: function(model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function(viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', function($scope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value);
- }
- }]
- });
- //改动的组件 ckeditor封装后的组件
- formlyConfigProvider.setType({
- name: 'ui-text-check',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- extraPlugins: 'uploadimage',
- uploadimageConfig: {
- backend: 'basic',
- settings: {
- uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
- headers: '',
- downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
- }
- },
- refresh: function(APIService, contentId, data) {
- return APIService.fetchDataList(contentId, data);
- },
- downloadUri: function(APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- upload: function(APIService, contentId) {
- return APIService.getSolutionDowpath(contentId);
- },
- view: function(attachmentId) {
- // return APIService.attachmentsPreviewUrl(contentId);
- },
- refreshDelay: 0,
- transform: function(model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function(viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', function($scope, $rootScope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
- //var expiry={'expiry':14804244006};
- //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
- //$scope.options.templateOptions.uploadimageConfig.settings.headers
- $scope.upload = function(contentId, filename) {
- var filename = filename;
- $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function(response) {
- var file = new Blob([response], { type: 'application/octet-stream' });
- // var filename = filename;
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- })
- };
- }]
- });
- //ui-grid展示控件
- formlyConfigProvider.setType({
- name: 'ui-grid-show',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- linkage: function() {
- },
- },
- };
- },
- controller: function($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
- var loginUser = $rootScope.user;
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- // $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
- $scope.gridOptions.columnDefs = [
- // { name:'id', width:80, enableFiltering:false},
- // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
- // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
- // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
- // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
- // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
- { name: 'inspection.title', displayName: '计划主题', width: 120, enableFiltering: false },
- { name: 'stateName', displayName: '状态', width: 80, enableFiltering: false },
- { name: 'processUser.name', displayName: '处理人', width: 80, enableFiltering: false },
- { name: 'startDate', displayName: '开始时间', width: 160, enableFiltering: false },
- { name: 'overdueTime', displayName: '逾期时间', width: 160, enableFiltering: false },
- ];
- var defaultFilterData = {
- "idx": 0,
- "sum": 10
- };
- //分页控制
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.refreshData('expand-right', filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- data.grid.appScope.selected.items = data.entity
- });
- };
- //页面获取数据
- $scope.refreshData = function(style, filterData) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- angular.extend(filterData, { inspectionProcessActual: { "inspectionid": $scope.model.id } })
- api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- // formlyConfigProvider.setType({
- // name: 'ui-mentio',
- // extends: 'textarea',
- // templateUrl : 'assets/views/customform/tpl/mentio.html',
- // defaultOptions:function(options){
- // return {
- // templateOptions: {
- // transform:function(model, value){
- // return value;
- // },
- // },
- // validation: {
- // messages: {
- // maxlength: function(viewValue, modelValue, scope) {
- // if(viewValue!=null){
- // if(viewValue.length>scope.to.maxlength){
- // return scope.to.label + ' 字数('+ viewValue.length +')超限('+scope.to.maxlength+')'
- // }else{
- // return "";
- // }
- // }
- // },
- // }
- // }
- // }
- // },
- // controller: ['$scope',function($scope){
- // $scope.people = [
- // { label: 'Joe'},
- // { label: 'Mike'},
- // { label: 'Diane'}
- // ]
- // var value = $scope.model[$scope.options.key];
- // if(angular.isFunction($scope.options.templateOptions.transform)){
- // $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- // }
- // }]
- // });
- //文本框自定义选择面板组件
- formlyConfigProvider.setType({
- name: 'ui-input-selectmodal',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- openModal: function(size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/modal-content.html',
- controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
- size: size,
- resolve: options.templateOptions.modalParam
- });
- modalInstance.result.then(function(selectedItem) {
- options.value(selectedItem);
- }, function() {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- }
- });
- //日期控件
- var datepicker_attr = [
- 'date-disabled',
- 'custom-class',
- 'show-weeks',
- 'starting-day',
- 'init-date',
- 'min-mode',
- 'max-mode',
- 'format-day',
- 'format-month',
- 'format-year',
- 'format-day-header',
- 'format-day-title',
- 'format-month-title',
- 'year-range',
- 'shortcut-propagation',
- 'datepicker-popup',
- 'show-button-bar',
- 'current-text',
- 'clear-text',
- 'close-text',
- 'close-on-date-selection',
- 'datepicker-append-to-body'
- ];
- var datepicker_bindings = [
- 'datepicker-mode',
- 'min-date',
- 'max-date'
- ];
- formlyConfigProvider.setType({
- name: 'ui-datetime',
- templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function($scope, $filter) {
- $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }]
- });
- //日期控件
- formlyConfigProvider.setType({
- name: 'ui-datepicker',
- templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function($scope, $filter) {
- // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
- if ($scope.model[$scope.options.key]) {
- } else {
- $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
- }
- $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.endOpen = true;
- $scope.datepicker = {};
- $scope.datepicker.opened = false;
- $scope.datepicker.open = function($event) {
- $scope.datepicker.opened = true;
- };
- }]
- });
- //含有周的日期
- formlyConfigProvider.setType({
- name: 'ui-datepickerweek',
- templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function($scope, $filter) {
- $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
- if ($scope.model[$scope.options.key]) {
- } else {
- $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
- }
- $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.endOpen = true;
- $scope.datepicker = {};
- $scope.datepicker.opened = false;
- $scope.datepicker.open = function($event) {
- $scope.datepicker.opened = true;
- };
- }]
- });
- //时分控件
- formlyConfigProvider.setType({
- name: 'ui-datehourtime',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
- defaultOptions: function(options) {
- return {
- noFormControl: true,
- // validators:{
- // required:{
- // expression:function(viewValue, modelValue){
- // console.log(options)
- // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
- // // var value = modelValue.getHours() || viewValue.getHours();
- // return value.length>=1;
- // }
- // }
- // }
- }
- },
- controller: ['$scope', '$log', function($scope, $log) {
- $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
- $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
- $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
- }]
- });
- //状态追踪
- formlyConfigProvider.setType({
- name: 'ui-followStatus',
- templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
- controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
- setTimeout(function() {
- var pkey = $scope.options.templateOptions.pkey;
- var dataId = $scope.model.id;
- api_bpm_data.fetchData(pkey, dataId).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- var processInstanceId = myData.data.processInstanceId;
- $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
- if (result.status == 200) {
- var newData = Restangular.stripRestangular(result);
- $scope.followData = newData.data;
- }
- });
- }
- })
- }, 10);
- }]
- });
- //历史记录
- formlyConfigProvider.setType({
- name: 'ui-history',
- templateUrl: 'assets/views/customform/tpl/ui-history.html',
- controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
- setTimeout(function() {
- var pkey = $scope.options.templateOptions.pkey;
- var dataId = $scope.model.id;
- api_bpm_data.fetchData(pkey, dataId).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- var processInstanceId = myData.data.processInstanceId;
- $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
- if (result.status == 200) {
- var newData = Restangular.stripRestangular(result);
- var long = newData.data.length - 1;
- $scope.followData = newData.data[long];
- }
- });
- }
- })
- }, 10);
- }]
- });
- //请求人信息显示
- formlyConfigProvider.setType({
- name: "ui-disrequester",
- templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function($scope) {
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //退回人信息显示
- formlyConfigProvider.setType({
- name: "ui-returnperson",
- templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function($scope) {
- $scope.group = "";
- $scope.role = "";
- if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- }
- }
- if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
- $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
- $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
- }
- }
- $scope.options.templateOptions.that = $scope;
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //指派技术人员
- formlyConfigProvider.setType({
- name: "ui-apiontperson",
- templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {
- transtlara: function(value, $scope) {}
- }
- };
- },
- controller: ['$scope', 'api_user_data', 'Restangular', function($scope, api_user_data, Restangular) {
- var filterData = { "idx": 0, "sum": 1000 }
- api_user_data.fetchDataList('group', filterData).then(function(response) {
- if (response.status == 200) {
- $scope.select = {};
- $scope.multipleDemo = {};
- $scope.userdata = {};
- var data = response.list;
- var item = [];
- $scope.multipleDemo = data;
- $scope.multipleDemo;
- }
- })
- $scope.options.templateOptions.onChange = function(id, options, groupdata, $event, model) {
- if (groupdata.option) {
- $scope.model[$scope.options.key] = {};
- var fildate = {
- "idx": 0,
- "sum": 1000,
- "user": {
- "roledata": { "rolecode": model.currentRole },
- "selectType": "1",
- "groupdata": { "id": groupdata.option.id }
- }
- }
- api_user_data.fetchDataList('user', fildate).then(function(response) {
- if (response.status == 200) {
- $scope.userdata = {};
- $scope.userdata = response.list;
- }
- })
- } else {
- $scope.model[$scope.options.key] = { id: groupdata.id.id }
- $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
- }
- }
- // }
- }]
- });
- // 请求人选控件
- formlyConfigProvider.setType({
- name: "ui-requesterselect",
- templateUrl: 'assets/views/customform/tpl/ui-requester.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
- api_user_data.fetchDataList('requester', { "idx": 0, "sum": 10, "requester": { "account": $scope.$root.user.account } }).then(function(response) {
- if (response.status == 200) {
- $scope.model[$scope.options.key] = response.list[0];
- }
- })
- }]
- });
- // 请求人选控件
- // formlyConfigProvider.setType({
- // name: "ui-requesterselect",
- // templateUrl: 'assets/views/customform/tpl/ui-requester.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- // defaultOptions: function(options, $scope) {
- // return {
- // templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- // linkage: function(searchtype, opt) {
- // var filterData = {
- // 'requester': {
- // 'searchKey': searchtype,
- // },
- // idx: 0,
- // sum: 10
- // };
- // if (opt.model.requester && opt.model.requester != null && opt.model.requester.requesterTypeDTO) {
- // angular.extend(filterData.requester, { 'requesterTypeDTO': opt.model.requester.requesterTypeDTO })
- // }
- // $scope.searchKey = searchtype;
- // // $scope.nameshow=false;
- // $scope.accountshow = false;
- // if (angular.isDefined(searchtype) && searchtype != '') {
- // $scope.accountshow = true;
- // options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function(response) {
- // var myData = options.templateOptions.Restangular.stripRestangular(response);
- // $scope.myData = myData.list;
- // if (myData.list.length >= 0) {
- // if (myData.list.length == 1) {
- // $scope.accountshow = false;
- // if ($scope.model) {
- // if ($scope.model.place) {
- // $scope.model.place.id = '';
- // }
- // if ($scope.model.area) {
- // $scope.model.area.id = '';
- // }
- // options.model.houseNumber = '';
- // }
- // // $scope.model.place.id = '';
- // // $scope.model.area.id = '';
- // // $scope.model.houseNumber = '';
- // options.value(myData.list[0]);
- // if ($scope.myData[0].placeDTO && $scope.myData[0].placeDTO.id) {
- // $scope.model.place.id = $scope.myData[0].placeDTO.id
- // }
- // if ($scope.myData[0].areaDTO && $scope.myData[0].areaDTO.id) {
- // $scope.model.area.id = $scope.myData[0].areaDTO.id
- // }
- // if ($scope.myData[0].houseNumber) {
- // $scope.model.houseNumber = $scope.myData[0].houseNumber;
- // }
- // } else if (myData.list.length == 0) {
- // $scope.accountshow = false;
- // if ($scope.model) {
- // if ($scope.model.place) {
- // $scope.model.place.id = '';
- // }
- // if ($scope.model.area) {
- // $scope.model.area.id = '';
- // }
- // options.model.houseNumber = '';
- // }
- // if (opt.model.requester && opt.model.requester != null && opt.model.requester.requesterTypeDTO) {
- // // $scope.model[requesterTypeDTO]=opt.model.requester.requesterTypeDTO;
- // options.value({ 'requesterTypeDTO': opt.model.requester.requesterTypeDTO });
- // }
- // } else if (myData.list.length > 1) {
- // $scope.accountshow = true;
- // // var requesternum={};
- // // requesternum['searchKey']=searchtype;
- // // options.value(requesternum);
- // }
- // }
- // });
- // $scope.show = function(filitem) {
- // // $scope.nameshow=false;
- // $scope.accountshow = false;
- // if ($scope.model) {
- // if ($scope.model.place) {
- // $scope.model.place.id = '';
- // }
- // if ($scope.model.area) {
- // $scope.model.area.id = '';
- // }
- // options.model.houseNumber = '';
- // }
- // options.value(filitem);
- // $scope.searchKey = filitem.account;
- // if (filitem.placeDTO && filitem.placeDTO.id) {
- // $scope.model.place.id = filitem.placeDTO.id
- // }
- // if (filitem.areaDTO && filitem.areaDTO.id) {
- // $scope.model.area.id = filitem.areaDTO.id
- // }
- // if (filitem.houseNumber) {
- // $scope.model.houseNumber = filitem.houseNumber;
- // }
- // }
- // } else {
- // $scope.accountshow = false;
- // searchtype = ''
- // }
- // },
- // openModal: function(size, options, modal) {
- // var modelObject = options.value();
- // var searchModal = function(filterSearchData) {
- // var modalInstance = modal.open({
- // templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- // controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchData, api_bpm_data) {
- // $scope.langs = i18nService.getAllLangs();
- // $scope.lang = 'zh-cn';
- // i18nService.setCurrentLang($scope.lang);
- // $scope.gridOptions = {};
- // $scope.gridOptions.data = 'myData';
- // $scope.gridOptions.enableColumnResizing = true;
- // $scope.gridOptions.enableFiltering = true;
- // $scope.gridOptions.enableGridMenu = false;
- // $scope.gridOptions.enableRowSelection = true;
- // $scope.gridOptions.showGridFooter = true;
- // $scope.gridOptions.showColumnFooter = true;
- // $scope.gridOptions.fastWatch = true;
- // $scope.gridOptions.useExternalFiltering = true;
- // $scope.gridOptions.useExternalPagination = true;
- // $scope.gridOptions.paginationPageSizes = [10];
- // $scope.gridOptions.paginationPageSize = 10;
- // $scope.gridOptions.multiSelect = false;
- // $scope.gridOptions.rowIdentity = function(row) {
- // return row.id;
- // };
- // $scope.gridOptions.getRowIdentity = function(row) {
- // return row.id;
- // };
- // $scope.gridOptions.columnDefs = [
- // { name: 'account', displayName: '一卡通号', width: 140 },
- // { name: 'studentNo', displayName: '学工号', width: 140 },
- // { name: 'name', displayName: '姓名', width: 100 },
- // { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
- // { name: 'mphone', displayName: '电话', width: 100, enableFiltering: false },
- // // { name:'email', displayName:'邮件', width:100},
- // { name: 'areaDTO.area', displayName: '区域', width: 100, enableFiltering: false },
- // { name: 'placeDTO.place', displayName: '地点', width: 100, enableFiltering: false }
- // ];
- // $scope.gridOptions.onRegisterApi = function(gridApi) {
- // $scope.gridApi = gridApi;
- // // var filtersData = $scope.memoryfilterData;
- // // filtersData.idx = newPage - 1;
- // // filtersData.sum = pageSize;
- // gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- // });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
- // $scope.selected.item = data.entity;
- // // }else{alert ("请求人工号格式不对,账号应为6位数,请重新填写!")}
- // });
- // gridApi.core.on.filterChanged($scope, function() {
- // var grid = this.grid;
- // var filtersData = {
- // idx: 0,
- // sum: 10
- // };
- // angular.forEach(grid.columns, function(item) {
- // if (item.enableFiltering) {
- // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // if (angular.isUndefined(filtersData['requester'])) {
- // filtersData['requester'] = {};
- // }
- // filtersData['requester'][item.field] = item.filters[0].term;
- // }
- // }
- // });
- // $scope.memoryfilterData = filtersData;
- // $scope.loadData(filtersData);
- // });
- // };
- // $scope.memoryfilterData = defaultFilterData = {
- // "idx": 0,
- // "sum": 10
- // };
- // $scope.loadData = function(filterData) {
- // items.fetchItems(filterData, APIService).then(function(data) {
- // var myData = Restangular.stripRestangular(data);
- // $scope.gridOptions.totalItems = myData.totalNum;
- // $scope.myData = myData.list;
- // });
- // };
- // $scope.title = title;
- // if (searchData) {
- // $scope.loadData(searchData);
- // } else {
- // $scope.loadData({
- // idx: 0,
- // sum: 10
- // });
- // }
- // $scope.selected = {
- // item: {}
- // };
- // $scope.ok = function() {
- // $modalInstance.close($scope.selected.item);
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // size: size,
- // resolve: {
- // items: function() {
- // return {
- // fetchItems: function(filterData, APIService) {
- // filterData = filterData || {};
- // if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
- // filterData = {
- // idx: 0,
- // sum: 10
- // };
- // }
- // return options.templateOptions.fetchItems(filterData, APIService);
- // }
- // };
- // },
- // title: function() {
- // return options.templateOptions.modalTitle;
- // },
- // Restangular: function() {
- // return options.templateOptions.Restangular;
- // },
- // APIService: function() {
- // return options.templateOptions.ApiService;
- // },
- // language: function() {
- // return options.templateOptions.language;
- // },
- // searchData: function() {
- // return filterSearchData;
- // }
- // }
- // });
- // modalInstance.result.then(function(selectedItem) {
- // if (options.model) {
- // if (options.model.place) {
- // options.model.place.id = '';
- // }
- // if (options.model.area) {
- // options.model.area.id = '';
- // }
- // options.model.houseNumber = '';
- // }
- // options.value(selectedItem);
- // $scope.searchKey = selectedItem.account;
- // if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
- // options.model.place.id = selectedItem.placeDTO.id
- // }
- // if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
- // options.model.area.id = selectedItem.areaDTO.id
- // }
- // if (selectedItem.houseNumber) {
- // options.model.houseNumber = selectedItem.houseNumber;
- // }
- // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
- // options.templateOptions.callback(selectedItem, options);
- // }
- // }, function() {
- // //console.log('Modal dismissed at: ' + new Date());
- // });
- // }
- // searchModal();
- // // }
- // },
- // addRequeter: function(size, options, modal) {
- // var modalInstance = modal.open({
- // templateUrl: 'assets/views/customform/tpl/modal-add-requester.html',
- // controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data) {
- // $scope.title = "新增请求人";
- // $scope.requester = {
- // };
- // api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.areas = response.list;
- // }
- // })
- // api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.networktypes = response.list;
- // }
- // })
- // $scope.onChange = function(item) {
- // // console.log(item)
- // $scope.requester.placeDTO = {};
- // api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.places = response.list;
- // }
- // })
- // }
- // $scope.refreshDepts = function(key) {
- // var filterData = {
- // 'idx': 0,
- // 'sum': 5,
- // 'dept': {
- // 'name': key
- // }
- // };
- // UserService.fetchDataList('department', filterData).then(function(response) {
- // if (response.status == 200) {
- // $scope.depts = response.list;
- // }
- // })
- // }
- // $scope.ok = function() {
- // if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
- // // SweetAlert.swal("请求人姓名未填!", "请填写请求人姓名", "error");
- // $ionicPopup.alert({
- // title: '请求人姓名未填!',
- // });
- // } else if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
- // // SweetAlert.swal("请求人一卡通号未填!", "请填写请求人一卡通号", "error");
- // $ionicPopup.alert({
- // title: '请求人一卡通号未填!',
- // });
- // } else if (angular.isUndefined($scope.requester.requesterTypeDTO) || $scope.requester.requesterTypeDTO == null || $scope.requester.requesterTypeDTO == "") {
- // // SweetAlert.swal("请求人职务!", "请填写请求人职务", "error");
- // $ionicPopup.alert({
- // title: '请求人职务未填!',
- // });
- // } else {
- // $modalInstance.close($scope.requester);
- // }
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // size: size,
- // resolve: {
- // items: function() {
- // return {
- // fetchItems: function(filterData, APIService) {
- // filterData = filterData || {};
- // if (!filterData.idx) {
- // filterData = {
- // idx: 0,
- // sum: 10
- // };
- // }
- // return options.templateOptions.fetchItems(filterData, APIService);
- // }
- // };
- // },
- // title: function() {
- // return options.templateOptions.modalTitle;
- // },
- // Restangular: function() {
- // return options.templateOptions.Restangular;
- // },
- // APIService: function() {
- // return options.templateOptions.ApiService;
- // },
- // UserService: function() {
- // return options.templateOptions.UserService;
- // }
- // }
- // });
- // modalInstance.result.then(function(selectedItem) {
- // if (selectedItem) {
- // var data = {
- // 'requester': selectedItem
- // };
- // $scope.searchKey = selectedItem.account;
- // options.templateOptions.UserService.addData('requester', data).then(function(response) {
- // if (response.status == 200) {
- // if (options.model) {
- // if (options.model.place) {
- // options.model.place.id = '';
- // }
- // if (options.model.area) {
- // options.model.area.id = '';
- // }
- // options.model.houseNumber = '';
- // }
- // options.value(response.data);
- // if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
- // options.model.place.id = selectedItem.placeDTO.id
- // }
- // if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
- // options.model.area.id = selectedItem.areaDTO.id
- // }
- // if (selectedItem.houseNumber) {
- // options.model.houseNumber = selectedItem.houseNumber;
- // }
- // }
- // })
- // }
- // }, function() {
- // //console.log('Modal dismissed at: ' + new Date());
- // });
- // },
- // changeRequeter: function(size, options, modal) {
- // var modalInstance = modal.open({
- // templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
- // controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data) {
- // $scope.title = "修改请求人";
- // $scope.requester = {
- // id: options.model.requester.id,
- // account: options.model.requester.account,
- // name: options.model.requester.name,
- // gender: options.model.requester.gender,
- // email: options.model.requester.email,
- // deptName: options.model.requester.deptName,
- // mphone: options.model.requester.mphone,
- // telephone: options.model.requester.telephone,
- // studentNo: options.model.requester.studentNo,
- // areaDTO: options.model.requester.areaDTO,
- // placeDTO: options.model.requester.placeDTO,
- // requesterTypeDTO: options.model.requester.requesterTypeDTO
- // };
- // api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.areas = response.list;
- // }
- // })
- // api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.networktypes = response.list;
- // }
- // })
- // if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
- // api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.places = response.list;
- // }
- // })
- // }
- // $scope.onChange = function(item) {
- // // console.log(item)
- // $scope.requester.placeDTO = {};
- // api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.places = response.list;
- // }
- // })
- // }
- // $scope.refreshDepts = function(key) {
- // var filterData = {
- // 'idx': 0,
- // 'sum': 5,
- // 'dept': {
- // 'name': key
- // }
- // };
- // UserService.fetchDataList('department', filterData).then(function(response) {
- // if (response.status == 200) {
- // $scope.depts = response.list;
- // }
- // })
- // }
- // $scope.ok = function() {
- // if ($scope.requester.account == "" || $scope.requester.name == "") {
- // // SweetAlert.swal("请求人姓名或一卡通号未填!", "请补全请求人信息", "error");
- // $ionicPopup.alert({
- // title: '请求人姓名或一卡通号未填!',
- // });
- // } else {
- // $modalInstance.close($scope.requester);
- // }
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // size: size,
- // resolve: {
- // items: function() {
- // return {
- // fetchItems: function(filterData, APIService) {
- // filterData = filterData || {};
- // if (!filterData.idx) {
- // filterData = {
- // idx: 0,
- // sum: 10
- // };
- // }
- // return options.templateOptions.fetchItems(filterData, APIService);
- // }
- // };
- // },
- // title: function() {
- // return options.templateOptions.modalTitle;
- // },
- // Restangular: function() {
- // return options.templateOptions.Restangular;
- // },
- // APIService: function() {
- // return options.templateOptions.ApiService;
- // },
- // UserService: function() {
- // return options.templateOptions.UserService;
- // }
- // }
- // });
- // modalInstance.result.then(function(selectedItem) {
- // if (selectedItem) {
- // var data = {
- // 'requester': selectedItem
- // };
- // options.templateOptions.UserService.addData('requester', data).then(function(response) {
- // if (response.status == 200) {
- // options.value(response.data);
- // // SweetAlert.swal("修改成功!", "", "error");
- // } else {
- // // SweetAlert.swal("修改失败!", "请重试", "error");
- // }
- // })
- // // }
- // }
- // }, function() {
- // //console.log('Modal dismissed at: ' + new Date());
- // });
- // }
- // }
- // };
- // },
- // controller: ['$scope', function($scope) {
- // $scope.options.templateOptions.ApiService.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.networktypes = response.list;
- // } else {
- // // SweetAlert.swal("系统错误!", "请刷新重试", "error");
- // $ionicPopup.alert({
- // title: '系统错误!',
- // });
- // }
- // })
- // // $scope.options.templateOptions.that = $scope;
- // }]
- // });
- //处理人信息
- formlyConfigProvider.setType({
- name: "ui-userinformation",
- templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function($scope) {
- $scope.group = "";
- $scope.role = "";
- // if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- // $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- // } else {
- // for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- // $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- // }
- // }
- // if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
- // $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
- // } else {
- // for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
- // $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
- // }
- // }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //处理界面处理人信息
- formlyConfigProvider.setType({
- name: "ui-handler",
- templateUrl: 'assets/views/customform/tpl/ui-handler.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function($scope) {
- $scope.group = "";
- // $scope.role="";
- if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- }
- }
- // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
- // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
- // }else{
- // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
- // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
- // }
- // }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //关闭界面处理人信息
- formlyConfigProvider.setType({
- name: "ui-closehandler",
- templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', '$rootScope', 'api_text', function($scope, $rootScope, api_text) {
- $scope.dialout = function(teleno) {
- var gid = "@0"
- var telephone = '9' + teleno
- api_text.dialout($rootScope.takes, gid, telephone).then(function(data) {
- if (data.errno == 0) {
- $rootScope.status = 6;
- }
- })
- }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- // formlyConfigProvider.setType({
- // name: "ui-closehandler",
- // templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- // defaultOptions:function(options){
- // return {
- // templateOptions: {
- // }
- // };
- // },
- // controller:['$scope','$rootScope','SweetAlert','api_text', function($scope,$rootScope,SweetAlert,api_text){
- // $scope.group="";
- // // $scope.role="";
- // if(angular.isDefined($scope.model.handlingPersonnelUser.group) &&$scope.model.handlingPersonnelUser.group.length==1){
- // $scope.group=$scope.model.handlingPersonnelUser.group[0].groupName;
- // }else{
- // for(var i=0;i<$scope.model.handlingPersonnelUser.group.length;i++){
- // $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName +",";
- // }
- // }
- // // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
- // // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
- // // }else{
- // // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
- // // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
- // // }
- // // }
- // $scope.options.templateOptions.that = $scope;
- // $scope.dialout = function(teleno){
- // api_text.callout($rootScope.takes,teleno).then(function(data){
- // if(data.errno==0){
- // SweetAlert.swal({
- // title: "呼叫成功",
- // text: "呼叫中心呼叫成功!",
- // type: "success"
- // });
- // }else{SweetAlert.swal({
- // title: "呼叫失败",
- // text: "请重新呼叫!",
- // type: "error"
- // });
- // }
- // })
- // }
- // }]
- // });
- //用户单选控件
- // formlyConfigProvider.setType({
- // name: "ui-userselect",
- // templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- // defaultOptions: function(options) {
- // return {
- // templateOptions: {
- // openModal: function(size, options, modal) {
- // var modalInstance = modal.open({
- // templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- // controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
- // $scope.langs = i18nService.getAllLangs();
- // $scope.lang = 'zh-cn';
- // i18nService.setCurrentLang($scope.lang);
- // $scope.gridOptions = {};
- // $scope.gridOptions.data = 'myData';
- // $scope.gridOptions.enableColumnResizing = true;
- // $scope.gridOptions.enableFiltering = true;
- // $scope.gridOptions.enableGridMenu = true;
- // $scope.gridOptions.enableRowSelection = true;
- // $scope.gridOptions.showGridFooter = true;
- // $scope.gridOptions.showColumnFooter = true;
- // $scope.gridOptions.fastWatch = true;
- // $scope.gridOptions.useExternalFiltering = true;
- // $scope.gridOptions.useExternalPagination = true;
- // $scope.gridOptions.paginationPageSizes = [10];
- // $scope.gridOptions.paginationPageSize = 10;
- // $scope.gridOptions.multiSelect = false;
- // $scope.gridOptions.rowIdentity = function(row) {
- // return row.id;
- // };
- // $scope.gridOptions.getRowIdentity = function(row) {
- // return row.id;
- // };
- // //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
- // $scope.gridOptions.columnDefs = [
- // // { name:'id', width:80, enableFiltering:false},
- // { name: 'account', displayName: '学工号', width: 120 },
- // { name: 'name', displayName: '名称', width: 100 },
- // { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
- // { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
- // { name: 'email', displayName: '邮件', width: 120, enableFiltering: false },
- // { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
- // { name: 'role[0].role', displayName: '角色', width: 100, enableFiltering: false },
- // { name: 'taskCount', displayName: '处理中事件数', width: 100, enableFiltering: false }
- // ];
- // $scope.gridOptions.onRegisterApi = function(gridApi) {
- // $scope.gridApi = gridApi;
- // gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- // //console.log(pageSize);
- // // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- // });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // $scope.selected.item = data.entity;
- // //console.log(data);
- // });
- // gridApi.core.on.filterChanged($scope, function() {
- // var grid = this.grid;
- // var filtersData = {
- // idx: 0,
- // sum: 10,
- // "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- // };
- // angular.forEach(grid.columns, function(item) {
- // if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // if (angular.isUndefined(filtersData['user'])) {
- // filtersData['user'] = {};
- // }
- // filtersData['user'][item.field] = item.filters[0].term;
- // }
- // }
- // });
- // $scope.memoryfilterData = filtersData;
- // $scope.loadData(filtersData);
- // });
- // };
- // if (!options.model) {
- // var mouse = { "model": { "currentRole": "" } };
- // angular.extend(options, mouse);
- // }
- // $scope.memoryfilterData = {
- // "idx": 0,
- // "sum": 10,
- // "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- // }
- // $scope.loadData = function(filterData) {
- // console.log("filtersData=111" + JSON.stringify(filterData))
- // items.fetchItems(filterData, APIService).then(function(data) {
- // var myData = Restangular.stripRestangular(data);
- // $scope.gridOptions.totalItems = myData.totalNum;
- // $scope.myData = myData.list;
- // });
- // };
- // $scope.title = title;
- // $scope.loadData({
- // idx: 0,
- // sum: 10,
- // "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- // });
- // $scope.selected = {
- // item: {}
- // };
- // $scope.ok = function() {
- // // if(onDataCallback&&angular.isFunction(onDataCallback)){
- // // onDataCallback($scope.selected.item, parentScope);
- // // }
- // $modalInstance.close($scope.selected.item);
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // size: size,
- // resolve: {
- // items: function() {
- // return {
- // fetchItems: function(filterData, APIService) {
- // filterData = filterData || {};
- // console.log(options)
- // if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- // filterData = {
- // idx: 0,
- // sum: 10,
- // "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
- // };
- // }
- // // function (filterData, APIService){filterData.user.roledata.rolecode='question investigation';return APIService.fetchDataList('user',filterData);}
- // return options.templateOptions.fetchItems(filterData, APIService);
- // }
- // };
- // },
- // title: function() {
- // return options.templateOptions.modalTitle;
- // },
- // Restangular: function() {
- // return options.templateOptions.Restangular;
- // },
- // APIService: function() {
- // return options.templateOptions.ApiService;
- // },
- // onDataCallback: function() {
- // return options.templateOptions.callback;
- // },
- // parentScope: function() {
- // return options.templateOptions.that;
- // }
- // }
- // });
- // modalInstance.result.then(function(selectedItem) {
- // // console.log(selectedItem);
- // options.value(selectedItem);
- // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
- // options.templateOptions.callback(selectedItem, options.templateOptions.that);
- // }
- // }, function() {
- // //console.log('Modal dismissed at: ' + new Date());
- // });
- // }
- // }
- // };
- // },
- // controller: ['$scope', function($scope) {
- // $scope.model[$scope.options.key] = [];
- // $scope.options.templateOptions.that = $scope;
- // }]
- // });
- //处理人控件 10#
- formlyConfigProvider.setType({
- name: "ui-userselect",
- templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- // defaultOptions: function(options) {
- // return {
- // templateOptions: {
- // refresh: function(filterData, APIService) {
- // return APIService.fetchDataList('user', filterData);
- // }
- // }
- // };
- // },
- controller: ['$scope', function($scope) {
- // $scope.model[$scope.options.key] = [];
- // var filterData = {
- // idx: 0,
- // sum: 10,
- // "user": { "roledata": { "rolecode": $scope.model.currentRole }, "selectType": "1" }
- // };
- // $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data) {
- // var myData = data.list;
- // $scope.myData = myData;
- // // $scope.model[$scope.options.key] = myData;
- // // $scope.options.value(myData);
- // // $scope.options.formControl.$validate();
- // });
- // $scope.getItem = function(item) {
- // $scope.model[$scope.options.key] = item;
- // $scope.options.value(item);
- // $scope.pl = item.name;
- // if ($scope.model.closecode) {
- // delete $scope.model.closecode
- // };
- // if ($scope.model.degree) {
- // delete $scope.model.degree
- // };
- // }
- // $scope.addlist = function() {
- // $scope.editId = 6;
- // $scope.model[$scope.options.key].push("");
- // }
- // $scope.editId = -1;
- // $scope.setEditId = function(pid, usersdata) {
- // $scope.usersdata = {};
- // $scope.editId = pid;
- // angular.extend($scope.usersdata, usersdata)
- // };
- // $scope.savelist = function(usersdata, pid) {
- // // console.log($scope.model[$scope.options.key])
- // for (i = 0; i < $scope.model[$scope.options.key].length; i++) {
- // if (usersdata.account == $scope.model[$scope.options.key][i].account) {
- // $scope.model[$scope.options.key][i] = $scope.usersdata;
- // }
- // }
- // $scope.editId = pid;
- // };
- // $scope.remove = function(itemId) {
- // angular.forEach($scope.model[$scope.options.key], function(entry, index) {
- // if (entry.id == itemId) {
- // $scope.model[$scope.options.key].splice(index, 1);
- // console.log($scope.options.formControl)
- // $scope.options.formControl.$validate();
- // } else {
- // }
- // });
- // }
- // if ($scope.options.templateOptions.transform) {
- // $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
- // }
- // if (angular.isFunction($scope.options.templateOptions.translate)) {
- // $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope);
- // }
- // $scope.$select.disabled = $scope.to.readOnly;
- $scope.to['onChange'] = function(item, opts, ts, event, model) {
- $scope.model[$scope.options.key] = ts.$select.selected;
- }
- }]
- });
- //可编辑列表控件
- // formlyConfigProvider.setType({
- // name: "ui-multiuserselectchange",
- // templateUrl: 'assets/views/customform/tpl/ui-multiuserselectchange.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- // defaultOptions:function(options){
- // return {
- // templateOptions: {
- // refresh:function(filterData,APIService){
- // return APIService.fetchDataList('user',filterData);
- // }
- // },
- // validators:{
- // required:{
- // expression:function(viewValue, modelValue){
- // var value = modelValue || viewValue;
- // return value.length>=1;
- // }
- // }
- // }
- // };
- // },
- // controller:['$scope','$filter', function($scope,$filter){
- // $scope.model[$scope.options.key] = [];
- // var filterData = {
- // idx:0,
- // sum:10,
- // "user":{"roledata":{"rolecode":$scope.model.currentRole},"selectType":"1"}
- // };
- // $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data){
- // var myData = data.list;
- // $scope.model[$scope.options.key]=myData;
- // $scope.options.value(myData);
- // $scope.options.formControl.$validate();
- // });
- // $scope.addlist = function(){
- // $scope.editId =6;
- // $scope.model[$scope.options.key].push("");
- // }
- // // $scope.tableParams = new ngTableParams({
- // // page: 1,
- // // count: 10
- // // }, {
- // // total: data.length,
- // // getData: function ($defer, params) {
- // // var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
- // // $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- // // }
- // // });
- // $scope.editId = -1;
- // $scope.setEditId = function (pid,usersdata) {
- // $scope.usersdata={};
- // $scope.editId = pid;
- // angular.extend($scope.usersdata,usersdata)
- // };
- // $scope.savelist = function (usersdata,pid) {
- // // console.log($scope.model[$scope.options.key])
- // for(i=0;i<$scope.model[$scope.options.key].length;i++){
- // if(usersdata.account==$scope.model[$scope.options.key][i].account){
- // $scope.model[$scope.options.key][i]=$scope.usersdata;
- // }
- // }
- // $scope.editId = pid;
- // };
- // $scope.remove = function(itemId){
- // angular.forEach($scope.model[$scope.options.key], function(entry,index){
- // if(entry.id == itemId){
- // $scope.model[$scope.options.key].splice(index,1);
- // console.log($scope.options.formControl)
- // $scope.options.formControl.$validate();
- // }else{
- // }
- // });
- // }
- // }]
- // });
- formlyConfigProvider.setType({
- name: "ui-multiuserselectchange",
- templateUrl: 'assets/views/customform/tpl/ui-multiuserselectchange.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {
- // refresh:function(filterData,APIService){
- // return APIService.fetchDataList('user',filterData);
- // }
- },
- validators: {
- required: {
- expression: function(viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value.length >= 1;
- }
- }
- }
- };
- },
- controller: ['$scope', '$filter', function($scope, $filter) {
- $scope.model[$scope.options.key] = [];
- var filterData = {
- idx: 0,
- sum: 10,
- "user": { "roledata": { "rolecode": $scope.model.currentRole }, "selectType": "1" }
- };
- $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data) {
- var myData = data.list;
- $scope.model[$scope.options.key] = myData;
- $scope.options.value(myData);
- $scope.options.formControl.$validate();
- });
- $scope.addlist = function() {
- $scope.editId = 6;
- $scope.model[$scope.options.key].push("");
- }
- $scope.editId = -1;
- $scope.setEditId = function(pid, usersdata) {
- $scope.usersdata = {};
- $scope.editId = pid;
- angular.extend($scope.usersdata, usersdata)
- };
- $scope.savelist = function(usersdata, pid) {
- // console.log($scope.model[$scope.options.key])
- for (i = 0; i < $scope.model[$scope.options.key].length; i++) {
- if (usersdata.account == $scope.model[$scope.options.key][i].account) {
- $scope.model[$scope.options.key][i] = $scope.usersdata;
- }
- }
- $scope.editId = pid;
- };
- $scope.remove = function(itemId) {
- angular.forEach($scope.model[$scope.options.key], function(entry, index) {
- if (entry.id == itemId) {
- $scope.model[$scope.options.key].splice(index, 1);
- console.log($scope.options.formControl)
- $scope.options.formControl.$validate();
- } else {
- }
- });
- }
- }]
- });
- //用户多选控件
- formlyConfigProvider.setType({
- name: "ui-multiuserselect",
- templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function(options) {
- return {
- templateOptions: {
- openModal: function(size, options, modal, model) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
- $scope.gridOptions.columnDefs = [
- // { name:'id', width:80, enableFiltering:false},
- { name: 'account', displayName: '账号', width: 140 },
- { name: 'name', displayName: '名称', width: 100 },
- { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
- { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
- { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
- { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
- { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: false }
- ];
- $scope.selected = {
- items: selectItems
- };
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.loadData(filtersData);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
- var j = 0;
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i] == scope.entity) {
- j++;
- break;
- }
- }
- if (j == 1) {
- scope.grid.appScope.selected.items.splice(i, 1);
- } else {
- scope.grid.appScope.selected.items.push(scope.entity)
- for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
- for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
- // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
- // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
- if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
- scope.grid.appScope.selected.items.splice(i, 1);
- }
- }
- }
- }
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
- // $scope.grid.appScope.selected.items.push($scope.entity);
- // });
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- };
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- //console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- if (!options.model) {
- var mouse = { "model": { "currentRole": "" } };
- angular.extend(options, mouse);
- }
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 10,
- "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- }
- $scope.loadData = function(filterData) {
- // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
- items.fetchItems(filterData, APIService).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- //console.log($scope.gridOptions.pagination.getTotalPages());
- // if($scope.selected.items){
- // angular.forEach($scope.selected.items,function(selectItem){
- // $scope.gridApi.selection.selectRow(selectItem);
- // });
- // }
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10,
- "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- });
- // $timeout(function(){
- // if($scope.selected.items){
- // angular.forEach($scope.selected.items,function(selectItem){
- // $scope.gridApi.selection.selectRow(selectItem);
- // });
- // }
- // },2000)
- $scope.ok = function() {
- // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function() {
- return {
- fetchItems: function(filterData, APIService) {
- filterData = filterData || {};
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10,
- "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function() {
- return options.templateOptions.modalTitle;
- },
- Restangular: function() {
- return options.templateOptions.Restangular;
- },
- APIService: function() {
- return options.templateOptions.ApiService;
- },
- selectItems: function() {
- return model || [];
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- options.value(selectedItem);
- options.formControl.$validate();
- }, function() {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- },
- validators: {
- required: {
- expression: function(viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value.length >= 1;
- }
- }
- }
- };
- },
- controller: ['$scope', function($scope) {
- $scope.model[$scope.options.key] = [];
- $scope.remove = function(itemId) {
- angular.forEach($scope.model[$scope.options.key], function(entry, index) {
- if (entry.id == itemId) {
- $scope.model[$scope.options.key].splice(index, 1);
- console.log($scope.options.formControl)
- $scope.options.formControl.$validate();
- } else {
- }
- });
- }
- }]
- });
- //重复事件
- formlyConfigProvider.setType({
- name: "ui-incidentmodelselect",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- openModal: function(size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = false;
- // $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- // console.log(newPage);
- // console.log(pageSize);
- $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
- });
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10
- };
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- filtersData['incident'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['problem'])) {
- filtersData['problem'] = {};
- }
- filtersData['problem'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['change'])) {
- filtersData['change'] = {};
- }
- filtersData['change'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['release'])) {
- filtersData['release'] = {};
- }
- filtersData['release'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.loadData(filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- $scope.loadData = function(filterData) {
- items.fetchItems(filterData, APIService).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10
- });
- $scope.selected = {
- item: {}
- };
- $scope.ok = function() {
- //console.log($scope.selected.item);
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function() {
- return {
- fetchItems: function(filterData, APIService) {
- filterData = filterData || {};
- // if(!filterData.idx){
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService, options);
- },
- columnDefs: function() {
- return options.templateOptions.columnDefs;
- }
- };
- },
- title: function() {
- return options.templateOptions.modalTitle;
- },
- Restangular: function() {
- return options.templateOptions.Restangular;
- },
- APIService: function() {
- return options.templateOptions.ApiService;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- var selectitem = { title: selectedItem.title, description: selectedItem.description }
- angular.extend(options.model, selectitem);
- options.value(selectedItem);
- }, function() {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- }
- });
- //选项选择控件
- formlyConfigProvider.setType({
- name: "ui-modelselect",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- openModal: function(size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- // console.log(newPage);
- // console.log(pageSize);
- $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
- });
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10
- };
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- filtersData['incident'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['problem'])) {
- filtersData['problem'] = {};
- }
- filtersData['problem'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['change'])) {
- filtersData['change'] = {};
- }
- filtersData['change'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['release'])) {
- filtersData['release'] = {};
- }
- filtersData['release'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.loadData(filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- $scope.loadData = function(filterData) {
- items.fetchItems(filterData, APIService).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10
- });
- $scope.selected = {
- item: {}
- };
- $scope.ok = function() {
- //console.log($scope.selected.item);
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function() {
- return {
- fetchItems: function(filterData, APIService) {
- filterData = filterData || {};
- // if(!filterData.idx){
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService, options);
- },
- columnDefs: function() {
- return options.templateOptions.columnDefs;
- }
- };
- },
- title: function() {
- return options.templateOptions.modalTitle;
- },
- Restangular: function() {
- return options.templateOptions.Restangular;
- },
- APIService: function() {
- return options.templateOptions.ApiService;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- options.value(selectedItem);
- }, function() {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- }
- });
- formlyConfigProvider.setType({
- name: 'ui-requestform',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
- controller: ['$scope', function($scope) {
- setTimeout(function() {
- var filterData = {
- "idx": 0,
- "sum": 5,
- "incident": { "requester": { "id": "" } }
- }
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- });
- }, 1000);
- }]
- });
- //工单控件
- formlyConfigProvider.setType({
- name: 'ui-workernumber',
- // extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
- controller: ['$scope', function($scope) {
- if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
- setTimeout(function() {
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- if (modelData.status == 200) {
- $scope.model[$scope.options.key] = modelData.data;
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }
- });
- }, 1000);
- }
- }]
- });
- //cmdb工单
- formlyConfigProvider.setType({
- name: 'ui-cmdbworkernumber',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
- controller: ['$scope', function($scope) {
- if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
- setTimeout(function() {
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function(result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- // if(modelData.status==200){
- $scope.model[$scope.options.key] = modelData[$scope.options.key];
- $scope.options.initialValue = $scope.model[$scope.options.key];
- // }
- });
- }, 1000);
- }
- }]
- });
- //无上传按钮附件上传组件
- formlyConfigProvider.setType({
- name: 'ui-dropfilenotup',
- templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', 'FileUploader', '$rootScope', '$ionicPopup', function($scope, FileUploader, $rootScope, $ionicPopup) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- // fn: function(item /*{File|FileLikeObject}*/ , options) {
- // return this.queue.length < 10;
- // },
- fn: function(item /*{File|FileLikeObject}*/ , options) {
- var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
- if (item.size > 10 * 1024 * 1024) {
- $ionicPopup.alert({
- title: '图片超过了10M',
- okText: '确认'
- });
- }
- if ('|jpg|png|jpeg|'.indexOf(type) == -1) {
- $ionicPopup.alert({
- title: '图片格式错误',
- okText: '确认'
- });
- }
- return '|jpg|png|jpeg|'.indexOf(type) !== -1 && item.size < 10 * 1024 * 1024;
- // return '|jpg|png|jpeg|'.indexOf(type) !== -1 && this.queue.length < 3;
- },
- // fn: function(item, options) { return this.queue.length < 4; }
- });
- $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.uploadAttachment(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function(item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function(fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- }]
- });
- //无按钮知识库上传
- formlyConfigProvider.setType({
- name: 'ui-dropfielkn',
- templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', function($scope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function(item /*{File|FileLikeObject}*/ , options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function(item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function(fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- }]
- });
- //附件上传列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropfile',
- templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', '$rootScope', function($scope, $rootScope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function(item /*{File|FileLikeObject}*/ , options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.uploadAttachment(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function(item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function(fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- }]
- });
- //知识库附件上传
- formlyConfigProvider.setType({
- name: 'ui-dropfielknow',
- templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', '$rootScope', function($scope, $rootScope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function(item /*{File|FileLikeObject}*/ , options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': $scope.model.knowledge.id });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function(item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function(fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- }]
- });
- //知识库附件下载列表
- formlyConfigProvider.setType({
- name: 'ui-dropfileknowledge',
- templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function(APIService, contentId, data) {
- return APIService.fetchDataList(contentId, data);
- },
- downloadUri: function(APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- download: function(APIService, contentId) {
- return APIService.getSolutionDowpath(contentId);
- },
- view: function(attachmentId) {
- // return APIService.attachmentsPreviewUrl(contentId);
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$rootScope', 'api_solution', '$http', function($scope, $timeout, $rootScope, api_solution, $http) {
- var _refreshDelayPromise;
- $scope.downloadUrl = function(contentId) {
- return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
- };
- $scope.download = function(contentId, filename) {
- $http({
- url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- console.log(data);
- });
- }
- $scope._refresh = function(refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function() {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- 'file', { "file": { "solutionId": $scope.model.knowledge.id }, "idx": "0", "sum": "1000" }).then(function(response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.list;
- $scope.view = function(attachmentId) {
- for (var i = 0; i < $scope.attachments.length; i++) {
- if ($scope.attachments[i].id == attachmentId) {
- window.open($scope.attachments[i].previewUrl);
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
- // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
- // }
- // });
- }
- }
- };
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- //附件下载列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropfiletable',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function(APIService, processInstanceId, data) {
- return APIService.listAttachments(processInstanceId, data);
- },
- downloadUri: function(APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- view: function(APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function(APIService, contentId, item) {
- var item = { 'url': APIService.download(contentId), 'headers': headers };
- return item;
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$rootScope', '$http', '$ionicPopup', function($scope, $timeout, $rootScope, $http, $ionicPopup) {
- var _refreshDelayPromise;
- // $scope.downloadUrl = function(contentId){
- // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
- // };
- // $scope.download = function(contentId, filename) {
- $scope.download = function(item) {
- // var headers=
- // $(document).click(function(e) { // 在页面任意位置点击而触发此事件
- // var eId = $(e.target).attr("id"); // e.target表示被点击的目标
- // console.log(eId)
- // });
- // var element = angular.element("#ui-dropfiletable-download");
- // console.log(element)
- $http({
- url: $scope.options.templateOptions.ApiService.download(item.contentId).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- // $(document).click(function(e) { // 在页面任意位置点击而触发此事件
- // var eId = $(e.target).attr("id"); // e.target表示被点击的目标
- // console.log(eId)
- // });
- // var src = window.URL.createObjectURL(data);
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- // var file1 = new Blob(data);
- var src = window.URL.createObjectURL(file);
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file).replace('blob:', '');
- // fileURL.replace('blob:', '');
- window.open(fileURL);
- // var a = document.createElement('a');
- // a.href = fileURL;
- // a.target = '_blank';
- // // a.download = filename;
- // document.body.appendChild(a);
- // a.click();
- // a.id = 'ui-dropfiletable-download-a';
- // if (!document.getElementById('ui-dropfiletable-download-a')) {
- // document.getElementById('ui-dropfiletable-download').appendChild(a);
- // // document.body.appendChild(a);
- // }
- // document.body.appendChild(a);
- // if (!$("#ui-dropfiletable-download-a")) {
- // $("#ui-dropfiletable-download").append(a);
- // }
- // if (document.getElementById('ui-dropfiletable-download-a')) {
- // document.getElementById('ui-dropfiletable-download-a').click();
- // }
- // if ($("#ui-dropfiletable-download-a")) {
- // $("#ui-dropfiletable-download-a").click(function() {
- // alert('ui-dropfiletable-download-a');
- // });
- // }
- // if ($("#ui-dropfiletable-download-a")) {
- // console.log($("#ui-dropfiletable-download-a").attr("id"));
- // $("#ui-dropfiletable-download-a").text('12345')
- // // $("#ui-dropfiletable-download-a").click();
- // }
- }).error(function(data, status, headers, config) {
- // console.log(data);
- });
- // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
- // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
- // var file = new Blob([response], {
- // type : 'application/octet-stream'
- // });
- // // var filename = filename;
- // //var file = new Blob([response], {type: 'application/pdf'});
- // var fileURL = URL.createObjectURL(file);
- // var a = document.createElement('a');
- // a.href = fileURL;
- // a.target = '_blank';
- // a.download = filename ;
- // document.body.appendChild(a);
- // a.click();
- // })
- };
- // $scope.view = function(contentId) {
- // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
- // if (response.state == 200) {
- // window.open(response.previewUrl);
- // }
- // })
- // };
- $scope.view = function(item) {
- if (item.type == 'jpg' || item.type == 'png' || item.type == 'gif') {
- // $http({
- // url: $scope.options.templateOptions.ApiService.download(item.id).getRequestedUrl(),
- // method: 'GET',
- // headers: {
- // //'Content-type' : 'application/xls',
- // 'Accept': '*/*'
- // },
- // responseType: 'arraybuffer'
- // }).success(function(data, status, headers, config) {
- // var file = new Blob([data], {
- // type: 'application/octet-stream'
- // });
- // //trick to download store a file having its URL
- // var img = document.createElement("img");
- // img.onload = function(e) {
- // window.URL.revokeObjectURL(img.src);
- // };
- // // img.src = window.URL.createObjectURL(blob);
- // img.src = window.URL.createObjectURL(file);
- // document.body.appendChild(img);
- // }).error(function(data, status, headers, config) {
- // // console.log(data);
- // });
- $scope.imgUrl = $scope.options.templateOptions.ApiService.download(item.id).getRequestedUrl();
- // $scope.imgShow = true;
- $ionicPopup.alert({
- // template: '<img src="http://115.156.150.70:8080/service/api/bpm/bpm/getAttachmentContent/675069" alt="" ng-src="{{imgUrl}}">',
- // template: '<div>123{{$parent}}</div>',
- template: "<img src=" + $scope.imgUrl + " style='width: 100%;'>",
- okText: '确认'
- })
- } else {
- $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, item.id).then(function(response) {
- if (response.state == 200) {
- window.open(response.previewUrl);
- }
- })
- }
- };
- /**
- * refresh
- */
- $scope._refresh = function(refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function() {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, { 'idx': 0, 'sum': 1000 }).then(function(response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- //微信附件下载列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropfilewechat',
- templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- // refresh: function(APIService, processInstanceId, data) {
- // return APIService.listAttachments(processInstanceId, data);
- // },
- // downloadUri: function(APIService, contentId) {
- // return APIService.downloadAttachment(contentId).getRequestedUrl();
- // },
- view: function(APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- // download: function(APIService, contentId, item) {
- // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
- // return item;
- // },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function($scope, $timeout, $stateParams, $rootScope, $http, api_wechatfile) {
- var _refreshDelayPromise;
- // $scope.downloadUrl = function(contentId){
- // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
- // };
- $scope.attachments = {};
- $scope.download = function(token, filename) {
- // var headers=
- $http({
- url: $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- // console.log(data);
- });
- };
- $scope.view = function(contentId) {
- $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
- if (response.state == 200) {
- window.open(response.previewUrl);
- }
- })
- };
- /**
- * refresh
- */
- $scope._refresh = function(refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function() {
- // console.log(JSON.parse($stateParams.model))
- var incidentChart = {};
- if ($stateParams.model) {
- incidentChart = JSON.parse($stateParams.model).model;
- }
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.model).then(function(response) {
- // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- // incidentChart.incident.type, incidentChart.flow).then(function(response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- formlyConfigProvider.setType({
- name: 'ui-paralleltask',
- templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- refresh: function(APIService, processInstanceId, data) {
- //return APIService.listAttachments(processInstanceId, data);
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', function($scope, $timeout) {}]
- });
- //repeatSection
- //
- formlyConfigProvider.setType({
- name: 'ui-repeatSection',
- templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- unique: 1,
- initDisplay: false
- }
- };
- },
- controller: function($scope) {
- //$scope.options.templateOptions.unique;
- $scope.formOptions = { formState: $scope.formState };
- $scope.addNew = addNew;
- $scope.copyFields = copyFields;
- function copyFields(fields) {
- fields = angular.copy(fields);
- addRandomIds(fields);
- return fields;
- }
- function addNew() {
- $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
- var repeatsection = $scope.model[$scope.options.key];
- var lastSection = repeatsection[repeatsection.length - 1];
- var newsection = {};
- repeatsection.push(newsection);
- }
- function addRandomIds(fields) {
- $scope.options.templateOptions.unique++;
- angular.forEach(fields, function(field, index) {
- if (field.fieldGroup) {
- addRandomIds(field.fieldGroup);
- return; // fieldGroups don't need an ID
- }
- if (field.templateOptions && field.templateOptions.fields) {
- addRandomIds(field.templateOptions.fields);
- }
- field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
- });
- }
- function getRandomInt(min, max) {
- return Math.floor(Math.random() * (max - min)) + min;
- }
- if ($scope.options.templateOptions.initDisplay) {
- addNew();
- }
- }
- });
- //时间轴任务列表组件
- // //主题控件
- // formlyConfigProvider.setType({
- // name: 'ui-titlesearch',
- // templateUrl: 'assets/views/customform/tpl/ui-knowledge.html',
- // extends: 'input',
- // templateUrl : 'assets/views/system/tpl/asideContent.html',
- // defaultOptions:function(options){
- // return {
- // };
- // },
- // controller: ['$scope','$aside',function($scope,$aside){
- // $scope.openAside = function (position) {
- // $aside.open({
- // templateUrl: 'asideContent.html',
- // placement: position,
- // size: 'sm',
- // backdrop: true,
- // controller: function ($scope, $modalInstance) {
- // $scope.ok = function (e) {
- // $modalInstance.close();
- // e.stopPropagation();
- // };
- // $scope.cancel = function (e) {
- // $modalInstance.dismiss();
- // e.stopPropagation();
- // };
- // }
- // });
- // };
- // }]
- // })
- //知识库按钮组件
- formlyConfigProvider.setType({
- name: 'ui-search',
- templateUrl: 'assets/views/customform/tpl/ui-knowledge.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- search: function(size, options, modal, keys, fields, el) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/search-knowledge.html',
- controller: function($rootScope, $scope, $modalInstance, searchKey, title, Restangular, APIService, modelscope, relatedAction) {
- $scope.options = {
- language: 'zh-cn',
- allowedContent: true,
- entities: false
- };
- $scope.onReady = function() {
- // ...
- };
- $scope.searchKey = searchKey;
- $scope.search = function(key) {
- // var datas={'key':key}
- APIService.searchSolutionByKey(key, $rootScope.user.id).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- // var status=myData.status;
- // if(status=="500"){
- // //toaster.pop('warning', '没有数据', '查询'+keys+'没有数据');
- // }else
- if (myData && myData.length > 0) {
- var data = myData;
- if (data.length > 0) {
- $scope.searchData = data;
- }
- }
- });
- };
- $scope.related = function(item) {
- // angular.forEach(fields, function(field){
- // if(field.key == 'directClose'){
- // field.value(true);
- // modelscope.$parent.$parent.$parent.model['start_code']='close';
- // }
- // if(field.key == 'handleDescription'){
- // field.model['handleDescription']=tentity.content;
- // }
- // });
- if (relatedAction && angular.isFunction(relatedAction)) {
- relatedAction(fields, modelscope, item);
- }
- $scope.cancel();
- // angular.forEach(fields,function(field){
- // });
- }
- $scope.title = title;
- $scope.search(searchKey);
- $scope.selected = {
- item: {}
- };
- $scope.ok = function() {
- //console.log($scope.selected.item);
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- searchKey: function() {
- return keys;
- },
- title: function() {
- return options.templateOptions.modalTitle;
- },
- Restangular: function() {
- return options.templateOptions.Restangular;
- },
- APIService: function() {
- return options.templateOptions.ApiService;
- },
- modelscope: function() {
- return el.$parent;
- },
- relatedAction: function() {
- return options.templateOptions.relationAction;
- }
- }
- });
- // modalInstance.result.then(function(selectedItem) {
- // options.value(selectedItem);
- // }, function() {
- // //console.log('Modal dismissed at: ' + new Date());
- // });
- }
- }
- };
- },
- controller: ['$scope', function($scope) {
- // $scope.searchModal = $scope.model[$scope.options.key];
- // $scope.$watch('searchModal',function(newValue, oldValue){
- // if (newValue === oldValue) { return; }
- // if (newValue.flag == oldValue.flag) { return; }
- // if (angular.isDefined(newValue.flag)&&(newValue.flag==true)){
- // if (newValue.searchKey!=''&&angular.isDefined(newValue.searchKey)){
- // $scope.options.templateOptions.search('lg',$scope.options,newValue.searchKey);
- // }
- // }
- // })
- //
- }]
- });
- //cmdb控件
- formlyConfigProvider.setType({
- name: 'ui-cmdb',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
- defaultOptions: function(options) {
- return {
- templateOptions: {
- onClick: function(size, options, modal, event, model) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
- controller: function($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster) {
- var width = $scope.width = 600;
- var height = $scope.height = 400;
- var tree;
- var d3 = window.d3;
- $scope.my_tree_handler = function(branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- APIService.query({ 'sign': classify }).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- console.log(myData.data.node);
- if (myData.data && myData.status == 200) {
- var ret = myData.data;
- redrawSvg(myData);
- }
- });
- };
- $scope.my_data = [];
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function(item) {
- list.push(item);
- });
- return list;
- }
- $scope.my_tree = tree = {};
- $scope.try_async_load = function() {
- $scope.my_data = [];
- $scope.select_treedata = [];
- $scope.doing_async = true;
- ConfigDataService.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
- $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- $scope.doing_async = false;
- });
- };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.try_async_load();
- $scope.onFilterCallback = function(item) {
- //console.log(item);
- if (angular.isDefined(item.children) && item.children.length >= 1) {
- //not valid
- } else {
- var tempclassify = item.prefix.toLowerCase() + item.sign;
- $scope.cifilter_classic = tempclassify;
- ConfigFormService.renderTabForm(tempclassify).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.propTypeOptions = myData;
- });
- }
- }
- $scope.onPropTypeChange = function(form) {
- $scope.propOptions = form.fields;
- }
- $scope.onPropChange = function(prop) {
- $scope.cifilter_prop = prop;
- }
- $scope.searchCI = function(searchKey, propObj, ciclassify) {
- //if(searchKey!=null&&searchKey.length>1){
- var searchData = {};
- if (angular.isUndefined(propObj)) {
- propObj = $scope.cifilter_prop;
- }
- if (angular.isUndefined(ciclassify)) {
- ciclassify = $scope.cifilter_classic;
- }
- searchData['sign'] = ciclassify;
- if (angular.isDefined(propObj)) {
- searchData[propObj.key] = searchKey;
- }
- APIService.query(searchData).then(function(response) {
- var data = Restangular.stripRestangular(response);
- //此处不清空nodes
- var node = data.data.node;
- var tempNode = [];
- //nodes 或者links 要去重
- for (var i = 0; i < node.length; i++) {
- var tmp = 0;
- for (var j = 0; j < nodes.length; j++) {
- if (node[i].uuid == nodes[j].uuid) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempNode.push(node[i]);
- }
- }
- for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
- nodes.push(tempNode[i]);
- }
- restart();
- })
- }
- $scope.refresh = function() {
- nodes.length = 0;
- links.length = 0;
- restart();
- }
- $scope.traversal = function() {
- if ($scope.selected_node == null) {
- // SweetAlert.swal({
- // title: "错误的操作!",
- // text: "没有配置项被选中!",
- // type: "error"
- // });
- $ionicPopup.alert({
- title: '没有配置项被选中!',
- okText: '确认'
- });
- } else {
- var uuid = $scope.selected_node.uuid;
- APIService.traversal(uuid).then(function(response) {
- var d = response.data;
- var node = d.node;
- var link = d.edge;
- var tempNode = [];
- var tempLink = [];
- //nodes 或者links 要去重
- for (var i = 0; i < node.length; i++) {
- var tmp = 0;
- for (var j = 0; j < nodes.length; j++) {
- if (node[i].id == nodes[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempNode.push(node[i]);
- }
- }
- for (var i = 0; i < link.length; i++) {
- var tmp = 0;
- for (var j = 0; j < links.length; j++) {
- if (link[i].id == links[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempLink.push(link[i]);
- }
- }
- //数据写入页面
- for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
- nodes.push(tempNode[i]);
- }
- for (var i = 0; i < tempLink.length; i++) { //link 不清空
- links.push(tempLink[i]);
- }
- //links转换
- for (var i = 0; i < links.length; i++) {
- for (var j = 0; j < nodes.length; j++) {
- if (links[i].source == nodes[j].id) {
- links[i].source = nodes[j];
- }
- if (links[i].target == nodes[j].id) {
- links[i].target = nodes[j];
- }
- }
- }
- restart();
- })
- }
- }
- var svg;
- var force;
- var drag_line, path, circle;
- //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
- //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
- //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
- var nodes = [],
- links = [];
- var treeNodes = [];
- //读取labels (node)
- var labels = [];
- function redrawSvg(json) {
- nodes.length = 0; //先清空
- links.length = 0;
- var data = json.data;
- for (var i = 0; i < data.node.length; i++) {
- nodes.push(data.node[i]);
- }
- restart();
- }
- //读取status (节点 连线)
- var statuses = [];
- ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
- if (result && result.status == 200) {
- d3.select('#nodeStatus').selectAll('option')
- .data(statuses).enter()
- .append('option')
- .attr('value', function(d) { return d.code; })
- .html(function(d) { return d.desc; });
- } else {
- // SweetAlert.swal({
- // title: "提示!",
- // text: "服务器请求异常!",
- // type: "error"
- // });
- $ionicPopup.alert({
- title: '服务器请求异常!',
- okText: '确认'
- });
- }
- });
- //查询relationship_type表 name 为表里的type,label为显示值
- var linkType = [];
- function fetchEdgeTypes() {
- ConfigDataService.fetchDataList('ciedgetype', { 'idx': 0, 'sum': 100 }).then(function(response) {
- if (response) {
- if (response['list']) {
- linkType = response['list'];
- // d3.select('#linkName').selectAll('option')
- // .data(linkType).enter()
- // .append('option')
- // .attr('value',function(d){return d.type;})
- // .html(function(d){ return d.label;});
- } else {
- // SweetAlert.swal({
- // title: "提示!",
- // text: "服务器请求异常!",
- // type: "error"
- // });
- $ionicPopup.alert({
- title: '服务器请求异常!',
- okText: '确认'
- });
- }
- } else {
- // SweetAlert.swal({
- // title: "提示!",
- // text: "服务器请求异常!",
- // type: "error"
- // });
- $ionicPopup.alert({
- title: '服务器请求异常!',
- okText: '确认'
- });
- }
- })
- }
- fetchEdgeTypes();
- /*
- // init D3 force layout
- var force = d3.layout.force()
- .nodes(nodes)
- .links(links)
- .size([width, height])
- .gravity(.05)
- .linkDistance(150)
- .linkStrength(2)
- .charge(-500)
- .on('tick', tick);
- // define arrow markers for graph links
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'end-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 6)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M0,-5L10,0L0,5')
- .attr('fill', '#000');
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'start-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 4)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M10,-5L0,0L10,5')
- .attr('fill', '#000');
- // line displayed when dragging new nodes
- var drag_line = svg.append('svg:path')
- .attr('class', 'link dragline hidden')
- .attr('d', 'M0,0L0,0');
- // handles to link and node element groups
- //(1)var path = svg.append('svg:g').selectAll('g')
- var path = svg.append('svg:g').selectAll('g'),
- circle = svg.append('svg:g').selectAll('g');
- */
- // mouse event vars
- var selected_node = null,
- selected_link = null,
- mousedown_link = null,
- mousedown_node = null,
- mouseup_node = null;
- function resetMouseVars() {
- mousedown_node = null;
- mouseup_node = null;
- mousedown_link = null;
- }
- // update force layout (called automatically each iteration)
- function tick() {
- // draw directed edges with proper padding from node centers
- path.selectAll('path').attr('d', function(d) {
- var deltaX = d.target.x - d.source.x,
- deltaY = d.target.y - d.source.y,
- dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
- normX = deltaX / dist,
- normY = deltaY / dist,
- sourcePadding = d.left ? 27 : 22,
- targetPadding = d.right ? 27 : 22,
- sourceX = d.source.x + (sourcePadding * normX),
- sourceY = d.source.y + (sourcePadding * normY),
- targetX = d.target.x - (targetPadding * normX),
- targetY = d.target.y - (targetPadding * normY);
- return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
- });
- circle.attr('transform', function(d) {
- return 'translate(' + d.x + ',' + d.y + ')';
- });
- }
- // update graph (called when needed)
- function restart() {
- //绑定link 数据
- path.datum(links);
- // path (link) group
- path = path.data(links, function(d) { return d.id; });
- var p = path.enter().append('svg:g');
- //update existing links
- path.selectAll('path').classed('selected', function(d) { return d === selected_link; })
- .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
- .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; });
- // add new links
- p.append('svg:path')
- .attr('class', 'link')
- .attr('id', function(d) { return "path_" + d.id; })
- // .attr('startOffset', '0%')
- .classed('selected', function(d) { return d === selected_link; })
- .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
- .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; })
- .on('mousedown', function(d) {
- if (d3.event.ctrlKey) return;
- //去除没有提交的连线
- for (var i = 0; i < links.length; i++) {
- if (links[i].id == -1 && d.id != -1) {
- links.splice(i, 1);
- }
- }
- // select link
- mousedown_link = d;
- if (mousedown_link === selected_link) {
- selected_link = $scope.selected_link = null;
- selected_node = $scope.selected_node = null;
- // d3.select("#linkDetail").attr('style','display:none');
- //hideLinkForm(true);//return ;
- } else {
- selected_link = $scope.selected_link = mousedown_link;
- selected_node = $scope.selected_node = null;
- }
- selected_node = $scope.selected_node = null;
- restart();
- });
- p.append('svg:text')
- .attr('x', 30)
- .attr('y', 20)
- .attr('class', 'fontM')
- .append('textPath')
- .attr('xlink:xlink:href', function(d, i) { return "#path_" + d.id; })
- .html(function(d) {
- for (var i = 0; i < linkType.length; i++) {
- if (linkType[i].type == d.name) {
- return linkType[i].label;
- }
- }
- });
- // remove old links
- path.exit().remove();
- // circle (node) group
- // NB: the function arg is crucial here! nodes are known by id, not by index!
- circle.datum(nodes);
- circle = circle.data(nodes, function(d) { return d.id; });
- // update existing nodes (reflexive & selected visual states)
- circle.selectAll('circle')
- .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
- .style('fill-opacity', 0.75) // add by xi
- .classed('reflexive', function(d) { return d.reflexive; });
- // add new nodes
- var g = circle.enter().append('svg:g');
- //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
- //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');
- g.append('svg:circle').attr('r', 24).style('fill', function(d) { return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)'; }).style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); }).style('stroke-width', '2');
- g.append('svg:circle')
- .attr('class', 'node')
- .attr('r', 18)
- .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
- .style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); })
- .style('fill-opacity', 0.25) //add by xj
- .style('stroke-opacity', 0.5) //add by xj
- .classed('reflexive', function(d) { return d.reflexive; });
- g.on('mouseover', function(d) {
- //if(!mousedown_node || d === mousedown_node) return;
- // enlarge target node
- //d3.select(this).attr('transform', 'scale(1.1)');
- })
- .on('mouseout', function(d) {
- //if(!mousedown_node || d === mousedown_node) return;
- // unenlarge target node
- //d3.select(this).attr('transform', '');
- })
- .on('mousedown', function(d) {
- if (d3.event.ctrlKey) return;
- //hideLinkForm(true);
- //去除没有提交的连线
- for (var i = 0; i < links.length; i++) {
- if (links[i].id == -1) {
- links.splice(i, 1);
- }
- }
- // select node
- mousedown_node = d;
- if (mousedown_node === selected_node) {
- selected_node = $scope.selected_node = null;
- } else {
- selected_node = $scope.selected_node = mousedown_node;
- selected_link = $scope.selected_link = null;
- // 点击节点 查询关系及节点 /traversal/{id}/{relation}
- APIService.findRefById(selected_node.id).then(function(result) {
- var d = result.data;
- var node = d.node;
- var link = d.edge;
- var tempNode = [];
- var tempLink = [];
- //nodes 或者links 要去重
- for (var i = 0; i < node.length; i++) {
- var tmp = 0;
- for (var j = 0; j < nodes.length; j++) {
- if (node[i].id == nodes[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempNode.push(node[i]);
- }
- }
- for (var i = 0; i < link.length; i++) {
- var tmp = 0;
- for (var j = 0; j < links.length; j++) {
- if (link[i].id == links[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempLink.push(link[i]);
- }
- }
- //数据写入页面
- for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
- nodes.push(tempNode[i]);
- }
- for (var i = 0; i < tempLink.length; i++) { //link 不清空
- links.push(tempLink[i]);
- }
- //links转换
- for (var i = 0; i < links.length; i++) {
- for (var j = 0; j < nodes.length; j++) {
- if (links[i].source == nodes[j].id) {
- links[i].source = nodes[j];
- }
- if (links[i].target == nodes[j].id) {
- links[i].target = nodes[j];
- }
- }
- }
- restart();
- });
- }
- // reposition drag line
- drag_line
- .style('marker-end', 'url(#end-arrow)')
- .classed('hidden', false)
- .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
- restart();
- })
- .on('mouseup', function(d) {
- if (!mousedown_node) return;
- });
- // show node name
- g.append('svg:text')
- .attr('x', 0)
- .attr('y', 34)
- .attr('class', 'id')
- .text(function(d) { return d.name; }); //TODO 改为 d.name
- //设置图片
- g.append('svg:foreignObject')
- .attr("width", 32)
- .attr("height", 32)
- .attr('x', "-16px")
- .attr('y', "-11px")
- .html(function(d) {
- for (var i = 0; i < labels.length; i++) {
- if (d.label == labels[i].sign) {
- return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
- }
- }
- });
- // remove old nodes
- circle.exit().remove();
- // set the graph in motion
- force.start();
- }
- function mousedown() {
- // prevent I-bar on drag
- //d3.event.preventDefault();
- // because :active only works in WebKit?
- svg.classed('active', true);
- if (mousedown_node) {
- viewNode(mousedown_node);
- }
- if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
- restart();
- }
- function mousemove() {
- if (!mousedown_node) return;
- // update drag line
- //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
- //restart();
- }
- function mouseup() {
- if (mousedown_node) {
- // hide drag line
- drag_line
- .classed('hidden', true)
- .style('marker-end', '');
- }
- // because :active only works in WebKit?
- svg.classed('active', false);
- // clear mouse event vars
- resetMouseVars();
- }
- function spliceLinksForNode(node) {
- var toSplice = links.filter(function(l) {
- return (l.source === node || l.target === node);
- });
- toSplice.map(function(l) {
- links.splice(links.indexOf(l), 1);
- });
- }
- // only respond once per keydown
- var lastKeyDown = -1;
- function keydown() {
- //d3.event.preventDefault();
- if (lastKeyDown !== -1) return;
- lastKeyDown = d3.event.keyCode;
- // ctrl
- if (d3.event.keyCode === 17) {
- circle.call(force.drag);
- svg.classed('ctrl', true);
- }
- if (!selected_node && !selected_link) return;
- switch (d3.event.keyCode) {
- case 8: // backspace
- case 66: // B
- if (selected_link) {
- // set link direction to both left and right
- selected_link.left = true;
- selected_link.right = true;
- }
- restart();
- break;
- case 76: // L
- if (selected_link) {
- // set link direction to left only
- selected_link.left = true;
- selected_link.right = false;
- }
- restart();
- break;
- case 82: // R
- if (selected_node) {
- // toggle node reflexivity
- selected_node.reflexive = !selected_node.reflexive;
- } else if (selected_link) {
- // set link direction to right only
- selected_link.left = false;
- selected_link.right = true;
- }
- restart();
- break;
- }
- }
- function keyup() {
- lastKeyDown = -1;
- // ctrl
- if (d3.event.keyCode === 17) {
- circle
- .on('mousedown.drag', null)
- .on('touchstart.drag', null);
- svg.classed('ctrl', false);
- }
- }
- function viewNode(node) {
- console.log(svg.attr('left'));
- //var el = angular.element('div.modal-dialog')[0];
- var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
- if (!$scope.selected_node.props.state) { $scope.selected_node.props.state = "空" } else if ($scope.selected_node.props.state) {
- if ($scope.selected_node.props.state == "1") { $scope.selected_node.props.state = "未审核" } else if ($scope.selected_node.props.state == "2") { $scope.selected_node.props.state = "已审核" } else if ($scope.selected_node.props.state == "3") { $scope.selected_node.props.state = "不匹配" } else if ($scope.selected_node.props.state == "4") { $scope.selected_node.props.state = "丢失" }
- };
- if (!$scope.selected_node.name) { $scope.selected_node.name = "空" }
- if (!$scope.selected_node.status) { $scope.selected_node.statu = "空" }
- if (!$scope.selected_node.props.useradmin) { $scope.selected_node.props.useradmin = "空" }
- Toaster.pop({
- // type: 'info',
- // title: title,
- body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
- '<p>配置标题:' + $scope.selected_node.name + '</p>' +
- '<p>状态:' + $scope.selected_node.status + '</p>' +
- '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
- '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
- bodyOutputType: 'trustedHtml',
- timeout: 3000
- })
- }
- //GT 颜色与数值对照表
- function colors(sign) {
- //num=num>20?num%20:parseInt(num);
- for (var i = 0; i < labels.length; i++) {
- var entity = labels[i];
- if (sign == entity.sign) {
- return entity.color;
- }
- if (i == labels.length - 1 && sign != entity.sign) {
- return '#ffeeee';
- }
- }
- }
- $scope.init = function() {
- svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
- // init D3 force layout
- force = d3.layout.force()
- .nodes(nodes)
- .links(links)
- .size([width, height])
- .gravity(.05)
- .linkDistance(150)
- .linkStrength(2)
- .charge(-500)
- .on('tick', tick);
- // define arrow markers for graph links
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'end-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 6)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M0,-5L10,0L0,5')
- .attr('fill', '#000');
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'start-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 4)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M10,-5L0,0L10,5')
- .attr('fill', '#000');
- // line displayed when dragging new nodes
- drag_line = svg.append('svg:path')
- .attr('class', 'link dragline hidden')
- .attr('d', 'M0,0L0,0');
- // handles to link and node element groups
- //(1)var path = svg.append('svg:g').selectAll('g')
- path = svg.append('svg:g').selectAll('g');
- circle = svg.append('svg:g').selectAll('g');
- svg.on('mousedown', mousedown)
- .on('mousemove', mousemove)
- .on('mouseup', mouseup);
- d3.select(window)
- .on('keydown', keydown)
- .on('keyup', keyup);
- }
- var CI = {};
- window.CI = CI;
- $scope.ok = function() {
- $modalInstance.close($scope.selected_node);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- title: function() {
- return options.templateOptions.title;
- },
- Restangular: function() {
- return options.templateOptions.Restangular;
- },
- APIService: function() {
- return options.templateOptions.ApiService;
- },
- ConfigDataService: function() {
- return options.templateOptions.ConfigDataService;
- },
- ConfigFormService: function() {
- return options.templateOptions.ConfigFormService;
- },
- SweetAlert: function() {
- return options.templateOptions.Alert;
- },
- Toaster: function() {
- return options.templateOptions.toaster;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- options.value(selectedItem.name + '-' + selectedItem.uuid);
- }, function() {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- }
- },
- controller: ['$scope', function($scope) {
- // setTimeout(function(){
- // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
- // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- // if(modelData.status==200){
- // $scope.model[$scope.options.key] = modelData.data;
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- // }
- // });
- // },1000);
- }]
- });
- });
- appFormly.run(function(formlyConfig, $parse) {
- //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
- var removeOnHideTransformer = function(fields, model) {
- return fields.map(function(field) {
- if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
- addFieldRemoveOnHideWatcher(field);
- }
- if (field.type == "ui-title") {
- addFieldRemoveOnHideWatcher(field);
- }
- return field;
- });
- };
- formlyConfig.extras.fieldTransform = removeOnHideTransformer;
- function addFieldRemoveOnHideWatcher(field) {
- var watcher = getWatcher();
- if (field.watcher) {
- if (!angular.isArray(field.watcher)) {
- field.watcher = [field.watcher];
- }
- field.watcher.push(watcher);
- } else {
- field.watcher = watcher;
- }
- }
- function getWatcher() {
- return {
- expression: function(field) {
- return field.hide;
- },
- listener: function(field, newHide, oldHide, scope) {
- if (field.hide) {
- if (field.templateOptions.pkey) {
- if (field.key == 'transferuser') {
- $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
- }
- } else {
- $parse(field.key).assign(scope.model, undefined);
- }
- }
- if (field.type == "ui-title") {
- $parse(field.key).assign(scope.model, undefined);
- }
- }
- };
- }
- });
- appFormly.controller('customFormIndexCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$timeout', '$interval', '$ionicPopup', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'WechatRestangular',
- function($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $timeout, $interval, $ionicPopup, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, WechatRestangular) {
- //console.log($parse('Restangular')($scope));
- //console.log($injector.get('Restangular'));
- //console.log($stateParams);
- // console.log('customFormIndexCtrl is loading');
- // alert(location.href);
- var vm = this;
- // $scope.vm = vm;
- vm.options = {};
- vm.exampleTitle = ['expressionProperties', 'model property'];
- vm.fields = [];
- vm.model = {};
- // $scope.langs = i18nService.getAllLangs();
- // $scope.lang = 'zh-cn';
- // i18nService.setCurrentLang($scope.lang);
- //alert($rootScope.user.id,null,2);
- //获取login中的数据
- var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
- var loginUser = sessionLogin.user;
- $rootScope.user = loginUser;
- // angular.extend(loginUser, {
- // areaDTO: {
- // 'area': '西区',
- // 'id': 3
- // },
- // placeDTO: {
- // 'place': '西区',
- // 'id': 5
- // },
- // houseNumber: 103,
- // mphone: '123456789'
- // });
- // vm.model["loginUser"] = $rootScope.user;
- // vm.model["loginUser"] = loginUser;
- var that = $injector;
- var parse = $parse;
- var formKey = "";
- var pdKey = "";
- var modelWatch = "";
- $scope.goBack = function() {
- history.go(-1);
- };
- if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- modelWatch = JSON.parse($stateParams.model);
- // console.log("modelWatch:"+ JSON.stringify(modelWatch));
- }
- if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
- pdKey = $state.current.pdKey;
- } else if ($stateParams.pdKey) {
- pdKey = $stateParams.pdKey;
- }
- // console.log("pdKey::" + JSON.stringify($state.current.title));
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- formKey = $stateParams.formKey;
- // console.log("formKey::"+JSON.stringify($stateParams.formKey));
- }
- if (angular.isDefined($stateParams.model)) {
- var formModel = $stateParams.model;
- }
- //用户测试数据,后续从header的auth中获取
- // var userId = 2;
- var userId = $rootScope.user.id;
- // userId = loginUser.id;
- //==============处理表单设计数据 开始====================
- //处理组件加载后台数据选项的方法
- // function refreshSelectOptions(searchVal, field) {
- // if (field.templateOptions.optionsUrl) {
- // var process = BpmRestangular.all("");
- // if (field.templateOptions.ApiService) {
- // process = UserRestangular.all("");
- // }
- // process.customPOST({ "idx": 0, "sum": 1000 }, field.templateOptions.optionsUrl).then(function(result) {
- // if (!field.templateOptions.options) {
- // field.templateOptions.options = [];
- // }
- // if (field.templateOptions.optionsDataKey) {
- // field.templateOptions.options = result[field.templateOptions.optionsDataKey];
- // // field.selectLists = result[field.templateOptions.optionsDataKey];
- // // var lists = result[field.templateOptions.optionsDataKey];
- // // field.templateOptions.list = lists[0].name;
- // } else {
- // field.templateOptions.options = result;
- // }
- // });
- // }
- // }
- function refreshSelectOptions(searchVal, field) {
- if (field.templateOptions.optionsUrl) {
- var process = BpmRestangular.all("");
- if (field.templateOptions.ApiService) {
- process = UserRestangular.all("");
- }
- if (field.templateOptions.Apicommon) {
- process = WechatRestangular.all("");
- }
- var datakey = { "idx": 0, "sum": 1000 };
- if (field.templateOptions.modelreasondata) {
- datakey = field.templateOptions.modelreasondata
- }
- if (field.templateOptions.userSelect) {
- angular.extend(datakey, field.templateOptions.userSelect);
- }
- process.customPOST(datakey, field.templateOptions.optionsUrl).then(function(result) {
- if (!field.templateOptions.options) {
- field.templateOptions.options = [];
- }
- if (field.templateOptions.optionsDataKey) {
- field.templateOptions.options = result[field.templateOptions.optionsDataKey];
- } else {
- field.templateOptions.options = result;
- }
- });
- }
- }
- //解析自定义表单设计数据
- function decodeVMForm(vmForm) {
- var result = { model: {}, fields: [] };
- //设置模型实体数据 begin
- // var mdata = vmForm.model;
- //解析数据实体
- var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
- angular.extend(result.model, mdata);
- if (modelWatch != null && modelWatch != '') {
- //angular.extend(result.model.incident,modelWatch.incident);
- //result.model.alarmType = modelWatch.alarmType;
- // vmForm.cancelUrl = modelWatch.cancelUrl;
- console.log(modelWatch.cancelUrl)
- for (var index in modelWatch.model) {
- //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
- if (result.model[index] != null) {
- angular.extend(result.model[index], modelWatch.model[index]);
- } else {
- result.model[index] = modelWatch.model[index];
- }
- }
- }
- //设置模型实体数据 end
- //解析设计数据生成表单项 begin
- var fields = [];
- //处理修改设计数据中展示设置
- angular.forEach(vmForm.fields, function(field) {
- if (field.key == "") {
- delete field.key;
- }
- if (angular.isDefined(field.extjson)) {
- var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj.templateOptions);
- delete extObj.templateOptions;
- for (var prop in extObj) {
- if (new RegExp("Expression").test(prop)) {
- //var obj = $scope.$eval(extObj[prop]);
- //extObj[prop] = $scope.$eval(extObj[prop]);
- if (extObj[prop] != null) {
- if (new RegExp("function").test(extObj[prop])) {
- var propValue = eval(extObj[prop]);
- extObj[prop] = propValue;
- } else {
- //console.log(extObj[prop]);
- var obj = $scope.$eval(extObj[prop]);
- extObj[prop] = obj;
- //console.log(obj);
- }
- }
- } else if (new RegExp("expressionProperties").test(prop)) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- } else {
- //if(p.indexOf("'")>=0){
- // var obj = $scope.$eval(extObj[prop][p]);
- // extObj[prop][$scope.$eval(p)]=obj;
- //}
- }
- }
- } else if ("watcher" == prop) {
- if (angular.isArray(extObj[prop])) {
- angular.forEach(extObj[prop], function(item, index) {
- for (var p in item) {
- if (new RegExp("function").test(item[p])) {
- var propValue = eval(item[p]);
- extObj[prop][index][p] = propValue;
- }
- }
- });
- } else if (angular.isObject(extObj[prop])) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- }
- }
- }
- }
- }
- angular.extend(field, extObj);
- delete field.extjson;
- }
- if (angular.isDefined(field.templateOptions)) {
- var templateOs = field.templateOptions;
- for (var property in templateOs) {
- //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
- if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
- if (new RegExp("function").test(templateOs[property])) {
- var propValue = eval(templateOs[property]);
- field.templateOptions[property] = propValue;
- } else {
- if (that.has(templateOs[property])) {
- field.templateOptions[property] = that.get(templateOs[property]);
- } else {
- field.templateOptions[property] = templateOs[property];
- }
- }
- } else if (templateOs[property] == null) {
- //delete field.templateOptions[property];
- } else {}
- }
- }
- console.log(field);
- if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
- var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj);
- delete field.templateOptions.extjson;
- }
- // ...
- if (field.templateOptions) {
- //处理远程获取数据控件方法调用
- if (field.templateOptions.optionsUrl) {
- field.templateOptions.refresh = refreshSelectOptions;
- }
- //事件脚本处理
- // if(field.templateOptions.ngChangeScript){
- // if(!field.expressionProperties)field.expressionProperties={};
- // field.expressionProperties.ngChange = function(modelVal,viewVal,ev){
- //// console.log(ev);
- //// console.log("change>>"+ev.options.key);
- // eval(field.templateOptions.ngChangeScript);
- // }
- // }
- // if(field.templateOptions.ngClickScript){
- // if(!field.expressionProperties)field.expressionProperties={};
- // field.expressionProperties.ngClick = function(modelVal,viewVal,ev){
- //// console.log(ev);
- //// console.log("click>>"+ev.options.key);
- // eval(field.templateOptions.ngClickScript);
- // }
- // }
- //处理嵌套属性数据绑定/
- if (field.templateOptions.pkey) {
- var pmodel, i = 0;
- angular.forEach(field.templateOptions.pkey.split("."), function(p) {
- if (i == 0) {
- if (result.model[p] == null) {
- result.model[p] = {};
- }
- pmodel = result.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- if (pmodel != null) {
- field.model = pmodel;
- if (pmodel[field.key] == null) {
- pmodel[field.key] = null;
- }
- }
- } else {
- if (result.model[field.key] == null) {
- result.model[field.key] = null;
- }
- }
- //处理弹出框组件初始化
- if (field.type == "ui-input-selectmodal") {
- // field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-requesterselect") {
- //field.templateOptions.language = $scope.lang;
- // field.templateOptions.modal = $modal;
- field.templateOptions.UserService = api_user_data;
- } else if (field.type == "ui-userselect") {
- // field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-multiuserselect") {
- // field.templateOptions.modal = $modal;
- } else if (field.type == "ui-search") {
- // field.templateOptions.modal = $modal;
- } else if (field.type == "ui-modelselect") {
- // field.templateOptions.modal = $modal;
- //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
- field.templateOptions.loginUser = $rootScope.user;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-incidentmodelselect") {
- // field.templateOptions.modal = $modal;
- //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
- // field.templateOptions.loginUser = $rootScope.user;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-dropfile") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfielknow") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfilenotup") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-dropfiletable") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-repeatSection") {
- var repeatForm = {
- model: {
- },
- fields: field.templateOptions.fields
- };
- repeatForm.model[field.key] = [];
- decodeVMForm(repeatForm);
- } else if (field.type == "ui-currentuser") {
- field.templateOptions.user = vm.model["loginUser"];
- // field.templateOptions.user = $rootScope.user;
- }
- }
- // console.log(field);
- result.fields.push(field);
- });
- angular.extend($scope.vm.fields, result.fields);
- angular.extend($scope.vm.model, result.model);
- // console.log("$scope.vm.model="+JSON.stringify($scope.vm.model));
- vm.model["loginUser"] = $rootScope.user;
- if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
- vmForm.cancelUrl = modelWatch.cancelUrl;
- }
- $scope.formData = vmForm;
- // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
- if ($scope.formData.url == "start") {
- $scope.Reset = true;
- $scope.close = false;
- } else if ($scope.formData.url == "complete") {
- $scope.Reset = false;
- $scope.close = true;
- }
- //解析设计数据生成表单项 end
- return result;
- }
- //======================处理表单设计数据 结束========================
- $scope.ldloading = {};
- function filter(obj) {
- angular.forEach(obj, function(key, value) {
- if (value === "" || value === null) {
- delete obj[key];
- } else if (Object.prototype.toString.call(value) === '[object Object]') {
- filter(value);
- } else if (angular.isArray(value)) {
- angular.forEach(value, function(item) {
- filter(item);
- });
- }
- });
- }
- $scope.closeModel = function() {
- // console.log("pdKey="+pdKey);
- // if ($stateParams.pdKey) {
- // pdKey = $stateParams.pdKey;
- // }
- if (pdKey == "bpm_incident") {
- $state.go('app.incidentMobile.incidentListMobile', {});
- } else if (pdKey == "bpm_change") {
- $state.go('app.change.list', {});
- } else if (pdKey == "bpm_problem") {
- $state.go('app.problem.list', {});
- } else if (pdKey == "bpm_release") {
- $state.go('app.release.list', {});
- } else if (pdKey == "bpm_schedule") {
- $state.go('app.scheduling.list', {});
- } else if (pdKey == "bpm_configure") {
- $state.go('app.cmdb.plist', {});
- } else if (pdKey == "bpm_reService") {
- $state.go('app.reService.manager', {});
- } else if (pdKey == "inspectionListForm") {
- $state.go('app.inspection.inspectList', {});
- } else if (pdKey == "bpm_inspection") {
- $state.go('app.inspection.inspectList', {});
- } else if (pdKey == "bpm_service_request") {
- $state.go('app.reService.manager', {});
- }
- event.preventDefault();
- };
- $scope.save = function(data) {
- api_bpm_domain.save($stateParams.taskId, data).then(function(response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- // SweetAlert.swal({
- // title: "暂存成功!",
- // confirmButtonColor: "#007AFF"
- // }, function() {
- // $state.go($scope.formData.cancelUrl);
- // });
- $ionicPopup.alert({
- title: '暂存成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- // $state.go($scope.formData.cancelUrl);
- });
- } else {
- // SweetAlert.swal({
- // title: "系统错误",
- // text: "系统错误,请稍后重试!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- // $state.go($scope.formData.cancelUrl);
- });
- }
- });
- event.preventDefault();
- }
- vm.submit = function(data, style) {
- // var pdKey = $stateParams.pdKey;
- if (vm.form.$valid) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
- // console.log("vm.options:"+ JSON.stringify(vm.options));
- vm.options.updateInitialValue();
- // console.log("dfjkasdhfkhskjf ")
- var _ = window._;
- vm.model = (function filter(obj) {
- var dateTransKeys = [];
- var filtered = _.pick(obj, function(v, k, obj) {
- if (_.isDate(v)) {
- dateTransKeys.push(k);
- }
- return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
- });
- return _.cloneDeep(filtered, function(v, index, object) {
- if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
- angular.forEach(dateTransKeys, function(item) {
- v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
- })
- dateTransKey = [];
- return v;
- }
- return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
- });
- })(vm.model);
- if (pdKey != "") {
- if ($scope.oprcode == "save") { //保存
- api_bpm_domain.save(taskId, vm.model).then(function(response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- // SweetAlert.swal({
- // title: "保存成功!",
- // confirmButtonColor: "#007AFF"
- // }, function() {
- // $state.go($scope.formData.cancelUri);
- // });
- $ionicPopup.alert({
- title: '保存成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- // $state.go($scope.formData.cancelUrl);
- });
- } else {
- // SweetAlert.swal({
- // title: "系统错误",
- // text: "系统错误,请稍后重试!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- })
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- } else {
- switch ($scope.formData.url) {
- case "start":
- vm.model["initUser"] = $rootScope.user.id;
- if (vm.model["assignee"] || vm.model["candidateGroups"]) {
- } else {
- vm.model["assignee"] = $rootScope.user.id;
- };
- if (pdKey == 'bpm_service_request') {
- delete vm.model.serviceCatalogueProcessActual.houseNumber;
- angular.extend(vm.model.serviceCatalogueProcessActual, {
- 'category': {
- 'id': $stateParams.userId
- }
- });
- };
- if (pdKey == 'weChatApplyStart') {
- if (vm.model.incident && vm.model.incident.placeId && angular.isObject(vm.model.incident.placeId)) {
- vm.model.incident.placeId = vm.model.incident.placeId.id
- }
- api_bpm_domain.weChatApplyStart('', vm.model).then(function(response) {
- if (response && response.state == 200) {
- var resData = Restangular.stripRestangular(response);
- if (resData) {
- // console.log("$scope.fileUploader="+$scope.fileUploader)
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.incident.id) {
- //$scope.uploader.options.url();
- $scope.fileUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, {
- 'access-token': sessionLogin.token,
- });
- //微信上传的用的是微信的事件id
- // item.url = api_bpm_domain.saveAttachments(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.url = api_bpm_domain.uploadAttachment(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({ 'filename': item.file.name });
- console.log($scope.fileUploader);
- };
- $scope.fileUploader.uploadAll();
- }
- }
- // SweetAlert.swal({
- // title: "提交成功!",
- // confirmButtonColor: "#007AFF"
- // }, function() {
- // $state.go($scope.formData.cancelUrl);
- // });
- $ionicPopup.alert({
- title: '提交成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- // $state.go($scope.formData.cancelUrl);
- });
- } else {
- // SweetAlert.swal({
- // title: "系统错误",
- // text: "系统错误,请稍后重试!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- })
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- } else {
- api_bpm_domain.start(pdKey, vm.model).then(function(response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData) {
- // console.log("$scope.fileUploader="+$scope.fileUploader)
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
- //$scope.uploader.options.url();
- $scope.fileUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, {
- 'access-token': sessionLogin.token,
- });
- //微信处理人上传的用的是流程id
- // angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.saveAttachments(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
- // item.url = api_bpm_domain.uploadAttachment(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- //console.log();
- };
- $scope.fileUploader.uploadAll();
- }
- }
- // SweetAlert.swal({
- // title: "提交成功!",
- // confirmButtonColor: "#007AFF"
- // }, function() {
- // $state.go($scope.formData.cancelUrl);
- // });
- $ionicPopup.alert({
- title: '提交成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- // $state.go($scope.formData.cancelUrl);
- });
- } else {
- // SweetAlert.swal({
- // title: "系统错误",
- // text: "系统错误,请稍后重试!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- })
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- }
- break;
- case "save":
- //weChatApplySave
- vm.model["initUser"] = $rootScope.user.id;
- if (vm.model["assignee"] || vm.model["candidateGroups"]) {
- } else {
- vm.model["assignee"] = $rootScope.user.id;
- };
- if (pdKey == 'bpm_service_request') {
- delete vm.model.serviceCatalogueProcessActual.houseNumber;
- angular.extend(vm.model.serviceCatalogueProcessActual, {
- 'category': {
- 'id': $stateParams.userId
- }
- });
- };
- if (pdKey == 'weChatApplySave') {
- api_bpm_domain.weChatApplySave($stateParams.incidentid, vm.model).then(function(response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData) {
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.incident.id) {
- $scope.fileUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, {
- 'access-token': sessionLogin.token,
- });
- item.url = api_bpm_domain.saveAttachments(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.url = api_bpm_domain.uploadAttachment(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({ 'filename': item.file.name });
- console.log($scope.fileUploader);
- };
- $scope.fileUploader.uploadAll();
- }
- }
- $ionicPopup.alert({
- title: '提交成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- });
- } else {
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- })
- }
- });
- } else {
- api_bpm_domain.save(pdKey, vm.model).then(function(response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData) {
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
- $scope.fileUploader.onBeforeUploadItem = function(item) {
- item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({ 'filename': item.file.name });
- };
- $scope.fileUploader.uploadAll();
- }
- }
- $ionicPopup.alert({
- title: '提交成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- });
- } else {
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- })
- }
- });
- }
- break;
- case "complete":
- //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
- //console.log("complete taskId::"+$stateParams.taskId);
- api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function(response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- // SweetAlert.swal({
- // title: "提交成功!",
- // confirmButtonColor: "#007AFF"
- // }, function() {
- // $state.go($scope.formData.cancelUrl);
- // });
- $ionicPopup.alert({
- title: '提交成功!',
- okText: '确认'
- }).then(function(res) {
- history.go(-1);
- // $state.go($scope.formData.cancelUrl);
- });
- } else {
- // SweetAlert.swal({
- // title: "系统错误",
- // text: "系统错误,请稍后重试!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- $ionicPopup.alert({
- title: '系统错误!',
- okText: '确认'
- })
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- break;
- case "back":
- $state.go($scope.formData.cancelUrl);
- break;
- default:
- // $scope.ldloading[style.replace('-', '_')] = false;
- break;
- }
- }
- // var submitFunc = api_bpm_domain[$scope.formData.url]
- // if(anuglar.isFunction(submitFunc)){
- // submitFunc.apply(null, pdKey)
- // }
- }
- } else {
- console.log(data)
- // angular.forEach(vm.form.$error.required, function(item){
- // var i=(item.$name).substring(item.$name.length-2)
- var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
- // for(var i=0;i<vm.fields.length;i++){
- if (vm.fields[i].name == vm.form.$error.required[0].$name) {
- // SweetAlert.swal({
- // title: vm.fields[i].templateOptions.label + '未填',
- // text: "请填写此项!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- $ionicPopup.alert({
- title: vm.fields[i].templateOptions.label + '未填',
- okText: '确认'
- })
- }
- // }
- // angular.forEach(vm.fields,function(f){
- // if(f.name == item.$name){
- // f.validation.show = true;
- // SweetAlert.swal({
- // title: f.templateOptions.label+'未填',
- // text: "请填写此项!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- // }
- // });
- // })
- }
- };
- $scope.vm = vm;
- $scope.reload = function() {
- if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
- var processInstanceId = $stateParams.processInstanceId;
- if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
- api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function(responseData) {
- if (responseData) { //console.log("responseData>>>");//console.log(responseData);
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- decodeVMForm(vmForm);
- //console.log($scope);
- }
- }
- });
- } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
- api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function(responseData) {
- if (responseData) { //console.log("responseData>>>");//console.log(responseData);
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- decodeVMForm(vmForm);
- //console.log($scope);
- }
- }
- });
- } else {
- api_bpm_domain.taskformkey($stateParams.taskId).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
- api_configure_form.renderForm(myData.data, userId, processInstanceId).then(function(responseData) {
- if (responseData) { //console.log("responseData>>>");//console.log(responseData);
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- decodeVMForm(vmForm);
- //console.log($scope);
- }
- }
- });
- }
- })
- }
- } else {
- // create process instance
- if (pdKey != "") { //for process
- if (pdKey == 'bpm_service_request') {
- api_configure_form.renderForm($stateParams.formUiStart, userId).then(function(responseData) {
- if (responseData) {
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) {
- decodeVMForm(vmForm);
- }
- }
- });
- } else if (pdKey == 'weChatApplyStart' || pdKey == 'weChatApplySave') {
- // alert('pdKey' + ':' + pdKey);
- // alert('formKey' + ':' + $stateParams.formKey);
- // alert(api_configure_form.renderForm($stateParams.formKey, '00000').getRequestedUrl());
- api_configure_form.renderForm($stateParams.formKey, '00000').then(function(responseData) {
- // var aa = Restangular.stripRestangular(responseData);
- // for (var i in aa) {
- // if (aa.hasOwnProperty(i)) { //filter,只输出man的私有属性
- // alert(i + ":" + aa[i]);
- // };
- // }
- if (responseData) {
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) {
- decodeVMForm(vmForm);
- }
- }
- });
- } else {
- api_bpm_domain.startformkey(pdKey).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- //myData.data = "arrangeform";
- api_configure_form.renderForm(myData.data, userId).then(function(responseData) {
- if (responseData) {
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) {
- decodeVMForm(vmForm);
- //console.log($rootScope);
- }
- }
- });
- }
- });
- }
- }
- }
- }
- if (sessionStorage.sessionLogin) {
- var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
- var loginUser = sessionLogin.user;
- $rootScope.user = sessionLogin.user;
- //默认数据
- $scope.defaultData = {
- 'assignee': loginUser.id,
- 'idx': 0,
- 'sum': 10,
- };
- //填充数据
- $scope.filterData = {
- 'assignee': loginUser.id,
- 'idx': 0,
- 'sum': 10,
- };
- $scope.reload()
- }
- $scope.$on("loginComplete", function(event, data) {
- var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
- var loginUser = sessionLogin.user;
- $rootScope.user = sessionLogin.user;
- //默认数据
- $scope.defaultData = {
- 'assignee': loginUser.id,
- 'idx': 0,
- 'sum': 10,
- };
- //填充数据
- $scope.filterData = {
- 'assignee': loginUser.id,
- 'idx': 0,
- 'sum': 10,
- };
- $scope.reload()
- });
- //console.log("end decode");
- }
- ]);
|