customFormIndexCtrl.js 442 KB

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