12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836 |
- 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) {
- console.log($scope)
- $scope.selection = {
- id: ''
- };
- //认证计费数据获取
- $scope.sumInfo = {};
- function getSumInfo() {
- api_bpm_data.sumInfo($scope.model.incident.account).then(function (data) {
- console.log(data)
- if (data) {
- $scope.sumInfo = data.data||{};
- }
- })
- }
- getSumInfo();
- // 收起重复事件侧滑框
- 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.keypressModel = function(e,key){
- if(e.keyCode === 13){
- $scope.openModel(key);
- }
- }
- // 引用知识库点击
- $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.title = $scope.model.incident.description = item.title;
- $scope.model.incident.category = item.category;
- if(item.category){
- $scope.model.incident.priority.id = item.category.priority.id;
- item.category.label = item.category.category;
- }
- var categoryId = item.category?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?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.options.templateOptions.pkey == "incident.handlerUser"){
- 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, e) {
- if(e.clientX === 0){
- return;
- }
- e.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];
- $scope.saveReqPlace = false;
- $scope.model.saveReqPlace = false;
- $scope.selectGradeBox = function(){
- $scope.saveReqPlace = !$scope.saveReqPlace;
- console.log($scope);
- $scope.model.saveReqPlace = $scope.saveReqPlace;
- }
- 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);
- // return;
- 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;
- console.log(vm)
- SweetAlert.swal({
- title: index.templateOptions.label + '未填2',
- 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
- // }
- // }
- console.log(vm);
- 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");
- }
- ]);
|