customFormIndexCtrl.js 366 KB

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