customFormIndexCtrl.js 362 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684
  1. var appFormly = angular.module('formlyExample', ['formly', 'formlyBootstrap', 'ui.bootstrap']);
  2. app.requires.push('formlyExample');
  3. appFormly.config(
  4. function config(formlyConfigProvider) {
  5. //格式转换方法 XXX-XXX转驼峰命名
  6. function camelize(string) {
  7. string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) {
  8. return chr ? chr.toUpperCase() : '';
  9. });
  10. // Ensure 1st char is always lowercase
  11. return string.replace(/^([A-Z])/, function(match, chr) {
  12. return chr ? chr.toLowerCase() : '';
  13. });
  14. }
  15. //获取ngModelAttr对象设置
  16. function getNgModelAttr(attrs, bindings) {
  17. var ngModelAttrs = {};
  18. angular.forEach(attrs, function(attr) {
  19. ngModelAttrs[camelize(attr)] = { attribute: attr };
  20. });
  21. angular.forEach(bindings, function(binding) {
  22. ngModelAttrs[camelize(binding)] = { bound: binding };
  23. });
  24. return ngModelAttrs;
  25. }
  26. formlyConfigProvider.setWrapper({
  27. name: 'bootstrapLabel',
  28. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  29. });
  30. formlyConfigProvider.setType({
  31. name: 'ui-panel',
  32. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  33. });
  34. formlyConfigProvider.setType({
  35. name: 'ui-currentuser',
  36. // extends: 'input',
  37. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  38. controller: ['$scope', function($scope) {
  39. if ($scope.options.templateOptions.user) {
  40. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  41. $scope.options.initialValue = $scope.model[$scope.options.key];
  42. } else {
  43. $scope.model[$scope.options.key] = $scope.$root.user;
  44. }
  45. }]
  46. });
  47. //仪表盘
  48. formlyConfigProvider.setType({
  49. name: 'ui-assess',
  50. // extends: 'input',
  51. templateUrl: 'assets/views/customform/tpl/assess.html',
  52. controller: ['$scope', function($scope) {
  53. // if ($scope.options.templateOptions.user) {
  54. // $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  55. // $scope.options.initialValue = $scope.model[$scope.options.key];
  56. // } else {
  57. // $scope.model[$scope.options.key] = $scope.$root.user;
  58. // }
  59. }]
  60. });
  61. //待处理事件列表
  62. formlyConfigProvider.setType({
  63. name: 'ui-areaplace',
  64. templateUrl: 'assets/views/customform/tpl/ui-inputright.html',
  65. // templateUrl: 'assets/views/customform/tpl/areaplace.html',
  66. // template: '<div class="contain"><div class="fixWidth"><div class="demo"><div id="trigger" class="trigger" style="cursor: pointer;">地区选择-级联</div></div> </div></div>',
  67. defaultOptions: function(options) {
  68. return {
  69. templateOptions: {
  70. // transform: function(model, modelKey) {
  71. // if (model[modelKey]) {
  72. // // return {
  73. // // value: model.name,
  74. // // id: model[modelKey]
  75. // // }
  76. // // return model[modelKey]
  77. // }
  78. // },
  79. // getlistdata: function($scope, key) {
  80. // if (options.templateOptions.optionsUrl) {
  81. // // if (options.templateOptions.ApiService) {
  82. // var process = {};
  83. // // }
  84. // var datakey = { "idx": 0, "sum": 1000 };
  85. // if (options.templateOptions.Restangular) {
  86. // var process = options.templateOptions.Restangular.all("");
  87. // }
  88. // if (key) {
  89. // angular.extend(datakey, { place: { areaId: $scope.$parent.$parent.$parent.model.incident.area.id, place: key, selectType: "pinyin_qs" } });
  90. // }
  91. // process.customPOST(datakey, options.templateOptions.optionsUrl).then(function(result) {
  92. // if (!options.templateOptions.options) {
  93. // $scope.to.options = [];
  94. // }
  95. // if (options.templateOptions.optionsDataKey) {
  96. // $scope.to.options = result[options.templateOptions.optionsDataKey];
  97. // } else {
  98. // $scope.to.options = result;
  99. // }
  100. // });
  101. // }
  102. // }
  103. }
  104. };
  105. },
  106. controller: ['$scope', '$aside', 'BpmRestangular', 'UserRestangular', 'WechatRestangular', 'api_user_data', function($scope, $aside, BpmRestangular, UserRestangular, WechatRestangular, api_user_data) {
  107. $scope.MobileSelect = {
  108. trigger: '#trigger',
  109. title: '地区选择',
  110. wheels: [{
  111. data: [{
  112. id: '1',
  113. value: '附近',
  114. childs: [{
  115. id: '1',
  116. value: '1000米'
  117. }, {
  118. id: '2',
  119. value: '2000米'
  120. }, {
  121. id: '3',
  122. value: '3000米'
  123. }, {
  124. id: '4',
  125. value: '5000米'
  126. }, {
  127. id: '5',
  128. value: '10000米'
  129. }]
  130. }, {
  131. id: '2',
  132. value: '上城区'
  133. }, {
  134. id: '3',
  135. value: '下城区'
  136. }, {
  137. id: '4',
  138. value: '江干区'
  139. }, {
  140. id: '5',
  141. value: '拱墅区'
  142. }, {
  143. id: '6',
  144. value: '西湖区'
  145. }]
  146. }],
  147. transitionEnd: function(indexArr, data) {
  148. console.log(data);
  149. },
  150. callback: function(indexArr, data) {
  151. console.log(data);
  152. }
  153. }
  154. }]
  155. });
  156. //待处理事件列表
  157. formlyConfigProvider.setType({
  158. name: 'ui-ngtable',
  159. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  160. defaultOptions: function(options) {
  161. return {
  162. templateOptions: {
  163. // relationAction: function() {
  164. // options.hideExpression = true
  165. // }
  166. }
  167. };
  168. },
  169. controller: ['$scope', '$timeout', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', function($scope, $timeout, api_bpm_data, $rootScope, ngTableParams, $filter) {
  170. var filterData = {
  171. "assignee": $rootScope.user.id,
  172. "candidateGroups": $rootScope.user.group[0].id,
  173. "searchtype": "done",
  174. "idx": 0,
  175. "sum": 10
  176. };
  177. api_bpm_data.fetchDataList('incident', filterData).then(function(data) {
  178. if (data.status == 200) {
  179. $scope.myData = data.list
  180. }
  181. })
  182. }]
  183. });
  184. //报表列表
  185. formlyConfigProvider.setType({
  186. name: 'ui-ngreport',
  187. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  188. defaultOptions: function(options) {
  189. return {
  190. templateOptions: {
  191. // relationAction: function() {
  192. // options.hideExpression = true
  193. // }
  194. }
  195. };
  196. },
  197. controller: ['$scope', '$timeout', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', function($scope, $timeout, api_bpm_data, $rootScope, ngTableParams, $filter) {
  198. var filterData = {
  199. "assignee": $rootScope.user.id,
  200. "candidateGroups": $rootScope.user.group[0].id,
  201. "searchtype": "done",
  202. "idx": 0,
  203. "sum": 10
  204. };
  205. // $scope.options.hideExpression = false;
  206. $scope.model.removereport = false;
  207. $scope.removes = function() {
  208. $scope.model.removereport = true;
  209. // $scope.options.templateOptions.relationAction();
  210. // $scope.palnes = false;
  211. // $scope.fields = {};
  212. }
  213. api_bpm_data.fetchDataList('incident', filterData).then(function(data) {
  214. if (data.status == 200) {
  215. $scope.myData = data.list
  216. }
  217. })
  218. }]
  219. });
  220. //请求人最近事件
  221. formlyConfigProvider.setType({
  222. name: 'ui-recentIncident',
  223. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  224. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  225. controller: ['$scope', 'api_solution', function($scope, api_solution) {
  226. var filterData = {
  227. 'incident': {
  228. 'requester': {
  229. 'id': ''
  230. }
  231. },
  232. idx: 0,
  233. sum: 3
  234. };
  235. setInterval(function() {
  236. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  237. var requester = $scope.model.requester;
  238. if (requester != null && angular.isDefined(requester.id)) {
  239. filterData.incident.requester.id = $scope.model.requester.id;
  240. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
  241. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  242. if (modelData.status == 200) {
  243. $scope.lastrequst = modelData.list;
  244. }
  245. });
  246. requester = null
  247. } else {}
  248. } else {}
  249. }, 1000);
  250. $scope.detail = function(data) {
  251. var modalInstance = $modal.open({
  252. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  253. controller: function($scope, $modalInstance) {
  254. $scope.entity = {};
  255. $scope.entity = data;
  256. $scope.cancel = function() {
  257. $modalInstance.dismiss('cancel');
  258. };
  259. },
  260. size: 'lg',
  261. });
  262. }
  263. }]
  264. });
  265. //参数列表
  266. formlyConfigProvider.setType({
  267. name: "ui-listinput",
  268. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  269. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  270. defaultOptions: function(options) {
  271. return {
  272. templateOptions: {}
  273. };
  274. },
  275. controller: ['$scope', function($scope) {
  276. }]
  277. });
  278. //时间段控件(分)
  279. formlyConfigProvider.setType({
  280. name: 'ui-timeslot',
  281. extends: 'input',
  282. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  283. controller: ['$scope', function($scope) {}]
  284. });
  285. //优先级级联可编辑控件
  286. formlyConfigProvider.setType({
  287. name: 'ui-overtime',
  288. // extends: 'input',
  289. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  290. controller: ['$scope', 'api_bpm_domain', function($scope, api_bpm_domain) {
  291. var filteData = {};
  292. var datas = {}
  293. setInterval(function() {
  294. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  295. filteData = "L" + $scope.model.priority.id;
  296. datas = $scope.model.priority.id;
  297. // console.log($scope.options.templateOptions)
  298. api_bpm_domain.expectedTime(filteData).then(function(requester) {
  299. // var overtime=requester.date;
  300. if (requester.state == 200) {
  301. // if($scope.options.key=="date"){
  302. $scope.model[$scope.options.key] = requester.date
  303. // }
  304. }
  305. })
  306. }
  307. }, 1000);
  308. }]
  309. });
  310. formlyConfigProvider.setType({
  311. name: 'ui-responsetime',
  312. extends: 'input',
  313. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  314. controller: ['$scope', 'api_bpm_domain', function($scope, api_bpm_domain) {
  315. var filteData = {};
  316. var datas = {}
  317. setInterval(function() {
  318. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  319. filteData = "L" + $scope.model.priority.id;
  320. datas = $scope.model.priority.id;
  321. // console.log($scope.options.templateOptions)
  322. api_bpm_domain.expectedTime(filteData).then(function(requester) {
  323. // var overtime=requester.date;
  324. if (requester.state == 200) {
  325. var keyName = {};
  326. if ($scope.options.key == "expectIntroTime") {
  327. keyName = "resolveTime";
  328. } else if ($scope.options.key == "expectResponseTime") { keyName = "responseTime"; }
  329. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  330. // }
  331. }
  332. })
  333. }
  334. }, 1000);
  335. }]
  336. });
  337. //知识库按钮组件
  338. formlyConfigProvider.setType({
  339. name: 'ui-discasecade',
  340. extends: 'input',
  341. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  342. defaultOptions: function(options) {
  343. return {
  344. templateOptions: {
  345. relationAction: function(fields, modelscope, item) {}
  346. }
  347. }
  348. },
  349. controller: ['$scope', '$rootScope', 'api_bpm_data', 'api_solution', function($scope, $rootScope, api_bpm_data, api_solution) {
  350. var titles = {}
  351. setInterval(function() {
  352. if ($scope.model.category != null && titles != $scope.model.category) {
  353. $scope.searchData = {};
  354. if ($scope.options.key == "title") {
  355. var filterData = { "idx": 0, "sum": 1000 };
  356. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function(data) {
  357. var datalist = data.list;
  358. angular.forEach(datalist, function(item) {
  359. if (item.id == $scope.model.category.id) {
  360. $scope.model[$scope.options.key] = item.category
  361. $scope.titles = item.category;
  362. titles = $scope.model.category;
  363. }
  364. })
  365. })
  366. }
  367. }
  368. }, 1000);
  369. }]
  370. });
  371. // formlyConfigProvider.setType({
  372. // name: 'ui-discasecade',
  373. // extends: 'input',
  374. // templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  375. // defaultOptions:function(options){
  376. // return{
  377. // templateOptions: {
  378. // refresh:function(){},
  379. // refreshDelay: 0,
  380. // linkage:function(modelName, data, model, modelKey, key){
  381. // console.log(model)
  382. // }
  383. // }
  384. // };
  385. // }
  386. // });
  387. //重构组件模板
  388. //获取当前人
  389. formlyConfigProvider.setType({
  390. name: 'ui-users',
  391. // extends: 'input',
  392. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  393. defaultOptions: function(options) {
  394. return {
  395. templateOptions: {
  396. translate: '',
  397. refreshDelay: 0
  398. }
  399. }
  400. },
  401. controller: ['$scope', function($scope) {
  402. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  403. $scope.options.templateOptions.translate = $scope.$root.user.name;
  404. }]
  405. });
  406. //只读控件
  407. formlyConfigProvider.setType({
  408. name: 'ui-label',
  409. extends: 'input',
  410. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  411. defaultOptions: function(options) {
  412. return {
  413. templateOptions: {
  414. translate: '',
  415. refreshDelay: 0
  416. }
  417. }
  418. },
  419. controller: ['$scope', function($scope) {
  420. console.log($scope.options.templateOptions)
  421. var value = $scope.model[$scope.options.key];
  422. function treeDesc(children, key, label) {
  423. if (label == "") {
  424. label = children[key];
  425. } else {
  426. label = children[key] + "-" + label;
  427. }
  428. if (angular.isDefined(children.parent)) {
  429. treeDesc(children.parent, key, label);
  430. } else {
  431. return label;
  432. }
  433. }
  434. if (angular.isArray(value)) {
  435. var tempValue = "";
  436. angular.forEach(value, function(item) {
  437. if (tempValue != "") {
  438. tempValue = tempValue + ",";
  439. }
  440. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  441. });
  442. $scope.options.templateOptions.translate = tempValue;
  443. } else if (angular.isObject(value)) {
  444. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  445. //tree
  446. // console.log("value.parent="+JSON.stringify(value.parent))
  447. var nameLabel = value[$scope.options.templateOptions.labelProp];
  448. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  449. $scope.options.templateOptions.translate = nameLabel;
  450. } else {
  451. $scope.options.templateOptions.translate = value;
  452. }
  453. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  454. console.log("value=" + value);
  455. $scope.options.templateOptions.translate = value;
  456. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  457. // console.log("value="+value);
  458. // $scope.options.templateOptions.translate = value;
  459. } else {
  460. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  461. $scope.options.templateOptions.translate = value;
  462. }
  463. if (angular.isFunction($scope.options.templateOptions.transform)) {
  464. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  465. if ($scope.options.templateOptions.isSubmit) {
  466. if ($scope.options.templateOptions.transform($scope.$root.user, value).id) {
  467. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value).value;
  468. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value).id
  469. console.log($scope.options.templateOptions.transform($scope.$root.user, value));
  470. } else {
  471. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value);
  472. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value);
  473. console.log($scope.options.templateOptions.transform($scope.$root.user, value));
  474. }
  475. } else {
  476. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value);
  477. }
  478. // var transform = function(model, value) {
  479. // if (model.account) {
  480. // return { value: model.name, id: model.account }
  481. // }
  482. // }
  483. }
  484. }]
  485. });
  486. //标题组件
  487. formlyConfigProvider.setType({
  488. name: 'ui-title',
  489. 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>'
  490. });
  491. //分类标题组件
  492. formlyConfigProvider.setType({
  493. name: 'ui-typeTitle',
  494. templateUrl: 'assets/views/customform/tpl/ui-typeTitle.html'
  495. });
  496. //按钮组
  497. formlyConfigProvider.setType({
  498. name: 'ui-button',
  499. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  500. defaultOptions: function(options) {
  501. return {
  502. noFormControl: true
  503. }
  504. }
  505. });
  506. //3d组link
  507. formlyConfigProvider.setType({
  508. name: 'ui-link',
  509. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  510. defaultOptions: function(options) {
  511. return {
  512. noFormControl: true
  513. }
  514. }
  515. });
  516. //隐藏域组件
  517. formlyConfigProvider.setType({
  518. name: 'ui-hidden',
  519. extends: 'input',
  520. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  521. defaultOptions: function(options) {
  522. return {
  523. // noFormControl: true
  524. };
  525. }
  526. });
  527. //文本框组件
  528. formlyConfigProvider.setType({
  529. name: 'ui-input',
  530. extends: 'input',
  531. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  532. defaultOptions: function(options) {
  533. return {
  534. templateOptions: {
  535. transform: function(model, modelKey) {
  536. if (model[modelKey]) {
  537. // return {
  538. // value: model.name,
  539. // id: model[modelKey]
  540. // }
  541. return model[modelKey]
  542. }
  543. }
  544. }
  545. };
  546. },
  547. controller: ['$scope', function($scope) {
  548. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  549. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  550. }
  551. //赋值和别名转化
  552. if ($scope.options.templateOptions.modelKey) {
  553. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, $scope.options.templateOptions.modelKey);
  554. }
  555. }]
  556. });
  557. //无html结构显示控件
  558. formlyConfigProvider.setType({
  559. name: 'ui-noTemplate',
  560. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  561. template: '<div ng-model="model[options.key]" style="display: none;"></div>',
  562. defaultOptions: function(options) {
  563. return {
  564. templateOptions: {
  565. transform: function(model, modelKey) {
  566. if (model[modelKey]) {
  567. // return {
  568. // value: model.name,
  569. // id: model[modelKey]
  570. // }
  571. return model[modelKey]
  572. }
  573. }
  574. }
  575. };
  576. },
  577. controller: ['$scope', function($scope) {
  578. console.log($scope.options.templateOptions)
  579. var value = $scope.model[$scope.options.key];
  580. function treeDesc(children, key, label) {
  581. if (label == "") {
  582. label = children[key];
  583. } else {
  584. label = children[key] + "-" + label;
  585. }
  586. if (angular.isDefined(children.parent)) {
  587. treeDesc(children.parent, key, label);
  588. } else {
  589. return label;
  590. }
  591. }
  592. if (angular.isArray(value)) {
  593. var tempValue = "";
  594. angular.forEach(value, function(item) {
  595. if (tempValue != "") {
  596. tempValue = tempValue + ",";
  597. }
  598. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  599. });
  600. $scope.options.templateOptions.translate = tempValue;
  601. } else if (angular.isObject(value)) {
  602. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  603. //tree
  604. // console.log("value.parent="+JSON.stringify(value.parent))
  605. var nameLabel = value[$scope.options.templateOptions.labelProp];
  606. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  607. $scope.options.templateOptions.translate = nameLabel;
  608. } else {
  609. $scope.options.templateOptions.translate = value;
  610. }
  611. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  612. console.log("value=" + value);
  613. $scope.options.templateOptions.translate = value;
  614. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  615. // console.log("value="+value);
  616. // $scope.options.templateOptions.translate = value;
  617. } else {
  618. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  619. $scope.options.templateOptions.translate = value;
  620. }
  621. if (angular.isFunction($scope.options.templateOptions.transform)) {
  622. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  623. if ($scope.options.templateOptions.isSubmit) {
  624. if ($scope.options.templateOptions.transform($scope.$root.user, value).id) {
  625. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value).value;
  626. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value).id
  627. console.log($scope.options.templateOptions.transform($scope.$root.user, value));
  628. } else {
  629. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.$root.user, value);
  630. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value);
  631. console.log($scope.options.templateOptions.transform($scope.$root.user, value));
  632. }
  633. } else {
  634. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value);
  635. }
  636. // var transform = function(model, value) {
  637. // if (model.account) {
  638. // return { value: model.name, id: model.account }
  639. // }
  640. // }
  641. }
  642. }]
  643. });
  644. //只读文本
  645. formlyConfigProvider.setType({
  646. name: 'ui-disableinput',
  647. extends: 'input',
  648. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  649. defaultOptions: function(options) {
  650. return {
  651. templateOptions: {
  652. transform: function(value) {
  653. var ret = "";
  654. if (value) {
  655. ret = "已删除";
  656. } else {
  657. ret = "正常";
  658. }
  659. return ret;
  660. }
  661. }
  662. };
  663. }
  664. });
  665. formlyConfigProvider.setType({
  666. name: 'ui-disinput',
  667. extends: 'input',
  668. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  669. defaultOptions: function(options) {
  670. return {
  671. templateOptions: {}
  672. };
  673. }
  674. });
  675. //数字组件
  676. formlyConfigProvider.setType({
  677. name: 'ui-number',
  678. extends: 'input',
  679. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  680. defaultOptions: function(options) {
  681. return {
  682. templateOptions: {}
  683. };
  684. },
  685. controller: ['$scope', function($scope) {
  686. console.log($scope.model[$scope.options.key]);
  687. }]
  688. });
  689. //普通下拉框
  690. // formlyConfigProvider.setType({
  691. // name: 'ui-select-prototype',
  692. // // extends: 'input',
  693. // templateUrl: 'assets/views/customform/tpl/ui-number.html',
  694. // defaultOptions: function(options) {
  695. // return {
  696. // templateOptions: {
  697. // // key: 'multiselectItem',
  698. // // type: 'ui-multi-select-tree',
  699. // // className: 'col-xs-6',
  700. // templateOptions: {
  701. // label: 'multiSelect',
  702. // placeholder: '请选择...',
  703. // isMultiSelect: false,
  704. // selLeafs: false, //只选叶子节点
  705. // refreshData: function(APIService) {
  706. // return APIService.fetchDataList('changeclassify', { 'idx': 0, 'sum': 100 });
  707. // },
  708. // APIService: api_bpm_data,
  709. // optionsDataKey: 'list',
  710. // refreshDelay: 1000,
  711. // onDataCallback: function(item, selectItems, options, field, model) {
  712. // model[options.key] = { id: item.id };
  713. // // console.log("item="+JSON.stringify(model))
  714. // }
  715. // }
  716. // }
  717. // };
  718. // },
  719. // controller: ['$scope', function($scope) {
  720. // console.log($scope.model[$scope.options.key]);
  721. // }]
  722. // });
  723. //下拉搜索框
  724. formlyConfigProvider.setType({
  725. name: 'ui-inputright',
  726. extends: 'input',
  727. templateUrl: 'assets/views/customform/tpl/ui-inputright.html',
  728. defaultOptions: function(options) {
  729. return {
  730. templateOptions: {
  731. transform: function(model, modelKey) {
  732. if (model[modelKey]) {
  733. // return {
  734. // value: model.name,
  735. // id: model[modelKey]
  736. // }
  737. // return model[modelKey]
  738. }
  739. },
  740. getlistdata: function($scope, key) {
  741. if (options.templateOptions.optionsUrl) {
  742. // if (options.templateOptions.ApiService) {
  743. var process = {};
  744. // }
  745. var datakey = { "idx": 0, "sum": 1000 };
  746. if (options.templateOptions.Restangular) {
  747. var process = options.templateOptions.Restangular.all("");
  748. }
  749. if (key) {
  750. angular.extend(datakey, { place: { areaId: $scope.$parent.$parent.$parent.model.incident.area.id, place: key, selectType: "pinyin_qs" } });
  751. }
  752. process.customPOST(datakey, options.templateOptions.optionsUrl).then(function(result) {
  753. if (!options.templateOptions.options) {
  754. $scope.to.options = [];
  755. }
  756. if (options.templateOptions.optionsDataKey) {
  757. $scope.to.options = result[options.templateOptions.optionsDataKey];
  758. } else {
  759. $scope.to.options = result;
  760. }
  761. });
  762. }
  763. }
  764. }
  765. };
  766. },
  767. controller: ['$scope', '$aside', 'BpmRestangular', 'UserRestangular', 'WechatRestangular', function($scope, $aside, BpmRestangular, UserRestangular, WechatRestangular) {
  768. $scope.inputclick = function() {
  769. var modalInstance = $aside.open({
  770. templateUrl: 'assets/views/customform/tpl/searchright.html',
  771. placement: 'right',
  772. backdrop: false,
  773. controller: function($scope, $modalInstance, scope) {
  774. $scope.search = {};
  775. $scope.options = scope.to.options;
  776. $scope.valueProp = scope.to.valueProp;
  777. $scope.labelProp = scope.to.labelProp;
  778. $scope.placeholder = scope.to.placeholder;
  779. $scope.ok = function(item) {
  780. $modalInstance.close(item);
  781. if (scope.options.templateOptions.translate) {
  782. scope.options.templateOptions.translate(item, scope);
  783. }
  784. }
  785. pushHistory();
  786. window.addEventListener("popstate", function(e) {
  787. // window.location = 'http://www.baidu.com';
  788. }, false);
  789. function pushHistory() {
  790. var state = {
  791. title: "title",
  792. url: "#"
  793. };
  794. window.history.pushState(state, "title", "#");
  795. }
  796. $scope.cancel = function() {
  797. $modalInstance.dismiss('cancel');
  798. }
  799. $scope.onChange = function(key) {
  800. if (scope.options.templateOptions.change) {
  801. scope.options.templateOptions.change($scope, scope, key);
  802. }
  803. }
  804. },
  805. size: 'lg',
  806. resolve: {
  807. scope: function() {
  808. return $scope;
  809. }
  810. }
  811. });
  812. modalInstance.result.then(function(selectedItem) {
  813. angular.extend($scope.model, selectedItem);
  814. $scope.model[$scope.options.key] = $scope.model[$scope.options.key];
  815. });
  816. }
  817. $scope.options.templateOptions.getlistdata($scope);
  818. }]
  819. });
  820. //下拉框组件
  821. formlyConfigProvider.setType({
  822. name: 'ui-select',
  823. extends: 'select',
  824. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  825. defaultOptions: function(options) {
  826. return {
  827. templateOptions: {
  828. // refresh: function() {},
  829. // refreshDelay: 0,
  830. linkage: function(modelName, data, model, modelKey, key) {
  831. angular.extend(data, { "idx": 0, "sum": 1000 });
  832. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  833. var myData = options.templateOptions.Restangular.stripRestangular(response);
  834. var list = myData.list;
  835. if (list.length == 1) {
  836. angular.forEach(model.fields, function(item) {
  837. angular.forEach(model.fields, function(item) {
  838. if (item.templateOptions.pkey == modelKey + "." + key) {
  839. item.model.id = '';
  840. item.model.place = '';
  841. if (key == "place") {
  842. item.templateOptions.options = list;
  843. } else if (key == "placeDTO") {
  844. item.templateOptions.options = list;
  845. } else { item.value(list[0][key][item.key]); }
  846. }
  847. })
  848. })
  849. } else {
  850. angular.forEach(model.fields, function(item) {
  851. angular.forEach(model.fields, function(item) {
  852. if (item.templateOptions.pkey == modelKey + "." + key) {
  853. item.model.id = '';
  854. item.model.place = '';
  855. if (key == "place") { item.templateOptions.options = list; }
  856. if (key == "placeDTO") { item.templateOptions.options = list; }
  857. }
  858. })
  859. })
  860. }
  861. });
  862. }
  863. },
  864. };
  865. },
  866. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  867. if ($scope.options.templateOptions.transform) {
  868. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  869. }
  870. if (angular.isFunction($scope.options.templateOptions.translate)) {
  871. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.model, $rootScope);
  872. }
  873. }]
  874. });
  875. //可修改下拉框组件
  876. formlyConfigProvider.setType({
  877. name: 'ui-selectchange',
  878. extends: 'select',
  879. templateUrl: 'assets/views/customform/tpl/ui-selectchange.html',
  880. defaultOptions: function(options) {
  881. return {
  882. templateOptions: {
  883. refresh: function() {},
  884. refreshDelay: 0,
  885. linkage: function(modelName, data, model, modelKey, key) {
  886. angular.extend(data, { "idx": 0, "sum": 1000 });
  887. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  888. var myData = options.templateOptions.Restangular.stripRestangular(response);
  889. var list = myData.list;
  890. if (list.length == 1) {
  891. angular.forEach(model.fields, function(item) {
  892. angular.forEach(model.fields, function(item) {
  893. if (item.templateOptions.pkey == modelKey + "." + key) {
  894. item.model.id = "";
  895. if (key == "place") {
  896. item.templateOptions.options = list;
  897. } else { item.value(list[0][key][item.key]); }
  898. }
  899. })
  900. })
  901. } else {
  902. angular.forEach(model.fields, function(item) {
  903. angular.forEach(model.fields, function(item) {
  904. if (item.templateOptions.pkey == modelKey + "." + key) {
  905. item.model.id = "";
  906. if (key == "place") {
  907. item.templateOptions.options = list;
  908. }
  909. }
  910. })
  911. })
  912. }
  913. });
  914. }
  915. },
  916. controller: ['$scope', function($scope) {
  917. if (angular.isArray($scope.model[$scope.options.key])) {
  918. } else {
  919. $scope.model[$scope.options.key] = [];
  920. }
  921. }]
  922. };
  923. }
  924. });
  925. //下拉多选框组件
  926. formlyConfigProvider.setType({
  927. name: 'ui-multiselect',
  928. extends: 'select',
  929. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  930. defaultOptions: function(options) {
  931. return {
  932. templateOptions: {
  933. refresh: function() {},
  934. refreshDelay: 0
  935. }
  936. };
  937. },
  938. controller: ['$scope', function($scope) {
  939. $scope.model[$scope.options.key] = [];
  940. }]
  941. });
  942. //下拉多选框灵活组件
  943. formlyConfigProvider.setType({
  944. name: 'ui-multiselectplus',
  945. extends: 'select',
  946. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  947. defaultOptions: function(options) {
  948. return {
  949. templateOptions: {
  950. refreshData: function(search, options, model, that) {
  951. var process = options.templateOptions.ApiService.all("");
  952. if (search) {
  953. } else {
  954. }
  955. var postData = options.templateOptions.optionsPostData;
  956. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  957. postData = options.templateOptions.optionsPostData(options, model, that);
  958. }
  959. process.customPOST(postData, options.templateOptions.optionsUrl).then(function(result) {
  960. if (!options.templateOptions.options) {
  961. options.templateOptions.options = [];
  962. }
  963. if (options.templateOptions.optionsDataKey) {
  964. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  965. } else {
  966. options.templateOptions.options = result;
  967. }
  968. if (options.templateOptions.optionsChecked) {
  969. options.value(options.templateOptions.options);
  970. }
  971. });
  972. },
  973. refreshDelay: 0
  974. }
  975. };
  976. },
  977. controller: ['$scope', function($scope) {
  978. if (angular.isArray($scope.model[$scope.options.key])) {
  979. } else {
  980. $scope.model[$scope.options.key] = [];
  981. }
  982. }]
  983. });
  984. //下拉树形多选组件
  985. formlyConfigProvider.setType({
  986. name: 'ui-multiselect-tree',
  987. extends: 'multiCheckbox',
  988. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  989. defaultOptions: function(options) {
  990. return {
  991. templateOptions: {
  992. linkage: function(modelName, data, model, modelKey, key) {
  993. angular.extend(data, { "idx": 0, "sum": 10 });
  994. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  995. var myData = options.templateOptions.Restangular.stripRestangular(response);
  996. var list = myData.list;
  997. if (list.length == 1) {
  998. angular.forEach(model.fields, function(item) {
  999. angular.forEach(model.fields, function(item) {
  1000. if (item.templateOptions.pkey == modelKey + "." + key) {
  1001. item.model.id = "";
  1002. if (key == "place") {
  1003. item.templateOptions.options = list;
  1004. } else { item.value(list[0][key][item.key]); }
  1005. }
  1006. })
  1007. })
  1008. }
  1009. });
  1010. },
  1011. // my_tree_handler : function(items) {
  1012. // console.log('erytuiyewrutyuweyrutewru')
  1013. // },
  1014. // onFilterCallback : function(items) {
  1015. // console.log('1341341234123')
  1016. // },
  1017. // onFilterCallback : function(items) {
  1018. // console.log('134134weafaesesd')
  1019. // },
  1020. refresh: function(items) {
  1021. var treedata = [];
  1022. function convertListToTree(data, treeMap) {
  1023. treedata = data;
  1024. for (var i = 0; i < data.length; i++) {
  1025. for (var j = 0; j < data.length; j++) {
  1026. if (data[i].pid && data[i].id && data[i].pid != 0) {
  1027. if (data[i].pid == data[j].id) {
  1028. data[i].parent = data[j];
  1029. }
  1030. }
  1031. }
  1032. }
  1033. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  1034. var root = null; //Initially set our loop to null
  1035. //loop over data
  1036. for (var i = 0; i < data.length; i++) {
  1037. var datum = data[i];
  1038. //each node will have children, so let's give it a "children" poperty
  1039. datum.children = [];
  1040. //add an entry for this node to the map so that any future children can
  1041. //lookup the parent
  1042. idToNodeMap[datum.id] = datum;
  1043. //Does this node have a parent?
  1044. // console.log("datum="+JSON.stringify(datum))
  1045. if (typeof datum.parent === "undefined" || datum.parent === null) {
  1046. //Doesn't look like it, so this node is the root of the tree
  1047. root = datum;
  1048. treeMap[datum.id] = root;
  1049. } else {
  1050. //This node has a parent, so let's look it up using the id
  1051. parentNode = idToNodeMap[datum.parent.id];
  1052. //We don't need this property, so let's delete it.
  1053. delete datum.parent;
  1054. //Let's add the current node as a child of the parent node.
  1055. parentNode.children.push(datum);
  1056. }
  1057. }
  1058. return root;
  1059. }
  1060. function convertParentToChildList(data) {
  1061. // console.log("data="+JSON.stringify(data))
  1062. var treeMap = {};
  1063. var list = [];
  1064. convertListToTree(data, treeMap);
  1065. angular.forEach(treeMap, function(item) {
  1066. list.push(item);
  1067. });
  1068. return list;
  1069. }
  1070. function selectItem(pmodel, childrens) {
  1071. if (angular.isArray(pmodel)) {
  1072. angular.forEach(pmodel, function(index) {
  1073. if (index && index.id) {
  1074. angular.forEach(childrens, function(item) {
  1075. if (item.id == index.id) {
  1076. item.selected = true;
  1077. }
  1078. if (item && item.children) {
  1079. selectItem(pmodel, item.children);
  1080. }
  1081. });
  1082. }
  1083. })
  1084. } else {
  1085. if (pmodel && pmodel.id) {
  1086. angular.forEach(childrens, function(item) {
  1087. if (item.id == pmodel.id) {
  1088. item.selected = true;
  1089. }
  1090. if (item && item.children) {
  1091. selectItem(pmodel, item.children);
  1092. }
  1093. });
  1094. }
  1095. }
  1096. }
  1097. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  1098. options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
  1099. if (!options.templateOptions.options) {
  1100. options.templateOptions.options = [];
  1101. }
  1102. if (options.templateOptions.optionsDataKey) {
  1103. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  1104. } else {
  1105. options.templateOptions.options = convertParentToChildList(result);
  1106. }
  1107. //set default value
  1108. var pmodel, i = 0;
  1109. if (options.templateOptions.pkey) {
  1110. if (options.templateOptions.pkey.indexOf(".") > 0) {
  1111. angular.forEach(options.templateOptions.pkey.split("."), function(p) {
  1112. if (i == 0) {
  1113. if (options.model[p] == null) {
  1114. options.model[p] = {};
  1115. }
  1116. pmodel = options.model[p];
  1117. i++;
  1118. } else {
  1119. if (pmodel[p] == null) {
  1120. pmodel[p] = {};
  1121. }
  1122. pmodel = pmodel[p];
  1123. }
  1124. });
  1125. } else {
  1126. pmodel = options.model;
  1127. }
  1128. }
  1129. if (pmodel) {
  1130. pmodel = pmodel[options.key];
  1131. } else if (options.model) {
  1132. pmodel = options.model[options.key];
  1133. } else {
  1134. pmodel = options.templateOptions.options;
  1135. }
  1136. if (angular.isArray(pmodel)) {
  1137. if (pmodel) {
  1138. // if(options.templateOptions.isMultiSelect==true){
  1139. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  1140. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  1141. // })
  1142. // }else{
  1143. selectItem(pmodel, options.templateOptions.options);
  1144. // }
  1145. }
  1146. } else {
  1147. if (pmodel && pmodel.id) {
  1148. selectItem(pmodel, options.templateOptions.options);
  1149. }
  1150. }
  1151. // for(var i=0;i<options.templateOptions.options.length;i++){
  1152. // options.templateOptions.options[i]={'id':options.templateOptions.options[i].id,'recate':options.templateOptions.options[i].recate}
  1153. // }
  1154. items.inputModel = options.templateOptions.options;
  1155. // console.log(model);
  1156. // console.log(options);
  1157. });
  1158. }
  1159. },
  1160. validators: {
  1161. required: {
  1162. expression: function(viewValue, modelValue) {
  1163. var value = modelValue || viewValue;
  1164. if (angular.isArray(value)) {
  1165. for (var i = 0; i < value.length; i++) {
  1166. value[i] = { id: value[i].id }
  1167. }
  1168. return value.length > 0
  1169. } else {
  1170. // console.log(options)
  1171. return value = "true";
  1172. // return value != null;
  1173. }
  1174. }
  1175. }
  1176. }
  1177. }
  1178. },
  1179. controller: ['$scope', 'api_configure_form', function($scope, api_configure_form) {
  1180. if ($scope.options.templateOptions.isMultiSelect) {
  1181. // console.log($scope);
  1182. } else {
  1183. if ($scope.model[$scope.options.key]) {
  1184. }
  1185. }
  1186. }]
  1187. });
  1188. //多选下拉框组件
  1189. formlyConfigProvider.setType({
  1190. name: 'ui-multi-select-tree',
  1191. extends: 'multiCheckbox',
  1192. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  1193. defaultOptions: function(options) {
  1194. return {
  1195. templateOptions: {
  1196. linkage: function(modelName, data, model, modelKey, key) {
  1197. angular.extend(data, { "idx": 0, "sum": 10 });
  1198. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  1199. var myData = options.templateOptions.Restangular.stripRestangular(response);
  1200. var list = myData.list;
  1201. if (list.length == 1) {
  1202. angular.forEach(model.fields, function(item) {
  1203. angular.forEach(model.fields, function(item) {
  1204. if (item.templateOptions.pkey == modelKey + "." + key) {
  1205. item.model.id = "";
  1206. if (key == "place") {
  1207. item.templateOptions.options = list;
  1208. } else { item.value(list[0][key][item.key]); }
  1209. }
  1210. })
  1211. })
  1212. }
  1213. });
  1214. },
  1215. getparentdata: function(items) {
  1216. console.log(items)
  1217. },
  1218. refresh: function(items) {
  1219. //console.log(items);
  1220. var treedata = [];
  1221. function convertListToTree(data, treeMap) {
  1222. treedata = data;
  1223. for (var i = 0; i < data.length; i++) {
  1224. for (var j = 0; j < data.length; j++) {
  1225. if (data[i].pid && data[i].id && data[i].pid != 0) {
  1226. if (data[i].pid == data[j].id) {
  1227. data[i].parent = data[j];
  1228. }
  1229. }
  1230. }
  1231. }
  1232. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  1233. var root = null; //Initially set our loop to null
  1234. //loop over data
  1235. for (var i = 0; i < data.length; i++) {
  1236. var datum = data[i];
  1237. //each node will have children, so let's give it a "children" poperty
  1238. datum.children = [];
  1239. //add an entry for this node to the map so that any future children can
  1240. //lookup the parent
  1241. idToNodeMap[datum.id] = datum;
  1242. //Does this node have a parent?
  1243. // console.log("datum="+JSON.stringify(datum))
  1244. if (typeof datum.parent === "undefined" || datum.parent === null) {
  1245. //Doesn't look like it, so this node is the root of the tree
  1246. root = datum;
  1247. treeMap[datum.id] = root;
  1248. } else {
  1249. //This node has a parent, so let's look it up using the id
  1250. parentNode = idToNodeMap[datum.parent.id];
  1251. //We don't need this property, so let's delete it.
  1252. delete datum.parent;
  1253. //Let's add the current node as a child of the parent node.
  1254. parentNode.children.push(datum);
  1255. }
  1256. }
  1257. return root;
  1258. }
  1259. function convertParentToChildList(data) {
  1260. // console.log("data="+JSON.stringify(data))
  1261. var treeMap = {};
  1262. var list = [];
  1263. convertListToTree(data, treeMap);
  1264. angular.forEach(treeMap, function(item) {
  1265. // console.log("item="+JSON.stringify(item))
  1266. list.push(item);
  1267. });
  1268. return list;
  1269. }
  1270. function selectItem(pmodel, childrens) {
  1271. if (angular.isArray(pmodel)) {
  1272. angular.forEach(pmodel, function(index) {
  1273. if (index && index.id) {
  1274. angular.forEach(childrens, function(item) {
  1275. if (item.id == index.id) {
  1276. item.selected = true;
  1277. }
  1278. if (item && item.children) {
  1279. selectItem(pmodel, item.children);
  1280. }
  1281. });
  1282. // angular.forEach(treedata,function(parentdata){
  1283. // if(parentdata.id == index.id){
  1284. // if(parentdata.parent&&parentdata.parent.id){
  1285. // parentdata.parent.$
  1286. // }
  1287. // item.selected = true;
  1288. // }
  1289. // if (item && item.children) {
  1290. // selectItem(pmodel ,item.children);
  1291. // }
  1292. // });
  1293. }
  1294. })
  1295. } else {
  1296. if (pmodel && pmodel.id) {
  1297. angular.forEach(childrens, function(item) {
  1298. if (item.id == pmodel.id) {
  1299. item.selected = true;
  1300. delete item.children;
  1301. }
  1302. if (item && item.children) {
  1303. selectItem(pmodel, item.children);
  1304. }
  1305. });
  1306. }
  1307. }
  1308. }
  1309. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  1310. options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
  1311. if (!options.templateOptions.options) {
  1312. options.templateOptions.options = [];
  1313. }
  1314. if (options.templateOptions.optionsDataKey) {
  1315. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  1316. } else {
  1317. options.templateOptions.options = convertParentToChildList(result);
  1318. }
  1319. //set default value
  1320. var pmodel, i = 0;
  1321. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  1322. if (options.templateOptions.pkey.indexOf(".") > 0) {
  1323. angular.forEach(options.templateOptions.pkey.split("."), function(p) {
  1324. if (i == 0) {
  1325. if (options.model[p] == null) {
  1326. options.model[p] = {};
  1327. }
  1328. pmodel = options.model[p];
  1329. i++;
  1330. } else {
  1331. if (pmodel[p] == null) {
  1332. pmodel[p] = {};
  1333. }
  1334. pmodel = pmodel[p];
  1335. }
  1336. });
  1337. } else {
  1338. pmodel = options.model;
  1339. }
  1340. }
  1341. if (pmodel) {
  1342. pmodel = pmodel[options.key];
  1343. } else if (options.model) {
  1344. pmodel = options.model[options.key];
  1345. }
  1346. // else if ($stateParams.model) {
  1347. // pmodel = $stateParams.model[options.key];
  1348. // }
  1349. if (angular.isArray(pmodel)) {
  1350. if (pmodel) {
  1351. selectItem(pmodel, options.templateOptions.options);
  1352. }
  1353. } else {
  1354. if (pmodel && pmodel.id) {
  1355. selectItem(pmodel, options.templateOptions.options);
  1356. }
  1357. }
  1358. // for(var i=0;i<options.templateOptions.options.length;i++){
  1359. // options.templateOptions.options[i]={'id':options.templateOptions.options[i].id,'recate':options.templateOptions.options[i].recate}
  1360. // }
  1361. items.inputModel = options.templateOptions.options;
  1362. // console.log(model);
  1363. // console.log(options);
  1364. });
  1365. }
  1366. },
  1367. validators: {
  1368. required: {
  1369. expression: function(viewValue, modelValue) {
  1370. var value = modelValue || viewValue;
  1371. if (angular.isArray(value)) {
  1372. return value.length > 0
  1373. } else {
  1374. console.log(options)
  1375. if (options.templateOptions.required) {
  1376. return value != null;
  1377. } else {
  1378. return value = "true";
  1379. }
  1380. // return value = "true";
  1381. }
  1382. }
  1383. }
  1384. }
  1385. }
  1386. },
  1387. controller: ['$scope', 'api_configure_form', function($scope, api_configure_form) {
  1388. if ($scope.options.templateOptions.isMultiSelect) {
  1389. // console.log($scope);
  1390. } else {
  1391. if ($scope.model[$scope.options.key]) {
  1392. }
  1393. }
  1394. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  1395. // console.log(item)
  1396. // // if(){
  1397. // // }
  1398. // // $scope.model[$scope.options.key]=item.id;
  1399. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  1400. // $scope.propTypeOptions = data;
  1401. // });
  1402. // }
  1403. // $scope.model[$scope.options.key]=[];
  1404. }]
  1405. });
  1406. //勾选组件
  1407. formlyConfigProvider.setType({
  1408. name: 'ui-checkbox',
  1409. extends: 'checkbox',
  1410. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html'
  1411. });
  1412. //没有边框的勾选组件
  1413. formlyConfigProvider.setType({
  1414. name: 'ui-checkbox-noBorder',
  1415. // extends: 'checkbox',
  1416. templateUrl: 'assets/views/customform/tpl/ui-checkbox-noBorder.html',
  1417. controller: ['$scope', function($scope) {
  1418. if ($scope.model[$scope.options.key] == true) {
  1419. $scope.checkIconfont = 'dsit-dui fontGreen';
  1420. } else {
  1421. $scope.checkIconfont = 'dsit-false-circle fontRed';
  1422. }
  1423. $scope.checked = function() {
  1424. $scope.model[$scope.options.key] = !$scope.model[$scope.options.key];
  1425. if ($scope.model[$scope.options.key] == true) {
  1426. $scope.checkIconfont = 'dsit-dui fontGreen';
  1427. } else {
  1428. $scope.checkIconfont = 'dsit-false-circle fontRed';
  1429. }
  1430. }
  1431. }]
  1432. });
  1433. //换行组件
  1434. formlyConfigProvider.setType({
  1435. name: 'ui-nextLine',
  1436. /*extends: 'input',*/
  1437. template: '<div></div>',
  1438. });
  1439. //多选框组件
  1440. formlyConfigProvider.setType({
  1441. name: 'ui-checklist',
  1442. extends: 'multiCheckbox',
  1443. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  1444. defaultOptions: function(options) {
  1445. return {
  1446. templateOptions: {
  1447. refresh: function() {},
  1448. refreshDelay: 0
  1449. }
  1450. };
  1451. }
  1452. });
  1453. //单选框组件
  1454. formlyConfigProvider.setType({
  1455. name: 'ui-radio',
  1456. extends: 'radio',
  1457. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  1458. defaultOptions: function(options) {
  1459. return {
  1460. templateOptions: {
  1461. refresh: function() {},
  1462. refreshDelay: 0
  1463. }
  1464. };
  1465. }
  1466. });
  1467. //文本域组件
  1468. formlyConfigProvider.setWrapper({
  1469. name: 'validation',
  1470. types: ['ui-textarea'],
  1471. 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>"
  1472. });
  1473. formlyConfigProvider.setType({
  1474. name: 'ui-textarea',
  1475. extends: 'textarea',
  1476. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  1477. defaultOptions: function(options) {
  1478. return {
  1479. templateOptions: {
  1480. transform: function(model, value) {
  1481. return value;
  1482. },
  1483. },
  1484. validation: {
  1485. messages: {
  1486. maxlength: function(viewValue, modelValue, scope) {
  1487. if (viewValue != null) {
  1488. if (viewValue.length > scope.to.maxlength) {
  1489. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1490. } else {
  1491. return "";
  1492. }
  1493. }
  1494. },
  1495. }
  1496. }
  1497. }
  1498. },
  1499. controller: ['$scope', function($scope) {
  1500. var value = $scope.model[$scope.options.key];
  1501. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1502. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.$root.user, value);
  1503. }
  1504. }]
  1505. });
  1506. //改动的组件 ckeditor封装后的组件
  1507. formlyConfigProvider.setType({
  1508. name: 'ui-text-check',
  1509. extends: 'textarea',
  1510. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  1511. defaultOptions: function(options) {
  1512. return {
  1513. templateOptions: {
  1514. extraPlugins: 'uploadimage',
  1515. uploadimageConfig: {
  1516. backend: 'basic',
  1517. settings: {
  1518. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  1519. headers: '',
  1520. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  1521. }
  1522. },
  1523. refresh: function(APIService, contentId, data) {
  1524. return APIService.fetchDataList(contentId, data);
  1525. },
  1526. downloadUri: function(APIService, contentId) {
  1527. return APIService.downloadAttachment(contentId).getRequestedUrl();
  1528. },
  1529. upload: function(APIService, contentId) {
  1530. return APIService.getSolutionDowpath(contentId);
  1531. },
  1532. view: function(attachmentId) {
  1533. // return APIService.attachmentsPreviewUrl(contentId);
  1534. },
  1535. refreshDelay: 0,
  1536. transform: function(model, value) {
  1537. return value;
  1538. },
  1539. },
  1540. validation: {
  1541. messages: {
  1542. maxlength: function(viewValue, modelValue, scope) {
  1543. if (viewValue != null) {
  1544. if (viewValue.length > scope.to.maxlength) {
  1545. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1546. } else {
  1547. return "";
  1548. }
  1549. }
  1550. },
  1551. }
  1552. }
  1553. }
  1554. },
  1555. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  1556. var value = $scope.model[$scope.options.key];
  1557. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1558. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1559. }
  1560. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  1561. //var expiry={'expiry':14804244006};
  1562. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  1563. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  1564. $scope.upload = function(contentId, filename) {
  1565. var filename = filename;
  1566. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  1567. var file = new Blob([response], { type: 'application/octet-stream' });
  1568. // var filename = filename;
  1569. var fileURL = URL.createObjectURL(file);
  1570. var a = document.createElement('a');
  1571. a.href = fileURL;
  1572. a.target = '_blank';
  1573. a.download = filename;
  1574. document.body.appendChild(a);
  1575. a.click();
  1576. })
  1577. };
  1578. }]
  1579. });
  1580. //ui-grid展示控件
  1581. formlyConfigProvider.setType({
  1582. name: 'ui-grid-show',
  1583. extends: 'multiCheckbox',
  1584. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  1585. defaultOptions: function(options) {
  1586. return {
  1587. templateOptions: {
  1588. linkage: function() {
  1589. },
  1590. },
  1591. };
  1592. },
  1593. controller: function($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  1594. var loginUser = $rootScope.user;
  1595. $scope.langs = i18nService.getAllLangs();
  1596. $scope.lang = 'zh-cn';
  1597. i18nService.setCurrentLang($scope.lang);
  1598. $scope.gridOptions = {};
  1599. $scope.gridOptions.data = 'myData';
  1600. $scope.gridOptions.enableColumnResizing = true;
  1601. // $scope.gridOptions.enableFiltering = true;
  1602. $scope.gridOptions.enableGridMenu = false;
  1603. $scope.gridOptions.enableRowSelection = true;
  1604. $scope.gridOptions.showGridFooter = true;
  1605. $scope.gridOptions.showColumnFooter = false;
  1606. $scope.gridOptions.fastWatch = true;
  1607. $scope.gridOptions.useExternalFiltering = true;
  1608. $scope.gridOptions.useExternalPagination = true;
  1609. $scope.gridOptions.paginationPageSizes = [10];
  1610. $scope.gridOptions.paginationPageSize = 10;
  1611. $scope.gridOptions.multiSelect = true;
  1612. $scope.gridOptions.rowIdentity = function(row) {
  1613. return row.id;
  1614. };
  1615. $scope.gridOptions.getRowIdentity = function(row) {
  1616. return row.id;
  1617. };
  1618. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  1619. $scope.gridOptions.columnDefs = [
  1620. // { name:'id', width:80, enableFiltering:false},
  1621. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  1622. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  1623. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  1624. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  1625. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  1626. { name: 'inspection.title', displayName: '计划主题', width: 120, enableFiltering: false },
  1627. { name: 'stateName', displayName: '状态', width: 80, enableFiltering: false },
  1628. { name: 'processUser.name', displayName: '处理人', width: 80, enableFiltering: false },
  1629. { name: 'startDate', displayName: '开始时间', width: 160, enableFiltering: false },
  1630. { name: 'overdueTime', displayName: '逾期时间', width: 160, enableFiltering: false },
  1631. ];
  1632. var defaultFilterData = {
  1633. "idx": 0,
  1634. "sum": 10
  1635. };
  1636. //分页控制
  1637. $scope.gridOptions.onRegisterApi = function(gridApi) {
  1638. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  1639. var filtersData = $scope.memoryfilterData;
  1640. filtersData.idx = newPage - 1;
  1641. filtersData.sum = pageSize;
  1642. $scope.refreshData('expand-right', filtersData);
  1643. });
  1644. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  1645. data.grid.appScope.selected.items = data.entity
  1646. });
  1647. };
  1648. //页面获取数据
  1649. $scope.refreshData = function(style, filterData) {
  1650. // $scope.ldloading[style.replace('-', '_')] = true;
  1651. if (angular.isUndefined(filterData)) {
  1652. filterData = defaultFilterData;
  1653. }
  1654. $scope.myData = [];
  1655. angular.extend(filterData, { inspectionProcessActual: { "inspectionid": $scope.model.id } })
  1656. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function(data) {
  1657. var myData = Restangular.stripRestangular(data);
  1658. $scope.gridOptions.totalItems = myData.totalNum;
  1659. $scope.myData = myData.list;
  1660. for (var i = 0; i < $scope.myData.length; i++) {
  1661. //添加序号
  1662. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  1663. }
  1664. // $scope.ldloading[style.replace('-', '_')] = false;
  1665. }, function() {
  1666. // $scope.ldloading[style.replace('-', '_')] = false;
  1667. });
  1668. };
  1669. $scope.refreshData('expand-right', defaultFilterData);
  1670. }
  1671. });
  1672. // formlyConfigProvider.setType({
  1673. // name: 'ui-mentio',
  1674. // extends: 'textarea',
  1675. // templateUrl : 'assets/views/customform/tpl/mentio.html',
  1676. // defaultOptions:function(options){
  1677. // return {
  1678. // templateOptions: {
  1679. // transform:function(model, value){
  1680. // return value;
  1681. // },
  1682. // },
  1683. // validation: {
  1684. // messages: {
  1685. // maxlength: function(viewValue, modelValue, scope) {
  1686. // if(viewValue!=null){
  1687. // if(viewValue.length>scope.to.maxlength){
  1688. // return scope.to.label + ' 字数('+ viewValue.length +')超限('+scope.to.maxlength+')'
  1689. // }else{
  1690. // return "";
  1691. // }
  1692. // }
  1693. // },
  1694. // }
  1695. // }
  1696. // }
  1697. // },
  1698. // controller: ['$scope',function($scope){
  1699. // $scope.people = [
  1700. // { label: 'Joe'},
  1701. // { label: 'Mike'},
  1702. // { label: 'Diane'}
  1703. // ]
  1704. // var value = $scope.model[$scope.options.key];
  1705. // if(angular.isFunction($scope.options.templateOptions.transform)){
  1706. // $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1707. // }
  1708. // }]
  1709. // });
  1710. //文本框自定义选择面板组件
  1711. formlyConfigProvider.setType({
  1712. name: 'ui-input-selectmodal',
  1713. extends: 'input',
  1714. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  1715. defaultOptions: function(options) {
  1716. return {
  1717. templateOptions: {
  1718. openModal: function(size, options, modal) {
  1719. var modalInstance = modal.open({
  1720. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  1721. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  1722. size: size,
  1723. resolve: options.templateOptions.modalParam
  1724. });
  1725. modalInstance.result.then(function(selectedItem) {
  1726. options.value(selectedItem);
  1727. }, function() {
  1728. //console.log('Modal dismissed at: ' + new Date());
  1729. });
  1730. }
  1731. }
  1732. };
  1733. }
  1734. });
  1735. //日期控件
  1736. var datepicker_attr = [
  1737. 'date-disabled',
  1738. 'custom-class',
  1739. 'show-weeks',
  1740. 'starting-day',
  1741. 'init-date',
  1742. 'min-mode',
  1743. 'max-mode',
  1744. 'format-day',
  1745. 'format-month',
  1746. 'format-year',
  1747. 'format-day-header',
  1748. 'format-day-title',
  1749. 'format-month-title',
  1750. 'year-range',
  1751. 'shortcut-propagation',
  1752. 'datepicker-popup',
  1753. 'show-button-bar',
  1754. 'current-text',
  1755. 'clear-text',
  1756. 'close-text',
  1757. 'close-on-date-selection',
  1758. 'datepicker-append-to-body'
  1759. ];
  1760. var datepicker_bindings = [
  1761. 'datepicker-mode',
  1762. 'min-date',
  1763. 'max-date'
  1764. ];
  1765. formlyConfigProvider.setType({
  1766. name: 'ui-datetime',
  1767. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  1768. extends: 'input',
  1769. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1770. defaultOptions: {
  1771. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  1772. templateOptions: {
  1773. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  1774. }
  1775. },
  1776. controller: ['$scope', '$filter', function($scope, $filter) {
  1777. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  1778. $scope.options.initialValue = $scope.model[$scope.options.key];
  1779. }]
  1780. });
  1781. //日期控件
  1782. formlyConfigProvider.setType({
  1783. name: 'ui-datepicker',
  1784. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  1785. extends: 'input',
  1786. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1787. defaultOptions: {
  1788. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  1789. templateOptions: {
  1790. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  1791. }
  1792. },
  1793. controller: ['$scope', '$filter', function($scope, $filter) {
  1794. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  1795. if ($scope.model[$scope.options.key]) {
  1796. } else {
  1797. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  1798. }
  1799. $scope.options.initialValue = $scope.model[$scope.options.key];
  1800. $scope.endOpen = true;
  1801. $scope.datepicker = {};
  1802. $scope.datepicker.opened = false;
  1803. $scope.datepicker.open = function($event) {
  1804. $scope.datepicker.opened = true;
  1805. };
  1806. }]
  1807. });
  1808. //含有周的日期
  1809. formlyConfigProvider.setType({
  1810. name: 'ui-datepickerweek',
  1811. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  1812. extends: 'input',
  1813. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1814. defaultOptions: {
  1815. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  1816. templateOptions: {
  1817. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  1818. }
  1819. },
  1820. controller: ['$scope', '$filter', function($scope, $filter) {
  1821. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  1822. if ($scope.model[$scope.options.key]) {
  1823. } else {
  1824. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  1825. }
  1826. $scope.options.initialValue = $scope.model[$scope.options.key];
  1827. $scope.endOpen = true;
  1828. $scope.datepicker = {};
  1829. $scope.datepicker.opened = false;
  1830. $scope.datepicker.open = function($event) {
  1831. $scope.datepicker.opened = true;
  1832. };
  1833. }]
  1834. });
  1835. //时分控件
  1836. formlyConfigProvider.setType({
  1837. name: 'ui-datehourtime',
  1838. extends: 'input',
  1839. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  1840. defaultOptions: function(options) {
  1841. return {
  1842. noFormControl: true,
  1843. // validators:{
  1844. // required:{
  1845. // expression:function(viewValue, modelValue){
  1846. // console.log(options)
  1847. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  1848. // // var value = modelValue.getHours() || viewValue.getHours();
  1849. // return value.length>=1;
  1850. // }
  1851. // }
  1852. // }
  1853. }
  1854. },
  1855. controller: ['$scope', '$log', function($scope, $log) {
  1856. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  1857. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  1858. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  1859. }]
  1860. });
  1861. //状态追踪
  1862. formlyConfigProvider.setType({
  1863. name: 'ui-followStatus',
  1864. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  1865. controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
  1866. setTimeout(function() {
  1867. var pkey = $scope.options.templateOptions.pkey;
  1868. var dataId = $scope.model.id;
  1869. api_bpm_data.fetchData(pkey, dataId).then(function(response) {
  1870. if (response) {
  1871. var myData = Restangular.stripRestangular(response);
  1872. var processInstanceId = myData.data.processInstanceId;
  1873. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
  1874. if (result.status == 200) {
  1875. var newData = Restangular.stripRestangular(result);
  1876. $scope.followData = newData.data;
  1877. }
  1878. });
  1879. }
  1880. })
  1881. }, 10);
  1882. }]
  1883. });
  1884. //历史记录
  1885. formlyConfigProvider.setType({
  1886. name: 'ui-history',
  1887. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  1888. controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
  1889. setTimeout(function() {
  1890. var pkey = $scope.options.templateOptions.pkey;
  1891. var dataId = $scope.model.id;
  1892. api_bpm_data.fetchData(pkey, dataId).then(function(response) {
  1893. if (response) {
  1894. var myData = Restangular.stripRestangular(response);
  1895. var processInstanceId = myData.data.processInstanceId;
  1896. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
  1897. if (result.status == 200) {
  1898. var newData = Restangular.stripRestangular(result);
  1899. var long = newData.data.length - 1;
  1900. $scope.followData = newData.data[long];
  1901. }
  1902. });
  1903. }
  1904. })
  1905. }, 10);
  1906. }]
  1907. });
  1908. //请求人信息显示
  1909. formlyConfigProvider.setType({
  1910. name: "ui-disrequester",
  1911. templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  1912. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1913. defaultOptions: function(options) {
  1914. return {
  1915. templateOptions: {}
  1916. };
  1917. },
  1918. controller: ['$scope', function($scope) {
  1919. $scope.options.templateOptions.that = $scope;
  1920. }]
  1921. });
  1922. //退回人信息显示
  1923. formlyConfigProvider.setType({
  1924. name: "ui-returnperson",
  1925. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  1926. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1927. defaultOptions: function(options) {
  1928. return {
  1929. templateOptions: {}
  1930. };
  1931. },
  1932. controller: ['$scope', function($scope) {
  1933. $scope.group = "";
  1934. $scope.role = "";
  1935. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  1936. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  1937. } else {
  1938. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  1939. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  1940. }
  1941. }
  1942. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  1943. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  1944. } else {
  1945. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  1946. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  1947. }
  1948. }
  1949. $scope.options.templateOptions.that = $scope;
  1950. $scope.options.templateOptions.that = $scope;
  1951. }]
  1952. });
  1953. //指派技术人员
  1954. formlyConfigProvider.setType({
  1955. name: "ui-apiontperson",
  1956. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  1957. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1958. defaultOptions: function(options) {
  1959. return {
  1960. templateOptions: {
  1961. transtlara: function(value, $scope) {}
  1962. }
  1963. };
  1964. },
  1965. controller: ['$scope', 'api_user_data', 'Restangular', function($scope, api_user_data, Restangular) {
  1966. var filterData = { "idx": 0, "sum": 1000 }
  1967. api_user_data.fetchDataList('group', filterData).then(function(response) {
  1968. if (response.status == 200) {
  1969. $scope.select = {};
  1970. $scope.multipleDemo = {};
  1971. $scope.userdata = {};
  1972. var data = response.list;
  1973. var item = [];
  1974. $scope.multipleDemo = data;
  1975. $scope.multipleDemo;
  1976. }
  1977. })
  1978. $scope.options.templateOptions.onChange = function(id, options, groupdata, $event, model) {
  1979. if (groupdata.option) {
  1980. $scope.model[$scope.options.key] = {};
  1981. var fildate = {
  1982. "idx": 0,
  1983. "sum": 1000,
  1984. "user": {
  1985. "roledata": { "rolecode": model.currentRole },
  1986. "selectType": "1",
  1987. "groupdata": { "id": groupdata.option.id }
  1988. }
  1989. }
  1990. api_user_data.fetchDataList('user', fildate).then(function(response) {
  1991. if (response.status == 200) {
  1992. $scope.userdata = {};
  1993. $scope.userdata = response.list;
  1994. }
  1995. })
  1996. } else {
  1997. $scope.model[$scope.options.key] = { id: groupdata.id.id }
  1998. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  1999. }
  2000. }
  2001. // }
  2002. }]
  2003. });
  2004. // 请求人选控件
  2005. formlyConfigProvider.setType({
  2006. name: "ui-requesterselect",
  2007. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  2008. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2009. controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
  2010. api_user_data.fetchDataList('requester', { "idx": 0, "sum": 10, "requester": { "account": $scope.$root.user.account } }).then(function(response) {
  2011. if (response.status == 200) {
  2012. $scope.model[$scope.options.key] = response.list[0];
  2013. }
  2014. })
  2015. }]
  2016. });
  2017. // 请求人选控件
  2018. // formlyConfigProvider.setType({
  2019. // name: "ui-requesterselect",
  2020. // templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  2021. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2022. // defaultOptions: function(options, $scope) {
  2023. // return {
  2024. // templateOptions: {
  2025. // checkform: function(options) {
  2026. // if (options.model.requester) {
  2027. // options.value(options.model.requester);
  2028. // }
  2029. // },
  2030. // linkage: function(searchtype, opt) {
  2031. // var filterData = {
  2032. // 'requester': {
  2033. // 'searchKey': searchtype,
  2034. // },
  2035. // idx: 0,
  2036. // sum: 10
  2037. // };
  2038. // if (opt.model.requester && opt.model.requester != null && opt.model.requester.requesterTypeDTO) {
  2039. // angular.extend(filterData.requester, { 'requesterTypeDTO': opt.model.requester.requesterTypeDTO })
  2040. // }
  2041. // $scope.searchKey = searchtype;
  2042. // // $scope.nameshow=false;
  2043. // $scope.accountshow = false;
  2044. // if (angular.isDefined(searchtype) && searchtype != '') {
  2045. // $scope.accountshow = true;
  2046. // options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function(response) {
  2047. // var myData = options.templateOptions.Restangular.stripRestangular(response);
  2048. // $scope.myData = myData.list;
  2049. // if (myData.list.length >= 0) {
  2050. // if (myData.list.length == 1) {
  2051. // $scope.accountshow = false;
  2052. // if ($scope.model) {
  2053. // if ($scope.model.place) {
  2054. // $scope.model.place.id = '';
  2055. // }
  2056. // if ($scope.model.area) {
  2057. // $scope.model.area.id = '';
  2058. // }
  2059. // options.model.houseNumber = '';
  2060. // }
  2061. // // $scope.model.place.id = '';
  2062. // // $scope.model.area.id = '';
  2063. // // $scope.model.houseNumber = '';
  2064. // options.value(myData.list[0]);
  2065. // if ($scope.myData[0].placeDTO && $scope.myData[0].placeDTO.id) {
  2066. // $scope.model.place.id = $scope.myData[0].placeDTO.id
  2067. // }
  2068. // if ($scope.myData[0].areaDTO && $scope.myData[0].areaDTO.id) {
  2069. // $scope.model.area.id = $scope.myData[0].areaDTO.id
  2070. // }
  2071. // if ($scope.myData[0].houseNumber) {
  2072. // $scope.model.houseNumber = $scope.myData[0].houseNumber;
  2073. // }
  2074. // } else if (myData.list.length == 0) {
  2075. // $scope.accountshow = false;
  2076. // if ($scope.model) {
  2077. // if ($scope.model.place) {
  2078. // $scope.model.place.id = '';
  2079. // }
  2080. // if ($scope.model.area) {
  2081. // $scope.model.area.id = '';
  2082. // }
  2083. // options.model.houseNumber = '';
  2084. // }
  2085. // if (opt.model.requester && opt.model.requester != null && opt.model.requester.requesterTypeDTO) {
  2086. // // $scope.model[requesterTypeDTO]=opt.model.requester.requesterTypeDTO;
  2087. // options.value({ 'requesterTypeDTO': opt.model.requester.requesterTypeDTO });
  2088. // }
  2089. // } else if (myData.list.length > 1) {
  2090. // $scope.accountshow = true;
  2091. // // var requesternum={};
  2092. // // requesternum['searchKey']=searchtype;
  2093. // // options.value(requesternum);
  2094. // }
  2095. // }
  2096. // });
  2097. // $scope.show = function(filitem) {
  2098. // // $scope.nameshow=false;
  2099. // $scope.accountshow = false;
  2100. // if ($scope.model) {
  2101. // if ($scope.model.place) {
  2102. // $scope.model.place.id = '';
  2103. // }
  2104. // if ($scope.model.area) {
  2105. // $scope.model.area.id = '';
  2106. // }
  2107. // options.model.houseNumber = '';
  2108. // }
  2109. // options.value(filitem);
  2110. // $scope.searchKey = filitem.account;
  2111. // if (filitem.placeDTO && filitem.placeDTO.id) {
  2112. // $scope.model.place.id = filitem.placeDTO.id
  2113. // }
  2114. // if (filitem.areaDTO && filitem.areaDTO.id) {
  2115. // $scope.model.area.id = filitem.areaDTO.id
  2116. // }
  2117. // if (filitem.houseNumber) {
  2118. // $scope.model.houseNumber = filitem.houseNumber;
  2119. // }
  2120. // }
  2121. // } else {
  2122. // $scope.accountshow = false;
  2123. // searchtype = ''
  2124. // }
  2125. // },
  2126. // openModal: function(size, options, modal) {
  2127. // var modelObject = options.value();
  2128. // var searchModal = function(filterSearchData) {
  2129. // var modalInstance = modal.open({
  2130. // templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  2131. // controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchData, api_bpm_data) {
  2132. // $scope.langs = i18nService.getAllLangs();
  2133. // $scope.lang = 'zh-cn';
  2134. // i18nService.setCurrentLang($scope.lang);
  2135. // $scope.gridOptions = {};
  2136. // $scope.gridOptions.data = 'myData';
  2137. // $scope.gridOptions.enableColumnResizing = true;
  2138. // $scope.gridOptions.enableFiltering = true;
  2139. // $scope.gridOptions.enableGridMenu = false;
  2140. // $scope.gridOptions.enableRowSelection = true;
  2141. // $scope.gridOptions.showGridFooter = true;
  2142. // $scope.gridOptions.showColumnFooter = true;
  2143. // $scope.gridOptions.fastWatch = true;
  2144. // $scope.gridOptions.useExternalFiltering = true;
  2145. // $scope.gridOptions.useExternalPagination = true;
  2146. // $scope.gridOptions.paginationPageSizes = [10];
  2147. // $scope.gridOptions.paginationPageSize = 10;
  2148. // $scope.gridOptions.multiSelect = false;
  2149. // $scope.gridOptions.rowIdentity = function(row) {
  2150. // return row.id;
  2151. // };
  2152. // $scope.gridOptions.getRowIdentity = function(row) {
  2153. // return row.id;
  2154. // };
  2155. // $scope.gridOptions.columnDefs = [
  2156. // { name: 'account', displayName: '一卡通号', width: 140 },
  2157. // { name: 'studentNo', displayName: '学工号', width: 140 },
  2158. // { name: 'name', displayName: '姓名', width: 100 },
  2159. // { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
  2160. // { name: 'mphone', displayName: '电话', width: 100, enableFiltering: false },
  2161. // // { name:'email', displayName:'邮件', width:100},
  2162. // { name: 'areaDTO.area', displayName: '区域', width: 100, enableFiltering: false },
  2163. // { name: 'placeDTO.place', displayName: '地点', width: 100, enableFiltering: false }
  2164. // ];
  2165. // $scope.gridOptions.onRegisterApi = function(gridApi) {
  2166. // $scope.gridApi = gridApi;
  2167. // // var filtersData = $scope.memoryfilterData;
  2168. // // filtersData.idx = newPage - 1;
  2169. // // filtersData.sum = pageSize;
  2170. // gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  2171. // var filtersData = $scope.memoryfilterData;
  2172. // filtersData.idx = newPage - 1;
  2173. // filtersData.sum = pageSize;
  2174. // $scope.loadData(filtersData);
  2175. // });
  2176. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  2177. // // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  2178. // $scope.selected.item = data.entity;
  2179. // // }else{alert ("请求人工号格式不对,账号应为6位数,请重新填写!")}
  2180. // });
  2181. // gridApi.core.on.filterChanged($scope, function() {
  2182. // var grid = this.grid;
  2183. // var filtersData = {
  2184. // idx: 0,
  2185. // sum: 10
  2186. // };
  2187. // angular.forEach(grid.columns, function(item) {
  2188. // if (item.enableFiltering) {
  2189. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  2190. // if (angular.isUndefined(filtersData['requester'])) {
  2191. // filtersData['requester'] = {};
  2192. // }
  2193. // filtersData['requester'][item.field] = item.filters[0].term;
  2194. // }
  2195. // }
  2196. // });
  2197. // $scope.memoryfilterData = filtersData;
  2198. // $scope.loadData(filtersData);
  2199. // });
  2200. // };
  2201. // $scope.memoryfilterData = defaultFilterData = {
  2202. // "idx": 0,
  2203. // "sum": 10
  2204. // };
  2205. // $scope.loadData = function(filterData) {
  2206. // items.fetchItems(filterData, APIService).then(function(data) {
  2207. // var myData = Restangular.stripRestangular(data);
  2208. // $scope.gridOptions.totalItems = myData.totalNum;
  2209. // $scope.myData = myData.list;
  2210. // });
  2211. // };
  2212. // $scope.title = title;
  2213. // if (searchData) {
  2214. // $scope.loadData(searchData);
  2215. // } else {
  2216. // $scope.loadData({
  2217. // idx: 0,
  2218. // sum: 10
  2219. // });
  2220. // }
  2221. // $scope.selected = {
  2222. // item: {}
  2223. // };
  2224. // $scope.ok = function() {
  2225. // $modalInstance.close($scope.selected.item);
  2226. // };
  2227. // $scope.cancel = function() {
  2228. // $modalInstance.dismiss('cancel');
  2229. // };
  2230. // },
  2231. // size: size,
  2232. // resolve: {
  2233. // items: function() {
  2234. // return {
  2235. // fetchItems: function(filterData, APIService) {
  2236. // filterData = filterData || {};
  2237. // if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  2238. // filterData = {
  2239. // idx: 0,
  2240. // sum: 10
  2241. // };
  2242. // }
  2243. // return options.templateOptions.fetchItems(filterData, APIService);
  2244. // }
  2245. // };
  2246. // },
  2247. // title: function() {
  2248. // return options.templateOptions.modalTitle;
  2249. // },
  2250. // Restangular: function() {
  2251. // return options.templateOptions.Restangular;
  2252. // },
  2253. // APIService: function() {
  2254. // return options.templateOptions.ApiService;
  2255. // },
  2256. // language: function() {
  2257. // return options.templateOptions.language;
  2258. // },
  2259. // searchData: function() {
  2260. // return filterSearchData;
  2261. // }
  2262. // }
  2263. // });
  2264. // modalInstance.result.then(function(selectedItem) {
  2265. // if (options.model) {
  2266. // if (options.model.place) {
  2267. // options.model.place.id = '';
  2268. // }
  2269. // if (options.model.area) {
  2270. // options.model.area.id = '';
  2271. // }
  2272. // options.model.houseNumber = '';
  2273. // }
  2274. // options.value(selectedItem);
  2275. // $scope.searchKey = selectedItem.account;
  2276. // if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  2277. // options.model.place.id = selectedItem.placeDTO.id
  2278. // }
  2279. // if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  2280. // options.model.area.id = selectedItem.areaDTO.id
  2281. // }
  2282. // if (selectedItem.houseNumber) {
  2283. // options.model.houseNumber = selectedItem.houseNumber;
  2284. // }
  2285. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  2286. // options.templateOptions.callback(selectedItem, options);
  2287. // }
  2288. // }, function() {
  2289. // //console.log('Modal dismissed at: ' + new Date());
  2290. // });
  2291. // }
  2292. // searchModal();
  2293. // // }
  2294. // },
  2295. // addRequeter: function(size, options, modal) {
  2296. // var modalInstance = modal.open({
  2297. // templateUrl: 'assets/views/customform/tpl/modal-add-requester.html',
  2298. // controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data) {
  2299. // $scope.title = "新增请求人";
  2300. // $scope.requester = {
  2301. // };
  2302. // api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function(response) {
  2303. // if (response.status == 200) {
  2304. // $scope.areas = response.list;
  2305. // }
  2306. // })
  2307. // api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
  2308. // if (response.status == 200) {
  2309. // $scope.networktypes = response.list;
  2310. // }
  2311. // })
  2312. // $scope.onChange = function(item) {
  2313. // // console.log(item)
  2314. // $scope.requester.placeDTO = {};
  2315. // api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
  2316. // if (response.status == 200) {
  2317. // $scope.places = response.list;
  2318. // }
  2319. // })
  2320. // }
  2321. // $scope.refreshDepts = function(key) {
  2322. // var filterData = {
  2323. // 'idx': 0,
  2324. // 'sum': 5,
  2325. // 'dept': {
  2326. // 'name': key
  2327. // }
  2328. // };
  2329. // UserService.fetchDataList('department', filterData).then(function(response) {
  2330. // if (response.status == 200) {
  2331. // $scope.depts = response.list;
  2332. // }
  2333. // })
  2334. // }
  2335. // $scope.ok = function() {
  2336. // if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  2337. // // SweetAlert.swal("请求人姓名未填!", "请填写请求人姓名", "error");
  2338. // $ionicPopup.alert({
  2339. // title: '请求人姓名未填!',
  2340. // });
  2341. // } else if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  2342. // // SweetAlert.swal("请求人一卡通号未填!", "请填写请求人一卡通号", "error");
  2343. // $ionicPopup.alert({
  2344. // title: '请求人一卡通号未填!',
  2345. // });
  2346. // } else if (angular.isUndefined($scope.requester.requesterTypeDTO) || $scope.requester.requesterTypeDTO == null || $scope.requester.requesterTypeDTO == "") {
  2347. // // SweetAlert.swal("请求人职务!", "请填写请求人职务", "error");
  2348. // $ionicPopup.alert({
  2349. // title: '请求人职务未填!',
  2350. // });
  2351. // } else {
  2352. // $modalInstance.close($scope.requester);
  2353. // }
  2354. // };
  2355. // $scope.cancel = function() {
  2356. // $modalInstance.dismiss('cancel');
  2357. // };
  2358. // },
  2359. // size: size,
  2360. // resolve: {
  2361. // items: function() {
  2362. // return {
  2363. // fetchItems: function(filterData, APIService) {
  2364. // filterData = filterData || {};
  2365. // if (!filterData.idx) {
  2366. // filterData = {
  2367. // idx: 0,
  2368. // sum: 10
  2369. // };
  2370. // }
  2371. // return options.templateOptions.fetchItems(filterData, APIService);
  2372. // }
  2373. // };
  2374. // },
  2375. // title: function() {
  2376. // return options.templateOptions.modalTitle;
  2377. // },
  2378. // Restangular: function() {
  2379. // return options.templateOptions.Restangular;
  2380. // },
  2381. // APIService: function() {
  2382. // return options.templateOptions.ApiService;
  2383. // },
  2384. // UserService: function() {
  2385. // return options.templateOptions.UserService;
  2386. // }
  2387. // }
  2388. // });
  2389. // modalInstance.result.then(function(selectedItem) {
  2390. // if (selectedItem) {
  2391. // var data = {
  2392. // 'requester': selectedItem
  2393. // };
  2394. // $scope.searchKey = selectedItem.account;
  2395. // options.templateOptions.UserService.addData('requester', data).then(function(response) {
  2396. // if (response.status == 200) {
  2397. // if (options.model) {
  2398. // if (options.model.place) {
  2399. // options.model.place.id = '';
  2400. // }
  2401. // if (options.model.area) {
  2402. // options.model.area.id = '';
  2403. // }
  2404. // options.model.houseNumber = '';
  2405. // }
  2406. // options.value(response.data);
  2407. // if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  2408. // options.model.place.id = selectedItem.placeDTO.id
  2409. // }
  2410. // if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  2411. // options.model.area.id = selectedItem.areaDTO.id
  2412. // }
  2413. // if (selectedItem.houseNumber) {
  2414. // options.model.houseNumber = selectedItem.houseNumber;
  2415. // }
  2416. // }
  2417. // })
  2418. // }
  2419. // }, function() {
  2420. // //console.log('Modal dismissed at: ' + new Date());
  2421. // });
  2422. // },
  2423. // changeRequeter: function(size, options, modal) {
  2424. // var modalInstance = modal.open({
  2425. // templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  2426. // controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data) {
  2427. // $scope.title = "修改请求人";
  2428. // $scope.requester = {
  2429. // id: options.model.requester.id,
  2430. // account: options.model.requester.account,
  2431. // name: options.model.requester.name,
  2432. // gender: options.model.requester.gender,
  2433. // email: options.model.requester.email,
  2434. // deptName: options.model.requester.deptName,
  2435. // mphone: options.model.requester.mphone,
  2436. // telephone: options.model.requester.telephone,
  2437. // studentNo: options.model.requester.studentNo,
  2438. // areaDTO: options.model.requester.areaDTO,
  2439. // placeDTO: options.model.requester.placeDTO,
  2440. // requesterTypeDTO: options.model.requester.requesterTypeDTO
  2441. // };
  2442. // api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function(response) {
  2443. // if (response.status == 200) {
  2444. // $scope.areas = response.list;
  2445. // }
  2446. // })
  2447. // api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
  2448. // if (response.status == 200) {
  2449. // $scope.networktypes = response.list;
  2450. // }
  2451. // })
  2452. // if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  2453. // api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function(response) {
  2454. // if (response.status == 200) {
  2455. // $scope.places = response.list;
  2456. // }
  2457. // })
  2458. // }
  2459. // $scope.onChange = function(item) {
  2460. // // console.log(item)
  2461. // $scope.requester.placeDTO = {};
  2462. // api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
  2463. // if (response.status == 200) {
  2464. // $scope.places = response.list;
  2465. // }
  2466. // })
  2467. // }
  2468. // $scope.refreshDepts = function(key) {
  2469. // var filterData = {
  2470. // 'idx': 0,
  2471. // 'sum': 5,
  2472. // 'dept': {
  2473. // 'name': key
  2474. // }
  2475. // };
  2476. // UserService.fetchDataList('department', filterData).then(function(response) {
  2477. // if (response.status == 200) {
  2478. // $scope.depts = response.list;
  2479. // }
  2480. // })
  2481. // }
  2482. // $scope.ok = function() {
  2483. // if ($scope.requester.account == "" || $scope.requester.name == "") {
  2484. // // SweetAlert.swal("请求人姓名或一卡通号未填!", "请补全请求人信息", "error");
  2485. // $ionicPopup.alert({
  2486. // title: '请求人姓名或一卡通号未填!',
  2487. // });
  2488. // } else {
  2489. // $modalInstance.close($scope.requester);
  2490. // }
  2491. // };
  2492. // $scope.cancel = function() {
  2493. // $modalInstance.dismiss('cancel');
  2494. // };
  2495. // },
  2496. // size: size,
  2497. // resolve: {
  2498. // items: function() {
  2499. // return {
  2500. // fetchItems: function(filterData, APIService) {
  2501. // filterData = filterData || {};
  2502. // if (!filterData.idx) {
  2503. // filterData = {
  2504. // idx: 0,
  2505. // sum: 10
  2506. // };
  2507. // }
  2508. // return options.templateOptions.fetchItems(filterData, APIService);
  2509. // }
  2510. // };
  2511. // },
  2512. // title: function() {
  2513. // return options.templateOptions.modalTitle;
  2514. // },
  2515. // Restangular: function() {
  2516. // return options.templateOptions.Restangular;
  2517. // },
  2518. // APIService: function() {
  2519. // return options.templateOptions.ApiService;
  2520. // },
  2521. // UserService: function() {
  2522. // return options.templateOptions.UserService;
  2523. // }
  2524. // }
  2525. // });
  2526. // modalInstance.result.then(function(selectedItem) {
  2527. // if (selectedItem) {
  2528. // var data = {
  2529. // 'requester': selectedItem
  2530. // };
  2531. // options.templateOptions.UserService.addData('requester', data).then(function(response) {
  2532. // if (response.status == 200) {
  2533. // options.value(response.data);
  2534. // // SweetAlert.swal("修改成功!", "", "error");
  2535. // } else {
  2536. // // SweetAlert.swal("修改失败!", "请重试", "error");
  2537. // }
  2538. // })
  2539. // // }
  2540. // }
  2541. // }, function() {
  2542. // //console.log('Modal dismissed at: ' + new Date());
  2543. // });
  2544. // }
  2545. // }
  2546. // };
  2547. // },
  2548. // controller: ['$scope', function($scope) {
  2549. // $scope.options.templateOptions.ApiService.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
  2550. // if (response.status == 200) {
  2551. // $scope.networktypes = response.list;
  2552. // } else {
  2553. // // SweetAlert.swal("系统错误!", "请刷新重试", "error");
  2554. // $ionicPopup.alert({
  2555. // title: '系统错误!',
  2556. // });
  2557. // }
  2558. // })
  2559. // // $scope.options.templateOptions.that = $scope;
  2560. // }]
  2561. // });
  2562. //处理人信息
  2563. formlyConfigProvider.setType({
  2564. name: "ui-userinformation",
  2565. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  2566. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2567. defaultOptions: function(options) {
  2568. return {
  2569. templateOptions: {}
  2570. };
  2571. },
  2572. controller: ['$scope', function($scope) {
  2573. $scope.group = "";
  2574. $scope.role = "";
  2575. // if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  2576. // $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  2577. // } else {
  2578. // for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  2579. // $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  2580. // }
  2581. // }
  2582. // if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  2583. // $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  2584. // } else {
  2585. // for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  2586. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  2587. // }
  2588. // }
  2589. $scope.options.templateOptions.that = $scope;
  2590. }]
  2591. });
  2592. //处理界面处理人信息
  2593. formlyConfigProvider.setType({
  2594. name: "ui-handler",
  2595. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  2596. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2597. defaultOptions: function(options) {
  2598. return {
  2599. templateOptions: {}
  2600. };
  2601. },
  2602. controller: ['$scope', function($scope) {
  2603. $scope.group = "";
  2604. // $scope.role="";
  2605. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  2606. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  2607. } else {
  2608. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  2609. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  2610. }
  2611. }
  2612. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  2613. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  2614. // }else{
  2615. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  2616. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  2617. // }
  2618. // }
  2619. $scope.options.templateOptions.that = $scope;
  2620. }]
  2621. });
  2622. //关闭界面处理人信息
  2623. formlyConfigProvider.setType({
  2624. name: "ui-closehandler",
  2625. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  2626. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2627. defaultOptions: function(options) {
  2628. return {
  2629. templateOptions: {}
  2630. };
  2631. },
  2632. controller: ['$scope', '$rootScope', 'api_text', function($scope, $rootScope, api_text) {
  2633. $scope.dialout = function(teleno) {
  2634. var gid = "@0"
  2635. var telephone = '9' + teleno
  2636. api_text.dialout($rootScope.takes, gid, telephone).then(function(data) {
  2637. if (data.errno == 0) {
  2638. $rootScope.status = 6;
  2639. }
  2640. })
  2641. }
  2642. $scope.options.templateOptions.that = $scope;
  2643. }]
  2644. });
  2645. // formlyConfigProvider.setType({
  2646. // name: "ui-closehandler",
  2647. // templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  2648. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2649. // defaultOptions:function(options){
  2650. // return {
  2651. // templateOptions: {
  2652. // }
  2653. // };
  2654. // },
  2655. // controller:['$scope','$rootScope','SweetAlert','api_text', function($scope,$rootScope,SweetAlert,api_text){
  2656. // $scope.group="";
  2657. // // $scope.role="";
  2658. // if(angular.isDefined($scope.model.handlingPersonnelUser.group) &&$scope.model.handlingPersonnelUser.group.length==1){
  2659. // $scope.group=$scope.model.handlingPersonnelUser.group[0].groupName;
  2660. // }else{
  2661. // for(var i=0;i<$scope.model.handlingPersonnelUser.group.length;i++){
  2662. // $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName +",";
  2663. // }
  2664. // }
  2665. // // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  2666. // // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  2667. // // }else{
  2668. // // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  2669. // // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  2670. // // }
  2671. // // }
  2672. // $scope.options.templateOptions.that = $scope;
  2673. // $scope.dialout = function(teleno){
  2674. // api_text.callout($rootScope.takes,teleno).then(function(data){
  2675. // if(data.errno==0){
  2676. // SweetAlert.swal({
  2677. // title: "呼叫成功",
  2678. // text: "呼叫中心呼叫成功!",
  2679. // type: "success"
  2680. // });
  2681. // }else{SweetAlert.swal({
  2682. // title: "呼叫失败",
  2683. // text: "请重新呼叫!",
  2684. // type: "error"
  2685. // });
  2686. // }
  2687. // })
  2688. // }
  2689. // }]
  2690. // });
  2691. //用户单选控件
  2692. // formlyConfigProvider.setType({
  2693. // name: "ui-userselect",
  2694. // templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  2695. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2696. // defaultOptions: function(options) {
  2697. // return {
  2698. // templateOptions: {
  2699. // openModal: function(size, options, modal) {
  2700. // var modalInstance = modal.open({
  2701. // templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  2702. // controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  2703. // $scope.langs = i18nService.getAllLangs();
  2704. // $scope.lang = 'zh-cn';
  2705. // i18nService.setCurrentLang($scope.lang);
  2706. // $scope.gridOptions = {};
  2707. // $scope.gridOptions.data = 'myData';
  2708. // $scope.gridOptions.enableColumnResizing = true;
  2709. // $scope.gridOptions.enableFiltering = true;
  2710. // $scope.gridOptions.enableGridMenu = true;
  2711. // $scope.gridOptions.enableRowSelection = true;
  2712. // $scope.gridOptions.showGridFooter = true;
  2713. // $scope.gridOptions.showColumnFooter = true;
  2714. // $scope.gridOptions.fastWatch = true;
  2715. // $scope.gridOptions.useExternalFiltering = true;
  2716. // $scope.gridOptions.useExternalPagination = true;
  2717. // $scope.gridOptions.paginationPageSizes = [10];
  2718. // $scope.gridOptions.paginationPageSize = 10;
  2719. // $scope.gridOptions.multiSelect = false;
  2720. // $scope.gridOptions.rowIdentity = function(row) {
  2721. // return row.id;
  2722. // };
  2723. // $scope.gridOptions.getRowIdentity = function(row) {
  2724. // return row.id;
  2725. // };
  2726. // //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  2727. // $scope.gridOptions.columnDefs = [
  2728. // // { name:'id', width:80, enableFiltering:false},
  2729. // { name: 'account', displayName: '学工号', width: 120 },
  2730. // { name: 'name', displayName: '名称', width: 100 },
  2731. // { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
  2732. // { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  2733. // { name: 'email', displayName: '邮件', width: 120, enableFiltering: false },
  2734. // { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
  2735. // { name: 'role[0].role', displayName: '角色', width: 100, enableFiltering: false },
  2736. // { name: 'taskCount', displayName: '处理中事件数', width: 100, enableFiltering: false }
  2737. // ];
  2738. // $scope.gridOptions.onRegisterApi = function(gridApi) {
  2739. // $scope.gridApi = gridApi;
  2740. // gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  2741. // var filtersData = $scope.memoryfilterData;
  2742. // filtersData.idx = newPage - 1;
  2743. // filtersData.sum = pageSize;
  2744. // $scope.loadData(filtersData);
  2745. // //console.log(pageSize);
  2746. // // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  2747. // });
  2748. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  2749. // $scope.selected.item = data.entity;
  2750. // //console.log(data);
  2751. // });
  2752. // gridApi.core.on.filterChanged($scope, function() {
  2753. // var grid = this.grid;
  2754. // var filtersData = {
  2755. // idx: 0,
  2756. // sum: 10,
  2757. // "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2758. // };
  2759. // angular.forEach(grid.columns, function(item) {
  2760. // if (item.enableFiltering) {
  2761. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  2762. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  2763. // if (angular.isUndefined(filtersData['user'])) {
  2764. // filtersData['user'] = {};
  2765. // }
  2766. // filtersData['user'][item.field] = item.filters[0].term;
  2767. // }
  2768. // }
  2769. // });
  2770. // $scope.memoryfilterData = filtersData;
  2771. // $scope.loadData(filtersData);
  2772. // });
  2773. // };
  2774. // if (!options.model) {
  2775. // var mouse = { "model": { "currentRole": "" } };
  2776. // angular.extend(options, mouse);
  2777. // }
  2778. // $scope.memoryfilterData = {
  2779. // "idx": 0,
  2780. // "sum": 10,
  2781. // "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2782. // }
  2783. // $scope.loadData = function(filterData) {
  2784. // console.log("filtersData=111" + JSON.stringify(filterData))
  2785. // items.fetchItems(filterData, APIService).then(function(data) {
  2786. // var myData = Restangular.stripRestangular(data);
  2787. // $scope.gridOptions.totalItems = myData.totalNum;
  2788. // $scope.myData = myData.list;
  2789. // });
  2790. // };
  2791. // $scope.title = title;
  2792. // $scope.loadData({
  2793. // idx: 0,
  2794. // sum: 10,
  2795. // "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  2796. // });
  2797. // $scope.selected = {
  2798. // item: {}
  2799. // };
  2800. // $scope.ok = function() {
  2801. // // if(onDataCallback&&angular.isFunction(onDataCallback)){
  2802. // // onDataCallback($scope.selected.item, parentScope);
  2803. // // }
  2804. // $modalInstance.close($scope.selected.item);
  2805. // };
  2806. // $scope.cancel = function() {
  2807. // $modalInstance.dismiss('cancel');
  2808. // };
  2809. // },
  2810. // size: size,
  2811. // resolve: {
  2812. // items: function() {
  2813. // return {
  2814. // fetchItems: function(filterData, APIService) {
  2815. // filterData = filterData || {};
  2816. // console.log(options)
  2817. // if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  2818. // filterData = {
  2819. // idx: 0,
  2820. // sum: 10,
  2821. // "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
  2822. // };
  2823. // }
  2824. // // function (filterData, APIService){filterData.user.roledata.rolecode='question investigation';return APIService.fetchDataList('user',filterData);}
  2825. // return options.templateOptions.fetchItems(filterData, APIService);
  2826. // }
  2827. // };
  2828. // },
  2829. // title: function() {
  2830. // return options.templateOptions.modalTitle;
  2831. // },
  2832. // Restangular: function() {
  2833. // return options.templateOptions.Restangular;
  2834. // },
  2835. // APIService: function() {
  2836. // return options.templateOptions.ApiService;
  2837. // },
  2838. // onDataCallback: function() {
  2839. // return options.templateOptions.callback;
  2840. // },
  2841. // parentScope: function() {
  2842. // return options.templateOptions.that;
  2843. // }
  2844. // }
  2845. // });
  2846. // modalInstance.result.then(function(selectedItem) {
  2847. // // console.log(selectedItem);
  2848. // options.value(selectedItem);
  2849. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  2850. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  2851. // }
  2852. // }, function() {
  2853. // //console.log('Modal dismissed at: ' + new Date());
  2854. // });
  2855. // }
  2856. // }
  2857. // };
  2858. // },
  2859. // controller: ['$scope', function($scope) {
  2860. // $scope.model[$scope.options.key] = [];
  2861. // $scope.options.templateOptions.that = $scope;
  2862. // }]
  2863. // });
  2864. //处理人控件 10#
  2865. formlyConfigProvider.setType({
  2866. name: "ui-userselect",
  2867. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  2868. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2869. // defaultOptions: function(options) {
  2870. // return {
  2871. // templateOptions: {
  2872. // refresh: function(filterData, APIService) {
  2873. // return APIService.fetchDataList('user', filterData);
  2874. // }
  2875. // }
  2876. // };
  2877. // },
  2878. controller: ['$scope', function($scope) {
  2879. // $scope.model[$scope.options.key] = [];
  2880. // var filterData = {
  2881. // idx: 0,
  2882. // sum: 10,
  2883. // "user": { "roledata": { "rolecode": $scope.model.currentRole }, "selectType": "1" }
  2884. // };
  2885. // $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data) {
  2886. // var myData = data.list;
  2887. // $scope.myData = myData;
  2888. // // $scope.model[$scope.options.key] = myData;
  2889. // // $scope.options.value(myData);
  2890. // // $scope.options.formControl.$validate();
  2891. // });
  2892. // $scope.getItem = function(item) {
  2893. // $scope.model[$scope.options.key] = item;
  2894. // $scope.options.value(item);
  2895. // $scope.pl = item.name;
  2896. // if ($scope.model.closecode) {
  2897. // delete $scope.model.closecode
  2898. // };
  2899. // if ($scope.model.degree) {
  2900. // delete $scope.model.degree
  2901. // };
  2902. // }
  2903. // $scope.addlist = function() {
  2904. // $scope.editId = 6;
  2905. // $scope.model[$scope.options.key].push("");
  2906. // }
  2907. // $scope.editId = -1;
  2908. // $scope.setEditId = function(pid, usersdata) {
  2909. // $scope.usersdata = {};
  2910. // $scope.editId = pid;
  2911. // angular.extend($scope.usersdata, usersdata)
  2912. // };
  2913. // $scope.savelist = function(usersdata, pid) {
  2914. // // console.log($scope.model[$scope.options.key])
  2915. // for (i = 0; i < $scope.model[$scope.options.key].length; i++) {
  2916. // if (usersdata.account == $scope.model[$scope.options.key][i].account) {
  2917. // $scope.model[$scope.options.key][i] = $scope.usersdata;
  2918. // }
  2919. // }
  2920. // $scope.editId = pid;
  2921. // };
  2922. // $scope.remove = function(itemId) {
  2923. // angular.forEach($scope.model[$scope.options.key], function(entry, index) {
  2924. // if (entry.id == itemId) {
  2925. // $scope.model[$scope.options.key].splice(index, 1);
  2926. // console.log($scope.options.formControl)
  2927. // $scope.options.formControl.$validate();
  2928. // } else {
  2929. // }
  2930. // });
  2931. // }
  2932. // if ($scope.options.templateOptions.transform) {
  2933. // $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  2934. // }
  2935. // if (angular.isFunction($scope.options.templateOptions.translate)) {
  2936. // $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope);
  2937. // }
  2938. // $scope.$select.disabled = $scope.to.readOnly;
  2939. $scope.to['onChange'] = function(item, opts, ts, event, model) {
  2940. $scope.model[$scope.options.key] = ts.$select.selected;
  2941. }
  2942. }]
  2943. });
  2944. //可编辑列表控件
  2945. // formlyConfigProvider.setType({
  2946. // name: "ui-multiuserselectchange",
  2947. // templateUrl: 'assets/views/customform/tpl/ui-multiuserselectchange.html',
  2948. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2949. // defaultOptions:function(options){
  2950. // return {
  2951. // templateOptions: {
  2952. // refresh:function(filterData,APIService){
  2953. // return APIService.fetchDataList('user',filterData);
  2954. // }
  2955. // },
  2956. // validators:{
  2957. // required:{
  2958. // expression:function(viewValue, modelValue){
  2959. // var value = modelValue || viewValue;
  2960. // return value.length>=1;
  2961. // }
  2962. // }
  2963. // }
  2964. // };
  2965. // },
  2966. // controller:['$scope','$filter', function($scope,$filter){
  2967. // $scope.model[$scope.options.key] = [];
  2968. // var filterData = {
  2969. // idx:0,
  2970. // sum:10,
  2971. // "user":{"roledata":{"rolecode":$scope.model.currentRole},"selectType":"1"}
  2972. // };
  2973. // $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data){
  2974. // var myData = data.list;
  2975. // $scope.model[$scope.options.key]=myData;
  2976. // $scope.options.value(myData);
  2977. // $scope.options.formControl.$validate();
  2978. // });
  2979. // $scope.addlist = function(){
  2980. // $scope.editId =6;
  2981. // $scope.model[$scope.options.key].push("");
  2982. // }
  2983. // // $scope.tableParams = new ngTableParams({
  2984. // // page: 1,
  2985. // // count: 10
  2986. // // }, {
  2987. // // total: data.length,
  2988. // // getData: function ($defer, params) {
  2989. // // var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  2990. // // $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  2991. // // }
  2992. // // });
  2993. // $scope.editId = -1;
  2994. // $scope.setEditId = function (pid,usersdata) {
  2995. // $scope.usersdata={};
  2996. // $scope.editId = pid;
  2997. // angular.extend($scope.usersdata,usersdata)
  2998. // };
  2999. // $scope.savelist = function (usersdata,pid) {
  3000. // // console.log($scope.model[$scope.options.key])
  3001. // for(i=0;i<$scope.model[$scope.options.key].length;i++){
  3002. // if(usersdata.account==$scope.model[$scope.options.key][i].account){
  3003. // $scope.model[$scope.options.key][i]=$scope.usersdata;
  3004. // }
  3005. // }
  3006. // $scope.editId = pid;
  3007. // };
  3008. // $scope.remove = function(itemId){
  3009. // angular.forEach($scope.model[$scope.options.key], function(entry,index){
  3010. // if(entry.id == itemId){
  3011. // $scope.model[$scope.options.key].splice(index,1);
  3012. // console.log($scope.options.formControl)
  3013. // $scope.options.formControl.$validate();
  3014. // }else{
  3015. // }
  3016. // });
  3017. // }
  3018. // }]
  3019. // });
  3020. formlyConfigProvider.setType({
  3021. name: "ui-multiuserselectchange",
  3022. templateUrl: 'assets/views/customform/tpl/ui-multiuserselectchange.html',
  3023. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3024. defaultOptions: function(options) {
  3025. return {
  3026. templateOptions: {
  3027. // refresh:function(filterData,APIService){
  3028. // return APIService.fetchDataList('user',filterData);
  3029. // }
  3030. },
  3031. validators: {
  3032. required: {
  3033. expression: function(viewValue, modelValue) {
  3034. var value = modelValue || viewValue;
  3035. return value.length >= 1;
  3036. }
  3037. }
  3038. }
  3039. };
  3040. },
  3041. controller: ['$scope', '$filter', function($scope, $filter) {
  3042. $scope.model[$scope.options.key] = [];
  3043. var filterData = {
  3044. idx: 0,
  3045. sum: 10,
  3046. "user": { "roledata": { "rolecode": $scope.model.currentRole }, "selectType": "1" }
  3047. };
  3048. $scope.options.templateOptions.refresh(filterData, $scope.options.templateOptions.ApiService).then(function(data) {
  3049. var myData = data.list;
  3050. $scope.model[$scope.options.key] = myData;
  3051. $scope.options.value(myData);
  3052. $scope.options.formControl.$validate();
  3053. });
  3054. $scope.addlist = function() {
  3055. $scope.editId = 6;
  3056. $scope.model[$scope.options.key].push("");
  3057. }
  3058. $scope.editId = -1;
  3059. $scope.setEditId = function(pid, usersdata) {
  3060. $scope.usersdata = {};
  3061. $scope.editId = pid;
  3062. angular.extend($scope.usersdata, usersdata)
  3063. };
  3064. $scope.savelist = function(usersdata, pid) {
  3065. // console.log($scope.model[$scope.options.key])
  3066. for (i = 0; i < $scope.model[$scope.options.key].length; i++) {
  3067. if (usersdata.account == $scope.model[$scope.options.key][i].account) {
  3068. $scope.model[$scope.options.key][i] = $scope.usersdata;
  3069. }
  3070. }
  3071. $scope.editId = pid;
  3072. };
  3073. $scope.remove = function(itemId) {
  3074. angular.forEach($scope.model[$scope.options.key], function(entry, index) {
  3075. if (entry.id == itemId) {
  3076. $scope.model[$scope.options.key].splice(index, 1);
  3077. console.log($scope.options.formControl)
  3078. $scope.options.formControl.$validate();
  3079. } else {
  3080. }
  3081. });
  3082. }
  3083. }]
  3084. });
  3085. //用户多选控件
  3086. formlyConfigProvider.setType({
  3087. name: "ui-multiuserselect",
  3088. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  3089. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3090. defaultOptions: function(options) {
  3091. return {
  3092. templateOptions: {
  3093. openModal: function(size, options, modal, model) {
  3094. var modalInstance = modal.open({
  3095. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  3096. controller: function($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  3097. $scope.langs = i18nService.getAllLangs();
  3098. $scope.lang = 'zh-cn';
  3099. i18nService.setCurrentLang($scope.lang);
  3100. $scope.gridOptions = {};
  3101. $scope.gridOptions.data = 'myData';
  3102. $scope.gridOptions.enableColumnResizing = true;
  3103. $scope.gridOptions.enableFiltering = true;
  3104. $scope.gridOptions.enableGridMenu = true;
  3105. $scope.gridOptions.showGridFooter = true;
  3106. $scope.gridOptions.showColumnFooter = true;
  3107. $scope.gridOptions.fastWatch = true;
  3108. $scope.gridOptions.useExternalFiltering = true;
  3109. $scope.gridOptions.useExternalPagination = true;
  3110. $scope.gridOptions.paginationPageSizes = [10];
  3111. $scope.gridOptions.paginationPageSize = 10;
  3112. $scope.gridOptions.multiSelect = true;
  3113. $scope.gridOptions.rowIdentity = function(row) {
  3114. return row.id;
  3115. };
  3116. $scope.gridOptions.getRowIdentity = function(row) {
  3117. return row.id;
  3118. };
  3119. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  3120. $scope.gridOptions.columnDefs = [
  3121. // { name:'id', width:80, enableFiltering:false},
  3122. { name: 'account', displayName: '账号', width: 140 },
  3123. { name: 'name', displayName: '名称', width: 100 },
  3124. { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
  3125. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  3126. { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
  3127. { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
  3128. { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: false }
  3129. ];
  3130. $scope.selected = {
  3131. items: selectItems
  3132. };
  3133. $scope.gridOptions.onRegisterApi = function(gridApi) {
  3134. $scope.gridApi = gridApi;
  3135. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  3136. var filtersData = $scope.memoryfilterData;
  3137. filtersData.idx = newPage - 1;
  3138. filtersData.sum = pageSize;
  3139. $scope.loadData(filtersData);
  3140. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  3141. });
  3142. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  3143. var j = 0;
  3144. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  3145. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  3146. j++;
  3147. break;
  3148. }
  3149. }
  3150. if (j == 1) {
  3151. scope.grid.appScope.selected.items.splice(i, 1);
  3152. } else {
  3153. scope.grid.appScope.selected.items.push(scope.entity)
  3154. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  3155. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  3156. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  3157. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  3158. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  3159. scope.grid.appScope.selected.items.splice(i, 1);
  3160. }
  3161. }
  3162. }
  3163. }
  3164. });
  3165. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  3166. // $scope.grid.appScope.selected.items.push($scope.entity);
  3167. // });
  3168. gridApi.core.on.filterChanged($scope, function() {
  3169. var grid = this.grid;
  3170. var filtersData = {
  3171. idx: 0,
  3172. sum: 10,
  3173. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  3174. };
  3175. angular.forEach(grid.columns, function(item) {
  3176. if (item.enableFiltering) {
  3177. //console.log("filtersData="+JSON.stringify(filtersData))
  3178. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  3179. if (angular.isUndefined(filtersData['user'])) {
  3180. filtersData['user'] = {};
  3181. }
  3182. filtersData['user'][item.field] = item.filters[0].term;
  3183. }
  3184. }
  3185. });
  3186. $scope.memoryfilterData = filtersData;
  3187. $scope.loadData(filtersData);
  3188. });
  3189. };
  3190. if (!options.model) {
  3191. var mouse = { "model": { "currentRole": "" } };
  3192. angular.extend(options, mouse);
  3193. }
  3194. $scope.memoryfilterData = {
  3195. "idx": 0,
  3196. "sum": 10,
  3197. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  3198. }
  3199. $scope.loadData = function(filterData) {
  3200. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  3201. items.fetchItems(filterData, APIService).then(function(data) {
  3202. var myData = Restangular.stripRestangular(data);
  3203. $scope.gridOptions.totalItems = myData.totalNum;
  3204. $scope.myData = myData.list;
  3205. //console.log($scope.gridOptions.pagination.getTotalPages());
  3206. // if($scope.selected.items){
  3207. // angular.forEach($scope.selected.items,function(selectItem){
  3208. // $scope.gridApi.selection.selectRow(selectItem);
  3209. // });
  3210. // }
  3211. });
  3212. };
  3213. $scope.title = title;
  3214. $scope.loadData({
  3215. idx: 0,
  3216. sum: 10,
  3217. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  3218. });
  3219. // $timeout(function(){
  3220. // if($scope.selected.items){
  3221. // angular.forEach($scope.selected.items,function(selectItem){
  3222. // $scope.gridApi.selection.selectRow(selectItem);
  3223. // });
  3224. // }
  3225. // },2000)
  3226. $scope.ok = function() {
  3227. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  3228. $modalInstance.close($scope.selected.items);
  3229. };
  3230. $scope.cancel = function() {
  3231. $modalInstance.dismiss('cancel');
  3232. };
  3233. },
  3234. size: size,
  3235. resolve: {
  3236. items: function() {
  3237. return {
  3238. fetchItems: function(filterData, APIService) {
  3239. filterData = filterData || {};
  3240. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  3241. filterData = {
  3242. idx: 0,
  3243. sum: 10,
  3244. "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
  3245. };
  3246. }
  3247. return options.templateOptions.fetchItems(filterData, APIService);
  3248. }
  3249. };
  3250. },
  3251. title: function() {
  3252. return options.templateOptions.modalTitle;
  3253. },
  3254. Restangular: function() {
  3255. return options.templateOptions.Restangular;
  3256. },
  3257. APIService: function() {
  3258. return options.templateOptions.ApiService;
  3259. },
  3260. selectItems: function() {
  3261. return model || [];
  3262. }
  3263. }
  3264. });
  3265. modalInstance.result.then(function(selectedItem) {
  3266. options.value(selectedItem);
  3267. options.formControl.$validate();
  3268. }, function() {
  3269. //console.log('Modal dismissed at: ' + new Date());
  3270. });
  3271. }
  3272. },
  3273. validators: {
  3274. required: {
  3275. expression: function(viewValue, modelValue) {
  3276. var value = modelValue || viewValue;
  3277. return value.length >= 1;
  3278. }
  3279. }
  3280. }
  3281. };
  3282. },
  3283. controller: ['$scope', function($scope) {
  3284. $scope.model[$scope.options.key] = [];
  3285. $scope.remove = function(itemId) {
  3286. angular.forEach($scope.model[$scope.options.key], function(entry, index) {
  3287. if (entry.id == itemId) {
  3288. $scope.model[$scope.options.key].splice(index, 1);
  3289. console.log($scope.options.formControl)
  3290. $scope.options.formControl.$validate();
  3291. } else {
  3292. }
  3293. });
  3294. }
  3295. }]
  3296. });
  3297. //重复事件
  3298. formlyConfigProvider.setType({
  3299. name: "ui-incidentmodelselect",
  3300. extends: 'input',
  3301. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  3302. defaultOptions: function(options) {
  3303. return {
  3304. templateOptions: {
  3305. openModal: function(size, options, modal) {
  3306. var modalInstance = modal.open({
  3307. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  3308. controller: function($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  3309. $scope.langs = i18nService.getAllLangs();
  3310. $scope.lang = 'zh-cn';
  3311. i18nService.setCurrentLang($scope.lang);
  3312. $scope.gridOptions = {};
  3313. $scope.gridOptions.data = 'myData';
  3314. $scope.gridOptions.enableColumnResizing = true;
  3315. $scope.gridOptions.enableFiltering = true;
  3316. $scope.gridOptions.enableGridMenu = true;
  3317. $scope.gridOptions.enableRowSelection = true;
  3318. $scope.gridOptions.showGridFooter = true;
  3319. $scope.gridOptions.showColumnFooter = true;
  3320. $scope.gridOptions.fastWatch = true;
  3321. $scope.gridOptions.useExternalFiltering = false;
  3322. // $scope.gridOptions.useExternalPagination = true;
  3323. $scope.gridOptions.paginationPageSizes = [10];
  3324. $scope.gridOptions.paginationPageSize = 10;
  3325. $scope.gridOptions.multiSelect = false;
  3326. $scope.gridOptions.rowIdentity = function(row) {
  3327. return row.id;
  3328. };
  3329. $scope.gridOptions.getRowIdentity = function(row) {
  3330. return row.id;
  3331. };
  3332. $scope.gridOptions.columnDefs = items.columnDefs();
  3333. $scope.gridOptions.onRegisterApi = function(gridApi) {
  3334. $scope.gridApi = gridApi;
  3335. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  3336. // console.log(newPage);
  3337. // console.log(pageSize);
  3338. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  3339. });
  3340. gridApi.core.on.filterChanged($scope, function() {
  3341. var grid = this.grid;
  3342. var filtersData = {
  3343. idx: 0,
  3344. sum: 10
  3345. };
  3346. angular.forEach(grid.columns, function(item) {
  3347. if (item.enableFiltering) {
  3348. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  3349. // console.log("filtersData="+JSON.stringify(filtersData))
  3350. if (angular.isUndefined(filtersData['incident'])) {
  3351. filtersData['incident'] = {};
  3352. }
  3353. filtersData['incident'][item.field] = item.filters[0].term;
  3354. if (angular.isUndefined(filtersData['problem'])) {
  3355. filtersData['problem'] = {};
  3356. }
  3357. filtersData['problem'][item.field] = item.filters[0].term;
  3358. if (angular.isUndefined(filtersData['change'])) {
  3359. filtersData['change'] = {};
  3360. }
  3361. filtersData['change'][item.field] = item.filters[0].term;
  3362. if (angular.isUndefined(filtersData['release'])) {
  3363. filtersData['release'] = {};
  3364. }
  3365. filtersData['release'][item.field] = item.filters[0].term;
  3366. }
  3367. }
  3368. });
  3369. $scope.loadData(filtersData);
  3370. });
  3371. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  3372. $scope.selected.item = data.entity;
  3373. //console.log(data);
  3374. });
  3375. };
  3376. $scope.loadData = function(filterData) {
  3377. items.fetchItems(filterData, APIService).then(function(data) {
  3378. var myData = Restangular.stripRestangular(data);
  3379. $scope.gridOptions.totalItems = myData.totalNum;
  3380. $scope.myData = myData.list;
  3381. });
  3382. };
  3383. $scope.title = title;
  3384. $scope.loadData({
  3385. idx: 0,
  3386. sum: 10
  3387. });
  3388. $scope.selected = {
  3389. item: {}
  3390. };
  3391. $scope.ok = function() {
  3392. //console.log($scope.selected.item);
  3393. $modalInstance.close($scope.selected.item);
  3394. };
  3395. $scope.cancel = function() {
  3396. $modalInstance.dismiss('cancel');
  3397. };
  3398. },
  3399. size: size,
  3400. resolve: {
  3401. items: function() {
  3402. return {
  3403. fetchItems: function(filterData, APIService) {
  3404. filterData = filterData || {};
  3405. // if(!filterData.idx){
  3406. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  3407. filterData = {
  3408. idx: 0,
  3409. sum: 10
  3410. };
  3411. }
  3412. return options.templateOptions.fetchItems(filterData, APIService, options);
  3413. },
  3414. columnDefs: function() {
  3415. return options.templateOptions.columnDefs;
  3416. }
  3417. };
  3418. },
  3419. title: function() {
  3420. return options.templateOptions.modalTitle;
  3421. },
  3422. Restangular: function() {
  3423. return options.templateOptions.Restangular;
  3424. },
  3425. APIService: function() {
  3426. return options.templateOptions.ApiService;
  3427. }
  3428. }
  3429. });
  3430. modalInstance.result.then(function(selectedItem) {
  3431. var selectitem = { title: selectedItem.title, description: selectedItem.description }
  3432. angular.extend(options.model, selectitem);
  3433. options.value(selectedItem);
  3434. }, function() {
  3435. //console.log('Modal dismissed at: ' + new Date());
  3436. });
  3437. }
  3438. }
  3439. };
  3440. }
  3441. });
  3442. //选项选择控件
  3443. formlyConfigProvider.setType({
  3444. name: "ui-modelselect",
  3445. extends: 'input',
  3446. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  3447. defaultOptions: function(options) {
  3448. return {
  3449. templateOptions: {
  3450. openModal: function(size, options, modal) {
  3451. var modalInstance = modal.open({
  3452. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  3453. controller: function($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  3454. $scope.langs = i18nService.getAllLangs();
  3455. $scope.lang = 'zh-cn';
  3456. i18nService.setCurrentLang($scope.lang);
  3457. $scope.gridOptions = {};
  3458. $scope.gridOptions.data = 'myData';
  3459. $scope.gridOptions.enableColumnResizing = true;
  3460. $scope.gridOptions.enableFiltering = true;
  3461. $scope.gridOptions.enableGridMenu = false;
  3462. $scope.gridOptions.enableRowSelection = true;
  3463. $scope.gridOptions.showGridFooter = true;
  3464. $scope.gridOptions.showColumnFooter = true;
  3465. $scope.gridOptions.fastWatch = true;
  3466. $scope.gridOptions.useExternalFiltering = true;
  3467. $scope.gridOptions.useExternalPagination = true;
  3468. $scope.gridOptions.paginationPageSizes = [10];
  3469. $scope.gridOptions.paginationPageSize = 10;
  3470. $scope.gridOptions.multiSelect = false;
  3471. $scope.gridOptions.rowIdentity = function(row) {
  3472. return row.id;
  3473. };
  3474. $scope.gridOptions.getRowIdentity = function(row) {
  3475. return row.id;
  3476. };
  3477. $scope.gridOptions.columnDefs = items.columnDefs();
  3478. $scope.gridOptions.onRegisterApi = function(gridApi) {
  3479. $scope.gridApi = gridApi;
  3480. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  3481. // console.log(newPage);
  3482. // console.log(pageSize);
  3483. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  3484. });
  3485. gridApi.core.on.filterChanged($scope, function() {
  3486. var grid = this.grid;
  3487. var filtersData = {
  3488. idx: 0,
  3489. sum: 10
  3490. };
  3491. angular.forEach(grid.columns, function(item) {
  3492. if (item.enableFiltering) {
  3493. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  3494. // console.log("filtersData="+JSON.stringify(filtersData))
  3495. if (angular.isUndefined(filtersData['incident'])) {
  3496. filtersData['incident'] = {};
  3497. }
  3498. filtersData['incident'][item.field] = item.filters[0].term;
  3499. if (angular.isUndefined(filtersData['problem'])) {
  3500. filtersData['problem'] = {};
  3501. }
  3502. filtersData['problem'][item.field] = item.filters[0].term;
  3503. if (angular.isUndefined(filtersData['change'])) {
  3504. filtersData['change'] = {};
  3505. }
  3506. filtersData['change'][item.field] = item.filters[0].term;
  3507. if (angular.isUndefined(filtersData['release'])) {
  3508. filtersData['release'] = {};
  3509. }
  3510. filtersData['release'][item.field] = item.filters[0].term;
  3511. }
  3512. }
  3513. });
  3514. $scope.loadData(filtersData);
  3515. });
  3516. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  3517. $scope.selected.item = data.entity;
  3518. //console.log(data);
  3519. });
  3520. };
  3521. $scope.loadData = function(filterData) {
  3522. items.fetchItems(filterData, APIService).then(function(data) {
  3523. var myData = Restangular.stripRestangular(data);
  3524. $scope.gridOptions.totalItems = myData.totalNum;
  3525. $scope.myData = myData.list;
  3526. });
  3527. };
  3528. $scope.title = title;
  3529. $scope.loadData({
  3530. idx: 0,
  3531. sum: 10
  3532. });
  3533. $scope.selected = {
  3534. item: {}
  3535. };
  3536. $scope.ok = function() {
  3537. //console.log($scope.selected.item);
  3538. $modalInstance.close($scope.selected.item);
  3539. };
  3540. $scope.cancel = function() {
  3541. $modalInstance.dismiss('cancel');
  3542. };
  3543. },
  3544. size: size,
  3545. resolve: {
  3546. items: function() {
  3547. return {
  3548. fetchItems: function(filterData, APIService) {
  3549. filterData = filterData || {};
  3550. // if(!filterData.idx){
  3551. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  3552. filterData = {
  3553. idx: 0,
  3554. sum: 10
  3555. };
  3556. }
  3557. return options.templateOptions.fetchItems(filterData, APIService, options);
  3558. },
  3559. columnDefs: function() {
  3560. return options.templateOptions.columnDefs;
  3561. }
  3562. };
  3563. },
  3564. title: function() {
  3565. return options.templateOptions.modalTitle;
  3566. },
  3567. Restangular: function() {
  3568. return options.templateOptions.Restangular;
  3569. },
  3570. APIService: function() {
  3571. return options.templateOptions.ApiService;
  3572. }
  3573. }
  3574. });
  3575. modalInstance.result.then(function(selectedItem) {
  3576. options.value(selectedItem);
  3577. }, function() {
  3578. //console.log('Modal dismissed at: ' + new Date());
  3579. });
  3580. }
  3581. }
  3582. };
  3583. }
  3584. });
  3585. formlyConfigProvider.setType({
  3586. name: 'ui-requestform',
  3587. extends: 'input',
  3588. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  3589. controller: ['$scope', function($scope) {
  3590. setTimeout(function() {
  3591. var filterData = {
  3592. "idx": 0,
  3593. "sum": 5,
  3594. "incident": { "requester": { "id": "" } }
  3595. }
  3596. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
  3597. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  3598. });
  3599. }, 1000);
  3600. }]
  3601. });
  3602. //工单控件
  3603. formlyConfigProvider.setType({
  3604. name: 'ui-workernumber',
  3605. // extends: 'input',
  3606. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  3607. controller: ['$scope', function($scope) {
  3608. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  3609. setTimeout(function() {
  3610. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result) {
  3611. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  3612. if (modelData.status == 200) {
  3613. $scope.model[$scope.options.key] = modelData.data;
  3614. $scope.options.initialValue = $scope.model[$scope.options.key];
  3615. }
  3616. });
  3617. }, 1000);
  3618. }
  3619. }]
  3620. });
  3621. //cmdb工单
  3622. formlyConfigProvider.setType({
  3623. name: 'ui-cmdbworkernumber',
  3624. extends: 'input',
  3625. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  3626. controller: ['$scope', function($scope) {
  3627. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  3628. setTimeout(function() {
  3629. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function(result) {
  3630. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  3631. // if(modelData.status==200){
  3632. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  3633. $scope.options.initialValue = $scope.model[$scope.options.key];
  3634. // }
  3635. });
  3636. }, 1000);
  3637. }
  3638. }]
  3639. });
  3640. //无上传按钮附件上传组件
  3641. formlyConfigProvider.setType({
  3642. name: 'ui-dropfilenotup',
  3643. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  3644. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3645. controller: ['$scope', 'FileUploader', '$rootScope', '$ionicPopup', function($scope, FileUploader, $rootScope, $ionicPopup) {
  3646. if (angular.isUndefined($scope.form.dropState)) {
  3647. $scope.form.dropState = false;
  3648. }
  3649. //附件上传数据
  3650. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3651. //$scope.options.templateOptions.uploader();
  3652. // FILTERS
  3653. uploader.filters.push({
  3654. name: 'customFilter',
  3655. // fn: function(item /*{File|FileLikeObject}*/ , options) {
  3656. // return this.queue.length < 10;
  3657. // },
  3658. fn: function(item /*{File|FileLikeObject}*/ , options) {
  3659. var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
  3660. if (item.size > 10 * 1024 * 1024) {
  3661. $ionicPopup.alert({
  3662. title: '图片超过了10M',
  3663. okText: '确认'
  3664. });
  3665. }
  3666. if ('|jpg|png|jpeg|'.indexOf(type) == -1) {
  3667. $ionicPopup.alert({
  3668. title: '图片格式错误',
  3669. okText: '确认'
  3670. });
  3671. }
  3672. return '|jpg|png|jpeg|'.indexOf(type) !== -1 && item.size < 10 * 1024 * 1024;
  3673. // return '|jpg|png|jpeg|'.indexOf(type) !== -1 && this.queue.length < 3;
  3674. },
  3675. // fn: function(item, options) { return this.queue.length < 4; }
  3676. });
  3677. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  3678. uploader.onBeforeUploadItem = function(item) {
  3679. angular.extend(item.headers, $rootScope.getSession());
  3680. item.url = APIService.uploadAttachment(processInstanceId, taskId, userId).getRequestedUrl();
  3681. item.formData.push({ 'fileName': item.file.name });
  3682. console.info('onBeforeUploadItem', item);
  3683. };
  3684. uploader.uploadAll();
  3685. }
  3686. // CALLBACKS
  3687. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  3688. console.info('onWhenAddingFileFailed', item, filter, options);
  3689. };
  3690. uploader.onAfterAddingFile = function(fileItem) {
  3691. console.info('onAfterAddingFile', fileItem);
  3692. };
  3693. uploader.onAfterAddingAll = function(addedFileItems) {
  3694. console.info('onAfterAddingAll', addedFileItems);
  3695. };
  3696. uploader.onBeforeUploadItem = function(item) {
  3697. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  3698. // // $scope.uploader.options.url();
  3699. // $scope.uploader.onBeforeUploadItem = function(item) {
  3700. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  3701. // console.info('onBeforeUploadItem', item);
  3702. // };
  3703. // $scope.uploader.uploadAll();
  3704. // }
  3705. console.info('onBeforeUploadItem', item);
  3706. };
  3707. uploader.onProgressItem = function(fileItem, progress) {
  3708. console.info('onProgressItem', fileItem, progress);
  3709. };
  3710. uploader.onProgressAll = function(progress) {
  3711. console.info('onProgressAll', progress);
  3712. };
  3713. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3714. console.info('onSuccessItem', fileItem, response, status, headers);
  3715. };
  3716. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3717. console.info('onErrorItem', fileItem, response, status, headers);
  3718. };
  3719. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3720. console.info('onCancelItem', fileItem, response, status, headers);
  3721. };
  3722. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3723. console.info('onCompleteItem', fileItem, response, status, headers);
  3724. };
  3725. uploader.onCompleteAll = function() {
  3726. console.info('onCompleteAll');
  3727. };
  3728. }]
  3729. });
  3730. //无按钮知识库上传
  3731. formlyConfigProvider.setType({
  3732. name: 'ui-dropfielkn',
  3733. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  3734. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3735. controller: ['$scope', function($scope) {
  3736. if (angular.isUndefined($scope.form.dropState)) {
  3737. $scope.form.dropState = false;
  3738. }
  3739. //附件上传数据
  3740. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3741. //$scope.options.templateOptions.uploader();
  3742. // FILTERS
  3743. uploader.filters.push({
  3744. name: 'customFilter',
  3745. fn: function(item /*{File|FileLikeObject}*/ , options) {
  3746. return this.queue.length < 10;
  3747. }
  3748. });
  3749. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  3750. uploader.onBeforeUploadItem = function(item) {
  3751. angular.extend(item.headers, $rootScope.getSession());
  3752. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  3753. item.formData.push({ 'fileName': item.file.name });
  3754. console.info('onBeforeUploadItem', item);
  3755. };
  3756. uploader.uploadAll();
  3757. }
  3758. // CALLBACKS
  3759. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  3760. console.info('onWhenAddingFileFailed', item, filter, options);
  3761. };
  3762. uploader.onAfterAddingFile = function(fileItem) {
  3763. console.info('onAfterAddingFile', fileItem);
  3764. };
  3765. uploader.onAfterAddingAll = function(addedFileItems) {
  3766. console.info('onAfterAddingAll', addedFileItems);
  3767. };
  3768. uploader.onBeforeUploadItem = function(item) {
  3769. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  3770. // // $scope.uploader.options.url();
  3771. // $scope.uploader.onBeforeUploadItem = function(item) {
  3772. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  3773. // console.info('onBeforeUploadItem', item);
  3774. // };
  3775. // $scope.uploader.uploadAll();
  3776. // }
  3777. console.info('onBeforeUploadItem', item);
  3778. };
  3779. uploader.onProgressItem = function(fileItem, progress) {
  3780. console.info('onProgressItem', fileItem, progress);
  3781. };
  3782. uploader.onProgressAll = function(progress) {
  3783. console.info('onProgressAll', progress);
  3784. };
  3785. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3786. console.info('onSuccessItem', fileItem, response, status, headers);
  3787. };
  3788. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3789. console.info('onErrorItem', fileItem, response, status, headers);
  3790. };
  3791. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3792. console.info('onCancelItem', fileItem, response, status, headers);
  3793. };
  3794. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3795. console.info('onCompleteItem', fileItem, response, status, headers);
  3796. };
  3797. uploader.onCompleteAll = function() {
  3798. console.info('onCompleteAll');
  3799. };
  3800. }]
  3801. });
  3802. //附件上传列表组件
  3803. formlyConfigProvider.setType({
  3804. name: 'ui-dropfile',
  3805. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  3806. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3807. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  3808. if (angular.isUndefined($scope.form.dropState)) {
  3809. $scope.form.dropState = false;
  3810. }
  3811. //附件上传数据
  3812. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3813. //$scope.options.templateOptions.uploader();
  3814. // FILTERS
  3815. uploader.filters.push({
  3816. name: 'customFilter',
  3817. fn: function(item /*{File|FileLikeObject}*/ , options) {
  3818. return this.queue.length < 10;
  3819. }
  3820. });
  3821. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  3822. uploader.onBeforeUploadItem = function(item) {
  3823. angular.extend(item.headers, $rootScope.getSession());
  3824. item.url = APIService.uploadAttachment(processInstanceId, taskId, userId).getRequestedUrl();
  3825. item.formData.push({ 'fileName': item.file.name });
  3826. console.info('onBeforeUploadItem', item);
  3827. };
  3828. uploader.uploadAll();
  3829. }
  3830. // CALLBACKS
  3831. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  3832. console.info('onWhenAddingFileFailed', item, filter, options);
  3833. };
  3834. uploader.onAfterAddingFile = function(fileItem) {
  3835. console.info('onAfterAddingFile', fileItem);
  3836. };
  3837. uploader.onAfterAddingAll = function(addedFileItems) {
  3838. console.info('onAfterAddingAll', addedFileItems);
  3839. };
  3840. uploader.onBeforeUploadItem = function(item) {
  3841. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  3842. // // $scope.uploader.options.url();
  3843. // $scope.uploader.onBeforeUploadItem = function(item) {
  3844. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  3845. // console.info('onBeforeUploadItem', item);
  3846. // };
  3847. // $scope.uploader.uploadAll();
  3848. // }
  3849. console.info('onBeforeUploadItem', item);
  3850. };
  3851. uploader.onProgressItem = function(fileItem, progress) {
  3852. console.info('onProgressItem', fileItem, progress);
  3853. };
  3854. uploader.onProgressAll = function(progress) {
  3855. console.info('onProgressAll', progress);
  3856. };
  3857. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3858. console.info('onSuccessItem', fileItem, response, status, headers);
  3859. };
  3860. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3861. console.info('onErrorItem', fileItem, response, status, headers);
  3862. };
  3863. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3864. console.info('onCancelItem', fileItem, response, status, headers);
  3865. };
  3866. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3867. console.info('onCompleteItem', fileItem, response, status, headers);
  3868. };
  3869. uploader.onCompleteAll = function() {
  3870. console.info('onCompleteAll');
  3871. };
  3872. }]
  3873. });
  3874. //知识库附件上传
  3875. formlyConfigProvider.setType({
  3876. name: 'ui-dropfielknow',
  3877. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  3878. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  3879. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  3880. if (angular.isUndefined($scope.form.dropState)) {
  3881. $scope.form.dropState = false;
  3882. }
  3883. //附件上传数据
  3884. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3885. //$scope.options.templateOptions.uploader();
  3886. // FILTERS
  3887. uploader.filters.push({
  3888. name: 'customFilter',
  3889. fn: function(item /*{File|FileLikeObject}*/ , options) {
  3890. return this.queue.length < 10;
  3891. }
  3892. });
  3893. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  3894. uploader.onBeforeUploadItem = function(item) {
  3895. angular.extend(item.headers, $rootScope.getSession());
  3896. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  3897. item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': $scope.model.knowledge.id });
  3898. console.info('onBeforeUploadItem', item);
  3899. };
  3900. uploader.uploadAll();
  3901. }
  3902. // CALLBACKS
  3903. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  3904. console.info('onWhenAddingFileFailed', item, filter, options);
  3905. };
  3906. uploader.onAfterAddingFile = function(fileItem) {
  3907. console.info('onAfterAddingFile', fileItem);
  3908. };
  3909. uploader.onAfterAddingAll = function(addedFileItems) {
  3910. console.info('onAfterAddingAll', addedFileItems);
  3911. };
  3912. uploader.onBeforeUploadItem = function(item) {
  3913. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  3914. // // $scope.uploader.options.url();
  3915. // $scope.uploader.onBeforeUploadItem = function(item) {
  3916. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  3917. // console.info('onBeforeUploadItem', item);
  3918. // };
  3919. // $scope.uploader.uploadAll();
  3920. // }
  3921. console.info('onBeforeUploadItem', item);
  3922. };
  3923. uploader.onProgressItem = function(fileItem, progress) {
  3924. console.info('onProgressItem', fileItem, progress);
  3925. };
  3926. uploader.onProgressAll = function(progress) {
  3927. console.info('onProgressAll', progress);
  3928. };
  3929. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3930. console.info('onSuccessItem', fileItem, response, status, headers);
  3931. };
  3932. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3933. console.info('onErrorItem', fileItem, response, status, headers);
  3934. };
  3935. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3936. console.info('onCancelItem', fileItem, response, status, headers);
  3937. };
  3938. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3939. console.info('onCompleteItem', fileItem, response, status, headers);
  3940. };
  3941. uploader.onCompleteAll = function() {
  3942. console.info('onCompleteAll');
  3943. };
  3944. }]
  3945. });
  3946. //知识库附件下载列表
  3947. formlyConfigProvider.setType({
  3948. name: 'ui-dropfileknowledge',
  3949. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  3950. defaultOptions: function(options) {
  3951. return {
  3952. templateOptions: {
  3953. refresh: function(APIService, contentId, data) {
  3954. return APIService.fetchDataList(contentId, data);
  3955. },
  3956. downloadUri: function(APIService, contentId) {
  3957. return APIService.downloadAttachment(contentId).getRequestedUrl();
  3958. },
  3959. download: function(APIService, contentId) {
  3960. return APIService.getSolutionDowpath(contentId);
  3961. },
  3962. view: function(attachmentId) {
  3963. // return APIService.attachmentsPreviewUrl(contentId);
  3964. },
  3965. refreshDelay: 0
  3966. }
  3967. };
  3968. },
  3969. controller: ['$scope', '$timeout', '$rootScope', 'api_solution', '$http', function($scope, $timeout, $rootScope, api_solution, $http) {
  3970. var _refreshDelayPromise;
  3971. $scope.downloadUrl = function(contentId) {
  3972. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  3973. };
  3974. $scope.download = function(contentId, filename) {
  3975. $http({
  3976. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  3977. method: 'GET',
  3978. headers: {
  3979. //'Content-type' : 'application/xls',
  3980. 'Accept': '*/*'
  3981. },
  3982. responseType: 'arraybuffer'
  3983. }).success(function(data, status, headers, config) {
  3984. var file = new Blob([data], {
  3985. type: 'application/octet-stream'
  3986. });
  3987. //trick to download store a file having its URL
  3988. var fileURL = URL.createObjectURL(file);
  3989. var a = document.createElement('a');
  3990. a.href = fileURL;
  3991. a.target = '_blank';
  3992. a.download = filename;
  3993. document.body.appendChild(a);
  3994. a.click();
  3995. }).error(function(data, status, headers, config) {
  3996. console.log(data);
  3997. });
  3998. }
  3999. $scope._refresh = function(refreshAttr) {
  4000. if (refreshAttr !== undefined) {
  4001. if (_refreshDelayPromise) {
  4002. $timeout.cancel(_refreshDelayPromise);
  4003. }
  4004. _refreshDelayPromise = $timeout(function() {
  4005. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  4006. 'file', { "file": { "solutionId": $scope.model.knowledge.id }, "idx": "0", "sum": "1000" }).then(function(response) {
  4007. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  4008. if (myData) {
  4009. $scope.attachments = myData.list;
  4010. $scope.view = function(attachmentId) {
  4011. for (var i = 0; i < $scope.attachments.length; i++) {
  4012. if ($scope.attachments[i].id == attachmentId) {
  4013. window.open($scope.attachments[i].previewUrl);
  4014. // var modalInstance = $modal.open({
  4015. // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  4016. // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  4017. // }
  4018. // });
  4019. }
  4020. }
  4021. };
  4022. }
  4023. });
  4024. }, $scope.options.templateOptions.refreshDelay);
  4025. }
  4026. }
  4027. $scope._refresh({});
  4028. // $scope.attachments = $scope.model[$scope.options.key]
  4029. }]
  4030. });
  4031. //附件下载列表组件
  4032. formlyConfigProvider.setType({
  4033. name: 'ui-dropfiletable',
  4034. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  4035. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  4036. defaultOptions: function(options) {
  4037. return {
  4038. templateOptions: {
  4039. refresh: function(APIService, processInstanceId, data) {
  4040. return APIService.listAttachments(processInstanceId, data);
  4041. },
  4042. downloadUri: function(APIService, contentId) {
  4043. return APIService.downloadAttachment(contentId).getRequestedUrl();
  4044. },
  4045. view: function(APIService, contentId) {
  4046. return APIService.attachmentsPreviewUrl(contentId);
  4047. },
  4048. download: function(APIService, contentId, item) {
  4049. var item = { 'url': APIService.download(contentId), 'headers': headers };
  4050. return item;
  4051. },
  4052. refreshDelay: 0
  4053. }
  4054. };
  4055. },
  4056. controller: ['$scope', '$timeout', '$rootScope', '$http', '$ionicPopup', function($scope, $timeout, $rootScope, $http, $ionicPopup) {
  4057. var _refreshDelayPromise;
  4058. // $scope.downloadUrl = function(contentId){
  4059. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  4060. // };
  4061. // $scope.download = function(contentId, filename) {
  4062. $scope.download = function(item) {
  4063. // var headers=
  4064. // $(document).click(function(e) { // 在页面任意位置点击而触发此事件
  4065. // var eId = $(e.target).attr("id"); // e.target表示被点击的目标
  4066. // console.log(eId)
  4067. // });
  4068. // var element = angular.element("#ui-dropfiletable-download");
  4069. // console.log(element)
  4070. $http({
  4071. url: $scope.options.templateOptions.ApiService.download(item.contentId).getRequestedUrl(),
  4072. method: 'GET',
  4073. headers: {
  4074. //'Content-type' : 'application/xls',
  4075. 'Accept': '*/*'
  4076. },
  4077. responseType: 'arraybuffer'
  4078. }).success(function(data, status, headers, config) {
  4079. // $(document).click(function(e) { // 在页面任意位置点击而触发此事件
  4080. // var eId = $(e.target).attr("id"); // e.target表示被点击的目标
  4081. // console.log(eId)
  4082. // });
  4083. // var src = window.URL.createObjectURL(data);
  4084. var file = new Blob([data], {
  4085. type: 'application/octet-stream'
  4086. });
  4087. // var file1 = new Blob(data);
  4088. var src = window.URL.createObjectURL(file);
  4089. //trick to download store a file having its URL
  4090. var fileURL = URL.createObjectURL(file).replace('blob:', '');
  4091. // fileURL.replace('blob:', '');
  4092. window.open(fileURL);
  4093. // var a = document.createElement('a');
  4094. // a.href = fileURL;
  4095. // a.target = '_blank';
  4096. // // a.download = filename;
  4097. // document.body.appendChild(a);
  4098. // a.click();
  4099. // a.id = 'ui-dropfiletable-download-a';
  4100. // if (!document.getElementById('ui-dropfiletable-download-a')) {
  4101. // document.getElementById('ui-dropfiletable-download').appendChild(a);
  4102. // // document.body.appendChild(a);
  4103. // }
  4104. // document.body.appendChild(a);
  4105. // if (!$("#ui-dropfiletable-download-a")) {
  4106. // $("#ui-dropfiletable-download").append(a);
  4107. // }
  4108. // if (document.getElementById('ui-dropfiletable-download-a')) {
  4109. // document.getElementById('ui-dropfiletable-download-a').click();
  4110. // }
  4111. // if ($("#ui-dropfiletable-download-a")) {
  4112. // $("#ui-dropfiletable-download-a").click(function() {
  4113. // alert('ui-dropfiletable-download-a');
  4114. // });
  4115. // }
  4116. // if ($("#ui-dropfiletable-download-a")) {
  4117. // console.log($("#ui-dropfiletable-download-a").attr("id"));
  4118. // $("#ui-dropfiletable-download-a").text('12345')
  4119. // // $("#ui-dropfiletable-download-a").click();
  4120. // }
  4121. }).error(function(data, status, headers, config) {
  4122. // console.log(data);
  4123. });
  4124. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  4125. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  4126. // var file = new Blob([response], {
  4127. // type : 'application/octet-stream'
  4128. // });
  4129. // // var filename = filename;
  4130. // //var file = new Blob([response], {type: 'application/pdf'});
  4131. // var fileURL = URL.createObjectURL(file);
  4132. // var a = document.createElement('a');
  4133. // a.href = fileURL;
  4134. // a.target = '_blank';
  4135. // a.download = filename ;
  4136. // document.body.appendChild(a);
  4137. // a.click();
  4138. // })
  4139. };
  4140. // $scope.view = function(contentId) {
  4141. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  4142. // if (response.state == 200) {
  4143. // window.open(response.previewUrl);
  4144. // }
  4145. // })
  4146. // };
  4147. $scope.view = function(item) {
  4148. if (item.type == 'jpg' || item.type == 'png' || item.type == 'gif') {
  4149. // $http({
  4150. // url: $scope.options.templateOptions.ApiService.download(item.id).getRequestedUrl(),
  4151. // method: 'GET',
  4152. // headers: {
  4153. // //'Content-type' : 'application/xls',
  4154. // 'Accept': '*/*'
  4155. // },
  4156. // responseType: 'arraybuffer'
  4157. // }).success(function(data, status, headers, config) {
  4158. // var file = new Blob([data], {
  4159. // type: 'application/octet-stream'
  4160. // });
  4161. // //trick to download store a file having its URL
  4162. // var img = document.createElement("img");
  4163. // img.onload = function(e) {
  4164. // window.URL.revokeObjectURL(img.src);
  4165. // };
  4166. // // img.src = window.URL.createObjectURL(blob);
  4167. // img.src = window.URL.createObjectURL(file);
  4168. // document.body.appendChild(img);
  4169. // }).error(function(data, status, headers, config) {
  4170. // // console.log(data);
  4171. // });
  4172. $scope.imgUrl = $scope.options.templateOptions.ApiService.download(item.id).getRequestedUrl();
  4173. // $scope.imgShow = true;
  4174. $ionicPopup.alert({
  4175. // template: '<img src="http://115.156.150.70:8080/service/api/bpm/bpm/getAttachmentContent/675069" alt="" ng-src="{{imgUrl}}">',
  4176. // template: '<div>123{{$parent}}</div>',
  4177. template: "<img src=" + $scope.imgUrl + " style='width: 100%;'>",
  4178. okText: '确认'
  4179. })
  4180. } else {
  4181. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, item.id).then(function(response) {
  4182. if (response.state == 200) {
  4183. window.open(response.previewUrl);
  4184. }
  4185. })
  4186. }
  4187. };
  4188. /**
  4189. * refresh
  4190. */
  4191. $scope._refresh = function(refreshAttr) {
  4192. if (refreshAttr !== undefined) {
  4193. if (_refreshDelayPromise) {
  4194. $timeout.cancel(_refreshDelayPromise);
  4195. }
  4196. _refreshDelayPromise = $timeout(function() {
  4197. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  4198. $scope.options.templateOptions.processInstanceId, { 'idx': 0, 'sum': 1000 }).then(function(response) {
  4199. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  4200. if (myData) {
  4201. $scope.attachments = myData.data;
  4202. }
  4203. });
  4204. }, $scope.options.templateOptions.refreshDelay);
  4205. }
  4206. }
  4207. $scope._refresh({});
  4208. // $scope.attachments = $scope.model[$scope.options.key]
  4209. }]
  4210. });
  4211. //微信附件下载列表组件
  4212. formlyConfigProvider.setType({
  4213. name: 'ui-dropfilewechat',
  4214. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  4215. defaultOptions: function(options) {
  4216. return {
  4217. templateOptions: {
  4218. // refresh: function(APIService, processInstanceId, data) {
  4219. // return APIService.listAttachments(processInstanceId, data);
  4220. // },
  4221. // downloadUri: function(APIService, contentId) {
  4222. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  4223. // },
  4224. view: function(APIService, contentId) {
  4225. return APIService.attachmentsPreviewUrl(contentId);
  4226. },
  4227. // download: function(APIService, contentId, item) {
  4228. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  4229. // return item;
  4230. // },
  4231. refreshDelay: 0
  4232. }
  4233. };
  4234. },
  4235. controller: ['$scope', '$timeout', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function($scope, $timeout, $stateParams, $rootScope, $http, api_wechatfile) {
  4236. var _refreshDelayPromise;
  4237. // $scope.downloadUrl = function(contentId){
  4238. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  4239. // };
  4240. $scope.attachments = {};
  4241. $scope.download = function(token, filename) {
  4242. // var headers=
  4243. $http({
  4244. url: $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl(),
  4245. method: 'GET',
  4246. headers: {
  4247. //'Content-type' : 'application/xls',
  4248. 'Accept': '*/*'
  4249. },
  4250. responseType: 'arraybuffer'
  4251. }).success(function(data, status, headers, config) {
  4252. var file = new Blob([data], {
  4253. type: 'application/octet-stream'
  4254. });
  4255. //trick to download store a file having its URL
  4256. var fileURL = URL.createObjectURL(file);
  4257. var a = document.createElement('a');
  4258. a.href = fileURL;
  4259. a.target = '_blank';
  4260. a.download = filename;
  4261. document.body.appendChild(a);
  4262. a.click();
  4263. }).error(function(data, status, headers, config) {
  4264. // console.log(data);
  4265. });
  4266. };
  4267. $scope.view = function(contentId) {
  4268. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  4269. if (response.state == 200) {
  4270. window.open(response.previewUrl);
  4271. }
  4272. })
  4273. };
  4274. /**
  4275. * refresh
  4276. */
  4277. $scope._refresh = function(refreshAttr) {
  4278. if (refreshAttr !== undefined) {
  4279. if (_refreshDelayPromise) {
  4280. $timeout.cancel(_refreshDelayPromise);
  4281. }
  4282. _refreshDelayPromise = $timeout(function() {
  4283. // console.log(JSON.parse($stateParams.model))
  4284. var incidentChart = {};
  4285. if ($stateParams.model) {
  4286. incidentChart = JSON.parse($stateParams.model).model;
  4287. }
  4288. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  4289. $scope.model).then(function(response) {
  4290. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  4291. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  4292. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  4293. if (myData) {
  4294. $scope.attachments = myData.data;
  4295. }
  4296. });
  4297. }, $scope.options.templateOptions.refreshDelay);
  4298. }
  4299. }
  4300. $scope._refresh({});
  4301. // $scope.attachments = $scope.model[$scope.options.key]
  4302. }]
  4303. });
  4304. formlyConfigProvider.setType({
  4305. name: 'ui-paralleltask',
  4306. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  4307. defaultOptions: function(options) {
  4308. return {
  4309. templateOptions: {
  4310. refresh: function(APIService, processInstanceId, data) {
  4311. //return APIService.listAttachments(processInstanceId, data);
  4312. },
  4313. refreshDelay: 0
  4314. }
  4315. };
  4316. },
  4317. controller: ['$scope', '$timeout', function($scope, $timeout) {}]
  4318. });
  4319. //repeatSection
  4320. //
  4321. formlyConfigProvider.setType({
  4322. name: 'ui-repeatSection',
  4323. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  4324. defaultOptions: function(options) {
  4325. return {
  4326. templateOptions: {
  4327. unique: 1,
  4328. initDisplay: false
  4329. }
  4330. };
  4331. },
  4332. controller: function($scope) {
  4333. //$scope.options.templateOptions.unique;
  4334. $scope.formOptions = { formState: $scope.formState };
  4335. $scope.addNew = addNew;
  4336. $scope.copyFields = copyFields;
  4337. function copyFields(fields) {
  4338. fields = angular.copy(fields);
  4339. addRandomIds(fields);
  4340. return fields;
  4341. }
  4342. function addNew() {
  4343. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  4344. var repeatsection = $scope.model[$scope.options.key];
  4345. var lastSection = repeatsection[repeatsection.length - 1];
  4346. var newsection = {};
  4347. repeatsection.push(newsection);
  4348. }
  4349. function addRandomIds(fields) {
  4350. $scope.options.templateOptions.unique++;
  4351. angular.forEach(fields, function(field, index) {
  4352. if (field.fieldGroup) {
  4353. addRandomIds(field.fieldGroup);
  4354. return; // fieldGroups don't need an ID
  4355. }
  4356. if (field.templateOptions && field.templateOptions.fields) {
  4357. addRandomIds(field.templateOptions.fields);
  4358. }
  4359. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  4360. });
  4361. }
  4362. function getRandomInt(min, max) {
  4363. return Math.floor(Math.random() * (max - min)) + min;
  4364. }
  4365. if ($scope.options.templateOptions.initDisplay) {
  4366. addNew();
  4367. }
  4368. }
  4369. });
  4370. //时间轴任务列表组件
  4371. // //主题控件
  4372. // formlyConfigProvider.setType({
  4373. // name: 'ui-titlesearch',
  4374. // templateUrl: 'assets/views/customform/tpl/ui-knowledge.html',
  4375. // extends: 'input',
  4376. // templateUrl : 'assets/views/system/tpl/asideContent.html',
  4377. // defaultOptions:function(options){
  4378. // return {
  4379. // };
  4380. // },
  4381. // controller: ['$scope','$aside',function($scope,$aside){
  4382. // $scope.openAside = function (position) {
  4383. // $aside.open({
  4384. // templateUrl: 'asideContent.html',
  4385. // placement: position,
  4386. // size: 'sm',
  4387. // backdrop: true,
  4388. // controller: function ($scope, $modalInstance) {
  4389. // $scope.ok = function (e) {
  4390. // $modalInstance.close();
  4391. // e.stopPropagation();
  4392. // };
  4393. // $scope.cancel = function (e) {
  4394. // $modalInstance.dismiss();
  4395. // e.stopPropagation();
  4396. // };
  4397. // }
  4398. // });
  4399. // };
  4400. // }]
  4401. // })
  4402. //知识库按钮组件
  4403. formlyConfigProvider.setType({
  4404. name: 'ui-search',
  4405. templateUrl: 'assets/views/customform/tpl/ui-knowledge.html',
  4406. defaultOptions: function(options) {
  4407. return {
  4408. templateOptions: {
  4409. search: function(size, options, modal, keys, fields, el) {
  4410. var modalInstance = modal.open({
  4411. templateUrl: 'assets/views/customform/tpl/search-knowledge.html',
  4412. controller: function($rootScope, $scope, $modalInstance, searchKey, title, Restangular, APIService, modelscope, relatedAction) {
  4413. $scope.options = {
  4414. language: 'zh-cn',
  4415. allowedContent: true,
  4416. entities: false
  4417. };
  4418. $scope.onReady = function() {
  4419. // ...
  4420. };
  4421. $scope.searchKey = searchKey;
  4422. $scope.search = function(key) {
  4423. // var datas={'key':key}
  4424. APIService.searchSolutionByKey(key, $rootScope.user.id).then(function(response) {
  4425. var myData = Restangular.stripRestangular(response);
  4426. // var status=myData.status;
  4427. // if(status=="500"){
  4428. // //toaster.pop('warning', '没有数据', '查询'+keys+'没有数据');
  4429. // }else
  4430. if (myData && myData.length > 0) {
  4431. var data = myData;
  4432. if (data.length > 0) {
  4433. $scope.searchData = data;
  4434. }
  4435. }
  4436. });
  4437. };
  4438. $scope.related = function(item) {
  4439. // angular.forEach(fields, function(field){
  4440. // if(field.key == 'directClose'){
  4441. // field.value(true);
  4442. // modelscope.$parent.$parent.$parent.model['start_code']='close';
  4443. // }
  4444. // if(field.key == 'handleDescription'){
  4445. // field.model['handleDescription']=tentity.content;
  4446. // }
  4447. // });
  4448. if (relatedAction && angular.isFunction(relatedAction)) {
  4449. relatedAction(fields, modelscope, item);
  4450. }
  4451. $scope.cancel();
  4452. // angular.forEach(fields,function(field){
  4453. // });
  4454. }
  4455. $scope.title = title;
  4456. $scope.search(searchKey);
  4457. $scope.selected = {
  4458. item: {}
  4459. };
  4460. $scope.ok = function() {
  4461. //console.log($scope.selected.item);
  4462. $modalInstance.close($scope.selected.item);
  4463. };
  4464. $scope.cancel = function() {
  4465. $modalInstance.dismiss('cancel');
  4466. };
  4467. },
  4468. size: size,
  4469. resolve: {
  4470. searchKey: function() {
  4471. return keys;
  4472. },
  4473. title: function() {
  4474. return options.templateOptions.modalTitle;
  4475. },
  4476. Restangular: function() {
  4477. return options.templateOptions.Restangular;
  4478. },
  4479. APIService: function() {
  4480. return options.templateOptions.ApiService;
  4481. },
  4482. modelscope: function() {
  4483. return el.$parent;
  4484. },
  4485. relatedAction: function() {
  4486. return options.templateOptions.relationAction;
  4487. }
  4488. }
  4489. });
  4490. // modalInstance.result.then(function(selectedItem) {
  4491. // options.value(selectedItem);
  4492. // }, function() {
  4493. // //console.log('Modal dismissed at: ' + new Date());
  4494. // });
  4495. }
  4496. }
  4497. };
  4498. },
  4499. controller: ['$scope', function($scope) {
  4500. // $scope.searchModal = $scope.model[$scope.options.key];
  4501. // $scope.$watch('searchModal',function(newValue, oldValue){
  4502. // if (newValue === oldValue) { return; }
  4503. // if (newValue.flag == oldValue.flag) { return; }
  4504. // if (angular.isDefined(newValue.flag)&&(newValue.flag==true)){
  4505. // if (newValue.searchKey!=''&&angular.isDefined(newValue.searchKey)){
  4506. // $scope.options.templateOptions.search('lg',$scope.options,newValue.searchKey);
  4507. // }
  4508. // }
  4509. // })
  4510. //
  4511. }]
  4512. });
  4513. //cmdb控件
  4514. formlyConfigProvider.setType({
  4515. name: 'ui-cmdb',
  4516. extends: 'input',
  4517. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  4518. defaultOptions: function(options) {
  4519. return {
  4520. templateOptions: {
  4521. onClick: function(size, options, modal, event, model) {
  4522. var modalInstance = modal.open({
  4523. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  4524. controller: function($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster) {
  4525. var width = $scope.width = 600;
  4526. var height = $scope.height = 400;
  4527. var tree;
  4528. var d3 = window.d3;
  4529. $scope.my_tree_handler = function(branch) {
  4530. //var _ref;
  4531. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  4532. APIService.query({ 'sign': classify }).then(function(data) {
  4533. var myData = Restangular.stripRestangular(data);
  4534. console.log(myData.data.node);
  4535. if (myData.data && myData.status == 200) {
  4536. var ret = myData.data;
  4537. redrawSvg(myData);
  4538. }
  4539. });
  4540. };
  4541. $scope.my_data = [];
  4542. function convertListToTree(data, treeMap) {
  4543. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  4544. var root = null; //Initially set our loop to null
  4545. var parentNode = null;
  4546. //loop over data
  4547. for (var i = 0; i < data.length; i++) {
  4548. var datum = data[i];
  4549. //each node will have children, so let's give it a "children" poperty
  4550. datum.children = [];
  4551. //add an entry for this node to the map so that any future children can
  4552. //lookup the parent
  4553. idToNodeMap[datum.id] = datum;
  4554. //Does this node have a parent?
  4555. if (typeof datum.parent === "undefined" || datum.parent == null) {
  4556. //Doesn't look like it, so this node is the root of the tree
  4557. root = datum;
  4558. treeMap[datum.id] = root;
  4559. } else {
  4560. //This node has a parent, so let's look it up using the id
  4561. parentNode = idToNodeMap[datum.parent.id];
  4562. //We don't need this property, so let's delete it.
  4563. delete datum.parent;
  4564. //Let's add the current node as a child of the parent node.
  4565. parentNode.children.push(datum);
  4566. }
  4567. }
  4568. return root;
  4569. }
  4570. function convertParentToChildList(data) {
  4571. var treeMap = {};
  4572. var list = [];
  4573. convertListToTree(data, treeMap);
  4574. angular.forEach(treeMap, function(item) {
  4575. list.push(item);
  4576. });
  4577. return list;
  4578. }
  4579. $scope.my_tree = tree = {};
  4580. $scope.try_async_load = function() {
  4581. $scope.my_data = [];
  4582. $scope.select_treedata = [];
  4583. $scope.doing_async = true;
  4584. ConfigDataService.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
  4585. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  4586. $scope.doing_async = false;
  4587. });
  4588. };
  4589. $scope.select_treedata = [];
  4590. $scope.propTypeOptions = [];
  4591. $scope.try_async_load();
  4592. $scope.onFilterCallback = function(item) {
  4593. //console.log(item);
  4594. if (angular.isDefined(item.children) && item.children.length >= 1) {
  4595. //not valid
  4596. } else {
  4597. var tempclassify = item.prefix.toLowerCase() + item.sign;
  4598. $scope.cifilter_classic = tempclassify;
  4599. ConfigFormService.renderTabForm(tempclassify).then(function(data) {
  4600. var myData = Restangular.stripRestangular(data);
  4601. $scope.propTypeOptions = myData;
  4602. });
  4603. }
  4604. }
  4605. $scope.onPropTypeChange = function(form) {
  4606. $scope.propOptions = form.fields;
  4607. }
  4608. $scope.onPropChange = function(prop) {
  4609. $scope.cifilter_prop = prop;
  4610. }
  4611. $scope.searchCI = function(searchKey, propObj, ciclassify) {
  4612. //if(searchKey!=null&&searchKey.length>1){
  4613. var searchData = {};
  4614. if (angular.isUndefined(propObj)) {
  4615. propObj = $scope.cifilter_prop;
  4616. }
  4617. if (angular.isUndefined(ciclassify)) {
  4618. ciclassify = $scope.cifilter_classic;
  4619. }
  4620. searchData['sign'] = ciclassify;
  4621. if (angular.isDefined(propObj)) {
  4622. searchData[propObj.key] = searchKey;
  4623. }
  4624. APIService.query(searchData).then(function(response) {
  4625. var data = Restangular.stripRestangular(response);
  4626. //此处不清空nodes
  4627. var node = data.data.node;
  4628. var tempNode = [];
  4629. //nodes 或者links 要去重
  4630. for (var i = 0; i < node.length; i++) {
  4631. var tmp = 0;
  4632. for (var j = 0; j < nodes.length; j++) {
  4633. if (node[i].uuid == nodes[j].uuid) {
  4634. tmp++;
  4635. break;
  4636. }
  4637. }
  4638. if (tmp == 0) {
  4639. tempNode.push(node[i]);
  4640. }
  4641. }
  4642. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  4643. nodes.push(tempNode[i]);
  4644. }
  4645. restart();
  4646. })
  4647. }
  4648. $scope.refresh = function() {
  4649. nodes.length = 0;
  4650. links.length = 0;
  4651. restart();
  4652. }
  4653. $scope.traversal = function() {
  4654. if ($scope.selected_node == null) {
  4655. // SweetAlert.swal({
  4656. // title: "错误的操作!",
  4657. // text: "没有配置项被选中!",
  4658. // type: "error"
  4659. // });
  4660. $ionicPopup.alert({
  4661. title: '没有配置项被选中!',
  4662. okText: '确认'
  4663. });
  4664. } else {
  4665. var uuid = $scope.selected_node.uuid;
  4666. APIService.traversal(uuid).then(function(response) {
  4667. var d = response.data;
  4668. var node = d.node;
  4669. var link = d.edge;
  4670. var tempNode = [];
  4671. var tempLink = [];
  4672. //nodes 或者links 要去重
  4673. for (var i = 0; i < node.length; i++) {
  4674. var tmp = 0;
  4675. for (var j = 0; j < nodes.length; j++) {
  4676. if (node[i].id == nodes[j].id) {
  4677. tmp++;
  4678. break;
  4679. }
  4680. }
  4681. if (tmp == 0) {
  4682. tempNode.push(node[i]);
  4683. }
  4684. }
  4685. for (var i = 0; i < link.length; i++) {
  4686. var tmp = 0;
  4687. for (var j = 0; j < links.length; j++) {
  4688. if (link[i].id == links[j].id) {
  4689. tmp++;
  4690. break;
  4691. }
  4692. }
  4693. if (tmp == 0) {
  4694. tempLink.push(link[i]);
  4695. }
  4696. }
  4697. //数据写入页面
  4698. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  4699. nodes.push(tempNode[i]);
  4700. }
  4701. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  4702. links.push(tempLink[i]);
  4703. }
  4704. //links转换
  4705. for (var i = 0; i < links.length; i++) {
  4706. for (var j = 0; j < nodes.length; j++) {
  4707. if (links[i].source == nodes[j].id) {
  4708. links[i].source = nodes[j];
  4709. }
  4710. if (links[i].target == nodes[j].id) {
  4711. links[i].target = nodes[j];
  4712. }
  4713. }
  4714. }
  4715. restart();
  4716. })
  4717. }
  4718. }
  4719. var svg;
  4720. var force;
  4721. var drag_line, path, circle;
  4722. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  4723. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  4724. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  4725. var nodes = [],
  4726. links = [];
  4727. var treeNodes = [];
  4728. //读取labels (node)
  4729. var labels = [];
  4730. function redrawSvg(json) {
  4731. nodes.length = 0; //先清空
  4732. links.length = 0;
  4733. var data = json.data;
  4734. for (var i = 0; i < data.node.length; i++) {
  4735. nodes.push(data.node[i]);
  4736. }
  4737. restart();
  4738. }
  4739. //读取status (节点 连线)
  4740. var statuses = [];
  4741. ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  4742. if (result && result.status == 200) {
  4743. d3.select('#nodeStatus').selectAll('option')
  4744. .data(statuses).enter()
  4745. .append('option')
  4746. .attr('value', function(d) { return d.code; })
  4747. .html(function(d) { return d.desc; });
  4748. } else {
  4749. // SweetAlert.swal({
  4750. // title: "提示!",
  4751. // text: "服务器请求异常!",
  4752. // type: "error"
  4753. // });
  4754. $ionicPopup.alert({
  4755. title: '服务器请求异常!',
  4756. okText: '确认'
  4757. });
  4758. }
  4759. });
  4760. //查询relationship_type表 name 为表里的type,label为显示值
  4761. var linkType = [];
  4762. function fetchEdgeTypes() {
  4763. ConfigDataService.fetchDataList('ciedgetype', { 'idx': 0, 'sum': 100 }).then(function(response) {
  4764. if (response) {
  4765. if (response['list']) {
  4766. linkType = response['list'];
  4767. // d3.select('#linkName').selectAll('option')
  4768. // .data(linkType).enter()
  4769. // .append('option')
  4770. // .attr('value',function(d){return d.type;})
  4771. // .html(function(d){ return d.label;});
  4772. } else {
  4773. // SweetAlert.swal({
  4774. // title: "提示!",
  4775. // text: "服务器请求异常!",
  4776. // type: "error"
  4777. // });
  4778. $ionicPopup.alert({
  4779. title: '服务器请求异常!',
  4780. okText: '确认'
  4781. });
  4782. }
  4783. } else {
  4784. // SweetAlert.swal({
  4785. // title: "提示!",
  4786. // text: "服务器请求异常!",
  4787. // type: "error"
  4788. // });
  4789. $ionicPopup.alert({
  4790. title: '服务器请求异常!',
  4791. okText: '确认'
  4792. });
  4793. }
  4794. })
  4795. }
  4796. fetchEdgeTypes();
  4797. /*
  4798. // init D3 force layout
  4799. var force = d3.layout.force()
  4800. .nodes(nodes)
  4801. .links(links)
  4802. .size([width, height])
  4803. .gravity(.05)
  4804. .linkDistance(150)
  4805. .linkStrength(2)
  4806. .charge(-500)
  4807. .on('tick', tick);
  4808. // define arrow markers for graph links
  4809. svg.append('svg:defs').append('svg:marker')
  4810. .attr('id', 'end-arrow')
  4811. .attr('viewBox', '0 -5 10 10')
  4812. .attr('refX', 6)
  4813. .attr('markerWidth', 3)
  4814. .attr('markerHeight', 3)
  4815. .attr('orient', 'auto')
  4816. .append('svg:path')
  4817. .attr('d', 'M0,-5L10,0L0,5')
  4818. .attr('fill', '#000');
  4819. svg.append('svg:defs').append('svg:marker')
  4820. .attr('id', 'start-arrow')
  4821. .attr('viewBox', '0 -5 10 10')
  4822. .attr('refX', 4)
  4823. .attr('markerWidth', 3)
  4824. .attr('markerHeight', 3)
  4825. .attr('orient', 'auto')
  4826. .append('svg:path')
  4827. .attr('d', 'M10,-5L0,0L10,5')
  4828. .attr('fill', '#000');
  4829. // line displayed when dragging new nodes
  4830. var drag_line = svg.append('svg:path')
  4831. .attr('class', 'link dragline hidden')
  4832. .attr('d', 'M0,0L0,0');
  4833. // handles to link and node element groups
  4834. //(1)var path = svg.append('svg:g').selectAll('g')
  4835. var path = svg.append('svg:g').selectAll('g'),
  4836. circle = svg.append('svg:g').selectAll('g');
  4837. */
  4838. // mouse event vars
  4839. var selected_node = null,
  4840. selected_link = null,
  4841. mousedown_link = null,
  4842. mousedown_node = null,
  4843. mouseup_node = null;
  4844. function resetMouseVars() {
  4845. mousedown_node = null;
  4846. mouseup_node = null;
  4847. mousedown_link = null;
  4848. }
  4849. // update force layout (called automatically each iteration)
  4850. function tick() {
  4851. // draw directed edges with proper padding from node centers
  4852. path.selectAll('path').attr('d', function(d) {
  4853. var deltaX = d.target.x - d.source.x,
  4854. deltaY = d.target.y - d.source.y,
  4855. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  4856. normX = deltaX / dist,
  4857. normY = deltaY / dist,
  4858. sourcePadding = d.left ? 27 : 22,
  4859. targetPadding = d.right ? 27 : 22,
  4860. sourceX = d.source.x + (sourcePadding * normX),
  4861. sourceY = d.source.y + (sourcePadding * normY),
  4862. targetX = d.target.x - (targetPadding * normX),
  4863. targetY = d.target.y - (targetPadding * normY);
  4864. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  4865. });
  4866. circle.attr('transform', function(d) {
  4867. return 'translate(' + d.x + ',' + d.y + ')';
  4868. });
  4869. }
  4870. // update graph (called when needed)
  4871. function restart() {
  4872. //绑定link 数据
  4873. path.datum(links);
  4874. // path (link) group
  4875. path = path.data(links, function(d) { return d.id; });
  4876. var p = path.enter().append('svg:g');
  4877. //update existing links
  4878. path.selectAll('path').classed('selected', function(d) { return d === selected_link; })
  4879. .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
  4880. .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; });
  4881. // add new links
  4882. p.append('svg:path')
  4883. .attr('class', 'link')
  4884. .attr('id', function(d) { return "path_" + d.id; })
  4885. // .attr('startOffset', '0%')
  4886. .classed('selected', function(d) { return d === selected_link; })
  4887. .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
  4888. .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; })
  4889. .on('mousedown', function(d) {
  4890. if (d3.event.ctrlKey) return;
  4891. //去除没有提交的连线
  4892. for (var i = 0; i < links.length; i++) {
  4893. if (links[i].id == -1 && d.id != -1) {
  4894. links.splice(i, 1);
  4895. }
  4896. }
  4897. // select link
  4898. mousedown_link = d;
  4899. if (mousedown_link === selected_link) {
  4900. selected_link = $scope.selected_link = null;
  4901. selected_node = $scope.selected_node = null;
  4902. // d3.select("#linkDetail").attr('style','display:none');
  4903. //hideLinkForm(true);//return ;
  4904. } else {
  4905. selected_link = $scope.selected_link = mousedown_link;
  4906. selected_node = $scope.selected_node = null;
  4907. }
  4908. selected_node = $scope.selected_node = null;
  4909. restart();
  4910. });
  4911. p.append('svg:text')
  4912. .attr('x', 30)
  4913. .attr('y', 20)
  4914. .attr('class', 'fontM')
  4915. .append('textPath')
  4916. .attr('xlink:xlink:href', function(d, i) { return "#path_" + d.id; })
  4917. .html(function(d) {
  4918. for (var i = 0; i < linkType.length; i++) {
  4919. if (linkType[i].type == d.name) {
  4920. return linkType[i].label;
  4921. }
  4922. }
  4923. });
  4924. // remove old links
  4925. path.exit().remove();
  4926. // circle (node) group
  4927. // NB: the function arg is crucial here! nodes are known by id, not by index!
  4928. circle.datum(nodes);
  4929. circle = circle.data(nodes, function(d) { return d.id; });
  4930. // update existing nodes (reflexive & selected visual states)
  4931. circle.selectAll('circle')
  4932. .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
  4933. .style('fill-opacity', 0.75) // add by xi
  4934. .classed('reflexive', function(d) { return d.reflexive; });
  4935. // add new nodes
  4936. var g = circle.enter().append('svg:g');
  4937. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  4938. //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');
  4939. 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');
  4940. g.append('svg:circle')
  4941. .attr('class', 'node')
  4942. .attr('r', 18)
  4943. .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
  4944. .style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); })
  4945. .style('fill-opacity', 0.25) //add by xj
  4946. .style('stroke-opacity', 0.5) //add by xj
  4947. .classed('reflexive', function(d) { return d.reflexive; });
  4948. g.on('mouseover', function(d) {
  4949. //if(!mousedown_node || d === mousedown_node) return;
  4950. // enlarge target node
  4951. //d3.select(this).attr('transform', 'scale(1.1)');
  4952. })
  4953. .on('mouseout', function(d) {
  4954. //if(!mousedown_node || d === mousedown_node) return;
  4955. // unenlarge target node
  4956. //d3.select(this).attr('transform', '');
  4957. })
  4958. .on('mousedown', function(d) {
  4959. if (d3.event.ctrlKey) return;
  4960. //hideLinkForm(true);
  4961. //去除没有提交的连线
  4962. for (var i = 0; i < links.length; i++) {
  4963. if (links[i].id == -1) {
  4964. links.splice(i, 1);
  4965. }
  4966. }
  4967. // select node
  4968. mousedown_node = d;
  4969. if (mousedown_node === selected_node) {
  4970. selected_node = $scope.selected_node = null;
  4971. } else {
  4972. selected_node = $scope.selected_node = mousedown_node;
  4973. selected_link = $scope.selected_link = null;
  4974. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  4975. APIService.findRefById(selected_node.id).then(function(result) {
  4976. var d = result.data;
  4977. var node = d.node;
  4978. var link = d.edge;
  4979. var tempNode = [];
  4980. var tempLink = [];
  4981. //nodes 或者links 要去重
  4982. for (var i = 0; i < node.length; i++) {
  4983. var tmp = 0;
  4984. for (var j = 0; j < nodes.length; j++) {
  4985. if (node[i].id == nodes[j].id) {
  4986. tmp++;
  4987. break;
  4988. }
  4989. }
  4990. if (tmp == 0) {
  4991. tempNode.push(node[i]);
  4992. }
  4993. }
  4994. for (var i = 0; i < link.length; i++) {
  4995. var tmp = 0;
  4996. for (var j = 0; j < links.length; j++) {
  4997. if (link[i].id == links[j].id) {
  4998. tmp++;
  4999. break;
  5000. }
  5001. }
  5002. if (tmp == 0) {
  5003. tempLink.push(link[i]);
  5004. }
  5005. }
  5006. //数据写入页面
  5007. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  5008. nodes.push(tempNode[i]);
  5009. }
  5010. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  5011. links.push(tempLink[i]);
  5012. }
  5013. //links转换
  5014. for (var i = 0; i < links.length; i++) {
  5015. for (var j = 0; j < nodes.length; j++) {
  5016. if (links[i].source == nodes[j].id) {
  5017. links[i].source = nodes[j];
  5018. }
  5019. if (links[i].target == nodes[j].id) {
  5020. links[i].target = nodes[j];
  5021. }
  5022. }
  5023. }
  5024. restart();
  5025. });
  5026. }
  5027. // reposition drag line
  5028. drag_line
  5029. .style('marker-end', 'url(#end-arrow)')
  5030. .classed('hidden', false)
  5031. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  5032. restart();
  5033. })
  5034. .on('mouseup', function(d) {
  5035. if (!mousedown_node) return;
  5036. });
  5037. // show node name
  5038. g.append('svg:text')
  5039. .attr('x', 0)
  5040. .attr('y', 34)
  5041. .attr('class', 'id')
  5042. .text(function(d) { return d.name; }); //TODO 改为 d.name
  5043. //设置图片
  5044. g.append('svg:foreignObject')
  5045. .attr("width", 32)
  5046. .attr("height", 32)
  5047. .attr('x', "-16px")
  5048. .attr('y', "-11px")
  5049. .html(function(d) {
  5050. for (var i = 0; i < labels.length; i++) {
  5051. if (d.label == labels[i].sign) {
  5052. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  5053. }
  5054. }
  5055. });
  5056. // remove old nodes
  5057. circle.exit().remove();
  5058. // set the graph in motion
  5059. force.start();
  5060. }
  5061. function mousedown() {
  5062. // prevent I-bar on drag
  5063. //d3.event.preventDefault();
  5064. // because :active only works in WebKit?
  5065. svg.classed('active', true);
  5066. if (mousedown_node) {
  5067. viewNode(mousedown_node);
  5068. }
  5069. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  5070. restart();
  5071. }
  5072. function mousemove() {
  5073. if (!mousedown_node) return;
  5074. // update drag line
  5075. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  5076. //restart();
  5077. }
  5078. function mouseup() {
  5079. if (mousedown_node) {
  5080. // hide drag line
  5081. drag_line
  5082. .classed('hidden', true)
  5083. .style('marker-end', '');
  5084. }
  5085. // because :active only works in WebKit?
  5086. svg.classed('active', false);
  5087. // clear mouse event vars
  5088. resetMouseVars();
  5089. }
  5090. function spliceLinksForNode(node) {
  5091. var toSplice = links.filter(function(l) {
  5092. return (l.source === node || l.target === node);
  5093. });
  5094. toSplice.map(function(l) {
  5095. links.splice(links.indexOf(l), 1);
  5096. });
  5097. }
  5098. // only respond once per keydown
  5099. var lastKeyDown = -1;
  5100. function keydown() {
  5101. //d3.event.preventDefault();
  5102. if (lastKeyDown !== -1) return;
  5103. lastKeyDown = d3.event.keyCode;
  5104. // ctrl
  5105. if (d3.event.keyCode === 17) {
  5106. circle.call(force.drag);
  5107. svg.classed('ctrl', true);
  5108. }
  5109. if (!selected_node && !selected_link) return;
  5110. switch (d3.event.keyCode) {
  5111. case 8: // backspace
  5112. case 66: // B
  5113. if (selected_link) {
  5114. // set link direction to both left and right
  5115. selected_link.left = true;
  5116. selected_link.right = true;
  5117. }
  5118. restart();
  5119. break;
  5120. case 76: // L
  5121. if (selected_link) {
  5122. // set link direction to left only
  5123. selected_link.left = true;
  5124. selected_link.right = false;
  5125. }
  5126. restart();
  5127. break;
  5128. case 82: // R
  5129. if (selected_node) {
  5130. // toggle node reflexivity
  5131. selected_node.reflexive = !selected_node.reflexive;
  5132. } else if (selected_link) {
  5133. // set link direction to right only
  5134. selected_link.left = false;
  5135. selected_link.right = true;
  5136. }
  5137. restart();
  5138. break;
  5139. }
  5140. }
  5141. function keyup() {
  5142. lastKeyDown = -1;
  5143. // ctrl
  5144. if (d3.event.keyCode === 17) {
  5145. circle
  5146. .on('mousedown.drag', null)
  5147. .on('touchstart.drag', null);
  5148. svg.classed('ctrl', false);
  5149. }
  5150. }
  5151. function viewNode(node) {
  5152. console.log(svg.attr('left'));
  5153. //var el = angular.element('div.modal-dialog')[0];
  5154. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  5155. if (!$scope.selected_node.props.state) { $scope.selected_node.props.state = "空" } else if ($scope.selected_node.props.state) {
  5156. 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 = "丢失" }
  5157. };
  5158. if (!$scope.selected_node.name) { $scope.selected_node.name = "空" }
  5159. if (!$scope.selected_node.status) { $scope.selected_node.statu = "空" }
  5160. if (!$scope.selected_node.props.useradmin) { $scope.selected_node.props.useradmin = "空" }
  5161. Toaster.pop({
  5162. // type: 'info',
  5163. // title: title,
  5164. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  5165. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  5166. '<p>状态:' + $scope.selected_node.status + '</p>' +
  5167. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  5168. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  5169. bodyOutputType: 'trustedHtml',
  5170. timeout: 3000
  5171. })
  5172. }
  5173. //GT 颜色与数值对照表
  5174. function colors(sign) {
  5175. //num=num>20?num%20:parseInt(num);
  5176. for (var i = 0; i < labels.length; i++) {
  5177. var entity = labels[i];
  5178. if (sign == entity.sign) {
  5179. return entity.color;
  5180. }
  5181. if (i == labels.length - 1 && sign != entity.sign) {
  5182. return '#ffeeee';
  5183. }
  5184. }
  5185. }
  5186. $scope.init = function() {
  5187. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  5188. // init D3 force layout
  5189. force = d3.layout.force()
  5190. .nodes(nodes)
  5191. .links(links)
  5192. .size([width, height])
  5193. .gravity(.05)
  5194. .linkDistance(150)
  5195. .linkStrength(2)
  5196. .charge(-500)
  5197. .on('tick', tick);
  5198. // define arrow markers for graph links
  5199. svg.append('svg:defs').append('svg:marker')
  5200. .attr('id', 'end-arrow')
  5201. .attr('viewBox', '0 -5 10 10')
  5202. .attr('refX', 6)
  5203. .attr('markerWidth', 3)
  5204. .attr('markerHeight', 3)
  5205. .attr('orient', 'auto')
  5206. .append('svg:path')
  5207. .attr('d', 'M0,-5L10,0L0,5')
  5208. .attr('fill', '#000');
  5209. svg.append('svg:defs').append('svg:marker')
  5210. .attr('id', 'start-arrow')
  5211. .attr('viewBox', '0 -5 10 10')
  5212. .attr('refX', 4)
  5213. .attr('markerWidth', 3)
  5214. .attr('markerHeight', 3)
  5215. .attr('orient', 'auto')
  5216. .append('svg:path')
  5217. .attr('d', 'M10,-5L0,0L10,5')
  5218. .attr('fill', '#000');
  5219. // line displayed when dragging new nodes
  5220. drag_line = svg.append('svg:path')
  5221. .attr('class', 'link dragline hidden')
  5222. .attr('d', 'M0,0L0,0');
  5223. // handles to link and node element groups
  5224. //(1)var path = svg.append('svg:g').selectAll('g')
  5225. path = svg.append('svg:g').selectAll('g');
  5226. circle = svg.append('svg:g').selectAll('g');
  5227. svg.on('mousedown', mousedown)
  5228. .on('mousemove', mousemove)
  5229. .on('mouseup', mouseup);
  5230. d3.select(window)
  5231. .on('keydown', keydown)
  5232. .on('keyup', keyup);
  5233. }
  5234. var CI = {};
  5235. window.CI = CI;
  5236. $scope.ok = function() {
  5237. $modalInstance.close($scope.selected_node);
  5238. };
  5239. $scope.cancel = function() {
  5240. $modalInstance.dismiss('cancel');
  5241. };
  5242. },
  5243. size: size,
  5244. resolve: {
  5245. title: function() {
  5246. return options.templateOptions.title;
  5247. },
  5248. Restangular: function() {
  5249. return options.templateOptions.Restangular;
  5250. },
  5251. APIService: function() {
  5252. return options.templateOptions.ApiService;
  5253. },
  5254. ConfigDataService: function() {
  5255. return options.templateOptions.ConfigDataService;
  5256. },
  5257. ConfigFormService: function() {
  5258. return options.templateOptions.ConfigFormService;
  5259. },
  5260. SweetAlert: function() {
  5261. return options.templateOptions.Alert;
  5262. },
  5263. Toaster: function() {
  5264. return options.templateOptions.toaster;
  5265. }
  5266. }
  5267. });
  5268. modalInstance.result.then(function(selectedItem) {
  5269. options.value(selectedItem.name + '-' + selectedItem.uuid);
  5270. }, function() {
  5271. //console.log('Modal dismissed at: ' + new Date());
  5272. });
  5273. }
  5274. }
  5275. }
  5276. },
  5277. controller: ['$scope', function($scope) {
  5278. // setTimeout(function(){
  5279. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  5280. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  5281. // if(modelData.status==200){
  5282. // $scope.model[$scope.options.key] = modelData.data;
  5283. // $scope.options.initialValue = $scope.model[$scope.options.key];
  5284. // }
  5285. // });
  5286. // },1000);
  5287. }]
  5288. });
  5289. });
  5290. appFormly.run(function(formlyConfig, $parse) {
  5291. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  5292. var removeOnHideTransformer = function(fields, model) {
  5293. return fields.map(function(field) {
  5294. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  5295. addFieldRemoveOnHideWatcher(field);
  5296. }
  5297. if (field.type == "ui-title") {
  5298. addFieldRemoveOnHideWatcher(field);
  5299. }
  5300. return field;
  5301. });
  5302. };
  5303. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  5304. function addFieldRemoveOnHideWatcher(field) {
  5305. var watcher = getWatcher();
  5306. if (field.watcher) {
  5307. if (!angular.isArray(field.watcher)) {
  5308. field.watcher = [field.watcher];
  5309. }
  5310. field.watcher.push(watcher);
  5311. } else {
  5312. field.watcher = watcher;
  5313. }
  5314. }
  5315. function getWatcher() {
  5316. return {
  5317. expression: function(field) {
  5318. return field.hide;
  5319. },
  5320. listener: function(field, newHide, oldHide, scope) {
  5321. if (field.hide) {
  5322. if (field.templateOptions.pkey) {
  5323. if (field.key == 'transferuser') {
  5324. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  5325. }
  5326. } else {
  5327. $parse(field.key).assign(scope.model, undefined);
  5328. }
  5329. }
  5330. if (field.type == "ui-title") {
  5331. $parse(field.key).assign(scope.model, undefined);
  5332. }
  5333. }
  5334. };
  5335. }
  5336. });
  5337. 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',
  5338. 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) {
  5339. //console.log($parse('Restangular')($scope));
  5340. //console.log($injector.get('Restangular'));
  5341. //console.log($stateParams);
  5342. // console.log('customFormIndexCtrl is loading');
  5343. // alert(location.href);
  5344. var vm = this;
  5345. // $scope.vm = vm;
  5346. vm.options = {};
  5347. vm.exampleTitle = ['expressionProperties', 'model property'];
  5348. vm.fields = [];
  5349. vm.model = {};
  5350. // $scope.langs = i18nService.getAllLangs();
  5351. // $scope.lang = 'zh-cn';
  5352. // i18nService.setCurrentLang($scope.lang);
  5353. //alert($rootScope.user.id,null,2);
  5354. //获取login中的数据
  5355. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  5356. var loginUser = sessionLogin.user;
  5357. $rootScope.user = loginUser;
  5358. // angular.extend(loginUser, {
  5359. // areaDTO: {
  5360. // 'area': '西区',
  5361. // 'id': 3
  5362. // },
  5363. // placeDTO: {
  5364. // 'place': '西区',
  5365. // 'id': 5
  5366. // },
  5367. // houseNumber: 103,
  5368. // mphone: '123456789'
  5369. // });
  5370. // vm.model["loginUser"] = $rootScope.user;
  5371. // vm.model["loginUser"] = loginUser;
  5372. var that = $injector;
  5373. var parse = $parse;
  5374. var formKey = "";
  5375. var pdKey = "";
  5376. var modelWatch = "";
  5377. $scope.goBack = function() {
  5378. history.go(-1);
  5379. };
  5380. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  5381. modelWatch = JSON.parse($stateParams.model);
  5382. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  5383. }
  5384. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  5385. pdKey = $state.current.pdKey;
  5386. } else if ($stateParams.pdKey) {
  5387. pdKey = $stateParams.pdKey;
  5388. }
  5389. // console.log("pdKey::" + JSON.stringify($state.current.title));
  5390. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  5391. formKey = $stateParams.formKey;
  5392. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  5393. }
  5394. if (angular.isDefined($stateParams.model)) {
  5395. var formModel = $stateParams.model;
  5396. }
  5397. //用户测试数据,后续从header的auth中获取
  5398. // var userId = 2;
  5399. var userId = $rootScope.user.id;
  5400. // userId = loginUser.id;
  5401. //==============处理表单设计数据 开始====================
  5402. //处理组件加载后台数据选项的方法
  5403. // function refreshSelectOptions(searchVal, field) {
  5404. // if (field.templateOptions.optionsUrl) {
  5405. // var process = BpmRestangular.all("");
  5406. // if (field.templateOptions.ApiService) {
  5407. // process = UserRestangular.all("");
  5408. // }
  5409. // process.customPOST({ "idx": 0, "sum": 1000 }, field.templateOptions.optionsUrl).then(function(result) {
  5410. // if (!field.templateOptions.options) {
  5411. // field.templateOptions.options = [];
  5412. // }
  5413. // if (field.templateOptions.optionsDataKey) {
  5414. // field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  5415. // // field.selectLists = result[field.templateOptions.optionsDataKey];
  5416. // // var lists = result[field.templateOptions.optionsDataKey];
  5417. // // field.templateOptions.list = lists[0].name;
  5418. // } else {
  5419. // field.templateOptions.options = result;
  5420. // }
  5421. // });
  5422. // }
  5423. // }
  5424. function refreshSelectOptions(searchVal, field) {
  5425. if (field.templateOptions.optionsUrl) {
  5426. var process = BpmRestangular.all("");
  5427. if (field.templateOptions.ApiService) {
  5428. process = UserRestangular.all("");
  5429. }
  5430. if (field.templateOptions.Apicommon) {
  5431. process = WechatRestangular.all("");
  5432. }
  5433. var datakey = { "idx": 0, "sum": 1000 };
  5434. if (field.templateOptions.modelreasondata) {
  5435. datakey = field.templateOptions.modelreasondata
  5436. }
  5437. if (field.templateOptions.userSelect) {
  5438. angular.extend(datakey, field.templateOptions.userSelect);
  5439. }
  5440. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function(result) {
  5441. if (!field.templateOptions.options) {
  5442. field.templateOptions.options = [];
  5443. }
  5444. if (field.templateOptions.optionsDataKey) {
  5445. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  5446. } else {
  5447. field.templateOptions.options = result;
  5448. }
  5449. });
  5450. }
  5451. }
  5452. //解析自定义表单设计数据
  5453. function decodeVMForm(vmForm) {
  5454. var result = { model: {}, fields: [] };
  5455. //设置模型实体数据 begin
  5456. // var mdata = vmForm.model;
  5457. //解析数据实体
  5458. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  5459. angular.extend(result.model, mdata);
  5460. if (modelWatch != null && modelWatch != '') {
  5461. //angular.extend(result.model.incident,modelWatch.incident);
  5462. //result.model.alarmType = modelWatch.alarmType;
  5463. // vmForm.cancelUrl = modelWatch.cancelUrl;
  5464. console.log(modelWatch.cancelUrl)
  5465. for (var index in modelWatch.model) {
  5466. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  5467. if (result.model[index] != null) {
  5468. angular.extend(result.model[index], modelWatch.model[index]);
  5469. } else {
  5470. result.model[index] = modelWatch.model[index];
  5471. }
  5472. }
  5473. }
  5474. //设置模型实体数据 end
  5475. //解析设计数据生成表单项 begin
  5476. var fields = [];
  5477. //处理修改设计数据中展示设置
  5478. angular.forEach(vmForm.fields, function(field) {
  5479. if (field.key == "") {
  5480. delete field.key;
  5481. }
  5482. if (angular.isDefined(field.extjson)) {
  5483. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  5484. angular.extend(field.templateOptions, extObj.templateOptions);
  5485. delete extObj.templateOptions;
  5486. for (var prop in extObj) {
  5487. if (new RegExp("Expression").test(prop)) {
  5488. //var obj = $scope.$eval(extObj[prop]);
  5489. //extObj[prop] = $scope.$eval(extObj[prop]);
  5490. if (extObj[prop] != null) {
  5491. if (new RegExp("function").test(extObj[prop])) {
  5492. var propValue = eval(extObj[prop]);
  5493. extObj[prop] = propValue;
  5494. } else {
  5495. //console.log(extObj[prop]);
  5496. var obj = $scope.$eval(extObj[prop]);
  5497. extObj[prop] = obj;
  5498. //console.log(obj);
  5499. }
  5500. }
  5501. } else if (new RegExp("expressionProperties").test(prop)) {
  5502. for (var p in extObj[prop]) {
  5503. if (new RegExp("function").test(extObj[prop][p])) {
  5504. var propValue = eval(extObj[prop][p]);
  5505. extObj[prop][p] = propValue;
  5506. } else {
  5507. //if(p.indexOf("'")>=0){
  5508. // var obj = $scope.$eval(extObj[prop][p]);
  5509. // extObj[prop][$scope.$eval(p)]=obj;
  5510. //}
  5511. }
  5512. }
  5513. } else if ("watcher" == prop) {
  5514. if (angular.isArray(extObj[prop])) {
  5515. angular.forEach(extObj[prop], function(item, index) {
  5516. for (var p in item) {
  5517. if (new RegExp("function").test(item[p])) {
  5518. var propValue = eval(item[p]);
  5519. extObj[prop][index][p] = propValue;
  5520. }
  5521. }
  5522. });
  5523. } else if (angular.isObject(extObj[prop])) {
  5524. for (var p in extObj[prop]) {
  5525. if (new RegExp("function").test(extObj[prop][p])) {
  5526. var propValue = eval(extObj[prop][p]);
  5527. extObj[prop][p] = propValue;
  5528. }
  5529. }
  5530. }
  5531. }
  5532. }
  5533. angular.extend(field, extObj);
  5534. delete field.extjson;
  5535. }
  5536. if (angular.isDefined(field.templateOptions)) {
  5537. var templateOs = field.templateOptions;
  5538. for (var property in templateOs) {
  5539. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  5540. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  5541. if (new RegExp("function").test(templateOs[property])) {
  5542. var propValue = eval(templateOs[property]);
  5543. field.templateOptions[property] = propValue;
  5544. } else {
  5545. if (that.has(templateOs[property])) {
  5546. field.templateOptions[property] = that.get(templateOs[property]);
  5547. } else {
  5548. field.templateOptions[property] = templateOs[property];
  5549. }
  5550. }
  5551. } else if (templateOs[property] == null) {
  5552. //delete field.templateOptions[property];
  5553. } else {}
  5554. }
  5555. }
  5556. console.log(field);
  5557. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  5558. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  5559. angular.extend(field.templateOptions, extObj);
  5560. delete field.templateOptions.extjson;
  5561. }
  5562. // ...
  5563. if (field.templateOptions) {
  5564. //处理远程获取数据控件方法调用
  5565. if (field.templateOptions.optionsUrl) {
  5566. field.templateOptions.refresh = refreshSelectOptions;
  5567. }
  5568. //事件脚本处理
  5569. // if(field.templateOptions.ngChangeScript){
  5570. // if(!field.expressionProperties)field.expressionProperties={};
  5571. // field.expressionProperties.ngChange = function(modelVal,viewVal,ev){
  5572. //// console.log(ev);
  5573. //// console.log("change>>"+ev.options.key);
  5574. // eval(field.templateOptions.ngChangeScript);
  5575. // }
  5576. // }
  5577. // if(field.templateOptions.ngClickScript){
  5578. // if(!field.expressionProperties)field.expressionProperties={};
  5579. // field.expressionProperties.ngClick = function(modelVal,viewVal,ev){
  5580. //// console.log(ev);
  5581. //// console.log("click>>"+ev.options.key);
  5582. // eval(field.templateOptions.ngClickScript);
  5583. // }
  5584. // }
  5585. //处理嵌套属性数据绑定/
  5586. if (field.templateOptions.pkey) {
  5587. var pmodel, i = 0;
  5588. angular.forEach(field.templateOptions.pkey.split("."), function(p) {
  5589. if (i == 0) {
  5590. if (result.model[p] == null) {
  5591. result.model[p] = {};
  5592. }
  5593. pmodel = result.model[p];
  5594. i++;
  5595. } else {
  5596. if (pmodel[p] == null) {
  5597. pmodel[p] = {};
  5598. }
  5599. pmodel = pmodel[p];
  5600. }
  5601. });
  5602. if (pmodel != null) {
  5603. field.model = pmodel;
  5604. if (pmodel[field.key] == null) {
  5605. pmodel[field.key] = null;
  5606. }
  5607. }
  5608. } else {
  5609. if (result.model[field.key] == null) {
  5610. result.model[field.key] = null;
  5611. }
  5612. }
  5613. //处理弹出框组件初始化
  5614. if (field.type == "ui-input-selectmodal") {
  5615. // field.templateOptions.modal = $modal;
  5616. //field.templateOptions.Restangular = Restangular;
  5617. } else if (field.type == "ui-requesterselect") {
  5618. //field.templateOptions.language = $scope.lang;
  5619. // field.templateOptions.modal = $modal;
  5620. field.templateOptions.UserService = api_user_data;
  5621. } else if (field.type == "ui-userselect") {
  5622. // field.templateOptions.modal = $modal;
  5623. //field.templateOptions.Restangular = Restangular;
  5624. } else if (field.type == "ui-multiuserselect") {
  5625. // field.templateOptions.modal = $modal;
  5626. } else if (field.type == "ui-search") {
  5627. // field.templateOptions.modal = $modal;
  5628. } else if (field.type == "ui-modelselect") {
  5629. // field.templateOptions.modal = $modal;
  5630. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  5631. field.templateOptions.loginUser = $rootScope.user;
  5632. //field.templateOptions.Restangular = Restangular;
  5633. } else if (field.type == "ui-incidentmodelselect") {
  5634. // field.templateOptions.modal = $modal;
  5635. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  5636. // field.templateOptions.loginUser = $rootScope.user;
  5637. //field.templateOptions.Restangular = Restangular;
  5638. } else if (field.type == "ui-dropfile") {
  5639. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  5640. url: '/uploader'
  5641. });
  5642. field.templateOptions.taskId = $stateParams.taskId;
  5643. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  5644. field.templateOptions.userId = $rootScope.user.id;
  5645. } else if (field.type == "ui-dropfielknow") {
  5646. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  5647. url: '/uploader'
  5648. });
  5649. field.templateOptions.taskId = $stateParams.taskId;
  5650. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  5651. field.templateOptions.userId = $rootScope.user.id;
  5652. } else if (field.type == "ui-dropfilenotup") {
  5653. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  5654. url: '/uploader'
  5655. });
  5656. field.templateOptions.taskId = $stateParams.taskId;
  5657. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  5658. field.templateOptions.userId = $rootScope.user.id;
  5659. //field.ApiService=api_bpm_domain;
  5660. } else if (field.type == "ui-dropfiletable") {
  5661. if (field.templateOptions.processInstanceId) {
  5662. } else {
  5663. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  5664. }
  5665. } else if (field.type == "ui-repeatSection") {
  5666. var repeatForm = {
  5667. model: {
  5668. },
  5669. fields: field.templateOptions.fields
  5670. };
  5671. repeatForm.model[field.key] = [];
  5672. decodeVMForm(repeatForm);
  5673. } else if (field.type == "ui-currentuser") {
  5674. field.templateOptions.user = vm.model["loginUser"];
  5675. // field.templateOptions.user = $rootScope.user;
  5676. }
  5677. }
  5678. // console.log(field);
  5679. result.fields.push(field);
  5680. });
  5681. angular.extend($scope.vm.fields, result.fields);
  5682. angular.extend($scope.vm.model, result.model);
  5683. // console.log("$scope.vm.model="+JSON.stringify($scope.vm.model));
  5684. vm.model["loginUser"] = $rootScope.user;
  5685. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  5686. vmForm.cancelUrl = modelWatch.cancelUrl;
  5687. }
  5688. $scope.formData = vmForm;
  5689. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  5690. if ($scope.formData.url == "start") {
  5691. $scope.Reset = true;
  5692. $scope.close = false;
  5693. } else if ($scope.formData.url == "complete") {
  5694. $scope.Reset = false;
  5695. $scope.close = true;
  5696. }
  5697. //解析设计数据生成表单项 end
  5698. return result;
  5699. }
  5700. //======================处理表单设计数据 结束========================
  5701. $scope.ldloading = {};
  5702. function filter(obj) {
  5703. angular.forEach(obj, function(key, value) {
  5704. if (value === "" || value === null) {
  5705. delete obj[key];
  5706. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  5707. filter(value);
  5708. } else if (angular.isArray(value)) {
  5709. angular.forEach(value, function(item) {
  5710. filter(item);
  5711. });
  5712. }
  5713. });
  5714. }
  5715. $scope.closeModel = function() {
  5716. // console.log("pdKey="+pdKey);
  5717. // if ($stateParams.pdKey) {
  5718. // pdKey = $stateParams.pdKey;
  5719. // }
  5720. if (pdKey == "bpm_incident") {
  5721. $state.go('app.incidentMobile.incidentListMobile', {});
  5722. } else if (pdKey == "bpm_change") {
  5723. $state.go('app.change.list', {});
  5724. } else if (pdKey == "bpm_problem") {
  5725. $state.go('app.problem.list', {});
  5726. } else if (pdKey == "bpm_release") {
  5727. $state.go('app.release.list', {});
  5728. } else if (pdKey == "bpm_schedule") {
  5729. $state.go('app.scheduling.list', {});
  5730. } else if (pdKey == "bpm_configure") {
  5731. $state.go('app.cmdb.plist', {});
  5732. } else if (pdKey == "bpm_reService") {
  5733. $state.go('app.reService.manager', {});
  5734. } else if (pdKey == "inspectionListForm") {
  5735. $state.go('app.inspection.inspectList', {});
  5736. } else if (pdKey == "bpm_inspection") {
  5737. $state.go('app.inspection.inspectList', {});
  5738. } else if (pdKey == "bpm_service_request") {
  5739. $state.go('app.reService.manager', {});
  5740. }
  5741. event.preventDefault();
  5742. };
  5743. $scope.save = function(data) {
  5744. api_bpm_domain.save($stateParams.taskId, data).then(function(response) {
  5745. if (response) {
  5746. var resData = Restangular.stripRestangular(response);
  5747. // SweetAlert.swal({
  5748. // title: "暂存成功!",
  5749. // confirmButtonColor: "#007AFF"
  5750. // }, function() {
  5751. // $state.go($scope.formData.cancelUrl);
  5752. // });
  5753. $ionicPopup.alert({
  5754. title: '暂存成功!',
  5755. okText: '确认'
  5756. }).then(function(res) {
  5757. history.go(-1);
  5758. // $state.go($scope.formData.cancelUrl);
  5759. });
  5760. } else {
  5761. // SweetAlert.swal({
  5762. // title: "系统错误",
  5763. // text: "系统错误,请稍后重试!",
  5764. // type: "error",
  5765. // confirmButtonColor: "#DD6B55"
  5766. // });
  5767. $ionicPopup.alert({
  5768. title: '系统错误!',
  5769. okText: '确认'
  5770. }).then(function(res) {
  5771. history.go(-1);
  5772. // $state.go($scope.formData.cancelUrl);
  5773. });
  5774. }
  5775. });
  5776. event.preventDefault();
  5777. }
  5778. vm.submit = function(data, style) {
  5779. // var pdKey = $stateParams.pdKey;
  5780. if (vm.form.$valid) {
  5781. // $scope.ldloading[style.replace('-', '_')] = true;
  5782. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  5783. // console.log("vm.options:"+ JSON.stringify(vm.options));
  5784. vm.options.updateInitialValue();
  5785. // console.log("dfjkasdhfkhskjf ")
  5786. var _ = window._;
  5787. vm.model = (function filter(obj) {
  5788. var dateTransKeys = [];
  5789. var filtered = _.pick(obj, function(v, k, obj) {
  5790. if (_.isDate(v)) {
  5791. dateTransKeys.push(k);
  5792. }
  5793. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  5794. });
  5795. return _.cloneDeep(filtered, function(v, index, object) {
  5796. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  5797. angular.forEach(dateTransKeys, function(item) {
  5798. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  5799. })
  5800. dateTransKey = [];
  5801. return v;
  5802. }
  5803. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  5804. });
  5805. })(vm.model);
  5806. if (pdKey != "") {
  5807. if ($scope.oprcode == "save") { //保存
  5808. api_bpm_domain.save(taskId, vm.model).then(function(response) {
  5809. if (response) {
  5810. var resData = Restangular.stripRestangular(response);
  5811. // SweetAlert.swal({
  5812. // title: "保存成功!",
  5813. // confirmButtonColor: "#007AFF"
  5814. // }, function() {
  5815. // $state.go($scope.formData.cancelUri);
  5816. // });
  5817. $ionicPopup.alert({
  5818. title: '保存成功!',
  5819. okText: '确认'
  5820. }).then(function(res) {
  5821. history.go(-1);
  5822. // $state.go($scope.formData.cancelUrl);
  5823. });
  5824. } else {
  5825. // SweetAlert.swal({
  5826. // title: "系统错误",
  5827. // text: "系统错误,请稍后重试!",
  5828. // type: "error",
  5829. // confirmButtonColor: "#DD6B55"
  5830. // });
  5831. $ionicPopup.alert({
  5832. title: '系统错误!',
  5833. okText: '确认'
  5834. })
  5835. }
  5836. // $scope.ldloading[style.replace('-', '_')] = false;
  5837. });
  5838. } else {
  5839. switch ($scope.formData.url) {
  5840. case "start":
  5841. vm.model["initUser"] = $rootScope.user.id;
  5842. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  5843. } else {
  5844. vm.model["assignee"] = $rootScope.user.id;
  5845. };
  5846. if (pdKey == 'bpm_service_request') {
  5847. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  5848. angular.extend(vm.model.serviceCatalogueProcessActual, {
  5849. 'category': {
  5850. 'id': $stateParams.userId
  5851. }
  5852. });
  5853. };
  5854. if (pdKey == 'weChatApplyStart') {
  5855. if (vm.model.incident && vm.model.incident.placeId && angular.isObject(vm.model.incident.placeId)) {
  5856. vm.model.incident.placeId = vm.model.incident.placeId.id
  5857. }
  5858. api_bpm_domain.weChatApplyStart('', vm.model).then(function(response) {
  5859. if (response && response.state == 200) {
  5860. var resData = Restangular.stripRestangular(response);
  5861. if (resData) {
  5862. // console.log("$scope.fileUploader="+$scope.fileUploader)
  5863. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.incident.id) {
  5864. //$scope.uploader.options.url();
  5865. $scope.fileUploader.onBeforeUploadItem = function(item) {
  5866. angular.extend(item.headers, {
  5867. 'access-token': sessionLogin.token,
  5868. });
  5869. //微信上传的用的是微信的事件id
  5870. // item.url = api_bpm_domain.saveAttachments(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
  5871. item.url = api_bpm_domain.uploadAttachment(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
  5872. item.formData.push({ 'filename': item.file.name });
  5873. console.log($scope.fileUploader);
  5874. };
  5875. $scope.fileUploader.uploadAll();
  5876. }
  5877. }
  5878. // SweetAlert.swal({
  5879. // title: "提交成功!",
  5880. // confirmButtonColor: "#007AFF"
  5881. // }, function() {
  5882. // $state.go($scope.formData.cancelUrl);
  5883. // });
  5884. $ionicPopup.alert({
  5885. title: '提交成功!',
  5886. okText: '确认'
  5887. }).then(function(res) {
  5888. history.go(-1);
  5889. // $state.go($scope.formData.cancelUrl);
  5890. });
  5891. } else {
  5892. // SweetAlert.swal({
  5893. // title: "系统错误",
  5894. // text: "系统错误,请稍后重试!",
  5895. // type: "error",
  5896. // confirmButtonColor: "#DD6B55"
  5897. // });
  5898. $ionicPopup.alert({
  5899. title: '系统错误!',
  5900. okText: '确认'
  5901. })
  5902. }
  5903. // $scope.ldloading[style.replace('-', '_')] = false;
  5904. });
  5905. } else {
  5906. api_bpm_domain.start(pdKey, vm.model).then(function(response) {
  5907. if (response) {
  5908. var resData = Restangular.stripRestangular(response);
  5909. if (resData) {
  5910. // console.log("$scope.fileUploader="+$scope.fileUploader)
  5911. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  5912. //$scope.uploader.options.url();
  5913. $scope.fileUploader.onBeforeUploadItem = function(item) {
  5914. angular.extend(item.headers, {
  5915. 'access-token': sessionLogin.token,
  5916. });
  5917. //微信处理人上传的用的是流程id
  5918. // angular.extend(item.headers, $rootScope.getSession());
  5919. item.url = api_bpm_domain.saveAttachments(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  5920. // item.url = api_bpm_domain.uploadAttachment(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
  5921. item.formData.push({ 'fileName': item.file.name });
  5922. //console.log();
  5923. };
  5924. $scope.fileUploader.uploadAll();
  5925. }
  5926. }
  5927. // SweetAlert.swal({
  5928. // title: "提交成功!",
  5929. // confirmButtonColor: "#007AFF"
  5930. // }, function() {
  5931. // $state.go($scope.formData.cancelUrl);
  5932. // });
  5933. $ionicPopup.alert({
  5934. title: '提交成功!',
  5935. okText: '确认'
  5936. }).then(function(res) {
  5937. history.go(-1);
  5938. // $state.go($scope.formData.cancelUrl);
  5939. });
  5940. } else {
  5941. // SweetAlert.swal({
  5942. // title: "系统错误",
  5943. // text: "系统错误,请稍后重试!",
  5944. // type: "error",
  5945. // confirmButtonColor: "#DD6B55"
  5946. // });
  5947. $ionicPopup.alert({
  5948. title: '系统错误!',
  5949. okText: '确认'
  5950. })
  5951. }
  5952. // $scope.ldloading[style.replace('-', '_')] = false;
  5953. });
  5954. }
  5955. break;
  5956. case "save":
  5957. //weChatApplySave
  5958. vm.model["initUser"] = $rootScope.user.id;
  5959. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  5960. } else {
  5961. vm.model["assignee"] = $rootScope.user.id;
  5962. };
  5963. if (pdKey == 'bpm_service_request') {
  5964. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  5965. angular.extend(vm.model.serviceCatalogueProcessActual, {
  5966. 'category': {
  5967. 'id': $stateParams.userId
  5968. }
  5969. });
  5970. };
  5971. if (pdKey == 'weChatApplySave') {
  5972. api_bpm_domain.weChatApplySave($stateParams.incidentid, vm.model).then(function(response) {
  5973. if (response) {
  5974. var resData = Restangular.stripRestangular(response);
  5975. if (resData) {
  5976. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.incident.id) {
  5977. $scope.fileUploader.onBeforeUploadItem = function(item) {
  5978. angular.extend(item.headers, {
  5979. 'access-token': sessionLogin.token,
  5980. });
  5981. item.url = api_bpm_domain.saveAttachments(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  5982. item.url = api_bpm_domain.uploadAttachment(resData.incident.id, '00000', $rootScope.user.id).getRequestedUrl();
  5983. item.formData.push({ 'filename': item.file.name });
  5984. console.log($scope.fileUploader);
  5985. };
  5986. $scope.fileUploader.uploadAll();
  5987. }
  5988. }
  5989. $ionicPopup.alert({
  5990. title: '提交成功!',
  5991. okText: '确认'
  5992. }).then(function(res) {
  5993. history.go(-1);
  5994. });
  5995. } else {
  5996. $ionicPopup.alert({
  5997. title: '系统错误!',
  5998. okText: '确认'
  5999. })
  6000. }
  6001. });
  6002. } else {
  6003. api_bpm_domain.save(pdKey, vm.model).then(function(response) {
  6004. if (response) {
  6005. var resData = Restangular.stripRestangular(response);
  6006. if (resData) {
  6007. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  6008. $scope.fileUploader.onBeforeUploadItem = function(item) {
  6009. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  6010. item.formData.push({ 'filename': item.file.name });
  6011. };
  6012. $scope.fileUploader.uploadAll();
  6013. }
  6014. }
  6015. $ionicPopup.alert({
  6016. title: '提交成功!',
  6017. okText: '确认'
  6018. }).then(function(res) {
  6019. history.go(-1);
  6020. });
  6021. } else {
  6022. $ionicPopup.alert({
  6023. title: '系统错误!',
  6024. okText: '确认'
  6025. })
  6026. }
  6027. });
  6028. }
  6029. break;
  6030. case "complete":
  6031. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  6032. //console.log("complete taskId::"+$stateParams.taskId);
  6033. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function(response) {
  6034. if (response) {
  6035. var resData = Restangular.stripRestangular(response);
  6036. // SweetAlert.swal({
  6037. // title: "提交成功!",
  6038. // confirmButtonColor: "#007AFF"
  6039. // }, function() {
  6040. // $state.go($scope.formData.cancelUrl);
  6041. // });
  6042. $ionicPopup.alert({
  6043. title: '提交成功!',
  6044. okText: '确认'
  6045. }).then(function(res) {
  6046. history.go(-1);
  6047. // $state.go($scope.formData.cancelUrl);
  6048. });
  6049. } else {
  6050. // SweetAlert.swal({
  6051. // title: "系统错误",
  6052. // text: "系统错误,请稍后重试!",
  6053. // type: "error",
  6054. // confirmButtonColor: "#DD6B55"
  6055. // });
  6056. $ionicPopup.alert({
  6057. title: '系统错误!',
  6058. okText: '确认'
  6059. })
  6060. }
  6061. // $scope.ldloading[style.replace('-', '_')] = false;
  6062. });
  6063. break;
  6064. case "back":
  6065. $state.go($scope.formData.cancelUrl);
  6066. break;
  6067. default:
  6068. // $scope.ldloading[style.replace('-', '_')] = false;
  6069. break;
  6070. }
  6071. }
  6072. // var submitFunc = api_bpm_domain[$scope.formData.url]
  6073. // if(anuglar.isFunction(submitFunc)){
  6074. // submitFunc.apply(null, pdKey)
  6075. // }
  6076. }
  6077. } else {
  6078. console.log(data)
  6079. // angular.forEach(vm.form.$error.required, function(item){
  6080. // var i=(item.$name).substring(item.$name.length-2)
  6081. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  6082. // for(var i=0;i<vm.fields.length;i++){
  6083. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  6084. // SweetAlert.swal({
  6085. // title: vm.fields[i].templateOptions.label + '未填',
  6086. // text: "请填写此项!",
  6087. // type: "error",
  6088. // confirmButtonColor: "#DD6B55"
  6089. // });
  6090. $ionicPopup.alert({
  6091. title: vm.fields[i].templateOptions.label + '未填',
  6092. okText: '确认'
  6093. })
  6094. }
  6095. // }
  6096. // angular.forEach(vm.fields,function(f){
  6097. // if(f.name == item.$name){
  6098. // f.validation.show = true;
  6099. // SweetAlert.swal({
  6100. // title: f.templateOptions.label+'未填',
  6101. // text: "请填写此项!",
  6102. // type: "error",
  6103. // confirmButtonColor: "#DD6B55"
  6104. // });
  6105. // }
  6106. // });
  6107. // })
  6108. }
  6109. };
  6110. $scope.vm = vm;
  6111. $scope.reload = function() {
  6112. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  6113. var processInstanceId = $stateParams.processInstanceId;
  6114. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  6115. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function(responseData) {
  6116. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  6117. var vmForm = Restangular.stripRestangular(responseData);
  6118. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6119. decodeVMForm(vmForm);
  6120. //console.log($scope);
  6121. }
  6122. }
  6123. });
  6124. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  6125. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function(responseData) {
  6126. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  6127. var vmForm = Restangular.stripRestangular(responseData);
  6128. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6129. decodeVMForm(vmForm);
  6130. //console.log($scope);
  6131. }
  6132. }
  6133. });
  6134. } else {
  6135. api_bpm_domain.taskformkey($stateParams.taskId).then(function(response) {
  6136. if (response) {
  6137. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  6138. api_configure_form.renderForm(myData.data, userId, processInstanceId).then(function(responseData) {
  6139. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  6140. var vmForm = Restangular.stripRestangular(responseData);
  6141. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6142. decodeVMForm(vmForm);
  6143. //console.log($scope);
  6144. }
  6145. }
  6146. });
  6147. }
  6148. })
  6149. }
  6150. } else {
  6151. // create process instance
  6152. if (pdKey != "") { //for process
  6153. if (pdKey == 'bpm_service_request') {
  6154. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function(responseData) {
  6155. if (responseData) {
  6156. var vmForm = Restangular.stripRestangular(responseData);
  6157. if (vmForm) {
  6158. decodeVMForm(vmForm);
  6159. }
  6160. }
  6161. });
  6162. } else if (pdKey == 'weChatApplyStart' || pdKey == 'weChatApplySave') {
  6163. // alert('pdKey' + ':' + pdKey);
  6164. // alert('formKey' + ':' + $stateParams.formKey);
  6165. // alert(api_configure_form.renderForm($stateParams.formKey, '00000').getRequestedUrl());
  6166. api_configure_form.renderForm($stateParams.formKey, '00000').then(function(responseData) {
  6167. // var aa = Restangular.stripRestangular(responseData);
  6168. // for (var i in aa) {
  6169. // if (aa.hasOwnProperty(i)) { //filter,只输出man的私有属性
  6170. // alert(i + ":" + aa[i]);
  6171. // };
  6172. // }
  6173. if (responseData) {
  6174. var vmForm = Restangular.stripRestangular(responseData);
  6175. if (vmForm) {
  6176. decodeVMForm(vmForm);
  6177. }
  6178. }
  6179. });
  6180. } else {
  6181. api_bpm_domain.startformkey(pdKey).then(function(response) {
  6182. if (response) {
  6183. var myData = Restangular.stripRestangular(response);
  6184. //myData.data = "arrangeform";
  6185. api_configure_form.renderForm(myData.data, userId).then(function(responseData) {
  6186. if (responseData) {
  6187. var vmForm = Restangular.stripRestangular(responseData);
  6188. if (vmForm) {
  6189. decodeVMForm(vmForm);
  6190. //console.log($rootScope);
  6191. }
  6192. }
  6193. });
  6194. }
  6195. });
  6196. }
  6197. }
  6198. }
  6199. }
  6200. if (sessionStorage.sessionLogin) {
  6201. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  6202. var loginUser = sessionLogin.user;
  6203. $rootScope.user = sessionLogin.user;
  6204. //默认数据
  6205. $scope.defaultData = {
  6206. 'assignee': loginUser.id,
  6207. 'idx': 0,
  6208. 'sum': 10,
  6209. };
  6210. //填充数据
  6211. $scope.filterData = {
  6212. 'assignee': loginUser.id,
  6213. 'idx': 0,
  6214. 'sum': 10,
  6215. };
  6216. $scope.reload()
  6217. }
  6218. $scope.$on("loginComplete", function(event, data) {
  6219. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  6220. var loginUser = sessionLogin.user;
  6221. $rootScope.user = sessionLogin.user;
  6222. //默认数据
  6223. $scope.defaultData = {
  6224. 'assignee': loginUser.id,
  6225. 'idx': 0,
  6226. 'sum': 10,
  6227. };
  6228. //填充数据
  6229. $scope.filterData = {
  6230. 'assignee': loginUser.id,
  6231. 'idx': 0,
  6232. 'sum': 10,
  6233. };
  6234. $scope.reload()
  6235. });
  6236. //console.log("end decode");
  6237. }
  6238. ]);