customformCtrl.js 792 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304
  1. var appFormly = angular.module('formlyExample', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlyExample');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. appFormly.config(
  10. function config(formlyConfigProvider) {
  11. //格式转换方法 XXX-XXX转驼峰命名
  12. function camelize(string) {
  13. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  14. return chr ? chr.toUpperCase() : '';
  15. });
  16. // Ensure 1st char is always lowercase
  17. return string.replace(/^([A-Z])/, function (match, chr) {
  18. return chr ? chr.toLowerCase() : '';
  19. });
  20. }
  21. //获取ngModelAttr对象设置
  22. function getNgModelAttr(attrs, bindings) {
  23. var ngModelAttrs = {};
  24. angular.forEach(attrs, function (attr) {
  25. ngModelAttrs[camelize(attr)] = { attribute: attr };
  26. });
  27. angular.forEach(bindings, function (binding) {
  28. ngModelAttrs[camelize(binding)] = { bound: binding };
  29. });
  30. return ngModelAttrs;
  31. }
  32. formlyConfigProvider.setWrapper({
  33. name: 'bootstrapLabel',
  34. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  35. });
  36. //流程图
  37. formlyConfigProvider.setType({
  38. name: 'ui-process',
  39. templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
  40. defaultOptions: function(options) {
  41. return {
  42. templateOptions: {
  43. refresh: function() {},
  44. refreshDelay: 0
  45. }
  46. };
  47. },
  48. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function($scope, $modal, SweetAlert, api_bpm_domain) {
  49. $scope.processdata = [];
  50. api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function(data) {
  51. console.log(data)
  52. $scope.processdata = data.data;
  53. })
  54. }]
  55. });
  56. //出库单详情
  57. formlyConfigProvider.setType({
  58. name: 'ui-getoutinform',
  59. extends: 'radio',
  60. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
  61. defaultOptions: function(options) {
  62. return {
  63. templateOptions: {
  64. refresh: function() {},
  65. refreshDelay: 0
  66. }
  67. };
  68. },
  69. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function($scope, $modal, SweetAlert, api_bpm_domain) {
  70. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  71. if ($scope.model.type.id = 0) {
  72. $scope.model.type.name = "新资产入库";
  73. } else if ($scope.model.type.id = 1) {
  74. $scope.model.type.name = "新设备领用出库";
  75. } else if ($scope.model.type.id = 2) {
  76. $scope.model.type.name = "资产归还";
  77. } else if ($scope.model.type.id = 4) {
  78. $scope.model.type.name = "设备更换";
  79. }
  80. }
  81. }]
  82. });
  83. //多选框组件
  84. formlyConfigProvider.setType({
  85. name: 'ui-checkboxmore',
  86. extends: 'radio',
  87. templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
  88. defaultOptions: function(options) {
  89. return {
  90. templateOptions: {
  91. refresh: function() {},
  92. refreshDelay: 0
  93. }
  94. };
  95. },
  96. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function($scope, $modal, SweetAlert, api_bpm_domain) {
  97. $scope.options.initialValue = $scope.model[$scope.options.key];
  98. }]
  99. });
  100. //入库单详情
  101. formlyConfigProvider.setType({
  102. name: 'ui-getininform',
  103. extends: 'radio',
  104. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
  105. defaultOptions: function(options) {
  106. return {
  107. templateOptions: {
  108. refresh: function() {},
  109. refreshDelay: 0
  110. }
  111. };
  112. },
  113. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function($scope, $modal, SweetAlert, api_bpm_domain) {
  114. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  115. if ($scope.model.type.id = 0) {
  116. $scope.model.type.name = "新资产入库";
  117. } else if ($scope.model.type.id = 1) {
  118. $scope.model.type.name = "新设备领用出库";
  119. } else if ($scope.model.type.id = 2) {
  120. $scope.model.type.name = "资产归还";
  121. } else if ($scope.model.type.id = 4) {
  122. $scope.model.type.name = "设备更换";
  123. }
  124. }
  125. }]
  126. });
  127. //申请人详情
  128. formlyConfigProvider.setType({
  129. name: 'ui-requsterinfom',
  130. extends: 'radio',
  131. templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
  132. defaultOptions: function(options) {
  133. return {
  134. templateOptions: {
  135. refresh: function() {},
  136. refreshDelay: 0
  137. }
  138. };
  139. }
  140. });
  141. //设备耗材list组件
  142. formlyConfigProvider.setType({
  143. name: 'ui-uplodchange',
  144. templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
  145. defaultOptions: function(options) {
  146. return {
  147. templateOptions: {
  148. refresh: function() {},
  149. refreshDelay: 0,
  150. view: function(APIService, contentId) {
  151. return APIService.downloadAttachment(contentId);
  152. }
  153. }
  154. };
  155. },
  156. controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function($scope, $filter, ngTableParams, $rootScope, Restangular) {
  157. // var data = { "haodata": [], "shedata": [] };
  158. var haodata = [];
  159. var shedata = [];
  160. if ($scope.model.consumables) {
  161. if (angular.isArray($scope.model.consumables)) {
  162. haodata = $scope.model.consumables;
  163. } else {
  164. haodata = JSON.parse($scope.model.consumables);
  165. }
  166. $scope.model.consumables = haodata;
  167. angular.forEach(haodata, function(item, index) {
  168. haodata[index].item = index + 1;
  169. })
  170. }
  171. if ($scope.model.assets) {
  172. if (angular.isArray($scope.model.assets)) {
  173. shedata = $scope.model.assets;
  174. } else {
  175. shedata = JSON.parse($scope.model.assets);
  176. }
  177. $scope.model.assets = shedata;
  178. angular.forEach(shedata, function(item, index) {
  179. shedata[index].item = index + 1;
  180. })
  181. }
  182. $scope.tableParamshao = new ngTableParams({
  183. page: 1,
  184. count: 5
  185. }, {
  186. total: haodata.length,
  187. getData: function($defer, params) {
  188. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  189. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  190. }
  191. });
  192. $scope.tableParamsshe = new ngTableParams({
  193. page: 1,
  194. count: 5
  195. }, {
  196. total: shedata.length,
  197. getData: function($defer, params) {
  198. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  199. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  200. }
  201. });
  202. $scope.editId = -1;
  203. $scope.setEditId = function(pid) {
  204. $scope.editId = pid;
  205. };
  206. if (angular.isUndefined($scope.form.dropState)) {
  207. $scope.form.dropState = false;
  208. }
  209. var to = $scope.options.templateOptions;
  210. var bindId = $scope.model.processInstanceId;
  211. //获取附件列表
  212. $scope.listAttachmen = function() {
  213. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function(result) {
  214. var myData = Restangular.stripRestangular(result);
  215. // $scope.listAttachmens = myData;
  216. $scope.attachments = myData.data;
  217. });
  218. };
  219. $scope.listAttachmen();
  220. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  221. // $scope.listAttachmen();
  222. // } else if (to.bindType && $scope.model[to.bindType].id) {
  223. // $scope.listAttachmen();
  224. // }
  225. //附件下载
  226. $scope.download = function(token, filename) {
  227. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  228. // window.open(downUrl);
  229. var a = document.createElement('a');
  230. a.href = downUrl;
  231. a.target = '_blank';
  232. a.download = filename;
  233. document.body.appendChild(a);
  234. a.click();
  235. };
  236. //附件预览
  237. $scope.view = function(id, previewUrl) {
  238. if (previewUrl) {
  239. window.open(previewUrl);
  240. }
  241. };
  242. }]
  243. });
  244. //多选框组件
  245. formlyConfigProvider.setType({
  246. name: 'ui-nodataimage',
  247. templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
  248. defaultOptions: function(options) {
  249. return {
  250. templateOptions: {
  251. refresh: function() {},
  252. refreshDelay: 0
  253. }
  254. };
  255. }
  256. });
  257. //ui-grid list
  258. formlyConfigProvider.setType({
  259. name: "ui-gridtwolist",
  260. // extends: 'input',
  261. templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
  262. defaultOptions: function(options, $scope) {
  263. return {
  264. templateOptions: {}
  265. };
  266. },
  267. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function($scope, $modal, i18nService, SweetAlert) {
  268. //gridone
  269. $scope.langs = i18nService.getAllLangs();
  270. $scope.lang = 'zh-cn';
  271. i18nService.setCurrentLang($scope.lang);
  272. $scope.gridOptions = {};
  273. $scope.gridOptions.data = 'myDatagrid';
  274. $scope.gridOptions.enableColumnResizing = true;
  275. $scope.gridOptions.enableFiltering = true;
  276. $scope.gridOptions.enableGridMenu = false;
  277. $scope.gridOptions.enableRowSelection = true;
  278. $scope.gridOptions.showGridFooter = true;
  279. $scope.gridOptions.showColumnFooter = false;
  280. $scope.gridOptions.fastWatch = true;
  281. $scope.gridOptions.useExternalFiltering = false;
  282. $scope.gridOptions.useExternalPagination = true;
  283. $scope.gridOptions.paginationPageSizes = [10];
  284. $scope.gridOptions.paginationPageSize = 10;
  285. $scope.gridOptions.multiSelect = false;
  286. $scope.myDatagrid = [];
  287. $scope.myDatagridall = [];
  288. $scope.selected = {
  289. item: {}
  290. };
  291. $scope.memoryfilterDatagrid = {
  292. idx: 0,
  293. sum: 10
  294. }
  295. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  296. filterData = {
  297. idx: 0,
  298. sum: 10
  299. };
  300. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  301. }
  302. $scope.gridOptions.rowIdentity = function(row) {
  303. return row.id;
  304. };
  305. $scope.gridOptions.getRowIdentity = function(row) {
  306. return row.id;
  307. };
  308. // $scope.gridOptions.columnDefs = items.columnDefs();
  309. $scope.interceptMydata = function(mydate, idx, sum) {
  310. return mydate.slice(idx * sum, (idx + 1) * sum)
  311. }
  312. $scope.gridOptions.onRegisterApi = function(gridApi) {
  313. $scope.gridApi = gridApi;
  314. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  315. $scope.memoryfilterDatagrid.idx = newPage - 1;
  316. $scope.memoryfilterDatagrid.sum = pageSize;
  317. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  318. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  319. });
  320. gridApi.core.on.filterChanged($scope, function() {});
  321. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  322. $scope.selected.item = data.entity;
  323. //console.log(data);
  324. });
  325. };
  326. $scope.loadData = function(mydate, idx, sum) {
  327. angular.forEach($scope.myDatagrid, function(item, index) {
  328. $scope.myDatagrid[index].item = index;
  329. })
  330. $scope.gridOptions.totalItems = mydate.length;
  331. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  332. }
  333. if ($scope.model.assets) {
  334. $scope.myDatagridall = $scope.model.assets;
  335. $scope.loadData($scope.model.assets, 0, 10)
  336. }
  337. $scope.saveData = function(itemin) {
  338. event.preventDefault();
  339. var modalInstance = $modal.open({
  340. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  341. controller: function($scope, $modalInstance, SweetAlert) {
  342. // $scope.consumptive = {};
  343. $scope.title = "填写领用设备信息";
  344. // if (items.name) {
  345. // $scope.consumptive.name = items.name.name;
  346. // }
  347. $scope.placechange = angular.copy(itemin);
  348. $scope.ok = function(item) {
  349. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  350. $modalInstance.close(item);
  351. } else {
  352. SweetAlert.swal({
  353. title: "数据填写不完整!",
  354. text: "请检查数据然后提交!",
  355. type: "error"
  356. });
  357. }
  358. };
  359. $scope.cancel = function() {
  360. $modalInstance.dismiss('cancel');
  361. };
  362. },
  363. resolve: {
  364. SweetAlert: function() {
  365. return SweetAlert;
  366. }
  367. }
  368. });
  369. modalInstance.result.then(function(selectedItem) {
  370. angular.forEach($scope.myDatagrid, function(item, index) {
  371. // $scope.myDatagrid[index].props.hw_state = "在线";
  372. if (item.id == selectedItem.id) {
  373. // $scope.myDatagrid[index] = selectedItem;
  374. angular.extend($scope.myDatagrid[index], selectedItem)
  375. }
  376. })
  377. // $scope.myData3.push(selectedItem);
  378. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  379. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  380. }
  381. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  382. })
  383. }
  384. //gridtwo
  385. $scope.langs = i18nService.getAllLangs();
  386. $scope.lang = 'zh-cn';
  387. i18nService.setCurrentLang($scope.lang);
  388. $scope.gridOptions2 = {};
  389. $scope.gridOptions2.data = 'myDatagridold';
  390. $scope.gridOptions2.enableColumnResizing = true;
  391. $scope.gridOptions2.enableFiltering = true;
  392. $scope.gridOptions2.enableGridMenu = false;
  393. $scope.gridOptions2.enableRowSelection = true;
  394. $scope.gridOptions2.showGridFooter = true;
  395. $scope.gridOptions2.showColumnFooter = false;
  396. $scope.gridOptions2.fastWatch = true;
  397. $scope.gridOptions2.useExternalFiltering = false;
  398. $scope.gridOptions.useExternalPagination = true;
  399. $scope.gridOptions2.paginationPageSizes = [10];
  400. $scope.gridOptions2.paginationPageSize = 10;
  401. $scope.gridOptions2.multiSelect = false;
  402. $scope.myDatagridold = [];
  403. $scope.myDatagridoldall = [];
  404. $scope.selected = {
  405. item: {}
  406. };
  407. $scope.memoryfilterDatagridold = {
  408. idx: 0,
  409. sum: 10
  410. }
  411. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  412. filterData = {
  413. idx: 0,
  414. sum: 10
  415. };
  416. $scope.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
  417. }
  418. $scope.gridOptions2.rowIdentity = function(row) {
  419. return row.id;
  420. };
  421. $scope.gridOptions2.getRowIdentity = function(row) {
  422. return row.id;
  423. };
  424. // $scope.gridOptions.columnDefs = items.columnDefs();
  425. $scope.interceptMydata = function(mydate, idx, sum) {
  426. return mydate.slice(idx * sum, (idx + 1) * sum)
  427. }
  428. if ($scope.model.oldAssets) {
  429. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  430. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
  431. }
  432. $scope.gridOptions2.onRegisterApi = function(gridApi) {
  433. $scope.gridApi = gridApi;
  434. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  435. $scope.memoryfilterDatagridold.idx = newPage - 1;
  436. $scope.memoryfilterDatagridold.sum = pageSize;
  437. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
  438. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  439. });
  440. gridApi.core.on.filterChanged($scope, function() {});
  441. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  442. $scope.selected.item = data.entity;
  443. //console.log(data);
  444. });
  445. };
  446. // $scope.loadData = function(mydate, idx, sum) {
  447. // angular.forEach($scope.myDatagridold, function(item, index) {
  448. // $scope.myDatagridold[index].item = index;
  449. // })
  450. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  451. // }
  452. // if ($scope.model.assets) {
  453. // $scope.myDatagridallold = $scope.model.assets;
  454. // $scope.loadData($scope.model.assets, 0, 10)
  455. // }
  456. // $scope.addoldassets = function(itemin) {
  457. // event.preventDefault();
  458. // var modalInstance = $modal.open({
  459. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  460. // controller: function($scope, $modalInstance, SweetAlert) {
  461. // // $scope.consumptive = {};
  462. // $scope.title = "填写领用设备信息";
  463. // // if (items.name) {
  464. // // $scope.consumptive.name = items.name.name;
  465. // // }
  466. // $scope.placechange = itemin;
  467. // $scope.ok = function(item) {
  468. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  469. // $modalInstance.close(item);
  470. // } else {
  471. // SweetAlert.swal({
  472. // title: "数据填写不完整!",
  473. // text: "请检查数据然后提交!",
  474. // type: "error"
  475. // });
  476. // }
  477. // };
  478. // $scope.cancel = function() {
  479. // $modalInstance.dismiss('cancel');
  480. // };
  481. // },
  482. // resolve: {
  483. // SweetAlert: function() {
  484. // return SweetAlert;
  485. // }
  486. // }
  487. // });
  488. $scope.interceptMydata = function(mydate, idx, sum) {
  489. return mydate.slice(idx * sum, (idx + 1) * sum)
  490. }
  491. $scope.addshebei = function() {
  492. event.preventDefault();
  493. var modalInstance = $modal.open({
  494. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  495. controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
  496. $scope.langs = i18nService.getAllLangs();
  497. $scope.lang = 'zh-cn';
  498. i18nService.setCurrentLang($scope.lang);
  499. $scope.gridOptions = {};
  500. $scope.gridOptions.data = 'myDatatwo';
  501. $scope.gridOptions.enableColumnResizing = true;
  502. $scope.gridOptions.enableFiltering = false;
  503. $scope.gridOptions.enableGridMenu = false;
  504. $scope.gridOptions.showGridFooter = true;
  505. $scope.gridOptions.showColumnFooter = false;
  506. $scope.gridOptions.fastWatch = true;
  507. $scope.gridOptions.useExternalFiltering = true;
  508. $scope.gridOptions.useExternalPagination = true;
  509. $scope.gridOptions.paginationPageSizes = [10];
  510. $scope.gridOptions.paginationPageSize = 10;
  511. $scope.gridOptions.multiSelect = true;
  512. $scope.gridOptions.rowIdentity = function(row) {
  513. return row.id;
  514. };
  515. $scope.gridOptions.getRowIdentity = function(row) {
  516. return row.id;
  517. };
  518. $scope.gridOptions.columnDefs = [
  519. { name: 'item', displayName: '序号', width: 80, enableFiltering: false },
  520. { name: 'uuid', displayName: '内部编号', width: 120 },
  521. { name: 'props.hw_mingcheng', displayName: '资产名称', width: 100 },
  522. { name: 'props.hw_cifilterClassic', displayName: '资产类型', width: 120, enableFiltering: false },
  523. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  524. { name: 'props.hw_state', displayName: '资产状态', width: 150, enableFiltering: false },
  525. { name: 'props.hwnw_area', displayName: '资产地点', width: 130, enableFiltering: false },
  526. { name: 'createtime', displayName: '申请时间', enableFiltering: false }
  527. ];
  528. // $scope.selectButtonClick
  529. var defaultFilterData = {
  530. // "assignee":2,
  531. // "applicationForm": { "hw_state": "在线" },
  532. "hw_state": "在线",
  533. "idx": 0,
  534. "sum": 10
  535. };
  536. $scope.memoryfilterData = {
  537. // "assignee":2,
  538. // "applicationForm": { "hw_state": "在线" },
  539. "hw_state": "在线",
  540. "idx": 0,
  541. "sum": 10
  542. }
  543. $scope.refreshData = function(style, filterData) {
  544. if (angular.isUndefined(filterData)) {
  545. filterData = defaultFilterData;
  546. }
  547. $scope.myDatatwo = [];
  548. // $scope.gridOptions['sum']=filterData.sum;
  549. api_cmdb.query(filterData).then(function(data) {
  550. // $scope.callsPending--;
  551. var myDatatwo = Restangular.stripRestangular(data);
  552. $scope.gridOptions['totalItems'] = data.total;
  553. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  554. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  555. }
  556. $scope.myDatatwo = myDatatwo.data.node;
  557. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  558. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  559. }
  560. }, function() {});
  561. };
  562. $scope.refreshData('expand-right', defaultFilterData);
  563. $scope.gridOptions.onRegisterApi = function(gridApi) {
  564. $scope.gridApi = gridApi;
  565. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  566. var filtersData = $scope.memoryfilterData;
  567. filtersData.idx = newPage - 1;
  568. filtersData.sum = pageSize;
  569. // $scope.loadData(filtersData);
  570. $scope.refreshData('expand-right', filtersData);
  571. //console.log(pageSize);
  572. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  573. });
  574. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  575. // $scope.selected.items.push(data.entity);
  576. //console.log(data);
  577. gridApi.selection.on.rowSelectionChanged($scope, function(scope, ect) {
  578. if (scope.isSelected) {
  579. scope.grid.appScope.selected.items.push(scope.entity)
  580. } else {
  581. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  582. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  583. scope.grid.appScope.selected.items.splice(i, 1);
  584. break;
  585. }
  586. }
  587. }
  588. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  589. });
  590. // });
  591. gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
  592. // $scope.selected.items = data.entity;
  593. //console.log(data);
  594. var selectitem = [];
  595. selectitem = angular.copy($scope.selected.items);
  596. for (var j = 0; j < rows.length; j++) {
  597. if (rows[j].isSelected == true) {
  598. selectitem.push(rows[j].entity);
  599. } else {
  600. delete selectitem[j];
  601. // rows.splice(j, 1);
  602. }
  603. }
  604. $scope.selected.items = [];
  605. for (var i = 0; i < selectitem.length; i++) {
  606. if (selectitem[i]) {
  607. $scope.selected.items.push(selectitem[i]);
  608. }
  609. }
  610. });
  611. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  612. // // if (row.entity.age > 45) {
  613. // row.grid.api.selection.selectRow(row.entity); // 选中行
  614. // // }
  615. // };
  616. gridApi.core.on.filterChanged($scope, function() {
  617. var grid = this.grid;
  618. var filtersData = {
  619. idx: 0,
  620. sum: 10,
  621. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  622. };
  623. angular.forEach(grid.columns, function(item) {
  624. if (item.enableFiltering) {
  625. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  626. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  627. if (angular.isUndefined(filtersData['user'])) {
  628. filtersData['user'] = {};
  629. }
  630. filtersData['user'][item.field] = item.filters[0].term;
  631. }
  632. }
  633. });
  634. $scope.memoryfilterData = filtersData;
  635. // $scope.loadData(filtersData);
  636. });
  637. };
  638. $scope.onDblClick = function(data, event) {
  639. // $scope.selected.items = data.entity;
  640. $scope.selectButtonClick(data, event);
  641. };
  642. $scope.title = title;
  643. //树形图
  644. var apple_selected, tree, treedata_avm, treedata_geography;
  645. $scope.my_tree_handler = function(branch) {
  646. //var _ref;
  647. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  648. api_cmdb.query({ 'sign': classify }).then(function(data) {
  649. var myDatalingbei = Restangular.stripRestangular(data);
  650. // console.log(myData.data.node);
  651. if (myDatalingbei.data && myDatalingbei.status == 200) {
  652. var ret = myDatalingbei.data;
  653. redrawSvg(myDatalingbei);
  654. }
  655. });
  656. };
  657. $scope.my_data = [];
  658. function convertListToTree(data, treeMap) {
  659. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  660. var root = null; //Initially set our loop to null
  661. var parentNode = null;
  662. //loop over data
  663. for (var i = 0; i < data.length; i++) {
  664. var datum = data[i];
  665. //each node will have children, so let's give it a "children" poperty
  666. datum.children = [];
  667. //add an entry for this node to the map so that any future children can
  668. //lookup the parent
  669. idToNodeMap[datum.id] = datum;
  670. //Does this node have a parent?
  671. if (typeof datum.parent === "undefined" || datum.parent == null) {
  672. //Doesn't look like it, so this node is the root of the tree
  673. root = datum;
  674. treeMap[datum.id] = root;
  675. } else {
  676. //This node has a parent, so let's look it up using the id
  677. parentNode = idToNodeMap[datum.parent.id];
  678. //We don't need this property, so let's delete it.
  679. delete datum.parent;
  680. //Let's add the current node as a child of the parent node.
  681. parentNode.children.push(datum);
  682. }
  683. }
  684. return root;
  685. }
  686. function convertParentToChildList(data) {
  687. var treeMap = {};
  688. var list = [];
  689. convertListToTree(data, treeMap);
  690. angular.forEach(treeMap, function(item) {
  691. list.push(item);
  692. });
  693. return list;
  694. }
  695. $scope.my_tree = tree = {};
  696. $scope.try_async_load = function() {
  697. $scope.my_data = [];
  698. $scope.select_treedata = [];
  699. $scope.doing_async = true;
  700. api_configure_data.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
  701. //console.log(result['list']);
  702. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  703. $scope.doing_async = false;
  704. // tree.expand_all();
  705. //console.log(treelist);
  706. });
  707. };
  708. $scope.select_treedata = [];
  709. $scope.propTypeOptions = [];
  710. $scope.try_async_load();
  711. $scope.onFilterremove = function(item) {
  712. console.log(item)
  713. }
  714. $scope.searchdata = {};
  715. $scope.clear = function() {
  716. $scope.searchdata = {};
  717. $scope.cifilter_classic = {};
  718. $scope.try_async_load();
  719. var fildata = {
  720. idx: 0,
  721. sum: 10,
  722. 'hw_state': '在线'
  723. }
  724. $scope.memoryfilterData = fildata;
  725. $scope.refreshData('expand-right', fildata);
  726. }
  727. $scope.chiceIncident = function(item) {
  728. var fildata = $scope.memoryfilterData;
  729. // fildata.applicationForm = {};
  730. // if (item.alltitle && item.alldata) {
  731. // fildata.applicationForm[item.alltitle.key] = item.alldata
  732. // }
  733. if (item && item.id) {
  734. var classify = item.prefix.toLowerCase() + item.sign;
  735. fildata.sign = classify
  736. }
  737. $scope.gridOptions.paginationCurrentPage = 1;
  738. var transitiondata = angular.copy(item);
  739. $scope.refreshData('expand-right', fildata);
  740. }
  741. $scope.applicadata = [];
  742. $scope.onFilterCallback = function(item) {
  743. var tempclassify = item.prefix.toLowerCase() + item.sign;
  744. api_configure_form.renderTabForm(tempclassify).then(function(data) {
  745. var myData = Restangular.stripRestangular(data);
  746. $scope.applicadata = myData[0].form.fields;
  747. });
  748. // }
  749. }
  750. // $scope.loadData({
  751. // idx: 0,
  752. // sum: 10,
  753. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  754. // });
  755. $scope.selected = {
  756. items: []
  757. };
  758. $scope.ok = function() {
  759. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  760. // onDataCallback($scope.selected.item, parentScope);
  761. // }
  762. $modalInstance.close($scope.selected.items);
  763. };
  764. $scope.cancel = function() {
  765. $modalInstance.dismiss('cancel');
  766. };
  767. },
  768. size: 'lg',
  769. resolve: {
  770. items: function() {
  771. return {
  772. fetchItems: function(filterData, APIService) {
  773. filterData = filterData || {};
  774. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  775. filterData = {
  776. idx: 0,
  777. sum: 10,
  778. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  779. };
  780. }
  781. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  782. }
  783. };
  784. },
  785. title: function() {
  786. return $scope.options.templateOptions.label;
  787. },
  788. Restangular: function() {
  789. return $scope.options.templateOptions.Restangular;
  790. },
  791. APIService: function() {
  792. return $scope.options.templateOptions.ApiService;
  793. },
  794. onDataCallback: function() {
  795. return $scope.options.templateOptions.callback;
  796. },
  797. parentScope: function() {
  798. return $scope.options.templateOptions.that;
  799. }
  800. }
  801. });
  802. modalInstance.result.then(function(selectedItem) {
  803. $scope.myDatagridoldall = selectedItem;
  804. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  805. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  806. }
  807. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  808. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  809. // $scope.model.oldAssets = $scope.myDatagridoldall;
  810. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  811. $scope.options.initialValue = $scope.model.oldAssets;
  812. });
  813. // }
  814. }
  815. $scope.changestate = function(itemin) {
  816. event.preventDefault();
  817. var modalInstance = $modal.open({
  818. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
  819. controller: function($scope, scope, $modalInstance, api_bpm_data) {
  820. $scope.title = '旧设备状态修改';
  821. $scope.stateshe = [{ "id": 2, "name": "在库" }, { "id": 4, "name": "报修" }, { "id": 3, "name": "报废" }];
  822. $scope.hw_state = {};
  823. $scope.ok = function(item) {
  824. $modalInstance.close(item.id);
  825. };
  826. $scope.cancel = function() {
  827. $modalInstance.dismiss('cancel');
  828. };
  829. },
  830. size: 'sm',
  831. resolve: {
  832. scope: function() {
  833. return $scope;
  834. }
  835. }
  836. });
  837. modalInstance.result.then(function(selectedItem) {
  838. if (selectedItem) {
  839. angular.forEach($scope.myDatagridallold, function(item, index) {
  840. if (item.id == itemin.id) {
  841. $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
  842. }
  843. })
  844. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  845. $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  846. }
  847. $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
  848. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
  849. // $scope.model.oldAssets = $scope.myDatagridallold;
  850. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
  851. $scope.options.initialValue = $scope.model.oldAssets;
  852. }
  853. })
  854. }
  855. $scope.savedata = function(data) {
  856. event.preventDefault();
  857. var modalInstance = $modal.open({
  858. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
  859. controller: function($scope, scope, $modalInstance, api_bpm_data) {
  860. $scope.title = '设备编辑';
  861. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  862. $scope.ok = function(item) {
  863. $modalInstance.close(item);
  864. };
  865. $scope.cancel = function() {
  866. $modalInstance.dismiss('cancel');
  867. };
  868. },
  869. size: 'sm',
  870. resolve: {
  871. scope: function() {
  872. return $scope;
  873. }
  874. }
  875. });
  876. modalInstance.result.then(function(selectedItem) {
  877. if (selectedItem) {
  878. angular.forEach($scope.myDatagridoldall, function(item, index) {
  879. if (item.id == data.id) {
  880. $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
  881. }
  882. })
  883. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  884. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  885. }
  886. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  887. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  888. // $scope.model.oldAssets = $scope.myDatagridoldall;
  889. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  890. $scope.options.initialValue = $scope.model.oldAssets;
  891. }
  892. })
  893. }
  894. $scope.removeold = function(data) {
  895. event.preventDefault();
  896. var modalInstance = $modal.open({
  897. templateUrl: 'assets/views/delete.html',
  898. controller: function($scope, scope, $modalInstance, api_bpm_data) {
  899. $scope.title = '设备删除';
  900. $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  901. $scope.ok = function() {
  902. $modalInstance.close(data);
  903. };
  904. $scope.cancel = function() {
  905. $modalInstance.dismiss('cancel');
  906. };
  907. },
  908. size: 'sm',
  909. resolve: {
  910. scope: function() {
  911. return $scope;
  912. }
  913. }
  914. });
  915. modalInstance.result.then(function(selectedItem) {
  916. if (selectedItem) {
  917. angular.forEach($scope.myDatagridoldall, function(item, index) {
  918. if (item.id == selectedItem.id) {
  919. $scope.myDatagridoldall.splice(index, 1);
  920. }
  921. })
  922. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  923. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  924. }
  925. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  926. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  927. // $scope.model.oldAssets = $scope.myDatagridoldall;
  928. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  929. $scope.options.initialValue = $scope.model.oldAssets;
  930. }
  931. })
  932. }
  933. }]
  934. });
  935. //ui-grid list
  936. formlyConfigProvider.setType({
  937. name: "ui-gridlist",
  938. extends: 'input',
  939. templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
  940. defaultOptions: function(options, $scope) {
  941. return {
  942. templateOptions: {}
  943. };
  944. },
  945. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function($scope, $modal, i18nService, SweetAlert) {
  946. //gridone
  947. $scope.langs = i18nService.getAllLangs();
  948. $scope.lang = 'zh-cn';
  949. i18nService.setCurrentLang($scope.lang);
  950. $scope.gridOptions = {};
  951. $scope.gridOptions.data = 'myDatagrid';
  952. $scope.gridOptions.enableColumnResizing = true;
  953. $scope.gridOptions.enableFiltering = true;
  954. $scope.gridOptions.enableGridMenu = false;
  955. $scope.gridOptions.enableRowSelection = true;
  956. $scope.gridOptions.showGridFooter = true;
  957. $scope.gridOptions.showColumnFooter = false;
  958. $scope.gridOptions.fastWatch = true;
  959. $scope.gridOptions.useExternalFiltering = false;
  960. // $scope.gridOptions.useExternalPagination = true;
  961. $scope.gridOptions.paginationPageSizes = [10];
  962. $scope.gridOptions.paginationPageSize = 10;
  963. $scope.gridOptions.multiSelect = false;
  964. $scope.myDatagrid = [];
  965. $scope.myDatagridall = [];
  966. $scope.selected = {
  967. item: {}
  968. };
  969. $scope.memoryfilterDatagrid = {
  970. idx: 0,
  971. sum: 10
  972. }
  973. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  974. filterData = {
  975. idx: 0,
  976. sum: 10
  977. };
  978. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  979. }
  980. $scope.gridOptions.rowIdentity = function(row) {
  981. return row.id;
  982. };
  983. $scope.gridOptions.getRowIdentity = function(row) {
  984. return row.id;
  985. };
  986. // $scope.gridOptions.columnDefs = items.columnDefs();
  987. $scope.interceptMydata = function(mydate, idx, sum) {
  988. return mydate.slice(idx * sum, (idx + 1) * sum)
  989. }
  990. $scope.gridOptions.onRegisterApi = function(gridApi) {
  991. $scope.gridApi = gridApi;
  992. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  993. $scope.memoryfilterDatagrid.idx = newPage - 1;
  994. $scope.memoryfilterDatagrid.sum = pageSize;
  995. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  996. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  997. });
  998. gridApi.core.on.filterChanged($scope, function() {});
  999. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  1000. $scope.selected.item = data.entity;
  1001. //console.log(data);
  1002. });
  1003. };
  1004. $scope.loadData = function(mydate, idx, sum) {
  1005. angular.forEach($scope.myDatagrid, function(item, index) {
  1006. $scope.myDatagrid[index].item = index;
  1007. })
  1008. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  1009. }
  1010. if ($scope.model.assets) {
  1011. $scope.myDatagridall = $scope.model.assets;
  1012. $scope.loadData($scope.model.assets, 0, 10)
  1013. }
  1014. $scope.saveData = function(itemin) {
  1015. event.preventDefault();
  1016. var modalInstance = $modal.open({
  1017. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  1018. controller: function($scope, $modalInstance, SweetAlert) {
  1019. // $scope.consumptive = {};
  1020. $scope.title = "填写领用设备信息";
  1021. // if (items.name) {
  1022. // $scope.consumptive.name = items.name.name;
  1023. // }
  1024. $scope.placechange = angular.copy(itemin);
  1025. $scope.ok = function(item) {
  1026. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  1027. $modalInstance.close(item);
  1028. } else {
  1029. SweetAlert.swal({
  1030. title: "数据填写不完整!",
  1031. text: "请检查数据然后提交!",
  1032. type: "error"
  1033. });
  1034. }
  1035. };
  1036. $scope.cancel = function() {
  1037. $modalInstance.dismiss('cancel');
  1038. };
  1039. },
  1040. resolve: {
  1041. SweetAlert: function() {
  1042. return SweetAlert;
  1043. }
  1044. }
  1045. });
  1046. modalInstance.result.then(function(selectedItem) {
  1047. angular.forEach($scope.myDatagrid, function(item, index) {
  1048. if (item.id == selectedItem.id) {
  1049. angular.extend($scope.myDatagrid[index], selectedItem)
  1050. }
  1051. })
  1052. // $scope.myData3.push(selectedItem);
  1053. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1054. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  1055. }
  1056. // $scope.model.assets = $scope.myDatagridall;
  1057. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  1058. })
  1059. }
  1060. }]
  1061. });
  1062. //设备耗材list组件
  1063. formlyConfigProvider.setType({
  1064. name: 'ui-shehaolist',
  1065. // extends: 'radio',
  1066. templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
  1067. defaultOptions: function(options) {
  1068. return {
  1069. templateOptions: {
  1070. refresh: function() {},
  1071. refreshDelay: 0
  1072. }
  1073. };
  1074. },
  1075. controller: ['$scope', "$filter", "ngTableParams", function($scope, $filter, ngTableParams) {
  1076. // var data = { "haodata": [], "shedata": [] };
  1077. var haodata = [];
  1078. var shedata = [];
  1079. if ($scope.model.consumables) {
  1080. if (angular.isArray($scope.model.consumables)) {
  1081. haodata = $scope.model.consumables;
  1082. } else {
  1083. haodata = JSON.parse($scope.model.consumables);
  1084. }
  1085. $scope.model.consumables = haodata;
  1086. angular.forEach(haodata, function(item, index) {
  1087. haodata[index].item = index + 1;
  1088. })
  1089. }
  1090. if ($scope.model.assets) {
  1091. if (angular.isArray($scope.model.assets)) {
  1092. shedata = $scope.model.assets;
  1093. } else {
  1094. shedata = JSON.parse($scope.model.assets);
  1095. }
  1096. $scope.model.assets = shedata;
  1097. angular.forEach(shedata, function(item, index) {
  1098. shedata[index].item = index + 1;
  1099. })
  1100. }
  1101. $scope.tableParamshao = new ngTableParams({
  1102. page: 1,
  1103. count: 5
  1104. }, {
  1105. total: haodata.length,
  1106. getData: function($defer, params) {
  1107. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  1108. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1109. }
  1110. });
  1111. $scope.tableParamsshe = new ngTableParams({
  1112. page: 1,
  1113. count: 5
  1114. }, {
  1115. total: shedata.length,
  1116. getData: function($defer, params) {
  1117. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  1118. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1119. }
  1120. });
  1121. $scope.editId = -1;
  1122. $scope.setEditId = function(pid) {
  1123. $scope.editId = pid;
  1124. };
  1125. if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
  1126. $scope.isAgree = "同意";
  1127. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
  1128. $scope.isAgree = "同意";
  1129. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
  1130. $scope.isAgree = "返回修改";
  1131. }
  1132. }]
  1133. });
  1134. //关联资产出库
  1135. formlyConfigProvider.setType({
  1136. name: "ui-meansmodelselect",
  1137. extends: 'input',
  1138. templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
  1139. defaultOptions: function(options) {
  1140. return {
  1141. templateOptions: {}
  1142. };
  1143. },
  1144. controller: ['$scope', '$modal', function($scope, $modal) {
  1145. $scope.openModal = function(size, options, modal) {
  1146. var modalInstance = $modal.open({
  1147. templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
  1148. controller: function($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService) {
  1149. $scope.langs = i18nService.getAllLangs();
  1150. $scope.lang = 'zh-cn';
  1151. i18nService.setCurrentLang($scope.lang);
  1152. $scope.gridOptions = {};
  1153. $scope.gridOptions.data = 'myData';
  1154. $scope.gridOptions.enableColumnResizing = true;
  1155. $scope.gridOptions.enableFiltering = false;
  1156. $scope.gridOptions.enableGridMenu = false;
  1157. $scope.gridOptions.showGridFooter = true;
  1158. $scope.gridOptions.showColumnFooter = false;
  1159. $scope.gridOptions.fastWatch = true;
  1160. $scope.gridOptions.useExternalFiltering = true;
  1161. $scope.gridOptions.useExternalPagination = true;
  1162. $scope.gridOptions.paginationPageSizes = [10];
  1163. $scope.gridOptions.paginationPageSize = 10;
  1164. $scope.gridOptions.multiSelect = false;
  1165. $scope.gridOptions.rowIdentity = function(row) {
  1166. return row.id;
  1167. };
  1168. $scope.gridOptions.getRowIdentity = function(row) {
  1169. return row.id;
  1170. };
  1171. $scope.states = [
  1172. { id: 0, name: '待批准' },
  1173. { id: 1, name: '已驳回' },
  1174. { id: 2, name: '待出库' },
  1175. { id: 3, name: '信息更新' },
  1176. { id: 4, name: '信息确认' },
  1177. { id: 5, name: '已关闭' }
  1178. ];
  1179. $scope.type = [
  1180. { id: 1, name: '资产入库' },
  1181. { id: 2, name: '资产归还' },
  1182. { id: 3, name: '资产领用' },
  1183. { id: 4, name: '资产更换' }
  1184. ];
  1185. $scope.typedata = function(row) {
  1186. if (row.type == 0) {
  1187. return "资产入库";
  1188. } else if (row.type == 2) {
  1189. return "资产归还";
  1190. } else if (row.type == 1) {
  1191. return "资产领用";
  1192. } else if (row.type == 4) {
  1193. return "资产更换";
  1194. }
  1195. };
  1196. $scope.statedata = function(row) {
  1197. if (row.status == 0) {
  1198. return "待批准";
  1199. } else if (row.status == 1) {
  1200. return "已驳回";
  1201. } else if (row.status == 2) {
  1202. return "待出库";
  1203. } else if (row.status == 3) {
  1204. return "信息更新";
  1205. } else if (row.status == 4) {
  1206. return "信息确认";
  1207. } else if (row.status == 5) {
  1208. return "已关闭";
  1209. }
  1210. };
  1211. $scope.application = [
  1212. { value: "serialNumbe", name: '申请单编号' },
  1213. // { value: "proposer", name: '申请人' },
  1214. { value: "purpose", name: '领用用途' },
  1215. // { value: "cmdbsign", name: '设备编号' }
  1216. ];
  1217. $scope.parameters = null;
  1218. $scope.open = function($event) {
  1219. $event.preventDefault();
  1220. $event.stopPropagation();
  1221. $scope.opened = !$scope.opened;
  1222. };
  1223. $scope.endOpen = function($event) {
  1224. $event.preventDefault();
  1225. $event.stopPropagation();
  1226. $scope.startOpened = false;
  1227. $scope.endOpened = !$scope.endOpened;
  1228. };
  1229. $scope.startOpen = function($event) {
  1230. $event.preventDefault();
  1231. $event.stopPropagation();
  1232. $scope.endOpened = false;
  1233. $scope.startOpened = !$scope.startOpened;
  1234. };
  1235. $scope.othcode = {};
  1236. $scope.searchkeys = {};
  1237. $scope.parameters = {};
  1238. $scope.memoryfilterData = {
  1239. "assignee": $rootScope.user.id,
  1240. "candidateGroups": $rootScope.user.group[0].id,
  1241. "searchType": "todo",
  1242. idx: 0,
  1243. sum: 10
  1244. }
  1245. $scope.clear = function() {
  1246. $scope.searchkeys = {};
  1247. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1248. // $scope.othcode = {};
  1249. $scope.parameters = {};
  1250. var fildata = {
  1251. "assignee": $rootScope.user.id,
  1252. "candidateGroups": $rootScope.user.group[0].id,
  1253. "searchType": "todo",
  1254. idx: 0,
  1255. sum: 10
  1256. }
  1257. // sessionStorage.removeItem("searchincident");
  1258. $scope.memoryfilterData = fildata;
  1259. $scope.loadData(fildata);
  1260. }
  1261. $scope.chiceIncident = function(parameters, item, stateid) {
  1262. var fildata = { "assignee": $rootScope.user.id, "candidateGroups": 1, "searchType": "todo", "idx": 0, "sum": 10 };
  1263. if (item) {
  1264. fildata.applicationForm = {};
  1265. if (item.alltitle && item.alldata) {
  1266. fildata.applicationForm[item.alltitle.value] = item.alldata
  1267. }
  1268. if (item.linkProposer) {
  1269. fildata.applicationForm.linkProposer = item.linkProposer
  1270. }
  1271. if (item.proposer) {
  1272. fildata.applicationForm.proposer = item.proposer
  1273. }
  1274. if (item.status) {
  1275. fildata.applicationForm['status'] = item.status.id;
  1276. }
  1277. if (item.type) {
  1278. fildata.applicationForm['type'] = item.type.id;
  1279. }
  1280. }
  1281. $scope.gridOptions.paginationCurrentPage = 1;
  1282. if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
  1283. angular.extend(fildata, { 'idx': 0, 'sum': $scope.gridOptions.paginationPageSize })
  1284. angular.extend(fildata.applicationForm, { 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'), 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59') })
  1285. }
  1286. var transitiondata = angular.copy(item);
  1287. // angular.extend(fildata.applicationForm, transitiondata)
  1288. $scope.loadData(fildata);
  1289. }
  1290. $scope.key = {};
  1291. api_user_data.fetchDataList('user', { "idx": 0, "sum": 1000, "flag": -1 }).then(function(data) {
  1292. $scope.handlingPersonnelUser = data.list;
  1293. });
  1294. $scope.gridOptions.columnDefs = items.columnDefs();
  1295. $scope.gridOptions.onRegisterApi = function(gridApi) {
  1296. $scope.gridApi = gridApi;
  1297. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  1298. // console.log(newPage);
  1299. // console.log(pageSize);
  1300. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  1301. });
  1302. gridApi.core.on.filterChanged($scope, function() {
  1303. });
  1304. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  1305. $scope.selected.item = data.entity;
  1306. //console.log(data);
  1307. });
  1308. };
  1309. $scope.loadData = function(filterData) {
  1310. items.fetchItems(filterData, APIService).then(function(data) {
  1311. var myData = Restangular.stripRestangular(data);
  1312. $scope.gridOptions.totalItems = myData.totalNum;
  1313. $scope.myData = myData.list;
  1314. for (var i = 0; i < $scope.myData.length; i++) {
  1315. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  1316. }
  1317. });
  1318. };
  1319. $scope.title = title;
  1320. $scope.loadData({
  1321. idx: 0,
  1322. sum: 10,
  1323. "assignee": $rootScope.user.id,
  1324. "candidateGroups": $rootScope.user.group[0].id,
  1325. "searchType": "todo",
  1326. });
  1327. $scope.selected = {
  1328. item: {}
  1329. };
  1330. $scope.ok = function() {
  1331. //console.log($scope.selected.item);
  1332. $modalInstance.close($scope.selected.item);
  1333. };
  1334. $scope.cancel = function() {
  1335. $modalInstance.dismiss('cancel');
  1336. };
  1337. },
  1338. size: 'lg',
  1339. resolve: {
  1340. items: function() {
  1341. return {
  1342. fetchItems: function(filterData, APIService) {
  1343. filterData = filterData || {};
  1344. // if(!filterData.idx){
  1345. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  1346. filterData = {
  1347. idx: 0,
  1348. sum: 10
  1349. };
  1350. }
  1351. return options.templateOptions.fetchItems(filterData, APIService, options);
  1352. },
  1353. columnDefs: function() {
  1354. return options.templateOptions.columnDefs;
  1355. }
  1356. };
  1357. },
  1358. title: function() {
  1359. return options.templateOptions.modalTitle;
  1360. },
  1361. Restangular: function() {
  1362. return options.templateOptions.Restangular;
  1363. },
  1364. APIService: function() {
  1365. return options.templateOptions.ApiService;
  1366. }
  1367. }
  1368. });
  1369. modalInstance.result.then(function(selectedItem) {
  1370. var selectitem = { title: selectedItem.title, description: selectedItem.description }
  1371. if (options.key == "chuku") {
  1372. if (selectedItem.assets) {
  1373. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  1374. }
  1375. if (selectedItem.consumables) {
  1376. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  1377. }
  1378. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  1379. options.value(selectedItem);
  1380. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1381. } else {
  1382. angular.extend(options.model, selectitem);
  1383. options.value(selectedItem);
  1384. }
  1385. }, function() {
  1386. //console.log('Modal dismissed at: ' + new Date());
  1387. });
  1388. }
  1389. }]
  1390. });
  1391. //文本框
  1392. formlyConfigProvider.setType({
  1393. name: 'ui-textcmdb',
  1394. extends: '',
  1395. templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
  1396. defaultOptions: function(options) {
  1397. return {
  1398. templateOptions: {
  1399. transform: function(model, value) {
  1400. return value;
  1401. },
  1402. },
  1403. validation: {
  1404. messages: {
  1405. maxlength: function(viewValue, modelValue, scope) {
  1406. if (viewValue != null) {
  1407. if (viewValue.length > scope.to.maxlength) {
  1408. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1409. } else {
  1410. return "";
  1411. }
  1412. }
  1413. },
  1414. }
  1415. }
  1416. }
  1417. },
  1418. controller: ['$scope', function($scope) {
  1419. var value = $scope.model[$scope.options.key];
  1420. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1421. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1422. }
  1423. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1424. $scope.options.templateOptions.felditem($scope);
  1425. }
  1426. }]
  1427. });
  1428. //设备组件
  1429. formlyConfigProvider.setType({
  1430. name: 'ui-applist',
  1431. extends: 'radio',
  1432. templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
  1433. defaultOptions: function(options) {
  1434. return {
  1435. templateOptions: {
  1436. refresh: function() {},
  1437. refreshDelay: 0
  1438. }
  1439. };
  1440. },
  1441. controller: ['$scope', "$filter", "ngTableParams", function($scope, $filter, ngTableParams) {
  1442. var data = [];
  1443. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1444. // data = JSON.parse($scope.model.consumables);
  1445. if (angular.isArray($scope.model.consumables)) {
  1446. data = $scope.model.consumables;
  1447. } else {
  1448. data = JSON.parse($scope.model.consumables);
  1449. }
  1450. $scope.model.consumables = data;
  1451. angular.forEach(data, function(item, index) {
  1452. data[index].item = index + 1;
  1453. })
  1454. }
  1455. if ($scope.model.assets && $scope.options.key == "assets") {
  1456. if (angular.isArray($scope.model.assets)) {
  1457. data = $scope.model.assets;
  1458. } else {
  1459. data = JSON.parse($scope.model.assets);
  1460. }
  1461. // data = JSON.parse($scope.model.assets);
  1462. $scope.model.assets = data;
  1463. angular.forEach(data, function(item, index) {
  1464. data[index].item = index + 1;
  1465. })
  1466. }
  1467. $scope.tableParams = new ngTableParams({
  1468. page: 1,
  1469. count: 5
  1470. }, {
  1471. total: data.length,
  1472. getData: function($defer, params) {
  1473. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1474. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1475. }
  1476. });
  1477. $scope.editId = -1;
  1478. $scope.setEditId = function(pid) {
  1479. $scope.editId = pid;
  1480. };
  1481. }]
  1482. });
  1483. //list组件
  1484. formlyConfigProvider.setType({
  1485. name: 'ui-gudinglist',
  1486. extends: 'radio',
  1487. templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
  1488. defaultOptions: function(options) {
  1489. return {
  1490. templateOptions: {
  1491. refresh: function() {},
  1492. refreshDelay: 0
  1493. }
  1494. };
  1495. },
  1496. controller: ['$scope', "$filter", "ngTableParams", function($scope, $filter, ngTableParams) {
  1497. var data = [];
  1498. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1499. // data = JSON.parse($scope.model.consumables);
  1500. if (angular.isArray($scope.model.consumables)) {
  1501. data = $scope.model.consumables;
  1502. } else {
  1503. data = JSON.parse($scope.model.consumables);
  1504. }
  1505. $scope.model.consumables = data;
  1506. angular.forEach(data, function(item, index) {
  1507. data[index].item = index + 1;
  1508. })
  1509. }
  1510. if ($scope.model.assets && $scope.options.key == "assets") {
  1511. if (angular.isArray($scope.model.assets)) {
  1512. data = $scope.model.assets;
  1513. } else {
  1514. data = JSON.parse($scope.model.assets);
  1515. }
  1516. // data = JSON.parse($scope.model.assets);
  1517. $scope.model.assets = data;
  1518. angular.forEach(data, function(item, index) {
  1519. data[index].item = index + 1;
  1520. })
  1521. }
  1522. $scope.tableParams = new ngTableParams({
  1523. page: 1,
  1524. count: 5
  1525. }, {
  1526. total: data.length,
  1527. getData: function($defer, params) {
  1528. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1529. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1530. }
  1531. });
  1532. $scope.editId = -1;
  1533. $scope.setEditId = function(pid) {
  1534. $scope.editId = pid;
  1535. };
  1536. }]
  1537. });
  1538. //other list tab组件
  1539. formlyConfigProvider.setType({
  1540. name: 'ui-otherlisttab',
  1541. extends: '',
  1542. templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
  1543. defaultOptions: function(options) {
  1544. return {
  1545. templateOptions: {
  1546. refresh: function() {},
  1547. refreshDelay: 0
  1548. }
  1549. };
  1550. },
  1551. controller: ['$scope', "$filter", "ngTableParams", function($scope, $filter, ngTableParams) {
  1552. }]
  1553. });
  1554. //审核查看组件
  1555. formlyConfigProvider.setType({
  1556. name: 'ui-aprovelist',
  1557. extends: '',
  1558. templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
  1559. defaultOptions: function(options) {
  1560. return {
  1561. templateOptions: {
  1562. refresh: function() {},
  1563. refreshDelay: 0
  1564. }
  1565. };
  1566. },
  1567. controller: ['$scope', "$filter", "ngTableParams", function($scope, $filter, ngTableParams) {
  1568. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  1569. $scope.isAgree = "同意";
  1570. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  1571. $scope.isAgree = "同意";
  1572. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  1573. $scope.isAgree = "返回修改";
  1574. }
  1575. }]
  1576. });
  1577. //other list组件
  1578. formlyConfigProvider.setType({
  1579. name: 'ui-otherlist',
  1580. extends: '',
  1581. templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
  1582. defaultOptions: function(options) {
  1583. return {
  1584. templateOptions: {
  1585. refresh: function() {},
  1586. refreshDelay: 0
  1587. }
  1588. };
  1589. },
  1590. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  1591. $scope.langs = i18nService.getAllLangs();
  1592. $scope.lang = 'zh-cn';
  1593. i18nService.setCurrentLang($scope.lang);
  1594. var vm = this;
  1595. vm.options = {};
  1596. vm.exampleTitle = ['expressionProperties', 'model property'];
  1597. vm.fields = [];
  1598. vm.models = {};
  1599. // vm.models["loginUser"] = $rootScope.user;
  1600. var that = $injector;
  1601. var parse = $parse;
  1602. var formKey = "";
  1603. var pdKey = "";
  1604. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1605. pdKey = $state.current.pdKey;
  1606. //console.log("pdKey::"+$state.current.pdKey);
  1607. }
  1608. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1609. formKey = $stateParams.formKey;
  1610. //console.log("formKey::"+$stateParams.formKey);
  1611. }
  1612. //用户测试数据,后续从header的auth中获取
  1613. var userId = 2;
  1614. userId = $rootScope.user.id;
  1615. //==============处理表单设计数据 开始====================
  1616. //处理组件加载后台数据选项的方法
  1617. function refreshSelectOptions(searchVal, field) {
  1618. if (field.templateOptions.optionsUrl) {
  1619. var process = BpmRestangular.all("");
  1620. if (field.templateOptions.ApiService) {
  1621. process = UserRestangular.all("");
  1622. }
  1623. process.customPOST({ "idx": 0, "sum": 1000 }, field.templateOptions.optionsUrl).then(function(result) {
  1624. if (!field.templateOptions.options) {
  1625. field.templateOptions.options = [];
  1626. }
  1627. if (field.templateOptions.optionsDataKey) {
  1628. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  1629. } else {
  1630. field.templateOptions.options = result;
  1631. }
  1632. });
  1633. }
  1634. }
  1635. function decodeVMTabForm(model, tabs) {
  1636. var result = { model: {}, tabs: [] };
  1637. var mdata = angular.fromJson(model);
  1638. angular.extend(result.model, mdata);
  1639. angular.forEach(tabs, function(tab) {
  1640. tab.form.model = vm.models;
  1641. angular.forEach(tab.form.fields, function(field) {
  1642. if (field.key == "") {
  1643. delete field.key;
  1644. }
  1645. field.type = "ui-otherlisttab";
  1646. if (angular.isDefined(field.extjson) && field.extjson != "") {
  1647. var extObj = angular.fromJson(field.extjson);
  1648. angular.extend(field.templateOptions, extObj.templateOptions);
  1649. delete extObj.templateOptions;
  1650. for (var prop in extObj) {
  1651. if (new RegExp("Expression").test(prop)) {
  1652. //var obj = $scope.$eval(extObj[prop]);
  1653. //extObj[prop] = $scope.$eval(extObj[prop]);
  1654. if (extObj[prop] != null) {
  1655. if (new RegExp("function").test(extObj[prop])) {
  1656. var propValue = eval(extObj[prop]);
  1657. extObj[prop] = propValue;
  1658. } else {
  1659. //console.log(extObj[prop]);
  1660. var obj = $scope.$eval(extObj[prop]);
  1661. extObj[prop] = obj;
  1662. //console.log(obj);
  1663. }
  1664. }
  1665. } else if (new RegExp("expressionProperties").test(prop)) {
  1666. for (var p in extObj[prop]) {
  1667. if (new RegExp("function").test(extObj[prop][p])) {
  1668. var propValue = eval(extObj[prop][p]);
  1669. extObj[prop][p] = propValue;
  1670. } else {
  1671. //if(p.indexOf("'")>=0){
  1672. // var obj = $scope.$eval(extObj[prop][p]);
  1673. // extObj[prop][$scope.$eval(p)]=obj;
  1674. //}
  1675. }
  1676. }
  1677. } else if ("watcher" == prop) {
  1678. if (angular.isArray(extObj[prop])) {
  1679. angular.forEach(extObj[prop], function(item, index) {
  1680. for (var p in item) {
  1681. if (new RegExp("function").test(item[p])) {
  1682. var propValue = eval(item[p]);
  1683. extObj[prop][index][p] = propValue;
  1684. }
  1685. }
  1686. });
  1687. } else if (angular.isObject(extObj[prop])) {
  1688. for (var p in extObj[prop]) {
  1689. if (new RegExp("function").test(extObj[prop][p])) {
  1690. var propValue = eval(extObj[prop][p]);
  1691. extObj[prop][p] = propValue;
  1692. }
  1693. }
  1694. }
  1695. }
  1696. }
  1697. angular.extend(field, extObj);
  1698. delete field.extjson;
  1699. }
  1700. if (field.extjson == "") {
  1701. delete field.extjson;
  1702. }
  1703. if (angular.isDefined(field.templateOptions)) {
  1704. var templateOs = field.templateOptions;
  1705. for (var property in templateOs) {
  1706. //console.log(property);
  1707. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  1708. if (new RegExp("function").test(templateOs[property])) {
  1709. var propValue = eval(templateOs[property]);
  1710. field.templateOptions[property] = propValue;
  1711. } else {
  1712. if (that.has(templateOs[property])) {
  1713. field.templateOptions[property] = that.get(templateOs[property]);
  1714. } else {
  1715. field.templateOptions[property] = templateOs[property];
  1716. }
  1717. }
  1718. } else if (templateOs[property] == null) {
  1719. //delete field.templateOptions[property];
  1720. } else {}
  1721. }
  1722. }
  1723. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  1724. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  1725. angular.extend(field.templateOptions, extObj);
  1726. delete field.templateOptions.extjson;
  1727. }
  1728. //...
  1729. if (field.templateOptions) {
  1730. //处理远程获取数据控件方法调用
  1731. if (field.templateOptions.optionsUrl) {
  1732. field.templateOptions.refresh = refreshSelectOptions;
  1733. }
  1734. //处理嵌套属性数据绑定/
  1735. if (field.templateOptions.pkey) {
  1736. var pmodel, i = 0;
  1737. angular.forEach(field.templateOptions.pkey.split("."), function(p) {
  1738. if (i == 0) {
  1739. if (result.model[p] == null) {
  1740. result.model[p] = {};
  1741. }
  1742. pmodel = result.model[p];
  1743. i++;
  1744. } else {
  1745. if (pmodel[p] == null) {
  1746. pmodel[p] = {};
  1747. }
  1748. pmodel = pmodel[p];
  1749. }
  1750. });
  1751. if (pmodel != null) {
  1752. field.model = pmodel;
  1753. if (pmodel[field.key] == null) {
  1754. pmodel[field.key] = null;
  1755. }
  1756. }
  1757. } else {
  1758. if (result.model[field.key] == null) {
  1759. result.model[field.key] = null;
  1760. }
  1761. }
  1762. //处理弹出框组件初始化
  1763. if (field.type == "ui-input-selectmodal") {
  1764. field.templateOptions.modal = $modal;
  1765. //field.templateOptions.Restangular = Restangular;
  1766. } else if (field.type == "ui-userselect") {
  1767. field.templateOptions.modal = $modal;
  1768. //field.templateOptions.Restangular = Restangular;
  1769. } else if (field.type == "ui-multiuserselect") {
  1770. field.templateOptions.modal = $modal;
  1771. } else if (field.type == "ui-modelselect") {
  1772. field.templateOptions.modal = $modal;
  1773. //field.templateOptions.Restangular = Restangular;
  1774. } else if (field.type == "ui-dropfile") {
  1775. field.templateOptions.fileUploader = new FileUploader({
  1776. url: '/uploader'
  1777. });
  1778. field.templateOptions.taskId = $stateParams.taskId;
  1779. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1780. field.templateOptions.userId = $rootScope.user.id;
  1781. //field.ApiService=api_bpm_domain;
  1782. } else if (field.type == "ui-dropfiletable") {
  1783. if (field.templateOptions.processInstanceId) {
  1784. } else {
  1785. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1786. }
  1787. } else if (field.type == "ui-repeatSection") {
  1788. var repeatForm = {
  1789. model: {
  1790. },
  1791. fields: field.templateOptions.fields
  1792. };
  1793. repeatForm.model[field.key] = [];
  1794. decodeVMTabForm(repeatForm);
  1795. }
  1796. }
  1797. // console.log(field);
  1798. //field
  1799. //result.fields.push(field);
  1800. })
  1801. });
  1802. vm.originalTabs = angular.copy(vm.form);
  1803. }
  1804. //======================处理表单设计数据 结束========================
  1805. $scope.ldloading = {};
  1806. function filter(obj) {
  1807. angular.forEach(obj, function(key, value) {
  1808. if (value === "" || value === null) {
  1809. delete obj[key];
  1810. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1811. filter(value);
  1812. } else if (angular.isArray(value)) {
  1813. angular.forEach(value, function(item) {
  1814. filter(item);
  1815. });
  1816. }
  1817. });
  1818. }
  1819. function invokeOnAllFormOptions(fn) {
  1820. angular.forEach(vm.tabs, function(tab) {
  1821. if (tab.form.options && tab.form.options[fn]) {
  1822. tab.form.options[fn]();
  1823. }
  1824. });
  1825. }
  1826. function encodeCIData(data, ciId) {
  1827. /*
  1828. create/update state:未审核
  1829. create createtime:系统时间
  1830. create/update lastupdatetime : 系统时间
  1831. label:ci分类
  1832. */
  1833. if (ciId) {
  1834. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  1835. var extraprop = 'props';
  1836. data[extraprop] = {};
  1837. for (var key in data) {
  1838. console.log(data[key]);
  1839. if (_.indexOf(baseprop, key) >= 0) {
  1840. continue;
  1841. } else {
  1842. data[extraprop][key] = data[key];
  1843. delete data[key];
  1844. }
  1845. }
  1846. if ($rootScope.user) {
  1847. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  1848. data[extraprop]['configperson'] = $rootScope.user.name;
  1849. var isCMAdminFlag = false;
  1850. angular.forEach($rootScope.user.role, function(roleItem) {
  1851. if (roleItem.rolecode == "cmdb charge") {
  1852. isCMAdminFlag = true;
  1853. }
  1854. })
  1855. if (!isCMAdminFlag) {
  1856. data[extraprop]['state'] = '1';
  1857. }
  1858. }
  1859. if (data.props.id) {
  1860. } else {
  1861. data.label = ciId;
  1862. }
  1863. return data;
  1864. }
  1865. return undefined;
  1866. }
  1867. function decodeCIModel(data) {
  1868. var extraprop = 'props';
  1869. if (data[extraprop]) {
  1870. for (var key in data[extraprop]) {
  1871. data[key] = data[extraprop][key];
  1872. }
  1873. delete data[extraprop];
  1874. }
  1875. data['iscmadmin'] = false;
  1876. angular.forEach($rootScope.user.role, function(roleItem) {
  1877. if (roleItem.rolecode == "cmdb charge") {
  1878. data['iscmadmin'] = true;
  1879. }
  1880. })
  1881. return data;
  1882. }
  1883. function formValid() {
  1884. angular.forEach(vm.tabs, function(item) {
  1885. //item.
  1886. })
  1887. }
  1888. $scope.vm = vm;
  1889. $scope.refreshcmdbform = function(item) {
  1890. var tempclassify = item.prefix.toLowerCase() + item.sign;
  1891. api_configure_form.renderTabForm(tempclassify).then(function(data) {
  1892. var myData = Restangular.stripRestangular(data);
  1893. $scope.propTypeOptions = myData;
  1894. $scope.templateProps = myData;
  1895. $scope.vm.tabs = myData;
  1896. if ($scope.model.assets) {
  1897. vm.models = JSON.parse($scope.model.assets);
  1898. }
  1899. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  1900. if (vm.models.vtvmvtm_kaiji) {
  1901. vm.models.vtvmvtm_kaiji = "是";
  1902. } else {
  1903. vm.models.vtvmvtm_kaiji = "否";
  1904. }
  1905. }
  1906. decodeVMTabForm(vm.models, vm.tabs);
  1907. });
  1908. // }
  1909. }
  1910. var cifilterClassic = {};
  1911. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  1912. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  1913. $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
  1914. // } else {}
  1915. }]
  1916. });
  1917. //固定资产下载
  1918. formlyConfigProvider.setType({
  1919. name: 'ui-dropupload',
  1920. templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
  1921. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  1922. defaultOptions: function(options) {
  1923. return {
  1924. templateOptions: {
  1925. view: function(APIService, contentId) {
  1926. return APIService.downloadAttachment(contentId);
  1927. },
  1928. },
  1929. };
  1930. },
  1931. controller: ['$scope', '$rootScope', 'Restangular', function($scope, $rootScope, Restangular) {
  1932. if (angular.isUndefined($scope.form.dropState)) {
  1933. $scope.form.dropState = false;
  1934. }
  1935. var to = $scope.options.templateOptions;
  1936. var bindId = $scope.model[to.bindType].processInstanceId;
  1937. //获取附件列表
  1938. $scope.listAttachmen = function() {
  1939. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function(result) {
  1940. var myData = Restangular.stripRestangular(result);
  1941. // $scope.listAttachmens = myData;
  1942. $scope.attachments = myData.data;
  1943. });
  1944. };
  1945. $scope.listAttachmen();
  1946. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  1947. // $scope.listAttachmen();
  1948. // } else if (to.bindType && $scope.model[to.bindType].id) {
  1949. // $scope.listAttachmen();
  1950. // }
  1951. //附件下载
  1952. $scope.download = function(token, filename) {
  1953. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  1954. var a = document.createElement('a');
  1955. a.href = downUrl;
  1956. a.target = '_blank';
  1957. a.download = filename;
  1958. document.body.appendChild(a);
  1959. a.click();
  1960. };
  1961. //附件预览
  1962. $scope.view = function(id, previewUrl) {
  1963. if (previewUrl) {
  1964. window.open(previewUrl);
  1965. }
  1966. };
  1967. }]
  1968. });
  1969. formlyConfigProvider.setType({
  1970. name: 'ui-form',
  1971. templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
  1972. defaultOptions: function(options) {
  1973. return {
  1974. templateOptions: {
  1975. // link: function() {}
  1976. }
  1977. };
  1978. },
  1979. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  1980. $scope.langs = i18nService.getAllLangs();
  1981. $scope.lang = 'zh-cn';
  1982. i18nService.setCurrentLang($scope.lang);
  1983. var vm = this;
  1984. vm.options = {};
  1985. vm.exampleTitle = ['expressionProperties', 'model property'];
  1986. vm.fields = [];
  1987. vm.models = {};
  1988. // vm.models["loginUser"] = $rootScope.user;
  1989. var that = $injector;
  1990. var parse = $parse;
  1991. var formKey = "";
  1992. var pdKey = "";
  1993. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1994. pdKey = $state.current.pdKey;
  1995. //console.log("pdKey::"+$state.current.pdKey);
  1996. }
  1997. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1998. formKey = $stateParams.formKey;
  1999. //console.log("formKey::"+$stateParams.formKey);
  2000. }
  2001. //用户测试数据,后续从header的auth中获取
  2002. var userId = 2;
  2003. userId = $rootScope.user.id;
  2004. //==============处理表单设计数据 开始====================
  2005. //处理组件加载后台数据选项的方法
  2006. function refreshSelectOptions(searchVal, field) {
  2007. if (field.templateOptions.optionsUrl) {
  2008. var process = BpmRestangular.all("");
  2009. if (field.templateOptions.ApiService) {
  2010. process = UserRestangular.all("");
  2011. }
  2012. process.customPOST({ "idx": 0, "sum": 1000 }, field.templateOptions.optionsUrl).then(function(result) {
  2013. if (!field.templateOptions.options) {
  2014. field.templateOptions.options = [];
  2015. }
  2016. if (field.templateOptions.optionsDataKey) {
  2017. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  2018. } else {
  2019. field.templateOptions.options = result;
  2020. }
  2021. });
  2022. }
  2023. }
  2024. function decodeVMTabForm(model, tabs) {
  2025. var result = { model: {}, tabs: [] };
  2026. var mdata = angular.fromJson(model);
  2027. angular.extend(result.model, mdata);
  2028. angular.forEach(tabs, function(tab) {
  2029. tab.form.model = vm.models;
  2030. angular.forEach(tab.form.fields, function(field) {
  2031. if (field.key == "") {
  2032. delete field.key;
  2033. }
  2034. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2035. var extObj = angular.fromJson(field.extjson);
  2036. angular.extend(field.templateOptions, extObj.templateOptions);
  2037. delete extObj.templateOptions;
  2038. for (var prop in extObj) {
  2039. if (new RegExp("Expression").test(prop)) {
  2040. //var obj = $scope.$eval(extObj[prop]);
  2041. //extObj[prop] = $scope.$eval(extObj[prop]);
  2042. if (extObj[prop] != null) {
  2043. if (new RegExp("function").test(extObj[prop])) {
  2044. var propValue = eval(extObj[prop]);
  2045. extObj[prop] = propValue;
  2046. } else {
  2047. //console.log(extObj[prop]);
  2048. var obj = $scope.$eval(extObj[prop]);
  2049. extObj[prop] = obj;
  2050. //console.log(obj);
  2051. }
  2052. }
  2053. } else if (new RegExp("expressionProperties").test(prop)) {
  2054. for (var p in extObj[prop]) {
  2055. if (new RegExp("function").test(extObj[prop][p])) {
  2056. var propValue = eval(extObj[prop][p]);
  2057. extObj[prop][p] = propValue;
  2058. } else {
  2059. //if(p.indexOf("'")>=0){
  2060. // var obj = $scope.$eval(extObj[prop][p]);
  2061. // extObj[prop][$scope.$eval(p)]=obj;
  2062. //}
  2063. }
  2064. }
  2065. } else if ("watcher" == prop) {
  2066. if (angular.isArray(extObj[prop])) {
  2067. angular.forEach(extObj[prop], function(item, index) {
  2068. for (var p in item) {
  2069. if (new RegExp("function").test(item[p])) {
  2070. var propValue = eval(item[p]);
  2071. extObj[prop][index][p] = propValue;
  2072. }
  2073. }
  2074. });
  2075. } else if (angular.isObject(extObj[prop])) {
  2076. for (var p in extObj[prop]) {
  2077. if (new RegExp("function").test(extObj[prop][p])) {
  2078. var propValue = eval(extObj[prop][p]);
  2079. extObj[prop][p] = propValue;
  2080. }
  2081. }
  2082. }
  2083. }
  2084. }
  2085. angular.extend(field, extObj);
  2086. delete field.extjson;
  2087. }
  2088. if (field.extjson == "") {
  2089. delete field.extjson;
  2090. }
  2091. if (angular.isDefined(field.templateOptions)) {
  2092. var templateOs = field.templateOptions;
  2093. for (var property in templateOs) {
  2094. //console.log(property);
  2095. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2096. if (new RegExp("function").test(templateOs[property])) {
  2097. var propValue = eval(templateOs[property]);
  2098. field.templateOptions[property] = propValue;
  2099. } else {
  2100. if (that.has(templateOs[property])) {
  2101. field.templateOptions[property] = that.get(templateOs[property]);
  2102. } else {
  2103. field.templateOptions[property] = templateOs[property];
  2104. }
  2105. }
  2106. } else if (templateOs[property] == null) {
  2107. //delete field.templateOptions[property];
  2108. } else {}
  2109. }
  2110. }
  2111. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2112. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2113. angular.extend(field.templateOptions, extObj);
  2114. delete field.templateOptions.extjson;
  2115. }
  2116. //...
  2117. if (field.templateOptions) {
  2118. //处理远程获取数据控件方法调用
  2119. if (field.templateOptions.optionsUrl) {
  2120. field.templateOptions.refresh = refreshSelectOptions;
  2121. }
  2122. //处理嵌套属性数据绑定/
  2123. if (field.templateOptions.pkey) {
  2124. var pmodel, i = 0;
  2125. angular.forEach(field.templateOptions.pkey.split("."), function(p) {
  2126. if (i == 0) {
  2127. if (result.model[p] == null) {
  2128. result.model[p] = {};
  2129. }
  2130. pmodel = result.model[p];
  2131. i++;
  2132. } else {
  2133. if (pmodel[p] == null) {
  2134. pmodel[p] = {};
  2135. }
  2136. pmodel = pmodel[p];
  2137. }
  2138. });
  2139. if (pmodel != null) {
  2140. field.model = pmodel;
  2141. if (pmodel[field.key] == null) {
  2142. pmodel[field.key] = null;
  2143. }
  2144. }
  2145. } else {
  2146. if (result.model[field.key] == null) {
  2147. result.model[field.key] = null;
  2148. }
  2149. }
  2150. //处理弹出框组件初始化
  2151. if (field.type == "ui-input-selectmodal") {
  2152. field.templateOptions.modal = $modal;
  2153. //field.templateOptions.Restangular = Restangular;
  2154. } else if (field.type == "ui-userselect") {
  2155. field.templateOptions.modal = $modal;
  2156. //field.templateOptions.Restangular = Restangular;
  2157. } else if (field.type == "ui-multiuserselect") {
  2158. field.templateOptions.modal = $modal;
  2159. } else if (field.type == "ui-modelselect") {
  2160. field.templateOptions.modal = $modal;
  2161. //field.templateOptions.Restangular = Restangular;
  2162. } else if (field.type == "ui-dropfile") {
  2163. field.templateOptions.fileUploader = new FileUploader({
  2164. url: '/uploader'
  2165. });
  2166. field.templateOptions.taskId = $stateParams.taskId;
  2167. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2168. field.templateOptions.userId = $rootScope.user.id;
  2169. //field.ApiService=api_bpm_domain;
  2170. } else if (field.type == "ui-dropfiletable") {
  2171. if (field.templateOptions.processInstanceId) {
  2172. } else {
  2173. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2174. }
  2175. } else if (field.type == "ui-repeatSection") {
  2176. var repeatForm = {
  2177. model: {
  2178. },
  2179. fields: field.templateOptions.fields
  2180. };
  2181. repeatForm.model[field.key] = [];
  2182. decodeVMTabForm(repeatForm);
  2183. }
  2184. }
  2185. // console.log(field);
  2186. //field
  2187. //result.fields.push(field);
  2188. })
  2189. });
  2190. vm.originalTabs = angular.copy(vm.form);
  2191. }
  2192. //解析自定义表单设计数据
  2193. function decodeVMForm(vmForm) {
  2194. var result = { model: {}, tabs: [] };
  2195. //设置模型实体数据 begin
  2196. // var mdata = vmForm.model;
  2197. //解析数据实体
  2198. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2199. angular.extend(result.model, mdata);
  2200. //设置模型实体数据 end
  2201. //解析设计数据生成表单项 begin
  2202. var fields = [];
  2203. //处理修改设计数据中展示设置
  2204. angular.forEach(vmForm.tabs, function(field) {
  2205. if (field.key == "") {
  2206. delete field.key;
  2207. }
  2208. if (angular.isDefined(field.extjson)) {
  2209. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2210. angular.extend(field.templateOptions, extObj.templateOptions);
  2211. delete extObj.templateOptions;
  2212. for (var prop in extObj) {
  2213. if (new RegExp("Expression").test(prop)) {
  2214. //var obj = $scope.$eval(extObj[prop]);
  2215. //extObj[prop] = $scope.$eval(extObj[prop]);
  2216. if (extObj[prop] != null) {
  2217. if (new RegExp("function").test(extObj[prop])) {
  2218. var propValue = eval(extObj[prop]);
  2219. extObj[prop] = propValue;
  2220. } else {
  2221. //console.log(extObj[prop]);
  2222. var obj = $scope.$eval(extObj[prop]);
  2223. extObj[prop] = obj;
  2224. //console.log(obj);
  2225. }
  2226. }
  2227. } else if (new RegExp("expressionProperties").test(prop)) {
  2228. for (var p in extObj[prop]) {
  2229. if (new RegExp("function").test(extObj[prop][p])) {
  2230. var propValue = eval(extObj[prop][p]);
  2231. extObj[prop][p] = propValue;
  2232. } else {
  2233. //if(p.indexOf("'")>=0){
  2234. // var obj = $scope.$eval(extObj[prop][p]);
  2235. // extObj[prop][$scope.$eval(p)]=obj;
  2236. //}
  2237. }
  2238. }
  2239. } else if ("watcher" == prop) {
  2240. if (angular.isArray(extObj[prop])) {
  2241. angular.forEach(extObj[prop], function(item, index) {
  2242. for (var p in item) {
  2243. if (new RegExp("function").test(item[p])) {
  2244. var propValue = eval(item[p]);
  2245. extObj[prop][index][p] = propValue;
  2246. }
  2247. }
  2248. });
  2249. } else if (angular.isObject(extObj[prop])) {
  2250. for (var p in extObj[prop]) {
  2251. if (new RegExp("function").test(extObj[prop][p])) {
  2252. var propValue = eval(extObj[prop][p]);
  2253. extObj[prop][p] = propValue;
  2254. }
  2255. }
  2256. }
  2257. }
  2258. }
  2259. angular.extend(field, extObj);
  2260. delete field.extjson;
  2261. }
  2262. if (angular.isDefined(field.templateOptions)) {
  2263. var templateOs = field.templateOptions;
  2264. for (var property in templateOs) {
  2265. //console.log(property);
  2266. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2267. if (new RegExp("function").test(templateOs[property])) {
  2268. var propValue = eval(templateOs[property]);
  2269. field.templateOptions[property] = propValue;
  2270. } else {
  2271. if (that.has(templateOs[property])) {
  2272. field.templateOptions[property] = that.get(templateOs[property]);
  2273. } else {
  2274. field.templateOptions[property] = templateOs[property];
  2275. }
  2276. }
  2277. } else if (templateOs[property] == null) {
  2278. //delete field.templateOptions[property];
  2279. } else {}
  2280. }
  2281. }
  2282. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2283. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2284. angular.extend(field.templateOptions, extObj);
  2285. delete field.templateOptions.extjson;
  2286. }
  2287. //...
  2288. if (field.templateOptions) {
  2289. //处理远程获取数据控件方法调用
  2290. if (field.templateOptions.optionsUrl) {
  2291. field.templateOptions.refresh = refreshSelectOptions;
  2292. }
  2293. //处理嵌套属性数据绑定/
  2294. if (field.templateOptions.pkey) {
  2295. var pmodel, i = 0;
  2296. angular.forEach(field.templateOptions.pkey.split("."), function(p) {
  2297. if (i == 0) {
  2298. if (result.model[p] == null) {
  2299. result.model[p] = {};
  2300. }
  2301. pmodel = result.model[p];
  2302. i++;
  2303. } else {
  2304. if (pmodel[p] == null) {
  2305. pmodel[p] = {};
  2306. }
  2307. pmodel = pmodel[p];
  2308. }
  2309. });
  2310. if (pmodel != null) {
  2311. field.model = pmodel;
  2312. if (pmodel[field.key] == null) {
  2313. pmodel[field.key] = null;
  2314. }
  2315. }
  2316. } else {
  2317. if (result.model[field.key] == null) {
  2318. result.model[field.key] = null;
  2319. }
  2320. }
  2321. //处理弹出框组件初始化
  2322. if (field.type == "ui-input-selectmodal") {
  2323. field.templateOptions.modal = $modal;
  2324. //field.templateOptions.Restangular = Restangular;
  2325. } else if (field.type == "ui-userselect") {
  2326. field.templateOptions.modal = $modal;
  2327. //field.templateOptions.Restangular = Restangular;
  2328. } else if (field.type == "ui-multiuserselect") {
  2329. field.templateOptions.modal = $modal;
  2330. } else if (field.type == "ui-modelselect") {
  2331. field.templateOptions.modal = $modal;
  2332. //field.templateOptions.Restangular = Restangular;
  2333. } else if (field.type == "ui-dropfile") {
  2334. field.templateOptions.fileUploader = new FileUploader({
  2335. url: '/uploader'
  2336. });
  2337. field.templateOptions.taskId = $stateParams.taskId;
  2338. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2339. field.templateOptions.userId = $rootScope.user.id;
  2340. //field.ApiService=api_bpm_domain;
  2341. } else if (field.type == "ui-dropfiletable") {
  2342. if (field.templateOptions.processInstanceId) {
  2343. } else {
  2344. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2345. }
  2346. } else if (field.type == "ui-repeatSection") {
  2347. var repeatForm = {
  2348. model: {
  2349. },
  2350. fields: field.templateOptions.fields
  2351. };
  2352. repeatForm.model[field.key] = [];
  2353. decodeVMForm(repeatForm);
  2354. }
  2355. }
  2356. // console.log(field);
  2357. result.fields.push(field);
  2358. });
  2359. angular.extend($scope.vm.fields, result.fields);
  2360. angular.extend($scope.vm.models, result.model);
  2361. $scope.formData = vmForm;
  2362. //console.log($scope.vm);
  2363. //解析设计数据生成表单项 end
  2364. return result;
  2365. }
  2366. //======================处理表单设计数据 结束========================
  2367. $scope.ldloading = {};
  2368. function filter(obj) {
  2369. angular.forEach(obj, function(key, value) {
  2370. if (value === "" || value === null) {
  2371. delete obj[key];
  2372. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  2373. filter(value);
  2374. } else if (angular.isArray(value)) {
  2375. angular.forEach(value, function(item) {
  2376. filter(item);
  2377. });
  2378. }
  2379. });
  2380. }
  2381. function invokeOnAllFormOptions(fn) {
  2382. angular.forEach(vm.tabs, function(tab) {
  2383. if (tab.form.options && tab.form.options[fn]) {
  2384. tab.form.options[fn]();
  2385. }
  2386. });
  2387. }
  2388. function encodeCIData(data, ciId) {
  2389. /*
  2390. create/update state:未审核
  2391. create createtime:系统时间
  2392. create/update lastupdatetime : 系统时间
  2393. label:ci分类
  2394. */
  2395. if (ciId) {
  2396. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2397. var extraprop = 'props';
  2398. data[extraprop] = {};
  2399. for (var key in data) {
  2400. console.log(data[key]);
  2401. if (_.indexOf(baseprop, key) >= 0) {
  2402. continue;
  2403. } else {
  2404. data[extraprop][key] = data[key];
  2405. delete data[key];
  2406. }
  2407. }
  2408. if ($rootScope.user) {
  2409. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2410. data[extraprop]['configperson'] = $rootScope.user.name;
  2411. var isCMAdminFlag = false;
  2412. angular.forEach($rootScope.user.role, function(roleItem) {
  2413. if (roleItem.rolecode == "cmdb charge") {
  2414. isCMAdminFlag = true;
  2415. }
  2416. })
  2417. if (!isCMAdminFlag) {
  2418. data[extraprop]['state'] = '1';
  2419. }
  2420. }
  2421. if (data.props.id) {
  2422. } else {
  2423. data.label = ciId;
  2424. }
  2425. return data;
  2426. }
  2427. return undefined;
  2428. }
  2429. function decodeCIModel(data) {
  2430. var extraprop = 'props';
  2431. if (data[extraprop]) {
  2432. for (var key in data[extraprop]) {
  2433. data[key] = data[extraprop][key];
  2434. }
  2435. delete data[extraprop];
  2436. }
  2437. data['iscmadmin'] = false;
  2438. angular.forEach($rootScope.user.role, function(roleItem) {
  2439. if (roleItem.rolecode == "cmdb charge") {
  2440. data['iscmadmin'] = true;
  2441. }
  2442. })
  2443. return data;
  2444. }
  2445. vm.remove = function(data, style) {
  2446. $scope.ldloading[style.replace('-', '_')] = true;
  2447. var modalInstance = $modal.open({
  2448. templateUrl: 'assets/views/delete.html',
  2449. controller: function($scope, scope, $modalInstance, api_bpm_data) {
  2450. var cidata = {
  2451. label: data.label,
  2452. id: data.id,
  2453. uuid: data.uuid,
  2454. name: data.name,
  2455. props: {}
  2456. };
  2457. if (cidata.id) {
  2458. cidata.props['removeflag'] = true;
  2459. cidata.props['lastupdateperson'] = vm.models.loginUser;
  2460. $scope.ok = function() {
  2461. $modalInstance.close(cidata);
  2462. };
  2463. $scope.cancel = function() {
  2464. $modalInstance.dismiss('cancel');
  2465. };
  2466. }
  2467. },
  2468. size: 'sm',
  2469. resolve: {
  2470. scope: function() {
  2471. return $scope;
  2472. }
  2473. }
  2474. });
  2475. modalInstance.result.then(function(selectedItem) {
  2476. if (selectedItem) {
  2477. // if (selectedItem.length > 0) {
  2478. api_cmdb.put(selectedItem, selectedItem.id).then(function(response) {
  2479. if (response) {
  2480. var resData = Restangular.stripRestangular(response);
  2481. SweetAlert.swal({
  2482. title: "删除成功!",
  2483. confirmButtonColor: "#007AFF"
  2484. }, function() {
  2485. $state.go("app.means.list");
  2486. // $scope.refreshform();
  2487. // reinitTabForm($scope.classify);
  2488. });
  2489. } else {
  2490. SweetAlert.swal({
  2491. title: "系统错误",
  2492. text: "系统错误,请稍后重试!",
  2493. type: "error",
  2494. confirmButtonColor: "#DD6B55"
  2495. });
  2496. }
  2497. $scope.ldloading[style.replace('-', '_')] = false;
  2498. });
  2499. }
  2500. })
  2501. }
  2502. function formValid() {
  2503. angular.forEach(vm.tabs, function(item) {
  2504. //item.
  2505. })
  2506. }
  2507. $scope.closeModel = function() {
  2508. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2509. if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
  2510. $state.go('app.means.list', {});
  2511. }
  2512. event.preventDefault();
  2513. }
  2514. }
  2515. // setInterval(function() {
  2516. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  2517. // cifilter_classic = $scope.model.cifilter_classic;
  2518. // $scope.refreshcmdbform(cifilter_classic);
  2519. // } else {}
  2520. // }, 100);
  2521. vm.models = (function filter(obj) {
  2522. var filtered = _.pick(obj, function(v) { return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true); });
  2523. return _.cloneDeep(filtered, function(v) { return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined; });
  2524. })(vm.models);
  2525. // setInterval(function() {
  2526. // if ($scope.model.type == 0) {
  2527. // $scope.model[$scope.options.key] = vm.models;
  2528. // }
  2529. // }, 100);
  2530. setInterval(function() {
  2531. if (vm.form && vm.form.$$parentForm.$valid) {
  2532. if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
  2533. vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2534. $scope.model[$scope.options.key] = vm.models;
  2535. }
  2536. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2537. // $scope.model[$scope.options.key] = vm.models;
  2538. }
  2539. }, 100);
  2540. vm.submit = function(data, ciId, templateitem, style) {
  2541. // $scope.ldloading[style.replace('-', '_')] = true;
  2542. console.log(vm.form.$$parentForm.$valid);
  2543. if (vm.form.$$parentForm.$valid) {
  2544. invokeOnAllFormOptions('updateInitialValue');
  2545. //alert(JSON.stringify(vm.model), null, 2);
  2546. //vm.options.updateInitialValue();
  2547. //console.log(vm.model);
  2548. var cidata = encodeCIData(vm.models, ciId);
  2549. if (cidata) {
  2550. //var cidata = ;
  2551. if (cidata.props.id) {
  2552. //修改
  2553. api_cmdb.put(cidata, ciId).then(function(response) {
  2554. if (response) {
  2555. var resData = Restangular.stripRestangular(response);
  2556. SweetAlert.swal({
  2557. title: "保存成功!",
  2558. confirmButtonColor: "#007AFF"
  2559. }, function() {
  2560. $scope.ldloading[style.replace('-', '_')] = false;
  2561. // $scope.refreshform();
  2562. $state.go("app.means.list");
  2563. });
  2564. } else {
  2565. SweetAlert.swal({
  2566. title: "系统错误",
  2567. text: "系统错误,请稍后重试!",
  2568. type: "error",
  2569. confirmButtonColor: "#DD6B55"
  2570. });
  2571. }
  2572. $scope.ldloading[style.replace('-', '_')] = false;
  2573. });
  2574. } else {
  2575. //新建
  2576. var type = 2;
  2577. api_sysinfo.getSerialnumber(type, templateitem.id).then(function(data) {
  2578. if (data && data.status == 200) {
  2579. cidata.uuid = data.uuid;
  2580. api_cmdb.create(cidata).then(function(response) {
  2581. if (response) {
  2582. var resData = Restangular.stripRestangular(response);
  2583. SweetAlert.swal({
  2584. title: "保存成功!",
  2585. text: "内部编号:" + cidata.uuid,
  2586. confirmButtonColor: "#007AFF"
  2587. }, function() {
  2588. $state.go("app.means.list");
  2589. });
  2590. // if(resData.status){
  2591. // resData
  2592. // }
  2593. } else {
  2594. SweetAlert.swal({
  2595. title: "系统错误",
  2596. text: "系统错误,请稍后重试!",
  2597. type: "error",
  2598. confirmButtonColor: "#DD6B55"
  2599. });
  2600. }
  2601. $scope.ldloading[style.replace('-', '_')] = false;
  2602. });
  2603. } else {
  2604. SweetAlert.swal({
  2605. title: "系统错误",
  2606. text: "内部编号生成出错!",
  2607. type: "error",
  2608. confirmButtonColor: "#DD6B55"
  2609. });
  2610. }
  2611. })
  2612. }
  2613. } else {
  2614. SweetAlert.swal({
  2615. title: "错误",
  2616. text: "错误,请选择资产分类!",
  2617. type: "error",
  2618. confirmButtonColor: "#DD6B55"
  2619. });
  2620. }
  2621. //alert(JSON.stringify(cidata), null, 2);
  2622. $scope.ldloading[style.replace('-', '_')] = true;
  2623. return;
  2624. var _ = window._;
  2625. vm.models = (function filter(obj) {
  2626. var filtered = _.pick(obj, function(v) { return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true); });
  2627. return _.cloneDeep(filtered, function(v) { return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined; });
  2628. })(vm.models);
  2629. } else {
  2630. if (vm.form.$$parentForm.$error) {
  2631. SweetAlert.swal({
  2632. title: "校验错误",
  2633. text: "请填写必填项!",
  2634. type: "error",
  2635. confirmButtonColor: "#DD6B55"
  2636. });
  2637. angular.forEach(vm.form.$$parentForm.$error.required, function(item) {
  2638. angular.forEach(vm.tabs, function(tab) {
  2639. angular.forEach(tab.form.fields, function(f) {
  2640. if (f.name == item.$name) {
  2641. f.validation.show = true;
  2642. tab.active = true;
  2643. }
  2644. })
  2645. })
  2646. });
  2647. $scope.ldloading[style.replace('-', '_')] = false;
  2648. }
  2649. }
  2650. };
  2651. $scope.vm = vm;
  2652. $scope.refreshcmdbform = function(item) {
  2653. // if ($stateParams.model) {
  2654. // var modeldata = JSON.parse($stateParams.model)
  2655. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2656. api_configure_form.renderTabForm(tempclassify).then(function(data) {
  2657. var myData = Restangular.stripRestangular(data);
  2658. $scope.propTypeOptions = myData;
  2659. $scope.templateProps = myData;
  2660. $scope.vm.tabs = myData;
  2661. if ($scope.model.asset && $scope.model.asset.length != "") {
  2662. vm.models = JSON.parse($scope.model.asset);
  2663. }
  2664. decodeVMTabForm(vm.models, vm.tabs);
  2665. });
  2666. // }
  2667. }
  2668. var cifilterClassic = {};
  2669. setInterval(function() {
  2670. if ($scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2671. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  2672. cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2673. $scope.refreshcmdbform(cifilterClassic);
  2674. } else {}
  2675. }, 100);
  2676. }]
  2677. });
  2678. //请求人信息
  2679. formlyConfigProvider.setType({
  2680. name: 'ui-cmdbinformation',
  2681. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
  2682. wrapper: ['bootstrapHasError'],
  2683. defaultOptions: function(options, $scope) {
  2684. return {
  2685. templateOptions: {
  2686. // checkform: function(options) {
  2687. // if (options.model.requester) {
  2688. // options.value(options.model.requester);
  2689. // }
  2690. // },
  2691. }
  2692. };
  2693. },
  2694. controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
  2695. if ($scope.options.templateOptions.loginUser) {
  2696. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
  2697. } else {
  2698. $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
  2699. }
  2700. $scope.options.initialValue = $scope.model[$scope.options.key];
  2701. }
  2702. }]
  2703. });
  2704. //资产属性
  2705. formlyConfigProvider.setType({
  2706. name: 'ui-cmdbtype',
  2707. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
  2708. wrapper: ['bootstrapHasError'],
  2709. defaultOptions: function(options, $scope) {
  2710. return {
  2711. templateOptions: {
  2712. // checkform: function(options) {
  2713. // if (options.model.requester) {
  2714. // options.value(options.model.requester);
  2715. // }
  2716. // },
  2717. }
  2718. };
  2719. },
  2720. controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
  2721. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2722. $scope.property = {
  2723. 'hw_change': $scope.to.loginUser,
  2724. 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
  2725. 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
  2726. }
  2727. if ($scope.$parent.$parent.$parent.model.assets) {
  2728. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  2729. }
  2730. }]
  2731. });
  2732. //申请单信息
  2733. formlyConfigProvider.setType({
  2734. name: 'ui-cmdbformimform',
  2735. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
  2736. wrapper: ['bootstrapHasError'],
  2737. defaultOptions: function(options, $scope) {
  2738. return {
  2739. templateOptions: {
  2740. // checkform: function(options) {
  2741. // if (options.model.requester) {
  2742. // options.value(options.model.requester);
  2743. // }
  2744. // },
  2745. }
  2746. };
  2747. },
  2748. controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
  2749. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2750. $scope.getininform = {
  2751. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2752. time: $scope.$parent.$parent.$parent.model.applicationForm.time
  2753. };
  2754. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  2755. $scope.getininform.types = "新资产入库";
  2756. } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
  2757. $scope.getininform.types = "资产归还";
  2758. }
  2759. }]
  2760. });
  2761. //出库单信息
  2762. formlyConfigProvider.setType({
  2763. name: 'ui-outinformation',
  2764. templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
  2765. wrapper: ['bootstrapHasError'],
  2766. defaultOptions: function(options, $scope) {
  2767. return {
  2768. templateOptions: {
  2769. // checkform: function(options) {
  2770. // if (options.model.requester) {
  2771. // options.value(options.model.requester);
  2772. // }
  2773. // },
  2774. }
  2775. };
  2776. },
  2777. controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
  2778. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2779. $scope.getininform = {
  2780. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2781. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  2782. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  2783. sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  2784. describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
  2785. };
  2786. if ($scope.$parent.$parent.$parent.model.type.id == 1) {
  2787. $scope.getininform.types = "新设备领用出库";
  2788. } else if ($scope.$parent.$parent.$parent.model.type.id == 4) {
  2789. $scope.getininform.types = "设备更换";
  2790. }
  2791. $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.id;
  2792. if ($scope.$parent.$parent.$parent.model.source.id == 1) {
  2793. $scope.getininform.source = "事件";
  2794. } else if ($scope.$parent.$parent.$parent.model.source.id == 2) {
  2795. $scope.getininform.source = "变更";
  2796. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  2797. } else if ($scope.$parent.$parent.$parent.model.source.id == 3) {
  2798. $scope.getininform.source = "其它";
  2799. }
  2800. }]
  2801. });
  2802. //资产附件上传
  2803. formlyConfigProvider.setType({
  2804. name: 'ui-cmdbuplode',
  2805. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
  2806. wrapper: ['bootstrapHasError'],
  2807. defaultOptions: function(options, $scope) {
  2808. return {
  2809. templateOptions: {
  2810. // checkform: function(options) {
  2811. // if (options.model.requester) {
  2812. // options.value(options.model.requester);
  2813. // }
  2814. // },
  2815. }
  2816. };
  2817. },
  2818. controller: ['$scope', '$rootScope', '$http', 'SweetAlert', 'FileUploader', 'api_user_data', 'i18nService', '$modal', 'Restangular', 'api_configure_data', 'api_cmdb', 'api_cmdb_new', 'api_wechatfile', function($scope, $rootScope, $http, SweetAlert, FileUploader, api_user_data, i18nService, $modal, Restangular, api_configure_data, api_cmdb, api_cmdb_new, api_wechatfile) {
  2819. $scope.state = 1;
  2820. $scope.myData3all = [];
  2821. $scope.myData3 = [];
  2822. $scope.memoryfilterDatahao = {
  2823. "idx": 0,
  2824. "sum": 10,
  2825. }
  2826. $scope.selected = {
  2827. items: []
  2828. };
  2829. $scope.interceptMydata = function(mydate, idx, sum) {
  2830. return mydate.slice(idx * sum, (idx + 1) * sum)
  2831. }
  2832. // $scope.importnext = function() {
  2833. // $scope.state = 2;
  2834. // event.preventDefault();
  2835. // }
  2836. $scope.workspaces = [];
  2837. $scope.options.templateOptions.getpush = function(item) {
  2838. $scope.workspaces = [];
  2839. if (item.gu) {
  2840. $scope.workspaces.push({ id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' })
  2841. }
  2842. if (item.hao) {
  2843. $scope.workspaces.push({ id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' })
  2844. }
  2845. };
  2846. //获取附件列表
  2847. $scope.listAttachmen = function() {
  2848. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function(result) {
  2849. var myData = Restangular.stripRestangular(result);
  2850. // $scope.listAttachmens = myData;
  2851. $scope.attachments = myData.data;
  2852. });
  2853. };
  2854. //附件列表
  2855. if ($scope.options.templateOptions.bindType) {
  2856. if (angular.isUndefined($scope.form.dropState)) {
  2857. $scope.form.dropState = false;
  2858. }
  2859. var to = $scope.options.templateOptions;
  2860. var bindId = $scope.model[to.bindType].processInstanceId;
  2861. $scope.listAttachmen();
  2862. }
  2863. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2864. // $scope.listAttachmen();
  2865. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2866. // $scope.listAttachmen();
  2867. // }
  2868. //附件下载
  2869. $scope.download = function(token, filename) {
  2870. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  2871. // window.open(downUrl);
  2872. var a = document.createElement('a');
  2873. a.href = downUrl;
  2874. a.target = '_blank';
  2875. a.download = filename;
  2876. document.body.appendChild(a);
  2877. a.click();
  2878. };
  2879. //附件预览
  2880. $scope.view = function(id, previewUrl) {
  2881. if (previewUrl) {
  2882. window.open(previewUrl);
  2883. }
  2884. };
  2885. //下载资产模版
  2886. $scope.filenum = 0;
  2887. $scope.openmeans = function() {
  2888. var modalInstance = $modal.open({
  2889. templateUrl: 'assets/views/means/tpl/meansdown.html',
  2890. controller: function($scope, scope, $modalInstance) {
  2891. $scope.item = {};
  2892. $scope.title = "选择下载模版";
  2893. $scope.lable = "资产模版下载";
  2894. function foreachdata(my_datas) {
  2895. // angular.forEach(my_datas, function(item, index) {
  2896. // if (item.children && item.children.length > 0) {
  2897. // foreachdata(item.children);
  2898. // } else {
  2899. // my_datas[index].checks = true;
  2900. // }
  2901. // })
  2902. for (var i = 0; i < my_datas.length; i++) {
  2903. if (my_datas[i].children && my_datas[i].children.length > 0) {
  2904. foreachdata(my_datas[i].children);
  2905. console.log($scope);
  2906. } else {
  2907. my_datas[i].checks = true;
  2908. }
  2909. }
  2910. }
  2911. function foreachtree(data) {
  2912. angular.forEach(data, function(item) {
  2913. // if (item.checks != true) {
  2914. item.checks = true;
  2915. item.expanded = true;
  2916. if (item.children && item.children.length > 0) {
  2917. foreachtree(item.children)
  2918. } else {
  2919. $scope.getslowtree.push(item)
  2920. }
  2921. // }
  2922. })
  2923. }
  2924. $scope.getslowtree = [];
  2925. $scope.slowtree = function(tree) {
  2926. foreachtree(tree)
  2927. return $scope.getslowtree
  2928. }
  2929. $scope.all = function(c, v) { //全选
  2930. if (c == true) {
  2931. $scope.formdashboard($scope.slowtree(v));
  2932. } else {
  2933. $scope.my_data_after = [];
  2934. angular.forEach($scope.my_data, function(item, index) {
  2935. $scope.my_data[index].checks = false;
  2936. $scope.my_data[index].expanded = false;
  2937. if (item.children && item.children.length > 0) {
  2938. angular.forEach(item.children, function(itemone, indexone) {
  2939. $scope.my_data[index].children[indexone].checks = false;
  2940. $scope.my_data[index].children[indexone].expanded = false;
  2941. if (itemone.children && itemone.children.length > 0) {
  2942. angular.forEach(itemone.children, function(itemtwo, indextwo) {
  2943. $scope.my_data[index].children[indexone].children[indextwo].checks = false;
  2944. })
  2945. } else {}
  2946. })
  2947. } else {}
  2948. })
  2949. $scope.mydatacate = [];
  2950. $scope.getslowtree = [];
  2951. // }
  2952. }
  2953. };
  2954. // $scope.searchone = function(search) {
  2955. // angular.forEach($scope.my_data, function(item) {
  2956. // if (item.indexOf(search) > 0) {
  2957. // }
  2958. // })
  2959. // }
  2960. $scope.checkall = function() {
  2961. angular.forEach($scope.my_data, function(item, index) {
  2962. scope.my_data[index].checks = true;
  2963. })
  2964. }
  2965. $scope.selectitem = [];
  2966. $scope.choiceitem = function(item) {
  2967. // if (item.checkeds) {
  2968. // item.checkeds = false;
  2969. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  2970. // // if ($scope.selectitem[i].id == item.id) {
  2971. // // $scope.selectitem.splice(i, 1)
  2972. // // }
  2973. // // }
  2974. // for (var i = 0; i < $scope.my_data_after; i++) {
  2975. // if ($scope.my_data_after[i].id == item.id) {
  2976. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  2977. // // $scope.selectitem.splice(i, 1)
  2978. // }
  2979. // }
  2980. // } else {
  2981. // item.checkeds = true;
  2982. // $scope.selectitem.push(item)
  2983. // }
  2984. for (var i = 0; i < $scope.my_data_after.length; i++) {
  2985. if ($scope.my_data_after[i].id == item.id) {
  2986. $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  2987. }
  2988. }
  2989. }
  2990. $scope.remove = function(removeitem) {
  2991. var realdat = angular.copy($scope.my_data_after)
  2992. // angular.extend(realdat, $scope.selectitem);
  2993. $scope.my_data_after = [];
  2994. angular.forEach(realdat, function(item) {
  2995. if (!item.checkeds) {
  2996. $scope.my_data_after.push(item)
  2997. }
  2998. })
  2999. $scope.mydatacate = angular.copy($scope.my_data_after);
  3000. }
  3001. $scope.try_async_loads = function(item, search) {
  3002. var fildatas = { 'idx': 0, 'sum': 1000 };
  3003. $scope.my_data = [];
  3004. // $scope.try_async_load = true;
  3005. if (item) {
  3006. angular.extend(fildatas, item)
  3007. }
  3008. api_configure_data.fetchDataList('ciclassify', fildatas).then(function(response) {
  3009. if (response.status == 200) {
  3010. var data = response.list;
  3011. var objects = [];
  3012. for (var i = 0; i < data.length; i++) {
  3013. var object = {};
  3014. object.id = data[i].id;
  3015. if (search) {
  3016. delete data[i].parent
  3017. } else {
  3018. if (data[i].parent && data[i].parent.id != 0) {
  3019. object.parent = data[i].parent.id;
  3020. }
  3021. }
  3022. angular.extend(object, data[i]);
  3023. objects.push(object);
  3024. }
  3025. $scope.my_data = convertParentToChildList(objects);
  3026. $scope.tree_data = angular.copy($scope.my_data);
  3027. if ($scope.my_data.length > 0) {
  3028. $scope.try_async_load = false;
  3029. }
  3030. } else {
  3031. SweetAlert.swal({
  3032. title: "系统错误!",
  3033. text: "请刷新重试!",
  3034. type: "error"
  3035. });
  3036. }
  3037. });
  3038. };
  3039. function convertListToTree(data, treeMap) {
  3040. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3041. var root = null; //Initially set our loop to null
  3042. //loop over data
  3043. for (var i = 0; i < data.length; i++) {
  3044. var datum = data[i];
  3045. //each node will have children, so let's give it a "children" poperty
  3046. datum.children = [];
  3047. //add an entry for this node to the map so that any future children can
  3048. //lookup the parent
  3049. idToNodeMap[datum.id] = datum;
  3050. //Does this node have a parent?
  3051. // console.log("datum="+JSON.stringify(datum))
  3052. if (typeof datum.parent === "undefined" || datum.parent === null) {
  3053. //Doesn't look like it, so this node is the root of the tree
  3054. root = datum;
  3055. treeMap[datum.id] = root;
  3056. } else {
  3057. //This node has a parent, so let's look it up using the id
  3058. parentNode = idToNodeMap[datum.parent.id];
  3059. //We don't need this property, so let's delete it.
  3060. // delete datum.parent;
  3061. //Let's add the current node as a child of the parent node.
  3062. parentNode.children.push(datum);
  3063. }
  3064. }
  3065. return root;
  3066. }
  3067. function convertParentToChildList(data) {
  3068. var treeMap = {};
  3069. var list = [];
  3070. convertListToTree(data, treeMap);
  3071. angular.forEach(treeMap, function(item) {
  3072. list.push(item);
  3073. });
  3074. return list;
  3075. }
  3076. function convertParentToChild(datato) {
  3077. var treeMapto = {};
  3078. var listto = [];
  3079. convertListToTree(datato, treeMapto);
  3080. angular.forEach(treeMapto, function(items) {
  3081. listto.push(items);
  3082. });
  3083. return listto;
  3084. }
  3085. $scope.try_async_loads();
  3086. $scope.searchdown = function(key) {
  3087. if (key && key != '') {
  3088. $scope.try_async_loads({ 'ciclassify': { "label": key } }, 'search')
  3089. } else {
  3090. $scope.try_async_loads()
  3091. }
  3092. // var mydatacatedown = angular.copy($scope.my_data);
  3093. // $scope.my_data = [];
  3094. // var objects = [];
  3095. // angular.forEach(mydatacatedown, function(item) {
  3096. // if (item.label.match(key)) {
  3097. // objects.push(item)
  3098. // } else {
  3099. // // $scope.my_data_after.push(item)
  3100. // }
  3101. // })
  3102. // $scope.my_data = convertParentToChildList(objects);
  3103. // $scope.tree_data = angular.copy($scope.my_data);
  3104. }
  3105. $scope.mydatacate = [];
  3106. $scope.searchup = function(key) {
  3107. // var mydatacate = angular.copy($scope.my_data_after);
  3108. $scope.my_data_after = [];
  3109. angular.forEach($scope.mydatacate, function(item) {
  3110. if (item.label.match(key)) {
  3111. $scope.my_data_after.push(item)
  3112. } else {}
  3113. })
  3114. }
  3115. //角色树
  3116. $scope.my_tree = [];
  3117. $scope.tree_data_after = [];
  3118. $scope.my_data = [];
  3119. $scope.my_data_after = [];
  3120. $scope.formdashboard = function(item) {
  3121. $scope.my_data_after = [];
  3122. angular.forEach(item, function(infox) {
  3123. if (infox.children.length == 0) {
  3124. $scope.my_data_after.push(infox);
  3125. }
  3126. })
  3127. $scope.mydatacate = angular.copy($scope.my_data_after);
  3128. }
  3129. $scope.ok = function(item) {
  3130. $modalInstance.close(item);
  3131. };
  3132. $scope.cancel = function() {
  3133. $modalInstance.dismiss('cancel');
  3134. };
  3135. },
  3136. // size: 'sm',
  3137. resolve: {
  3138. scope: function() {
  3139. return $scope;
  3140. }
  3141. }
  3142. });
  3143. modalInstance.result.then(function(selectedItem) {
  3144. // $rootScope.isMask = true;
  3145. if (selectedItem) {
  3146. var type = 1;
  3147. var fildat = { 'configure': selectedItem };
  3148. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  3149. // // if (data.errno == 0) {
  3150. // var file = new Blob([data], {
  3151. // // 'Accept': '*/*'
  3152. // type: 'application/octet-stream'
  3153. // // type: 'application/vnd.ms-excel'
  3154. // });
  3155. // //trick to download store a file having its URL
  3156. // var fileURL = URL.createObjectURL(file);
  3157. // var a = document.createElement('a');
  3158. // a.href = fileURL;
  3159. // a.target = '_blank';
  3160. // a.download = "资产导入模版.xlsx";
  3161. // document.body.appendChild(a);
  3162. // a.click();
  3163. // // }
  3164. // })
  3165. $http({
  3166. url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
  3167. method: 'POST',
  3168. data: JSON.stringify(fildat),
  3169. headers: {
  3170. // 'Content-type': 'application/xls',
  3171. 'Accept': '*/*'
  3172. },
  3173. responseType: 'arraybuffer'
  3174. }).success(function(data, status, headers, config) {
  3175. $rootScope.isMask = false;
  3176. var file = new Blob([data], {
  3177. type: 'application/octet-stream'
  3178. // type : 'application/vnd.ms-excel'
  3179. });
  3180. //trick to download store a file having its URL
  3181. var fileURL = URL.createObjectURL(file);
  3182. var a = document.createElement('a');
  3183. a.href = fileURL;
  3184. a.target = '_blank';
  3185. a.download = "资产导入模版.xlsx";
  3186. document.body.appendChild(a);
  3187. a.click();
  3188. }).error(function(data, status, headers, config) {
  3189. // console.log(data);
  3190. $rootScope.isMask = false;
  3191. });
  3192. // break;
  3193. // }
  3194. // }
  3195. // }
  3196. // })
  3197. } else {
  3198. SweetAlert.swal({
  3199. title: "未选择资产分类!",
  3200. text: "请选择资产分类",
  3201. type: "error"
  3202. }, function() {
  3203. $rootScope.isMask = false;
  3204. });
  3205. }
  3206. // }
  3207. });
  3208. }
  3209. $scope.wrongdata = [];
  3210. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3211. var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
  3212. $scope.importopen = function() { //导入触发事件
  3213. if (angular.isUndefined($scope.form.dropState)) {
  3214. $scope.form.dropState = false;
  3215. }
  3216. //附件上传数据
  3217. //$scope.options.templateOptions.uploader();
  3218. // FILTERS
  3219. uploader.filters.push({
  3220. name: 'customFilter',
  3221. fn: function(item /*{File|FileLikeObject}*/ , options) {
  3222. return this.queue.length < 2;
  3223. }
  3224. });
  3225. // CALLBACKS
  3226. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  3227. console.info('onWhenAddingFileFailed', item, filter, options);
  3228. };
  3229. uploader.onAfterAddingFile = function(fileItem) {
  3230. console.info('onAfterAddingFile', fileItem);
  3231. };
  3232. uploader.onAfterAddingAll = function(addedFileItems) {
  3233. console.info('onAfterAddingAll', addedFileItems);
  3234. };
  3235. uploader.onBeforeUploadItem = function(item) {
  3236. console.info('onBeforeUploadItem', item);
  3237. };
  3238. uploader.onProgressItem = function(fileItem, progress) {
  3239. console.info('onProgressItem', fileItem, progress);
  3240. };
  3241. uploader.onProgressAll = function(progress) {
  3242. console.info('onProgressAll', progress);
  3243. };
  3244. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3245. // console.info('onSuccessItem', fileItem, response, status, headers);
  3246. // };
  3247. uploader.onErrorItem = function(fileItem, response, status, headers) {
  3248. console.info('onErrorItem', fileItem, response, status, headers);
  3249. };
  3250. uploader.onCancelItem = function(fileItem, response, status, headers) {
  3251. console.info('onCancelItem', fileItem, response, status, headers);
  3252. };
  3253. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  3254. console.info('onCompleteItem', fileItem, response, status, headers);
  3255. };
  3256. uploader.onCompleteAll = function() {
  3257. console.info('onCompleteAll');
  3258. };
  3259. }
  3260. // $scope.importnext = function() {
  3261. // $scope.state = 2;
  3262. // event.preventDefault();
  3263. // }
  3264. $scope.importnext = function() {
  3265. event.preventDefault();
  3266. // $rootScope.isMask = true;
  3267. $rootScope.loading = true;
  3268. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3269. uploader.onBeforeUploadItem = function(item) {
  3270. angular.extend(item.headers, $rootScope.getSession());
  3271. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3272. // if (item.index > 1) {
  3273. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3274. // }
  3275. // item.index = 1;
  3276. item.formData = [{ 'filename': item.file.name }];
  3277. console.info('onBeforeUploadItem', item);
  3278. };
  3279. uploader.uploadAll();
  3280. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3281. if (response.status == 200) {
  3282. $scope.wrongdata = [];
  3283. $rootScope.loading = false;
  3284. if (response.abnormal) {
  3285. $scope.state = 2;
  3286. angular.forEach(response.msg, function(item) {
  3287. $scope.wrongdata.push({ 'name': item.assetName, 'line': item.row, 'cmdbname': item.name, 'errotip': [{ 'label': item.msg }] })
  3288. })
  3289. } else {
  3290. $scope.state = 3;
  3291. }
  3292. } else {
  3293. $rootScope.loading = false;
  3294. $scope.state = 2;
  3295. }
  3296. }
  3297. }
  3298. $scope.clearItems = function() { //重新选择文件时,清空队列,达到覆盖文件的效果
  3299. uploader.clearQueue();
  3300. // uploader.remove();
  3301. // uploader.cancel();
  3302. // uploader.onChange();
  3303. }
  3304. uploader.onAfterAddingFile = function(fileItem) {
  3305. $scope.fileItem = fileItem._file;
  3306. // $scope.$apply();
  3307. // $scope.fileItem = filenum;
  3308. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  3309. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  3310. $scope.filenum++;
  3311. };
  3312. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3313. $scope.uploadStatus = true; //上传成功则把状态改为true
  3314. // alert(response.path);
  3315. };
  3316. $scope.importnext = function() {
  3317. event.preventDefault();
  3318. // uploader.onChange();
  3319. $rootScope.loading = true;
  3320. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3321. uploader.onBeforeUploadItem = function(item) {
  3322. angular.extend(item.headers, $rootScope.getSession());
  3323. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3324. // if (item.index > 1) {
  3325. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3326. // }
  3327. // item.index = 1;
  3328. item.formData = [{ 'filename': item.file.name }];
  3329. console.info('onBeforeUploadItem', item);
  3330. };
  3331. uploader.uploadAll();
  3332. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3333. if (response.status == 200) {
  3334. $scope.wrongdata = [];
  3335. // uploader.queue = [];
  3336. $rootScope.loading = false;
  3337. if (response.abnormal) {
  3338. $scope.state = 2;
  3339. uploader.clearQueue();
  3340. angular.forEach(response.msg, function(item) {
  3341. $scope.wrongdata.push({ 'name': item.assetName, 'line': item.row, 'cmdbname': item.name, 'errotip': [{ 'label': item.msg }] })
  3342. })
  3343. } else {
  3344. $scope.state = 3;
  3345. }
  3346. } else {
  3347. uploader.clearQueue();
  3348. $rootScope.loading = false;
  3349. $scope.state = 2;
  3350. }
  3351. }
  3352. }
  3353. var setAllInactive = function() {
  3354. angular.forEach($scope.workspaces, function(workspace) {
  3355. workspace.active = false;
  3356. });
  3357. };
  3358. //添加
  3359. var addNewWorkspace = function(name, contentUrl) {
  3360. var id = $scope.workspaces.length + 1;
  3361. $scope.workspaces.push({
  3362. id: id,
  3363. name: name,
  3364. active: true,
  3365. contentUrl: 'main/html/content.html'
  3366. });
  3367. };
  3368. //关闭
  3369. $scope.closeopen = function(closedata) {
  3370. event.preventDefault();
  3371. angular.forEach($scope.workspaces, function(item, index) {
  3372. if (closedata.id == item.id) {
  3373. if (closedata.id == 1) {
  3374. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  3375. } else {
  3376. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  3377. }
  3378. $scope.workspaces.splice(index, 1);
  3379. }
  3380. })
  3381. }
  3382. // $scope.workspaces = [
  3383. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  3384. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3385. // ];
  3386. $scope.addWorkspace = function(contentUrl, name) {
  3387. setAllInactive();
  3388. addNewWorkspace(name, contentUrl);
  3389. };
  3390. // $rootScope.addWorkspace = $scope.addWorkspace;
  3391. $scope.close = function(idNumber) {
  3392. var index = 0; //记录当前元素下标
  3393. angular.forEach($scope.workspaces, function(workspace) {
  3394. if (workspace.id === idNumber) {
  3395. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3396. }
  3397. index++;
  3398. });
  3399. };
  3400. //grid2
  3401. $scope.langs = i18nService.getAllLangs();
  3402. $scope.lang = 'zh-cn';
  3403. i18nService.setCurrentLang($scope.lang);
  3404. $scope.gridOptions2 = {};
  3405. $scope.gridOptions2.data = 'myData3';
  3406. $scope.gridOptions2.enableColumnResizing = true;
  3407. $scope.gridOptions2.enableFiltering = false;
  3408. $scope.gridOptions2.enableGridMenu = false;
  3409. $scope.gridOptions2.showGridFooter = true;
  3410. $scope.gridOptions2.showColumnFooter = false;
  3411. $scope.gridOptions2.fastWatch = true;
  3412. $scope.gridOptions2.useExternalFiltering = true;
  3413. $scope.gridOptions2.useExternalPagination = true;
  3414. $scope.gridOptions2.paginationPageSizes = [10];
  3415. $scope.gridOptions2.paginationPageSize = 10;
  3416. $scope.gridOptions2.multiSelect = false;
  3417. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  3418. $scope.gridOptions2.columnDefs = [
  3419. { name: 'item', displayName: '序号', width: 120 },
  3420. { name: 'name', displayName: '耗材名称', width: 80, enableFiltering: false },
  3421. { name: 'model', displayName: '品牌/型号', width: 100, enableFiltering: false },
  3422. { name: 'Specifications', displayName: '规格', width: 150, enableFiltering: false },
  3423. { name: 'sum', displayName: '数量', enableFiltering: false },
  3424. {
  3425. name: '操作',
  3426. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3427. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  3428. '</div></div>',
  3429. enableFiltering: false
  3430. },
  3431. ];
  3432. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  3433. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  3434. $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
  3435. for (var i = 0; i < $scope.myData3all.length; i++) {
  3436. $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  3437. }
  3438. // $scope.model.consumables = $scope.myDataone;
  3439. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3440. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
  3441. $scope.model.applicationForm.consumables = $scope.myData3all;
  3442. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3443. $scope.options.templateOptions.getpush({ "hao": true, "gu": true });
  3444. } else {
  3445. $scope.options.templateOptions.getpush({ "hao": true });
  3446. }
  3447. } else {
  3448. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3449. $scope.options.templateOptions.getpush({ "gu": true });
  3450. }
  3451. }
  3452. }
  3453. $scope.options.templateOptions.workspaces = $scope.workspaces;
  3454. $scope.changecai = function(item) {
  3455. event.preventDefault();
  3456. var modalInstance = $modal.open({
  3457. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  3458. controller: function($scope, $modalInstance) {
  3459. $scope.title = "修改耗材数量";
  3460. $scope.consumptive = angular.copy(item);
  3461. $scope.ok = function() {
  3462. $modalInstance.close($scope.consumptive);
  3463. };
  3464. $scope.cancel = function() {
  3465. $modalInstance.dismiss('cancel');
  3466. };
  3467. },
  3468. size: 'sm'
  3469. });
  3470. modalInstance.result.then(function(selectedItem) {
  3471. // angular.forEach($scope.myData3, function(items, index) {
  3472. // if (items.id == selectedItem.id) {
  3473. // $scope.myData3[index] = selectedItem;
  3474. // }
  3475. // })
  3476. // // $scope.myData3.push(selectedItem);
  3477. // $scope.model.applicationForm.consumables = $scope.myData3;
  3478. angular.forEach($scope.myData3all, function(items, index) {
  3479. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  3480. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  3481. angular.extend($scope.myData3all[index], selectedItem)
  3482. }
  3483. })
  3484. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3485. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3486. $scope.model.applicationForm.consumables = $scope.myData3all;
  3487. })
  3488. }
  3489. $scope.gridOptions2.onRegisterApi = function(gridApi) {
  3490. $scope.gridApi = gridApi;
  3491. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  3492. // var filtersData = $scope.memoryfilterDatahao;
  3493. // filtersData.idx = newPage - 1;
  3494. // filtersData.sum = pageSize;
  3495. // $scope.loadData(filtersData);
  3496. $scope.memoryfilterDatahao.idx = newPage - 1;
  3497. $scope.memoryfilterDatahao.sum = pageSize;
  3498. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
  3499. });
  3500. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  3501. $scope.selected.items = data.entity;
  3502. //console.log(data);
  3503. });
  3504. gridApi.selection.on.rowSelectionChangedBatch($scope, function(data) {
  3505. $scope.selected.items = data.entity;
  3506. //console.log(data);
  3507. });
  3508. gridApi.core.on.filterChanged($scope, function() {
  3509. var grid = this.grid;
  3510. var filtersData = {
  3511. idx: 0,
  3512. sum: 10,
  3513. };
  3514. $scope.memoryfilterDatahao = filtersData;
  3515. // $scope.loadData(filtersData);
  3516. // $scope.memoryfilterDatahao.idx = newPage - 1;
  3517. // $scope.memoryfilterDatahao.sum = pageSize;
  3518. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3519. });
  3520. };
  3521. $scope.haocaiopen = function(items) {
  3522. event.preventDefault();
  3523. var modalInstance = $modal.open({
  3524. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3525. controller: function($scope, $modalInstance, SweetAlert) {
  3526. $scope.consumptive = {};
  3527. $scope.title = "新增耗材";
  3528. if (items.name) {
  3529. $scope.consumptive.name = items.name.name;
  3530. }
  3531. $scope.clearNoNum = function(obj, attr) {
  3532. //先把非数字的都替换掉,除了数字和.
  3533. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3534. //必须保证第一个为数字而不是.
  3535. obj[attr] = obj[attr].replace(/^\./g, "");
  3536. //保证只有出现一个.而没有多个.
  3537. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3538. //保证.只出现一次,而不能出现两次以上
  3539. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3540. //小于最大值
  3541. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3542. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3543. // obj[attr] = '';
  3544. // }
  3545. }
  3546. $scope.ok = function(item) {
  3547. // if (item.name && item.model && item.Specifications && item.sum) {
  3548. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3549. $modalInstance.close(item);
  3550. } else {
  3551. SweetAlert.swal({
  3552. title: "数据填写不完整!",
  3553. text: "请检查数据然后提交!",
  3554. type: "error"
  3555. });
  3556. }
  3557. };
  3558. $scope.cancel = function() {
  3559. $modalInstance.dismiss('cancel');
  3560. };
  3561. },
  3562. size: 'sm',
  3563. resolve: {
  3564. SweetAlert: function() {
  3565. return SweetAlert;
  3566. }
  3567. }
  3568. });
  3569. modalInstance.result.then(function(selectedItem) {
  3570. api_wechatfile.addDictionary({
  3571. "type": "list",
  3572. "key": "haocaifenlei",
  3573. "name": selectedItem.name,
  3574. "parent": selectedItem.id,
  3575. "value": "1"
  3576. }).then(function(data) {
  3577. // $scope.haocainame.name = data.list;
  3578. api_wechatfile.addDictionary({
  3579. "type": "list",
  3580. "key": "pinpai",
  3581. "name": selectedItem.model,
  3582. "parent": data.id,
  3583. "value": "1"
  3584. }).then(function(data) {
  3585. // $scope.haocainame = data.list;
  3586. })
  3587. api_wechatfile.addDictionary({
  3588. "type": "list",
  3589. "key": "guige",
  3590. "name": selectedItem.Specifications,
  3591. "parent": data.id,
  3592. "value": "1"
  3593. }).then(function(data) {
  3594. // $scope.haocainame = data.list;
  3595. })
  3596. })
  3597. // $scope.myData3.push(selectedItem);
  3598. // for (var i = 0; i < $scope.myData3.length; i++) {
  3599. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3600. // }
  3601. // $scope.model.applicationForm.consumables = $scope.myData3;
  3602. $scope.myData3all.push(selectedItem);
  3603. for (var i = 0; i < $scope.myData3all.length; i++) {
  3604. $scope.myData3all[i]['item'] = i + 1
  3605. }
  3606. // $scope.model.consumables = $scope.myDataone;
  3607. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3608. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3609. $scope.model.applicationForm.consumables = $scope.myData3all;
  3610. })
  3611. }
  3612. $scope.haocaiadd = function() {
  3613. event.preventDefault();
  3614. var modalInstance = $modal.open({
  3615. templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
  3616. controller: function($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  3617. $scope.haocainame = [];
  3618. $scope.pinpai = [];
  3619. $scope.guige = [];
  3620. $scope.consumptive = {};
  3621. $scope.consumpall = {};
  3622. $scope.title = "添加耗材";
  3623. api_wechatfile.getDictionaryForList({ "key": "haocaifenlei" }).then(function(data) {
  3624. $scope.haocainame = data;
  3625. })
  3626. $scope.clearNoNum = function(obj, attr) {
  3627. //先把非数字的都替换掉,除了数字和.
  3628. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3629. //必须保证第一个为数字而不是.
  3630. obj[attr] = obj[attr].replace(/^\./g, "");
  3631. //保证只有出现一个.而没有多个.
  3632. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3633. //保证.只出现一次,而不能出现两次以上
  3634. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3635. //小于最大值
  3636. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3637. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3638. // obj[attr] = '';
  3639. // }
  3640. }
  3641. $scope.onChange = function(parent) {
  3642. $scope.consumptive.model = {};
  3643. $scope.consumptive.Specifications = {};
  3644. api_wechatfile.getDictionaryForList({ "key": "pinpai", "parent": parent.id }).then(function(data) {
  3645. $scope.pinpai = data;
  3646. })
  3647. api_wechatfile.getDictionaryForList({ "key": "guige", "parent": parent.id }).then(function(data) {
  3648. $scope.guige = data;
  3649. })
  3650. }
  3651. $scope.addhaocai = function() {
  3652. $modalInstance.dismiss('cancel');
  3653. scope.haocaiopen($scope.consumptive);
  3654. }
  3655. $scope.ok = function(item) {
  3656. var items = {};
  3657. var submittrue = true;
  3658. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3659. items = { "modelid": item.model.id, "nameid": item.name.id, "Specificationsid": item.Specifications.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  3660. angular.forEach(scope.myData3all, function(itemsdata) {
  3661. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  3662. submittrue = false;
  3663. }
  3664. })
  3665. if (submittrue) {
  3666. $modalInstance.close(items);
  3667. } else {
  3668. SweetAlert.swal({
  3669. title: "该耗材已有添加",
  3670. text: "请检查数据然后提交!",
  3671. type: "error"
  3672. });
  3673. }
  3674. } else {
  3675. SweetAlert.swal({
  3676. title: "数据填写不完整!",
  3677. text: "请检查数据然后提交!",
  3678. type: "error"
  3679. });
  3680. }
  3681. // var isold = false;
  3682. // if (item.name && item.model && item.Specifications && item.sum) {
  3683. // for (var i = 0; i < scope.myData3all.length; i++) {
  3684. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  3685. // isold = true;
  3686. // }
  3687. // }
  3688. // if (isold) {
  3689. // SweetAlert.swal({
  3690. // title: "该耗材已添加!",
  3691. // text: "请不要重复添加耗材!",
  3692. // type: "error"
  3693. // });
  3694. // } else {
  3695. // $scope.consumpall.model = $scope.consumpall.brandModel;
  3696. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  3697. // $scope.consumpall.sum = item.sum;
  3698. // delete $scope.consumpall.brandModel;
  3699. // delete $scope.consumpall.specification;
  3700. // $modalInstance.close($scope.consumpall);
  3701. // }
  3702. // } else {
  3703. // SweetAlert.swal({
  3704. // title: "数据填写不完整!",
  3705. // text: "请检查数据然后提交!",
  3706. // type: "error"
  3707. // });
  3708. // }
  3709. };
  3710. $scope.cancel = function() {
  3711. $modalInstance.dismiss('cancel');
  3712. };
  3713. },
  3714. size: 'sm',
  3715. resolve: {
  3716. scope: function() {
  3717. return $scope;
  3718. }
  3719. }
  3720. });
  3721. modalInstance.result.then(function(selectedItem) {
  3722. $scope.myData3all.push(selectedItem);
  3723. for (var i = 0; i < $scope.myData3all.length; i++) {
  3724. $scope.myData3all[i]['item'] = i + 1
  3725. }
  3726. // $scope.model.consumables = $scope.myDataone;
  3727. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3728. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3729. $scope.model.applicationForm.consumables = $scope.myData3all;
  3730. })
  3731. }
  3732. $scope.onDblClick = function(data, event) {
  3733. $scope.selectButtonClick(data, event);
  3734. };
  3735. // $scope.memoryfilterDatahao = {
  3736. // "idx": 0,
  3737. // "sum": 10,
  3738. // }
  3739. // $scope.loadData = function(filterData) {};
  3740. $scope.title = title;
  3741. if (angular.isFunction($scope.options.templateOptions.transform)) {
  3742. $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
  3743. }
  3744. }]
  3745. });
  3746. //归还设备耗材tab
  3747. formlyConfigProvider.setType({
  3748. name: 'ui-cmdbreturntab',
  3749. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
  3750. wrapper: ['bootstrapHasError'],
  3751. defaultOptions: function(options, $scope) {
  3752. return {
  3753. templateOptions: {
  3754. // checkform: function(options) {
  3755. // if (options.model.requester) {
  3756. // options.value(options.model.requester);
  3757. // }
  3758. // },
  3759. }
  3760. };
  3761. },
  3762. controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
  3763. var setAllInactive = function() {
  3764. angular.forEach($scope.workspaces, function(workspace) {
  3765. workspace.active = false;
  3766. });
  3767. };
  3768. $scope.memoryfilterData = {
  3769. "idx": 0,
  3770. "sum": 10,
  3771. }
  3772. //添加
  3773. var addNewWorkspace = function(name, contentUrl) {
  3774. var id = $scope.workspaces.length + 1;
  3775. $scope.workspaces.push({
  3776. id: id,
  3777. name: name,
  3778. active: true,
  3779. contentUrl: 'main/html/content.html'
  3780. });
  3781. };
  3782. $scope.workspaces = [
  3783. { id: 1, name: "归还设备", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html' },
  3784. { id: 2, name: "归还耗材", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3785. ];
  3786. $scope.addWorkspace = function(contentUrl, name) {
  3787. setAllInactive();
  3788. addNewWorkspace(name, contentUrl);
  3789. };
  3790. // $rootScope.addWorkspace = $scope.addWorkspace;
  3791. $scope.close = function(idNumber) {
  3792. var index = 0; //记录当前元素下标
  3793. angular.forEach($scope.workspaces, function(workspace) {
  3794. if (workspace.id === idNumber) {
  3795. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3796. }
  3797. index++;
  3798. });
  3799. };
  3800. $scope.memoryfilterDataguishe = {
  3801. "idx": 0,
  3802. "sum": 10,
  3803. }
  3804. //grid1
  3805. $scope.langs = i18nService.getAllLangs();
  3806. $scope.lang = 'zh-cn';
  3807. i18nService.setCurrentLang($scope.lang);
  3808. $scope.gridOptions1 = {};
  3809. $scope.gridOptions1.data = 'myData1';
  3810. $scope.gridOptions1.enableColumnResizing = true;
  3811. $scope.gridOptions1.enableFiltering = false;
  3812. $scope.gridOptions1.enableGridMenu = false;
  3813. $scope.gridOptions1.showGridFooter = true;
  3814. $scope.gridOptions1.showColumnFooter = false;
  3815. $scope.gridOptions1.fastWatch = true;
  3816. $scope.gridOptions1.useExternalFiltering = true;
  3817. $scope.gridOptions1.useExternalPagination = true;
  3818. $scope.gridOptions1.paginationPageSizes = [10];
  3819. $scope.gridOptions1.paginationPageSize = 10;
  3820. $scope.gridOptions1.multiSelect = false;
  3821. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  3822. $scope.gridOptions1.columnDefs = [
  3823. { name: 'item', displayName: '序号', width: 120 },
  3824. { name: 'props.hw_cifilterClassic', displayName: '设备类型', width: 150, enableFiltering: false },
  3825. { name: 'props.hw_mingcheng', displayName: '设备名称', width: 180, enableFiltering: false },
  3826. { name: 'uuid', displayName: '设备编号', width: 180, enableFiltering: false },
  3827. { name: 'props.hw_state', width: 150, displayName: '状态', enableFiltering: false },
  3828. {
  3829. name: '操作',
  3830. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  3831. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  3832. '</div></div>',
  3833. enableFiltering: false
  3834. },
  3835. ];
  3836. // $scope.selectButtonClick
  3837. $scope.gridOptions1.onRegisterApi = function(gridApi) {
  3838. $scope.gridApi = gridApi;
  3839. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  3840. // var filtersData = $scope.memoryfilterData;
  3841. // filtersData.idx = newPage - 1;
  3842. // filtersData.sum = pageSize;
  3843. // $scope.loadData(filtersData);
  3844. $scope.memoryfilterDataguishe.idx = newPage - 1;
  3845. $scope.memoryfilterDataguishe.sum = pageSize;
  3846. $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
  3847. });
  3848. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  3849. $scope.selected.items = data.entity;
  3850. //console.log(data);
  3851. });
  3852. gridApi.selection.on.rowSelectionChangedBatch($scope, function(data) {
  3853. $scope.selected.items = data.entity;
  3854. //console.log(data);
  3855. });
  3856. gridApi.core.on.filterChanged($scope, function() {
  3857. // var grid = this.grid;
  3858. // var filtersData = {
  3859. // idx: 0,
  3860. // sum: 20,
  3861. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  3862. // };
  3863. // angular.forEach(grid.columns, function(item) {
  3864. // if (item.enableFiltering) {
  3865. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  3866. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  3867. // if (angular.isUndefined(filtersData['user'])) {
  3868. // filtersData['user'] = {};
  3869. // }
  3870. // filtersData['user'][item.field] = item.filters[0].term;
  3871. // }
  3872. // }
  3873. // });
  3874. // $scope.memoryfilterData = filtersData;
  3875. // $scope.loadData(filtersData);
  3876. });
  3877. };
  3878. $scope.changegu = function(item) {
  3879. event.preventDefault();
  3880. var modalInstance = $modal.open({
  3881. templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
  3882. controller: function($scope, $modalInstance) {
  3883. $scope.title = "修改设备状态";
  3884. $scope.hw_state = {};;
  3885. if (item.status) {
  3886. $scope.hw_state.name = item.hw_state;
  3887. }
  3888. // $scope.consumptive = item;
  3889. $scope.stateshe = [{ "id": 2, "name": "在库" }, { "id": 4, "name": "报修" }, { "id": 3, "name": "报废" }]
  3890. $scope.ok = function(item) {
  3891. $modalInstance.close($scope.hw_state);
  3892. };
  3893. $scope.cancel = function() {
  3894. $modalInstance.dismiss('cancel');
  3895. };
  3896. },
  3897. size: 'sm'
  3898. });
  3899. modalInstance.result.then(function(selectedItem) {
  3900. angular.forEach($scope.myData1, function(items, index) {
  3901. if (items.id == item.id) {
  3902. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  3903. }
  3904. })
  3905. $scope.model.assets = $scope.myData1;
  3906. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
  3907. })
  3908. }
  3909. $scope.onDblClick = function(data, event) {
  3910. $scope.selectButtonClick(data, event);
  3911. };
  3912. $scope.memoryfilterData = {
  3913. "idx": 0,
  3914. "sum": 10,
  3915. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  3916. }
  3917. // $scope.myData = {};
  3918. $scope.loadData = function(filterData) {};
  3919. $scope.title = title;
  3920. $scope.loadData({
  3921. idx: 0,
  3922. sum: 10,
  3923. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  3924. });
  3925. $scope.selected = {
  3926. items: []
  3927. };
  3928. $scope.myData2 = [];
  3929. $scope.consumptive = {};
  3930. $scope.myDataguibeiall = [];
  3931. $scope.haocaiopen = function(items) {
  3932. event.preventDefault();
  3933. var modalInstance = $modal.open({
  3934. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3935. controller: function($scope, $modalInstance, SweetAlert, api_wechatfile) {
  3936. $scope.consumptive = {};
  3937. $scope.title = "新增耗材";
  3938. if (items.name) {
  3939. $scope.consumptive.name = items.name.name;
  3940. }
  3941. $scope.ok = function(item) {
  3942. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3943. $modalInstance.close(item);
  3944. } else {
  3945. SweetAlert.swal({
  3946. title: "数据填写不完整!",
  3947. text: "请检查数据然后提交!",
  3948. type: "error"
  3949. });
  3950. }
  3951. };
  3952. $scope.cancel = function() {
  3953. $modalInstance.dismiss('cancel');
  3954. };
  3955. },
  3956. size: 'sm'
  3957. });
  3958. modalInstance.result.then(function(selectedItem) {
  3959. api_wechatfile.addDictionary({
  3960. "type": "list",
  3961. "key": "haocaifenlei",
  3962. "name": selectedItem.name,
  3963. "parent": selectedItem.id,
  3964. "value": "1"
  3965. }).then(function(data) {
  3966. // $scope.haocainame.name = data.list;
  3967. api_wechatfile.addDictionary({
  3968. "type": "list",
  3969. "key": "pinpai",
  3970. "name": selectedItem.model,
  3971. "parent": data.id,
  3972. "value": "1"
  3973. }).then(function(data) {
  3974. // $scope.haocainame = data.list;
  3975. })
  3976. api_wechatfile.addDictionary({
  3977. "type": "list",
  3978. "key": "guige",
  3979. "name": selectedItem.Specifications,
  3980. "parent": data.id,
  3981. "value": "1"
  3982. }).then(function(data) {
  3983. // $scope.haocainame = data.list;
  3984. })
  3985. })
  3986. $scope.myData2.push(selectedItem);
  3987. for (var i = 0; i < $scope.myData2.length; i++) {
  3988. $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3989. }
  3990. // $scope.model.applicationForm.consumables = $scope.myData2;
  3991. angular.forEach($scope.myDataguibeiall, function(items, index) {
  3992. if (items.id == selectedItem.id) {
  3993. $scope.myDataguibeiall.splice(index, 1);
  3994. }
  3995. })
  3996. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
  3997. $scope.model.consumables = $scope.myDataguibeiall;
  3998. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  3999. $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
  4000. })
  4001. }
  4002. //grid2
  4003. $scope.langs = i18nService.getAllLangs();
  4004. $scope.lang = 'zh-cn';
  4005. i18nService.setCurrentLang($scope.lang);
  4006. $scope.gridOptions2 = {};
  4007. $scope.gridOptions2.data = 'myData2';
  4008. $scope.gridOptions2.enableColumnResizing = true;
  4009. $scope.gridOptions2.enableFiltering = false;
  4010. $scope.gridOptions2.enableGridMenu = false;
  4011. $scope.gridOptions2.showGridFooter = true;
  4012. $scope.gridOptions2.showColumnFooter = false;
  4013. $scope.gridOptions2.fastWatch = true;
  4014. $scope.gridOptions2.useExternalFiltering = true;
  4015. $scope.gridOptions2.useExternalPagination = true;
  4016. $scope.gridOptions2.paginationPageSizes = [10];
  4017. $scope.gridOptions2.paginationPageSize = 10;
  4018. $scope.gridOptions2.multiSelect = false;
  4019. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4020. $scope.modelcons = {};
  4021. $scope.modelass = {};
  4022. $scope.myData2all = [];
  4023. $scope.myData1all = [];
  4024. $scope.memoryfilterDatagui = {
  4025. "idx": 0,
  4026. "sum": 10
  4027. }
  4028. setInterval(function() {
  4029. if ($scope.model.assets) {
  4030. if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4031. $scope.modelass = $scope.model.assets;
  4032. if (JSON.stringify($scope.model.assets) == "{}") {
  4033. $scope.model.assets = []
  4034. } else {
  4035. $scope.model.assets = JSON.parse($scope.model.assets);
  4036. }
  4037. // $scope.myData1 = $scope.model.assets;
  4038. // for (var i = 0; i < $scope.myData1.length; i++) {
  4039. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4040. // }
  4041. $scope.myData1all = $scope.model.assets;
  4042. for (var i = 0; i < $scope.myData1all.length; i++) {
  4043. $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4044. }
  4045. $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
  4046. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
  4047. }
  4048. }
  4049. if ($scope.model.consumables) {
  4050. if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4051. $scope.modelass = $scope.model.consumables;
  4052. if (JSON.stringify($scope.model.consumables) == "{}") {
  4053. $scope.model.consumables = [];
  4054. } else {
  4055. $scope.model.consumables = JSON.parse($scope.model.consumables);
  4056. }
  4057. // $scope.myData2 = $scope.model.consumables;
  4058. // for (var i = 0; i < $scope.myData2.length; i++) {
  4059. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4060. // }
  4061. $scope.myData2all = $scope.model.consumables;
  4062. for (var i = 0; i < $scope.myData2all.length; i++) {
  4063. $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4064. }
  4065. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4066. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
  4067. // $scope.model.consumables = $scope.myData2all;
  4068. }
  4069. }
  4070. }, 100);
  4071. $scope.gridOptions2.columnDefs = [
  4072. { name: 'item', displayName: '序号', width: 120 },
  4073. { name: 'name', displayName: '耗材名称', width: 180, enableFiltering: false },
  4074. { name: 'model', displayName: '品牌/型号', width: 180, enableFiltering: false },
  4075. { name: 'Specifications', displayName: '规格', width: 150, enableFiltering: false },
  4076. { name: 'sum', width: 150, displayName: '数量', enableFiltering: false },
  4077. {
  4078. name: '操作',
  4079. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4080. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4081. '</div></div>',
  4082. enableFiltering: false
  4083. },
  4084. ];
  4085. // $scope.selectButtonClick
  4086. $scope.gridOptions2.onRegisterApi = function(gridApi) {
  4087. $scope.gridApi = gridApi;
  4088. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  4089. // var filtersData = $scope.memoryfilterDatagui;
  4090. // filtersData.idx = newPage - 1;
  4091. // filtersData.sum = pageSize;
  4092. $scope.memoryfilterDatagui.idx = newPage - 1;
  4093. $scope.memoryfilterDatagui.sum = pageSize;
  4094. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4095. });
  4096. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  4097. $scope.selected.items = data.entity;
  4098. //console.log(data);
  4099. });
  4100. gridApi.selection.on.rowSelectionChangedBatch($scope, function(data) {
  4101. $scope.selected.items = data.entity;
  4102. //console.log(data);
  4103. });
  4104. gridApi.core.on.filterChanged($scope, function() {
  4105. var grid = this.grid;
  4106. var filtersData = {
  4107. idx: 0,
  4108. sum: 10,
  4109. };
  4110. angular.forEach(grid.columns, function(item) {
  4111. if (item.enableFiltering) {
  4112. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4113. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4114. if (angular.isUndefined(filtersData['user'])) {
  4115. filtersData['user'] = {};
  4116. }
  4117. filtersData['user'][item.field] = item.filters[0].term;
  4118. }
  4119. }
  4120. });
  4121. $scope.memoryfilterData = filtersData;
  4122. $scope.loadData(filtersData);
  4123. });
  4124. };
  4125. $scope.changecai = function(item) {
  4126. event.preventDefault();
  4127. var modalInstance = $modal.open({
  4128. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4129. controller: function($scope, $modalInstance) {
  4130. $scope.title = "修改耗材数量";
  4131. $scope.consumptive = angular.copy(item);
  4132. // $scope.consumptive = item;
  4133. $scope.maxsum = item.inventoryNum;
  4134. $scope.clearNoNum = function(obj, attr) {
  4135. //先把非数字的都替换掉,除了数字和.
  4136. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4137. //必须保证第一个为数字而不是.
  4138. obj[attr] = obj[attr].replace(/^\./g, "");
  4139. //保证只有出现一个.而没有多个.
  4140. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4141. //保证.只出现一次,而不能出现两次以上
  4142. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4143. //小于最大值
  4144. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4145. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4146. // obj[attr] = '';
  4147. // }
  4148. }
  4149. $scope.ok = function() {
  4150. $modalInstance.close($scope.consumptive);
  4151. };
  4152. $scope.cancel = function() {
  4153. $modalInstance.dismiss('cancel');
  4154. };
  4155. },
  4156. size: 'sm'
  4157. });
  4158. modalInstance.result.then(function(selectedItem) {
  4159. angular.forEach($scope.myData2all, function(items, index) {
  4160. // if (items.id == selectedItem.id) {
  4161. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  4162. angular.extend($scope.myData2all[index], selectedItem)
  4163. }
  4164. })
  4165. // $scope.model.consumables = $scope.myData2;
  4166. // $scope.myData2 = $scope.model.consumables;
  4167. // $scope.myData2all.push(selectedItem);
  4168. // for (var i = 0; i < $scope.myData2all.length; i++) {
  4169. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4170. // }
  4171. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4172. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4173. $scope.model.consumables = $scope.myData2all;
  4174. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4175. })
  4176. }
  4177. $scope.interceptMydata = function(mydate, idx, sum) {
  4178. return mydate.slice(idx * sum, (idx + 1) * sum)
  4179. }
  4180. $scope.haocaiadd = function() {
  4181. event.preventDefault();
  4182. var modalInstance = $modal.open({
  4183. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  4184. controller: function($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
  4185. $scope.haocainame = [];
  4186. $scope.pinpai = [];
  4187. $scope.guige = [];
  4188. $scope.consumptive = {};
  4189. $scope.consumptiveall = {};
  4190. $scope.title = "添加耗材";
  4191. api_wechatfile.getDictionaryForList({ "key": "haocaifenlei" }).then(function(data) {
  4192. $scope.haocainame = data;
  4193. })
  4194. $scope.clearNoNum = function(obj, attr) {
  4195. //先把非数字的都替换掉,除了数字和.
  4196. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4197. //必须保证第一个为数字而不是.
  4198. obj[attr] = obj[attr].replace(/^\./g, "");
  4199. //保证只有出现一个.而没有多个.
  4200. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4201. //保证.只出现一次,而不能出现两次以上
  4202. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4203. //小于最大值
  4204. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4205. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4206. obj[attr] = '';
  4207. }
  4208. }
  4209. $scope.onChange = function(parent) {
  4210. $scope.consumptive.model = {};
  4211. $scope.consumptive.Specifications = {};
  4212. api_wechatfile.getDictionaryForList({ "key": "pinpai", "parent": parent.id }).then(function(data) {
  4213. $scope.pinpai = data;
  4214. })
  4215. api_wechatfile.getDictionaryForList({ "key": "guige", "parent": parent.id }).then(function(data) {
  4216. $scope.guige = data;
  4217. })
  4218. }
  4219. // $scope.onChangesum = function(item) {
  4220. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  4221. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  4222. // $scope.consumptiveall = data1;
  4223. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  4224. // // if (data.list && data.list.length != 0) {
  4225. // // var myData = data.list;
  4226. // // $scope.consumptiveall = myData[0];
  4227. // // $scope.maxsum = myData[0].inventoryNum;
  4228. // // } else if (data.list && data.list.length == 0) {
  4229. // // SweetAlert.swal({
  4230. // // title: "库存数据存在问题!",
  4231. // // text: "请检查库存数据!",
  4232. // // type: "error"
  4233. // // });
  4234. // // }
  4235. // // });
  4236. // }
  4237. // }
  4238. $scope.addhaocai = function() {
  4239. $modalInstance.dismiss('cancel');
  4240. scope.haocaiopen($scope.consumptive);
  4241. }
  4242. $scope.ok = function(item) {
  4243. var submittrue = true;
  4244. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4245. var data = { "modelid": item.model.id, "nameid": item.name.id, "Specificationsid": item.Specifications.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4246. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4247. // $modalInstance.close(data);
  4248. angular.forEach(scope.myData2all, function(itemsdata) {
  4249. // if (item.model.id == itemsdata.id) {
  4250. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  4251. submittrue = false;
  4252. }
  4253. })
  4254. if (submittrue) {
  4255. $modalInstance.close(data);
  4256. } else {
  4257. SweetAlert.swal({
  4258. title: "该耗材已有添加",
  4259. text: "请检查数据然后提交!",
  4260. type: "error"
  4261. });
  4262. }
  4263. } else {
  4264. SweetAlert.swal({
  4265. title: "数据填写不完整!",
  4266. text: "请检查数据然后提交!",
  4267. type: "error"
  4268. });
  4269. }
  4270. };
  4271. $scope.cancel = function() {
  4272. $modalInstance.dismiss('cancel');
  4273. };
  4274. },
  4275. size: 'sm',
  4276. resolve: {
  4277. scope: function() {
  4278. return $scope;
  4279. }
  4280. }
  4281. });
  4282. modalInstance.result.then(function(selectedItem) {
  4283. // $scope.myData2.push(selectedItem);
  4284. // for (var i = 0; i < $scope.myData2.length; i++) {
  4285. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4286. // }
  4287. // $scope.model.consumables = $scope.myData2;
  4288. $scope.myData2all.push(selectedItem);
  4289. for (var i = 0; i < $scope.myData2all.length; i++) {
  4290. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4291. $scope.myData2all[i]['item'] = i + 1
  4292. }
  4293. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4294. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4295. $scope.model.consumables = $scope.myData2all;
  4296. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4297. })
  4298. }
  4299. $scope.onDblClick = function(data, event) {
  4300. $scope.selectButtonClick(data, event);
  4301. };
  4302. $scope.memoryfilterData = {
  4303. "idx": 0,
  4304. "sum": 20,
  4305. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4306. }
  4307. $scope.myData = {};
  4308. $scope.loadData = function(filterData) {};
  4309. $scope.title = title;
  4310. $scope.loadData({
  4311. idx: 0,
  4312. sum: 20,
  4313. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4314. });
  4315. $scope.selected = {
  4316. items: {}
  4317. };
  4318. }]
  4319. });
  4320. //tab 列表
  4321. formlyConfigProvider.setType({
  4322. name: 'ui-cmdbtab',
  4323. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
  4324. wrapper: ['bootstrapHasError'],
  4325. defaultOptions: function(options, $scope) {
  4326. return {
  4327. templateOptions: {}
  4328. };
  4329. },
  4330. controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function($scope, api_user_data, i18nService, $modal, api_cmdb) {
  4331. $scope.memoryfilterDatashe = {
  4332. "idx": 0,
  4333. "sum": 10
  4334. }
  4335. $scope.myDataoneall = [];
  4336. var setAllInactive = function() {
  4337. angular.forEach($scope.workspaces, function(workspace) {
  4338. workspace.active = false;
  4339. });
  4340. };
  4341. //添加
  4342. var addNewWorkspace = function(name, contentUrl) {
  4343. var id = $scope.workspaces.length + 1;
  4344. $scope.workspaces.push({
  4345. id: id,
  4346. name: name,
  4347. active: true,
  4348. contentUrl: 'main/html/content.html'
  4349. });
  4350. };
  4351. //关闭
  4352. $scope.remove = function(closedata) {
  4353. event.preventDefault();
  4354. angular.forEach($scope.workspaces, function(item, index) {
  4355. if (closedata.id == item.id) {
  4356. if (closedata.id == 1) {
  4357. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  4358. } else {
  4359. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  4360. }
  4361. $scope.workspaces.splice(index, 1);
  4362. }
  4363. })
  4364. }
  4365. $scope.workspaces = [];
  4366. $scope.options.templateOptions.getpush = function(item) {
  4367. $scope.workspaces = [];
  4368. if (item.gu) {
  4369. $scope.workspaces.push({ id: 1, name: "领用设备", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html' })
  4370. }
  4371. if (item.hao) {
  4372. $scope.workspaces.push({ id: 2, name: "领用耗材", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' })
  4373. }
  4374. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4375. };
  4376. $scope.addWorkspace = function(contentUrl, name) {
  4377. setAllInactive();
  4378. addNewWorkspace(name, contentUrl);
  4379. };
  4380. // $rootScope.addWorkspace = $scope.addWorkspace;
  4381. // $scope.remove = function(idNumber) {
  4382. // var index = 0; //记录当前元素下标
  4383. // angular.forEach($scope.workspaces, function(workspace) {
  4384. // if (workspace.id === idNumber.id) {
  4385. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4386. // }
  4387. // index++;
  4388. // });
  4389. // };
  4390. // setInterval(function() {
  4391. // if ($scope.model.assets) {
  4392. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4393. // $scope.modelass = $scope.model.assets;
  4394. // if (JSON.stringify($scope.model.assets) == "{}") {
  4395. // $scope.model.assets = []
  4396. // } else {
  4397. // $scope.model.assets = JSON.parse($scope.model.assets);
  4398. // }
  4399. // $scope.myDatalingbeiall = $scope.model.assets;
  4400. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4401. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4402. // }
  4403. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4404. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4405. // }
  4406. // }
  4407. // if ($scope.model.consumables) {
  4408. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4409. // $scope.modelass = $scope.model.consumables;
  4410. // if (JSON.stringify($scope.model.consumables) == "{}") {
  4411. // $scope.model.consumables = [];
  4412. // } else {
  4413. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  4414. // }
  4415. // $scope.myDatalingbeiall = $scope.model.consumables;
  4416. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4417. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4418. // }
  4419. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  4420. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4421. // // $scope.model.consumables = $scope.myData2all;
  4422. // }
  4423. // }
  4424. // }, 100);
  4425. //grid1
  4426. $scope.langs = i18nService.getAllLangs();
  4427. $scope.lang = 'zh-cn';
  4428. i18nService.setCurrentLang($scope.lang);
  4429. $scope.gridOptions1 = {};
  4430. $scope.gridOptions1.data = 'myDatalingbei';
  4431. $scope.gridOptions1.enableColumnResizing = true;
  4432. $scope.gridOptions1.enableFiltering = false;
  4433. $scope.gridOptions1.enableGridMenu = false;
  4434. $scope.gridOptions1.showGridFooter = true;
  4435. $scope.gridOptions1.showColumnFooter = false;
  4436. $scope.gridOptions1.fastWatch = true;
  4437. $scope.gridOptions1.useExternalFiltering = true;
  4438. $scope.gridOptions1.useExternalPagination = true;
  4439. $scope.gridOptions1.paginationPageSizes = [10];
  4440. $scope.gridOptions1.paginationPageSize = 10;
  4441. $scope.gridOptions1.multiSelect = false;
  4442. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4443. $scope.gridOptions1.columnDefs = [
  4444. { name: 'item', displayName: '序号', width: 120 },
  4445. { name: 'props.hw_cifilterClassic', displayName: '设备类型', width: 150, enableFiltering: false },
  4446. { name: 'props.hw_mingcheng', displayName: '设备名称', width: 100, enableFiltering: false },
  4447. { name: 'uuid', displayName: '设备编号', enableFiltering: false }
  4448. ];
  4449. $scope.myDatalingbeiall = [];
  4450. $scope.gridOptions1.onRegisterApi = function(gridApi) {
  4451. $scope.gridApi = gridApi;
  4452. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  4453. // var filtersData = $scope.memoryfilterData;
  4454. // filtersData.idx = newPage - 1;
  4455. // filtersData.sum = pageSize;
  4456. // $scope.loadData(filtersData);
  4457. $scope.memoryfilterDatashe.idx = newPage - 1;
  4458. $scope.memoryfilterDatashe.sum = pageSize;
  4459. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
  4460. });
  4461. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  4462. $scope.selected.items = data.entity;
  4463. //console.log(data);
  4464. });
  4465. gridApi.selection.on.rowSelectionChangedBatch($scope, function(data) {
  4466. $scope.selected.items = data.entity;
  4467. //console.log(data);
  4468. });
  4469. gridApi.core.on.filterChanged($scope, function() {
  4470. var grid = this.grid;
  4471. var filtersData = {
  4472. idx: 0,
  4473. sum: 20,
  4474. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4475. };
  4476. angular.forEach(grid.columns, function(item) {
  4477. if (item.enableFiltering) {
  4478. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4479. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4480. if (angular.isUndefined(filtersData['user'])) {
  4481. filtersData['user'] = {};
  4482. }
  4483. filtersData['user'][item.field] = item.filters[0].term;
  4484. }
  4485. }
  4486. });
  4487. $scope.memoryfilterDatashe = filtersData;
  4488. // $scope.loadData(filtersData);
  4489. });
  4490. };
  4491. $scope.interceptMydata = function(mydate, idx, sum) {
  4492. return mydate.slice(idx * sum, (idx + 1) * sum)
  4493. }
  4494. $scope.removeshebei = function(item) {
  4495. event.preventDefault();
  4496. var modalInstance = $modal.open({
  4497. templateUrl: 'assets/views/delete.html',
  4498. controller: function($scope, $modalInstance, scope) {
  4499. $scope.title = '设备移除';
  4500. $scope.connect = '确定要移除此设备?';
  4501. $scope.consumptive = scope.selected.items;
  4502. $scope.ok = function() {
  4503. $modalInstance.close($scope.consumptive);
  4504. };
  4505. $scope.cancel = function() {
  4506. $modalInstance.dismiss('cancel');
  4507. };
  4508. },
  4509. size: 'sm',
  4510. resolve: {
  4511. scope: function() {
  4512. return $scope;
  4513. },
  4514. }
  4515. });
  4516. modalInstance.result.then(function(selectedItem) {
  4517. angular.forEach($scope.myDatalingbeiall, function(items, index) {
  4518. if (items.id == selectedItem.id) {
  4519. $scope.myDatalingbeiall.splice(index, 1);
  4520. }
  4521. })
  4522. // $scope.myData3.push(selectedItem);
  4523. $scope.model.consumables = $scope.myDatalingbeiall;
  4524. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
  4525. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4526. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4527. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
  4528. }
  4529. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4530. })
  4531. }
  4532. $scope.addshebei = function() {
  4533. event.preventDefault();
  4534. var modalInstance = $modal.open({
  4535. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  4536. controller: function($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
  4537. $scope.langs = i18nService.getAllLangs();
  4538. $scope.lang = 'zh-cn';
  4539. i18nService.setCurrentLang($scope.lang);
  4540. $scope.gridOptions = {};
  4541. $scope.gridOptions.data = 'myDatatwo';
  4542. $scope.gridOptions.enableColumnResizing = true;
  4543. $scope.gridOptions.enableFiltering = false;
  4544. $scope.gridOptions.enableGridMenu = false;
  4545. $scope.gridOptions.showGridFooter = true;
  4546. $scope.gridOptions.showColumnFooter = false;
  4547. $scope.gridOptions.fastWatch = true;
  4548. $scope.gridOptions.useExternalFiltering = true;
  4549. $scope.gridOptions.useExternalPagination = true;
  4550. $scope.gridOptions.paginationPageSizes = [10];
  4551. $scope.gridOptions.paginationPageSize = 10;
  4552. $scope.gridOptions.multiSelect = true;
  4553. $scope.gridOptions.rowIdentity = function(row) {
  4554. return row.id;
  4555. };
  4556. $scope.gridOptions.getRowIdentity = function(row) {
  4557. return row.id;
  4558. };
  4559. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4560. $scope.gridOptions.columnDefs = [
  4561. { name: 'item', displayName: '序号', width: 80, enableFiltering: false },
  4562. { name: 'uuid', displayName: '内部编号', width: 120 },
  4563. { name: 'props.hw_mingcheng', displayName: '资产名称', width: 100 },
  4564. { name: 'props.hw_cifilterClassic', displayName: '资产类型', width: 80, enableFiltering: false },
  4565. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  4566. { name: 'props.hw_state', displayName: '资产状态', width: 150, enableFiltering: false },
  4567. { name: 'props.hwnw_area', displayName: '资产地点', width: 130, enableFiltering: false },
  4568. { name: 'createtime', displayName: '申请时间', enableFiltering: false }
  4569. ];
  4570. // $scope.selectButtonClick
  4571. var defaultFilterData = {
  4572. // "assignee":2,
  4573. // "sign":"basehwitndl",
  4574. // "applicationForm": { "hw_state": "在线" },
  4575. "hw_state": "在库",
  4576. "idx": 0,
  4577. "sum": 10
  4578. };
  4579. $scope.memoryfilterData = {
  4580. // "assignee":2,
  4581. // "sign":"basehwitndl",
  4582. // "applicationForm": { "hw_state": "在线" },
  4583. "hw_state": "在库",
  4584. "idx": 0,
  4585. "sum": 10
  4586. }
  4587. $scope.refreshData = function(style, filterData) {
  4588. if (angular.isUndefined(filterData)) {
  4589. filterData = defaultFilterData;
  4590. }
  4591. $scope.myDatatwo = [];
  4592. // $scope.gridOptions['sum']=filterData.sum;
  4593. api_cmdb.query(filterData).then(function(data) {
  4594. // $scope.callsPending--;
  4595. var filterData = $scope.memoryfilterData;
  4596. var myDatatwo = Restangular.stripRestangular(data);
  4597. $scope.gridOptions['totalItems'] = data.total;
  4598. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  4599. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  4600. }
  4601. $scope.myDatatwo = myDatatwo.data.node;
  4602. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  4603. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  4604. }
  4605. }, function() {});
  4606. };
  4607. $scope.refreshData('expand-right', defaultFilterData);
  4608. $scope.gridOptions.onRegisterApi = function(gridApi) {
  4609. $scope.gridApi = gridApi;
  4610. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  4611. var filtersData = $scope.memoryfilterData;
  4612. filtersData.idx = newPage - 1;
  4613. filtersData.sum = pageSize;
  4614. // $scope.loadData(filtersData);
  4615. $scope.refreshData('expand-right', filtersData);
  4616. //console.log(pageSize);
  4617. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  4618. });
  4619. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  4620. // $scope.selected.items.push(data.entity);
  4621. //console.log(data);
  4622. gridApi.selection.on.rowSelectionChanged($scope, function(scope, ect) {
  4623. if (scope.isSelected) {
  4624. scope.grid.appScope.selected.items.push(scope.entity)
  4625. } else {
  4626. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  4627. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  4628. scope.grid.appScope.selected.items.splice(i, 1);
  4629. break;
  4630. }
  4631. }
  4632. }
  4633. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  4634. });
  4635. // });
  4636. gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
  4637. // $scope.selected.items = data.entity;
  4638. //console.log(data);
  4639. var selectitem = [];
  4640. selectitem = angular.copy($scope.selected.items);
  4641. for (var j = 0; j < rows.length; j++) {
  4642. if (rows[j].isSelected == true) {
  4643. selectitem.push(rows[j].entity);
  4644. } else {
  4645. delete selectitem[j];
  4646. // rows.splice(j, 1);
  4647. }
  4648. }
  4649. $scope.selected.items = [];
  4650. for (var i = 0; i < selectitem.length; i++) {
  4651. if (selectitem[i]) {
  4652. $scope.selected.items.push(selectitem[i]);
  4653. }
  4654. }
  4655. });
  4656. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  4657. // // if (row.entity.age > 45) {
  4658. // row.grid.api.selection.selectRow(row.entity); // 选中行
  4659. // // }
  4660. // };
  4661. gridApi.core.on.filterChanged($scope, function() {
  4662. var grid = this.grid;
  4663. var filtersData = {
  4664. idx: 0,
  4665. sum: 10,
  4666. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4667. };
  4668. angular.forEach(grid.columns, function(item) {
  4669. if (item.enableFiltering) {
  4670. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4671. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4672. if (angular.isUndefined(filtersData['user'])) {
  4673. filtersData['user'] = {};
  4674. }
  4675. filtersData['user'][item.field] = item.filters[0].term;
  4676. }
  4677. }
  4678. });
  4679. $scope.memoryfilterData = filtersData;
  4680. // $scope.loadData(filtersData);
  4681. });
  4682. };
  4683. $scope.onDblClick = function(data, event) {
  4684. // $scope.selected.items = data.entity;
  4685. $scope.selectButtonClick(data, event);
  4686. };
  4687. // $scope.loadData = function(filterData) {
  4688. // // console.log("filtersData=111" + JSON.stringify(filterData))
  4689. // items.fetchItems(filterData, APIService).then(function(data) {
  4690. // var myDatatwo = Restangular.stripRestangular(data);
  4691. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  4692. // $scope.myDatatwo = myDatatwo.list;
  4693. // });
  4694. // };
  4695. $scope.title = title;
  4696. //树形图
  4697. var apple_selected, tree, treedata_avm, treedata_geography;
  4698. $scope.my_tree_handler = function(branch) {
  4699. //var _ref;
  4700. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  4701. api_cmdb.query({ 'sign': classify }).then(function(data) {
  4702. var myDatalingbei = Restangular.stripRestangular(data);
  4703. // console.log(myData.data.node);
  4704. if (myDatalingbei.data && myDatalingbei.status == 200) {
  4705. var ret = myDatalingbei.data;
  4706. redrawSvg(myDatalingbei);
  4707. }
  4708. });
  4709. };
  4710. $scope.my_data = [];
  4711. function convertListToTree(data, treeMap) {
  4712. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  4713. var root = null; //Initially set our loop to null
  4714. var parentNode = null;
  4715. //loop over data
  4716. for (var i = 0; i < data.length; i++) {
  4717. var datum = data[i];
  4718. //each node will have children, so let's give it a "children" poperty
  4719. datum.children = [];
  4720. //add an entry for this node to the map so that any future children can
  4721. //lookup the parent
  4722. idToNodeMap[datum.id] = datum;
  4723. //Does this node have a parent?
  4724. if (typeof datum.parent === "undefined" || datum.parent === null) {
  4725. //Doesn't look like it, so this node is the root of the tree
  4726. root = datum;
  4727. treeMap[datum.id] = root;
  4728. } else {
  4729. //This node has a parent, so let's look it up using the id
  4730. parentNode = idToNodeMap[datum.parent.id];
  4731. //We don't need this property, so let's delete it.
  4732. delete datum.parent;
  4733. //Let's add the current node as a child of the parent node.
  4734. parentNode.children.push(datum);
  4735. }
  4736. }
  4737. return root;
  4738. }
  4739. function convertParentToChildList(data) {
  4740. var treeMap = {};
  4741. var list = [];
  4742. convertListToTree(data, treeMap);
  4743. angular.forEach(treeMap, function(item) {
  4744. list.push(item);
  4745. });
  4746. return list;
  4747. }
  4748. $scope.my_tree = tree = {};
  4749. $scope.try_async_load = function() {
  4750. $scope.my_data = [];
  4751. $scope.select_treedata = [];
  4752. $scope.doing_async = true;
  4753. api_configure_data.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
  4754. //console.log(result['list']);
  4755. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  4756. $scope.doing_async = false;
  4757. // tree.expand_all();
  4758. //console.log(treelist);
  4759. });
  4760. };
  4761. $scope.select_treedata = [];
  4762. $scope.propTypeOptions = [];
  4763. $scope.try_async_load();
  4764. $scope.onFilterremove = function(item) {
  4765. console.log(item)
  4766. }
  4767. $scope.searchdata = {};
  4768. $scope.clear = function() {
  4769. $scope.searchdata = {};
  4770. $scope.cifilter_classic = {};
  4771. $scope.try_async_load();
  4772. var fildata = {
  4773. idx: 0,
  4774. sum: 10,
  4775. 'hw_state': '在库'
  4776. }
  4777. $scope.memoryfilterData = fildata;
  4778. $scope.refreshData('expand-right', fildata);
  4779. }
  4780. $scope.cifilter_classic = {};
  4781. $scope.chiceIncident = function(item) {
  4782. var fildata = defaultFilterData;
  4783. // fildata.applicationForm = {};
  4784. // sign: basehwnwswt
  4785. if (item && item.id) {
  4786. var classify = item.prefix.toLowerCase() + item.sign;
  4787. fildata.sign = classify
  4788. }
  4789. $scope.gridOptions.paginationCurrentPage = 1;
  4790. var transitiondata = angular.copy(item);
  4791. $scope.refreshData('expand-right', fildata);
  4792. }
  4793. $scope.applicadata = [];
  4794. $scope.onFilterCallback = function(item) {
  4795. var tempclassify = item.prefix.toLowerCase() + item.sign;
  4796. api_configure_form.renderTabForm(tempclassify).then(function(data) {
  4797. var myData = Restangular.stripRestangular(data);
  4798. $scope.applicadata = myData[0].form.fields;
  4799. });
  4800. // }
  4801. }
  4802. // $scope.loadData({
  4803. // idx: 0,
  4804. // sum: 10,
  4805. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4806. // });
  4807. $scope.selected = {
  4808. items: []
  4809. };
  4810. $scope.ok = function() {
  4811. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  4812. // onDataCallback($scope.selected.item, parentScope);
  4813. // }
  4814. $modalInstance.close($scope.selected.items);
  4815. };
  4816. $scope.cancel = function() {
  4817. $modalInstance.dismiss('cancel');
  4818. };
  4819. },
  4820. size: 'lg',
  4821. resolve: {
  4822. items: function() {
  4823. return {
  4824. fetchItems: function(filterData, APIService) {
  4825. filterData = filterData || {};
  4826. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  4827. filterData = {
  4828. idx: 0,
  4829. sum: 10,
  4830. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4831. };
  4832. }
  4833. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  4834. }
  4835. };
  4836. },
  4837. title: function() {
  4838. return $scope.options.templateOptions.label;
  4839. },
  4840. Restangular: function() {
  4841. return $scope.options.templateOptions.Restangular;
  4842. },
  4843. APIService: function() {
  4844. return $scope.options.templateOptions.ApiService;
  4845. },
  4846. onDataCallback: function() {
  4847. return $scope.options.templateOptions.callback;
  4848. },
  4849. parentScope: function() {
  4850. return $scope.options.templateOptions.that;
  4851. }
  4852. }
  4853. });
  4854. modalInstance.result.then(function(selectedItem) {
  4855. // console.log(selectedItem);
  4856. // options.value(selectedItem);
  4857. var filterData = $scope.memoryfilterDatashe;
  4858. $scope.myDatalingbeiall = selectedItem;
  4859. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4860. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4861. $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
  4862. }
  4863. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4864. $scope.model.assets = $scope.myDatalingbeiall;
  4865. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
  4866. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  4867. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  4868. // }
  4869. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  4870. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  4871. // }
  4872. }, function() {
  4873. //console.log('Modal dismissed at: ' + new Date());
  4874. });
  4875. }
  4876. $scope.onDblClick = function(data, event) {
  4877. $scope.selectButtonClick(data, event);
  4878. };
  4879. // $scope.loadData = function(filterData) {};
  4880. $scope.title = title;
  4881. // $scope.loadData({
  4882. // idx: 0,
  4883. // sum: 20,
  4884. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4885. // });
  4886. $scope.selected = {
  4887. items: []
  4888. };
  4889. //grid2
  4890. $scope.langs = i18nService.getAllLangs();
  4891. $scope.lang = 'zh-cn';
  4892. i18nService.setCurrentLang($scope.lang);
  4893. $scope.gridOptions2 = {};
  4894. $scope.gridOptions2.data = 'myDataone';
  4895. $scope.gridOptions2.enableColumnResizing = true;
  4896. $scope.gridOptions2.enableFiltering = false;
  4897. $scope.gridOptions2.enableGridMenu = false;
  4898. $scope.gridOptions2.showGridFooter = true;
  4899. $scope.gridOptions2.showColumnFooter = false;
  4900. $scope.gridOptions2.fastWatch = true;
  4901. $scope.gridOptions2.useExternalFiltering = true;
  4902. $scope.gridOptions2.useExternalPagination = true;
  4903. $scope.gridOptions2.paginationPageSizes = [10];
  4904. $scope.gridOptions2.paginationPageSize = 10;
  4905. $scope.gridOptions2.multiSelect = false;
  4906. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4907. $scope.gridOptions2.columnDefs = [
  4908. { name: 'item', displayName: '序号', width: 120 },
  4909. { name: 'name', displayName: '耗材名称', width: 150, enableFiltering: false },
  4910. { name: 'model', displayName: '品牌/型号', width: 100, enableFiltering: false },
  4911. { name: 'Specifications', displayName: '规格', width: 150, enableFiltering: false },
  4912. { name: 'sum', displayName: '领用数量', enableFiltering: false }
  4913. ];
  4914. // $scope.selectButtonClick
  4915. $scope.gridOptions2.onRegisterApi = function(gridApi) {
  4916. $scope.gridApi = gridApi;
  4917. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  4918. // var filtersData = $scope.memoryfilterData;
  4919. // filtersData.idx = newPage - 1;
  4920. // filtersData.sum = pageSize;
  4921. // $scope.loadData(filtersData);
  4922. $scope.memoryfilterDatahao.idx = newPage - 1;
  4923. $scope.memoryfilterDatahao.sum = pageSize;
  4924. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
  4925. });
  4926. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  4927. $scope.selected.items.push(data.entity);
  4928. //console.log(data);
  4929. });
  4930. gridApi.selection.on.rowSelectionChangedBatch($scope, function(data) {
  4931. $scope.selected.items.push(data.entity);
  4932. //console.log(data);
  4933. });
  4934. gridApi.core.on.filterChanged($scope, function() {
  4935. var grid = this.grid;
  4936. var filtersData = {
  4937. idx: 0,
  4938. sum: 10,
  4939. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4940. };
  4941. angular.forEach(grid.columns, function(item) {
  4942. if (item.enableFiltering) {
  4943. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4944. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4945. if (angular.isUndefined(filtersData['user'])) {
  4946. filtersData['user'] = {};
  4947. }
  4948. filtersData['user'][item.field] = item.filters[0].term;
  4949. }
  4950. }
  4951. });
  4952. $scope.memoryfilterDatahao = filtersData;
  4953. $scope.loadData(filtersData);
  4954. });
  4955. };
  4956. $scope.removehaocai = function(item) {
  4957. event.preventDefault();
  4958. // var modalInstance = $modal.open({
  4959. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4960. // controller: function($scope, $modalInstance) {
  4961. // $scope.title = "修改耗材数量";
  4962. // $scope.consumptive = item;
  4963. // $scope.ok = function() {
  4964. // $modalInstance.close($scope.consumptive);
  4965. // };
  4966. // $scope.cancel = function() {
  4967. // $modalInstance.dismiss('cancel');
  4968. // };
  4969. // },
  4970. // size: 'sm'
  4971. // });
  4972. var modalInstance = $modal.open({
  4973. templateUrl: 'assets/views/delete.html',
  4974. controller: function($scope, $modalInstance, scope) {
  4975. $scope.title = '耗材移除';
  4976. $scope.connect = '确定要移除此设备?';
  4977. $scope.consumptive = scope.selected.items[0];
  4978. $scope.ok = function() {
  4979. $modalInstance.close($scope.consumptive);
  4980. };
  4981. $scope.cancel = function() {
  4982. $modalInstance.dismiss('cancel');
  4983. };
  4984. },
  4985. size: 'sm',
  4986. resolve: {
  4987. scope: function() {
  4988. return $scope;
  4989. },
  4990. }
  4991. });
  4992. modalInstance.result.then(function(selectedItem) {
  4993. // angular.forEach($scope.myData3, function(items, index) {
  4994. // if (items.id == selectedItem.id) {
  4995. // $scope.myData3[index] = selectedItem;
  4996. // }
  4997. // })
  4998. // $scope.model.applicationForm.consumables = $scope.myData3;
  4999. angular.forEach($scope.myDataoneall, function(items, index) {
  5000. if (items.id == selectedItem.id) {
  5001. $scope.myDataoneall.splice(index, 1);
  5002. }
  5003. })
  5004. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5005. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5006. }
  5007. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5008. $scope.model.consumables = $scope.myDataoneall;
  5009. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5010. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5011. $scope.selected = {
  5012. items: []
  5013. };
  5014. })
  5015. }
  5016. $scope.haocaiadd = function() {
  5017. event.preventDefault();
  5018. var modalInstance = $modal.open({
  5019. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  5020. controller: function($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  5021. $scope.haocainame = [];
  5022. $scope.pinpai = [];
  5023. $scope.guige = [];
  5024. $scope.consumptive = {};
  5025. $scope.consumpall = {};
  5026. $scope.title = "添加耗材";
  5027. api_wechatfile.getDictionaryForList({ "key": "haocaifenlei" }).then(function(data) {
  5028. $scope.haocainame = data;
  5029. })
  5030. $scope.clearNoNum = function(obj, attr) {
  5031. //先把非数字的都替换掉,除了数字和.
  5032. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5033. //必须保证第一个为数字而不是.
  5034. obj[attr] = obj[attr].replace(/^\./g, "");
  5035. //保证只有出现一个.而没有多个.
  5036. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5037. //保证.只出现一次,而不能出现两次以上
  5038. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  5039. //小于最大值
  5040. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5041. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5042. obj[attr] = '';
  5043. }
  5044. }
  5045. $scope.onChange = function(parent) {
  5046. $scope.consumptive.model = {};
  5047. $scope.consumptive.Specifications = {};
  5048. api_wechatfile.getDictionaryForList({ "key": "pinpai", "parent": parent.id }).then(function(data) {
  5049. $scope.pinpai = data;
  5050. })
  5051. api_wechatfile.getDictionaryForList({ "key": "guige", "parent": parent.id }).then(function(data) {
  5052. $scope.guige = data;
  5053. })
  5054. }
  5055. $scope.onChangesum = function(item) {
  5056. if (item.name && item.model.id && item.Specifications.id) {
  5057. $scope.consumptive.sum = "";
  5058. var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "brandModel": item.model.name, "specification": item.Specifications.name } }
  5059. api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5060. if (data.status == 200 && data.list.length > 0) {
  5061. var myData = data.list;
  5062. $scope.consumpall = myData[0];
  5063. $scope.maxsum = myData[0].inventoryNum;
  5064. } else {
  5065. SweetAlert.swal({
  5066. title: "不存在该耗材",
  5067. text: "请检查库存后重新填写!",
  5068. type: "error"
  5069. });
  5070. }
  5071. });
  5072. }
  5073. }
  5074. $scope.addhaocai = function() {
  5075. $modalInstance.dismiss('cancel');
  5076. scope.haocaiopen($scope.consumptive);
  5077. }
  5078. $scope.ok = function(item) {
  5079. var items = {};
  5080. // if (item.name && item.model && item.Specifications && item.sum) {
  5081. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5082. // $scope.consumpall.model = $scope.consumpall.brandModel;
  5083. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  5084. // $scope.consumpall.sum = item.sum;
  5085. // delete $scope.consumpall.brandModel;
  5086. // delete $scope.consumpall.specification;
  5087. // $modalInstance.close($scope.consumpall);
  5088. // } else {
  5089. // SweetAlert.swal({
  5090. // title: "数据填写不完整!",
  5091. // text: "请检查数据然后提交!",
  5092. // type: "error"
  5093. // });
  5094. // }
  5095. var isold = false;
  5096. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  5097. for (var i = 0; i < scope.myDataoneall.length; i++) {
  5098. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  5099. isold = true;
  5100. }
  5101. }
  5102. if (isold) {
  5103. SweetAlert.swal({
  5104. title: "该耗材已添加!",
  5105. text: "请不要重复添加耗材!",
  5106. type: "error"
  5107. });
  5108. } else {
  5109. $scope.consumpall.model = $scope.consumpall.brandModel;
  5110. $scope.consumpall.Specifications = $scope.consumpall.specification;
  5111. $scope.consumpall.sum = item.sum;
  5112. delete $scope.consumpall.brandModel;
  5113. delete $scope.consumpall.specification;
  5114. $modalInstance.close($scope.consumpall);
  5115. }
  5116. } else {
  5117. SweetAlert.swal({
  5118. title: "数据填写不完整!",
  5119. text: "请检查数据然后提交!",
  5120. type: "error"
  5121. });
  5122. }
  5123. // $modalInstance.close(item);
  5124. };
  5125. $scope.cancel = function() {
  5126. $modalInstance.dismiss('cancel');
  5127. };
  5128. },
  5129. size: 'sm',
  5130. resolve: {
  5131. scope: function() {
  5132. return $scope;
  5133. }
  5134. }
  5135. });
  5136. modalInstance.result.then(function(selectedItem) {
  5137. $scope.myDataoneall.push(selectedItem);
  5138. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5139. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5140. }
  5141. // $scope.model.consumables = $scope.myDataone;
  5142. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5143. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5144. $scope.model.consumables = $scope.myDataoneall;
  5145. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5146. })
  5147. }
  5148. $scope.onDblClick = function(data, event) {
  5149. $scope.selectButtonClick(data, event);
  5150. };
  5151. $scope.memoryfilterDatahao = {
  5152. "idx": 0,
  5153. "sum": 10,
  5154. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5155. }
  5156. $scope.myDataone = [];
  5157. $scope.loadData = function(filterData) {};
  5158. $scope.title = title;
  5159. $scope.ldloading = {};
  5160. $scope.selected = {
  5161. items: []
  5162. };
  5163. if ($scope.$parent.$parent.$parent.model.gettype) {
  5164. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  5165. if ($scope.model.assets) {
  5166. if (JSON.stringify($scope.model.assets) == "{}") {
  5167. $scope.model.assets = []
  5168. } else {
  5169. $scope.model.assets = JSON.parse($scope.model.assets);
  5170. }
  5171. $scope.myDatalingbeiall = $scope.model.assets;
  5172. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5173. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
  5174. }
  5175. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5176. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5177. }
  5178. if ($scope.model.consumables) {
  5179. if (JSON.stringify($scope.model.consumables) == "{}") {
  5180. $scope.model.consumables = []
  5181. } else {
  5182. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5183. }
  5184. $scope.myDataoneall = $scope.model.consumables;
  5185. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5186. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5187. }
  5188. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5189. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5190. }
  5191. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5192. $scope.options.templateOptions.getpush({ "hao": true, "gu": true });
  5193. } else {
  5194. $scope.options.templateOptions.getpush({ "hao": true });
  5195. }
  5196. } else {
  5197. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5198. $scope.options.templateOptions.getpush({ "gu": true });
  5199. }
  5200. }
  5201. }
  5202. }]
  5203. });
  5204. formlyConfigProvider.setType({
  5205. name: 'ui-panel',
  5206. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  5207. });
  5208. formlyConfigProvider.setType({
  5209. name: 'ui-currentuser',
  5210. extends: 'input',
  5211. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  5212. defaultOptions: function(options) {
  5213. return {
  5214. templateOptions: {
  5215. // link: function() {}
  5216. }
  5217. };
  5218. },
  5219. controller: ['$scope', function($scope) {
  5220. if ($scope.options.templateOptions.user) {
  5221. if (angular.isFunction($scope.options.templateOptions.transform)) {
  5222. if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  5223. $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  5224. }
  5225. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5226. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5227. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  5228. }
  5229. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  5230. $scope.options.initialValue = $scope.model[$scope.options.key];
  5231. }
  5232. }]
  5233. });
  5234. //仪表盘
  5235. //待处理变更列表
  5236. formlyConfigProvider.setType({
  5237. name: 'ui-ngpchangetable',
  5238. templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
  5239. defaultOptions: function(options) {
  5240. return {
  5241. templateOptions: {
  5242. // relationAction: function() {
  5243. // options.hideExpression = true
  5244. // }
  5245. }
  5246. };
  5247. },
  5248. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5249. // var filterData = {
  5250. // "assignee": $rootScope.user.id,
  5251. // "searchtype": "all",
  5252. // "idx": "0",
  5253. // "sum": "10"
  5254. // };
  5255. var filterData = { "idx": "0", "sum": "10", "assignee": 2, "searchType": "todo" }
  5256. $scope.incidentprocess = function(item) {
  5257. $state.go('app.wt_change.add', { taskId: item.taskId, processInstanceId: item.processInstanceId });
  5258. }
  5259. $scope.more = function() {
  5260. $state.go('app.wt_change.list', {})
  5261. }
  5262. api_bpm_domain.fetchtask('bpm_change', filterData).then(function(data) {
  5263. if (data.data) {
  5264. $scope.myData = data.data;
  5265. } else {
  5266. SweetAlert.swal({
  5267. title: "操作异常!",
  5268. text: "系统异常,请稍后重试,或者联系管理员!",
  5269. type: "error"
  5270. });
  5271. }
  5272. })
  5273. $scope.removes = function() {
  5274. var modalInstance = $modal.open({
  5275. templateUrl: 'assets/views/delete.html',
  5276. controller: function($scope, $modalInstance) {
  5277. $scope.ok = function() {
  5278. $modalInstance.close();
  5279. };
  5280. $scope.cancel = function() {
  5281. $modalInstance.dismiss('cancel');
  5282. };
  5283. },
  5284. size: 'sm'
  5285. });
  5286. modalInstance.result.then(function() {
  5287. console.log($scope.$parent.$parent.$parent.$parent)
  5288. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5289. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5290. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5291. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5292. break;
  5293. }
  5294. }
  5295. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5296. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5297. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5298. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5299. }
  5300. })
  5301. }
  5302. }]
  5303. });
  5304. //待处理问题列表
  5305. formlyConfigProvider.setType({
  5306. name: 'ui-ngproblemtable',
  5307. templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
  5308. defaultOptions: function(options) {
  5309. return {
  5310. templateOptions: {
  5311. // relationAction: function() {
  5312. // options.hideExpression = true
  5313. // }
  5314. }
  5315. };
  5316. },
  5317. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
  5318. var filterData = {
  5319. "assignee": $rootScope.user.id,
  5320. "candidateGroups": $rootScope.user.group[0].id,
  5321. "searchtype": "todo",
  5322. "idx": 0,
  5323. "sum": 10
  5324. };
  5325. $scope.incidentprocess = function(item) {
  5326. $state.go('app.wt_change.add', { taskId: item.taskId, processInstanceId: item.processInstanceId });
  5327. }
  5328. $scope.more = function() {
  5329. $state.go('app.wt_change.list', {})
  5330. }
  5331. api_bpm_data.fetchDataList('changeclassify', filterData).then(function(data) {
  5332. if (data.data) {
  5333. $scope.myData = data.data;
  5334. } else {
  5335. SweetAlert.swal({
  5336. title: "操作异常!",
  5337. text: "系统异常,请稍后重试,或者联系管理员!",
  5338. type: "error"
  5339. });
  5340. }
  5341. })
  5342. $scope.removes = function() {
  5343. var modalInstance = $modal.open({
  5344. templateUrl: 'assets/views/delete.html',
  5345. controller: function($scope, $modalInstance) {
  5346. $scope.ok = function() {
  5347. $modalInstance.close();
  5348. };
  5349. $scope.cancel = function() {
  5350. $modalInstance.dismiss('cancel');
  5351. };
  5352. },
  5353. size: 'sm'
  5354. });
  5355. modalInstance.result.then(function() {
  5356. console.log($scope.$parent.$parent.$parent.$parent)
  5357. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5358. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5359. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5360. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5361. break;
  5362. }
  5363. }
  5364. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5365. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5366. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5367. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5368. }
  5369. })
  5370. }
  5371. }]
  5372. });
  5373. //待处理事件列表
  5374. formlyConfigProvider.setType({
  5375. name: 'ui-ngtable',
  5376. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  5377. defaultOptions: function(options) {
  5378. return {
  5379. templateOptions: {
  5380. // relationAction: function() {
  5381. // options.hideExpression = true
  5382. // }
  5383. }
  5384. };
  5385. },
  5386. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5387. var filterData = {
  5388. "assignee": $rootScope.user.id,
  5389. "candidateGroups": $rootScope.user.group[0].id,
  5390. "searchtype": "done",
  5391. "idx": 0,
  5392. "sum": 10
  5393. };
  5394. $scope.incidentprocess = function(item) {
  5395. $state.go('app.incident.editor', { taskId: item.taskId, processInstanceId: item.processInstanceId });
  5396. }
  5397. $scope.more = function() {
  5398. $state.go('app.incident.list', {})
  5399. }
  5400. api_bpm_domain.fetchtask('bpm_incident', filterData).then(function(data) {
  5401. if (data.data) {
  5402. $scope.myData = data.data;
  5403. } else {
  5404. SweetAlert.swal({
  5405. title: "操作异常!",
  5406. text: "系统异常,请稍后重试,或者联系管理员!",
  5407. type: "error"
  5408. });
  5409. }
  5410. })
  5411. $scope.removes = function() {
  5412. var modalInstance = $modal.open({
  5413. templateUrl: 'assets/views/delete.html',
  5414. controller: function($scope, $modalInstance) {
  5415. $scope.ok = function() {
  5416. $modalInstance.close();
  5417. };
  5418. $scope.cancel = function() {
  5419. $modalInstance.dismiss('cancel');
  5420. };
  5421. },
  5422. size: 'sm'
  5423. });
  5424. modalInstance.result.then(function() {
  5425. console.log($scope.$parent.$parent.$parent.$parent)
  5426. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5427. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5428. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5429. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5430. break;
  5431. }
  5432. }
  5433. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5434. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5435. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5436. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5437. }
  5438. })
  5439. }
  5440. }]
  5441. });
  5442. //知识库列表
  5443. formlyConfigProvider.setType({
  5444. name: 'ui-knowledge',
  5445. templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
  5446. defaultOptions: function(options) {
  5447. return {
  5448. templateOptions: {
  5449. // relationAction: function() {
  5450. // options.hideExpression = true
  5451. // }
  5452. }
  5453. };
  5454. },
  5455. controller: ['$scope', '$modal', '$timeout', 'api_solution','api_zsk', '$rootScope', 'ngTableParams', '$filter', '$state', function($scope, $modal, $timeout, api_solution,api_zsk, $rootScope, ngTableParams, $filter, $state) {
  5456. var filterData = {
  5457. "key": "null",
  5458. "pageIndex": 0,
  5459. "pageSum": 6,
  5460. "status": 0,
  5461. "userId": $rootScope.user.id
  5462. };
  5463. $scope.model.removereport = false;
  5464. $scope.removes = function() {
  5465. $scope.model.removereport = true;
  5466. }
  5467. $scope.more = function() {
  5468. $state.go('app.knowledge.manager', {});
  5469. }
  5470. var jry_filterData={
  5471. idx:0,
  5472. sum:10,
  5473. solution:{
  5474. keywords:"",
  5475. solutionType:{id:""},
  5476. status:{id:72}
  5477. }
  5478. }
  5479. // api_solution.findSolutionByKeys(filterData).then(function(data) {
  5480. // if (data.status == 200) {
  5481. // $scope.myData = data.list
  5482. // }
  5483. // })
  5484. api_zsk.jry_get_list(jry_filterData,"solution").then(function(data) {
  5485. if (data.status == 200) {
  5486. $scope.myData = data.list
  5487. }
  5488. })
  5489. $scope.removes = function() {
  5490. var modalInstance = $modal.open({
  5491. templateUrl: 'assets/views/delete.html',
  5492. controller: function($scope, $modalInstance) {
  5493. $scope.ok = function() {
  5494. $modalInstance.close();
  5495. };
  5496. $scope.cancel = function() {
  5497. $modalInstance.dismiss('cancel');
  5498. };
  5499. },
  5500. size: 'sm'
  5501. });
  5502. modalInstance.result.then(function() {
  5503. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5504. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5505. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5506. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5507. break;
  5508. }
  5509. }
  5510. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5511. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5512. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5513. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5514. }
  5515. })
  5516. }
  5517. }]
  5518. });
  5519. //公告列表
  5520. formlyConfigProvider.setType({
  5521. name: 'ui-ngnotice',
  5522. templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
  5523. defaultOptions: function(options) {
  5524. return {
  5525. templateOptions: {
  5526. // relationAction: function() {
  5527. // options.hideExpression = true
  5528. // }
  5529. }
  5530. };
  5531. },
  5532. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
  5533. var filterData = {
  5534. "idx": 0,
  5535. "sum": 10
  5536. };
  5537. // $scope.$scope.model.className = "col-xs-12";
  5538. api_user_data.fetchDataList('notice', filterData).then(function(data) {
  5539. if (data) {
  5540. $scope.myData = data.data;
  5541. } else {
  5542. SweetAlert.swal({
  5543. title: "操作异常!",
  5544. text: "系统异常,请稍后重试,或者联系管理员!",
  5545. type: "error"
  5546. });
  5547. }
  5548. })
  5549. $scope.more = function() {
  5550. $state.go('app.system.notice.list', {});
  5551. }
  5552. $scope.removes = function() {
  5553. var modalInstance = $modal.open({
  5554. templateUrl: 'assets/views/delete.html',
  5555. controller: function($scope, $modalInstance) {
  5556. $scope.ok = function() {
  5557. $modalInstance.close();
  5558. };
  5559. $scope.cancel = function() {
  5560. $modalInstance.dismiss('cancel');
  5561. };
  5562. },
  5563. size: 'sm'
  5564. });
  5565. modalInstance.result.then(function() {
  5566. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5567. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5568. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5569. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5570. break;
  5571. }
  5572. }
  5573. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5574. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5575. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5576. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5577. }
  5578. })
  5579. }
  5580. }]
  5581. });
  5582. //事件统计图
  5583. formlyConfigProvider.setType({
  5584. name: 'ui-incidentreport',
  5585. templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
  5586. defaultOptions: function(options) {
  5587. return {
  5588. templateOptions: {
  5589. // relationAction: function() {
  5590. // options.hideExpression = true
  5591. // }
  5592. }
  5593. };
  5594. },
  5595. controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function($scope, $modal, moment, api_report, $cookieStore) {
  5596. // api_report.getLicenseKey().then(function(response) {
  5597. // $cookieStore.put('Auth-Token', response.token);
  5598. // $scope.try_async_load();
  5599. // });
  5600. $scope.try_async_load = function() {
  5601. $scope.my_data = [];
  5602. api_report.list().then(function(response) {
  5603. var dataList = response;
  5604. getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
  5605. $scope.repoRoot.name = "事件报表"
  5606. convertRepoObject($scope.repoRoot);
  5607. $scope.my_data.push($scope.repoRoot);
  5608. });
  5609. };
  5610. var workspace = {};
  5611. $scope.repoRoot = null;
  5612. function getRepoRoot(repo, path) {
  5613. angular.forEach(repo, function(value, key) {
  5614. if (value.path == path) {
  5615. $scope.repoRoot = value;
  5616. } else {
  5617. if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
  5618. getRepoRoot(value.repoObjects, path);
  5619. } else {
  5620. }
  5621. }
  5622. });
  5623. }
  5624. function convertRepoObject(repo) {
  5625. if (angular.isArray(repo)) {
  5626. angular.forEach(repo, function(value, key) {
  5627. convertRepoObject(value);
  5628. })
  5629. } else {
  5630. if (angular.isDefined(repo.name)) {
  5631. if (repo.name.indexOf(".") >= 0) {
  5632. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  5633. } else {
  5634. repo.label = repo.name;
  5635. }
  5636. //delete repo.name;
  5637. }
  5638. if (angular.isDefined(repo.repoObjects)) {
  5639. repo.children = [];
  5640. repo.children = repo.repoObjects;
  5641. delete repo.repoObjects;
  5642. convertRepoObject(repo.children);
  5643. }
  5644. }
  5645. }
  5646. function parseDateParameter(parameters) {
  5647. var result = undefined;
  5648. if (angular.isArray(parameters)) {
  5649. // angular.forEach(parmeters,function(param){
  5650. // param.
  5651. // })
  5652. } else {
  5653. result = {};
  5654. for (var k in parameters) {
  5655. if (k.indexOf("Date") > 0) {
  5656. if (angular.isString(parameters[k])) {
  5657. result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
  5658. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  5659. }
  5660. }
  5661. }
  5662. }
  5663. return result;
  5664. }
  5665. function ConvertDateParameter(parameters) {
  5666. var result = undefined;
  5667. if (angular.isArray(parameters)) {
  5668. //
  5669. } else {
  5670. result = {};
  5671. for (var k in parameters) {
  5672. if (k.indexOf("Date") > 0) {
  5673. if (angular.isDate(parameters[k])) {
  5674. result[k] = moment(parameters[k]).format("YYYYMMDD");
  5675. } else if (angular.isString(parameters[k])) {
  5676. result[k] = parameters[k];
  5677. }
  5678. }
  5679. }
  5680. }
  5681. return result;
  5682. }
  5683. var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  5684. var queryUUID;
  5685. function genUUID() {
  5686. var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
  5687. function(c) {
  5688. var r = Math.random() * 16 | 0,
  5689. v = c == 'x' ? r : (r & 0x3 | 0x8);
  5690. return v.toString(16);
  5691. }).toUpperCase();
  5692. return uuid;
  5693. }
  5694. queryUUID = genUUID();
  5695. var pathincidenttimekey = [];
  5696. var incidenttime = {
  5697. 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
  5698. 'endtimes': moment(new Date()).format('YYYYMMDD')
  5699. };
  5700. var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
  5701. var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
  5702. var averages = [
  5703. [thisdaymine - 86400000 * 14, 0],
  5704. [thisdaymine - 86400000 * 13, 0],
  5705. [thisdaymine - 86400000 * 12, 0],
  5706. [thisdaymine - 86400000 * 11, 0],
  5707. [thisdaymine - 86400000 * 10, 0],
  5708. [thisdaymine - 86400000 * 9, 0],
  5709. [thisdaymine - 86400000 * 8, 0],
  5710. [thisdaymine - 86400000 * 7, 0],
  5711. [thisdaymine - 86400000 * 6, 0],
  5712. [thisdaymine - 86400000 * 5, 0],
  5713. [thisdaymine - 86400000 * 4, 0],
  5714. [thisdaymine - 86400000 * 3, 0],
  5715. [thisdaymine - 86400000 * 2, 0],
  5716. [thisdaymine - 86400000 * 1, 0],
  5717. [thisdaymine, 0]
  5718. ];
  5719. // var getreportdata = function(incidenttime, path) {
  5720. // api_report.getMdx(path, queryUUID).then(function(response) {
  5721. // var mdxquery = response;
  5722. // workspace.query = mdxquery;
  5723. // workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  5724. // workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  5725. // $scope.parameters = parseDateParameter(workspace.query.parameters);
  5726. // weekuser(mdxquery);
  5727. // });
  5728. // }
  5729. // getreportdata(incidenttime, incidentchart);
  5730. var weekuser = function(mdxquery) {
  5731. var key = [];
  5732. api_report.execute(mdxquery).then(function(data) {
  5733. $scope.rheaders = [];
  5734. $scope.rRows = [];
  5735. var reportData = data;
  5736. if (reportData.cellset == null || reportData.cellset.length == 0) {
  5737. $scope.shows = true;
  5738. $scope.empty = "数据为空!"
  5739. } else {
  5740. angular.forEach(reportData.cellset, function(item, i) {
  5741. angular.forEach(averages, function(index, j) {
  5742. // angular.forEach(averages, function(item, index) {
  5743. if (item.length > 1 && i > 0 && item[1].value != '') {
  5744. if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
  5745. index[1] = Number(item[1].value);
  5746. }
  5747. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  5748. }
  5749. // })
  5750. })
  5751. })
  5752. incidentchartfun(averages);
  5753. }
  5754. })
  5755. }
  5756. var incidentchartfun = function(incidentchartkey) {
  5757. // $scope.isMaskincident = false;
  5758. Highcharts.chart('incidentchart', {
  5759. title: {
  5760. text: '事件近15天趋势图'
  5761. },
  5762. xAxis: {
  5763. type: 'datetime',
  5764. labels: {
  5765. align: 'left',
  5766. step: 1
  5767. }
  5768. },
  5769. yAxis: {
  5770. title: {
  5771. text: null
  5772. }
  5773. },
  5774. tooltip: {
  5775. crosshairs: true,
  5776. shared: true,
  5777. valueSuffix: '条'
  5778. },
  5779. legend: {},
  5780. series: [{
  5781. name: '生成事件',
  5782. data: incidentchartkey,
  5783. zIndex: 1,
  5784. marker: {
  5785. fillColor: 'white',
  5786. lineWidth: 2,
  5787. lineColor: Highcharts.getOptions().colors[0]
  5788. }
  5789. }]
  5790. });
  5791. }
  5792. $scope.data = {
  5793. labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
  5794. datasets: [{
  5795. label: '新增事件数量',
  5796. fillColor: 'rgba(220,220,220,0.2)',
  5797. strokeColor: 'rgba(220,220,220,1)',
  5798. pointColor: 'rgba(220,220,220,1)',
  5799. pointStrokeColor: '#fff',
  5800. pointHighlightFill: '#fff',
  5801. pointHighlightStroke: 'rgba(220,220,220,1)',
  5802. data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
  5803. },
  5804. {
  5805. label: '已解决事件数量',
  5806. fillColor: 'rgba(151,187,205,0.2)',
  5807. strokeColor: 'rgba(151,187,205,1)',
  5808. pointColor: 'rgba(151,187,205,1)',
  5809. pointStrokeColor: '#fff',
  5810. pointHighlightFill: '#fff',
  5811. pointHighlightStroke: 'rgba(151,187,205,1)',
  5812. data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
  5813. }
  5814. ]
  5815. };
  5816. $scope.removes = function() {
  5817. var modalInstance = $modal.open({
  5818. templateUrl: 'assets/views/delete.html',
  5819. controller: function($scope, $modalInstance) {
  5820. $scope.ok = function() {
  5821. $modalInstance.close();
  5822. };
  5823. $scope.cancel = function() {
  5824. $modalInstance.dismiss('cancel');
  5825. };
  5826. },
  5827. size: 'sm'
  5828. });
  5829. modalInstance.result.then(function() {
  5830. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5831. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5832. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5833. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5834. break;
  5835. }
  5836. }
  5837. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5838. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5839. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5840. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5841. }
  5842. })
  5843. }
  5844. var addDatas = 0;
  5845. var resolve = 0;
  5846. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  5847. addDatas = addDatas + $scope.data.datasets[0].data[i];
  5848. }
  5849. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  5850. resolve = resolve + $scope.data.datasets[1].data[i];
  5851. }
  5852. $scope.resolution = (resolve / addDatas * 100).toFixed(2);
  5853. $scope.opt = {
  5854. maintainAspectRatio: false,
  5855. // Sets the chart to be responsive
  5856. responsive: true,
  5857. ///Boolean - Whether grid lines are shown across the chart
  5858. scaleShowGridLines: true,
  5859. //String - Colour of the grid lines
  5860. scaleGridLineColor: 'rgba(0,0,0,.05)',
  5861. //Number - Width of the grid lines
  5862. scaleGridLineWidth: 1,
  5863. //Boolean - Whether the line is curved between points
  5864. bezierCurve: false,
  5865. //Number - Tension of the bezier curve between points
  5866. bezierCurveTension: 0.4,
  5867. //Boolean - Whether to show a dot for each point
  5868. pointDot: true,
  5869. //Number - Radius of each point dot in pixels
  5870. pointDotRadius: 4,
  5871. //Number - Pixel width of point dot stroke
  5872. pointDotStrokeWidth: 1,
  5873. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  5874. pointHitDetectionRadius: 20,
  5875. //Boolean - Whether to show a stroke for datasets
  5876. datasetStroke: true,
  5877. //Number - Pixel width of dataset stroke
  5878. datasetStrokeWidth: 2,
  5879. //Boolean - Whether to fill the dataset with a colour
  5880. datasetFill: true,
  5881. // Function - on animation progress
  5882. onAnimationProgress: function() {},
  5883. // Function - on animation complete
  5884. onAnimationComplete: function() {},
  5885. //String - A legend template
  5886. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  5887. };
  5888. angular.extend($scope.options, $scope.opt)
  5889. $scope.datamonth = {
  5890. labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
  5891. datasets: [{
  5892. label: '新增事件数量',
  5893. fillColor: 'rgba(220,220,220,0.5)',
  5894. strokeColor: 'rgba(220,220,220,0.8)',
  5895. highlightFill: 'rgba(220,220,220,0.75)',
  5896. highlightStroke: 'rgba(220,220,220,1)',
  5897. data: [65, 59, 80, 81, 56, 55]
  5898. },
  5899. {
  5900. label: '已解决事件数量',
  5901. fillColor: 'rgba(151,187,205,0.5)',
  5902. strokeColor: 'rgba(151,187,205,0.8)',
  5903. highlightFill: 'rgba(151,187,205,0.75)',
  5904. highlightStroke: 'rgba(151,187,205,1)',
  5905. data: [28, 48, 40, 19, 86, 27]
  5906. }
  5907. ]
  5908. };
  5909. // Chart.js Options
  5910. $scope.taption = {
  5911. maintainAspectRatio: false,
  5912. // Sets the chart to be responsive
  5913. responsive: true,
  5914. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  5915. scaleBeginAtZero: true,
  5916. //Boolean - Whether grid lines are shown across the chart
  5917. scaleShowGridLines: true,
  5918. //String - Colour of the grid lines
  5919. scaleGridLineColor: "rgba(0,0,0,.05)",
  5920. //Number - Width of the grid lines
  5921. scaleGridLineWidth: 1,
  5922. //Boolean - If there is a stroke on each bar
  5923. barShowStroke: true,
  5924. //Number - Pixel width of the bar stroke
  5925. barStrokeWidth: 2,
  5926. //Number - Spacing between each of the X value sets
  5927. barValueSpacing: 5,
  5928. //Number - Spacing between data sets within X values
  5929. barDatasetSpacing: 1,
  5930. //String - A legend template
  5931. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  5932. };
  5933. }]
  5934. });
  5935. //排版日历
  5936. formlyConfigProvider.setType({
  5937. name: 'ui-dashcalendar',
  5938. templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
  5939. defaultOptions: function(options) {
  5940. return {
  5941. templateOptions: {
  5942. // relationAction: function() {
  5943. // options.hideExpression = true
  5944. // }
  5945. }
  5946. };
  5947. },
  5948. controller: ["$rootScope", "$scope", "$modal", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", "$state", function($rootScope, $scope, $modal, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data, $state) {
  5949. var loginUser = $rootScope.user;
  5950. calendarConfig.dateFormatter = 'moment';
  5951. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  5952. calendarConfig.i18nStrings.timeLabel = '时间';
  5953. calendarConfig.i18nStrings.weekNumber = '{week}周';
  5954. calendarConfig.allDateFormats = {
  5955. angular: {
  5956. date: {
  5957. hour: 'ha',
  5958. day: 'd MMM',
  5959. month: 'MMMM',
  5960. weekDay: 'EEEE',
  5961. time: 'HH:mm',
  5962. datetime: 'MMM d, h:mm a'
  5963. },
  5964. title: {
  5965. day: 'yyyy MMMM EEEE d',
  5966. week: '{year}年第{week}周',
  5967. month: 'yyyy MMMM',
  5968. year: 'yyyy'
  5969. }
  5970. },
  5971. moment: {
  5972. date: {
  5973. hour: 'ha',
  5974. day: 'MMMDD日',
  5975. month: 'MMMM',
  5976. weekDay: 'dddd',
  5977. time: 'HH:mm',
  5978. datetime: 'MMM D, h:mm a'
  5979. },
  5980. title: {
  5981. day: 'YYYY年MMMMDD日, dddd ',
  5982. week: '{year}年第{week}周',
  5983. month: 'YYYY年MMMM',
  5984. year: 'YYYY'
  5985. }
  5986. }
  5987. };
  5988. moment.locale('zh_cn', {
  5989. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  5990. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  5991. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  5992. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  5993. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  5994. longDateFormat: {
  5995. LT: 'Ah点mm分',
  5996. LTS: 'Ah点m分s秒',
  5997. L: 'YYYY-MM-DD',
  5998. LL: 'YYYY年MMMD日',
  5999. LLL: 'YYYY年MMMD日Ah点mm分',
  6000. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  6001. l: 'YYYY-MM-DD',
  6002. ll: 'YYYY年MMMD日',
  6003. lll: 'YYYY年MMMD日Ah点mm分',
  6004. llll: 'YYYY年MMMD日ddddAh点mm分'
  6005. },
  6006. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6007. meridiemHour: function(hour, meridiem) {
  6008. if (hour === 12) {
  6009. hour = 0;
  6010. }
  6011. if (meridiem === '凌晨' || meridiem === '早上' ||
  6012. meridiem === '上午') {
  6013. return hour;
  6014. } else if (meridiem === '下午' || meridiem === '晚上') {
  6015. return hour + 12;
  6016. } else {
  6017. // '中午'
  6018. return hour >= 11 ? hour : hour + 12;
  6019. }
  6020. },
  6021. meridiem: function(hour, minute, isLower) {
  6022. var hm = hour * 100 + minute;
  6023. if (hm < 600) {
  6024. return '凌晨';
  6025. } else if (hm < 900) {
  6026. return '早上';
  6027. } else if (hm < 1130) {
  6028. return '上午';
  6029. } else if (hm < 1230) {
  6030. return '中午';
  6031. } else if (hm < 1800) {
  6032. return '下午';
  6033. } else {
  6034. return '晚上';
  6035. }
  6036. },
  6037. calendar: {
  6038. sameDay: function() {
  6039. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  6040. },
  6041. nextDay: function() {
  6042. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  6043. },
  6044. lastDay: function() {
  6045. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  6046. },
  6047. nextWeek: function() {
  6048. var startOfWeek, prefix;
  6049. startOfWeek = moment().startOf('week');
  6050. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  6051. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6052. },
  6053. lastWeek: function() {
  6054. var startOfWeek, prefix;
  6055. startOfWeek = moment().startOf('week');
  6056. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  6057. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6058. },
  6059. sameElse: 'LL'
  6060. },
  6061. ordinalParse: /\d{1,2}(日|月|周)/,
  6062. ordinal: function(number, period) {
  6063. switch (period) {
  6064. case 'd':
  6065. case 'D':
  6066. case 'DDD':
  6067. return number + '日';
  6068. case 'M':
  6069. return number + '月';
  6070. case 'w':
  6071. case 'W':
  6072. return number + '周';
  6073. default:
  6074. return number;
  6075. }
  6076. },
  6077. relativeTime: {
  6078. future: '%s内',
  6079. past: '%s前',
  6080. s: '几秒',
  6081. m: '1 分钟',
  6082. mm: '%d 分钟',
  6083. h: '1 小时',
  6084. hh: '%d 小时',
  6085. d: '1 天',
  6086. dd: '%d 天',
  6087. M: '1 个月',
  6088. MM: '%d 个月',
  6089. y: '1 年',
  6090. yy: '%d 年'
  6091. },
  6092. week: {
  6093. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6094. dow: 1, // Monday is the first day of the week.
  6095. doy: 4 // The week that contains Jan 4th is the first week of the year.
  6096. }
  6097. });
  6098. var date = new Date();
  6099. var d = date.getDate();
  6100. var m = date.getMonth();
  6101. var y = date.getFullYear();
  6102. var filterData = {
  6103. "userId": loginUser.id,
  6104. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  6105. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  6106. };
  6107. var load = $scope.load = function(filterData) {
  6108. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response) {
  6109. if (response.status == 200) {
  6110. $scope.events = [];
  6111. var myData = response.list;
  6112. angular.forEach(myData, function(item) {
  6113. var eventTemp = {};
  6114. eventTemp.title = item.description;
  6115. eventTemp.type = item.scheduleClass.code;
  6116. eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
  6117. eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
  6118. eventTemp.startTime = item['scheduleOrderDTO'].startTime;
  6119. eventTemp.endTime = item['scheduleOrderDTO'].endTime;
  6120. //eventTemp.ends_at = moment(item.endTime).toDate();
  6121. eventTemp.id = item.id;
  6122. eventTemp.deletable = false;
  6123. eventTemp.user = item.user;
  6124. $scope.events.push(eventTemp);
  6125. })
  6126. }
  6127. });
  6128. }
  6129. // var load = $scope.load = function(filterData){
  6130. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  6131. // console.log("response="+JSON.stringify(response));
  6132. // if(response.status==200){
  6133. // $scope.events = [];
  6134. // console.log(response.list);
  6135. // var myData = response.list;
  6136. // angular.forEach(myData,function(item){
  6137. // var eventTemp = {};
  6138. // eventTemp.title = item.description;
  6139. // eventTemp.type = item.scheduleClass.code;
  6140. // eventTemp.startsAt = moment(item.startTime).toDate();
  6141. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  6142. // eventTemp.startTime = item.startTime;
  6143. // eventTemp.endTime = item.endTime;
  6144. // //eventTemp.ends_at = moment(item.endTime).toDate();
  6145. // eventTemp.id = item.id;
  6146. // eventTemp.deletable = false;
  6147. // eventTemp.users = item.users;
  6148. // $scope.events.push(eventTemp);
  6149. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  6150. // })
  6151. // }
  6152. // });
  6153. // }
  6154. $scope.scheduleClass = {};
  6155. var convertEvent = function(scheduleorder) {
  6156. var eventTemp = {};
  6157. eventTemp.title = scheduleorder.description;
  6158. eventTemp.type = scheduleorder.scheduleClass.code;
  6159. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  6160. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  6161. eventTemp.id = scheduleorder.id;
  6162. eventTemp.user = scheduleorder.user;
  6163. eventTemp.deletable = false;
  6164. return eventTemp;
  6165. }
  6166. // var convertEvent = function(scheduleorder){
  6167. // var eventTemp = {};
  6168. // eventTemp.title = scheduleorder.description;
  6169. // eventTemp.type = scheduleorder.scheduleClass.code;
  6170. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  6171. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  6172. // eventTemp.id = scheduleorder.id;
  6173. // eventTemp.users = scheduleorder.users;
  6174. // eventTemp.deletable = false;
  6175. // return eventTemp;
  6176. // }
  6177. api_bpm_schedule.getScheduleClass().then(function(response) {
  6178. if (response.status == 200) {
  6179. var scheduleClassList = response.list;
  6180. angular.forEach(scheduleClassList, function(item) {
  6181. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  6182. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  6183. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  6184. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  6185. $scope.scheduleClass[item['code']] = item;
  6186. })
  6187. }
  6188. })
  6189. $scope.events = [];
  6190. $scope.calendarView = 'month';
  6191. //$scope.calendarDay = new Date();
  6192. $scope.calendarDate = moment().startOf('month').toDate();
  6193. $scope.timeLabel = "时间";
  6194. $scope.eventLabel = "描述";
  6195. function showModal(action, event) {
  6196. // console.log("action="+JSON.stringify(action))
  6197. var modalInstance = $aside.open({
  6198. templateUrl: 'scheduleEvent.html',
  6199. placement: 'right',
  6200. size: 'sm',
  6201. backdrop: true,
  6202. controller: function($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  6203. $scope.$modalInstance = $modalInstance;
  6204. $scope.action = action;
  6205. $scope.event = event;
  6206. $scope.scheduleClassic = scheduleClass;
  6207. $scope.$watch('event.type', function(newvalue, oldvalue) {
  6208. // if(oldvalue == newvalue) return;
  6209. // if(scheduleClass[newvalue]){
  6210. var sm = MementFormat(scheduleClass[newvalue].startTime);
  6211. var em = MementFormat(scheduleClass[newvalue].endTime);
  6212. console.log("sm=" + JSON.stringify(sm))
  6213. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  6214. console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  6215. if (sm.hour() > em.hour()) {
  6216. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6217. console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  6218. } else {
  6219. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6220. console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  6221. }
  6222. // }
  6223. });
  6224. // $scope.ok = function (event) {
  6225. // console.log("event="+JSON.stringify(event))
  6226. // event.action = action;
  6227. // $modalInstance.close(event);
  6228. // };
  6229. $scope.cancel = function(event) {
  6230. $modalInstance.dismiss();
  6231. };
  6232. var acUserSelect = $scope.refreshUser = function(key) {
  6233. //for test
  6234. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  6235. // return;
  6236. var data = { "idx": "0", "sum": "5" };
  6237. if (key) {
  6238. data['user'] = {
  6239. 'name': key
  6240. };
  6241. }
  6242. APIService.fetchDataList('user', data).then(function(response) {
  6243. if (response) {
  6244. if (response.status = 200) {
  6245. $scope.users = response.list;
  6246. console.log($scope.users);
  6247. }
  6248. }
  6249. })
  6250. };
  6251. if (angular.isDefined(event.users) && event.users.length > 0) {
  6252. }
  6253. $scope.users = [event.user];
  6254. acUserSelect();
  6255. },
  6256. resolve: {
  6257. scheduleClass: function() {
  6258. return $scope.scheduleClass;
  6259. },
  6260. APIService: function() {
  6261. return api_user_data;
  6262. },
  6263. MementFormat: function() {
  6264. return moment;
  6265. }
  6266. }
  6267. });
  6268. modalInstance.result.then(function(selectedEvent) {
  6269. if (selectedEvent.action == 'Clicked') {
  6270. // var data = {
  6271. // "scheduleorder":{
  6272. // "id":selectedEvent.id,
  6273. // "description":selectedEvent.title,
  6274. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  6275. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  6276. // "users":selectedEvent.users,
  6277. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  6278. // }
  6279. // };
  6280. // api_bpm_schedule.update(data).then(function(response){
  6281. // if(response.status==200){
  6282. // SweetAlert.swal({
  6283. // title: "操作成功!",
  6284. // text: "排班更新成功!",
  6285. // type: "succes"
  6286. // });
  6287. // angular.forEach($scope.events,function(item){
  6288. // if(item.id==selectedEvent.id){
  6289. // item = selectedEvent;
  6290. // }
  6291. // })
  6292. // }else{
  6293. // SweetAlert.swal({
  6294. // title: "操作失败",
  6295. // text: "排班更新失败,请稍后重试!",
  6296. // type: "error"
  6297. // })
  6298. // }
  6299. // })
  6300. } else {
  6301. //
  6302. }
  6303. });
  6304. }
  6305. $scope.moment = function(string) {
  6306. return moment(string);
  6307. }
  6308. $scope.eventClicked = function(event) {
  6309. // console.log("event="+JSON.stringify(event))
  6310. showModal('Clicked', event);
  6311. };
  6312. $scope.eventEdited = function(event) {
  6313. showModal('Edited', event);
  6314. };
  6315. var updateView = function(newvalue, oldvalue) {
  6316. if (oldvalue == newvalue) return;
  6317. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  6318. if ($scope.calendarView == "year") {
  6319. } else if ($scope.calendarView == "month") {
  6320. timeStart = moment(newvalue).startOf('month');
  6321. timeEnd = moment(newvalue).endOf('month');
  6322. } else if ($scope.calendarView == "week") {
  6323. timeStart = moment(newvalue).startOf('week');
  6324. timeEnd = moment(newvalue).endOf('week');
  6325. } else if ($scope.calendarView == "Day") {
  6326. timeStart = moment(newvalue).startOf('day');
  6327. timeEnd = moment(newvalue).endOf('day');
  6328. }
  6329. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  6330. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  6331. filterData["startTime"] = timeStartSpan;
  6332. filterData["endTime"] = timeEndSpan;
  6333. load(filterData);
  6334. }
  6335. $scope.$watch('calendarDate', updateView)
  6336. $scope.next = function() {
  6337. $scope.calendarControl.next();
  6338. }
  6339. $scope.prev = function() {
  6340. $scope.calendarControl.prev();
  6341. }
  6342. $scope.setCalendarToToday = function() {
  6343. $scope.calendarDay = new Date();
  6344. };
  6345. $scope.toggle = function($event, field, event) {
  6346. $event.preventDefault();
  6347. $event.stopPropagation();
  6348. event[field] = !event[field];
  6349. };
  6350. $scope.load(filterData);
  6351. $scope.more = function() {
  6352. $state.go('app.scheduling.myscheduling', {});
  6353. }
  6354. $scope.removes = function() {
  6355. var modalInstance = $modal.open({
  6356. templateUrl: 'assets/views/delete.html',
  6357. controller: function($scope, $modalInstance) {
  6358. $scope.ok = function() {
  6359. $modalInstance.close();
  6360. };
  6361. $scope.cancel = function() {
  6362. $modalInstance.dismiss('cancel');
  6363. };
  6364. },
  6365. size: 'sm'
  6366. });
  6367. modalInstance.result.then(function() {
  6368. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6369. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6370. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6371. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6372. break;
  6373. }
  6374. }
  6375. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6376. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6377. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6378. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6379. }
  6380. })
  6381. }
  6382. }]
  6383. });
  6384. //空格组件
  6385. formlyConfigProvider.setType({
  6386. name: 'ui-black',
  6387. /*extends: 'input',*/
  6388. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  6389. });
  6390. //请求人最近事件
  6391. formlyConfigProvider.setType({
  6392. name: 'ui-recentIncident',
  6393. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  6394. controller: ['$scope', '$modal', 'api_solution', function($scope, $modal, api_solution) {
  6395. var filterData = {
  6396. 'incident': {
  6397. 'requester': {
  6398. 'id': ''
  6399. }
  6400. },
  6401. idx: 0,
  6402. sum: 3
  6403. };
  6404. setInterval(function() {
  6405. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  6406. var requester = $scope.model.requester;
  6407. if (requester != null && angular.isDefined(requester.id)) {
  6408. filterData.incident.requester.id = $scope.model.requester.id;
  6409. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function(result) {
  6410. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  6411. if (modelData.status == 200) {
  6412. $scope.lastrequst = modelData.list;
  6413. }
  6414. });
  6415. requester = null
  6416. } else {}
  6417. } else {}
  6418. }, 1000);
  6419. $scope.detail = function(data) {
  6420. var modalInstance = $modal.open({
  6421. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  6422. controller: function($scope, $modalInstance) {
  6423. $scope.entity = {};
  6424. $scope.entity = data;
  6425. $scope.cancel = function() {
  6426. $modalInstance.dismiss('cancel');
  6427. };
  6428. },
  6429. size: 'lg',
  6430. });
  6431. }
  6432. }]
  6433. });
  6434. //参数列表
  6435. formlyConfigProvider.setType({
  6436. name: "ui-listinput",
  6437. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  6438. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6439. defaultOptions: function(options) {
  6440. return {
  6441. templateOptions: {}
  6442. };
  6443. },
  6444. controller: ['$scope', function($scope) {
  6445. }]
  6446. });
  6447. //时间段控件(分)
  6448. formlyConfigProvider.setType({
  6449. name: 'ui-timeslot',
  6450. extends: 'input',
  6451. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6452. controller: ['$scope', function($scope) {}]
  6453. });
  6454. //优先级级联-逾期时间
  6455. formlyConfigProvider.setType({
  6456. name: 'ui-overtime',
  6457. extends: 'input',
  6458. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  6459. controller: ['$scope', 'api_bpm_domain', function($scope, api_bpm_domain) {
  6460. var filteData = {};
  6461. var datas = {}
  6462. setInterval(function() {
  6463. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  6464. filteData = "L" + $scope.model.priority.id;
  6465. datas = $scope.model.priority.id;
  6466. // console.log($scope.options.templateOptions)
  6467. api_bpm_domain.expectedTime(filteData).then(function(requester) {
  6468. // var overtime=requester.date;
  6469. if (requester.state == 200) {
  6470. // if($scope.options.key=="date"){
  6471. $scope.model[$scope.options.key] = requester.date
  6472. // }
  6473. }
  6474. })
  6475. }
  6476. }, 1000);
  6477. }]
  6478. });
  6479. formlyConfigProvider.setType({
  6480. name: 'ui-responsetime',
  6481. extends: 'input',
  6482. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6483. controller: ['$scope', 'api_bpm_domain', function($scope, api_bpm_domain) {
  6484. var filteData = {};
  6485. var datas = {}
  6486. setInterval(function() {
  6487. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  6488. filteData = "L" + $scope.model.priority.id;
  6489. datas = $scope.model.priority.id;
  6490. // console.log($scope.options.templateOptions)
  6491. api_bpm_domain.expectedTime(filteData).then(function(requester) {
  6492. // var overtime=requester.date;
  6493. if (requester.state == 200) {
  6494. var keyName = {};
  6495. // $scope.model.overdueTime = requester.date;
  6496. if ($scope.options.key == "expectIntroTime") {
  6497. keyName = "resolveTime";
  6498. } else if ($scope.options.key == "expectResponseTime") {
  6499. keyName = "responseTime";
  6500. }
  6501. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  6502. // }
  6503. console.log($scope.$parent.$parent.$parent.model)
  6504. }
  6505. if (requester.date1) {
  6506. $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
  6507. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
  6508. $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
  6509. $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
  6510. }
  6511. })
  6512. }
  6513. }, 1000);
  6514. }]
  6515. });
  6516. //知识库按钮组件
  6517. formlyConfigProvider.setType({
  6518. name: 'ui-discasecade',
  6519. extends: 'input',
  6520. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  6521. defaultOptions: function(options) {
  6522. return {
  6523. templateOptions: {
  6524. relationAction: function(fields, modelscope, item) {}
  6525. },
  6526. validators: {
  6527. required: {
  6528. expression: function(viewValue, modelValue) {
  6529. var value = modelValue || viewValue;
  6530. // return value = "true";
  6531. }
  6532. }
  6533. }
  6534. }
  6535. },
  6536. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside','api_zsk','api_wechatfile','up_down_file','$http', function($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside,api_zsk,api_wechatfile,up_down_file,$http) {
  6537. // $scope.options.initialValue = $scope.model[$scope.options.key];
  6538. $scope.searchField = $scope.options.model[$scope.options.key];
  6539. $scope.searchData = "";
  6540. $scope.onChangeadd = function(searchData) {
  6541. $scope.searchKey = searchData.account;
  6542. // $scope.searchDataadd = searchData;
  6543. var requesdata = angular.copy(searchData)
  6544. $scope.requester = requesdata;
  6545. }
  6546. $scope.refreshUseradd = function(searchKey) { //主题搜索
  6547. $scope.searchData = searchKey;
  6548. reashdata($scope.searchData);
  6549. }
  6550. $scope.getMydata = function(x) {
  6551. $scope.model[$scope.options.key] = JSON.parse(x).title;
  6552. $scope.searchField = $scope.model[$scope.options.key];
  6553. }
  6554. $scope.getMydataone = function(x) {
  6555. $scope.model[$scope.options.key] = x;
  6556. $scope.searchField = $scope.model[$scope.options.key];
  6557. }
  6558. $scope.fildata = {
  6559. "idx": 0,
  6560. "sum": 10
  6561. // 'incident': { 'tilte': item }
  6562. }
  6563. function reashdata(item) {
  6564. if (item && item != "") {
  6565. angular.extend($scope.fildata, { 'incident': { 'title': item } })
  6566. } else {
  6567. delete $scope.fildata.incident;
  6568. }
  6569. api_bpm_data.fetchDataList('incident', $scope.fildata).then(function(response) {
  6570. if (response) {
  6571. if (response.status = 200) {
  6572. var myData = response;
  6573. $scope.myData = myData.list;
  6574. }
  6575. }
  6576. })
  6577. }
  6578. function delHtmlTag(str) {
  6579. return str.replace(/<[^>]+>/g, "");
  6580. }
  6581. reashdata();
  6582. var changedata = {};
  6583. setInterval(function() {
  6584. if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
  6585. $scope.searchData = {};
  6586. changedata = angular.copy($scope.model.category);
  6587. if ($scope.options.key == "title") {
  6588. var filterData = { "idx": 0, "sum": 1000 };
  6589. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function(data) {
  6590. var datalist = data.list;
  6591. angular.forEach(datalist, function(item) {
  6592. if (item.id == $scope.model.category.id) {
  6593. $scope.model[$scope.options.key] = item.category;
  6594. $scope.searchField = $scope.options.model[$scope.options.key];
  6595. $scope.titles = item.category;
  6596. // }
  6597. // })
  6598. // })
  6599. // }
  6600. titles = $scope.model.category;
  6601. }
  6602. })
  6603. })
  6604. }
  6605. }
  6606. }, 1000);
  6607. $scope.open = function(key, options, fildata, $event, model) {
  6608. if (key && key.length > 1) {
  6609. api_zsk.solutionData({ "solution": { "searchWord": key }, "idx": "0", "sum": "1000" }, 'solution').then(function(response) {
  6610. if (response && response.list.length > 0) {
  6611. $scope.dlideboxslide = true
  6612. angular.forEach(response, function(item) {
  6613. console.log(response)
  6614. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  6615. // if (response.status == 200) {
  6616. // var quote = { 'totalNum': response.totalNum }
  6617. // item = angular.extend(item, quote)
  6618. // }
  6619. // })
  6620. $scope.searchData = response.list;
  6621. console.log($scope.searchData)
  6622. })
  6623. $scope.changes = false;
  6624. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  6625. // $scope.closepages = function(e) {
  6626. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  6627. // event.preventDefault();
  6628. // };
  6629. $scope.shows = false;
  6630. $scope.tempData = {};
  6631. $scope.showpage = function(item) {
  6632. item.content = delHtmlTag(item.content);
  6633. $scope.shows = true;
  6634. $scope.tempData = item;
  6635. if (item.content != null) {
  6636. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  6637. }
  6638. $scope.knowledgedata = item;
  6639. $scope.pageid = item.id;
  6640. $scope.changes = !$scope.changes;
  6641. api_wechatfile.listAttachments('solution',item.id).then(function(data) {
  6642. if (data) {
  6643. $scope.attachments = data.data;
  6644. $scope.view = function(attachmentId) {
  6645. for (var i = 0; i < $scope.attachments.length; i++) {
  6646. if ($scope.attachments[i].id == attachmentId) {
  6647. window.open($scope.attachments[i].previewUrl);
  6648. }
  6649. }
  6650. };
  6651. // $scope.download = function(contentId, filename) {
  6652. // console.log(contentId);
  6653. // var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", contentId.token).getRequestedUrl();
  6654. // var a = document.createElement('a');
  6655. // a.href = downUrl;
  6656. // a.target = '_blank';
  6657. // a.download = contentId.name;
  6658. // document.body.appendChild(a);
  6659. // a.click();
  6660. // // api_solution.getSolutionDowpath(contentId).then(function(response) {
  6661. // // var file = new Blob([response], {
  6662. // // type: 'application/octet-stream'
  6663. // // });
  6664. // // // var filename = filename;
  6665. // // var fileURL = URL.createObjectURL(file);
  6666. // // var a = document.createElement('a');
  6667. // // a.href = fileURL;
  6668. // // a.target = '_blank';
  6669. // // a.download = filename;
  6670. // // document.body.appendChild(a);
  6671. // // a.click();
  6672. // // })
  6673. // };
  6674. }
  6675. })
  6676. }
  6677. $scope.download = function(contentId, filename) {
  6678. console.log(contentId);
  6679. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", contentId.token).getRequestedUrl();
  6680. var data={token:contentId.token};
  6681. $http({
  6682. url:downUrl,
  6683. method:'POST',
  6684. data:data,
  6685. headers:{
  6686. 'Accept':'*/*'
  6687. },
  6688. responseType:'arraybuffer'
  6689. }).success(function(res){
  6690. var file = new Blob([res], {
  6691. type: 'application/octet-stream'
  6692. });
  6693. var fileURL = URL.createObjectURL(file);
  6694. var a = document.createElement('a');
  6695. a.href = fileURL;
  6696. a.target = '_blank';
  6697. a.download = contentId.name;
  6698. document.body.appendChild(a);
  6699. a.click();
  6700. })
  6701. // api_solution.getSolutionDowpath(contentId).then(function(response) {
  6702. // var file = new Blob([response], {
  6703. // type: 'application/octet-stream'
  6704. // });
  6705. // // var filename = filename;
  6706. // var fileURL = URL.createObjectURL(file);
  6707. // var a = document.createElement('a');
  6708. // a.href = fileURL;
  6709. // a.target = '_blank';
  6710. // a.download = filename;
  6711. // document.body.appendChild(a);
  6712. // a.click();
  6713. // })
  6714. };
  6715. $scope.related = function(item) {
  6716. // console.log(options.model);
  6717. if (item.content != null) {
  6718. item.content = item.content.replace("<p>", "").replace("</p>", "")
  6719. }
  6720. // fildata.$parent.$parent.$parent.model.directClose = true;
  6721. // options.model.handleDescription = item.content;
  6722. var data = { 'solutionQuote': { 'solutionId': item.id, 'incidentsign': options.model.incidentsign } };
  6723. // $scope.$parent.$parent.$parent.model.incident.handleDescription=item.content;
  6724. // $scope.dlideboxslide = false;
  6725. api_zsk.solutionQuote(item.id).then(function(response) {
  6726. if (response.status == 200) {
  6727. // console.log(response, $scope);
  6728. // $scope.$parent.$parent.$parent.model.incident.handleDescription=item.content;
  6729. $scope.$parent.$parent.$parent.model.incident.description=item.content;
  6730. $scope.dlideboxslide = false;
  6731. // $scope.$parent.$parent.$parent.model.start_code = 'close';
  6732. // $scope.$parent.$parent.$parent.model.incident.handlingPersonnelUser = $scope.$parent.$parent.$parent.model.incident.acceptUser;
  6733. SweetAlert.swal("引用成功", "知识库已引用", "success");
  6734. } else {
  6735. SweetAlert.swal("引用失败", "知识库未引用", "error");
  6736. };
  6737. })
  6738. }
  6739. $scope.close = function() {
  6740. $scope.changes = !$scope.changes;
  6741. event.preventDefault();
  6742. }
  6743. } else { SweetAlert.swal("引用失败", "没有可引用的知识库", "error"); }
  6744. });
  6745. }
  6746. };
  6747. }]
  6748. });
  6749. //下拉输入组件
  6750. formlyConfigProvider.setType({
  6751. name: 'ui-selectinput',
  6752. extends: 'input',
  6753. templateUrl: 'assets/views/customform/tpl/selectinput.html',
  6754. defaultOptions: function(options) {
  6755. return {
  6756. templateOptions: {
  6757. refresh: function() {},
  6758. refreshDelay: 0,
  6759. linkage: function(modelName, data) {
  6760. }
  6761. },
  6762. }
  6763. },
  6764. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  6765. $scope.searchData = "";
  6766. $scope.onChangeadd = function(searchData) {
  6767. // $scope.searchKey = searchData.account;
  6768. // var requesdata = angular.copy(searchData)
  6769. // $scope.requester = requesdata;
  6770. }
  6771. $scope.refreshUseradd = function(searchKey) { //主题搜索
  6772. // $scope.searchData = searchKey;
  6773. // reashdata($scope.searchData);
  6774. }
  6775. $scope.getMydata = function(x) {
  6776. $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
  6777. $scope.searchField = $scope.model[$scope.options.key];
  6778. }
  6779. $scope.getMydataone = function(x) {
  6780. $scope.model[$scope.options.key] = x;
  6781. $scope.searchField = $scope.model[$scope.options.key];
  6782. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
  6783. $scope.hidden = false;
  6784. } else {
  6785. $scope.hidden = true;
  6786. }
  6787. }
  6788. function reashdata(item) {
  6789. $scope.myData = $scope.options.templateOptions.mydata;
  6790. }
  6791. reashdata()
  6792. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  6793. $scope.options.templateOptions.fetchItems($scope);
  6794. }
  6795. }]
  6796. });
  6797. //重构组件模板
  6798. //获取当前人
  6799. formlyConfigProvider.setType({
  6800. name: 'ui-users',
  6801. extends: 'input',
  6802. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  6803. defaultOptions: function(options) {
  6804. return {
  6805. templateOptions: {
  6806. translate: '',
  6807. refreshDelay: 0
  6808. }
  6809. }
  6810. },
  6811. controller: ['$scope', function($scope) {
  6812. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  6813. $scope.options.templateOptions.translate = $scope.$root.user.name;
  6814. }]
  6815. });
  6816. //只读控件
  6817. formlyConfigProvider.setType({
  6818. name: 'ui-label',
  6819. extends: 'input',
  6820. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  6821. defaultOptions: function(options) {
  6822. return {
  6823. templateOptions: {
  6824. translate: '',
  6825. refreshDelay: 0
  6826. }
  6827. }
  6828. },
  6829. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  6830. // console.log($scope.options.templateOptions)
  6831. var value = $scope.model[$scope.options.key];
  6832. function treeDesc(children, key, label) {
  6833. if (label == "") {
  6834. label = children[key];
  6835. } else {
  6836. label = children[key] + "-" + label;
  6837. }
  6838. if (angular.isDefined(children.parent)) {
  6839. treeDesc(children.parent, key, label);
  6840. } else {
  6841. return label;
  6842. }
  6843. }
  6844. if (angular.isArray(value)) {
  6845. var tempValue = "";
  6846. angular.forEach(value, function(item) {
  6847. if (tempValue != "") {
  6848. tempValue = tempValue + ",";
  6849. }
  6850. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  6851. });
  6852. $scope.options.templateOptions.translate = tempValue;
  6853. } else if (angular.isObject(value)) {
  6854. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  6855. //tree
  6856. // console.log("value.parent="+JSON.stringify(value.parent))
  6857. var nameLabel = value[$scope.options.templateOptions.labelProp];
  6858. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  6859. $scope.options.templateOptions.translate = nameLabel;
  6860. } else {
  6861. $scope.options.templateOptions.translate = value;
  6862. }
  6863. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  6864. // console.log("value=" + value);
  6865. $scope.options.templateOptions.translate = value;
  6866. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  6867. // console.log("value="+value);
  6868. // $scope.options.templateOptions.translate = value;
  6869. } else {
  6870. // var datasdf = JSON.parse(value);
  6871. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  6872. $scope.options.templateOptions.translate = value;
  6873. }
  6874. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6875. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  6876. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
  6877. }
  6878. }]
  6879. });
  6880. //小标题组件
  6881. formlyConfigProvider.setType({
  6882. name: 'ui-header',
  6883. template: '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>'
  6884. });
  6885. //标题组件
  6886. formlyConfigProvider.setType({
  6887. name: 'ui-title',
  6888. template: '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>'
  6889. });
  6890. //标栏是否展示
  6891. formlyConfigProvider.setType({
  6892. name: 'ui-orshow',
  6893. template: '<div class=\"panel\"><div class=\"panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix\"><h3 class=\"pull-left panel-title text-head margin-left-10\" ng-if=\"options.templateOptions.label\">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
  6894. controller: ['$scope', function($scope) {
  6895. $scope.clickshow = function(key) {
  6896. // $scope.model[$scope.options.key] != key;
  6897. if (key == false) {
  6898. $scope.model[$scope.options.key] = true
  6899. } else {
  6900. $scope.model[$scope.options.key] = false
  6901. }
  6902. }
  6903. }]
  6904. });
  6905. //按钮组
  6906. formlyConfigProvider.setType({
  6907. name: 'ui-button',
  6908. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  6909. defaultOptions: function(options) {
  6910. return {
  6911. noFormControl: true
  6912. }
  6913. }
  6914. });
  6915. //3d组link
  6916. formlyConfigProvider.setType({
  6917. name: 'ui-link',
  6918. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  6919. defaultOptions: function(options) {
  6920. return {
  6921. noFormControl: true
  6922. }
  6923. }
  6924. });
  6925. //隐藏域组件
  6926. formlyConfigProvider.setType({
  6927. name: 'ui-hidden',
  6928. extends: 'input',
  6929. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  6930. defaultOptions: function(options) {
  6931. return {
  6932. // noFormControl: true
  6933. };
  6934. }
  6935. });
  6936. //文本框组件
  6937. formlyConfigProvider.setType({
  6938. name: 'ui-input',
  6939. extends: 'input',
  6940. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  6941. defaultOptions: function(options) {
  6942. return {
  6943. templateOptions: {
  6944. transform: function(value) {}
  6945. }
  6946. };
  6947. },
  6948. controller: ['$scope', '$timeout', function($scope, $timeout) {
  6949. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  6950. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  6951. }
  6952. }]
  6953. });
  6954. //jry-上传下载一体
  6955. formlyConfigProvider.setType({
  6956. name: 'ui-upDropFile',
  6957. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  6958. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6959. defaultOptions: function(options) {
  6960. return {
  6961. templateOptions: {
  6962. view: function(APIService, contentId) {
  6963. return APIService.downloadAttachment(contentId);
  6964. },
  6965. // ApiService: 'api_wechatfile',
  6966. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  6967. // upUrl: 'common/common/uploadAttachment',
  6968. // listAttachmentUrl: 'common/common/listAttachment',
  6969. // downUrl: 'common/common/downloadAttachment',
  6970. // bindType: 'incident',
  6971. // bindId: 2323
  6972. },
  6973. // validators: {
  6974. // required: {
  6975. // expression: function(viewValue, modelValue) {
  6976. // var value = modelValue || viewValue;
  6977. // return value.length >= 1;
  6978. // }
  6979. // }
  6980. // }
  6981. };
  6982. },
  6983. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  6984. if (angular.isUndefined($scope.form.dropState)) {
  6985. $scope.form.dropState = false;
  6986. }
  6987. if ($scope.model.incident) {
  6988. if ($scope.model.incident.alarm) {
  6989. console.log($scope)
  6990. if ($scope.model.incident.alarm) {
  6991. if ($scope.model.incident.alarm.alarmExtension) {
  6992. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  6993. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  6994. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  6995. console.log($scope.model.incident.description)
  6996. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  6997. } else {
  6998. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  6999. }
  7000. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  7001. console.log($scope.model.incident.description)
  7002. };
  7003. }
  7004. api_bpm.tellCategory($scope.model.incident.category.id).then(function(wt_data) {
  7005. console.log(wt_data);
  7006. if (wt_data) {
  7007. $rootScope.wt_category = wt_data.data;
  7008. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  7009. $rootScope.wt_child = wt_data.child
  7010. }
  7011. })
  7012. if ($scope.model.titleName == '接单') {
  7013. $scope.model.receive_code = 'handler'
  7014. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  7015. $scope.model.isHandlerUser = true;
  7016. }
  7017. }
  7018. if ($scope.model.titleName == '事件处理') {
  7019. console.log($scope.model.cmdbCode)
  7020. if ($scope.model.cmdbCode) {
  7021. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  7022. }
  7023. }
  7024. } else {
  7025. $rootScope.wt_category = '';
  7026. }
  7027. //附件上传数据
  7028. if ($scope.options.templateOptions.fileUploader) {
  7029. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  7030. //$scope.options.templateOptions.uploader();
  7031. console.log(uploader)
  7032. // FILTERS
  7033. uploader.filters.push({
  7034. name: 'customFilter',
  7035. fn: function(item /*{File|FileLikeObject}*/ , options) {
  7036. return this.queue.length < 10;
  7037. }
  7038. });
  7039. }
  7040. var to = $scope.options.templateOptions;
  7041. // var bindType = $scope.model.bindType;
  7042. if (to.bindType == 'incident') {
  7043. var bindId = $scope.model[to.bindType].processInstanceId;
  7044. } else if (to.bindType == 'change') {
  7045. var bindId = $scope.model[to.bindType].processInstanceId;
  7046. } else {
  7047. var bindId = $scope.model[to.bindType].id;
  7048. }
  7049. //获取附件列表
  7050. $scope.listAttachmen = function() {
  7051. to.ApiService.listAttachment(to.listAttachmentUrl,"solution", bindId).then(function(result) {
  7052. var myData = Restangular.stripRestangular(result);
  7053. // $scope.listAttachmens = myData;
  7054. $scope.attachments = myData.data;
  7055. });
  7056. };
  7057. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  7058. $scope.listAttachmen();
  7059. } else if (to.bindType && $scope.model[to.bindType].id) {
  7060. $scope.listAttachmen();
  7061. }
  7062. //附件上传
  7063. $scope.isUpfload = to.isUpfload;
  7064. $scope.dropfile = function(APIService, processInstanceId, taskId, userId) {
  7065. uploader.onBeforeUploadItem = function(item) {
  7066. angular.extend(item.headers, $rootScope.getSession());
  7067. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  7068. item.formData.push({
  7069. 'filename': item.file.name
  7070. });
  7071. };
  7072. uploader.uploadAll();
  7073. }
  7074. //附件下载
  7075. $scope.download = function(token, filename) {
  7076. // var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  7077. // var a = document.createElement('a');
  7078. // a.href = downUrl;
  7079. // a.target = '_blank';
  7080. // a.download = filename;
  7081. // document.body.appendChild(a);
  7082. // a.click();
  7083. // var headers=
  7084. $http({
  7085. url: to.ApiService.downloadAttachment(to.downUrl).getRequestedUrl(),
  7086. method: 'POST',
  7087. data:{token},
  7088. headers: {
  7089. //'Content-type' : 'application/xls',
  7090. 'Accept': '*/*'
  7091. },
  7092. responseType: 'arraybuffer'
  7093. }).success(function (data, status, headers, config) {
  7094. var file = new Blob([data], {
  7095. type: 'application/octet-stream'
  7096. });
  7097. //trick to download store a file having its URL
  7098. var fileURL = URL.createObjectURL(file);
  7099. var a = document.createElement('a');
  7100. a.href = fileURL;
  7101. a.target = '_blank';
  7102. a.download = filename;
  7103. document.body.appendChild(a);
  7104. a.click();
  7105. }).error(function (data, status, headers, config) {
  7106. // console.log(data);
  7107. });
  7108. };
  7109. //附件预览
  7110. $scope.view = function(id, previewUrl) {
  7111. if (previewUrl) {
  7112. window.open(previewUrl);
  7113. }
  7114. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  7115. // if (response.state == 200) {
  7116. // window.open(response.previewUrl);
  7117. // }
  7118. // })
  7119. };
  7120. // CALLBACKS
  7121. if (uploader) {
  7122. uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  7123. console.info('onWhenAddingFileFailed', item, filter, options);
  7124. };
  7125. uploader.onAfterAddingFile = function(fileItem) {
  7126. console.info('onAfterAddingFile', fileItem);
  7127. };
  7128. uploader.onAfterAddingAll = function(addedFileItems) {
  7129. console.info('onAfterAddingAll', addedFileItems);
  7130. };
  7131. uploader.onBeforeUploadItem = function(item) {
  7132. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  7133. // // $scope.uploader.options.url();
  7134. // $scope.uploader.onBeforeUploadItem = function(item) {
  7135. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  7136. // console.info('onBeforeUploadItem', item);
  7137. // };
  7138. // $scope.uploader.uploadAll();
  7139. // }
  7140. console.info('onBeforeUploadItem', item);
  7141. };
  7142. uploader.onProgressItem = function(fileItem, progress) {
  7143. console.info('onProgressItem', fileItem, progress);
  7144. };
  7145. uploader.onProgressAll = function(progress) {
  7146. console.info('onProgressAll', progress);
  7147. };
  7148. uploader.onSuccessItem = function(fileItem, response, status, headers) {
  7149. console.info('onSuccessItem', fileItem, response, status, headers);
  7150. if (response.status == 200) {
  7151. $scope.listAttachmen();
  7152. }
  7153. };
  7154. uploader.onErrorItem = function(fileItem, response, status, headers) {
  7155. console.info('onErrorItem', fileItem, response, status, headers);
  7156. };
  7157. uploader.onCancelItem = function(fileItem, response, status, headers) {
  7158. console.info('onCancelItem', fileItem, response, status, headers);
  7159. };
  7160. uploader.onCompleteItem = function(fileItem, response, status, headers) {
  7161. console.info('onCompleteItem', fileItem, response, status, headers);
  7162. };
  7163. uploader.onCompleteAll = function() {
  7164. console.info('onCompleteAll');
  7165. };
  7166. }
  7167. }]
  7168. });
  7169. //文本框组件
  7170. formlyConfigProvider.setType({
  7171. name: 'ui-num',
  7172. extends: 'input',
  7173. templateUrl: 'assets/views/customform/tpl/ui-num.html',
  7174. defaultOptions: function(options) {
  7175. return {
  7176. templateOptions: {
  7177. transform: function(value) {}
  7178. }
  7179. };
  7180. },
  7181. controller: ['$scope', '$timeout', function($scope, $timeout) {
  7182. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7183. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7184. }
  7185. $scope.clearNoNum = function(obj, attr) {
  7186. //先把非数字的都替换掉,除了数字和.
  7187. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  7188. //必须保证第一个为数字而不是.
  7189. obj[attr] = obj[attr].replace(/^\./g, "");
  7190. //保证只有出现一个.而没有多个.
  7191. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  7192. //保证.只出现一次,而不能出现两次以上
  7193. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  7194. //小于最大值
  7195. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  7196. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  7197. // obj[attr] = '';
  7198. // }
  7199. }
  7200. }]
  7201. });
  7202. // //关联请求人文本框组件
  7203. // formlyConfigProvider.setType({
  7204. // name: 'ui-requestinput',
  7205. // extends: 'input',
  7206. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7207. // defaultOptions: function(options) {
  7208. // return {
  7209. // templateOptions: {
  7210. // transform: function(value) {},
  7211. // linkData: function(options) {}
  7212. // }
  7213. // };
  7214. // }
  7215. // });
  7216. //只读文本
  7217. formlyConfigProvider.setType({
  7218. name: 'ui-disableinput',
  7219. extends: 'input',
  7220. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  7221. defaultOptions: function(options) {
  7222. return {
  7223. templateOptions: {
  7224. transform: function(value) {
  7225. var ret = "";
  7226. if (value) {
  7227. ret = "已删除";
  7228. } else {
  7229. ret = "正常";
  7230. }
  7231. return ret;
  7232. }
  7233. }
  7234. };
  7235. }
  7236. });
  7237. formlyConfigProvider.setType({
  7238. name: 'ui-disinput',
  7239. extends: 'input',
  7240. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  7241. defaultOptions: function(options) {
  7242. return {
  7243. templateOptions: {}
  7244. };
  7245. }
  7246. });
  7247. //数字组件
  7248. formlyConfigProvider.setType({
  7249. name: 'ui-number',
  7250. extends: 'input',
  7251. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  7252. defaultOptions: function(options) {
  7253. return {
  7254. templateOptions: {}
  7255. };
  7256. },
  7257. controller: ['$scope', function($scope) {
  7258. // console.log($scope.model[$scope.options.key]);
  7259. }]
  7260. });
  7261. // //下拉框组件
  7262. // formlyConfigProvider.setType({
  7263. // name: 'ui-select',
  7264. // extends: 'select',
  7265. // templateUrl: 'assets/views/customform/tpl/ui-select.html',
  7266. // defaultOptions: function(options, scope) {
  7267. // return {
  7268. // templateOptions: {
  7269. // refresh: function() {},
  7270. // refreshDelay: 0,
  7271. // linkage: function(modelName, data, model, modelKey, key) {
  7272. // // if (options.templateOptions.modeldatas) {
  7273. // // angular.extend(data, modeldatas);
  7274. // // } else {
  7275. // angular.extend(data, { "idx": 0, "sum": 1000 });
  7276. // // }
  7277. // options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  7278. // var myData = options.templateOptions.Restangular.stripRestangular(response);
  7279. // // console.log(myData);
  7280. // var list = myData.list;
  7281. // if (list.length == 1) {
  7282. // angular.forEach(model.fields, function(item) {
  7283. // // console.log(item);
  7284. // angular.forEach(model.fields, function(item) {
  7285. // if (item.templateOptions.pkey == modelKey + "." + key) {
  7286. // item.model.id = "";
  7287. // if (key == "place") {
  7288. // item.templateOptions.options = list;
  7289. // } else if (key == "placeDTO") {
  7290. // item.templateOptions.options = list;
  7291. // } else { item.value(list[0][key][item.key]); }
  7292. // }
  7293. // })
  7294. // })
  7295. // } else {
  7296. // angular.forEach(model.fields, function(item) {
  7297. // // console.log(item);
  7298. // angular.forEach(model.fields, function(item) {
  7299. // if (item.templateOptions.pkey == modelKey + "." + key) {
  7300. // item.model.id = "";
  7301. // if (key == "place") { item.templateOptions.options = list; }
  7302. // if (key == "placeDTO") { item.templateOptions.options = list; }
  7303. // }
  7304. // })
  7305. // })
  7306. // }
  7307. // });
  7308. // }
  7309. // },
  7310. // controller: ['$scope', '$rootScope',
  7311. // function($scope, $rootScope) {
  7312. // var filterData = {
  7313. // "idx": 0,
  7314. // "sum": 1000,
  7315. // }
  7316. // console.log($scope.options);
  7317. // if ($scope.options.templateOptions.label == '变更经理') {
  7318. // $scope.options.templateOptions.onChange($scope.model, $scope.options, $scope);
  7319. // } else {
  7320. // if ($scope.options.templateOptions.transform) {
  7321. // $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  7322. // }
  7323. // }
  7324. // if (angular.isFunction($scope.options.templateOptions.translate)) {
  7325. // $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  7326. // }
  7327. // if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  7328. // $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  7329. // }
  7330. // if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  7331. // $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  7332. // }
  7333. // if (angular.isFunction($scope.options.templateOptions.wt_fetchItems)) {
  7334. // $scope.options.templateOptions.wt_fetchItems($scope.options.templateOptions.ApiService, filterData);
  7335. // }
  7336. // }
  7337. // ]
  7338. // };
  7339. // }
  7340. // });
  7341. //下拉框组件
  7342. formlyConfigProvider.setType({
  7343. name: 'ui-select',
  7344. extends: 'select',
  7345. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  7346. defaultOptions: function (options, scope) {
  7347. return {
  7348. templateOptions: {
  7349. // refresh: function() {},
  7350. refreshDelay: 0,
  7351. linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
  7352. angular.extend(data, { "idx": 0, "sum": 1000 });
  7353. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  7354. var myData = options.templateOptions.Restangular.stripRestangular(response);
  7355. var list = myData.list;
  7356. // console.log(myData)
  7357. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  7358. // console.log('balabalabala');
  7359. // console.log(res);
  7360. // })
  7361. if (list.length == 1) {
  7362. if (options.templateOptions.APIport) {
  7363. options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
  7364. if (response.state == "200") {
  7365. // if (model.$parent.model && model.$parent.model.incident) {
  7366. // } else {
  7367. // model.$parent.model = { 'incident': {} };
  7368. // }
  7369. var myDatas = response.serviceLevelAgreement;
  7370. //逾期
  7371. scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
  7372. //解决
  7373. scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
  7374. //响应
  7375. scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
  7376. } else {
  7377. }
  7378. });
  7379. }
  7380. angular.forEach(model.fields, function (item) {
  7381. angular.forEach(model.fields, function (item) {
  7382. if (item.templateOptions.pkey == modelKey + "." + key) {
  7383. item.model.id = "";
  7384. if (key == "place") {
  7385. item.templateOptions.options = list;
  7386. } else if (key == "placeDTO") {
  7387. item.templateOptions.options = list;
  7388. } else {
  7389. item.value(list[0][key][item.key]);
  7390. }
  7391. }
  7392. })
  7393. })
  7394. } else {
  7395. if (model.fields) {
  7396. angular.forEach(model.fields, function (item) {
  7397. angular.forEach(model.fields, function (item) {
  7398. if (item.templateOptions.pkey == modelKey + "." + key) {
  7399. item.model.id = "";
  7400. if (key == "place") {
  7401. item.templateOptions.isnosearch = true;
  7402. item.templateOptions.options = list;
  7403. }
  7404. if (key == "placeDTO") { item.templateOptions.options = list; }
  7405. }
  7406. })
  7407. })
  7408. } else {
  7409. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  7410. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  7411. if (item.templateOptions.pkey == modelKey + "." + key) {
  7412. if (key == "place") {
  7413. item.templateOptions.isnosearch = true;
  7414. item.templateOptions.options = list;
  7415. scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
  7416. }
  7417. if (key == "placeDTO") { item.templateOptions.options = list; }
  7418. }
  7419. })
  7420. })
  7421. }
  7422. }
  7423. });
  7424. },
  7425. validators: {
  7426. required: {
  7427. expression: function (viewValue, modelValue) {
  7428. var value = modelValue || viewValue;
  7429. return value != null;
  7430. // return value.length>=1;
  7431. // if (modelValue && viewValue) {
  7432. // return value != null;
  7433. // } else {
  7434. // var value = modelValue || viewValue;
  7435. // return value.length > 0;
  7436. // }
  7437. }
  7438. }
  7439. }
  7440. },
  7441. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  7442. // $scope.myFilter = function(item) {
  7443. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  7444. // }
  7445. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  7446. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  7447. $scope.options.templateOptions.linkage("place", { "place": { "areaId": $scope.$parent.$parent.$parent.model.incident.area.id } }, $scope.$parent.$parent.$parent.model, "incident", "place");
  7448. }
  7449. }
  7450. $scope.myFilter = $scope;
  7451. if ($scope.options.templateOptions.transform) {
  7452. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  7453. }
  7454. if (angular.isFunction($scope.options.templateOptions.translate)) {
  7455. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  7456. }
  7457. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  7458. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  7459. }
  7460. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  7461. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  7462. }
  7463. }]
  7464. };
  7465. }
  7466. });
  7467. //可修改下拉框组件
  7468. formlyConfigProvider.setType({
  7469. name: 'ui-selectchange',
  7470. extends: 'select',
  7471. templateUrl: 'assets/views/customform/tpl/ui-selectchange.html',
  7472. defaultOptions: function(options) {
  7473. return {
  7474. templateOptions: {
  7475. refresh: function() {},
  7476. refreshDelay: 0,
  7477. linkage: function(modelName, data, model, modelKey, key) {
  7478. angular.extend(data, { "idx": 0, "sum": 1000 });
  7479. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  7480. var myData = options.templateOptions.Restangular.stripRestangular(response);
  7481. var list = myData.list;
  7482. if (list.length == 1) {
  7483. angular.forEach(model.fields, function(item) {
  7484. angular.forEach(model.fields, function(item) {
  7485. if (item.templateOptions.pkey == modelKey + "." + key) {
  7486. item.model.id = "";
  7487. if (key == "place") {
  7488. item.templateOptions.options = list;
  7489. } else { item.value(list[0][key][item.key]); }
  7490. }
  7491. })
  7492. })
  7493. } else {
  7494. angular.forEach(model.fields, function(item) {
  7495. angular.forEach(model.fields, function(item) {
  7496. if (item.templateOptions.pkey == modelKey + "." + key) {
  7497. item.model.id = "";
  7498. if (key == "place") {
  7499. item.templateOptions.options = list;
  7500. }
  7501. }
  7502. })
  7503. })
  7504. }
  7505. });
  7506. }
  7507. },
  7508. controller: ['$scope', function($scope) {
  7509. if (angular.isArray($scope.model[$scope.options.key])) {
  7510. } else {
  7511. $scope.model[$scope.options.key] = [];
  7512. }
  7513. }]
  7514. };
  7515. }
  7516. });
  7517. //下拉多选框组件
  7518. formlyConfigProvider.setType({
  7519. name: 'ui-multiselect',
  7520. extends: 'select',
  7521. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  7522. defaultOptions: function(options) {
  7523. return {
  7524. templateOptions: {
  7525. refresh: function() {},
  7526. refreshDelay: 0
  7527. }
  7528. };
  7529. },
  7530. controller: ['$scope', function($scope) {
  7531. $scope.model[$scope.options.key] = [];
  7532. }]
  7533. });
  7534. //下拉多选框灵活组件
  7535. formlyConfigProvider.setType({
  7536. name: 'ui-multiselectplus',
  7537. extends: 'multiCheckbox',
  7538. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  7539. defaultOptions: function(options) {
  7540. return {
  7541. templateOptions: {
  7542. refreshData: function(search, options, model, that) {
  7543. var process = options.templateOptions.ApiService.all("");
  7544. if (search) {
  7545. } else {
  7546. }
  7547. var postData = options.templateOptions.optionsPostData;
  7548. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  7549. postData = options.templateOptions.optionsPostData(options, model, that);
  7550. }
  7551. process.customPOST(postData, options.templateOptions.optionsUrl).then(function(result) {
  7552. // if (!options.templateOptions.options) {
  7553. // options.templateOptions.options = [];
  7554. // }
  7555. if (options.templateOptions.optionsDataKey) {
  7556. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  7557. } else {
  7558. options.templateOptions.options = result;
  7559. }
  7560. if (options.templateOptions.optionsChecked) {
  7561. // return options.value = null;
  7562. options.value(options.model[options.key]);
  7563. }
  7564. });
  7565. },
  7566. refreshDelay: 0,
  7567. // },
  7568. // validators: {
  7569. // required: {
  7570. // expression: function(viewValue, modelValue) {
  7571. // var value = modelValue || viewValue;
  7572. // // return value.length>=1;
  7573. // // if (modelValue && viewValue) {
  7574. // // return value != null;
  7575. // // } else {
  7576. // // var value = modelValue || viewValue;
  7577. // // return value.length > 0;
  7578. // // }
  7579. // }
  7580. // }
  7581. }
  7582. };
  7583. },
  7584. controller: ['$scope', function($scope) {
  7585. if (angular.isArray($scope.model[$scope.options.key])) {
  7586. } else {
  7587. $scope.model[$scope.options.key] = [];
  7588. }
  7589. }]
  7590. });
  7591. //下拉树形多选组件
  7592. formlyConfigProvider.setType({
  7593. name: 'ui-multiselect-tree',
  7594. extends: 'multiCheckbox',
  7595. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  7596. defaultOptions: function(options) {
  7597. return {
  7598. templateOptions: {
  7599. linkage: function(modelName, data, model, modelKey, key) {
  7600. angular.extend(data, { "idx": 0, "sum": 10 });
  7601. options.templateOptions.APIService.fetchDataList(modelName, data).then(function(response) {
  7602. var myData = options.templateOptions.Restangular.stripRestangular(response);
  7603. var list = myData.list;
  7604. if (list.length == 1) {
  7605. angular.forEach(model.fields, function(item) {
  7606. angular.forEach(model.fields, function(item) {
  7607. if (item.templateOptions.pkey == modelKey + "." + key) {
  7608. item.model.id = "";
  7609. if (key == "place") {
  7610. item.templateOptions.options = list;
  7611. } else { item.value(list[0][key][item.key]); }
  7612. }
  7613. })
  7614. })
  7615. }
  7616. });
  7617. },
  7618. // my_tree_handler : function(items) {
  7619. // console.log('erytuiyewrutyuweyrutewru')
  7620. // },
  7621. // onFilterCallback : function(items) {
  7622. // console.log('1341341234123')
  7623. // },
  7624. // onFilterCallback : function(items) {
  7625. // console.log('134134weafaesesd')
  7626. // },
  7627. refresh: function(items) {
  7628. var treedata = [];
  7629. function convertListToTree(data, treeMap) {
  7630. treedata = data;
  7631. for (var i = 0; i < data.length; i++) {
  7632. for (var j = 0; j < data.length; j++) {
  7633. if (data[i].pid && data[i].id && data[i].pid != 0) {
  7634. if (data[i].pid == data[j].id) {
  7635. data[i].parent = data[j];
  7636. }
  7637. }
  7638. }
  7639. }
  7640. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  7641. var root = null; //Initially set our loop to null
  7642. //loop over data
  7643. for (var i = 0; i < data.length; i++) {
  7644. var datum = data[i];
  7645. //each node will have children, so let's give it a "children" poperty
  7646. datum.children = [];
  7647. //add an entry for this node to the map so that any future children can
  7648. //lookup the parent
  7649. idToNodeMap[datum.id] = datum;
  7650. //Does this node have a parent?
  7651. // console.log("datum="+JSON.stringify(datum))
  7652. if (typeof datum.parent === "undefined" || datum.parent === null) {
  7653. //Doesn't look like it, so this node is the root of the tree
  7654. root = datum;
  7655. treeMap[datum.id] = root;
  7656. } else {
  7657. //This node has a parent, so let's look it up using the id
  7658. parentNode = idToNodeMap[datum.parent.id];
  7659. //We don't need this property, so let's delete it.
  7660. delete datum.parent;
  7661. //Let's add the current node as a child of the parent node.
  7662. parentNode.children.push(datum);
  7663. }
  7664. }
  7665. return root;
  7666. }
  7667. function convertParentToChildList(data) {
  7668. // console.log("data="+JSON.stringify(data))
  7669. var treeMap = {};
  7670. var list = [];
  7671. convertListToTree(data, treeMap);
  7672. angular.forEach(treeMap, function(item) {
  7673. list.push(item);
  7674. });
  7675. return list;
  7676. }
  7677. function selectItem(pmodel, childrens) {
  7678. if (angular.isArray(pmodel)) {
  7679. angular.forEach(pmodel, function(index) {
  7680. if (index && index.id) {
  7681. angular.forEach(childrens, function(item) {
  7682. if (item.id == index.id) {
  7683. item.selected = true;
  7684. }
  7685. if (item && item.children) {
  7686. selectItem(pmodel, item.children);
  7687. }
  7688. });
  7689. }
  7690. })
  7691. } else {
  7692. if (pmodel && pmodel.id) {
  7693. angular.forEach(childrens, function(item) {
  7694. if (item.id == pmodel.id) {
  7695. item.selected = true;
  7696. }
  7697. if (item && item.children) {
  7698. selectItem(pmodel, item.children);
  7699. }
  7700. });
  7701. }
  7702. }
  7703. }
  7704. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  7705. options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
  7706. if (result.status == 200) {
  7707. if (!options.templateOptions.options) {
  7708. options.templateOptions.options = [];
  7709. }
  7710. if (options.templateOptions.optionsDataKey) {
  7711. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  7712. } else {
  7713. options.templateOptions.options = convertParentToChildList(result);
  7714. }
  7715. //set default value
  7716. var pmodel, i = 0;
  7717. if (options.templateOptions.pkey) {
  7718. if (options.templateOptions.pkey.indexOf(".") > 0) {
  7719. angular.forEach(options.templateOptions.pkey.split("."), function(p) {
  7720. if (i == 0) {
  7721. if (options.model[p] == null) {
  7722. options.model[p] = {};
  7723. }
  7724. pmodel = options.model[p];
  7725. i++;
  7726. } else {
  7727. if (pmodel[p] == null) {
  7728. pmodel[p] = {};
  7729. }
  7730. pmodel = pmodel[p];
  7731. }
  7732. });
  7733. } else {
  7734. pmodel = options.model;
  7735. }
  7736. }
  7737. if (pmodel) {
  7738. pmodel = pmodel[options.key];
  7739. } else if (options.model) {
  7740. pmodel = options.model[options.key];
  7741. } else {
  7742. pmodel = options.templateOptions.options;
  7743. }
  7744. if (angular.isArray(pmodel)) {
  7745. if (pmodel) {
  7746. // if(options.templateOptions.isMultiSelect==true){
  7747. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  7748. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  7749. // })
  7750. // }else{
  7751. selectItem(pmodel, options.templateOptions.options);
  7752. // }
  7753. }
  7754. } else {
  7755. if (pmodel && pmodel.id) {
  7756. selectItem(pmodel, options.templateOptions.options);
  7757. }
  7758. }
  7759. items.inputModel = options.templateOptions.options;
  7760. }
  7761. });
  7762. }
  7763. },
  7764. validators: {
  7765. required: {
  7766. expression: function(viewValue, modelValue) {
  7767. var value = modelValue || viewValue;
  7768. if (angular.isArray(value)) {
  7769. for (var i = 0; i < value.length; i++) {
  7770. value[i] = { id: value[i].id }
  7771. }
  7772. return value.length > 0
  7773. } else {
  7774. // console.log(options)
  7775. // return value = "true";
  7776. return value != null;
  7777. }
  7778. }
  7779. }
  7780. }
  7781. }
  7782. },
  7783. controller: ['$scope', 'api_configure_form', function($scope, api_configure_form) {
  7784. if ($scope.options.templateOptions.isMultiSelect) {
  7785. // console.log($scope);
  7786. } else {
  7787. if ($scope.model[$scope.options.key]) {
  7788. }
  7789. }
  7790. }]
  7791. });
  7792. //多选下拉框组件
  7793. formlyConfigProvider.setType({
  7794. name: 'ui-multi-select-tree',
  7795. extends: 'multiCheckbox',
  7796. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  7797. defaultOptions: function(options) {
  7798. return {
  7799. templateOptions: {
  7800. refresh: function(items) {
  7801. //console.log(items);
  7802. function convertListToTree(data, treeMap) {
  7803. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  7804. var root = null; //Initially set our loop to null
  7805. //loop over data
  7806. for (var i = 0; i < data.length; i++) {
  7807. var datum = data[i];
  7808. //each node will have children, so let's give it a "children" poperty
  7809. datum.children = [];
  7810. //add an entry for this node to the map so that any future children can
  7811. //lookup the parent
  7812. idToNodeMap[datum.id] = datum;
  7813. //Does this node have a parent?
  7814. // console.log("datum="+JSON.stringify(datum))
  7815. if (typeof datum.parent === "undefined" || typeof datum.parent === "null") {
  7816. //Doesn't look like it, so this node is the root of the tree
  7817. root = datum;
  7818. treeMap[i] = root;
  7819. } else {
  7820. //This node has a parent, so let's look it up using the id
  7821. parentNode = idToNodeMap[datum.parent.id];
  7822. //We don't need this property, so let's delete it.
  7823. delete datum.parent;
  7824. //Let's add the current node as a child of the parent node.
  7825. parentNode.children.push(datum);
  7826. }
  7827. }
  7828. return root;
  7829. }
  7830. function convertParentToChildList(data) {
  7831. // console.log("data="+JSON.stringify(data))
  7832. var treeMap = {};
  7833. var list = [];
  7834. convertListToTree(data, treeMap);
  7835. angular.forEach(treeMap, function(item) {
  7836. // console.log("item="+JSON.stringify(item))
  7837. list.push(item);
  7838. });
  7839. return list;
  7840. }
  7841. function selectItem(pmodel, childrens) {
  7842. if (angular.isArray(pmodel)) {
  7843. } else {
  7844. if (pmodel && pmodel.id) {
  7845. angular.forEach(childrens, function(item) {
  7846. if (item.id == pmodel.id) {
  7847. item.selected = true;
  7848. }
  7849. if (item && item.children) {
  7850. selectItem(pmodel, item.children);
  7851. }
  7852. });
  7853. }
  7854. }
  7855. }
  7856. options.templateOptions.refreshData(options.templateOptions.APIService).then(function(result) {
  7857. if (!options.templateOptions.options) {
  7858. options.templateOptions.options = [];
  7859. }
  7860. if (options.templateOptions.optionsDataKey) {
  7861. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  7862. } else {
  7863. options.templateOptions.options = convertParentToChildList(result);
  7864. }
  7865. //set default value
  7866. var pmodel, i = 0;
  7867. if (options.templateOptions.pkey) {
  7868. if (options.templateOptions.pkey.indexOf(".") > 0) {
  7869. angular.forEach(options.templateOptions.pkey.split("."), function(p) {
  7870. if (i == 0) {
  7871. if (options.model[p] == null) {
  7872. options.model[p] = {};
  7873. }
  7874. pmodel = options.model[p];
  7875. i++;
  7876. } else {
  7877. if (pmodel[p] == null) {
  7878. pmodel[p] = {};
  7879. }
  7880. pmodel = pmodel[p];
  7881. }
  7882. });
  7883. } else {
  7884. pmodel = options.model[options.templateOptions.pkey];
  7885. }
  7886. }
  7887. if (pmodel) {
  7888. pmodel = pmodel[options.key];
  7889. } else {
  7890. pmodel = options.model[options.key];
  7891. }
  7892. if (pmodel && pmodel.id) {
  7893. selectItem(pmodel, options.templateOptions.options);
  7894. }
  7895. items.inputModel = options.templateOptions.options;
  7896. });
  7897. }
  7898. },
  7899. // $scope.onChange(model[options.key], options, this, $event ,model){validators.required.expression()}
  7900. validators: {
  7901. required: {
  7902. expression: function(viewValue, modelValue) {
  7903. var value = modelValue || viewValue;
  7904. if (angular.isArray(value)) {
  7905. return value.length > 0
  7906. } else if (angular.isUndefined(value)) {
  7907. return value = "";
  7908. } else {
  7909. return value != null;
  7910. }
  7911. }
  7912. }
  7913. }
  7914. }
  7915. },
  7916. controller: ['$scope', function($scope) {
  7917. if ($scope.options.templateOptions.isMultiSelect) {
  7918. } else {
  7919. if ($scope.model[$scope.options.key]) {}
  7920. }
  7921. //$scope.model[$scope.options.key]=[];
  7922. }]
  7923. });
  7924. //勾选组件
  7925. formlyConfigProvider.setType({
  7926. name: 'ui-checkbox',
  7927. extends: 'checkbox',
  7928. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  7929. controller: ['$scope', function($scope) {
  7930. if (angular.isFunction($scope.options.templateOptions.transform)) {
  7931. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope, $scope.model);
  7932. }
  7933. }]
  7934. });
  7935. // //复选框
  7936. // formlyConfigProvider.setType({
  7937. // name: 'ui-checkboxmore',
  7938. // extends: 'checkbox',
  7939. // templateUrl: 'assets/views/customform/tpl/ui-checkbox.html'
  7940. // });
  7941. //换行组件
  7942. formlyConfigProvider.setType({
  7943. name: 'ui-nextLine',
  7944. /*extends: 'input',*/
  7945. template: '<div></div>',
  7946. });
  7947. //多选框组件
  7948. formlyConfigProvider.setType({
  7949. name: 'ui-checklist',
  7950. extends: 'multiCheckbox',
  7951. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  7952. defaultOptions: function(options) {
  7953. return {
  7954. templateOptions: {
  7955. refresh: function() {},
  7956. refreshDelay: 0
  7957. }
  7958. };
  7959. }
  7960. });
  7961. //单选框组件
  7962. formlyConfigProvider.setType({
  7963. name: 'ui-radio',
  7964. extends: 'radio',
  7965. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  7966. defaultOptions: function(options) {
  7967. return {
  7968. templateOptions: {
  7969. refresh: function() {},
  7970. refreshDelay: 0
  7971. }
  7972. };
  7973. }
  7974. });
  7975. //文本域组件
  7976. formlyConfigProvider.setWrapper({
  7977. name: 'validation',
  7978. types: ['ui-textarea'],
  7979. 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>"
  7980. });
  7981. formlyConfigProvider.setType({
  7982. name: 'ui-textarea',
  7983. extends: 'textarea',
  7984. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  7985. defaultOptions: function(options) {
  7986. return {
  7987. templateOptions: {
  7988. transform: function(model, value) {
  7989. return value;
  7990. },
  7991. },
  7992. validation: {
  7993. messages: {
  7994. maxlength: function(viewValue, modelValue, scope) {
  7995. if (viewValue != null) {
  7996. if (viewValue.length > scope.to.maxlength) {
  7997. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  7998. } else {
  7999. return "";
  8000. }
  8001. }
  8002. },
  8003. }
  8004. }
  8005. }
  8006. },
  8007. controller: ['$scope', function($scope) {
  8008. var value = $scope.model[$scope.options.key];
  8009. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8010. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8011. }
  8012. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  8013. $scope.options.templateOptions.felditem($scope);
  8014. }
  8015. }]
  8016. });
  8017. //常用语句选择textarea
  8018. formlyConfigProvider.setType({
  8019. name: 'ui-textselect',
  8020. extends: 'textarea',
  8021. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  8022. defaultOptions: function(options) {
  8023. return {
  8024. templateOptions: {
  8025. transform: function(model, value) {
  8026. return value;
  8027. },
  8028. },
  8029. validation: {
  8030. messages: {
  8031. maxlength: function(viewValue, modelValue, scope) {
  8032. if (viewValue != null) {
  8033. if (viewValue.length > scope.to.maxlength) {
  8034. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8035. } else {
  8036. return "";
  8037. }
  8038. }
  8039. },
  8040. }
  8041. }
  8042. }
  8043. },
  8044. controller: ['$scope', function($scope) {
  8045. var value = $scope.model[$scope.options.key];
  8046. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8047. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8048. }
  8049. }]
  8050. });
  8051. //改动的组件 ckeditor封装后的组件
  8052. formlyConfigProvider.setType({
  8053. name: 'ui-text-check',
  8054. extends: 'textarea',
  8055. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  8056. defaultOptions: function(options) {
  8057. return {
  8058. templateOptions: {
  8059. extraPlugins: 'uploadimage',
  8060. uploadimageConfig: {
  8061. backend: 'basic',
  8062. settings: {
  8063. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  8064. headers: '',
  8065. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  8066. }
  8067. },
  8068. refresh: function(APIService, contentId, data) {
  8069. return APIService.fetchDataList(contentId, data);
  8070. },
  8071. downloadUri: function(APIService, contentId) {
  8072. return APIService.downloadAttachment(contentId).getRequestedUrl();
  8073. },
  8074. upload: function(APIService, contentId) {
  8075. return APIService.getSolutionDowpath(contentId);
  8076. },
  8077. view: function(attachmentId) {
  8078. // return APIService.attachmentsPreviewUrl(contentId);
  8079. },
  8080. refreshDelay: 0,
  8081. transform: function(model, value) {
  8082. return value;
  8083. },
  8084. },
  8085. validation: {
  8086. messages: {
  8087. maxlength: function(viewValue, modelValue, scope) {
  8088. if (viewValue != null) {
  8089. if (viewValue.length > scope.to.maxlength) {
  8090. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8091. } else {
  8092. return "";
  8093. }
  8094. }
  8095. },
  8096. }
  8097. }
  8098. }
  8099. },
  8100. controller: ['$scope', '$rootScope', function($scope, $rootScope) {
  8101. var value = $scope.model[$scope.options.key];
  8102. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8103. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8104. }
  8105. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  8106. //var expiry={'expiry':14804244006};
  8107. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  8108. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  8109. $scope.upload = function(contentId, filename) {
  8110. var filename = filename;
  8111. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  8112. var file = new Blob([response], { type: 'application/octet-stream' });
  8113. // var filename = filename;
  8114. var fileURL = URL.createObjectURL(file);
  8115. var a = document.createElement('a');
  8116. a.href = fileURL;
  8117. a.target = '_blank';
  8118. a.download = filename;
  8119. document.body.appendChild(a);
  8120. a.click();
  8121. })
  8122. };
  8123. }]
  8124. });
  8125. //ui-grid展示控件
  8126. formlyConfigProvider.setType({
  8127. name: 'ui-grid-show',
  8128. extends: 'multiCheckbox',
  8129. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  8130. defaultOptions: function(options) {
  8131. return {
  8132. templateOptions: {
  8133. linkage: function() {
  8134. },
  8135. },
  8136. };
  8137. },
  8138. controller: function($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  8139. var loginUser = $rootScope.user;
  8140. $scope.langs = i18nService.getAllLangs();
  8141. $scope.lang = 'zh-cn';
  8142. i18nService.setCurrentLang($scope.lang);
  8143. $scope.gridOptions = {};
  8144. $scope.gridOptions.data = 'myData';
  8145. $scope.gridOptions.enableColumnResizing = true;
  8146. // $scope.gridOptions.enableFiltering = true;
  8147. $scope.gridOptions.enableGridMenu = false;
  8148. $scope.gridOptions.enableRowSelection = true;
  8149. $scope.gridOptions.showGridFooter = true;
  8150. $scope.gridOptions.showColumnFooter = false;
  8151. $scope.gridOptions.fastWatch = true;
  8152. $scope.gridOptions.useExternalFiltering = true;
  8153. $scope.gridOptions.useExternalPagination = true;
  8154. $scope.gridOptions.paginationPageSizes = [10];
  8155. $scope.gridOptions.paginationPageSize = 10;
  8156. $scope.gridOptions.multiSelect = true;
  8157. $scope.gridOptions.rowIdentity = function(row) {
  8158. return row.id;
  8159. };
  8160. $scope.gridOptions.getRowIdentity = function(row) {
  8161. return row.id;
  8162. };
  8163. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  8164. $scope.gridOptions.columnDefs = [
  8165. // { name:'id', width:80, enableFiltering:false},
  8166. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  8167. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  8168. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  8169. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  8170. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  8171. { name: 'inspection.title', displayName: '计划主题', width: 120, enableFiltering: false },
  8172. { name: 'stateName', displayName: '状态', width: 80, enableFiltering: false },
  8173. { name: 'processUser.name', displayName: '处理人', width: 80, enableFiltering: false },
  8174. { name: 'startDate', displayName: '开始时间', width: 160, enableFiltering: false },
  8175. { name: 'overdueTime', displayName: '逾期时间', width: 160, enableFiltering: false },
  8176. ];
  8177. var defaultFilterData = {
  8178. "idx": 0,
  8179. "sum": 10
  8180. };
  8181. //分页控制
  8182. $scope.gridOptions.onRegisterApi = function(gridApi) {
  8183. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  8184. var filtersData = $scope.memoryfilterData;
  8185. filtersData.idx = newPage - 1;
  8186. filtersData.sum = pageSize;
  8187. $scope.refreshData('expand-right', filtersData);
  8188. });
  8189. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  8190. data.grid.appScope.selected.items = data.entity
  8191. });
  8192. };
  8193. //页面获取数据
  8194. $scope.refreshData = function(style, filterData) {
  8195. // $scope.ldloading[style.replace('-', '_')] = true;
  8196. if (angular.isUndefined(filterData)) {
  8197. filterData = defaultFilterData;
  8198. }
  8199. $scope.myData = [];
  8200. angular.extend(filterData, { inspectionProcessActual: { "inspectionid": $scope.model.id } })
  8201. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function(data) {
  8202. var myData = Restangular.stripRestangular(data);
  8203. $scope.gridOptions.totalItems = myData.totalNum;
  8204. $scope.myData = myData.list;
  8205. for (var i = 0; i < $scope.myData.length; i++) {
  8206. //添加序号
  8207. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  8208. }
  8209. // $scope.ldloading[style.replace('-', '_')] = false;
  8210. }, function() {
  8211. // $scope.ldloading[style.replace('-', '_')] = false;
  8212. });
  8213. };
  8214. $scope.refreshData('expand-right', defaultFilterData);
  8215. }
  8216. });
  8217. // formlyConfigProvider.setType({
  8218. // name: 'ui-mentio',
  8219. // extends: 'textarea',
  8220. // templateUrl : 'assets/views/customform/tpl/mentio.html',
  8221. // defaultOptions:function(options){
  8222. // return {
  8223. // templateOptions: {
  8224. // transform:function(model, value){
  8225. // return value;
  8226. // },
  8227. // },
  8228. // validation: {
  8229. // messages: {
  8230. // maxlength: function(viewValue, modelValue, scope) {
  8231. // if(viewValue!=null){
  8232. // if(viewValue.length>scope.to.maxlength){
  8233. // return scope.to.label + ' 字数('+ viewValue.length +')超限('+scope.to.maxlength+')'
  8234. // }else{
  8235. // return "";
  8236. // }
  8237. // }
  8238. // },
  8239. // }
  8240. // }
  8241. // }
  8242. // },
  8243. // controller: ['$scope',function($scope){
  8244. // $scope.people = [
  8245. // { label: 'Joe'},
  8246. // { label: 'Mike'},
  8247. // { label: 'Diane'}
  8248. // ]
  8249. // var value = $scope.model[$scope.options.key];
  8250. // if(angular.isFunction($scope.options.templateOptions.transform)){
  8251. // $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8252. // }
  8253. // }]
  8254. // });
  8255. //文本框自定义选择面板组件
  8256. formlyConfigProvider.setType({
  8257. name: 'ui-input-selectmodal',
  8258. extends: 'input',
  8259. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  8260. defaultOptions: function(options) {
  8261. return {
  8262. templateOptions: {
  8263. openModal: function(size, options, modal) {
  8264. var modalInstance = modal.open({
  8265. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  8266. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  8267. size: size,
  8268. resolve: options.templateOptions.modalParam
  8269. });
  8270. modalInstance.result.then(function(selectedItem) {
  8271. options.value(selectedItem);
  8272. }, function() {
  8273. //console.log('Modal dismissed at: ' + new Date());
  8274. });
  8275. }
  8276. }
  8277. };
  8278. }
  8279. });
  8280. //日期控件
  8281. var datepicker_attr = [
  8282. 'date-disabled',
  8283. 'custom-class',
  8284. 'show-weeks',
  8285. 'starting-day',
  8286. 'init-date',
  8287. 'min-mode',
  8288. 'max-mode',
  8289. 'format-day',
  8290. 'format-month',
  8291. 'format-year',
  8292. 'format-day-header',
  8293. 'format-day-title',
  8294. 'format-month-title',
  8295. 'year-range',
  8296. 'shortcut-propagation',
  8297. 'datepicker-popup',
  8298. 'show-button-bar',
  8299. 'current-text',
  8300. 'clear-text',
  8301. 'close-text',
  8302. 'close-on-date-selection',
  8303. 'datepicker-append-to-body'
  8304. ];
  8305. var datepicker_bindings = [
  8306. 'datepicker-mode',
  8307. 'min-date',
  8308. 'max-date'
  8309. ];
  8310. formlyConfigProvider.setType({
  8311. name: 'ui-datetime',
  8312. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  8313. extends: 'input',
  8314. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8315. defaultOptions: {
  8316. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8317. templateOptions: {
  8318. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8319. }
  8320. },
  8321. controller: ['$scope', '$filter', function($scope, $filter) {
  8322. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  8323. $scope.options.initialValue = $scope.model[$scope.options.key];
  8324. }]
  8325. });
  8326. //日期控件
  8327. formlyConfigProvider.setType({
  8328. name: 'ui-datepicker',
  8329. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  8330. extends: 'input',
  8331. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8332. defaultOptions: {
  8333. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8334. templateOptions: {
  8335. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8336. }
  8337. },
  8338. controller: ['$scope', '$filter', function($scope, $filter) {
  8339. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  8340. if ($scope.model[$scope.options.key]) {
  8341. } else {
  8342. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  8343. }
  8344. $scope.options.initialValue = $scope.model[$scope.options.key];
  8345. $scope.endOpen = true;
  8346. $scope.datepicker = {};
  8347. $scope.datepicker.opened = false;
  8348. $scope.datepicker.open = function($event) {
  8349. $scope.datepicker.opened = true;
  8350. };
  8351. }]
  8352. });
  8353. //含有周的日期
  8354. formlyConfigProvider.setType({
  8355. name: 'ui-datepickerweek',
  8356. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  8357. extends: 'input',
  8358. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8359. defaultOptions: {
  8360. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8361. templateOptions: {
  8362. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8363. }
  8364. },
  8365. controller: ['$scope', '$filter', function($scope, $filter) {
  8366. if ($scope.options.templateOptions.transform) {
  8367. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8368. }
  8369. if ($scope.model[$scope.options.key]) {
  8370. } else {
  8371. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  8372. }
  8373. $scope.options.initialValue = $scope.model[$scope.options.key];
  8374. $scope.endOpen = true;
  8375. $scope.datepicker = {};
  8376. $scope.datepicker.opened = false;
  8377. $scope.datepicker.open = function($event) {
  8378. $scope.datepicker.opened = true;
  8379. };
  8380. }]
  8381. });
  8382. //时分控件
  8383. formlyConfigProvider.setType({
  8384. name: 'ui-datehourtime',
  8385. extends: 'input',
  8386. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  8387. defaultOptions: function(options) {
  8388. return {
  8389. noFormControl: true,
  8390. // validators:{
  8391. // required:{
  8392. // expression:function(viewValue, modelValue){
  8393. // console.log(options)
  8394. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  8395. // // var value = modelValue.getHours() || viewValue.getHours();
  8396. // return value.length>=1;
  8397. // }
  8398. // }
  8399. // }
  8400. }
  8401. },
  8402. controller: ['$scope', '$log', function($scope, $log) {
  8403. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  8404. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  8405. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  8406. }]
  8407. });
  8408. //状态追踪
  8409. formlyConfigProvider.setType({
  8410. name: 'ui-followStatus',
  8411. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  8412. controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
  8413. setTimeout(function() {
  8414. var pkey = $scope.options.templateOptions.pkey;
  8415. var dataId = $scope.model.id;
  8416. if (dataId) {
  8417. api_bpm_data.fetchData(pkey, dataId).then(function(response) {
  8418. if (response) {
  8419. var myData = Restangular.stripRestangular(response);
  8420. var processInstanceId = myData.data.processInstanceId;
  8421. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
  8422. if (result.status == 200) {
  8423. var newData = Restangular.stripRestangular(result);
  8424. $scope.followData = newData.data;
  8425. }
  8426. });
  8427. }
  8428. })
  8429. }
  8430. }, 10);
  8431. }]
  8432. });
  8433. //历史记录
  8434. formlyConfigProvider.setType({
  8435. name: 'ui-history',
  8436. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  8437. controller: ['$scope', 'api_bpm_data', 'Restangular', function($scope, api_bpm_data, Restangular) {
  8438. setTimeout(function() {
  8439. var pkey = $scope.options.templateOptions.pkey;
  8440. var dataId = $scope.model.id;
  8441. api_bpm_data.fetchData(pkey, dataId).then(function(response) {
  8442. if (response) {
  8443. var myData = Restangular.stripRestangular(response);
  8444. var processInstanceId = myData.data.processInstanceId;
  8445. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function(result) {
  8446. if (result.status == 200) {
  8447. var newData = Restangular.stripRestangular(result);
  8448. var long = newData.data.length - 1;
  8449. $scope.followData = newData.data[long];
  8450. }
  8451. });
  8452. }
  8453. })
  8454. }, 10);
  8455. }]
  8456. });
  8457. //请求人信息显示
  8458. formlyConfigProvider.setType({
  8459. name: "ui-disrequester",
  8460. templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  8461. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8462. defaultOptions: function(options) {
  8463. return {
  8464. templateOptions: {}
  8465. };
  8466. },
  8467. controller: ['$scope', function($scope) {
  8468. $scope.options.templateOptions.that = $scope;
  8469. }]
  8470. });
  8471. //退回人信息显示
  8472. formlyConfigProvider.setType({
  8473. name: "ui-returnperson",
  8474. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  8475. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8476. defaultOptions: function(options) {
  8477. return {
  8478. templateOptions: {}
  8479. };
  8480. },
  8481. controller: ['$scope', function($scope) {
  8482. $scope.group = "";
  8483. $scope.role = "";
  8484. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  8485. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  8486. } else {
  8487. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  8488. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  8489. }
  8490. }
  8491. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  8492. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  8493. } else {
  8494. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  8495. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  8496. }
  8497. }
  8498. $scope.options.templateOptions.that = $scope;
  8499. $scope.options.templateOptions.that = $scope;
  8500. }]
  8501. });
  8502. //指派技术人员
  8503. formlyConfigProvider.setType({
  8504. name: "ui-apiontperson",
  8505. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  8506. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8507. defaultOptions: function(options) {
  8508. return {
  8509. templateOptions: {
  8510. transtlara: function(value, $scope) {}
  8511. }
  8512. };
  8513. },
  8514. controller: ['$scope', 'api_user_data', 'Restangular', function($scope, api_user_data, Restangular) {
  8515. var filterData = { "idx": 0, "sum": 1000 }
  8516. api_user_data.fetchDataList('group', filterData).then(function(response) {
  8517. if (response.status == 200) {
  8518. $scope.select = {};
  8519. $scope.multipleDemo = {};
  8520. $scope.userdata = {};
  8521. var data = response.list;
  8522. var item = [];
  8523. $scope.multipleDemo = data;
  8524. $scope.multipleDemo;
  8525. }
  8526. })
  8527. $scope.options.templateOptions.onChange = function(id, options, groupdata, $event, model) {
  8528. if (groupdata.option) {
  8529. $scope.model[$scope.options.key] = {};
  8530. var fildate = {
  8531. "idx": 0,
  8532. "sum": 1000,
  8533. "user": {
  8534. "roledata": { "rolecode": model.currentRole },
  8535. "selectType": "1",
  8536. "groupdata": { "id": groupdata.option.id }
  8537. }
  8538. }
  8539. api_user_data.fetchDataList('user', fildate).then(function(response) {
  8540. if (response.status == 200) {
  8541. $scope.userdata = {};
  8542. $scope.userdata = response.list;
  8543. }
  8544. })
  8545. } else {
  8546. $scope.model[$scope.options.key] = { id: groupdata.id.id }
  8547. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  8548. }
  8549. }
  8550. // }
  8551. }]
  8552. });
  8553. //请求人信息
  8554. formlyConfigProvider.setType({
  8555. name: 'ui-requesterinformation',
  8556. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  8557. // wrapper: ['bootstrapHasError'],
  8558. defaultOptions: function(options, $scope,api_user) {
  8559. return {
  8560. templateOptions: {
  8561. checkform: function(options) {
  8562. if (options.model.requester) {
  8563. options.value(options.model.requester);
  8564. }
  8565. },
  8566. addRequeter: function(size, options, modal) {
  8567. event.preventDefault();
  8568. var modalInstance = modal.open({
  8569. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  8570. controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data,api_user) {
  8571. $scope.title = "新增报修人";
  8572. $scope.requester = {};
  8573. $scope.searchData = {};
  8574. // $scope.requesdata = ["key4", "xyz", "key3", "xxxx", "key2", "value2", "key1", "value1"];
  8575. $scope.onChangeadd = function(searchData) {
  8576. $scope.searchKey = searchData.account;
  8577. // $scope.searchDataadd = searchData;
  8578. var requesdata = angular.copy(searchData)
  8579. if (requesdata.mphone) {
  8580. delete requesdata.mphone;
  8581. }
  8582. $scope.requester = requesdata;
  8583. }
  8584. $scope.refreshUseradd = function(searchKey) { //请求人搜索
  8585. $scope.requester.account = searchKey;
  8586. $scope.searchData = searchKey;
  8587. serchdataadd(searchKey);
  8588. }
  8589. $scope.getMydata = function(x) {
  8590. $scope.searchField = JSON.parse(x[0]).account;
  8591. $scope.requester = JSON.parse(x[0]);
  8592. }
  8593. $scope.getMydataone = function(x) {
  8594. $scope.searchField = x;
  8595. $scope.requester.account = x;
  8596. }
  8597. serchdataadd();
  8598. function serchdataadd(searchKey) {
  8599. if (searchKey) {
  8600. var filterData = {
  8601. 'requester': {
  8602. 'searchKey': searchKey,
  8603. },
  8604. idx: 0,
  8605. sum: 10
  8606. };
  8607. } else {
  8608. var filterData = {
  8609. idx: 0,
  8610. sum: 10
  8611. };
  8612. }
  8613. // serchdataadd(searchKey)
  8614. // if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  8615. // angular.extend(filterData.requester, { 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO })
  8616. // }
  8617. api_user_data.fetchDataList('requester', filterData).then(function(response) {
  8618. var myData = response;
  8619. $scope.myData = myData.list;
  8620. });
  8621. }
  8622. api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function(response) {
  8623. if (response.status == 200) {
  8624. $scope.areas = response.list;
  8625. }
  8626. })
  8627. api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
  8628. if (response.status == 200) {
  8629. $scope.networktypes = response.list;
  8630. }
  8631. })
  8632. $scope.onChange = function(item) {
  8633. // console.log(item)
  8634. // $scope.requester.placeDTO = {};
  8635. api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
  8636. if (response.status == 200) {
  8637. $scope.places = response.list;
  8638. }
  8639. })
  8640. }
  8641. $scope.refreshDepts = function(key) {
  8642. var filterData = {
  8643. 'idx': 0,
  8644. 'sum': 5,
  8645. 'dept': {
  8646. 'name': key
  8647. }
  8648. };
  8649. UserService.fetchDataList('department', filterData).then(function(response) {
  8650. if (response.status == 200) {
  8651. $scope.depts = response.list;
  8652. }
  8653. })
  8654. }
  8655. $scope.ok = function() {
  8656. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  8657. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  8658. // } else if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  8659. // SweetAlert.swal("请求人学工号未填!", "请填写请求人学工号", "error");
  8660. // } else if (angular.isUndefined($scope.requester.requesterTypeDTO) || $scope.requester.requesterTypeDTO == null || $scope.requester.requesterTypeDTO == "") {
  8661. // SweetAlert.swal("请求人职务未填!", "请填写请求人职务", "error");
  8662. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  8663. SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
  8664. } else {
  8665. // var jry_placeDate={
  8666. // idx:0,
  8667. // sum:1000,
  8668. // place:{
  8669. // areaId:$scope.requester.areaDTO.id
  8670. // }
  8671. // };
  8672. // api_user.fetchDataList("place",jry_placeDate).then(function(){
  8673. // })
  8674. $modalInstance.close($scope.requester);
  8675. }
  8676. };
  8677. $scope.cancel = function() {
  8678. $modalInstance.dismiss('cancel');
  8679. };
  8680. },
  8681. resolve: {
  8682. items: function() {
  8683. return {
  8684. fetchItems: function(filterData, APIService) {
  8685. filterData = filterData || {};
  8686. if (!filterData.idx) {
  8687. filterData = {
  8688. idx: 0,
  8689. sum: 10
  8690. };
  8691. }
  8692. return options.templateOptions.fetchItems(filterData, APIService);
  8693. }
  8694. };
  8695. },
  8696. title: function() {
  8697. return options.templateOptions.modalTitle;
  8698. },
  8699. Restangular: function() {
  8700. return options.templateOptions.Restangular;
  8701. },
  8702. APIService: function() {
  8703. return options.templateOptions.ApiService;
  8704. },
  8705. UserService: function() {
  8706. return options.templateOptions.UserService;
  8707. }
  8708. }
  8709. });
  8710. modalInstance.result.then(function(selectedItem) {
  8711. console.log(selectedItem);
  8712. console.log(options);
  8713. if (selectedItem) {
  8714. var data = {
  8715. 'requester': selectedItem
  8716. };
  8717. // var jry_placeDate={
  8718. // idx:0,
  8719. // sum:1000,
  8720. // place:{
  8721. // areaId:selectedItem.areaDTO.id
  8722. // }
  8723. // };
  8724. // api_user.fetchDataList("place",jry_placeDate).then(function(){
  8725. // })
  8726. $scope.searchKey = selectedItem.account;
  8727. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  8728. options.templateOptions.UserService.addData('requester', data).then(function(response) {
  8729. if (response.status == 200) {
  8730. if (options.model) {
  8731. if (options.model.place) {
  8732. options.model.place.id = '';
  8733. }
  8734. if (options.model.area) {
  8735. options.model.area.id = '';
  8736. }
  8737. options.model.contacts = selectedItem.name;
  8738. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8739. options.model.contactsInformation = selectedItem.mphone;
  8740. } else if (selectedItem.operationSystem) {
  8741. } else {
  8742. options.model.contactsInformation = selectedItem.telephone;
  8743. }
  8744. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8745. // options.model.priority = { 'id': 2, 'name': '高' };
  8746. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8747. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  8748. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  8749. }
  8750. // options.model.houseNumber = '';
  8751. }
  8752. options.value(response.data);
  8753. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  8754. options.model.place.id = selectedItem.placeDTO.id
  8755. }
  8756. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  8757. options.model.area.id = selectedItem.areaDTO.id
  8758. }
  8759. // if (selectedItem.houseNumber) {
  8760. // options.model.houseNumber = selectedItem.houseNumber;
  8761. // }
  8762. }
  8763. })
  8764. }
  8765. }, function() {
  8766. //console.log('Modal dismissed at: ' + new Date());
  8767. });
  8768. // event.preventDefault();
  8769. },
  8770. changeRequeter: function(size, options, modal, modeldata) {
  8771. var modalInstance = modal.open({
  8772. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  8773. controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data) {
  8774. $scope.title = "修改报修人";
  8775. $scope.requester = {
  8776. id: modeldata.requester.id,
  8777. account: modeldata.requester.account,
  8778. name: modeldata.requester.name,
  8779. gender: modeldata.requester.gender,
  8780. email: modeldata.requester.email,
  8781. deptName: modeldata.requester.deptName,
  8782. mphone: modeldata.requester.mphone,
  8783. telephone: modeldata.requester.telephone,
  8784. studentNo: modeldata.requester.studentNo,
  8785. areaDTO: modeldata.requester.areaDTO,
  8786. placeDTO: modeldata.requester.placeDTO,
  8787. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  8788. };
  8789. $scope.onChangeadd = function(searchData) {
  8790. $scope.searchKey = searchData.account;
  8791. // $scope.searchDataadd = searchData;
  8792. var requesdata = angular.copy(searchData)
  8793. if (requesdata.mphone) {
  8794. delete requesdata.mphone;
  8795. }
  8796. $scope.requester = requesdata;
  8797. }
  8798. $scope.refreshUseradd = function(searchKey) { //请求人搜索
  8799. $scope.requester.account = searchKey;
  8800. $scope.searchData = searchKey;
  8801. serchdataadd(searchKey);
  8802. }
  8803. $scope.getMydata = function(x) {
  8804. $scope.searchField = JSON.parse(x[0]).account;
  8805. $scope.requester = JSON.parse(x[0]);
  8806. }
  8807. $scope.getMydataone = function(x) {
  8808. $scope.searchField = x;
  8809. $scope.requester.account = x;
  8810. }
  8811. serchdataadd();
  8812. function serchdataadd(searchKey) {
  8813. if (searchKey) {
  8814. var filterData = {
  8815. 'requester': {
  8816. 'searchKey': searchKey,
  8817. },
  8818. idx: 0,
  8819. sum: 10
  8820. };
  8821. } else {
  8822. var filterData = {
  8823. idx: 0,
  8824. sum: 10
  8825. };
  8826. }
  8827. api_user_data.fetchDataList('requester', filterData).then(function(response) {
  8828. var myData = response;
  8829. $scope.myData = myData.list;
  8830. });
  8831. }
  8832. api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function(response) {
  8833. if (response.status == 200) {
  8834. $scope.areas = response.list;
  8835. }
  8836. })
  8837. api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
  8838. if (response.status == 200) {
  8839. $scope.networktypes = response.list;
  8840. }
  8841. })
  8842. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  8843. api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function(response) {
  8844. if (response.status == 200) {
  8845. $scope.places = response.list;
  8846. }
  8847. })
  8848. }
  8849. $scope.onChange = function(item) {
  8850. // console.log(item)
  8851. $scope.requester.placeDTO = {};
  8852. api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
  8853. if (response.status == 200) {
  8854. $scope.places = response.list;
  8855. }
  8856. })
  8857. }
  8858. $scope.refreshDepts = function(key) {
  8859. var filterData = {
  8860. 'idx': 0,
  8861. 'sum': 5,
  8862. 'dept': {
  8863. 'name': key
  8864. }
  8865. };
  8866. UserService.fetchDataList('department', filterData).then(function(response) {
  8867. if (response.status == 200) {
  8868. $scope.depts = response.list;
  8869. }
  8870. })
  8871. }
  8872. $scope.ok = function() {
  8873. if ($scope.requester.account == "" || $scope.requester.name == "") {
  8874. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  8875. } else {
  8876. $modalInstance.close($scope.requester);
  8877. }
  8878. };
  8879. $scope.cancel = function() {
  8880. $modalInstance.dismiss('cancel');
  8881. };
  8882. },
  8883. // size: size,
  8884. resolve: {
  8885. items: function() {
  8886. return {
  8887. fetchItems: function(filterData, APIService) {
  8888. filterData = filterData || {};
  8889. if (!filterData.idx) {
  8890. filterData = {
  8891. idx: 0,
  8892. sum: 10
  8893. };
  8894. }
  8895. return options.templateOptions.fetchItems(filterData, APIService);
  8896. }
  8897. };
  8898. },
  8899. title: function() {
  8900. return options.templateOptions.modalTitle;
  8901. },
  8902. Restangular: function() {
  8903. return options.templateOptions.Restangular;
  8904. },
  8905. APIService: function() {
  8906. return options.templateOptions.ApiService;
  8907. },
  8908. UserService: function() {
  8909. return options.templateOptions.UserService;
  8910. }
  8911. }
  8912. });
  8913. modalInstance.result.then(function(selectedItem) {
  8914. if (selectedItem) {
  8915. if (options.model) {
  8916. if (options.model.place) {
  8917. options.model.place.id = '';
  8918. }
  8919. if (options.model.area) {
  8920. options.model.area.id = '';
  8921. }
  8922. options.model.contacts = selectedItem.name;
  8923. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8924. options.model.contactsInformation = selectedItem.mphone;
  8925. } else {
  8926. options.model.contactsInformation = selectedItem.telephone;
  8927. }
  8928. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  8929. options.model.place.id = selectedItem.placeDTO.id
  8930. }
  8931. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  8932. options.model.area.id = selectedItem.areaDTO.id
  8933. }
  8934. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8935. // options.model.priority = { 'id': 2, 'name': '高' };
  8936. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8937. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  8938. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  8939. }
  8940. }
  8941. // console.log($scope);
  8942. // $scope.$parent.$parent.$parent.model.requestershow = selectedItem;
  8943. var data = {
  8944. 'requester': selectedItem
  8945. };
  8946. options.templateOptions.UserService.addData('requester', data).then(function(response) {
  8947. if (response.status == 200) {
  8948. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  8949. options.value(response.data);
  8950. // SweetAlert.swal("修改成功!", "", "error");
  8951. } else {
  8952. // SweetAlert.swal("修改失败!", "请重试", "error");
  8953. }
  8954. })
  8955. // }
  8956. }
  8957. }, function() {
  8958. //console.log('Modal dismissed at: ' + new Date());
  8959. });
  8960. event.preventDefault();
  8961. }
  8962. }
  8963. };
  8964. },
  8965. controller: ['$scope', 'api_user_data', function($scope, api_user_data) {
  8966. $scope.options.initialValue = $scope.model[$scope.options.key];
  8967. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  8968. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8969. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  8970. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  8971. }
  8972. // //呼叫中心
  8973. // var cdrid = 15727076480;
  8974. // if (cdrid) {
  8975. // // var cdrid = cdrid;
  8976. // // var response={cdrid:'219023836'}
  8977. // var filterData = { "idx": 0, "sum": 10, "requester": { "mphone": cdrid, "telephone": cdrid, "selectType": 1 } }
  8978. // api_user_data.fetchDataList('requester', filterData).then(function(data) {
  8979. // var myData = data;
  8980. // // $rootScope.phone="";
  8981. // if (myData.list.length == 0) {
  8982. // var modalInstance = $modal.open({
  8983. // templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  8984. // controller: function($scope, $modalInstance, api_user_data) {
  8985. // $scope.title = "新增报修人";
  8986. // $scope.requester = {};
  8987. // $scope.onChangeadd = function(searchData) {
  8988. // $scope.searchKey = searchData.account;
  8989. // // $scope.searchDataadd = searchData;
  8990. // var requesdata = angular.copy(searchData)
  8991. // // if (requesdata.mphone) {
  8992. // // delete requesdata.mphone;
  8993. // // }
  8994. // if (requesdata.telephone) {
  8995. // delete requesdata.telephone;
  8996. // }
  8997. // angular.extend($scope.requester, requesdata);
  8998. // }
  8999. // $scope.refreshUseradd = function(searchKey) { //请求人搜索
  9000. // $scope.requester.account = searchKey;
  9001. // $scope.searchData = searchKey;
  9002. // serchdataadd(searchKey);
  9003. // }
  9004. // $scope.getMydata = function(x) {
  9005. // var reqestdatap = JSON.parse(x[0])
  9006. // if ($scope.requester.telephone) {
  9007. // delete reqestdatap.telephone;
  9008. // }
  9009. // $scope.searchField = JSON.parse(x[0]).account;
  9010. // angular.extend($scope.requester, reqestdatap);
  9011. // }
  9012. // $scope.getMydataone = function(x) {
  9013. // $scope.searchField = x;
  9014. // $scope.requester.account = x;
  9015. // }
  9016. // serchdataadd();
  9017. // function serchdataadd(searchKey) {
  9018. // if (searchKey) {
  9019. // var filterData = {
  9020. // 'requester': {
  9021. // 'searchKey': searchKey,
  9022. // },
  9023. // idx: 0,
  9024. // sum: 10
  9025. // };
  9026. // } else {
  9027. // var filterData = {
  9028. // idx: 0,
  9029. // sum: 10
  9030. // };
  9031. // }
  9032. // api_user_data.fetchDataList('requester', filterData).then(function(response) {
  9033. // var myData = response;
  9034. // $scope.myData = myData.list;
  9035. // });
  9036. // }
  9037. // // if ((/^1[34578]\d{9}$/.test($rootScope.phone))) {
  9038. // // $scope.requester = { 'mphone': $rootScope.phone };
  9039. // // } else {
  9040. // // $scope.requester = { 'telephone': $rootScope.phone };
  9041. // // }
  9042. // $scope.requester = { 'telephone': $rootScope.phone };
  9043. // $scope.ok = function() {
  9044. // $modalInstance.close($scope.requester);
  9045. // };
  9046. // $scope.cancel = function() {
  9047. // $modalInstance.dismiss('cancel');
  9048. // };
  9049. // },
  9050. // });
  9051. // modalInstance.result.then(function(selectedItem) {
  9052. // if (selectedItem) {
  9053. // if (selectedItem.telephone && !selectedItem.mphone) {
  9054. // selectedItem.telephone = angular.copy(selectedItem.mphone);
  9055. // delete selectedItem.mphone;
  9056. // }
  9057. // var data = {
  9058. // 'requester': selectedItem
  9059. // };
  9060. // api_user_data.addData('requester', data).then(function(response) {
  9061. // if (response.status == 200) {
  9062. // var data = { 'requestershow': response.data, 'incident': { 'requester': response.data, 'area': response.areaDTO, 'place': response.placeDTO, 'houseNumber': response.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } };
  9063. // angular.extend($scope.model, data)
  9064. // // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  9065. // }
  9066. // })
  9067. // }
  9068. // });
  9069. // } else if (myData.list.length == 1) {
  9070. // var data = { 'requestershow': myData.list[0], 'incident': { 'requester': myData.list[0], 'area': myData.list[0].areaDTO, 'place': myData.list[0].placeDTO, 'houseNumber': myData.list[0].houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } };
  9071. // angular.extend($scope.model, data);
  9072. // // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  9073. // } else {
  9074. // var modalInstance = $modal.open({
  9075. // templateUrl: 'assets/views/createincident.html',
  9076. // controller: function($scope, $modalInstance, api_user_data) {
  9077. // $scope.title = "请确定报修人";
  9078. // $scope.requester = myData.list;
  9079. // $scope.choice = function(requester) {
  9080. // $modalInstance.dismiss('cancel');
  9081. // var data = { 'requestershow': requester, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } };
  9082. // angular.extend($scope.model, data);
  9083. // // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  9084. // };
  9085. // $scope.cancel = function() {
  9086. // $modalInstance.dismiss('cancel');
  9087. // };
  9088. // },
  9089. // size: "lg"
  9090. // });
  9091. // }
  9092. // })
  9093. // }
  9094. }]
  9095. });
  9096. //业务系统信息
  9097. formlyConfigProvider.setType({
  9098. name: 'ui-wt_business_system',
  9099. templateUrl: 'assets/views/customform/tpl/ui-wt_business_system.html',
  9100. // wrapper: ['bootstrapHasError'],
  9101. defaultOptions: function(options, $scope) {
  9102. return {
  9103. templateOptions: {
  9104. checkform: function(options) {
  9105. if (options.model.requester) {
  9106. options.value(options.model.requester);
  9107. }
  9108. },
  9109. addRequeter: function(size, options, modal) {
  9110. event.preventDefault();
  9111. var modalInstance = modal.open({
  9112. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  9113. controller: function($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data) {
  9114. $scope.title = "新增报修人";
  9115. $scope.requester = {};
  9116. $scope.searchData = {};
  9117. // $scope.requesdata = ["key4", "xyz", "key3", "xxxx", "key2", "value2", "key1", "value1"];
  9118. $scope.onChangeadd = function(searchData) {
  9119. $scope.searchKey = searchData.account;
  9120. // $scope.searchDataadd = searchData;
  9121. var requesdata = angular.copy(searchData)
  9122. if (requesdata.mphone) {
  9123. delete requesdata.mphone;
  9124. }
  9125. $scope.requester = requesdata;
  9126. }
  9127. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  9128. $scope.requester.account = searchKey;
  9129. $scope.searchData = searchKey;
  9130. serchdataadd(searchKey);
  9131. }
  9132. $scope.getMydata = function (x) {
  9133. $scope.searchField = JSON.parse(x[0]).account;
  9134. $scope.requester = JSON.parse(x[0]);
  9135. }
  9136. $scope.getMydataone = function (x) {
  9137. $scope.searchField = x;
  9138. $scope.requester.account = x;
  9139. }
  9140. serchdataadd();
  9141. function serchdataadd(searchKey) {
  9142. if (searchKey) {
  9143. var filterData = {
  9144. 'requester': {
  9145. 'searchKey': searchKey,
  9146. },
  9147. idx: 0,
  9148. sum: 10
  9149. };
  9150. } else {
  9151. var filterData = {
  9152. idx: 0,
  9153. sum: 10
  9154. };
  9155. }
  9156. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  9157. var myData = response;
  9158. $scope.myData = myData.list;
  9159. });
  9160. }
  9161. api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function (response) {
  9162. if (response.status == 200) {
  9163. $scope.areas = response.list;
  9164. }
  9165. })
  9166. api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function (response) {
  9167. if (response.status == 200) {
  9168. $scope.networktypes = response.list;
  9169. }
  9170. })
  9171. $scope.requesterAreaid = "";
  9172. $scope.onChange = function (item) {
  9173. $scope.requesterAreaid = item.id;
  9174. api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function (response) {
  9175. if (response.status == 200) {
  9176. $scope.places = response.list;
  9177. delete $scope.requester.placeDTO;
  9178. }
  9179. })
  9180. }
  9181. $scope.refresh = function (searchVal) {
  9182. var faildata = {};
  9183. if ($scope.requesterAreaid) {
  9184. faildata = {
  9185. 'idx': 0,
  9186. 'sum': 1000,
  9187. 'place': { 'areaId': $scope.requesterAreaid, 'place': searchVal, 'selectType': 'pinyin_qs' }
  9188. }
  9189. } else {
  9190. faildata = {
  9191. 'idx': 0,
  9192. 'sum': 1000,
  9193. 'place': { 'place': searchVal, 'selectType': 'pinyin_qs' }
  9194. }
  9195. }
  9196. api_user_data.fetchDataList('place', faildata).then(function (response) {
  9197. $scope.places = response.list;
  9198. delete $scope.requester.placeDTO;
  9199. })
  9200. }
  9201. $scope.refreshDepts = function (key) {
  9202. var filterData = {
  9203. 'idx': 0,
  9204. 'sum': 5,
  9205. 'dept': {
  9206. 'name': key
  9207. }
  9208. };
  9209. UserService.fetchDataList('department', filterData).then(function (response) {
  9210. if (response.status == 200) {
  9211. $scope.depts = response.list;
  9212. }
  9213. })
  9214. }
  9215. $scope.ok = function () {
  9216. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  9217. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  9218. // } else if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  9219. // SweetAlert.swal("请求人学工号未填!", "请填写请求人学工号", "error");
  9220. // } else if (angular.isUndefined($scope.requester.requesterTypeDTO) || $scope.requester.requesterTypeDTO == null || $scope.requester.requesterTypeDTO == "") {
  9221. // SweetAlert.swal("请求人职务未填!", "请填写请求人职务", "error");
  9222. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  9223. SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
  9224. } else {
  9225. $scope.requesterId = $scope.requester.id;
  9226. var data = { incident: { requester: { id: $scope.requesterId } }, idx: 0, sum: 3 };
  9227. api_statistic.tableData(data, 'incident').then(function (data) {
  9228. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  9229. })
  9230. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  9231. if (newObj != oldObj) {
  9232. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  9233. }
  9234. })
  9235. $modalInstance.close($scope.requester);
  9236. }
  9237. };
  9238. $scope.cancel = function () {
  9239. $modalInstance.dismiss('cancel');
  9240. };
  9241. },
  9242. resolve: {
  9243. items: function () {
  9244. return {
  9245. fetchItems: function (filterData, APIService) {
  9246. filterData = filterData || {};
  9247. if (!filterData.idx) {
  9248. filterData = {
  9249. idx: 0,
  9250. sum: 10
  9251. };
  9252. }
  9253. return options.templateOptions.fetchItems(filterData, APIService);
  9254. }
  9255. };
  9256. },
  9257. title: function () {
  9258. return options.templateOptions.modalTitle;
  9259. },
  9260. Restangular: function () {
  9261. return options.templateOptions.Restangular;
  9262. },
  9263. APIService: function () {
  9264. return options.templateOptions.ApiService;
  9265. },
  9266. UserService: function () {
  9267. return options.templateOptions.UserService;
  9268. },
  9269. sco: function () {
  9270. return $scope;
  9271. }
  9272. }
  9273. });
  9274. modalInstance.result.then(function (selectedItem) {
  9275. console.log(selectedItem)
  9276. if (selectedItem) {
  9277. var data = {
  9278. 'requester': selectedItem
  9279. };
  9280. $scope.searchKey = selectedItem.account;
  9281. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  9282. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  9283. if (response.status == 200) {
  9284. if (options.model) {
  9285. if (options.model.place) {
  9286. options.model.place.id = '';
  9287. }
  9288. if (options.model.area) {
  9289. options.model.area.id = '';
  9290. }
  9291. options.model.contacts = selectedItem.name;
  9292. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  9293. options.model.contactsInformation = selectedItem.mphone;
  9294. } else {
  9295. options.model.contactsInformation = selectedItem.telephone;
  9296. }
  9297. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9298. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9299. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9300. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9301. }
  9302. }
  9303. options.value(response.data);
  9304. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  9305. options.model.place.id = selectedItem.placeDTO.id
  9306. }
  9307. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  9308. options.model.area.id = selectedItem.areaDTO.id
  9309. }
  9310. if (selectedItem.houseNumber) {
  9311. options.model.houseNumber = selectedItem.houseNumber
  9312. }
  9313. if (selectedItem.id) {
  9314. $scope.$parent.$parent.$parent.model.xxx = selectedItem.id;
  9315. options.model.account = selectedItem.account;
  9316. }
  9317. }
  9318. })
  9319. }
  9320. }, function () {
  9321. });
  9322. },
  9323. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  9324. var modalInstance = modal.open({
  9325. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  9326. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  9327. $scope.title = "修改报修人";
  9328. $scope.requester = {
  9329. id: modeldata.requester.id,
  9330. account: modeldata.requester.account,
  9331. name: modeldata.requester.name,
  9332. gender: modeldata.requester.gender,
  9333. email: modeldata.requester.email,
  9334. deptName: modeldata.requester.deptName,
  9335. mphone: modeldata.requester.mphone,
  9336. telephone: modeldata.requester.telephone,
  9337. studentNo: modeldata.requester.studentNo,
  9338. areaDTO: modeldata.requester.areaDTO,
  9339. placeDTO: modeldata.requester.placeDTO,
  9340. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  9341. };
  9342. $scope.onChangeadd = function (searchData) {
  9343. $scope.searchKey = searchData.account;
  9344. var requesdata = angular.copy(searchData)
  9345. if (requesdata.mphone) {
  9346. delete requesdata.mphone;
  9347. }
  9348. $scope.requester = requesdata;
  9349. }
  9350. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  9351. $scope.requester.account = searchKey;
  9352. $scope.searchData = searchKey;
  9353. serchdataadd(searchKey);
  9354. }
  9355. $scope.getMydata = function (x) {
  9356. $scope.searchField = JSON.parse(x[0]).account;
  9357. $scope.requester = JSON.parse(x[0]);
  9358. }
  9359. $scope.getMydataone = function (x) {
  9360. $scope.searchField = x;
  9361. $scope.requester.account = x;
  9362. }
  9363. serchdataadd();
  9364. function serchdataadd(searchKey) {
  9365. if (searchKey) {
  9366. var filterData = {
  9367. 'requester': {
  9368. 'searchKey': searchKey,
  9369. },
  9370. idx: 0,
  9371. sum: 10
  9372. };
  9373. } else {
  9374. var filterData = {
  9375. idx: 0,
  9376. sum: 10
  9377. };
  9378. }
  9379. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  9380. var myData = response;
  9381. $scope.myData = myData.list;
  9382. });
  9383. }
  9384. api_user_data.fetchDataList('area', { idx: 0, sum: 1000 }).then(function (response) {
  9385. if (response.status == 200) {
  9386. $scope.areas = response.list;
  9387. }
  9388. })
  9389. api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function (response) {
  9390. if (response.status == 200) {
  9391. $scope.networktypes = response.list;
  9392. }
  9393. })
  9394. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  9395. api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function (response) {
  9396. if (response.status == 200) {
  9397. $scope.places = response.list;
  9398. }
  9399. })
  9400. }
  9401. $scope.onChange = function (item) {
  9402. $scope.requester.placeDTO = {};
  9403. api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function (response) {
  9404. if (response.status == 200) {
  9405. $scope.places = response.list;
  9406. }
  9407. })
  9408. }
  9409. $scope.refreshDepts = function (key) {
  9410. var filterData = {
  9411. 'idx': 0,
  9412. 'sum': 5,
  9413. 'dept': {
  9414. 'name': key
  9415. }
  9416. };
  9417. UserService.fetchDataList('department', filterData).then(function (response) {
  9418. if (response.status == 200) {
  9419. $scope.depts = response.list;
  9420. }
  9421. })
  9422. }
  9423. $scope.ok = function () {
  9424. if ($scope.requester.account == "" || $scope.requester.name == "") {
  9425. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  9426. } else {
  9427. $modalInstance.close($scope.requester);
  9428. }
  9429. };
  9430. $scope.cancel = function () {
  9431. $modalInstance.dismiss('cancel');
  9432. };
  9433. },
  9434. resolve: {
  9435. items: function () {
  9436. return {
  9437. fetchItems: function (filterData, APIService) {
  9438. filterData = filterData || {};
  9439. if (!filterData.idx) {
  9440. filterData = {
  9441. idx: 0,
  9442. sum: 10
  9443. };
  9444. }
  9445. return options.templateOptions.fetchItems(filterData, APIService);
  9446. }
  9447. };
  9448. },
  9449. title: function () {
  9450. return options.templateOptions.modalTitle;
  9451. },
  9452. Restangular: function () {
  9453. return options.templateOptions.Restangular;
  9454. },
  9455. APIService: function () {
  9456. return options.templateOptions.ApiService;
  9457. },
  9458. UserService: function () {
  9459. return options.templateOptions.UserService;
  9460. }
  9461. }
  9462. });
  9463. modalInstance.result.then(function (selectedItem) {
  9464. console.log(selectedItem)
  9465. if (selectedItem) {
  9466. if (options.model) {
  9467. if (options.model.place) {
  9468. options.model.place.id = '';
  9469. }
  9470. if (options.model.area) {
  9471. options.model.area.id = '';
  9472. }
  9473. options.model.contacts = selectedItem.name;
  9474. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  9475. options.model.contactsInformation = selectedItem.mphone;
  9476. } else {
  9477. options.model.contactsInformation = selectedItem.telephone;
  9478. }
  9479. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  9480. options.model.place.id = selectedItem.placeDTO.id
  9481. }
  9482. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  9483. options.model.area.id = selectedItem.areaDTO.id
  9484. }
  9485. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9486. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9487. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9488. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9489. }
  9490. }
  9491. var data = {
  9492. 'requester': selectedItem
  9493. };
  9494. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  9495. if (response.status == 200) {
  9496. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  9497. options.value(response.data);
  9498. } else {
  9499. }
  9500. })
  9501. }
  9502. }, function () {
  9503. });
  9504. event.preventDefault();
  9505. }
  9506. }
  9507. };
  9508. },
  9509. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  9510. $scope.options.initialValue = $scope.model[$scope.options.key];
  9511. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  9512. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9513. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9514. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9515. }
  9516. }]
  9517. });
  9518. // 请求人选控件
  9519. formlyConfigProvider.setType({
  9520. name: "ui-requesterselect",
  9521. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  9522. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  9523. defaultOptions: function (options, $scope) {
  9524. return {
  9525. templateOptions: {
  9526. // checkform: function(options) {
  9527. // if (options.model.requestershow) {
  9528. // options.value(options.model.requestershow);
  9529. // }
  9530. // },
  9531. validators: {
  9532. required: {
  9533. expression: function (viewValue, modelValue) {
  9534. var value = modelValue || viewValue;
  9535. return value.length >= 1;
  9536. }
  9537. }
  9538. },
  9539. openModal: function (size, options, modal) { //查找弹出框
  9540. var modelObject = options.value();
  9541. var searchModal = function (filterSearchData) {
  9542. var modalInstance = modal.open({
  9543. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  9544. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  9545. $scope.langs = i18nService.getAllLangs();
  9546. $scope.lang = 'zh-cn';
  9547. i18nService.setCurrentLang($scope.lang);
  9548. $scope.gridOptions = {};
  9549. $scope.gridOptions.data = 'myData';
  9550. $scope.gridOptions.enableColumnResizing = true;
  9551. $scope.gridOptions.enableFiltering = true;
  9552. $scope.gridOptions.enableGridMenu = false;
  9553. $scope.gridOptions.enableRowSelection = true;
  9554. $scope.gridOptions.showGridFooter = true;
  9555. $scope.gridOptions.showColumnFooter = false;
  9556. $scope.gridOptions.fastWatch = true;
  9557. $scope.gridOptions.useExternalFiltering = true;
  9558. $scope.gridOptions.useExternalPagination = true;
  9559. $scope.gridOptions.paginationPageSizes = [10];
  9560. $scope.gridOptions.paginationPageSize = 10;
  9561. $scope.gridOptions.multiSelect = false;
  9562. $scope.gridOptions.rowIdentity = function (row) {
  9563. return row.id;
  9564. };
  9565. $scope.gridOptions.getRowIdentity = function (row) {
  9566. return row.id;
  9567. };
  9568. $scope.gridOptions.columnDefs = [
  9569. { name: 'account', displayName: '人员编号', width: 140 },
  9570. { name: 'name', displayName: '姓名', width: 100 },
  9571. { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
  9572. { name: 'mphone', displayName: '电话', width: 100, enableFiltering: false },
  9573. { name: 'email', displayName: '邮件', width: 100 },
  9574. { name: 'areaDTO.area', displayName: '区域', width: 100, enableFiltering: false },
  9575. { name: 'placeDTO.place', displayName: '地点', enableFiltering: false }
  9576. ];
  9577. $scope.gridOptions.onRegisterApi = function (gridApi) {
  9578. $scope.gridApi = gridApi;
  9579. // var filtersData = $scope.memoryfilterData;
  9580. // filtersData.idx = newPage - 1;
  9581. // filtersData.sum = pageSize;
  9582. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  9583. var filtersData = $scope.memoryfilterData;
  9584. filtersData.idx = newPage - 1;
  9585. filtersData.sum = pageSize;
  9586. $scope.loadData(filtersData);
  9587. });
  9588. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  9589. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  9590. $scope.selected.item = data.entity;
  9591. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  9592. });
  9593. gridApi.core.on.filterChanged($scope, function () {
  9594. var grid = this.grid;
  9595. var filtersData = {
  9596. idx: 0,
  9597. sum: 10
  9598. // 'requester': { 'userType': 1 }
  9599. };
  9600. angular.forEach(grid.columns, function (item) {
  9601. if (item.enableFiltering) {
  9602. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  9603. if (angular.isUndefined(filtersData['requester'])) {
  9604. filtersData['requester'] = {};
  9605. }
  9606. filtersData['requester'][item.field] = item.filters[0].term;
  9607. }
  9608. }
  9609. });
  9610. $scope.memoryfilterData = filtersData;
  9611. $scope.loadData(filtersData);
  9612. });
  9613. };
  9614. $scope.memoryfilterData = defaultFilterData = {
  9615. "idx": 0,
  9616. "sum": 10
  9617. };
  9618. $scope.loadData = function (filterData) {
  9619. if (!filterData.requester) {
  9620. filterData.requester = {};
  9621. }
  9622. if (scope.roleidcode) {
  9623. angular.extend(filterData['requester'], { 'userType': 1 });
  9624. }
  9625. items.fetchItems(filterData, APIService).then(function (data) {
  9626. var myData = Restangular.stripRestangular(data);
  9627. $scope.gridOptions.totalItems = myData.totalNum;
  9628. $scope.myData = myData.list;
  9629. });
  9630. };
  9631. $scope.title = title;
  9632. if (searchDatas) {
  9633. $scope.loadData(searchDatas);
  9634. } else {
  9635. $scope.loadData({
  9636. idx: 0,
  9637. sum: 10,
  9638. });
  9639. }
  9640. $scope.selected = {
  9641. item: {}
  9642. };
  9643. $scope.ok = function () {
  9644. $modalInstance.close($scope.selected.item);
  9645. };
  9646. $scope.cancel = function () {
  9647. $modalInstance.dismiss('cancel');
  9648. };
  9649. },
  9650. size: size,
  9651. resolve: {
  9652. items: function () {
  9653. return {
  9654. fetchItems: function (filterData, APIService) {
  9655. filterData = filterData || {};
  9656. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  9657. filterData = {
  9658. idx: 0,
  9659. sum: 10
  9660. };
  9661. }
  9662. return options.templateOptions.fetchItems(filterData, APIService);
  9663. }
  9664. };
  9665. },
  9666. title: function () {
  9667. return options.templateOptions.modalTitle;
  9668. },
  9669. Restangular: function () {
  9670. return options.templateOptions.Restangular;
  9671. },
  9672. APIService: function () {
  9673. return options.templateOptions.ApiService;
  9674. },
  9675. language: function () {
  9676. return options.templateOptions.language;
  9677. },
  9678. searchDatas: function () {
  9679. return filterSearchData;
  9680. },
  9681. scope: function () {
  9682. return $scope;
  9683. }
  9684. }
  9685. });
  9686. modalInstance.result.then(function (selectedItem) {
  9687. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  9688. selectedItem.telephone = $scope.model.incident.contactsInformation;
  9689. }
  9690. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  9691. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  9692. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  9693. if ($scope.model) {
  9694. if ($scope.model.incident.place) {
  9695. $scope.model.incident.place.id = '';
  9696. }
  9697. if ($scope.model.area) {
  9698. $scope.model.incident.area.id = '';
  9699. }
  9700. $scope.model.incident.contacts = selectedItem.name;
  9701. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  9702. $scope.model.incident.contactsInformation = selectedItem.mphone;
  9703. } else {
  9704. $scope.model.incident.contactsInformation = selectedItem.telephone;
  9705. }
  9706. $scope.model.incident.houseNumber = '';
  9707. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9708. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9709. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9710. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9711. }
  9712. }
  9713. $scope.options.value(selectedItem);
  9714. $scope.searchData = selectedItem.account;
  9715. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  9716. $scope.model.incident.place.id = selectedItem.placeDTO.id
  9717. }
  9718. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  9719. $scope.model.incident.area.id = selectedItem.areaDTO.id
  9720. }
  9721. if (selectedItem.houseNumber) {
  9722. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  9723. }
  9724. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  9725. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9726. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9727. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  9728. }
  9729. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  9730. options.templateOptions.callback(selectedItem, options);
  9731. }
  9732. if (!$scope.roleidcode) {
  9733. $scope.charging(selectedItem, modal)
  9734. }
  9735. $scope.recentlyincident(selectedItem);
  9736. }, function () {
  9737. //console.log('Modal dismissed at: ' + new Date());
  9738. });
  9739. }
  9740. searchModal();
  9741. // }
  9742. }
  9743. }
  9744. };
  9745. },
  9746. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  9747. $scope.roleidcode = true;
  9748. // $scope.options.initialValue = undefined;
  9749. if ($rootScope.user && $rootScope.user.role) {
  9750. angular.forEach($rootScope.user.role, function (item) {
  9751. if (item.rolecode == "call center") {
  9752. $scope.roleidcode = false;
  9753. }
  9754. })
  9755. }
  9756. $scope.recently = false;
  9757. $scope.recentlyincident = function (key, model) { //关联事件
  9758. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", { "idx": 0, "sum": 4, incident: { requester: { id: key.id } } }).then(function (response) {
  9759. if (response.status == 200) {
  9760. $scope.recently = true;
  9761. $scope.recentincident = response.list;
  9762. } else {
  9763. $scope.recently = false;
  9764. }
  9765. })
  9766. $scope.bodyHeight = window.innerHeight - 100;
  9767. $(window).resize(function () {
  9768. $scope.bodyHeight = window.innerHeight - 100;
  9769. });
  9770. // $scope.shows = false;
  9771. $scope.tempData = {};
  9772. $scope.close = function () {
  9773. $scope.changes = !$scope.changes;
  9774. event.preventDefault();
  9775. }
  9776. }
  9777. $scope.charging = function (key, model) { //计费弹出框
  9778. //用户信息
  9779. $scope.information = {};
  9780. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", { "userId": key.account }).then(function (response) {
  9781. // if (response.status == 200) {
  9782. if (response && response.data) {
  9783. angular.extend($scope.information, response.data[0]);
  9784. // $scope.information = response.data[0];
  9785. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  9786. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  9787. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  9788. } else if (response.err) {
  9789. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  9790. }
  9791. // }
  9792. })
  9793. //上网明细
  9794. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", { "userId": key.account, "limit": "10", "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'), "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') }).then(function (response) {
  9795. // if (response.status == 200) {
  9796. if (response && response.data) {
  9797. angular.forEach(response.data, function (item, index) {
  9798. if (item.logoutTime) {
  9799. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  9800. }
  9801. if (item.loginTime) {
  9802. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  9803. }
  9804. })
  9805. $scope.logininform = response.data;
  9806. } else if (response.err) {
  9807. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  9808. }
  9809. })
  9810. //黑名单
  9811. // $scope.information.blacklist = "否"
  9812. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", { "userId": key.account }).then(function (response) {
  9813. // if (response.status == 200) {
  9814. // $scope.logininformation = response.data;
  9815. if (response) {
  9816. if (response.data || response.data != null) {
  9817. $scope.information.blacklist = "是"
  9818. } else {
  9819. if (response.err) {
  9820. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  9821. } else {
  9822. $scope.information.blacklist = "否"
  9823. }
  9824. }
  9825. }
  9826. // }
  9827. })
  9828. $scope.bodyHeight = window.innerHeight - 100;
  9829. $(window).resize(function () {
  9830. $scope.bodyHeight = window.innerHeight - 100;
  9831. });
  9832. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  9833. // $scope.closepages = function(e) {
  9834. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  9835. // event.preventDefault();
  9836. // };
  9837. // $scope.shows = false;
  9838. $scope.tempData = {};
  9839. $scope.close = function () {
  9840. $scope.changes = !$scope.changes;
  9841. event.preventDefault();
  9842. }
  9843. }
  9844. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function (response) {
  9845. if (response.status == 200) {
  9846. $scope.networktypes = response.list;
  9847. } else {
  9848. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  9849. }
  9850. })
  9851. function serchdata(searchKey) {
  9852. if (searchKey) {
  9853. var filterData = {
  9854. 'requester': {
  9855. 'searchKey': searchKey
  9856. // 'userType': 1
  9857. },
  9858. idx: 0,
  9859. sum: 10
  9860. };
  9861. } else {
  9862. var filterData = {
  9863. 'idx': 0,
  9864. 'requester': {},
  9865. 'sum': 10
  9866. };
  9867. }
  9868. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  9869. angular.extend(filterData.requester, { 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO });
  9870. if (!$scope.options.model.contactsInformation) {
  9871. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  9872. }
  9873. }
  9874. if ($scope.roleidcode) {
  9875. angular.extend(filterData['requester'], { 'userType': 1 });
  9876. }
  9877. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  9878. var myData = response;
  9879. $scope.myData = myData.list;
  9880. });
  9881. }
  9882. $scope.searchData = {};
  9883. $scope.refreshUser = function (searchKey) { //请求人搜索
  9884. if (searchKey && searchKey != "") {
  9885. serchdata(searchKey);
  9886. }
  9887. }
  9888. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  9889. if (!$scope.roleidcode) {
  9890. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  9891. }
  9892. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  9893. }
  9894. $scope.onChange = function (searchData) {
  9895. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  9896. searchData.telephone = $scope.model.incident.contactsInformation;;
  9897. }
  9898. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  9899. if (!$scope.roleidcode) {
  9900. $scope.charging(searchData);
  9901. }
  9902. $scope.recentlyincident(searchData);
  9903. $scope.accountshow = false;
  9904. if ($scope.model.incident) {
  9905. if ($scope.model.incident.place) {
  9906. $scope.model.incident.place.id = '';
  9907. }
  9908. if ($scope.model.incident.area) {
  9909. $scope.model.incident.area.id = '';
  9910. }
  9911. $scope.model.incident.contacts = searchData.name;
  9912. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  9913. $scope.model.incident.contactsInformation = searchData.mphone;
  9914. } else {
  9915. $scope.model.incident.contactsInformation = searchData.telephone;
  9916. }
  9917. $scope.model.incident.houseNumber = '';
  9918. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  9919. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9920. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9921. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  9922. }
  9923. }
  9924. $scope.options.value(searchData);
  9925. $scope.searchKey = searchData.account;
  9926. if (searchData.placeDTO && searchData.placeDTO.id) {
  9927. $scope.model.incident.place.id = searchData.placeDTO.id
  9928. }
  9929. if (searchData.areaDTO && searchData.areaDTO.id) {
  9930. $scope.model.incident.area.id = searchData.areaDTO.id
  9931. }
  9932. if (searchData.houseNumber) {
  9933. $scope.model.incident.houseNumber = searchData.houseNumber;
  9934. }
  9935. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  9936. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  9937. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  9938. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  9939. }
  9940. }
  9941. }]
  9942. });
  9943. //ui-grid-table展示控件
  9944. formlyConfigProvider.setType({
  9945. name: 'ui-grid-table',
  9946. // extends: 'multiCheckbox',//去掉冒号
  9947. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  9948. defaultOptions: function (options) {
  9949. return {
  9950. templateOptions: {
  9951. linkage: function () {
  9952. },
  9953. },
  9954. };
  9955. },
  9956. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  9957. var loginUser = $rootScope.user;
  9958. $scope.langs = i18nService.getAllLangs();
  9959. $scope.lang = 'zh-cn';
  9960. i18nService.setCurrentLang($scope.lang);
  9961. $scope.gridOptions = {};
  9962. $scope.gridOptions.data = 'myData';
  9963. $scope.gridOptions.enableColumnResizing = true;
  9964. $scope.gridOptions.enableGridMenu = false;
  9965. $scope.gridOptions.enableRowSelection = true;
  9966. $scope.gridOptions.showGridFooter = false;
  9967. $scope.gridOptions.showColumnFooter = false;
  9968. $scope.gridOptions.fastWatch = true;
  9969. $scope.gridOptions.useExternalFiltering = true;
  9970. $scope.gridOptions.useExternalPagination = false;
  9971. $scope.gridOptions.paginationPageSizes = [10];
  9972. $scope.gridOptions.paginationPageSize = 3;
  9973. $scope.gridOptions.multiSelect = false;
  9974. $scope.gridOptions.rowIdentity = function (row) {
  9975. return row.id;
  9976. };
  9977. $scope.gridOptions.getRowIdentity = function (row) {
  9978. return row.id;
  9979. };
  9980. $scope.gridOptions.columnDefs = [
  9981. { name: 'item', displayName: '序号', width: 80, enableFiltering: false },
  9982. { name: 'incidentsign', displayName: '单号', width: 80, enableFiltering: false },
  9983. { name: 'description', displayName: '主题', width: 80, enableFiltering: false },
  9984. { name: 'state.name', displayName: '状态', width: 110, enableFiltering: false },
  9985. { name: 'acceptDate', displayName: '创建时间', width: 160, enableFiltering: false },
  9986. { name: 'requester.name', displayName: '请求人', width: 80, enableFiltering: false },
  9987. { name: 'handlingPersonnelUser.name', displayName: '处理人', width: 160, enableFiltering: false },
  9988. { name: 'place.place', displayName: '区域地点', width: 160, enableFiltering: false },
  9989. ];
  9990. // var defaultFilterData = {
  9991. // "idx": 0,
  9992. // "sum": 3
  9993. // };
  9994. // // //分页控制
  9995. $scope.gridOptions.onRegisterApi = function (gridApi) {
  9996. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  9997. var filtersData = $scope.memoryfilterData;
  9998. filtersData.idx = newPage - 1;
  9999. filtersData.sum = pageSize;
  10000. $scope.refreshData('expand-right', filtersData);
  10001. });
  10002. // 表格单选事件
  10003. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10004. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  10005. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  10006. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  10007. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  10008. str = str.split("").reverse().join("");
  10009. var del = addstr.split("").reverse().join("");
  10010. // console.log(del);
  10011. var reg = new RegExp(del);
  10012. str = str.replace(reg, '');
  10013. str = str.split("").reverse().join("")
  10014. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  10015. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  10016. str += data.entity.description;
  10017. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  10018. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  10019. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  10020. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  10021. }
  10022. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  10023. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  10024. });
  10025. };
  10026. // 刷新表格
  10027. setInterval(function () {
  10028. // console.log($scope.myData);
  10029. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  10030. // console.log($scope.myData);
  10031. if ($scope.myData != null) {
  10032. for (var i = 0; i < $scope.myData.length; i++) {
  10033. //添加序号
  10034. $scope.myData[i]['item'] = i + 1;
  10035. }
  10036. }
  10037. }, 1000)
  10038. }
  10039. });
  10040. //处理人信息
  10041. formlyConfigProvider.setType({
  10042. name: "ui-userinformation",
  10043. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  10044. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10045. defaultOptions: function (options) {
  10046. return {
  10047. templateOptions: {}
  10048. };
  10049. },
  10050. controller: ['$scope', function ($scope) {
  10051. $scope.group = "";
  10052. $scope.role = "";
  10053. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10054. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10055. } else {
  10056. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10057. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10058. }
  10059. }
  10060. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10061. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10062. } else {
  10063. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10064. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10065. }
  10066. }
  10067. $scope.options.templateOptions.that = $scope;
  10068. }]
  10069. });
  10070. //处理界面处理人信息
  10071. formlyConfigProvider.setType({
  10072. name: "ui-handler",
  10073. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  10074. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10075. defaultOptions: function (options) {
  10076. return {
  10077. templateOptions: {}
  10078. };
  10079. },
  10080. controller: ['$scope', function ($scope) {
  10081. $scope.group = "";
  10082. // $scope.role="";
  10083. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10084. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10085. } else {
  10086. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10087. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10088. }
  10089. }
  10090. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  10091. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  10092. // }else{
  10093. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  10094. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  10095. // }
  10096. // }
  10097. $scope.options.templateOptions.that = $scope;
  10098. }]
  10099. });
  10100. //打电话
  10101. formlyConfigProvider.setType({
  10102. name: "ui-inputcall",
  10103. extends: 'input',
  10104. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  10105. defaultOptions: function (options) {
  10106. return {
  10107. templateOptions: {
  10108. transform: function (value) { }
  10109. }
  10110. };
  10111. },
  10112. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  10113. $scope.dialout = function (teleno) {
  10114. var gid = "@0"
  10115. var telephone = '9' + teleno
  10116. $rootScope.callout = 2;
  10117. if ($rootScope.takes) {
  10118. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  10119. if (data.errno == 0) {
  10120. $rootScope.status = 6;
  10121. }
  10122. })
  10123. } else {
  10124. SweetAlert.swal({
  10125. title: "呼叫失败",
  10126. text: "请先签入呼叫中心!",
  10127. type: "error",
  10128. confirmButtonColor: "#DD6B55"
  10129. });
  10130. }
  10131. }
  10132. $scope.options.templateOptions.that = $scope;
  10133. }]
  10134. });
  10135. //关闭界面处理人信息
  10136. formlyConfigProvider.setType({
  10137. name: "ui-closehandler",
  10138. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  10139. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10140. defaultOptions: function (options) {
  10141. return {
  10142. templateOptions: {}
  10143. };
  10144. },
  10145. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  10146. $scope.dialout = function (teleno) {
  10147. var gid = "@0"
  10148. var telephone = '9' + teleno
  10149. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  10150. if (data.errno == 0) {
  10151. $rootScope.status = 6;
  10152. }
  10153. })
  10154. }
  10155. $scope.options.templateOptions.that = $scope;
  10156. }]
  10157. });
  10158. //用户单选控件
  10159. formlyConfigProvider.setType({
  10160. name: "ui-userselect",
  10161. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  10162. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10163. defaultOptions: function (options) {
  10164. return {
  10165. templateOptions: {
  10166. openModal: function (size, options, modal) {
  10167. console.log(modal);
  10168. var modalInstance = modal.open({
  10169. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10170. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  10171. $scope.langs = i18nService.getAllLangs();
  10172. $scope.lang = 'zh-cn';
  10173. i18nService.setCurrentLang($scope.lang);
  10174. $scope.gridOptions = {};
  10175. $scope.gridOptions.data = 'myData';
  10176. $scope.gridOptions.enableColumnResizing = true;
  10177. $scope.gridOptions.enableFiltering = true;
  10178. $scope.gridOptions.enableGridMenu = false;
  10179. $scope.gridOptions.showGridFooter = true;
  10180. $scope.gridOptions.showColumnFooter = false;
  10181. $scope.gridOptions.fastWatch = true;
  10182. $scope.gridOptions.useExternalFiltering = true;
  10183. $scope.gridOptions.useExternalPagination = true;
  10184. $scope.gridOptions.paginationPageSizes = [20];
  10185. $scope.gridOptions.paginationPageSize = 20;
  10186. $scope.gridOptions.multiSelect = false;
  10187. $scope.gridOptions.rowIdentity = function (row) {
  10188. return row.id;
  10189. };
  10190. $scope.gridOptions.getRowIdentity = function (row) {
  10191. return row.id;
  10192. };
  10193. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  10194. $scope.gridOptions.columnDefs = [
  10195. { name: 'account', displayName: '人员编号', width: 120 },
  10196. {
  10197. name: 'name',
  10198. displayName: '姓名',
  10199. width: 100,
  10200. cellTemplate: '<div>' +
  10201. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  10202. '</div>'
  10203. },
  10204. { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
  10205. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  10206. { name: 'email', displayName: '邮箱', width: 150, enableFiltering: false },
  10207. { name: 'dept.dept', displayName: '部门', width: 130, enableFiltering: false },
  10208. { name: 'taskCount', displayName: '处理中事件数', enableFiltering: false }
  10209. ];
  10210. // $scope.selectButtonClick
  10211. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10212. $scope.gridApi = gridApi;
  10213. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10214. var filtersData = $scope.memoryfilterData;
  10215. filtersData.idx = newPage - 1;
  10216. filtersData.sum = pageSize;
  10217. $scope.loadData(filtersData);
  10218. //console.log(pageSize);
  10219. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  10220. });
  10221. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10222. $scope.selected.items = data.entity;
  10223. //console.log(data);
  10224. });
  10225. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  10226. $scope.selected.items = data.entity;
  10227. //console.log(data);
  10228. });
  10229. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  10230. // // if (row.entity.age > 45) {
  10231. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10232. // // }
  10233. // };
  10234. gridApi.core.on.filterChanged($scope, function () {
  10235. var grid = this.grid;
  10236. var filtersData = {
  10237. idx: 0,
  10238. sum: 20,
  10239. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  10240. };
  10241. angular.forEach(grid.columns, function (item) {
  10242. if (item.enableFiltering) {
  10243. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  10244. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10245. if (angular.isUndefined(filtersData['user'])) {
  10246. filtersData['user'] = {};
  10247. }
  10248. filtersData['user'][item.field] = item.filters[0].term;
  10249. }
  10250. }
  10251. });
  10252. $scope.memoryfilterData = filtersData;
  10253. $scope.loadData(filtersData);
  10254. });
  10255. };
  10256. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  10257. // if (row.entity.age > 45) {
  10258. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10259. // }
  10260. // },
  10261. $scope.onDblClick = function (data, event) {
  10262. // $scope.selected.items = data.entity;
  10263. $scope.selectButtonClick(data, event);
  10264. };
  10265. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  10266. // $scope.selected.items = data.entity;
  10267. // })
  10268. // };
  10269. $scope.memoryfilterData = {
  10270. "idx": 0,
  10271. "sum": 20,
  10272. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  10273. }
  10274. $scope.loadData = function (filterData) {
  10275. // console.log("filtersData=111" + JSON.stringify(filterData))
  10276. items.fetchItems(filterData, APIService).then(function (data) {
  10277. var myData = Restangular.stripRestangular(data);
  10278. $scope.gridOptions.totalItems = myData.totalNum;
  10279. $scope.myData = myData.list;
  10280. });
  10281. };
  10282. $scope.title = title;
  10283. $scope.loadData({
  10284. idx: 0,
  10285. sum: 20,
  10286. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  10287. });
  10288. $scope.selected = {
  10289. items: {}
  10290. };
  10291. $scope.ok = function () {
  10292. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  10293. // onDataCallback($scope.selected.item, parentScope);
  10294. // }
  10295. $modalInstance.close($scope.selected.items);
  10296. };
  10297. $scope.cancel = function () {
  10298. $modalInstance.dismiss('cancel');
  10299. };
  10300. },
  10301. size: size,
  10302. resolve: {
  10303. items: function () {
  10304. return {
  10305. fetchItems: function (filterData, APIService) {
  10306. filterData = filterData || {};
  10307. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10308. filterData = {
  10309. idx: 0,
  10310. sum: 20,
  10311. "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  10312. };
  10313. }
  10314. return options.templateOptions.fetchItems(filterData, APIService);
  10315. }
  10316. };
  10317. },
  10318. title: function () {
  10319. return options.templateOptions.label;
  10320. },
  10321. Restangular: function () {
  10322. return options.templateOptions.Restangular;
  10323. },
  10324. APIService: function () {
  10325. return options.templateOptions.ApiService;
  10326. },
  10327. onDataCallback: function () {
  10328. return options.templateOptions.callback;
  10329. },
  10330. parentScope: function () {
  10331. return options.templateOptions.that;
  10332. }
  10333. }
  10334. });
  10335. modalInstance.result.then(function (selectedItem) {
  10336. // console.log(selectedItem);
  10337. options.value(selectedItem);
  10338. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  10339. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  10340. }
  10341. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  10342. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  10343. }
  10344. }, function () {
  10345. //console.log('Modal dismissed at: ' + new Date());
  10346. });
  10347. }
  10348. }
  10349. };
  10350. },
  10351. controller: ['$scope', function ($scope) {
  10352. $scope.options.templateOptions.that = $scope;
  10353. }]
  10354. });
  10355. //用户单选控件(dd 单选input带搜索)
  10356. formlyConfigProvider.setType({
  10357. name: "ui-userselectSearch",
  10358. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  10359. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10360. defaultOptions: function (options) {
  10361. return {
  10362. templateOptions: {
  10363. openModal: function (size, options, modal) {
  10364. var modalInstance = modal.open({
  10365. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10366. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  10367. $scope.langs = i18nService.getAllLangs();
  10368. $scope.lang = 'zh-cn';
  10369. i18nService.setCurrentLang($scope.lang);
  10370. $scope.gridOptions = {};
  10371. $scope.gridOptions.data = 'myData';
  10372. $scope.gridOptions.enableColumnResizing = true;
  10373. $scope.gridOptions.enableFiltering = true;
  10374. $scope.gridOptions.enableGridMenu = false;
  10375. $scope.gridOptions.showGridFooter = true;
  10376. $scope.gridOptions.showColumnFooter = false;
  10377. $scope.gridOptions.fastWatch = true;
  10378. $scope.gridOptions.useExternalFiltering = true;
  10379. $scope.gridOptions.useExternalPagination = true;
  10380. $scope.gridOptions.paginationPageSizes = [20];
  10381. $scope.gridOptions.paginationPageSize = 20;
  10382. $scope.gridOptions.multiSelect = false;
  10383. $scope.gridOptions.rowIdentity = function (row) {
  10384. return row.id;
  10385. };
  10386. $scope.gridOptions.getRowIdentity = function (row) {
  10387. return row.id;
  10388. };
  10389. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  10390. $scope.gridOptions.columnDefs = [
  10391. { name: 'account', displayName: '人员编号', width: 120 },
  10392. {
  10393. name: 'name',
  10394. displayName: '姓名',
  10395. width: 100,
  10396. cellTemplate: '<div>' +
  10397. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  10398. '</div>'
  10399. },
  10400. { name: 'gender', displayName: '性别', width: 80, enableFiltering: false },
  10401. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  10402. { name: 'email', displayName: '邮箱', width: 150, enableFiltering: false },
  10403. { name: 'dept.dept', displayName: '部门', width: 130, enableFiltering: false },
  10404. { name: 'taskCount', displayName: '处理中事件数', enableFiltering: false }
  10405. ];
  10406. // $scope.selectButtonClick
  10407. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10408. $scope.gridApi = gridApi;
  10409. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10410. var filtersData = $scope.memoryfilterData;
  10411. filtersData.idx = newPage - 1;
  10412. filtersData.sum = pageSize;
  10413. $scope.loadData(filtersData);
  10414. //console.log(pageSize);
  10415. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  10416. });
  10417. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10418. $scope.selected.items = data.entity;
  10419. //console.log(data);
  10420. });
  10421. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  10422. $scope.selected.items = data.entity;
  10423. //console.log(data);
  10424. });
  10425. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  10426. // // if (row.entity.age > 45) {
  10427. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10428. // // }
  10429. // };
  10430. gridApi.core.on.filterChanged($scope, function () {
  10431. var grid = this.grid;
  10432. var filtersData = { idx: 0, sum: 1000, user: { roledata: { rolecode: "first-line support" }, selectType: "1" } };
  10433. angular.forEach(grid.columns, function (item) {
  10434. if (item.enableFiltering) {
  10435. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  10436. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10437. if (angular.isUndefined(filtersData['user'])) {
  10438. filtersData['user'] = {};
  10439. }
  10440. filtersData['user'][item.field] = item.filters[0].term;
  10441. }
  10442. }
  10443. });
  10444. $scope.memoryfilterData = filtersData;
  10445. $scope.loadData(filtersData);
  10446. });
  10447. };
  10448. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  10449. // if (row.entity.age > 45) {
  10450. // row.grid.api.selection.selectRow(row.entity); // 选中行
  10451. // }
  10452. // },
  10453. $scope.onDblClick = function (data, event) {
  10454. // $scope.selected.items = data.entity;
  10455. $scope.selectButtonClick(data, event);
  10456. };
  10457. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  10458. // $scope.selected.items = data.entity;
  10459. // })
  10460. // };
  10461. $scope.memoryfilterData = { idx: 0, sum: 1000, user: { roledata: { rolecode: "first-line support" }, selectType: "1" } }
  10462. $scope.loadData = function (filterData) {
  10463. // console.log("filtersData=111" + JSON.stringify(filterData))
  10464. items.fetchItems(filterData, APIService).then(function (data) {
  10465. var myData = Restangular.stripRestangular(data);
  10466. $scope.gridOptions.totalItems = myData.totalNum;
  10467. $scope.myData = myData.list;
  10468. });
  10469. };
  10470. $scope.title = title;
  10471. $scope.loadData({ idx: 0, sum: 1000, user: { roledata: { rolecode: "first-line support" }, selectType: "1" } });
  10472. $scope.selected = {
  10473. items: {}
  10474. };
  10475. $scope.ok = function () {
  10476. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  10477. // onDataCallback($scope.selected.item, parentScope);
  10478. // }
  10479. $modalInstance.close($scope.selected.items);
  10480. };
  10481. $scope.cancel = function () {
  10482. $modalInstance.dismiss('cancel');
  10483. };
  10484. },
  10485. size: size,
  10486. resolve: {
  10487. items: function () {
  10488. return {
  10489. fetchItems: function (filterData, APIService) {
  10490. filterData = filterData || {};
  10491. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10492. filterData = { idx: 0, sum: 1000, user: { roledata: { rolecode: "first-line support" }, selectType: "1" } };
  10493. }
  10494. return options.templateOptions.fetchItems(filterData, APIService);
  10495. }
  10496. };
  10497. },
  10498. title: function () {
  10499. return options.templateOptions.label;
  10500. },
  10501. Restangular: function () {
  10502. return options.templateOptions.Restangular;
  10503. },
  10504. APIService: function () {
  10505. return options.templateOptions.ApiService;
  10506. },
  10507. onDataCallback: function () {
  10508. return options.templateOptions.callback;
  10509. },
  10510. parentScope: function () {
  10511. return options.templateOptions.that;
  10512. }
  10513. }
  10514. });
  10515. modalInstance.result.then(function (selectedItem) {
  10516. // console.log(selectedItem);
  10517. options.value(selectedItem);
  10518. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  10519. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  10520. }
  10521. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  10522. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  10523. }
  10524. }, function () {
  10525. //console.log('Modal dismissed at: ' + new Date());
  10526. });
  10527. }
  10528. }
  10529. };
  10530. },
  10531. controller: ['$scope', function ($scope) {
  10532. $scope.options.templateOptions.that = $scope;
  10533. }]
  10534. });
  10535. //用户多选控件
  10536. formlyConfigProvider.setType({
  10537. name: "ui-multiuserselect",
  10538. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  10539. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10540. defaultOptions: function (options) {
  10541. return {
  10542. templateOptions: {
  10543. openModal: function (size, options, modal, model) {
  10544. var modalInstance = modal.open({
  10545. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10546. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  10547. $scope.langs = i18nService.getAllLangs();
  10548. $scope.lang = 'zh-cn';
  10549. i18nService.setCurrentLang($scope.lang);
  10550. $scope.gridOptions = {};
  10551. $scope.gridOptions.data = 'myData';
  10552. $scope.gridOptions.enableColumnResizing = true;
  10553. $scope.gridOptions.enableFiltering = true;
  10554. $scope.gridOptions.enableGridMenu = true;
  10555. $scope.gridOptions.showGridFooter = true;
  10556. $scope.gridOptions.showColumnFooter = true;
  10557. $scope.gridOptions.fastWatch = true;
  10558. $scope.gridOptions.useExternalFiltering = true;
  10559. $scope.gridOptions.useExternalPagination = true;
  10560. $scope.gridOptions.paginationPageSizes = [10];
  10561. $scope.gridOptions.paginationPageSize = 10;
  10562. $scope.gridOptions.multiSelect = true;
  10563. $scope.gridOptions.rowIdentity = function (row) {
  10564. return row.id;
  10565. };
  10566. $scope.gridOptions.getRowIdentity = function (row) {
  10567. return row.id;
  10568. };
  10569. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10570. $scope.gridOptions.columnDefs = [
  10571. // { name:'id', width:80, enableFiltering:false},
  10572. { name: 'account', displayName: '账号', width: 140 },
  10573. { name: 'name', displayName: '名称', width: 100 },
  10574. { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
  10575. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  10576. { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
  10577. { name: 'dept.dept', displayName: '部门', width: 100, enableFiltering: false },
  10578. { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: false }
  10579. ];
  10580. $scope.selected = {
  10581. items: selectItems
  10582. };
  10583. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10584. $scope.gridApi = gridApi;
  10585. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10586. var filtersData = $scope.memoryfilterData;
  10587. filtersData.idx = newPage - 1;
  10588. filtersData.sum = pageSize;
  10589. $scope.loadData(filtersData);
  10590. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  10591. });
  10592. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  10593. var j = 0;
  10594. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  10595. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  10596. j++;
  10597. break;
  10598. }
  10599. }
  10600. if (j == 1) {
  10601. scope.grid.appScope.selected.items.splice(i, 1);
  10602. } else {
  10603. scope.grid.appScope.selected.items.push(scope.entity)
  10604. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  10605. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  10606. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  10607. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  10608. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  10609. scope.grid.appScope.selected.items.splice(i, 1);
  10610. }
  10611. }
  10612. }
  10613. }
  10614. });
  10615. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  10616. // $scope.grid.appScope.selected.items.push($scope.entity);
  10617. // });
  10618. gridApi.core.on.filterChanged($scope, function () {
  10619. var grid = this.grid;
  10620. var filtersData = {
  10621. idx: 0,
  10622. sum: 10,
  10623. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  10624. };
  10625. angular.forEach(grid.columns, function (item) {
  10626. if (item.enableFiltering) {
  10627. //console.log("filtersData="+JSON.stringify(filtersData))
  10628. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10629. if (angular.isUndefined(filtersData['user'])) {
  10630. filtersData['user'] = {};
  10631. }
  10632. filtersData['user'][item.field] = item.filters[0].term;
  10633. }
  10634. }
  10635. });
  10636. $scope.memoryfilterData = filtersData;
  10637. $scope.loadData(filtersData);
  10638. });
  10639. };
  10640. if (!options.model) {
  10641. var mouse = { "model": { "currentRole": "" } };
  10642. angular.extend(options, mouse);
  10643. }
  10644. $scope.memoryfilterData = {
  10645. "idx": 0,
  10646. "sum": 10,
  10647. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  10648. }
  10649. $scope.loadData = function (filterData) {
  10650. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  10651. items.fetchItems(filterData, APIService).then(function (data) {
  10652. var myData = Restangular.stripRestangular(data);
  10653. $scope.gridOptions.totalItems = myData.totalNum;
  10654. $scope.myData = myData.list;
  10655. //console.log($scope.gridOptions.pagination.getTotalPages());
  10656. // if($scope.selected.items){
  10657. // angular.forEach($scope.selected.items,function(selectItem){
  10658. // $scope.gridApi.selection.selectRow(selectItem);
  10659. // });
  10660. // }
  10661. });
  10662. };
  10663. $scope.title = title;
  10664. $scope.loadData({
  10665. idx: 0,
  10666. sum: 10,
  10667. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  10668. });
  10669. // $timeout(function(){
  10670. // if($scope.selected.items){
  10671. // angular.forEach($scope.selected.items,function(selectItem){
  10672. // $scope.gridApi.selection.selectRow(selectItem);
  10673. // });
  10674. // }
  10675. // },2000)
  10676. $scope.ok = function () {
  10677. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  10678. $modalInstance.close($scope.selected.items);
  10679. };
  10680. $scope.cancel = function () {
  10681. $modalInstance.dismiss('cancel');
  10682. };
  10683. },
  10684. size: size,
  10685. resolve: {
  10686. items: function () {
  10687. return {
  10688. fetchItems: function (filterData, APIService) {
  10689. filterData = filterData || {};
  10690. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10691. filterData = {
  10692. idx: 0,
  10693. sum: 10,
  10694. "user": { "roledata": { "rolecode": options.model.incident.currentRole }, "selectType": "1" }
  10695. };
  10696. }
  10697. return options.templateOptions.fetchItems(filterData, APIService);
  10698. }
  10699. };
  10700. },
  10701. title: function () {
  10702. return options.templateOptions.modalTitle;
  10703. },
  10704. Restangular: function () {
  10705. return options.templateOptions.Restangular;
  10706. },
  10707. APIService: function () {
  10708. return options.templateOptions.ApiService;
  10709. },
  10710. selectItems: function () {
  10711. return model || [];
  10712. }
  10713. }
  10714. });
  10715. modalInstance.result.then(function (selectedItem) {
  10716. options.value(selectedItem);
  10717. options.formControl.$validate();
  10718. }, function () {
  10719. //console.log('Modal dismissed at: ' + new Date());
  10720. });
  10721. }
  10722. },
  10723. validators: {
  10724. required: {
  10725. expression: function (viewValue, modelValue) {
  10726. var value = modelValue || viewValue;
  10727. return value.length >= 1;
  10728. }
  10729. }
  10730. }
  10731. };
  10732. },
  10733. controller: ['$scope', function ($scope) {
  10734. $scope.model[$scope.options.key] = [];
  10735. $scope.remove = function (itemId) {
  10736. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  10737. if (entry.id == itemId) {
  10738. $scope.model[$scope.options.key].splice(index, 1);
  10739. // console.log($scope.options.formControl)
  10740. $scope.options.formControl.$validate();
  10741. } else {
  10742. }
  10743. });
  10744. }
  10745. }]
  10746. });
  10747. //用户多选控件-字符串展示
  10748. formlyConfigProvider.setType({
  10749. name: 'ui-stringuserselect',
  10750. extends: 'input',
  10751. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  10752. defaultOptions: function (options) {
  10753. return {
  10754. templateOptions: {
  10755. translate: '',
  10756. refreshDelay: 0
  10757. }
  10758. }
  10759. },
  10760. controller: ['$scope', function ($scope) {
  10761. var keydata = "";
  10762. if (angular.isArray($scope.model)) {
  10763. angular.forEach($scope.model, function (item) {
  10764. keydata = keydata + "," + item.name;
  10765. })
  10766. }
  10767. // $scope.model[$scope.options.key] = [];
  10768. }]
  10769. });
  10770. //重复事件
  10771. formlyConfigProvider.setType({
  10772. name: "ui-incidentmodelselect",
  10773. extends: 'input',
  10774. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  10775. defaultOptions: function (options) {
  10776. return {
  10777. templateOptions: {
  10778. openModal: function (size, options, modal) {
  10779. var modalInstance = modal.open({
  10780. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10781. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  10782. $scope.langs = i18nService.getAllLangs();
  10783. $scope.lang = 'zh-cn';
  10784. i18nService.setCurrentLang($scope.lang);
  10785. $scope.gridOptions = {};
  10786. $scope.gridOptions.data = 'myData';
  10787. $scope.gridOptions.enableColumnResizing = true;
  10788. $scope.gridOptions.enableFiltering = true;
  10789. $scope.gridOptions.enableGridMenu = false;
  10790. $scope.gridOptions.enableRowSelection = true;
  10791. $scope.gridOptions.showGridFooter = true;
  10792. $scope.gridOptions.showColumnFooter = false;
  10793. $scope.gridOptions.fastWatch = true;
  10794. $scope.gridOptions.useExternalFiltering = false;
  10795. // $scope.gridOptions.useExternalPagination = true;
  10796. $scope.gridOptions.paginationPageSizes = [10];
  10797. $scope.gridOptions.paginationPageSize = 10;
  10798. $scope.gridOptions.multiSelect = false;
  10799. $scope.gridOptions.rowIdentity = function (row) {
  10800. return row.id;
  10801. };
  10802. $scope.gridOptions.getRowIdentity = function (row) {
  10803. return row.id;
  10804. };
  10805. $scope.gridOptions.columnDefs = items.columnDefs();
  10806. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10807. $scope.gridApi = gridApi;
  10808. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10809. // console.log(newPage);
  10810. // console.log(pageSize);
  10811. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  10812. });
  10813. gridApi.core.on.filterChanged($scope, function () {
  10814. var grid = this.grid;
  10815. var filtersData = {
  10816. idx: 0,
  10817. sum: 10
  10818. };
  10819. angular.forEach(grid.columns, function (item) {
  10820. if (item.enableFiltering) {
  10821. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10822. // console.log("filtersData="+JSON.stringify(filtersData))
  10823. if (angular.isUndefined(filtersData['incident'])) {
  10824. filtersData['incident'] = {};
  10825. }
  10826. filtersData['incident'][item.field] = item.filters[0].term;
  10827. if (angular.isUndefined(filtersData['problem'])) {
  10828. filtersData['problem'] = {};
  10829. }
  10830. filtersData['problem'][item.field] = item.filters[0].term;
  10831. if (angular.isUndefined(filtersData['change'])) {
  10832. filtersData['change'] = {};
  10833. }
  10834. filtersData['change'][item.field] = item.filters[0].term;
  10835. if (angular.isUndefined(filtersData['release'])) {
  10836. filtersData['release'] = {};
  10837. }
  10838. filtersData['release'][item.field] = item.filters[0].term;
  10839. }
  10840. }
  10841. });
  10842. $scope.loadData(filtersData);
  10843. });
  10844. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10845. $scope.selected.item = data.entity;
  10846. //console.log(data);
  10847. });
  10848. };
  10849. $scope.loadData = function (filterData) {
  10850. items.fetchItems(filterData, APIService).then(function (data) {
  10851. var myData = Restangular.stripRestangular(data);
  10852. $scope.gridOptions.totalItems = myData.totalNum;
  10853. $scope.myData = myData.list;
  10854. });
  10855. };
  10856. $scope.title = title;
  10857. $scope.loadData({
  10858. idx: 0,
  10859. sum: 10
  10860. });
  10861. $scope.selected = {
  10862. item: {}
  10863. };
  10864. $scope.ok = function () {
  10865. //console.log($scope.selected.item);
  10866. $modalInstance.close($scope.selected.item);
  10867. };
  10868. $scope.cancel = function () {
  10869. $modalInstance.dismiss('cancel');
  10870. };
  10871. },
  10872. size: size,
  10873. resolve: {
  10874. items: function () {
  10875. return {
  10876. fetchItems: function (filterData, APIService) {
  10877. filterData = filterData || {};
  10878. // if(!filterData.idx){
  10879. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  10880. filterData = {
  10881. idx: 0,
  10882. sum: 10
  10883. };
  10884. }
  10885. return options.templateOptions.fetchItems(filterData, APIService, options);
  10886. },
  10887. columnDefs: function () {
  10888. return options.templateOptions.columnDefs;
  10889. }
  10890. };
  10891. },
  10892. title: function () {
  10893. return options.templateOptions.modalTitle;
  10894. },
  10895. Restangular: function () {
  10896. return options.templateOptions.Restangular;
  10897. },
  10898. APIService: function () {
  10899. return options.templateOptions.ApiService;
  10900. }
  10901. }
  10902. });
  10903. modalInstance.result.then(function (selectedItem) {
  10904. var selectitem = { title: selectedItem.title, description: selectedItem.description }
  10905. angular.extend(options.model, selectitem);
  10906. options.value(selectedItem);
  10907. }, function () {
  10908. //console.log('Modal dismissed at: ' + new Date());
  10909. });
  10910. }
  10911. }
  10912. };
  10913. }
  10914. });
  10915. //选项选择控件
  10916. formlyConfigProvider.setType({
  10917. name: "ui-modelselect",
  10918. extends: 'input',
  10919. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  10920. defaultOptions: function (options) {
  10921. return {
  10922. templateOptions: {
  10923. openModal: function (size, options, modal) {
  10924. var modalInstance = modal.open({
  10925. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  10926. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  10927. $scope.langs = i18nService.getAllLangs();
  10928. $scope.lang = 'zh-cn';
  10929. i18nService.setCurrentLang($scope.lang);
  10930. $scope.gridOptions = {};
  10931. $scope.gridOptions.data = 'myData';
  10932. $scope.gridOptions.enableColumnResizing = true;
  10933. $scope.gridOptions.enableFiltering = true;
  10934. $scope.gridOptions.enableGridMenu = false;
  10935. $scope.gridOptions.enableRowSelection = true;
  10936. $scope.gridOptions.showGridFooter = true;
  10937. $scope.gridOptions.showColumnFooter = true;
  10938. $scope.gridOptions.fastWatch = true;
  10939. $scope.gridOptions.useExternalFiltering = true;
  10940. $scope.gridOptions.useExternalPagination = true;
  10941. $scope.gridOptions.paginationPageSizes = [10];
  10942. $scope.gridOptions.paginationPageSize = 10;
  10943. $scope.gridOptions.multiSelect = false;
  10944. $scope.gridOptions.rowIdentity = function (row) {
  10945. return row.id;
  10946. };
  10947. $scope.gridOptions.getRowIdentity = function (row) {
  10948. return row.id;
  10949. };
  10950. $scope.gridOptions.columnDefs = items.columnDefs();
  10951. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10952. $scope.gridApi = gridApi;
  10953. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10954. // console.log(newPage);
  10955. // console.log(pageSize);
  10956. $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  10957. });
  10958. gridApi.core.on.filterChanged($scope, function () {
  10959. var grid = this.grid;
  10960. var filtersData = {
  10961. idx: 0,
  10962. sum: 10
  10963. };
  10964. angular.forEach(grid.columns, function (item) {
  10965. if (item.enableFiltering) {
  10966. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  10967. // console.log("filtersData="+JSON.stringify(filtersData))
  10968. if (angular.isUndefined(filtersData['incident'])) {
  10969. filtersData['incident'] = {};
  10970. }
  10971. filtersData['incident'][item.field] = item.filters[0].term;
  10972. if (angular.isUndefined(filtersData['problem'])) {
  10973. filtersData['problem'] = {};
  10974. }
  10975. filtersData['problem'][item.field] = item.filters[0].term;
  10976. if (angular.isUndefined(filtersData['change'])) {
  10977. filtersData['change'] = {};
  10978. }
  10979. filtersData['change'][item.field] = item.filters[0].term;
  10980. if (angular.isUndefined(filtersData['release'])) {
  10981. filtersData['release'] = {};
  10982. }
  10983. filtersData['release'][item.field] = item.filters[0].term;
  10984. }
  10985. }
  10986. });
  10987. $scope.loadData(filtersData);
  10988. });
  10989. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10990. $scope.selected.item = data.entity;
  10991. //console.log(data);
  10992. });
  10993. };
  10994. $scope.loadData = function (filterData) {
  10995. items.fetchItems(filterData, APIService).then(function (data) {
  10996. var myData = Restangular.stripRestangular(data);
  10997. $scope.gridOptions.totalItems = myData.totalNum;
  10998. $scope.myData = myData.list;
  10999. });
  11000. };
  11001. $scope.title = title;
  11002. $scope.loadData({
  11003. idx: 0,
  11004. sum: 10
  11005. });
  11006. $scope.selected = {
  11007. item: {}
  11008. };
  11009. $scope.ok = function () {
  11010. //console.log($scope.selected.item);
  11011. $modalInstance.close($scope.selected.item);
  11012. };
  11013. $scope.cancel = function () {
  11014. $modalInstance.dismiss('cancel');
  11015. };
  11016. },
  11017. size: size,
  11018. resolve: {
  11019. items: function () {
  11020. return {
  11021. fetchItems: function (filterData, APIService) {
  11022. filterData = filterData || {};
  11023. // if(!filterData.idx){
  11024. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  11025. filterData = {
  11026. idx: 0,
  11027. sum: 10
  11028. };
  11029. }
  11030. return options.templateOptions.fetchItems(filterData, APIService, options);
  11031. },
  11032. columnDefs: function () {
  11033. return options.templateOptions.columnDefs;
  11034. }
  11035. };
  11036. },
  11037. title: function () {
  11038. return options.templateOptions.modalTitle;
  11039. },
  11040. Restangular: function () {
  11041. return options.templateOptions.Restangular;
  11042. },
  11043. APIService: function () {
  11044. return options.templateOptions.ApiService;
  11045. }
  11046. }
  11047. });
  11048. modalInstance.result.then(function (selectedItem) {
  11049. options.value(selectedItem);
  11050. }, function () {
  11051. //console.log('Modal dismissed at: ' + new Date());
  11052. });
  11053. }
  11054. }
  11055. };
  11056. }
  11057. });
  11058. formlyConfigProvider.setType({
  11059. name: 'ui-requestform',
  11060. extends: 'input',
  11061. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  11062. controller: ['$scope', function ($scope) {
  11063. setTimeout(function () {
  11064. var filterData = {
  11065. "idx": 0,
  11066. "sum": 5,
  11067. "incident": { "requester": { "id": "" } }
  11068. }
  11069. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  11070. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11071. });
  11072. }, 1000);
  11073. }]
  11074. });
  11075. //工单/受理人控件
  11076. formlyConfigProvider.setType({
  11077. name: 'ui-workernumbersign',
  11078. // extends: 'label',
  11079. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  11080. controller: ['$scope', function ($scope) {
  11081. $scope.jry_ceshi=function(){
  11082. console.log($scope.model)
  11083. }
  11084. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  11085. setTimeout(function () {
  11086. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  11087. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11088. if (modelData.status == 200) {
  11089. $scope.model[$scope.options.key] = modelData.data;
  11090. $scope.options.initialValue = $scope.model[$scope.options.key];
  11091. }
  11092. });
  11093. }, 1000);
  11094. }
  11095. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  11096. if (angular.isFunction($scope.options.templateOptions.transform)) {
  11097. if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  11098. $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  11099. }
  11100. $scope.$parent.$parent.$parent.model['directClose'] = false;
  11101. $scope.$parent.$parent.$parent.model['directClose'] = false;
  11102. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  11103. }
  11104. $scope.model.acceptUser = $scope.options.templateOptions.user;
  11105. // $scope.options.initialValue = $scope.model.acceptUser;
  11106. }
  11107. }]
  11108. });
  11109. //工单控件-only number
  11110. formlyConfigProvider.setType({
  11111. name: 'ui-workernumber',
  11112. extends: 'input',
  11113. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  11114. controller: ['$scope', function ($scope) {
  11115. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  11116. setTimeout(function () {
  11117. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  11118. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11119. if (modelData.status == 200) {
  11120. $scope.model[$scope.options.key] = modelData.data;
  11121. $scope.options.initialValue = $scope.model[$scope.options.key];
  11122. }
  11123. });
  11124. }, 1000);
  11125. }
  11126. }]
  11127. });
  11128. //cmdb工单
  11129. formlyConfigProvider.setType({
  11130. name: 'ui-cmdbworkernumber',
  11131. extends: 'input',
  11132. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  11133. controller: ['$scope', function ($scope) {
  11134. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  11135. setTimeout(function () {
  11136. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  11137. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  11138. // if(modelData.status==200){
  11139. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  11140. $scope.options.initialValue = $scope.model[$scope.options.key];
  11141. // }
  11142. });
  11143. }, 1000);
  11144. }
  11145. }]
  11146. });
  11147. //无上传按钮附件上传组件
  11148. formlyConfigProvider.setType({
  11149. name: 'ui-dropfilenotup',
  11150. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  11151. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11152. controller: ['$scope', function ($scope) {
  11153. if (angular.isUndefined($scope.form.dropState)) {
  11154. $scope.form.dropState = false;
  11155. }
  11156. //附件上传数据
  11157. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11158. //$scope.options.templateOptions.uploader();
  11159. // FILTERS
  11160. uploader.filters.push({
  11161. name: 'customFilter',
  11162. fn: function (item /*{File|FileLikeObject}*/, options) {
  11163. return this.queue.length < 10;
  11164. }
  11165. });
  11166. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11167. uploader.onBeforeUploadItem = function (item) {
  11168. angular.extend(item.headers, $rootScope.getSession());
  11169. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  11170. item.formData.push({ 'fileName': item.file.name });
  11171. console.info('onBeforeUploadItem', item);
  11172. };
  11173. uploader.uploadAll();
  11174. }
  11175. // CALLBACKS
  11176. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  11177. console.info('onWhenAddingFileFailed', item, filter, options);
  11178. };
  11179. uploader.onAfterAddingFile = function (fileItem) {
  11180. console.info('onAfterAddingFile', fileItem);
  11181. };
  11182. uploader.onAfterAddingAll = function (addedFileItems) {
  11183. console.info('onAfterAddingAll', addedFileItems);
  11184. };
  11185. uploader.onBeforeUploadItem = function (item) {
  11186. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11187. // // $scope.uploader.options.url();
  11188. // $scope.uploader.onBeforeUploadItem = function(item) {
  11189. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11190. // console.info('onBeforeUploadItem', item);
  11191. // };
  11192. // $scope.uploader.uploadAll();
  11193. // }
  11194. console.info('onBeforeUploadItem', item);
  11195. };
  11196. uploader.onProgressItem = function (fileItem, progress) {
  11197. console.info('onProgressItem', fileItem, progress);
  11198. };
  11199. uploader.onProgressAll = function (progress) {
  11200. console.info('onProgressAll', progress);
  11201. };
  11202. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11203. console.info('onSuccessItem', fileItem, response, status, headers);
  11204. };
  11205. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11206. console.info('onErrorItem', fileItem, response, status, headers);
  11207. };
  11208. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11209. console.info('onCancelItem', fileItem, response, status, headers);
  11210. };
  11211. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11212. console.info('onCompleteItem', fileItem, response, status, headers);
  11213. };
  11214. uploader.onCompleteAll = function () {
  11215. console.info('onCompleteAll');
  11216. };
  11217. }]
  11218. });
  11219. //无按钮知识库上传
  11220. formlyConfigProvider.setType({
  11221. name: 'ui-dropfielkn',
  11222. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  11223. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11224. controller: ['$scope', function ($scope) {
  11225. if (angular.isUndefined($scope.form.dropState)) {
  11226. $scope.form.dropState = false;
  11227. }
  11228. //附件上传数据
  11229. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11230. //$scope.options.templateOptions.uploader();
  11231. // FILTERS
  11232. uploader.filters.push({
  11233. name: 'customFilter',
  11234. fn: function (item /*{File|FileLikeObject}*/, options) {
  11235. return this.queue.length < 10;
  11236. }
  11237. });
  11238. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11239. uploader.onBeforeUploadItem = function (item) {
  11240. angular.extend(item.headers, $rootScope.getSession());
  11241. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  11242. item.formData.push({ 'fileName': item.file.name });
  11243. console.info('onBeforeUploadItem', item);
  11244. };
  11245. uploader.uploadAll();
  11246. }
  11247. // CALLBACKS
  11248. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  11249. console.info('onWhenAddingFileFailed', item, filter, options);
  11250. };
  11251. uploader.onAfterAddingFile = function (fileItem) {
  11252. console.info('onAfterAddingFile', fileItem);
  11253. };
  11254. uploader.onAfterAddingAll = function (addedFileItems) {
  11255. console.info('onAfterAddingAll', addedFileItems);
  11256. };
  11257. uploader.onBeforeUploadItem = function (item) {
  11258. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11259. // // $scope.uploader.options.url();
  11260. // $scope.uploader.onBeforeUploadItem = function(item) {
  11261. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11262. // console.info('onBeforeUploadItem', item);
  11263. // };
  11264. // $scope.uploader.uploadAll();
  11265. // }
  11266. console.info('onBeforeUploadItem', item);
  11267. };
  11268. uploader.onProgressItem = function (fileItem, progress) {
  11269. console.info('onProgressItem', fileItem, progress);
  11270. };
  11271. uploader.onProgressAll = function (progress) {
  11272. console.info('onProgressAll', progress);
  11273. };
  11274. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11275. console.info('onSuccessItem', fileItem, response, status, headers);
  11276. };
  11277. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11278. console.info('onErrorItem', fileItem, response, status, headers);
  11279. };
  11280. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11281. console.info('onCancelItem', fileItem, response, status, headers);
  11282. };
  11283. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11284. console.info('onCompleteItem', fileItem, response, status, headers);
  11285. };
  11286. uploader.onCompleteAll = function () {
  11287. console.info('onCompleteAll');
  11288. };
  11289. }]
  11290. });
  11291. //附件上传列表组件
  11292. formlyConfigProvider.setType({
  11293. name: 'ui-dropfile',
  11294. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  11295. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11296. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  11297. if (angular.isUndefined($scope.form.dropState)) {
  11298. $scope.form.dropState = false;
  11299. }
  11300. //附件上传数据
  11301. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11302. //$scope.options.templateOptions.uploader();
  11303. // FILTERS
  11304. uploader.filters.push({
  11305. name: 'customFilter',
  11306. fn: function (item /*{File|FileLikeObject}*/, options) {
  11307. return this.queue.length < 10;
  11308. }
  11309. });
  11310. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11311. uploader.onBeforeUploadItem = function (item) {
  11312. angular.extend(item.headers, $rootScope.getSession());
  11313. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  11314. // if ($scope.options.templateOptions.formket) {
  11315. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  11316. // } else {
  11317. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  11318. // }
  11319. } else {
  11320. item.url = APIService.jry_saveAttachments(processInstanceId).getRequestedUrl();
  11321. }
  11322. item.formData.push({ 'filename': item.file.name });
  11323. console.info('onBeforeUploadItem', item);
  11324. };
  11325. uploader.uploadAll();
  11326. }
  11327. // CALLBACKS
  11328. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  11329. console.info('onWhenAddingFileFailed', item, filter, options);
  11330. };
  11331. uploader.onAfterAddingFile = function (fileItem) {
  11332. console.info('onAfterAddingFile', fileItem);
  11333. };
  11334. uploader.onAfterAddingAll = function (addedFileItems) {
  11335. console.info('onAfterAddingAll', addedFileItems);
  11336. };
  11337. uploader.onBeforeUploadItem = function (item) {
  11338. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11339. // // $scope.uploader.options.url();
  11340. // $scope.uploader.onBeforeUploadItem = function(item) {
  11341. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11342. // console.info('onBeforeUploadItem', item);
  11343. // };
  11344. // $scope.uploader.uploadAll();
  11345. // }
  11346. console.info('onBeforeUploadItem', item);
  11347. };
  11348. uploader.onProgressItem = function (fileItem, progress) {
  11349. console.info('onProgressItem', fileItem, progress);
  11350. };
  11351. uploader.onProgressAll = function (progress) {
  11352. console.info('onProgressAll', progress);
  11353. };
  11354. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11355. console.info('onSuccessItem', fileItem, response, status, headers);
  11356. };
  11357. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11358. console.info('onErrorItem', fileItem, response, status, headers);
  11359. };
  11360. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11361. console.info('onCancelItem', fileItem, response, status, headers);
  11362. };
  11363. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11364. console.info('onCompleteItem', fileItem, response, status, headers);
  11365. };
  11366. uploader.onCompleteAll = function () {
  11367. console.info('onCompleteAll');
  11368. };
  11369. }]
  11370. });
  11371. //知识库附件上传
  11372. formlyConfigProvider.setType({
  11373. name: 'ui-dropfielknow',
  11374. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  11375. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11376. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  11377. if (angular.isUndefined($scope.form.dropState)) {
  11378. $scope.form.dropState = false;
  11379. }
  11380. //附件上传数据
  11381. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  11382. //$scope.options.templateOptions.uploader();
  11383. // FILTERS
  11384. uploader.filters.push({
  11385. name: 'customFilter',
  11386. fn: function (item /*{File|FileLikeObject}*/, options) {
  11387. return this.queue.length < 10;
  11388. }
  11389. });
  11390. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  11391. uploader.onBeforeUploadItem = function (item) {
  11392. angular.extend(item.headers, $rootScope.getSession());
  11393. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  11394. item.formData.push({ 'fileName': item.file.name, 'type': 'solution', 'solutionId': $scope.model.knowledge.id });
  11395. console.info('onBeforeUploadItem', item);
  11396. };
  11397. uploader.uploadAll();
  11398. }
  11399. // CALLBACKS
  11400. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  11401. console.info('onWhenAddingFileFailed', item, filter, options);
  11402. };
  11403. uploader.onAfterAddingFile = function (fileItem) {
  11404. console.info('onAfterAddingFile', fileItem);
  11405. };
  11406. uploader.onAfterAddingAll = function (addedFileItems) {
  11407. console.info('onAfterAddingAll', addedFileItems);
  11408. };
  11409. uploader.onBeforeUploadItem = function (item) {
  11410. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  11411. // // $scope.uploader.options.url();
  11412. // $scope.uploader.onBeforeUploadItem = function(item) {
  11413. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  11414. // console.info('onBeforeUploadItem', item);
  11415. // };
  11416. // $scope.uploader.uploadAll();
  11417. // }
  11418. console.info('onBeforeUploadItem', item);
  11419. };
  11420. uploader.onProgressItem = function (fileItem, progress) {
  11421. console.info('onProgressItem', fileItem, progress);
  11422. };
  11423. uploader.onProgressAll = function (progress) {
  11424. console.info('onProgressAll', progress);
  11425. };
  11426. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  11427. console.info('onSuccessItem', fileItem, response, status, headers);
  11428. };
  11429. uploader.onErrorItem = function (fileItem, response, status, headers) {
  11430. console.info('onErrorItem', fileItem, response, status, headers);
  11431. };
  11432. uploader.onCancelItem = function (fileItem, response, status, headers) {
  11433. console.info('onCancelItem', fileItem, response, status, headers);
  11434. };
  11435. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  11436. console.info('onCompleteItem', fileItem, response, status, headers);
  11437. };
  11438. uploader.onCompleteAll = function () {
  11439. console.info('onCompleteAll');
  11440. };
  11441. }]
  11442. });
  11443. //知识库附件下载列表
  11444. formlyConfigProvider.setType({
  11445. name: 'ui-dropfileknowledge',
  11446. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  11447. defaultOptions: function (options) {
  11448. return {
  11449. templateOptions: {
  11450. refresh: function (APIService, contentId, data) {
  11451. return APIService.fetchDataList(contentId, data);
  11452. },
  11453. downloadUri: function (APIService, contentId) {
  11454. return APIService.downloadAttachment(contentId).getRequestedUrl();
  11455. },
  11456. download: function (APIService, contentId) {
  11457. return APIService.getSolutionDowpath(contentId);
  11458. },
  11459. view: function (attachmentId) {
  11460. // return APIService.attachmentsPreviewUrl(contentId);
  11461. },
  11462. refreshDelay: 0
  11463. }
  11464. };
  11465. },
  11466. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  11467. var _refreshDelayPromise;
  11468. $scope.attachments = [];
  11469. $scope.downloadUrl = function (contentId) {
  11470. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  11471. };
  11472. $scope.download = function (contentId, filename) {
  11473. $http({
  11474. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  11475. method: 'GET',
  11476. headers: {
  11477. //'Content-type' : 'application/xls',
  11478. 'Accept': '*/*'
  11479. },
  11480. responseType: 'arraybuffer'
  11481. }).success(function (data, status, headers, config) {
  11482. var file = new Blob([data], {
  11483. type: 'application/octet-stream'
  11484. });
  11485. //trick to download store a file having its URL
  11486. var fileURL = URL.createObjectURL(file);
  11487. var a = document.createElement('a');
  11488. a.href = fileURL;
  11489. a.target = '_blank';
  11490. a.download = filename;
  11491. document.body.appendChild(a);
  11492. a.click();
  11493. }).error(function (data, status, headers, config) {
  11494. // console.log(data);
  11495. });
  11496. }
  11497. $scope.view = function (contentId, filename, attachment) {
  11498. var index = filename.indexOf(".");
  11499. var type = filename.substring(index + 1);
  11500. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  11501. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  11502. // var modalInstance = $modal.open({
  11503. // backdrop: false,
  11504. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  11505. // controller: function($scope, scope, $modalInstance, filename) {
  11506. // $scope.title = filename;
  11507. // $scope.imageurl = scope.imageurl;
  11508. // $scope.cancel = function() {
  11509. // $modalInstance.dismiss('cancel');
  11510. // }
  11511. // },
  11512. // resolve: {
  11513. // scope: function() {
  11514. // return $scope;
  11515. // },
  11516. // filename: function() {
  11517. // return filename;
  11518. // }
  11519. // }
  11520. // });
  11521. // event.preventDefault();
  11522. // } else {
  11523. // for (var i = 0; i < $scope.attachments.length; i++) {
  11524. // if ($scope.attachments[i].id == attachmentId) {
  11525. window.open(attachment.previewUrl);
  11526. // }
  11527. // }
  11528. // }
  11529. };
  11530. $scope._refresh = function (refreshAttr) {
  11531. if (refreshAttr !== undefined) {
  11532. if (_refreshDelayPromise) {
  11533. $timeout.cancel(_refreshDelayPromise);
  11534. }
  11535. _refreshDelayPromise = $timeout(function () {
  11536. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  11537. 'file', { "file": { "solutionId": $scope.model.knowledge.id }, "idx": "0", "sum": "1000" }).then(function (response) {
  11538. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  11539. if (myData) {
  11540. $scope.attachments = myData.list;
  11541. // $scope.view = function(attachmentId) {
  11542. // for (var i = 0; i < $scope.attachments.length; i++) {
  11543. // if ($scope.attachments[i].id == attachmentId) {
  11544. // window.open($scope.attachments[i].previewUrl);
  11545. // // var modalInstance = $modal.open({
  11546. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  11547. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  11548. // // }
  11549. // // });
  11550. // }
  11551. // }
  11552. // };
  11553. }
  11554. });
  11555. }, $scope.options.templateOptions.refreshDelay);
  11556. }
  11557. }
  11558. $scope._refresh({});
  11559. // $scope.attachments = $scope.model[$scope.options.key]
  11560. }]
  11561. });
  11562. //附件图片下载
  11563. formlyConfigProvider.setType({
  11564. name: 'ui-downimage',
  11565. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  11566. defaultOptions: function (options) {
  11567. return {
  11568. templateOptions: {
  11569. refresh: function (APIService, processInstanceId, data) {
  11570. return APIService.listAttachments(processInstanceId, data);
  11571. },
  11572. downloadUri: function (APIService, contentId) {
  11573. return APIService.downloadAttachment(contentId).getRequestedUrl();
  11574. },
  11575. view: function (APIService, contentId) {
  11576. return APIService.attachmentsPreviewUrl(contentId);
  11577. },
  11578. download: function (APIService, contentId, item) {
  11579. var item = { 'url': APIService.download(contentId), 'headers': headers };
  11580. return item;
  11581. },
  11582. refreshDelay: 0
  11583. }
  11584. };
  11585. },
  11586. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  11587. var _refreshDelayPromise;
  11588. // $scope.downloadUrl = function(contentId){
  11589. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  11590. // };
  11591. $scope.download = function (contentId, filename) {
  11592. // var headers=
  11593. $http({
  11594. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  11595. method: 'GET',
  11596. headers: {
  11597. //'Content-type' : 'application/xls',
  11598. 'Accept': '*/*'
  11599. },
  11600. responseType: 'arraybuffer'
  11601. }).success(function (data, status, headers, config) {
  11602. var file = new Blob([data], {
  11603. type: 'application/octet-stream'
  11604. });
  11605. //trick to download store a file having its URL
  11606. var fileURL = URL.createObjectURL(file);
  11607. var a = document.createElement('a');
  11608. a.href = fileURL;
  11609. a.target = '_blank';
  11610. a.download = filename;
  11611. document.body.appendChild(a);
  11612. a.click();
  11613. }).error(function (data, status, headers, config) {
  11614. // console.log(data);
  11615. });
  11616. };
  11617. $scope.view = function (contentId) {
  11618. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  11619. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  11620. // if (response.state == 200) {
  11621. // window.open(response.previewUrl);
  11622. // }
  11623. // })
  11624. };
  11625. /**
  11626. * refresh
  11627. */
  11628. $scope._refresh = function (refreshAttr) {
  11629. if (refreshAttr !== undefined) {
  11630. if (_refreshDelayPromise) {
  11631. $timeout.cancel(_refreshDelayPromise);
  11632. }
  11633. _refreshDelayPromise = $timeout(function () {
  11634. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  11635. $scope.options.templateOptions.processInstanceId, { 'idx': 0, 'sum': 1000 }).then(function (response) {
  11636. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  11637. if (myData) {
  11638. $scope.attachments = myData.data;
  11639. }
  11640. });
  11641. }, $scope.options.templateOptions.refreshDelay);
  11642. }
  11643. }
  11644. $scope._refresh({});
  11645. // $scope.attachments = $scope.model[$scope.options.key]
  11646. }]
  11647. });
  11648. //附件下载列表组件
  11649. formlyConfigProvider.setType({
  11650. name: 'ui-dropfiletable',
  11651. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  11652. defaultOptions: function (options) {
  11653. return {
  11654. templateOptions: {
  11655. refresh: function (APIService, processInstanceId, data,filekey) {
  11656. return APIService.jry_listAttachments(filekey,processInstanceId);
  11657. },
  11658. downloadUri: function (APIService, contentId) {
  11659. return APIService.downloadAttachment(contentId).getRequestedUrl();
  11660. },
  11661. view: function (APIService, contentId) {
  11662. return APIService.attachmentsPreviewUrl(contentId);
  11663. },
  11664. download: function (APIService, contentId, item) {
  11665. var item = { 'url': APIService.download(contentId), 'headers': headers };
  11666. return item;
  11667. },
  11668. refreshDelay: 0
  11669. }
  11670. };
  11671. },
  11672. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  11673. var _refreshDelayPromise;
  11674. // $scope.downloadUrl = function(contentId){
  11675. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  11676. // };
  11677. $scope.download = function (contentId, filename,token) {
  11678. // var headers=
  11679. $http({
  11680. url: $scope.options.templateOptions.ApiService.jry_download().getRequestedUrl(),
  11681. method: 'POST',
  11682. data:{token},
  11683. headers: {
  11684. //'Content-type' : 'application/xls',
  11685. 'Accept': '*/*'
  11686. },
  11687. responseType: 'arraybuffer'
  11688. }).success(function (data, status, headers, config) {
  11689. var file = new Blob([data], {
  11690. type: 'application/octet-stream'
  11691. });
  11692. //trick to download store a file having its URL
  11693. var fileURL = URL.createObjectURL(file);
  11694. var a = document.createElement('a');
  11695. a.href = fileURL;
  11696. a.target = '_blank';
  11697. a.download = filename;
  11698. document.body.appendChild(a);
  11699. a.click();
  11700. }).error(function (data, status, headers, config) {
  11701. // console.log(data);
  11702. });
  11703. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  11704. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  11705. // var file = new Blob([response], {
  11706. // type : 'application/octet-stream'
  11707. // });
  11708. // // var filename = filename;
  11709. // //var file = new Blob([response], {type: 'application/pdf'});
  11710. // var fileURL = URL.createObjectURL(file);
  11711. // var a = document.createElement('a');
  11712. // a.href = fileURL;
  11713. // a.target = '_blank';
  11714. // a.download = filename ;
  11715. // document.body.appendChild(a);
  11716. // a.click();
  11717. // })
  11718. };
  11719. $scope.view = function (contentId, token, filename, type) {
  11720. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  11721. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  11722. // var modalInstance = $modal.open({
  11723. // backdrop: false,
  11724. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  11725. // controller: function($scope, scope, $modalInstance, filename) {
  11726. // $scope.title = filename;
  11727. // $scope.imageurl = scope.imageurl;
  11728. // $scope.cancel = function() {
  11729. // $modalInstance.dismiss('cancel');
  11730. // }
  11731. // },
  11732. // resolve: {
  11733. // scope: function() {
  11734. // return $scope;
  11735. // },
  11736. // filename: function() {
  11737. // return filename;
  11738. // }
  11739. // }
  11740. // });
  11741. // event.preventDefault();
  11742. // } else {
  11743. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  11744. if (response.state == 200) {
  11745. window.open(response.previewUrl);
  11746. }
  11747. })
  11748. // }
  11749. };
  11750. /**
  11751. * refresh
  11752. */
  11753. $scope._refresh = function (refreshAttr) {
  11754. if (refreshAttr !== undefined) {
  11755. if (_refreshDelayPromise) {
  11756. $timeout.cancel(_refreshDelayPromise);
  11757. }
  11758. _refreshDelayPromise = $timeout(function () {
  11759. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  11760. $scope.options.templateOptions.processInstanceId, { 'idx': 0, 'sum': 1000 },$scope.options.templateOptions.filekey).then(function (response) {
  11761. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  11762. if (myData) {
  11763. $scope.attachments = myData.data;
  11764. }
  11765. });
  11766. }, $scope.options.templateOptions.refreshDelay);
  11767. }
  11768. }
  11769. $scope._refresh({});
  11770. // $scope.attachments = $scope.model[$scope.options.key]
  11771. }]
  11772. });
  11773. //微信附件下载列表组件
  11774. formlyConfigProvider.setType({
  11775. name: 'ui-dropfilewechat',
  11776. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  11777. defaultOptions: function (options) {
  11778. return {
  11779. templateOptions: {
  11780. // refresh: function(APIService, processInstanceId, data) {
  11781. // return APIService.listAttachments(processInstanceId, data);
  11782. // },
  11783. // downloadUri: function(APIService, contentId) {
  11784. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  11785. // },
  11786. view: function (APIService, contentId) {
  11787. // return APIService.attachmentsPreviewUrl(contentId);
  11788. return APIService.attachmentsPreviewUrl(contentId);
  11789. },
  11790. download: function (APIService, contentId, item) {
  11791. var item = { 'url': APIService.download(contentId), 'headers': headers };
  11792. return item;
  11793. },
  11794. // download: function(APIService, contentId, item) {
  11795. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  11796. // return item;
  11797. // },
  11798. refreshDelay: 0
  11799. }
  11800. };
  11801. },
  11802. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  11803. var _refreshDelayPromise;
  11804. // $scope.downloadUrl = function(contentId){
  11805. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  11806. // };
  11807. $scope.attachments = {};
  11808. $scope.previewUrl = '';
  11809. $scope.download = function (token, filename) {
  11810. // var headers=
  11811. $http({
  11812. url: $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl(),
  11813. method: 'GET',
  11814. headers: {
  11815. //'Content-type' : 'application/xls',
  11816. 'Accept': '*/*'
  11817. },
  11818. responseType: 'arraybuffer'
  11819. }).success(function (data, status, headers, config) {
  11820. var file = new Blob([data], {
  11821. type: 'application/octet-stream'
  11822. });
  11823. //trick to download store a file having its URL
  11824. var fileURL = URL.createObjectURL(file);
  11825. var a = document.createElement('a');
  11826. a.href = fileURL;
  11827. a.target = '_blank';
  11828. a.download = filename;
  11829. document.body.appendChild(a);
  11830. a.click();
  11831. }).error(function (data, status, headers, config) {
  11832. // console.log(data);
  11833. });
  11834. };
  11835. $scope.view = function (contentId, token, filename, type, previewUrl) {
  11836. // if (type) {
  11837. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  11838. // var modalInstance = $modal.open({
  11839. // backdrop: false,
  11840. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  11841. // controller: function($scope, scope, $modalInstance, filename) {
  11842. // $scope.title = filename;
  11843. // $scope.imageurl = scope.imageurl;
  11844. // $scope.cancel = function() {
  11845. // $modalInstance.dismiss('cancel');
  11846. // }
  11847. // },
  11848. // resolve: {
  11849. // scope: function() {
  11850. // return $scope;
  11851. // },
  11852. // filename: function() {
  11853. // return filename;
  11854. // }
  11855. // }
  11856. // });
  11857. // event.preventDefault();
  11858. // } else {
  11859. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  11860. // if (response.state == 200) {
  11861. // window.open(response.previewUrl);
  11862. // }
  11863. // })
  11864. window.open(previewUrl);
  11865. // }
  11866. };
  11867. /**
  11868. * refresh
  11869. */
  11870. $scope._refresh = function (refreshAttr) {
  11871. if (refreshAttr !== undefined) {
  11872. if (_refreshDelayPromise) {
  11873. $timeout.cancel(_refreshDelayPromise);
  11874. }
  11875. _refreshDelayPromise = $timeout(function () {
  11876. // console.log(JSON.parse($stateParams.model))
  11877. var incidentChart = {};
  11878. if ($stateParams.model) {
  11879. incidentChart = JSON.parse($stateParams.model).model;
  11880. }
  11881. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  11882. $scope.model).then(function (response) {
  11883. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  11884. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  11885. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  11886. if (myData) {
  11887. $scope.attachments = myData.data;
  11888. }
  11889. });
  11890. }, $scope.options.templateOptions.refreshDelay);
  11891. }
  11892. }
  11893. $scope._refresh({});
  11894. // $scope.attachments = $scope.model[$scope.options.key]
  11895. }]
  11896. });
  11897. formlyConfigProvider.setType({
  11898. name: 'ui-paralleltask',
  11899. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  11900. defaultOptions: function (options) {
  11901. return {
  11902. templateOptions: {
  11903. refresh: function (APIService, processInstanceId, data) {
  11904. //return APIService.listAttachments(processInstanceId, data);
  11905. },
  11906. refreshDelay: 0
  11907. }
  11908. };
  11909. },
  11910. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  11911. });
  11912. //repeatSection
  11913. //
  11914. formlyConfigProvider.setType({
  11915. name: 'ui-repeatSection',
  11916. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  11917. defaultOptions: function (options) {
  11918. return {
  11919. templateOptions: {
  11920. unique: 1,
  11921. initDisplay: false
  11922. }
  11923. };
  11924. },
  11925. controller: function ($scope) {
  11926. //$scope.options.templateOptions.unique;
  11927. $scope.formOptions = { formState: $scope.formState };
  11928. $scope.addNew = addNew;
  11929. $scope.copyFields = copyFields;
  11930. function copyFields(fields) {
  11931. fields = angular.copy(fields);
  11932. addRandomIds(fields);
  11933. return fields;
  11934. }
  11935. function addNew() {
  11936. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  11937. var repeatsection = $scope.model[$scope.options.key];
  11938. var lastSection = repeatsection[repeatsection.length - 1];
  11939. var newsection = {};
  11940. repeatsection.push(newsection);
  11941. }
  11942. function addRandomIds(fields) {
  11943. $scope.options.templateOptions.unique++;
  11944. angular.forEach(fields, function (field, index) {
  11945. if (field.fieldGroup) {
  11946. addRandomIds(field.fieldGroup);
  11947. return; // fieldGroups don't need an ID
  11948. }
  11949. if (field.templateOptions && field.templateOptions.fields) {
  11950. addRandomIds(field.templateOptions.fields);
  11951. }
  11952. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  11953. });
  11954. }
  11955. function getRandomInt(min, max) {
  11956. return Math.floor(Math.random() * (max - min)) + min;
  11957. }
  11958. if ($scope.options.templateOptions.initDisplay) {
  11959. addNew();
  11960. }
  11961. }
  11962. });
  11963. //时间轴任务列表组件
  11964. //cmdb控件
  11965. formlyConfigProvider.setType({
  11966. name: 'ui-cmdb',
  11967. extends: 'input',
  11968. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  11969. defaultOptions: function (options) {
  11970. return {
  11971. templateOptions: {
  11972. onClick: function (size, options, modal, event, model) {
  11973. var modalInstance = modal.open({
  11974. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  11975. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster) {
  11976. var width = $scope.width = 600;
  11977. var height = $scope.height = 400;
  11978. var tree;
  11979. var d3 = window.d3;
  11980. $scope.my_tree_handler = function (branch) {
  11981. //var _ref;
  11982. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  11983. APIService.query({ 'sign': classify }).then(function (data) {
  11984. var myData = Restangular.stripRestangular(data);
  11985. // console.log(myData.data.node);
  11986. if (myData.data && myData.status == 200) {
  11987. var ret = myData.data;
  11988. redrawSvg(myData);
  11989. }
  11990. });
  11991. };
  11992. $scope.my_data = [];
  11993. function convertListToTree(data, treeMap) {
  11994. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11995. var root = null; //Initially set our loop to null
  11996. var parentNode = null;
  11997. //loop over data
  11998. for (var i = 0; i < data.length; i++) {
  11999. var datum = data[i];
  12000. //each node will have children, so let's give it a "children" poperty
  12001. datum.children = [];
  12002. //add an entry for this node to the map so that any future children can
  12003. //lookup the parent
  12004. idToNodeMap[datum.id] = datum;
  12005. //Does this node have a parent?
  12006. if (typeof datum.parent === "undefined" || datum.parent == null) {
  12007. //Doesn't look like it, so this node is the root of the tree
  12008. root = datum;
  12009. treeMap[datum.id] = root;
  12010. } else {
  12011. //This node has a parent, so let's look it up using the id
  12012. parentNode = idToNodeMap[datum.parent.id];
  12013. //We don't need this property, so let's delete it.
  12014. delete datum.parent;
  12015. //Let's add the current node as a child of the parent node.
  12016. parentNode.children.push(datum);
  12017. }
  12018. }
  12019. return root;
  12020. }
  12021. function convertParentToChildList(data) {
  12022. var treeMap = {};
  12023. var list = [];
  12024. convertListToTree(data, treeMap);
  12025. angular.forEach(treeMap, function (item) {
  12026. list.push(item);
  12027. });
  12028. return list;
  12029. }
  12030. $scope.my_tree = tree = {};
  12031. $scope.try_async_load = function () {
  12032. $scope.my_data = [];
  12033. $scope.select_treedata = [];
  12034. $scope.doing_async = true;
  12035. ConfigDataService.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function (result) {
  12036. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  12037. $scope.doing_async = false;
  12038. });
  12039. };
  12040. $scope.select_treedata = [];
  12041. $scope.propTypeOptions = [];
  12042. $scope.try_async_load();
  12043. $scope.onFilterCallback = function (item) {
  12044. //console.log(item);
  12045. if (angular.isDefined(item.children) && item.children.length >= 1) {
  12046. //not valid
  12047. } else {
  12048. var tempclassify = item.prefix.toLowerCase() + item.sign;
  12049. $scope.cifilter_classic = tempclassify;
  12050. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  12051. var myData = Restangular.stripRestangular(data);
  12052. $scope.propTypeOptions = myData;
  12053. });
  12054. }
  12055. }
  12056. $scope.onPropTypeChange = function (form) {
  12057. $scope.propOptions = form.fields;
  12058. }
  12059. $scope.onPropChange = function (prop) {
  12060. $scope.cifilter_prop = prop;
  12061. }
  12062. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  12063. //if(searchKey!=null&&searchKey.length>1){
  12064. var searchData = {};
  12065. if (angular.isUndefined(propObj)) {
  12066. propObj = $scope.cifilter_prop;
  12067. }
  12068. if (angular.isUndefined(ciclassify)) {
  12069. ciclassify = $scope.cifilter_classic;
  12070. }
  12071. searchData['sign'] = ciclassify;
  12072. if (angular.isDefined(propObj)) {
  12073. searchData[propObj.key] = searchKey;
  12074. }
  12075. APIService.query(searchData).then(function (response) {
  12076. var data = Restangular.stripRestangular(response);
  12077. //此处不清空nodes
  12078. var node = data.data.node;
  12079. var tempNode = [];
  12080. //nodes 或者links 要去重
  12081. for (var i = 0; i < node.length; i++) {
  12082. var tmp = 0;
  12083. for (var j = 0; j < nodes.length; j++) {
  12084. if (node[i].uuid == nodes[j].uuid) {
  12085. tmp++;
  12086. break;
  12087. }
  12088. }
  12089. if (tmp == 0) {
  12090. tempNode.push(node[i]);
  12091. }
  12092. }
  12093. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  12094. nodes.push(tempNode[i]);
  12095. }
  12096. restart();
  12097. })
  12098. }
  12099. $scope.refresh = function () {
  12100. nodes.length = 0;
  12101. links.length = 0;
  12102. restart();
  12103. }
  12104. $scope.traversal = function () {
  12105. if ($scope.selected_node == null) {
  12106. SweetAlert.swal({
  12107. title: "错误的操作!",
  12108. text: "没有配置项被选中!",
  12109. type: "error"
  12110. });
  12111. } else {
  12112. var uuid = $scope.selected_node.uuid;
  12113. APIService.traversal(uuid).then(function (response) {
  12114. var d = response.data;
  12115. var node = d.node;
  12116. var link = d.edge;
  12117. var tempNode = [];
  12118. var tempLink = [];
  12119. //nodes 或者links 要去重
  12120. for (var i = 0; i < node.length; i++) {
  12121. var tmp = 0;
  12122. for (var j = 0; j < nodes.length; j++) {
  12123. if (node[i].id == nodes[j].id) {
  12124. tmp++;
  12125. break;
  12126. }
  12127. }
  12128. if (tmp == 0) {
  12129. tempNode.push(node[i]);
  12130. }
  12131. }
  12132. for (var i = 0; i < link.length; i++) {
  12133. var tmp = 0;
  12134. for (var j = 0; j < links.length; j++) {
  12135. if (link[i].id == links[j].id) {
  12136. tmp++;
  12137. break;
  12138. }
  12139. }
  12140. if (tmp == 0) {
  12141. tempLink.push(link[i]);
  12142. }
  12143. }
  12144. //数据写入页面
  12145. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  12146. nodes.push(tempNode[i]);
  12147. }
  12148. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  12149. links.push(tempLink[i]);
  12150. }
  12151. //links转换
  12152. for (var i = 0; i < links.length; i++) {
  12153. for (var j = 0; j < nodes.length; j++) {
  12154. if (links[i].source == nodes[j].id) {
  12155. links[i].source = nodes[j];
  12156. }
  12157. if (links[i].target == nodes[j].id) {
  12158. links[i].target = nodes[j];
  12159. }
  12160. }
  12161. }
  12162. restart();
  12163. })
  12164. }
  12165. }
  12166. var svg;
  12167. var force;
  12168. var drag_line, path, circle;
  12169. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  12170. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  12171. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  12172. var nodes = [],
  12173. links = [];
  12174. var treeNodes = [];
  12175. //读取labels (node)
  12176. var labels = [];
  12177. function redrawSvg(json) {
  12178. nodes.length = 0; //先清空
  12179. links.length = 0;
  12180. var data = json.data;
  12181. for (var i = 0; i < data.node.length; i++) {
  12182. nodes.push(data.node[i]);
  12183. }
  12184. restart();
  12185. }
  12186. //读取status (节点 连线)
  12187. var statuses = [];
  12188. ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function (result) {
  12189. if (result && result.status == 200) {
  12190. d3.select('#nodeStatus').selectAll('option')
  12191. .data(statuses).enter()
  12192. .append('option')
  12193. .attr('value', function (d) { return d.code; })
  12194. .html(function (d) { return d.desc; });
  12195. } else {
  12196. SweetAlert.swal({
  12197. title: "提示!",
  12198. text: "服务器请求异常!",
  12199. type: "error"
  12200. });
  12201. }
  12202. });
  12203. //查询relationship_type表 name 为表里的type,label为显示值
  12204. var linkType = [];
  12205. function fetchEdgeTypes() {
  12206. ConfigDataService.fetchDataList('ciedgetype', { 'idx': 0, 'sum': 100 }).then(function (response) {
  12207. if (response) {
  12208. if (response['list']) {
  12209. linkType = response['list'];
  12210. // d3.select('#linkName').selectAll('option')
  12211. // .data(linkType).enter()
  12212. // .append('option')
  12213. // .attr('value',function(d){return d.type;})
  12214. // .html(function(d){ return d.label;});
  12215. } else {
  12216. SweetAlert.swal({
  12217. title: "提示!",
  12218. text: "服务器请求异常!",
  12219. type: "error"
  12220. });
  12221. }
  12222. } else {
  12223. SweetAlert.swal({
  12224. title: "提示!",
  12225. text: "服务器请求异常!",
  12226. type: "error"
  12227. });
  12228. }
  12229. })
  12230. }
  12231. fetchEdgeTypes();
  12232. /*
  12233. // init D3 force layout
  12234. var force = d3.layout.force()
  12235. .nodes(nodes)
  12236. .links(links)
  12237. .size([width, height])
  12238. .gravity(.05)
  12239. .linkDistance(150)
  12240. .linkStrength(2)
  12241. .charge(-500)
  12242. .on('tick', tick);
  12243. // define arrow markers for graph links
  12244. svg.append('svg:defs').append('svg:marker')
  12245. .attr('id', 'end-arrow')
  12246. .attr('viewBox', '0 -5 10 10')
  12247. .attr('refX', 6)
  12248. .attr('markerWidth', 3)
  12249. .attr('markerHeight', 3)
  12250. .attr('orient', 'auto')
  12251. .append('svg:path')
  12252. .attr('d', 'M0,-5L10,0L0,5')
  12253. .attr('fill', '#000');
  12254. svg.append('svg:defs').append('svg:marker')
  12255. .attr('id', 'start-arrow')
  12256. .attr('viewBox', '0 -5 10 10')
  12257. .attr('refX', 4)
  12258. .attr('markerWidth', 3)
  12259. .attr('markerHeight', 3)
  12260. .attr('orient', 'auto')
  12261. .append('svg:path')
  12262. .attr('d', 'M10,-5L0,0L10,5')
  12263. .attr('fill', '#000');
  12264. // line displayed when dragging new nodes
  12265. var drag_line = svg.append('svg:path')
  12266. .attr('class', 'link dragline hidden')
  12267. .attr('d', 'M0,0L0,0');
  12268. // handles to link and node element groups
  12269. //(1)var path = svg.append('svg:g').selectAll('g')
  12270. var path = svg.append('svg:g').selectAll('g'),
  12271. circle = svg.append('svg:g').selectAll('g');
  12272. */
  12273. // mouse event vars
  12274. var selected_node = null,
  12275. selected_link = null,
  12276. mousedown_link = null,
  12277. mousedown_node = null,
  12278. mouseup_node = null;
  12279. function resetMouseVars() {
  12280. mousedown_node = null;
  12281. mouseup_node = null;
  12282. mousedown_link = null;
  12283. }
  12284. // update force layout (called automatically each iteration)
  12285. function tick() {
  12286. // draw directed edges with proper padding from node centers
  12287. path.selectAll('path').attr('d', function (d) {
  12288. var deltaX = d.target.x - d.source.x,
  12289. deltaY = d.target.y - d.source.y,
  12290. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  12291. normX = deltaX / dist,
  12292. normY = deltaY / dist,
  12293. sourcePadding = d.left ? 27 : 22,
  12294. targetPadding = d.right ? 27 : 22,
  12295. sourceX = d.source.x + (sourcePadding * normX),
  12296. sourceY = d.source.y + (sourcePadding * normY),
  12297. targetX = d.target.x - (targetPadding * normX),
  12298. targetY = d.target.y - (targetPadding * normY);
  12299. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  12300. });
  12301. circle.attr('transform', function (d) {
  12302. return 'translate(' + d.x + ',' + d.y + ')';
  12303. });
  12304. }
  12305. // update graph (called when needed)
  12306. function restart() {
  12307. //绑定link 数据
  12308. path.datum(links);
  12309. // path (link) group
  12310. path = path.data(links, function (d) { return d.id; });
  12311. var p = path.enter().append('svg:g');
  12312. //update existing links
  12313. path.selectAll('path').classed('selected', function (d) { return d === selected_link; })
  12314. .style('marker-start', function (d) { return d.left ? 'url(#start-arrow)' : ''; })
  12315. .style('marker-end', function (d) { return d.right ? 'url(#end-arrow)' : ''; });
  12316. // add new links
  12317. p.append('svg:path')
  12318. .attr('class', 'link')
  12319. .attr('id', function (d) { return "path_" + d.id; })
  12320. // .attr('startOffset', '0%')
  12321. .classed('selected', function (d) { return d === selected_link; })
  12322. .style('marker-start', function (d) { return d.left ? 'url(#start-arrow)' : ''; })
  12323. .style('marker-end', function (d) { return d.right ? 'url(#end-arrow)' : ''; })
  12324. .on('mousedown', function (d) {
  12325. if (d3.event.ctrlKey) return;
  12326. //去除没有提交的连线
  12327. for (var i = 0; i < links.length; i++) {
  12328. if (links[i].id == -1 && d.id != -1) {
  12329. links.splice(i, 1);
  12330. }
  12331. }
  12332. // select link
  12333. mousedown_link = d;
  12334. if (mousedown_link === selected_link) {
  12335. selected_link = $scope.selected_link = null;
  12336. selected_node = $scope.selected_node = null;
  12337. // d3.select("#linkDetail").attr('style','display:none');
  12338. //hideLinkForm(true);//return ;
  12339. } else {
  12340. selected_link = $scope.selected_link = mousedown_link;
  12341. selected_node = $scope.selected_node = null;
  12342. }
  12343. selected_node = $scope.selected_node = null;
  12344. restart();
  12345. });
  12346. p.append('svg:text')
  12347. .attr('x', 30)
  12348. .attr('y', 20)
  12349. .attr('class', 'fontM')
  12350. .append('textPath')
  12351. .attr('xlink:xlink:href', function (d, i) { return "#path_" + d.id; })
  12352. .html(function (d) {
  12353. for (var i = 0; i < linkType.length; i++) {
  12354. if (linkType[i].type == d.name) {
  12355. return linkType[i].label;
  12356. }
  12357. }
  12358. });
  12359. // remove old links
  12360. path.exit().remove();
  12361. // circle (node) group
  12362. // NB: the function arg is crucial here! nodes are known by id, not by index!
  12363. circle.datum(nodes);
  12364. circle = circle.data(nodes, function (d) { return d.id; });
  12365. // update existing nodes (reflexive & selected visual states)
  12366. circle.selectAll('circle')
  12367. .style('fill', function (d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
  12368. .style('fill-opacity', 0.75) // add by xi
  12369. .classed('reflexive', function (d) { return d.reflexive; });
  12370. // add new nodes
  12371. var g = circle.enter().append('svg:g');
  12372. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  12373. //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');
  12374. 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');
  12375. g.append('svg:circle')
  12376. .attr('class', 'node')
  12377. .attr('r', 18)
  12378. .style('fill', function (d) { return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label); })
  12379. .style('stroke', function (d) { return d3.rgb(colors(d.label)).darker().toString(); })
  12380. .style('fill-opacity', 0.25) //add by xj
  12381. .style('stroke-opacity', 0.5) //add by xj
  12382. .classed('reflexive', function (d) { return d.reflexive; });
  12383. g.on('mouseover', function (d) {
  12384. //if(!mousedown_node || d === mousedown_node) return;
  12385. // enlarge target node
  12386. //d3.select(this).attr('transform', 'scale(1.1)');
  12387. })
  12388. .on('mouseout', function (d) {
  12389. //if(!mousedown_node || d === mousedown_node) return;
  12390. // unenlarge target node
  12391. //d3.select(this).attr('transform', '');
  12392. })
  12393. .on('mousedown', function (d) {
  12394. if (d3.event.ctrlKey) return;
  12395. //hideLinkForm(true);
  12396. //去除没有提交的连线
  12397. for (var i = 0; i < links.length; i++) {
  12398. if (links[i].id == -1) {
  12399. links.splice(i, 1);
  12400. }
  12401. }
  12402. // select node
  12403. mousedown_node = d;
  12404. if (mousedown_node === selected_node) {
  12405. selected_node = $scope.selected_node = null;
  12406. } else {
  12407. selected_node = $scope.selected_node = mousedown_node;
  12408. selected_link = $scope.selected_link = null;
  12409. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  12410. APIService.findRefById(selected_node.id).then(function (result) {
  12411. var d = result.data;
  12412. var node = d.node;
  12413. var link = d.edge;
  12414. var tempNode = [];
  12415. var tempLink = [];
  12416. //nodes 或者links 要去重
  12417. for (var i = 0; i < node.length; i++) {
  12418. var tmp = 0;
  12419. for (var j = 0; j < nodes.length; j++) {
  12420. if (node[i].id == nodes[j].id) {
  12421. tmp++;
  12422. break;
  12423. }
  12424. }
  12425. if (tmp == 0) {
  12426. tempNode.push(node[i]);
  12427. }
  12428. }
  12429. for (var i = 0; i < link.length; i++) {
  12430. var tmp = 0;
  12431. for (var j = 0; j < links.length; j++) {
  12432. if (link[i].id == links[j].id) {
  12433. tmp++;
  12434. break;
  12435. }
  12436. }
  12437. if (tmp == 0) {
  12438. tempLink.push(link[i]);
  12439. }
  12440. }
  12441. //数据写入页面
  12442. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  12443. nodes.push(tempNode[i]);
  12444. }
  12445. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  12446. links.push(tempLink[i]);
  12447. }
  12448. //links转换
  12449. for (var i = 0; i < links.length; i++) {
  12450. for (var j = 0; j < nodes.length; j++) {
  12451. if (links[i].source == nodes[j].id) {
  12452. links[i].source = nodes[j];
  12453. }
  12454. if (links[i].target == nodes[j].id) {
  12455. links[i].target = nodes[j];
  12456. }
  12457. }
  12458. }
  12459. restart();
  12460. });
  12461. }
  12462. // reposition drag line
  12463. drag_line
  12464. .style('marker-end', 'url(#end-arrow)')
  12465. .classed('hidden', false)
  12466. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  12467. restart();
  12468. })
  12469. .on('mouseup', function (d) {
  12470. if (!mousedown_node) return;
  12471. });
  12472. // show node name
  12473. g.append('svg:text')
  12474. .attr('x', 0)
  12475. .attr('y', 34)
  12476. .attr('class', 'id')
  12477. .text(function (d) { return d.name; }); //TODO 改为 d.name
  12478. //设置图片
  12479. g.append('svg:foreignObject')
  12480. .attr("width", 32)
  12481. .attr("height", 32)
  12482. .attr('x', "-16px")
  12483. .attr('y', "-11px")
  12484. .html(function (d) {
  12485. for (var i = 0; i < labels.length; i++) {
  12486. if (d.label == labels[i].sign) {
  12487. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  12488. }
  12489. }
  12490. });
  12491. // remove old nodes
  12492. circle.exit().remove();
  12493. // set the graph in motion
  12494. force.start();
  12495. }
  12496. function mousedown() {
  12497. // prevent I-bar on drag
  12498. //d3.event.preventDefault();
  12499. // because :active only works in WebKit?
  12500. svg.classed('active', true);
  12501. if (mousedown_node) {
  12502. viewNode(mousedown_node);
  12503. }
  12504. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  12505. restart();
  12506. }
  12507. function mousemove() {
  12508. if (!mousedown_node) return;
  12509. // update drag line
  12510. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  12511. //restart();
  12512. }
  12513. function mouseup() {
  12514. if (mousedown_node) {
  12515. // hide drag line
  12516. drag_line
  12517. .classed('hidden', true)
  12518. .style('marker-end', '');
  12519. }
  12520. // because :active only works in WebKit?
  12521. svg.classed('active', false);
  12522. // clear mouse event vars
  12523. resetMouseVars();
  12524. }
  12525. function spliceLinksForNode(node) {
  12526. var toSplice = links.filter(function (l) {
  12527. return (l.source === node || l.target === node);
  12528. });
  12529. toSplice.map(function (l) {
  12530. links.splice(links.indexOf(l), 1);
  12531. });
  12532. }
  12533. // only respond once per keydown
  12534. var lastKeyDown = -1;
  12535. function keydown() {
  12536. //d3.event.preventDefault();
  12537. if (lastKeyDown !== -1) return;
  12538. lastKeyDown = d3.event.keyCode;
  12539. // ctrl
  12540. if (d3.event.keyCode === 17) {
  12541. circle.call(force.drag);
  12542. svg.classed('ctrl', true);
  12543. }
  12544. if (!selected_node && !selected_link) return;
  12545. switch (d3.event.keyCode) {
  12546. case 8: // backspace
  12547. case 66: // B
  12548. if (selected_link) {
  12549. // set link direction to both left and right
  12550. selected_link.left = true;
  12551. selected_link.right = true;
  12552. }
  12553. restart();
  12554. break;
  12555. case 76: // L
  12556. if (selected_link) {
  12557. // set link direction to left only
  12558. selected_link.left = true;
  12559. selected_link.right = false;
  12560. }
  12561. restart();
  12562. break;
  12563. case 82: // R
  12564. if (selected_node) {
  12565. // toggle node reflexivity
  12566. selected_node.reflexive = !selected_node.reflexive;
  12567. } else if (selected_link) {
  12568. // set link direction to right only
  12569. selected_link.left = false;
  12570. selected_link.right = true;
  12571. }
  12572. restart();
  12573. break;
  12574. }
  12575. }
  12576. function keyup() {
  12577. lastKeyDown = -1;
  12578. // ctrl
  12579. if (d3.event.keyCode === 17) {
  12580. circle
  12581. .on('mousedown.drag', null)
  12582. .on('touchstart.drag', null);
  12583. svg.classed('ctrl', false);
  12584. }
  12585. }
  12586. function viewNode(node) {
  12587. // console.log(svg.attr('left'));
  12588. //var el = angular.element('div.modal-dialog')[0];
  12589. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  12590. if (!$scope.selected_node.props.state) { $scope.selected_node.props.state = "空" } else if ($scope.selected_node.props.state) {
  12591. 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 = "丢失" }
  12592. };
  12593. if (!$scope.selected_node.name) { $scope.selected_node.name = "空" }
  12594. if (!$scope.selected_node.status) { $scope.selected_node.statu = "空" }
  12595. if (!$scope.selected_node.props.useradmin) { $scope.selected_node.props.useradmin = "空" }
  12596. Toaster.pop({
  12597. // type: 'info',
  12598. // title: title,
  12599. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  12600. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  12601. '<p>状态:' + $scope.selected_node.status + '</p>' +
  12602. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  12603. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  12604. bodyOutputType: 'trustedHtml',
  12605. timeout: 3000
  12606. })
  12607. }
  12608. //GT 颜色与数值对照表
  12609. function colors(sign) {
  12610. //num=num>20?num%20:parseInt(num);
  12611. for (var i = 0; i < labels.length; i++) {
  12612. var entity = labels[i];
  12613. if (sign == entity.sign) {
  12614. return entity.color;
  12615. }
  12616. if (i == labels.length - 1 && sign != entity.sign) {
  12617. return '#ffeeee';
  12618. }
  12619. }
  12620. }
  12621. $scope.init = function () {
  12622. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  12623. // init D3 force layout
  12624. force = d3.layout.force()
  12625. .nodes(nodes)
  12626. .links(links)
  12627. .size([width, height])
  12628. .gravity(.05)
  12629. .linkDistance(150)
  12630. .linkStrength(2)
  12631. .charge(-500)
  12632. .on('tick', tick);
  12633. // define arrow markers for graph links
  12634. svg.append('svg:defs').append('svg:marker')
  12635. .attr('id', 'end-arrow')
  12636. .attr('viewBox', '0 -5 10 10')
  12637. .attr('refX', 6)
  12638. .attr('markerWidth', 3)
  12639. .attr('markerHeight', 3)
  12640. .attr('orient', 'auto')
  12641. .append('svg:path')
  12642. .attr('d', 'M0,-5L10,0L0,5')
  12643. .attr('fill', '#000');
  12644. svg.append('svg:defs').append('svg:marker')
  12645. .attr('id', 'start-arrow')
  12646. .attr('viewBox', '0 -5 10 10')
  12647. .attr('refX', 4)
  12648. .attr('markerWidth', 3)
  12649. .attr('markerHeight', 3)
  12650. .attr('orient', 'auto')
  12651. .append('svg:path')
  12652. .attr('d', 'M10,-5L0,0L10,5')
  12653. .attr('fill', '#000');
  12654. // line displayed when dragging new nodes
  12655. drag_line = svg.append('svg:path')
  12656. .attr('class', 'link dragline hidden')
  12657. .attr('d', 'M0,0L0,0');
  12658. // handles to link and node element groups
  12659. //(1)var path = svg.append('svg:g').selectAll('g')
  12660. path = svg.append('svg:g').selectAll('g');
  12661. circle = svg.append('svg:g').selectAll('g');
  12662. svg.on('mousedown', mousedown)
  12663. .on('mousemove', mousemove)
  12664. .on('mouseup', mouseup);
  12665. d3.select(window)
  12666. .on('keydown', keydown)
  12667. .on('keyup', keyup);
  12668. }
  12669. var CI = {};
  12670. window.CI = CI;
  12671. $scope.ok = function () {
  12672. $modalInstance.close($scope.selected_node);
  12673. };
  12674. $scope.cancel = function () {
  12675. $modalInstance.dismiss('cancel');
  12676. };
  12677. },
  12678. size: size,
  12679. resolve: {
  12680. title: function () {
  12681. return options.templateOptions.title;
  12682. },
  12683. Restangular: function () {
  12684. return options.templateOptions.Restangular;
  12685. },
  12686. APIService: function () {
  12687. return options.templateOptions.ApiService;
  12688. },
  12689. ConfigDataService: function () {
  12690. return options.templateOptions.ConfigDataService;
  12691. },
  12692. ConfigFormService: function () {
  12693. return options.templateOptions.ConfigFormService;
  12694. },
  12695. SweetAlert: function () {
  12696. return options.templateOptions.Alert;
  12697. },
  12698. Toaster: function () {
  12699. return options.templateOptions.toaster;
  12700. }
  12701. }
  12702. });
  12703. modalInstance.result.then(function (selectedItem) {
  12704. options.value(selectedItem.name + '-' + selectedItem.uuid);
  12705. }, function () {
  12706. //console.log('Modal dismissed at: ' + new Date());
  12707. });
  12708. }
  12709. }
  12710. }
  12711. },
  12712. controller: ['$scope', function ($scope) {
  12713. // setTimeout(function(){
  12714. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  12715. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  12716. // if(modelData.status==200){
  12717. // $scope.model[$scope.options.key] = modelData.data;
  12718. // $scope.options.initialValue = $scope.model[$scope.options.key];
  12719. // }
  12720. // });
  12721. // },1000);
  12722. }]
  12723. });
  12724. });
  12725. appFormly.run(function (formlyConfig, $parse) {
  12726. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  12727. var removeOnHideTransformer = function (fields, model) {
  12728. return fields.map(function (field) {
  12729. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  12730. addFieldRemoveOnHideWatcher(field);
  12731. }
  12732. if (field.type == "ui-title") {
  12733. addFieldRemoveOnHideWatcher(field);
  12734. }
  12735. return field;
  12736. });
  12737. };
  12738. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  12739. function addFieldRemoveOnHideWatcher(field) {
  12740. var watcher = getWatcher();
  12741. if (field.watcher) {
  12742. if (!angular.isArray(field.watcher)) {
  12743. field.watcher = [field.watcher];
  12744. }
  12745. field.watcher.push(watcher);
  12746. } else {
  12747. field.watcher = watcher;
  12748. }
  12749. }
  12750. function getWatcher() {
  12751. return {
  12752. expression: function (field) {
  12753. return field.hide;
  12754. },
  12755. listener: function (field, newHide, oldHide, scope) {
  12756. if (field.hide) {
  12757. if (field.templateOptions.pkey) {
  12758. if (field.key == 'transferuser') {
  12759. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  12760. }
  12761. } else {
  12762. $parse(field.key).assign(scope.model, undefined);
  12763. }
  12764. }
  12765. if (field.type == "ui-title") {
  12766. $parse(field.key).assign(scope.model, undefined);
  12767. }
  12768. }
  12769. };
  12770. }
  12771. });
  12772. appFormly.controller('CustomformCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'Restangular', 'UserRestangular', 'BpmRestangular', 'WechatRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_statistic',
  12773. function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, Restangular, UserRestangular, BpmRestangular, WechatRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, api_statistic) {
  12774. //console.log($parse('Restangular')($scope));
  12775. //console.log($injector.get('Restangular'));
  12776. //console.log($stateParams);
  12777. var vm = this;
  12778. vm.options = {};
  12779. vm.exampleTitle = ['expressionProperties', 'model property'];
  12780. vm.fields = [];
  12781. vm.model = {};
  12782. // $scope.jry_formFun=(function(filterData, APIService){filterData.user.roledata.rolecode='question investigation';return APIService.fetchDataList('user',filterData)})
  12783. $scope.langs = i18nService.getAllLangs();
  12784. $scope.lang = 'zh-cn';
  12785. i18nService.setCurrentLang($scope.lang);
  12786. //alert($rootScope.user.id,null,2);
  12787. vm.model["loginUser"] = $rootScope.user;
  12788. var that = $injector;
  12789. var parse = $parse;
  12790. var formKey = "";
  12791. var pdKey = "";
  12792. var modelWatch = "";
  12793. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  12794. modelWatch = JSON.parse($stateParams.model);
  12795. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  12796. }
  12797. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  12798. pdKey = $state.current.pdKey;
  12799. } else if ($stateParams.pdKey) {
  12800. pdKey = $stateParams.pdKey;
  12801. }
  12802. // console.log("pdKey::" + JSON.stringify($state.current.title));
  12803. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  12804. formKey = $stateParams.formKey;
  12805. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  12806. }
  12807. if (angular.isDefined($stateParams.model)) {
  12808. var formModel = $stateParams.model;
  12809. }
  12810. //用户测试数据,后续从header的auth中获取
  12811. var userId = 2;
  12812. userId = $rootScope.user.id;
  12813. //==============处理表单设计数据 开始====================
  12814. //处理组件加载后台数据选项的方法
  12815. function refreshSelectOptions(searchVal, field) {
  12816. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  12817. var process = BpmRestangular.all("");
  12818. if (field.templateOptions.ApiService) {
  12819. process = UserRestangular.all("");
  12820. }
  12821. if (field.templateOptions.Apicommon) {
  12822. process = WechatRestangular.all("");
  12823. }
  12824. var datakey = { "idx": 0, "sum": 1000 };
  12825. if (field.templateOptions.modelreasondata) {
  12826. datakey = field.templateOptions.modelreasondata
  12827. }
  12828. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  12829. if (!field.templateOptions.options) {
  12830. field.templateOptions.options = [];
  12831. }
  12832. if (field.templateOptions.optionsDataKey) {
  12833. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  12834. } else {
  12835. field.templateOptions.options = result;
  12836. }
  12837. });
  12838. }
  12839. }
  12840. //获取表单后数据处理
  12841. function formfield(field, result) {
  12842. // angular.forEach(fields.fields, function(field) {
  12843. if (field.key == "") {
  12844. delete field.key;
  12845. }
  12846. if (angular.isDefined(field.extjson)) {
  12847. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  12848. angular.extend(field.templateOptions, extObj.templateOptions);
  12849. delete extObj.templateOptions;
  12850. for (var prop in extObj) {
  12851. if (new RegExp("Expression").test(prop)) {
  12852. //var obj = $scope.$eval(extObj[prop]);
  12853. //extObj[prop] = $scope.$eval(extObj[prop]);
  12854. if (extObj[prop] != null) {
  12855. if (new RegExp("function").test(extObj[prop])) {
  12856. var propValue = eval(extObj[prop]);
  12857. extObj[prop] = propValue;
  12858. } else {
  12859. //console.log(extObj[prop]);
  12860. var obj = $scope.$eval(extObj[prop]);
  12861. extObj[prop] = obj;
  12862. //console.log(obj);
  12863. }
  12864. }
  12865. } else if (new RegExp("expressionProperties").test(prop)) {
  12866. for (var p in extObj[prop]) {
  12867. if (new RegExp("function").test(extObj[prop][p])) {
  12868. var propValue = eval(extObj[prop][p]);
  12869. extObj[prop][p] = propValue;
  12870. } else {
  12871. //if(p.indexOf("'")>=0){
  12872. // var obj = $scope.$eval(extObj[prop][p]);
  12873. // extObj[prop][$scope.$eval(p)]=obj;
  12874. //}
  12875. }
  12876. }
  12877. } else if ("watcher" == prop) {
  12878. if (angular.isArray(extObj[prop])) {
  12879. angular.forEach(extObj[prop], function (item, index) {
  12880. for (var p in item) {
  12881. if (new RegExp("function").test(item[p])) {
  12882. var propValue = eval(item[p]);
  12883. extObj[prop][index][p] = propValue;
  12884. }
  12885. }
  12886. });
  12887. } else if (angular.isObject(extObj[prop])) {
  12888. for (var p in extObj[prop]) {
  12889. if (new RegExp("function").test(extObj[prop][p])) {
  12890. var propValue = eval(extObj[prop][p]);
  12891. extObj[prop][p] = propValue;
  12892. }
  12893. }
  12894. }
  12895. }
  12896. }
  12897. angular.extend(field, extObj);
  12898. delete field.extjson;
  12899. }
  12900. if (angular.isDefined(field.templateOptions)) {
  12901. var templateOs = field.templateOptions;
  12902. for (var property in templateOs) {
  12903. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  12904. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  12905. if (new RegExp("function").test(templateOs[property])) {
  12906. var propValue = eval(templateOs[property]);
  12907. field.templateOptions[property] = propValue;
  12908. } else {
  12909. if (that.has(templateOs[property])) {
  12910. field.templateOptions[property] = that.get(templateOs[property]);
  12911. } else {
  12912. field.templateOptions[property] = templateOs[property];
  12913. }
  12914. }
  12915. } else if (templateOs[property] == null) {
  12916. //delete field.templateOptions[property];
  12917. } else { }
  12918. }
  12919. }
  12920. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  12921. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  12922. angular.extend(field.templateOptions, extObj);
  12923. delete field.templateOptions.extjson;
  12924. }
  12925. // ...
  12926. if (field.templateOptions) {
  12927. //处理远程获取数据控件方法调用
  12928. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  12929. // if (!field.templateOptions.isnoreash) {
  12930. field.templateOptions.refresh = refreshSelectOptions;
  12931. // }
  12932. }
  12933. //处理嵌套属性数据绑定/
  12934. if (field.templateOptions.pkey) {
  12935. var pmodel, i = 0;
  12936. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  12937. if (i == 0) {
  12938. if (result.model[p] == null) {
  12939. result.model[p] = {};
  12940. }
  12941. pmodel = result.model[p];
  12942. i++;
  12943. } else {
  12944. if (pmodel[p] == null) {
  12945. pmodel[p] = {};
  12946. }
  12947. pmodel = pmodel[p];
  12948. }
  12949. });
  12950. if (pmodel != null) {
  12951. field.model = pmodel;
  12952. if (pmodel[field.key] == null) {
  12953. pmodel[field.key] = null;
  12954. }
  12955. }
  12956. } else {
  12957. if (result.model[field.key] == null) {
  12958. result.model[field.key] = null;
  12959. }
  12960. }
  12961. //处理弹出框组件初始化
  12962. if (field.type == "ui-input-selectmodal") {
  12963. field.templateOptions.modal = $modal;
  12964. //field.templateOptions.Restangular = Restangular;
  12965. } else if (field.type == "ui-requesterselect") {
  12966. //field.templateOptions.language = $scope.lang;
  12967. field.templateOptions.modal = $modal;
  12968. field.templateOptions.UserService = api_user_data;
  12969. } else if (field.type == "ui-requesterinformation") {
  12970. field.templateOptions.modal = $modal;
  12971. field.templateOptions.UserService = api_user_data;
  12972. } else if (field.type == "ui-userselect") {
  12973. field.templateOptions.modal = $modal;
  12974. //field.templateOptions.Restangular = Restangular;
  12975. }
  12976. // else if (field.type == "ui-repeatSection") {
  12977. // field.templateOptions.fields[3].templateOptions.fetchItems=eval(field.templateOptions.fields[3].templateOptions.fetchItems);
  12978. // field.templateOptions.fields[3].templateOptions["modal"]=$modal;
  12979. // }
  12980. else if (field.type == "ui-userselectSearch") {
  12981. field.templateOptions.modal = $modal;
  12982. //field.templateOptions.Restangular = Restangular;
  12983. } else if (field.type == "ui-multiuserselect") {
  12984. field.templateOptions.modal = $modal;
  12985. } else if (field.type == "ui-stringuserselect") {
  12986. field.templateOptions.modal = $modal;
  12987. } else if (field.type == "ui-search") {
  12988. field.templateOptions.modal = $modal;
  12989. } else if (field.type == "ui-modelselect") {
  12990. field.templateOptions.modal = $modal;
  12991. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  12992. field.templateOptions.loginUser = $rootScope.user;
  12993. //field.templateOptions.Restangular = Restangular;
  12994. } else if (field.type == "ui-incidentmodelselect") {
  12995. field.templateOptions.modal = $modal;
  12996. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  12997. field.templateOptions.loginUser = $rootScope.user;
  12998. //field.templateOptions.Restangular = Restangular;
  12999. } else if (field.type == "ui-dropfile") {
  13000. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13001. url: '/uploader'
  13002. });
  13003. field.templateOptions.taskId = $stateParams.taskId;
  13004. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13005. field.templateOptions.userId = $rootScope.user.id;
  13006. } else if (field.type == "ui-dropfielknow") {
  13007. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13008. url: '/uploader'
  13009. });
  13010. field.templateOptions.taskId = $stateParams.taskId;
  13011. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13012. field.templateOptions.userId = $rootScope.user.id;
  13013. } else if (field.type == "ui-dropfilenotup") {
  13014. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  13015. url: '/uploader'
  13016. });
  13017. field.templateOptions.taskId = $stateParams.taskId;
  13018. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13019. field.templateOptions.userId = $rootScope.user.id;
  13020. //field.ApiService=api_bpm_domain;
  13021. } else if (field.type == "ui-dropfiletable") {
  13022. if (field.templateOptions.processInstanceId) {
  13023. } else {
  13024. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  13025. }
  13026. } else if (field.type == "ui-repeatSection") {
  13027. var repeatForm = {
  13028. model: {
  13029. },
  13030. fields: field.templateOptions.fields
  13031. };
  13032. repeatForm.model[field.key] = [];
  13033. decodeVMForm(repeatForm);
  13034. } else if (field.type == "ui-currentuser") {
  13035. field.templateOptions.user = vm.model["loginUser"];
  13036. } else if (field.type == "ui-workernumbersign") {
  13037. field.templateOptions.user = vm.model["loginUser"];
  13038. }
  13039. }
  13040. }
  13041. //解析自定义表单设计数据
  13042. $scope.oldfromtype = true;
  13043. function decodeVMForm(vmForm) {
  13044. if (vmForm.formType == "1") {
  13045. $scope.oldfromtype = false;
  13046. } else {
  13047. $scope.oldfromtype = true;
  13048. }
  13049. var result = { model: {}, fields: [] };
  13050. //设置模型实体数据 begin
  13051. // var mdata = vmForm.model;
  13052. //解析数据实体
  13053. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  13054. angular.extend(result.model, mdata);
  13055. if (modelWatch != null && modelWatch != '') {
  13056. //angular.extend(result.model.incident,modelWatch.incident);
  13057. //result.model.alarmType = modelWatch.alarmType;
  13058. // vmForm.cancelUrl = modelWatch.cancelUrl;
  13059. // console.log(modelWatch.cancelUrl)
  13060. for (var index in modelWatch.model) {
  13061. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  13062. if (result.model[index] != null) {
  13063. angular.extend(result.model[index], modelWatch.model[index]);
  13064. } else {
  13065. result.model[index] = modelWatch.model[index];
  13066. }
  13067. }
  13068. }
  13069. //设置模型实体数据 end
  13070. //解析设计数据生成表单项 begin
  13071. var fields = [];
  13072. //处理修改设计数据中展示设置
  13073. angular.forEach(vmForm.fields, function (fields) {
  13074. if (vmForm.formType == "1") {
  13075. angular.forEach(fields.fields, function (field) {
  13076. formfield(field, result);
  13077. });
  13078. } else {
  13079. formfield(fields, result);
  13080. }
  13081. // console.log(field);
  13082. result.fields.push(fields);
  13083. });
  13084. angular.extend($scope.vm.fields, result.fields);
  13085. angular.extend($scope.vm.model, result.model);
  13086. vm.model["loginUser"] = $rootScope.user;
  13087. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  13088. vmForm.cancelUrl = modelWatch.cancelUrl;
  13089. }
  13090. $scope.formData = vmForm;
  13091. console.log($scope.formData.url);
  13092. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  13093. if ($scope.formData.url == "start") {
  13094. $scope.Reset = true;
  13095. $scope.close = true;
  13096. $rootScope.isMask = false;
  13097. } else if ($scope.formData.url == "complete") {
  13098. $scope.Reset = false;
  13099. $scope.close = true;
  13100. }
  13101. //解析设计数据生成表单项 end
  13102. return result;
  13103. }
  13104. //======================处理表单设计数据 结束========================
  13105. $scope.ldloading = {};
  13106. function filter(obj) {
  13107. angular.forEach(obj, function (key, value) {
  13108. if (value === "" || value === null) {
  13109. delete obj[key];
  13110. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  13111. filter(value);
  13112. } else if (angular.isArray(value)) {
  13113. angular.forEach(value, function (item) {
  13114. filter(item);
  13115. });
  13116. }
  13117. });
  13118. }
  13119. $scope.closeModel = function () {
  13120. $state.go($scope.formData.cancelUrl, {});
  13121. event.preventDefault();
  13122. };
  13123. $scope.save = function (data) {
  13124. api_bpm_domain.save($stateParams.taskId, data).then(function (response) {
  13125. if (response) {
  13126. var resData = Restangular.stripRestangular(response);
  13127. SweetAlert.swal({
  13128. title: "暂存成功!",
  13129. confirmButtonColor: "#007AFF"
  13130. }, function () {
  13131. $state.go($scope.formData.cancelUrl);
  13132. });
  13133. } else {
  13134. SweetAlert.swal({
  13135. title: "系统错误",
  13136. text: "系统错误,请稍后重试!",
  13137. type: "error",
  13138. confirmButtonColor: "#DD6B55"
  13139. });
  13140. }
  13141. });
  13142. event.preventDefault();
  13143. }
  13144. vm.submit = function (data, style) {
  13145. // var pdKey = $stateParams.pdKey;
  13146. if (vm.form.$valid) {
  13147. if (data.incident&&data.incident.synergetic) {
  13148. console.log(data.incident.synergetic);
  13149. var synergetic = [];
  13150. for (var i = 0; i < data.incident.synergetic.length; i++) {
  13151. synergetic.push({ id: data.incident.synergetic[i] });
  13152. }
  13153. data.incident.synergetic = synergetic;
  13154. vm.model.incident.synergetic = synergetic;
  13155. }
  13156. $scope.ldloading[style.replace('-', '_')] = true;
  13157. var startsub = true;
  13158. if (pdKey == 'bpm_incident') {
  13159. angular.forEach(vm.fields, function (item) {
  13160. angular.forEach(item.fields, function (index) {
  13161. if (index.templateOptions.required && !index.hide) {
  13162. if (index.model) {
  13163. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  13164. if (index.model[index.key].id && index.model[index.key].id == '') {
  13165. startsub = false;
  13166. $scope.ldloading.expand_right = false;
  13167. SweetAlert.swal({
  13168. title: index.templateOptions.label + '未填',
  13169. text: "请填写此项!",
  13170. type: "error",
  13171. confirmButtonColor: "#DD6B55"
  13172. });
  13173. } else { }
  13174. } else {
  13175. startsub = false;
  13176. $scope.ldloading.expand_right = false;
  13177. SweetAlert.swal({
  13178. title: index.templateOptions.label + '未填',
  13179. text: "请填写此项!",
  13180. type: "error",
  13181. confirmButtonColor: "#DD6B55"
  13182. });
  13183. }
  13184. } else {
  13185. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  13186. } else {
  13187. startsub = false;
  13188. $scope.ldloading.expand_right = false;
  13189. SweetAlert.swal({
  13190. title: index.templateOptions.label + '未填',
  13191. text: "请填写此项!",
  13192. type: "error",
  13193. confirmButtonColor: "#DD6B55"
  13194. });
  13195. }
  13196. }
  13197. }
  13198. })
  13199. })
  13200. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  13201. // startsub = false;
  13202. // $scope.ldloading.expand_right = false;
  13203. // SweetAlert.swal({
  13204. // title: '保修人未填',
  13205. // text: "请填写此项!",
  13206. // type: "error",
  13207. // confirmButtonColor: "#DD6B55"
  13208. // });
  13209. // }
  13210. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  13211. // } else {
  13212. // startsub = false;
  13213. // $scope.ldloading.expand_right = false;
  13214. // SweetAlert.swal({
  13215. // title: '事件分类未填',
  13216. // text: "请填写此项!",
  13217. // type: "error",
  13218. // confirmButtonColor: "#DD6B55"
  13219. // });
  13220. // }
  13221. }
  13222. if (startsub) {
  13223. $scope.ldloading[style.replace('-', '_')] = true;
  13224. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  13225. // console.log("vm.options:"+ JSON.stringify(vm.options));
  13226. vm.options.updateInitialValue();
  13227. // console.log("dfjkasdhfkhskjf ")
  13228. var _ = window._;
  13229. vm.model = (function filter(obj) {
  13230. var dateTransKeys = [];
  13231. var filtered = _.pick(obj, function (v, k, obj) {
  13232. if (_.isDate(v)) {
  13233. dateTransKeys.push(k);
  13234. }
  13235. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  13236. });
  13237. return _.cloneDeep(filtered, function (v, index, object) {
  13238. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  13239. angular.forEach(dateTransKeys, function (item) {
  13240. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  13241. })
  13242. dateTransKey = [];
  13243. return v;
  13244. }
  13245. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  13246. });
  13247. })(vm.model);
  13248. if (pdKey != "") {
  13249. if ($scope.oprcode == "save") { //保存
  13250. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  13251. if (response) {
  13252. var resData = Restangular.stripRestangular(response);
  13253. SweetAlert.swal({
  13254. title: "保存成功!",
  13255. confirmButtonColor: "#007AFF"
  13256. }, function () {
  13257. $state.go($scope.formData.cancelUri);
  13258. });
  13259. // if(resData.status){
  13260. // resData
  13261. // }
  13262. } else {
  13263. SweetAlert.swal({
  13264. title: "系统错误",
  13265. text: "系统错误,请稍后重试!",
  13266. type: "error",
  13267. confirmButtonColor: "#DD6B55"
  13268. });
  13269. }
  13270. $scope.ldloading[style.replace('-', '_')] = false;
  13271. });
  13272. } else {
  13273. switch ($scope.formData.url) {
  13274. case "start":
  13275. vm.model["initUser"] = $rootScope.user.id;
  13276. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  13277. } else {
  13278. vm.model["assignee"] = $rootScope.user.id;
  13279. }
  13280. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  13281. vm.model.candidateGroups = vm.model.candidateGroups.id;
  13282. }
  13283. if (pdKey == 'bpm_service_request') {
  13284. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  13285. angular.extend(vm.model.serviceCatalogueProcessActual, {
  13286. 'category': {
  13287. 'id': $stateParams.userId
  13288. }
  13289. });
  13290. }
  13291. // if ($scope.login && vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "" && !$rootScope.busy) {
  13292. // $rootScope.setidle();
  13293. // }
  13294. api_bpm_domain.start(pdKey, vm.model).then(function (response) {
  13295. // console.log("response="+JSON.stringify(response));
  13296. if (response) {
  13297. var resData = Restangular.stripRestangular(response);
  13298. if (resData) {
  13299. console.log(vm);
  13300. console.log(resData);
  13301. // if (resData) {
  13302. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  13303. $scope.fileUploader.onBeforeUploadItem = function (item) {
  13304. angular.extend(item.headers, $rootScope.getSession());
  13305. item.url = api_bpm_domain.uploadAttachment(vm.model.filekey,resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  13306. item.formData.push({ 'fileName': item.file.name });
  13307. //console.log();
  13308. };
  13309. $scope.fileUploader.uploadAll();
  13310. }
  13311. // } else {
  13312. // }
  13313. }
  13314. SweetAlert.swal({
  13315. title: "提交成功!",
  13316. type: "success",
  13317. confirmButtonColor: "#007AFF"
  13318. }, function () {
  13319. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  13320. $rootScope.app.layout.isSidebarClosed = false;
  13321. if ($scope.login && !$rootScope.busy) {
  13322. $rootScope.setidle();
  13323. }
  13324. }
  13325. $state.go($scope.formData.cancelUrl);
  13326. });
  13327. } else {
  13328. SweetAlert.swal({
  13329. title: "系统错误",
  13330. text: "系统错误,请稍后重试!",
  13331. type: "error",
  13332. confirmButtonColor: "#DD6B55"
  13333. });
  13334. }
  13335. $scope.ldloading[style.replace('-', '_')] = false;
  13336. });
  13337. break;
  13338. case "complete":
  13339. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  13340. //console.log("complete taskId::"+$stateParams.taskId);
  13341. // console.log(vm)
  13342. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  13343. if (response) {
  13344. var resData = Restangular.stripRestangular(response);
  13345. SweetAlert.swal({
  13346. title: "提交成功!",
  13347. type: "success",
  13348. confirmButtonColor: "#007AFF"
  13349. }, function () {
  13350. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13351. // // $scope.uploader.options.url();
  13352. // $scope.uploader.onBeforeUploadItem = function(item) {
  13353. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13354. // console.info('onBeforeUploadItem', item);
  13355. // };
  13356. // $scope.uploader.uploadAll();
  13357. // }
  13358. $state.go($scope.formData.cancelUrl);
  13359. });
  13360. } else {
  13361. SweetAlert.swal({
  13362. title: "系统错误",
  13363. text: "系统错误,请稍后重试!",
  13364. type: "error",
  13365. confirmButtonColor: "#DD6B55"
  13366. });
  13367. }
  13368. $scope.ldloading[style.replace('-', '_')] = false;
  13369. });
  13370. break;
  13371. case "back":
  13372. $state.go($scope.formData.cancelUrl);
  13373. break;
  13374. default:
  13375. $scope.ldloading[style.replace('-', '_')] = false;
  13376. break;
  13377. }
  13378. }
  13379. // var submitFunc = api_bpm_domain[$scope.formData.url]
  13380. // if(anuglar.isFunction(submitFunc)){
  13381. // submitFunc.apply(null, pdKey)
  13382. // }
  13383. }
  13384. }
  13385. } else {
  13386. // console.log(data)
  13387. // angular.forEach(vm.form.$error.required, function(item){
  13388. // var i=(item.$name).substring(item.$name.length-2)
  13389. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  13390. // for(var i=0;i<vm.fields.length;i++){
  13391. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  13392. SweetAlert.swal({
  13393. title: vm.fields[i].templateOptions.label + '未填',
  13394. text: "请填写此项!",
  13395. type: "error",
  13396. confirmButtonColor: "#DD6B55"
  13397. });
  13398. }
  13399. // }
  13400. // angular.forEach(vm.fields,function(f){
  13401. // if(f.name == item.$name){
  13402. // f.validation.show = true;
  13403. // SweetAlert.swal({
  13404. // title: f.templateOptions.label+'未填',
  13405. // text: "请填写此项!",
  13406. // type: "error",
  13407. // confirmButtonColor: "#DD6B55"
  13408. // });
  13409. // }
  13410. // });
  13411. // })
  13412. }
  13413. };
  13414. $scope.vm = vm;
  13415. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  13416. var processInstanceId = $stateParams.processInstanceId;
  13417. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  13418. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  13419. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  13420. var vmForm = Restangular.stripRestangular(responseData);
  13421. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  13422. decodeVMForm(vmForm);
  13423. }
  13424. }
  13425. });
  13426. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  13427. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  13428. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  13429. var vmForm = Restangular.stripRestangular(responseData);
  13430. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  13431. decodeVMForm(vmForm);
  13432. }
  13433. }
  13434. });
  13435. } else {
  13436. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  13437. if (response) {
  13438. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  13439. api_configure_form.renderForm(myData.data, userId, processInstanceId).then(function (responseData) {
  13440. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  13441. var vmForm = Restangular.stripRestangular(responseData);
  13442. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  13443. decodeVMForm(vmForm);
  13444. }
  13445. }
  13446. });
  13447. }
  13448. })
  13449. }
  13450. } else {
  13451. // create process instance
  13452. if (pdKey != "") { //for process
  13453. if (pdKey == 'bpm_service_request') {
  13454. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  13455. if (responseData) {
  13456. var vmForm = Restangular.stripRestangular(responseData);
  13457. if (vmForm) {
  13458. decodeVMForm(vmForm);
  13459. }
  13460. }
  13461. });
  13462. } else {
  13463. api_bpm_domain.startformkey(pdKey).then(function (response) {
  13464. if (response) {
  13465. var myData = Restangular.stripRestangular(response);
  13466. //myData.data = "arrangeform";
  13467. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  13468. if (responseData) {
  13469. var vmForm = Restangular.stripRestangular(responseData);
  13470. if (vmForm) {
  13471. decodeVMForm(vmForm);
  13472. }
  13473. }
  13474. });
  13475. }
  13476. });
  13477. }
  13478. } else { //for form
  13479. //TODO
  13480. //测试数据 开始
  13481. var testJson = {
  13482. fields: [{
  13483. fields: [{
  13484. className: "col-xs-12",
  13485. noFormControl: true,
  13486. key: "formtitle",
  13487. templateOptions: { readOnly: false, placeholder: "新建事件单", hidden: false, label: "事件工单", required: false },
  13488. type: "ui-title"
  13489. }]
  13490. }, {
  13491. fields: [{
  13492. key: 'selectUser',
  13493. type: 'ui-requesterinformation',
  13494. className: 'col-xs-12',
  13495. templateOptions: {
  13496. label: '请求人信息',
  13497. modalTitle: '请求人列表',
  13498. fetchItems: function (filterData, APIService) {
  13499. return APIService.fetchDataList('requester', filterData);
  13500. },
  13501. Restangular: Restangular,
  13502. ApiService: api_user_data
  13503. // onClick:function(val, options, field, event , model){
  13504. // console.log(options);
  13505. // }
  13506. }
  13507. }]
  13508. }, {
  13509. fields: [{
  13510. key: 'first',
  13511. type: 'ui-workernumber',
  13512. className: 'col-xs-12',
  13513. templateOptions: {
  13514. type: 'input',
  13515. label: '事件单号',
  13516. pkey: 'name'
  13517. }
  13518. }]
  13519. }, {
  13520. fields: [{
  13521. type: 'ui-header',
  13522. key: 'title',
  13523. className: 'col-xs-12',
  13524. templateOptions: {
  13525. label: '报修人',
  13526. pkey: 'change'
  13527. }
  13528. }, {
  13529. type: 'ui-input',
  13530. key: 'title',
  13531. className: 'col-xs-4',
  13532. templateOptions: {
  13533. label: '报修人',
  13534. pkey: 'change'
  13535. }
  13536. }, {
  13537. type: 'ui-input',
  13538. key: 'title',
  13539. className: 'col-xs-4',
  13540. templateOptions: {
  13541. label: '联系人',
  13542. pkey: 'change'
  13543. }
  13544. }, {
  13545. type: 'ui-input',
  13546. key: 'title',
  13547. className: 'col-xs-4',
  13548. templateOptions: {
  13549. label: '联系电话',
  13550. pkey: 'change'
  13551. }
  13552. }]
  13553. }, {
  13554. fields: [{
  13555. type: 'ui-header',
  13556. key: 'title1',
  13557. className: 'col-xs-12',
  13558. templateOptions: {
  13559. label: '报修人',
  13560. pkey: 'change'
  13561. }
  13562. }, {
  13563. type: 'ui-input',
  13564. key: 'title2',
  13565. className: 'col-xs-4',
  13566. templateOptions: {
  13567. label: '报修人',
  13568. pkey: 'change'
  13569. }
  13570. }, {
  13571. type: 'ui-input',
  13572. key: 'title3',
  13573. className: 'col-xs-4',
  13574. templateOptions: {
  13575. label: '联系人',
  13576. pkey: 'change'
  13577. }
  13578. }, {
  13579. type: 'ui-input',
  13580. key: 'title4',
  13581. className: 'col-xs-4',
  13582. templateOptions: {
  13583. label: '联系电话',
  13584. pkey: 'change'
  13585. }
  13586. }]
  13587. }],
  13588. model: [{
  13589. username: "robin lau",
  13590. password: "123456",
  13591. chkme: false,
  13592. start_code: 0,
  13593. formtitle: "Hey!I am title value!",
  13594. name: {
  13595. first: "robin",
  13596. last: "lau"
  13597. },
  13598. multiselectItem: []
  13599. //date:"2015-09-15 00:00:00"
  13600. }]
  13601. // }
  13602. };
  13603. setTimeout(function () {
  13604. decodeVMForm(testJson);
  13605. $scope.$apply();
  13606. }, 500);
  13607. //测试数据结束
  13608. }
  13609. }
  13610. //console.log("end decode");
  13611. }
  13612. ]);