1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807 |
- var appFormly = angular.module('formlyExample', [
- 'formly', 'formlyBootstrap', 'ui.bootstrap',
- 'ngSanitize', 'ui.select', 'ui.grid'
- ]);
- app.requires.push('formlyExample');
- // var appFormly = angular.module('formlyExample', [
- // 'formly', 'formlyBootstrap','ui.bootstrap',
- // 'ngSanitize','ui.select','ui.grid'],
- // 图片上传
- app.factory('fileReader', ["$q", "$log", function ($q, $log) {
- var onLoad = function (reader, deferred, scope) {
- return function () {
- scope.$apply(function () {
- deferred.resolve(reader.result);
- });
- };
- };
- var onError = function (reader, deferred, scope) {
- return function () {
- scope.$apply(function () {
- deferred.reject(reader.result);
- });
- };
- };
- var getReader = function (deferred, scope) {
- var reader = new FileReader(); //fileReader
- reader.onload = onLoad(reader, deferred, scope);
- reader.onerror = onError(reader, deferred, scope);
- return reader;
- };
- var readAsDataURL = function (file, scope) {
- var deferred = $q.defer();
- var reader = getReader(deferred, scope);
- reader.readAsDataURL(file);
- return deferred.promise;
- };
- return {
- readAsDataUrl: readAsDataURL
- };
- }])
- appFormly.filter('minutesToHours', function() { //分钟转小时
- return function(num) {
- var hour = parseInt(num / 60);
- var minute = num % 60;
- return hour + '小时' + minute + '分钟';
- }
- });
- appFormly.config(
- function config(formlyConfigProvider) {
- //格式转换方法 XXX-XXX转驼峰命名
- function camelize(string) {
- string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
- return chr ? chr.toUpperCase() : '';
- });
- // Ensure 1st char is always lowercase
- return string.replace(/^([A-Z])/, function (match, chr) {
- return chr ? chr.toLowerCase() : '';
- });
- }
- //获取ngModelAttr对象设置
- function getNgModelAttr(attrs, bindings) {
- var ngModelAttrs = {};
- angular.forEach(attrs, function (attr) {
- ngModelAttrs[camelize(attr)] = {
- attribute: attr
- };
- });
- angular.forEach(bindings, function (binding) {
- ngModelAttrs[camelize(binding)] = {
- bound: binding
- };
- });
- return ngModelAttrs;
- }
- formlyConfigProvider.setWrapper({
- name: 'bootstrapLabel',
- templateUrl: 'assets/views/customform/tpl/normal-label.html'
- });
- //流程图
- formlyConfigProvider.setType({
- name: 'ui-process',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
- $scope.processdata = [];
- api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function (data) {
- console.log(data)
- $scope.processdata = data.data;
- })
- }]
- });
- //出库单详情
- formlyConfigProvider.setType({
- name: 'ui-getoutinform',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
- if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
- if ($scope.model.type.id = 0) {
- $scope.model.type.name = "新资产入库";
- } else if ($scope.model.type.id = 1) {
- $scope.model.type.name = "新设备领用出库";
- } else if ($scope.model.type.id = 2) {
- $scope.model.type.name = "资产归还";
- } else if ($scope.model.type.id = 4) {
- $scope.model.type.name = "设备更换";
- }
- }
- }]
- });
- //多选框组件
- formlyConfigProvider.setType({
- name: 'ui-checkboxmore',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }]
- });
- //入库单详情
- formlyConfigProvider.setType({
- name: 'ui-getininform',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
- if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
- if ($scope.model.type.id = 0) {
- $scope.model.type.name = "新资产入库";
- } else if ($scope.model.type.id = 1) {
- $scope.model.type.name = "新设备领用出库";
- } else if ($scope.model.type.id = 2) {
- $scope.model.type.name = "资产归还";
- } else if ($scope.model.type.id = 4) {
- $scope.model.type.name = "设备更换";
- }
- }
- }]
- });
- //申请人详情
- formlyConfigProvider.setType({
- name: 'ui-requsterinfom',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- }
- });
- //设备耗材list组件
- formlyConfigProvider.setType({
- name: 'ui-uplodchange',
- templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0,
- view: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId);
- }
- }
- };
- },
- controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
- // var data = { "haodata": [], "shedata": [] };
- var haodata = [];
- var shedata = [];
- if ($scope.model.consumables) {
- if (angular.isArray($scope.model.consumables)) {
- haodata = $scope.model.consumables;
- } else {
- haodata = JSON.parse($scope.model.consumables);
- }
- $scope.model.consumables = haodata;
- angular.forEach(haodata, function (item, index) {
- haodata[index].item = index + 1;
- })
- }
- if ($scope.model.assets) {
- if (angular.isArray($scope.model.assets)) {
- shedata = $scope.model.assets;
- } else {
- shedata = JSON.parse($scope.model.assets);
- }
- $scope.model.assets = shedata;
- angular.forEach(shedata, function (item, index) {
- shedata[index].item = index + 1;
- })
- }
- $scope.tableParamshao = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: haodata.length,
- getData: function ($defer, params) {
- var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- $scope.tableParamsshe = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: shedata.length,
- getData: function ($defer, params) {
- var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- $scope.editId = -1;
- $scope.setEditId = function (pid) {
- $scope.editId = pid;
- };
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- var to = $scope.options.templateOptions;
- var bindId = $scope.model.processInstanceId;
- //获取附件列表
- $scope.listAttachmen = function () {
- to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
- var myData = Restangular.stripRestangular(result);
- // $scope.listAttachmens = myData;
- $scope.attachments = myData.data;
- });
- };
- $scope.listAttachmen();
- // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
- // $scope.listAttachmen();
- // } else if (to.bindType && $scope.model[to.bindType].id) {
- // $scope.listAttachmen();
- // }
- //附件下载
- $scope.download = function (token, filename) {
- var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
- // window.open(downUrl);
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- //附件预览
- $scope.view = function (id, previewUrl) {
- if (previewUrl) {
- window.open(previewUrl);
- }
- };
- }]
- });
- //多选框组件
- formlyConfigProvider.setType({
- name: 'ui-nodataimage',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- }
- });
- //ui-grid list
- formlyConfigProvider.setType({
- name: "ui-gridtwolist",
- // extends: 'input',
- templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
- //gridone
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myDatagrid';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.myDatagrid = [];
- $scope.myDatagridall = [];
- $scope.selected = {
- item: {}
- };
- $scope.memoryfilterDatagrid = {
- idx: 0,
- sum: 10
- }
- if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
- filterData = {
- idx: 0,
- sum: 10
- };
- $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
- }
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- // $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- $scope.memoryfilterDatagrid.idx = newPage - 1;
- $scope.memoryfilterDatagrid.sum = pageSize;
- $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
- $scope.loadData({
- "idx": newPage - 1,
- "sum": pageSize
- });
- });
- gridApi.core.on.filterChanged($scope, function () { });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- $scope.loadData = function (mydate, idx, sum) {
- angular.forEach($scope.myDatagrid, function (item, index) {
- $scope.myDatagrid[index].item = index;
- })
- $scope.gridOptions.totalItems = mydate.length;
- $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
- }
- if ($scope.model.assets) {
- $scope.myDatagridall = $scope.model.assets;
- $scope.loadData($scope.model.assets, 0, 10)
- }
- $scope.saveData = function (itemin) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
- controller: function ($scope, $modalInstance, SweetAlert) {
- // $scope.consumptive = {};
- $scope.title = "填写领用设备信息";
- // if (items.name) {
- // $scope.consumptive.name = items.name.name;
- // }
- $scope.placechange = angular.copy(itemin);
- $scope.ok = function (item) {
- if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
- $modalInstance.close(item);
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- resolve: {
- SweetAlert: function () {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- angular.forEach($scope.myDatagrid, function (item, index) {
- // $scope.myDatagrid[index].props.hw_state = "在线";
- if (item.id == selectedItem.id) {
- // $scope.myDatagrid[index] = selectedItem;
- angular.extend($scope.myDatagrid[index], selectedItem)
- }
- })
- // $scope.myData3.push(selectedItem);
- for (var i = 0; i < $scope.myDatagrid.length; i++) {
- $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
- }
- $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
- })
- }
- //gridtwo
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions2 = {};
- $scope.gridOptions2.data = 'myDatagridold';
- $scope.gridOptions2.enableColumnResizing = true;
- $scope.gridOptions2.enableFiltering = true;
- $scope.gridOptions2.enableGridMenu = false;
- $scope.gridOptions2.enableRowSelection = true;
- $scope.gridOptions2.showGridFooter = true;
- $scope.gridOptions2.showColumnFooter = false;
- $scope.gridOptions2.fastWatch = true;
- $scope.gridOptions2.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions2.paginationPageSizes = [10];
- $scope.gridOptions2.paginationPageSize = 10;
- $scope.gridOptions2.multiSelect = false;
- $scope.myDatagridold = [];
- $scope.myDatagridoldall = [];
- $scope.selected = {
- item: {}
- };
- $scope.memoryfilterDatagridold = {
- idx: 0,
- sum: 10
- }
- if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
- filterData = {
- idx: 0,
- sum: 10
- };
- $scope.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
- }
- $scope.gridOptions2.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions2.getRowIdentity = function (row) {
- return row.id;
- };
- // $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- if ($scope.model.oldAssets) {
- $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
- $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
- }
- $scope.gridOptions2.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- $scope.memoryfilterDatagridold.idx = newPage - 1;
- $scope.memoryfilterDatagridold.sum = pageSize;
- $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
- // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
- });
- gridApi.core.on.filterChanged($scope, function () { });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- // $scope.loadData = function(mydate, idx, sum) {
- // angular.forEach($scope.myDatagridold, function(item, index) {
- // $scope.myDatagridold[index].item = index;
- // })
- // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
- // }
- // if ($scope.model.assets) {
- // $scope.myDatagridallold = $scope.model.assets;
- // $scope.loadData($scope.model.assets, 0, 10)
- // }
- // $scope.addoldassets = function(itemin) {
- // event.preventDefault();
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
- // controller: function($scope, $modalInstance, SweetAlert) {
- // // $scope.consumptive = {};
- // $scope.title = "填写领用设备信息";
- // // if (items.name) {
- // // $scope.consumptive.name = items.name.name;
- // // }
- // $scope.placechange = itemin;
- // $scope.ok = function(item) {
- // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
- // $modalInstance.close(item);
- // } else {
- // SweetAlert.swal({
- // title: "数据填写不完整!",
- // text: "请检查数据然后提交!",
- // type: "error"
- // });
- // }
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // resolve: {
- // SweetAlert: function() {
- // return SweetAlert;
- // }
- // }
- // });
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- $scope.addshebei = function () {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
- controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myDatatwo';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'uuid',
- displayName: '内部编号',
- width: 150
- },
- {
- name: 'props.hw_mingcheng',
- displayName: '资产名称',
- width: 100
- },
- {
- name: 'props.hw_cifilterClassic',
- displayName: '资产类型',
- width: 120,
- enableFiltering: false
- },
- // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
- {
- name: 'props.hw_state',
- displayName: '资产状态',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'props.hwnw_area',
- displayName: '资产地点',
- width: 130,
- enableFiltering: false
- },
- {
- name: 'createtime',
- displayName: '申请时间',
- enableFiltering: false
- }
- ];
- // $scope.selectButtonClick
- var defaultFilterData = {
- // "assignee":2,
- // "applicationForm": { "hw_state": "在线" },
- "hw_state": "在线",
- "idx": 0,
- "sum": 10
- };
- $scope.memoryfilterData = {
- // "assignee":2,
- // "applicationForm": { "hw_state": "在线" },
- "hw_state": "在线",
- "idx": 0,
- "sum": 10
- }
- $scope.refreshData = function (style, filterData) {
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myDatatwo = [];
- // $scope.gridOptions['sum']=filterData.sum;
- api_cmdb.query(filterData).then(function (data) {
- // $scope.callsPending--;
- var myDatatwo = Restangular.stripRestangular(data);
- $scope.gridOptions['totalItems'] = data.total;
- for (var i = 0; i < myDatatwo.data.node.length; i++) {
- myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
- }
- $scope.myDatatwo = myDatatwo.data.node;
- for (var i = 0; i < $scope.myDatatwo.length; i++) {
- $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- }, function () { });
- };
- $scope.refreshData('expand-right', defaultFilterData);
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- $scope.refreshData('expand-right', filtersData);
- //console.log(pageSize);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // $scope.selected.items.push(data.entity);
- //console.log(data);
- gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
- if (scope.isSelected) {
- scope.grid.appScope.selected.items.push(scope.entity)
- } else {
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
- scope.grid.appScope.selected.items.splice(i, 1);
- break;
- }
- }
- }
- $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
- });
- // });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
- // $scope.selected.items = data.entity;
- //console.log(data);
- var selectitem = [];
- selectitem = angular.copy($scope.selected.items);
- for (var j = 0; j < rows.length; j++) {
- if (rows[j].isSelected == true) {
- selectitem.push(rows[j].entity);
- } else {
- delete selectitem[j];
- // rows.splice(j, 1);
- }
- }
- $scope.selected.items = [];
- for (var i = 0; i < selectitem.length; i++) {
- if (selectitem[i]) {
- $scope.selected.items.push(selectitem[i]);
- }
- }
- });
- // gridApi.selection.on.selectAllRows = function(row) { //GridRow
- // // if (row.entity.age > 45) {
- // row.grid.api.selection.selectRow(row.entity); // 选中行
- // // }
- // };
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- // $scope.loadData(filtersData);
- });
- };
- $scope.onDblClick = function (data, event) {
- // $scope.selected.items = data.entity;
- $scope.selectButtonClick(data, event);
- };
- $scope.title = title;
- //树形图
- var apple_selected, tree, treedata_avm, treedata_geography;
- $scope.my_tree_handler = function (branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- api_cmdb.query({
- 'sign': classify
- }).then(function (data) {
- var myDatalingbei = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if (myDatalingbei.data && myDatalingbei.status == 200) {
- var ret = myDatalingbei.data;
- redrawSvg(myDatalingbei);
- }
- });
- };
- $scope.my_data = [];
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.my_tree = tree = {};
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.select_treedata = [];
- $scope.doing_async = true;
- api_configure_data.fetchDataList('ciclassify', {
- 'idx': 0,
- 'sum': 100
- }).then(function (result) {
- //console.log(result['list']);
- $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- $scope.doing_async = false;
- // tree.expand_all();
- //console.log(treelist);
- });
- };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.try_async_load();
- $scope.onFilterremove = function (item) {
- console.log(item)
- }
- $scope.searchdata = {};
- $scope.clear = function () {
- $scope.searchdata = {};
- $scope.cifilter_classic = {};
- $scope.try_async_load();
- var fildata = {
- idx: 0,
- sum: 10,
- 'hw_state': '在线'
- }
- $scope.memoryfilterData = fildata;
- $scope.refreshData('expand-right', fildata);
- }
- $scope.chiceIncident = function (item) {
- var fildata = $scope.memoryfilterData;
- // fildata.applicationForm = {};
- // if (item.alltitle && item.alldata) {
- // fildata.applicationForm[item.alltitle.key] = item.alldata
- // }
- if (item && item.id) {
- var classify = item.prefix.toLowerCase() + item.sign;
- fildata.sign = classify
- }
- $scope.gridOptions.paginationCurrentPage = 1;
- var transitiondata = angular.copy(item);
- $scope.refreshData('expand-right', fildata);
- }
- $scope.applicadata = [];
- $scope.onFilterCallback = function (item) {
- var tempclassify = item.prefix.toLowerCase() + item.sign;
- api_configure_form.renderTabForm(tempclassify).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.applicadata = myData[0].form.fields;
- });
- // }
- }
- // $scope.loadData({
- // idx: 0,
- // sum: 10,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- // });
- $scope.selected = {
- items: []
- };
- $scope.ok = function () {
- // if(onDataCallback&&angular.isFunction(onDataCallback)){
- // onDataCallback($scope.selected.item, parentScope);
- // }
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg',
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- };
- }
- return $scope.options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return $scope.options.templateOptions.label;
- },
- Restangular: function () {
- return $scope.options.templateOptions.Restangular;
- },
- APIService: function () {
- return $scope.options.templateOptions.ApiService;
- },
- onDataCallback: function () {
- return $scope.options.templateOptions.callback;
- },
- parentScope: function () {
- return $scope.options.templateOptions.that;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- $scope.myDatagridoldall = selectedItem;
- for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
- $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
- }
- $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
- $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
- // $scope.model.oldAssets = $scope.myDatagridoldall;
- $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
- $scope.options.initialValue = $scope.model.oldAssets;
- });
- // }
- }
- $scope.changestate = function (itemin) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- $scope.title = '旧设备状态修改';
- $scope.stateshe = [{
- "id": 2,
- "name": "在库"
- }, {
- "id": 4,
- "name": "报修"
- }, {
- "id": 3,
- "name": "报废"
- }];
- $scope.hw_state = {};
- $scope.ok = function (item) {
- $modalInstance.close(item.id);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- angular.forEach($scope.myDatagridallold, function (item, index) {
- if (item.id == itemin.id) {
- $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
- }
- })
- for (var i = 0; i < $scope.myDatagridallold.length; i++) {
- $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
- }
- $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
- $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
- // $scope.model.oldAssets = $scope.myDatagridallold;
- $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
- $scope.options.initialValue = $scope.model.oldAssets;
- }
- })
- }
- $scope.savedata = function (data) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- $scope.title = '设备编辑';
- // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
- $scope.ok = function (item) {
- $modalInstance.close(item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- angular.forEach($scope.myDatagridoldall, function (item, index) {
- if (item.id == data.id) {
- $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
- }
- })
- for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
- $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
- }
- $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
- $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
- // $scope.model.oldAssets = $scope.myDatagridoldall;
- $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
- $scope.options.initialValue = $scope.model.oldAssets;
- }
- })
- }
- $scope.removeold = function (data) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- $scope.title = '设备删除';
- $scope.connect = '删除的数据不可恢复,请确认继续操作!';
- $scope.ok = function () {
- $modalInstance.close(data);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- angular.forEach($scope.myDatagridoldall, function (item, index) {
- if (item.id == selectedItem.id) {
- $scope.myDatagridoldall.splice(index, 1);
- }
- })
- for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
- $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
- }
- $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
- $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
- // $scope.model.oldAssets = $scope.myDatagridoldall;
- $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
- $scope.options.initialValue = $scope.model.oldAssets;
- }
- })
- }
- }]
- });
- //ui-grid list
- formlyConfigProvider.setType({
- name: "ui-gridlist",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
- //gridone
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myDatagrid';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = false;
- // $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.myDatagrid = [];
- $scope.myDatagridall = [];
- $scope.selected = {
- item: {}
- };
- $scope.memoryfilterDatagrid = {
- idx: 0,
- sum: 10
- }
- if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
- filterData = {
- idx: 0,
- sum: 10
- };
- $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
- }
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- // $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- $scope.memoryfilterDatagrid.idx = newPage - 1;
- $scope.memoryfilterDatagrid.sum = pageSize;
- $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
- $scope.loadData({
- "idx": newPage - 1,
- "sum": pageSize
- });
- });
- gridApi.core.on.filterChanged($scope, function () { });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- $scope.loadData = function (mydate, idx, sum) {
- angular.forEach($scope.myDatagrid, function (item, index) {
- $scope.myDatagrid[index].item = index;
- })
- $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
- }
- if ($scope.model.assets) {
- $scope.myDatagridall = $scope.model.assets;
- $scope.loadData($scope.model.assets, 0, 10)
- }
- $scope.saveData = function (itemin) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
- controller: function ($scope, $modalInstance, SweetAlert) {
- // $scope.consumptive = {};
- $scope.title = "填写领用设备信息";
- // if (items.name) {
- // $scope.consumptive.name = items.name.name;
- // }
- $scope.placechange = angular.copy(itemin);
- $scope.ok = function (item) {
- if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
- $modalInstance.close(item);
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- resolve: {
- SweetAlert: function () {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- angular.forEach($scope.myDatagrid, function (item, index) {
- if (item.id == selectedItem.id) {
- angular.extend($scope.myDatagrid[index], selectedItem)
- }
- })
- // $scope.myData3.push(selectedItem);
- for (var i = 0; i < $scope.myDatagrid.length; i++) {
- $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
- }
- // $scope.model.assets = $scope.myDatagridall;
- $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
- })
- }
- }]
- });
- //设备耗材list组件
- formlyConfigProvider.setType({
- name: 'ui-shehaolist',
- // extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
- // var data = { "haodata": [], "shedata": [] };
- var haodata = [];
- var shedata = [];
- if ($scope.model.consumables) {
- if (angular.isArray($scope.model.consumables)) {
- haodata = $scope.model.consumables;
- } else {
- haodata = JSON.parse($scope.model.consumables);
- }
- $scope.model.consumables = haodata;
- angular.forEach(haodata, function (item, index) {
- haodata[index].item = index + 1;
- })
- }
- if ($scope.model.assets) {
- if (angular.isArray($scope.model.assets)) {
- shedata = $scope.model.assets;
- } else {
- shedata = JSON.parse($scope.model.assets);
- }
- $scope.model.assets = shedata;
- angular.forEach(shedata, function (item, index) {
- shedata[index].item = index + 1;
- })
- }
- $scope.tableParamshao = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: haodata.length,
- getData: function ($defer, params) {
- var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- $scope.tableParamsshe = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: shedata.length,
- getData: function ($defer, params) {
- var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- $scope.editId = -1;
- $scope.setEditId = function (pid) {
- $scope.editId = pid;
- };
- if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
- $scope.isAgree = "同意";
- } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
- $scope.isAgree = "同意";
- } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
- $scope.isAgree = "返回修改";
- }
- }]
- });
- //关联资产出库
- formlyConfigProvider.setType({
- name: "ui-meansmodelselect",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', '$modal', function ($scope, $modal) {
- $scope.openModal = function (size, options, modal) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
- controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService, api_wechatfile) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- // $scope.states = [{
- // id: 0,
- // name: '待批准'
- // },
- // {
- // id: 1,
- // name: '已驳回'
- // },
- // {
- // id: 2,
- // name: '待出库'
- // },
- // {
- // id: 3,
- // name: '信息更新'
- // },
- // {
- // id: 4,
- // name: '信息确认'
- // },
- // {
- // id: 5,
- // name: '已关闭'
- // }
- // ];
- $scope.getStatesDictionary = function () {
- var data = {
- "key": "applicationForm_status",
- "type": "list"
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- $scope.states = res
- })
- };
- $scope.getStatesDictionary();
- $scope.type = [{
- id: 1,
- name: '资产入库'
- },
- {
- id: 2,
- name: '资产归还'
- },
- {
- id: 3,
- name: '资产领用'
- },
- {
- id: 4,
- name: '资产更换'
- }
- ];
- $scope.typedata = function (row) {
- if (row.type == 0) {
- return "资产入库";
- } else if (row.type == 2) {
- return "资产归还";
- } else if (row.type == 1) {
- return "资产领用";
- } else if (row.type == 4) {
- return "资产更换";
- }
- };
- $scope.statedata = function (row) {
- if (row.status == 0) {
- return "待批准";
- } else if (row.status == 1) {
- return "已驳回";
- } else if (row.status == 2) {
- return "待出库";
- } else if (row.status == 3) {
- return "信息更新";
- } else if (row.status == 4) {
- return "信息确认";
- } else if (row.status == 5) {
- return "已关闭";
- }
- };
- $scope.transferTime = function (time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $scope.application = [{
- value: "serialNumbe",
- name: '申请单编号'
- },
- // { value: "proposer", name: '申请人' },
- {
- value: "purpose",
- name: '领用用途'
- },
- // { value: "cmdbsign", name: '设备编号' }
- ];
- $scope.parameters = null;
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.othcode = {};
- $scope.searchkeys = {};
- $scope.parameters = {};
- $scope.memoryfilterData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchType": "todo",
- idx: 0,
- sum: 10
- }
- $scope.clear = function () {
- $scope.searchkeys = {};
- // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
- // $scope.othcode = {};
- $scope.parameters = {};
- var fildata = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchType": "todo",
- idx: 0,
- sum: 10
- }
- // sessionStorage.removeItem("searchincident");
- $scope.memoryfilterData = fildata;
- $scope.loadData(fildata);
- }
- $scope.chiceIncident = function (parameters, item, stateid) {
- var fildata = {
- "assignee": $rootScope.user.id,
- "candidateGroups": 1,
- "searchType": "todo",
- "idx": 0,
- "sum": 10
- };
- if (item) {
- fildata.applicationForm = {};
- if (item.alltitle && item.alldata) {
- fildata.applicationForm[item.alltitle.value] = item.alldata
- }
- if (item.linkProposer) {
- fildata.applicationForm.linkProposer = item.linkProposer
- }
- if (item.proposer) {
- fildata.applicationForm.proposer = item.proposer
- }
- if (item.status) {
- fildata.applicationForm['status'] = {
- id: item.status.id
- };
- }
- if (item.type) {
- fildata.applicationForm['type'] = {
- id: item.type.id
- };
- }
- }
- $scope.gridOptions.paginationCurrentPage = 1;
- if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
- angular.extend(fildata, {
- 'idx': 0,
- 'sum': $scope.gridOptions.paginationPageSize
- })
- angular.extend(fildata.applicationForm, {
- 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'),
- 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59')
- })
- }
- var transitiondata = angular.copy(item);
- // angular.extend(fildata.applicationForm, transitiondata)
- $scope.loadData(fildata);
- }
- $scope.key = {};
- api_user_data.fetchDataList('user', {
- "idx": 0,
- "sum": 1000,
- "flag": -1
- }).then(function (data) {
- $scope.handlingPersonnelUser = data.list;
- });
- $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // console.log(newPage);
- // console.log(pageSize);
- $scope.loadData({
- "idx": newPage - 1,
- "sum": pageSize
- });
- });
- gridApi.core.on.filterChanged($scope, function () {
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- $scope.loadData = function (filterData) {
- items.fetchItems(filterData, APIService).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
- }
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10,
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchType": "todo",
- });
- $scope.selected = {
- item: {}
- };
- $scope.ok = function () {
- //console.log($scope.selected.item);
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg',
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- // if(!filterData.idx){
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService, options);
- },
- columnDefs: function () {
- return options.templateOptions.columnDefs;
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- var selectitem = {
- title: selectedItem.title,
- description: selectedItem.description
- }
- if (options.key == "chuku") {
- if (selectedItem.assets) {
- $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
- }
- if (selectedItem.consumables) {
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
- }
- angular.extend($scope.$parent.$parent.$parent.model, selectitem);
- options.value(selectedItem);
- // options.model.consumables = JSON.parse(selectedItem.consumables);
- } else {
- angular.extend(options.model, selectitem);
- options.value(selectedItem);
- }
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }]
- });
- //文本框
- formlyConfigProvider.setType({
- name: 'ui-textcmdb',
- extends: '',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', function ($scope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- if (angular.isFunction($scope.options.templateOptions.felditem)) {
- $scope.options.templateOptions.felditem($scope);
- }
- }]
- });
- //设备组件
- formlyConfigProvider.setType({
- name: 'ui-applist',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
- var data = [];
- if ($scope.model.consumables && $scope.options.key == "consumables") {
- // data = JSON.parse($scope.model.consumables);
- if (angular.isArray($scope.model.consumables)) {
- data = $scope.model.consumables;
- } else {
- data = JSON.parse($scope.model.consumables);
- }
- $scope.model.consumables = data;
- angular.forEach(data, function (item, index) {
- data[index].item = index + 1;
- })
- }
- if ($scope.model.assets && $scope.options.key == "assets") {
- if (angular.isArray($scope.model.assets)) {
- data = $scope.model.assets;
- } else {
- data = JSON.parse($scope.model.assets);
- }
- // data = JSON.parse($scope.model.assets);
- $scope.model.assets = data;
- angular.forEach(data, function (item, index) {
- data[index].item = index + 1;
- })
- }
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: data.length,
- getData: function ($defer, params) {
- var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- $scope.editId = -1;
- $scope.setEditId = function (pid) {
- $scope.editId = pid;
- };
- }]
- });
- //list组件
- formlyConfigProvider.setType({
- name: 'ui-gudinglist',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
- var data = [];
- if ($scope.model.consumables && $scope.options.key == "consumables") {
- // data = JSON.parse($scope.model.consumables);
- if (angular.isArray($scope.model.consumables)) {
- data = $scope.model.consumables;
- } else {
- data = JSON.parse($scope.model.consumables);
- }
- $scope.model.consumables = data;
- angular.forEach(data, function (item, index) {
- data[index].item = index + 1;
- })
- }
- if ($scope.model.assets && $scope.options.key == "assets") {
- if (angular.isArray($scope.model.assets)) {
- data = $scope.model.assets;
- } else {
- data = JSON.parse($scope.model.assets);
- }
- // data = JSON.parse($scope.model.assets);
- $scope.model.assets = data;
- angular.forEach(data, function (item, index) {
- data[index].item = index + 1;
- })
- }
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: data.length,
- getData: function ($defer, params) {
- var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- $scope.editId = -1;
- $scope.setEditId = function (pid) {
- $scope.editId = pid;
- };
- }]
- });
- //other list tab组件
- formlyConfigProvider.setType({
- name: 'ui-otherlisttab',
- extends: '',
- templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
- }]
- });
- //审核查看组件
- formlyConfigProvider.setType({
- name: 'ui-aprovelist',
- extends: '',
- templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
- if ($scope.model.isAgree && $scope.model.isAgree == "2") {
- $scope.isAgree = "同意";
- } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
- $scope.isAgree = "同意";
- } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
- $scope.isAgree = "返回修改";
- }
- }]
- });
- //other list组件
- formlyConfigProvider.setType({
- name: 'ui-otherlist',
- extends: '',
- templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
- console.log("哈哈");
- console.log($scope);
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var vm = this;
- vm.options = {};
- vm.exampleTitle = ['expressionProperties', 'model property'];
- vm.fields = [];
- vm.models = {};
- // vm.models["loginUser"] = $rootScope.user;
- var that = $injector;
- var parse = $parse;
- var formKey = "";
- var pdKey = "";
- if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
- pdKey = $state.current.pdKey;
- //console.log("pdKey::"+$state.current.pdKey);
- }
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- formKey = $stateParams.formKey;
- //console.log("formKey::"+$stateParams.formKey);
- }
- //用户测试数据,后续从header的auth中获取
- var userId = 2;
- userId = $rootScope.user.id;
- //==============处理表单设计数据 开始====================
- //处理组件加载后台数据选项的方法
- function refreshSelectOptions(searchVal, field) {
- if (field.templateOptions.optionsUrl) {
- var process = BpmRestangular.all("");
- if (field.templateOptions.ApiService) {
- process = UserRestangular.all("");
- }
- process.customPOST({
- "idx": 0,
- "sum": 1000
- }, field.templateOptions.optionsUrl).then(function (result) {
- if (!field.templateOptions.options) {
- field.templateOptions.options = [];
- }
- if (field.templateOptions.optionsDataKey) {
- field.templateOptions.options = result[field.templateOptions.optionsDataKey];
- } else {
- field.templateOptions.options = result;
- }
- });
- }
- }
- function decodeVMTabForm(model, tabs) {
- var result = {
- model: {},
- tabs: []
- };
- var mdata = angular.fromJson(model);
- angular.extend(result.model, mdata);
- angular.forEach(tabs, function (tab) {
- tab.form.model = vm.models;
- angular.forEach(tab.form.fields, function (field) {
- if (field.key == "") {
- delete field.key;
- }
- field.type = "ui-otherlisttab";
- if (angular.isDefined(field.extjson) && field.extjson != "") {
- var extObj = angular.fromJson(field.extjson);
- angular.extend(field.templateOptions, extObj.templateOptions);
- delete extObj.templateOptions;
- for (var prop in extObj) {
- if (new RegExp("Expression").test(prop)) {
- //var obj = $scope.$eval(extObj[prop]);
- //extObj[prop] = $scope.$eval(extObj[prop]);
- if (extObj[prop] != null) {
- if (new RegExp("function").test(extObj[prop])) {
- var propValue = eval(extObj[prop]);
- extObj[prop] = propValue;
- } else {
- //console.log(extObj[prop]);
- var obj = $scope.$eval(extObj[prop]);
- extObj[prop] = obj;
- //console.log(obj);
- }
- }
- } else if (new RegExp("expressionProperties").test(prop)) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- } else {
- //if(p.indexOf("'")>=0){
- // var obj = $scope.$eval(extObj[prop][p]);
- // extObj[prop][$scope.$eval(p)]=obj;
- //}
- }
- }
- } else if ("watcher" == prop) {
- if (angular.isArray(extObj[prop])) {
- angular.forEach(extObj[prop], function (item, index) {
- for (var p in item) {
- if (new RegExp("function").test(item[p])) {
- var propValue = eval(item[p]);
- extObj[prop][index][p] = propValue;
- }
- }
- });
- } else if (angular.isObject(extObj[prop])) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- }
- }
- }
- }
- }
- angular.extend(field, extObj);
- delete field.extjson;
- }
- if (field.extjson == "") {
- delete field.extjson;
- }
- if (angular.isDefined(field.templateOptions)) {
- var templateOs = field.templateOptions;
- for (var property in templateOs) {
- //console.log(property);
- if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
- if (new RegExp("function").test(templateOs[property])) {
- var propValue = eval(templateOs[property]);
- field.templateOptions[property] = propValue;
- } else {
- if (that.has(templateOs[property])) {
- field.templateOptions[property] = that.get(templateOs[property]);
- } else {
- field.templateOptions[property] = templateOs[property];
- }
- }
- } else if (templateOs[property] == null) {
- //delete field.templateOptions[property];
- } else { }
- }
- }
- if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
- var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj);
- delete field.templateOptions.extjson;
- }
- //...
- if (field.templateOptions) {
- //处理远程获取数据控件方法调用
- if (field.templateOptions.optionsUrl) {
- field.templateOptions.refresh = refreshSelectOptions;
- }
- //处理嵌套属性数据绑定/
- if (field.templateOptions.pkey) {
- var pmodel, i = 0;
- angular.forEach(field.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (result.model[p] == null) {
- result.model[p] = {};
- }
- pmodel = result.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- if (pmodel != null) {
- field.model = pmodel;
- if (pmodel[field.key] == null) {
- pmodel[field.key] = null;
- }
- }
- } else {
- if (result.model[field.key] == null) {
- result.model[field.key] = null;
- }
- }
- //处理弹出框组件初始化
- if (field.type == "ui-input-selectmodal") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-userselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-multiuserselect") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-modelselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-cmdbuplode") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader',
- queueLimit: 1, //文件个数
- autoUpload: true
- });
- // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
- } else if (field.type == "ui-dropfile") {
- field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-dropfiletable") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-repeatSection") {
- var repeatForm = {
- model: {
- },
- fields: field.templateOptions.fields
- };
- repeatForm.model[field.key] = [];
- decodeVMTabForm(repeatForm);
- }
- }
- // console.log(field);
- //field
- //result.fields.push(field);
- })
- });
- vm.originalTabs = angular.copy(vm.form);
- }
- //======================处理表单设计数据 结束========================
- $scope.ldloading = {};
- function filter(obj) {
- angular.forEach(obj, function (key, value) {
- if (value === "" || value === null) {
- delete obj[key];
- } else if (Object.prototype.toString.call(value) === '[object Object]') {
- filter(value);
- } else if (angular.isArray(value)) {
- angular.forEach(value, function (item) {
- filter(item);
- });
- }
- });
- }
- function invokeOnAllFormOptions(fn) {
- angular.forEach(vm.tabs, function (tab) {
- if (tab.form.options && tab.form.options[fn]) {
- tab.form.options[fn]();
- }
- });
- }
- function encodeCIData(data, ciId) {
- /*
- create/update state:未审核
- create createtime:系统时间
- create/update lastupdatetime : 系统时间
- label:ci分类
- */
- if (ciId) {
- var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
- var extraprop = 'props';
- data[extraprop] = {};
- for (var key in data) {
- console.log(data[key]);
- if (_.indexOf(baseprop, key) >= 0) {
- continue;
- } else {
- data[extraprop][key] = data[key];
- delete data[key];
- }
- }
- if ($rootScope.user) {
- data[extraprop]['lastupdateperson'] = $rootScope.user.name;
- data[extraprop]['configperson'] = $rootScope.user.name;
- var isCMAdminFlag = false;
- angular.forEach($rootScope.user.role, function (roleItem) {
- if (roleItem.rolecode == "cmdb charge") {
- isCMAdminFlag = true;
- }
- })
- if (!isCMAdminFlag) {
- data[extraprop]['state'] = '1';
- }
- }
- if (data.props.id) {
- } else {
- data.label = ciId;
- }
- return data;
- }
- return undefined;
- }
- function decodeCIModel(data) {
- var extraprop = 'props';
- if (data[extraprop]) {
- for (var key in data[extraprop]) {
- data[key] = data[extraprop][key];
- }
- delete data[extraprop];
- }
- data['iscmadmin'] = false;
- angular.forEach($rootScope.user.role, function (roleItem) {
- if (roleItem.rolecode == "cmdb charge") {
- data['iscmadmin'] = true;
- }
- })
- return data;
- }
- function formValid() {
- angular.forEach(vm.tabs, function (item) {
- //item.
- })
- }
- $scope.vm = vm;
- $scope.refreshcmdbform = function (item) {
- var tempclassify = item.prefix.toLowerCase() + item.sign;
- api_configure_form.renderTabForm(tempclassify).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.propTypeOptions = myData;
- $scope.templateProps = myData;
- $scope.vm.tabs = myData;
- if ($scope.model.assets) {
- vm.models = JSON.parse($scope.model.assets);
- }
- if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
- if (vm.models.vtvmvtm_kaiji) {
- vm.models.vtvmvtm_kaiji = "是";
- } else {
- vm.models.vtvmvtm_kaiji = "否";
- }
- }
- decodeVMTabForm(vm.models, vm.tabs);
- });
- // }
- }
- var cifilterClassic = {};
- // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
- // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
- $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
- // } else {}
- }]
- });
- //固定资产下载
- formlyConfigProvider.setType({
- name: 'ui-dropupload',
- templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- view: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId);
- },
- },
- };
- },
- controller: ['$scope', '$rootScope', 'Restangular', function ($scope, $rootScope, Restangular) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- var to = $scope.options.templateOptions;
- var bindId = $scope.model[to.bindType].processInstanceId;
- //获取附件列表
- $scope.listAttachmen = function () {
- to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
- var myData = Restangular.stripRestangular(result);
- // $scope.listAttachmens = myData;
- $scope.attachments = myData.data;
- });
- };
- $scope.listAttachmen();
- // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
- // $scope.listAttachmen();
- // } else if (to.bindType && $scope.model[to.bindType].id) {
- // $scope.listAttachmen();
- // }
- //附件下载
- $scope.download = function (token, filename) {
- var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- //附件预览
- $scope.view = function (id, previewUrl) {
- if (previewUrl) {
- window.open(previewUrl);
- }
- };
- }]
- });
- formlyConfigProvider.setType({
- name: 'ui-form',
- templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // link: function() {}
- }
- };
- },
- controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var vm = this;
- vm.options = {};
- vm.exampleTitle = ['expressionProperties', 'model property'];
- vm.fields = [];
- vm.models = {};
- // vm.models["loginUser"] = $rootScope.user;
- var that = $injector;
- var parse = $parse;
- var formKey = "";
- var pdKey = "";
- if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
- pdKey = $state.current.pdKey;
- //console.log("pdKey::"+$state.current.pdKey);
- }
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- formKey = $stateParams.formKey;
- //console.log("formKey::"+$stateParams.formKey);
- }
- //用户测试数据,后续从header的auth中获取
- var userId = 2;
- userId = $rootScope.user.id;
- //==============处理表单设计数据 开始====================
- //处理组件加载后台数据选项的方法
- function refreshSelectOptions(searchVal, field) {
- if (field.templateOptions.optionsUrl) {
- var process = BpmRestangular.all("");
- if (field.templateOptions.ApiService) {
- process = UserRestangular.all("");
- }
- process.customPOST({
- "idx": 0,
- "sum": 1000
- }, field.templateOptions.optionsUrl).then(function (result) {
- if (!field.templateOptions.options) {
- field.templateOptions.options = [];
- }
- if (field.templateOptions.optionsDataKey) {
- field.templateOptions.options = result[field.templateOptions.optionsDataKey];
- } else {
- field.templateOptions.options = result;
- }
- });
- }
- }
- function decodeVMTabForm(model, tabs) {
- var result = {
- model: {},
- tabs: []
- };
- var mdata = angular.fromJson(model);
- angular.extend(result.model, mdata);
- angular.forEach(tabs, function (tab) {
- tab.form.model = vm.models;
- angular.forEach(tab.form.fields, function (field) {
- if (field.key == "") {
- delete field.key;
- }
- if (angular.isDefined(field.extjson) && field.extjson != "") {
- var extObj = angular.fromJson(field.extjson);
- angular.extend(field.templateOptions, extObj.templateOptions);
- delete extObj.templateOptions;
- for (var prop in extObj) {
- if (new RegExp("Expression").test(prop)) {
- //var obj = $scope.$eval(extObj[prop]);
- //extObj[prop] = $scope.$eval(extObj[prop]);
- if (extObj[prop] != null) {
- if (new RegExp("function").test(extObj[prop])) {
- var propValue = eval(extObj[prop]);
- extObj[prop] = propValue;
- } else {
- //console.log(extObj[prop]);
- var obj = $scope.$eval(extObj[prop]);
- extObj[prop] = obj;
- //console.log(obj);
- }
- }
- } else if (new RegExp("expressionProperties").test(prop)) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- } else {
- //if(p.indexOf("'")>=0){
- // var obj = $scope.$eval(extObj[prop][p]);
- // extObj[prop][$scope.$eval(p)]=obj;
- //}
- }
- }
- } else if ("watcher" == prop) {
- if (angular.isArray(extObj[prop])) {
- angular.forEach(extObj[prop], function (item, index) {
- for (var p in item) {
- if (new RegExp("function").test(item[p])) {
- var propValue = eval(item[p]);
- extObj[prop][index][p] = propValue;
- }
- }
- });
- } else if (angular.isObject(extObj[prop])) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- }
- }
- }
- }
- }
- angular.extend(field, extObj);
- delete field.extjson;
- }
- if (field.extjson == "") {
- delete field.extjson;
- }
- if (angular.isDefined(field.templateOptions)) {
- var templateOs = field.templateOptions;
- for (var property in templateOs) {
- //console.log(property);
- if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
- if (new RegExp("function").test(templateOs[property])) {
- var propValue = eval(templateOs[property]);
- field.templateOptions[property] = propValue;
- } else {
- if (that.has(templateOs[property])) {
- field.templateOptions[property] = that.get(templateOs[property]);
- } else {
- field.templateOptions[property] = templateOs[property];
- }
- }
- } else if (templateOs[property] == null) {
- //delete field.templateOptions[property];
- } else { }
- }
- }
- if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
- var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj);
- delete field.templateOptions.extjson;
- }
- //...
- if (field.templateOptions) {
- //处理远程获取数据控件方法调用
- if (field.templateOptions.optionsUrl) {
- field.templateOptions.refresh = refreshSelectOptions;
- }
- //处理嵌套属性数据绑定/
- if (field.templateOptions.pkey) {
- var pmodel, i = 0;
- angular.forEach(field.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (result.model[p] == null) {
- result.model[p] = {};
- }
- pmodel = result.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- if (pmodel != null) {
- field.model = pmodel;
- if (pmodel[field.key] == null) {
- pmodel[field.key] = null;
- }
- }
- } else {
- if (result.model[field.key] == null) {
- result.model[field.key] = null;
- }
- }
- //处理弹出框组件初始化
- if (field.type == "ui-input-selectmodal") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-userselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-multiuserselect") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-modelselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-dropfile") {
- field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- // }else if (field.type == "ui-uploadFile") {
- // field.templateOptions.fileUploader = new FileUploader({
- // url: '/uploader'
- // });
- // field.templateOptions.taskId = $stateParams.taskId;
- // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- // field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-dropfiletable") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-dropFiles") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-showImgs") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-repeatSection") {
- var repeatForm = {
- model: {
- },
- fields: field.templateOptions.fields
- };
- repeatForm.model[field.key] = [];
- decodeVMTabForm(repeatForm);
- }
- }
- // console.log(field);
- //field
- //result.fields.push(field);
- })
- });
- vm.originalTabs = angular.copy(vm.form);
- }
- //解析自定义表单设计数据
- function decodeVMForm(vmForm) {
- var result = {
- model: {},
- tabs: []
- };
- //设置模型实体数据 begin
- // var mdata = vmForm.model;
- //解析数据实体
- var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
- angular.extend(result.model, mdata);
- //设置模型实体数据 end
- //解析设计数据生成表单项 begin
- var fields = [];
- //处理修改设计数据中展示设置
- angular.forEach(vmForm.tabs, function (field) {
- if (field.key == "") {
- delete field.key;
- }
- if (angular.isDefined(field.extjson)) {
- var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj.templateOptions);
- delete extObj.templateOptions;
- for (var prop in extObj) {
- if (new RegExp("Expression").test(prop)) {
- //var obj = $scope.$eval(extObj[prop]);
- //extObj[prop] = $scope.$eval(extObj[prop]);
- if (extObj[prop] != null) {
- if (new RegExp("function").test(extObj[prop])) {
- var propValue = eval(extObj[prop]);
- extObj[prop] = propValue;
- } else {
- //console.log(extObj[prop]);
- var obj = $scope.$eval(extObj[prop]);
- extObj[prop] = obj;
- //console.log(obj);
- }
- }
- } else if (new RegExp("expressionProperties").test(prop)) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- } else {
- //if(p.indexOf("'")>=0){
- // var obj = $scope.$eval(extObj[prop][p]);
- // extObj[prop][$scope.$eval(p)]=obj;
- //}
- }
- }
- } else if ("watcher" == prop) {
- if (angular.isArray(extObj[prop])) {
- angular.forEach(extObj[prop], function (item, index) {
- for (var p in item) {
- if (new RegExp("function").test(item[p])) {
- var propValue = eval(item[p]);
- extObj[prop][index][p] = propValue;
- }
- }
- });
- } else if (angular.isObject(extObj[prop])) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- }
- }
- }
- }
- }
- angular.extend(field, extObj);
- delete field.extjson;
- }
- if (angular.isDefined(field.templateOptions)) {
- var templateOs = field.templateOptions;
- for (var property in templateOs) {
- //console.log(property);
- if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
- if (new RegExp("function").test(templateOs[property])) {
- var propValue = eval(templateOs[property]);
- field.templateOptions[property] = propValue;
- } else {
- if (that.has(templateOs[property])) {
- field.templateOptions[property] = that.get(templateOs[property]);
- } else {
- field.templateOptions[property] = templateOs[property];
- }
- }
- } else if (templateOs[property] == null) {
- //delete field.templateOptions[property];
- } else { }
- }
- }
- if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
- var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj);
- delete field.templateOptions.extjson;
- }
- //...
- if (field.templateOptions) {
- //处理远程获取数据控件方法调用
- if (field.templateOptions.optionsUrl) {
- field.templateOptions.refresh = refreshSelectOptions;
- }
- //处理嵌套属性数据绑定/
- if (field.templateOptions.pkey) {
- var pmodel, i = 0;
- angular.forEach(field.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (result.model[p] == null) {
- result.model[p] = {};
- }
- pmodel = result.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- if (pmodel != null) {
- field.model = pmodel;
- if (pmodel[field.key] == null) {
- pmodel[field.key] = null;
- }
- }
- } else {
- if (result.model[field.key] == null) {
- result.model[field.key] = null;
- }
- }
- //处理弹出框组件初始化
- if (field.type == "ui-input-selectmodal") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-userselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-multiuserselect") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-modelselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-dropfile") {
- field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-dropfiletable") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-dropFiles") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-showImgs") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-repeatSection") {
- var repeatForm = {
- model: {
- },
- fields: field.templateOptions.fields
- };
- repeatForm.model[field.key] = [];
- decodeVMForm(repeatForm);
- }
- }
- // console.log(field);
- result.fields.push(field);
- });
- angular.extend($scope.vm.fields, result.fields);
- angular.extend($scope.vm.models, result.model);
- $scope.formData = vmForm;
- //console.log($scope.vm);
- //解析设计数据生成表单项 end
- return result;
- }
- //======================处理表单设计数据 结束========================
- $scope.ldloading = {};
- function filter(obj) {
- angular.forEach(obj, function (key, value) {
- if (value === "" || value === null) {
- delete obj[key];
- } else if (Object.prototype.toString.call(value) === '[object Object]') {
- filter(value);
- } else if (angular.isArray(value)) {
- angular.forEach(value, function (item) {
- filter(item);
- });
- }
- });
- }
- function invokeOnAllFormOptions(fn) {
- angular.forEach(vm.tabs, function (tab) {
- if (tab.form.options && tab.form.options[fn]) {
- tab.form.options[fn]();
- }
- });
- }
- function encodeCIData(data, ciId) {
- /*
- create/update state:未审核
- create createtime:系统时间
- create/update lastupdatetime : 系统时间
- label:ci分类
- */
- if (ciId) {
- var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
- var extraprop = 'props';
- data[extraprop] = {};
- for (var key in data) {
- console.log(data[key]);
- if (_.indexOf(baseprop, key) >= 0) {
- continue;
- } else {
- data[extraprop][key] = data[key];
- delete data[key];
- }
- }
- if ($rootScope.user) {
- data[extraprop]['lastupdateperson'] = $rootScope.user.name;
- data[extraprop]['configperson'] = $rootScope.user.name;
- var isCMAdminFlag = false;
- angular.forEach($rootScope.user.role, function (roleItem) {
- if (roleItem.rolecode == "cmdb charge") {
- isCMAdminFlag = true;
- }
- })
- if (!isCMAdminFlag) {
- data[extraprop]['state'] = '1';
- }
- }
- if (data.props.id) {
- } else {
- data.label = ciId;
- }
- return data;
- }
- return undefined;
- }
- function decodeCIModel(data) {
- var extraprop = 'props';
- if (data[extraprop]) {
- for (var key in data[extraprop]) {
- data[key] = data[extraprop][key];
- }
- delete data[extraprop];
- }
- data['iscmadmin'] = false;
- angular.forEach($rootScope.user.role, function (roleItem) {
- if (roleItem.rolecode == "cmdb charge") {
- data['iscmadmin'] = true;
- }
- })
- return data;
- }
- vm.remove = function (data, style) {
- $scope.ldloading[style.replace('-', '_')] = true;
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- var cidata = {
- label: data.label,
- id: data.id,
- uuid: data.uuid,
- name: data.name,
- props: {}
- };
- if (cidata.id) {
- cidata.props['removeflag'] = true;
- cidata.props['lastupdateperson'] = vm.models.loginUser;
- $scope.ok = function () {
- $modalInstance.close(cidata);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- }
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- // if (selectedItem.length > 0) {
- api_cmdb.put(selectedItem, selectedItem.id).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- SweetAlert.swal({
- title: "删除成功!",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go("app.means.list");
- // $scope.refreshform();
- // reinitTabForm($scope.classify);
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- }
- })
- }
- function formValid() {
- angular.forEach(vm.tabs, function (item) {
- //item.
- })
- }
- $scope.closeModel = function () {
- console.log($stateParams);
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
- $state.go('app.means.list', {});
- }
- event.preventDefault();
- }
- }
- // setInterval(function() {
- // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
- // cifilter_classic = $scope.model.cifilter_classic;
- // $scope.refreshcmdbform(cifilter_classic);
- // } else {}
- // }, 100);
- vm.models = (function filter(obj) {
- var filtered = _.pick(obj, function (v) {
- return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
- });
- return _.cloneDeep(filtered, function (v) {
- return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
- });
- })(vm.models);
- // setInterval(function() {
- // if ($scope.model.type == 0) {
- // $scope.model[$scope.options.key] = vm.models;
- // }
- // }, 100);
- setInterval(function () {
- if (vm.form && vm.form.$$parentForm.$valid) {
- if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
- vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
- $scope.model[$scope.options.key] = vm.models;
- }
- // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
- // $scope.model[$scope.options.key] = vm.models;
- }
- }, 100);
- vm.submit = function (data, ciId, templateitem, style) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- console.log(vm.form.$$parentForm.$valid);
- if (vm.form.$$parentForm.$valid) {
- invokeOnAllFormOptions('updateInitialValue');
- //alert(JSON.stringify(vm.model), null, 2);
- //vm.options.updateInitialValue();
- //console.log(vm.model);
- var cidata = encodeCIData(vm.models, ciId);
- if (cidata) {
- //var cidata = ;
- if (cidata.props.id) {
- //修改
- api_cmdb.put(cidata, ciId).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- SweetAlert.swal({
- title: "保存成功!",
- confirmButtonColor: "#007AFF"
- }, function () {
- $scope.ldloading[style.replace('-', '_')] = false;
- // $scope.refreshform();
- $state.go("app.means.list");
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- } else {
- //新建
- var type = 2;
- api_sysinfo.getSerialnumber(type, templateitem.id).then(function (data) {
- if (data && data.status == 200) {
- cidata.uuid = data.uuid;
- api_cmdb.create(cidata).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- SweetAlert.swal({
- title: "保存成功!",
- text: "内部编号:" + cidata.uuid,
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go("app.means.list");
- });
- // if(resData.status){
- // resData
- // }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "内部编号生成出错!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- })
- }
- } else {
- SweetAlert.swal({
- title: "错误",
- text: "错误,请选择资产分类!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- //alert(JSON.stringify(cidata), null, 2);
- $scope.ldloading[style.replace('-', '_')] = true;
- return;
- var _ = window._;
- vm.models = (function filter(obj) {
- var filtered = _.pick(obj, function (v) {
- return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
- });
- return _.cloneDeep(filtered, function (v) {
- return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
- });
- })(vm.models);
- } else {
- if (vm.form.$$parentForm.$error) {
- SweetAlert.swal({
- title: "校验错误",
- text: "请填写必填项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- angular.forEach(vm.form.$$parentForm.$error.required, function (item) {
- angular.forEach(vm.tabs, function (tab) {
- angular.forEach(tab.form.fields, function (f) {
- if (f.name == item.$name) {
- f.validation.show = true;
- tab.active = true;
- }
- })
- })
- });
- $scope.ldloading[style.replace('-', '_')] = false;
- }
- }
- };
- $scope.vm = vm;
- $scope.refreshcmdbform = function (item) {
- // if ($stateParams.model) {
- // var modeldata = JSON.parse($stateParams.model)
- var tempclassify = item.prefix.toLowerCase() + item.sign;
- api_configure_form.renderTabForm(tempclassify).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.propTypeOptions = myData;
- $scope.templateProps = myData;
- $scope.vm.tabs = myData;
- if ($scope.model.asset && $scope.model.asset.length != "") {
- vm.models = JSON.parse($scope.model.asset);
- }
- decodeVMTabForm(vm.models, vm.tabs);
- });
- // }
- }
- var cifilterClassic = {};
- setInterval(function () {
- if ($scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
- // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
- cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
- $scope.refreshcmdbform(cifilterClassic);
- } else { }
- }, 100);
- }]
- });
- //请求人信息
- formlyConfigProvider.setType({
- name: 'ui-cmdbinformation',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- }
- };
- },
- controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
- if ($scope.options.templateOptions.loginUser) {
- if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
- } else {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
- }
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }
- }]
- });
- //资产属性
- formlyConfigProvider.setType({
- name: 'ui-cmdbtype',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- }
- };
- },
- controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.property = {
- 'hw_change': $scope.to.loginUser,
- 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
- 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
- }
- if ($scope.$parent.$parent.$parent.model.assets) {
- $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
- }
- }]
- });
- //申请单信息
- formlyConfigProvider.setType({
- name: 'ui-cmdbformimform',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- }
- };
- },
- controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.getininform = {
- serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
- time: $scope.$parent.$parent.$parent.model.applicationForm.time
- };
- if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
- $scope.getininform.types = "新资产入库";
- } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
- $scope.getininform.types = "资产归还";
- }
- }]
- });
- //出库单信息
- formlyConfigProvider.setType({
- name: 'ui-outinformation',
- templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- }
- };
- },
- controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.getininform = {
- serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
- time: $scope.$parent.$parent.$parent.model.applicationForm.time,
- // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
- sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
- describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
- };
- if ($scope.$parent.$parent.$parent.model.type.value == "1") {
- $scope.getininform.types = "新设备领用出库";
- } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
- $scope.getininform.types = "设备更换";
- }
- $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.value;
- if ($scope.$parent.$parent.$parent.model.source.value == "1") {
- $scope.getininform.source = "事件";
- } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
- $scope.getininform.source = "变更";
- // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
- } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
- $scope.getininform.source = "其它";
- }
- }]
- });
- //资产附件上传
- formlyConfigProvider.setType({
- name: 'ui-cmdbuplode',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- }
- };
- },
- controller: ['$scope', '$rootScope', '$http', 'SweetAlert', 'FileUploader', 'api_user_data', 'i18nService', '$modal', 'Restangular', 'api_configure_data', 'api_cmdb', 'api_cmdb_new', 'api_wechatfile', 'api_sysinfo', function ($scope, $rootScope, $http, SweetAlert, FileUploader, api_user_data, i18nService, $modal, Restangular, api_configure_data, api_cmdb, api_cmdb_new, api_wechatfile, api_sysinfo) {
- $scope.state = 1;
- $scope.myData3all = [];
- $scope.myData3 = [];
- $scope.memoryfilterDatahao = {
- "idx": 0,
- "sum": 10,
- }
- $scope.selected = {
- items: []
- };
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- // $scope.importnext = function() {
- // $scope.state = 2;
- // event.preventDefault();
- // }
- $scope.workspaces = [];
- $scope.options.templateOptions.getpush = function (item) {
- $scope.workspaces = [];
- if (item.gu) {
- $scope.workspaces.push({
- id: 1,
- name: "固定资产",
- active: true,
- contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html'
- })
- }
- if (item.hao) {
- $scope.workspaces.push({
- id: 2,
- name: "耗材资产",
- active: true,
- contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
- })
- }
- };
- //获取附件列表
- $scope.listAttachmen = function () {
- to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
- var myData = Restangular.stripRestangular(result);
- // $scope.listAttachmens = myData;
- $scope.attachments = myData.data;
- });
- };
- //附件列表
- if ($scope.options.templateOptions.bindType) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- var to = $scope.options.templateOptions;
- var bindId = $scope.model[to.bindType].processInstanceId;
- $scope.listAttachmen();
- }
- // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
- // $scope.listAttachmen();
- // } else if (to.bindType && $scope.model[to.bindType].id) {
- // $scope.listAttachmen();
- // }
- //附件下载
- $scope.download = function (token, filename) {
- var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
- // window.open(downUrl);
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- //附件预览
- $scope.view = function (id, previewUrl) {
- if (previewUrl) {
- window.open(previewUrl);
- }
- };
- //下载资产模版
- $scope.filenum = 0;
- $scope.openmeans = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/means/tpl/meansdown.html',
- controller: function ($scope, scope, $modalInstance) {
- $scope.item = {};
- $scope.title = "选择下载模版";
- $scope.lable = "资产模版下载";
- function foreachdata(my_datas) {
- // angular.forEach(my_datas, function(item, index) {
- // if (item.children && item.children.length > 0) {
- // foreachdata(item.children);
- // } else {
- // my_datas[index].checks = true;
- // }
- // })
- for (var i = 0; i < my_datas.length; i++) {
- if (my_datas[i].children && my_datas[i].children.length > 0) {
- foreachdata(my_datas[i].children);
- console.log($scope);
- } else {
- my_datas[i].checks = true;
- }
- }
- }
- function foreachtree(data) {
- angular.forEach(data, function (item) {
- // if (item.checks != true) {
- item.checks = true;
- item.expanded = true;
- if (item.children && item.children.length > 0) {
- foreachtree(item.children)
- } else {
- $scope.getslowtree.push(item)
- }
- // }
- })
- }
- $scope.getslowtree = [];
- $scope.slowtree = function (tree) {
- foreachtree(tree)
- return $scope.getslowtree
- }
- $scope.all = function (c, v) { //全选
- if (c == true) {
- $scope.formdashboard($scope.slowtree(v));
- } else {
- $scope.my_data_after = [];
- angular.forEach($scope.my_data, function (item, index) {
- $scope.my_data[index].checks = false;
- $scope.my_data[index].expanded = false;
- if (item.children && item.children.length > 0) {
- angular.forEach(item.children, function (itemone, indexone) {
- $scope.my_data[index].children[indexone].checks = false;
- $scope.my_data[index].children[indexone].expanded = false;
- if (itemone.children && itemone.children.length > 0) {
- angular.forEach(itemone.children, function (itemtwo, indextwo) {
- $scope.my_data[index].children[indexone].children[indextwo].checks = false;
- })
- } else { }
- })
- } else { }
- })
- $scope.mydatacate = [];
- $scope.getslowtree = [];
- // }
- }
- };
- // $scope.searchone = function(search) {
- // angular.forEach($scope.my_data, function(item) {
- // if (item.indexOf(search) > 0) {
- // }
- // })
- // }
- $scope.checkall = function () {
- angular.forEach($scope.my_data, function (item, index) {
- scope.my_data[index].checks = true;
- })
- }
- $scope.selectitem = [];
- $scope.choiceitem = function (item) {
- // if (item.checkeds) {
- // item.checkeds = false;
- // // for (var i = 0; i < $scope.selectitem.length; i++) {
- // // if ($scope.selectitem[i].id == item.id) {
- // // $scope.selectitem.splice(i, 1)
- // // }
- // // }
- // for (var i = 0; i < $scope.my_data_after; i++) {
- // if ($scope.my_data_after[i].id == item.id) {
- // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
- // // $scope.selectitem.splice(i, 1)
- // }
- // }
- // } else {
- // item.checkeds = true;
- // $scope.selectitem.push(item)
- // }
- for (var i = 0; i < $scope.my_data_after.length; i++) {
- if ($scope.my_data_after[i].id == item.id) {
- $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
- }
- }
- }
- $scope.remove = function (removeitem) {
- var realdat = angular.copy($scope.my_data_after)
- // angular.extend(realdat, $scope.selectitem);
- $scope.my_data_after = [];
- angular.forEach(realdat, function (item) {
- if (!item.checkeds) {
- $scope.my_data_after.push(item)
- }
- })
- $scope.mydatacate = angular.copy($scope.my_data_after);
- }
- $scope.try_async_loads = function (item, search) {
- var fildatas = {
- 'idx': 0,
- 'sum': 1000
- };
- $scope.my_data = [];
- // $scope.try_async_load = true;
- if (item) {
- angular.extend(fildatas, item)
- }
- api_configure_data.fetchDataList('ciclassify', fildatas).then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (search) {
- delete data[i].parent
- } else {
- if (data[i].parent && data[i].parent.id != 0) {
- object.parent = data[i].parent.id;
- }
- }
- angular.extend(object, data[i]);
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.try_async_load = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- // console.log("datum="+JSON.stringify(datum))
- if (typeof datum.parent === "undefined" || datum.parent === null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- // delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- function convertParentToChild(datato) {
- var treeMapto = {};
- var listto = [];
- convertListToTree(datato, treeMapto);
- angular.forEach(treeMapto, function (items) {
- listto.push(items);
- });
- return listto;
- }
- $scope.try_async_loads();
- $scope.searchdown = function (key) {
- if (key && key != '') {
- $scope.try_async_loads({
- 'ciclassify': {
- "label": key
- }
- }, 'search')
- } else {
- $scope.try_async_loads()
- }
- // var mydatacatedown = angular.copy($scope.my_data);
- // $scope.my_data = [];
- // var objects = [];
- // angular.forEach(mydatacatedown, function(item) {
- // if (item.label.match(key)) {
- // objects.push(item)
- // } else {
- // // $scope.my_data_after.push(item)
- // }
- // })
- // $scope.my_data = convertParentToChildList(objects);
- // $scope.tree_data = angular.copy($scope.my_data);
- }
- $scope.mydatacate = [];
- $scope.searchup = function (key) {
- // var mydatacate = angular.copy($scope.my_data_after);
- $scope.my_data_after = [];
- angular.forEach($scope.mydatacate, function (item) {
- if (item.label.match(key)) {
- $scope.my_data_after.push(item)
- } else { }
- })
- }
- //角色树
- $scope.my_tree = [];
- $scope.tree_data_after = [];
- $scope.my_data = [];
- $scope.my_data_after = [];
- $scope.formdashboard = function (item) {
- $scope.my_data_after = [];
- angular.forEach(item, function (infox) {
- if (infox.children.length == 0) {
- $scope.my_data_after.push(infox);
- }
- })
- $scope.mydatacate = angular.copy($scope.my_data_after);
- }
- $scope.ok = function (item) {
- $modalInstance.close(item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- // size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // $rootScope.isMask = true;
- if (selectedItem) {
- var type = 1;
- var fildat = {
- 'configure': selectedItem
- };
- // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
- // // if (data.errno == 0) {
- // var file = new Blob([data], {
- // // 'Accept': '*/*'
- // type: 'application/octet-stream'
- // // type: 'application/vnd.ms-excel'
- // });
- // //trick to download store a file having its URL
- // var fileURL = URL.createObjectURL(file);
- // var a = document.createElement('a');
- // a.href = fileURL;
- // a.target = '_blank';
- // a.download = "资产导入模版.xlsx";
- // document.body.appendChild(a);
- // a.click();
- // // }
- // })
- $http({
- url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
- method: 'POST',
- data: JSON.stringify(fildat),
- headers: {
- // 'Content-type': 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- $rootScope.isMask = false;
- var file = new Blob([data], {
- type: 'application/octet-stream'
- // type : 'application/vnd.ms-excel'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = "资产导入模版.xlsx";
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- $rootScope.isMask = false;
- });
- // break;
- // }
- // }
- // }
- // })
- } else {
- SweetAlert.swal({
- title: "未选择资产分类!",
- text: "请选择资产分类",
- type: "error"
- }, function () {
- $rootScope.isMask = false;
- });
- }
- // }
- });
- }
- $scope.wrongdata = [];
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
- $scope.importopen = function () { //导入触发事件
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 2;
- }
- });
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- // uploader.onSuccessItem = function(fileItem, response, status, headers) {
- // console.info('onSuccessItem', fileItem, response, status, headers);
- // };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }
- // $scope.importnext = function() {
- // $scope.state = 2;
- // event.preventDefault();
- // }
- $scope.importnext = function () {
- event.preventDefault();
- // $rootScope.isMask = true;
- $rootScope.loading = true;
- // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
- // if (item.index > 1) {
- // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
- // }
- // item.index = 1;
- item.formData = [{
- 'filename': item.file.name
- }];
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- if (response.status == 200) {
- $scope.wrongdata = [];
- $rootScope.loading = false;
- if (response.abnormal) {
- $scope.state = 2;
- angular.forEach(response.msg, function (item) {
- $scope.wrongdata.push({
- 'name': item.assetName,
- 'line': item.row,
- 'cmdbname': item.name,
- 'errotip': [{
- 'label': item.msg
- }]
- })
- })
- } else {
- $scope.state = 3;
- }
- } else {
- $rootScope.loading = false;
- $scope.state = 2;
- }
- }
- }
- $scope.clearItems = function () { //重新选择文件时,清空队列,达到覆盖文件的效果
- uploader.clearQueue();
- // uploader.remove();
- // uploader.cancel();
- // uploader.onChange();
- }
- uploader.onAfterAddingFile = function (fileItem) {
- $scope.fileItem = fileItem._file;
- // $scope.$apply();
- // $scope.fileItem = filenum;
- // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
- // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
- $scope.filenum++;
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- $scope.uploadStatus = true; //上传成功则把状态改为true
- // alert(response.path);
- };
- $scope.importnext = function () {
- event.preventDefault();
- // uploader.onChange();
- $rootScope.loading = true;
- // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
- // if (item.index > 1) {
- // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
- // }
- // item.index = 1;
- item.formData = [{
- 'filename': item.file.name
- }];
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- if (response.status == 200) {
- $scope.wrongdata = [];
- // uploader.queue = [];
- $rootScope.loading = false;
- if (response.abnormal) {
- $scope.state = 2;
- uploader.clearQueue();
- angular.forEach(response.msg, function (item) {
- $scope.wrongdata.push({
- 'name': item.assetName,
- 'line': item.row,
- 'cmdbname': item.name,
- 'errotip': [{
- 'label': item.msg
- }]
- })
- })
- } else {
- $scope.state = 3;
- }
- } else {
- uploader.clearQueue();
- $rootScope.loading = false;
- $scope.state = 2;
- }
- }
- }
- var setAllInactive = function () {
- angular.forEach($scope.workspaces, function (workspace) {
- workspace.active = false;
- });
- };
- //添加
- var addNewWorkspace = function (name, contentUrl) {
- var id = $scope.workspaces.length + 1;
- $scope.workspaces.push({
- id: id,
- name: name,
- active: true,
- contentUrl: 'main/html/content.html'
- });
- };
- //关闭
- $scope.closeopen = function (closedata) {
- event.preventDefault();
- angular.forEach($scope.workspaces, function (item, index) {
- if (closedata.id == item.id) {
- if (closedata.id == 1) {
- $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
- } else {
- $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
- }
- $scope.workspaces.splice(index, 1);
- }
- })
- }
- // $scope.workspaces = [
- // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
- // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
- // ];
- $scope.addWorkspace = function (contentUrl, name) {
- setAllInactive();
- addNewWorkspace(name, contentUrl);
- };
- // $rootScope.addWorkspace = $scope.addWorkspace;
- $scope.close = function (idNumber) {
- var index = 0; //记录当前元素下标
- angular.forEach($scope.workspaces, function (workspace) {
- if (workspace.id === idNumber) {
- $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
- }
- index++;
- });
- };
- //grid2
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions2 = {};
- $scope.gridOptions2.data = 'myData3';
- $scope.gridOptions2.enableColumnResizing = true;
- $scope.gridOptions2.enableFiltering = false;
- $scope.gridOptions2.enableGridMenu = false;
- $scope.gridOptions2.showGridFooter = true;
- $scope.gridOptions2.showColumnFooter = false;
- $scope.gridOptions2.fastWatch = true;
- $scope.gridOptions2.useExternalFiltering = true;
- $scope.gridOptions2.useExternalPagination = true;
- $scope.gridOptions2.paginationPageSizes = [10];
- $scope.gridOptions2.paginationPageSize = 10;
- $scope.gridOptions2.multiSelect = false;
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions2.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 120
- },
- {
- name: 'name',
- displayName: '耗材名称',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'model',
- displayName: '品牌/型号',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'Specifications',
- displayName: '规格',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'sum',
- displayName: '数量',
- enableFiltering: false
- },
- {
- name: '操作',
- cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
- '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
- '</div></div>',
- enableFiltering: false
- },
- ];
- if ($scope.$parent.$parent.$parent.model.uplodtype) {
- if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
- $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
- for (var i = 0; i < $scope.myData3all.length; i++) {
- $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
- }
- // $scope.model.consumables = $scope.myDataone;
- $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
- $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
- $scope.model.applicationForm.consumables = $scope.myData3all;
- if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
- $scope.options.templateOptions.getpush({
- "hao": true,
- "gu": true
- });
- } else {
- $scope.options.templateOptions.getpush({
- "hao": true
- });
- }
- } else {
- if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
- $scope.options.templateOptions.getpush({
- "gu": true
- });
- }
- }
- }
- $scope.options.templateOptions.workspaces = $scope.workspaces;
- $scope.changecai = function (item) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
- controller: function ($scope, $modalInstance) {
- $scope.title = "修改耗材数量";
- $scope.consumptive = angular.copy(item);
- $scope.ok = function () {
- $modalInstance.close($scope.consumptive);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function (selectedItem) {
- // angular.forEach($scope.myData3, function(items, index) {
- // if (items.id == selectedItem.id) {
- // $scope.myData3[index] = selectedItem;
- // }
- // })
- // // $scope.myData3.push(selectedItem);
- // $scope.model.applicationForm.consumables = $scope.myData3;
- angular.forEach($scope.myData3all, function (items, index) {
- if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
- // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
- angular.extend($scope.myData3all[index], selectedItem)
- }
- })
- $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
- $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
- $scope.model.applicationForm.consumables = $scope.myData3all;
- })
- }
- $scope.gridOptions2.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterDatahao;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- $scope.memoryfilterDatahao.idx = newPage - 1;
- $scope.memoryfilterDatahao.sum = pageSize;
- $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- };
- $scope.memoryfilterDatahao = filtersData;
- // $scope.loadData(filtersData);
- // $scope.memoryfilterDatahao.idx = newPage - 1;
- // $scope.memoryfilterDatahao.sum = pageSize;
- $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
- });
- };
- $scope.haocaiopen = function (items) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
- controller: function ($scope, $modalInstance, SweetAlert) {
- $scope.consumptive = {};
- $scope.title = "新增耗材";
- if (items.name) {
- $scope.consumptive.name = items.name.name;
- }
- $scope.clearNoNum = function (obj, attr) {
- //先把非数字的都替换掉,除了数字和.
- obj[attr] = obj[attr].replace(/[^\d.]/g, "");
- //必须保证第一个为数字而不是.
- obj[attr] = obj[attr].replace(/^\./g, "");
- //保证只有出现一个.而没有多个.
- obj[attr] = obj[attr].replace(/\.{2,}/g, "");
- //保证.只出现一次,而不能出现两次以上
- obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- //小于最大值
- // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
- // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
- // obj[attr] = '';
- // }
- }
- $scope.ok = function (item) {
- // if (item.name && item.model && item.Specifications && item.sum) {
- if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
- $modalInstance.close(item);
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- SweetAlert: function () {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- api_sysinfo.addData('dictionaryTree', {
- // "type": "list",
- "key": "haocaifenlei",
- "name": selectedItem.name,
- "parent": selectedItem.id,
- "value": selectedItem.name,
- "deleted": false,
- "level": 1
- }).then(function (data) {
- // $scope.haocainame.name = data.list;
- api_sysinfo.addData('dictionaryTree', {
- // "type": "list",
- "key": "pinpai",
- "name": selectedItem.model,
- "parent": data.id,
- "value": selectedItem.model,
- "deleted": false,
- "level": 2
- }).then(function (data) {
- // $scope.haocainame = data.list;
- })
- api_sysinfo.addData({
- // "type": "list",
- "key": "guige",
- "name": selectedItem.Specifications,
- "parent": data.id,
- "value": selectedItem.Specifications,
- "deleted": false,
- "level": 2
- }).then(function (data) {
- // $scope.haocainame = data.list;
- })
- })
- // $scope.myData3.push(selectedItem);
- // for (var i = 0; i < $scope.myData3.length; i++) {
- // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
- // }
- // $scope.model.applicationForm.consumables = $scope.myData3;
- $scope.myData3all.push(selectedItem);
- for (var i = 0; i < $scope.myData3all.length; i++) {
- $scope.myData3all[i]['item'] = i + 1
- }
- // $scope.model.consumables = $scope.myDataone;
- $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
- $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
- $scope.model.applicationForm.consumables = $scope.myData3all;
- })
- }
- $scope.haocaiadd = function () {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
- controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
- $scope.haocainame = [];
- $scope.pinpai = [];
- $scope.guige = [];
- $scope.consumptive = {};
- $scope.consumpall = {};
- $scope.title = "添加耗材";
- api_wechatfile.getDictionary({
- "key": "haocaifenlei",
- "type": "tree"
- }).then(function (data) {
- $scope.haocainame = data;
- })
- $scope.clearNoNum = function (obj, attr) {
- //先把非数字的都替换掉,除了数字和.
- obj[attr] = obj[attr].replace(/[^\d.]/g, "");
- //必须保证第一个为数字而不是.
- obj[attr] = obj[attr].replace(/^\./g, "");
- //保证只有出现一个.而没有多个.
- obj[attr] = obj[attr].replace(/\.{2,}/g, "");
- //保证.只出现一次,而不能出现两次以上
- obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- //小于最大值
- // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
- // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
- // obj[attr] = '';
- // }
- }
- $scope.onChange = function (parent) {
- $scope.consumptive.model = {};
- $scope.consumptive.Specifications = {};
- api_wechatfile.getDictionaryForList({
- "key": "pinpai",
- "parent": parent.id
- }).then(function (data) {
- $scope.pinpai = data;
- })
- api_wechatfile.getDictionaryForList({
- "key": "guige",
- "parent": parent.id
- }).then(function (data) {
- $scope.guige = data;
- })
- }
- $scope.addhaocai = function () {
- $modalInstance.dismiss('cancel');
- scope.haocaiopen($scope.consumptive);
- }
- $scope.ok = function (item) {
- var items = {};
- var submittrue = true;
- if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
- items = {
- "modelid": item.model.id,
- "nameid": item.name.id,
- "Specificationsid": item.Specifications.id,
- "name": item.name.name,
- "model": item.model.name,
- "Specifications": item.Specifications.name,
- "sum": item.sum
- }
- angular.forEach(scope.myData3all, function (itemsdata) {
- if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
- submittrue = false;
- }
- })
- if (submittrue) {
- $modalInstance.close(items);
- } else {
- SweetAlert.swal({
- title: "该耗材已有添加",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- // var isold = false;
- // if (item.name && item.model && item.Specifications && item.sum) {
- // for (var i = 0; i < scope.myData3all.length; i++) {
- // if (scope.myData3all[i].id == $scope.consumpall.id) {
- // isold = true;
- // }
- // }
- // if (isold) {
- // SweetAlert.swal({
- // title: "该耗材已添加!",
- // text: "请不要重复添加耗材!",
- // type: "error"
- // });
- // } else {
- // $scope.consumpall.model = $scope.consumpall.brandModel;
- // $scope.consumpall.Specifications = $scope.consumpall.specification;
- // $scope.consumpall.sum = item.sum;
- // delete $scope.consumpall.brandModel;
- // delete $scope.consumpall.specification;
- // $modalInstance.close($scope.consumpall);
- // }
- // } else {
- // SweetAlert.swal({
- // title: "数据填写不完整!",
- // text: "请检查数据然后提交!",
- // type: "error"
- // });
- // }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- $scope.myData3all.push(selectedItem);
- for (var i = 0; i < $scope.myData3all.length; i++) {
- $scope.myData3all[i]['item'] = i + 1
- }
- // $scope.model.consumables = $scope.myDataone;
- $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
- $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
- $scope.model.applicationForm.consumables = $scope.myData3all;
- })
- }
- $scope.onDblClick = function (data, event) {
- $scope.selectButtonClick(data, event);
- };
- // $scope.memoryfilterDatahao = {
- // "idx": 0,
- // "sum": 10,
- // }
- // $scope.loadData = function(filterData) {};
- // $scope.title = title;
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
- }
- }]
- });
- //归还设备耗材tab
- formlyConfigProvider.setType({
- name: 'ui-cmdbreturntab',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requester) {
- // options.value(options.model.requester);
- // }
- // },
- }
- };
- },
- controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function ($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
- var setAllInactive = function () {
- angular.forEach($scope.workspaces, function (workspace) {
- workspace.active = false;
- });
- };
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 10,
- }
- //添加
- var addNewWorkspace = function (name, contentUrl) {
- var id = $scope.workspaces.length + 1;
- $scope.workspaces.push({
- id: id,
- name: name,
- active: true,
- contentUrl: 'main/html/content.html'
- });
- };
- $scope.workspaces = [{
- id: 1,
- name: "归还设备",
- active: true,
- contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
- },
- {
- id: 2,
- name: "归还耗材",
- active: true,
- contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
- }
- ];
- $scope.addWorkspace = function (contentUrl, name) {
- setAllInactive();
- addNewWorkspace(name, contentUrl);
- };
- // $rootScope.addWorkspace = $scope.addWorkspace;
- $scope.close = function (idNumber) {
- var index = 0; //记录当前元素下标
- angular.forEach($scope.workspaces, function (workspace) {
- if (workspace.id === idNumber) {
- $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
- }
- index++;
- });
- };
- $scope.memoryfilterDataguishe = {
- "idx": 0,
- "sum": 10,
- }
- //grid1
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions1 = {};
- $scope.gridOptions1.data = 'myData1';
- $scope.gridOptions1.enableColumnResizing = true;
- $scope.gridOptions1.enableFiltering = false;
- $scope.gridOptions1.enableGridMenu = false;
- $scope.gridOptions1.showGridFooter = true;
- $scope.gridOptions1.showColumnFooter = false;
- $scope.gridOptions1.fastWatch = true;
- $scope.gridOptions1.useExternalFiltering = true;
- $scope.gridOptions1.useExternalPagination = true;
- $scope.gridOptions1.paginationPageSizes = [10];
- $scope.gridOptions1.paginationPageSize = 10;
- $scope.gridOptions1.multiSelect = false;
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions1.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 120
- },
- {
- name: 'props.hw_cifilterClassic',
- displayName: '设备类型',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'props.hw_mingcheng',
- displayName: '设备名称',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'uuid',
- displayName: '设备编号',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'props.hw_state',
- width: 150,
- displayName: '状态',
- enableFiltering: false
- },
- {
- name: '操作',
- cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
- '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
- '</div></div>',
- enableFiltering: false
- },
- ];
- // $scope.selectButtonClick
- $scope.gridOptions1.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- $scope.memoryfilterDataguishe.idx = newPage - 1;
- $scope.memoryfilterDataguishe.sum = pageSize;
- $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.core.on.filterChanged($scope, function () {
- // var grid = this.grid;
- // var filtersData = {
- // idx: 0,
- // sum: 20,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- // };
- // angular.forEach(grid.columns, function(item) {
- // if (item.enableFiltering) {
- // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // if (angular.isUndefined(filtersData['user'])) {
- // filtersData['user'] = {};
- // }
- // filtersData['user'][item.field] = item.filters[0].term;
- // }
- // }
- // });
- // $scope.memoryfilterData = filtersData;
- // $scope.loadData(filtersData);
- });
- };
- $scope.changegu = function (item) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
- controller: function ($scope, $modalInstance) {
- $scope.title = "修改设备状态";
- $scope.hw_state = {};;
- if (item.status) {
- $scope.hw_state.name = item.hw_state;
- }
- // $scope.consumptive = item;
- $scope.stateshe = [{
- "id": 2,
- "name": "在库"
- }, {
- "id": 4,
- "name": "报修"
- }, {
- "id": 3,
- "name": "报废"
- }]
- $scope.ok = function (item) {
- $modalInstance.close($scope.hw_state);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function (selectedItem) {
- angular.forEach($scope.myData1, function (items, index) {
- if (items.id == item.id) {
- $scope.myData1[index].props.hw_state = selectedItem.id.name;
- }
- })
- $scope.model.assets = $scope.myData1;
- $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
- })
- }
- $scope.onDblClick = function (data, event) {
- $scope.selectButtonClick(data, event);
- };
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 10,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- }
- // $scope.myData = {};
- $scope.loadData = function (filterData) { };
- // $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- });
- $scope.selected = {
- items: []
- };
- $scope.myData2 = [];
- $scope.consumptive = {};
- $scope.myDataguibeiall = [];
- $scope.haocaiopen = function (items) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
- controller: function ($scope, $modalInstance, SweetAlert, api_wechatfile, api_sysinfo) {
- $scope.consumptive = {};
- $scope.title = "新增耗材";
- if (items.name) {
- $scope.consumptive.name = items.name.name;
- }
- $scope.ok = function (item) {
- if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
- $modalInstance.close(item);
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function (selectedItem) {
- api_sysinfo.addData({
- "type": "list",
- "key": "haocaifenlei",
- "name": selectedItem.name,
- "parent": selectedItem.id,
- "value": "1"
- }).then(function (data) {
- // $scope.haocainame.name = data.list;
- api_wechatfile.addDictionary({
- "type": "list",
- "key": "pinpai",
- "name": selectedItem.model,
- "parent": data.id,
- "value": "1"
- }).then(function (data) {
- // $scope.haocainame = data.list;
- })
- api_wechatfile.addDictionary({
- "type": "list",
- "key": "guige",
- "name": selectedItem.Specifications,
- "parent": data.id,
- "value": "1"
- }).then(function (data) {
- // $scope.haocainame = data.list;
- })
- })
- $scope.myData2.push(selectedItem);
- for (var i = 0; i < $scope.myData2.length; i++) {
- $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
- }
- // $scope.model.applicationForm.consumables = $scope.myData2;
- angular.forEach($scope.myDataguibeiall, function (items, index) {
- if (items.id == selectedItem.id) {
- $scope.myDataguibeiall.splice(index, 1);
- }
- })
- $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
- $scope.model.consumables = $scope.myDataguibeiall;
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
- $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
- })
- }
- //grid2
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions2 = {};
- $scope.gridOptions2.data = 'myData2';
- $scope.gridOptions2.enableColumnResizing = true;
- $scope.gridOptions2.enableFiltering = false;
- $scope.gridOptions2.enableGridMenu = false;
- $scope.gridOptions2.showGridFooter = true;
- $scope.gridOptions2.showColumnFooter = false;
- $scope.gridOptions2.fastWatch = true;
- $scope.gridOptions2.useExternalFiltering = true;
- $scope.gridOptions2.useExternalPagination = true;
- $scope.gridOptions2.paginationPageSizes = [10];
- $scope.gridOptions2.paginationPageSize = 10;
- $scope.gridOptions2.multiSelect = false;
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.modelcons = {};
- $scope.modelass = {};
- $scope.myData2all = [];
- $scope.myData1all = [];
- $scope.memoryfilterDatagui = {
- "idx": 0,
- "sum": 10
- }
- setInterval(function () {
- if ($scope.model.assets) {
- if ($scope.model.assets != $scope.modelass && typeof ($scope.model.assets) == 'string') {
- $scope.modelass = $scope.model.assets;
- if (JSON.stringify($scope.model.assets) == "{}") {
- $scope.model.assets = []
- } else {
- $scope.model.assets = JSON.parse($scope.model.assets);
- }
- // $scope.myData1 = $scope.model.assets;
- // for (var i = 0; i < $scope.myData1.length; i++) {
- // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
- // }
- $scope.myData1all = $scope.model.assets;
- for (var i = 0; i < $scope.myData1all.length; i++) {
- $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
- }
- $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
- $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
- }
- }
- if ($scope.model.consumables) {
- if ($scope.model.consumables != $scope.modelcons && typeof ($scope.model.consumables) == 'string') {
- $scope.modelass = $scope.model.consumables;
- if (JSON.stringify($scope.model.consumables) == "{}") {
- $scope.model.consumables = [];
- } else {
- $scope.model.consumables = JSON.parse($scope.model.consumables);
- }
- // $scope.myData2 = $scope.model.consumables;
- // for (var i = 0; i < $scope.myData2.length; i++) {
- // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
- // }
- $scope.myData2all = $scope.model.consumables;
- for (var i = 0; i < $scope.myData2all.length; i++) {
- $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
- }
- $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
- $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
- // $scope.model.consumables = $scope.myData2all;
- }
- }
- }, 100);
- $scope.gridOptions2.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 120
- },
- {
- name: 'name',
- displayName: '耗材名称',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'model',
- displayName: '品牌/型号',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'Specifications',
- displayName: '规格',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'sum',
- width: 150,
- displayName: '数量',
- enableFiltering: false
- },
- {
- name: '操作',
- cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
- '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
- '</div></div>',
- enableFiltering: false
- },
- ];
- // $scope.selectButtonClick
- $scope.gridOptions2.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterDatagui;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- $scope.memoryfilterDatagui.idx = newPage - 1;
- $scope.memoryfilterDatagui.sum = pageSize;
- $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- $scope.changecai = function (item) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
- controller: function ($scope, $modalInstance) {
- $scope.title = "修改耗材数量";
- $scope.consumptive = angular.copy(item);
- // $scope.consumptive = item;
- $scope.maxsum = item.inventoryNum;
- $scope.clearNoNum = function (obj, attr) {
- //先把非数字的都替换掉,除了数字和.
- obj[attr] = obj[attr].replace(/[^\d.]/g, "");
- //必须保证第一个为数字而不是.
- obj[attr] = obj[attr].replace(/^\./g, "");
- //保证只有出现一个.而没有多个.
- obj[attr] = obj[attr].replace(/\.{2,}/g, "");
- //保证.只出现一次,而不能出现两次以上
- obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- //小于最大值
- // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
- // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
- // obj[attr] = '';
- // }
- }
- $scope.ok = function () {
- $modalInstance.close($scope.consumptive);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function (selectedItem) {
- angular.forEach($scope.myData2all, function (items, index) {
- // if (items.id == selectedItem.id) {
- if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
- angular.extend($scope.myData2all[index], selectedItem)
- }
- })
- // $scope.model.consumables = $scope.myData2;
- // $scope.myData2 = $scope.model.consumables;
- // $scope.myData2all.push(selectedItem);
- // for (var i = 0; i < $scope.myData2all.length; i++) {
- // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
- // }
- $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
- $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
- $scope.model.consumables = $scope.myData2all;
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
- })
- }
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- $scope.haocaiadd = function () {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
- controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
- $scope.haocainame = [];
- $scope.pinpai = [];
- $scope.guige = [];
- $scope.consumptive = {};
- $scope.consumptiveall = {};
- $scope.title = "添加耗材";
- api_wechatfile.getDictionaryForList({
- "key": "haocaifenlei"
- }).then(function (data) {
- $scope.haocainame = data;
- })
- $scope.clearNoNum = function (obj, attr) {
- //先把非数字的都替换掉,除了数字和.
- obj[attr] = obj[attr].replace(/[^\d.]/g, "");
- //必须保证第一个为数字而不是.
- obj[attr] = obj[attr].replace(/^\./g, "");
- //保证只有出现一个.而没有多个.
- obj[attr] = obj[attr].replace(/\.{2,}/g, "");
- //保证.只出现一次,而不能出现两次以上
- obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- //小于最大值
- if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
- alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
- obj[attr] = '';
- }
- }
- $scope.onChange = function (parent) {
- $scope.consumptive.model = {};
- $scope.consumptive.Specifications = {};
- api_wechatfile.getDictionaryForList({
- "key": "pinpai",
- "parent": parent.id
- }).then(function (data) {
- $scope.pinpai = data;
- })
- api_wechatfile.getDictionaryForList({
- "key": "guige",
- "parent": parent.id
- }).then(function (data) {
- $scope.guige = data;
- })
- }
- // $scope.onChangesum = function(item) {
- // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
- // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
- // $scope.consumptiveall = data1;
- // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
- // // if (data.list && data.list.length != 0) {
- // // var myData = data.list;
- // // $scope.consumptiveall = myData[0];
- // // $scope.maxsum = myData[0].inventoryNum;
- // // } else if (data.list && data.list.length == 0) {
- // // SweetAlert.swal({
- // // title: "库存数据存在问题!",
- // // text: "请检查库存数据!",
- // // type: "error"
- // // });
- // // }
- // // });
- // }
- // }
- $scope.addhaocai = function () {
- $modalInstance.dismiss('cancel');
- scope.haocaiopen($scope.consumptive);
- }
- $scope.ok = function (item) {
- var submittrue = true;
- // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
- var data = {
- "modelid": item.model.id,
- "nameid": item.name.id,
- "Specificationsid": item.Specifications.id,
- "name": item.name.name,
- "model": item.model.name,
- "Specifications": item.Specifications.name,
- "sum": item.sum
- }
- if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
- // $modalInstance.close(data);
- angular.forEach(scope.myData2all, function (itemsdata) {
- // if (item.model.id == itemsdata.id) {
- if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
- submittrue = false;
- }
- })
- if (submittrue) {
- $modalInstance.close(data);
- } else {
- SweetAlert.swal({
- title: "该耗材已有添加",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // $scope.myData2.push(selectedItem);
- // for (var i = 0; i < $scope.myData2.length; i++) {
- // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
- // }
- // $scope.model.consumables = $scope.myData2;
- $scope.myData2all.push(selectedItem);
- for (var i = 0; i < $scope.myData2all.length; i++) {
- // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
- $scope.myData2all[i]['item'] = i + 1
- }
- $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
- $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
- $scope.model.consumables = $scope.myData2all;
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
- })
- }
- $scope.onDblClick = function (data, event) {
- $scope.selectButtonClick(data, event);
- };
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 20,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- }
- $scope.myData = {};
- $scope.loadData = function (filterData) { };
- // $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 20,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- });
- $scope.selected = {
- items: {}
- };
- }]
- });
- //tab 列表
- formlyConfigProvider.setType({
- name: 'ui-cmdbtab',
- templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
- $scope.memoryfilterDatashe = {
- "idx": 0,
- "sum": 10
- }
- $scope.myDataoneall = [];
- var setAllInactive = function () {
- angular.forEach($scope.workspaces, function (workspace) {
- workspace.active = false;
- });
- };
- //添加
- var addNewWorkspace = function (name, contentUrl) {
- var id = $scope.workspaces.length + 1;
- $scope.workspaces.push({
- id: id,
- name: name,
- active: true,
- contentUrl: 'main/html/content.html'
- });
- };
- //关闭
- $scope.remove = function (closedata) {
- event.preventDefault();
- angular.forEach($scope.workspaces, function (item, index) {
- if (closedata.id == item.id) {
- if (closedata.id == 1) {
- $scope.$parent.$parent.$parent.model.gettype.gu = false;
- } else {
- $scope.$parent.$parent.$parent.model.gettype.hao = false;
- }
- $scope.workspaces.splice(index, 1);
- }
- })
- }
- $scope.workspaces = [];
- $scope.options.templateOptions.getpush = function (item) {
- $scope.workspaces = [];
- if (item.gu) {
- $scope.workspaces.push({
- id: 1,
- name: "领用设备",
- active: true,
- contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
- })
- }
- if (item.hao) {
- $scope.workspaces.push({
- id: 2,
- name: "领用耗材",
- active: true,
- contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
- })
- }
- $scope.options.templateOptions.workspaces = $scope.workspaces;
- };
- $scope.addWorkspace = function (contentUrl, name) {
- setAllInactive();
- addNewWorkspace(name, contentUrl);
- };
- // $rootScope.addWorkspace = $scope.addWorkspace;
- // $scope.remove = function(idNumber) {
- // var index = 0; //记录当前元素下标
- // angular.forEach($scope.workspaces, function(workspace) {
- // if (workspace.id === idNumber.id) {
- // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
- // }
- // index++;
- // });
- // };
- // setInterval(function() {
- // if ($scope.model.assets) {
- // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
- // $scope.modelass = $scope.model.assets;
- // if (JSON.stringify($scope.model.assets) == "{}") {
- // $scope.model.assets = []
- // } else {
- // $scope.model.assets = JSON.parse($scope.model.assets);
- // }
- // $scope.myDatalingbeiall = $scope.model.assets;
- // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
- // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
- // }
- // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
- // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
- // }
- // }
- // if ($scope.model.consumables) {
- // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
- // $scope.modelass = $scope.model.consumables;
- // if (JSON.stringify($scope.model.consumables) == "{}") {
- // $scope.model.consumables = [];
- // } else {
- // $scope.model.consumables = JSON.parse($scope.model.consumables);
- // }
- // $scope.myDatalingbeiall = $scope.model.consumables;
- // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
- // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
- // }
- // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
- // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
- // // $scope.model.consumables = $scope.myData2all;
- // }
- // }
- // }, 100);
- //grid1
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions1 = {};
- $scope.gridOptions1.data = 'myDatalingbei';
- $scope.gridOptions1.enableColumnResizing = true;
- $scope.gridOptions1.enableFiltering = false;
- $scope.gridOptions1.enableGridMenu = false;
- $scope.gridOptions1.showGridFooter = true;
- $scope.gridOptions1.showColumnFooter = false;
- $scope.gridOptions1.fastWatch = true;
- $scope.gridOptions1.useExternalFiltering = true;
- $scope.gridOptions1.useExternalPagination = true;
- $scope.gridOptions1.paginationPageSizes = [10];
- $scope.gridOptions1.paginationPageSize = 10;
- $scope.gridOptions1.multiSelect = false;
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions1.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 120
- },
- {
- name: 'props.hw_cifilterClassic',
- displayName: '设备类型',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'props.hw_mingcheng',
- displayName: '设备名称',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'uuid',
- displayName: '设备编号',
- enableFiltering: false
- }
- ];
- $scope.myDatalingbeiall = [];
- $scope.gridOptions1.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- $scope.memoryfilterDatashe.idx = newPage - 1;
- $scope.memoryfilterDatashe.sum = pageSize;
- $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 20,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterDatashe = filtersData;
- // $scope.loadData(filtersData);
- });
- };
- $scope.interceptMydata = function (mydate, idx, sum) {
- return mydate.slice(idx * sum, (idx + 1) * sum)
- }
- $scope.removeshebei = function (item) {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance, scope) {
- $scope.title = '设备移除';
- $scope.connect = '确定要移除此设备?';
- $scope.consumptive = scope.selected.items;
- $scope.ok = function () {
- $modalInstance.close($scope.consumptive);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- }
- });
- modalInstance.result.then(function (selectedItem) {
- angular.forEach($scope.myDatalingbeiall, function (items, index) {
- if (items.id == selectedItem.id) {
- $scope.myDatalingbeiall.splice(index, 1);
- }
- })
- // $scope.myData3.push(selectedItem);
- $scope.model.consumables = $scope.myDatalingbeiall;
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
- $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
- for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
- $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
- }
- $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
- })
- }
- $scope.addshebei = function () {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
- controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myDatatwo';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'uuid',
- displayName: '内部编号',
- width: 175
- },
- {
- name: 'props.hw_mingcheng',
- displayName: '资产名称',
- width: 120
- },
- {
- name: 'props.hw_cifilterClassic',
- displayName: '资产类型',
- width: 80,
- enableFiltering: false
- },
- // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
- {
- name: 'props.hw_state',
- displayName: '资产状态',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'props.hwnw_area',
- displayName: '资产地点',
- width: 130,
- enableFiltering: false
- },
- {
- name: 'createtime',
- displayName: '申请时间',
- enableFiltering: false
- }
- ];
- // $scope.selectButtonClick
- var defaultFilterData = {
- // "assignee":2,
- // "sign":"basehwitndl",
- // "applicationForm": { "hw_state": "在线" },
- "hw_state": "在库",
- "idx": 0,
- "sum": 10
- };
- $scope.memoryfilterData = {
- // "assignee":2,
- // "sign":"basehwitndl",
- // "applicationForm": { "hw_state": "在线" },
- "hw_state": "在库",
- "idx": 0,
- "sum": 10
- }
- $scope.refreshData = function (style, filterData) {
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myDatatwo = [];
- // $scope.gridOptions['sum']=filterData.sum;
- api_cmdb.query(filterData).then(function (data) {
- // $scope.callsPending--;
- var filterData = $scope.memoryfilterData;
- var myDatatwo = Restangular.stripRestangular(data);
- $scope.gridOptions['totalItems'] = data.total;
- for (var i = 0; i < myDatatwo.data.node.length; i++) {
- myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
- }
- $scope.myDatatwo = myDatatwo.data.node;
- for (var i = 0; i < $scope.myDatatwo.length; i++) {
- $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- }, function () { });
- };
- $scope.refreshData('expand-right', defaultFilterData);
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- $scope.refreshData('expand-right', filtersData);
- //console.log(pageSize);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // $scope.selected.items.push(data.entity);
- //console.log(data);
- gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
- if (scope.isSelected) {
- scope.grid.appScope.selected.items.push(scope.entity)
- } else {
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
- scope.grid.appScope.selected.items.splice(i, 1);
- break;
- }
- }
- }
- $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
- });
- // });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
- // $scope.selected.items = data.entity;
- //console.log(data);
- var selectitem = [];
- selectitem = angular.copy($scope.selected.items);
- for (var j = 0; j < rows.length; j++) {
- if (rows[j].isSelected == true) {
- selectitem.push(rows[j].entity);
- } else {
- delete selectitem[j];
- // rows.splice(j, 1);
- }
- }
- $scope.selected.items = [];
- for (var i = 0; i < selectitem.length; i++) {
- if (selectitem[i]) {
- $scope.selected.items.push(selectitem[i]);
- }
- }
- });
- // gridApi.selection.on.selectAllRows = function(row) { //GridRow
- // // if (row.entity.age > 45) {
- // row.grid.api.selection.selectRow(row.entity); // 选中行
- // // }
- // };
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- // $scope.loadData(filtersData);
- });
- };
- $scope.onDblClick = function (data, event) {
- // $scope.selected.items = data.entity;
- $scope.selectButtonClick(data, event);
- };
- // $scope.loadData = function(filterData) {
- // // console.log("filtersData=111" + JSON.stringify(filterData))
- // items.fetchItems(filterData, APIService).then(function(data) {
- // var myDatatwo = Restangular.stripRestangular(data);
- // $scope.gridOptions.totalItems = myDatatwo.totalNum;
- // $scope.myDatatwo = myDatatwo.list;
- // });
- // };
- $scope.title = title;
- //树形图
- var apple_selected, tree, treedata_avm, treedata_geography;
- $scope.my_tree_handler = function (branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- api_cmdb.query({
- 'sign': classify
- }).then(function (data) {
- var myDatalingbei = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if (myDatalingbei.data && myDatalingbei.status == 200) {
- var ret = myDatalingbei.data;
- redrawSvg(myDatalingbei);
- }
- });
- };
- $scope.my_data = [];
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.my_tree = tree = {};
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.select_treedata = [];
- $scope.doing_async = true;
- api_configure_data.fetchDataList('ciclassify', {
- 'idx': 0,
- 'sum': 100
- }).then(function (result) {
- //console.log(result['list']);
- $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- $scope.doing_async = false;
- // tree.expand_all();
- //console.log(treelist);
- });
- };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.try_async_load();
- $scope.onFilterremove = function (item) {
- console.log(item)
- }
- $scope.searchdata = {};
- $scope.clear = function () {
- $scope.searchdata = {};
- $scope.cifilter_classic = {};
- $scope.try_async_load();
- var fildata = {
- idx: 0,
- sum: 10,
- 'hw_state': '在库'
- }
- $scope.memoryfilterData = fildata;
- $scope.refreshData('expand-right', fildata);
- }
- $scope.cifilter_classic = {};
- $scope.chiceIncident = function (item) {
- var fildata = defaultFilterData;
- // fildata.applicationForm = {};
- // sign: basehwnwswt
- if (item && item.id) {
- var classify = item.prefix.toLowerCase() + item.sign;
- fildata.sign = classify
- } else {
- delete fildata.sign
- }
- $scope.gridOptions.paginationCurrentPage = 1;
- var transitiondata = angular.copy(item);
- $scope.refreshData('expand-right', fildata);
- }
- $scope.applicadata = [];
- $scope.onFilterCallback = function (item) {
- var tempclassify = item.prefix.toLowerCase() + item.sign;
- api_configure_form.renderTabForm(tempclassify).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.applicadata = myData[0].form.fields;
- });
- // }
- }
- // $scope.loadData({
- // idx: 0,
- // sum: 10,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- // });
- $scope.selected = {
- items: []
- };
- $scope.ok = function () {
- // if(onDataCallback&&angular.isFunction(onDataCallback)){
- // onDataCallback($scope.selected.item, parentScope);
- // }
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg',
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- }
- return $scope.options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return $scope.options.templateOptions.label;
- },
- Restangular: function () {
- return $scope.options.templateOptions.Restangular;
- },
- APIService: function () {
- return $scope.options.templateOptions.ApiService;
- },
- onDataCallback: function () {
- return $scope.options.templateOptions.callback;
- },
- parentScope: function () {
- return $scope.options.templateOptions.that;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // console.log(selectedItem);
- // options.value(selectedItem);
- var filterData = $scope.memoryfilterDatashe;
- $scope.myDatalingbeiall = selectedItem;
- $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
- for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
- $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
- $scope.model.assets = $scope.myDatalingbeiall;
- $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
- // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
- // options.templateOptions.callback(selectedItem, options.templateOptions.that);
- // }
- // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
- // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
- // }
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- $scope.onDblClick = function (data, event) {
- $scope.selectButtonClick(data, event);
- };
- // $scope.loadData = function(filterData) {};
- // $scope.title = title;
- // $scope.loadData({
- // idx: 0,
- // sum: 20,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- // });
- $scope.selected = {
- items: []
- };
- //grid2
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions2 = {};
- $scope.gridOptions2.data = 'myDataone';
- $scope.gridOptions2.enableColumnResizing = true;
- $scope.gridOptions2.enableFiltering = false;
- $scope.gridOptions2.enableGridMenu = false;
- $scope.gridOptions2.showGridFooter = true;
- $scope.gridOptions2.showColumnFooter = false;
- $scope.gridOptions2.fastWatch = true;
- $scope.gridOptions2.useExternalFiltering = true;
- $scope.gridOptions2.useExternalPagination = true;
- $scope.gridOptions2.paginationPageSizes = [10];
- $scope.gridOptions2.paginationPageSize = 10;
- $scope.gridOptions2.multiSelect = false;
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions2.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 120
- },
- {
- name: 'name',
- displayName: '耗材名称',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'model',
- displayName: '品牌/型号',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'Specifications',
- displayName: '规格',
- width: 150,
- enableFiltering: false
- },
- {
- name: 'sum',
- displayName: '领用数量',
- enableFiltering: false
- }
- ];
- // $scope.selectButtonClick
- $scope.gridOptions2.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- // $scope.loadData(filtersData);
- $scope.memoryfilterDatahao.idx = newPage - 1;
- $scope.memoryfilterDatahao.sum = pageSize;
- $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items.push(data.entity);
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items.push(data.entity);
- //console.log(data);
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterDatahao = filtersData;
- $scope.loadData(filtersData);
- });
- };
- $scope.removehaocai = function (item) {
- event.preventDefault();
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
- // controller: function($scope, $modalInstance) {
- // $scope.title = "修改耗材数量";
- // $scope.consumptive = item;
- // $scope.ok = function() {
- // $modalInstance.close($scope.consumptive);
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // size: 'sm'
- // });
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance, scope) {
- $scope.title = '耗材移除';
- $scope.connect = '确定要移除此设备?';
- $scope.consumptive = scope.selected.items[0];
- $scope.ok = function () {
- $modalInstance.close($scope.consumptive);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // angular.forEach($scope.myData3, function(items, index) {
- // if (items.id == selectedItem.id) {
- // $scope.myData3[index] = selectedItem;
- // }
- // })
- // $scope.model.applicationForm.consumables = $scope.myData3;
- angular.forEach($scope.myDataoneall, function (items, index) {
- if (items.id == selectedItem.id) {
- $scope.myDataoneall.splice(index, 1);
- }
- })
- for (var i = 0; i < $scope.myDataoneall.length; i++) {
- $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
- }
- $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
- $scope.model.consumables = $scope.myDataoneall;
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
- $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
- $scope.selected = {
- items: []
- };
- })
- }
- $scope.haocaiadd = function () {
- event.preventDefault();
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
- controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
- $scope.haocainame = [];
- $scope.pinpai = [];
- $scope.guige = [];
- $scope.consumptive = {};
- $scope.consumpall = {};
- $scope.title = "添加耗材";
- api_wechatfile.getDictionaryForList({
- "key": "haocaifenlei"
- }).then(function (data) {
- $scope.haocainame = data;
- })
- $scope.clearNoNum = function (obj, attr) {
- //先把非数字的都替换掉,除了数字和.
- obj[attr] = obj[attr].replace(/[^\d.]/g, "");
- //必须保证第一个为数字而不是.
- obj[attr] = obj[attr].replace(/^\./g, "");
- //保证只有出现一个.而没有多个.
- obj[attr] = obj[attr].replace(/\.{2,}/g, "");
- //保证.只出现一次,而不能出现两次以上
- obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- //小于最大值
- if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
- alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
- obj[attr] = '';
- }
- }
- $scope.onChange = function (parent) {
- $scope.consumptive.model = {};
- $scope.consumptive.Specifications = {};
- api_wechatfile.getDictionaryForList({
- "key": "pinpai",
- "parent": parent.id
- }).then(function (data) {
- $scope.pinpai = data;
- })
- api_wechatfile.getDictionaryForList({
- "key": "guige",
- "parent": parent.id
- }).then(function (data) {
- $scope.guige = data;
- })
- }
- $scope.onChangesum = function (item) {
- if (item.name && item.model.id && item.Specifications.id) {
- $scope.consumptive.sum = "";
- var data1 = {
- "idx": 0,
- "sum": 10,
- "consumable": {
- "name": item.name.name,
- "brandModel": item.model.name,
- "specification": item.Specifications.name
- }
- }
- api_cmdb3.fetchDataList('consumable', data1).then(function (data) {
- if (data.status == 200 && data.list.length > 0) {
- var myData = data.list;
- $scope.consumpall = myData[0];
- $scope.maxsum = myData[0].inventoryNum;
- } else {
- SweetAlert.swal({
- title: "不存在该耗材",
- text: "请检查库存后重新填写!",
- type: "error"
- });
- }
- });
- }
- }
- $scope.addhaocai = function () {
- $modalInstance.dismiss('cancel');
- scope.haocaiopen($scope.consumptive);
- }
- $scope.ok = function (item) {
- var items = {};
- // if (item.name && item.model && item.Specifications && item.sum) {
- // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
- // $scope.consumpall.model = $scope.consumpall.brandModel;
- // $scope.consumpall.Specifications = $scope.consumpall.specification;
- // $scope.consumpall.sum = item.sum;
- // delete $scope.consumpall.brandModel;
- // delete $scope.consumpall.specification;
- // $modalInstance.close($scope.consumpall);
- // } else {
- // SweetAlert.swal({
- // title: "数据填写不完整!",
- // text: "请检查数据然后提交!",
- // type: "error"
- // });
- // }
- var isold = false;
- if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
- for (var i = 0; i < scope.myDataoneall.length; i++) {
- if (scope.myDataoneall[i].id == $scope.consumpall.id) {
- isold = true;
- }
- }
- if (isold) {
- SweetAlert.swal({
- title: "该耗材已添加!",
- text: "请不要重复添加耗材!",
- type: "error"
- });
- } else {
- $scope.consumpall.model = $scope.consumpall.brandModel;
- $scope.consumpall.Specifications = $scope.consumpall.specification;
- $scope.consumpall.sum = item.sum;
- delete $scope.consumpall.brandModel;
- delete $scope.consumpall.specification;
- $modalInstance.close($scope.consumpall);
- }
- } else {
- SweetAlert.swal({
- title: "数据填写不完整!",
- text: "请检查数据然后提交!",
- type: "error"
- });
- }
- // $modalInstance.close(item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- $scope.myDataoneall.push(selectedItem);
- for (var i = 0; i < $scope.myDataoneall.length; i++) {
- $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
- }
- // $scope.model.consumables = $scope.myDataone;
- $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
- $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
- $scope.model.consumables = $scope.myDataoneall;
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
- })
- }
- $scope.onDblClick = function (data, event) {
- $scope.selectButtonClick(data, event);
- };
- $scope.memoryfilterDatahao = {
- "idx": 0,
- "sum": 10,
- // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
- }
- $scope.myDataone = [];
- $scope.loadData = function (filterData) { };
- // $scope.title = title;
- $scope.ldloading = {};
- $scope.selected = {
- items: []
- };
- if ($scope.$parent.$parent.$parent.model.gettype) {
- if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
- if ($scope.model.assets) {
- if (JSON.stringify($scope.model.assets) == "{}") {
- $scope.model.assets = []
- } else {
- $scope.model.assets = JSON.parse($scope.model.assets);
- }
- $scope.myDatalingbeiall = $scope.model.assets;
- for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
- $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
- }
- $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
- $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
- }
- if ($scope.model.consumables) {
- if (JSON.stringify($scope.model.consumables) == "{}") {
- $scope.model.consumables = []
- } else {
- $scope.model.consumables = JSON.parse($scope.model.consumables);
- }
- $scope.myDataoneall = $scope.model.consumables;
- for (var i = 0; i < $scope.myDataoneall.length; i++) {
- $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
- }
- $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
- $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
- }
- if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
- $scope.options.templateOptions.getpush({
- "hao": true,
- "gu": true
- });
- } else {
- $scope.options.templateOptions.getpush({
- "hao": true
- });
- }
- } else {
- if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
- $scope.options.templateOptions.getpush({
- "gu": true
- });
- }
- }
- }
- }]
- });
- formlyConfigProvider.setType({
- name: 'ui-panel',
- templateUrl: 'assets/views/customform/tpl/ui-panel.html'
- });
- formlyConfigProvider.setType({
- name: 'ui-currentuser',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-username.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // link: function() {}
- }
- };
- },
- controller: ['$scope', function ($scope) {
- if ($scope.options.templateOptions.user) {
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
- // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
- // }
- $scope.$parent.$parent.$parent.model['directClose'] = false;
- $scope.$parent.$parent.$parent.model['directClose'] = false;
- $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
- }
- $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }
- }]
- });
- //仪表盘
- //待处理变更列表
- formlyConfigProvider.setType({
- name: 'ui-ngpchangetable',
- templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
- // var filterData = {
- // "assignee": $rootScope.user.id,
- // "searchtype": "all",
- // "idx": "0",
- // "sum": "10"
- // };
- var filterData = {
- "idx": "0",
- "sum": "10",
- "assignee": 2,
- "searchType": "todo"
- }
- $scope.incidentprocess = function (item) {
- $state.go('app.wt_change.add', {
- taskId: item.taskId,
- processInstanceId: item.processInstanceId
- });
- }
- $scope.more = function () {
- $state.go('app.wt_change.list', {})
- }
- api_bpm_domain.fetchtask('bpm_change', filterData).then(function (data) {
- if (data.data) {
- $scope.myData = data.data;
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- console.log($scope.$parent.$parent.$parent.$parent)
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- }]
- });
- //待处理问题列表
- formlyConfigProvider.setType({
- name: 'ui-ngproblemtable',
- templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
- var filterData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchtype": "todo",
- "idx": 0,
- "sum": 10
- };
- $scope.incidentprocess = function (item) {
- $state.go('app.wt_change.add', {
- taskId: item.taskId,
- processInstanceId: item.processInstanceId
- });
- }
- $scope.more = function () {
- $state.go('app.wt_change.list', {})
- }
- api_bpm_data.fetchDataList('changeclassify', filterData).then(function (data) {
- if (data.data) {
- $scope.myData = data.data;
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- console.log($scope.$parent.$parent.$parent.$parent)
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- }]
- });
- //待处理事件列表
- formlyConfigProvider.setType({
- name: 'ui-ngtable',
- templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
- var filterData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchtype": "done",
- "idx": 0,
- "sum": 10
- };
- $scope.incidentprocess = function (item) {
- $state.go('app.incident.editor', {
- taskId: item.taskId,
- processInstanceId: item.processInstanceId
- });
- }
- $scope.more = function () {
- $state.go('app.incident.list', {})
- }
- api_bpm_domain.fetchtask('bpm_incident', filterData).then(function (data) {
- if (data.data) {
- $scope.myData = data.data;
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- console.log($scope.$parent.$parent.$parent.$parent)
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- }]
- });
- //知识库列表
- formlyConfigProvider.setType({
- name: 'ui-knowledge',
- templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$modal', '$timeout', 'api_solution', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, api_solution, $rootScope, ngTableParams, $filter, $state) {
- var filterData = {
- "key": "null",
- "pageIndex": 0,
- "pageSum": 6,
- "status": 0,
- "userId": $rootScope.user.id
- };
- $scope.model.removereport = false;
- $scope.removes = function () {
- $scope.model.removereport = true;
- }
- $scope.more = function () {
- $state.go('app.knowledge.manager', {});
- }
- api_solution.findSolutionByKeys(filterData).then(function (data) {
- if (data.status == 200) {
- $scope.myData = data.list
- }
- })
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- }]
- });
- //公告列表
- formlyConfigProvider.setType({
- name: 'ui-ngnotice',
- templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
- var filterData = {
- "idx": 0,
- "sum": 10
- };
- // $scope.$scope.model.className = "col-xs-12";
- api_user_data.fetchDataList('notice', filterData).then(function (data) {
- if (data) {
- $scope.myData = data.data;
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- $scope.more = function () {
- $state.go('app.system.notice.list', {});
- }
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- }]
- });
- //事件统计图
- formlyConfigProvider.setType({
- name: 'ui-incidentreport',
- templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function ($scope, $modal, moment, api_report, $cookieStore) {
- api_report.getLicenseKey().then(function (response) {
- $cookieStore.put('Auth-Token', response.token);
- $scope.try_async_load();
- });
- $scope.try_async_load = function () {
- $scope.my_data = [];
- api_report.list().then(function (response) {
- var dataList = response;
- getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
- $scope.repoRoot.name = "事件报表"
- convertRepoObject($scope.repoRoot);
- $scope.my_data.push($scope.repoRoot);
- });
- };
- var workspace = {};
- $scope.repoRoot = null;
- function getRepoRoot(repo, path) {
- angular.forEach(repo, function (value, key) {
- if (value.path == path) {
- $scope.repoRoot = value;
- } else {
- if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
- getRepoRoot(value.repoObjects, path);
- } else {
- }
- }
- });
- }
- function convertRepoObject(repo) {
- if (angular.isArray(repo)) {
- angular.forEach(repo, function (value, key) {
- convertRepoObject(value);
- })
- } else {
- if (angular.isDefined(repo.name)) {
- if (repo.name.indexOf(".") >= 0) {
- repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
- } else {
- repo.label = repo.name;
- }
- //delete repo.name;
- }
- if (angular.isDefined(repo.repoObjects)) {
- repo.children = [];
- repo.children = repo.repoObjects;
- delete repo.repoObjects;
- convertRepoObject(repo.children);
- }
- }
- }
- function parseDateParameter(parameters) {
- var result = undefined;
- if (angular.isArray(parameters)) {
- // angular.forEach(parmeters,function(param){
- // param.
- // })
- } else {
- result = {};
- for (var k in parameters) {
- if (k.indexOf("Date") > 0) {
- if (angular.isString(parameters[k])) {
- result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
- //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
- }
- }
- }
- }
- return result;
- }
- function ConvertDateParameter(parameters) {
- var result = undefined;
- if (angular.isArray(parameters)) {
- //
- } else {
- result = {};
- for (var k in parameters) {
- if (k.indexOf("Date") > 0) {
- if (angular.isDate(parameters[k])) {
- result[k] = moment(parameters[k]).format("YYYYMMDD");
- } else if (angular.isString(parameters[k])) {
- result[k] = parameters[k];
- }
- }
- }
- }
- return result;
- }
- var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
- var queryUUID;
- function genUUID() {
- var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
- function (c) {
- var r = Math.random() * 16 | 0,
- v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- }).toUpperCase();
- return uuid;
- }
- queryUUID = genUUID();
- var pathincidenttimekey = [];
- var incidenttime = {
- 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
- 'endtimes': moment(new Date()).format('YYYYMMDD')
- };
- var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
- var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
- var averages = [
- [thisdaymine - 86400000 * 14, 0],
- [thisdaymine - 86400000 * 13, 0],
- [thisdaymine - 86400000 * 12, 0],
- [thisdaymine - 86400000 * 11, 0],
- [thisdaymine - 86400000 * 10, 0],
- [thisdaymine - 86400000 * 9, 0],
- [thisdaymine - 86400000 * 8, 0],
- [thisdaymine - 86400000 * 7, 0],
- [thisdaymine - 86400000 * 6, 0],
- [thisdaymine - 86400000 * 5, 0],
- [thisdaymine - 86400000 * 4, 0],
- [thisdaymine - 86400000 * 3, 0],
- [thisdaymine - 86400000 * 2, 0],
- [thisdaymine - 86400000 * 1, 0],
- [thisdaymine, 0]
- ];
- var getreportdata = function (incidenttime, path) {
- api_report.getMdx(path, queryUUID).then(function (response) {
- var mdxquery = response;
- workspace.query = mdxquery;
- workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
- workspace.query.parameters.paramDateTo = incidenttime.endtimes;
- $scope.parameters = parseDateParameter(workspace.query.parameters);
- weekuser(mdxquery);
- });
- }
- getreportdata(incidenttime, incidentchart);
- var weekuser = function (mdxquery) {
- var key = [];
- api_report.execute(mdxquery).then(function (data) {
- $scope.rheaders = [];
- $scope.rRows = [];
- var reportData = data;
- if (reportData.cellset == null || reportData.cellset.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!"
- } else {
- angular.forEach(reportData.cellset, function (item, i) {
- angular.forEach(averages, function (index, j) {
- // angular.forEach(averages, function(item, index) {
- if (item.length > 1 && i > 0 && item[1].value != '') {
- if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
- index[1] = Number(item[1].value);
- }
- // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
- }
- // })
- })
- })
- incidentchartfun(averages);
- }
- })
- }
- var incidentchartfun = function (incidentchartkey) {
- // $scope.isMaskincident = false;
- Highcharts.chart('incidentchart', {
- title: {
- text: '事件近15天趋势图'
- },
- xAxis: {
- type: 'datetime',
- labels: {
- align: 'left',
- step: 1
- }
- },
- yAxis: {
- title: {
- text: null
- }
- },
- tooltip: {
- crosshairs: true,
- shared: true,
- valueSuffix: '条'
- },
- legend: {},
- series: [{
- name: '生成事件',
- data: incidentchartkey,
- zIndex: 1,
- marker: {
- fillColor: 'white',
- lineWidth: 2,
- lineColor: Highcharts.getOptions().colors[0]
- }
- }]
- });
- }
- $scope.data = {
- labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
- datasets: [{
- label: '新增事件数量',
- fillColor: 'rgba(220,220,220,0.2)',
- strokeColor: 'rgba(220,220,220,1)',
- pointColor: 'rgba(220,220,220,1)',
- pointStrokeColor: '#fff',
- pointHighlightFill: '#fff',
- pointHighlightStroke: 'rgba(220,220,220,1)',
- data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
- },
- {
- label: '已解决事件数量',
- fillColor: 'rgba(151,187,205,0.2)',
- strokeColor: 'rgba(151,187,205,1)',
- pointColor: 'rgba(151,187,205,1)',
- pointStrokeColor: '#fff',
- pointHighlightFill: '#fff',
- pointHighlightStroke: 'rgba(151,187,205,1)',
- data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
- }
- ]
- };
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- var addDatas = 0;
- var resolve = 0;
- for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
- addDatas = addDatas + $scope.data.datasets[0].data[i];
- }
- for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
- resolve = resolve + $scope.data.datasets[1].data[i];
- }
- $scope.resolution = (resolve / addDatas * 100).toFixed(2);
- $scope.opt = {
- maintainAspectRatio: false,
- // Sets the chart to be responsive
- responsive: true,
- ///Boolean - Whether grid lines are shown across the chart
- scaleShowGridLines: true,
- //String - Colour of the grid lines
- scaleGridLineColor: 'rgba(0,0,0,.05)',
- //Number - Width of the grid lines
- scaleGridLineWidth: 1,
- //Boolean - Whether the line is curved between points
- bezierCurve: false,
- //Number - Tension of the bezier curve between points
- bezierCurveTension: 0.4,
- //Boolean - Whether to show a dot for each point
- pointDot: true,
- //Number - Radius of each point dot in pixels
- pointDotRadius: 4,
- //Number - Pixel width of point dot stroke
- pointDotStrokeWidth: 1,
- //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
- pointHitDetectionRadius: 20,
- //Boolean - Whether to show a stroke for datasets
- datasetStroke: true,
- //Number - Pixel width of dataset stroke
- datasetStrokeWidth: 2,
- //Boolean - Whether to fill the dataset with a colour
- datasetFill: true,
- // Function - on animation progress
- onAnimationProgress: function () { },
- // Function - on animation complete
- onAnimationComplete: function () { },
- //String - A legend template
- legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
- };
- angular.extend($scope.options, $scope.opt)
- $scope.datamonth = {
- labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
- datasets: [{
- label: '新增事件数量',
- fillColor: 'rgba(220,220,220,0.5)',
- strokeColor: 'rgba(220,220,220,0.8)',
- highlightFill: 'rgba(220,220,220,0.75)',
- highlightStroke: 'rgba(220,220,220,1)',
- data: [65, 59, 80, 81, 56, 55]
- },
- {
- label: '已解决事件数量',
- fillColor: 'rgba(151,187,205,0.5)',
- strokeColor: 'rgba(151,187,205,0.8)',
- highlightFill: 'rgba(151,187,205,0.75)',
- highlightStroke: 'rgba(151,187,205,1)',
- data: [28, 48, 40, 19, 86, 27]
- }
- ]
- };
- // Chart.js Options
- $scope.taption = {
- maintainAspectRatio: false,
- // Sets the chart to be responsive
- responsive: true,
- //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
- scaleBeginAtZero: true,
- //Boolean - Whether grid lines are shown across the chart
- scaleShowGridLines: true,
- //String - Colour of the grid lines
- scaleGridLineColor: "rgba(0,0,0,.05)",
- //Number - Width of the grid lines
- scaleGridLineWidth: 1,
- //Boolean - If there is a stroke on each bar
- barShowStroke: true,
- //Number - Pixel width of the bar stroke
- barStrokeWidth: 2,
- //Number - Spacing between each of the X value sets
- barValueSpacing: 5,
- //Number - Spacing between data sets within X values
- barDatasetSpacing: 1,
- //String - A legend template
- legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
- };
- }]
- });
- //排版日历
- formlyConfigProvider.setType({
- name: 'ui-dashcalendar',
- templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // relationAction: function() {
- // options.hideExpression = true
- // }
- }
- };
- },
- controller: ["$rootScope", "$scope", "$modal", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", "$state", function ($rootScope, $scope, $modal, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data, $state) {
- var loginUser = $rootScope.user;
- calendarConfig.dateFormatter = 'moment';
- calendarConfig.i18nStrings.eventsLabel = '排班描述';
- calendarConfig.i18nStrings.timeLabel = '时间';
- calendarConfig.i18nStrings.weekNumber = '{week}周';
- calendarConfig.allDateFormats = {
- angular: {
- date: {
- hour: 'ha',
- day: 'd MMM',
- month: 'MMMM',
- weekDay: 'EEEE',
- time: 'HH:mm',
- datetime: 'MMM d, h:mm a'
- },
- title: {
- day: 'yyyy MMMM EEEE d',
- week: '{year}年第{week}周',
- month: 'yyyy MMMM',
- year: 'yyyy'
- }
- },
- moment: {
- date: {
- hour: 'ha',
- day: 'MMMDD日',
- month: 'MMMM',
- weekDay: 'dddd',
- time: 'HH:mm',
- datetime: 'MMM D, h:mm a'
- },
- title: {
- day: 'YYYY年MMMMDD日, dddd ',
- week: '{year}年第{week}周',
- month: 'YYYY年MMMM',
- year: 'YYYY'
- }
- }
- };
- moment.locale('zh_cn', {
- months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
- monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
- weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
- weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
- weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
- longDateFormat: {
- LT: 'Ah点mm分',
- LTS: 'Ah点m分s秒',
- L: 'YYYY-MM-DD',
- LL: 'YYYY年MMMD日',
- LLL: 'YYYY年MMMD日Ah点mm分',
- LLLL: 'YYYY年MMMD日ddddAh点mm分',
- l: 'YYYY-MM-DD',
- ll: 'YYYY年MMMD日',
- lll: 'YYYY年MMMD日Ah点mm分',
- llll: 'YYYY年MMMD日ddddAh点mm分'
- },
- meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
- meridiemHour: function (hour, meridiem) {
- if (hour === 12) {
- hour = 0;
- }
- if (meridiem === '凌晨' || meridiem === '早上' ||
- meridiem === '上午') {
- return hour;
- } else if (meridiem === '下午' || meridiem === '晚上') {
- return hour + 12;
- } else {
- // '中午'
- return hour >= 11 ? hour : hour + 12;
- }
- },
- meridiem: function (hour, minute, isLower) {
- var hm = hour * 100 + minute;
- if (hm < 600) {
- return '凌晨';
- } else if (hm < 900) {
- return '早上';
- } else if (hm < 1130) {
- return '上午';
- } else if (hm < 1230) {
- return '中午';
- } else if (hm < 1800) {
- return '下午';
- } else {
- return '晚上';
- }
- },
- calendar: {
- sameDay: function () {
- return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
- },
- nextDay: function () {
- return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
- },
- lastDay: function () {
- return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
- },
- nextWeek: function () {
- var startOfWeek, prefix;
- startOfWeek = moment().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
- return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
- },
- lastWeek: function () {
- var startOfWeek, prefix;
- startOfWeek = moment().startOf('week');
- prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
- return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
- },
- sameElse: 'LL'
- },
- ordinalParse: /\d{1,2}(日|月|周)/,
- ordinal: function (number, period) {
- switch (period) {
- case 'd':
- case 'D':
- case 'DDD':
- return number + '日';
- case 'M':
- return number + '月';
- case 'w':
- case 'W':
- return number + '周';
- default:
- return number;
- }
- },
- relativeTime: {
- future: '%s内',
- past: '%s前',
- s: '几秒',
- m: '1 分钟',
- mm: '%d 分钟',
- h: '1 小时',
- hh: '%d 小时',
- d: '1 天',
- dd: '%d 天',
- M: '1 个月',
- MM: '%d 个月',
- y: '1 年',
- yy: '%d 年'
- },
- week: {
- // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
- dow: 1, // Monday is the first day of the week.
- doy: 4 // The week that contains Jan 4th is the first week of the year.
- }
- });
- var date = new Date();
- var d = date.getDate();
- var m = date.getMonth();
- var y = date.getFullYear();
- var filterData = {
- "userId": loginUser.id,
- "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
- "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
- };
- var load = $scope.load = function (filterData) {
- api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function (response) {
- if (response.status == 200) {
- $scope.events = [];
- var myData = response.list;
- angular.forEach(myData, function (item) {
- var eventTemp = {};
- eventTemp.title = item.description;
- eventTemp.type = item.scheduleClass.code;
- eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
- eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
- eventTemp.startTime = item['scheduleOrderDTO'].startTime;
- eventTemp.endTime = item['scheduleOrderDTO'].endTime;
- //eventTemp.ends_at = moment(item.endTime).toDate();
- eventTemp.id = item.id;
- eventTemp.deletable = false;
- eventTemp.user = item.user;
- $scope.events.push(eventTemp);
- })
- }
- });
- }
- // var load = $scope.load = function(filterData){
- // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
- // console.log("response="+JSON.stringify(response));
- // if(response.status==200){
- // $scope.events = [];
- // console.log(response.list);
- // var myData = response.list;
- // angular.forEach(myData,function(item){
- // var eventTemp = {};
- // eventTemp.title = item.description;
- // eventTemp.type = item.scheduleClass.code;
- // eventTemp.startsAt = moment(item.startTime).toDate();
- // eventTemp.endsAtTime = moment(item.endTime).toDate();
- // eventTemp.startTime = item.startTime;
- // eventTemp.endTime = item.endTime;
- // //eventTemp.ends_at = moment(item.endTime).toDate();
- // eventTemp.id = item.id;
- // eventTemp.deletable = false;
- // eventTemp.users = item.users;
- // $scope.events.push(eventTemp);
- // // console.log("eventTemp="+JSON.stringify(eventTemp));
- // })
- // }
- // });
- // }
- $scope.scheduleClass = {};
- var convertEvent = function (scheduleorder) {
- var eventTemp = {};
- eventTemp.title = scheduleorder.description;
- eventTemp.type = scheduleorder.scheduleClass.code;
- eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
- //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
- eventTemp.id = scheduleorder.id;
- eventTemp.user = scheduleorder.user;
- eventTemp.deletable = false;
- return eventTemp;
- }
- // var convertEvent = function(scheduleorder){
- // var eventTemp = {};
- // eventTemp.title = scheduleorder.description;
- // eventTemp.type = scheduleorder.scheduleClass.code;
- // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
- // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
- // eventTemp.id = scheduleorder.id;
- // eventTemp.users = scheduleorder.users;
- // eventTemp.deletable = false;
- // return eventTemp;
- // }
- api_bpm_schedule.getScheduleClass().then(function (response) {
- if (response.status == 200) {
- var scheduleClassList = response.list;
- angular.forEach(scheduleClassList, function (item) {
- item.startsAt = moment(item.startTime).format('HH:mm:ss');
- item.endsAt = moment(item.endTime).format('HH:mm:ss');
- // console.log("item.startsAt="+JSON.stringify(item.startsAt))
- // console.log("item.endsAt="+JSON.stringify(item.endsAt))
- $scope.scheduleClass[item['code']] = item;
- })
- }
- })
- $scope.events = [];
- $scope.calendarView = 'month';
- //$scope.calendarDay = new Date();
- $scope.calendarDate = moment().startOf('month').toDate();
- $scope.timeLabel = "时间";
- $scope.eventLabel = "描述";
- function showModal(action, event) {
- // console.log("action="+JSON.stringify(action))
- var modalInstance = $aside.open({
- templateUrl: 'scheduleEvent.html',
- placement: 'right',
- size: 'sm',
- backdrop: true,
- controller: function ($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
- $scope.$modalInstance = $modalInstance;
- $scope.action = action;
- $scope.event = event;
- $scope.scheduleClassic = scheduleClass;
- $scope.$watch('event.type', function (newvalue, oldvalue) {
- // if(oldvalue == newvalue) return;
- // if(scheduleClass[newvalue]){
- var sm = MementFormat(scheduleClass[newvalue].startTime);
- var em = MementFormat(scheduleClass[newvalue].endTime);
- console.log("sm=" + JSON.stringify(sm))
- event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
- console.log("event.starts_at=" + JSON.stringify(event.starts_at))
- if (sm.hour() > em.hour()) {
- event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- console.log("event.ends_at=" + JSON.stringify(event.starts_at))
- } else {
- event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- console.log("event.ends_at=" + JSON.stringify(event.ends_at))
- }
- // }
- });
- // $scope.ok = function (event) {
- // console.log("event="+JSON.stringify(event))
- // event.action = action;
- // $modalInstance.close(event);
- // };
- $scope.cancel = function (event) {
- $modalInstance.dismiss();
- };
- var acUserSelect = $scope.refreshUser = function (key) {
- //for test
- // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
- // return;
- var data = {
- "idx": "0",
- "sum": "5"
- };
- if (key) {
- data['user'] = {
- 'name': key
- };
- }
- APIService.fetchDataList('user', data).then(function (response) {
- if (response) {
- if (response.status = 200) {
- $scope.users = response.list;
- console.log($scope.users);
- }
- }
- })
- };
- if (angular.isDefined(event.users) && event.users.length > 0) {
- }
- $scope.users = [event.user];
- acUserSelect();
- },
- resolve: {
- scheduleClass: function () {
- return $scope.scheduleClass;
- },
- APIService: function () {
- return api_user_data;
- },
- MementFormat: function () {
- return moment;
- }
- }
- });
- modalInstance.result.then(function (selectedEvent) {
- if (selectedEvent.action == 'Clicked') {
- // var data = {
- // "scheduleorder":{
- // "id":selectedEvent.id,
- // "description":selectedEvent.title,
- // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
- // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
- // "users":selectedEvent.users,
- // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
- // }
- // };
- // api_bpm_schedule.update(data).then(function(response){
- // if(response.status==200){
- // SweetAlert.swal({
- // title: "操作成功!",
- // text: "排班更新成功!",
- // type: "succes"
- // });
- // angular.forEach($scope.events,function(item){
- // if(item.id==selectedEvent.id){
- // item = selectedEvent;
- // }
- // })
- // }else{
- // SweetAlert.swal({
- // title: "操作失败",
- // text: "排班更新失败,请稍后重试!",
- // type: "error"
- // })
- // }
- // })
- } else {
- //
- }
- });
- }
- $scope.moment = function (string) {
- return moment(string);
- }
- $scope.eventClicked = function (event) {
- // console.log("event="+JSON.stringify(event))
- showModal('Clicked', event);
- };
- $scope.eventEdited = function (event) {
- showModal('Edited', event);
- };
- var updateView = function (newvalue, oldvalue) {
- if (oldvalue == newvalue) return;
- var timeStart, timeEnd, timeStartSpan, timeEndSpan;
- if ($scope.calendarView == "year") {
- } else if ($scope.calendarView == "month") {
- timeStart = moment(newvalue).startOf('month');
- timeEnd = moment(newvalue).endOf('month');
- } else if ($scope.calendarView == "week") {
- timeStart = moment(newvalue).startOf('week');
- timeEnd = moment(newvalue).endOf('week');
- } else if ($scope.calendarView == "Day") {
- timeStart = moment(newvalue).startOf('day');
- timeEnd = moment(newvalue).endOf('day');
- }
- timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
- timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
- filterData["startTime"] = timeStartSpan;
- filterData["endTime"] = timeEndSpan;
- load(filterData);
- }
- $scope.$watch('calendarDate', updateView)
- $scope.next = function () {
- $scope.calendarControl.next();
- }
- $scope.prev = function () {
- $scope.calendarControl.prev();
- }
- $scope.setCalendarToToday = function () {
- $scope.calendarDay = new Date();
- };
- $scope.toggle = function ($event, field, event) {
- $event.preventDefault();
- $event.stopPropagation();
- event[field] = !event[field];
- };
- $scope.load(filterData);
- $scope.more = function () {
- $state.go('app.scheduling.myscheduling', {});
- }
- $scope.removes = function () {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, $modalInstance) {
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm'
- });
- modalInstance.result.then(function () {
- for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
- if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
- // $scope.resonseform.fields.push($scope.responseData.fields[i]);
- $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
- break;
- }
- }
- var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
- $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
- }
- })
- }
- }]
- });
- //空格组件
- formlyConfigProvider.setType({
- name: 'ui-black',
- /*extends: 'input',*/
- template: '<div class="input-group col-xs-12" style="height:80px"></div>',
- });
- //请求人最近事件
- formlyConfigProvider.setType({
- name: 'ui-recentIncident',
- templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
- controller: ['$scope', '$modal', 'api_solution', function ($scope, $modal, api_solution) {
- var filterData = {
- 'incident': {
- 'requester': {
- 'id': ''
- }
- },
- idx: 0,
- sum: 3
- };
- setInterval(function () {
- if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
- var requester = $scope.model.requester;
- if (requester != null && angular.isDefined(requester.id)) {
- filterData.incident.requester.id = $scope.model.requester.id;
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- if (modelData.status == 200) {
- $scope.lastrequst = modelData.list;
- }
- });
- requester = null
- } else { }
- } else { }
- }, 1000);
- $scope.detail = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/detailincident.html',
- controller: function ($scope, $modalInstance) {
- $scope.entity = {};
- $scope.entity = data;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg',
- });
- }
- }]
- });
- //参数列表
- formlyConfigProvider.setType({
- name: "ui-listinput",
- templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) {
- }]
- });
- //时间段控件(分)
- formlyConfigProvider.setType({
- name: 'ui-timeslot',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
- controller: ['$scope', function ($scope) { }]
- });
- //优先级级联-逾期时间
- formlyConfigProvider.setType({
- name: 'ui-overtime',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
- controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
- var filteData = {};
- var datas = {}
- setInterval(function () {
- if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
- filteData = "L" + $scope.model.priority.id;
- datas = $scope.model.priority.id;
- // console.log($scope.options.templateOptions)
- api_bpm_domain.expectedTime(filteData).then(function (requester) {
- // var overtime=requester.date;
- if (requester.state == 200) {
- // if($scope.options.key=="date"){
- $scope.model[$scope.options.key] = requester.date
- // }
- }
- })
- }
- }, 1000);
- }]
- });
- formlyConfigProvider.setType({
- name: 'ui-responsetime',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
- controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
- var filteData = {};
- var datas = {}
- setInterval(function () {
- if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
- filteData = "L" + $scope.model.priority.id;
- datas = $scope.model.priority.id;
- // console.log($scope.options.templateOptions)
- api_bpm_domain.expectedTime(filteData).then(function (requester) {
- // var overtime=requester.date;
- if (requester.state == 200) {
- var keyName = {};
- // $scope.model.overdueTime = requester.date;
- if ($scope.options.key == "expectIntroTime") {
- keyName = "resolveTime";
- } else if ($scope.options.key == "expectResponseTime") {
- keyName = "responseTime";
- }
- $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
- // }
- console.log($scope.$parent.$parent.$parent.model)
- }
- if (requester.date1) {
- $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
- $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
- $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
- $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
- }
- })
- }
- }, 1000);
- }]
- });
- //知识库按钮组件
- formlyConfigProvider.setType({
- name: 'ui-discasecade',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- relationAction: function (fields, modelscope, item) { }
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- // return value = "true";
- }
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.searchField = $scope.options.model[$scope.options.key];
- $scope.searchData = "";
- $scope.onChangeadd = function (searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- $scope.requester = requesdata;
- }
- $scope.refreshUseradd = function (searchKey) { //主题搜索
- $scope.searchData = searchKey;
- reashdata($scope.searchData);
- }
- $scope.getMydata = function (x) {
- $scope.model[$scope.options.key] = JSON.parse(x).title;
- $scope.searchField = $scope.model[$scope.options.key];
- }
- $scope.getMydataone = function (x) {
- $scope.model[$scope.options.key] = x;
- $scope.searchField = $scope.model[$scope.options.key];
- }
- $scope.fildata = {
- "idx": 0,
- "sum": 10
- // 'incident': { 'tilte': item }
- }
- function reashdata(item) {
- if (item && item != "") {
- angular.extend($scope.fildata, {
- 'incident': {
- 'title': item
- }
- })
- } else {
- delete $scope.fildata.incident;
- }
- api_bpm_data.fetchDataList('incident', $scope.fildata).then(function (response) {
- if (response) {
- if (response.status = 200) {
- var myData = response;
- $scope.myData = myData.list;
- }
- }
- })
- }
- function delHtmlTag(str) {
- return str.replace(/<[^>]+>/g, "");
- }
- // reashdata();
- var changedata = {};
- setInterval(function () {
- if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
- $scope.searchData = {};
- changedata = angular.copy($scope.model.category);
- if ($scope.options.key == "title") {
- var filterData = {
- "idx": 0,
- "sum": 1000
- };
- api_bpm_data.fetchDataList('incidentcategory', filterData).then(function (data) {
- var datalist = data.list;
- angular.forEach(datalist, function (item) {
- if (item.id == $scope.model.category.id) {
- $scope.model[$scope.options.key] = item.category;
- $scope.searchField = $scope.options.model[$scope.options.key];
- $scope.titles = item.category;
- titles = $scope.model.category;
- }
- })
- })
- }
- }
- }, 1000);
- $scope.open = function (key, options, fildata, $event, model) {
- if (key && key.length > 1) {
- api_zsk.solutionData({
- "solution": {
- "searchWord": key
- },
- "idx": "0",
- "sum": "1000"
- }, 'solution').then(function (response) {
- if (response && response.list.length > 0) {
- $scope.dlideboxslide = true
- angular.forEach(response, function (item) {
- console.log(response)
- // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
- // if (response.status == 200) {
- // var quote = { 'totalNum': response.totalNum }
- // item = angular.extend(item, quote)
- // }
- // })
- $scope.searchData = response.list;
- console.log($scope.searchData)
- })
- $scope.changes = false;
- // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
- // $scope.closepages = function(e) {
- // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
- // event.preventDefault();
- // };
- $scope.shows = false;
- $scope.tempData = {};
- $scope.showpage = function (item) {
- item.content = delHtmlTag(item.content);
- $scope.shows = true;
- $scope.tempData = item;
- if (item.content != null) {
- $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
- }
- $scope.knowledgedata = item;
- $scope.pageid = item.id;
- $scope.changes = !$scope.changes;
- api_bpm_domain.listAttachments(item.id)
- // api_solution.fetchDataList('file', {
- // "file": {
- // "solutionId": item.id
- // },
- // "idx": "0",
- // "sum": "1000"
- // })
- .then(function (data) {
- if (data) {
- $scope.attachments = data.list;
- $scope.view = function (attachmentId) {
- for (var i = 0; i < $scope.attachments.length; i++) {
- if ($scope.attachments[i].id == attachmentId) {
- window.open($scope.attachments[i].previewUrl);
- }
- }
- };
- $scope.download = function (contentId, filename) {
- api_solution.getSolutionDowpath(contentId).then(function (response) {
- var file = new Blob([response], {
- type: 'application/octet-stream'
- });
- // var filename = filename;
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- })
- };
- }
- })
- }
- $scope.related = function (item) {
- if (item.content != null) {
- item.content = item.content.replace("<p>", "").replace("</p>", "")
- }
- // fildata.$parent.$parent.$parent.model.directClose = 0;
- options.model.handleDescription = item.content;
- var data = {
- 'solutionQuote': {
- 'solutionId': item.id,
- 'incidentsign': options.model.incidentsign
- }
- };
- api_zsk.solutionQuote(item.id).then(function (response) {
- if (response.status == 200) {
- SweetAlert.swal("引用成功", "知识库已引用", "success");
- fildata.$parent.$parent.$parent.$parent.model.start_code = 'close';
- fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
- } else {
- SweetAlert.swal("引用失败", "知识库未引用", "error");
- };
- })
- }
- $scope.close = function () {
- $scope.changes = !$scope.changes;
- event.preventDefault();
- }
- }
- });
- }
- };
- }]
- });
- //侧滑选择重复事件
- formlyConfigProvider.setType({
- name: 'ui-repeatIncidentbtn',
- templateUrl: 'assets/views/customform/tpl/ui-repeatIncidentbtn.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- relationAction: function (fields, modelscope, item) { }
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- // var value = modelValue || viewValue;
- }
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
- $scope.selection = {
- id: ''
- };
- // 收起重复事件侧滑框
- function reashdata(item) {
- var fildata = {
- idx: 0,
- incident: {
- department: {
- id: $scope.model.incident.department.id,
- },
- },
- sum: 3
- }
- api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
- console.log(data)
- if (data) {
- $scope.repeatData = data.list;
- }
- })
- }
- reashdata();
- // 确认选中的重复事件
- $scope.repeatIncidentOk = function () {
- if ($scope.selection.id) {
- $scope.model.incident.repeat = $scope.selection;
- $scope.model.isRepeat = true; //隐藏处理信息
- console.log($scope.model);
- }
- angular.element('#repeatIncident').removeClass('active');
- }
- // 取消选中的重复事件
- $scope.repeatIncidentCancle = function () {
- angular.element('#repeatIncident').removeClass('active');
- return;
- }
- }]
- });
- //侧滑选择知识库查询
- formlyConfigProvider.setType({
- name: 'ui-knowledgebtn',
- templateUrl: 'assets/views/customform/tpl/ui-knowledgebtn.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- relationAction: function (fields, modelscope, item) { }
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- // var value = modelValue || viewValue;
- }
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', 'api_wechatfile', 'up_down_file', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain, api_wechatfile, up_down_file) {
- // 引用知识库点击
- $scope.searchKeyWord = '';
- $scope.openModel = function (key) {
- // alert(1)//重点
- $scope.searchKeyWord = key;
- if (key) {
- api_zsk.solutionData({
- "solution": {
- threeSearch: key,
- status: { id: 72 },//已发布
- selectType: "keySearch"
- },
- "idx": "0",
- "sum": "1000"
- }, 'solution').then(function (response) {
- $scope.searchData = response.list;
- });
- }
- };
- $scope.openModel($scope.model.incident.description)
- // 展开/收起
- $scope.showId = '';
- $scope.ifshow = false;
- $scope.showAll = function (id) {
- $scope.attachments = []
- if ($scope.showId == id) {
- $scope.ifshow = !$scope.ifshow;
- } else {
- $scope.ifshow = true;
- }
- $scope.showId = id;
- // 获取附件
- api_wechatfile.listAttachments('knowledge', $scope.showId).then(function (data) {
- $scope.attachments = data.data;
- $scope.download = function (token, filename) {
- var downUrl = up_down_file.downloadAttachment('common/common/downloadAttachment', token).getRequestedUrl();
- // window.open(downUrl);
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- })
- }
- // 引用
- $scope.related = function (item) {
- console.log(item,'引用名')
- if (item.content) {
- item.content = item.content.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/ /g, '')
- }
- $scope.model.incident.handleDescription = item.content;
- $scope.model.incident.category = item.category;
- $scope.model.incident.priority.id = item.category.priority.id;
- $scope.model.incident.title = $scope.model.incident.description = item.title;
- item.category.label = item.category.category;
- var categoryId = item.category.id;
- // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
- function getres(nodes) {
- if (!nodes || nodes.length == 0) {
- return;
- }
- nodes.forEach(e => {
- e.selected = false;
- if (e.id == categoryId) {
- e.selected = true;
- return false;
- }
- getres(e.children)
- })
- }
- var categorys = [];
- $scope.fields.forEach((e, i) => {
- if (e.key == 'category') {
- categorys = e.templateOptions.options;
- if (categorys.length) {
- getres(categorys);
- $scope.fields[i].templateOptions.options = categorys;
- $scope.$root.refreshSelectedItems();
- }
- return false;
- }
- })
- // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
- $scope.model.candidateGroups = item.category.group
- // 携带关联优先级,事件工单信息的时间
- if ($scope.model && $scope.model.incident && item.category && item.category.priority && item.category.priority.id) {
- api_bpm_domain.expectedTime('L' + (item.category.priority.id - 1559)).then(function (res) {
- $scope.model.incident.expectResponseTime = $scope.$parent.$parent.$parent.model.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
- $scope.model.incident.expectIntroTime = $scope.$parent.$parent.$parent.model.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
- $scope.model.incident.overdueTime = $scope.$parent.$parent.$parent.model.incident.overdueTime = res.date;
- })
- }
- api_zsk.solutionQuote(item.id).then(function (response) {
- if (response.status == 200) {
- $('#seachknowledge').removeClass('active')
- SweetAlert.swal("引用成功", "知识库已引用", "success");
- $scope.$parent.$parent.$parent.model.start_code = 'close';
- $scope.$parent.$parent.$parent.model.directClose = 0;
- console.log($scope.model)
- } else {
- SweetAlert.swal("引用失败", "知识库未引用", "error");
- };
- })
- }
- }]
- });
- //下拉输入组件
- formlyConfigProvider.setType({
- name: 'ui-selectinput',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/selectinput.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0,
- linkage: function (modelName, data) {
- }
- },
- }
- },
- controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
- $scope.searchData = "";
- $scope.onChangeadd = function (searchData) {
- // $scope.searchKey = searchData.account;
- // var requesdata = angular.copy(searchData)
- // $scope.requester = requesdata;
- }
- $scope.refreshUseradd = function (searchKey) { //主题搜索
- // $scope.searchData = searchKey;
- // reashdata($scope.searchData);
- }
- $scope.getMydata = function (x) {
- $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
- $scope.searchField = $scope.model[$scope.options.key];
- }
- $scope.getMydataone = function (x) {
- $scope.model[$scope.options.key] = x;
- $scope.searchField = $scope.model[$scope.options.key];
- if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
- $scope.hidden = false;
- } else {
- $scope.hidden = true;
- }
- }
- function reashdata(item) {
- $scope.myData = $scope.options.templateOptions.mydata;
- }
- reashdata()
- if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
- $scope.options.templateOptions.fetchItems($scope);
- }
- }]
- });
- //重构组件模板
- //获取当前人
- formlyConfigProvider.setType({
- name: 'ui-users',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-label.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- translate: '',
- refreshDelay: 0
- }
- }
- },
- controller: ['$scope', function ($scope) {
- // $scope.model[$scope.options.key]=$scope.$root.user.name;
- $scope.options.templateOptions.translate = $scope.$root.user.name;
- }]
- });
- //只读控件
- formlyConfigProvider.setType({
- name: 'ui-label',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-label.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- translate: '',
- refreshDelay: 0
- }
- }
- },
- controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
- // console.log($scope.options.templateOptions)
- // console.log($scope.options,'options1122');
- $scope.isSolutionLabel = false;
- $scope.solutionLabelStr = "";
- // console.log($scope.options.templateOptions.solotinLabel);
- if ($scope.options.templateOptions.solotinLabel) {
- $scope.isSolutionLabel = true;
- if ($scope.model[$scope.options.key]) {
- var solutionArr = $scope.model[$scope.options.key].split("/");
- $scope.solutionLabelStr = solutionArr.join(" ");
- }
- }
- var value = $scope.model[$scope.options.key];
- // ----------------
- // ----------------
- // console.log(value, 'pppp')
- function treeDesc(children, key, label) {
- if (label == "") {
- label = children[key];
- } else {
- label = children[key] + "-" + label;
- }
- if (angular.isDefined(children.parent)) {
- treeDesc(children.parent, key, label);
- } else {
- return label;
- }
- }
- if (angular.isArray(value)) {
- var tempValue = "";
- angular.forEach(value, function (item) {
- if (tempValue != "") {
- tempValue = tempValue + ",";
- }
- tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
- });
- $scope.options.templateOptions.translate = tempValue;
- } else if (angular.isObject(value)) {
- if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
- //tree
- // console.log("value.parent="+JSON.stringify(value.parent))
- var nameLabel = value[$scope.options.templateOptions.labelProp];
- nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
- $scope.options.templateOptions.translate = nameLabel;
- } else {
- $scope.options.templateOptions.translate = value;
- }
- } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
- // console.log("value=" + value);
- $scope.options.templateOptions.translate = value;
- // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
- // console.log("value="+value);
- // $scope.options.templateOptions.translate = value;
- } else {
- // var datasdf = JSON.parse(value);
- // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
- $scope.options.templateOptions.translate = value;
- }
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
- $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
- }
- // console.log($scope.options.templateOptions.translate,99999);
- }]
- });
- //小标题组件
- formlyConfigProvider.setType({
- name: 'ui-header',
- template: '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>'
- });
- //标题组件
- formlyConfigProvider.setType({
- name: 'ui-title',
- template: '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>'
- });
- //标栏是否展示
- formlyConfigProvider.setType({
- name: 'ui-orshow',
- template: '<div class=\"panel\"><div class=\"panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix\"><h3 class=\"pull-left panel-title text-head margin-left-10\" ng-if=\"options.templateOptions.label\">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
- controller: ['$scope', function ($scope) {
- $scope.clickshow = function (key) {
- // $scope.model[$scope.options.key] != key;
- if (key == false) {
- $scope.model[$scope.options.key] = true
- } else {
- $scope.model[$scope.options.key] = false
- }
- }
- }]
- });
- //按钮组
- formlyConfigProvider.setType({
- name: 'ui-button',
- templateUrl: 'assets/views/customform/tpl/ui-button.html',
- defaultOptions: function (options) {
- return {
- noFormControl: true
- }
- }
- });
- //3d组link
- formlyConfigProvider.setType({
- name: 'ui-link',
- templateUrl: 'assets/views/customform/tpl/ui-link.html',
- defaultOptions: function (options) {
- return {
- noFormControl: true
- }
- }
- });
- //隐藏域组件
- formlyConfigProvider.setType({
- name: 'ui-hidden',
- extends: 'input',
- template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
- defaultOptions: function (options) {
- return {
- // noFormControl: true
- };
- }
- });
- //文本框组件
- formlyConfigProvider.setType({
- name: 'ui-input',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-input.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (value) { }
- }
- };
- },
- controller: ['$scope', '$timeout', function ($scope, $timeout) {
- // console.log($scope.model[$scope.options.key]);
- // console.log($scope.options)
- if (angular.isFunction($scope.options.templateOptions.linkData)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
- }
- }]
- });
- //搜索下拉框-故障地点seimin
- formlyConfigProvider.setType({
- name: 'ui-select-search',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-select-search.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (value) { }
- }
- };
- },
- controller: ['$scope','$rootScope', 'api_search_area', function ($scope,$rootScope, api_search_area) {
- // console.log($scope.options, $scope.model)
- // ----------------分割线 start-----------------
- // 故障地点下拉
- $scope.address_arr = [];//故障地点所有数据
- $scope.addressFlag = false;//默认下拉框列表隐藏
- //点击文本框
- $scope.AddressClickHandle = function () {
- $scope.getDepartmentList();
- angular.element('#bx_address_ul').scrollTop(0);
- }
- //修改文字,实时监听
- $scope.ksChangeHandle = _.debounce(function () {
- $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === undefined ? '' : $scope.model[$scope.options.key];
- $scope.getDepartmentList();
- angular.element('#bx_address_ul').scrollTop(0);
- }, 500)
- //获取故障地点seimin
- $scope.getDepartmentList = function () {
- $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === null ? '' : $scope.model[$scope.options.key];
- api_search_area.getAreaList({ "searchKey": $scope.model[$scope.options.key] })
- .then(res => {
- if (res.state == 200) {
- $scope.address_arr = res.result;
- $scope.addressFlag = true;//显示
- }
- })
- .catch(err => {
- console.log(err);
- })
- }
- // $scope.getDepartmentList();
- // console.log($scope.model[$scope.options.key])
- //下拉框列表选中
- $scope.addressItemClick = function (obj) {
- $scope.addressFlag = false;//隐藏
- $scope.model[$scope.options.key] = obj.place ? obj.area.area + obj.place : obj.area;
- //选择故障地点后带入区域地点2020年4月23日15:20:44
- $scope.model.selecthouseNumber = obj;
- console.log($scope,77777)
- $scope.$root.selecthouseNumber = obj;
- }
- //点击空白处隐藏
- angular.element(document).on('click', function (e) {
- if (e.target !== angular.element('#bx_address').get(0)) {
- $scope.addressFlag = false;//隐藏
- //模拟placeholder
- // if ($('#bx_address').val() == '') {
- // $('#bx_address').val('请选择报修科室');
- // }
- }
- })
- // -----------------分割线 end----------------
- }]
- });
- //知识库关键字组件
- formlyConfigProvider.setType({
- name: 'ui-knowledgeKeywords',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-knowledgeKeywords.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (value) { }
- }
- };
- },
- controller: ['$scope', '$timeout', 'SweetAlert', function ($scope, $timeout, SweetAlert) {
- $scope.valueLength = [{
- "value": ""
- }];
- $scope.valueAll = [];
- if ($scope.model[$scope.options.key]) {
- var valueArr = $scope.model[$scope.options.key].split("/");
- $scope.valueLength = [];
- for (var i = 0; i < valueArr.length; i++) {
- $scope.valueLength.push({
- "value": valueArr[i]
- })
- }
- }
- $scope.addIpt = function () {
- if ($scope.valueLength.length < 5) {
- $scope.valueLength.push({
- "value": ""
- })
- } else {
- SweetAlert.swal({
- title: "添加失败",
- text: "关键字不能超过5个!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- };
- $scope.closeIpt = function (data) {
- $scope.valueLength.splice(data, 1)
- }
- $scope.toOption = function () {
- $scope.valueAll = [];
- for (var i = 0; i < $scope.valueLength.length; i++) {
- if ($scope.valueLength[i].value != "") {
- $scope.valueAll.push($scope.valueLength[i].value)
- }
- }
- $scope.model.label = $scope.valueAll.join("/")
- }
- }]
- });
- //文本框组件
- formlyConfigProvider.setType({
- name: 'ui-num',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-num.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (value) { }
- }
- };
- },
- controller: ['$scope', '$timeout', function ($scope, $timeout) {
- if (angular.isFunction($scope.options.templateOptions.linkData)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
- }
- $scope.clearNoNum = function (obj, attr) {
- //先把非数字的都替换掉,除了数字和.
- obj[attr] = obj[attr].replace(/[^\d.]/g, "");
- //必须保证第一个为数字而不是.
- obj[attr] = obj[attr].replace(/^\./g, "");
- //保证只有出现一个.而没有多个.
- obj[attr] = obj[attr].replace(/\.{2,}/g, "");
- //保证.只出现一次,而不能出现两次以上
- obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- //小于最大值
- // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
- // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
- // obj[attr] = '';
- // }
- }
- }]
- });
- // //关联请求人文本框组件
- // formlyConfigProvider.setType({
- // name: 'ui-requestinput',
- // extends: 'input',
- // templateUrl: 'assets/views/customform/tpl/ui-input.html',
- // defaultOptions: function(options) {
- // return {
- // templateOptions: {
- // transform: function(value) {},
- // linkData: function(options) {}
- // }
- // };
- // }
- // });
- //只读文本
- formlyConfigProvider.setType({
- name: 'ui-disableinput',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (value) {
- var ret = "";
- if (value) {
- ret = "已删除";
- } else {
- ret = "正常";
- }
- return ret;
- }
- }
- };
- }
- });
- formlyConfigProvider.setType({
- name: 'ui-disinput',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- }
- });
- //数字组件
- formlyConfigProvider.setType({
- name: 'ui-number',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-number.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) { }]
- });
- //含有周的日期
- formlyConfigProvider.setType({
- name: 'ui-datepickerweek',
- templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function ($scope, $filter) {
- $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
- if ($scope.model[$scope.options.key]) {
- } else {
- $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
- }
- $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.endOpen = true;
- $scope.datepicker = {};
- $scope.datepicker.opened = false;
- $scope.datepicker.open = function ($event) {
- $scope.datepicker.opened = true;
- };
- }]
- });
- //lmm
- //分配任务列表
- formlyConfigProvider.setType({
- name: 'jry_taskDistributionList',
- templateUrl: 'assets/views/customform/tpl/jry_taskDistributionList.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- }
- };
- },
- controller: function ($rootScope, $scope, api_user_data, $modal, api_doc_data, i18nService, SweetAlert, api_wechatfile) {
- // 获取状态
- $scope.stateListData = {};
- $scope.getStateData = function () {//lyl
- var data = {
- "key": 'task_sub_state',
- "type": 'list'
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- angular.forEach(res, function (v, i) {
- $scope.stateListData[v.value] = v.id;
- })
- })
- }
- $scope.getStateData();
- var loginUser = $rootScope.user;
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- // console.log($scope.model);//lmmmm
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: "10%",
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'taskDescribe',
- displayName: '任务说明',
- width: "25%",
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
- '</div>'
- },
- {
- name: 'assign.name',
- displayName: '指派人',
- width: "5%",
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
- '</div>'
- },
- {
- name: 'startTime',
- displayName: '开始时间',
- width: '13%',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
- '</div>'
- },
- {
- name: 'endTime',
- displayName: '结束时间',
- width: '13%',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
- '</div>'
- },
- {
- name: 'priority.name',
- displayName: '优先级',
- width: "5%",
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
- '</div>'
- },
- {
- name: 'state.name',
- displayName: '状态',
- width: "5%",
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
- '</div>'
- },
- {
- name: '操作',//lmmm
- cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
- '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
- '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
- '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
- '<a ng-click="grid.appScope.see(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[2]||row.entity.state.id==grid.appScope.stateListData[3]||grid.appScope.model.showSee">查看</a>' +
- '</div></div>',
- enableFiltering: false
- }
- ];
- // 查看
- $scope.see = function (data) {
- $scope.seeData = data;
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
- controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
- $scope.personData = {}; //指派人
- $scope.priorityData = {}; //优先级
- $scope.personListData = {}; //指派人下拉数据
- $scope.priorityListData = {}; //优先级下拉数据
- $scope.startTime = ""; //开始时间
- $scope.releaseShow = "no";
- $scope.subShow = "no";
- $scope.onlySee = "ok";
- $scope.endTime = ""; //结束时间
- $scope.taskDescribe = ""; //任务描述
- $scope.taskDescribe = scope.seeData.taskDescribe;
- $scope.personData.data = scope.seeData.assign;
- $scope.priorityData.data = scope.seeData.priority;
- $scope.startTime = scope.seeData.startTime;
- $scope.endTime = scope.seeData.endTime;
- $scope.done = scope.seeData.done;
- $scope.feedback = scope.seeData.feedback;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- backdrop: true
- });
- }
- // 编辑
- $scope.edit = function (data) {
- $scope.editData = data;
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
- controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
- console.log(scope.editData);
- $scope.personData = {}; //指派人
- $scope.priorityData = {}; //优先级
- $scope.personListData = {}; //指派人下拉数据
- $scope.priorityListData = {}; //优先级下拉数据
- $scope.startTime = ""; //开始时间
- $scope.releaseShow = "no";
- $scope.endTime = ""; //结束时间
- $scope.taskDescribe = ""; //任务描述
- $scope.taskDescribe = scope.editData.taskDescribe;
- $scope.personData.data = scope.editData.assign;
- $scope.priorityData.data = scope.editData.priority;
- $scope.startTime = scope.editData.startTime;
- $scope.endTime = scope.editData.endTime;
- // 指派人下拉框数据
- $scope.getPersonData = function () {
- var data = {
- "idx": 0,
- "sum": 1000
- }
- api_user_data.fetchDataList("user", data).then(function (res) {
- $scope.personListData = res.list;
- })
- }
- $scope.getPersonData();
- //优先级下拉数据
- $scope.getPriorityData = function () {
- var data = {
- "key": "change_rick_level",
- "type": "list"
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- $scope.priorityListData = res
- })
- }
- $scope.getPriorityData();
- // 获取状态-lmm
- $scope.stateListData = {};
- $scope.getStateData = function () {//lyl
- var data = {
- "key": 'task_sub_state',
- "type": 'list'
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- angular.forEach(res, function (v, i) {
- $scope.stateListData[v.value] = v.id;
- })
- })
- }
- $scope.getStateData();
- //时间控件
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- // 确定
- $scope.ok = function (item) {
- if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
- $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
- $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
- $scope.addData = {
- "taskSub": {
- "taskDescribe": $scope.taskDescribe,
- "assign": $scope.personData.data,
- "priority": $scope.priorityData.data,
- "startTime": $scope.startTime,
- "endTime": $scope.endTime,
- "taskMonth": {
- "id": scope.model.taskMonth.id
- },
- "id": scope.editData.id
- }
- }
- $scope.addData.taskSub["state"] = {
- "id": $scope.stateListData[1]
- };
- api_user_data.updData('taskSub', $scope.addData).then(function (res) {
- if (res.status == 200) {
- SweetAlert.swal({
- title: "修改成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- scope.refreshData(scope.jry_filterdata);
- $modalInstance.dismiss('cancel');
- } else {
- SweetAlert.swal({
- title: "修改失败",
- text: "系统错误,请重试!",
- type: "error"
- });
- $modalInstance.dismiss('cancel');
- }
- })
- } else {
- SweetAlert.swal({
- title: "修改失败",
- text: "必填项不能为空!",
- type: "error"
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- backdrop: true
- });
- }
- // 发布
- $scope.release = function (data) {
- SweetAlert.swal({
- title: "确认发布?",
- text: "请确定发布操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- data.state.id = $scope.stateListData[2];
- delete data.item;
- api_user_data.updData("taskSub", {
- taskSub: data
- }).then(function (res) {
- if (res.status == 200) {
- SweetAlert.swal({
- title: "发布成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- $scope.refreshData($scope.jry_filterdata);
- } else {
- SweetAlert.swal({
- title: "删除失败",
- text: "系统错误,请重试!",
- type: "error"
- });
- }
- })
- } else {
- SweetAlert.swal("操作取消", "发布取消", "error");
- }
- });
- }
- // 删除
- $scope.remove = function (data) {
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
- if (res.status == 200) {
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- $scope.refreshData($scope.jry_filterdata);
- } else {
- SweetAlert.swal({
- title: "删除失败",
- text: "系统错误,请重试!",
- type: "error"
- });
- }
- })
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- $scope.refreshData = function (filterData) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- $scope.memoryfilterData = filterData;
- api_doc_data.fetchDataList('taskSub', filterData).then(function (data) {
- var myData = data;
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.removeFileNum = myData.totalNum;
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
- $scope.myData[i].startTime = moment($scope.myData[i].startTime).format('YYYY-MM-DD HH:mm:ss');
- $scope.myData[i].endTime = moment($scope.myData[i].endTime).format('YYYY-MM-DD HH:mm:ss');
- }
- }
- }, function () {
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- //分页控制
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- $scope.jry_filterdata.idx = newPage - 1;
- $scope.fenye = newPage - 1;
- $scope.jry_filterdata.sum = pageSize;
- $scope.refreshData($scope.jry_filterdata);
- });
- }
- $scope.fenye = 0;
- if ($scope.model.label == "分配任务") {
- $scope.jry_filterdata = {
- "idx": $scope.fenye,
- "sum": 10,
- "taskSub": {
- "taskMonth": {
- "id": $scope.model.taskMonth.id
- },
- "userid": loginUser.id,
- "role": loginUser.role
- }
- };
- } else {
- $scope.jry_filterdata = {
- "idx": $scope.fenye,
- "sum": 10,
- "taskSub": {
- "taskMonth": {
- "id": $scope.model.taskMonth.id
- },
- "userid": loginUser.id,
- "role": loginUser.role,
- "type": 1
- }
- };
- }
- $scope.refreshData($scope.jry_filterdata);
- //新增模态框
- $scope.newDistribution = function () {
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
- controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
- $scope.personData = {}; //指派人
- $scope.priorityData = {}; //优先级
- $scope.personListData = {}; //指派人下拉数据
- $scope.priorityListData = {}; //优先级下拉数据
- $scope.startTime = ""; //开始时间
- $scope.endTime = ""; //结束时间
- $scope.taskDescribe = ""; //任务描述
- $scope.motaikuang = "";
- $scope.shijian = "哈哈";
- // 指派人下拉框数据
- $scope.getPersonData = function () {
- var data = {
- "idx": 0,
- "sum": 1000
- }
- api_user_data.fetchDataList("user", data).then(function (res) {
- $scope.personListData = res.list;
- })
- }
- $scope.getPersonData();
- //优先级下拉数据
- $scope.getPriorityData = function () {
- var data = {
- "key": "change_rick_level",
- "type": "list"
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- $scope.priorityListData = res
- })
- }
- // 控制结束时间的最大时间
- $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
- // 控制结束时间的最小时间
- $scope.jryEndMinTime = scope.model.taskMonth.startTime;
- $scope.$watch('startTime', function (n, o) {
- if (n) {
- if (n > scope.model.taskMonth.startTime) {
- $scope.jryEndMinTime = n
- }
- }
- })
- // 控制开始时间的最小时间
- $scope.jryStartMinTime = scope.model.taskMonth.startTime;
- // 控制开始时间的最大时间
- $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
- $scope.$watch('endTime', function (n, o) {
- if (n) {
- if (n < scope.model.taskMonth.endTime) {
- $scope.jryStartMaxTime = n
- }
- }
- })
- $scope.getPriorityData();
- //时间控件
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.datepickerPopup = 'yyyy-MM-dd HH:mm:ss';
- // 获取状态-lmm
- $scope.stateListData = {};
- $scope.getStateData = function () {//lyl
- var data = {
- "key": 'task_sub_state',
- "type": 'list'
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- angular.forEach(res, function (v, i) {
- $scope.stateListData[v.value] = v.id;
- })
- })
- }
- $scope.getStateData();
- // 草稿保存
- $scope.ok = function (item) {
- if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
- $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
- $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
- $scope.addData = {
- "taskSub": {
- "taskDescribe": $scope.taskDescribe,
- "assign": $scope.personData.data,
- "priority": $scope.priorityData.data,
- "startTime": $scope.startTime,
- "endTime": $scope.endTime,
- "taskMonth": {
- "id": scope.model.taskMonth.id
- }
- }
- }
- $scope.addData.taskSub["state"] = {
- "id": $scope.stateListData[1]
- };
- api_user_data.addData('taskSub', $scope.addData).then(function (res) {
- if (res.status == 200) {
- SweetAlert.swal({
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- scope.refreshData(scope.jry_filterdata);
- $modalInstance.dismiss('cancel');
- } else {
- SweetAlert.swal({
- title: "保存失败",
- text: "系统错误,请重试!",
- type: "error"
- });
- $modalInstance.dismiss('cancel');
- }
- })
- } else {
- SweetAlert.swal({
- title: "保存失败",
- text: "必填项不能为空!",
- type: "error"
- });
- }
- };
- // 发布
- $scope.release = function () {
- if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
- $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
- $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
- $scope.addData = {
- "taskSub": {
- "taskDescribe": $scope.taskDescribe,
- "assign": $scope.personData.data,
- "priority": $scope.priorityData.data,
- "startTime": $scope.startTime,
- "endTime": $scope.endTime,
- "taskMonth": {
- "id": scope.model.taskMonth.id
- }
- }
- }
- $scope.addData.taskSub["state"] = {
- "id": $scope.stateListData[1]
- };
- api_user_data.addData('taskSub', $scope.addData).then(function (res) {
- if (res.status == 200) {
- SweetAlert.swal({
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- scope.refreshData(scope.jry_filterdata);
- $modalInstance.dismiss('cancel');
- } else {
- SweetAlert.swal({
- title: "保存失败",
- text: "系统错误,请重试!",
- type: "error"
- });
- $modalInstance.dismiss('cancel');
- }
- })
- } else {
- SweetAlert.swal({
- title: "保存失败",
- text: "必填项不能为空!",
- type: "error"
- });
- }
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- backdrop: true
- });
- }
- }
- });
- // 多次反馈文本域组件--jry
- formlyConfigProvider.setType({
- name: 'ui-feedbacktTextarea',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-feedbacktTextarea.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', 'moment', function ($scope, moment) {
- // console.log($scope);
- var timeKey = $scope.options.templateOptions.time;
- $scope.time = moment($scope.model[timeKey]).format('YYYY-MM-DD HH:mm:ss');
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- if (angular.isFunction($scope.options.templateOptions.felditem)) {
- $scope.options.templateOptions.felditem($scope);
- }
- }]
- });
- //任务管理开始时间--jry
- formlyConfigProvider.setType({
- name: 'ui-jryStartdatepicker',
- templateUrl: 'assets/views/customform/tpl/ui-jryStartdatepicker.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function ($scope, $filter) {
- // console.log($scope.model[$scope.options.key],'lmm');
- $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
- if ($scope.model[$scope.options.key]) {
- $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
- }
- // console.log($scope.model[$scope.options.key],'lmm');
- // console.log($scope.model,'lmm',$scope.options.key);
- $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.endOpen = true;
- $scope.datepicker = {};
- $scope.datepicker.opened = false;
- $scope.datepicker.open = function ($event) {
- $scope.datepicker.opened = true;
- };
- }]
- });
- //任务管理结束时间--jry
- formlyConfigProvider.setType({
- name: 'ui-jryEnddatepicker',
- templateUrl: 'assets/views/customform/tpl/ui-jryEnddatepicker.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function ($scope, $filter) {
- $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
- if ($scope.model[$scope.options.key]) {
- $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
- }
- $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.endOpen = true;
- $scope.datepicker = {};
- $scope.datepicker.opened = false;
- $scope.datepicker.open = function ($event) {
- $scope.datepicker.opened = true;
- };
- }]
- });
- //下拉多选框灵活组件--jry
- formlyConfigProvider.setType({
- name: 'ui-jry_multiselectplus',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refreshData: function (search, options, model, that) {
- // var process = options.templateOptions.ApiService.all("");
- if (search) {
- } else {
- }
- var postData = options.templateOptions.optionsPostData;
- if (angular.isFunction(options.templateOptions.optionsPostData)) {
- postData = options.templateOptions.optionsPostData(options, model, that);
- }
- options.templateOptions.ApiService.fetchDataList(options.templateOptions.optionsUrl, options.templateOptions.optionsPostData).then(function (result) {
- // if (!options.templateOptions.options) {
- // options.templateOptions.options = [];
- // }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = result[options.templateOptions.optionsDataKey];
- } else {
- options.templateOptions.options = result;
- }
- if (options.templateOptions.optionsChecked) {
- // return options.value = null;
- options.value(options.model[options.key]);
- }
- });
- },
- refreshDelay: 0,
- // },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value != null;
- // return value.length>=1;
- // if (modelValue && viewValue) {
- // return value != null;
- // } else {
- // var value = modelValue || viewValue;
- // return value.length > 0;
- // }
- }
- }
- }
- }
- };
- },
- controller: ['$scope', function ($scope) {
- console.log($scope.to);
- if (angular.isArray($scope.model[$scope.options.key])) {
- } else {
- $scope.model[$scope.options.key] = [];
- }
- }]
- });
- //下拉框组件
- formlyConfigProvider.setType({
- name: 'ui-select',
- extends: 'select',
- templateUrl: 'assets/views/customform/tpl/ui-select.html',
- defaultOptions: function (options, scope) {
- return {
- templateOptions: {
- // refresh: function() {},
- refreshDelay: 0,
- linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
- console.log(model,'model')
- angular.extend(data, {
- "idx": 0,
- "sum": 1000
- });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- console.log(myData)
- // api_bpm_domain.expectedTime("L" + item).then(function(res){
- // console.log('balabalabala');
- // console.log(res);
- // })
- if (list.length == 1) {
- if (options.templateOptions.APIport) {
- options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
- if (response.state == "200") {
- // if (model.$parent.model && model.$parent.model.incident) {
- // } else {
- // model.$parent.model = { 'incident': {} };
- // }
- var myDatas = response.serviceLevelAgreement;
- //逾期
- scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
- //解决
- scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
- //响应
- scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
- } else {
- }
- });
- }
- angular.forEach(model.fields, function (item) {
- angular.forEach(model.fields, function (item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- } else if (key == "placeDTO") {
- item.templateOptions.options = list;
- } else if (key == "requester") {
- } else {
- item.value(list[0][key][item.key]);
- }
- }
- })
- })
- } else {
- if (model.fields) {
- angular.forEach(model.fields, function (item) {
- angular.forEach(model.fields, function (item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.isnosearch = true;
- item.templateOptions.options = list;
- }
- if (key == "placeDTO") {
- item.templateOptions.options = list;
- }
- if (key == "requester") {
- }
- }
- })
- })
- } else {
- angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
- angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- if (key == "place") {
- item.templateOptions.isnosearch = true;
- item.templateOptions.options = list;
- scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
- }
- if (key == "placeDTO") {
- item.templateOptions.options = list;
- }
- if (key == "requester") {
- }
- }
- })
- })
- }
- }
- console.log(key)
- //报修科室
- if (key == 'dept') {
- // 报修科室单选
- scope.$parent.$parent.$parent.model.incident.department = response.list[0];
- scope.$parent.$parent.$parent.model.incident.contactsInformation = response.list[0].phone;
- // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
- // 选择重复事件侧滑框
- scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
- setTimeout(() => {
- scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
- }, 500);
- }
- // 报修人
- if (key == 'requester') {
- // 报修人单选
- scope.$parent.$parent.$parent.model.incident.requester = response.list[
- 0];
- console.log(scope.$parent.$parent.$parent.model)
- scope.$parent.$parent.$parent.model.incident.account = response.list[
- 0].account;
- var selectedItem = response.list[
- 0];
- var data = {
- 'requester': selectedItem
- };
- scope.$parent.$parent.$parent.model[
- 'requestershow'] = selectedItem;
- console.log(selectedItem, '----------------------')
- // if (selectedItem.dept.place.place) {
- // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
- // }
- scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.houseNumber?selectedItem.houseNumber:'';
- scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place?selectedItem.place.area.id:null;
- scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place?selectedItem.place.id:null;
- console.log(scope,89898998)
- // console.log(scope.formData,'接单页面');
- //1,选择报修人后带入区域地点2020年4月23日19:34:17
- scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
- scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
- options.templateOptions.ApiService.addData('requester',
- data).then(function (response) {
- if (response.status == 200) {
- if (scope.$parent.$parent.$parent) {
- if (scope.$parent.$parent.$parent.place) {
- scope.$parent.$parent.$parent.place.id = '';
- }
- if (scope.$parent.$parent.$parent.area) {
- scope.$parent.$parent.$parent.area.id = '';
- }
- scope.$parent.$parent.$parent.model.incident.contacts = selectedItem.name;
- if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
- scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.mphone;
- } else {
- scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.telephone;
- }
- if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
- scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- }
- }
- if (!response.data.id) {
- response.data.id = selectedItem.id
- }
- console.log(scope);
- // if (scope.$parent.$parent.$parent.model.saveAgain) {
- // if (selectedItem.place && selectedItem.place.id) {
- // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
- // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
- // };
- // } else {
- // if (selectedItem.place && selectedItem.place.id) {
- // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
- // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
- // };
- // }
- // if(scope.$parent.$parent.$parent.model.incident.area){
- // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
- // }
- if (selectedItem.id) {
- scope.$parent.$parent.$parent.model.incident.account = selectedItem.account;
- }
- // 选择重复事件侧滑框
- // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
- scope.$parent.$parent.$parent.model[
- 'repeatIncidentShow'] = false;
- setTimeout(() => {
- scope.$parent.$parent.$parent.model[
- 'repeatIncidentShow'] = true;
- },
- 500);
- // }
- }
- })
- }
- });
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value != null;
- // return value.length>=1;
- // if (modelValue && viewValue) {
- // return value != null;
- // } else {
- // var value = modelValue || viewValue;
- // return value.length > 0;
- // }
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
- // $scope.myFilter = function(item) {
- // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
- // }
- // console.log($scope,'风浪')
- if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
- if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
- $scope.options.templateOptions.linkage("place", {
- "place": {
- "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
- // area:{
- // id:$scope.$parent.$parent.$parent.model.incident.area.id
- // }
- }
- }, $scope.$parent.$parent.$parent.model, "incident", "place");
- }
- }
- $scope.myFilter = $scope;
- // console.log($scope.options.templateOptions)
- console.log($scope,77777)
- //处理人根据事件分类自动带入
- if($scope.id == 'formly_2_ui-select_id_6'){
- if($scope.$parent.$parent.$parent.model.incident.handlerUser){
- if($scope.$parent.$parent.$parent.model.incident.handlerUser.id){
- $scope.options.model.id = $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
- }
- }
- }
- // 关闭事件页面满意度评价下拉框处理
- if($scope.options.templateOptions.onlyKey=="close_degree"){
- $scope.model.id = $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id
- }
- if($scope.options.templateOptions.initData == 1){
- $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
- }
- if ($scope.options.templateOptions.transform) {
- $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
- }
- if (angular.isFunction($scope.options.templateOptions.translate)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
- }
- if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
- }
- if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
- $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
- }
- }]
- };
- }
- });
- //下拉多选框组件
- formlyConfigProvider.setType({
- name: 'ui-multiselect',
- extends: 'select',
- templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 1000
- }
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.model[$scope.options.key] = [];
- }]
- });
- //下拉多选框灵活组件
- formlyConfigProvider.setType({
- name: 'ui-multiselectplus',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- refreshData: function (search, options, model, that) {
- var process = options.templateOptions.ApiService.all("");
- if (search) {
- } else {
- }
- var postData = options.templateOptions.optionsPostData;
- if (angular.isFunction(options.templateOptions.optionsPostData)) {
- postData = options.templateOptions.optionsPostData(options, model, that);
- }
- if (options.templateOptions.modelreasondata) {
- postData = options.templateOptions.modelreasondata
- }
- process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
- // if (!options.templateOptions.options) {
- // options.templateOptions.options = [];
- // }
- // 过滤下拉列表已选择的值
- var modelVal = $scope.model[$scope.options.key];
- for (var i = 0; i < result.list.length; i++) {
- for (var j = 0; j < modelVal.length; j++) {
- if (result.list[i].id == modelVal[j].id) {
- result.list.splice(i, 1)
- }
- }
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = result[options.templateOptions.optionsDataKey];
- } else {
- options.templateOptions.options = result;
- }
- if (options.templateOptions.optionsChecked) {
- // return options.value = null;
- options.value(options.model[options.key]);
- }
- });
- },
- refreshDelay: 0,
- // },
- // validators: {
- // required: {
- // expression: function(viewValue, modelValue) {
- // var value = modelValue || viewValue;
- // // return value.length>=1;
- // // if (modelValue && viewValue) {
- // // return value != null;
- // // } else {
- // // var value = modelValue || viewValue;
- // // return value.length > 0;
- // // }
- // }
- // }
- }
- };
- },
- controller: ['$scope', function ($scope) {
- if (angular.isArray($scope.model[$scope.options.key])) {
- } else {
- $scope.model[$scope.options.key] = [];
- }
- }]
- });
- //下拉树形多选组件
- formlyConfigProvider.setType({
- name: 'ui-multiselect-tree',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- linkage: function (modelName, data, model, modelKey, key) {
- angular.extend(data, {
- "idx": 0,
- "sum": 10
- });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- if (list.length == 1) {
- angular.forEach(model.fields, function (item) {
- angular.forEach(model.fields, function (item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- } else {
- item.value(list[0][key][item.key]);
- }
- }
- })
- })
- }
- });
- },
- // my_tree_handler : function(items) {
- // },
- // onFilterCallback : function(items) {
- // },
- // onFilterCallback : function(items) {
- // },
- refresh: function (items) {
- var treedata = [];
- function convertListToTree(data, treeMap) {
- treedata = data;
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < data.length; j++) {
- if (data[i].pid && data[i].id && data[i].pid != 0) {
- if (data[i].pid == data[j].id) {
- data[i].parent = data[j];
- }
- }
- }
- }
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent === null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- // console.log("data="+JSON.stringify(data))
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- function selectItem(pmodel, childrens) {
- if (angular.isArray(pmodel)) {
- angular.forEach(pmodel, function (index) {
- if (index && index.id) {
- angular.forEach(childrens, function (item) {
- if (item.id == index.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- })
- } else {
- if (pmodel && pmodel.id) {
- angular.forEach(childrens, function (item) {
- if (item.id == pmodel.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- }
- }
- // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
- options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
- if (result.status == 200) {
- if (!options.templateOptions.options) {
- options.templateOptions.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
- } else {
- options.templateOptions.options = convertParentToChildList(result);
- }
- //set default value
- var pmodel, i = 0;
- if (options.templateOptions.pkey) {
- if (options.templateOptions.pkey.indexOf(".") > 0) {
- angular.forEach(options.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (options.model[p] == null) {
- options.model[p] = {};
- }
- pmodel = options.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- } else {
- pmodel = options.model;
- }
- }
- if (pmodel) {
- pmodel = pmodel[options.key];
- } else if (options.model) {
- pmodel = options.model[options.key];
- } else {
- pmodel = options.templateOptions.options;
- }
- if (angular.isArray(pmodel)) {
- if (pmodel) {
- // if(options.templateOptions.isMultiSelect==true){
- // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
- // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
- // })
- // }else{
- selectItem(pmodel, options.templateOptions.options);
- // }
- }
- } else {
- if (pmodel && pmodel.id) {
- selectItem(pmodel, options.templateOptions.options);
- }
- }
- items.inputModel = options.templateOptions.options;
- }
- });
- }
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- if (angular.isArray(value)) {
- for (var i = 0; i < value.length; i++) {
- value[i] = {
- id: value[i].id
- }
- }
- return value.length > 0
- } else {
- // console.log(options)
- // return value = "true";
- return value != null;
- }
- }
- }
- }
- }
- },
- controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
- if ($scope.options.templateOptions.isMultiSelect) {
- // console.log($scope);
- } else {
- if ($scope.model[$scope.options.key]) {
- }
- }
- }]
- });
- //多选下拉框组件
- formlyConfigProvider.setType({
- name: 'ui-multi-select-tree',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- linkage: function (modelName, data, model, modelKey, key) {
- angular.extend(data, {
- "idx": 0,
- "sum": 10
- });
- options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
- var myData = options.templateOptions.Restangular.stripRestangular(response);
- var list = myData.list;
- if (list.length == 1) {
- angular.forEach(model.fields, function (item) {
- angular.forEach(model.fields, function (item) {
- if (item.templateOptions.pkey == modelKey + "." + key) {
- item.model.id = "";
- if (key == "place") {
- item.templateOptions.options = list;
- } else {
- item.value(list[0][key][item.key]);
- }
- }
- })
- })
- }
- });
- },
- getparentdata: function (items) {
- // console.log(items)
- },
- refresh: function (items, search, fn) {
- console.log(items);
- var treedata = [];
- function convertListToTree(data, treeMap) {
- // console.log(data)
- treedata = data;
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < data.length; j++) {
- if (data[i].pid && data[i].id && data[i].pid != 0) {
- if (data[i].pid == data[j].id) {
- data[i].parent = data[j];
- }
- }
- // if (data[i].id) {
- // if (data[i].id== data[j].id) {
- // data[i].parent = data[j];
- // }
- // }
- }
- }
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = []; //Initially set our loop to null
- if (search == 'search' && items.filterKeyword) {
- function transform(nodes) {
- var treeConverter = {
- result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
- attributeName: 'id', //节点唯一标识符
- needFind: true, //是否查询节点在result中已经存在,为了优化效率
- transform: function (node) { //转化递归函数,参数:一个待插入节点
- if (node.parent != null) { //该节点有父节点
- var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
- if (this.needFind) {
- for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
- if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
- return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- }
- }
- }
- this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
- // delete node.parent; //删除该节点的parent属性,如果有的话
- node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
- newNode.children.push(node); //将该node节点push进newNode的子节点数组中
- return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
- } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
- // delete node.parent; //删除该节点的parent属性,如果有的话
- if (this.result == null) { //根节点不存在
- node.children = []; //给该节点增加children:[]属性
- return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- } else {
- node.children = [];
- // 顶级去重
- for (var i = 0; i < this.result.children.length; i++) {
- if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
- return this.result.children[i];
- }
- }
- this.result.children.push(node)
- return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- }
- }
- },
- getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
- var _node = {};
- _node.children = [];
- this.result = _node; //重置根节点
- this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
- nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
- nodes.forEach(item => { //循环调用转化方法
- this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
- this.transform(item);
- })
- return this.result; //返回根节点
- }
- }
- var result = treeConverter.getWhole(nodes); //调用
- return result;
- }
- var li = transform(data).children;
- // li=[...new Set(li)]
- console.log(li)
- treeMap = li;
- fn(li);
- return li;
- } else {
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent === null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- // delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- if (search == 'search' && items.filterKeyword) {
- var lis = convertListToTree(data, treeMap)
- return lis;
- } else {
- if (data[0] && data[0].orders) {
- list = data;
- } else {
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- // console.log("item="+JSON.stringify(item))
- list.push(item);
- });
- }
- return list;
- }
- }
- function selectItem(pmodel, childrens) {
- if (angular.isArray(pmodel)) {
- angular.forEach(pmodel, function (index) {
- if (index && index.id) {
- angular.forEach(childrens, function (item) {
- if (item.id == index.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- // angular.forEach(treedata,function(parentdata){
- // if(parentdata.id == index.id){
- // if(parentdata.parent&&parentdata.parent.id){
- // parentdata.parent.$
- // }
- // item.selected = true;
- // }
- // if (item && item.children) {
- // selectItem(pmodel ,item.children);
- // }
- // });
- }
- })
- } else {
- if (pmodel && pmodel.id) {
- angular.forEach(childrens, function (item, index) {
- if (item.id == pmodel.id) {
- item.selected = true;
- delete item.children;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- }
- }
- function selectItemchild(pmodel, childrens) {
- if (angular.isArray(pmodel)) {
- angular.forEach(pmodel, function (index) {
- if (index && index.id) {
- angular.forEach(childrens, function (item) {
- if (item.id == index.id) {
- item.selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- })
- } else {
- if (pmodel && pmodel.id) {
- angular.forEach(childrens, function (item, index) {
- if (item.id == pmodel.id) {
- item.selected = true;
- childrens[index].selected = true;
- }
- if (item && item.children) {
- selectItem(pmodel, item.children);
- }
- });
- }
- }
- }
- // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
- if (search === 'search' && items.filterKeyword) {
- // bala:树形模糊搜索
- options.templateOptions.bala(options.templateOptions.APIService, items.filterKeyword).then(function (result) {
- result.list = [...new Set(result.list)]; //去重
- if (!options.templateOptions.options) {
- options.templateOptions.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
- } else {
- options.templateOptions.options = convertParentToChildList(result);
- }
- //set default value
- var pmodel, i = 0;
- if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
- if (options.templateOptions.pkey.indexOf(".") > 0) {
- angular.forEach(options.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (options.model[p] == null) {
- options.model[p] = {};
- }
- pmodel = options.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- } else {
- pmodel = options.model;
- }
- }
- var topdata = angular.copy(options.templateOptions.options);
- if (pmodel) {
- pmodel = pmodel[options.key];
- } else if (options.model) {
- pmodel = options.model[options.key];
- }
- if (angular.isArray(pmodel)) {
- if (pmodel) {
- items.inputModel = angular.copy(options.templateOptions.options);
- selectItem(pmodel, options.templateOptions.options);
- }
- } else {
- if (pmodel && pmodel.id) {
- items.inputModel = angular.copy(options.templateOptions.options);
- selectItem(pmodel, options.templateOptions.options);
- } else {
- // items.inputModel = options.templateOptions.options;
- }
- }
- // items.inputModel = options.templateOptions.options;
- items.selectModel = options.templateOptions.options;
- // 可在此展开
- if (!items.inputModel) {
- items.inputModel = items.selectModel;
- } else {
- selectItemchild(pmodel, items.inputModel);
- // for (var i = 0; i < items.inputModel.length; i++) {
- // items.inputModel[i].
- // for (var j = 0; j < items.selectModel.length; j++) {
- // if (items.selectModel[j].id == items.inputModel[i].id) {
- // items.inputModel[i].selected = true;
- // }
- // }
- // }
- }
- return items.inputModel;
- // options.templateOptions.options = angular.copy(topdata);
- // console.log(model);
- // console.log(options);
- });
- } else {
- options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
- if (!options.templateOptions.options) {
- options.templateOptions.options = [];
- }
- if (options.templateOptions.optionsDataKey) {
- options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
- } else {
- options.templateOptions.options = convertParentToChildList(result);
- }
- //set default value
- var pmodel, i = 0;
- if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
- if (options.templateOptions.pkey.indexOf(".") > 0) {
- angular.forEach(options.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (options.model[p] == null) {
- options.model[p] = {};
- }
- pmodel = options.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- } else {
- pmodel = options.model;
- }
- }
- var topdata = angular.copy(options.templateOptions.options);
- if (pmodel) {
- pmodel = pmodel[options.key];
- } else if (options.model) {
- pmodel = options.model[options.key];
- }
- if (angular.isArray(pmodel)) {
- if (pmodel) {
- items.inputModel = angular.copy(options.templateOptions.options);
- selectItem(pmodel, options.templateOptions.options);
- }
- } else {
- if (pmodel && pmodel.id) {
- items.inputModel = angular.copy(options.templateOptions.options);
- selectItem(pmodel, options.templateOptions.options);
- } else {
- // items.inputModel = options.templateOptions.options;
- }
- }
- // items.inputModel = options.templateOptions.options;
- items.selectModel = options.templateOptions.options;
- if (!items.inputModel) {
- items.inputModel = items.selectModel;
- } else {
- selectItemchild(pmodel, items.inputModel);
- // for (var i = 0; i < items.inputModel.length; i++) {
- // for (var j = 0; j < items.selectModel.length; j++) {
- // if (items.selectModel[j].id == items.inputModel[i].id) {
- // items.inputModel[i].selected = true;
- // }
- // }
- // }
- }
- // options.templateOptions.options = angular.copy(topdata);
- // console.log(model);
- // console.log(options);
- });
- }
- }
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- if (angular.isArray(value)) {
- return value.length > 0
- } else {
- // console.log(options)
- if (options.templateOptions.required && !value) {
- // return value != null;
- } else {
- return value;
- }
- // return value = "true";
- }
- }
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', 'api_configure_form', 'api_bpm_domain', function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
- $rootScope.checkClicked = function (item) {
- angular.forEach($scope.to.options, function (itemone) {
- if (!item.parent) {
- if (item.id == itemone.id) {
- // itemone.isExpanded = true;
- } else {
- itemone.isExpanded = false;
- }
- } else {
- if (item.parent.id == itemone.id) {
- angular.forEach(itemone.children, function (itemtwo) {
- if (item.id == itemtwo.id) { } else {
- itemtwo.isExpanded = false;
- }
- })
- }
- }
- })
- // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
- console.log($scope,'gsm');
-
- if ($scope.originalModel && $scope.originalModel.incident && item.category && (!item.children || !item.children.length) && item.priority && item.priority.id) {
- api_bpm_domain.expectedTime('L' + (item.priority.id - 1559)).then(function (res) {
- $scope.originalModel.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
- $scope.originalModel.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
- $scope.originalModel.incident.overdueTime = res.date;
- })
- // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
- // setTimeout(() => {
- // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
- // }, 500);
- // console.log($scope.$parent.$parent.$parent)
- }
- }
- if ($scope.options.templateOptions.isMultiSelect) {
- // console.log($scope);
- } else {
- if ($scope.model[$scope.options.key]) {
- }
- }
- // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
- // console.log(item)
- // // if(){
- // // }
- // // $scope.model[$scope.options.key]=item.id;
- // api_configure_form.renderTabForm(item.prefix).then(function(data){
- // $scope.propTypeOptions = data;
- // });
- // }
- // $scope.model[$scope.options.key]=[];
- // $scope.fn
- $rootScope.bala1 = function (items, fn) {
- // $scope.fn = fn;
- console.log(items)
- // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
- $scope.options.templateOptions.refresh(items, 'search', fn)
- // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
- // // return res.list;
- // console.log(666)
- // fn(res.list)
- // })
- }
- }]
- });
- //勾选组件
- formlyConfigProvider.setType({
- name: 'ui-checkbox',
- extends: 'checkbox',
- templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
- controller: ['$scope', function ($scope) {
- // 巡检生成事件,默认派单
- if ($scope.model.isInspection) {
- $scope.model[$scope.options.key] = true;
- };
- if ($scope.model[$scope.options.key] == "true") {
- $scope.model[$scope.options.key] = true;
- };
- if ($scope.model[$scope.options.key] == "false") {
- $scope.model[$scope.options.key] = false;
- };
- }]
- });
- //换行组件
- formlyConfigProvider.setType({
- name: 'ui-nextLine',
- /*extends: 'input',*/
- template: '<div></div>',
- });
- //多选框组件
- formlyConfigProvider.setType({
- name: 'ui-checklist',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- }
- });
- //单选框组件
- formlyConfigProvider.setType({
- name: 'ui-radio',
- extends: 'radio',
- templateUrl: 'assets/views/customform/tpl/ui-radio.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function () { },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', function ($scope) {
- // 巡检生成事件,默认派单
- if ($scope.model.isInspection) {
- $scope.model[$scope.options.key] = true;
- // $scope.model.isHandlerUser=true;
- $scope.model.start_code = "assignment";
- console.log($scope.model);
- };
- //多次暂存配置
- // console.log($scope);
- if ($scope.model.saveAgain) {
- if ($scope.model.directClose == "1" || $scope.model.directClose == true) {
- $scope.model[$scope.options.key] = true;
- // if($scope.model.incident.handlingPersonnelUser){
- // delete $scope.model.incident.handlingPersonnelUser;
- // };
- if ($scope.model.incident.handleDescription) {
- delete $scope.model.incident.handleDescription
- };
- if ($scope.model.incident.closecode) {
- delete $scope.model.incident.closecode
- };
- if ($scope.model.incident.degree) {
- delete $scope.model.incident.degree
- }
- } else {
- $scope.model.incident.handlingPersonnelUser = $scope.model.incident.acceptUser;
- $scope.model[$scope.options.key] = false
- }
- }
- }]
- });
- //文本域组件
- formlyConfigProvider.setWrapper({
- name: 'validation',
- types: ['ui-textarea'],
- template: "<formly-transclude></formly-transclude><div class=\"has-error\" ng-messages=\"fc.$error\" ng-if=\"options.formControl.$touched\"><div class=\"error\" ng-message=\"{{::name}}\" ng-repeat=\"(name, message) in ::options.validation.messages\">{{message(fc.$viewValue, fc.$modelValue, this)}}</div></div>"
- });
- formlyConfigProvider.setType({
- name: 'ui-textarea',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', function ($scope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- if (angular.isFunction($scope.options.templateOptions.felditem)) {
- $scope.options.templateOptions.felditem($scope);
- }
- }]
- });
- // div版的textarea(展示富文本框内容用)
- formlyConfigProvider.setType({
- name: 'ui-divTextarea',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-divTextarea.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- // maxlength: function (viewValue, modelValue, scope) {
- // if (viewValue != null) {
- // if (viewValue.length > scope.to.maxlength) {
- // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- // } else {
- // return "";
- // }
- // }
- // },
- }
- }
- }
- },
- controller: ['$scope', function ($scope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- if (angular.isFunction($scope.options.templateOptions.felditem)) {
- $scope.options.templateOptions.felditem($scope);
- }
- }]
- });
- // 带有知识库引用的textarea
- formlyConfigProvider.setType({
- name: 'ui-textAreaKnowledge',
- // extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-textAreaKnowledge.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_bpm_domain', 'api_solution', '$aside', 'api_zsk', 'up_down_file', 'api_wechatfile', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_bpm_domain, api_solution, $aside, api_zsk, up_down_file, api_wechatfile) {
- // console.log($scope);
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- if (angular.isFunction($scope.options.templateOptions.felditem)) {
- $scope.options.templateOptions.felditem($scope);
- }
- // 引用知识库点击
- $scope.openSolution = function () {
- $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
- setTimeout(() => {
- $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
- }, 100);
- }
- }]
- });
- //常用语句选择textarea
- formlyConfigProvider.setType({
- name: 'ui-textselect',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', function ($scope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- }]
- });
- //改动的组件 ckeditor封装后的组件
- formlyConfigProvider.setType({
- name: 'ui-text-check',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- extraPlugins: 'uploadimage',
- uploadimageConfig: {
- backend: 'basic',
- settings: {
- uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
- headers: '',
- downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
- }
- },
- refresh: function (APIService, contentId, data) {
- return APIService.fetchDataList(contentId, data);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- upload: function (APIService, contentId) {
- return APIService.getSolutionDowpath(contentId);
- },
- view: function (attachmentId) {
- // return APIService.attachmentsPreviewUrl(contentId);
- },
- refreshDelay: 0,
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
- //var expiry={'expiry':14804244006};
- //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
- //$scope.options.templateOptions.uploadimageConfig.settings.headers
- $scope.upload = function (contentId, filename) {
- var filename = filename;
- $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
- var file = new Blob([response], {
- type: 'application/octet-stream'
- });
- // var filename = filename;
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- })
- };
- }]
- });
- //改动的组件 ckeditor封装后的附文本组件
- formlyConfigProvider.setType({
- name: 'ui-fuwenben',
- extends: 'textarea',
- templateUrl: 'assets/views/customform/tpl/ui-fuwenben.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- allowedContent: 'img[!src]',//允许展示源码的标签,否则会被富文本框强制删除
- extraPlugins: 'uploadimage',
- uploadimageConfig: {
- backend: 'basic',
- settings: {
- uploadUrl: options.templateOptions.APIService.upload(-110).getRequestedUrl(),
- headers: '',
- downloadUrl: options.templateOptions.APIService.uploadResponseUri()
- }
- },
- refresh: function (APIService, contentId, data) {
- return APIService.fetchDataList(-110, data);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(-110).getRequestedUrl();
- },
- upload: function (APIService, contentId) {
- return APIService.getSolutionDowpath(-110);
- },
- view: function (attachmentId) {
- // return APIService.attachmentsPreviewUrl(contentId);
- },
- refreshDelay: 0,
- transform: function (model, value) {
- return value;
- },
- },
- validation: {
- messages: {
- maxlength: function (viewValue, modelValue, scope) {
- if (viewValue != null) {
- if (viewValue.length > scope.to.maxlength) {
- return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
- } else {
- return "";
- }
- }
- },
- }
- }
- }
- },
- controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
- var value = $scope.model[$scope.options.key];
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
- }
- $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
- //var expiry={'expiry':14804244006};
- //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
- //$scope.options.templateOptions.uploadimageConfig.settings.headers
- $scope.upload = function (contentId, filename) {
- var filename = filename;
- $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, -110).then(function (response) {
- var file = new Blob([response], {
- type: 'application/octet-stream'
- });
- // var filename = filename;
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- })
- };
- }]
- });
- //ui-grid展示控件
- formlyConfigProvider.setType({
- name: 'ui-grid-show',
- extends: 'multiCheckbox',
- templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- linkage: function () {
- },
- },
- };
- },
- controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
- var loginUser = $rootScope.user;
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- // $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
- $scope.gridOptions.columnDefs = [
- // { name:'id', width:80, enableFiltering:false},
- // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
- // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
- // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
- // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
- // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
- {
- name: 'inspection.title',
- displayName: '计划主题',
- width: 120,
- enableFiltering: false
- },
- {
- name: 'stateName',
- displayName: '状态',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'processUser.name',
- displayName: '处理人',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'startDate',
- displayName: '开始时间',
- width: 160,
- enableFiltering: false
- },
- {
- name: 'overdueTime',
- displayName: '逾期时间',
- width: 160,
- enableFiltering: false
- },
- ];
- var defaultFilterData = {
- "idx": 0,
- "sum": 10
- };
- //分页控制
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.refreshData('expand-right', filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- data.grid.appScope.selected.items = data.entity
- });
- };
- //页面获取数据
- $scope.refreshData = function (style, filterData) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- angular.extend(filterData, {
- inspectionProcessActual: {
- "inspectionid": $scope.model.id
- }
- })
- api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- // $scope.ldloading[style.replace('-', '_')] = false;
- }, function () {
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- //文本框自定义选择面板组件
- formlyConfigProvider.setType({
- name: 'ui-input-selectmodal',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- openModal: function (size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/modal-content.html',
- controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
- size: size,
- resolve: options.templateOptions.modalParam
- });
- modalInstance.result.then(function (selectedItem) {
- options.value(selectedItem);
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- }
- });
- //日期控件
- var datepicker_attr = [
- 'date-disabled',
- 'custom-class',
- 'show-weeks',
- 'starting-day',
- 'init-date',
- 'min-mode',
- 'max-mode',
- 'format-day',
- 'format-month',
- 'format-year',
- 'format-day-header',
- 'format-day-title',
- 'format-month-title',
- 'year-range',
- 'shortcut-propagation',
- 'datepicker-popup',
- 'show-button-bar',
- 'current-text',
- 'clear-text',
- 'close-text',
- 'close-on-date-selection',
- 'datepicker-append-to-body'
- ];
- var datepicker_bindings = [
- 'datepicker-mode',
- 'min-date',
- 'max-date'
- ];
- formlyConfigProvider.setType({
- name: 'ui-datetime',
- templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function ($scope, $filter) {
- $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }]
- });
- //日期控件
- formlyConfigProvider.setType({
- name: 'ui-datepicker',
- templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
- extends: 'input',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: {
- ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
- templateOptions: {
- datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
- }
- },
- controller: ['$scope', '$filter', function ($scope, $filter) {
- // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
- if ($scope.model[$scope.options.key]) {
- } else {
- $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
- }
- $scope.options.initialValue = $scope.model[$scope.options.key];
- $scope.endOpen = true;
- $scope.datepicker = {};
- $scope.datepicker.opened = false;
- $scope.datepicker.open = function ($event) {
- $scope.datepicker.opened = true;
- };
- }]
- });
- //时分控件
- formlyConfigProvider.setType({
- name: 'ui-datehourtime',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
- defaultOptions: function (options) {
- return {
- noFormControl: true,
- // validators:{
- // required:{
- // expression:function(viewValue, modelValue){
- // console.log(options)
- // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
- // // var value = modelValue.getHours() || viewValue.getHours();
- // return value.length>=1;
- // }
- // }
- // }
- }
- },
- controller: ['$scope', '$log', function ($scope, $log) {
- $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
- $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
- $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
- }]
- });
- //状态追踪
- formlyConfigProvider.setType({
- name: 'ui-followStatus',
- templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
- controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
- setTimeout(function () {
- var pkey = $scope.options.templateOptions.pkey;
- var dataId = $scope.model.id;
- if (dataId) {
- api_bpm_data.fetchData(pkey, dataId).then(function (response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- var processInstanceId = myData.data.processInstanceId;
- $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
- if (result.status == 200) {
- var newData = Restangular.stripRestangular(result);
- $scope.followData = newData.data;
- }
- });
- }
- })
- }
- }, 10);
- }]
- });
- //历史记录
- formlyConfigProvider.setType({
- name: 'ui-history',
- templateUrl: 'assets/views/customform/tpl/ui-history.html',
- controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
- setTimeout(function () {
- var pkey = $scope.options.templateOptions.pkey;
- var dataId = $scope.model.id;
- api_bpm_data.fetchData(pkey, dataId).then(function (response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- var processInstanceId = myData.data.processInstanceId;
- $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
- if (result.status == 200) {
- var newData = Restangular.stripRestangular(result);
- var long = newData.data.length - 1;
- $scope.followData = newData.data[long];
- }
- });
- }
- })
- }, 10);
- }]
- });
- // //请求人信息显示
- // formlyConfigProvider.setType({
- // name: "ui-disrequester",
- // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
- // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- // defaultOptions: function(options) {
- // return {
- // templateOptions: {}
- // };
- // },
- // controller: ['$scope', function($scope) {
- // $scope.options.templateOptions.that = $scope;
- // }]
- // });
- //退回人信息显示
- formlyConfigProvider.setType({
- name: "ui-returnperson",
- templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.group = "";
- $scope.role = "";
- if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- }
- }
- if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
- $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
- $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
- }
- }
- $scope.options.templateOptions.that = $scope;
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //退回人信息显示(去掉工作组&角色)
- formlyConfigProvider.setType({
- name: "ui-returnpersonNoGroup",
- templateUrl: 'assets/views/customform/tpl/ui-returnpersonNoGroup.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.group = "";
- $scope.role = "";
- if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- }
- }
- if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
- $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
- $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
- }
- }
- $scope.options.templateOptions.that = $scope;
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //指派技术人员
- formlyConfigProvider.setType({
- name: "ui-apiontperson",
- templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transtlara: function (value, $scope) { }
- }
- };
- },
- controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
- var filterData = {
- "idx": 0,
- "sum": 1000
- }
- api_user_data.fetchDataList('group', filterData).then(function (response) {
- if (response.status == 200) {
- $scope.select = {};
- $scope.multipleDemo = {};
- $scope.userdata = {};
- var data = response.list;
- var item = [];
- $scope.multipleDemo = data;
- $scope.multipleDemo;
- }
- })
- $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
- if (groupdata.option) {
- $scope.model[$scope.options.key] = {};
- var fildate = {
- "idx": 0,
- "sum": 1000,
- "user": {
- "roledata": {
- "rolecode": model.currentRole
- },
- "selectType": "1",
- "groupdata": {
- "id": groupdata.option.id
- }
- }
- }
- api_user_data.fetchDataList('user', fildate).then(function (response) {
- if (response.status == 200) {
- $scope.userdata = {};
- $scope.userdata = response.list;
- }
- })
- } else {
- $scope.model[$scope.options.key] = {
- id: groupdata.id.id
- }
- $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
- }
- }
- // }
- }]
- });
- //请求科室信息(小蓝框) lmm
- formlyConfigProvider.setType({
- name: 'ui-deptinformation',
- templateUrl: 'assets/views/customform/tpl/ui-deptinformation.html',
- defaultOptions: function (options, $scope, $rootScope, api_statistic) {
- return {
- templateOptions: {
- checkform: function (options) {
- }
- }
- };
- },
- controller: ['$scope', 'api_statistic', function ($scope, api_statistic) {
- // console.log($scope)
- }]
- });
- //请求人信息
- formlyConfigProvider.setType({
- name: 'ui-requesterinformation',
- templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
- defaultOptions: function (options, $scope, $rootScope, api_statistic) {
- return {
- templateOptions: {
- checkform: function (options) {
- if (options.model.requester) {
- options.value(options.model.requester);
- }
- },
- addRequeter: function (size, options, modal) {
- event.preventDefault();
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
- $scope.title = "新增报修人";
- $scope.requester = {};
- $scope.searchData = {};
- $scope.onChangeadd = function (searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- if (requesdata.mphone) {
- delete requesdata.mphone;
- }
- $scope.requester = requesdata;
- console.log($scope.requester)
- }
- $scope.refreshUseradd = function (searchKey) { //请求人搜索
- $scope.requester.account = searchKey;
- $scope.searchData = searchKey;
- serchdataadd(searchKey);
- }
- $scope.getMydata = function (x) {
- $scope.searchField = JSON.parse(x[0]).account;
- $scope.requester = JSON.parse(x[0]);
- console.log($scope.requester)
- }
- $scope.getMydataone = function (x) {
- $scope.searchField = x;
- $scope.requester.account = x;
- }
- serchdataadd();
- api_wechatfile.getDictionary({
- "type": "list",
- "key": "male"
- }).then(function (data) {
- if (data.status == 200) {
- requester.gender = data.list;
- }
- })
- function serchdataadd(searchKey) {
- if (searchKey) {
- var filterData = {
- 'requester': {
- 'searchKey': searchKey,
- },
- idx: 0,
- sum: 10
- };
- } else {
- var filterData = {
- idx: 0,
- sum: 10
- };
- }
- api_user_data.fetchDataList('requester', filterData).then(function (response) {
- var myData = response;
- $scope.myData = myData.list;
- });
- }
- api_user_data.fetchDataList('area', {
- idx: 0,
- sum: 1000
- }).then(function (response) {
- if (response.status == 200) {
- $scope.areas = response.list;
- }
- })
- api_wechatfile.getDictionary({
- key: "requester_type",
- type: "list"
- }, {
- idx: 0,
- sum: 100
- }).then(function (response) {
- if (response) {
- $scope.networktypes = response;
- }
- })
- $scope.requesterAreaid = "";
- $scope.onChange = function (item) {
- $scope.requesterAreaid = item.id;
- api_user_data.fetchDataList('place', {
- place: {
- area: {
- id: item.id
- }
- },
- idx: 0,
- sum: 1000
- }).then(function (response) {
- if (response.status == 200) {
- $scope.places = response.list;
- delete $scope.requester.placeDTO;
- }
- })
- }
- $scope.refresh = function (searchVal) {
- var faildata = {};
- if ($scope.requesterAreaid) {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': {
- 'areaId': $scope.requesterAreaid,
- 'place': searchVal,
- 'selectType': 'pinyin_qs'
- }
- }
- } else {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': {
- 'place': searchVal,
- 'selectType': 'pinyin_qs'
- }
- }
- }
- api_user_data.fetchDataList('place', faildata).then(function (response) {
- $scope.places = response.list;
- delete $scope.requester.placeDTO;
- })
- }
- $scope.refreshDepts = function (key) {
- var filterData = {
- 'idx': 0,
- 'sum': 5,
- 'dept': {
- 'name': key
- }
- };
- UserService.fetchDataList('department', filterData).then(function (response) {
- if (response.status == 200) {
- $scope.depts = response.list;
- }
- })
- }
- $scope.ok = function () {
- if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
- SweetAlert.swal("报修人员编号未填!", "请填写报修人员编号", "error");
- } else if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
- SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
- } else if (angular.isUndefined($scope.requester.requesterType) || $scope.requester.requesterType == null || $scope.requester.requesterTypeDTO == "") {
- SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
- } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
- SweetAlert.swal("报修人联系电话未填!", "请填写报修人联系电话", "error");
- } else {
- $scope.requesterId = $scope.requester.id;
- var data = {
- incident: {
- requester: {
- id: $scope.requesterId
- }
- },
- idx: 0,
- sum: 3
- };
- api_statistic.tableData(data, 'incident').then(function (data) {
- sco.$parent.$parent.$parent.model.incident.tableList = data.list;
- })
- $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
- if (newObj != oldObj) {
- sco.$parent.$parent.$parent.model.incident.tableList = newObj;
- }
- })//lmm
- console.log($scope.requester)
- $modalInstance.close($scope.requester);
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (!filterData.idx) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- UserService: function () {
- return options.templateOptions.UserService;
- },
- sco: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- console.log(selectedItem)
- if (selectedItem) {
- var data = {
- 'requester': selectedItem
- };
- $scope.searchKey = selectedItem.account;
- // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
- // if (selectedItem.place && selectedItem.place.place) {
- // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
- // }
- options.templateOptions.UserService.addData('requester', data).then(function (response) {
- if (response.status == 200) {
- if (options.model) {
- options.model.requester = response.data
- $scope.$parent.$parent.$parent.model.incident.requester = response.data;
- $scope.$parent.$parent.$parent.model.requestershow = response.data;
- if (options.model.place) {
- options.model.place.id = '';
- }
- if (options.model.area) {
- options.model.area.id = '';
- }
- options.model.contacts = selectedItem.name;
- if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
- options.model.contactsInformation = selectedItem.mphone;
- } else {
- options.model.contactsInformation = selectedItem.telephone;
- }
- if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
- }
- }
- if (!response.data.id) {
- response.data.id = selectedItem.id
- }
- options.value(response.data);
- options.value(response.data);
- console.log($scope,'0000000');
- //新增报修人带入区域地点2020年4月23日19:48:15
- $scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
- $scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
- if ($scope.$parent.$parent.$parent.model.saveAgain) {
- if (selectedItem.place && selectedItem.place.id) {
- options.model.place.id = selectedItem.place.id
- options.model.place.area.id = selectedItem.place.area.id
- };
- } else {
- if (selectedItem.place && selectedItem.place.id) {
- options.model.place.id = selectedItem.place.id
- options.model.area.id = selectedItem.place.area.id
- };
- }
- // if (selectedItem.areaDTO && selectedItem.place.area.id) {
- // options.model.area.id = selectedItem.place.area.id
- // }
- if (selectedItem.houseNumber) {
- options.model.houseNumber = selectedItem.houseNumber
- }
- // if (selectedItem.id) {
- options.model.account = selectedItem.account;
- // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
- var baoxiuFields = $scope.$parent.$parent.$parent.$parent.$parent.vm.fields[1].fields;
- var baoxiurenTo;
- baoxiuFields.forEach((e, i) => {
- if (e.key == 'account') {
- baoxiurenTo = e.templateOptions
- baoxiurenTo.APIService.fetchDataList('requester', {
- "idx": 0,
- "sum": 20,
- requester: {
- searchKey: selectedItem.account
- }
- }).then(res => {
- baoxiurenTo.options = res.list;
- options.model.account = selectedItem.account;
- })
- }
- })
- // }
- // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
- // 选择重复事件侧滑框
- // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
- $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
- setTimeout(() => {
- $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
- }, 500);
- // }
- }
- })
- }
- }, function () { });
- },
- changeRequeter: function (size, options, modal, modeldata, $rootScope) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
- controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
- $scope.title = "修改报修人";
- $scope.requester = {
- id: modeldata.requester.id,
- account: modeldata.requester.account,
- name: modeldata.requester.name,
- gender: modeldata.requester.gender,
- email: modeldata.requester.email,
- deptName: modeldata.requester.deptName,
- mphone: modeldata.requester.mphone,
- telephone: modeldata.requester.telephone,
- studentNo: modeldata.requester.studentNo,
- areaDTO: modeldata.requester.areaDTO,
- placeDTO: modeldata.requester.placeDTO,
- requesterTypeDTO: modeldata.requester.requesterTypeDTO
- };
- $scope.onChangeadd = function (searchData) {
- console.log(searchData)
- $scope.searchKey = searchData.account;
- var requesdata = angular.copy(searchData)
- if (requesdata.mphone) {
- delete requesdata.mphone;
- }
- $scope.requester = requesdata;
- }
- $scope.refreshUseradd = function (searchKey) { //请求人搜索
- $scope.requester.account = searchKey;
- $scope.searchData = searchKey;
- serchdataadd(searchKey);
- }
- $scope.getMydata = function (x) {
- $scope.searchField = JSON.parse(x[0]).account;
- $scope.requester = JSON.parse(x[0]);
- }
- $scope.getMydataone = function (x) {
- $scope.searchField = x;
- $scope.requester.account = x;
- }
- serchdataadd();
- function serchdataadd(searchKey) {
- if (searchKey) {
- var filterData = {
- 'requester': {
- 'searchKey': searchKey,
- },
- idx: 0,
- sum: 10
- };
- } else {
- var filterData = {
- idx: 0,
- sum: 10
- };
- }
- api_user_data.fetchDataList('requester', filterData).then(function (response) {
- var myData = response;
- $scope.myData = myData.list;
- });
- }
- api_user_data.fetchDataList('area', {
- idx: 0,
- sum: 1000
- }).then(function (response) {
- if (response.status == 200) {
- $scope.areas = response.list;
- }
- })
- api_user_data.fetchDataList('requesterType', {
- idx: 0,
- sum: 100
- }).then(function (response) {
- if (response.status == 200) {
- $scope.networktypes = response.list;
- }
- })
- if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
- api_user_data.fetchDataList('place', {
- place: {
- areaId: $scope.requester.areaDTO.id
- },
- idx: 0,
- sum: 1000
- }).then(function (response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- $scope.onChange = function (item) {
- $scope.requester.placeDTO = {};
- api_user_data.fetchDataList('place', {
- place: {
- areaId: item.id
- },
- idx: 0,
- sum: 1000
- }).then(function (response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- $scope.refreshDepts = function (key) {
- var filterData = {
- 'idx': 0,
- 'sum': 5,
- 'dept': {
- 'name': key
- }
- };
- UserService.fetchDataList('department', filterData).then(function (response) {
- if (response.status == 200) {
- $scope.depts = response.list;
- }
- })
- }
- $scope.ok = function () {
- if ($scope.requester.account == "" || $scope.requester.name == "") {
- SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
- } else {
- $modalInstance.close($scope.requester);
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (!filterData.idx) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- UserService: function () {
- return options.templateOptions.UserService;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- console.log(selectedItem)
- if (selectedItem) {
- if (options.model) {
- if (options.model.place) {
- options.model.place.id = '';
- }
- if (options.model.area) {
- options.model.area.id = '';
- }
- options.model.contacts = selectedItem.name;
- if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
- options.model.contactsInformation = selectedItem.mphone;
- } else {
- options.model.contactsInformation = selectedItem.telephone;
- }
- if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
- options.model.place.id = selectedItem.placeDTO.id
- }
- if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
- options.model.area.id = selectedItem.areaDTO.id
- }
- if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- $scope.$parent.$parent.$parent.model.incident.influence.id = 1
- }
- }
- var data = {
- 'requester': selectedItem
- };
- options.templateOptions.UserService.addData('requester', data).then(function (response) {
- if (response.status == 200) {
- $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
- options.value(response.data);
- } else { }
- })
- }
- }, function () { });
- event.preventDefault();
- }
- }
- };
- },
- controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
- $scope.options.initialValue = $scope.model[$scope.options.key];
- if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- $scope.$parent.$parent.$parent.model.incident.influence.id = 1
- }
- }]
- });
- // 请求人选控件
- formlyConfigProvider.setType({
- name: "ui-requesterselect",
- templateUrl: 'assets/views/customform/tpl/ui-requester.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options, $scope) {
- return {
- templateOptions: {
- // checkform: function(options) {
- // if (options.model.requestershow) {
- // options.value(options.model.requestershow);
- // }
- // },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value.length >= 1;
- }
- }
- },
- openModal: function (size, options, modal) { //查找弹出框
- var modelObject = options.value();
- var searchModal = function (filterSearchData) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [{
- name: 'account',
- displayName: '人员编号',
- width: 140
- },
- {
- name: 'name',
- displayName: '姓名',
- width: 100
- },
- {
- name: 'gender.name',
- displayName: '性别',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'mphone',
- displayName: '电话',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'email',
- displayName: '邮件',
- width: 100
- },
- {
- name: 'areaDTO.area',
- displayName: '区域',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'placeDTO.place',
- displayName: '地点',
- enableFiltering: false
- }
- ];
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.loadData(filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
- $scope.selected.item = data.entity;
- // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10
- // 'requester': { 'userType': 1 }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['requester'])) {
- filtersData['requester'] = {};
- }
- filtersData['requester'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- $scope.memoryfilterData = defaultFilterData = {
- "idx": 0,
- "sum": 10
- };
- $scope.loadData = function (filterData) {
- if (!filterData.requester) {
- filterData.requester = {};
- }
- if (scope.roleidcode) {
- angular.extend(filterData['requester'], {
- 'userType': 1
- });
- }
- items.fetchItems(filterData, APIService).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- // $scope.title = title;
- if (searchDatas) {
- $scope.loadData(searchDatas);
- } else {
- $scope.loadData({
- idx: 0,
- sum: 10,
- });
- }
- $scope.selected = {
- item: {}
- };
- $scope.ok = function () {
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- language: function () {
- return options.templateOptions.language;
- },
- searchDatas: function () {
- return filterSearchData;
- },
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if ($scope.$parent.$parent.$parent.model.incident.callID) {
- selectedItem.telephone = $scope.model.incident.contactsInformation;
- }
- $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
- // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
- // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
- if ($scope.model) {
- if ($scope.model.incident.place) {
- $scope.model.incident.place.id = '';
- }
- if ($scope.model.area) {
- $scope.model.incident.area.id = '';
- }
- $scope.model.incident.contacts = selectedItem.name;
- if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
- $scope.model.incident.contactsInformation = selectedItem.mphone;
- } else {
- $scope.model.incident.contactsInformation = selectedItem.telephone;
- }
- $scope.model.incident.houseNumber = '';
- if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- $scope.$parent.$parent.$parent.model.incident.influence.id = 1
- }
- }
- $scope.options.value(selectedItem);
- $scope.searchData = selectedItem.account;
- if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
- $scope.model.incident.place.id = selectedItem.placeDTO.id
- }
- if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
- $scope.model.incident.area.id = selectedItem.areaDTO.id
- }
- if (selectedItem.houseNumber) {
- $scope.model.incident.houseNumber = selectedItem.houseNumber;
- }
- if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- $scope.$parent.$parent.$parent.model.incident.influence.id = 1
- }
- if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
- options.templateOptions.callback(selectedItem, options);
- }
- if (!$scope.roleidcode) {
- $scope.charging(selectedItem, modal)
- }
- $scope.recentlyincident(selectedItem);
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- searchModal();
- // }
- }
- }
- };
- },
- controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
- $scope.roleidcode = true;
- // $scope.options.initialValue = undefined;
- if ($rootScope.user && $rootScope.user.role) {
- angular.forEach($rootScope.user.role, function (item) {
- if (item.rolecode == "call center") {
- $scope.roleidcode = false;
- }
- })
- }
- $scope.recently = false;
- $scope.recentlyincident = function (key, model) { //关联事件
- $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
- "idx": 0,
- "sum": 4,
- incident: {
- requester: {
- id: key.id
- }
- }
- }).then(function (response) {
- if (response.status == 200) {
- $scope.recently = true;
- $scope.recentincident = response.list;
- } else {
- $scope.recently = false;
- }
- })
- $scope.bodyHeight = window.innerHeight - 100;
- $(window).resize(function () {
- $scope.bodyHeight = window.innerHeight - 100;
- });
- // $scope.shows = false;
- $scope.tempData = {};
- $scope.close = function () {
- $scope.changes = !$scope.changes;
- event.preventDefault();
- }
- }
- $scope.charging = function (key, model) { //计费弹出框
- //用户信息
- $scope.information = {};
- $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
- "userId": key.account
- }).then(function (response) {
- // if (response.status == 200) {
- if (response && response.data) {
- angular.extend($scope.information, response.data[0]);
- // $scope.information = response.data[0];
- $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
- $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
- $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
- } else if (response.err) {
- SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
- }
- // }
- })
- //上网明细
- $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
- "userId": key.account,
- "limit": "10",
- "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
- "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
- }).then(function (response) {
- // if (response.status == 200) {
- if (response && response.data) {
- angular.forEach(response.data, function (item, index) {
- if (item.logoutTime) {
- response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
- }
- if (item.loginTime) {
- response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
- }
- })
- $scope.logininform = response.data;
- } else if (response.err) {
- SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
- }
- })
- //黑名单
- // $scope.information.blacklist = "否"
- $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
- "userId": key.account
- }).then(function (response) {
- // if (response.status == 200) {
- // $scope.logininformation = response.data;
- if (response) {
- if (response.data || response.data != null) {
- $scope.information.blacklist = "是"
- } else {
- if (response.err) {
- // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
- } else {
- $scope.information.blacklist = "否"
- }
- }
- }
- // }
- })
- $scope.bodyHeight = window.innerHeight - 100;
- $(window).resize(function () {
- $scope.bodyHeight = window.innerHeight - 100;
- });
- // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
- // $scope.closepages = function(e) {
- // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
- // event.preventDefault();
- // };
- // $scope.shows = false;
- $scope.tempData = {};
- $scope.close = function () {
- $scope.changes = !$scope.changes;
- event.preventDefault();
- }
- }
- $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
- idx: 0,
- sum: 100
- }).then(function (response) {
- if (response.status == 200) {
- $scope.networktypes = response.list;
- } else {
- SweetAlert.swal("系统错误!", "请刷新重试", "error");
- }
- })
- function serchdata(searchKey) {
- if (searchKey) {
- var filterData = {
- 'requester': {
- 'searchKey': searchKey
- // 'userType': 1
- },
- idx: 0,
- sum: 10
- };
- } else {
- var filterData = {
- 'idx': 0,
- 'requester': {},
- 'sum': 10
- };
- }
- if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
- angular.extend(filterData.requester, {
- 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
- });
- if (!$scope.options.model.contactsInformation) {
- $scope.options.model.contactsInformation = $scope.model.requester.mphone;
- }
- }
- if ($scope.roleidcode) {
- angular.extend(filterData['requester'], {
- 'userType': 1
- });
- }
- $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
- var myData = response;
- $scope.myData = myData.list;
- });
- }
- $scope.searchData = {};
- $scope.refreshUser = function (searchKey) { //请求人搜索
- if (searchKey && searchKey != "") {
- serchdata(searchKey);
- }
- }
- if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
- if (!$scope.roleidcode) {
- $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
- }
- $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
- }
- $scope.onChange = function (searchData) {
- if ($scope.$parent.$parent.$parent.model.incident.callID) {
- searchData.telephone = $scope.model.incident.contactsInformation;;
- }
- $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
- if (!$scope.roleidcode) {
- $scope.charging(searchData);
- }
- $scope.recentlyincident(searchData);
- $scope.accountshow = false;
- if ($scope.model.incident) {
- if ($scope.model.incident.place) {
- $scope.model.incident.place.id = '';
- }
- if ($scope.model.incident.area) {
- $scope.model.incident.area.id = '';
- }
- $scope.model.incident.contacts = searchData.name;
- if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
- $scope.model.incident.contactsInformation = searchData.mphone;
- } else {
- $scope.model.incident.contactsInformation = searchData.telephone;
- }
- $scope.model.incident.houseNumber = '';
- if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
- }
- }
- $scope.options.value(searchData);
- $scope.searchKey = searchData.account;
- if (searchData.placeDTO && searchData.placeDTO.id) {
- $scope.model.incident.place.id = searchData.placeDTO.id
- }
- if (searchData.areaDTO && searchData.areaDTO.id) {
- $scope.model.incident.area.id = searchData.areaDTO.id
- }
- if (searchData.houseNumber) {
- $scope.model.incident.houseNumber = searchData.houseNumber;
- }
- if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
- $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
- $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
- $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
- }
- }
- }]
- });
- //ui-grid-table展示控件
- formlyConfigProvider.setType({
- name: 'ui-grid-table',
- // extends: 'multiCheckbox',//去掉冒号
- templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- linkage: function () { },
- },
- };
- },
- controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
- var loginUser = $rootScope.user;
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = false;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = false;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 3;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'incidentsign',
- displayName: '单号',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'description',
- displayName: '主题',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'state.name',
- displayName: '状态',
- width: 110,
- enableFiltering: false
- },
- {
- name: 'acceptDate',
- displayName: '创建时间',
- width: 160,
- enableFiltering: false
- },
- {
- name: 'requester.name',
- displayName: '请求人',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'handlingPersonnelUser.name',
- displayName: '处理人',
- width: 160,
- enableFiltering: false
- },
- {
- name: 'place.place',
- displayName: '区域地点',
- width: 160,
- enableFiltering: false
- },
- ];
- // var defaultFilterData = {
- // "idx": 0,
- // "sum": 3
- // };
- // // //分页控制
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.refreshData('expand-right', filtersData);
- });
- // 表格单选事件
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
- data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
- data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
- var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
- str = str.split("").reverse().join("");
- var del = addstr.split("").reverse().join("");
- // console.log(del);
- var reg = new RegExp(del);
- str = str.replace(reg, '');
- str = str.split("").reverse().join("")
- if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
- data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
- str += data.entity.description;
- data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
- } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
- data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
- data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
- }
- data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
- data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
- });
- };
- // 刷新表格
- setInterval(function () {
- // console.log($scope.myData);
- $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
- // console.log($scope.myData);
- if ($scope.myData != null) {
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]['item'] = i + 1;
- }
- }
- }, 1000)
- }
- });
- //处理人信息
- formlyConfigProvider.setType({
- name: "ui-userinformation",
- templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.group = "";
- $scope.role = "";
- if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- }
- }
- if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
- $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
- $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
- }
- }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //处理界面处理人信息
- formlyConfigProvider.setType({
- name: "ui-handler",
- templateUrl: 'assets/views/customform/tpl/ui-handler.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.group = "";
- // $scope.role="";
- if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
- $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
- } else {
- for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
- $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
- }
- }
- // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
- // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
- // }else{
- // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
- // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
- // }
- // }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //微信事件流程
- formlyConfigProvider.setType({
- name: "ui-wxIncidentProcess",
- templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', function ($scope) {
- console.log($scope.model);
- $scope.pingjia = false;
- $scope.jiejue = false;
- if ($scope.model.incidentState.value == "3") {
- $scope.pingjia = true
- } else if ($scope.model.incidentState.value == "4") {
- $scope.jiejue = true;
- }
- }]
- });
- //打电话
- formlyConfigProvider.setType({
- name: "ui-inputcall",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/inputcall.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- transform: function (value) { }
- }
- };
- },
- controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
- $scope.dialout = function (teleno) {
- var gid = "@0"
- var telephone = '9' + teleno
- $rootScope.callout = 2;
- if ($rootScope.takes) {
- api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
- if (data.errno == 0) {
- $rootScope.status = 6;
- }
- })
- } else {
- SweetAlert.swal({
- title: "呼叫失败",
- text: "请先签入呼叫中心!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //关闭界面处理人信息
- formlyConfigProvider.setType({
- name: "ui-closehandler",
- templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {}
- };
- },
- controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
- $scope.dialout = function (teleno) {
- var gid = "@0"
- var telephone = '9' + teleno
- api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
- if (data.errno == 0) {
- $rootScope.status = 6;
- }
- })
- }
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //用户单选控件
- formlyConfigProvider.setType({
- name: "ui-userselect",
- templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- openModal: function (size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions.columnDefs = [{
- name: 'account',
- displayName: '人员编号',
- width: 120
- },
- {
- name: 'name',
- displayName: '姓名',
- width: 100,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
- '</div>'
- },
- // {
- // name: 'gender.name',
- // displayName: '性别',
- // width: 80,
- // enableFiltering: false
- // },
- {
- name: 'phone',
- displayName: '电话',
- width: 230,
- enableFiltering: false
- },
- {
- name: 'email',
- displayName: '邮箱',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'dept.dept',
- displayName: '科室',
- width: 130,
- enableFiltering: false
- },
- {
- name: 'taskCount',
- displayName: '处理中事件数',
- enableFiltering: false
- }
- ];
- // $scope.selectButtonClick
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.loadData(filtersData);
- //console.log(pageSize);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- // gridApi.selection.on.selectAllRows = function(row) { //GridRow
- // // if (row.entity.age > 45) {
- // row.grid.api.selection.selectRow(row.entity); // 选中行
- // // }
- // };
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
- // if (row.entity.age > 45) {
- // row.grid.api.selection.selectRow(row.entity); // 选中行
- // }
- // },
- $scope.onDblClick = function (data, event) {
- // $scope.selected.items = data.entity;
- $scope.selectButtonClick(data, event);
- };
- // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // $scope.selected.items = data.entity;
- // })
- // };
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- }
- $scope.loadData = function (filterData) {
- // console.log("filtersData=111" + JSON.stringify(filterData))
- items.fetchItems(filterData, APIService).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- // $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- });
- $scope.selected = {
- items: {}
- };
- $scope.ok = function () {
- // if(onDataCallback&&angular.isFunction(onDataCallback)){
- // onDataCallback($scope.selected.item, parentScope);
- // }
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": "roleset"
- },
- "selectType": "1"
- }
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return options.templateOptions.label;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- onDataCallback: function () {
- return options.templateOptions.callback;
- },
- parentScope: function () {
- return options.templateOptions.that;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // console.log(selectedItem);
- options.value(selectedItem);
- if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
- options.templateOptions.callback(selectedItem, options.templateOptions.that);
- }
- if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
- options.templateOptions.linkData(selectedItem, options.templateOptions.that);
- }
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.options.templateOptions.that = $scope;
- // $scope.options.model[$scope.options.key] = {}
- }]
- });
- //用户单选控件(dd 单选input带搜索)
- formlyConfigProvider.setType({
- name: "ui-userselectSearch",
- templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- openModal: function (size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions.columnDefs = [{
- name: 'account',
- displayName: '人员编号',
- width: 120
- },
- {
- name: 'name',
- displayName: '姓名',
- width: 100,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
- '</div>'
- },
- // {
- // name: 'gender.name',
- // displayName: '性别',
- // width: 80,
- // enableFiltering: false
- // },
- {
- name: 'phone',
- displayName: '电话',
- width: 230,
- enableFiltering: false
- },
- {
- name: 'email',
- displayName: '邮箱',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'dept.dept',
- displayName: '科室',
- width: 130,
- enableFiltering: false
- },
- {
- name: 'taskCount',
- displayName: '处理中事件数',
- enableFiltering: false
- }
- ];
- // $scope.selectButtonClick
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.loadData(filtersData);
- //console.log(pageSize);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
- $scope.selected.items = data.entity;
- //console.log(data);
- });
- // gridApi.selection.on.selectAllRows = function(row) { //GridRow
- // // if (row.entity.age > 45) {
- // row.grid.api.selection.selectRow(row.entity); // 选中行
- // // }
- // };
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- user: {
- roledata: {
- rolecode: "first-line support"
- },
- selectType: "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- // console.log("item.filters[0]=" + JSON.stringify(item.filters));
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
- // if (row.entity.age > 45) {
- // row.grid.api.selection.selectRow(row.entity); // 选中行
- // }
- // },
- $scope.onDblClick = function (data, event) {
- // $scope.selected.items = data.entity;
- $scope.selectButtonClick(data, event);
- };
- // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // $scope.selected.items = data.entity;
- // })
- // };
- $scope.memoryfilterData = {
- idx: 0,
- sum: 10,
- user: {
- roledata: {
- rolecode: "first-line support"
- },
- selectType: "1"
- }
- }
- $scope.loadData = function (filterData) {
- // console.log("filtersData=111" + JSON.stringify(filterData))
- items.fetchItems(filterData, APIService).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10,
- user: {
- roledata: {
- rolecode: "first-line support"
- },
- selectType: "1"
- }
- });
- $scope.selected = {
- items: {}
- };
- $scope.ok = function () {
- // if(onDataCallback&&angular.isFunction(onDataCallback)){
- // onDataCallback($scope.selected.item, parentScope);
- // }
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10,
- user: {
- roledata: {
- rolecode: "first-line support"
- },
- selectType: "1"
- }
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return options.templateOptions.label;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- onDataCallback: function () {
- return options.templateOptions.callback;
- },
- parentScope: function () {
- return options.templateOptions.that;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- // console.log(selectedItem);
- options.value(selectedItem);
- if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
- options.templateOptions.callback(selectedItem, options.templateOptions.that);
- }
- if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
- options.templateOptions.linkData(selectedItem, options.templateOptions.that);
- }
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.options.templateOptions.that = $scope;
- }]
- });
- //用户多选控件
- formlyConfigProvider.setType({
- name: "ui-multiuserselect",
- templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- openModal: function (size, options, modal, model) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
- $scope.gridOptions.columnDefs = [
- // { name:'id', width:80, enableFiltering:false},
- {
- name: 'account',
- displayName: '账号',
- width: 140
- },
- {
- name: 'name',
- displayName: '名称',
- width: 100
- },
- {
- name: 'gender.name',
- displayName: '性别',
- width: 140,
- enableFiltering: false
- },
- {
- name: 'phone',
- displayName: '电话',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'email',
- displayName: '邮件',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'dept.dept',
- displayName: '科室',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'group[0].groupName',
- displayName: '职位',
- width: 100,
- enableFiltering: false
- }
- ];
- $scope.selected = {
- items: selectItems
- };
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.loadData(filtersData);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
- var j = 0;
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i] == scope.entity) {
- j++;
- break;
- }
- }
- if (j == 1) {
- scope.grid.appScope.selected.items.splice(i, 1);
- } else {
- scope.grid.appScope.selected.items.push(scope.entity)
- for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
- for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
- // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
- // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
- if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
- scope.grid.appScope.selected.items.splice(i, 1);
- }
- }
- }
- }
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
- // $scope.grid.appScope.selected.items.push($scope.entity);
- // });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": options.model.currentRole
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- //console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- if (!options.model) {
- var mouse = {
- "model": {
- "currentRole": ""
- }
- };
- angular.extend(options, mouse);
- }
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 10,
- "user": {
- "roledata": {
- "rolecode": options.model.currentRole
- },
- "selectType": "1"
- }
- }
- $scope.loadData = function (filterData) {
- // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
- items.fetchItems(filterData, APIService).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- //console.log($scope.gridOptions.pagination.getTotalPages());
- // if($scope.selected.items){
- // angular.forEach($scope.selected.items,function(selectItem){
- // $scope.gridApi.selection.selectRow(selectItem);
- // });
- // }
- });
- };
- // $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": options.model.currentRole
- },
- "selectType": "1"
- }
- });
- // $timeout(function(){
- // if($scope.selected.items){
- // angular.forEach($scope.selected.items,function(selectItem){
- // $scope.gridApi.selection.selectRow(selectItem);
- // });
- // }
- // },2000)
- $scope.ok = function () {
- // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": options.model.incident.currentRole
- },
- "selectType": "1"
- }
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService);
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- selectItems: function () {
- return model || [];
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- options.value(selectedItem);
- options.formControl.$validate();
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- },
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value.length >= 1;
- }
- }
- }
- };
- },
- controller: ['$scope', function ($scope) {
- $scope.model[$scope.options.key] = [];
- $scope.remove = function (itemId) {
- angular.forEach($scope.model[$scope.options.key], function (entry, index) {
- if (entry.id == itemId) {
- $scope.model[$scope.options.key].splice(index, 1);
- // console.log($scope.options.formControl)
- $scope.options.formControl.$validate();
- } else {
- }
- });
- }
- }]
- });
- //用户多选控件-字符串展示
- formlyConfigProvider.setType({
- name: 'ui-stringuserselect',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- translate: '',
- refreshDelay: 0
- }
- }
- },
- controller: ['$scope', function ($scope) {
- var keydata = "";
- if (angular.isArray($scope.model)) {
- angular.forEach($scope.model, function (item) {
- keydata = keydata + "," + item.name;
- })
- }
- // $scope.model[$scope.options.key] = [];
- }]
- });
- //重复事件
- formlyConfigProvider.setType({
- name: "ui-incidentmodelselect",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- openModal: function (size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- var mun = $scope.gridOptions.paginationPageSize;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.transferTime = function (time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // console.log(newPage);
- // console.log(pageSize);
- $scope.loadData({
- "idx": newPage - 1,
- "sum": pageSize
- });
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 100
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- filtersData['incident'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['problem'])) {
- filtersData['problem'] = {};
- }
- filtersData['problem'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['change'])) {
- filtersData['change'] = {};
- }
- filtersData['change'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['release'])) {
- filtersData['release'] = {};
- }
- filtersData['release'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.loadData(filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- //资产
- $scope.cmdb = {}
- //资产状态
- $scope.state_data = [{
- "name": "全部状态",
- "value": ""
- },
- {
- "name": "在库",
- "value": "1"
- },
- {
- "name": "在线",
- "value": "2"
- },
- {
- "name": "借出",
- "value": "3"
- },
- {
- "name": "报修",
- "value": "4"
- },
- {
- "name": "报废",
- "value": "5"
- },
- {
- "name": "备用",
- "value": "6"
- },
- ]
- //资产类型
- $scope.wt_zcfl = function () {
- api_configure_data.fetchDataList('ciclassify', {
- idx: 0,
- sum: 100
- }).then(function (data) {
- console.log(data);
- // $scope.wt_zclx = data.list;
- console.log(data);
- $scope.wtData = []
- if (data.status == 200) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- // $scope.wtData=data.list;
- data = data.list;
- //知识库分类数据三级处理
- for (var i = 0; i < data.length; i++) {
- // console.log(data[i])
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- // console.log(datum);
- datum.children = [];
- if (!datum.parent) {
- $scope.wtData.push(datum);
- // console.log($scope.wtData)
- } else {
- if ($scope.wtData[0]) {
- if ($scope.wtData[0].id == datum.parent.id) {
- $scope.wtData[0].children.push(datum);
- }
- for (var j = 0; j < $scope.wtData[0].children.length; j++) {
- if ($scope.wtData[0].children[j].id == datum.parent.id) {
- $scope.wtData[0].children[j].children.push(datum);
- }
- };
- }
- if ($scope.wtData[1]) {
- if ($scope.wtData[1].id == datum.parent.id) {
- $scope.wtData[1].children.push(datum);
- }
- for (var j = 0; j < $scope.wtData[1].children.length; j++) {
- if ($scope.wtData[1].children[j].id == datum.parent.id) {
- $scope.wtData[1].children[j].children.push(datum);
- }
- };
- }
- if ($scope.wtData[2]) {
- if ($scope.wtData[2].id == datum.parent.id) {
- $scope.wtData[2].children.push(datum);
- }
- for (var j = 0; j < $scope.wtData[2].children.length; j++) {
- if ($scope.wtData[2].children[j].id == datum.parent.id) {
- $scope.wtData[2].children[j].children.push(datum);
- }
- };
- }
- }
- // console.log($scope.wtData)
- idToNodeMap[datum.id] = datum;
- root = datum;
- // treeMap[datum.id] = root;
- }
- }
- });
- }
- $scope.wt_zcfl();
- //事件
- //受理人,处理人
- $scope.searchkeys = {};
- var fieldata = {
- "idx": 0,
- "sum": 100,
- "flag": -1
- };
- getUser(fieldata, 3);
- function getUser(fieldatas, it) {
- api_user_data.fetchDataList('user', fieldatas).then(function (data) {
- if (it == 1) {
- $scope.acceptUser = data.list;
- } else if (it == 2) {
- $scope.handlingPersonnelUser = data.list;
- } else if (it == 3) {
- $scope.acceptUser = data.list;
- $scope.handlingPersonnelUser = data.list;
- }
- });
- }
- //状态
- $scope.othcode = {};
- api_bpm_data.fetchDataList('incidentstatus', {
- "idx": 0,
- "sum": 100
- }).then(function (response) {
- if (response) {
- if (response.status = 200) {
- $scope.state = response.list;
- }
- }
- })
- var defaultFilterData = {
- "assignee": $rootScope.user.id,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- var defaultFilterData1 = {
- // "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- //搜索
- $scope.chiceIncident = function (parameters, item, stateid) {
- console.log(item, stateid);
- console.log($scope);
- if ($scope.title == '关联资产编号') {
- // alert('222222222222');
- var fildata = defaultFilterData1;
- $scope.gridOptions.paginationCurrentPage = 1;
- var transitiondata = angular.copy(item);
- angular.extend(fildata, transitiondata);
- if (fildata.hw_state) {
- fildata.hw_state = fildata.hw_state.name;
- }
- if (fildata.sign) {
- fildata.sign = fildata.sign.prefix + fildata.sign.sign;
- fildata.sign = fildata.sign.split(';');
- fildata.sign = fildata.sign.join('');
- fildata.sign = fildata.sign.toLowerCase()
- }
- if (fildata.keys) {
- fildata['searchCriteria'] = 'uuid';
- }
- console.log(fildata);
- $scope.loadData(fildata);
- }
- if ($scope.title == '关联事件工单') {
- // alert('3333333333333333')
- if (stateid && stateid.code) {
- item.statusId = stateid.code;
- }
- var fildata = defaultFilterData;
- // $scope.memoryfilterData = fildata;
- if (!fildata.incident) {
- fildata['incident'] = {};
- }
- $scope.gridOptions.paginationCurrentPage = 1;
- var transitiondata = angular.copy(item);
- angular.extend(fildata.incident, transitiondata);
- console.log(fildata)
- // $scope.loadData(fildata);
- api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
- console.log(data)
- if (data) {
- $scope.myData = data.list;
- $scope.gridOptions.totalItems = data.totalNum;
- }
- })
- }
- }
- //重置
- $scope.replacement = function (parameters, searchkeys, othcode) {
- // console.log(parameters, searchkeys, othcode);
- delete (defaultFilterData.incident);
- console.log(defaultFilterData)
- $scope.parameters = null;
- $scope.searchkeys = {};
- $scope.othcode = {};
- $scope.wt_zcfl();
- }
- $scope.loadData = function (filterData) {
- items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- if (myData.data && myData.data.node) {
- $scope.gridOptions.totalItems = myData.total;
- $scope.myData = myData.data.node;
- } else {
- if (myData.resultCount) {
- $scope.gridOptions['totalItems'] = myData.resultCount;
- } else {
- $scope.gridOptions.totalItems = myData.totalNum;
- }
- if (myData.list) {
- $scope.myData = myData.list;
- } else {
- $scope.myData = myData.data;
- }
- }
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10
- });
- $scope.selected = {
- item: {}
- };
- $scope.ok = function () {
- //console.log($scope.selected.item);
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService, $rootScope) {
- filterData = filterData || {};
- // if(!filterData.idx){
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
- },
- columnDefs: function () {
- return options.templateOptions.columnDefs;
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- var selectitem = {
- title: selectedItem.title,
- description: selectedItem.description
- }
- if (options.key == "chuku") {
- if (selectedItem.assets) {
- $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
- }
- if (selectedItem.consumables) {
- $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
- }
- angular.extend($scope.$parent.$parent.$parent.model, selectitem);
- options.value(selectedItem);
- // options.model.consumables = JSON.parse(consumables);
- } else if (options.templateOptions.pkey == "change") {
- console.log(options)
- angular.extend(options.model);
- options.value(selectedItem);
- } else if (options.key == "cmdbCode") {
- var zc_selectitem = selectedItem.uuid;
- // angular.extend(options.model,zc_selectitem);
- options.model.cmdbCode = zc_selectitem;
- // angular.extend(options.model,zc_selectitem);
- // options.templateOptions.displayName=zc_selectitem;
- options.value(selectedItem);
- console.log(options.model)
- } else {
- angular.extend(options.model, selectitem);
- options.value(selectedItem);
- }
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- }
- });
- //选项选择控件
- formlyConfigProvider.setType({
- name: "ui-modelselect",
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- openModal: function (size, options, modal) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = false;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = items.columnDefs();
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // console.log(newPage);
- // console.log(pageSize);
- $scope.loadData({
- "idx": newPage - 1,
- "sum": pageSize
- });
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- // console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- filtersData['incident'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['problem'])) {
- filtersData['problem'] = {};
- }
- filtersData['problem'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['change'])) {
- filtersData['change'] = {};
- }
- filtersData['change'][item.field] = item.filters[0].term;
- if (angular.isUndefined(filtersData['release'])) {
- filtersData['release'] = {};
- }
- filtersData['release'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.loadData(filtersData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- $scope.selected.item = data.entity;
- //console.log(data);
- });
- };
- $scope.loadData = function (filterData) {
- items.fetchItems(filterData, APIService).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- $scope.title = title;
- $scope.loadData({
- idx: 0,
- sum: 10
- });
- $scope.selected = {
- item: {}
- };
- $scope.ok = function () {
- if ($scope.selected.item.scheduleOrder) {
- $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
- }
- //console.log($scope.selected.item);
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) {
- filterData = filterData || {};
- // if(!filterData.idx){
- if (angular.isDefined(filterData.idx) && filterData.idx == null) {
- filterData = {
- idx: 0,
- sum: 10
- };
- }
- return options.templateOptions.fetchItems(filterData, APIService, options);
- },
- columnDefs: function () {
- return options.templateOptions.columnDefs;
- }
- };
- },
- title: function () {
- return options.templateOptions.modalTitle;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- options.value(selectedItem);
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- };
- }
- });
- formlyConfigProvider.setType({
- name: 'ui-requestform',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
- controller: ['$scope', function ($scope) {
- setTimeout(function () {
- var filterData = {
- "idx": 0,
- "sum": 5,
- "incident": {
- "requester": {
- "id": ""
- }
- }
- }
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- });
- }, 1000);
- }]
- });
- //报修图片展示
- formlyConfigProvider.setType({
- name: 'ui-repair-photos',
- // extends: 'label',
- templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
- controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
- console.log($scope);
- $scope.fileUrls = [];
- if ($scope.model.wxFile) {
- api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
- $scope.fileUrls = res.data
- })
- }
- console.log($stateParams);
- if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
- api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
- $scope.fileUrls = res.data
- })
- }
- if ($scope.model.flow) {
- api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
- $scope.fileUrls = res.data
- })
- }
- // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
- // // setTimeout(function () {
- // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
- // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- // // if (modelData.status == 200) {
- // // $scope.model[$scope.options.key] = modelData.data;
- // // $scope.options.initialValue = $scope.model[$scope.options.key];
- // // }
- // // });
- // // }, 1000);
- // }
- $scope.showBigImg = false;
- $scope.showBigImgCli = function (data) {
- $scope.showBigImg = true;
- $scope.bigImgUrl = data
- }
- $scope.closeBigImg = function () {
- $scope.showBigImg = false
- }
- }]
- });
- //图片展示
- formlyConfigProvider.setType({
- name: 'ui-showImgs',
- templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, processInstanceId, data) {
- return APIService.listAttachments(processInstanceId);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- view: function (APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function (APIService, contentId, item) {
- var item = {
- 'url': APIService.download(contentId),
- 'headers': headers
- };
- return item;
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
- var _refreshDelayPromise;
- /**
- * refresh
- */
- $scope._refresh = function (refreshAttr) {
- $scope.attachments = [];
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- // 暂存附件
- if ($scope.$parent.$parent.$parent.model.save_fileId) {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- for (var i = 0; i < myData.data.length; i++) {
- $scope.attachments.push(myData.data[i]);
- }
- };
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.$parent.$parent.$parent.model.save_fileId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response2) {
- var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
- if (myData2) {
- for (var i = 0; i < myData2.data.length; i++) {
- $scope.attachments.push(myData2.data[i]);
- }
- };
- console.log($scope.attachments)
- });
- });
- // 正常附件
- } else {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = [];
- $scope.imgs = []
- myData.data.forEach(e => {
- if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
- $scope.imgs.push(e)
- }
- })
- $scope.imgs = $scope.imgs.splice(0, 3);
- console.log($scope.imgs)
- }
- });
- }
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- // 预览
- $scope.preview = function (url, idx) {
- var title = $scope.imgs[idx].title
- $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
- controller: function ($scope, scope, $modalInstance) {
- $scope.title = title;
- $scope.imageurl = url;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- }
- }]
- });
- //工单/受理人控件
- formlyConfigProvider.setType({
- name: 'ui-workernumbersign',
- // extends: 'label',
- templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
- controller: ['$scope', function ($scope) {
- // 2020年4月24日13:20:40
- console.log($scope,'docu');
- // 左侧事件工单区域地点填充
- $scope.model.selecthouseNumber = $scope.model.place;
- if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
- setTimeout(function () {
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- if (modelData.status == 200) {
- $scope.model[$scope.options.key] = modelData.data;
- $scope.options.initialValue = $scope.model[$scope.options.key];
-
- }
- });
- }, 1000);
- }
- if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
- if (angular.isFunction($scope.options.templateOptions.transform)) {
- // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
- // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
- // }
- $scope.$parent.$parent.$parent.model['directClose'] = false;
- $scope.$parent.$parent.$parent.model['directClose'] = false;
- $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
- }
- $scope.model.acceptUser = $scope.options.templateOptions.user;
- // $scope.options.initialValue = $scope.model.acceptUser;
- }
- }]
- });
- //工单控件-only number
- formlyConfigProvider.setType({
- name: 'ui-workernumber',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
- controller: ['$scope', function ($scope) {
- if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
- setTimeout(function () {
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- if (modelData.status == 200) {
- $scope.model[$scope.options.key] = modelData.data;
- $scope.options.initialValue = $scope.model[$scope.options.key];
- }
- });
- }, 1000);
- }
- }]
- });
- //cmdb工单
- formlyConfigProvider.setType({
- name: 'ui-cmdbworkernumber',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
- controller: ['$scope', function ($scope) {
- if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
- setTimeout(function () {
- $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
- var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- // if(modelData.status==200){
- $scope.model[$scope.options.key] = modelData[$scope.options.key];
- $scope.options.initialValue = $scope.model[$scope.options.key];
- // }
- });
- }, 1000);
- }
- }]
- });
- //简易上传图片组件
- formlyConfigProvider.setType({
- name: 'ui-uploadImgs',
- templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
- wrapper: ['bootstrapHasError'],
- controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
- $scope.imgshows = [];
- $scope.uploadimgs = [];
- var model = $parse('upload_img');
- var modelSetter = model.assign;
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- // 添加
- $scope.change = function (event) {
- var element = $('.upinp')
- modelSetter($scope, element[0].files[0]);
- //附件预览
- $scope.imgupload = event.files[0];
- getFile($scope.imgupload, $scope);
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, $scope) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, $scope)
- .then(function (result) {
- $scope.imgshows.push(result)
- var file = document.querySelector('input[type=file]').files[0];
- $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
- console.log($scope.imgshows, $scope.uploadimgs)
- if ($scope.imgshows.length < 3) {
- $('#upup').show()
- } else {
- $('#upup').hide()
- }
- });
- };
- }
- // 删除
- $scope.uploadimg_del = function (index, imgs) {
- console.log(index, imgs)
- $scope.imgshows.splice(index, 1);
- $scope.uploadimgs.splice(index, 1);
- if ($scope.imgshows.length < 3) {
- $('#upup').show()
- } else {
- $('#upup').hide()
- }
- }
- // 预览
- $scope.preview = function (url, idx) {
- var name = $scope.uploadimgs[idx].name
- $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
- controller: function ($scope, scope, $modalInstance) {
- $scope.title = name;
- $scope.imageurl = url;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- }
- if (uploader) {
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }
- // console.log(modelSetter)
- }]
- });
- //jry-上传下载一体
- formlyConfigProvider.setType({
- name: 'ui-upDropFile',
- templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- view: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId);
- },
- // ApiService: 'api_wechatfile',
- // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
- // upUrl: 'common/common/uploadAttachment',
- // listAttachmentUrl: 'common/common/listAttachment',
- // downUrl: 'common/common/downloadAttachment',
- // bindType: 'incident',
- // bindId: 2323
- },
- // validators: {
- // required: {
- // expression: function(viewValue, modelValue) {
- // var value = modelValue || viewValue;
- // return value.length >= 1;
- // }
- // }
- // }
- };
- },
- controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
- console.log($scope);
- $scope.showFileUp = true;
- if ($scope.model.isKnowledge_detail) {
- $scope.showFileUp = false;
- }
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- if ($scope.model.incident) {
- if ($scope.model.incident.alarm) {
- console.log($scope)
- if ($scope.model.incident.alarm) {
- if ($scope.model.incident.alarm.alarmExtension) {
- $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
- $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
- $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
- console.log($scope.model.incident.description)
- $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
- } else {
- $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
- }
- $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
- console.log($scope.model.incident.description)
- };
- }
- api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
- console.log(wt_data);
- if (wt_data) {
- $rootScope.wt_category = wt_data.data;
- $rootScope.wt_categoryId = $scope.model.incident.category.id;
- $rootScope.wt_child = wt_data.child
- }
- })
- if ($scope.model.titleName == '接单') {
- $scope.model.receive_code = 'handler'
- if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
- $scope.model.isHandlerUser = true;
- }
- }
- if ($scope.model.titleName == '事件处理') {
- console.log($scope.model.cmdbCode)
- if ($scope.model.cmdbCode) {
- $scope.model.incident.cmdbCode = $scope.model.cmdbCode
- }
- }
- } else {
- $rootScope.wt_category = '';
- }
- //附件上传数据
- if ($scope.options.templateOptions.fileUploader) {
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- console.log(uploader)
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- }
- var to = $scope.options.templateOptions;
- // var bindType = $scope.model.bindType;
- if (to.bindType == 'incident') {
- var bindId = $scope.model[to.bindType].processInstanceId;
- } else if (to.bindType == 'change') {
- var bindId = $scope.model[to.bindType].processInstanceId;
- } else {
- var bindId = $scope.model[to.bindType].id;
- }
- //获取附件列表
- $scope.listAttachmen = function () {
- to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
- var myData = Restangular.stripRestangular(result);
- // $scope.listAttachmens = myData;
- $scope.attachments = myData.data;
- });
- };
- if (to.bindType && $scope.model[to.bindType].processInstanceId) {
- $scope.listAttachmen();
- } else if (to.bindType && $scope.model[to.bindType].id) {
- $scope.listAttachmen();
- }
- //附件上传
- $scope.isUpfload = to.isUpfload;
- $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
- item.formData.push({
- 'filename': item.file.name
- });
- };
- uploader.uploadAll();
- }
- //附件下载
- $scope.download = function (token, filename) {
- var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
- // window.open(downUrl);
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- //附件预览
- $scope.view = function (id, previewUrl) {
- if (previewUrl) {
- window.open(previewUrl);
- }
- // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
- // if (response.state == 200) {
- // window.open(response.previewUrl);
- // }
- // })
- };
- // CALLBACKS
- if (uploader) {
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- if (response.status == 200) {
- $scope.listAttachmen();
- }
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }
- }]
- });
- //简易上传下载附件组件
- formlyConfigProvider.setType({
- name: 'ui-upDownFiles',
- templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
- wrapper: ['bootstrapHasError'],
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, processInstanceId, data) {
- return APIService.listAttachments(processInstanceId);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- view: function (APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function (APIService, contentId, item) {
- var item = {
- 'url': APIService.download(contentId),
- 'headers': headers
- };
- return item;
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- // uploader.onBeforeUploadItem = function (item) {
- // angular.extend(item.headers, $rootScope.getSession());
- // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
- // item.formData.push({
- // 'fileName': item.file.name
- // });
- // console.info('onBeforeUploadItem', item);
- // };
- // }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- if (fileItem.file.size >= 1024 * 1024 * 10) {
- alert('文件过大');
- fileItem.uploader.queue.pop()
- console.log($scope);
- }
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- // console.info('onAfterAddingAll', addedFileItems);
- // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
- // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
- // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
- // console.log(123)
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- var _refreshDelayPromise;
- // 下载
- $scope.download = function (contentId, filename, token) {
- // console.log(contentId, filename, token)
- //附件下载
- var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
- // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
- // console.log(downUrl)
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- $scope._refresh = function (refreshAttr) {
- $scope.attachments = [];
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- // 暂存附件
- if ($scope.$parent.$parent.$parent.model.save_fileId) {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- for (var i = 0; i < myData.data.length; i++) {
- $scope.attachments.push(myData.data[i]);
- }
- };
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.$parent.$parent.$parent.model.save_fileId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response2) {
- var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
- if (myData2) {
- for (var i = 0; i < myData2.data.length; i++) {
- $scope.attachments.push(myData2.data[i]);
- }
- // 只展示除图片以外的附件
- var a = [];
- $scope.attachments.forEach(e => {
- if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
- // $scope.imgs.push(e)
- } else {
- a.push(e)
- }
- })
- $scope.attachments = a;
- };
- console.log($scope.attachments)
- });
- });
- // 正常附件
- } else {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- // 只展示除图片以外的附件
- var a = [];
- $scope.attachments.forEach(e => {
- if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
- // $scope.imgs.push(e)
- } else {
- a.push(e)
- }
- })
- $scope.attachments = a;
- }
- });
- }
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- }]
- });
- //简易上传附件组件
- formlyConfigProvider.setType({
- name: 'ui-uploadFiles',
- templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
- wrapper: ['bootstrapHasError'],
- controller: ['$scope', function ($scope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- console.info('onBeforeUploadItem', item);
- };
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- if (fileItem.file.size >= 1024 * 1024 * 10) {
- alert('文件过大');
- fileItem.uploader.queue.pop()
- console.log($scope);
- }
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- // console.info('onAfterAddingAll', addedFileItems);
- // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
- // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
- // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
- // console.log(123)
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }]
- });
- //无上传按钮附件上传组件
- formlyConfigProvider.setType({
- name: 'ui-dropfilenotup',
- templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', function ($scope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }]
- });
- //无按钮知识库上传
- formlyConfigProvider.setType({
- name: 'ui-dropfielkn',
- templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', function ($scope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }]
- });
- //附件上传列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropfile',
- templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
- // if ($scope.options.templateOptions.formket) {
- // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
- // } else {
- item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
- // }
- } else {
- item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
- }
- item.formData.push({
- 'filename': item.file.name
- });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }]
- });
- //简易附件展示下载列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropFiles',
- templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, processInstanceId, data) {
- return APIService.listAttachments(processInstanceId);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- view: function (APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function (APIService, contentId, item) {
- var item = {
- 'url': APIService.download(contentId),
- 'headers': headers
- };
- return item;
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
- var _refreshDelayPromise;
- // $scope.downloadUrl = function(contentId){
- // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
- // };
- $scope.download = function (contentId, filename, token) {
- // console.log(contentId, filename, token)
- //附件下载
- var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
- // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
- // console.log(downUrl)
- var a = document.createElement('a');
- a.href = downUrl;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- $scope.view = function (contentId, token, filename, type) {
- $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
- if (response.state == 200) {
- window.open(response.previewUrl);
- }
- })
- };
- /**
- * refresh
- */
- $scope._refresh = function (refreshAttr) {
- $scope.attachments = [];
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- // 暂存附件
- if ($scope.$parent.$parent.$parent.model.save_fileId) {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- for (var i = 0; i < myData.data.length; i++) {
- $scope.attachments.push(myData.data[i]);
- }
- };
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.$parent.$parent.$parent.model.save_fileId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response2) {
- var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
- if (myData2) {
- for (var i = 0; i < myData2.data.length; i++) {
- $scope.attachments.push(myData2.data[i]);
- }
- // 只展示除图片以外的附件
- var a = [];
- $scope.attachments.forEach(e => {
- if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
- // $scope.imgs.push(e)
- } else {
- a.push(e)
- }
- })
- $scope.attachments = a;
- };
- console.log($scope.attachments)
- });
- });
- // 正常附件
- } else {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- // 只展示除图片以外的附件
- var a = [];
- $scope.attachments.forEach(e => {
- if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
- // $scope.imgs.push(e)
- } else {
- a.push(e)
- }
- })
- $scope.attachments = a;
- console.log($scope.attachments)
- }
- });
- }
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- //知识库附件上传
- formlyConfigProvider.setType({
- name: 'ui-dropfielknow',
- templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
- wrapper: ['bootstrapLabel', 'bootstrapHasError'],
- controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
- if (angular.isUndefined($scope.form.dropState)) {
- $scope.form.dropState = false;
- }
- //附件上传数据
- var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
- //$scope.options.templateOptions.uploader();
- // FILTERS
- uploader.filters.push({
- name: 'customFilter',
- fn: function (item /*{File|FileLikeObject}*/, options) {
- return this.queue.length < 10;
- }
- });
- $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
- uploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name,
- 'type': 'solution',
- 'solutionId': $scope.model.knowledge.id
- });
- console.info('onBeforeUploadItem', item);
- };
- uploader.uploadAll();
- }
- // CALLBACKS
- uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
- // // $scope.uploader.options.url();
- // $scope.uploader.onBeforeUploadItem = function(item) {
- // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
- // console.info('onBeforeUploadItem', item);
- // };
- // $scope.uploader.uploadAll();
- // }
- console.info('onBeforeUploadItem', item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info('onProgressAll', progress);
- };
- uploader.onSuccessItem = function (fileItem, response, status, headers) {
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info('onCompleteAll');
- };
- }]
- });
- //知识库附件下载列表
- formlyConfigProvider.setType({
- name: 'ui-dropfileknowledge',
- templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, contentId, data) {
- return APIService.fetchDataList(contentId, data);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- download: function (APIService, contentId) {
- return APIService.getSolutionDowpath(contentId);
- },
- view: function (attachmentId) {
- // return APIService.attachmentsPreviewUrl(contentId);
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
- var _refreshDelayPromise;
- $scope.attachments = [];
- $scope.downloadUrl = function (contentId) {
- return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
- };
- $scope.download = function (contentId, filename) {
- $http({
- url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- });
- }
- $scope.view = function (contentId, filename, attachment) {
- var index = filename.indexOf(".");
- var type = filename.substring(index + 1);
- // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
- // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
- // var modalInstance = $modal.open({
- // backdrop: false,
- // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
- // controller: function($scope, scope, $modalInstance, filename) {
- // $scope.title = filename;
- // $scope.imageurl = scope.imageurl;
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // }
- // },
- // resolve: {
- // scope: function() {
- // return $scope;
- // },
- // filename: function() {
- // return filename;
- // }
- // }
- // });
- // event.preventDefault();
- // } else {
- // for (var i = 0; i < $scope.attachments.length; i++) {
- // if ($scope.attachments[i].id == attachmentId) {
- window.open(attachment.previewUrl);
- // }
- // }
- // }
- };
- $scope._refresh = function (refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- 'file', {
- "file": {
- "solutionId": $scope.model.knowledge.id
- },
- "idx": "0",
- "sum": "1000"
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.list;
- // $scope.view = function(attachmentId) {
- // for (var i = 0; i < $scope.attachments.length; i++) {
- // if ($scope.attachments[i].id == attachmentId) {
- // window.open($scope.attachments[i].previewUrl);
- // // var modalInstance = $modal.open({
- // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
- // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
- // // }
- // // });
- // }
- // }
- // };
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- //附件图片下载
- formlyConfigProvider.setType({
- name: 'ui-downimage',
- templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, processInstanceId, data) {
- return APIService.listAttachments(processInstanceId, data);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- view: function (APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function (APIService, contentId, item) {
- var item = {
- 'url': APIService.download(contentId),
- 'headers': headers
- };
- return item;
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
- var _refreshDelayPromise;
- // $scope.downloadUrl = function(contentId){
- // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
- // };
- $scope.download = function (contentId, filename) {
- // var headers=
- $http({
- url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- });
- };
- $scope.view = function (contentId) {
- $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
- // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
- // if (response.state == 200) {
- // window.open(response.previewUrl);
- // }
- // })
- };
- /**
- * refresh
- */
- $scope._refresh = function (refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- //附件下载列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropfiletable',
- templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, processInstanceId, data) {
- return APIService.listAttachments(processInstanceId, data);
- },
- downloadUri: function (APIService, contentId) {
- return APIService.downloadAttachment(contentId).getRequestedUrl();
- },
- view: function (APIService, contentId) {
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function (APIService, contentId, item) {
- var item = {
- 'url': APIService.download(contentId),
- 'headers': headers
- };
- return item;
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
- var _refreshDelayPromise;
- // $scope.downloadUrl = function(contentId){
- // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
- // };
- $scope.download = function (contentId, filename) {
- // var headers=
- $http({
- url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- });
- // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
- // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
- // var file = new Blob([response], {
- // type : 'application/octet-stream'
- // });
- // // var filename = filename;
- // //var file = new Blob([response], {type: 'application/pdf'});
- // var fileURL = URL.createObjectURL(file);
- // var a = document.createElement('a');
- // a.href = fileURL;
- // a.target = '_blank';
- // a.download = filename ;
- // document.body.appendChild(a);
- // a.click();
- // })
- };
- $scope.view = function (contentId, token, filename, type) {
- // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
- // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
- // var modalInstance = $modal.open({
- // backdrop: false,
- // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
- // controller: function($scope, scope, $modalInstance, filename) {
- // $scope.title = filename;
- // $scope.imageurl = scope.imageurl;
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // }
- // },
- // resolve: {
- // scope: function() {
- // return $scope;
- // },
- // filename: function() {
- // return filename;
- // }
- // }
- // });
- // event.preventDefault();
- // } else {
- $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
- if (response.state == 200) {
- window.open(response.previewUrl);
- }
- })
- // }
- };
- /**
- * refresh
- */
- $scope._refresh = function (refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.options.templateOptions.processInstanceId, {
- 'idx': 0,
- 'sum': 1000
- }).then(function (response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- //微信附件下载列表组件
- formlyConfigProvider.setType({
- name: 'ui-dropfilewechat',
- templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- // refresh: function(APIService, processInstanceId, data) {
- // return APIService.listAttachments(processInstanceId, data);
- // },
- // downloadUri: function(APIService, contentId) {
- // return APIService.downloadAttachment(contentId).getRequestedUrl();
- // },
- view: function (APIService, contentId) {
- // return APIService.attachmentsPreviewUrl(contentId);
- return APIService.attachmentsPreviewUrl(contentId);
- },
- download: function (APIService, contentId, item) {
- var item = {
- 'url': APIService.download(contentId),
- 'headers': headers
- };
- return item;
- },
- // download: function(APIService, contentId, item) {
- // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
- // return item;
- // },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
- var _refreshDelayPromise;
- // $scope.downloadUrl = function(contentId){
- // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
- // };
- $scope.attachments = {};
- $scope.previewUrl = '';
- $scope.download = function (token, filename) {
- // var headers=
- console.log($scope);
- $http({
- url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
- method: 'GET',
- headers: {
- //'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- });
- };
- $scope.view = function (contentId, token, filename, type, previewUrl) {
- // if (type) {
- // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
- // var modalInstance = $modal.open({
- // backdrop: false,
- // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
- // controller: function($scope, scope, $modalInstance, filename) {
- // $scope.title = filename;
- // $scope.imageurl = scope.imageurl;
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // }
- // },
- // resolve: {
- // scope: function() {
- // return $scope;
- // },
- // filename: function() {
- // return filename;
- // }
- // }
- // });
- // event.preventDefault();
- // } else {
- // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
- // if (response.state == 200) {
- // window.open(response.previewUrl);
- // }
- // })
- window.open(previewUrl);
- // }
- };
- /**
- * refresh
- */
- $scope._refresh = function (refreshAttr) {
- if (refreshAttr !== undefined) {
- if (_refreshDelayPromise) {
- $timeout.cancel(_refreshDelayPromise);
- }
- _refreshDelayPromise = $timeout(function () {
- // console.log(JSON.parse($stateParams.model))
- var incidentChart = {};
- if ($stateParams.model) {
- incidentChart = JSON.parse($stateParams.model).model;
- }
- $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- $scope.model).then(function (response) {
- // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
- // incidentChart.incident.type, incidentChart.flow).then(function(response) {
- var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
- if (myData) {
- $scope.attachments = myData.data;
- }
- });
- }, $scope.options.templateOptions.refreshDelay);
- }
- }
- $scope._refresh({});
- // $scope.attachments = $scope.model[$scope.options.key]
- }]
- });
- formlyConfigProvider.setType({
- name: 'ui-paralleltask',
- templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- refresh: function (APIService, processInstanceId, data) {
- //return APIService.listAttachments(processInstanceId, data);
- },
- refreshDelay: 0
- }
- };
- },
- controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
- });
- //repeatSection
- //
- formlyConfigProvider.setType({
- name: 'ui-repeatSection',
- templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- unique: 1,
- initDisplay: false
- }
- };
- },
- controller: function ($scope) {
- //$scope.options.templateOptions.unique;
- $scope.formOptions = {
- formState: $scope.formState
- };
- $scope.addNew = addNew;
- $scope.copyFields = copyFields;
- function copyFields(fields) {
- fields = angular.copy(fields);
- addRandomIds(fields);
- return fields;
- }
- function addNew() {
- $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
- var repeatsection = $scope.model[$scope.options.key];
- var lastSection = repeatsection[repeatsection.length - 1];
- var newsection = {};
- repeatsection.push(newsection);
- }
- function addRandomIds(fields) {
- $scope.options.templateOptions.unique++;
- angular.forEach(fields, function (field, index) {
- if (field.fieldGroup) {
- addRandomIds(field.fieldGroup);
- return; // fieldGroups don't need an ID
- }
- if (field.templateOptions && field.templateOptions.fields) {
- addRandomIds(field.templateOptions.fields);
- }
- field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
- });
- }
- function getRandomInt(min, max) {
- return Math.floor(Math.random() * (max - min)) + min;
- }
- if ($scope.options.templateOptions.initDisplay) {
- addNew();
- }
- }
- });
- //时间轴任务列表组件
- //cmdb控件
- formlyConfigProvider.setType({
- name: 'ui-cmdb',
- extends: 'input',
- templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
- defaultOptions: function (options) {
- return {
- templateOptions: {
- onClick: function (size, options, modal, event, model) {
- var modalInstance = modal.open({
- templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
- controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
- var width = $scope.width = 600;
- var height = $scope.height = 400;
- var tree;
- var d3 = window.d3;
- $scope.my_tree_handler = function (branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- APIService.query({
- 'sign': classify
- }).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if (myData.data && myData.status == 200) {
- var ret = myData.data;
- redrawSvg(myData);
- }
- });
- };
- $scope.my_data = [];
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.my_tree = tree = {};
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.select_treedata = [];
- $scope.doing_async = true;
- ConfigDataService.fetchDataList('ciclassify', {
- 'idx': 0,
- 'sum': 100
- }).then(function (result) {
- $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- $scope.doing_async = false;
- });
- // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
- // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- // $scope.doing_async = false;
- // });
- };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.try_async_load();
- $scope.onFilterCallback = function (item) {
- //console.log(item);
- if (angular.isDefined(item.children) && item.children.length >= 1) {
- //not valid
- } else {
- var tempclassify = item.prefix.toLowerCase() + item.sign;
- $scope.cifilter_classic = tempclassify;
- ConfigFormService.renderTabForm(tempclassify).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.propTypeOptions = myData;
- });
- }
- }
- $scope.onPropTypeChange = function (form) {
- $scope.propOptions = form.fields;
- }
- $scope.onPropChange = function (prop) {
- $scope.cifilter_prop = prop;
- }
- $scope.searchCI = function (searchKey, propObj, ciclassify) {
- //if(searchKey!=null&&searchKey.length>1){
- var searchData = {};
- if (angular.isUndefined(propObj)) {
- propObj = $scope.cifilter_prop;
- }
- if (angular.isUndefined(ciclassify)) {
- ciclassify = $scope.cifilter_classic;
- }
- searchData['sign'] = ciclassify;
- if (angular.isDefined(propObj)) {
- searchData[propObj.key] = searchKey;
- }
- APIService.query(searchData).then(function (response) {
- var data = Restangular.stripRestangular(response);
- //此处不清空nodes
- var node = data.data.node;
- var tempNode = [];
- //nodes 或者links 要去重
- for (var i = 0; i < node.length; i++) {
- var tmp = 0;
- for (var j = 0; j < nodes.length; j++) {
- if (node[i].uuid == nodes[j].uuid) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempNode.push(node[i]);
- }
- }
- for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
- nodes.push(tempNode[i]);
- }
- restart();
- })
- }
- $scope.refresh = function () {
- nodes.length = 0;
- links.length = 0;
- restart();
- }
- $scope.traversal = function () {
- if ($scope.selected_node == null) {
- SweetAlert.swal({
- title: "错误的操作!",
- text: "没有配置项被选中!",
- type: "error"
- });
- } else {
- var uuid = $scope.selected_node.uuid;
- APIService.traversal(uuid).then(function (response) {
- var d = response.data;
- var node = d.node;
- var link = d.edge;
- var tempNode = [];
- var tempLink = [];
- //nodes 或者links 要去重
- for (var i = 0; i < node.length; i++) {
- var tmp = 0;
- for (var j = 0; j < nodes.length; j++) {
- if (node[i].id == nodes[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempNode.push(node[i]);
- }
- }
- for (var i = 0; i < link.length; i++) {
- var tmp = 0;
- for (var j = 0; j < links.length; j++) {
- if (link[i].id == links[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempLink.push(link[i]);
- }
- }
- //数据写入页面
- for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
- nodes.push(tempNode[i]);
- }
- for (var i = 0; i < tempLink.length; i++) { //link 不清空
- links.push(tempLink[i]);
- }
- //links转换
- for (var i = 0; i < links.length; i++) {
- for (var j = 0; j < nodes.length; j++) {
- if (links[i].source == nodes[j].id) {
- links[i].source = nodes[j];
- }
- if (links[i].target == nodes[j].id) {
- links[i].target = nodes[j];
- }
- }
- }
- restart();
- })
- }
- }
- var svg;
- var force;
- var drag_line, path, circle;
- //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
- //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
- //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
- var nodes = [],
- links = [];
- var treeNodes = [];
- //读取labels (node)
- var labels = [];
- function redrawSvg(json) {
- nodes.length = 0; //先清空
- links.length = 0;
- var data = json.data;
- for (var i = 0; i < data.node.length; i++) {
- nodes.push(data.node[i]);
- }
- restart();
- }
- //读取status (节点 连线)
- var statuses = [];
- // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
- // if (result && result.status == 200) {
- // d3.select('#nodeStatus').selectAll('option')
- // .data(statuses).enter()
- // .append('option')
- // .attr('value', function(d) { return d.code; })
- // .html(function(d) { return d.desc; });
- // } else {
- // SweetAlert.swal({
- // title: "提示!",
- // text: "服务器请求异常!",
- // type: "error"
- // });
- // }
- // });
- api_wechatfile.getDictionary({
- 'key': 'cmdb_status',
- 'type': 'list'
- }).then(function (result) {
- if (result) {
- d3.select('#nodeStatus').selectAll('option')
- .data(statuses).enter()
- .append('option')
- .attr('value', function (d) {
- return d.code;
- })
- .html(function (d) {
- return d.desc;
- });
- } else {
- SweetAlert.swal({
- title: "提示!",
- text: "服务器请求异常!",
- type: "error"
- });
- }
- });
- //查询relationship_type表 name 为表里的type,label为显示值
- var linkType = [];
- function fetchEdgeTypes() {
- ConfigDataService.fetchDataList('ciedgetype', {
- 'idx': 0,
- 'sum': 100
- }).then(function (response) {
- if (response) {
- if (response['list']) {
- linkType = response['list'];
- // d3.select('#linkName').selectAll('option')
- // .data(linkType).enter()
- // .append('option')
- // .attr('value',function(d){return d.type;})
- // .html(function(d){ return d.label;});
- } else {
- SweetAlert.swal({
- title: "提示!",
- text: "服务器请求异常!",
- type: "error"
- });
- }
- } else {
- SweetAlert.swal({
- title: "提示!",
- text: "服务器请求异常!",
- type: "error"
- });
- }
- })
- }
- // fetchEdgeTypes();
- /*
- // init D3 force layout
- var force = d3.layout.force()
- .nodes(nodes)
- .links(links)
- .size([width, height])
- .gravity(.05)
- .linkDistance(150)
- .linkStrength(2)
- .charge(-500)
- .on('tick', tick);
- // define arrow markers for graph links
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'end-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 6)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M0,-5L10,0L0,5')
- .attr('fill', '#000');
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'start-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 4)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M10,-5L0,0L10,5')
- .attr('fill', '#000');
- // line displayed when dragging new nodes
- var drag_line = svg.append('svg:path')
- .attr('class', 'link dragline hidden')
- .attr('d', 'M0,0L0,0');
- // handles to link and node element groups
- //(1)var path = svg.append('svg:g').selectAll('g')
- var path = svg.append('svg:g').selectAll('g'),
- circle = svg.append('svg:g').selectAll('g');
- */
- // mouse event vars
- var selected_node = null,
- selected_link = null,
- mousedown_link = null,
- mousedown_node = null,
- mouseup_node = null;
- function resetMouseVars() {
- mousedown_node = null;
- mouseup_node = null;
- mousedown_link = null;
- }
- // update force layout (called automatically each iteration)
- function tick() {
- // draw directed edges with proper padding from node centers
- path.selectAll('path').attr('d', function (d) {
- var deltaX = d.target.x - d.source.x,
- deltaY = d.target.y - d.source.y,
- dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
- normX = deltaX / dist,
- normY = deltaY / dist,
- sourcePadding = d.left ? 27 : 22,
- targetPadding = d.right ? 27 : 22,
- sourceX = d.source.x + (sourcePadding * normX),
- sourceY = d.source.y + (sourcePadding * normY),
- targetX = d.target.x - (targetPadding * normX),
- targetY = d.target.y - (targetPadding * normY);
- return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
- });
- circle.attr('transform', function (d) {
- return 'translate(' + d.x + ',' + d.y + ')';
- });
- }
- // update graph (called when needed)
- function restart() {
- //绑定link 数据
- path.datum(links);
- // path (link) group
- path = path.data(links, function (d) {
- return d.id;
- });
- var p = path.enter().append('svg:g');
- //update existing links
- path.selectAll('path').classed('selected', function (d) {
- return d === selected_link;
- })
- .style('marker-start', function (d) {
- return d.left ? 'url(#start-arrow)' : '';
- })
- .style('marker-end', function (d) {
- return d.right ? 'url(#end-arrow)' : '';
- });
- // add new links
- p.append('svg:path')
- .attr('class', 'link')
- .attr('id', function (d) {
- return "path_" + d.id;
- })
- // .attr('startOffset', '0%')
- .classed('selected', function (d) {
- return d === selected_link;
- })
- .style('marker-start', function (d) {
- return d.left ? 'url(#start-arrow)' : '';
- })
- .style('marker-end', function (d) {
- return d.right ? 'url(#end-arrow)' : '';
- })
- .on('mousedown', function (d) {
- if (d3.event.ctrlKey) return;
- //去除没有提交的连线
- for (var i = 0; i < links.length; i++) {
- if (links[i].id == -1 && d.id != -1) {
- links.splice(i, 1);
- }
- }
- // select link
- mousedown_link = d;
- if (mousedown_link === selected_link) {
- selected_link = $scope.selected_link = null;
- selected_node = $scope.selected_node = null;
- // d3.select("#linkDetail").attr('style','display:none');
- //hideLinkForm(true);//return ;
- } else {
- selected_link = $scope.selected_link = mousedown_link;
- selected_node = $scope.selected_node = null;
- }
- selected_node = $scope.selected_node = null;
- restart();
- });
- p.append('svg:text')
- .attr('x', 30)
- .attr('y', 20)
- .attr('class', 'fontM')
- .append('textPath')
- .attr('xlink:xlink:href', function (d, i) {
- return "#path_" + d.id;
- })
- .html(function (d) {
- for (var i = 0; i < linkType.length; i++) {
- if (linkType[i].type == d.name) {
- return linkType[i].label;
- }
- }
- });
- // remove old links
- path.exit().remove();
- // circle (node) group
- // NB: the function arg is crucial here! nodes are known by id, not by index!
- circle.datum(nodes);
- circle = circle.data(nodes, function (d) {
- return d.id;
- });
- // update existing nodes (reflexive & selected visual states)
- circle.selectAll('circle')
- .style('fill', function (d) {
- return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
- })
- .style('fill-opacity', 0.75) // add by xi
- .classed('reflexive', function (d) {
- return d.reflexive;
- });
- // add new nodes
- var g = circle.enter().append('svg:g');
- //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
- //g.append('svg:circle').attr('r',24).style('fill','rgb(255,255,255)').style('stroke', function(d) { return d3.rgb(colors(d.label)).darker().toString(); }).style('stroke-width','2');
- g.append('svg:circle').attr('r', 24).style('fill', function (d) {
- return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
- }).style('stroke', function (d) {
- return d3.rgb(colors(d.label)).darker().toString();
- }).style('stroke-width', '2');
- g.append('svg:circle')
- .attr('class', 'node')
- .attr('r', 18)
- .style('fill', function (d) {
- return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
- })
- .style('stroke', function (d) {
- return d3.rgb(colors(d.label)).darker().toString();
- })
- .style('fill-opacity', 0.25) //add by xj
- .style('stroke-opacity', 0.5) //add by xj
- .classed('reflexive', function (d) {
- return d.reflexive;
- });
- g.on('mouseover', function (d) {
- //if(!mousedown_node || d === mousedown_node) return;
- // enlarge target node
- //d3.select(this).attr('transform', 'scale(1.1)');
- })
- .on('mouseout', function (d) {
- //if(!mousedown_node || d === mousedown_node) return;
- // unenlarge target node
- //d3.select(this).attr('transform', '');
- })
- .on('mousedown', function (d) {
- if (d3.event.ctrlKey) return;
- //hideLinkForm(true);
- //去除没有提交的连线
- for (var i = 0; i < links.length; i++) {
- if (links[i].id == -1) {
- links.splice(i, 1);
- }
- }
- // select node
- mousedown_node = d;
- if (mousedown_node === selected_node) {
- selected_node = $scope.selected_node = null;
- } else {
- selected_node = $scope.selected_node = mousedown_node;
- selected_link = $scope.selected_link = null;
- // 点击节点 查询关系及节点 /traversal/{id}/{relation}
- APIService.findRefById(selected_node.id).then(function (result) {
- var d = result.data;
- var node = d.node;
- var link = d.edge;
- var tempNode = [];
- var tempLink = [];
- //nodes 或者links 要去重
- for (var i = 0; i < node.length; i++) {
- var tmp = 0;
- for (var j = 0; j < nodes.length; j++) {
- if (node[i].id == nodes[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempNode.push(node[i]);
- }
- }
- for (var i = 0; i < link.length; i++) {
- var tmp = 0;
- for (var j = 0; j < links.length; j++) {
- if (link[i].id == links[j].id) {
- tmp++;
- break;
- }
- }
- if (tmp == 0) {
- tempLink.push(link[i]);
- }
- }
- //数据写入页面
- for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
- nodes.push(tempNode[i]);
- }
- for (var i = 0; i < tempLink.length; i++) { //link 不清空
- links.push(tempLink[i]);
- }
- //links转换
- for (var i = 0; i < links.length; i++) {
- for (var j = 0; j < nodes.length; j++) {
- if (links[i].source == nodes[j].id) {
- links[i].source = nodes[j];
- }
- if (links[i].target == nodes[j].id) {
- links[i].target = nodes[j];
- }
- }
- }
- restart();
- });
- }
- // reposition drag line
- drag_line
- .style('marker-end', 'url(#end-arrow)')
- .classed('hidden', false)
- .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
- restart();
- })
- .on('mouseup', function (d) {
- if (!mousedown_node) return;
- });
- // show node name
- g.append('svg:text')
- .attr('x', 0)
- .attr('y', 34)
- .attr('class', 'id')
- .text(function (d) {
- return d.name;
- }); //TODO 改为 d.name
- //设置图片
- g.append('svg:foreignObject')
- .attr("width", 32)
- .attr("height", 32)
- .attr('x', "-16px")
- .attr('y', "-11px")
- .html(function (d) {
- for (var i = 0; i < labels.length; i++) {
- if (d.label == labels[i].sign) {
- return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
- }
- }
- });
- // remove old nodes
- circle.exit().remove();
- // set the graph in motion
- force.start();
- }
- function mousedown() {
- // prevent I-bar on drag
- //d3.event.preventDefault();
- // because :active only works in WebKit?
- svg.classed('active', true);
- if (mousedown_node) {
- viewNode(mousedown_node);
- }
- if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
- restart();
- }
- function mousemove() {
- if (!mousedown_node) return;
- // update drag line
- //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
- //restart();
- }
- function mouseup() {
- if (mousedown_node) {
- // hide drag line
- drag_line
- .classed('hidden', true)
- .style('marker-end', '');
- }
- // because :active only works in WebKit?
- svg.classed('active', false);
- // clear mouse event vars
- resetMouseVars();
- }
- function spliceLinksForNode(node) {
- var toSplice = links.filter(function (l) {
- return (l.source === node || l.target === node);
- });
- toSplice.map(function (l) {
- links.splice(links.indexOf(l), 1);
- });
- }
- // only respond once per keydown
- var lastKeyDown = -1;
- function keydown() {
- //d3.event.preventDefault();
- if (lastKeyDown !== -1) return;
- lastKeyDown = d3.event.keyCode;
- // ctrl
- if (d3.event.keyCode === 17) {
- circle.call(force.drag);
- svg.classed('ctrl', true);
- }
- if (!selected_node && !selected_link) return;
- switch (d3.event.keyCode) {
- case 8: // backspace
- case 66: // B
- if (selected_link) {
- // set link direction to both left and right
- selected_link.left = true;
- selected_link.right = true;
- }
- restart();
- break;
- case 76: // L
- if (selected_link) {
- // set link direction to left only
- selected_link.left = true;
- selected_link.right = false;
- }
- restart();
- break;
- case 82: // R
- if (selected_node) {
- // toggle node reflexivity
- selected_node.reflexive = !selected_node.reflexive;
- } else if (selected_link) {
- // set link direction to right only
- selected_link.left = false;
- selected_link.right = true;
- }
- restart();
- break;
- }
- }
- function keyup() {
- lastKeyDown = -1;
- // ctrl
- if (d3.event.keyCode === 17) {
- circle
- .on('mousedown.drag', null)
- .on('touchstart.drag', null);
- svg.classed('ctrl', false);
- }
- }
- function viewNode(node) {
- // console.log(svg.attr('left'));
- //var el = angular.element('div.modal-dialog')[0];
- var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
- if (!$scope.selected_node.props.state) {
- $scope.selected_node.props.state = "空"
- } else if ($scope.selected_node.props.state) {
- if ($scope.selected_node.props.state == "1") {
- $scope.selected_node.props.state = "未审核"
- } else if ($scope.selected_node.props.state == "2") {
- $scope.selected_node.props.state = "已审核"
- } else if ($scope.selected_node.props.state == "3") {
- $scope.selected_node.props.state = "不匹配"
- } else if ($scope.selected_node.props.state == "4") {
- $scope.selected_node.props.state = "丢失"
- }
- };
- if (!$scope.selected_node.name) {
- $scope.selected_node.name = "空"
- }
- if (!$scope.selected_node.status) {
- $scope.selected_node.statu = "空"
- }
- if (!$scope.selected_node.props.useradmin) {
- $scope.selected_node.props.useradmin = "空"
- }
- Toaster.pop({
- // type: 'info',
- // title: title,
- body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
- '<p>配置标题:' + $scope.selected_node.name + '</p>' +
- '<p>状态:' + $scope.selected_node.status + '</p>' +
- '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
- '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
- bodyOutputType: 'trustedHtml',
- timeout: 3000
- })
- }
- //GT 颜色与数值对照表
- function colors(sign) {
- //num=num>20?num%20:parseInt(num);
- for (var i = 0; i < labels.length; i++) {
- var entity = labels[i];
- if (sign == entity.sign) {
- return entity.color;
- }
- if (i == labels.length - 1 && sign != entity.sign) {
- return '#ffeeee';
- }
- }
- }
- $scope.init = function () {
- svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
- // init D3 force layout
- force = d3.layout.force()
- .nodes(nodes)
- .links(links)
- .size([width, height])
- .gravity(.05)
- .linkDistance(150)
- .linkStrength(2)
- .charge(-500)
- .on('tick', tick);
- // define arrow markers for graph links
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'end-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 6)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M0,-5L10,0L0,5')
- .attr('fill', '#000');
- svg.append('svg:defs').append('svg:marker')
- .attr('id', 'start-arrow')
- .attr('viewBox', '0 -5 10 10')
- .attr('refX', 4)
- .attr('markerWidth', 3)
- .attr('markerHeight', 3)
- .attr('orient', 'auto')
- .append('svg:path')
- .attr('d', 'M10,-5L0,0L10,5')
- .attr('fill', '#000');
- // line displayed when dragging new nodes
- drag_line = svg.append('svg:path')
- .attr('class', 'link dragline hidden')
- .attr('d', 'M0,0L0,0');
- // handles to link and node element groups
- //(1)var path = svg.append('svg:g').selectAll('g')
- path = svg.append('svg:g').selectAll('g');
- circle = svg.append('svg:g').selectAll('g');
- svg.on('mousedown', mousedown)
- .on('mousemove', mousemove)
- .on('mouseup', mouseup);
- d3.select(window)
- .on('keydown', keydown)
- .on('keyup', keyup);
- }
- var CI = {};
- window.CI = CI;
- $scope.ok = function () {
- $modalInstance.close($scope.selected_node);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: size,
- resolve: {
- title: function () {
- return options.templateOptions.title;
- },
- Restangular: function () {
- return options.templateOptions.Restangular;
- },
- APIService: function () {
- return options.templateOptions.ApiService;
- },
- ConfigDataService: function () {
- return options.templateOptions.ConfigDataService;
- },
- ConfigFormService: function () {
- return options.templateOptions.ConfigFormService;
- },
- SweetAlert: function () {
- return options.templateOptions.Alert;
- },
- Toaster: function () {
- return options.templateOptions.toaster;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- options.value(selectedItem.name + '-' + selectedItem.uuid);
- }, function () {
- //console.log('Modal dismissed at: ' + new Date());
- });
- }
- }
- }
- },
- controller: ['$scope', function ($scope) {
- // setTimeout(function(){
- // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
- // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
- // if(modelData.status==200){
- // $scope.model[$scope.options.key] = modelData.data;
- // $scope.options.initialValue = $scope.model[$scope.options.key];
- // }
- // });
- // },1000);
- }]
- });
- });
- appFormly.run(function (formlyConfig, $parse) {
- //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
- var removeOnHideTransformer = function (fields, model) {
- return fields.map(function (field) {
- if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
- addFieldRemoveOnHideWatcher(field);
- }
- if (field.type == "ui-title") {
- addFieldRemoveOnHideWatcher(field);
- }
- return field;
- });
- };
- formlyConfig.extras.fieldTransform = removeOnHideTransformer;
- function addFieldRemoveOnHideWatcher(field) {
- var watcher = getWatcher();
- if (field.watcher) {
- if (!angular.isArray(field.watcher)) {
- field.watcher = [field.watcher];
- }
- field.watcher.push(watcher);
- } else {
- field.watcher = watcher;
- }
- }
- function getWatcher() {
- return {
- expression: function (field) {
- return field.hide;
- },
- listener: function (field, newHide, oldHide, scope) {
- if (field.hide) {
- if (field.templateOptions.pkey) {
- if (field.key == 'transferuser') {
- $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
- }
- } else {
- $parse(field.key).assign(scope.model, undefined);
- }
- }
- if (field.type == "ui-title") {
- $parse(field.key).assign(scope.model, undefined);
- }
- }
- };
- }
- });
- appFormly.controller('CustomformCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'Restangular', 'UserRestangular', 'BpmRestangular', 'WechatRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_statistic', 'up_down_file', 'fileReader',
- function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, Restangular, UserRestangular, BpmRestangular, WechatRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, api_statistic, up_down_file, fileReader) {
- //console.log($parse('Restangular')($scope));
- //console.log($injector.get('Restangular'));
- //console.log($stateParams);
- //保存报修主体
- $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
- $scope.imgUrlList = [];
- $scope.uploadimg_del = function () {
- console.log(123)
- };
- var vm = this;
- vm.options = {};
- vm.exampleTitle = ['expressionProperties', 'model property'];
- vm.fields = [];
- vm.model = {};
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- //alert($rootScope.user.id,null,2);
- vm.model["loginUser"] = $rootScope.user;
- var loginUser = $rootScope.user;
- // console.log(vm);
- var that = $injector;
- var parse = $parse;
- var formKey = "";
- var pdKey = "";
- var modelWatch = "";
- if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- modelWatch = JSON.parse($stateParams.model);
- // console.log("modelWatch:"+ JSON.stringify(modelWatch));
- // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
- console.log(modelWatch,$rootScope)
- // if(modelWatch.model.incident){
- // if(modelWatch.model.incident.place){
- // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
- // }else{
- // $rootScope.selecthouseNumber = undefined;
- // }
- // }
- }
- if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
- pdKey = $state.current.pdKey;
- } else if ($stateParams.pdKey) {
- pdKey = $stateParams.pdKey;
- }
- // console.log("pdKey::" + JSON.stringify($state.current.title));
- if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
- formKey = $stateParams.formKey;
- // console.log("formKey::"+JSON.stringify($stateParams.formKey));
- }
- if (angular.isDefined($stateParams.model)) {
- var formModel = $stateParams.model;
- }
- //用户测试数据,后续从header的auth中获取
- var userId = 2;
- userId = $rootScope.user.id;
- //==============处理表单设计数据 开始====================
- //处理组件加载后台数据选项的方法
- function refreshSelectOptions(searchVal, field) {
- if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
- var process = BpmRestangular.all("");
- if (field.templateOptions.ApiService) {
- process = UserRestangular.all("");
- }
- if (field.templateOptions.Apicommon) {
- process = WechatRestangular.all("");
- }
- var datakey = {
- "idx": 0,
- "sum": 1000
- };
- if (field.templateOptions.modelreasondata) {
- datakey = field.templateOptions.modelreasondata
- }
- process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
- if (!field.templateOptions.options) {
- field.templateOptions.options = [];
- }
- if (field.templateOptions.optionsDataKey) {
- field.templateOptions.options = result[field.templateOptions.optionsDataKey];
- } else {
- field.templateOptions.options = result;
- }
- });
- }
- }
- //获取表单后数据处理
- function formfield(field, result) {
- // angular.forEach(fields.fields, function(field) {
- if (field.key == "") {
- delete field.key;
- }
- if (angular.isDefined(field.extjson)) {
- var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj.templateOptions);
- delete extObj.templateOptions;
- for (var prop in extObj) {
- if (new RegExp("Expression").test(prop)) {
- //var obj = $scope.$eval(extObj[prop]);
- //extObj[prop] = $scope.$eval(extObj[prop]);
- if (extObj[prop] != null) {
- if (new RegExp("function").test(extObj[prop])) {
- var propValue = eval(extObj[prop]);
- extObj[prop] = propValue;
- } else {
- //console.log(extObj[prop]);
- var obj = $scope.$eval(extObj[prop]);
- extObj[prop] = obj;
- //console.log(obj);
- }
- }
- } else if (new RegExp("expressionProperties").test(prop)) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- } else {
- //if(p.indexOf("'")>=0){
- // var obj = $scope.$eval(extObj[prop][p]);
- // extObj[prop][$scope.$eval(p)]=obj;
- //}
- }
- }
- } else if ("watcher" == prop) {
- if (angular.isArray(extObj[prop])) {
- angular.forEach(extObj[prop], function (item, index) {
- for (var p in item) {
- if (new RegExp("function").test(item[p])) {
- var propValue = eval(item[p]);
- extObj[prop][index][p] = propValue;
- }
- }
- });
- } else if (angular.isObject(extObj[prop])) {
- for (var p in extObj[prop]) {
- if (new RegExp("function").test(extObj[prop][p])) {
- var propValue = eval(extObj[prop][p]);
- extObj[prop][p] = propValue;
- }
- }
- }
- }
- }
- angular.extend(field, extObj);
- delete field.extjson;
- }
- if (angular.isDefined(field.templateOptions)) {
- var templateOs = field.templateOptions;
- // console.log(templateOs,'come')
- for (var property in templateOs) {
- //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
- if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
- if (new RegExp("function").test(templateOs[property])) {
- var propValue = eval(templateOs[property]);
- field.templateOptions[property] = propValue;
- } else {
- if (that.has(templateOs[property])) {
- field.templateOptions[property] = that.get(templateOs[property]);
- } else {
- field.templateOptions[property] = templateOs[property];
- }
- }
- } else if (templateOs[property] == null) {
- //delete field.templateOptions[property];
- } else { }
- }
- }
- if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
- var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
- angular.extend(field.templateOptions, extObj);
- delete field.templateOptions.extjson;
- }
- // ...
- if (field.templateOptions) {
- //处理远程获取数据控件方法调用
- if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
- // if (!field.templateOptions.isnoreash) {
- field.templateOptions.refresh = refreshSelectOptions;
- // }
- }
- //处理嵌套属性数据绑定/
- if (field.templateOptions.pkey) {
- var pmodel, i = 0;
- angular.forEach(field.templateOptions.pkey.split("."), function (p) {
- if (i == 0) {
- if (result.model[p] == null) {
- result.model[p] = {};
- }
- pmodel = result.model[p];
- i++;
- } else {
- if (pmodel[p] == null) {
- pmodel[p] = {};
- }
- pmodel = pmodel[p];
- }
- });
- if (pmodel != null) {
- field.model = pmodel;
- if (pmodel[field.key] == null) {
- pmodel[field.key] = null;
- }
- }
- } else {
- if (result.model[field.key] == null) {
- result.model[field.key] = null;
- }
- }
- //处理弹出框组件初始化
- if (field.type == "ui-input-selectmodal") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-requesterselect") {
- //field.templateOptions.language = $scope.lang;
- field.templateOptions.modal = $modal;
- field.templateOptions.UserService = api_user_data;
- } else if (field.type == "ui-deptinformation") {
- field.templateOptions.modal = $modal;
- field.templateOptions.UserService = api_user_data;
- } else if (field.type == "ui-requesterinformation") {
- field.templateOptions.modal = $modal;
- field.templateOptions.UserService = api_user_data;
- } else if (field.type == "ui-userselect") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-userselectSearch") {
- field.templateOptions.modal = $modal;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-multiuserselect") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-stringuserselect") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-search") {
- field.templateOptions.modal = $modal;
- } else if (field.type == "ui-modelselect") {
- field.templateOptions.modal = $modal;
- //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
- field.templateOptions.loginUser = $rootScope.user;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-incidentmodelselect") {
- field.templateOptions.modal = $modal;
- //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
- field.templateOptions.loginUser = $rootScope.user;
- //field.templateOptions.Restangular = Restangular;
- } else if (field.type == "ui-dropfile") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfielknow") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-upDropFile") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- } else if (field.type == "ui-dropfilenotup") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-uploadFiles") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-upDownFiles") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-uploadImgs") {
- $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
- url: '/uploader'
- });
- field.templateOptions.taskId = $stateParams.taskId;
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- field.templateOptions.userId = $rootScope.user.id;
- //field.ApiService=api_bpm_domain;
- } else if (field.type == "ui-dropfiletable") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-dropFiles") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-showImgs") {
- if (field.templateOptions.processInstanceId) {
- } else {
- field.templateOptions.processInstanceId = $stateParams.processInstanceId;
- }
- } else if (field.type == "ui-repeatSection") {
- var repeatForm = {
- model: {
- },
- fields: field.templateOptions.fields
- };
- repeatForm.model[field.key] = [];
- decodeVMForm(repeatForm);
- } else if (field.type == "ui-currentuser") {
- field.templateOptions.user = vm.model["loginUser"];
- } else if (field.type == "ui-workernumbersign") {
- field.templateOptions.user = vm.model["loginUser"];
- } else if (field.type == "ui-repair-photos") {
- field.templateOptions.user = vm.model["loginUser"];
- }
- }
- }
- //解析自定义表单设计数据
- $scope.oldfromtype = true;
- function decodeVMForm(vmForm) {
- if (vmForm.formType == "1") {
- $scope.oldfromtype = false;
- } else {
- $scope.oldfromtype = true;
- }
- var result = {
- model: {},
- fields: []
- };
- //设置模型实体数据 begin
- // var mdata = vmForm.model;
- //解析数据实体
- var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
- angular.extend(result.model, mdata);
- if (modelWatch != null && modelWatch != '') {
- //angular.extend(result.model.incident,modelWatch.incident);
- //result.model.alarmType = modelWatch.alarmType;
- // vmForm.cancelUrl = modelWatch.cancelUrl;
- // console.log(modelWatch.cancelUrl)
- for (var index in modelWatch.model) {
- //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
- if (result.model[index] != null) {
- angular.extend(result.model[index], modelWatch.model[index]);
- } else {
- result.model[index] = modelWatch.model[index];
- }
- }
- }
- //设置模型实体数据 end
- //解析设计数据生成表单项 begin
- var fields = [];
- //处理修改设计数据中展示设置
- angular.forEach(vmForm.fields, function (fields) {
- if (vmForm.formType == "1") {
- angular.forEach(fields.fields, function (field) {
- formfield(field, result);
- });
- } else {
- formfield(fields, result);
- }
- // console.log(field);
- result.fields.push(fields);
- });
- angular.extend($scope.vm.fields, result.fields);
- angular.extend($scope.vm.model, result.model);
- vm.model["loginUser"] = $rootScope.user;
- //增加识别报修主体seimin
- vm.model.repairType = $scope.repairMain.valueconfig;
- if(vm.model.incident){
- vm.model.incident.repairType = $scope.repairMain.valueconfig;
- }
- console.log(vm, 'repairType')//lmm
- if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
- vmForm.cancelUrl = modelWatch.cancelUrl;
- }
- $scope.formData = vmForm;
- console.log($scope.formData,4444444)
- // console.log($scope.formData.url);
- // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
- if ($scope.formData.url == "start") {
- $scope.Reset = true;
- $scope.close = true;
- $rootScope.isMask = false;
- } else if ($scope.formData.url == "complete") {
- $scope.Reset = false;
- $scope.close = true;
- }
- //解析设计数据生成表单项 end
- return result;
- }
- //======================处理表单设计数据 结束========================
- $scope.ldloading = {};
- function filter(obj) {
- angular.forEach(obj, function (key, value) {
- if (value === "" || value === null) {
- delete obj[key];
- } else if (Object.prototype.toString.call(value) === '[object Object]') {
- filter(value);
- } else if (angular.isArray(value)) {
- angular.forEach(value, function (item) {
- filter(item);
- });
- }
- });
- }
- $scope.closeModel = function () {
- // console.log($stateParams);
- $state.go($scope.formData.cancelUrl, {});
- event.preventDefault();
- };
- // console.log(vm);
- // 暂存
- $scope.save = function (data) {
- console.log(vm)
- if (vm.model.startSave) {
- vm.model["initUser"] = $rootScope.user.id;
- vm.model.start_code = "temporary";
- //处理请求数据0327
- var data0327 = JSON.parse(JSON.stringify(vm.model));
- delete data0327.repairType;
- // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
- if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
- data0327.incident.place = {
- id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
- }
- }
- api_bpm_domain.start(pdKey, data0327).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData) {
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- //console.log();
- };
- $scope.fileUploader.uploadAll();
- }
- }
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go($scope.formData.cancelUrl);
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- event.preventDefault();
- } else if (vm.model.saveAgain) {
- var toData = {
- "incident": vm.model.incident
- };
- api_user_data.updData("incident", toData).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go($scope.formData.cancelUrl);
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- event.preventDefault();
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- }
- // 巡检生成事件
- $scope.inspectionToIncident = function () {
- var userData = {
- "idx": 0,
- "sum": 10,
- "requester": {
- "name": loginUser.name
- }
- }
- api_user_data.fetchDataList("requester", userData).then(function (res) {
- console.log(res);
- var toUser = {};
- if (res.list.length > 0) {
- toUser = res.list[0]
- } else {
- toUser = loginUser
- }
- console.log(vm);
- var incidentDescription = "";
- console.log($stateParams.formUiEdit);
- if ($stateParams.formUiEdit == "inspection_confirm") {
- if (vm.model.wnCheckEnable) {
- incidentDescription = incidentDescription.concat(" 机房温度检查异常")
- }
- if (vm.model.sdCheckEnable) {
- incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
- }
- if (vm.model.xfjCheckEnable) {
- incidentDescription = incidentDescription.concat(" 新风机检查异常")
- }
- if (vm.model.lsCheckEnable) {
- incidentDescription = incidentDescription.concat(" 漏水检查异常")
- }
- if (vm.model.xfCheckEnable) {
- incidentDescription = incidentDescription.concat(" 消防检查异常")
- }
- if (vm.model.upsCheckEnable) {
- incidentDescription = incidentDescription.concat(" UPS供电检查异常")
- }
- if (vm.model.dcCheckEnable) {
- incidentDescription = incidentDescription.concat(" 电池连接检查异常")
- }
- if (vm.model.plCheckEnable) {
- incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
- }
- if (vm.model.wjtdCheckEnable) {
- incidentDescription = incidentDescription.concat(" 外机通道检查异常")
- }
- if (vm.model.descriptionTextarea) {
- incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
- }
- }
- // console.log(incidentDescription)
- var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
- var formdata = {
- 'model': {
- // 'isInspection': true,
- // 'start_code':'assignment',
- // 'isHandlerUser':false,
- 'incident': {
- 'requester':bxr ,
- 'area': bxr.place.area,
- 'place': bxr.place,
- 'houseNumber': bxr.houseNumber,
- 'contacts': bxr.name,
- 'contactsInformation': bxr.mphone,
- // 'category': data.wxIncidentClassifyDTO.category,
- 'description': incidentDescription,
- 'source': {
- 'id': 1552
- },
- // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
- // 'sourceType': data.incident.sourceType,
- // 'fileUrl': data.incident.fileUrl
- },
- // 'requestershow': toUser,//2020年4月27日22:29:15
- // 'flow': data.incident.id
- // 'assignee': loginUser.id//2020年4月27日22:29:25
- }
- }
- // console.log(formdata,toUser,'1111');
- console.log(formdata,'1111');
- // return;
- $state.go("app.incident.chart", {
- 'model': JSON.stringify(formdata)
- });
- })
- // var formdata = {
- // model:$rootScope.login_requester
- // };
- // console.log(formdata,'00000')
- // return;
- // $state.go("app.incident.chart", {
- // 'model': JSON.stringify(formdata)
- // });
- event.preventDefault();
- };
- // console.log(vm);
- // 创建事件seimin
- vm.submit = function (data, style) {
- console.log(vm,22222);
- if (vm.model.handler_code == undefined) {
- vm.model.handler_code = "resolve";
- }
- if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
- delete vm.model.change.requestingPerson.menu;
- }
- // var pdKey = $stateParams.pdKey;
- if (vm.form.$valid) {
- if (data.incident && data.incident.synergetic) {
- console.log(data.incident.synergetic);
- var synergetic = [];
- for (var i = 0; i < data.incident.synergetic.length; i++) {
- synergetic.push({
- id: data.incident.synergetic[i]
- });
- }
- data.incident.synergetic = synergetic;
- vm.model.incident.synergetic = synergetic;
- }
- $scope.ldloading[style.replace('-', '_')] = true;
- var startsub = true;
- if (pdKey == 'bpm_incident') {
- angular.forEach(vm.fields, function (item) {
- angular.forEach(item.fields, function (index) {
- if (index.templateOptions.required && !index.hide) {
- if (index.model) {
- if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
- if (index.model[index.key].id && index.model[index.key].id == '') {
- startsub = false;
- $scope.ldloading.expand_right = false;
- SweetAlert.swal({
- title: index.templateOptions.label + '未填',
- text: "请填写此项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- } else { }
- } else {
- startsub = false;
- $scope.ldloading.expand_right = false;
- SweetAlert.swal({
- title: index.templateOptions.label + '未填',
- text: "请填写此项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- } else {
- if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
- } else {
- startsub = false;
- $scope.ldloading.expand_right = false;
- SweetAlert.swal({
- title: index.templateOptions.label + '未填',
- text: "请填写此项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- }
- }
- })
- })
- // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
- // startsub = false;
- // $scope.ldloading.expand_right = false;
- // SweetAlert.swal({
- // title: '保修人未填',
- // text: "请填写此项!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- // }
- // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
- // } else {
- // startsub = false;
- // $scope.ldloading.expand_right = false;
- // SweetAlert.swal({
- // title: '事件分类未填',
- // text: "请填写此项!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- // }
- }
- if (startsub) {
- $scope.ldloading[style.replace('-', '_')] = true;
- // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
- // console.log("vm.options:"+ JSON.stringify(vm.options));
- vm.options.updateInitialValue();
- // console.log("dfjkasdhfkhskjf ")
- var _ = window._;
- vm.model = (function filter(obj) {
- var dateTransKeys = [];
- var filtered = _.pick(obj, function (v, k, obj) {
- if (_.isDate(v)) {
- dateTransKeys.push(k);
- }
- return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
- });
- return _.cloneDeep(filtered, function (v, index, object) {
- if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
- angular.forEach(dateTransKeys, function (item) {
- v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
- })
- dateTransKey = [];
- return v;
- }
- return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
- });
- })(vm.model);
- if (pdKey != "") {
- if ($scope.oprcode == "save") { //保存
- api_bpm_domain.save(taskId, vm.model).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- SweetAlert.swal({
- title: "保存成功!",
- confirmButtonColor: "#007AFF"
- }, function () {
- $state.go($scope.formData.cancelUri);
- });
- // if(resData.status){
- // resData
- // }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- } else {
- console.log($scope.formData.url,'zzzz')
- switch ($scope.formData.url) {
- case "start":
- vm.model["initUser"] = $rootScope.user.id;
- if (vm.model["assignee"] || vm.model["candidateGroups"]) {
- } else {
- vm.model["assignee"] = $rootScope.user.id;
- }
- if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
- vm.model.candidateGroups = vm.model.candidateGroups.id;
- }
- if (pdKey == 'bpm_service_request') {
- delete vm.model.serviceCatalogueProcessActual.houseNumber;
- angular.extend(vm.model.serviceCatalogueProcessActual, {
- 'category': {
- 'id': $stateParams.userId
- }
- });
- }
- if (vm.model.schedule && vm.model.schedule.initUser) {
- delete vm.model.schedule.initUser.menu
- }
- if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
- delete vm.model.candidateGroups
- }
- if (vm.model.start_code == 'close') {
- // 直接处理
- vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
- delete vm.model.incident.handlerUser
- delete vm.model.candidateGroups;
- } else if (vm.model.start_code == 'assignment') {
- // 派单
- delete vm.model.incident.handlingPersonnelUser
- }
- if ($stateParams.processInstanceId && vm.model.isZanCun) {
- $scope.jry_processInstanceId = $stateParams.processInstanceId;
- }
- if ($scope.jry_processInstanceId) {
- vm.model["save_fileId"] = $scope.jry_processInstanceId
- }
- //事件暂存判断
- if (vm.model.saveAgain) {
- if (vm.model.directClose == "1" || vm.model.directClose == true) {
- vm.model.start_code = "assignment";
- vm.model.temporary_code = "assignment";
- } else {
- vm.model.start_code = "close";
- vm.model.temporary_code = "close"
- };
- if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
- delete vm.model.candidateGroups
- }
- }
- //处理请求数据0327
- var data0327 = JSON.parse(JSON.stringify(vm.model));
- delete data0327.repairType;
- // 增加地点的请求参数2020年4月24日10:44:36
- // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
- if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
- data0327.incident.place = {
- id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
- }
- }
- api_bpm_domain.start(pdKey, data0327).then(function (response) {
- // console.log("response="+JSON.stringify(response));
- if (response) {
- var resData = Restangular.stripRestangular(response);
- if (resData) {
- if (resData) {
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- //console.log();
- };
- $scope.fileUploader.uploadAll();
- }
- }
- }
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
- $rootScope.app.layout.isSidebarClosed = false;
- if ($scope.login && !$rootScope.busy) {
- $rootScope.setidle();
- }
- }
- $state.go($scope.formData.cancelUrl);
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- break;
- case "complete":
- //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
- //console.log("complete taskId::"+$stateParams.taskId);
- if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
- SweetAlert.swal({
- title: "处理人未填",
- text: "请填写此项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
- if (response) {
- var resData = Restangular.stripRestangular(response);
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
- console.log(vm);
- if (vm.model.incident) {
- // $scope.fileUploader.onBeforeUploadItem = function (item) {
- // angular.extend(item.headers, $rootScope.getSession());
- // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
- // item.formData.push({
- // 'fileName': item.file.name
- // });
- // };
- // $scope.fileUploader.uploadAll();
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- //console.log();
- };
- $scope.fileUploader.uploadAll();
- } else if (vm.model.problem) {
- $scope.fileUploader.onBeforeUploadItem = function (item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
- item.formData.push({
- 'fileName': item.file.name
- });
- };
- $scope.fileUploader.uploadAll();
- } else if (vm.model.change) {
- }
- }
- $state.go($scope.formData.cancelUrl);
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- break;
- case "back":
- $state.go($scope.formData.cancelUrl);
- break;
- default:
- $scope.ldloading[style.replace('-', '_')] = false;
- break;
- }
- }
- // var submitFunc = api_bpm_domain[$scope.formData.url]
- // if(anuglar.isFunction(submitFunc)){
- // submitFunc.apply(null, pdKey)
- // }
- }
- }
- } else {
- // console.log(data)
- // angular.forEach(vm.form.$error.required, function(item){
- // var i=(item.$name).substring(item.$name.length-2)
- var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
- // for(var i=0;i<vm.fields.length;i++){
- if (vm.fields[i].name == vm.form.$error.required[0].$name) {
- SweetAlert.swal({
- title: vm.fields[i].templateOptions.label + '未填',
- text: "请填写此项!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- // }
- // angular.forEach(vm.fields,function(f){
- // if(f.name == item.$name){
- // f.validation.show = true;
- // SweetAlert.swal({
- // title: f.templateOptions.label+'未填',
- // text: "请填写此项!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- // }
- // });
- // })
- }
- };
- $scope.vm = vm;
- console.log($stateParams,pdKey,88888)
- console.log($scope.vm,'assdfsdf')
-
-
- if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
- var processInstanceId = $stateParams.processInstanceId;
- var itemId = $stateParams.dataId;
- console.log($stateParams)
- if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
- api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
- if (responseData) { //console.log("responseData>>>");//console.log(responseData);
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- decodeVMForm(vmForm);
- }
- }
- });
- } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
- api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
- if (responseData) { //console.log("responseData>>>");//console.log(responseData);
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- decodeVMForm(vmForm);
- }
- }
- });
- } else {
- api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
- if (response) {
- var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
- api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
- if (responseData) { //console.log("responseData>>>");//console.log(responseData);
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
- decodeVMForm(vmForm);
- console.log(vmForm,111111);
- // $scope.model.selecthouseNumber = vmForm.model.incident.place;
- console.log($scope,'今天')//2020年4月24日11:40:55
- }
- }
- });
- }
- })
- }
- } else {
- // create process instance
- if (pdKey != "") { //for process
- if (pdKey == 'bpm_service_request') {
- api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
- if (responseData) {
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) {
- decodeVMForm(vmForm);
- }
- }
- });
- } else {
- api_bpm_domain.startformkey(pdKey).then(function (response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- //myData.data = "arrangeform";
- api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
- if (responseData) {
- var vmForm = Restangular.stripRestangular(responseData);
- if (vmForm) {
- decodeVMForm(vmForm);
- }
- }
- });
- }
- });
- }
- } else { //for form
- //TODO
- //测试数据 开始
- var testJson = {
- fields: [{
- fields: [{
- className: "col-xs-12",
- noFormControl: true,
- key: "formtitle",
- templateOptions: {
- readOnly: false,
- placeholder: "新建事件单",
- hidden: false,
- label: "事件工单",
- required: false
- },
- type: "ui-title"
- }]
- }, {
- fields: [{
- key: 'selectUser',
- type: 'ui-deptinformation',
- className: 'col-xs-12',
- templateOptions: {
- label: '请求人信息',
- modalTitle: '请求人列表',
- fetchItems: function (filterData, APIService) {
- return APIService.fetchDataList('requester', filterData);
- },
- Restangular: Restangular,
- ApiService: api_user_data
- // onClick:function(val, options, field, event , model){
- // console.log(options);
- // }
- }
- }]
- }, {
- fields: [{
- key: 'first',
- type: 'ui-workernumber',
- className: 'col-xs-12',
- templateOptions: {
- type: 'input',
- label: '事件单号',
- pkey: 'name'
- }
- }]
- }, {
- fields: [{
- type: 'ui-header',
- key: 'title',
- className: 'col-xs-12',
- templateOptions: {
- label: '报修人',
- pkey: 'change'
- }
- }, {
- type: 'ui-input',
- key: 'title',
- className: 'col-xs-4',
- templateOptions: {
- label: '报修人',
- pkey: 'change'
- }
- }, {
- type: 'ui-input',
- key: 'title',
- className: 'col-xs-4',
- templateOptions: {
- label: '联系人',
- pkey: 'change'
- }
- }, {
- type: 'ui-input',
- key: 'title',
- className: 'col-xs-4',
- templateOptions: {
- label: '联系电话',
- pkey: 'change'
- }
- }]
- }, {
- fields: [{
- type: 'ui-header',
- key: 'title1',
- className: 'col-xs-12',
- templateOptions: {
- label: '报修人',
- pkey: 'change'
- }
- }, {
- type: 'ui-input',
- key: 'title2',
- className: 'col-xs-4',
- templateOptions: {
- label: '报修人',
- pkey: 'change'
- }
- }, {
- type: 'ui-input',
- key: 'title3',
- className: 'col-xs-4',
- templateOptions: {
- label: '联系人',
- pkey: 'change'
- }
- }, {
- type: 'ui-input',
- key: 'title4',
- className: 'col-xs-4',
- templateOptions: {
- label: '联系电话',
- pkey: 'change'
- }
- }]
- }],
- model: [{
- username: "robin lau",
- password: "123456",
- chkme: false,
- start_code: 0,
- formtitle: "Hey!I am title value!",
- name: {
- first: "robin",
- last: "lau"
- },
- multiselectItem: []
- //date:"2015-09-15 00:00:00"
- }]
- // }
- };
- setTimeout(function () {
- decodeVMForm(testJson);
- $scope.$apply();
- }, 500);
- //测试数据结束
- }
- }
- //console.log("end decode");
- }
- ]);
|