123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044 |
- 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({
- overwriteOk: true,
- 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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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() {},
- getScope: function () {
- return scope;
- },
- 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);
- // }
- // }
- // });
- }
- //新建事件,选择派单,选择工作组查找处理人baba
- if (key == "handlerUser") {
- model.fields.forEach(function (v) {
- if (v.templateOptions.pkey == "incident.handlerUser") {
- v.templateOptions.options = list;
- if (model.model.incident.handlerUser) {
- if (model.model.incident.handlerUser.id) {
- var flag = list.some(function (v) {
- return v.id == model.model.incident.handlerUser.id;
- });
- if (flag) {
- v.model.id = model.model.incident.handlerUser.id;
- }
- }
- }
- }
- });
- }
- });
- },
- 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",
- "$stateParams",
- function ($scope, $rootScope, api_bpm_domain, $stateParams) {
- // $scope.myFilter = function(item) {
- // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
- // }
- console.log($scope, "风浪");
- //工作组添加全部选项
- // if($scope.options.templateOptions.label == '工作组'){
- // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
- // $scope.model._group = 0;
- // }
- 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 (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- var paramsModel = JSON.parse($stateParams.model)
- if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
- $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
- $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
- }
- }
- //处理人根据事件分类自动带入baba
- if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
- console.log($scope.options.templateOptions.pkey);
- if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
- if (
- $scope.$parent.$parent.$parent.model.incident.handlerUser.id
- ) {
- $scope.$parent.$parent.$parent.model.assignee =
- $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-select-xj",
- extends: "select",
- templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
- defaultOptions: function (options, scope) {
- return {
- templateOptions: {
- getScope: function () {
- return scope;
- },
- refreshDelay: 0,
- validators: {
- required: {
- expression: function (viewValue, modelValue) {
- var value = modelValue || viewValue;
- return value != null;
- },
- },
- },
- },
- controller: [
- "$scope",
- "$rootScope",
- "api_bpm_domain",
- "$stateParams",
- function ($scope, $rootScope, api_bpm_domain, $stateParams) {
- $scope.model[$scope.options.key] = '全部';//默认全部
- var arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
- arr.unshift({value:'全部',name:'全部'});
- $scope.options.templateOptions.options = arr;
- console.log($scope)
- // ts.$parent.fields.forEach(v=>{
- // if(v.templateOptions.onlyKey === "batchNos"){
- // //巡检计划-批次号
- // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
- // v.templateOptions.getScope().refreshData(batchNos)
- // }
- // })
- // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
- // console.log($scope.options)
- // console.log($scope.model)
- },
- ],
- };
- },
- });
- //下拉多选框组件
- 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-isteven",
- extends: "select",
- templateUrl: "assets/views/customform/tpl/ui-isteven.html",
- defaultOptions: function (options,$scope) {
- return {
- templateOptions: {
- refresh: function () {
- console.log(options)
- options.templateOptions
- .refreshData(options.templateOptions.APIService)
- .then(function (result) {
- if(result.status == 200){
- console.log(result.list)
- //树形结构转换
- function formatDataTree2(json){
- var _json = JSON.parse(JSON.stringify(json));
- return _json.filter(p=>{
- var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
- _arr.length && (p.children = _arr);
- return !p.parent;
- })
- }
- console.log(result.list)
- var list = formatDataTree2(result.list);
- console.log(list)
- // $scope.treeList = angular.copy(list);
- var resultList = [];
- //转换数据
- function trasData(list,obj){
- if(obj){
- //有父级
- list.forEach(v=>{
- var type = "<strong>"+ v.parent.type +"</strong>";//父级type
- var i = resultList.findIndex(c=>c.type == type);
- if(v.children){
- resultList.splice(i+1,0,{
- type: "<strong>"+ v.type +"</strong>",
- msId: v.id,
- msGroup: true,
- },{msGroup: false})
- trasData(v.children,v);
- }else{
- resultList.splice(i+1,0,{...v,...{ticked:false}});
- }
- })
- }else{
- //顶级
- list.forEach(v=>{
- if(v.children){
- resultList.push({
- type: "<strong>"+ v.type +"</strong>",
- msId: v.id,
- msGroup: true,
- },{msGroup: false})
- trasData(v.children,v);
- }else{
- resultList.push(...v,...{ticked:false});
- }
- })
- }
- return resultList;
- }
- var __arr = trasData(list,null);
- console.log(__arr,options.model.typeIds.split(','))
- if(options.model.typeIds){
- //有巡检类型,则需要回显
- __arr.forEach(w=>{
- w.ticked = options.model.typeIds.split(',').includes(w.id+'');
- })
- }
- $scope.webBrowsersGrouped = __arr;
- console.log($scope.webBrowsersGrouped);
- }
- })
- },
- refreshDelay: 1000,
- },
- };
- },
- controller: [
- "$scope",
- function ($scope) {
- console.log($scope)
- $scope.to.refresh();//获取列表数据
- // $scope.model[$scope.options.key] = [];
- //单项点击或菜单
- $scope.fClick = function(data){
- console.log($scope.outputBrowsers)
- $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
- console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
- // if(data.id){
- // //单项点击
- // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
- // //有巡检类型
- // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
- // if(data.ticked){
- // arr.push(data.id);
- // }else{
- // arr = arr.filter(v=>v != data.id);
- // }
- // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
- // }else{
- // //无巡检类型
- // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
- // if(data.ticked){
- // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
- // }else{
- // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
- // }
- // }
- // }else{
- // // 菜单点击
- // console.log($scope.webBrowsersGrouped,data.msId);
- // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
- // return v.parent?v.parent.id == data.msId:false;
- // })
- // if(treeResultArr.every(v=>v.ticked)){
- // //全部都是true的情况下,需要移除,否则增加
- // }
- // console.log(treeResultArr)
- // // --------------------------------------
- // // var treeArr = [];
- // // function findParent(treeList){
- // // treeList.forEach(v=>{
- // // if(v.id == data.msId){
- // // treeArr = v.children;
- // // }else{
- // // if(v.children){
- // // findParent(v.children);
- // // }
- // // }
- // // })
- // // return treeArr;
- // // }
- // // var treeResultArr = findParent($scope.treeList);
- // // console.log(treeResultArr)
- // // -----------------------------------
- // }
- }
- // 全选
- $scope.fSelectAll = function(){
- // console.log($scope.webBrowsersGrouped)
- var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
- // console.log(arr);
- $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
- console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
- }
- // 全不选
- $scope.fSelectNone = function(){
- $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
- console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
- }
- // 配置信息
- $scope.outputBrowsers = [];
- $scope.localLang = {
- selectAll: "全选",
- selectNone: "全不选",
- nothingSelected: "请选择"
- }
- },
- ],
- });
- //下拉多选框灵活组件
- 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) {
- console.log(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];
- var ides = [];
- var rList = result.list || result;
- if ($scope.options.key == "serviceTypeIds") {
- modelVal = modelVal.map(function (v) {
- if (typeof v !== 'object') {
- return { id: v };
- } else {
- return v;
- }
- })
- }
- for (var i = 0; i < modelVal.length; i++) {
- for (var j = 0; j < rList.length; j++) {
- if (rList[j].id == modelVal[i].id) {
- ides.push(rList[j].id);
- }
- }
- }
- ides.forEach(function (v1) {
- rList.forEach(function (v2) {
- if (v1 == v2.id) {
- rList = rList.filter(v => v.id != v2.id);
- }
- })
- })
- options.templateOptions.options = rList;
- // 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, options);
- 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) {
- //回显事件分类,带出绑定的人或组start caocao
- if (items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
- console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
- var item = result[options.templateOptions.optionsDataKey].find(function (v) {
- return v.id == items.$parent.originalModel.incident.category.id;
- })
- console.log(item)//11615
- if (item) {
- if (item.userOrGroupType === 1) {
- items.$parent.originalModel.start_code = 'assignment';
- items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
- items.$parent.originalModel.directClose = true;
- items.$parent.originalModel.isHandlerUser = false;
- setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
- } else if (item.userOrGroupType === 2) {
- items.$parent.originalModel.start_code = 'assignment';
- items.$parent.originalModel.candidateGroups = item.group;
- items.$parent.originalModel.directClose = true;
- items.$parent.originalModel.isHandlerUser = false;
- } else {
- items.$parent.originalModel.start_code = 'close';
- items.$parent.originalModel.directClose = false;
- items.$parent.originalModel.isHandlerUser = false;
- delete items.$parent.originalModel.candidateGroups;
- delete items.$parent.originalModel.incident.handlerUser
- }
- }
- }
- //回显事件分类,带出绑定的人或组end
- 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);//baba
- } 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) {
- console.log($scope)
- if($scope.options.templateOptions.isTrue){
- //是否默认打开
- $scope.model[$scope.options.key] = true;
- }
- // 巡检生成事件,默认派单
- 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;
- }
- },
- ],
- });
- //勾选组件(禁用)--yeye
- formlyConfigProvider.setType({
- name: "ui-checkbox-disabled",
- extends: "checkbox",
- templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.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,scope) {
- return {
- templateOptions: {
- linkage: function () { },
- getScope: function () {
- return scope;
- },
- },
- };
- },
- 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,
- },
- {
- name: "batchNo",
- 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;
- console.log(angular.isUndefined(filterData))
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- console.log(filterData)
- if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
- filterData.inspectionProcessActual = {
- inspectionid: $scope.model.id,
- batchNo:filterData.inspectionProcessActual.batchNo
- }
- }else{
- filterData.inspectionProcessActual = {
- inspectionid: $scope.model.id
- }
- }
- // angular.extend(filterData, {
- // inspectionProcessActual: {
- // inspectionid: $scope.model.id,
- // },
- // });
- console.log(filterData)
- 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-handlerLog",
- templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
- controller: [
- "$scope",
- "api_bpm_data",
- "Restangular",
- function ($scope, api_bpm_data, Restangular) {
- console.log($scope, 'ui-handlerLog')
- },
- ],
- });
- //资产
- formlyConfigProvider.setType({
- name: "ui-zc",
- templateUrl: "assets/views/customform/tpl/ui-zc.html",
- controller: [
- "$scope",
- "api_bpm_data",
- "Restangular",
- function ($scope, api_bpm_data, Restangular) {
- console.log($scope, 'ui-zc');
- $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
- },
- ],
- });
- //绑定的耗材
- formlyConfigProvider.setType({
- name: "ui-hc",
- templateUrl: "assets/views/customform/tpl/ui-hc.html",
- controller: [
- "$scope",
- "api_cmdb2",
- "Restangular",
- function ($scope, api_cmdb2, Restangular) {
- console.log($scope, 'ui-hc')
- $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
- $scope.list = [];
- var sjId = $scope.model.incident.id;
- api_cmdb2.getHc(sjId).then(function (response) {
- console.log(response)
- if (response.status == 200) {
- $scope.list = response.data;
- }
- })
- },
- ],
- });
- //历史记录
- 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) {
- 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,
- $stateParams
- ) {
- $modalInstance.SweetAlert = SweetAlert;
- $scope.title = "新增报修人";
- $scope.requester = {};
- $scope.searchData = {};
- if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- var paramsModel = JSON.parse($stateParams.model)
- //来电-添加报修人-回显电话
- if (paramsModel.model.incident.requester.hjzxPhone) {
- $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
- }
- }
- $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);
- // }
- } else {
- modalInstance.SweetAlert.swal({
- title: "系统错误",
- text: "账号重复!",
- type: "error",
- });
- }
- });
- }
- },
- 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",
- "$stateParams",
- function ($scope, api_user_data, api_statistic, $stateParams) {
- console.log($stateParams)
- if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- var paramsModel = JSON.parse($stateParams.model)
- //来电-添加报修人
- if (paramsModel.model.incident.requester.hjzxPhone) {
- $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
- }
- }
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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;
- // var agcount = tlwsa.tlaGetagentcount();
- // var agcountFlag = false;
- // console.log(teleno)
- // // 查询当前话机是否签入
- // for (var i = 0; i < agcount; i++) {
- // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
- // agcountFlag = true;
- // }
- // }
- if (localStorage.getItem('fenjiNumber')) {
- // var caller = localStorage.getItem('phoneNumber');//呼叫人
- // console.log(sessionStorage.getItem('phones'))
- // var phones = JSON.parse(sessionStorage.getItem('phones'));
- // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
- // console.log(isHuajihao)
- // if(isHuajihao){
- // tlwsa.tlaCallagc(teleno);
- // }else{
- // tlwsa.tlaCallout(teleno, caller, 0);
- // }
- // var caller = localStorage.getItem('fenjiNumber');//呼叫人
- $rootScope.toggle('off-sidebar');
- // tlwsa.tlaCallout(teleno, caller, 0);
- } 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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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, 20, 50, 100];
- $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(0.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_domain1",
- "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_domain1,
- 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_LinHu_confirm") {
- var fields = vm.fields
- .filter((v) => {
- v.key = (v.key || "").toString();
- return v.key.indexOf("sdCheckEnable") > -1;
- })
- .map((v) => ({
- key: v.key,
- name: v.templateOptions.label,
- value: vm.model[v.key],
- }));
- fields.forEach(v=>{
- if (vm.model[v.key]) {
- incidentDescription =
- incidentDescription.concat(v.name);
- }
- })
- if (vm.model.descriptionTextarea) {
- incidentDescription = incidentDescription.concat(
- " " + "整改意见:" + vm.model.descriptionTextarea
- );
- }
- }
- // console.log(incidentDescription)
- var bxr = JSON.parse(localStorage.getItem("login_requester"));
- 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 + "未填",
- 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
- // }
- // }
- if (data0327.start_code == "close") {
- data0327.incident.directProcess = 1;
- }
- console.log(vm);
- if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
- var paramsModel = JSON.parse($stateParams.model)
- //来电-传话机id
- if (paramsModel.model.incident.sockid) {
- data0327.incident.callID = paramsModel.model.incident.sockid;
- }
- }
- 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;
- }
- console.log(vm);
- //处理日志
- // 处理日志不为空并且事件是处理中状态
- if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
- api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
- baseHandler();
- })
- } else {
- baseHandler();
- }
- // return;
- function baseHandler() {
- 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) {
- }else if(vm.model.inspectionProcessActual){
- //巡检图片上传yeye
- $scope.fileUploader.onBeforeUploadItem =
- function (item) {
- angular.extend(
- item.headers,
- $rootScope.getSession()
- );
- item.url = api_bpm_domain1
- .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
- .getRequestedUrl();
- item.formData.push({
- fileName: item.file.name,
- });
- //console.log();
- };
- $scope.fileUploader.uploadAll();
- }
- }
- $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");
- },
- ]);
|