customformCtrl.js 351 KB

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