customformCtrl_备份20170525.js 347 KB

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