customformCtrl.js 958 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793
  1. var appFormly = angular.module('formlyExample', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlyExample');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. // 图片上传
  10. app.factory('fileReader', ["$q", "$log", function ($q, $log) {
  11. var onLoad = function (reader, deferred, scope) {
  12. return function () {
  13. scope.$apply(function () {
  14. deferred.resolve(reader.result);
  15. });
  16. };
  17. };
  18. var onError = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.reject(reader.result);
  22. });
  23. };
  24. };
  25. var getReader = function (deferred, scope) {
  26. var reader = new FileReader(); //fileReader
  27. reader.onload = onLoad(reader, deferred, scope);
  28. reader.onerror = onError(reader, deferred, scope);
  29. return reader;
  30. };
  31. var readAsDataURL = function (file, scope) {
  32. var deferred = $q.defer();
  33. var reader = getReader(deferred, scope);
  34. reader.readAsDataURL(file);
  35. return deferred.promise;
  36. };
  37. return {
  38. readAsDataUrl: readAsDataURL
  39. };
  40. }])
  41. appFormly.config(
  42. function config(formlyConfigProvider) {
  43. //格式转换方法 XXX-XXX转驼峰命名
  44. function camelize(string) {
  45. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  46. return chr ? chr.toUpperCase() : '';
  47. });
  48. // Ensure 1st char is always lowercase
  49. return string.replace(/^([A-Z])/, function (match, chr) {
  50. return chr ? chr.toLowerCase() : '';
  51. });
  52. }
  53. //获取ngModelAttr对象设置
  54. function getNgModelAttr(attrs, bindings) {
  55. var ngModelAttrs = {};
  56. angular.forEach(attrs, function (attr) {
  57. ngModelAttrs[camelize(attr)] = {
  58. attribute: attr
  59. };
  60. });
  61. angular.forEach(bindings, function (binding) {
  62. ngModelAttrs[camelize(binding)] = {
  63. bound: binding
  64. };
  65. });
  66. return ngModelAttrs;
  67. }
  68. formlyConfigProvider.setWrapper({
  69. name: 'bootstrapLabel',
  70. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  71. });
  72. //流程图
  73. formlyConfigProvider.setType({
  74. name: 'ui-process',
  75. templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
  76. defaultOptions: function (options) {
  77. return {
  78. templateOptions: {
  79. refresh: function () { },
  80. refreshDelay: 0
  81. }
  82. };
  83. },
  84. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  85. $scope.processdata = [];
  86. api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function (data) {
  87. console.log(data)
  88. $scope.processdata = data.data;
  89. })
  90. }]
  91. });
  92. //出库单详情
  93. formlyConfigProvider.setType({
  94. name: 'ui-getoutinform',
  95. extends: 'radio',
  96. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
  97. defaultOptions: function (options) {
  98. return {
  99. templateOptions: {
  100. refresh: function () { },
  101. refreshDelay: 0
  102. }
  103. };
  104. },
  105. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  107. if ($scope.model.type.id = 0) {
  108. $scope.model.type.name = "新资产入库";
  109. } else if ($scope.model.type.id = 1) {
  110. $scope.model.type.name = "新设备领用出库";
  111. } else if ($scope.model.type.id = 2) {
  112. $scope.model.type.name = "资产归还";
  113. } else if ($scope.model.type.id = 4) {
  114. $scope.model.type.name = "设备更换";
  115. }
  116. }
  117. }]
  118. });
  119. //多选框组件
  120. formlyConfigProvider.setType({
  121. name: 'ui-checkboxmore',
  122. extends: 'radio',
  123. templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
  124. defaultOptions: function (options) {
  125. return {
  126. templateOptions: {
  127. refresh: function () { },
  128. refreshDelay: 0
  129. }
  130. };
  131. },
  132. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  133. $scope.options.initialValue = $scope.model[$scope.options.key];
  134. }]
  135. });
  136. //入库单详情
  137. formlyConfigProvider.setType({
  138. name: 'ui-getininform',
  139. extends: 'radio',
  140. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
  141. defaultOptions: function (options) {
  142. return {
  143. templateOptions: {
  144. refresh: function () { },
  145. refreshDelay: 0
  146. }
  147. };
  148. },
  149. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  150. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  151. if ($scope.model.type.id = 0) {
  152. $scope.model.type.name = "新资产入库";
  153. } else if ($scope.model.type.id = 1) {
  154. $scope.model.type.name = "新设备领用出库";
  155. } else if ($scope.model.type.id = 2) {
  156. $scope.model.type.name = "资产归还";
  157. } else if ($scope.model.type.id = 4) {
  158. $scope.model.type.name = "设备更换";
  159. }
  160. }
  161. }]
  162. });
  163. //申请人详情
  164. formlyConfigProvider.setType({
  165. name: 'ui-requsterinfom',
  166. extends: 'radio',
  167. templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
  168. defaultOptions: function (options) {
  169. return {
  170. templateOptions: {
  171. refresh: function () { },
  172. refreshDelay: 0
  173. }
  174. };
  175. }
  176. });
  177. //设备耗材list组件
  178. formlyConfigProvider.setType({
  179. name: 'ui-uplodchange',
  180. templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
  181. defaultOptions: function (options) {
  182. return {
  183. templateOptions: {
  184. refresh: function () { },
  185. refreshDelay: 0,
  186. view: function (APIService, contentId) {
  187. return APIService.downloadAttachment(contentId);
  188. }
  189. }
  190. };
  191. },
  192. controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  193. // var data = { "haodata": [], "shedata": [] };
  194. var haodata = [];
  195. var shedata = [];
  196. if ($scope.model.consumables) {
  197. if (angular.isArray($scope.model.consumables)) {
  198. haodata = $scope.model.consumables;
  199. } else {
  200. haodata = JSON.parse($scope.model.consumables);
  201. }
  202. $scope.model.consumables = haodata;
  203. angular.forEach(haodata, function (item, index) {
  204. haodata[index].item = index + 1;
  205. })
  206. }
  207. if ($scope.model.assets) {
  208. if (angular.isArray($scope.model.assets)) {
  209. shedata = $scope.model.assets;
  210. } else {
  211. shedata = JSON.parse($scope.model.assets);
  212. }
  213. $scope.model.assets = shedata;
  214. angular.forEach(shedata, function (item, index) {
  215. shedata[index].item = index + 1;
  216. })
  217. }
  218. $scope.tableParamshao = new ngTableParams({
  219. page: 1,
  220. count: 5
  221. }, {
  222. total: haodata.length,
  223. getData: function ($defer, params) {
  224. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  225. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  226. }
  227. });
  228. $scope.tableParamsshe = new ngTableParams({
  229. page: 1,
  230. count: 5
  231. }, {
  232. total: shedata.length,
  233. getData: function ($defer, params) {
  234. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  235. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  236. }
  237. });
  238. $scope.editId = -1;
  239. $scope.setEditId = function (pid) {
  240. $scope.editId = pid;
  241. };
  242. if (angular.isUndefined($scope.form.dropState)) {
  243. $scope.form.dropState = false;
  244. }
  245. var to = $scope.options.templateOptions;
  246. var bindId = $scope.model.processInstanceId;
  247. //获取附件列表
  248. $scope.listAttachmen = function () {
  249. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  250. var myData = Restangular.stripRestangular(result);
  251. // $scope.listAttachmens = myData;
  252. $scope.attachments = myData.data;
  253. });
  254. };
  255. $scope.listAttachmen();
  256. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  257. // $scope.listAttachmen();
  258. // } else if (to.bindType && $scope.model[to.bindType].id) {
  259. // $scope.listAttachmen();
  260. // }
  261. //附件下载
  262. $scope.download = function (token, filename) {
  263. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  264. // window.open(downUrl);
  265. var a = document.createElement('a');
  266. a.href = downUrl;
  267. a.target = '_blank';
  268. a.download = filename;
  269. document.body.appendChild(a);
  270. a.click();
  271. };
  272. //附件预览
  273. $scope.view = function (id, previewUrl) {
  274. if (previewUrl) {
  275. window.open(previewUrl);
  276. }
  277. };
  278. }]
  279. });
  280. //多选框组件
  281. formlyConfigProvider.setType({
  282. name: 'ui-nodataimage',
  283. templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
  284. defaultOptions: function (options) {
  285. return {
  286. templateOptions: {
  287. refresh: function () { },
  288. refreshDelay: 0
  289. }
  290. };
  291. }
  292. });
  293. //ui-grid list
  294. formlyConfigProvider.setType({
  295. name: "ui-gridtwolist",
  296. // extends: 'input',
  297. templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
  298. defaultOptions: function (options, $scope) {
  299. return {
  300. templateOptions: {}
  301. };
  302. },
  303. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  304. //gridone
  305. $scope.langs = i18nService.getAllLangs();
  306. $scope.lang = 'zh-cn';
  307. i18nService.setCurrentLang($scope.lang);
  308. $scope.gridOptions = {};
  309. $scope.gridOptions.data = 'myDatagrid';
  310. $scope.gridOptions.enableColumnResizing = true;
  311. $scope.gridOptions.enableFiltering = true;
  312. $scope.gridOptions.enableGridMenu = false;
  313. $scope.gridOptions.enableRowSelection = true;
  314. $scope.gridOptions.showGridFooter = true;
  315. $scope.gridOptions.showColumnFooter = false;
  316. $scope.gridOptions.fastWatch = true;
  317. $scope.gridOptions.useExternalFiltering = false;
  318. $scope.gridOptions.useExternalPagination = true;
  319. $scope.gridOptions.paginationPageSizes = [10];
  320. $scope.gridOptions.paginationPageSize = 10;
  321. $scope.gridOptions.multiSelect = false;
  322. $scope.myDatagrid = [];
  323. $scope.myDatagridall = [];
  324. $scope.selected = {
  325. item: {}
  326. };
  327. $scope.memoryfilterDatagrid = {
  328. idx: 0,
  329. sum: 10
  330. }
  331. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  332. filterData = {
  333. idx: 0,
  334. sum: 10
  335. };
  336. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  337. }
  338. $scope.gridOptions.rowIdentity = function (row) {
  339. return row.id;
  340. };
  341. $scope.gridOptions.getRowIdentity = function (row) {
  342. return row.id;
  343. };
  344. // $scope.gridOptions.columnDefs = items.columnDefs();
  345. $scope.interceptMydata = function (mydate, idx, sum) {
  346. return mydate.slice(idx * sum, (idx + 1) * sum)
  347. }
  348. $scope.gridOptions.onRegisterApi = function (gridApi) {
  349. $scope.gridApi = gridApi;
  350. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  351. $scope.memoryfilterDatagrid.idx = newPage - 1;
  352. $scope.memoryfilterDatagrid.sum = pageSize;
  353. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  354. $scope.loadData({
  355. "idx": newPage - 1,
  356. "sum": pageSize
  357. });
  358. });
  359. gridApi.core.on.filterChanged($scope, function () { });
  360. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  361. $scope.selected.item = data.entity;
  362. //console.log(data);
  363. });
  364. };
  365. $scope.loadData = function (mydate, idx, sum) {
  366. angular.forEach($scope.myDatagrid, function (item, index) {
  367. $scope.myDatagrid[index].item = index;
  368. })
  369. $scope.gridOptions.totalItems = mydate.length;
  370. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  371. }
  372. if ($scope.model.assets) {
  373. $scope.myDatagridall = $scope.model.assets;
  374. $scope.loadData($scope.model.assets, 0, 10)
  375. }
  376. $scope.saveData = function (itemin) {
  377. event.preventDefault();
  378. var modalInstance = $modal.open({
  379. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  380. controller: function ($scope, $modalInstance, SweetAlert) {
  381. // $scope.consumptive = {};
  382. $scope.title = "填写领用设备信息";
  383. // if (items.name) {
  384. // $scope.consumptive.name = items.name.name;
  385. // }
  386. $scope.placechange = angular.copy(itemin);
  387. $scope.ok = function (item) {
  388. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  389. $modalInstance.close(item);
  390. } else {
  391. SweetAlert.swal({
  392. title: "数据填写不完整!",
  393. text: "请检查数据然后提交!",
  394. type: "error"
  395. });
  396. }
  397. };
  398. $scope.cancel = function () {
  399. $modalInstance.dismiss('cancel');
  400. };
  401. },
  402. resolve: {
  403. SweetAlert: function () {
  404. return SweetAlert;
  405. }
  406. }
  407. });
  408. modalInstance.result.then(function (selectedItem) {
  409. angular.forEach($scope.myDatagrid, function (item, index) {
  410. // $scope.myDatagrid[index].props.hw_state = "在线";
  411. if (item.id == selectedItem.id) {
  412. // $scope.myDatagrid[index] = selectedItem;
  413. angular.extend($scope.myDatagrid[index], selectedItem)
  414. }
  415. })
  416. // $scope.myData3.push(selectedItem);
  417. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  418. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  419. }
  420. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  421. })
  422. }
  423. //gridtwo
  424. $scope.langs = i18nService.getAllLangs();
  425. $scope.lang = 'zh-cn';
  426. i18nService.setCurrentLang($scope.lang);
  427. $scope.gridOptions2 = {};
  428. $scope.gridOptions2.data = 'myDatagridold';
  429. $scope.gridOptions2.enableColumnResizing = true;
  430. $scope.gridOptions2.enableFiltering = true;
  431. $scope.gridOptions2.enableGridMenu = false;
  432. $scope.gridOptions2.enableRowSelection = true;
  433. $scope.gridOptions2.showGridFooter = true;
  434. $scope.gridOptions2.showColumnFooter = false;
  435. $scope.gridOptions2.fastWatch = true;
  436. $scope.gridOptions2.useExternalFiltering = false;
  437. $scope.gridOptions.useExternalPagination = true;
  438. $scope.gridOptions2.paginationPageSizes = [10];
  439. $scope.gridOptions2.paginationPageSize = 10;
  440. $scope.gridOptions2.multiSelect = false;
  441. $scope.myDatagridold = [];
  442. $scope.myDatagridoldall = [];
  443. $scope.selected = {
  444. item: {}
  445. };
  446. $scope.memoryfilterDatagridold = {
  447. idx: 0,
  448. sum: 10
  449. }
  450. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  451. filterData = {
  452. idx: 0,
  453. sum: 10
  454. };
  455. $scope.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
  456. }
  457. $scope.gridOptions2.rowIdentity = function (row) {
  458. return row.id;
  459. };
  460. $scope.gridOptions2.getRowIdentity = function (row) {
  461. return row.id;
  462. };
  463. // $scope.gridOptions.columnDefs = items.columnDefs();
  464. $scope.interceptMydata = function (mydate, idx, sum) {
  465. return mydate.slice(idx * sum, (idx + 1) * sum)
  466. }
  467. if ($scope.model.oldAssets) {
  468. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  469. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
  470. }
  471. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  472. $scope.gridApi = gridApi;
  473. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  474. $scope.memoryfilterDatagridold.idx = newPage - 1;
  475. $scope.memoryfilterDatagridold.sum = pageSize;
  476. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
  477. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  478. });
  479. gridApi.core.on.filterChanged($scope, function () { });
  480. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  481. $scope.selected.item = data.entity;
  482. //console.log(data);
  483. });
  484. };
  485. // $scope.loadData = function(mydate, idx, sum) {
  486. // angular.forEach($scope.myDatagridold, function(item, index) {
  487. // $scope.myDatagridold[index].item = index;
  488. // })
  489. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  490. // }
  491. // if ($scope.model.assets) {
  492. // $scope.myDatagridallold = $scope.model.assets;
  493. // $scope.loadData($scope.model.assets, 0, 10)
  494. // }
  495. // $scope.addoldassets = function(itemin) {
  496. // event.preventDefault();
  497. // var modalInstance = $modal.open({
  498. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  499. // controller: function($scope, $modalInstance, SweetAlert) {
  500. // // $scope.consumptive = {};
  501. // $scope.title = "填写领用设备信息";
  502. // // if (items.name) {
  503. // // $scope.consumptive.name = items.name.name;
  504. // // }
  505. // $scope.placechange = itemin;
  506. // $scope.ok = function(item) {
  507. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  508. // $modalInstance.close(item);
  509. // } else {
  510. // SweetAlert.swal({
  511. // title: "数据填写不完整!",
  512. // text: "请检查数据然后提交!",
  513. // type: "error"
  514. // });
  515. // }
  516. // };
  517. // $scope.cancel = function() {
  518. // $modalInstance.dismiss('cancel');
  519. // };
  520. // },
  521. // resolve: {
  522. // SweetAlert: function() {
  523. // return SweetAlert;
  524. // }
  525. // }
  526. // });
  527. $scope.interceptMydata = function (mydate, idx, sum) {
  528. return mydate.slice(idx * sum, (idx + 1) * sum)
  529. }
  530. $scope.addshebei = function () {
  531. event.preventDefault();
  532. var modalInstance = $modal.open({
  533. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  534. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
  535. $scope.langs = i18nService.getAllLangs();
  536. $scope.lang = 'zh-cn';
  537. i18nService.setCurrentLang($scope.lang);
  538. $scope.gridOptions = {};
  539. $scope.gridOptions.data = 'myDatatwo';
  540. $scope.gridOptions.enableColumnResizing = true;
  541. $scope.gridOptions.enableFiltering = false;
  542. $scope.gridOptions.enableGridMenu = false;
  543. $scope.gridOptions.showGridFooter = true;
  544. $scope.gridOptions.showColumnFooter = false;
  545. $scope.gridOptions.fastWatch = true;
  546. $scope.gridOptions.useExternalFiltering = true;
  547. $scope.gridOptions.useExternalPagination = true;
  548. $scope.gridOptions.paginationPageSizes = [10];
  549. $scope.gridOptions.paginationPageSize = 10;
  550. $scope.gridOptions.multiSelect = true;
  551. $scope.gridOptions.rowIdentity = function (row) {
  552. return row.id;
  553. };
  554. $scope.gridOptions.getRowIdentity = function (row) {
  555. return row.id;
  556. };
  557. $scope.gridOptions.columnDefs = [{
  558. name: 'item',
  559. displayName: '序号',
  560. width: 80,
  561. enableFiltering: false
  562. },
  563. {
  564. name: 'uuid',
  565. displayName: '内部编号',
  566. width: 150
  567. },
  568. {
  569. name: 'props.hw_mingcheng',
  570. displayName: '资产名称',
  571. width: 100
  572. },
  573. {
  574. name: 'props.hw_cifilterClassic',
  575. displayName: '资产类型',
  576. width: 120,
  577. enableFiltering: false
  578. },
  579. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  580. {
  581. name: 'props.hw_state',
  582. displayName: '资产状态',
  583. width: 150,
  584. enableFiltering: false
  585. },
  586. {
  587. name: 'props.hwnw_area',
  588. displayName: '资产地点',
  589. width: 130,
  590. enableFiltering: false
  591. },
  592. {
  593. name: 'createtime',
  594. displayName: '申请时间',
  595. enableFiltering: false
  596. }
  597. ];
  598. // $scope.selectButtonClick
  599. var defaultFilterData = {
  600. // "assignee":2,
  601. // "applicationForm": { "hw_state": "在线" },
  602. "hw_state": "在线",
  603. "idx": 0,
  604. "sum": 10
  605. };
  606. $scope.memoryfilterData = {
  607. // "assignee":2,
  608. // "applicationForm": { "hw_state": "在线" },
  609. "hw_state": "在线",
  610. "idx": 0,
  611. "sum": 10
  612. }
  613. $scope.refreshData = function (style, filterData) {
  614. if (angular.isUndefined(filterData)) {
  615. filterData = defaultFilterData;
  616. }
  617. $scope.myDatatwo = [];
  618. // $scope.gridOptions['sum']=filterData.sum;
  619. api_cmdb.query(filterData).then(function (data) {
  620. // $scope.callsPending--;
  621. var myDatatwo = Restangular.stripRestangular(data);
  622. $scope.gridOptions['totalItems'] = data.total;
  623. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  624. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  625. }
  626. $scope.myDatatwo = myDatatwo.data.node;
  627. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  628. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  629. }
  630. }, function () { });
  631. };
  632. $scope.refreshData('expand-right', defaultFilterData);
  633. $scope.gridOptions.onRegisterApi = function (gridApi) {
  634. $scope.gridApi = gridApi;
  635. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  636. var filtersData = $scope.memoryfilterData;
  637. filtersData.idx = newPage - 1;
  638. filtersData.sum = pageSize;
  639. // $scope.loadData(filtersData);
  640. $scope.refreshData('expand-right', filtersData);
  641. //console.log(pageSize);
  642. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  643. });
  644. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  645. // $scope.selected.items.push(data.entity);
  646. //console.log(data);
  647. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  648. if (scope.isSelected) {
  649. scope.grid.appScope.selected.items.push(scope.entity)
  650. } else {
  651. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  652. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  653. scope.grid.appScope.selected.items.splice(i, 1);
  654. break;
  655. }
  656. }
  657. }
  658. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  659. });
  660. // });
  661. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  662. // $scope.selected.items = data.entity;
  663. //console.log(data);
  664. var selectitem = [];
  665. selectitem = angular.copy($scope.selected.items);
  666. for (var j = 0; j < rows.length; j++) {
  667. if (rows[j].isSelected == true) {
  668. selectitem.push(rows[j].entity);
  669. } else {
  670. delete selectitem[j];
  671. // rows.splice(j, 1);
  672. }
  673. }
  674. $scope.selected.items = [];
  675. for (var i = 0; i < selectitem.length; i++) {
  676. if (selectitem[i]) {
  677. $scope.selected.items.push(selectitem[i]);
  678. }
  679. }
  680. });
  681. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  682. // // if (row.entity.age > 45) {
  683. // row.grid.api.selection.selectRow(row.entity); // 选中行
  684. // // }
  685. // };
  686. gridApi.core.on.filterChanged($scope, function () {
  687. var grid = this.grid;
  688. var filtersData = {
  689. idx: 0,
  690. sum: 10,
  691. "user": {
  692. "roledata": {
  693. "rolecode": "roleset"
  694. },
  695. "selectType": "1"
  696. }
  697. };
  698. angular.forEach(grid.columns, function (item) {
  699. if (item.enableFiltering) {
  700. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  701. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  702. if (angular.isUndefined(filtersData['user'])) {
  703. filtersData['user'] = {};
  704. }
  705. filtersData['user'][item.field] = item.filters[0].term;
  706. }
  707. }
  708. });
  709. $scope.memoryfilterData = filtersData;
  710. // $scope.loadData(filtersData);
  711. });
  712. };
  713. $scope.onDblClick = function (data, event) {
  714. // $scope.selected.items = data.entity;
  715. $scope.selectButtonClick(data, event);
  716. };
  717. $scope.title = title;
  718. //树形图
  719. var apple_selected, tree, treedata_avm, treedata_geography;
  720. $scope.my_tree_handler = function (branch) {
  721. //var _ref;
  722. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  723. api_cmdb.query({
  724. 'sign': classify
  725. }).then(function (data) {
  726. var myDatalingbei = Restangular.stripRestangular(data);
  727. // console.log(myData.data.node);
  728. if (myDatalingbei.data && myDatalingbei.status == 200) {
  729. var ret = myDatalingbei.data;
  730. redrawSvg(myDatalingbei);
  731. }
  732. });
  733. };
  734. $scope.my_data = [];
  735. function convertListToTree(data, treeMap) {
  736. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  737. var root = null; //Initially set our loop to null
  738. var parentNode = null;
  739. //loop over data
  740. for (var i = 0; i < data.length; i++) {
  741. var datum = data[i];
  742. //each node will have children, so let's give it a "children" poperty
  743. datum.children = [];
  744. //add an entry for this node to the map so that any future children can
  745. //lookup the parent
  746. idToNodeMap[datum.id] = datum;
  747. //Does this node have a parent?
  748. if (typeof datum.parent === "undefined" || datum.parent == null) {
  749. //Doesn't look like it, so this node is the root of the tree
  750. root = datum;
  751. treeMap[datum.id] = root;
  752. } else {
  753. //This node has a parent, so let's look it up using the id
  754. parentNode = idToNodeMap[datum.parent.id];
  755. //We don't need this property, so let's delete it.
  756. delete datum.parent;
  757. //Let's add the current node as a child of the parent node.
  758. parentNode.children.push(datum);
  759. }
  760. }
  761. return root;
  762. }
  763. function convertParentToChildList(data) {
  764. var treeMap = {};
  765. var list = [];
  766. convertListToTree(data, treeMap);
  767. angular.forEach(treeMap, function (item) {
  768. list.push(item);
  769. });
  770. return list;
  771. }
  772. $scope.my_tree = tree = {};
  773. $scope.try_async_load = function () {
  774. $scope.my_data = [];
  775. $scope.select_treedata = [];
  776. $scope.doing_async = true;
  777. api_configure_data.fetchDataList('ciclassify', {
  778. 'idx': 0,
  779. 'sum': 100
  780. }).then(function (result) {
  781. //console.log(result['list']);
  782. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  783. $scope.doing_async = false;
  784. // tree.expand_all();
  785. //console.log(treelist);
  786. });
  787. };
  788. $scope.select_treedata = [];
  789. $scope.propTypeOptions = [];
  790. $scope.try_async_load();
  791. $scope.onFilterremove = function (item) {
  792. console.log(item)
  793. }
  794. $scope.searchdata = {};
  795. $scope.clear = function () {
  796. $scope.searchdata = {};
  797. $scope.cifilter_classic = {};
  798. $scope.try_async_load();
  799. var fildata = {
  800. idx: 0,
  801. sum: 10,
  802. 'hw_state': '在线'
  803. }
  804. $scope.memoryfilterData = fildata;
  805. $scope.refreshData('expand-right', fildata);
  806. }
  807. $scope.chiceIncident = function (item) {
  808. var fildata = $scope.memoryfilterData;
  809. // fildata.applicationForm = {};
  810. // if (item.alltitle && item.alldata) {
  811. // fildata.applicationForm[item.alltitle.key] = item.alldata
  812. // }
  813. if (item && item.id) {
  814. var classify = item.prefix.toLowerCase() + item.sign;
  815. fildata.sign = classify
  816. }
  817. $scope.gridOptions.paginationCurrentPage = 1;
  818. var transitiondata = angular.copy(item);
  819. $scope.refreshData('expand-right', fildata);
  820. }
  821. $scope.applicadata = [];
  822. $scope.onFilterCallback = function (item) {
  823. var tempclassify = item.prefix.toLowerCase() + item.sign;
  824. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  825. var myData = Restangular.stripRestangular(data);
  826. $scope.applicadata = myData[0].form.fields;
  827. });
  828. // }
  829. }
  830. // $scope.loadData({
  831. // idx: 0,
  832. // sum: 10,
  833. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  834. // });
  835. $scope.selected = {
  836. items: []
  837. };
  838. $scope.ok = function () {
  839. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  840. // onDataCallback($scope.selected.item, parentScope);
  841. // }
  842. $modalInstance.close($scope.selected.items);
  843. };
  844. $scope.cancel = function () {
  845. $modalInstance.dismiss('cancel');
  846. };
  847. },
  848. size: 'lg',
  849. resolve: {
  850. items: function () {
  851. return {
  852. fetchItems: function (filterData, APIService) {
  853. filterData = filterData || {};
  854. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  855. filterData = {
  856. idx: 0,
  857. sum: 10,
  858. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  859. };
  860. }
  861. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  862. }
  863. };
  864. },
  865. title: function () {
  866. return $scope.options.templateOptions.label;
  867. },
  868. Restangular: function () {
  869. return $scope.options.templateOptions.Restangular;
  870. },
  871. APIService: function () {
  872. return $scope.options.templateOptions.ApiService;
  873. },
  874. onDataCallback: function () {
  875. return $scope.options.templateOptions.callback;
  876. },
  877. parentScope: function () {
  878. return $scope.options.templateOptions.that;
  879. }
  880. }
  881. });
  882. modalInstance.result.then(function (selectedItem) {
  883. $scope.myDatagridoldall = selectedItem;
  884. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  885. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  886. }
  887. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  888. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  889. // $scope.model.oldAssets = $scope.myDatagridoldall;
  890. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  891. $scope.options.initialValue = $scope.model.oldAssets;
  892. });
  893. // }
  894. }
  895. $scope.changestate = function (itemin) {
  896. event.preventDefault();
  897. var modalInstance = $modal.open({
  898. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
  899. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  900. $scope.title = '旧设备状态修改';
  901. $scope.stateshe = [{
  902. "id": 2,
  903. "name": "在库"
  904. }, {
  905. "id": 4,
  906. "name": "报修"
  907. }, {
  908. "id": 3,
  909. "name": "报废"
  910. }];
  911. $scope.hw_state = {};
  912. $scope.ok = function (item) {
  913. $modalInstance.close(item.id);
  914. };
  915. $scope.cancel = function () {
  916. $modalInstance.dismiss('cancel');
  917. };
  918. },
  919. size: 'sm',
  920. resolve: {
  921. scope: function () {
  922. return $scope;
  923. }
  924. }
  925. });
  926. modalInstance.result.then(function (selectedItem) {
  927. if (selectedItem) {
  928. angular.forEach($scope.myDatagridallold, function (item, index) {
  929. if (item.id == itemin.id) {
  930. $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
  931. }
  932. })
  933. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  934. $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  935. }
  936. $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
  937. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
  938. // $scope.model.oldAssets = $scope.myDatagridallold;
  939. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
  940. $scope.options.initialValue = $scope.model.oldAssets;
  941. }
  942. })
  943. }
  944. $scope.savedata = function (data) {
  945. event.preventDefault();
  946. var modalInstance = $modal.open({
  947. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
  948. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  949. $scope.title = '设备编辑';
  950. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  951. $scope.ok = function (item) {
  952. $modalInstance.close(item);
  953. };
  954. $scope.cancel = function () {
  955. $modalInstance.dismiss('cancel');
  956. };
  957. },
  958. size: 'sm',
  959. resolve: {
  960. scope: function () {
  961. return $scope;
  962. }
  963. }
  964. });
  965. modalInstance.result.then(function (selectedItem) {
  966. if (selectedItem) {
  967. angular.forEach($scope.myDatagridoldall, function (item, index) {
  968. if (item.id == data.id) {
  969. $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
  970. }
  971. })
  972. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  973. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  974. }
  975. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  976. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  977. // $scope.model.oldAssets = $scope.myDatagridoldall;
  978. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  979. $scope.options.initialValue = $scope.model.oldAssets;
  980. }
  981. })
  982. }
  983. $scope.removeold = function (data) {
  984. event.preventDefault();
  985. var modalInstance = $modal.open({
  986. templateUrl: 'assets/views/delete.html',
  987. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  988. $scope.title = '设备删除';
  989. $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  990. $scope.ok = function () {
  991. $modalInstance.close(data);
  992. };
  993. $scope.cancel = function () {
  994. $modalInstance.dismiss('cancel');
  995. };
  996. },
  997. size: 'sm',
  998. resolve: {
  999. scope: function () {
  1000. return $scope;
  1001. }
  1002. }
  1003. });
  1004. modalInstance.result.then(function (selectedItem) {
  1005. if (selectedItem) {
  1006. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1007. if (item.id == selectedItem.id) {
  1008. $scope.myDatagridoldall.splice(index, 1);
  1009. }
  1010. })
  1011. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1012. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  1013. }
  1014. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  1015. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  1016. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1017. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  1018. $scope.options.initialValue = $scope.model.oldAssets;
  1019. }
  1020. })
  1021. }
  1022. }]
  1023. });
  1024. //ui-grid list
  1025. formlyConfigProvider.setType({
  1026. name: "ui-gridlist",
  1027. extends: 'input',
  1028. templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
  1029. defaultOptions: function (options, $scope) {
  1030. return {
  1031. templateOptions: {}
  1032. };
  1033. },
  1034. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  1035. //gridone
  1036. $scope.langs = i18nService.getAllLangs();
  1037. $scope.lang = 'zh-cn';
  1038. i18nService.setCurrentLang($scope.lang);
  1039. $scope.gridOptions = {};
  1040. $scope.gridOptions.data = 'myDatagrid';
  1041. $scope.gridOptions.enableColumnResizing = true;
  1042. $scope.gridOptions.enableFiltering = true;
  1043. $scope.gridOptions.enableGridMenu = false;
  1044. $scope.gridOptions.enableRowSelection = true;
  1045. $scope.gridOptions.showGridFooter = true;
  1046. $scope.gridOptions.showColumnFooter = false;
  1047. $scope.gridOptions.fastWatch = true;
  1048. $scope.gridOptions.useExternalFiltering = false;
  1049. // $scope.gridOptions.useExternalPagination = true;
  1050. $scope.gridOptions.paginationPageSizes = [10];
  1051. $scope.gridOptions.paginationPageSize = 10;
  1052. $scope.gridOptions.multiSelect = false;
  1053. $scope.myDatagrid = [];
  1054. $scope.myDatagridall = [];
  1055. $scope.selected = {
  1056. item: {}
  1057. };
  1058. $scope.memoryfilterDatagrid = {
  1059. idx: 0,
  1060. sum: 10
  1061. }
  1062. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1063. filterData = {
  1064. idx: 0,
  1065. sum: 10
  1066. };
  1067. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  1068. }
  1069. $scope.gridOptions.rowIdentity = function (row) {
  1070. return row.id;
  1071. };
  1072. $scope.gridOptions.getRowIdentity = function (row) {
  1073. return row.id;
  1074. };
  1075. // $scope.gridOptions.columnDefs = items.columnDefs();
  1076. $scope.interceptMydata = function (mydate, idx, sum) {
  1077. return mydate.slice(idx * sum, (idx + 1) * sum)
  1078. }
  1079. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1080. $scope.gridApi = gridApi;
  1081. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1082. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1083. $scope.memoryfilterDatagrid.sum = pageSize;
  1084. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  1085. $scope.loadData({
  1086. "idx": newPage - 1,
  1087. "sum": pageSize
  1088. });
  1089. });
  1090. gridApi.core.on.filterChanged($scope, function () { });
  1091. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1092. $scope.selected.item = data.entity;
  1093. //console.log(data);
  1094. });
  1095. };
  1096. $scope.loadData = function (mydate, idx, sum) {
  1097. angular.forEach($scope.myDatagrid, function (item, index) {
  1098. $scope.myDatagrid[index].item = index;
  1099. })
  1100. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  1101. }
  1102. if ($scope.model.assets) {
  1103. $scope.myDatagridall = $scope.model.assets;
  1104. $scope.loadData($scope.model.assets, 0, 10)
  1105. }
  1106. $scope.saveData = function (itemin) {
  1107. event.preventDefault();
  1108. var modalInstance = $modal.open({
  1109. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  1110. controller: function ($scope, $modalInstance, SweetAlert) {
  1111. // $scope.consumptive = {};
  1112. $scope.title = "填写领用设备信息";
  1113. // if (items.name) {
  1114. // $scope.consumptive.name = items.name.name;
  1115. // }
  1116. $scope.placechange = angular.copy(itemin);
  1117. $scope.ok = function (item) {
  1118. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  1119. $modalInstance.close(item);
  1120. } else {
  1121. SweetAlert.swal({
  1122. title: "数据填写不完整!",
  1123. text: "请检查数据然后提交!",
  1124. type: "error"
  1125. });
  1126. }
  1127. };
  1128. $scope.cancel = function () {
  1129. $modalInstance.dismiss('cancel');
  1130. };
  1131. },
  1132. resolve: {
  1133. SweetAlert: function () {
  1134. return SweetAlert;
  1135. }
  1136. }
  1137. });
  1138. modalInstance.result.then(function (selectedItem) {
  1139. angular.forEach($scope.myDatagrid, function (item, index) {
  1140. if (item.id == selectedItem.id) {
  1141. angular.extend($scope.myDatagrid[index], selectedItem)
  1142. }
  1143. })
  1144. // $scope.myData3.push(selectedItem);
  1145. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1146. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  1147. }
  1148. // $scope.model.assets = $scope.myDatagridall;
  1149. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  1150. })
  1151. }
  1152. }]
  1153. });
  1154. //设备耗材list组件
  1155. formlyConfigProvider.setType({
  1156. name: 'ui-shehaolist',
  1157. // extends: 'radio',
  1158. templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
  1159. defaultOptions: function (options) {
  1160. return {
  1161. templateOptions: {
  1162. refresh: function () { },
  1163. refreshDelay: 0
  1164. }
  1165. };
  1166. },
  1167. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1168. // var data = { "haodata": [], "shedata": [] };
  1169. var haodata = [];
  1170. var shedata = [];
  1171. if ($scope.model.consumables) {
  1172. if (angular.isArray($scope.model.consumables)) {
  1173. haodata = $scope.model.consumables;
  1174. } else {
  1175. haodata = JSON.parse($scope.model.consumables);
  1176. }
  1177. $scope.model.consumables = haodata;
  1178. angular.forEach(haodata, function (item, index) {
  1179. haodata[index].item = index + 1;
  1180. })
  1181. }
  1182. if ($scope.model.assets) {
  1183. if (angular.isArray($scope.model.assets)) {
  1184. shedata = $scope.model.assets;
  1185. } else {
  1186. shedata = JSON.parse($scope.model.assets);
  1187. }
  1188. $scope.model.assets = shedata;
  1189. angular.forEach(shedata, function (item, index) {
  1190. shedata[index].item = index + 1;
  1191. })
  1192. }
  1193. $scope.tableParamshao = new ngTableParams({
  1194. page: 1,
  1195. count: 5
  1196. }, {
  1197. total: haodata.length,
  1198. getData: function ($defer, params) {
  1199. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  1200. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1201. }
  1202. });
  1203. $scope.tableParamsshe = new ngTableParams({
  1204. page: 1,
  1205. count: 5
  1206. }, {
  1207. total: shedata.length,
  1208. getData: function ($defer, params) {
  1209. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  1210. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1211. }
  1212. });
  1213. $scope.editId = -1;
  1214. $scope.setEditId = function (pid) {
  1215. $scope.editId = pid;
  1216. };
  1217. if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
  1218. $scope.isAgree = "同意";
  1219. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
  1220. $scope.isAgree = "同意";
  1221. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
  1222. $scope.isAgree = "返回修改";
  1223. }
  1224. }]
  1225. });
  1226. //关联资产出库
  1227. formlyConfigProvider.setType({
  1228. name: "ui-meansmodelselect",
  1229. extends: 'input',
  1230. templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
  1231. defaultOptions: function (options) {
  1232. return {
  1233. templateOptions: {}
  1234. };
  1235. },
  1236. controller: ['$scope', '$modal', function ($scope, $modal) {
  1237. $scope.openModal = function (size, options, modal) {
  1238. var modalInstance = $modal.open({
  1239. templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
  1240. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService, api_wechatfile) {
  1241. $scope.langs = i18nService.getAllLangs();
  1242. $scope.lang = 'zh-cn';
  1243. i18nService.setCurrentLang($scope.lang);
  1244. $scope.gridOptions = {};
  1245. $scope.gridOptions.data = 'myData';
  1246. $scope.gridOptions.enableColumnResizing = true;
  1247. $scope.gridOptions.enableFiltering = false;
  1248. $scope.gridOptions.enableGridMenu = false;
  1249. $scope.gridOptions.showGridFooter = true;
  1250. $scope.gridOptions.showColumnFooter = false;
  1251. $scope.gridOptions.fastWatch = true;
  1252. $scope.gridOptions.useExternalFiltering = true;
  1253. $scope.gridOptions.useExternalPagination = true;
  1254. $scope.gridOptions.paginationPageSizes = [10];
  1255. $scope.gridOptions.paginationPageSize = 10;
  1256. $scope.gridOptions.multiSelect = false;
  1257. $scope.gridOptions.rowIdentity = function (row) {
  1258. return row.id;
  1259. };
  1260. $scope.gridOptions.getRowIdentity = function (row) {
  1261. return row.id;
  1262. };
  1263. // $scope.states = [{
  1264. // id: 0,
  1265. // name: '待批准'
  1266. // },
  1267. // {
  1268. // id: 1,
  1269. // name: '已驳回'
  1270. // },
  1271. // {
  1272. // id: 2,
  1273. // name: '待出库'
  1274. // },
  1275. // {
  1276. // id: 3,
  1277. // name: '信息更新'
  1278. // },
  1279. // {
  1280. // id: 4,
  1281. // name: '信息确认'
  1282. // },
  1283. // {
  1284. // id: 5,
  1285. // name: '已关闭'
  1286. // }
  1287. // ];
  1288. $scope.getStatesDictionary = function () {
  1289. var data = {
  1290. "key": "applicationForm_status",
  1291. "type": "list"
  1292. }
  1293. api_wechatfile.getDictionary(data).then(function (res) {
  1294. $scope.states = res
  1295. })
  1296. };
  1297. $scope.getStatesDictionary();
  1298. $scope.type = [{
  1299. id: 1,
  1300. name: '资产入库'
  1301. },
  1302. {
  1303. id: 2,
  1304. name: '资产归还'
  1305. },
  1306. {
  1307. id: 3,
  1308. name: '资产领用'
  1309. },
  1310. {
  1311. id: 4,
  1312. name: '资产更换'
  1313. }
  1314. ];
  1315. $scope.typedata = function (row) {
  1316. if (row.type == 0) {
  1317. return "资产入库";
  1318. } else if (row.type == 2) {
  1319. return "资产归还";
  1320. } else if (row.type == 1) {
  1321. return "资产领用";
  1322. } else if (row.type == 4) {
  1323. return "资产更换";
  1324. }
  1325. };
  1326. $scope.statedata = function (row) {
  1327. if (row.status == 0) {
  1328. return "待批准";
  1329. } else if (row.status == 1) {
  1330. return "已驳回";
  1331. } else if (row.status == 2) {
  1332. return "待出库";
  1333. } else if (row.status == 3) {
  1334. return "信息更新";
  1335. } else if (row.status == 4) {
  1336. return "信息确认";
  1337. } else if (row.status == 5) {
  1338. return "已关闭";
  1339. }
  1340. };
  1341. $scope.transferTime = function (time) {
  1342. return moment(time).format('YYYY-MM-DD HH:mm');
  1343. }
  1344. $scope.application = [{
  1345. value: "serialNumbe",
  1346. name: '申请单编号'
  1347. },
  1348. // { value: "proposer", name: '申请人' },
  1349. {
  1350. value: "purpose",
  1351. name: '领用用途'
  1352. },
  1353. // { value: "cmdbsign", name: '设备编号' }
  1354. ];
  1355. $scope.parameters = null;
  1356. $scope.open = function ($event) {
  1357. $event.preventDefault();
  1358. $event.stopPropagation();
  1359. $scope.opened = !$scope.opened;
  1360. };
  1361. $scope.endOpen = function ($event) {
  1362. $event.preventDefault();
  1363. $event.stopPropagation();
  1364. $scope.startOpened = false;
  1365. $scope.endOpened = !$scope.endOpened;
  1366. };
  1367. $scope.startOpen = function ($event) {
  1368. $event.preventDefault();
  1369. $event.stopPropagation();
  1370. $scope.endOpened = false;
  1371. $scope.startOpened = !$scope.startOpened;
  1372. };
  1373. $scope.othcode = {};
  1374. $scope.searchkeys = {};
  1375. $scope.parameters = {};
  1376. $scope.memoryfilterData = {
  1377. "assignee": $rootScope.user.id,
  1378. "candidateGroups": $rootScope.user.group[0].id,
  1379. "searchType": "todo",
  1380. idx: 0,
  1381. sum: 10
  1382. }
  1383. $scope.clear = function () {
  1384. $scope.searchkeys = {};
  1385. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1386. // $scope.othcode = {};
  1387. $scope.parameters = {};
  1388. var fildata = {
  1389. "assignee": $rootScope.user.id,
  1390. "candidateGroups": $rootScope.user.group[0].id,
  1391. "searchType": "todo",
  1392. idx: 0,
  1393. sum: 10
  1394. }
  1395. // sessionStorage.removeItem("searchincident");
  1396. $scope.memoryfilterData = fildata;
  1397. $scope.loadData(fildata);
  1398. }
  1399. $scope.chiceIncident = function (parameters, item, stateid) {
  1400. var fildata = {
  1401. "assignee": $rootScope.user.id,
  1402. "candidateGroups": 1,
  1403. "searchType": "todo",
  1404. "idx": 0,
  1405. "sum": 10
  1406. };
  1407. if (item) {
  1408. fildata.applicationForm = {};
  1409. if (item.alltitle && item.alldata) {
  1410. fildata.applicationForm[item.alltitle.value] = item.alldata
  1411. }
  1412. if (item.linkProposer) {
  1413. fildata.applicationForm.linkProposer = item.linkProposer
  1414. }
  1415. if (item.proposer) {
  1416. fildata.applicationForm.proposer = item.proposer
  1417. }
  1418. if (item.status) {
  1419. fildata.applicationForm['status'] = {
  1420. id: item.status.id
  1421. };
  1422. }
  1423. if (item.type) {
  1424. fildata.applicationForm['type'] = {
  1425. id: item.type.id
  1426. };
  1427. }
  1428. }
  1429. $scope.gridOptions.paginationCurrentPage = 1;
  1430. if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
  1431. angular.extend(fildata, {
  1432. 'idx': 0,
  1433. 'sum': $scope.gridOptions.paginationPageSize
  1434. })
  1435. angular.extend(fildata.applicationForm, {
  1436. 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'),
  1437. 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59')
  1438. })
  1439. }
  1440. var transitiondata = angular.copy(item);
  1441. // angular.extend(fildata.applicationForm, transitiondata)
  1442. $scope.loadData(fildata);
  1443. }
  1444. $scope.key = {};
  1445. api_user_data.fetchDataList('user', {
  1446. "idx": 0,
  1447. "sum": 1000,
  1448. "flag": -1
  1449. }).then(function (data) {
  1450. $scope.handlingPersonnelUser = data.list;
  1451. });
  1452. $scope.gridOptions.columnDefs = items.columnDefs();
  1453. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1454. $scope.gridApi = gridApi;
  1455. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1456. // console.log(newPage);
  1457. // console.log(pageSize);
  1458. $scope.loadData({
  1459. "idx": newPage - 1,
  1460. "sum": pageSize
  1461. });
  1462. });
  1463. gridApi.core.on.filterChanged($scope, function () {
  1464. });
  1465. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1466. $scope.selected.item = data.entity;
  1467. //console.log(data);
  1468. });
  1469. };
  1470. $scope.loadData = function (filterData) {
  1471. items.fetchItems(filterData, APIService).then(function (data) {
  1472. var myData = Restangular.stripRestangular(data);
  1473. $scope.gridOptions.totalItems = myData.totalNum;
  1474. $scope.myData = myData.list;
  1475. for (var i = 0; i < $scope.myData.length; i++) {
  1476. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  1477. }
  1478. });
  1479. };
  1480. $scope.title = title;
  1481. $scope.loadData({
  1482. idx: 0,
  1483. sum: 10,
  1484. "assignee": $rootScope.user.id,
  1485. "candidateGroups": $rootScope.user.group[0].id,
  1486. "searchType": "todo",
  1487. });
  1488. $scope.selected = {
  1489. item: {}
  1490. };
  1491. $scope.ok = function () {
  1492. //console.log($scope.selected.item);
  1493. $modalInstance.close($scope.selected.item);
  1494. };
  1495. $scope.cancel = function () {
  1496. $modalInstance.dismiss('cancel');
  1497. };
  1498. },
  1499. size: 'lg',
  1500. resolve: {
  1501. items: function () {
  1502. return {
  1503. fetchItems: function (filterData, APIService) {
  1504. filterData = filterData || {};
  1505. // if(!filterData.idx){
  1506. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  1507. filterData = {
  1508. idx: 0,
  1509. sum: 10
  1510. };
  1511. }
  1512. return options.templateOptions.fetchItems(filterData, APIService, options);
  1513. },
  1514. columnDefs: function () {
  1515. return options.templateOptions.columnDefs;
  1516. }
  1517. };
  1518. },
  1519. title: function () {
  1520. return options.templateOptions.modalTitle;
  1521. },
  1522. Restangular: function () {
  1523. return options.templateOptions.Restangular;
  1524. },
  1525. APIService: function () {
  1526. return options.templateOptions.ApiService;
  1527. }
  1528. }
  1529. });
  1530. modalInstance.result.then(function (selectedItem) {
  1531. var selectitem = {
  1532. title: selectedItem.title,
  1533. description: selectedItem.description
  1534. }
  1535. if (options.key == "chuku") {
  1536. if (selectedItem.assets) {
  1537. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  1538. }
  1539. if (selectedItem.consumables) {
  1540. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  1541. }
  1542. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  1543. options.value(selectedItem);
  1544. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1545. } else {
  1546. angular.extend(options.model, selectitem);
  1547. options.value(selectedItem);
  1548. }
  1549. }, function () {
  1550. //console.log('Modal dismissed at: ' + new Date());
  1551. });
  1552. }
  1553. }]
  1554. });
  1555. //文本框
  1556. formlyConfigProvider.setType({
  1557. name: 'ui-textcmdb',
  1558. extends: '',
  1559. templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
  1560. defaultOptions: function (options) {
  1561. return {
  1562. templateOptions: {
  1563. transform: function (model, value) {
  1564. return value;
  1565. },
  1566. },
  1567. validation: {
  1568. messages: {
  1569. maxlength: function (viewValue, modelValue, scope) {
  1570. if (viewValue != null) {
  1571. if (viewValue.length > scope.to.maxlength) {
  1572. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1573. } else {
  1574. return "";
  1575. }
  1576. }
  1577. },
  1578. }
  1579. }
  1580. }
  1581. },
  1582. controller: ['$scope', function ($scope) {
  1583. var value = $scope.model[$scope.options.key];
  1584. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1585. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1586. }
  1587. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1588. $scope.options.templateOptions.felditem($scope);
  1589. }
  1590. }]
  1591. });
  1592. //设备组件
  1593. formlyConfigProvider.setType({
  1594. name: 'ui-applist',
  1595. extends: 'radio',
  1596. templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
  1597. defaultOptions: function (options) {
  1598. return {
  1599. templateOptions: {
  1600. refresh: function () { },
  1601. refreshDelay: 0
  1602. }
  1603. };
  1604. },
  1605. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1606. var data = [];
  1607. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1608. // data = JSON.parse($scope.model.consumables);
  1609. if (angular.isArray($scope.model.consumables)) {
  1610. data = $scope.model.consumables;
  1611. } else {
  1612. data = JSON.parse($scope.model.consumables);
  1613. }
  1614. $scope.model.consumables = data;
  1615. angular.forEach(data, function (item, index) {
  1616. data[index].item = index + 1;
  1617. })
  1618. }
  1619. if ($scope.model.assets && $scope.options.key == "assets") {
  1620. if (angular.isArray($scope.model.assets)) {
  1621. data = $scope.model.assets;
  1622. } else {
  1623. data = JSON.parse($scope.model.assets);
  1624. }
  1625. // data = JSON.parse($scope.model.assets);
  1626. $scope.model.assets = data;
  1627. angular.forEach(data, function (item, index) {
  1628. data[index].item = index + 1;
  1629. })
  1630. }
  1631. $scope.tableParams = new ngTableParams({
  1632. page: 1,
  1633. count: 5
  1634. }, {
  1635. total: data.length,
  1636. getData: function ($defer, params) {
  1637. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1638. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1639. }
  1640. });
  1641. $scope.editId = -1;
  1642. $scope.setEditId = function (pid) {
  1643. $scope.editId = pid;
  1644. };
  1645. }]
  1646. });
  1647. //list组件
  1648. formlyConfigProvider.setType({
  1649. name: 'ui-gudinglist',
  1650. extends: 'radio',
  1651. templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
  1652. defaultOptions: function (options) {
  1653. return {
  1654. templateOptions: {
  1655. refresh: function () { },
  1656. refreshDelay: 0
  1657. }
  1658. };
  1659. },
  1660. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1661. var data = [];
  1662. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1663. // data = JSON.parse($scope.model.consumables);
  1664. if (angular.isArray($scope.model.consumables)) {
  1665. data = $scope.model.consumables;
  1666. } else {
  1667. data = JSON.parse($scope.model.consumables);
  1668. }
  1669. $scope.model.consumables = data;
  1670. angular.forEach(data, function (item, index) {
  1671. data[index].item = index + 1;
  1672. })
  1673. }
  1674. if ($scope.model.assets && $scope.options.key == "assets") {
  1675. if (angular.isArray($scope.model.assets)) {
  1676. data = $scope.model.assets;
  1677. } else {
  1678. data = JSON.parse($scope.model.assets);
  1679. }
  1680. // data = JSON.parse($scope.model.assets);
  1681. $scope.model.assets = data;
  1682. angular.forEach(data, function (item, index) {
  1683. data[index].item = index + 1;
  1684. })
  1685. }
  1686. $scope.tableParams = new ngTableParams({
  1687. page: 1,
  1688. count: 5
  1689. }, {
  1690. total: data.length,
  1691. getData: function ($defer, params) {
  1692. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1693. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1694. }
  1695. });
  1696. $scope.editId = -1;
  1697. $scope.setEditId = function (pid) {
  1698. $scope.editId = pid;
  1699. };
  1700. }]
  1701. });
  1702. //other list tab组件
  1703. formlyConfigProvider.setType({
  1704. name: 'ui-otherlisttab',
  1705. extends: '',
  1706. templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
  1707. defaultOptions: function (options) {
  1708. return {
  1709. templateOptions: {
  1710. refresh: function () { },
  1711. refreshDelay: 0
  1712. }
  1713. };
  1714. },
  1715. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1716. }]
  1717. });
  1718. //审核查看组件
  1719. formlyConfigProvider.setType({
  1720. name: 'ui-aprovelist',
  1721. extends: '',
  1722. templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
  1723. defaultOptions: function (options) {
  1724. return {
  1725. templateOptions: {
  1726. refresh: function () { },
  1727. refreshDelay: 0
  1728. }
  1729. };
  1730. },
  1731. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1732. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  1733. $scope.isAgree = "同意";
  1734. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  1735. $scope.isAgree = "同意";
  1736. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  1737. $scope.isAgree = "返回修改";
  1738. }
  1739. }]
  1740. });
  1741. //other list组件
  1742. formlyConfigProvider.setType({
  1743. name: 'ui-otherlist',
  1744. extends: '',
  1745. templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
  1746. defaultOptions: function (options) {
  1747. return {
  1748. templateOptions: {
  1749. refresh: function () { },
  1750. refreshDelay: 0
  1751. }
  1752. };
  1753. },
  1754. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  1755. console.log("哈哈");
  1756. console.log($scope);
  1757. $scope.langs = i18nService.getAllLangs();
  1758. $scope.lang = 'zh-cn';
  1759. i18nService.setCurrentLang($scope.lang);
  1760. var vm = this;
  1761. vm.options = {};
  1762. vm.exampleTitle = ['expressionProperties', 'model property'];
  1763. vm.fields = [];
  1764. vm.models = {};
  1765. // vm.models["loginUser"] = $rootScope.user;
  1766. var that = $injector;
  1767. var parse = $parse;
  1768. var formKey = "";
  1769. var pdKey = "";
  1770. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1771. pdKey = $state.current.pdKey;
  1772. //console.log("pdKey::"+$state.current.pdKey);
  1773. }
  1774. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1775. formKey = $stateParams.formKey;
  1776. //console.log("formKey::"+$stateParams.formKey);
  1777. }
  1778. //用户测试数据,后续从header的auth中获取
  1779. var userId = 2;
  1780. userId = $rootScope.user.id;
  1781. //==============处理表单设计数据 开始====================
  1782. //处理组件加载后台数据选项的方法
  1783. function refreshSelectOptions(searchVal, field) {
  1784. if (field.templateOptions.optionsUrl) {
  1785. var process = BpmRestangular.all("");
  1786. if (field.templateOptions.ApiService) {
  1787. process = UserRestangular.all("");
  1788. }
  1789. process.customPOST({
  1790. "idx": 0,
  1791. "sum": 1000
  1792. }, field.templateOptions.optionsUrl).then(function (result) {
  1793. if (!field.templateOptions.options) {
  1794. field.templateOptions.options = [];
  1795. }
  1796. if (field.templateOptions.optionsDataKey) {
  1797. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  1798. } else {
  1799. field.templateOptions.options = result;
  1800. }
  1801. });
  1802. }
  1803. }
  1804. function decodeVMTabForm(model, tabs) {
  1805. var result = {
  1806. model: {},
  1807. tabs: []
  1808. };
  1809. var mdata = angular.fromJson(model);
  1810. angular.extend(result.model, mdata);
  1811. angular.forEach(tabs, function (tab) {
  1812. tab.form.model = vm.models;
  1813. angular.forEach(tab.form.fields, function (field) {
  1814. if (field.key == "") {
  1815. delete field.key;
  1816. }
  1817. field.type = "ui-otherlisttab";
  1818. if (angular.isDefined(field.extjson) && field.extjson != "") {
  1819. var extObj = angular.fromJson(field.extjson);
  1820. angular.extend(field.templateOptions, extObj.templateOptions);
  1821. delete extObj.templateOptions;
  1822. for (var prop in extObj) {
  1823. if (new RegExp("Expression").test(prop)) {
  1824. //var obj = $scope.$eval(extObj[prop]);
  1825. //extObj[prop] = $scope.$eval(extObj[prop]);
  1826. if (extObj[prop] != null) {
  1827. if (new RegExp("function").test(extObj[prop])) {
  1828. var propValue = eval(extObj[prop]);
  1829. extObj[prop] = propValue;
  1830. } else {
  1831. //console.log(extObj[prop]);
  1832. var obj = $scope.$eval(extObj[prop]);
  1833. extObj[prop] = obj;
  1834. //console.log(obj);
  1835. }
  1836. }
  1837. } else if (new RegExp("expressionProperties").test(prop)) {
  1838. for (var p in extObj[prop]) {
  1839. if (new RegExp("function").test(extObj[prop][p])) {
  1840. var propValue = eval(extObj[prop][p]);
  1841. extObj[prop][p] = propValue;
  1842. } else {
  1843. //if(p.indexOf("'")>=0){
  1844. // var obj = $scope.$eval(extObj[prop][p]);
  1845. // extObj[prop][$scope.$eval(p)]=obj;
  1846. //}
  1847. }
  1848. }
  1849. } else if ("watcher" == prop) {
  1850. if (angular.isArray(extObj[prop])) {
  1851. angular.forEach(extObj[prop], function (item, index) {
  1852. for (var p in item) {
  1853. if (new RegExp("function").test(item[p])) {
  1854. var propValue = eval(item[p]);
  1855. extObj[prop][index][p] = propValue;
  1856. }
  1857. }
  1858. });
  1859. } else if (angular.isObject(extObj[prop])) {
  1860. for (var p in extObj[prop]) {
  1861. if (new RegExp("function").test(extObj[prop][p])) {
  1862. var propValue = eval(extObj[prop][p]);
  1863. extObj[prop][p] = propValue;
  1864. }
  1865. }
  1866. }
  1867. }
  1868. }
  1869. angular.extend(field, extObj);
  1870. delete field.extjson;
  1871. }
  1872. if (field.extjson == "") {
  1873. delete field.extjson;
  1874. }
  1875. if (angular.isDefined(field.templateOptions)) {
  1876. var templateOs = field.templateOptions;
  1877. for (var property in templateOs) {
  1878. //console.log(property);
  1879. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  1880. if (new RegExp("function").test(templateOs[property])) {
  1881. var propValue = eval(templateOs[property]);
  1882. field.templateOptions[property] = propValue;
  1883. } else {
  1884. if (that.has(templateOs[property])) {
  1885. field.templateOptions[property] = that.get(templateOs[property]);
  1886. } else {
  1887. field.templateOptions[property] = templateOs[property];
  1888. }
  1889. }
  1890. } else if (templateOs[property] == null) {
  1891. //delete field.templateOptions[property];
  1892. } else { }
  1893. }
  1894. }
  1895. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  1896. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  1897. angular.extend(field.templateOptions, extObj);
  1898. delete field.templateOptions.extjson;
  1899. }
  1900. //...
  1901. if (field.templateOptions) {
  1902. //处理远程获取数据控件方法调用
  1903. if (field.templateOptions.optionsUrl) {
  1904. field.templateOptions.refresh = refreshSelectOptions;
  1905. }
  1906. //处理嵌套属性数据绑定/
  1907. if (field.templateOptions.pkey) {
  1908. var pmodel, i = 0;
  1909. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  1910. if (i == 0) {
  1911. if (result.model[p] == null) {
  1912. result.model[p] = {};
  1913. }
  1914. pmodel = result.model[p];
  1915. i++;
  1916. } else {
  1917. if (pmodel[p] == null) {
  1918. pmodel[p] = {};
  1919. }
  1920. pmodel = pmodel[p];
  1921. }
  1922. });
  1923. if (pmodel != null) {
  1924. field.model = pmodel;
  1925. if (pmodel[field.key] == null) {
  1926. pmodel[field.key] = null;
  1927. }
  1928. }
  1929. } else {
  1930. if (result.model[field.key] == null) {
  1931. result.model[field.key] = null;
  1932. }
  1933. }
  1934. //处理弹出框组件初始化
  1935. if (field.type == "ui-input-selectmodal") {
  1936. field.templateOptions.modal = $modal;
  1937. //field.templateOptions.Restangular = Restangular;
  1938. } else if (field.type == "ui-userselect") {
  1939. field.templateOptions.modal = $modal;
  1940. //field.templateOptions.Restangular = Restangular;
  1941. } else if (field.type == "ui-multiuserselect") {
  1942. field.templateOptions.modal = $modal;
  1943. } else if (field.type == "ui-modelselect") {
  1944. field.templateOptions.modal = $modal;
  1945. //field.templateOptions.Restangular = Restangular;
  1946. } else if (field.type == "ui-cmdbuplode") {
  1947. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  1948. url: '/uploader',
  1949. queueLimit: 1, //文件个数
  1950. autoUpload: true
  1951. });
  1952. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  1953. } else if (field.type == "ui-dropfile") {
  1954. field.templateOptions.fileUploader = new FileUploader({
  1955. url: '/uploader'
  1956. });
  1957. field.templateOptions.taskId = $stateParams.taskId;
  1958. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1959. field.templateOptions.userId = $rootScope.user.id;
  1960. //field.ApiService=api_bpm_domain;
  1961. } else if (field.type == "ui-dropfiletable") {
  1962. if (field.templateOptions.processInstanceId) {
  1963. } else {
  1964. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1965. }
  1966. } else if (field.type == "ui-repeatSection") {
  1967. var repeatForm = {
  1968. model: {
  1969. },
  1970. fields: field.templateOptions.fields
  1971. };
  1972. repeatForm.model[field.key] = [];
  1973. decodeVMTabForm(repeatForm);
  1974. }
  1975. }
  1976. // console.log(field);
  1977. //field
  1978. //result.fields.push(field);
  1979. })
  1980. });
  1981. vm.originalTabs = angular.copy(vm.form);
  1982. }
  1983. //======================处理表单设计数据 结束========================
  1984. $scope.ldloading = {};
  1985. function filter(obj) {
  1986. angular.forEach(obj, function (key, value) {
  1987. if (value === "" || value === null) {
  1988. delete obj[key];
  1989. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1990. filter(value);
  1991. } else if (angular.isArray(value)) {
  1992. angular.forEach(value, function (item) {
  1993. filter(item);
  1994. });
  1995. }
  1996. });
  1997. }
  1998. function invokeOnAllFormOptions(fn) {
  1999. angular.forEach(vm.tabs, function (tab) {
  2000. if (tab.form.options && tab.form.options[fn]) {
  2001. tab.form.options[fn]();
  2002. }
  2003. });
  2004. }
  2005. function encodeCIData(data, ciId) {
  2006. /*
  2007. create/update state:未审核
  2008. create createtime:系统时间
  2009. create/update lastupdatetime : 系统时间
  2010. label:ci分类
  2011. */
  2012. if (ciId) {
  2013. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2014. var extraprop = 'props';
  2015. data[extraprop] = {};
  2016. for (var key in data) {
  2017. console.log(data[key]);
  2018. if (_.indexOf(baseprop, key) >= 0) {
  2019. continue;
  2020. } else {
  2021. data[extraprop][key] = data[key];
  2022. delete data[key];
  2023. }
  2024. }
  2025. if ($rootScope.user) {
  2026. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2027. data[extraprop]['configperson'] = $rootScope.user.name;
  2028. var isCMAdminFlag = false;
  2029. angular.forEach($rootScope.user.role, function (roleItem) {
  2030. if (roleItem.rolecode == "cmdb charge") {
  2031. isCMAdminFlag = true;
  2032. }
  2033. })
  2034. if (!isCMAdminFlag) {
  2035. data[extraprop]['state'] = '1';
  2036. }
  2037. }
  2038. if (data.props.id) {
  2039. } else {
  2040. data.label = ciId;
  2041. }
  2042. return data;
  2043. }
  2044. return undefined;
  2045. }
  2046. function decodeCIModel(data) {
  2047. var extraprop = 'props';
  2048. if (data[extraprop]) {
  2049. for (var key in data[extraprop]) {
  2050. data[key] = data[extraprop][key];
  2051. }
  2052. delete data[extraprop];
  2053. }
  2054. data['iscmadmin'] = false;
  2055. angular.forEach($rootScope.user.role, function (roleItem) {
  2056. if (roleItem.rolecode == "cmdb charge") {
  2057. data['iscmadmin'] = true;
  2058. }
  2059. })
  2060. return data;
  2061. }
  2062. function formValid() {
  2063. angular.forEach(vm.tabs, function (item) {
  2064. //item.
  2065. })
  2066. }
  2067. $scope.vm = vm;
  2068. $scope.refreshcmdbform = function (item) {
  2069. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2070. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2071. var myData = Restangular.stripRestangular(data);
  2072. $scope.propTypeOptions = myData;
  2073. $scope.templateProps = myData;
  2074. $scope.vm.tabs = myData;
  2075. if ($scope.model.assets) {
  2076. vm.models = JSON.parse($scope.model.assets);
  2077. }
  2078. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2079. if (vm.models.vtvmvtm_kaiji) {
  2080. vm.models.vtvmvtm_kaiji = "是";
  2081. } else {
  2082. vm.models.vtvmvtm_kaiji = "否";
  2083. }
  2084. }
  2085. decodeVMTabForm(vm.models, vm.tabs);
  2086. });
  2087. // }
  2088. }
  2089. var cifilterClassic = {};
  2090. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2091. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2092. $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
  2093. // } else {}
  2094. }]
  2095. });
  2096. //固定资产下载
  2097. formlyConfigProvider.setType({
  2098. name: 'ui-dropupload',
  2099. templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
  2100. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2101. defaultOptions: function (options) {
  2102. return {
  2103. templateOptions: {
  2104. view: function (APIService, contentId) {
  2105. return APIService.downloadAttachment(contentId);
  2106. },
  2107. },
  2108. };
  2109. },
  2110. controller: ['$scope', '$rootScope', 'Restangular', function ($scope, $rootScope, Restangular) {
  2111. if (angular.isUndefined($scope.form.dropState)) {
  2112. $scope.form.dropState = false;
  2113. }
  2114. var to = $scope.options.templateOptions;
  2115. var bindId = $scope.model[to.bindType].processInstanceId;
  2116. //获取附件列表
  2117. $scope.listAttachmen = function () {
  2118. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  2119. var myData = Restangular.stripRestangular(result);
  2120. // $scope.listAttachmens = myData;
  2121. $scope.attachments = myData.data;
  2122. });
  2123. };
  2124. $scope.listAttachmen();
  2125. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2126. // $scope.listAttachmen();
  2127. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2128. // $scope.listAttachmen();
  2129. // }
  2130. //附件下载
  2131. $scope.download = function (token, filename) {
  2132. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  2133. var a = document.createElement('a');
  2134. a.href = downUrl;
  2135. a.target = '_blank';
  2136. a.download = filename;
  2137. document.body.appendChild(a);
  2138. a.click();
  2139. };
  2140. //附件预览
  2141. $scope.view = function (id, previewUrl) {
  2142. if (previewUrl) {
  2143. window.open(previewUrl);
  2144. }
  2145. };
  2146. }]
  2147. });
  2148. formlyConfigProvider.setType({
  2149. name: 'ui-form',
  2150. templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
  2151. defaultOptions: function (options) {
  2152. return {
  2153. templateOptions: {
  2154. // link: function() {}
  2155. }
  2156. };
  2157. },
  2158. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  2159. $scope.langs = i18nService.getAllLangs();
  2160. $scope.lang = 'zh-cn';
  2161. i18nService.setCurrentLang($scope.lang);
  2162. var vm = this;
  2163. vm.options = {};
  2164. vm.exampleTitle = ['expressionProperties', 'model property'];
  2165. vm.fields = [];
  2166. vm.models = {};
  2167. // vm.models["loginUser"] = $rootScope.user;
  2168. var that = $injector;
  2169. var parse = $parse;
  2170. var formKey = "";
  2171. var pdKey = "";
  2172. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  2173. pdKey = $state.current.pdKey;
  2174. //console.log("pdKey::"+$state.current.pdKey);
  2175. }
  2176. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2177. formKey = $stateParams.formKey;
  2178. //console.log("formKey::"+$stateParams.formKey);
  2179. }
  2180. //用户测试数据,后续从header的auth中获取
  2181. var userId = 2;
  2182. userId = $rootScope.user.id;
  2183. //==============处理表单设计数据 开始====================
  2184. //处理组件加载后台数据选项的方法
  2185. function refreshSelectOptions(searchVal, field) {
  2186. if (field.templateOptions.optionsUrl) {
  2187. var process = BpmRestangular.all("");
  2188. if (field.templateOptions.ApiService) {
  2189. process = UserRestangular.all("");
  2190. }
  2191. process.customPOST({
  2192. "idx": 0,
  2193. "sum": 1000
  2194. }, field.templateOptions.optionsUrl).then(function (result) {
  2195. if (!field.templateOptions.options) {
  2196. field.templateOptions.options = [];
  2197. }
  2198. if (field.templateOptions.optionsDataKey) {
  2199. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  2200. } else {
  2201. field.templateOptions.options = result;
  2202. }
  2203. });
  2204. }
  2205. }
  2206. function decodeVMTabForm(model, tabs) {
  2207. var result = {
  2208. model: {},
  2209. tabs: []
  2210. };
  2211. var mdata = angular.fromJson(model);
  2212. angular.extend(result.model, mdata);
  2213. angular.forEach(tabs, function (tab) {
  2214. tab.form.model = vm.models;
  2215. angular.forEach(tab.form.fields, function (field) {
  2216. if (field.key == "") {
  2217. delete field.key;
  2218. }
  2219. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2220. var extObj = angular.fromJson(field.extjson);
  2221. angular.extend(field.templateOptions, extObj.templateOptions);
  2222. delete extObj.templateOptions;
  2223. for (var prop in extObj) {
  2224. if (new RegExp("Expression").test(prop)) {
  2225. //var obj = $scope.$eval(extObj[prop]);
  2226. //extObj[prop] = $scope.$eval(extObj[prop]);
  2227. if (extObj[prop] != null) {
  2228. if (new RegExp("function").test(extObj[prop])) {
  2229. var propValue = eval(extObj[prop]);
  2230. extObj[prop] = propValue;
  2231. } else {
  2232. //console.log(extObj[prop]);
  2233. var obj = $scope.$eval(extObj[prop]);
  2234. extObj[prop] = obj;
  2235. //console.log(obj);
  2236. }
  2237. }
  2238. } else if (new RegExp("expressionProperties").test(prop)) {
  2239. for (var p in extObj[prop]) {
  2240. if (new RegExp("function").test(extObj[prop][p])) {
  2241. var propValue = eval(extObj[prop][p]);
  2242. extObj[prop][p] = propValue;
  2243. } else {
  2244. //if(p.indexOf("'")>=0){
  2245. // var obj = $scope.$eval(extObj[prop][p]);
  2246. // extObj[prop][$scope.$eval(p)]=obj;
  2247. //}
  2248. }
  2249. }
  2250. } else if ("watcher" == prop) {
  2251. if (angular.isArray(extObj[prop])) {
  2252. angular.forEach(extObj[prop], function (item, index) {
  2253. for (var p in item) {
  2254. if (new RegExp("function").test(item[p])) {
  2255. var propValue = eval(item[p]);
  2256. extObj[prop][index][p] = propValue;
  2257. }
  2258. }
  2259. });
  2260. } else if (angular.isObject(extObj[prop])) {
  2261. for (var p in extObj[prop]) {
  2262. if (new RegExp("function").test(extObj[prop][p])) {
  2263. var propValue = eval(extObj[prop][p]);
  2264. extObj[prop][p] = propValue;
  2265. }
  2266. }
  2267. }
  2268. }
  2269. }
  2270. angular.extend(field, extObj);
  2271. delete field.extjson;
  2272. }
  2273. if (field.extjson == "") {
  2274. delete field.extjson;
  2275. }
  2276. if (angular.isDefined(field.templateOptions)) {
  2277. var templateOs = field.templateOptions;
  2278. for (var property in templateOs) {
  2279. //console.log(property);
  2280. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2281. if (new RegExp("function").test(templateOs[property])) {
  2282. var propValue = eval(templateOs[property]);
  2283. field.templateOptions[property] = propValue;
  2284. } else {
  2285. if (that.has(templateOs[property])) {
  2286. field.templateOptions[property] = that.get(templateOs[property]);
  2287. } else {
  2288. field.templateOptions[property] = templateOs[property];
  2289. }
  2290. }
  2291. } else if (templateOs[property] == null) {
  2292. //delete field.templateOptions[property];
  2293. } else { }
  2294. }
  2295. }
  2296. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2297. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2298. angular.extend(field.templateOptions, extObj);
  2299. delete field.templateOptions.extjson;
  2300. }
  2301. //...
  2302. if (field.templateOptions) {
  2303. //处理远程获取数据控件方法调用
  2304. if (field.templateOptions.optionsUrl) {
  2305. field.templateOptions.refresh = refreshSelectOptions;
  2306. }
  2307. //处理嵌套属性数据绑定/
  2308. if (field.templateOptions.pkey) {
  2309. var pmodel, i = 0;
  2310. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2311. if (i == 0) {
  2312. if (result.model[p] == null) {
  2313. result.model[p] = {};
  2314. }
  2315. pmodel = result.model[p];
  2316. i++;
  2317. } else {
  2318. if (pmodel[p] == null) {
  2319. pmodel[p] = {};
  2320. }
  2321. pmodel = pmodel[p];
  2322. }
  2323. });
  2324. if (pmodel != null) {
  2325. field.model = pmodel;
  2326. if (pmodel[field.key] == null) {
  2327. pmodel[field.key] = null;
  2328. }
  2329. }
  2330. } else {
  2331. if (result.model[field.key] == null) {
  2332. result.model[field.key] = null;
  2333. }
  2334. }
  2335. //处理弹出框组件初始化
  2336. if (field.type == "ui-input-selectmodal") {
  2337. field.templateOptions.modal = $modal;
  2338. //field.templateOptions.Restangular = Restangular;
  2339. } else if (field.type == "ui-userselect") {
  2340. field.templateOptions.modal = $modal;
  2341. //field.templateOptions.Restangular = Restangular;
  2342. } else if (field.type == "ui-multiuserselect") {
  2343. field.templateOptions.modal = $modal;
  2344. } else if (field.type == "ui-modelselect") {
  2345. field.templateOptions.modal = $modal;
  2346. //field.templateOptions.Restangular = Restangular;
  2347. } else if (field.type == "ui-dropfile") {
  2348. field.templateOptions.fileUploader = new FileUploader({
  2349. url: '/uploader'
  2350. });
  2351. field.templateOptions.taskId = $stateParams.taskId;
  2352. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2353. field.templateOptions.userId = $rootScope.user.id;
  2354. //field.ApiService=api_bpm_domain;
  2355. // }else if (field.type == "ui-uploadFile") {
  2356. // field.templateOptions.fileUploader = new FileUploader({
  2357. // url: '/uploader'
  2358. // });
  2359. // field.templateOptions.taskId = $stateParams.taskId;
  2360. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2361. // field.templateOptions.userId = $rootScope.user.id;
  2362. //field.ApiService=api_bpm_domain;
  2363. } else if (field.type == "ui-dropfiletable") {
  2364. if (field.templateOptions.processInstanceId) {
  2365. } else {
  2366. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2367. }
  2368. } else if (field.type == "ui-dropFiles") {
  2369. if (field.templateOptions.processInstanceId) {
  2370. } else {
  2371. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2372. }
  2373. } else if (field.type == "ui-showImgs") {
  2374. if (field.templateOptions.processInstanceId) {
  2375. } else {
  2376. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2377. }
  2378. } else if (field.type == "ui-repeatSection") {
  2379. var repeatForm = {
  2380. model: {
  2381. },
  2382. fields: field.templateOptions.fields
  2383. };
  2384. repeatForm.model[field.key] = [];
  2385. decodeVMTabForm(repeatForm);
  2386. }
  2387. }
  2388. // console.log(field);
  2389. //field
  2390. //result.fields.push(field);
  2391. })
  2392. });
  2393. vm.originalTabs = angular.copy(vm.form);
  2394. }
  2395. //解析自定义表单设计数据
  2396. function decodeVMForm(vmForm) {
  2397. var result = {
  2398. model: {},
  2399. tabs: []
  2400. };
  2401. //设置模型实体数据 begin
  2402. // var mdata = vmForm.model;
  2403. //解析数据实体
  2404. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2405. angular.extend(result.model, mdata);
  2406. //设置模型实体数据 end
  2407. //解析设计数据生成表单项 begin
  2408. var fields = [];
  2409. //处理修改设计数据中展示设置
  2410. angular.forEach(vmForm.tabs, function (field) {
  2411. if (field.key == "") {
  2412. delete field.key;
  2413. }
  2414. if (angular.isDefined(field.extjson)) {
  2415. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2416. angular.extend(field.templateOptions, extObj.templateOptions);
  2417. delete extObj.templateOptions;
  2418. for (var prop in extObj) {
  2419. if (new RegExp("Expression").test(prop)) {
  2420. //var obj = $scope.$eval(extObj[prop]);
  2421. //extObj[prop] = $scope.$eval(extObj[prop]);
  2422. if (extObj[prop] != null) {
  2423. if (new RegExp("function").test(extObj[prop])) {
  2424. var propValue = eval(extObj[prop]);
  2425. extObj[prop] = propValue;
  2426. } else {
  2427. //console.log(extObj[prop]);
  2428. var obj = $scope.$eval(extObj[prop]);
  2429. extObj[prop] = obj;
  2430. //console.log(obj);
  2431. }
  2432. }
  2433. } else if (new RegExp("expressionProperties").test(prop)) {
  2434. for (var p in extObj[prop]) {
  2435. if (new RegExp("function").test(extObj[prop][p])) {
  2436. var propValue = eval(extObj[prop][p]);
  2437. extObj[prop][p] = propValue;
  2438. } else {
  2439. //if(p.indexOf("'")>=0){
  2440. // var obj = $scope.$eval(extObj[prop][p]);
  2441. // extObj[prop][$scope.$eval(p)]=obj;
  2442. //}
  2443. }
  2444. }
  2445. } else if ("watcher" == prop) {
  2446. if (angular.isArray(extObj[prop])) {
  2447. angular.forEach(extObj[prop], function (item, index) {
  2448. for (var p in item) {
  2449. if (new RegExp("function").test(item[p])) {
  2450. var propValue = eval(item[p]);
  2451. extObj[prop][index][p] = propValue;
  2452. }
  2453. }
  2454. });
  2455. } else if (angular.isObject(extObj[prop])) {
  2456. for (var p in extObj[prop]) {
  2457. if (new RegExp("function").test(extObj[prop][p])) {
  2458. var propValue = eval(extObj[prop][p]);
  2459. extObj[prop][p] = propValue;
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465. angular.extend(field, extObj);
  2466. delete field.extjson;
  2467. }
  2468. if (angular.isDefined(field.templateOptions)) {
  2469. var templateOs = field.templateOptions;
  2470. for (var property in templateOs) {
  2471. //console.log(property);
  2472. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2473. if (new RegExp("function").test(templateOs[property])) {
  2474. var propValue = eval(templateOs[property]);
  2475. field.templateOptions[property] = propValue;
  2476. } else {
  2477. if (that.has(templateOs[property])) {
  2478. field.templateOptions[property] = that.get(templateOs[property]);
  2479. } else {
  2480. field.templateOptions[property] = templateOs[property];
  2481. }
  2482. }
  2483. } else if (templateOs[property] == null) {
  2484. //delete field.templateOptions[property];
  2485. } else { }
  2486. }
  2487. }
  2488. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2489. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2490. angular.extend(field.templateOptions, extObj);
  2491. delete field.templateOptions.extjson;
  2492. }
  2493. //...
  2494. if (field.templateOptions) {
  2495. //处理远程获取数据控件方法调用
  2496. if (field.templateOptions.optionsUrl) {
  2497. field.templateOptions.refresh = refreshSelectOptions;
  2498. }
  2499. //处理嵌套属性数据绑定/
  2500. if (field.templateOptions.pkey) {
  2501. var pmodel, i = 0;
  2502. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2503. if (i == 0) {
  2504. if (result.model[p] == null) {
  2505. result.model[p] = {};
  2506. }
  2507. pmodel = result.model[p];
  2508. i++;
  2509. } else {
  2510. if (pmodel[p] == null) {
  2511. pmodel[p] = {};
  2512. }
  2513. pmodel = pmodel[p];
  2514. }
  2515. });
  2516. if (pmodel != null) {
  2517. field.model = pmodel;
  2518. if (pmodel[field.key] == null) {
  2519. pmodel[field.key] = null;
  2520. }
  2521. }
  2522. } else {
  2523. if (result.model[field.key] == null) {
  2524. result.model[field.key] = null;
  2525. }
  2526. }
  2527. //处理弹出框组件初始化
  2528. if (field.type == "ui-input-selectmodal") {
  2529. field.templateOptions.modal = $modal;
  2530. //field.templateOptions.Restangular = Restangular;
  2531. } else if (field.type == "ui-userselect") {
  2532. field.templateOptions.modal = $modal;
  2533. //field.templateOptions.Restangular = Restangular;
  2534. } else if (field.type == "ui-multiuserselect") {
  2535. field.templateOptions.modal = $modal;
  2536. } else if (field.type == "ui-modelselect") {
  2537. field.templateOptions.modal = $modal;
  2538. //field.templateOptions.Restangular = Restangular;
  2539. } else if (field.type == "ui-dropfile") {
  2540. field.templateOptions.fileUploader = new FileUploader({
  2541. url: '/uploader'
  2542. });
  2543. field.templateOptions.taskId = $stateParams.taskId;
  2544. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2545. field.templateOptions.userId = $rootScope.user.id;
  2546. //field.ApiService=api_bpm_domain;
  2547. } else if (field.type == "ui-dropfiletable") {
  2548. if (field.templateOptions.processInstanceId) {
  2549. } else {
  2550. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2551. }
  2552. } else if (field.type == "ui-dropFiles") {
  2553. if (field.templateOptions.processInstanceId) {
  2554. } else {
  2555. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2556. }
  2557. } else if (field.type == "ui-showImgs") {
  2558. if (field.templateOptions.processInstanceId) {
  2559. } else {
  2560. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2561. }
  2562. } else if (field.type == "ui-repeatSection") {
  2563. var repeatForm = {
  2564. model: {
  2565. },
  2566. fields: field.templateOptions.fields
  2567. };
  2568. repeatForm.model[field.key] = [];
  2569. decodeVMForm(repeatForm);
  2570. }
  2571. }
  2572. // console.log(field);
  2573. result.fields.push(field);
  2574. });
  2575. angular.extend($scope.vm.fields, result.fields);
  2576. angular.extend($scope.vm.models, result.model);
  2577. $scope.formData = vmForm;
  2578. //console.log($scope.vm);
  2579. //解析设计数据生成表单项 end
  2580. return result;
  2581. }
  2582. //======================处理表单设计数据 结束========================
  2583. $scope.ldloading = {};
  2584. function filter(obj) {
  2585. angular.forEach(obj, function (key, value) {
  2586. if (value === "" || value === null) {
  2587. delete obj[key];
  2588. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  2589. filter(value);
  2590. } else if (angular.isArray(value)) {
  2591. angular.forEach(value, function (item) {
  2592. filter(item);
  2593. });
  2594. }
  2595. });
  2596. }
  2597. function invokeOnAllFormOptions(fn) {
  2598. angular.forEach(vm.tabs, function (tab) {
  2599. if (tab.form.options && tab.form.options[fn]) {
  2600. tab.form.options[fn]();
  2601. }
  2602. });
  2603. }
  2604. function encodeCIData(data, ciId) {
  2605. /*
  2606. create/update state:未审核
  2607. create createtime:系统时间
  2608. create/update lastupdatetime : 系统时间
  2609. label:ci分类
  2610. */
  2611. if (ciId) {
  2612. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2613. var extraprop = 'props';
  2614. data[extraprop] = {};
  2615. for (var key in data) {
  2616. console.log(data[key]);
  2617. if (_.indexOf(baseprop, key) >= 0) {
  2618. continue;
  2619. } else {
  2620. data[extraprop][key] = data[key];
  2621. delete data[key];
  2622. }
  2623. }
  2624. if ($rootScope.user) {
  2625. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2626. data[extraprop]['configperson'] = $rootScope.user.name;
  2627. var isCMAdminFlag = false;
  2628. angular.forEach($rootScope.user.role, function (roleItem) {
  2629. if (roleItem.rolecode == "cmdb charge") {
  2630. isCMAdminFlag = true;
  2631. }
  2632. })
  2633. if (!isCMAdminFlag) {
  2634. data[extraprop]['state'] = '1';
  2635. }
  2636. }
  2637. if (data.props.id) {
  2638. } else {
  2639. data.label = ciId;
  2640. }
  2641. return data;
  2642. }
  2643. return undefined;
  2644. }
  2645. function decodeCIModel(data) {
  2646. var extraprop = 'props';
  2647. if (data[extraprop]) {
  2648. for (var key in data[extraprop]) {
  2649. data[key] = data[extraprop][key];
  2650. }
  2651. delete data[extraprop];
  2652. }
  2653. data['iscmadmin'] = false;
  2654. angular.forEach($rootScope.user.role, function (roleItem) {
  2655. if (roleItem.rolecode == "cmdb charge") {
  2656. data['iscmadmin'] = true;
  2657. }
  2658. })
  2659. return data;
  2660. }
  2661. vm.remove = function (data, style) {
  2662. $scope.ldloading[style.replace('-', '_')] = true;
  2663. var modalInstance = $modal.open({
  2664. templateUrl: 'assets/views/delete.html',
  2665. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  2666. var cidata = {
  2667. label: data.label,
  2668. id: data.id,
  2669. uuid: data.uuid,
  2670. name: data.name,
  2671. props: {}
  2672. };
  2673. if (cidata.id) {
  2674. cidata.props['removeflag'] = true;
  2675. cidata.props['lastupdateperson'] = vm.models.loginUser;
  2676. $scope.ok = function () {
  2677. $modalInstance.close(cidata);
  2678. };
  2679. $scope.cancel = function () {
  2680. $modalInstance.dismiss('cancel');
  2681. };
  2682. }
  2683. },
  2684. size: 'sm',
  2685. resolve: {
  2686. scope: function () {
  2687. return $scope;
  2688. }
  2689. }
  2690. });
  2691. modalInstance.result.then(function (selectedItem) {
  2692. if (selectedItem) {
  2693. // if (selectedItem.length > 0) {
  2694. api_cmdb.put(selectedItem, selectedItem.id).then(function (response) {
  2695. if (response) {
  2696. var resData = Restangular.stripRestangular(response);
  2697. SweetAlert.swal({
  2698. title: "删除成功!",
  2699. confirmButtonColor: "#007AFF"
  2700. }, function () {
  2701. $state.go("app.means.list");
  2702. // $scope.refreshform();
  2703. // reinitTabForm($scope.classify);
  2704. });
  2705. } else {
  2706. SweetAlert.swal({
  2707. title: "系统错误",
  2708. text: "系统错误,请稍后重试!",
  2709. type: "error",
  2710. confirmButtonColor: "#DD6B55"
  2711. });
  2712. }
  2713. $scope.ldloading[style.replace('-', '_')] = false;
  2714. });
  2715. }
  2716. })
  2717. }
  2718. function formValid() {
  2719. angular.forEach(vm.tabs, function (item) {
  2720. //item.
  2721. })
  2722. }
  2723. $scope.closeModel = function () {
  2724. console.log($stateParams);
  2725. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2726. if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
  2727. $state.go('app.means.list', {});
  2728. }
  2729. event.preventDefault();
  2730. }
  2731. }
  2732. // setInterval(function() {
  2733. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  2734. // cifilter_classic = $scope.model.cifilter_classic;
  2735. // $scope.refreshcmdbform(cifilter_classic);
  2736. // } else {}
  2737. // }, 100);
  2738. vm.models = (function filter(obj) {
  2739. var filtered = _.pick(obj, function (v) {
  2740. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2741. });
  2742. return _.cloneDeep(filtered, function (v) {
  2743. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2744. });
  2745. })(vm.models);
  2746. // setInterval(function() {
  2747. // if ($scope.model.type == 0) {
  2748. // $scope.model[$scope.options.key] = vm.models;
  2749. // }
  2750. // }, 100);
  2751. setInterval(function () {
  2752. if (vm.form && vm.form.$$parentForm.$valid) {
  2753. if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
  2754. vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2755. $scope.model[$scope.options.key] = vm.models;
  2756. }
  2757. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2758. // $scope.model[$scope.options.key] = vm.models;
  2759. }
  2760. }, 100);
  2761. vm.submit = function (data, ciId, templateitem, style) {
  2762. // $scope.ldloading[style.replace('-', '_')] = true;
  2763. console.log(vm.form.$$parentForm.$valid);
  2764. if (vm.form.$$parentForm.$valid) {
  2765. invokeOnAllFormOptions('updateInitialValue');
  2766. //alert(JSON.stringify(vm.model), null, 2);
  2767. //vm.options.updateInitialValue();
  2768. //console.log(vm.model);
  2769. var cidata = encodeCIData(vm.models, ciId);
  2770. if (cidata) {
  2771. //var cidata = ;
  2772. if (cidata.props.id) {
  2773. //修改
  2774. api_cmdb.put(cidata, ciId).then(function (response) {
  2775. if (response) {
  2776. var resData = Restangular.stripRestangular(response);
  2777. SweetAlert.swal({
  2778. title: "保存成功!",
  2779. confirmButtonColor: "#007AFF"
  2780. }, function () {
  2781. $scope.ldloading[style.replace('-', '_')] = false;
  2782. // $scope.refreshform();
  2783. $state.go("app.means.list");
  2784. });
  2785. } else {
  2786. SweetAlert.swal({
  2787. title: "系统错误",
  2788. text: "系统错误,请稍后重试!",
  2789. type: "error",
  2790. confirmButtonColor: "#DD6B55"
  2791. });
  2792. }
  2793. $scope.ldloading[style.replace('-', '_')] = false;
  2794. });
  2795. } else {
  2796. //新建
  2797. var type = 2;
  2798. api_sysinfo.getSerialnumber(type, templateitem.id).then(function (data) {
  2799. if (data && data.status == 200) {
  2800. cidata.uuid = data.uuid;
  2801. api_cmdb.create(cidata).then(function (response) {
  2802. if (response) {
  2803. var resData = Restangular.stripRestangular(response);
  2804. SweetAlert.swal({
  2805. title: "保存成功!",
  2806. text: "内部编号:" + cidata.uuid,
  2807. confirmButtonColor: "#007AFF"
  2808. }, function () {
  2809. $state.go("app.means.list");
  2810. });
  2811. // if(resData.status){
  2812. // resData
  2813. // }
  2814. } else {
  2815. SweetAlert.swal({
  2816. title: "系统错误",
  2817. text: "系统错误,请稍后重试!",
  2818. type: "error",
  2819. confirmButtonColor: "#DD6B55"
  2820. });
  2821. }
  2822. $scope.ldloading[style.replace('-', '_')] = false;
  2823. });
  2824. } else {
  2825. SweetAlert.swal({
  2826. title: "系统错误",
  2827. text: "内部编号生成出错!",
  2828. type: "error",
  2829. confirmButtonColor: "#DD6B55"
  2830. });
  2831. }
  2832. })
  2833. }
  2834. } else {
  2835. SweetAlert.swal({
  2836. title: "错误",
  2837. text: "错误,请选择资产分类!",
  2838. type: "error",
  2839. confirmButtonColor: "#DD6B55"
  2840. });
  2841. }
  2842. //alert(JSON.stringify(cidata), null, 2);
  2843. $scope.ldloading[style.replace('-', '_')] = true;
  2844. return;
  2845. var _ = window._;
  2846. vm.models = (function filter(obj) {
  2847. var filtered = _.pick(obj, function (v) {
  2848. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2849. });
  2850. return _.cloneDeep(filtered, function (v) {
  2851. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2852. });
  2853. })(vm.models);
  2854. } else {
  2855. if (vm.form.$$parentForm.$error) {
  2856. SweetAlert.swal({
  2857. title: "校验错误",
  2858. text: "请填写必填项!",
  2859. type: "error",
  2860. confirmButtonColor: "#DD6B55"
  2861. });
  2862. angular.forEach(vm.form.$$parentForm.$error.required, function (item) {
  2863. angular.forEach(vm.tabs, function (tab) {
  2864. angular.forEach(tab.form.fields, function (f) {
  2865. if (f.name == item.$name) {
  2866. f.validation.show = true;
  2867. tab.active = true;
  2868. }
  2869. })
  2870. })
  2871. });
  2872. $scope.ldloading[style.replace('-', '_')] = false;
  2873. }
  2874. }
  2875. };
  2876. $scope.vm = vm;
  2877. $scope.refreshcmdbform = function (item) {
  2878. // if ($stateParams.model) {
  2879. // var modeldata = JSON.parse($stateParams.model)
  2880. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2881. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2882. var myData = Restangular.stripRestangular(data);
  2883. $scope.propTypeOptions = myData;
  2884. $scope.templateProps = myData;
  2885. $scope.vm.tabs = myData;
  2886. if ($scope.model.asset && $scope.model.asset.length != "") {
  2887. vm.models = JSON.parse($scope.model.asset);
  2888. }
  2889. decodeVMTabForm(vm.models, vm.tabs);
  2890. });
  2891. // }
  2892. }
  2893. var cifilterClassic = {};
  2894. setInterval(function () {
  2895. if ($scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2896. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  2897. cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2898. $scope.refreshcmdbform(cifilterClassic);
  2899. } else { }
  2900. }, 100);
  2901. }]
  2902. });
  2903. //请求人信息
  2904. formlyConfigProvider.setType({
  2905. name: 'ui-cmdbinformation',
  2906. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
  2907. wrapper: ['bootstrapHasError'],
  2908. defaultOptions: function (options, $scope) {
  2909. return {
  2910. templateOptions: {
  2911. // checkform: function(options) {
  2912. // if (options.model.requester) {
  2913. // options.value(options.model.requester);
  2914. // }
  2915. // },
  2916. }
  2917. };
  2918. },
  2919. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2920. if ($scope.options.templateOptions.loginUser) {
  2921. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
  2922. } else {
  2923. $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
  2924. }
  2925. $scope.options.initialValue = $scope.model[$scope.options.key];
  2926. }
  2927. }]
  2928. });
  2929. //资产属性
  2930. formlyConfigProvider.setType({
  2931. name: 'ui-cmdbtype',
  2932. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
  2933. wrapper: ['bootstrapHasError'],
  2934. defaultOptions: function (options, $scope) {
  2935. return {
  2936. templateOptions: {
  2937. // checkform: function(options) {
  2938. // if (options.model.requester) {
  2939. // options.value(options.model.requester);
  2940. // }
  2941. // },
  2942. }
  2943. };
  2944. },
  2945. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2946. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2947. $scope.property = {
  2948. 'hw_change': $scope.to.loginUser,
  2949. 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
  2950. 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
  2951. }
  2952. if ($scope.$parent.$parent.$parent.model.assets) {
  2953. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  2954. }
  2955. }]
  2956. });
  2957. //申请单信息
  2958. formlyConfigProvider.setType({
  2959. name: 'ui-cmdbformimform',
  2960. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
  2961. wrapper: ['bootstrapHasError'],
  2962. defaultOptions: function (options, $scope) {
  2963. return {
  2964. templateOptions: {
  2965. // checkform: function(options) {
  2966. // if (options.model.requester) {
  2967. // options.value(options.model.requester);
  2968. // }
  2969. // },
  2970. }
  2971. };
  2972. },
  2973. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2974. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2975. $scope.getininform = {
  2976. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2977. time: $scope.$parent.$parent.$parent.model.applicationForm.time
  2978. };
  2979. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  2980. $scope.getininform.types = "新资产入库";
  2981. } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
  2982. $scope.getininform.types = "资产归还";
  2983. }
  2984. }]
  2985. });
  2986. //出库单信息
  2987. formlyConfigProvider.setType({
  2988. name: 'ui-outinformation',
  2989. templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
  2990. wrapper: ['bootstrapHasError'],
  2991. defaultOptions: function (options, $scope) {
  2992. return {
  2993. templateOptions: {
  2994. // checkform: function(options) {
  2995. // if (options.model.requester) {
  2996. // options.value(options.model.requester);
  2997. // }
  2998. // },
  2999. }
  3000. };
  3001. },
  3002. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  3003. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3004. $scope.getininform = {
  3005. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3006. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3007. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3008. sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3009. describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
  3010. };
  3011. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3012. $scope.getininform.types = "新设备领用出库";
  3013. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3014. $scope.getininform.types = "设备更换";
  3015. }
  3016. $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.value;
  3017. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3018. $scope.getininform.source = "事件";
  3019. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3020. $scope.getininform.source = "变更";
  3021. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3022. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3023. $scope.getininform.source = "其它";
  3024. }
  3025. }]
  3026. });
  3027. //资产附件上传
  3028. formlyConfigProvider.setType({
  3029. name: 'ui-cmdbuplode',
  3030. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
  3031. wrapper: ['bootstrapHasError'],
  3032. defaultOptions: function (options, $scope) {
  3033. return {
  3034. templateOptions: {
  3035. // checkform: function(options) {
  3036. // if (options.model.requester) {
  3037. // options.value(options.model.requester);
  3038. // }
  3039. // },
  3040. }
  3041. };
  3042. },
  3043. controller: ['$scope', '$rootScope', '$http', 'SweetAlert', 'FileUploader', 'api_user_data', 'i18nService', '$modal', 'Restangular', 'api_configure_data', 'api_cmdb', 'api_cmdb_new', 'api_wechatfile', 'api_sysinfo', function ($scope, $rootScope, $http, SweetAlert, FileUploader, api_user_data, i18nService, $modal, Restangular, api_configure_data, api_cmdb, api_cmdb_new, api_wechatfile, api_sysinfo) {
  3044. $scope.state = 1;
  3045. $scope.myData3all = [];
  3046. $scope.myData3 = [];
  3047. $scope.memoryfilterDatahao = {
  3048. "idx": 0,
  3049. "sum": 10,
  3050. }
  3051. $scope.selected = {
  3052. items: []
  3053. };
  3054. $scope.interceptMydata = function (mydate, idx, sum) {
  3055. return mydate.slice(idx * sum, (idx + 1) * sum)
  3056. }
  3057. // $scope.importnext = function() {
  3058. // $scope.state = 2;
  3059. // event.preventDefault();
  3060. // }
  3061. $scope.workspaces = [];
  3062. $scope.options.templateOptions.getpush = function (item) {
  3063. $scope.workspaces = [];
  3064. if (item.gu) {
  3065. $scope.workspaces.push({
  3066. id: 1,
  3067. name: "固定资产",
  3068. active: true,
  3069. contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html'
  3070. })
  3071. }
  3072. if (item.hao) {
  3073. $scope.workspaces.push({
  3074. id: 2,
  3075. name: "耗材资产",
  3076. active: true,
  3077. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  3078. })
  3079. }
  3080. };
  3081. //获取附件列表
  3082. $scope.listAttachmen = function () {
  3083. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  3084. var myData = Restangular.stripRestangular(result);
  3085. // $scope.listAttachmens = myData;
  3086. $scope.attachments = myData.data;
  3087. });
  3088. };
  3089. //附件列表
  3090. if ($scope.options.templateOptions.bindType) {
  3091. if (angular.isUndefined($scope.form.dropState)) {
  3092. $scope.form.dropState = false;
  3093. }
  3094. var to = $scope.options.templateOptions;
  3095. var bindId = $scope.model[to.bindType].processInstanceId;
  3096. $scope.listAttachmen();
  3097. }
  3098. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3099. // $scope.listAttachmen();
  3100. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3101. // $scope.listAttachmen();
  3102. // }
  3103. //附件下载
  3104. $scope.download = function (token, filename) {
  3105. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  3106. // window.open(downUrl);
  3107. var a = document.createElement('a');
  3108. a.href = downUrl;
  3109. a.target = '_blank';
  3110. a.download = filename;
  3111. document.body.appendChild(a);
  3112. a.click();
  3113. };
  3114. //附件预览
  3115. $scope.view = function (id, previewUrl) {
  3116. if (previewUrl) {
  3117. window.open(previewUrl);
  3118. }
  3119. };
  3120. //下载资产模版
  3121. $scope.filenum = 0;
  3122. $scope.openmeans = function () {
  3123. var modalInstance = $modal.open({
  3124. templateUrl: 'assets/views/means/tpl/meansdown.html',
  3125. controller: function ($scope, scope, $modalInstance) {
  3126. $scope.item = {};
  3127. $scope.title = "选择下载模版";
  3128. $scope.lable = "资产模版下载";
  3129. function foreachdata(my_datas) {
  3130. // angular.forEach(my_datas, function(item, index) {
  3131. // if (item.children && item.children.length > 0) {
  3132. // foreachdata(item.children);
  3133. // } else {
  3134. // my_datas[index].checks = true;
  3135. // }
  3136. // })
  3137. for (var i = 0; i < my_datas.length; i++) {
  3138. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3139. foreachdata(my_datas[i].children);
  3140. console.log($scope);
  3141. } else {
  3142. my_datas[i].checks = true;
  3143. }
  3144. }
  3145. }
  3146. function foreachtree(data) {
  3147. angular.forEach(data, function (item) {
  3148. // if (item.checks != true) {
  3149. item.checks = true;
  3150. item.expanded = true;
  3151. if (item.children && item.children.length > 0) {
  3152. foreachtree(item.children)
  3153. } else {
  3154. $scope.getslowtree.push(item)
  3155. }
  3156. // }
  3157. })
  3158. }
  3159. $scope.getslowtree = [];
  3160. $scope.slowtree = function (tree) {
  3161. foreachtree(tree)
  3162. return $scope.getslowtree
  3163. }
  3164. $scope.all = function (c, v) { //全选
  3165. if (c == true) {
  3166. $scope.formdashboard($scope.slowtree(v));
  3167. } else {
  3168. $scope.my_data_after = [];
  3169. angular.forEach($scope.my_data, function (item, index) {
  3170. $scope.my_data[index].checks = false;
  3171. $scope.my_data[index].expanded = false;
  3172. if (item.children && item.children.length > 0) {
  3173. angular.forEach(item.children, function (itemone, indexone) {
  3174. $scope.my_data[index].children[indexone].checks = false;
  3175. $scope.my_data[index].children[indexone].expanded = false;
  3176. if (itemone.children && itemone.children.length > 0) {
  3177. angular.forEach(itemone.children, function (itemtwo, indextwo) {
  3178. $scope.my_data[index].children[indexone].children[indextwo].checks = false;
  3179. })
  3180. } else { }
  3181. })
  3182. } else { }
  3183. })
  3184. $scope.mydatacate = [];
  3185. $scope.getslowtree = [];
  3186. // }
  3187. }
  3188. };
  3189. // $scope.searchone = function(search) {
  3190. // angular.forEach($scope.my_data, function(item) {
  3191. // if (item.indexOf(search) > 0) {
  3192. // }
  3193. // })
  3194. // }
  3195. $scope.checkall = function () {
  3196. angular.forEach($scope.my_data, function (item, index) {
  3197. scope.my_data[index].checks = true;
  3198. })
  3199. }
  3200. $scope.selectitem = [];
  3201. $scope.choiceitem = function (item) {
  3202. // if (item.checkeds) {
  3203. // item.checkeds = false;
  3204. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3205. // // if ($scope.selectitem[i].id == item.id) {
  3206. // // $scope.selectitem.splice(i, 1)
  3207. // // }
  3208. // // }
  3209. // for (var i = 0; i < $scope.my_data_after; i++) {
  3210. // if ($scope.my_data_after[i].id == item.id) {
  3211. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3212. // // $scope.selectitem.splice(i, 1)
  3213. // }
  3214. // }
  3215. // } else {
  3216. // item.checkeds = true;
  3217. // $scope.selectitem.push(item)
  3218. // }
  3219. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3220. if ($scope.my_data_after[i].id == item.id) {
  3221. $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3222. }
  3223. }
  3224. }
  3225. $scope.remove = function (removeitem) {
  3226. var realdat = angular.copy($scope.my_data_after)
  3227. // angular.extend(realdat, $scope.selectitem);
  3228. $scope.my_data_after = [];
  3229. angular.forEach(realdat, function (item) {
  3230. if (!item.checkeds) {
  3231. $scope.my_data_after.push(item)
  3232. }
  3233. })
  3234. $scope.mydatacate = angular.copy($scope.my_data_after);
  3235. }
  3236. $scope.try_async_loads = function (item, search) {
  3237. var fildatas = {
  3238. 'idx': 0,
  3239. 'sum': 1000
  3240. };
  3241. $scope.my_data = [];
  3242. // $scope.try_async_load = true;
  3243. if (item) {
  3244. angular.extend(fildatas, item)
  3245. }
  3246. api_configure_data.fetchDataList('ciclassify', fildatas).then(function (response) {
  3247. if (response.status == 200) {
  3248. var data = response.list;
  3249. var objects = [];
  3250. for (var i = 0; i < data.length; i++) {
  3251. var object = {};
  3252. object.id = data[i].id;
  3253. if (search) {
  3254. delete data[i].parent
  3255. } else {
  3256. if (data[i].parent && data[i].parent.id != 0) {
  3257. object.parent = data[i].parent.id;
  3258. }
  3259. }
  3260. angular.extend(object, data[i]);
  3261. objects.push(object);
  3262. }
  3263. $scope.my_data = convertParentToChildList(objects);
  3264. $scope.tree_data = angular.copy($scope.my_data);
  3265. if ($scope.my_data.length > 0) {
  3266. $scope.try_async_load = false;
  3267. }
  3268. } else {
  3269. SweetAlert.swal({
  3270. title: "系统错误!",
  3271. text: "请刷新重试!",
  3272. type: "error"
  3273. });
  3274. }
  3275. });
  3276. };
  3277. function convertListToTree(data, treeMap) {
  3278. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3279. var root = null; //Initially set our loop to null
  3280. //loop over data
  3281. for (var i = 0; i < data.length; i++) {
  3282. var datum = data[i];
  3283. //each node will have children, so let's give it a "children" poperty
  3284. datum.children = [];
  3285. //add an entry for this node to the map so that any future children can
  3286. //lookup the parent
  3287. idToNodeMap[datum.id] = datum;
  3288. //Does this node have a parent?
  3289. // console.log("datum="+JSON.stringify(datum))
  3290. if (typeof datum.parent === "undefined" || datum.parent === null) {
  3291. //Doesn't look like it, so this node is the root of the tree
  3292. root = datum;
  3293. treeMap[datum.id] = root;
  3294. } else {
  3295. //This node has a parent, so let's look it up using the id
  3296. parentNode = idToNodeMap[datum.parent.id];
  3297. //We don't need this property, so let's delete it.
  3298. // delete datum.parent;
  3299. //Let's add the current node as a child of the parent node.
  3300. parentNode.children.push(datum);
  3301. }
  3302. }
  3303. return root;
  3304. }
  3305. function convertParentToChildList(data) {
  3306. var treeMap = {};
  3307. var list = [];
  3308. convertListToTree(data, treeMap);
  3309. angular.forEach(treeMap, function (item) {
  3310. list.push(item);
  3311. });
  3312. return list;
  3313. }
  3314. function convertParentToChild(datato) {
  3315. var treeMapto = {};
  3316. var listto = [];
  3317. convertListToTree(datato, treeMapto);
  3318. angular.forEach(treeMapto, function (items) {
  3319. listto.push(items);
  3320. });
  3321. return listto;
  3322. }
  3323. $scope.try_async_loads();
  3324. $scope.searchdown = function (key) {
  3325. if (key && key != '') {
  3326. $scope.try_async_loads({
  3327. 'ciclassify': {
  3328. "label": key
  3329. }
  3330. }, 'search')
  3331. } else {
  3332. $scope.try_async_loads()
  3333. }
  3334. // var mydatacatedown = angular.copy($scope.my_data);
  3335. // $scope.my_data = [];
  3336. // var objects = [];
  3337. // angular.forEach(mydatacatedown, function(item) {
  3338. // if (item.label.match(key)) {
  3339. // objects.push(item)
  3340. // } else {
  3341. // // $scope.my_data_after.push(item)
  3342. // }
  3343. // })
  3344. // $scope.my_data = convertParentToChildList(objects);
  3345. // $scope.tree_data = angular.copy($scope.my_data);
  3346. }
  3347. $scope.mydatacate = [];
  3348. $scope.searchup = function (key) {
  3349. // var mydatacate = angular.copy($scope.my_data_after);
  3350. $scope.my_data_after = [];
  3351. angular.forEach($scope.mydatacate, function (item) {
  3352. if (item.label.match(key)) {
  3353. $scope.my_data_after.push(item)
  3354. } else { }
  3355. })
  3356. }
  3357. //角色树
  3358. $scope.my_tree = [];
  3359. $scope.tree_data_after = [];
  3360. $scope.my_data = [];
  3361. $scope.my_data_after = [];
  3362. $scope.formdashboard = function (item) {
  3363. $scope.my_data_after = [];
  3364. angular.forEach(item, function (infox) {
  3365. if (infox.children.length == 0) {
  3366. $scope.my_data_after.push(infox);
  3367. }
  3368. })
  3369. $scope.mydatacate = angular.copy($scope.my_data_after);
  3370. }
  3371. $scope.ok = function (item) {
  3372. $modalInstance.close(item);
  3373. };
  3374. $scope.cancel = function () {
  3375. $modalInstance.dismiss('cancel');
  3376. };
  3377. },
  3378. // size: 'sm',
  3379. resolve: {
  3380. scope: function () {
  3381. return $scope;
  3382. }
  3383. }
  3384. });
  3385. modalInstance.result.then(function (selectedItem) {
  3386. // $rootScope.isMask = true;
  3387. if (selectedItem) {
  3388. var type = 1;
  3389. var fildat = {
  3390. 'configure': selectedItem
  3391. };
  3392. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  3393. // // if (data.errno == 0) {
  3394. // var file = new Blob([data], {
  3395. // // 'Accept': '*/*'
  3396. // type: 'application/octet-stream'
  3397. // // type: 'application/vnd.ms-excel'
  3398. // });
  3399. // //trick to download store a file having its URL
  3400. // var fileURL = URL.createObjectURL(file);
  3401. // var a = document.createElement('a');
  3402. // a.href = fileURL;
  3403. // a.target = '_blank';
  3404. // a.download = "资产导入模版.xlsx";
  3405. // document.body.appendChild(a);
  3406. // a.click();
  3407. // // }
  3408. // })
  3409. $http({
  3410. url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
  3411. method: 'POST',
  3412. data: JSON.stringify(fildat),
  3413. headers: {
  3414. // 'Content-type': 'application/xls',
  3415. 'Accept': '*/*'
  3416. },
  3417. responseType: 'arraybuffer'
  3418. }).success(function (data, status, headers, config) {
  3419. $rootScope.isMask = false;
  3420. var file = new Blob([data], {
  3421. type: 'application/octet-stream'
  3422. // type : 'application/vnd.ms-excel'
  3423. });
  3424. //trick to download store a file having its URL
  3425. var fileURL = URL.createObjectURL(file);
  3426. var a = document.createElement('a');
  3427. a.href = fileURL;
  3428. a.target = '_blank';
  3429. a.download = "资产导入模版.xlsx";
  3430. document.body.appendChild(a);
  3431. a.click();
  3432. }).error(function (data, status, headers, config) {
  3433. // console.log(data);
  3434. $rootScope.isMask = false;
  3435. });
  3436. // break;
  3437. // }
  3438. // }
  3439. // }
  3440. // })
  3441. } else {
  3442. SweetAlert.swal({
  3443. title: "未选择资产分类!",
  3444. text: "请选择资产分类",
  3445. type: "error"
  3446. }, function () {
  3447. $rootScope.isMask = false;
  3448. });
  3449. }
  3450. // }
  3451. });
  3452. }
  3453. $scope.wrongdata = [];
  3454. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3455. var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
  3456. $scope.importopen = function () { //导入触发事件
  3457. if (angular.isUndefined($scope.form.dropState)) {
  3458. $scope.form.dropState = false;
  3459. }
  3460. //附件上传数据
  3461. //$scope.options.templateOptions.uploader();
  3462. // FILTERS
  3463. uploader.filters.push({
  3464. name: 'customFilter',
  3465. fn: function (item /*{File|FileLikeObject}*/, options) {
  3466. return this.queue.length < 2;
  3467. }
  3468. });
  3469. // CALLBACKS
  3470. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  3471. console.info('onWhenAddingFileFailed', item, filter, options);
  3472. };
  3473. uploader.onAfterAddingFile = function (fileItem) {
  3474. console.info('onAfterAddingFile', fileItem);
  3475. };
  3476. uploader.onAfterAddingAll = function (addedFileItems) {
  3477. console.info('onAfterAddingAll', addedFileItems);
  3478. };
  3479. uploader.onBeforeUploadItem = function (item) {
  3480. console.info('onBeforeUploadItem', item);
  3481. };
  3482. uploader.onProgressItem = function (fileItem, progress) {
  3483. console.info('onProgressItem', fileItem, progress);
  3484. };
  3485. uploader.onProgressAll = function (progress) {
  3486. console.info('onProgressAll', progress);
  3487. };
  3488. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3489. // console.info('onSuccessItem', fileItem, response, status, headers);
  3490. // };
  3491. uploader.onErrorItem = function (fileItem, response, status, headers) {
  3492. console.info('onErrorItem', fileItem, response, status, headers);
  3493. };
  3494. uploader.onCancelItem = function (fileItem, response, status, headers) {
  3495. console.info('onCancelItem', fileItem, response, status, headers);
  3496. };
  3497. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  3498. console.info('onCompleteItem', fileItem, response, status, headers);
  3499. };
  3500. uploader.onCompleteAll = function () {
  3501. console.info('onCompleteAll');
  3502. };
  3503. }
  3504. // $scope.importnext = function() {
  3505. // $scope.state = 2;
  3506. // event.preventDefault();
  3507. // }
  3508. $scope.importnext = function () {
  3509. event.preventDefault();
  3510. // $rootScope.isMask = true;
  3511. $rootScope.loading = true;
  3512. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3513. uploader.onBeforeUploadItem = function (item) {
  3514. angular.extend(item.headers, $rootScope.getSession());
  3515. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3516. // if (item.index > 1) {
  3517. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3518. // }
  3519. // item.index = 1;
  3520. item.formData = [{
  3521. 'filename': item.file.name
  3522. }];
  3523. console.info('onBeforeUploadItem', item);
  3524. };
  3525. uploader.uploadAll();
  3526. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3527. if (response.status == 200) {
  3528. $scope.wrongdata = [];
  3529. $rootScope.loading = false;
  3530. if (response.abnormal) {
  3531. $scope.state = 2;
  3532. angular.forEach(response.msg, function (item) {
  3533. $scope.wrongdata.push({
  3534. 'name': item.assetName,
  3535. 'line': item.row,
  3536. 'cmdbname': item.name,
  3537. 'errotip': [{
  3538. 'label': item.msg
  3539. }]
  3540. })
  3541. })
  3542. } else {
  3543. $scope.state = 3;
  3544. }
  3545. } else {
  3546. $rootScope.loading = false;
  3547. $scope.state = 2;
  3548. }
  3549. }
  3550. }
  3551. $scope.clearItems = function () { //重新选择文件时,清空队列,达到覆盖文件的效果
  3552. uploader.clearQueue();
  3553. // uploader.remove();
  3554. // uploader.cancel();
  3555. // uploader.onChange();
  3556. }
  3557. uploader.onAfterAddingFile = function (fileItem) {
  3558. $scope.fileItem = fileItem._file;
  3559. // $scope.$apply();
  3560. // $scope.fileItem = filenum;
  3561. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  3562. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  3563. $scope.filenum++;
  3564. };
  3565. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3566. $scope.uploadStatus = true; //上传成功则把状态改为true
  3567. // alert(response.path);
  3568. };
  3569. $scope.importnext = function () {
  3570. event.preventDefault();
  3571. // uploader.onChange();
  3572. $rootScope.loading = true;
  3573. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3574. uploader.onBeforeUploadItem = function (item) {
  3575. angular.extend(item.headers, $rootScope.getSession());
  3576. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3577. // if (item.index > 1) {
  3578. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3579. // }
  3580. // item.index = 1;
  3581. item.formData = [{
  3582. 'filename': item.file.name
  3583. }];
  3584. console.info('onBeforeUploadItem', item);
  3585. };
  3586. uploader.uploadAll();
  3587. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3588. if (response.status == 200) {
  3589. $scope.wrongdata = [];
  3590. // uploader.queue = [];
  3591. $rootScope.loading = false;
  3592. if (response.abnormal) {
  3593. $scope.state = 2;
  3594. uploader.clearQueue();
  3595. angular.forEach(response.msg, function (item) {
  3596. $scope.wrongdata.push({
  3597. 'name': item.assetName,
  3598. 'line': item.row,
  3599. 'cmdbname': item.name,
  3600. 'errotip': [{
  3601. 'label': item.msg
  3602. }]
  3603. })
  3604. })
  3605. } else {
  3606. $scope.state = 3;
  3607. }
  3608. } else {
  3609. uploader.clearQueue();
  3610. $rootScope.loading = false;
  3611. $scope.state = 2;
  3612. }
  3613. }
  3614. }
  3615. var setAllInactive = function () {
  3616. angular.forEach($scope.workspaces, function (workspace) {
  3617. workspace.active = false;
  3618. });
  3619. };
  3620. //添加
  3621. var addNewWorkspace = function (name, contentUrl) {
  3622. var id = $scope.workspaces.length + 1;
  3623. $scope.workspaces.push({
  3624. id: id,
  3625. name: name,
  3626. active: true,
  3627. contentUrl: 'main/html/content.html'
  3628. });
  3629. };
  3630. //关闭
  3631. $scope.closeopen = function (closedata) {
  3632. event.preventDefault();
  3633. angular.forEach($scope.workspaces, function (item, index) {
  3634. if (closedata.id == item.id) {
  3635. if (closedata.id == 1) {
  3636. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  3637. } else {
  3638. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  3639. }
  3640. $scope.workspaces.splice(index, 1);
  3641. }
  3642. })
  3643. }
  3644. // $scope.workspaces = [
  3645. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  3646. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3647. // ];
  3648. $scope.addWorkspace = function (contentUrl, name) {
  3649. setAllInactive();
  3650. addNewWorkspace(name, contentUrl);
  3651. };
  3652. // $rootScope.addWorkspace = $scope.addWorkspace;
  3653. $scope.close = function (idNumber) {
  3654. var index = 0; //记录当前元素下标
  3655. angular.forEach($scope.workspaces, function (workspace) {
  3656. if (workspace.id === idNumber) {
  3657. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3658. }
  3659. index++;
  3660. });
  3661. };
  3662. //grid2
  3663. $scope.langs = i18nService.getAllLangs();
  3664. $scope.lang = 'zh-cn';
  3665. i18nService.setCurrentLang($scope.lang);
  3666. $scope.gridOptions2 = {};
  3667. $scope.gridOptions2.data = 'myData3';
  3668. $scope.gridOptions2.enableColumnResizing = true;
  3669. $scope.gridOptions2.enableFiltering = false;
  3670. $scope.gridOptions2.enableGridMenu = false;
  3671. $scope.gridOptions2.showGridFooter = true;
  3672. $scope.gridOptions2.showColumnFooter = false;
  3673. $scope.gridOptions2.fastWatch = true;
  3674. $scope.gridOptions2.useExternalFiltering = true;
  3675. $scope.gridOptions2.useExternalPagination = true;
  3676. $scope.gridOptions2.paginationPageSizes = [10];
  3677. $scope.gridOptions2.paginationPageSize = 10;
  3678. $scope.gridOptions2.multiSelect = false;
  3679. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  3680. $scope.gridOptions2.columnDefs = [{
  3681. name: 'item',
  3682. displayName: '序号',
  3683. width: 120
  3684. },
  3685. {
  3686. name: 'name',
  3687. displayName: '耗材名称',
  3688. width: 80,
  3689. enableFiltering: false
  3690. },
  3691. {
  3692. name: 'model',
  3693. displayName: '品牌/型号',
  3694. width: 100,
  3695. enableFiltering: false
  3696. },
  3697. {
  3698. name: 'Specifications',
  3699. displayName: '规格',
  3700. width: 150,
  3701. enableFiltering: false
  3702. },
  3703. {
  3704. name: 'sum',
  3705. displayName: '数量',
  3706. enableFiltering: false
  3707. },
  3708. {
  3709. name: '操作',
  3710. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3711. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  3712. '</div></div>',
  3713. enableFiltering: false
  3714. },
  3715. ];
  3716. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  3717. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  3718. $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
  3719. for (var i = 0; i < $scope.myData3all.length; i++) {
  3720. $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  3721. }
  3722. // $scope.model.consumables = $scope.myDataone;
  3723. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3724. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
  3725. $scope.model.applicationForm.consumables = $scope.myData3all;
  3726. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3727. $scope.options.templateOptions.getpush({
  3728. "hao": true,
  3729. "gu": true
  3730. });
  3731. } else {
  3732. $scope.options.templateOptions.getpush({
  3733. "hao": true
  3734. });
  3735. }
  3736. } else {
  3737. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3738. $scope.options.templateOptions.getpush({
  3739. "gu": true
  3740. });
  3741. }
  3742. }
  3743. }
  3744. $scope.options.templateOptions.workspaces = $scope.workspaces;
  3745. $scope.changecai = function (item) {
  3746. event.preventDefault();
  3747. var modalInstance = $modal.open({
  3748. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  3749. controller: function ($scope, $modalInstance) {
  3750. $scope.title = "修改耗材数量";
  3751. $scope.consumptive = angular.copy(item);
  3752. $scope.ok = function () {
  3753. $modalInstance.close($scope.consumptive);
  3754. };
  3755. $scope.cancel = function () {
  3756. $modalInstance.dismiss('cancel');
  3757. };
  3758. },
  3759. size: 'sm'
  3760. });
  3761. modalInstance.result.then(function (selectedItem) {
  3762. // angular.forEach($scope.myData3, function(items, index) {
  3763. // if (items.id == selectedItem.id) {
  3764. // $scope.myData3[index] = selectedItem;
  3765. // }
  3766. // })
  3767. // // $scope.myData3.push(selectedItem);
  3768. // $scope.model.applicationForm.consumables = $scope.myData3;
  3769. angular.forEach($scope.myData3all, function (items, index) {
  3770. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  3771. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  3772. angular.extend($scope.myData3all[index], selectedItem)
  3773. }
  3774. })
  3775. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3776. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3777. $scope.model.applicationForm.consumables = $scope.myData3all;
  3778. })
  3779. }
  3780. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  3781. $scope.gridApi = gridApi;
  3782. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  3783. // var filtersData = $scope.memoryfilterDatahao;
  3784. // filtersData.idx = newPage - 1;
  3785. // filtersData.sum = pageSize;
  3786. // $scope.loadData(filtersData);
  3787. $scope.memoryfilterDatahao.idx = newPage - 1;
  3788. $scope.memoryfilterDatahao.sum = pageSize;
  3789. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
  3790. });
  3791. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  3792. $scope.selected.items = data.entity;
  3793. //console.log(data);
  3794. });
  3795. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  3796. $scope.selected.items = data.entity;
  3797. //console.log(data);
  3798. });
  3799. gridApi.core.on.filterChanged($scope, function () {
  3800. var grid = this.grid;
  3801. var filtersData = {
  3802. idx: 0,
  3803. sum: 10,
  3804. };
  3805. $scope.memoryfilterDatahao = filtersData;
  3806. // $scope.loadData(filtersData);
  3807. // $scope.memoryfilterDatahao.idx = newPage - 1;
  3808. // $scope.memoryfilterDatahao.sum = pageSize;
  3809. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3810. });
  3811. };
  3812. $scope.haocaiopen = function (items) {
  3813. event.preventDefault();
  3814. var modalInstance = $modal.open({
  3815. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3816. controller: function ($scope, $modalInstance, SweetAlert) {
  3817. $scope.consumptive = {};
  3818. $scope.title = "新增耗材";
  3819. if (items.name) {
  3820. $scope.consumptive.name = items.name.name;
  3821. }
  3822. $scope.clearNoNum = function (obj, attr) {
  3823. //先把非数字的都替换掉,除了数字和.
  3824. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3825. //必须保证第一个为数字而不是.
  3826. obj[attr] = obj[attr].replace(/^\./g, "");
  3827. //保证只有出现一个.而没有多个.
  3828. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3829. //保证.只出现一次,而不能出现两次以上
  3830. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3831. //小于最大值
  3832. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3833. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3834. // obj[attr] = '';
  3835. // }
  3836. }
  3837. $scope.ok = function (item) {
  3838. // if (item.name && item.model && item.Specifications && item.sum) {
  3839. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3840. $modalInstance.close(item);
  3841. } else {
  3842. SweetAlert.swal({
  3843. title: "数据填写不完整!",
  3844. text: "请检查数据然后提交!",
  3845. type: "error"
  3846. });
  3847. }
  3848. };
  3849. $scope.cancel = function () {
  3850. $modalInstance.dismiss('cancel');
  3851. };
  3852. },
  3853. size: 'sm',
  3854. resolve: {
  3855. SweetAlert: function () {
  3856. return SweetAlert;
  3857. }
  3858. }
  3859. });
  3860. modalInstance.result.then(function (selectedItem) {
  3861. api_sysinfo.addData('dictionaryTree', {
  3862. // "type": "list",
  3863. "key": "haocaifenlei",
  3864. "name": selectedItem.name,
  3865. "parent": selectedItem.id,
  3866. "value": selectedItem.name,
  3867. "deleted": false,
  3868. "level": 1
  3869. }).then(function (data) {
  3870. // $scope.haocainame.name = data.list;
  3871. api_sysinfo.addData('dictionaryTree', {
  3872. // "type": "list",
  3873. "key": "pinpai",
  3874. "name": selectedItem.model,
  3875. "parent": data.id,
  3876. "value": selectedItem.model,
  3877. "deleted": false,
  3878. "level": 2
  3879. }).then(function (data) {
  3880. // $scope.haocainame = data.list;
  3881. })
  3882. api_sysinfo.addData({
  3883. // "type": "list",
  3884. "key": "guige",
  3885. "name": selectedItem.Specifications,
  3886. "parent": data.id,
  3887. "value": selectedItem.Specifications,
  3888. "deleted": false,
  3889. "level": 2
  3890. }).then(function (data) {
  3891. // $scope.haocainame = data.list;
  3892. })
  3893. })
  3894. // $scope.myData3.push(selectedItem);
  3895. // for (var i = 0; i < $scope.myData3.length; i++) {
  3896. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3897. // }
  3898. // $scope.model.applicationForm.consumables = $scope.myData3;
  3899. $scope.myData3all.push(selectedItem);
  3900. for (var i = 0; i < $scope.myData3all.length; i++) {
  3901. $scope.myData3all[i]['item'] = i + 1
  3902. }
  3903. // $scope.model.consumables = $scope.myDataone;
  3904. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3905. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3906. $scope.model.applicationForm.consumables = $scope.myData3all;
  3907. })
  3908. }
  3909. $scope.haocaiadd = function () {
  3910. event.preventDefault();
  3911. var modalInstance = $modal.open({
  3912. templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
  3913. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  3914. $scope.haocainame = [];
  3915. $scope.pinpai = [];
  3916. $scope.guige = [];
  3917. $scope.consumptive = {};
  3918. $scope.consumpall = {};
  3919. $scope.title = "添加耗材";
  3920. api_wechatfile.getDictionary({
  3921. "key": "haocaifenlei",
  3922. "type": "tree"
  3923. }).then(function (data) {
  3924. $scope.haocainame = data;
  3925. })
  3926. $scope.clearNoNum = function (obj, attr) {
  3927. //先把非数字的都替换掉,除了数字和.
  3928. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3929. //必须保证第一个为数字而不是.
  3930. obj[attr] = obj[attr].replace(/^\./g, "");
  3931. //保证只有出现一个.而没有多个.
  3932. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3933. //保证.只出现一次,而不能出现两次以上
  3934. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3935. //小于最大值
  3936. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3937. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3938. // obj[attr] = '';
  3939. // }
  3940. }
  3941. $scope.onChange = function (parent) {
  3942. $scope.consumptive.model = {};
  3943. $scope.consumptive.Specifications = {};
  3944. api_wechatfile.getDictionaryForList({
  3945. "key": "pinpai",
  3946. "parent": parent.id
  3947. }).then(function (data) {
  3948. $scope.pinpai = data;
  3949. })
  3950. api_wechatfile.getDictionaryForList({
  3951. "key": "guige",
  3952. "parent": parent.id
  3953. }).then(function (data) {
  3954. $scope.guige = data;
  3955. })
  3956. }
  3957. $scope.addhaocai = function () {
  3958. $modalInstance.dismiss('cancel');
  3959. scope.haocaiopen($scope.consumptive);
  3960. }
  3961. $scope.ok = function (item) {
  3962. var items = {};
  3963. var submittrue = true;
  3964. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3965. items = {
  3966. "modelid": item.model.id,
  3967. "nameid": item.name.id,
  3968. "Specificationsid": item.Specifications.id,
  3969. "name": item.name.name,
  3970. "model": item.model.name,
  3971. "Specifications": item.Specifications.name,
  3972. "sum": item.sum
  3973. }
  3974. angular.forEach(scope.myData3all, function (itemsdata) {
  3975. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  3976. submittrue = false;
  3977. }
  3978. })
  3979. if (submittrue) {
  3980. $modalInstance.close(items);
  3981. } else {
  3982. SweetAlert.swal({
  3983. title: "该耗材已有添加",
  3984. text: "请检查数据然后提交!",
  3985. type: "error"
  3986. });
  3987. }
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "数据填写不完整!",
  3991. text: "请检查数据然后提交!",
  3992. type: "error"
  3993. });
  3994. }
  3995. // var isold = false;
  3996. // if (item.name && item.model && item.Specifications && item.sum) {
  3997. // for (var i = 0; i < scope.myData3all.length; i++) {
  3998. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  3999. // isold = true;
  4000. // }
  4001. // }
  4002. // if (isold) {
  4003. // SweetAlert.swal({
  4004. // title: "该耗材已添加!",
  4005. // text: "请不要重复添加耗材!",
  4006. // type: "error"
  4007. // });
  4008. // } else {
  4009. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4010. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4011. // $scope.consumpall.sum = item.sum;
  4012. // delete $scope.consumpall.brandModel;
  4013. // delete $scope.consumpall.specification;
  4014. // $modalInstance.close($scope.consumpall);
  4015. // }
  4016. // } else {
  4017. // SweetAlert.swal({
  4018. // title: "数据填写不完整!",
  4019. // text: "请检查数据然后提交!",
  4020. // type: "error"
  4021. // });
  4022. // }
  4023. };
  4024. $scope.cancel = function () {
  4025. $modalInstance.dismiss('cancel');
  4026. };
  4027. },
  4028. size: 'sm',
  4029. resolve: {
  4030. scope: function () {
  4031. return $scope;
  4032. }
  4033. }
  4034. });
  4035. modalInstance.result.then(function (selectedItem) {
  4036. $scope.myData3all.push(selectedItem);
  4037. for (var i = 0; i < $scope.myData3all.length; i++) {
  4038. $scope.myData3all[i]['item'] = i + 1
  4039. }
  4040. // $scope.model.consumables = $scope.myDataone;
  4041. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  4042. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  4043. $scope.model.applicationForm.consumables = $scope.myData3all;
  4044. })
  4045. }
  4046. $scope.onDblClick = function (data, event) {
  4047. $scope.selectButtonClick(data, event);
  4048. };
  4049. // $scope.memoryfilterDatahao = {
  4050. // "idx": 0,
  4051. // "sum": 10,
  4052. // }
  4053. // $scope.loadData = function(filterData) {};
  4054. // $scope.title = title;
  4055. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4056. $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
  4057. }
  4058. }]
  4059. });
  4060. //归还设备耗材tab
  4061. formlyConfigProvider.setType({
  4062. name: 'ui-cmdbreturntab',
  4063. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
  4064. wrapper: ['bootstrapHasError'],
  4065. defaultOptions: function (options, $scope) {
  4066. return {
  4067. templateOptions: {
  4068. // checkform: function(options) {
  4069. // if (options.model.requester) {
  4070. // options.value(options.model.requester);
  4071. // }
  4072. // },
  4073. }
  4074. };
  4075. },
  4076. controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function ($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
  4077. var setAllInactive = function () {
  4078. angular.forEach($scope.workspaces, function (workspace) {
  4079. workspace.active = false;
  4080. });
  4081. };
  4082. $scope.memoryfilterData = {
  4083. "idx": 0,
  4084. "sum": 10,
  4085. }
  4086. //添加
  4087. var addNewWorkspace = function (name, contentUrl) {
  4088. var id = $scope.workspaces.length + 1;
  4089. $scope.workspaces.push({
  4090. id: id,
  4091. name: name,
  4092. active: true,
  4093. contentUrl: 'main/html/content.html'
  4094. });
  4095. };
  4096. $scope.workspaces = [{
  4097. id: 1,
  4098. name: "归还设备",
  4099. active: true,
  4100. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4101. },
  4102. {
  4103. id: 2,
  4104. name: "归还耗材",
  4105. active: true,
  4106. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4107. }
  4108. ];
  4109. $scope.addWorkspace = function (contentUrl, name) {
  4110. setAllInactive();
  4111. addNewWorkspace(name, contentUrl);
  4112. };
  4113. // $rootScope.addWorkspace = $scope.addWorkspace;
  4114. $scope.close = function (idNumber) {
  4115. var index = 0; //记录当前元素下标
  4116. angular.forEach($scope.workspaces, function (workspace) {
  4117. if (workspace.id === idNumber) {
  4118. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4119. }
  4120. index++;
  4121. });
  4122. };
  4123. $scope.memoryfilterDataguishe = {
  4124. "idx": 0,
  4125. "sum": 10,
  4126. }
  4127. //grid1
  4128. $scope.langs = i18nService.getAllLangs();
  4129. $scope.lang = 'zh-cn';
  4130. i18nService.setCurrentLang($scope.lang);
  4131. $scope.gridOptions1 = {};
  4132. $scope.gridOptions1.data = 'myData1';
  4133. $scope.gridOptions1.enableColumnResizing = true;
  4134. $scope.gridOptions1.enableFiltering = false;
  4135. $scope.gridOptions1.enableGridMenu = false;
  4136. $scope.gridOptions1.showGridFooter = true;
  4137. $scope.gridOptions1.showColumnFooter = false;
  4138. $scope.gridOptions1.fastWatch = true;
  4139. $scope.gridOptions1.useExternalFiltering = true;
  4140. $scope.gridOptions1.useExternalPagination = true;
  4141. $scope.gridOptions1.paginationPageSizes = [10];
  4142. $scope.gridOptions1.paginationPageSize = 10;
  4143. $scope.gridOptions1.multiSelect = false;
  4144. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4145. $scope.gridOptions1.columnDefs = [{
  4146. name: 'item',
  4147. displayName: '序号',
  4148. width: 120
  4149. },
  4150. {
  4151. name: 'props.hw_cifilterClassic',
  4152. displayName: '设备类型',
  4153. width: 150,
  4154. enableFiltering: false
  4155. },
  4156. {
  4157. name: 'props.hw_mingcheng',
  4158. displayName: '设备名称',
  4159. width: 180,
  4160. enableFiltering: false
  4161. },
  4162. {
  4163. name: 'uuid',
  4164. displayName: '设备编号',
  4165. width: 180,
  4166. enableFiltering: false
  4167. },
  4168. {
  4169. name: 'props.hw_state',
  4170. width: 150,
  4171. displayName: '状态',
  4172. enableFiltering: false
  4173. },
  4174. {
  4175. name: '操作',
  4176. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4177. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  4178. '</div></div>',
  4179. enableFiltering: false
  4180. },
  4181. ];
  4182. // $scope.selectButtonClick
  4183. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4184. $scope.gridApi = gridApi;
  4185. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4186. // var filtersData = $scope.memoryfilterData;
  4187. // filtersData.idx = newPage - 1;
  4188. // filtersData.sum = pageSize;
  4189. // $scope.loadData(filtersData);
  4190. $scope.memoryfilterDataguishe.idx = newPage - 1;
  4191. $scope.memoryfilterDataguishe.sum = pageSize;
  4192. $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
  4193. });
  4194. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4195. $scope.selected.items = data.entity;
  4196. //console.log(data);
  4197. });
  4198. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4199. $scope.selected.items = data.entity;
  4200. //console.log(data);
  4201. });
  4202. gridApi.core.on.filterChanged($scope, function () {
  4203. // var grid = this.grid;
  4204. // var filtersData = {
  4205. // idx: 0,
  4206. // sum: 20,
  4207. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4208. // };
  4209. // angular.forEach(grid.columns, function(item) {
  4210. // if (item.enableFiltering) {
  4211. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4212. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4213. // if (angular.isUndefined(filtersData['user'])) {
  4214. // filtersData['user'] = {};
  4215. // }
  4216. // filtersData['user'][item.field] = item.filters[0].term;
  4217. // }
  4218. // }
  4219. // });
  4220. // $scope.memoryfilterData = filtersData;
  4221. // $scope.loadData(filtersData);
  4222. });
  4223. };
  4224. $scope.changegu = function (item) {
  4225. event.preventDefault();
  4226. var modalInstance = $modal.open({
  4227. templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
  4228. controller: function ($scope, $modalInstance) {
  4229. $scope.title = "修改设备状态";
  4230. $scope.hw_state = {};;
  4231. if (item.status) {
  4232. $scope.hw_state.name = item.hw_state;
  4233. }
  4234. // $scope.consumptive = item;
  4235. $scope.stateshe = [{
  4236. "id": 2,
  4237. "name": "在库"
  4238. }, {
  4239. "id": 4,
  4240. "name": "报修"
  4241. }, {
  4242. "id": 3,
  4243. "name": "报废"
  4244. }]
  4245. $scope.ok = function (item) {
  4246. $modalInstance.close($scope.hw_state);
  4247. };
  4248. $scope.cancel = function () {
  4249. $modalInstance.dismiss('cancel');
  4250. };
  4251. },
  4252. size: 'sm'
  4253. });
  4254. modalInstance.result.then(function (selectedItem) {
  4255. angular.forEach($scope.myData1, function (items, index) {
  4256. if (items.id == item.id) {
  4257. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  4258. }
  4259. })
  4260. $scope.model.assets = $scope.myData1;
  4261. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
  4262. })
  4263. }
  4264. $scope.onDblClick = function (data, event) {
  4265. $scope.selectButtonClick(data, event);
  4266. };
  4267. $scope.memoryfilterData = {
  4268. "idx": 0,
  4269. "sum": 10,
  4270. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4271. }
  4272. // $scope.myData = {};
  4273. $scope.loadData = function (filterData) { };
  4274. // $scope.title = title;
  4275. $scope.loadData({
  4276. idx: 0,
  4277. sum: 10,
  4278. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4279. });
  4280. $scope.selected = {
  4281. items: []
  4282. };
  4283. $scope.myData2 = [];
  4284. $scope.consumptive = {};
  4285. $scope.myDataguibeiall = [];
  4286. $scope.haocaiopen = function (items) {
  4287. event.preventDefault();
  4288. var modalInstance = $modal.open({
  4289. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  4290. controller: function ($scope, $modalInstance, SweetAlert, api_wechatfile, api_sysinfo) {
  4291. $scope.consumptive = {};
  4292. $scope.title = "新增耗材";
  4293. if (items.name) {
  4294. $scope.consumptive.name = items.name.name;
  4295. }
  4296. $scope.ok = function (item) {
  4297. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4298. $modalInstance.close(item);
  4299. } else {
  4300. SweetAlert.swal({
  4301. title: "数据填写不完整!",
  4302. text: "请检查数据然后提交!",
  4303. type: "error"
  4304. });
  4305. }
  4306. };
  4307. $scope.cancel = function () {
  4308. $modalInstance.dismiss('cancel');
  4309. };
  4310. },
  4311. size: 'sm'
  4312. });
  4313. modalInstance.result.then(function (selectedItem) {
  4314. api_sysinfo.addData({
  4315. "type": "list",
  4316. "key": "haocaifenlei",
  4317. "name": selectedItem.name,
  4318. "parent": selectedItem.id,
  4319. "value": "1"
  4320. }).then(function (data) {
  4321. // $scope.haocainame.name = data.list;
  4322. api_wechatfile.addDictionary({
  4323. "type": "list",
  4324. "key": "pinpai",
  4325. "name": selectedItem.model,
  4326. "parent": data.id,
  4327. "value": "1"
  4328. }).then(function (data) {
  4329. // $scope.haocainame = data.list;
  4330. })
  4331. api_wechatfile.addDictionary({
  4332. "type": "list",
  4333. "key": "guige",
  4334. "name": selectedItem.Specifications,
  4335. "parent": data.id,
  4336. "value": "1"
  4337. }).then(function (data) {
  4338. // $scope.haocainame = data.list;
  4339. })
  4340. })
  4341. $scope.myData2.push(selectedItem);
  4342. for (var i = 0; i < $scope.myData2.length; i++) {
  4343. $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4344. }
  4345. // $scope.model.applicationForm.consumables = $scope.myData2;
  4346. angular.forEach($scope.myDataguibeiall, function (items, index) {
  4347. if (items.id == selectedItem.id) {
  4348. $scope.myDataguibeiall.splice(index, 1);
  4349. }
  4350. })
  4351. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
  4352. $scope.model.consumables = $scope.myDataguibeiall;
  4353. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4354. $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
  4355. })
  4356. }
  4357. //grid2
  4358. $scope.langs = i18nService.getAllLangs();
  4359. $scope.lang = 'zh-cn';
  4360. i18nService.setCurrentLang($scope.lang);
  4361. $scope.gridOptions2 = {};
  4362. $scope.gridOptions2.data = 'myData2';
  4363. $scope.gridOptions2.enableColumnResizing = true;
  4364. $scope.gridOptions2.enableFiltering = false;
  4365. $scope.gridOptions2.enableGridMenu = false;
  4366. $scope.gridOptions2.showGridFooter = true;
  4367. $scope.gridOptions2.showColumnFooter = false;
  4368. $scope.gridOptions2.fastWatch = true;
  4369. $scope.gridOptions2.useExternalFiltering = true;
  4370. $scope.gridOptions2.useExternalPagination = true;
  4371. $scope.gridOptions2.paginationPageSizes = [10];
  4372. $scope.gridOptions2.paginationPageSize = 10;
  4373. $scope.gridOptions2.multiSelect = false;
  4374. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4375. $scope.modelcons = {};
  4376. $scope.modelass = {};
  4377. $scope.myData2all = [];
  4378. $scope.myData1all = [];
  4379. $scope.memoryfilterDatagui = {
  4380. "idx": 0,
  4381. "sum": 10
  4382. }
  4383. setInterval(function () {
  4384. if ($scope.model.assets) {
  4385. if ($scope.model.assets != $scope.modelass && typeof ($scope.model.assets) == 'string') {
  4386. $scope.modelass = $scope.model.assets;
  4387. if (JSON.stringify($scope.model.assets) == "{}") {
  4388. $scope.model.assets = []
  4389. } else {
  4390. $scope.model.assets = JSON.parse($scope.model.assets);
  4391. }
  4392. // $scope.myData1 = $scope.model.assets;
  4393. // for (var i = 0; i < $scope.myData1.length; i++) {
  4394. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4395. // }
  4396. $scope.myData1all = $scope.model.assets;
  4397. for (var i = 0; i < $scope.myData1all.length; i++) {
  4398. $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4399. }
  4400. $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
  4401. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
  4402. }
  4403. }
  4404. if ($scope.model.consumables) {
  4405. if ($scope.model.consumables != $scope.modelcons && typeof ($scope.model.consumables) == 'string') {
  4406. $scope.modelass = $scope.model.consumables;
  4407. if (JSON.stringify($scope.model.consumables) == "{}") {
  4408. $scope.model.consumables = [];
  4409. } else {
  4410. $scope.model.consumables = JSON.parse($scope.model.consumables);
  4411. }
  4412. // $scope.myData2 = $scope.model.consumables;
  4413. // for (var i = 0; i < $scope.myData2.length; i++) {
  4414. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4415. // }
  4416. $scope.myData2all = $scope.model.consumables;
  4417. for (var i = 0; i < $scope.myData2all.length; i++) {
  4418. $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4419. }
  4420. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4421. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
  4422. // $scope.model.consumables = $scope.myData2all;
  4423. }
  4424. }
  4425. }, 100);
  4426. $scope.gridOptions2.columnDefs = [{
  4427. name: 'item',
  4428. displayName: '序号',
  4429. width: 120
  4430. },
  4431. {
  4432. name: 'name',
  4433. displayName: '耗材名称',
  4434. width: 180,
  4435. enableFiltering: false
  4436. },
  4437. {
  4438. name: 'model',
  4439. displayName: '品牌/型号',
  4440. width: 180,
  4441. enableFiltering: false
  4442. },
  4443. {
  4444. name: 'Specifications',
  4445. displayName: '规格',
  4446. width: 150,
  4447. enableFiltering: false
  4448. },
  4449. {
  4450. name: 'sum',
  4451. width: 150,
  4452. displayName: '数量',
  4453. enableFiltering: false
  4454. },
  4455. {
  4456. name: '操作',
  4457. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4458. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4459. '</div></div>',
  4460. enableFiltering: false
  4461. },
  4462. ];
  4463. // $scope.selectButtonClick
  4464. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4465. $scope.gridApi = gridApi;
  4466. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4467. // var filtersData = $scope.memoryfilterDatagui;
  4468. // filtersData.idx = newPage - 1;
  4469. // filtersData.sum = pageSize;
  4470. $scope.memoryfilterDatagui.idx = newPage - 1;
  4471. $scope.memoryfilterDatagui.sum = pageSize;
  4472. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4473. });
  4474. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4475. $scope.selected.items = data.entity;
  4476. //console.log(data);
  4477. });
  4478. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4479. $scope.selected.items = data.entity;
  4480. //console.log(data);
  4481. });
  4482. gridApi.core.on.filterChanged($scope, function () {
  4483. var grid = this.grid;
  4484. var filtersData = {
  4485. idx: 0,
  4486. sum: 10,
  4487. };
  4488. angular.forEach(grid.columns, function (item) {
  4489. if (item.enableFiltering) {
  4490. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4491. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4492. if (angular.isUndefined(filtersData['user'])) {
  4493. filtersData['user'] = {};
  4494. }
  4495. filtersData['user'][item.field] = item.filters[0].term;
  4496. }
  4497. }
  4498. });
  4499. $scope.memoryfilterData = filtersData;
  4500. $scope.loadData(filtersData);
  4501. });
  4502. };
  4503. $scope.changecai = function (item) {
  4504. event.preventDefault();
  4505. var modalInstance = $modal.open({
  4506. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4507. controller: function ($scope, $modalInstance) {
  4508. $scope.title = "修改耗材数量";
  4509. $scope.consumptive = angular.copy(item);
  4510. // $scope.consumptive = item;
  4511. $scope.maxsum = item.inventoryNum;
  4512. $scope.clearNoNum = function (obj, attr) {
  4513. //先把非数字的都替换掉,除了数字和.
  4514. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4515. //必须保证第一个为数字而不是.
  4516. obj[attr] = obj[attr].replace(/^\./g, "");
  4517. //保证只有出现一个.而没有多个.
  4518. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4519. //保证.只出现一次,而不能出现两次以上
  4520. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4521. //小于最大值
  4522. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4523. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4524. // obj[attr] = '';
  4525. // }
  4526. }
  4527. $scope.ok = function () {
  4528. $modalInstance.close($scope.consumptive);
  4529. };
  4530. $scope.cancel = function () {
  4531. $modalInstance.dismiss('cancel');
  4532. };
  4533. },
  4534. size: 'sm'
  4535. });
  4536. modalInstance.result.then(function (selectedItem) {
  4537. angular.forEach($scope.myData2all, function (items, index) {
  4538. // if (items.id == selectedItem.id) {
  4539. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  4540. angular.extend($scope.myData2all[index], selectedItem)
  4541. }
  4542. })
  4543. // $scope.model.consumables = $scope.myData2;
  4544. // $scope.myData2 = $scope.model.consumables;
  4545. // $scope.myData2all.push(selectedItem);
  4546. // for (var i = 0; i < $scope.myData2all.length; i++) {
  4547. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4548. // }
  4549. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4550. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4551. $scope.model.consumables = $scope.myData2all;
  4552. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4553. })
  4554. }
  4555. $scope.interceptMydata = function (mydate, idx, sum) {
  4556. return mydate.slice(idx * sum, (idx + 1) * sum)
  4557. }
  4558. $scope.haocaiadd = function () {
  4559. event.preventDefault();
  4560. var modalInstance = $modal.open({
  4561. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  4562. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
  4563. $scope.haocainame = [];
  4564. $scope.pinpai = [];
  4565. $scope.guige = [];
  4566. $scope.consumptive = {};
  4567. $scope.consumptiveall = {};
  4568. $scope.title = "添加耗材";
  4569. api_wechatfile.getDictionaryForList({
  4570. "key": "haocaifenlei"
  4571. }).then(function (data) {
  4572. $scope.haocainame = data;
  4573. })
  4574. $scope.clearNoNum = function (obj, attr) {
  4575. //先把非数字的都替换掉,除了数字和.
  4576. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4577. //必须保证第一个为数字而不是.
  4578. obj[attr] = obj[attr].replace(/^\./g, "");
  4579. //保证只有出现一个.而没有多个.
  4580. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4581. //保证.只出现一次,而不能出现两次以上
  4582. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4583. //小于最大值
  4584. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4585. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4586. obj[attr] = '';
  4587. }
  4588. }
  4589. $scope.onChange = function (parent) {
  4590. $scope.consumptive.model = {};
  4591. $scope.consumptive.Specifications = {};
  4592. api_wechatfile.getDictionaryForList({
  4593. "key": "pinpai",
  4594. "parent": parent.id
  4595. }).then(function (data) {
  4596. $scope.pinpai = data;
  4597. })
  4598. api_wechatfile.getDictionaryForList({
  4599. "key": "guige",
  4600. "parent": parent.id
  4601. }).then(function (data) {
  4602. $scope.guige = data;
  4603. })
  4604. }
  4605. // $scope.onChangesum = function(item) {
  4606. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  4607. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  4608. // $scope.consumptiveall = data1;
  4609. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  4610. // // if (data.list && data.list.length != 0) {
  4611. // // var myData = data.list;
  4612. // // $scope.consumptiveall = myData[0];
  4613. // // $scope.maxsum = myData[0].inventoryNum;
  4614. // // } else if (data.list && data.list.length == 0) {
  4615. // // SweetAlert.swal({
  4616. // // title: "库存数据存在问题!",
  4617. // // text: "请检查库存数据!",
  4618. // // type: "error"
  4619. // // });
  4620. // // }
  4621. // // });
  4622. // }
  4623. // }
  4624. $scope.addhaocai = function () {
  4625. $modalInstance.dismiss('cancel');
  4626. scope.haocaiopen($scope.consumptive);
  4627. }
  4628. $scope.ok = function (item) {
  4629. var submittrue = true;
  4630. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4631. var data = {
  4632. "modelid": item.model.id,
  4633. "nameid": item.name.id,
  4634. "Specificationsid": item.Specifications.id,
  4635. "name": item.name.name,
  4636. "model": item.model.name,
  4637. "Specifications": item.Specifications.name,
  4638. "sum": item.sum
  4639. }
  4640. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4641. // $modalInstance.close(data);
  4642. angular.forEach(scope.myData2all, function (itemsdata) {
  4643. // if (item.model.id == itemsdata.id) {
  4644. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  4645. submittrue = false;
  4646. }
  4647. })
  4648. if (submittrue) {
  4649. $modalInstance.close(data);
  4650. } else {
  4651. SweetAlert.swal({
  4652. title: "该耗材已有添加",
  4653. text: "请检查数据然后提交!",
  4654. type: "error"
  4655. });
  4656. }
  4657. } else {
  4658. SweetAlert.swal({
  4659. title: "数据填写不完整!",
  4660. text: "请检查数据然后提交!",
  4661. type: "error"
  4662. });
  4663. }
  4664. };
  4665. $scope.cancel = function () {
  4666. $modalInstance.dismiss('cancel');
  4667. };
  4668. },
  4669. size: 'sm',
  4670. resolve: {
  4671. scope: function () {
  4672. return $scope;
  4673. }
  4674. }
  4675. });
  4676. modalInstance.result.then(function (selectedItem) {
  4677. // $scope.myData2.push(selectedItem);
  4678. // for (var i = 0; i < $scope.myData2.length; i++) {
  4679. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4680. // }
  4681. // $scope.model.consumables = $scope.myData2;
  4682. $scope.myData2all.push(selectedItem);
  4683. for (var i = 0; i < $scope.myData2all.length; i++) {
  4684. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4685. $scope.myData2all[i]['item'] = i + 1
  4686. }
  4687. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4688. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4689. $scope.model.consumables = $scope.myData2all;
  4690. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4691. })
  4692. }
  4693. $scope.onDblClick = function (data, event) {
  4694. $scope.selectButtonClick(data, event);
  4695. };
  4696. $scope.memoryfilterData = {
  4697. "idx": 0,
  4698. "sum": 20,
  4699. "user": {
  4700. "roledata": {
  4701. "rolecode": "roleset"
  4702. },
  4703. "selectType": "1"
  4704. }
  4705. }
  4706. $scope.myData = {};
  4707. $scope.loadData = function (filterData) { };
  4708. // $scope.title = title;
  4709. $scope.loadData({
  4710. idx: 0,
  4711. sum: 20,
  4712. "user": {
  4713. "roledata": {
  4714. "rolecode": "roleset"
  4715. },
  4716. "selectType": "1"
  4717. }
  4718. });
  4719. $scope.selected = {
  4720. items: {}
  4721. };
  4722. }]
  4723. });
  4724. //tab 列表
  4725. formlyConfigProvider.setType({
  4726. name: 'ui-cmdbtab',
  4727. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
  4728. wrapper: ['bootstrapHasError'],
  4729. defaultOptions: function (options, $scope) {
  4730. return {
  4731. templateOptions: {}
  4732. };
  4733. },
  4734. controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  4735. $scope.memoryfilterDatashe = {
  4736. "idx": 0,
  4737. "sum": 10
  4738. }
  4739. $scope.myDataoneall = [];
  4740. var setAllInactive = function () {
  4741. angular.forEach($scope.workspaces, function (workspace) {
  4742. workspace.active = false;
  4743. });
  4744. };
  4745. //添加
  4746. var addNewWorkspace = function (name, contentUrl) {
  4747. var id = $scope.workspaces.length + 1;
  4748. $scope.workspaces.push({
  4749. id: id,
  4750. name: name,
  4751. active: true,
  4752. contentUrl: 'main/html/content.html'
  4753. });
  4754. };
  4755. //关闭
  4756. $scope.remove = function (closedata) {
  4757. event.preventDefault();
  4758. angular.forEach($scope.workspaces, function (item, index) {
  4759. if (closedata.id == item.id) {
  4760. if (closedata.id == 1) {
  4761. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  4762. } else {
  4763. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  4764. }
  4765. $scope.workspaces.splice(index, 1);
  4766. }
  4767. })
  4768. }
  4769. $scope.workspaces = [];
  4770. $scope.options.templateOptions.getpush = function (item) {
  4771. $scope.workspaces = [];
  4772. if (item.gu) {
  4773. $scope.workspaces.push({
  4774. id: 1,
  4775. name: "领用设备",
  4776. active: true,
  4777. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4778. })
  4779. }
  4780. if (item.hao) {
  4781. $scope.workspaces.push({
  4782. id: 2,
  4783. name: "领用耗材",
  4784. active: true,
  4785. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4786. })
  4787. }
  4788. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4789. };
  4790. $scope.addWorkspace = function (contentUrl, name) {
  4791. setAllInactive();
  4792. addNewWorkspace(name, contentUrl);
  4793. };
  4794. // $rootScope.addWorkspace = $scope.addWorkspace;
  4795. // $scope.remove = function(idNumber) {
  4796. // var index = 0; //记录当前元素下标
  4797. // angular.forEach($scope.workspaces, function(workspace) {
  4798. // if (workspace.id === idNumber.id) {
  4799. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4800. // }
  4801. // index++;
  4802. // });
  4803. // };
  4804. // setInterval(function() {
  4805. // if ($scope.model.assets) {
  4806. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4807. // $scope.modelass = $scope.model.assets;
  4808. // if (JSON.stringify($scope.model.assets) == "{}") {
  4809. // $scope.model.assets = []
  4810. // } else {
  4811. // $scope.model.assets = JSON.parse($scope.model.assets);
  4812. // }
  4813. // $scope.myDatalingbeiall = $scope.model.assets;
  4814. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4815. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4816. // }
  4817. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4818. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4819. // }
  4820. // }
  4821. // if ($scope.model.consumables) {
  4822. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4823. // $scope.modelass = $scope.model.consumables;
  4824. // if (JSON.stringify($scope.model.consumables) == "{}") {
  4825. // $scope.model.consumables = [];
  4826. // } else {
  4827. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  4828. // }
  4829. // $scope.myDatalingbeiall = $scope.model.consumables;
  4830. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4831. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4832. // }
  4833. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  4834. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4835. // // $scope.model.consumables = $scope.myData2all;
  4836. // }
  4837. // }
  4838. // }, 100);
  4839. //grid1
  4840. $scope.langs = i18nService.getAllLangs();
  4841. $scope.lang = 'zh-cn';
  4842. i18nService.setCurrentLang($scope.lang);
  4843. $scope.gridOptions1 = {};
  4844. $scope.gridOptions1.data = 'myDatalingbei';
  4845. $scope.gridOptions1.enableColumnResizing = true;
  4846. $scope.gridOptions1.enableFiltering = false;
  4847. $scope.gridOptions1.enableGridMenu = false;
  4848. $scope.gridOptions1.showGridFooter = true;
  4849. $scope.gridOptions1.showColumnFooter = false;
  4850. $scope.gridOptions1.fastWatch = true;
  4851. $scope.gridOptions1.useExternalFiltering = true;
  4852. $scope.gridOptions1.useExternalPagination = true;
  4853. $scope.gridOptions1.paginationPageSizes = [10];
  4854. $scope.gridOptions1.paginationPageSize = 10;
  4855. $scope.gridOptions1.multiSelect = false;
  4856. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4857. $scope.gridOptions1.columnDefs = [{
  4858. name: 'item',
  4859. displayName: '序号',
  4860. width: 120
  4861. },
  4862. {
  4863. name: 'props.hw_cifilterClassic',
  4864. displayName: '设备类型',
  4865. width: 150,
  4866. enableFiltering: false
  4867. },
  4868. {
  4869. name: 'props.hw_mingcheng',
  4870. displayName: '设备名称',
  4871. width: 100,
  4872. enableFiltering: false
  4873. },
  4874. {
  4875. name: 'uuid',
  4876. displayName: '设备编号',
  4877. enableFiltering: false
  4878. }
  4879. ];
  4880. $scope.myDatalingbeiall = [];
  4881. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4882. $scope.gridApi = gridApi;
  4883. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4884. // var filtersData = $scope.memoryfilterData;
  4885. // filtersData.idx = newPage - 1;
  4886. // filtersData.sum = pageSize;
  4887. // $scope.loadData(filtersData);
  4888. $scope.memoryfilterDatashe.idx = newPage - 1;
  4889. $scope.memoryfilterDatashe.sum = pageSize;
  4890. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
  4891. });
  4892. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4893. $scope.selected.items = data.entity;
  4894. //console.log(data);
  4895. });
  4896. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4897. $scope.selected.items = data.entity;
  4898. //console.log(data);
  4899. });
  4900. gridApi.core.on.filterChanged($scope, function () {
  4901. var grid = this.grid;
  4902. var filtersData = {
  4903. idx: 0,
  4904. sum: 20,
  4905. "user": {
  4906. "roledata": {
  4907. "rolecode": "roleset"
  4908. },
  4909. "selectType": "1"
  4910. }
  4911. };
  4912. angular.forEach(grid.columns, function (item) {
  4913. if (item.enableFiltering) {
  4914. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4915. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4916. if (angular.isUndefined(filtersData['user'])) {
  4917. filtersData['user'] = {};
  4918. }
  4919. filtersData['user'][item.field] = item.filters[0].term;
  4920. }
  4921. }
  4922. });
  4923. $scope.memoryfilterDatashe = filtersData;
  4924. // $scope.loadData(filtersData);
  4925. });
  4926. };
  4927. $scope.interceptMydata = function (mydate, idx, sum) {
  4928. return mydate.slice(idx * sum, (idx + 1) * sum)
  4929. }
  4930. $scope.removeshebei = function (item) {
  4931. event.preventDefault();
  4932. var modalInstance = $modal.open({
  4933. templateUrl: 'assets/views/delete.html',
  4934. controller: function ($scope, $modalInstance, scope) {
  4935. $scope.title = '设备移除';
  4936. $scope.connect = '确定要移除此设备?';
  4937. $scope.consumptive = scope.selected.items;
  4938. $scope.ok = function () {
  4939. $modalInstance.close($scope.consumptive);
  4940. };
  4941. $scope.cancel = function () {
  4942. $modalInstance.dismiss('cancel');
  4943. };
  4944. },
  4945. size: 'sm',
  4946. resolve: {
  4947. scope: function () {
  4948. return $scope;
  4949. },
  4950. }
  4951. });
  4952. modalInstance.result.then(function (selectedItem) {
  4953. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  4954. if (items.id == selectedItem.id) {
  4955. $scope.myDatalingbeiall.splice(index, 1);
  4956. }
  4957. })
  4958. // $scope.myData3.push(selectedItem);
  4959. $scope.model.consumables = $scope.myDatalingbeiall;
  4960. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
  4961. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4962. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4963. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
  4964. }
  4965. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4966. })
  4967. }
  4968. $scope.addshebei = function () {
  4969. event.preventDefault();
  4970. var modalInstance = $modal.open({
  4971. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  4972. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
  4973. $scope.langs = i18nService.getAllLangs();
  4974. $scope.lang = 'zh-cn';
  4975. i18nService.setCurrentLang($scope.lang);
  4976. $scope.gridOptions = {};
  4977. $scope.gridOptions.data = 'myDatatwo';
  4978. $scope.gridOptions.enableColumnResizing = true;
  4979. $scope.gridOptions.enableFiltering = false;
  4980. $scope.gridOptions.enableGridMenu = false;
  4981. $scope.gridOptions.showGridFooter = true;
  4982. $scope.gridOptions.showColumnFooter = false;
  4983. $scope.gridOptions.fastWatch = true;
  4984. $scope.gridOptions.useExternalFiltering = true;
  4985. $scope.gridOptions.useExternalPagination = true;
  4986. $scope.gridOptions.paginationPageSizes = [10];
  4987. $scope.gridOptions.paginationPageSize = 10;
  4988. $scope.gridOptions.multiSelect = true;
  4989. $scope.gridOptions.rowIdentity = function (row) {
  4990. return row.id;
  4991. };
  4992. $scope.gridOptions.getRowIdentity = function (row) {
  4993. return row.id;
  4994. };
  4995. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4996. $scope.gridOptions.columnDefs = [{
  4997. name: 'item',
  4998. displayName: '序号',
  4999. width: 80,
  5000. enableFiltering: false
  5001. },
  5002. {
  5003. name: 'uuid',
  5004. displayName: '内部编号',
  5005. width: 175
  5006. },
  5007. {
  5008. name: 'props.hw_mingcheng',
  5009. displayName: '资产名称',
  5010. width: 120
  5011. },
  5012. {
  5013. name: 'props.hw_cifilterClassic',
  5014. displayName: '资产类型',
  5015. width: 80,
  5016. enableFiltering: false
  5017. },
  5018. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  5019. {
  5020. name: 'props.hw_state',
  5021. displayName: '资产状态',
  5022. width: 150,
  5023. enableFiltering: false
  5024. },
  5025. {
  5026. name: 'props.hwnw_area',
  5027. displayName: '资产地点',
  5028. width: 130,
  5029. enableFiltering: false
  5030. },
  5031. {
  5032. name: 'createtime',
  5033. displayName: '申请时间',
  5034. enableFiltering: false
  5035. }
  5036. ];
  5037. // $scope.selectButtonClick
  5038. var defaultFilterData = {
  5039. // "assignee":2,
  5040. // "sign":"basehwitndl",
  5041. // "applicationForm": { "hw_state": "在线" },
  5042. "hw_state": "在库",
  5043. "idx": 0,
  5044. "sum": 10
  5045. };
  5046. $scope.memoryfilterData = {
  5047. // "assignee":2,
  5048. // "sign":"basehwitndl",
  5049. // "applicationForm": { "hw_state": "在线" },
  5050. "hw_state": "在库",
  5051. "idx": 0,
  5052. "sum": 10
  5053. }
  5054. $scope.refreshData = function (style, filterData) {
  5055. if (angular.isUndefined(filterData)) {
  5056. filterData = defaultFilterData;
  5057. }
  5058. $scope.myDatatwo = [];
  5059. // $scope.gridOptions['sum']=filterData.sum;
  5060. api_cmdb.query(filterData).then(function (data) {
  5061. // $scope.callsPending--;
  5062. var filterData = $scope.memoryfilterData;
  5063. var myDatatwo = Restangular.stripRestangular(data);
  5064. $scope.gridOptions['totalItems'] = data.total;
  5065. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  5066. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  5067. }
  5068. $scope.myDatatwo = myDatatwo.data.node;
  5069. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  5070. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5071. }
  5072. }, function () { });
  5073. };
  5074. $scope.refreshData('expand-right', defaultFilterData);
  5075. $scope.gridOptions.onRegisterApi = function (gridApi) {
  5076. $scope.gridApi = gridApi;
  5077. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5078. var filtersData = $scope.memoryfilterData;
  5079. filtersData.idx = newPage - 1;
  5080. filtersData.sum = pageSize;
  5081. // $scope.loadData(filtersData);
  5082. $scope.refreshData('expand-right', filtersData);
  5083. //console.log(pageSize);
  5084. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  5085. });
  5086. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  5087. // $scope.selected.items.push(data.entity);
  5088. //console.log(data);
  5089. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  5090. if (scope.isSelected) {
  5091. scope.grid.appScope.selected.items.push(scope.entity)
  5092. } else {
  5093. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  5094. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  5095. scope.grid.appScope.selected.items.splice(i, 1);
  5096. break;
  5097. }
  5098. }
  5099. }
  5100. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  5101. });
  5102. // });
  5103. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  5104. // $scope.selected.items = data.entity;
  5105. //console.log(data);
  5106. var selectitem = [];
  5107. selectitem = angular.copy($scope.selected.items);
  5108. for (var j = 0; j < rows.length; j++) {
  5109. if (rows[j].isSelected == true) {
  5110. selectitem.push(rows[j].entity);
  5111. } else {
  5112. delete selectitem[j];
  5113. // rows.splice(j, 1);
  5114. }
  5115. }
  5116. $scope.selected.items = [];
  5117. for (var i = 0; i < selectitem.length; i++) {
  5118. if (selectitem[i]) {
  5119. $scope.selected.items.push(selectitem[i]);
  5120. }
  5121. }
  5122. });
  5123. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  5124. // // if (row.entity.age > 45) {
  5125. // row.grid.api.selection.selectRow(row.entity); // 选中行
  5126. // // }
  5127. // };
  5128. gridApi.core.on.filterChanged($scope, function () {
  5129. var grid = this.grid;
  5130. var filtersData = {
  5131. idx: 0,
  5132. sum: 10,
  5133. "user": {
  5134. "roledata": {
  5135. "rolecode": "roleset"
  5136. },
  5137. "selectType": "1"
  5138. }
  5139. };
  5140. angular.forEach(grid.columns, function (item) {
  5141. if (item.enableFiltering) {
  5142. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5143. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5144. if (angular.isUndefined(filtersData['user'])) {
  5145. filtersData['user'] = {};
  5146. }
  5147. filtersData['user'][item.field] = item.filters[0].term;
  5148. }
  5149. }
  5150. });
  5151. $scope.memoryfilterData = filtersData;
  5152. // $scope.loadData(filtersData);
  5153. });
  5154. };
  5155. $scope.onDblClick = function (data, event) {
  5156. // $scope.selected.items = data.entity;
  5157. $scope.selectButtonClick(data, event);
  5158. };
  5159. // $scope.loadData = function(filterData) {
  5160. // // console.log("filtersData=111" + JSON.stringify(filterData))
  5161. // items.fetchItems(filterData, APIService).then(function(data) {
  5162. // var myDatatwo = Restangular.stripRestangular(data);
  5163. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  5164. // $scope.myDatatwo = myDatatwo.list;
  5165. // });
  5166. // };
  5167. $scope.title = title;
  5168. //树形图
  5169. var apple_selected, tree, treedata_avm, treedata_geography;
  5170. $scope.my_tree_handler = function (branch) {
  5171. //var _ref;
  5172. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  5173. api_cmdb.query({
  5174. 'sign': classify
  5175. }).then(function (data) {
  5176. var myDatalingbei = Restangular.stripRestangular(data);
  5177. // console.log(myData.data.node);
  5178. if (myDatalingbei.data && myDatalingbei.status == 200) {
  5179. var ret = myDatalingbei.data;
  5180. redrawSvg(myDatalingbei);
  5181. }
  5182. });
  5183. };
  5184. $scope.my_data = [];
  5185. function convertListToTree(data, treeMap) {
  5186. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  5187. var root = null; //Initially set our loop to null
  5188. var parentNode = null;
  5189. //loop over data
  5190. for (var i = 0; i < data.length; i++) {
  5191. var datum = data[i];
  5192. //each node will have children, so let's give it a "children" poperty
  5193. datum.children = [];
  5194. //add an entry for this node to the map so that any future children can
  5195. //lookup the parent
  5196. idToNodeMap[datum.id] = datum;
  5197. //Does this node have a parent?
  5198. if (typeof datum.parent === "undefined" || datum.parent == null) {
  5199. //Doesn't look like it, so this node is the root of the tree
  5200. root = datum;
  5201. treeMap[datum.id] = root;
  5202. } else {
  5203. //This node has a parent, so let's look it up using the id
  5204. parentNode = idToNodeMap[datum.parent.id];
  5205. //We don't need this property, so let's delete it.
  5206. delete datum.parent;
  5207. //Let's add the current node as a child of the parent node.
  5208. parentNode.children.push(datum);
  5209. }
  5210. }
  5211. return root;
  5212. }
  5213. function convertParentToChildList(data) {
  5214. var treeMap = {};
  5215. var list = [];
  5216. convertListToTree(data, treeMap);
  5217. angular.forEach(treeMap, function (item) {
  5218. list.push(item);
  5219. });
  5220. return list;
  5221. }
  5222. $scope.my_tree = tree = {};
  5223. $scope.try_async_load = function () {
  5224. $scope.my_data = [];
  5225. $scope.select_treedata = [];
  5226. $scope.doing_async = true;
  5227. api_configure_data.fetchDataList('ciclassify', {
  5228. 'idx': 0,
  5229. 'sum': 100
  5230. }).then(function (result) {
  5231. //console.log(result['list']);
  5232. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  5233. $scope.doing_async = false;
  5234. // tree.expand_all();
  5235. //console.log(treelist);
  5236. });
  5237. };
  5238. $scope.select_treedata = [];
  5239. $scope.propTypeOptions = [];
  5240. $scope.try_async_load();
  5241. $scope.onFilterremove = function (item) {
  5242. console.log(item)
  5243. }
  5244. $scope.searchdata = {};
  5245. $scope.clear = function () {
  5246. $scope.searchdata = {};
  5247. $scope.cifilter_classic = {};
  5248. $scope.try_async_load();
  5249. var fildata = {
  5250. idx: 0,
  5251. sum: 10,
  5252. 'hw_state': '在库'
  5253. }
  5254. $scope.memoryfilterData = fildata;
  5255. $scope.refreshData('expand-right', fildata);
  5256. }
  5257. $scope.cifilter_classic = {};
  5258. $scope.chiceIncident = function (item) {
  5259. var fildata = defaultFilterData;
  5260. // fildata.applicationForm = {};
  5261. // sign: basehwnwswt
  5262. if (item && item.id) {
  5263. var classify = item.prefix.toLowerCase() + item.sign;
  5264. fildata.sign = classify
  5265. } else {
  5266. delete fildata.sign
  5267. }
  5268. $scope.gridOptions.paginationCurrentPage = 1;
  5269. var transitiondata = angular.copy(item);
  5270. $scope.refreshData('expand-right', fildata);
  5271. }
  5272. $scope.applicadata = [];
  5273. $scope.onFilterCallback = function (item) {
  5274. var tempclassify = item.prefix.toLowerCase() + item.sign;
  5275. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  5276. var myData = Restangular.stripRestangular(data);
  5277. $scope.applicadata = myData[0].form.fields;
  5278. });
  5279. // }
  5280. }
  5281. // $scope.loadData({
  5282. // idx: 0,
  5283. // sum: 10,
  5284. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5285. // });
  5286. $scope.selected = {
  5287. items: []
  5288. };
  5289. $scope.ok = function () {
  5290. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  5291. // onDataCallback($scope.selected.item, parentScope);
  5292. // }
  5293. $modalInstance.close($scope.selected.items);
  5294. };
  5295. $scope.cancel = function () {
  5296. $modalInstance.dismiss('cancel');
  5297. };
  5298. },
  5299. size: 'lg',
  5300. resolve: {
  5301. items: function () {
  5302. return {
  5303. fetchItems: function (filterData, APIService) {
  5304. filterData = filterData || {};
  5305. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  5306. filterData = {
  5307. idx: 0,
  5308. sum: 10,
  5309. "user": {
  5310. "roledata": {
  5311. "rolecode": "roleset"
  5312. },
  5313. "selectType": "1"
  5314. }
  5315. };
  5316. }
  5317. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  5318. }
  5319. };
  5320. },
  5321. title: function () {
  5322. return $scope.options.templateOptions.label;
  5323. },
  5324. Restangular: function () {
  5325. return $scope.options.templateOptions.Restangular;
  5326. },
  5327. APIService: function () {
  5328. return $scope.options.templateOptions.ApiService;
  5329. },
  5330. onDataCallback: function () {
  5331. return $scope.options.templateOptions.callback;
  5332. },
  5333. parentScope: function () {
  5334. return $scope.options.templateOptions.that;
  5335. }
  5336. }
  5337. });
  5338. modalInstance.result.then(function (selectedItem) {
  5339. // console.log(selectedItem);
  5340. // options.value(selectedItem);
  5341. var filterData = $scope.memoryfilterDatashe;
  5342. $scope.myDatalingbeiall = selectedItem;
  5343. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5344. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5345. $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5346. }
  5347. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5348. $scope.model.assets = $scope.myDatalingbeiall;
  5349. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
  5350. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  5351. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  5352. // }
  5353. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  5354. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  5355. // }
  5356. }, function () {
  5357. //console.log('Modal dismissed at: ' + new Date());
  5358. });
  5359. }
  5360. $scope.onDblClick = function (data, event) {
  5361. $scope.selectButtonClick(data, event);
  5362. };
  5363. // $scope.loadData = function(filterData) {};
  5364. // $scope.title = title;
  5365. // $scope.loadData({
  5366. // idx: 0,
  5367. // sum: 20,
  5368. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5369. // });
  5370. $scope.selected = {
  5371. items: []
  5372. };
  5373. //grid2
  5374. $scope.langs = i18nService.getAllLangs();
  5375. $scope.lang = 'zh-cn';
  5376. i18nService.setCurrentLang($scope.lang);
  5377. $scope.gridOptions2 = {};
  5378. $scope.gridOptions2.data = 'myDataone';
  5379. $scope.gridOptions2.enableColumnResizing = true;
  5380. $scope.gridOptions2.enableFiltering = false;
  5381. $scope.gridOptions2.enableGridMenu = false;
  5382. $scope.gridOptions2.showGridFooter = true;
  5383. $scope.gridOptions2.showColumnFooter = false;
  5384. $scope.gridOptions2.fastWatch = true;
  5385. $scope.gridOptions2.useExternalFiltering = true;
  5386. $scope.gridOptions2.useExternalPagination = true;
  5387. $scope.gridOptions2.paginationPageSizes = [10];
  5388. $scope.gridOptions2.paginationPageSize = 10;
  5389. $scope.gridOptions2.multiSelect = false;
  5390. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5391. $scope.gridOptions2.columnDefs = [{
  5392. name: 'item',
  5393. displayName: '序号',
  5394. width: 120
  5395. },
  5396. {
  5397. name: 'name',
  5398. displayName: '耗材名称',
  5399. width: 150,
  5400. enableFiltering: false
  5401. },
  5402. {
  5403. name: 'model',
  5404. displayName: '品牌/型号',
  5405. width: 100,
  5406. enableFiltering: false
  5407. },
  5408. {
  5409. name: 'Specifications',
  5410. displayName: '规格',
  5411. width: 150,
  5412. enableFiltering: false
  5413. },
  5414. {
  5415. name: 'sum',
  5416. displayName: '领用数量',
  5417. enableFiltering: false
  5418. }
  5419. ];
  5420. // $scope.selectButtonClick
  5421. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5422. $scope.gridApi = gridApi;
  5423. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5424. // var filtersData = $scope.memoryfilterData;
  5425. // filtersData.idx = newPage - 1;
  5426. // filtersData.sum = pageSize;
  5427. // $scope.loadData(filtersData);
  5428. $scope.memoryfilterDatahao.idx = newPage - 1;
  5429. $scope.memoryfilterDatahao.sum = pageSize;
  5430. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
  5431. });
  5432. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5433. $scope.selected.items.push(data.entity);
  5434. //console.log(data);
  5435. });
  5436. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  5437. $scope.selected.items.push(data.entity);
  5438. //console.log(data);
  5439. });
  5440. gridApi.core.on.filterChanged($scope, function () {
  5441. var grid = this.grid;
  5442. var filtersData = {
  5443. idx: 0,
  5444. sum: 10,
  5445. "user": {
  5446. "roledata": {
  5447. "rolecode": "roleset"
  5448. },
  5449. "selectType": "1"
  5450. }
  5451. };
  5452. angular.forEach(grid.columns, function (item) {
  5453. if (item.enableFiltering) {
  5454. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5455. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5456. if (angular.isUndefined(filtersData['user'])) {
  5457. filtersData['user'] = {};
  5458. }
  5459. filtersData['user'][item.field] = item.filters[0].term;
  5460. }
  5461. }
  5462. });
  5463. $scope.memoryfilterDatahao = filtersData;
  5464. $scope.loadData(filtersData);
  5465. });
  5466. };
  5467. $scope.removehaocai = function (item) {
  5468. event.preventDefault();
  5469. // var modalInstance = $modal.open({
  5470. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  5471. // controller: function($scope, $modalInstance) {
  5472. // $scope.title = "修改耗材数量";
  5473. // $scope.consumptive = item;
  5474. // $scope.ok = function() {
  5475. // $modalInstance.close($scope.consumptive);
  5476. // };
  5477. // $scope.cancel = function() {
  5478. // $modalInstance.dismiss('cancel');
  5479. // };
  5480. // },
  5481. // size: 'sm'
  5482. // });
  5483. var modalInstance = $modal.open({
  5484. templateUrl: 'assets/views/delete.html',
  5485. controller: function ($scope, $modalInstance, scope) {
  5486. $scope.title = '耗材移除';
  5487. $scope.connect = '确定要移除此设备?';
  5488. $scope.consumptive = scope.selected.items[0];
  5489. $scope.ok = function () {
  5490. $modalInstance.close($scope.consumptive);
  5491. };
  5492. $scope.cancel = function () {
  5493. $modalInstance.dismiss('cancel');
  5494. };
  5495. },
  5496. size: 'sm',
  5497. resolve: {
  5498. scope: function () {
  5499. return $scope;
  5500. },
  5501. }
  5502. });
  5503. modalInstance.result.then(function (selectedItem) {
  5504. // angular.forEach($scope.myData3, function(items, index) {
  5505. // if (items.id == selectedItem.id) {
  5506. // $scope.myData3[index] = selectedItem;
  5507. // }
  5508. // })
  5509. // $scope.model.applicationForm.consumables = $scope.myData3;
  5510. angular.forEach($scope.myDataoneall, function (items, index) {
  5511. if (items.id == selectedItem.id) {
  5512. $scope.myDataoneall.splice(index, 1);
  5513. }
  5514. })
  5515. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5516. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5517. }
  5518. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5519. $scope.model.consumables = $scope.myDataoneall;
  5520. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5521. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5522. $scope.selected = {
  5523. items: []
  5524. };
  5525. })
  5526. }
  5527. $scope.haocaiadd = function () {
  5528. event.preventDefault();
  5529. var modalInstance = $modal.open({
  5530. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  5531. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  5532. $scope.haocainame = [];
  5533. $scope.pinpai = [];
  5534. $scope.guige = [];
  5535. $scope.consumptive = {};
  5536. $scope.consumpall = {};
  5537. $scope.title = "添加耗材";
  5538. api_wechatfile.getDictionaryForList({
  5539. "key": "haocaifenlei"
  5540. }).then(function (data) {
  5541. $scope.haocainame = data;
  5542. })
  5543. $scope.clearNoNum = function (obj, attr) {
  5544. //先把非数字的都替换掉,除了数字和.
  5545. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5546. //必须保证第一个为数字而不是.
  5547. obj[attr] = obj[attr].replace(/^\./g, "");
  5548. //保证只有出现一个.而没有多个.
  5549. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5550. //保证.只出现一次,而不能出现两次以上
  5551. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  5552. //小于最大值
  5553. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5554. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5555. obj[attr] = '';
  5556. }
  5557. }
  5558. $scope.onChange = function (parent) {
  5559. $scope.consumptive.model = {};
  5560. $scope.consumptive.Specifications = {};
  5561. api_wechatfile.getDictionaryForList({
  5562. "key": "pinpai",
  5563. "parent": parent.id
  5564. }).then(function (data) {
  5565. $scope.pinpai = data;
  5566. })
  5567. api_wechatfile.getDictionaryForList({
  5568. "key": "guige",
  5569. "parent": parent.id
  5570. }).then(function (data) {
  5571. $scope.guige = data;
  5572. })
  5573. }
  5574. $scope.onChangesum = function (item) {
  5575. if (item.name && item.model.id && item.Specifications.id) {
  5576. $scope.consumptive.sum = "";
  5577. var data1 = {
  5578. "idx": 0,
  5579. "sum": 10,
  5580. "consumable": {
  5581. "name": item.name.name,
  5582. "brandModel": item.model.name,
  5583. "specification": item.Specifications.name
  5584. }
  5585. }
  5586. api_cmdb3.fetchDataList('consumable', data1).then(function (data) {
  5587. if (data.status == 200 && data.list.length > 0) {
  5588. var myData = data.list;
  5589. $scope.consumpall = myData[0];
  5590. $scope.maxsum = myData[0].inventoryNum;
  5591. } else {
  5592. SweetAlert.swal({
  5593. title: "不存在该耗材",
  5594. text: "请检查库存后重新填写!",
  5595. type: "error"
  5596. });
  5597. }
  5598. });
  5599. }
  5600. }
  5601. $scope.addhaocai = function () {
  5602. $modalInstance.dismiss('cancel');
  5603. scope.haocaiopen($scope.consumptive);
  5604. }
  5605. $scope.ok = function (item) {
  5606. var items = {};
  5607. // if (item.name && item.model && item.Specifications && item.sum) {
  5608. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5609. // $scope.consumpall.model = $scope.consumpall.brandModel;
  5610. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  5611. // $scope.consumpall.sum = item.sum;
  5612. // delete $scope.consumpall.brandModel;
  5613. // delete $scope.consumpall.specification;
  5614. // $modalInstance.close($scope.consumpall);
  5615. // } else {
  5616. // SweetAlert.swal({
  5617. // title: "数据填写不完整!",
  5618. // text: "请检查数据然后提交!",
  5619. // type: "error"
  5620. // });
  5621. // }
  5622. var isold = false;
  5623. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  5624. for (var i = 0; i < scope.myDataoneall.length; i++) {
  5625. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  5626. isold = true;
  5627. }
  5628. }
  5629. if (isold) {
  5630. SweetAlert.swal({
  5631. title: "该耗材已添加!",
  5632. text: "请不要重复添加耗材!",
  5633. type: "error"
  5634. });
  5635. } else {
  5636. $scope.consumpall.model = $scope.consumpall.brandModel;
  5637. $scope.consumpall.Specifications = $scope.consumpall.specification;
  5638. $scope.consumpall.sum = item.sum;
  5639. delete $scope.consumpall.brandModel;
  5640. delete $scope.consumpall.specification;
  5641. $modalInstance.close($scope.consumpall);
  5642. }
  5643. } else {
  5644. SweetAlert.swal({
  5645. title: "数据填写不完整!",
  5646. text: "请检查数据然后提交!",
  5647. type: "error"
  5648. });
  5649. }
  5650. // $modalInstance.close(item);
  5651. };
  5652. $scope.cancel = function () {
  5653. $modalInstance.dismiss('cancel');
  5654. };
  5655. },
  5656. size: 'sm',
  5657. resolve: {
  5658. scope: function () {
  5659. return $scope;
  5660. }
  5661. }
  5662. });
  5663. modalInstance.result.then(function (selectedItem) {
  5664. $scope.myDataoneall.push(selectedItem);
  5665. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5666. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5667. }
  5668. // $scope.model.consumables = $scope.myDataone;
  5669. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5670. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5671. $scope.model.consumables = $scope.myDataoneall;
  5672. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5673. })
  5674. }
  5675. $scope.onDblClick = function (data, event) {
  5676. $scope.selectButtonClick(data, event);
  5677. };
  5678. $scope.memoryfilterDatahao = {
  5679. "idx": 0,
  5680. "sum": 10,
  5681. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5682. }
  5683. $scope.myDataone = [];
  5684. $scope.loadData = function (filterData) { };
  5685. // $scope.title = title;
  5686. $scope.ldloading = {};
  5687. $scope.selected = {
  5688. items: []
  5689. };
  5690. if ($scope.$parent.$parent.$parent.model.gettype) {
  5691. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  5692. if ($scope.model.assets) {
  5693. if (JSON.stringify($scope.model.assets) == "{}") {
  5694. $scope.model.assets = []
  5695. } else {
  5696. $scope.model.assets = JSON.parse($scope.model.assets);
  5697. }
  5698. $scope.myDatalingbeiall = $scope.model.assets;
  5699. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5700. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
  5701. }
  5702. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5703. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5704. }
  5705. if ($scope.model.consumables) {
  5706. if (JSON.stringify($scope.model.consumables) == "{}") {
  5707. $scope.model.consumables = []
  5708. } else {
  5709. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5710. }
  5711. $scope.myDataoneall = $scope.model.consumables;
  5712. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5713. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5714. }
  5715. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5716. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5717. }
  5718. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5719. $scope.options.templateOptions.getpush({
  5720. "hao": true,
  5721. "gu": true
  5722. });
  5723. } else {
  5724. $scope.options.templateOptions.getpush({
  5725. "hao": true
  5726. });
  5727. }
  5728. } else {
  5729. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5730. $scope.options.templateOptions.getpush({
  5731. "gu": true
  5732. });
  5733. }
  5734. }
  5735. }
  5736. }]
  5737. });
  5738. formlyConfigProvider.setType({
  5739. name: 'ui-panel',
  5740. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  5741. });
  5742. formlyConfigProvider.setType({
  5743. name: 'ui-currentuser',
  5744. extends: 'input',
  5745. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  5746. defaultOptions: function (options) {
  5747. return {
  5748. templateOptions: {
  5749. // link: function() {}
  5750. }
  5751. };
  5752. },
  5753. controller: ['$scope', function ($scope) {
  5754. if ($scope.options.templateOptions.user) {
  5755. if (angular.isFunction($scope.options.templateOptions.transform)) {
  5756. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  5757. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  5758. // }
  5759. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5760. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5761. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  5762. }
  5763. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  5764. $scope.options.initialValue = $scope.model[$scope.options.key];
  5765. }
  5766. }]
  5767. });
  5768. //仪表盘
  5769. //待处理变更列表
  5770. formlyConfigProvider.setType({
  5771. name: 'ui-ngpchangetable',
  5772. templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
  5773. defaultOptions: function (options) {
  5774. return {
  5775. templateOptions: {
  5776. // relationAction: function() {
  5777. // options.hideExpression = true
  5778. // }
  5779. }
  5780. };
  5781. },
  5782. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5783. // var filterData = {
  5784. // "assignee": $rootScope.user.id,
  5785. // "searchtype": "all",
  5786. // "idx": "0",
  5787. // "sum": "10"
  5788. // };
  5789. var filterData = {
  5790. "idx": "0",
  5791. "sum": "10",
  5792. "assignee": 2,
  5793. "searchType": "todo"
  5794. }
  5795. $scope.incidentprocess = function (item) {
  5796. $state.go('app.wt_change.add', {
  5797. taskId: item.taskId,
  5798. processInstanceId: item.processInstanceId
  5799. });
  5800. }
  5801. $scope.more = function () {
  5802. $state.go('app.wt_change.list', {})
  5803. }
  5804. api_bpm_domain.fetchtask('bpm_change', filterData).then(function (data) {
  5805. if (data.data) {
  5806. $scope.myData = data.data;
  5807. } else {
  5808. SweetAlert.swal({
  5809. title: "操作异常!",
  5810. text: "系统异常,请稍后重试,或者联系管理员!",
  5811. type: "error"
  5812. });
  5813. }
  5814. })
  5815. $scope.removes = function () {
  5816. var modalInstance = $modal.open({
  5817. templateUrl: 'assets/views/delete.html',
  5818. controller: function ($scope, $modalInstance) {
  5819. $scope.ok = function () {
  5820. $modalInstance.close();
  5821. };
  5822. $scope.cancel = function () {
  5823. $modalInstance.dismiss('cancel');
  5824. };
  5825. },
  5826. size: 'sm'
  5827. });
  5828. modalInstance.result.then(function () {
  5829. console.log($scope.$parent.$parent.$parent.$parent)
  5830. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5831. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5832. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5833. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5834. break;
  5835. }
  5836. }
  5837. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5838. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5839. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5840. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5841. }
  5842. })
  5843. }
  5844. }]
  5845. });
  5846. //待处理问题列表
  5847. formlyConfigProvider.setType({
  5848. name: 'ui-ngproblemtable',
  5849. templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
  5850. defaultOptions: function (options) {
  5851. return {
  5852. templateOptions: {
  5853. // relationAction: function() {
  5854. // options.hideExpression = true
  5855. // }
  5856. }
  5857. };
  5858. },
  5859. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
  5860. var filterData = {
  5861. "assignee": $rootScope.user.id,
  5862. "candidateGroups": $rootScope.user.group[0].id,
  5863. "searchtype": "todo",
  5864. "idx": 0,
  5865. "sum": 10
  5866. };
  5867. $scope.incidentprocess = function (item) {
  5868. $state.go('app.wt_change.add', {
  5869. taskId: item.taskId,
  5870. processInstanceId: item.processInstanceId
  5871. });
  5872. }
  5873. $scope.more = function () {
  5874. $state.go('app.wt_change.list', {})
  5875. }
  5876. api_bpm_data.fetchDataList('changeclassify', filterData).then(function (data) {
  5877. if (data.data) {
  5878. $scope.myData = data.data;
  5879. } else {
  5880. SweetAlert.swal({
  5881. title: "操作异常!",
  5882. text: "系统异常,请稍后重试,或者联系管理员!",
  5883. type: "error"
  5884. });
  5885. }
  5886. })
  5887. $scope.removes = function () {
  5888. var modalInstance = $modal.open({
  5889. templateUrl: 'assets/views/delete.html',
  5890. controller: function ($scope, $modalInstance) {
  5891. $scope.ok = function () {
  5892. $modalInstance.close();
  5893. };
  5894. $scope.cancel = function () {
  5895. $modalInstance.dismiss('cancel');
  5896. };
  5897. },
  5898. size: 'sm'
  5899. });
  5900. modalInstance.result.then(function () {
  5901. console.log($scope.$parent.$parent.$parent.$parent)
  5902. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5903. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5904. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5905. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5906. break;
  5907. }
  5908. }
  5909. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5910. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5911. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5912. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5913. }
  5914. })
  5915. }
  5916. }]
  5917. });
  5918. //待处理事件列表
  5919. formlyConfigProvider.setType({
  5920. name: 'ui-ngtable',
  5921. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  5922. defaultOptions: function (options) {
  5923. return {
  5924. templateOptions: {
  5925. // relationAction: function() {
  5926. // options.hideExpression = true
  5927. // }
  5928. }
  5929. };
  5930. },
  5931. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5932. var filterData = {
  5933. "assignee": $rootScope.user.id,
  5934. "candidateGroups": $rootScope.user.group[0].id,
  5935. "searchtype": "done",
  5936. "idx": 0,
  5937. "sum": 10
  5938. };
  5939. $scope.incidentprocess = function (item) {
  5940. $state.go('app.incident.editor', {
  5941. taskId: item.taskId,
  5942. processInstanceId: item.processInstanceId
  5943. });
  5944. }
  5945. $scope.more = function () {
  5946. $state.go('app.incident.list', {})
  5947. }
  5948. api_bpm_domain.fetchtask('bpm_incident', filterData).then(function (data) {
  5949. if (data.data) {
  5950. $scope.myData = data.data;
  5951. } else {
  5952. SweetAlert.swal({
  5953. title: "操作异常!",
  5954. text: "系统异常,请稍后重试,或者联系管理员!",
  5955. type: "error"
  5956. });
  5957. }
  5958. })
  5959. $scope.removes = function () {
  5960. var modalInstance = $modal.open({
  5961. templateUrl: 'assets/views/delete.html',
  5962. controller: function ($scope, $modalInstance) {
  5963. $scope.ok = function () {
  5964. $modalInstance.close();
  5965. };
  5966. $scope.cancel = function () {
  5967. $modalInstance.dismiss('cancel');
  5968. };
  5969. },
  5970. size: 'sm'
  5971. });
  5972. modalInstance.result.then(function () {
  5973. console.log($scope.$parent.$parent.$parent.$parent)
  5974. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5975. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5976. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5977. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5978. break;
  5979. }
  5980. }
  5981. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5982. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5983. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5984. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5985. }
  5986. })
  5987. }
  5988. }]
  5989. });
  5990. //知识库列表
  5991. formlyConfigProvider.setType({
  5992. name: 'ui-knowledge',
  5993. templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
  5994. defaultOptions: function (options) {
  5995. return {
  5996. templateOptions: {
  5997. // relationAction: function() {
  5998. // options.hideExpression = true
  5999. // }
  6000. }
  6001. };
  6002. },
  6003. controller: ['$scope', '$modal', '$timeout', 'api_solution', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, api_solution, $rootScope, ngTableParams, $filter, $state) {
  6004. var filterData = {
  6005. "key": "null",
  6006. "pageIndex": 0,
  6007. "pageSum": 6,
  6008. "status": 0,
  6009. "userId": $rootScope.user.id
  6010. };
  6011. $scope.model.removereport = false;
  6012. $scope.removes = function () {
  6013. $scope.model.removereport = true;
  6014. }
  6015. $scope.more = function () {
  6016. $state.go('app.knowledge.manager', {});
  6017. }
  6018. api_solution.findSolutionByKeys(filterData).then(function (data) {
  6019. if (data.status == 200) {
  6020. $scope.myData = data.list
  6021. }
  6022. })
  6023. $scope.removes = function () {
  6024. var modalInstance = $modal.open({
  6025. templateUrl: 'assets/views/delete.html',
  6026. controller: function ($scope, $modalInstance) {
  6027. $scope.ok = function () {
  6028. $modalInstance.close();
  6029. };
  6030. $scope.cancel = function () {
  6031. $modalInstance.dismiss('cancel');
  6032. };
  6033. },
  6034. size: 'sm'
  6035. });
  6036. modalInstance.result.then(function () {
  6037. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6038. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6039. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6040. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6041. break;
  6042. }
  6043. }
  6044. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6045. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6046. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6047. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6048. }
  6049. })
  6050. }
  6051. }]
  6052. });
  6053. //公告列表
  6054. formlyConfigProvider.setType({
  6055. name: 'ui-ngnotice',
  6056. templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
  6057. defaultOptions: function (options) {
  6058. return {
  6059. templateOptions: {
  6060. // relationAction: function() {
  6061. // options.hideExpression = true
  6062. // }
  6063. }
  6064. };
  6065. },
  6066. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
  6067. var filterData = {
  6068. "idx": 0,
  6069. "sum": 10
  6070. };
  6071. // $scope.$scope.model.className = "col-xs-12";
  6072. api_user_data.fetchDataList('notice', filterData).then(function (data) {
  6073. if (data) {
  6074. $scope.myData = data.data;
  6075. } else {
  6076. SweetAlert.swal({
  6077. title: "操作异常!",
  6078. text: "系统异常,请稍后重试,或者联系管理员!",
  6079. type: "error"
  6080. });
  6081. }
  6082. })
  6083. $scope.more = function () {
  6084. $state.go('app.system.notice.list', {});
  6085. }
  6086. $scope.removes = function () {
  6087. var modalInstance = $modal.open({
  6088. templateUrl: 'assets/views/delete.html',
  6089. controller: function ($scope, $modalInstance) {
  6090. $scope.ok = function () {
  6091. $modalInstance.close();
  6092. };
  6093. $scope.cancel = function () {
  6094. $modalInstance.dismiss('cancel');
  6095. };
  6096. },
  6097. size: 'sm'
  6098. });
  6099. modalInstance.result.then(function () {
  6100. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6101. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6102. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6103. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6104. break;
  6105. }
  6106. }
  6107. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6108. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6109. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6110. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6111. }
  6112. })
  6113. }
  6114. }]
  6115. });
  6116. //事件统计图
  6117. formlyConfigProvider.setType({
  6118. name: 'ui-incidentreport',
  6119. templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
  6120. defaultOptions: function (options) {
  6121. return {
  6122. templateOptions: {
  6123. // relationAction: function() {
  6124. // options.hideExpression = true
  6125. // }
  6126. }
  6127. };
  6128. },
  6129. controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function ($scope, $modal, moment, api_report, $cookieStore) {
  6130. api_report.getLicenseKey().then(function (response) {
  6131. $cookieStore.put('Auth-Token', response.token);
  6132. $scope.try_async_load();
  6133. });
  6134. $scope.try_async_load = function () {
  6135. $scope.my_data = [];
  6136. api_report.list().then(function (response) {
  6137. var dataList = response;
  6138. getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
  6139. $scope.repoRoot.name = "事件报表"
  6140. convertRepoObject($scope.repoRoot);
  6141. $scope.my_data.push($scope.repoRoot);
  6142. });
  6143. };
  6144. var workspace = {};
  6145. $scope.repoRoot = null;
  6146. function getRepoRoot(repo, path) {
  6147. angular.forEach(repo, function (value, key) {
  6148. if (value.path == path) {
  6149. $scope.repoRoot = value;
  6150. } else {
  6151. if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
  6152. getRepoRoot(value.repoObjects, path);
  6153. } else {
  6154. }
  6155. }
  6156. });
  6157. }
  6158. function convertRepoObject(repo) {
  6159. if (angular.isArray(repo)) {
  6160. angular.forEach(repo, function (value, key) {
  6161. convertRepoObject(value);
  6162. })
  6163. } else {
  6164. if (angular.isDefined(repo.name)) {
  6165. if (repo.name.indexOf(".") >= 0) {
  6166. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  6167. } else {
  6168. repo.label = repo.name;
  6169. }
  6170. //delete repo.name;
  6171. }
  6172. if (angular.isDefined(repo.repoObjects)) {
  6173. repo.children = [];
  6174. repo.children = repo.repoObjects;
  6175. delete repo.repoObjects;
  6176. convertRepoObject(repo.children);
  6177. }
  6178. }
  6179. }
  6180. function parseDateParameter(parameters) {
  6181. var result = undefined;
  6182. if (angular.isArray(parameters)) {
  6183. // angular.forEach(parmeters,function(param){
  6184. // param.
  6185. // })
  6186. } else {
  6187. result = {};
  6188. for (var k in parameters) {
  6189. if (k.indexOf("Date") > 0) {
  6190. if (angular.isString(parameters[k])) {
  6191. result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
  6192. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  6193. }
  6194. }
  6195. }
  6196. }
  6197. return result;
  6198. }
  6199. function ConvertDateParameter(parameters) {
  6200. var result = undefined;
  6201. if (angular.isArray(parameters)) {
  6202. //
  6203. } else {
  6204. result = {};
  6205. for (var k in parameters) {
  6206. if (k.indexOf("Date") > 0) {
  6207. if (angular.isDate(parameters[k])) {
  6208. result[k] = moment(parameters[k]).format("YYYYMMDD");
  6209. } else if (angular.isString(parameters[k])) {
  6210. result[k] = parameters[k];
  6211. }
  6212. }
  6213. }
  6214. }
  6215. return result;
  6216. }
  6217. var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  6218. var queryUUID;
  6219. function genUUID() {
  6220. var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
  6221. function (c) {
  6222. var r = Math.random() * 16 | 0,
  6223. v = c == 'x' ? r : (r & 0x3 | 0x8);
  6224. return v.toString(16);
  6225. }).toUpperCase();
  6226. return uuid;
  6227. }
  6228. queryUUID = genUUID();
  6229. var pathincidenttimekey = [];
  6230. var incidenttime = {
  6231. 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
  6232. 'endtimes': moment(new Date()).format('YYYYMMDD')
  6233. };
  6234. var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
  6235. var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
  6236. var averages = [
  6237. [thisdaymine - 86400000 * 14, 0],
  6238. [thisdaymine - 86400000 * 13, 0],
  6239. [thisdaymine - 86400000 * 12, 0],
  6240. [thisdaymine - 86400000 * 11, 0],
  6241. [thisdaymine - 86400000 * 10, 0],
  6242. [thisdaymine - 86400000 * 9, 0],
  6243. [thisdaymine - 86400000 * 8, 0],
  6244. [thisdaymine - 86400000 * 7, 0],
  6245. [thisdaymine - 86400000 * 6, 0],
  6246. [thisdaymine - 86400000 * 5, 0],
  6247. [thisdaymine - 86400000 * 4, 0],
  6248. [thisdaymine - 86400000 * 3, 0],
  6249. [thisdaymine - 86400000 * 2, 0],
  6250. [thisdaymine - 86400000 * 1, 0],
  6251. [thisdaymine, 0]
  6252. ];
  6253. var getreportdata = function (incidenttime, path) {
  6254. api_report.getMdx(path, queryUUID).then(function (response) {
  6255. var mdxquery = response;
  6256. workspace.query = mdxquery;
  6257. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  6258. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  6259. $scope.parameters = parseDateParameter(workspace.query.parameters);
  6260. weekuser(mdxquery);
  6261. });
  6262. }
  6263. getreportdata(incidenttime, incidentchart);
  6264. var weekuser = function (mdxquery) {
  6265. var key = [];
  6266. api_report.execute(mdxquery).then(function (data) {
  6267. $scope.rheaders = [];
  6268. $scope.rRows = [];
  6269. var reportData = data;
  6270. if (reportData.cellset == null || reportData.cellset.length == 0) {
  6271. $scope.shows = true;
  6272. $scope.empty = "数据为空!"
  6273. } else {
  6274. angular.forEach(reportData.cellset, function (item, i) {
  6275. angular.forEach(averages, function (index, j) {
  6276. // angular.forEach(averages, function(item, index) {
  6277. if (item.length > 1 && i > 0 && item[1].value != '') {
  6278. if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
  6279. index[1] = Number(item[1].value);
  6280. }
  6281. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  6282. }
  6283. // })
  6284. })
  6285. })
  6286. incidentchartfun(averages);
  6287. }
  6288. })
  6289. }
  6290. var incidentchartfun = function (incidentchartkey) {
  6291. // $scope.isMaskincident = false;
  6292. Highcharts.chart('incidentchart', {
  6293. title: {
  6294. text: '事件近15天趋势图'
  6295. },
  6296. xAxis: {
  6297. type: 'datetime',
  6298. labels: {
  6299. align: 'left',
  6300. step: 1
  6301. }
  6302. },
  6303. yAxis: {
  6304. title: {
  6305. text: null
  6306. }
  6307. },
  6308. tooltip: {
  6309. crosshairs: true,
  6310. shared: true,
  6311. valueSuffix: '条'
  6312. },
  6313. legend: {},
  6314. series: [{
  6315. name: '生成事件',
  6316. data: incidentchartkey,
  6317. zIndex: 1,
  6318. marker: {
  6319. fillColor: 'white',
  6320. lineWidth: 2,
  6321. lineColor: Highcharts.getOptions().colors[0]
  6322. }
  6323. }]
  6324. });
  6325. }
  6326. $scope.data = {
  6327. labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
  6328. datasets: [{
  6329. label: '新增事件数量',
  6330. fillColor: 'rgba(220,220,220,0.2)',
  6331. strokeColor: 'rgba(220,220,220,1)',
  6332. pointColor: 'rgba(220,220,220,1)',
  6333. pointStrokeColor: '#fff',
  6334. pointHighlightFill: '#fff',
  6335. pointHighlightStroke: 'rgba(220,220,220,1)',
  6336. data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
  6337. },
  6338. {
  6339. label: '已解决事件数量',
  6340. fillColor: 'rgba(151,187,205,0.2)',
  6341. strokeColor: 'rgba(151,187,205,1)',
  6342. pointColor: 'rgba(151,187,205,1)',
  6343. pointStrokeColor: '#fff',
  6344. pointHighlightFill: '#fff',
  6345. pointHighlightStroke: 'rgba(151,187,205,1)',
  6346. data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
  6347. }
  6348. ]
  6349. };
  6350. $scope.removes = function () {
  6351. var modalInstance = $modal.open({
  6352. templateUrl: 'assets/views/delete.html',
  6353. controller: function ($scope, $modalInstance) {
  6354. $scope.ok = function () {
  6355. $modalInstance.close();
  6356. };
  6357. $scope.cancel = function () {
  6358. $modalInstance.dismiss('cancel');
  6359. };
  6360. },
  6361. size: 'sm'
  6362. });
  6363. modalInstance.result.then(function () {
  6364. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6365. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6366. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6367. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6368. break;
  6369. }
  6370. }
  6371. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6372. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6373. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6374. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6375. }
  6376. })
  6377. }
  6378. var addDatas = 0;
  6379. var resolve = 0;
  6380. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  6381. addDatas = addDatas + $scope.data.datasets[0].data[i];
  6382. }
  6383. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  6384. resolve = resolve + $scope.data.datasets[1].data[i];
  6385. }
  6386. $scope.resolution = (resolve / addDatas * 100).toFixed(2);
  6387. $scope.opt = {
  6388. maintainAspectRatio: false,
  6389. // Sets the chart to be responsive
  6390. responsive: true,
  6391. ///Boolean - Whether grid lines are shown across the chart
  6392. scaleShowGridLines: true,
  6393. //String - Colour of the grid lines
  6394. scaleGridLineColor: 'rgba(0,0,0,.05)',
  6395. //Number - Width of the grid lines
  6396. scaleGridLineWidth: 1,
  6397. //Boolean - Whether the line is curved between points
  6398. bezierCurve: false,
  6399. //Number - Tension of the bezier curve between points
  6400. bezierCurveTension: 0.4,
  6401. //Boolean - Whether to show a dot for each point
  6402. pointDot: true,
  6403. //Number - Radius of each point dot in pixels
  6404. pointDotRadius: 4,
  6405. //Number - Pixel width of point dot stroke
  6406. pointDotStrokeWidth: 1,
  6407. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  6408. pointHitDetectionRadius: 20,
  6409. //Boolean - Whether to show a stroke for datasets
  6410. datasetStroke: true,
  6411. //Number - Pixel width of dataset stroke
  6412. datasetStrokeWidth: 2,
  6413. //Boolean - Whether to fill the dataset with a colour
  6414. datasetFill: true,
  6415. // Function - on animation progress
  6416. onAnimationProgress: function () { },
  6417. // Function - on animation complete
  6418. onAnimationComplete: function () { },
  6419. //String - A legend template
  6420. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  6421. };
  6422. angular.extend($scope.options, $scope.opt)
  6423. $scope.datamonth = {
  6424. labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
  6425. datasets: [{
  6426. label: '新增事件数量',
  6427. fillColor: 'rgba(220,220,220,0.5)',
  6428. strokeColor: 'rgba(220,220,220,0.8)',
  6429. highlightFill: 'rgba(220,220,220,0.75)',
  6430. highlightStroke: 'rgba(220,220,220,1)',
  6431. data: [65, 59, 80, 81, 56, 55]
  6432. },
  6433. {
  6434. label: '已解决事件数量',
  6435. fillColor: 'rgba(151,187,205,0.5)',
  6436. strokeColor: 'rgba(151,187,205,0.8)',
  6437. highlightFill: 'rgba(151,187,205,0.75)',
  6438. highlightStroke: 'rgba(151,187,205,1)',
  6439. data: [28, 48, 40, 19, 86, 27]
  6440. }
  6441. ]
  6442. };
  6443. // Chart.js Options
  6444. $scope.taption = {
  6445. maintainAspectRatio: false,
  6446. // Sets the chart to be responsive
  6447. responsive: true,
  6448. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  6449. scaleBeginAtZero: true,
  6450. //Boolean - Whether grid lines are shown across the chart
  6451. scaleShowGridLines: true,
  6452. //String - Colour of the grid lines
  6453. scaleGridLineColor: "rgba(0,0,0,.05)",
  6454. //Number - Width of the grid lines
  6455. scaleGridLineWidth: 1,
  6456. //Boolean - If there is a stroke on each bar
  6457. barShowStroke: true,
  6458. //Number - Pixel width of the bar stroke
  6459. barStrokeWidth: 2,
  6460. //Number - Spacing between each of the X value sets
  6461. barValueSpacing: 5,
  6462. //Number - Spacing between data sets within X values
  6463. barDatasetSpacing: 1,
  6464. //String - A legend template
  6465. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  6466. };
  6467. }]
  6468. });
  6469. //排版日历
  6470. formlyConfigProvider.setType({
  6471. name: 'ui-dashcalendar',
  6472. templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
  6473. defaultOptions: function (options) {
  6474. return {
  6475. templateOptions: {
  6476. // relationAction: function() {
  6477. // options.hideExpression = true
  6478. // }
  6479. }
  6480. };
  6481. },
  6482. controller: ["$rootScope", "$scope", "$modal", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", "$state", function ($rootScope, $scope, $modal, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data, $state) {
  6483. var loginUser = $rootScope.user;
  6484. calendarConfig.dateFormatter = 'moment';
  6485. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  6486. calendarConfig.i18nStrings.timeLabel = '时间';
  6487. calendarConfig.i18nStrings.weekNumber = '{week}周';
  6488. calendarConfig.allDateFormats = {
  6489. angular: {
  6490. date: {
  6491. hour: 'ha',
  6492. day: 'd MMM',
  6493. month: 'MMMM',
  6494. weekDay: 'EEEE',
  6495. time: 'HH:mm',
  6496. datetime: 'MMM d, h:mm a'
  6497. },
  6498. title: {
  6499. day: 'yyyy MMMM EEEE d',
  6500. week: '{year}年第{week}周',
  6501. month: 'yyyy MMMM',
  6502. year: 'yyyy'
  6503. }
  6504. },
  6505. moment: {
  6506. date: {
  6507. hour: 'ha',
  6508. day: 'MMMDD日',
  6509. month: 'MMMM',
  6510. weekDay: 'dddd',
  6511. time: 'HH:mm',
  6512. datetime: 'MMM D, h:mm a'
  6513. },
  6514. title: {
  6515. day: 'YYYY年MMMMDD日, dddd ',
  6516. week: '{year}年第{week}周',
  6517. month: 'YYYY年MMMM',
  6518. year: 'YYYY'
  6519. }
  6520. }
  6521. };
  6522. moment.locale('zh_cn', {
  6523. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  6524. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  6525. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6526. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6527. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6528. longDateFormat: {
  6529. LT: 'Ah点mm分',
  6530. LTS: 'Ah点m分s秒',
  6531. L: 'YYYY-MM-DD',
  6532. LL: 'YYYY年MMMD日',
  6533. LLL: 'YYYY年MMMD日Ah点mm分',
  6534. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  6535. l: 'YYYY-MM-DD',
  6536. ll: 'YYYY年MMMD日',
  6537. lll: 'YYYY年MMMD日Ah点mm分',
  6538. llll: 'YYYY年MMMD日ddddAh点mm分'
  6539. },
  6540. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6541. meridiemHour: function (hour, meridiem) {
  6542. if (hour === 12) {
  6543. hour = 0;
  6544. }
  6545. if (meridiem === '凌晨' || meridiem === '早上' ||
  6546. meridiem === '上午') {
  6547. return hour;
  6548. } else if (meridiem === '下午' || meridiem === '晚上') {
  6549. return hour + 12;
  6550. } else {
  6551. // '中午'
  6552. return hour >= 11 ? hour : hour + 12;
  6553. }
  6554. },
  6555. meridiem: function (hour, minute, isLower) {
  6556. var hm = hour * 100 + minute;
  6557. if (hm < 600) {
  6558. return '凌晨';
  6559. } else if (hm < 900) {
  6560. return '早上';
  6561. } else if (hm < 1130) {
  6562. return '上午';
  6563. } else if (hm < 1230) {
  6564. return '中午';
  6565. } else if (hm < 1800) {
  6566. return '下午';
  6567. } else {
  6568. return '晚上';
  6569. }
  6570. },
  6571. calendar: {
  6572. sameDay: function () {
  6573. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  6574. },
  6575. nextDay: function () {
  6576. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  6577. },
  6578. lastDay: function () {
  6579. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  6580. },
  6581. nextWeek: function () {
  6582. var startOfWeek, prefix;
  6583. startOfWeek = moment().startOf('week');
  6584. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  6585. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6586. },
  6587. lastWeek: function () {
  6588. var startOfWeek, prefix;
  6589. startOfWeek = moment().startOf('week');
  6590. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  6591. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6592. },
  6593. sameElse: 'LL'
  6594. },
  6595. ordinalParse: /\d{1,2}(日|月|周)/,
  6596. ordinal: function (number, period) {
  6597. switch (period) {
  6598. case 'd':
  6599. case 'D':
  6600. case 'DDD':
  6601. return number + '日';
  6602. case 'M':
  6603. return number + '月';
  6604. case 'w':
  6605. case 'W':
  6606. return number + '周';
  6607. default:
  6608. return number;
  6609. }
  6610. },
  6611. relativeTime: {
  6612. future: '%s内',
  6613. past: '%s前',
  6614. s: '几秒',
  6615. m: '1 分钟',
  6616. mm: '%d 分钟',
  6617. h: '1 小时',
  6618. hh: '%d 小时',
  6619. d: '1 天',
  6620. dd: '%d 天',
  6621. M: '1 个月',
  6622. MM: '%d 个月',
  6623. y: '1 年',
  6624. yy: '%d 年'
  6625. },
  6626. week: {
  6627. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6628. dow: 1, // Monday is the first day of the week.
  6629. doy: 4 // The week that contains Jan 4th is the first week of the year.
  6630. }
  6631. });
  6632. var date = new Date();
  6633. var d = date.getDate();
  6634. var m = date.getMonth();
  6635. var y = date.getFullYear();
  6636. var filterData = {
  6637. "userId": loginUser.id,
  6638. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  6639. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  6640. };
  6641. var load = $scope.load = function (filterData) {
  6642. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function (response) {
  6643. if (response.status == 200) {
  6644. $scope.events = [];
  6645. var myData = response.list;
  6646. angular.forEach(myData, function (item) {
  6647. var eventTemp = {};
  6648. eventTemp.title = item.description;
  6649. eventTemp.type = item.scheduleClass.code;
  6650. eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
  6651. eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
  6652. eventTemp.startTime = item['scheduleOrderDTO'].startTime;
  6653. eventTemp.endTime = item['scheduleOrderDTO'].endTime;
  6654. //eventTemp.ends_at = moment(item.endTime).toDate();
  6655. eventTemp.id = item.id;
  6656. eventTemp.deletable = false;
  6657. eventTemp.user = item.user;
  6658. $scope.events.push(eventTemp);
  6659. })
  6660. }
  6661. });
  6662. }
  6663. // var load = $scope.load = function(filterData){
  6664. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  6665. // console.log("response="+JSON.stringify(response));
  6666. // if(response.status==200){
  6667. // $scope.events = [];
  6668. // console.log(response.list);
  6669. // var myData = response.list;
  6670. // angular.forEach(myData,function(item){
  6671. // var eventTemp = {};
  6672. // eventTemp.title = item.description;
  6673. // eventTemp.type = item.scheduleClass.code;
  6674. // eventTemp.startsAt = moment(item.startTime).toDate();
  6675. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  6676. // eventTemp.startTime = item.startTime;
  6677. // eventTemp.endTime = item.endTime;
  6678. // //eventTemp.ends_at = moment(item.endTime).toDate();
  6679. // eventTemp.id = item.id;
  6680. // eventTemp.deletable = false;
  6681. // eventTemp.users = item.users;
  6682. // $scope.events.push(eventTemp);
  6683. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  6684. // })
  6685. // }
  6686. // });
  6687. // }
  6688. $scope.scheduleClass = {};
  6689. var convertEvent = function (scheduleorder) {
  6690. var eventTemp = {};
  6691. eventTemp.title = scheduleorder.description;
  6692. eventTemp.type = scheduleorder.scheduleClass.code;
  6693. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  6694. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  6695. eventTemp.id = scheduleorder.id;
  6696. eventTemp.user = scheduleorder.user;
  6697. eventTemp.deletable = false;
  6698. return eventTemp;
  6699. }
  6700. // var convertEvent = function(scheduleorder){
  6701. // var eventTemp = {};
  6702. // eventTemp.title = scheduleorder.description;
  6703. // eventTemp.type = scheduleorder.scheduleClass.code;
  6704. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  6705. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  6706. // eventTemp.id = scheduleorder.id;
  6707. // eventTemp.users = scheduleorder.users;
  6708. // eventTemp.deletable = false;
  6709. // return eventTemp;
  6710. // }
  6711. api_bpm_schedule.getScheduleClass().then(function (response) {
  6712. if (response.status == 200) {
  6713. var scheduleClassList = response.list;
  6714. angular.forEach(scheduleClassList, function (item) {
  6715. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  6716. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  6717. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  6718. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  6719. $scope.scheduleClass[item['code']] = item;
  6720. })
  6721. }
  6722. })
  6723. $scope.events = [];
  6724. $scope.calendarView = 'month';
  6725. //$scope.calendarDay = new Date();
  6726. $scope.calendarDate = moment().startOf('month').toDate();
  6727. $scope.timeLabel = "时间";
  6728. $scope.eventLabel = "描述";
  6729. function showModal(action, event) {
  6730. // console.log("action="+JSON.stringify(action))
  6731. var modalInstance = $aside.open({
  6732. templateUrl: 'scheduleEvent.html',
  6733. placement: 'right',
  6734. size: 'sm',
  6735. backdrop: true,
  6736. controller: function ($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  6737. $scope.$modalInstance = $modalInstance;
  6738. $scope.action = action;
  6739. $scope.event = event;
  6740. $scope.scheduleClassic = scheduleClass;
  6741. $scope.$watch('event.type', function (newvalue, oldvalue) {
  6742. // if(oldvalue == newvalue) return;
  6743. // if(scheduleClass[newvalue]){
  6744. var sm = MementFormat(scheduleClass[newvalue].startTime);
  6745. var em = MementFormat(scheduleClass[newvalue].endTime);
  6746. console.log("sm=" + JSON.stringify(sm))
  6747. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  6748. console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  6749. if (sm.hour() > em.hour()) {
  6750. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6751. console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  6752. } else {
  6753. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6754. console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  6755. }
  6756. // }
  6757. });
  6758. // $scope.ok = function (event) {
  6759. // console.log("event="+JSON.stringify(event))
  6760. // event.action = action;
  6761. // $modalInstance.close(event);
  6762. // };
  6763. $scope.cancel = function (event) {
  6764. $modalInstance.dismiss();
  6765. };
  6766. var acUserSelect = $scope.refreshUser = function (key) {
  6767. //for test
  6768. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  6769. // return;
  6770. var data = {
  6771. "idx": "0",
  6772. "sum": "5"
  6773. };
  6774. if (key) {
  6775. data['user'] = {
  6776. 'name': key
  6777. };
  6778. }
  6779. APIService.fetchDataList('user', data).then(function (response) {
  6780. if (response) {
  6781. if (response.status = 200) {
  6782. $scope.users = response.list;
  6783. console.log($scope.users);
  6784. }
  6785. }
  6786. })
  6787. };
  6788. if (angular.isDefined(event.users) && event.users.length > 0) {
  6789. }
  6790. $scope.users = [event.user];
  6791. acUserSelect();
  6792. },
  6793. resolve: {
  6794. scheduleClass: function () {
  6795. return $scope.scheduleClass;
  6796. },
  6797. APIService: function () {
  6798. return api_user_data;
  6799. },
  6800. MementFormat: function () {
  6801. return moment;
  6802. }
  6803. }
  6804. });
  6805. modalInstance.result.then(function (selectedEvent) {
  6806. if (selectedEvent.action == 'Clicked') {
  6807. // var data = {
  6808. // "scheduleorder":{
  6809. // "id":selectedEvent.id,
  6810. // "description":selectedEvent.title,
  6811. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  6812. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  6813. // "users":selectedEvent.users,
  6814. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  6815. // }
  6816. // };
  6817. // api_bpm_schedule.update(data).then(function(response){
  6818. // if(response.status==200){
  6819. // SweetAlert.swal({
  6820. // title: "操作成功!",
  6821. // text: "排班更新成功!",
  6822. // type: "succes"
  6823. // });
  6824. // angular.forEach($scope.events,function(item){
  6825. // if(item.id==selectedEvent.id){
  6826. // item = selectedEvent;
  6827. // }
  6828. // })
  6829. // }else{
  6830. // SweetAlert.swal({
  6831. // title: "操作失败",
  6832. // text: "排班更新失败,请稍后重试!",
  6833. // type: "error"
  6834. // })
  6835. // }
  6836. // })
  6837. } else {
  6838. //
  6839. }
  6840. });
  6841. }
  6842. $scope.moment = function (string) {
  6843. return moment(string);
  6844. }
  6845. $scope.eventClicked = function (event) {
  6846. // console.log("event="+JSON.stringify(event))
  6847. showModal('Clicked', event);
  6848. };
  6849. $scope.eventEdited = function (event) {
  6850. showModal('Edited', event);
  6851. };
  6852. var updateView = function (newvalue, oldvalue) {
  6853. if (oldvalue == newvalue) return;
  6854. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  6855. if ($scope.calendarView == "year") {
  6856. } else if ($scope.calendarView == "month") {
  6857. timeStart = moment(newvalue).startOf('month');
  6858. timeEnd = moment(newvalue).endOf('month');
  6859. } else if ($scope.calendarView == "week") {
  6860. timeStart = moment(newvalue).startOf('week');
  6861. timeEnd = moment(newvalue).endOf('week');
  6862. } else if ($scope.calendarView == "Day") {
  6863. timeStart = moment(newvalue).startOf('day');
  6864. timeEnd = moment(newvalue).endOf('day');
  6865. }
  6866. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  6867. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  6868. filterData["startTime"] = timeStartSpan;
  6869. filterData["endTime"] = timeEndSpan;
  6870. load(filterData);
  6871. }
  6872. $scope.$watch('calendarDate', updateView)
  6873. $scope.next = function () {
  6874. $scope.calendarControl.next();
  6875. }
  6876. $scope.prev = function () {
  6877. $scope.calendarControl.prev();
  6878. }
  6879. $scope.setCalendarToToday = function () {
  6880. $scope.calendarDay = new Date();
  6881. };
  6882. $scope.toggle = function ($event, field, event) {
  6883. $event.preventDefault();
  6884. $event.stopPropagation();
  6885. event[field] = !event[field];
  6886. };
  6887. $scope.load(filterData);
  6888. $scope.more = function () {
  6889. $state.go('app.scheduling.myscheduling', {});
  6890. }
  6891. $scope.removes = function () {
  6892. var modalInstance = $modal.open({
  6893. templateUrl: 'assets/views/delete.html',
  6894. controller: function ($scope, $modalInstance) {
  6895. $scope.ok = function () {
  6896. $modalInstance.close();
  6897. };
  6898. $scope.cancel = function () {
  6899. $modalInstance.dismiss('cancel');
  6900. };
  6901. },
  6902. size: 'sm'
  6903. });
  6904. modalInstance.result.then(function () {
  6905. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6906. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6907. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6908. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6909. break;
  6910. }
  6911. }
  6912. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6913. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6914. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6915. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6916. }
  6917. })
  6918. }
  6919. }]
  6920. });
  6921. //空格组件
  6922. formlyConfigProvider.setType({
  6923. name: 'ui-black',
  6924. /*extends: 'input',*/
  6925. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  6926. });
  6927. //请求人最近事件
  6928. formlyConfigProvider.setType({
  6929. name: 'ui-recentIncident',
  6930. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  6931. controller: ['$scope', '$modal', 'api_solution', function ($scope, $modal, api_solution) {
  6932. var filterData = {
  6933. 'incident': {
  6934. 'requester': {
  6935. 'id': ''
  6936. }
  6937. },
  6938. idx: 0,
  6939. sum: 3
  6940. };
  6941. setInterval(function () {
  6942. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  6943. var requester = $scope.model.requester;
  6944. if (requester != null && angular.isDefined(requester.id)) {
  6945. filterData.incident.requester.id = $scope.model.requester.id;
  6946. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  6947. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  6948. if (modelData.status == 200) {
  6949. $scope.lastrequst = modelData.list;
  6950. }
  6951. });
  6952. requester = null
  6953. } else { }
  6954. } else { }
  6955. }, 1000);
  6956. $scope.detail = function (data) {
  6957. var modalInstance = $modal.open({
  6958. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  6959. controller: function ($scope, $modalInstance) {
  6960. $scope.entity = {};
  6961. $scope.entity = data;
  6962. $scope.cancel = function () {
  6963. $modalInstance.dismiss('cancel');
  6964. };
  6965. },
  6966. size: 'lg',
  6967. });
  6968. }
  6969. }]
  6970. });
  6971. //参数列表
  6972. formlyConfigProvider.setType({
  6973. name: "ui-listinput",
  6974. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  6975. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6976. defaultOptions: function (options) {
  6977. return {
  6978. templateOptions: {}
  6979. };
  6980. },
  6981. controller: ['$scope', function ($scope) {
  6982. }]
  6983. });
  6984. //时间段控件(分)
  6985. formlyConfigProvider.setType({
  6986. name: 'ui-timeslot',
  6987. extends: 'input',
  6988. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6989. controller: ['$scope', function ($scope) { }]
  6990. });
  6991. //优先级级联-逾期时间
  6992. formlyConfigProvider.setType({
  6993. name: 'ui-overtime',
  6994. extends: 'input',
  6995. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  6996. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  6997. var filteData = {};
  6998. var datas = {}
  6999. setInterval(function () {
  7000. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7001. filteData = "L" + $scope.model.priority.id;
  7002. datas = $scope.model.priority.id;
  7003. // console.log($scope.options.templateOptions)
  7004. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7005. // var overtime=requester.date;
  7006. if (requester.state == 200) {
  7007. // if($scope.options.key=="date"){
  7008. $scope.model[$scope.options.key] = requester.date
  7009. // }
  7010. }
  7011. })
  7012. }
  7013. }, 1000);
  7014. }]
  7015. });
  7016. formlyConfigProvider.setType({
  7017. name: 'ui-responsetime',
  7018. extends: 'input',
  7019. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  7020. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7021. var filteData = {};
  7022. var datas = {}
  7023. setInterval(function () {
  7024. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7025. filteData = "L" + $scope.model.priority.id;
  7026. datas = $scope.model.priority.id;
  7027. // console.log($scope.options.templateOptions)
  7028. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7029. // var overtime=requester.date;
  7030. if (requester.state == 200) {
  7031. var keyName = {};
  7032. // $scope.model.overdueTime = requester.date;
  7033. if ($scope.options.key == "expectIntroTime") {
  7034. keyName = "resolveTime";
  7035. } else if ($scope.options.key == "expectResponseTime") {
  7036. keyName = "responseTime";
  7037. }
  7038. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  7039. // }
  7040. console.log($scope.$parent.$parent.$parent.model)
  7041. }
  7042. if (requester.date1) {
  7043. $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
  7044. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
  7045. $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
  7046. $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
  7047. }
  7048. })
  7049. }
  7050. }, 1000);
  7051. }]
  7052. });
  7053. //知识库按钮组件
  7054. formlyConfigProvider.setType({
  7055. name: 'ui-discasecade',
  7056. extends: 'input',
  7057. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  7058. defaultOptions: function (options) {
  7059. return {
  7060. templateOptions: {
  7061. relationAction: function (fields, modelscope, item) { }
  7062. },
  7063. validators: {
  7064. required: {
  7065. expression: function (viewValue, modelValue) {
  7066. var value = modelValue || viewValue;
  7067. // return value = "true";
  7068. }
  7069. }
  7070. }
  7071. }
  7072. },
  7073. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
  7074. // $scope.options.initialValue = $scope.model[$scope.options.key];
  7075. $scope.searchField = $scope.options.model[$scope.options.key];
  7076. $scope.searchData = "";
  7077. $scope.onChangeadd = function (searchData) {
  7078. $scope.searchKey = searchData.account;
  7079. // $scope.searchDataadd = searchData;
  7080. var requesdata = angular.copy(searchData)
  7081. $scope.requester = requesdata;
  7082. }
  7083. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7084. $scope.searchData = searchKey;
  7085. reashdata($scope.searchData);
  7086. }
  7087. $scope.getMydata = function (x) {
  7088. $scope.model[$scope.options.key] = JSON.parse(x).title;
  7089. $scope.searchField = $scope.model[$scope.options.key];
  7090. }
  7091. $scope.getMydataone = function (x) {
  7092. $scope.model[$scope.options.key] = x;
  7093. $scope.searchField = $scope.model[$scope.options.key];
  7094. }
  7095. $scope.fildata = {
  7096. "idx": 0,
  7097. "sum": 10
  7098. // 'incident': { 'tilte': item }
  7099. }
  7100. function reashdata(item) {
  7101. if (item && item != "") {
  7102. angular.extend($scope.fildata, {
  7103. 'incident': {
  7104. 'title': item
  7105. }
  7106. })
  7107. } else {
  7108. delete $scope.fildata.incident;
  7109. }
  7110. api_bpm_data.fetchDataList('incident', $scope.fildata).then(function (response) {
  7111. if (response) {
  7112. if (response.status = 200) {
  7113. var myData = response;
  7114. $scope.myData = myData.list;
  7115. }
  7116. }
  7117. })
  7118. }
  7119. function delHtmlTag(str) {
  7120. return str.replace(/<[^>]+>/g, "");
  7121. }
  7122. // reashdata();
  7123. var changedata = {};
  7124. setInterval(function () {
  7125. if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
  7126. $scope.searchData = {};
  7127. changedata = angular.copy($scope.model.category);
  7128. if ($scope.options.key == "title") {
  7129. var filterData = {
  7130. "idx": 0,
  7131. "sum": 1000
  7132. };
  7133. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function (data) {
  7134. var datalist = data.list;
  7135. angular.forEach(datalist, function (item) {
  7136. if (item.id == $scope.model.category.id) {
  7137. $scope.model[$scope.options.key] = item.category;
  7138. $scope.searchField = $scope.options.model[$scope.options.key];
  7139. $scope.titles = item.category;
  7140. titles = $scope.model.category;
  7141. }
  7142. })
  7143. })
  7144. }
  7145. }
  7146. }, 1000);
  7147. $scope.open = function (key, options, fildata, $event, model) {
  7148. if (key && key.length > 1) {
  7149. api_zsk.solutionData({
  7150. "solution": {
  7151. "searchWord": key
  7152. },
  7153. "idx": "0",
  7154. "sum": "1000"
  7155. }, 'solution').then(function (response) {
  7156. if (response && response.list.length > 0) {
  7157. $scope.dlideboxslide = true
  7158. angular.forEach(response, function (item) {
  7159. console.log(response)
  7160. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  7161. // if (response.status == 200) {
  7162. // var quote = { 'totalNum': response.totalNum }
  7163. // item = angular.extend(item, quote)
  7164. // }
  7165. // })
  7166. $scope.searchData = response.list;
  7167. console.log($scope.searchData)
  7168. })
  7169. $scope.changes = false;
  7170. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  7171. // $scope.closepages = function(e) {
  7172. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  7173. // event.preventDefault();
  7174. // };
  7175. $scope.shows = false;
  7176. $scope.tempData = {};
  7177. $scope.showpage = function (item) {
  7178. item.content = delHtmlTag(item.content);
  7179. $scope.shows = true;
  7180. $scope.tempData = item;
  7181. if (item.content != null) {
  7182. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  7183. }
  7184. $scope.knowledgedata = item;
  7185. $scope.pageid = item.id;
  7186. $scope.changes = !$scope.changes;
  7187. api_bpm_domain.listAttachments(item.id)
  7188. // api_solution.fetchDataList('file', {
  7189. // "file": {
  7190. // "solutionId": item.id
  7191. // },
  7192. // "idx": "0",
  7193. // "sum": "1000"
  7194. // })
  7195. .then(function (data) {
  7196. if (data) {
  7197. $scope.attachments = data.list;
  7198. $scope.view = function (attachmentId) {
  7199. for (var i = 0; i < $scope.attachments.length; i++) {
  7200. if ($scope.attachments[i].id == attachmentId) {
  7201. window.open($scope.attachments[i].previewUrl);
  7202. }
  7203. }
  7204. };
  7205. $scope.download = function (contentId, filename) {
  7206. api_solution.getSolutionDowpath(contentId).then(function (response) {
  7207. var file = new Blob([response], {
  7208. type: 'application/octet-stream'
  7209. });
  7210. // var filename = filename;
  7211. var fileURL = URL.createObjectURL(file);
  7212. var a = document.createElement('a');
  7213. a.href = fileURL;
  7214. a.target = '_blank';
  7215. a.download = filename;
  7216. document.body.appendChild(a);
  7217. a.click();
  7218. })
  7219. };
  7220. }
  7221. })
  7222. }
  7223. $scope.related = function (item) {
  7224. if (item.content != null) {
  7225. item.content = item.content.replace("<p>", "").replace("</p>", "")
  7226. }
  7227. // fildata.$parent.$parent.$parent.model.directClose = 0;
  7228. options.model.handleDescription = item.content;
  7229. var data = {
  7230. 'solutionQuote': {
  7231. 'solutionId': item.id,
  7232. 'incidentsign': options.model.incidentsign
  7233. }
  7234. };
  7235. api_zsk.solutionQuote(item.id).then(function (response) {
  7236. if (response.status == 200) {
  7237. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7238. fildata.$parent.$parent.$parent.$parent.model.start_code = 'close';
  7239. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  7240. } else {
  7241. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7242. };
  7243. })
  7244. }
  7245. $scope.close = function () {
  7246. $scope.changes = !$scope.changes;
  7247. event.preventDefault();
  7248. }
  7249. }
  7250. });
  7251. }
  7252. };
  7253. }]
  7254. });
  7255. //侧滑选择重复事件
  7256. formlyConfigProvider.setType({
  7257. name: 'ui-repeatIncidentbtn',
  7258. templateUrl: 'assets/views/customform/tpl/ui-repeatIncidentbtn.html',
  7259. defaultOptions: function (options) {
  7260. return {
  7261. templateOptions: {
  7262. relationAction: function (fields, modelscope, item) { }
  7263. },
  7264. validators: {
  7265. required: {
  7266. expression: function (viewValue, modelValue) {
  7267. // var value = modelValue || viewValue;
  7268. }
  7269. }
  7270. }
  7271. }
  7272. },
  7273. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
  7274. $scope.selection = {
  7275. id: ''
  7276. };
  7277. // 收起重复事件侧滑框
  7278. function reashdata(item) {
  7279. var fildata = {
  7280. idx: 0,
  7281. incident: {
  7282. department: {
  7283. id: $scope.model.incident.department.id,
  7284. },
  7285. },
  7286. sum: 3
  7287. }
  7288. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  7289. console.log(data)
  7290. if (data) {
  7291. $scope.repeatData = data.list;
  7292. }
  7293. })
  7294. }
  7295. reashdata();
  7296. // 确认选中的重复事件
  7297. $scope.repeatIncidentOk = function () {
  7298. if ($scope.selection.id) {
  7299. $scope.model.incident.repeat = $scope.selection;
  7300. $scope.model.isRepeat = true; //隐藏处理信息
  7301. console.log($scope.model);
  7302. }
  7303. angular.element('#repeatIncident').removeClass('active');
  7304. }
  7305. // 取消选中的重复事件
  7306. $scope.repeatIncidentCancle = function () {
  7307. angular.element('#repeatIncident').removeClass('active');
  7308. return;
  7309. }
  7310. }]
  7311. });
  7312. //侧滑选择知识库查询
  7313. formlyConfigProvider.setType({
  7314. name: 'ui-knowledgebtn',
  7315. templateUrl: 'assets/views/customform/tpl/ui-knowledgebtn.html',
  7316. defaultOptions: function (options) {
  7317. return {
  7318. templateOptions: {
  7319. relationAction: function (fields, modelscope, item) { }
  7320. },
  7321. validators: {
  7322. required: {
  7323. expression: function (viewValue, modelValue) {
  7324. // var value = modelValue || viewValue;
  7325. }
  7326. }
  7327. }
  7328. }
  7329. },
  7330. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', 'api_wechatfile', 'up_down_file', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain, api_wechatfile, up_down_file) {
  7331. // 引用知识库点击
  7332. $scope.searchKeyWord = '';
  7333. $scope.openModel = function (key) {
  7334. // alert(1)//重点
  7335. $scope.searchKeyWord = key;
  7336. if (key) {
  7337. api_zsk.solutionData({
  7338. "solution": {
  7339. threeSearch: key,
  7340. status: { id: 72 },//已发布
  7341. selectType: "keySearch"
  7342. },
  7343. "idx": "0",
  7344. "sum": "1000"
  7345. }, 'solution').then(function (response) {
  7346. $scope.searchData = response.list;
  7347. });
  7348. }
  7349. };
  7350. $scope.openModel($scope.model.incident.description)
  7351. // 展开/收起
  7352. $scope.showId = '';
  7353. $scope.ifshow = false;
  7354. $scope.showAll = function (id) {
  7355. $scope.attachments = []
  7356. if ($scope.showId == id) {
  7357. $scope.ifshow = !$scope.ifshow;
  7358. } else {
  7359. $scope.ifshow = true;
  7360. }
  7361. $scope.showId = id;
  7362. // 获取附件
  7363. api_wechatfile.listAttachments('knowledge', $scope.showId).then(function (data) {
  7364. $scope.attachments = data.data;
  7365. $scope.download = function (token, filename) {
  7366. var downUrl = up_down_file.downloadAttachment('common/common/downloadAttachment', token).getRequestedUrl();
  7367. // window.open(downUrl);
  7368. var a = document.createElement('a');
  7369. a.href = downUrl;
  7370. a.target = '_blank';
  7371. a.download = filename;
  7372. document.body.appendChild(a);
  7373. a.click();
  7374. };
  7375. })
  7376. }
  7377. // 引用
  7378. $scope.related = function (item) {
  7379. console.log(item,'引用名')
  7380. if (item.content) {
  7381. item.content = item.content.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/&nbsp;/g, '')
  7382. }
  7383. $scope.model.incident.handleDescription = item.content;
  7384. $scope.model.incident.category = item.category;
  7385. $scope.model.incident.priority.id = item.category.priority.id;
  7386. $scope.model.incident.title = $scope.model.incident.description = item.title;
  7387. item.category.label = item.category.category;
  7388. var categoryId = item.category.id;
  7389. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  7390. function getres(nodes) {
  7391. if (!nodes || nodes.length == 0) {
  7392. return;
  7393. }
  7394. nodes.forEach(e => {
  7395. e.selected = false;
  7396. if (e.id == categoryId) {
  7397. e.selected = true;
  7398. return false;
  7399. }
  7400. getres(e.children)
  7401. })
  7402. }
  7403. var categorys = [];
  7404. $scope.fields.forEach((e, i) => {
  7405. if (e.key == 'category') {
  7406. categorys = e.templateOptions.options;
  7407. if (categorys.length) {
  7408. getres(categorys);
  7409. $scope.fields[i].templateOptions.options = categorys;
  7410. $scope.$root.refreshSelectedItems();
  7411. }
  7412. return false;
  7413. }
  7414. })
  7415. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  7416. $scope.model.candidateGroups = item.category.group
  7417. // 携带关联优先级,事件工单信息的时间
  7418. if ($scope.model && $scope.model.incident && item.category && item.category.priority && item.category.priority.id) {
  7419. api_bpm_domain.expectedTime('L' + (item.category.priority.id - 1559)).then(function (res) {
  7420. $scope.model.incident.expectResponseTime = $scope.$parent.$parent.$parent.model.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  7421. $scope.model.incident.expectIntroTime = $scope.$parent.$parent.$parent.model.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  7422. $scope.model.incident.overdueTime = $scope.$parent.$parent.$parent.model.incident.overdueTime = res.date;
  7423. })
  7424. }
  7425. api_zsk.solutionQuote(item.id).then(function (response) {
  7426. if (response.status == 200) {
  7427. $('#seachknowledge').removeClass('active')
  7428. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7429. $scope.$parent.$parent.$parent.model.start_code = 'close';
  7430. $scope.$parent.$parent.$parent.model.directClose = 0;
  7431. console.log($scope.model)
  7432. } else {
  7433. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7434. };
  7435. })
  7436. }
  7437. }]
  7438. });
  7439. //下拉输入组件
  7440. formlyConfigProvider.setType({
  7441. name: 'ui-selectinput',
  7442. extends: 'input',
  7443. templateUrl: 'assets/views/customform/tpl/selectinput.html',
  7444. defaultOptions: function (options) {
  7445. return {
  7446. templateOptions: {
  7447. refresh: function () { },
  7448. refreshDelay: 0,
  7449. linkage: function (modelName, data) {
  7450. }
  7451. },
  7452. }
  7453. },
  7454. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  7455. $scope.searchData = "";
  7456. $scope.onChangeadd = function (searchData) {
  7457. // $scope.searchKey = searchData.account;
  7458. // var requesdata = angular.copy(searchData)
  7459. // $scope.requester = requesdata;
  7460. }
  7461. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7462. // $scope.searchData = searchKey;
  7463. // reashdata($scope.searchData);
  7464. }
  7465. $scope.getMydata = function (x) {
  7466. $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
  7467. $scope.searchField = $scope.model[$scope.options.key];
  7468. }
  7469. $scope.getMydataone = function (x) {
  7470. $scope.model[$scope.options.key] = x;
  7471. $scope.searchField = $scope.model[$scope.options.key];
  7472. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
  7473. $scope.hidden = false;
  7474. } else {
  7475. $scope.hidden = true;
  7476. }
  7477. }
  7478. function reashdata(item) {
  7479. $scope.myData = $scope.options.templateOptions.mydata;
  7480. }
  7481. reashdata()
  7482. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  7483. $scope.options.templateOptions.fetchItems($scope);
  7484. }
  7485. }]
  7486. });
  7487. //重构组件模板
  7488. //获取当前人
  7489. formlyConfigProvider.setType({
  7490. name: 'ui-users',
  7491. extends: 'input',
  7492. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7493. defaultOptions: function (options) {
  7494. return {
  7495. templateOptions: {
  7496. translate: '',
  7497. refreshDelay: 0
  7498. }
  7499. }
  7500. },
  7501. controller: ['$scope', function ($scope) {
  7502. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  7503. $scope.options.templateOptions.translate = $scope.$root.user.name;
  7504. }]
  7505. });
  7506. //只读控件
  7507. formlyConfigProvider.setType({
  7508. name: 'ui-label',
  7509. extends: 'input',
  7510. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7511. defaultOptions: function (options) {
  7512. return {
  7513. templateOptions: {
  7514. translate: '',
  7515. refreshDelay: 0
  7516. }
  7517. }
  7518. },
  7519. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  7520. // console.log($scope.options.templateOptions)
  7521. // console.log($scope.options,'options1122');
  7522. $scope.isSolutionLabel = false;
  7523. $scope.solutionLabelStr = "";
  7524. // console.log($scope.options.templateOptions.solotinLabel);
  7525. if ($scope.options.templateOptions.solotinLabel) {
  7526. $scope.isSolutionLabel = true;
  7527. if ($scope.model[$scope.options.key]) {
  7528. var solutionArr = $scope.model[$scope.options.key].split("/");
  7529. $scope.solutionLabelStr = solutionArr.join(" ");
  7530. }
  7531. }
  7532. var value = $scope.model[$scope.options.key];
  7533. // ----------------
  7534. // ----------------
  7535. // console.log(value, 'pppp')
  7536. function treeDesc(children, key, label) {
  7537. if (label == "") {
  7538. label = children[key];
  7539. } else {
  7540. label = children[key] + "-" + label;
  7541. }
  7542. if (angular.isDefined(children.parent)) {
  7543. treeDesc(children.parent, key, label);
  7544. } else {
  7545. return label;
  7546. }
  7547. }
  7548. if (angular.isArray(value)) {
  7549. var tempValue = "";
  7550. angular.forEach(value, function (item) {
  7551. if (tempValue != "") {
  7552. tempValue = tempValue + ",";
  7553. }
  7554. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  7555. });
  7556. $scope.options.templateOptions.translate = tempValue;
  7557. } else if (angular.isObject(value)) {
  7558. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  7559. //tree
  7560. // console.log("value.parent="+JSON.stringify(value.parent))
  7561. var nameLabel = value[$scope.options.templateOptions.labelProp];
  7562. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  7563. $scope.options.templateOptions.translate = nameLabel;
  7564. } else {
  7565. $scope.options.templateOptions.translate = value;
  7566. }
  7567. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  7568. // console.log("value=" + value);
  7569. $scope.options.templateOptions.translate = value;
  7570. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  7571. // console.log("value="+value);
  7572. // $scope.options.templateOptions.translate = value;
  7573. } else {
  7574. // var datasdf = JSON.parse(value);
  7575. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  7576. $scope.options.templateOptions.translate = value;
  7577. }
  7578. if (angular.isFunction($scope.options.templateOptions.transform)) {
  7579. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  7580. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
  7581. }
  7582. // console.log($scope.options.templateOptions.translate,99999);
  7583. }]
  7584. });
  7585. //小标题组件
  7586. formlyConfigProvider.setType({
  7587. name: 'ui-header',
  7588. template: '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>'
  7589. });
  7590. //标题组件
  7591. formlyConfigProvider.setType({
  7592. name: 'ui-title',
  7593. template: '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>'
  7594. });
  7595. //标栏是否展示
  7596. formlyConfigProvider.setType({
  7597. name: 'ui-orshow',
  7598. template: '<div class=\"panel\"><div class=\"panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix\"><h3 class=\"pull-left panel-title text-head margin-left-10\" ng-if=\"options.templateOptions.label\">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
  7599. controller: ['$scope', function ($scope) {
  7600. $scope.clickshow = function (key) {
  7601. // $scope.model[$scope.options.key] != key;
  7602. if (key == false) {
  7603. $scope.model[$scope.options.key] = true
  7604. } else {
  7605. $scope.model[$scope.options.key] = false
  7606. }
  7607. }
  7608. }]
  7609. });
  7610. //按钮组
  7611. formlyConfigProvider.setType({
  7612. name: 'ui-button',
  7613. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  7614. defaultOptions: function (options) {
  7615. return {
  7616. noFormControl: true
  7617. }
  7618. }
  7619. });
  7620. //3d组link
  7621. formlyConfigProvider.setType({
  7622. name: 'ui-link',
  7623. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  7624. defaultOptions: function (options) {
  7625. return {
  7626. noFormControl: true
  7627. }
  7628. }
  7629. });
  7630. //隐藏域组件
  7631. formlyConfigProvider.setType({
  7632. name: 'ui-hidden',
  7633. extends: 'input',
  7634. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  7635. defaultOptions: function (options) {
  7636. return {
  7637. // noFormControl: true
  7638. };
  7639. }
  7640. });
  7641. //文本框组件
  7642. formlyConfigProvider.setType({
  7643. name: 'ui-input',
  7644. extends: 'input',
  7645. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7646. defaultOptions: function (options) {
  7647. return {
  7648. templateOptions: {
  7649. transform: function (value) { }
  7650. }
  7651. };
  7652. },
  7653. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7654. // console.log($scope.model[$scope.options.key]);
  7655. // console.log($scope.options)
  7656. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7657. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7658. }
  7659. }]
  7660. });
  7661. //搜索下拉框-故障地点seimin
  7662. formlyConfigProvider.setType({
  7663. name: 'ui-select-search',
  7664. extends: 'input',
  7665. templateUrl: 'assets/views/customform/tpl/ui-select-search.html',
  7666. defaultOptions: function (options) {
  7667. return {
  7668. templateOptions: {
  7669. transform: function (value) { }
  7670. }
  7671. };
  7672. },
  7673. controller: ['$scope','$rootScope', 'api_search_area', function ($scope,$rootScope, api_search_area) {
  7674. // console.log($scope.options, $scope.model)
  7675. // ----------------分割线 start-----------------
  7676. // 故障地点下拉
  7677. $scope.address_arr = [];//故障地点所有数据
  7678. $scope.addressFlag = false;//默认下拉框列表隐藏
  7679. //点击文本框
  7680. $scope.AddressClickHandle = function () {
  7681. $scope.getDepartmentList();
  7682. angular.element('#bx_address_ul').scrollTop(0);
  7683. }
  7684. //修改文字,实时监听
  7685. $scope.ksChangeHandle = _.debounce(function () {
  7686. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === undefined ? '' : $scope.model[$scope.options.key];
  7687. $scope.getDepartmentList();
  7688. angular.element('#bx_address_ul').scrollTop(0);
  7689. }, 500)
  7690. //获取故障地点seimin
  7691. $scope.getDepartmentList = function () {
  7692. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === null ? '' : $scope.model[$scope.options.key];
  7693. api_search_area.getAreaList({ "searchKey": $scope.model[$scope.options.key] })
  7694. .then(res => {
  7695. if (res.state == 200) {
  7696. $scope.address_arr = res.result;
  7697. $scope.addressFlag = true;//显示
  7698. }
  7699. })
  7700. .catch(err => {
  7701. console.log(err);
  7702. })
  7703. }
  7704. // $scope.getDepartmentList();
  7705. // console.log($scope.model[$scope.options.key])
  7706. //下拉框列表选中
  7707. $scope.addressItemClick = function (obj) {
  7708. $scope.addressFlag = false;//隐藏
  7709. $scope.model[$scope.options.key] = obj.place ? obj.area.area + obj.place : obj.area;
  7710. //选择故障地点后带入区域地点2020年4月23日15:20:44
  7711. $scope.model.selecthouseNumber = obj;
  7712. console.log($scope,77777)
  7713. $scope.$root.selecthouseNumber = obj;
  7714. }
  7715. //点击空白处隐藏
  7716. angular.element(document).on('click', function (e) {
  7717. if (e.target !== angular.element('#bx_address').get(0)) {
  7718. $scope.addressFlag = false;//隐藏
  7719. //模拟placeholder
  7720. // if ($('#bx_address').val() == '') {
  7721. // $('#bx_address').val('请选择报修科室');
  7722. // }
  7723. }
  7724. })
  7725. // -----------------分割线 end----------------
  7726. }]
  7727. });
  7728. //知识库关键字组件
  7729. formlyConfigProvider.setType({
  7730. name: 'ui-knowledgeKeywords',
  7731. extends: 'input',
  7732. templateUrl: 'assets/views/customform/tpl/ui-knowledgeKeywords.html',
  7733. defaultOptions: function (options) {
  7734. return {
  7735. templateOptions: {
  7736. transform: function (value) { }
  7737. }
  7738. };
  7739. },
  7740. controller: ['$scope', '$timeout', 'SweetAlert', function ($scope, $timeout, SweetAlert) {
  7741. $scope.valueLength = [{
  7742. "value": ""
  7743. }];
  7744. $scope.valueAll = [];
  7745. if ($scope.model[$scope.options.key]) {
  7746. var valueArr = $scope.model[$scope.options.key].split("/");
  7747. $scope.valueLength = [];
  7748. for (var i = 0; i < valueArr.length; i++) {
  7749. $scope.valueLength.push({
  7750. "value": valueArr[i]
  7751. })
  7752. }
  7753. }
  7754. $scope.addIpt = function () {
  7755. if ($scope.valueLength.length < 5) {
  7756. $scope.valueLength.push({
  7757. "value": ""
  7758. })
  7759. } else {
  7760. SweetAlert.swal({
  7761. title: "添加失败",
  7762. text: "关键字不能超过5个!",
  7763. type: "error",
  7764. confirmButtonColor: "#DD6B55"
  7765. });
  7766. }
  7767. };
  7768. $scope.closeIpt = function (data) {
  7769. $scope.valueLength.splice(data, 1)
  7770. }
  7771. $scope.toOption = function () {
  7772. $scope.valueAll = [];
  7773. for (var i = 0; i < $scope.valueLength.length; i++) {
  7774. if ($scope.valueLength[i].value != "") {
  7775. $scope.valueAll.push($scope.valueLength[i].value)
  7776. }
  7777. }
  7778. $scope.model.label = $scope.valueAll.join("/")
  7779. }
  7780. }]
  7781. });
  7782. //文本框组件
  7783. formlyConfigProvider.setType({
  7784. name: 'ui-num',
  7785. extends: 'input',
  7786. templateUrl: 'assets/views/customform/tpl/ui-num.html',
  7787. defaultOptions: function (options) {
  7788. return {
  7789. templateOptions: {
  7790. transform: function (value) { }
  7791. }
  7792. };
  7793. },
  7794. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7795. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7796. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7797. }
  7798. $scope.clearNoNum = function (obj, attr) {
  7799. //先把非数字的都替换掉,除了数字和.
  7800. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  7801. //必须保证第一个为数字而不是.
  7802. obj[attr] = obj[attr].replace(/^\./g, "");
  7803. //保证只有出现一个.而没有多个.
  7804. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  7805. //保证.只出现一次,而不能出现两次以上
  7806. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  7807. //小于最大值
  7808. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  7809. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  7810. // obj[attr] = '';
  7811. // }
  7812. }
  7813. }]
  7814. });
  7815. // //关联请求人文本框组件
  7816. // formlyConfigProvider.setType({
  7817. // name: 'ui-requestinput',
  7818. // extends: 'input',
  7819. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7820. // defaultOptions: function(options) {
  7821. // return {
  7822. // templateOptions: {
  7823. // transform: function(value) {},
  7824. // linkData: function(options) {}
  7825. // }
  7826. // };
  7827. // }
  7828. // });
  7829. //只读文本
  7830. formlyConfigProvider.setType({
  7831. name: 'ui-disableinput',
  7832. extends: 'input',
  7833. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  7834. defaultOptions: function (options) {
  7835. return {
  7836. templateOptions: {
  7837. transform: function (value) {
  7838. var ret = "";
  7839. if (value) {
  7840. ret = "已删除";
  7841. } else {
  7842. ret = "正常";
  7843. }
  7844. return ret;
  7845. }
  7846. }
  7847. };
  7848. }
  7849. });
  7850. formlyConfigProvider.setType({
  7851. name: 'ui-disinput',
  7852. extends: 'input',
  7853. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  7854. defaultOptions: function (options) {
  7855. return {
  7856. templateOptions: {}
  7857. };
  7858. }
  7859. });
  7860. //数字组件
  7861. formlyConfigProvider.setType({
  7862. name: 'ui-number',
  7863. extends: 'input',
  7864. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  7865. defaultOptions: function (options) {
  7866. return {
  7867. templateOptions: {}
  7868. };
  7869. },
  7870. controller: ['$scope', function ($scope) { }]
  7871. });
  7872. //含有周的日期
  7873. formlyConfigProvider.setType({
  7874. name: 'ui-datepickerweek',
  7875. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  7876. extends: 'input',
  7877. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  7878. defaultOptions: {
  7879. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  7880. templateOptions: {
  7881. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  7882. }
  7883. },
  7884. controller: ['$scope', '$filter', function ($scope, $filter) {
  7885. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  7886. if ($scope.model[$scope.options.key]) {
  7887. } else {
  7888. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  7889. }
  7890. $scope.options.initialValue = $scope.model[$scope.options.key];
  7891. $scope.endOpen = true;
  7892. $scope.datepicker = {};
  7893. $scope.datepicker.opened = false;
  7894. $scope.datepicker.open = function ($event) {
  7895. $scope.datepicker.opened = true;
  7896. };
  7897. }]
  7898. });
  7899. //lmm
  7900. //分配任务列表
  7901. formlyConfigProvider.setType({
  7902. name: 'jry_taskDistributionList',
  7903. templateUrl: 'assets/views/customform/tpl/jry_taskDistributionList.html',
  7904. wrapper: ['bootstrapHasError'],
  7905. defaultOptions: function (options, $scope) {
  7906. return {
  7907. templateOptions: {
  7908. }
  7909. };
  7910. },
  7911. controller: function ($rootScope, $scope, api_user_data, $modal, api_doc_data, i18nService, SweetAlert, api_wechatfile) {
  7912. // 获取状态
  7913. $scope.stateListData = {};
  7914. $scope.getStateData = function () {//lyl
  7915. var data = {
  7916. "key": 'task_sub_state',
  7917. "type": 'list'
  7918. }
  7919. api_wechatfile.getDictionary(data).then(function (res) {
  7920. angular.forEach(res, function (v, i) {
  7921. $scope.stateListData[v.value] = v.id;
  7922. })
  7923. })
  7924. }
  7925. $scope.getStateData();
  7926. var loginUser = $rootScope.user;
  7927. $scope.langs = i18nService.getAllLangs();
  7928. $scope.lang = 'zh-cn';
  7929. i18nService.setCurrentLang($scope.lang);
  7930. $scope.gridOptions = {};
  7931. $scope.gridOptions.data = 'myData';
  7932. $scope.gridOptions.enableColumnResizing = true;
  7933. $scope.gridOptions.enableGridMenu = false;
  7934. $scope.gridOptions.enableRowSelection = true;
  7935. $scope.gridOptions.showGridFooter = true;
  7936. $scope.gridOptions.showColumnFooter = false;
  7937. $scope.gridOptions.fastWatch = true;
  7938. $scope.gridOptions.useExternalFiltering = true;
  7939. $scope.gridOptions.useExternalPagination = true;
  7940. $scope.gridOptions.paginationPageSizes = [10];
  7941. $scope.gridOptions.paginationPageSize = 10;
  7942. $scope.gridOptions.multiSelect = true;
  7943. $scope.gridOptions.rowIdentity = function (row) {
  7944. return row.id;
  7945. };
  7946. $scope.gridOptions.getRowIdentity = function (row) {
  7947. return row.id;
  7948. };
  7949. // console.log($scope.model);//lmmmm
  7950. $scope.gridOptions.columnDefs = [{
  7951. name: 'item',
  7952. displayName: '序号',
  7953. width: "10%",
  7954. cellTemplate: '<div>' +
  7955. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  7956. '</div>'
  7957. },
  7958. {
  7959. name: 'taskDescribe',
  7960. displayName: '任务说明',
  7961. width: "25%",
  7962. enableFiltering: false,
  7963. cellTemplate: '<div>' +
  7964. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  7965. '</div>'
  7966. },
  7967. {
  7968. name: 'assign.name',
  7969. displayName: '指派人',
  7970. width: "5%",
  7971. enableFiltering: false,
  7972. cellTemplate: '<div>' +
  7973. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  7974. '</div>'
  7975. },
  7976. {
  7977. name: 'startTime',
  7978. displayName: '开始时间',
  7979. width: '13%',
  7980. enableFiltering: false,
  7981. cellTemplate: '<div>' +
  7982. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  7983. '</div>'
  7984. },
  7985. {
  7986. name: 'endTime',
  7987. displayName: '结束时间',
  7988. width: '13%',
  7989. enableFiltering: false,
  7990. cellTemplate: '<div>' +
  7991. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  7992. '</div>'
  7993. },
  7994. {
  7995. name: 'priority.name',
  7996. displayName: '优先级',
  7997. width: "5%",
  7998. enableFiltering: false,
  7999. cellTemplate: '<div>' +
  8000. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  8001. '</div>'
  8002. },
  8003. {
  8004. name: 'state.name',
  8005. displayName: '状态',
  8006. width: "5%",
  8007. enableFiltering: false,
  8008. cellTemplate: '<div>' +
  8009. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  8010. '</div>'
  8011. },
  8012. {
  8013. name: '操作',//lmmm
  8014. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  8015. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  8016. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  8017. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  8018. '<a ng-click="grid.appScope.see(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[2]||row.entity.state.id==grid.appScope.stateListData[3]||grid.appScope.model.showSee">查看</a>' +
  8019. '</div></div>',
  8020. enableFiltering: false
  8021. }
  8022. ];
  8023. // 查看
  8024. $scope.see = function (data) {
  8025. $scope.seeData = data;
  8026. var modalInstance = $modal.open({
  8027. backdrop: false,
  8028. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8029. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8030. $scope.personData = {}; //指派人
  8031. $scope.priorityData = {}; //优先级
  8032. $scope.personListData = {}; //指派人下拉数据
  8033. $scope.priorityListData = {}; //优先级下拉数据
  8034. $scope.startTime = ""; //开始时间
  8035. $scope.releaseShow = "no";
  8036. $scope.subShow = "no";
  8037. $scope.onlySee = "ok";
  8038. $scope.endTime = ""; //结束时间
  8039. $scope.taskDescribe = ""; //任务描述
  8040. $scope.taskDescribe = scope.seeData.taskDescribe;
  8041. $scope.personData.data = scope.seeData.assign;
  8042. $scope.priorityData.data = scope.seeData.priority;
  8043. $scope.startTime = scope.seeData.startTime;
  8044. $scope.endTime = scope.seeData.endTime;
  8045. $scope.done = scope.seeData.done;
  8046. $scope.feedback = scope.seeData.feedback;
  8047. $scope.cancel = function () {
  8048. $modalInstance.dismiss('cancel');
  8049. }
  8050. },
  8051. size: 'sm',
  8052. resolve: {
  8053. scope: function () {
  8054. return $scope;
  8055. },
  8056. },
  8057. backdrop: true
  8058. });
  8059. }
  8060. // 编辑
  8061. $scope.edit = function (data) {
  8062. $scope.editData = data;
  8063. var modalInstance = $modal.open({
  8064. backdrop: false,
  8065. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8066. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8067. console.log(scope.editData);
  8068. $scope.personData = {}; //指派人
  8069. $scope.priorityData = {}; //优先级
  8070. $scope.personListData = {}; //指派人下拉数据
  8071. $scope.priorityListData = {}; //优先级下拉数据
  8072. $scope.startTime = ""; //开始时间
  8073. $scope.releaseShow = "no";
  8074. $scope.endTime = ""; //结束时间
  8075. $scope.taskDescribe = ""; //任务描述
  8076. $scope.taskDescribe = scope.editData.taskDescribe;
  8077. $scope.personData.data = scope.editData.assign;
  8078. $scope.priorityData.data = scope.editData.priority;
  8079. $scope.startTime = scope.editData.startTime;
  8080. $scope.endTime = scope.editData.endTime;
  8081. // 指派人下拉框数据
  8082. $scope.getPersonData = function () {
  8083. var data = {
  8084. "idx": 0,
  8085. "sum": 1000
  8086. }
  8087. api_user_data.fetchDataList("user", data).then(function (res) {
  8088. $scope.personListData = res.list;
  8089. })
  8090. }
  8091. $scope.getPersonData();
  8092. //优先级下拉数据
  8093. $scope.getPriorityData = function () {
  8094. var data = {
  8095. "key": "change_rick_level",
  8096. "type": "list"
  8097. }
  8098. api_wechatfile.getDictionary(data).then(function (res) {
  8099. $scope.priorityListData = res
  8100. })
  8101. }
  8102. $scope.getPriorityData();
  8103. // 获取状态-lmm
  8104. $scope.stateListData = {};
  8105. $scope.getStateData = function () {//lyl
  8106. var data = {
  8107. "key": 'task_sub_state',
  8108. "type": 'list'
  8109. }
  8110. api_wechatfile.getDictionary(data).then(function (res) {
  8111. angular.forEach(res, function (v, i) {
  8112. $scope.stateListData[v.value] = v.id;
  8113. })
  8114. })
  8115. }
  8116. $scope.getStateData();
  8117. //时间控件
  8118. $scope.open = function ($event) {
  8119. $event.preventDefault();
  8120. $event.stopPropagation();
  8121. $scope.opened = !$scope.opened;
  8122. };
  8123. $scope.endOpen = function ($event) {
  8124. $event.preventDefault();
  8125. $event.stopPropagation();
  8126. $scope.startOpened = false;
  8127. $scope.endOpened = !$scope.endOpened;
  8128. };
  8129. $scope.startOpen = function ($event) {
  8130. $event.preventDefault();
  8131. $event.stopPropagation();
  8132. $scope.endOpened = false;
  8133. $scope.startOpened = !$scope.startOpened;
  8134. };
  8135. // 确定
  8136. $scope.ok = function (item) {
  8137. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8138. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8139. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8140. $scope.addData = {
  8141. "taskSub": {
  8142. "taskDescribe": $scope.taskDescribe,
  8143. "assign": $scope.personData.data,
  8144. "priority": $scope.priorityData.data,
  8145. "startTime": $scope.startTime,
  8146. "endTime": $scope.endTime,
  8147. "taskMonth": {
  8148. "id": scope.model.taskMonth.id
  8149. },
  8150. "id": scope.editData.id
  8151. }
  8152. }
  8153. $scope.addData.taskSub["state"] = {
  8154. "id": $scope.stateListData[1]
  8155. };
  8156. api_user_data.updData('taskSub', $scope.addData).then(function (res) {
  8157. if (res.status == 200) {
  8158. SweetAlert.swal({
  8159. title: "修改成功!",
  8160. type: "success",
  8161. confirmButtonColor: "#007AFF"
  8162. });
  8163. scope.refreshData(scope.jry_filterdata);
  8164. $modalInstance.dismiss('cancel');
  8165. } else {
  8166. SweetAlert.swal({
  8167. title: "修改失败",
  8168. text: "系统错误,请重试!",
  8169. type: "error"
  8170. });
  8171. $modalInstance.dismiss('cancel');
  8172. }
  8173. })
  8174. } else {
  8175. SweetAlert.swal({
  8176. title: "修改失败",
  8177. text: "必填项不能为空!",
  8178. type: "error"
  8179. });
  8180. }
  8181. };
  8182. $scope.cancel = function () {
  8183. $modalInstance.dismiss('cancel');
  8184. }
  8185. },
  8186. size: 'sm',
  8187. resolve: {
  8188. scope: function () {
  8189. return $scope;
  8190. },
  8191. },
  8192. backdrop: true
  8193. });
  8194. }
  8195. // 发布
  8196. $scope.release = function (data) {
  8197. SweetAlert.swal({
  8198. title: "确认发布?",
  8199. text: "请确定发布操作!",
  8200. type: "warning",
  8201. showCancelButton: true,
  8202. confirmButtonColor: "#DD6B55",
  8203. confirmButtonText: "确定",
  8204. cancelButtonText: "取消",
  8205. closeOnConfirm: false,
  8206. closeOnCancel: false
  8207. }, function (isConfirm) {
  8208. if (isConfirm) {
  8209. data.state.id = $scope.stateListData[2];
  8210. delete data.item;
  8211. api_user_data.updData("taskSub", {
  8212. taskSub: data
  8213. }).then(function (res) {
  8214. if (res.status == 200) {
  8215. SweetAlert.swal({
  8216. title: "发布成功!",
  8217. type: "success",
  8218. confirmButtonColor: "#007AFF"
  8219. });
  8220. $scope.refreshData($scope.jry_filterdata);
  8221. } else {
  8222. SweetAlert.swal({
  8223. title: "删除失败",
  8224. text: "系统错误,请重试!",
  8225. type: "error"
  8226. });
  8227. }
  8228. })
  8229. } else {
  8230. SweetAlert.swal("操作取消", "发布取消", "error");
  8231. }
  8232. });
  8233. }
  8234. // 删除
  8235. $scope.remove = function (data) {
  8236. SweetAlert.swal({
  8237. title: "确认删除?",
  8238. text: "删除的数据不可恢复,请确认继续操作!",
  8239. type: "warning",
  8240. showCancelButton: true,
  8241. confirmButtonColor: "#DD6B55",
  8242. confirmButtonText: "继续删除",
  8243. cancelButtonText: "取消操作",
  8244. closeOnConfirm: false,
  8245. closeOnCancel: false
  8246. }, function (isConfirm) {
  8247. if (isConfirm) {
  8248. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  8249. if (res.status == 200) {
  8250. SweetAlert.swal({
  8251. title: "删除成功!",
  8252. type: "success",
  8253. confirmButtonColor: "#007AFF"
  8254. });
  8255. $scope.refreshData($scope.jry_filterdata);
  8256. } else {
  8257. SweetAlert.swal({
  8258. title: "删除失败",
  8259. text: "系统错误,请重试!",
  8260. type: "error"
  8261. });
  8262. }
  8263. })
  8264. } else {
  8265. SweetAlert.swal("操作取消", "数据安全", "error");
  8266. }
  8267. });
  8268. }
  8269. $scope.refreshData = function (filterData) {
  8270. // $scope.ldloading[style.replace('-', '_')] = true;
  8271. if (angular.isUndefined(filterData)) {
  8272. filterData = defaultFilterData;
  8273. }
  8274. $scope.myData = [];
  8275. $scope.memoryfilterData = filterData;
  8276. api_doc_data.fetchDataList('taskSub', filterData).then(function (data) {
  8277. var myData = data;
  8278. $scope.gridOptions.totalItems = myData.totalNum;
  8279. $scope.removeFileNum = myData.totalNum;
  8280. if (angular.isArray(myData.list)) {
  8281. $scope.myData = myData.list;
  8282. for (var i = 0; i < $scope.myData.length; i++) {
  8283. //添加序号
  8284. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  8285. $scope.myData[i].startTime = moment($scope.myData[i].startTime).format('YYYY-MM-DD HH:mm:ss');
  8286. $scope.myData[i].endTime = moment($scope.myData[i].endTime).format('YYYY-MM-DD HH:mm:ss');
  8287. }
  8288. }
  8289. }, function () {
  8290. // $scope.ldloading[style.replace('-', '_')] = false;
  8291. });
  8292. };
  8293. //分页控制
  8294. $scope.gridOptions.onRegisterApi = function (gridApi) {
  8295. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  8296. $scope.jry_filterdata.idx = newPage - 1;
  8297. $scope.fenye = newPage - 1;
  8298. $scope.jry_filterdata.sum = pageSize;
  8299. $scope.refreshData($scope.jry_filterdata);
  8300. });
  8301. }
  8302. $scope.fenye = 0;
  8303. if ($scope.model.label == "分配任务") {
  8304. $scope.jry_filterdata = {
  8305. "idx": $scope.fenye,
  8306. "sum": 10,
  8307. "taskSub": {
  8308. "taskMonth": {
  8309. "id": $scope.model.taskMonth.id
  8310. },
  8311. "userid": loginUser.id,
  8312. "role": loginUser.role
  8313. }
  8314. };
  8315. } else {
  8316. $scope.jry_filterdata = {
  8317. "idx": $scope.fenye,
  8318. "sum": 10,
  8319. "taskSub": {
  8320. "taskMonth": {
  8321. "id": $scope.model.taskMonth.id
  8322. },
  8323. "userid": loginUser.id,
  8324. "role": loginUser.role,
  8325. "type": 1
  8326. }
  8327. };
  8328. }
  8329. $scope.refreshData($scope.jry_filterdata);
  8330. //新增模态框
  8331. $scope.newDistribution = function () {
  8332. var modalInstance = $modal.open({
  8333. backdrop: false,
  8334. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8335. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8336. $scope.personData = {}; //指派人
  8337. $scope.priorityData = {}; //优先级
  8338. $scope.personListData = {}; //指派人下拉数据
  8339. $scope.priorityListData = {}; //优先级下拉数据
  8340. $scope.startTime = ""; //开始时间
  8341. $scope.endTime = ""; //结束时间
  8342. $scope.taskDescribe = ""; //任务描述
  8343. $scope.motaikuang = "";
  8344. $scope.shijian = "哈哈";
  8345. // 指派人下拉框数据
  8346. $scope.getPersonData = function () {
  8347. var data = {
  8348. "idx": 0,
  8349. "sum": 1000
  8350. }
  8351. api_user_data.fetchDataList("user", data).then(function (res) {
  8352. $scope.personListData = res.list;
  8353. })
  8354. }
  8355. $scope.getPersonData();
  8356. //优先级下拉数据
  8357. $scope.getPriorityData = function () {
  8358. var data = {
  8359. "key": "change_rick_level",
  8360. "type": "list"
  8361. }
  8362. api_wechatfile.getDictionary(data).then(function (res) {
  8363. $scope.priorityListData = res
  8364. })
  8365. }
  8366. // 控制结束时间的最大时间
  8367. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  8368. // 控制结束时间的最小时间
  8369. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  8370. $scope.$watch('startTime', function (n, o) {
  8371. if (n) {
  8372. if (n > scope.model.taskMonth.startTime) {
  8373. $scope.jryEndMinTime = n
  8374. }
  8375. }
  8376. })
  8377. // 控制开始时间的最小时间
  8378. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  8379. // 控制开始时间的最大时间
  8380. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  8381. $scope.$watch('endTime', function (n, o) {
  8382. if (n) {
  8383. if (n < scope.model.taskMonth.endTime) {
  8384. $scope.jryStartMaxTime = n
  8385. }
  8386. }
  8387. })
  8388. $scope.getPriorityData();
  8389. //时间控件
  8390. $scope.open = function ($event) {
  8391. $event.preventDefault();
  8392. $event.stopPropagation();
  8393. $scope.opened = !$scope.opened;
  8394. };
  8395. $scope.endOpen = function ($event) {
  8396. $event.preventDefault();
  8397. $event.stopPropagation();
  8398. $scope.startOpened = false;
  8399. $scope.endOpened = !$scope.endOpened;
  8400. };
  8401. $scope.startOpen = function ($event) {
  8402. $event.preventDefault();
  8403. $event.stopPropagation();
  8404. $scope.endOpened = false;
  8405. $scope.startOpened = !$scope.startOpened;
  8406. };
  8407. $scope.datepickerPopup = 'yyyy-MM-dd HH:mm:ss';
  8408. // 获取状态-lmm
  8409. $scope.stateListData = {};
  8410. $scope.getStateData = function () {//lyl
  8411. var data = {
  8412. "key": 'task_sub_state',
  8413. "type": 'list'
  8414. }
  8415. api_wechatfile.getDictionary(data).then(function (res) {
  8416. angular.forEach(res, function (v, i) {
  8417. $scope.stateListData[v.value] = v.id;
  8418. })
  8419. })
  8420. }
  8421. $scope.getStateData();
  8422. // 草稿保存
  8423. $scope.ok = function (item) {
  8424. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8425. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8426. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8427. $scope.addData = {
  8428. "taskSub": {
  8429. "taskDescribe": $scope.taskDescribe,
  8430. "assign": $scope.personData.data,
  8431. "priority": $scope.priorityData.data,
  8432. "startTime": $scope.startTime,
  8433. "endTime": $scope.endTime,
  8434. "taskMonth": {
  8435. "id": scope.model.taskMonth.id
  8436. }
  8437. }
  8438. }
  8439. $scope.addData.taskSub["state"] = {
  8440. "id": $scope.stateListData[1]
  8441. };
  8442. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8443. if (res.status == 200) {
  8444. SweetAlert.swal({
  8445. title: "保存成功!",
  8446. type: "success",
  8447. confirmButtonColor: "#007AFF"
  8448. });
  8449. scope.refreshData(scope.jry_filterdata);
  8450. $modalInstance.dismiss('cancel');
  8451. } else {
  8452. SweetAlert.swal({
  8453. title: "保存失败",
  8454. text: "系统错误,请重试!",
  8455. type: "error"
  8456. });
  8457. $modalInstance.dismiss('cancel');
  8458. }
  8459. })
  8460. } else {
  8461. SweetAlert.swal({
  8462. title: "保存失败",
  8463. text: "必填项不能为空!",
  8464. type: "error"
  8465. });
  8466. }
  8467. };
  8468. // 发布
  8469. $scope.release = function () {
  8470. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8471. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8472. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8473. $scope.addData = {
  8474. "taskSub": {
  8475. "taskDescribe": $scope.taskDescribe,
  8476. "assign": $scope.personData.data,
  8477. "priority": $scope.priorityData.data,
  8478. "startTime": $scope.startTime,
  8479. "endTime": $scope.endTime,
  8480. "taskMonth": {
  8481. "id": scope.model.taskMonth.id
  8482. }
  8483. }
  8484. }
  8485. $scope.addData.taskSub["state"] = {
  8486. "id": $scope.stateListData[1]
  8487. };
  8488. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8489. if (res.status == 200) {
  8490. SweetAlert.swal({
  8491. title: "保存成功!",
  8492. type: "success",
  8493. confirmButtonColor: "#007AFF"
  8494. });
  8495. scope.refreshData(scope.jry_filterdata);
  8496. $modalInstance.dismiss('cancel');
  8497. } else {
  8498. SweetAlert.swal({
  8499. title: "保存失败",
  8500. text: "系统错误,请重试!",
  8501. type: "error"
  8502. });
  8503. $modalInstance.dismiss('cancel');
  8504. }
  8505. })
  8506. } else {
  8507. SweetAlert.swal({
  8508. title: "保存失败",
  8509. text: "必填项不能为空!",
  8510. type: "error"
  8511. });
  8512. }
  8513. }
  8514. $scope.cancel = function () {
  8515. $modalInstance.dismiss('cancel');
  8516. }
  8517. },
  8518. size: 'sm',
  8519. resolve: {
  8520. scope: function () {
  8521. return $scope;
  8522. },
  8523. },
  8524. backdrop: true
  8525. });
  8526. }
  8527. }
  8528. });
  8529. // 多次反馈文本域组件--jry
  8530. formlyConfigProvider.setType({
  8531. name: 'ui-feedbacktTextarea',
  8532. extends: 'textarea',
  8533. templateUrl: 'assets/views/customform/tpl/ui-feedbacktTextarea.html',
  8534. defaultOptions: function (options) {
  8535. return {
  8536. templateOptions: {
  8537. transform: function (model, value) {
  8538. return value;
  8539. },
  8540. },
  8541. validation: {
  8542. messages: {
  8543. maxlength: function (viewValue, modelValue, scope) {
  8544. if (viewValue != null) {
  8545. if (viewValue.length > scope.to.maxlength) {
  8546. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8547. } else {
  8548. return "";
  8549. }
  8550. }
  8551. },
  8552. }
  8553. }
  8554. }
  8555. },
  8556. controller: ['$scope', 'moment', function ($scope, moment) {
  8557. // console.log($scope);
  8558. var timeKey = $scope.options.templateOptions.time;
  8559. $scope.time = moment($scope.model[timeKey]).format('YYYY-MM-DD HH:mm:ss');
  8560. var value = $scope.model[$scope.options.key];
  8561. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8562. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8563. }
  8564. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  8565. $scope.options.templateOptions.felditem($scope);
  8566. }
  8567. }]
  8568. });
  8569. //任务管理开始时间--jry
  8570. formlyConfigProvider.setType({
  8571. name: 'ui-jryStartdatepicker',
  8572. templateUrl: 'assets/views/customform/tpl/ui-jryStartdatepicker.html',
  8573. extends: 'input',
  8574. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8575. defaultOptions: {
  8576. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8577. templateOptions: {
  8578. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8579. }
  8580. },
  8581. controller: ['$scope', '$filter', function ($scope, $filter) {
  8582. // console.log($scope.model[$scope.options.key],'lmm');
  8583. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8584. if ($scope.model[$scope.options.key]) {
  8585. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8586. }
  8587. // console.log($scope.model[$scope.options.key],'lmm');
  8588. // console.log($scope.model,'lmm',$scope.options.key);
  8589. $scope.options.initialValue = $scope.model[$scope.options.key];
  8590. $scope.endOpen = true;
  8591. $scope.datepicker = {};
  8592. $scope.datepicker.opened = false;
  8593. $scope.datepicker.open = function ($event) {
  8594. $scope.datepicker.opened = true;
  8595. };
  8596. }]
  8597. });
  8598. //任务管理结束时间--jry
  8599. formlyConfigProvider.setType({
  8600. name: 'ui-jryEnddatepicker',
  8601. templateUrl: 'assets/views/customform/tpl/ui-jryEnddatepicker.html',
  8602. extends: 'input',
  8603. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8604. defaultOptions: {
  8605. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8606. templateOptions: {
  8607. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8608. }
  8609. },
  8610. controller: ['$scope', '$filter', function ($scope, $filter) {
  8611. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8612. if ($scope.model[$scope.options.key]) {
  8613. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8614. }
  8615. $scope.options.initialValue = $scope.model[$scope.options.key];
  8616. $scope.endOpen = true;
  8617. $scope.datepicker = {};
  8618. $scope.datepicker.opened = false;
  8619. $scope.datepicker.open = function ($event) {
  8620. $scope.datepicker.opened = true;
  8621. };
  8622. }]
  8623. });
  8624. //下拉多选框灵活组件--jry
  8625. formlyConfigProvider.setType({
  8626. name: 'ui-jry_multiselectplus',
  8627. extends: 'multiCheckbox',
  8628. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8629. defaultOptions: function (options) {
  8630. return {
  8631. templateOptions: {
  8632. refreshData: function (search, options, model, that) {
  8633. // var process = options.templateOptions.ApiService.all("");
  8634. if (search) {
  8635. } else {
  8636. }
  8637. var postData = options.templateOptions.optionsPostData;
  8638. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8639. postData = options.templateOptions.optionsPostData(options, model, that);
  8640. }
  8641. options.templateOptions.ApiService.fetchDataList(options.templateOptions.optionsUrl, options.templateOptions.optionsPostData).then(function (result) {
  8642. // if (!options.templateOptions.options) {
  8643. // options.templateOptions.options = [];
  8644. // }
  8645. if (options.templateOptions.optionsDataKey) {
  8646. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8647. } else {
  8648. options.templateOptions.options = result;
  8649. }
  8650. if (options.templateOptions.optionsChecked) {
  8651. // return options.value = null;
  8652. options.value(options.model[options.key]);
  8653. }
  8654. });
  8655. },
  8656. refreshDelay: 0,
  8657. // },
  8658. validators: {
  8659. required: {
  8660. expression: function (viewValue, modelValue) {
  8661. var value = modelValue || viewValue;
  8662. return value != null;
  8663. // return value.length>=1;
  8664. // if (modelValue && viewValue) {
  8665. // return value != null;
  8666. // } else {
  8667. // var value = modelValue || viewValue;
  8668. // return value.length > 0;
  8669. // }
  8670. }
  8671. }
  8672. }
  8673. }
  8674. };
  8675. },
  8676. controller: ['$scope', function ($scope) {
  8677. console.log($scope.to);
  8678. if (angular.isArray($scope.model[$scope.options.key])) {
  8679. } else {
  8680. $scope.model[$scope.options.key] = [];
  8681. }
  8682. }]
  8683. });
  8684. //下拉框组件
  8685. formlyConfigProvider.setType({
  8686. name: 'ui-select',
  8687. extends: 'select',
  8688. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  8689. defaultOptions: function (options, scope) {
  8690. return {
  8691. templateOptions: {
  8692. // refresh: function() {},
  8693. refreshDelay: 0,
  8694. linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
  8695. console.log(model,'model')
  8696. angular.extend(data, {
  8697. "idx": 0,
  8698. "sum": 1000
  8699. });
  8700. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  8701. var myData = options.templateOptions.Restangular.stripRestangular(response);
  8702. var list = myData.list;
  8703. console.log(myData)
  8704. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  8705. // console.log('balabalabala');
  8706. // console.log(res);
  8707. // })
  8708. if (list.length == 1) {
  8709. if (options.templateOptions.APIport) {
  8710. options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
  8711. if (response.state == "200") {
  8712. // if (model.$parent.model && model.$parent.model.incident) {
  8713. // } else {
  8714. // model.$parent.model = { 'incident': {} };
  8715. // }
  8716. var myDatas = response.serviceLevelAgreement;
  8717. //逾期
  8718. scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
  8719. //解决
  8720. scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
  8721. //响应
  8722. scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
  8723. } else {
  8724. }
  8725. });
  8726. }
  8727. angular.forEach(model.fields, function (item) {
  8728. angular.forEach(model.fields, function (item) {
  8729. if (item.templateOptions.pkey == modelKey + "." + key) {
  8730. item.model.id = "";
  8731. if (key == "place") {
  8732. item.templateOptions.options = list;
  8733. } else if (key == "placeDTO") {
  8734. item.templateOptions.options = list;
  8735. } else if (key == "requester") {
  8736. } else {
  8737. item.value(list[0][key][item.key]);
  8738. }
  8739. }
  8740. })
  8741. })
  8742. } else {
  8743. if (model.fields) {
  8744. angular.forEach(model.fields, function (item) {
  8745. angular.forEach(model.fields, function (item) {
  8746. if (item.templateOptions.pkey == modelKey + "." + key) {
  8747. item.model.id = "";
  8748. if (key == "place") {
  8749. item.templateOptions.isnosearch = true;
  8750. item.templateOptions.options = list;
  8751. }
  8752. if (key == "placeDTO") {
  8753. item.templateOptions.options = list;
  8754. }
  8755. if (key == "requester") {
  8756. }
  8757. }
  8758. })
  8759. })
  8760. } else {
  8761. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8762. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8763. if (item.templateOptions.pkey == modelKey + "." + key) {
  8764. if (key == "place") {
  8765. item.templateOptions.isnosearch = true;
  8766. item.templateOptions.options = list;
  8767. scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
  8768. }
  8769. if (key == "placeDTO") {
  8770. item.templateOptions.options = list;
  8771. }
  8772. if (key == "requester") {
  8773. }
  8774. }
  8775. })
  8776. })
  8777. }
  8778. }
  8779. console.log(key)
  8780. //报修科室
  8781. if (key == 'dept') {
  8782. // 报修科室单选
  8783. scope.$parent.$parent.$parent.model.incident.department = response.list[0];
  8784. scope.$parent.$parent.$parent.model.incident.contactsInformation = response.list[0].phone;
  8785. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  8786. // 选择重复事件侧滑框
  8787. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  8788. setTimeout(() => {
  8789. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  8790. }, 500);
  8791. }
  8792. // 报修人
  8793. if (key == 'requester') {
  8794. // 报修人单选
  8795. scope.$parent.$parent.$parent.model.incident.requester = response.list[
  8796. 0];
  8797. console.log(scope.$parent.$parent.$parent.model)
  8798. scope.$parent.$parent.$parent.model.incident.account = response.list[
  8799. 0].account;
  8800. var selectedItem = response.list[
  8801. 0];
  8802. var data = {
  8803. 'requester': selectedItem
  8804. };
  8805. scope.$parent.$parent.$parent.model[
  8806. 'requestershow'] = selectedItem;
  8807. console.log(selectedItem, '----------------------')
  8808. // if (selectedItem.dept.place.place) {
  8809. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  8810. // }
  8811. scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.houseNumber?selectedItem.houseNumber:'';
  8812. scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place?selectedItem.place.area.id:null;
  8813. scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place?selectedItem.place.id:null;
  8814. console.log(scope,89898998)
  8815. // console.log(scope.formData,'接单页面');
  8816. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  8817. scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8818. scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8819. options.templateOptions.ApiService.addData('requester',
  8820. data).then(function (response) {
  8821. if (response.status == 200) {
  8822. if (scope.$parent.$parent.$parent) {
  8823. if (scope.$parent.$parent.$parent.place) {
  8824. scope.$parent.$parent.$parent.place.id = '';
  8825. }
  8826. if (scope.$parent.$parent.$parent.area) {
  8827. scope.$parent.$parent.$parent.area.id = '';
  8828. }
  8829. scope.$parent.$parent.$parent.model.incident.contacts = selectedItem.name;
  8830. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8831. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.mphone;
  8832. } else {
  8833. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.telephone;
  8834. }
  8835. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8836. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8837. }
  8838. }
  8839. if (!response.data.id) {
  8840. response.data.id = selectedItem.id
  8841. }
  8842. console.log(scope);
  8843. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  8844. // if (selectedItem.place && selectedItem.place.id) {
  8845. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8846. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  8847. // };
  8848. // } else {
  8849. // if (selectedItem.place && selectedItem.place.id) {
  8850. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8851. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  8852. // };
  8853. // }
  8854. // if(scope.$parent.$parent.$parent.model.incident.area){
  8855. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  8856. // }
  8857. if (selectedItem.id) {
  8858. scope.$parent.$parent.$parent.model.incident.account = selectedItem.account;
  8859. }
  8860. // 选择重复事件侧滑框
  8861. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  8862. scope.$parent.$parent.$parent.model[
  8863. 'repeatIncidentShow'] = false;
  8864. setTimeout(() => {
  8865. scope.$parent.$parent.$parent.model[
  8866. 'repeatIncidentShow'] = true;
  8867. },
  8868. 500);
  8869. // }
  8870. }
  8871. })
  8872. }
  8873. });
  8874. },
  8875. validators: {
  8876. required: {
  8877. expression: function (viewValue, modelValue) {
  8878. var value = modelValue || viewValue;
  8879. return value != null;
  8880. // return value.length>=1;
  8881. // if (modelValue && viewValue) {
  8882. // return value != null;
  8883. // } else {
  8884. // var value = modelValue || viewValue;
  8885. // return value.length > 0;
  8886. // }
  8887. }
  8888. }
  8889. }
  8890. },
  8891. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  8892. // $scope.myFilter = function(item) {
  8893. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  8894. // }
  8895. // console.log($scope,'风浪')
  8896. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  8897. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  8898. $scope.options.templateOptions.linkage("place", {
  8899. "place": {
  8900. "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
  8901. // area:{
  8902. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  8903. // }
  8904. }
  8905. }, $scope.$parent.$parent.$parent.model, "incident", "place");
  8906. }
  8907. }
  8908. $scope.myFilter = $scope;
  8909. // console.log($scope.options.templateOptions)
  8910. console.log($scope,77777)
  8911. // 关闭事件页面满意度评价下拉框处理
  8912. if($scope.options.templateOptions.onlyKey=="close_degree"){
  8913. $scope.model.id = $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id
  8914. }
  8915. if($scope.options.templateOptions.initData == 1){
  8916. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8917. }
  8918. if ($scope.options.templateOptions.transform) {
  8919. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8920. }
  8921. if (angular.isFunction($scope.options.templateOptions.translate)) {
  8922. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  8923. }
  8924. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  8925. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  8926. }
  8927. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  8928. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  8929. }
  8930. }]
  8931. };
  8932. }
  8933. });
  8934. //下拉多选框组件
  8935. formlyConfigProvider.setType({
  8936. name: 'ui-multiselect',
  8937. extends: 'select',
  8938. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  8939. defaultOptions: function (options) {
  8940. return {
  8941. templateOptions: {
  8942. refresh: function () { },
  8943. refreshDelay: 1000
  8944. }
  8945. };
  8946. },
  8947. controller: ['$scope', function ($scope) {
  8948. $scope.model[$scope.options.key] = [];
  8949. }]
  8950. });
  8951. //下拉多选框灵活组件
  8952. formlyConfigProvider.setType({
  8953. name: 'ui-multiselectplus',
  8954. extends: 'multiCheckbox',
  8955. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8956. defaultOptions: function (options, $scope) {
  8957. return {
  8958. templateOptions: {
  8959. refreshData: function (search, options, model, that) {
  8960. var process = options.templateOptions.ApiService.all("");
  8961. if (search) {
  8962. } else {
  8963. }
  8964. var postData = options.templateOptions.optionsPostData;
  8965. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8966. postData = options.templateOptions.optionsPostData(options, model, that);
  8967. }
  8968. if (options.templateOptions.modelreasondata) {
  8969. postData = options.templateOptions.modelreasondata
  8970. }
  8971. process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
  8972. // if (!options.templateOptions.options) {
  8973. // options.templateOptions.options = [];
  8974. // }
  8975. // 过滤下拉列表已选择的值
  8976. var modelVal = $scope.model[$scope.options.key];
  8977. for (var i = 0; i < result.list.length; i++) {
  8978. for (var j = 0; j < modelVal.length; j++) {
  8979. if (result.list[i].id == modelVal[j].id) {
  8980. result.list.splice(i, 1)
  8981. }
  8982. }
  8983. }
  8984. if (options.templateOptions.optionsDataKey) {
  8985. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8986. } else {
  8987. options.templateOptions.options = result;
  8988. }
  8989. if (options.templateOptions.optionsChecked) {
  8990. // return options.value = null;
  8991. options.value(options.model[options.key]);
  8992. }
  8993. });
  8994. },
  8995. refreshDelay: 0,
  8996. // },
  8997. // validators: {
  8998. // required: {
  8999. // expression: function(viewValue, modelValue) {
  9000. // var value = modelValue || viewValue;
  9001. // // return value.length>=1;
  9002. // // if (modelValue && viewValue) {
  9003. // // return value != null;
  9004. // // } else {
  9005. // // var value = modelValue || viewValue;
  9006. // // return value.length > 0;
  9007. // // }
  9008. // }
  9009. // }
  9010. }
  9011. };
  9012. },
  9013. controller: ['$scope', function ($scope) {
  9014. if (angular.isArray($scope.model[$scope.options.key])) {
  9015. } else {
  9016. $scope.model[$scope.options.key] = [];
  9017. }
  9018. }]
  9019. });
  9020. //下拉树形多选组件
  9021. formlyConfigProvider.setType({
  9022. name: 'ui-multiselect-tree',
  9023. extends: 'multiCheckbox',
  9024. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9025. defaultOptions: function (options) {
  9026. return {
  9027. templateOptions: {
  9028. linkage: function (modelName, data, model, modelKey, key) {
  9029. angular.extend(data, {
  9030. "idx": 0,
  9031. "sum": 10
  9032. });
  9033. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9034. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9035. var list = myData.list;
  9036. if (list.length == 1) {
  9037. angular.forEach(model.fields, function (item) {
  9038. angular.forEach(model.fields, function (item) {
  9039. if (item.templateOptions.pkey == modelKey + "." + key) {
  9040. item.model.id = "";
  9041. if (key == "place") {
  9042. item.templateOptions.options = list;
  9043. } else {
  9044. item.value(list[0][key][item.key]);
  9045. }
  9046. }
  9047. })
  9048. })
  9049. }
  9050. });
  9051. },
  9052. // my_tree_handler : function(items) {
  9053. // },
  9054. // onFilterCallback : function(items) {
  9055. // },
  9056. // onFilterCallback : function(items) {
  9057. // },
  9058. refresh: function (items) {
  9059. var treedata = [];
  9060. function convertListToTree(data, treeMap) {
  9061. treedata = data;
  9062. for (var i = 0; i < data.length; i++) {
  9063. for (var j = 0; j < data.length; j++) {
  9064. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9065. if (data[i].pid == data[j].id) {
  9066. data[i].parent = data[j];
  9067. }
  9068. }
  9069. }
  9070. }
  9071. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9072. var root = null; //Initially set our loop to null
  9073. //loop over data
  9074. for (var i = 0; i < data.length; i++) {
  9075. var datum = data[i];
  9076. //each node will have children, so let's give it a "children" poperty
  9077. datum.children = [];
  9078. //add an entry for this node to the map so that any future children can
  9079. //lookup the parent
  9080. idToNodeMap[datum.id] = datum;
  9081. //Does this node have a parent?
  9082. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9083. //Doesn't look like it, so this node is the root of the tree
  9084. root = datum;
  9085. treeMap[datum.id] = root;
  9086. } else {
  9087. //This node has a parent, so let's look it up using the id
  9088. parentNode = idToNodeMap[datum.parent.id];
  9089. //We don't need this property, so let's delete it.
  9090. delete datum.parent;
  9091. //Let's add the current node as a child of the parent node.
  9092. parentNode.children.push(datum);
  9093. }
  9094. }
  9095. return root;
  9096. }
  9097. function convertParentToChildList(data) {
  9098. // console.log("data="+JSON.stringify(data))
  9099. var treeMap = {};
  9100. var list = [];
  9101. convertListToTree(data, treeMap);
  9102. angular.forEach(treeMap, function (item) {
  9103. list.push(item);
  9104. });
  9105. return list;
  9106. }
  9107. function selectItem(pmodel, childrens) {
  9108. if (angular.isArray(pmodel)) {
  9109. angular.forEach(pmodel, function (index) {
  9110. if (index && index.id) {
  9111. angular.forEach(childrens, function (item) {
  9112. if (item.id == index.id) {
  9113. item.selected = true;
  9114. }
  9115. if (item && item.children) {
  9116. selectItem(pmodel, item.children);
  9117. }
  9118. });
  9119. }
  9120. })
  9121. } else {
  9122. if (pmodel && pmodel.id) {
  9123. angular.forEach(childrens, function (item) {
  9124. if (item.id == pmodel.id) {
  9125. item.selected = true;
  9126. }
  9127. if (item && item.children) {
  9128. selectItem(pmodel, item.children);
  9129. }
  9130. });
  9131. }
  9132. }
  9133. }
  9134. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9135. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9136. if (result.status == 200) {
  9137. if (!options.templateOptions.options) {
  9138. options.templateOptions.options = [];
  9139. }
  9140. if (options.templateOptions.optionsDataKey) {
  9141. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9142. } else {
  9143. options.templateOptions.options = convertParentToChildList(result);
  9144. }
  9145. //set default value
  9146. var pmodel, i = 0;
  9147. if (options.templateOptions.pkey) {
  9148. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9149. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9150. if (i == 0) {
  9151. if (options.model[p] == null) {
  9152. options.model[p] = {};
  9153. }
  9154. pmodel = options.model[p];
  9155. i++;
  9156. } else {
  9157. if (pmodel[p] == null) {
  9158. pmodel[p] = {};
  9159. }
  9160. pmodel = pmodel[p];
  9161. }
  9162. });
  9163. } else {
  9164. pmodel = options.model;
  9165. }
  9166. }
  9167. if (pmodel) {
  9168. pmodel = pmodel[options.key];
  9169. } else if (options.model) {
  9170. pmodel = options.model[options.key];
  9171. } else {
  9172. pmodel = options.templateOptions.options;
  9173. }
  9174. if (angular.isArray(pmodel)) {
  9175. if (pmodel) {
  9176. // if(options.templateOptions.isMultiSelect==true){
  9177. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  9178. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  9179. // })
  9180. // }else{
  9181. selectItem(pmodel, options.templateOptions.options);
  9182. // }
  9183. }
  9184. } else {
  9185. if (pmodel && pmodel.id) {
  9186. selectItem(pmodel, options.templateOptions.options);
  9187. }
  9188. }
  9189. items.inputModel = options.templateOptions.options;
  9190. }
  9191. });
  9192. }
  9193. },
  9194. validators: {
  9195. required: {
  9196. expression: function (viewValue, modelValue) {
  9197. var value = modelValue || viewValue;
  9198. if (angular.isArray(value)) {
  9199. for (var i = 0; i < value.length; i++) {
  9200. value[i] = {
  9201. id: value[i].id
  9202. }
  9203. }
  9204. return value.length > 0
  9205. } else {
  9206. // console.log(options)
  9207. // return value = "true";
  9208. return value != null;
  9209. }
  9210. }
  9211. }
  9212. }
  9213. }
  9214. },
  9215. controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
  9216. if ($scope.options.templateOptions.isMultiSelect) {
  9217. // console.log($scope);
  9218. } else {
  9219. if ($scope.model[$scope.options.key]) {
  9220. }
  9221. }
  9222. }]
  9223. });
  9224. //多选下拉框组件
  9225. formlyConfigProvider.setType({
  9226. name: 'ui-multi-select-tree',
  9227. extends: 'input',
  9228. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9229. defaultOptions: function (options) {
  9230. return {
  9231. templateOptions: {
  9232. linkage: function (modelName, data, model, modelKey, key) {
  9233. angular.extend(data, {
  9234. "idx": 0,
  9235. "sum": 10
  9236. });
  9237. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9238. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9239. var list = myData.list;
  9240. if (list.length == 1) {
  9241. angular.forEach(model.fields, function (item) {
  9242. angular.forEach(model.fields, function (item) {
  9243. if (item.templateOptions.pkey == modelKey + "." + key) {
  9244. item.model.id = "";
  9245. if (key == "place") {
  9246. item.templateOptions.options = list;
  9247. } else {
  9248. item.value(list[0][key][item.key]);
  9249. }
  9250. }
  9251. })
  9252. })
  9253. }
  9254. });
  9255. },
  9256. getparentdata: function (items) {
  9257. // console.log(items)
  9258. },
  9259. refresh: function (items, search, fn) {
  9260. console.log(items);
  9261. var treedata = [];
  9262. function convertListToTree(data, treeMap) {
  9263. // console.log(data)
  9264. treedata = data;
  9265. for (var i = 0; i < data.length; i++) {
  9266. for (var j = 0; j < data.length; j++) {
  9267. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9268. if (data[i].pid == data[j].id) {
  9269. data[i].parent = data[j];
  9270. }
  9271. }
  9272. // if (data[i].id) {
  9273. // if (data[i].id== data[j].id) {
  9274. // data[i].parent = data[j];
  9275. // }
  9276. // }
  9277. }
  9278. }
  9279. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9280. var root = []; //Initially set our loop to null
  9281. if (search == 'search' && items.filterKeyword) {
  9282. function transform(nodes) {
  9283. var treeConverter = {
  9284. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  9285. attributeName: 'id', //节点唯一标识符
  9286. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  9287. transform: function (node) { //转化递归函数,参数:一个待插入节点
  9288. if (node.parent != null) { //该节点有父节点
  9289. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  9290. if (this.needFind) {
  9291. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  9292. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  9293. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9294. }
  9295. }
  9296. }
  9297. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  9298. // delete node.parent; //删除该节点的parent属性,如果有的话
  9299. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  9300. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  9301. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  9302. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  9303. // delete node.parent; //删除该节点的parent属性,如果有的话
  9304. if (this.result == null) { //根节点不存在
  9305. node.children = []; //给该节点增加children:[]属性
  9306. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9307. } else {
  9308. node.children = [];
  9309. // 顶级去重
  9310. for (var i = 0; i < this.result.children.length; i++) {
  9311. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  9312. return this.result.children[i];
  9313. }
  9314. }
  9315. this.result.children.push(node)
  9316. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9317. }
  9318. }
  9319. },
  9320. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  9321. var _node = {};
  9322. _node.children = [];
  9323. this.result = _node; //重置根节点
  9324. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  9325. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  9326. nodes.forEach(item => { //循环调用转化方法
  9327. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  9328. this.transform(item);
  9329. })
  9330. return this.result; //返回根节点
  9331. }
  9332. }
  9333. var result = treeConverter.getWhole(nodes); //调用
  9334. return result;
  9335. }
  9336. var li = transform(data).children;
  9337. // li=[...new Set(li)]
  9338. console.log(li)
  9339. treeMap = li;
  9340. fn(li);
  9341. return li;
  9342. } else {
  9343. //loop over data
  9344. for (var i = 0; i < data.length; i++) {
  9345. var datum = data[i];
  9346. //each node will have children, so let's give it a "children" poperty
  9347. datum.children = [];
  9348. //add an entry for this node to the map so that any future children can
  9349. //lookup the parent
  9350. idToNodeMap[datum.id] = datum;
  9351. //Does this node have a parent?
  9352. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9353. //Doesn't look like it, so this node is the root of the tree
  9354. root = datum;
  9355. treeMap[datum.id] = root;
  9356. } else {
  9357. //This node has a parent, so let's look it up using the id
  9358. parentNode = idToNodeMap[datum.parent.id];
  9359. //We don't need this property, so let's delete it.
  9360. // delete datum.parent;
  9361. //Let's add the current node as a child of the parent node.
  9362. parentNode.children.push(datum);
  9363. }
  9364. }
  9365. }
  9366. return root;
  9367. }
  9368. function convertParentToChildList(data) {
  9369. var treeMap = {};
  9370. var list = [];
  9371. if (search == 'search' && items.filterKeyword) {
  9372. var lis = convertListToTree(data, treeMap)
  9373. return lis;
  9374. } else {
  9375. if (data[0] && data[0].orders) {
  9376. list = data;
  9377. } else {
  9378. convertListToTree(data, treeMap);
  9379. angular.forEach(treeMap, function (item) {
  9380. // console.log("item="+JSON.stringify(item))
  9381. list.push(item);
  9382. });
  9383. }
  9384. return list;
  9385. }
  9386. }
  9387. function selectItem(pmodel, childrens) {
  9388. if (angular.isArray(pmodel)) {
  9389. angular.forEach(pmodel, function (index) {
  9390. if (index && index.id) {
  9391. angular.forEach(childrens, function (item) {
  9392. if (item.id == index.id) {
  9393. item.selected = true;
  9394. }
  9395. if (item && item.children) {
  9396. selectItem(pmodel, item.children);
  9397. }
  9398. });
  9399. // angular.forEach(treedata,function(parentdata){
  9400. // if(parentdata.id == index.id){
  9401. // if(parentdata.parent&&parentdata.parent.id){
  9402. // parentdata.parent.$
  9403. // }
  9404. // item.selected = true;
  9405. // }
  9406. // if (item && item.children) {
  9407. // selectItem(pmodel ,item.children);
  9408. // }
  9409. // });
  9410. }
  9411. })
  9412. } else {
  9413. if (pmodel && pmodel.id) {
  9414. angular.forEach(childrens, function (item, index) {
  9415. if (item.id == pmodel.id) {
  9416. item.selected = true;
  9417. delete item.children;
  9418. }
  9419. if (item && item.children) {
  9420. selectItem(pmodel, item.children);
  9421. }
  9422. });
  9423. }
  9424. }
  9425. }
  9426. function selectItemchild(pmodel, childrens) {
  9427. if (angular.isArray(pmodel)) {
  9428. angular.forEach(pmodel, function (index) {
  9429. if (index && index.id) {
  9430. angular.forEach(childrens, function (item) {
  9431. if (item.id == index.id) {
  9432. item.selected = true;
  9433. }
  9434. if (item && item.children) {
  9435. selectItem(pmodel, item.children);
  9436. }
  9437. });
  9438. }
  9439. })
  9440. } else {
  9441. if (pmodel && pmodel.id) {
  9442. angular.forEach(childrens, function (item, index) {
  9443. if (item.id == pmodel.id) {
  9444. item.selected = true;
  9445. childrens[index].selected = true;
  9446. }
  9447. if (item && item.children) {
  9448. selectItem(pmodel, item.children);
  9449. }
  9450. });
  9451. }
  9452. }
  9453. }
  9454. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9455. if (search === 'search' && items.filterKeyword) {
  9456. // bala:树形模糊搜索
  9457. options.templateOptions.bala(options.templateOptions.APIService, items.filterKeyword).then(function (result) {
  9458. result.list = [...new Set(result.list)]; //去重
  9459. if (!options.templateOptions.options) {
  9460. options.templateOptions.options = [];
  9461. }
  9462. if (options.templateOptions.optionsDataKey) {
  9463. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9464. } else {
  9465. options.templateOptions.options = convertParentToChildList(result);
  9466. }
  9467. //set default value
  9468. var pmodel, i = 0;
  9469. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9470. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9471. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9472. if (i == 0) {
  9473. if (options.model[p] == null) {
  9474. options.model[p] = {};
  9475. }
  9476. pmodel = options.model[p];
  9477. i++;
  9478. } else {
  9479. if (pmodel[p] == null) {
  9480. pmodel[p] = {};
  9481. }
  9482. pmodel = pmodel[p];
  9483. }
  9484. });
  9485. } else {
  9486. pmodel = options.model;
  9487. }
  9488. }
  9489. var topdata = angular.copy(options.templateOptions.options);
  9490. if (pmodel) {
  9491. pmodel = pmodel[options.key];
  9492. } else if (options.model) {
  9493. pmodel = options.model[options.key];
  9494. }
  9495. if (angular.isArray(pmodel)) {
  9496. if (pmodel) {
  9497. items.inputModel = angular.copy(options.templateOptions.options);
  9498. selectItem(pmodel, options.templateOptions.options);
  9499. }
  9500. } else {
  9501. if (pmodel && pmodel.id) {
  9502. items.inputModel = angular.copy(options.templateOptions.options);
  9503. selectItem(pmodel, options.templateOptions.options);
  9504. } else {
  9505. // items.inputModel = options.templateOptions.options;
  9506. }
  9507. }
  9508. // items.inputModel = options.templateOptions.options;
  9509. items.selectModel = options.templateOptions.options;
  9510. // 可在此展开
  9511. if (!items.inputModel) {
  9512. items.inputModel = items.selectModel;
  9513. } else {
  9514. selectItemchild(pmodel, items.inputModel);
  9515. // for (var i = 0; i < items.inputModel.length; i++) {
  9516. // items.inputModel[i].
  9517. // for (var j = 0; j < items.selectModel.length; j++) {
  9518. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9519. // items.inputModel[i].selected = true;
  9520. // }
  9521. // }
  9522. // }
  9523. }
  9524. return items.inputModel;
  9525. // options.templateOptions.options = angular.copy(topdata);
  9526. // console.log(model);
  9527. // console.log(options);
  9528. });
  9529. } else {
  9530. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9531. if (!options.templateOptions.options) {
  9532. options.templateOptions.options = [];
  9533. }
  9534. if (options.templateOptions.optionsDataKey) {
  9535. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9536. } else {
  9537. options.templateOptions.options = convertParentToChildList(result);
  9538. }
  9539. //set default value
  9540. var pmodel, i = 0;
  9541. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9542. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9543. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9544. if (i == 0) {
  9545. if (options.model[p] == null) {
  9546. options.model[p] = {};
  9547. }
  9548. pmodel = options.model[p];
  9549. i++;
  9550. } else {
  9551. if (pmodel[p] == null) {
  9552. pmodel[p] = {};
  9553. }
  9554. pmodel = pmodel[p];
  9555. }
  9556. });
  9557. } else {
  9558. pmodel = options.model;
  9559. }
  9560. }
  9561. var topdata = angular.copy(options.templateOptions.options);
  9562. if (pmodel) {
  9563. pmodel = pmodel[options.key];
  9564. } else if (options.model) {
  9565. pmodel = options.model[options.key];
  9566. }
  9567. if (angular.isArray(pmodel)) {
  9568. if (pmodel) {
  9569. items.inputModel = angular.copy(options.templateOptions.options);
  9570. selectItem(pmodel, options.templateOptions.options);
  9571. }
  9572. } else {
  9573. if (pmodel && pmodel.id) {
  9574. items.inputModel = angular.copy(options.templateOptions.options);
  9575. selectItem(pmodel, options.templateOptions.options);
  9576. } else {
  9577. // items.inputModel = options.templateOptions.options;
  9578. }
  9579. }
  9580. // items.inputModel = options.templateOptions.options;
  9581. items.selectModel = options.templateOptions.options;
  9582. if (!items.inputModel) {
  9583. items.inputModel = items.selectModel;
  9584. } else {
  9585. selectItemchild(pmodel, items.inputModel);
  9586. // for (var i = 0; i < items.inputModel.length; i++) {
  9587. // for (var j = 0; j < items.selectModel.length; j++) {
  9588. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9589. // items.inputModel[i].selected = true;
  9590. // }
  9591. // }
  9592. // }
  9593. }
  9594. // options.templateOptions.options = angular.copy(topdata);
  9595. // console.log(model);
  9596. // console.log(options);
  9597. });
  9598. }
  9599. }
  9600. },
  9601. validators: {
  9602. required: {
  9603. expression: function (viewValue, modelValue) {
  9604. var value = modelValue || viewValue;
  9605. if (angular.isArray(value)) {
  9606. return value.length > 0
  9607. } else {
  9608. // console.log(options)
  9609. if (options.templateOptions.required && !value) {
  9610. // return value != null;
  9611. } else {
  9612. return value;
  9613. }
  9614. // return value = "true";
  9615. }
  9616. }
  9617. }
  9618. }
  9619. }
  9620. },
  9621. controller: ['$scope', '$rootScope', 'api_configure_form', 'api_bpm_domain', function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  9622. $rootScope.checkClicked = function (item) {
  9623. angular.forEach($scope.to.options, function (itemone) {
  9624. if (!item.parent) {
  9625. if (item.id == itemone.id) {
  9626. // itemone.isExpanded = true;
  9627. } else {
  9628. itemone.isExpanded = false;
  9629. }
  9630. } else {
  9631. if (item.parent.id == itemone.id) {
  9632. angular.forEach(itemone.children, function (itemtwo) {
  9633. if (item.id == itemtwo.id) { } else {
  9634. itemtwo.isExpanded = false;
  9635. }
  9636. })
  9637. }
  9638. }
  9639. })
  9640. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  9641. console.log($scope,'gsm');
  9642. if ($scope.originalModel && $scope.originalModel.incident && item.category && (!item.children || !item.children.length) && item.priority && item.priority.id) {
  9643. api_bpm_domain.expectedTime('L' + (item.priority.id - 1559)).then(function (res) {
  9644. $scope.originalModel.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  9645. $scope.originalModel.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  9646. $scope.originalModel.incident.overdueTime = res.date;
  9647. })
  9648. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9649. // setTimeout(() => {
  9650. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9651. // }, 500);
  9652. // console.log($scope.$parent.$parent.$parent)
  9653. }
  9654. }
  9655. if ($scope.options.templateOptions.isMultiSelect) {
  9656. // console.log($scope);
  9657. } else {
  9658. if ($scope.model[$scope.options.key]) {
  9659. }
  9660. }
  9661. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  9662. // console.log(item)
  9663. // // if(){
  9664. // // }
  9665. // // $scope.model[$scope.options.key]=item.id;
  9666. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  9667. // $scope.propTypeOptions = data;
  9668. // });
  9669. // }
  9670. // $scope.model[$scope.options.key]=[];
  9671. // $scope.fn
  9672. $rootScope.bala1 = function (items, fn) {
  9673. // $scope.fn = fn;
  9674. console.log(items)
  9675. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  9676. $scope.options.templateOptions.refresh(items, 'search', fn)
  9677. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  9678. // // return res.list;
  9679. // console.log(666)
  9680. // fn(res.list)
  9681. // })
  9682. }
  9683. }]
  9684. });
  9685. //勾选组件
  9686. formlyConfigProvider.setType({
  9687. name: 'ui-checkbox',
  9688. extends: 'checkbox',
  9689. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  9690. controller: ['$scope', function ($scope) {
  9691. // 巡检生成事件,默认派单
  9692. if ($scope.model.isInspection) {
  9693. $scope.model[$scope.options.key] = true;
  9694. };
  9695. if ($scope.model[$scope.options.key] == "true") {
  9696. $scope.model[$scope.options.key] = true;
  9697. };
  9698. if ($scope.model[$scope.options.key] == "false") {
  9699. $scope.model[$scope.options.key] = false;
  9700. };
  9701. }]
  9702. });
  9703. //换行组件
  9704. formlyConfigProvider.setType({
  9705. name: 'ui-nextLine',
  9706. /*extends: 'input',*/
  9707. template: '<div></div>',
  9708. });
  9709. //多选框组件
  9710. formlyConfigProvider.setType({
  9711. name: 'ui-checklist',
  9712. extends: 'multiCheckbox',
  9713. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  9714. defaultOptions: function (options) {
  9715. return {
  9716. templateOptions: {
  9717. refresh: function () { },
  9718. refreshDelay: 0
  9719. }
  9720. };
  9721. }
  9722. });
  9723. //单选框组件
  9724. formlyConfigProvider.setType({
  9725. name: 'ui-radio',
  9726. extends: 'radio',
  9727. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  9728. defaultOptions: function (options) {
  9729. return {
  9730. templateOptions: {
  9731. refresh: function () { },
  9732. refreshDelay: 0
  9733. }
  9734. };
  9735. },
  9736. controller: ['$scope', function ($scope) {
  9737. // 巡检生成事件,默认派单
  9738. if ($scope.model.isInspection) {
  9739. $scope.model[$scope.options.key] = true;
  9740. // $scope.model.isHandlerUser=true;
  9741. $scope.model.start_code = "assignment";
  9742. console.log($scope.model);
  9743. };
  9744. //多次暂存配置
  9745. // console.log($scope);
  9746. if ($scope.model.saveAgain) {
  9747. if ($scope.model.directClose == "1" || $scope.model.directClose == true) {
  9748. $scope.model[$scope.options.key] = true;
  9749. // if($scope.model.incident.handlingPersonnelUser){
  9750. // delete $scope.model.incident.handlingPersonnelUser;
  9751. // };
  9752. if ($scope.model.incident.handleDescription) {
  9753. delete $scope.model.incident.handleDescription
  9754. };
  9755. if ($scope.model.incident.closecode) {
  9756. delete $scope.model.incident.closecode
  9757. };
  9758. if ($scope.model.incident.degree) {
  9759. delete $scope.model.incident.degree
  9760. }
  9761. } else {
  9762. $scope.model.incident.handlingPersonnelUser = $scope.model.incident.acceptUser;
  9763. $scope.model[$scope.options.key] = false
  9764. }
  9765. }
  9766. }]
  9767. });
  9768. //文本域组件
  9769. formlyConfigProvider.setWrapper({
  9770. name: 'validation',
  9771. types: ['ui-textarea'],
  9772. 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>"
  9773. });
  9774. formlyConfigProvider.setType({
  9775. name: 'ui-textarea',
  9776. extends: 'textarea',
  9777. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  9778. defaultOptions: function (options) {
  9779. return {
  9780. templateOptions: {
  9781. transform: function (model, value) {
  9782. return value;
  9783. },
  9784. },
  9785. validation: {
  9786. messages: {
  9787. maxlength: function (viewValue, modelValue, scope) {
  9788. if (viewValue != null) {
  9789. if (viewValue.length > scope.to.maxlength) {
  9790. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9791. } else {
  9792. return "";
  9793. }
  9794. }
  9795. },
  9796. }
  9797. }
  9798. }
  9799. },
  9800. controller: ['$scope', function ($scope) {
  9801. var value = $scope.model[$scope.options.key];
  9802. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9803. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9804. }
  9805. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9806. $scope.options.templateOptions.felditem($scope);
  9807. }
  9808. }]
  9809. });
  9810. // div版的textarea(展示富文本框内容用)
  9811. formlyConfigProvider.setType({
  9812. name: 'ui-divTextarea',
  9813. extends: 'textarea',
  9814. templateUrl: 'assets/views/customform/tpl/ui-divTextarea.html',
  9815. defaultOptions: function (options) {
  9816. return {
  9817. templateOptions: {
  9818. transform: function (model, value) {
  9819. return value;
  9820. },
  9821. },
  9822. validation: {
  9823. messages: {
  9824. // maxlength: function (viewValue, modelValue, scope) {
  9825. // if (viewValue != null) {
  9826. // if (viewValue.length > scope.to.maxlength) {
  9827. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9828. // } else {
  9829. // return "";
  9830. // }
  9831. // }
  9832. // },
  9833. }
  9834. }
  9835. }
  9836. },
  9837. controller: ['$scope', function ($scope) {
  9838. var value = $scope.model[$scope.options.key];
  9839. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9840. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9841. }
  9842. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9843. $scope.options.templateOptions.felditem($scope);
  9844. }
  9845. }]
  9846. });
  9847. // 带有知识库引用的textarea
  9848. formlyConfigProvider.setType({
  9849. name: 'ui-textAreaKnowledge',
  9850. // extends: 'textarea',
  9851. templateUrl: 'assets/views/customform/tpl/ui-textAreaKnowledge.html',
  9852. defaultOptions: function (options) {
  9853. return {
  9854. templateOptions: {
  9855. transform: function (model, value) {
  9856. return value;
  9857. },
  9858. },
  9859. validation: {
  9860. messages: {
  9861. maxlength: function (viewValue, modelValue, scope) {
  9862. if (viewValue != null) {
  9863. if (viewValue.length > scope.to.maxlength) {
  9864. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9865. } else {
  9866. return "";
  9867. }
  9868. }
  9869. },
  9870. }
  9871. }
  9872. }
  9873. },
  9874. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_bpm_domain', 'api_solution', '$aside', 'api_zsk', 'up_down_file', 'api_wechatfile', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_bpm_domain, api_solution, $aside, api_zsk, up_down_file, api_wechatfile) {
  9875. // console.log($scope);
  9876. var value = $scope.model[$scope.options.key];
  9877. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9878. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9879. }
  9880. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9881. $scope.options.templateOptions.felditem($scope);
  9882. }
  9883. // 引用知识库点击
  9884. $scope.openSolution = function () {
  9885. $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9886. setTimeout(() => {
  9887. $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9888. }, 100);
  9889. }
  9890. }]
  9891. });
  9892. //常用语句选择textarea
  9893. formlyConfigProvider.setType({
  9894. name: 'ui-textselect',
  9895. extends: 'textarea',
  9896. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  9897. defaultOptions: function (options) {
  9898. return {
  9899. templateOptions: {
  9900. transform: function (model, value) {
  9901. return value;
  9902. },
  9903. },
  9904. validation: {
  9905. messages: {
  9906. maxlength: function (viewValue, modelValue, scope) {
  9907. if (viewValue != null) {
  9908. if (viewValue.length > scope.to.maxlength) {
  9909. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9910. } else {
  9911. return "";
  9912. }
  9913. }
  9914. },
  9915. }
  9916. }
  9917. }
  9918. },
  9919. controller: ['$scope', function ($scope) {
  9920. var value = $scope.model[$scope.options.key];
  9921. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9922. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9923. }
  9924. }]
  9925. });
  9926. //改动的组件 ckeditor封装后的组件
  9927. formlyConfigProvider.setType({
  9928. name: 'ui-text-check',
  9929. extends: 'textarea',
  9930. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  9931. defaultOptions: function (options) {
  9932. return {
  9933. templateOptions: {
  9934. extraPlugins: 'uploadimage',
  9935. uploadimageConfig: {
  9936. backend: 'basic',
  9937. settings: {
  9938. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  9939. headers: '',
  9940. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  9941. }
  9942. },
  9943. refresh: function (APIService, contentId, data) {
  9944. return APIService.fetchDataList(contentId, data);
  9945. },
  9946. downloadUri: function (APIService, contentId) {
  9947. return APIService.downloadAttachment(contentId).getRequestedUrl();
  9948. },
  9949. upload: function (APIService, contentId) {
  9950. return APIService.getSolutionDowpath(contentId);
  9951. },
  9952. view: function (attachmentId) {
  9953. // return APIService.attachmentsPreviewUrl(contentId);
  9954. },
  9955. refreshDelay: 0,
  9956. transform: function (model, value) {
  9957. return value;
  9958. },
  9959. },
  9960. validation: {
  9961. messages: {
  9962. maxlength: function (viewValue, modelValue, scope) {
  9963. if (viewValue != null) {
  9964. if (viewValue.length > scope.to.maxlength) {
  9965. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9966. } else {
  9967. return "";
  9968. }
  9969. }
  9970. },
  9971. }
  9972. }
  9973. }
  9974. },
  9975. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  9976. var value = $scope.model[$scope.options.key];
  9977. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9978. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9979. }
  9980. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  9981. //var expiry={'expiry':14804244006};
  9982. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  9983. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  9984. $scope.upload = function (contentId, filename) {
  9985. var filename = filename;
  9986. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  9987. var file = new Blob([response], {
  9988. type: 'application/octet-stream'
  9989. });
  9990. // var filename = filename;
  9991. var fileURL = URL.createObjectURL(file);
  9992. var a = document.createElement('a');
  9993. a.href = fileURL;
  9994. a.target = '_blank';
  9995. a.download = filename;
  9996. document.body.appendChild(a);
  9997. a.click();
  9998. })
  9999. };
  10000. }]
  10001. });
  10002. //改动的组件 ckeditor封装后的附文本组件
  10003. formlyConfigProvider.setType({
  10004. name: 'ui-fuwenben',
  10005. extends: 'textarea',
  10006. templateUrl: 'assets/views/customform/tpl/ui-fuwenben.html',
  10007. defaultOptions: function (options) {
  10008. return {
  10009. templateOptions: {
  10010. allowedContent: 'img[!src]',//允许展示源码的标签,否则会被富文本框强制删除
  10011. extraPlugins: 'uploadimage',
  10012. uploadimageConfig: {
  10013. backend: 'basic',
  10014. settings: {
  10015. uploadUrl: options.templateOptions.APIService.upload(-110).getRequestedUrl(),
  10016. headers: '',
  10017. downloadUrl: options.templateOptions.APIService.uploadResponseUri()
  10018. }
  10019. },
  10020. refresh: function (APIService, contentId, data) {
  10021. return APIService.fetchDataList(-110, data);
  10022. },
  10023. downloadUri: function (APIService, contentId) {
  10024. return APIService.downloadAttachment(-110).getRequestedUrl();
  10025. },
  10026. upload: function (APIService, contentId) {
  10027. return APIService.getSolutionDowpath(-110);
  10028. },
  10029. view: function (attachmentId) {
  10030. // return APIService.attachmentsPreviewUrl(contentId);
  10031. },
  10032. refreshDelay: 0,
  10033. transform: function (model, value) {
  10034. return value;
  10035. },
  10036. },
  10037. validation: {
  10038. messages: {
  10039. maxlength: function (viewValue, modelValue, scope) {
  10040. if (viewValue != null) {
  10041. if (viewValue.length > scope.to.maxlength) {
  10042. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  10043. } else {
  10044. return "";
  10045. }
  10046. }
  10047. },
  10048. }
  10049. }
  10050. }
  10051. },
  10052. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10053. var value = $scope.model[$scope.options.key];
  10054. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10055. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10056. }
  10057. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10058. //var expiry={'expiry':14804244006};
  10059. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10060. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10061. $scope.upload = function (contentId, filename) {
  10062. var filename = filename;
  10063. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, -110).then(function (response) {
  10064. var file = new Blob([response], {
  10065. type: 'application/octet-stream'
  10066. });
  10067. // var filename = filename;
  10068. var fileURL = URL.createObjectURL(file);
  10069. var a = document.createElement('a');
  10070. a.href = fileURL;
  10071. a.target = '_blank';
  10072. a.download = filename;
  10073. document.body.appendChild(a);
  10074. a.click();
  10075. })
  10076. };
  10077. }]
  10078. });
  10079. //ui-grid展示控件
  10080. formlyConfigProvider.setType({
  10081. name: 'ui-grid-show',
  10082. extends: 'multiCheckbox',
  10083. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  10084. defaultOptions: function (options) {
  10085. return {
  10086. templateOptions: {
  10087. linkage: function () {
  10088. },
  10089. },
  10090. };
  10091. },
  10092. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  10093. var loginUser = $rootScope.user;
  10094. $scope.langs = i18nService.getAllLangs();
  10095. $scope.lang = 'zh-cn';
  10096. i18nService.setCurrentLang($scope.lang);
  10097. $scope.gridOptions = {};
  10098. $scope.gridOptions.data = 'myData';
  10099. $scope.gridOptions.enableColumnResizing = true;
  10100. // $scope.gridOptions.enableFiltering = true;
  10101. $scope.gridOptions.enableGridMenu = false;
  10102. $scope.gridOptions.enableRowSelection = true;
  10103. $scope.gridOptions.showGridFooter = true;
  10104. $scope.gridOptions.showColumnFooter = false;
  10105. $scope.gridOptions.fastWatch = true;
  10106. $scope.gridOptions.useExternalFiltering = true;
  10107. $scope.gridOptions.useExternalPagination = true;
  10108. $scope.gridOptions.paginationPageSizes = [10];
  10109. $scope.gridOptions.paginationPageSize = 10;
  10110. $scope.gridOptions.multiSelect = true;
  10111. $scope.gridOptions.rowIdentity = function (row) {
  10112. return row.id;
  10113. };
  10114. $scope.gridOptions.getRowIdentity = function (row) {
  10115. return row.id;
  10116. };
  10117. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10118. $scope.gridOptions.columnDefs = [
  10119. // { name:'id', width:80, enableFiltering:false},
  10120. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  10121. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  10122. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  10123. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  10124. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  10125. {
  10126. name: 'inspection.title',
  10127. displayName: '计划主题',
  10128. width: 120,
  10129. enableFiltering: false
  10130. },
  10131. {
  10132. name: 'stateName',
  10133. displayName: '状态',
  10134. width: 80,
  10135. enableFiltering: false
  10136. },
  10137. {
  10138. name: 'processUser.name',
  10139. displayName: '处理人',
  10140. width: 80,
  10141. enableFiltering: false
  10142. },
  10143. {
  10144. name: 'startDate',
  10145. displayName: '开始时间',
  10146. width: 160,
  10147. enableFiltering: false
  10148. },
  10149. {
  10150. name: 'overdueTime',
  10151. displayName: '逾期时间',
  10152. width: 160,
  10153. enableFiltering: false
  10154. },
  10155. ];
  10156. var defaultFilterData = {
  10157. "idx": 0,
  10158. "sum": 10
  10159. };
  10160. //分页控制
  10161. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10162. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10163. var filtersData = $scope.memoryfilterData;
  10164. filtersData.idx = newPage - 1;
  10165. filtersData.sum = pageSize;
  10166. $scope.refreshData('expand-right', filtersData);
  10167. });
  10168. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10169. data.grid.appScope.selected.items = data.entity
  10170. });
  10171. };
  10172. //页面获取数据
  10173. $scope.refreshData = function (style, filterData) {
  10174. // $scope.ldloading[style.replace('-', '_')] = true;
  10175. if (angular.isUndefined(filterData)) {
  10176. filterData = defaultFilterData;
  10177. }
  10178. $scope.myData = [];
  10179. angular.extend(filterData, {
  10180. inspectionProcessActual: {
  10181. "inspectionid": $scope.model.id
  10182. }
  10183. })
  10184. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
  10185. var myData = Restangular.stripRestangular(data);
  10186. $scope.gridOptions.totalItems = myData.totalNum;
  10187. $scope.myData = myData.list;
  10188. for (var i = 0; i < $scope.myData.length; i++) {
  10189. //添加序号
  10190. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  10191. }
  10192. // $scope.ldloading[style.replace('-', '_')] = false;
  10193. }, function () {
  10194. // $scope.ldloading[style.replace('-', '_')] = false;
  10195. });
  10196. };
  10197. $scope.refreshData('expand-right', defaultFilterData);
  10198. }
  10199. });
  10200. //文本框自定义选择面板组件
  10201. formlyConfigProvider.setType({
  10202. name: 'ui-input-selectmodal',
  10203. extends: 'input',
  10204. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  10205. defaultOptions: function (options) {
  10206. return {
  10207. templateOptions: {
  10208. openModal: function (size, options, modal) {
  10209. var modalInstance = modal.open({
  10210. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  10211. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  10212. size: size,
  10213. resolve: options.templateOptions.modalParam
  10214. });
  10215. modalInstance.result.then(function (selectedItem) {
  10216. options.value(selectedItem);
  10217. }, function () {
  10218. //console.log('Modal dismissed at: ' + new Date());
  10219. });
  10220. }
  10221. }
  10222. };
  10223. }
  10224. });
  10225. //日期控件
  10226. var datepicker_attr = [
  10227. 'date-disabled',
  10228. 'custom-class',
  10229. 'show-weeks',
  10230. 'starting-day',
  10231. 'init-date',
  10232. 'min-mode',
  10233. 'max-mode',
  10234. 'format-day',
  10235. 'format-month',
  10236. 'format-year',
  10237. 'format-day-header',
  10238. 'format-day-title',
  10239. 'format-month-title',
  10240. 'year-range',
  10241. 'shortcut-propagation',
  10242. 'datepicker-popup',
  10243. 'show-button-bar',
  10244. 'current-text',
  10245. 'clear-text',
  10246. 'close-text',
  10247. 'close-on-date-selection',
  10248. 'datepicker-append-to-body'
  10249. ];
  10250. var datepicker_bindings = [
  10251. 'datepicker-mode',
  10252. 'min-date',
  10253. 'max-date'
  10254. ];
  10255. formlyConfigProvider.setType({
  10256. name: 'ui-datetime',
  10257. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  10258. extends: 'input',
  10259. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10260. defaultOptions: {
  10261. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10262. templateOptions: {
  10263. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10264. }
  10265. },
  10266. controller: ['$scope', '$filter', function ($scope, $filter) {
  10267. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10268. $scope.options.initialValue = $scope.model[$scope.options.key];
  10269. }]
  10270. });
  10271. //日期控件
  10272. formlyConfigProvider.setType({
  10273. name: 'ui-datepicker',
  10274. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  10275. extends: 'input',
  10276. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10277. defaultOptions: {
  10278. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10279. templateOptions: {
  10280. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10281. }
  10282. },
  10283. controller: ['$scope', '$filter', function ($scope, $filter) {
  10284. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  10285. if ($scope.model[$scope.options.key]) {
  10286. } else {
  10287. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10288. }
  10289. $scope.options.initialValue = $scope.model[$scope.options.key];
  10290. $scope.endOpen = true;
  10291. $scope.datepicker = {};
  10292. $scope.datepicker.opened = false;
  10293. $scope.datepicker.open = function ($event) {
  10294. $scope.datepicker.opened = true;
  10295. };
  10296. }]
  10297. });
  10298. //时分控件
  10299. formlyConfigProvider.setType({
  10300. name: 'ui-datehourtime',
  10301. extends: 'input',
  10302. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  10303. defaultOptions: function (options) {
  10304. return {
  10305. noFormControl: true,
  10306. // validators:{
  10307. // required:{
  10308. // expression:function(viewValue, modelValue){
  10309. // console.log(options)
  10310. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  10311. // // var value = modelValue.getHours() || viewValue.getHours();
  10312. // return value.length>=1;
  10313. // }
  10314. // }
  10315. // }
  10316. }
  10317. },
  10318. controller: ['$scope', '$log', function ($scope, $log) {
  10319. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  10320. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  10321. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  10322. }]
  10323. });
  10324. //状态追踪
  10325. formlyConfigProvider.setType({
  10326. name: 'ui-followStatus',
  10327. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  10328. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10329. setTimeout(function () {
  10330. var pkey = $scope.options.templateOptions.pkey;
  10331. var dataId = $scope.model.id;
  10332. if (dataId) {
  10333. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10334. if (response) {
  10335. var myData = Restangular.stripRestangular(response);
  10336. var processInstanceId = myData.data.processInstanceId;
  10337. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10338. if (result.status == 200) {
  10339. var newData = Restangular.stripRestangular(result);
  10340. $scope.followData = newData.data;
  10341. }
  10342. });
  10343. }
  10344. })
  10345. }
  10346. }, 10);
  10347. }]
  10348. });
  10349. //历史记录
  10350. formlyConfigProvider.setType({
  10351. name: 'ui-history',
  10352. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  10353. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10354. setTimeout(function () {
  10355. var pkey = $scope.options.templateOptions.pkey;
  10356. var dataId = $scope.model.id;
  10357. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10358. if (response) {
  10359. var myData = Restangular.stripRestangular(response);
  10360. var processInstanceId = myData.data.processInstanceId;
  10361. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10362. if (result.status == 200) {
  10363. var newData = Restangular.stripRestangular(result);
  10364. var long = newData.data.length - 1;
  10365. $scope.followData = newData.data[long];
  10366. }
  10367. });
  10368. }
  10369. })
  10370. }, 10);
  10371. }]
  10372. });
  10373. // //请求人信息显示
  10374. // formlyConfigProvider.setType({
  10375. // name: "ui-disrequester",
  10376. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  10377. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10378. // defaultOptions: function(options) {
  10379. // return {
  10380. // templateOptions: {}
  10381. // };
  10382. // },
  10383. // controller: ['$scope', function($scope) {
  10384. // $scope.options.templateOptions.that = $scope;
  10385. // }]
  10386. // });
  10387. //退回人信息显示
  10388. formlyConfigProvider.setType({
  10389. name: "ui-returnperson",
  10390. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  10391. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10392. defaultOptions: function (options) {
  10393. return {
  10394. templateOptions: {}
  10395. };
  10396. },
  10397. controller: ['$scope', function ($scope) {
  10398. $scope.group = "";
  10399. $scope.role = "";
  10400. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10401. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10402. } else {
  10403. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10404. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10405. }
  10406. }
  10407. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10408. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10409. } else {
  10410. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10411. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10412. }
  10413. }
  10414. $scope.options.templateOptions.that = $scope;
  10415. $scope.options.templateOptions.that = $scope;
  10416. }]
  10417. });
  10418. //退回人信息显示(去掉工作组&角色)
  10419. formlyConfigProvider.setType({
  10420. name: "ui-returnpersonNoGroup",
  10421. templateUrl: 'assets/views/customform/tpl/ui-returnpersonNoGroup.html',
  10422. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10423. defaultOptions: function (options) {
  10424. return {
  10425. templateOptions: {}
  10426. };
  10427. },
  10428. controller: ['$scope', function ($scope) {
  10429. $scope.group = "";
  10430. $scope.role = "";
  10431. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10432. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10433. } else {
  10434. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10435. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10436. }
  10437. }
  10438. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10439. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10440. } else {
  10441. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10442. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10443. }
  10444. }
  10445. $scope.options.templateOptions.that = $scope;
  10446. $scope.options.templateOptions.that = $scope;
  10447. }]
  10448. });
  10449. //指派技术人员
  10450. formlyConfigProvider.setType({
  10451. name: "ui-apiontperson",
  10452. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  10453. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10454. defaultOptions: function (options) {
  10455. return {
  10456. templateOptions: {
  10457. transtlara: function (value, $scope) { }
  10458. }
  10459. };
  10460. },
  10461. controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
  10462. var filterData = {
  10463. "idx": 0,
  10464. "sum": 1000
  10465. }
  10466. api_user_data.fetchDataList('group', filterData).then(function (response) {
  10467. if (response.status == 200) {
  10468. $scope.select = {};
  10469. $scope.multipleDemo = {};
  10470. $scope.userdata = {};
  10471. var data = response.list;
  10472. var item = [];
  10473. $scope.multipleDemo = data;
  10474. $scope.multipleDemo;
  10475. }
  10476. })
  10477. $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
  10478. if (groupdata.option) {
  10479. $scope.model[$scope.options.key] = {};
  10480. var fildate = {
  10481. "idx": 0,
  10482. "sum": 1000,
  10483. "user": {
  10484. "roledata": {
  10485. "rolecode": model.currentRole
  10486. },
  10487. "selectType": "1",
  10488. "groupdata": {
  10489. "id": groupdata.option.id
  10490. }
  10491. }
  10492. }
  10493. api_user_data.fetchDataList('user', fildate).then(function (response) {
  10494. if (response.status == 200) {
  10495. $scope.userdata = {};
  10496. $scope.userdata = response.list;
  10497. }
  10498. })
  10499. } else {
  10500. $scope.model[$scope.options.key] = {
  10501. id: groupdata.id.id
  10502. }
  10503. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  10504. }
  10505. }
  10506. // }
  10507. }]
  10508. });
  10509. //请求科室信息(小蓝框) lmm
  10510. formlyConfigProvider.setType({
  10511. name: 'ui-deptinformation',
  10512. templateUrl: 'assets/views/customform/tpl/ui-deptinformation.html',
  10513. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10514. return {
  10515. templateOptions: {
  10516. checkform: function (options) {
  10517. }
  10518. }
  10519. };
  10520. },
  10521. controller: ['$scope', 'api_statistic', function ($scope, api_statistic) {
  10522. // console.log($scope)
  10523. }]
  10524. });
  10525. //请求人信息
  10526. formlyConfigProvider.setType({
  10527. name: 'ui-requesterinformation',
  10528. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  10529. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10530. return {
  10531. templateOptions: {
  10532. checkform: function (options) {
  10533. if (options.model.requester) {
  10534. options.value(options.model.requester);
  10535. }
  10536. },
  10537. addRequeter: function (size, options, modal) {
  10538. event.preventDefault();
  10539. var modalInstance = modal.open({
  10540. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  10541. controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
  10542. $scope.title = "新增报修人";
  10543. $scope.requester = {};
  10544. $scope.searchData = {};
  10545. $scope.onChangeadd = function (searchData) {
  10546. $scope.searchKey = searchData.account;
  10547. // $scope.searchDataadd = searchData;
  10548. var requesdata = angular.copy(searchData)
  10549. if (requesdata.mphone) {
  10550. delete requesdata.mphone;
  10551. }
  10552. $scope.requester = requesdata;
  10553. console.log($scope.requester)
  10554. }
  10555. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10556. $scope.requester.account = searchKey;
  10557. $scope.searchData = searchKey;
  10558. serchdataadd(searchKey);
  10559. }
  10560. $scope.getMydata = function (x) {
  10561. $scope.searchField = JSON.parse(x[0]).account;
  10562. $scope.requester = JSON.parse(x[0]);
  10563. console.log($scope.requester)
  10564. }
  10565. $scope.getMydataone = function (x) {
  10566. $scope.searchField = x;
  10567. $scope.requester.account = x;
  10568. }
  10569. serchdataadd();
  10570. api_wechatfile.getDictionary({
  10571. "type": "list",
  10572. "key": "male"
  10573. }).then(function (data) {
  10574. if (data.status == 200) {
  10575. requester.gender = data.list;
  10576. }
  10577. })
  10578. function serchdataadd(searchKey) {
  10579. if (searchKey) {
  10580. var filterData = {
  10581. 'requester': {
  10582. 'searchKey': searchKey,
  10583. },
  10584. idx: 0,
  10585. sum: 10
  10586. };
  10587. } else {
  10588. var filterData = {
  10589. idx: 0,
  10590. sum: 10
  10591. };
  10592. }
  10593. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10594. var myData = response;
  10595. $scope.myData = myData.list;
  10596. });
  10597. }
  10598. api_user_data.fetchDataList('area', {
  10599. idx: 0,
  10600. sum: 1000
  10601. }).then(function (response) {
  10602. if (response.status == 200) {
  10603. $scope.areas = response.list;
  10604. }
  10605. })
  10606. api_wechatfile.getDictionary({
  10607. key: "requester_type",
  10608. type: "list"
  10609. }, {
  10610. idx: 0,
  10611. sum: 100
  10612. }).then(function (response) {
  10613. if (response) {
  10614. $scope.networktypes = response;
  10615. }
  10616. })
  10617. $scope.requesterAreaid = "";
  10618. $scope.onChange = function (item) {
  10619. $scope.requesterAreaid = item.id;
  10620. api_user_data.fetchDataList('place', {
  10621. place: {
  10622. area: {
  10623. id: item.id
  10624. }
  10625. },
  10626. idx: 0,
  10627. sum: 1000
  10628. }).then(function (response) {
  10629. if (response.status == 200) {
  10630. $scope.places = response.list;
  10631. delete $scope.requester.placeDTO;
  10632. }
  10633. })
  10634. }
  10635. $scope.refresh = function (searchVal) {
  10636. var faildata = {};
  10637. if ($scope.requesterAreaid) {
  10638. faildata = {
  10639. 'idx': 0,
  10640. 'sum': 1000,
  10641. 'place': {
  10642. 'areaId': $scope.requesterAreaid,
  10643. 'place': searchVal,
  10644. 'selectType': 'pinyin_qs'
  10645. }
  10646. }
  10647. } else {
  10648. faildata = {
  10649. 'idx': 0,
  10650. 'sum': 1000,
  10651. 'place': {
  10652. 'place': searchVal,
  10653. 'selectType': 'pinyin_qs'
  10654. }
  10655. }
  10656. }
  10657. api_user_data.fetchDataList('place', faildata).then(function (response) {
  10658. $scope.places = response.list;
  10659. delete $scope.requester.placeDTO;
  10660. })
  10661. }
  10662. $scope.refreshDepts = function (key) {
  10663. var filterData = {
  10664. 'idx': 0,
  10665. 'sum': 5,
  10666. 'dept': {
  10667. 'name': key
  10668. }
  10669. };
  10670. UserService.fetchDataList('department', filterData).then(function (response) {
  10671. if (response.status == 200) {
  10672. $scope.depts = response.list;
  10673. }
  10674. })
  10675. }
  10676. $scope.ok = function () {
  10677. if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  10678. SweetAlert.swal("报修人员编号未填!", "请填写报修人员编号", "error");
  10679. } else if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  10680. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  10681. } else if (angular.isUndefined($scope.requester.requesterType) || $scope.requester.requesterType == null || $scope.requester.requesterTypeDTO == "") {
  10682. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  10683. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  10684. SweetAlert.swal("报修人联系电话未填!", "请填写报修人联系电话", "error");
  10685. } else {
  10686. $scope.requesterId = $scope.requester.id;
  10687. var data = {
  10688. incident: {
  10689. requester: {
  10690. id: $scope.requesterId
  10691. }
  10692. },
  10693. idx: 0,
  10694. sum: 3
  10695. };
  10696. api_statistic.tableData(data, 'incident').then(function (data) {
  10697. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  10698. })
  10699. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  10700. if (newObj != oldObj) {
  10701. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  10702. }
  10703. })//lmm
  10704. console.log($scope.requester)
  10705. $modalInstance.close($scope.requester);
  10706. }
  10707. };
  10708. $scope.cancel = function () {
  10709. $modalInstance.dismiss('cancel');
  10710. };
  10711. },
  10712. resolve: {
  10713. items: function () {
  10714. return {
  10715. fetchItems: function (filterData, APIService) {
  10716. filterData = filterData || {};
  10717. if (!filterData.idx) {
  10718. filterData = {
  10719. idx: 0,
  10720. sum: 10
  10721. };
  10722. }
  10723. return options.templateOptions.fetchItems(filterData, APIService);
  10724. }
  10725. };
  10726. },
  10727. title: function () {
  10728. return options.templateOptions.modalTitle;
  10729. },
  10730. Restangular: function () {
  10731. return options.templateOptions.Restangular;
  10732. },
  10733. APIService: function () {
  10734. return options.templateOptions.ApiService;
  10735. },
  10736. UserService: function () {
  10737. return options.templateOptions.UserService;
  10738. },
  10739. sco: function () {
  10740. return $scope;
  10741. }
  10742. }
  10743. });
  10744. modalInstance.result.then(function (selectedItem) {
  10745. console.log(selectedItem)
  10746. if (selectedItem) {
  10747. var data = {
  10748. 'requester': selectedItem
  10749. };
  10750. $scope.searchKey = selectedItem.account;
  10751. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  10752. // if (selectedItem.place && selectedItem.place.place) {
  10753. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  10754. // }
  10755. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  10756. if (response.status == 200) {
  10757. if (options.model) {
  10758. options.model.requester = response.data
  10759. $scope.$parent.$parent.$parent.model.incident.requester = response.data;
  10760. $scope.$parent.$parent.$parent.model.requestershow = response.data;
  10761. if (options.model.place) {
  10762. options.model.place.id = '';
  10763. }
  10764. if (options.model.area) {
  10765. options.model.area.id = '';
  10766. }
  10767. options.model.contacts = selectedItem.name;
  10768. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  10769. options.model.contactsInformation = selectedItem.mphone;
  10770. } else {
  10771. options.model.contactsInformation = selectedItem.telephone;
  10772. }
  10773. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  10774. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10775. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  10776. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  10777. }
  10778. }
  10779. if (!response.data.id) {
  10780. response.data.id = selectedItem.id
  10781. }
  10782. options.value(response.data);
  10783. options.value(response.data);
  10784. console.log($scope,'0000000');
  10785. //新增报修人带入区域地点2020年4月23日19:48:15
  10786. $scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10787. $scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10788. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  10789. if (selectedItem.place && selectedItem.place.id) {
  10790. options.model.place.id = selectedItem.place.id
  10791. options.model.place.area.id = selectedItem.place.area.id
  10792. };
  10793. } else {
  10794. if (selectedItem.place && selectedItem.place.id) {
  10795. options.model.place.id = selectedItem.place.id
  10796. options.model.area.id = selectedItem.place.area.id
  10797. };
  10798. }
  10799. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  10800. // options.model.area.id = selectedItem.place.area.id
  10801. // }
  10802. if (selectedItem.houseNumber) {
  10803. options.model.houseNumber = selectedItem.houseNumber
  10804. }
  10805. // if (selectedItem.id) {
  10806. options.model.account = selectedItem.account;
  10807. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  10808. var baoxiuFields = $scope.$parent.$parent.$parent.$parent.$parent.vm.fields[1].fields;
  10809. var baoxiurenTo;
  10810. baoxiuFields.forEach((e, i) => {
  10811. if (e.key == 'account') {
  10812. baoxiurenTo = e.templateOptions
  10813. baoxiurenTo.APIService.fetchDataList('requester', {
  10814. "idx": 0,
  10815. "sum": 20,
  10816. requester: {
  10817. searchKey: selectedItem.account
  10818. }
  10819. }).then(res => {
  10820. baoxiurenTo.options = res.list;
  10821. options.model.account = selectedItem.account;
  10822. })
  10823. }
  10824. })
  10825. // }
  10826. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  10827. // 选择重复事件侧滑框
  10828. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  10829. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  10830. setTimeout(() => {
  10831. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  10832. }, 500);
  10833. // }
  10834. }
  10835. })
  10836. }
  10837. }, function () { });
  10838. },
  10839. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  10840. var modalInstance = modal.open({
  10841. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  10842. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  10843. $scope.title = "修改报修人";
  10844. $scope.requester = {
  10845. id: modeldata.requester.id,
  10846. account: modeldata.requester.account,
  10847. name: modeldata.requester.name,
  10848. gender: modeldata.requester.gender,
  10849. email: modeldata.requester.email,
  10850. deptName: modeldata.requester.deptName,
  10851. mphone: modeldata.requester.mphone,
  10852. telephone: modeldata.requester.telephone,
  10853. studentNo: modeldata.requester.studentNo,
  10854. areaDTO: modeldata.requester.areaDTO,
  10855. placeDTO: modeldata.requester.placeDTO,
  10856. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  10857. };
  10858. $scope.onChangeadd = function (searchData) {
  10859. console.log(searchData)
  10860. $scope.searchKey = searchData.account;
  10861. var requesdata = angular.copy(searchData)
  10862. if (requesdata.mphone) {
  10863. delete requesdata.mphone;
  10864. }
  10865. $scope.requester = requesdata;
  10866. }
  10867. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10868. $scope.requester.account = searchKey;
  10869. $scope.searchData = searchKey;
  10870. serchdataadd(searchKey);
  10871. }
  10872. $scope.getMydata = function (x) {
  10873. $scope.searchField = JSON.parse(x[0]).account;
  10874. $scope.requester = JSON.parse(x[0]);
  10875. }
  10876. $scope.getMydataone = function (x) {
  10877. $scope.searchField = x;
  10878. $scope.requester.account = x;
  10879. }
  10880. serchdataadd();
  10881. function serchdataadd(searchKey) {
  10882. if (searchKey) {
  10883. var filterData = {
  10884. 'requester': {
  10885. 'searchKey': searchKey,
  10886. },
  10887. idx: 0,
  10888. sum: 10
  10889. };
  10890. } else {
  10891. var filterData = {
  10892. idx: 0,
  10893. sum: 10
  10894. };
  10895. }
  10896. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10897. var myData = response;
  10898. $scope.myData = myData.list;
  10899. });
  10900. }
  10901. api_user_data.fetchDataList('area', {
  10902. idx: 0,
  10903. sum: 1000
  10904. }).then(function (response) {
  10905. if (response.status == 200) {
  10906. $scope.areas = response.list;
  10907. }
  10908. })
  10909. api_user_data.fetchDataList('requesterType', {
  10910. idx: 0,
  10911. sum: 100
  10912. }).then(function (response) {
  10913. if (response.status == 200) {
  10914. $scope.networktypes = response.list;
  10915. }
  10916. })
  10917. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  10918. api_user_data.fetchDataList('place', {
  10919. place: {
  10920. areaId: $scope.requester.areaDTO.id
  10921. },
  10922. idx: 0,
  10923. sum: 1000
  10924. }).then(function (response) {
  10925. if (response.status == 200) {
  10926. $scope.places = response.list;
  10927. }
  10928. })
  10929. }
  10930. $scope.onChange = function (item) {
  10931. $scope.requester.placeDTO = {};
  10932. api_user_data.fetchDataList('place', {
  10933. place: {
  10934. areaId: item.id
  10935. },
  10936. idx: 0,
  10937. sum: 1000
  10938. }).then(function (response) {
  10939. if (response.status == 200) {
  10940. $scope.places = response.list;
  10941. }
  10942. })
  10943. }
  10944. $scope.refreshDepts = function (key) {
  10945. var filterData = {
  10946. 'idx': 0,
  10947. 'sum': 5,
  10948. 'dept': {
  10949. 'name': key
  10950. }
  10951. };
  10952. UserService.fetchDataList('department', filterData).then(function (response) {
  10953. if (response.status == 200) {
  10954. $scope.depts = response.list;
  10955. }
  10956. })
  10957. }
  10958. $scope.ok = function () {
  10959. if ($scope.requester.account == "" || $scope.requester.name == "") {
  10960. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  10961. } else {
  10962. $modalInstance.close($scope.requester);
  10963. }
  10964. };
  10965. $scope.cancel = function () {
  10966. $modalInstance.dismiss('cancel');
  10967. };
  10968. },
  10969. resolve: {
  10970. items: function () {
  10971. return {
  10972. fetchItems: function (filterData, APIService) {
  10973. filterData = filterData || {};
  10974. if (!filterData.idx) {
  10975. filterData = {
  10976. idx: 0,
  10977. sum: 10
  10978. };
  10979. }
  10980. return options.templateOptions.fetchItems(filterData, APIService);
  10981. }
  10982. };
  10983. },
  10984. title: function () {
  10985. return options.templateOptions.modalTitle;
  10986. },
  10987. Restangular: function () {
  10988. return options.templateOptions.Restangular;
  10989. },
  10990. APIService: function () {
  10991. return options.templateOptions.ApiService;
  10992. },
  10993. UserService: function () {
  10994. return options.templateOptions.UserService;
  10995. }
  10996. }
  10997. });
  10998. modalInstance.result.then(function (selectedItem) {
  10999. console.log(selectedItem)
  11000. if (selectedItem) {
  11001. if (options.model) {
  11002. if (options.model.place) {
  11003. options.model.place.id = '';
  11004. }
  11005. if (options.model.area) {
  11006. options.model.area.id = '';
  11007. }
  11008. options.model.contacts = selectedItem.name;
  11009. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11010. options.model.contactsInformation = selectedItem.mphone;
  11011. } else {
  11012. options.model.contactsInformation = selectedItem.telephone;
  11013. }
  11014. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11015. options.model.place.id = selectedItem.placeDTO.id
  11016. }
  11017. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11018. options.model.area.id = selectedItem.areaDTO.id
  11019. }
  11020. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11021. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11022. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11023. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11024. }
  11025. }
  11026. var data = {
  11027. 'requester': selectedItem
  11028. };
  11029. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  11030. if (response.status == 200) {
  11031. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  11032. options.value(response.data);
  11033. } else { }
  11034. })
  11035. }
  11036. }, function () { });
  11037. event.preventDefault();
  11038. }
  11039. }
  11040. };
  11041. },
  11042. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  11043. $scope.options.initialValue = $scope.model[$scope.options.key];
  11044. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  11045. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11046. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11047. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11048. }
  11049. }]
  11050. });
  11051. // 请求人选控件
  11052. formlyConfigProvider.setType({
  11053. name: "ui-requesterselect",
  11054. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  11055. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11056. defaultOptions: function (options, $scope) {
  11057. return {
  11058. templateOptions: {
  11059. // checkform: function(options) {
  11060. // if (options.model.requestershow) {
  11061. // options.value(options.model.requestershow);
  11062. // }
  11063. // },
  11064. validators: {
  11065. required: {
  11066. expression: function (viewValue, modelValue) {
  11067. var value = modelValue || viewValue;
  11068. return value.length >= 1;
  11069. }
  11070. }
  11071. },
  11072. openModal: function (size, options, modal) { //查找弹出框
  11073. var modelObject = options.value();
  11074. var searchModal = function (filterSearchData) {
  11075. var modalInstance = modal.open({
  11076. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11077. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  11078. $scope.langs = i18nService.getAllLangs();
  11079. $scope.lang = 'zh-cn';
  11080. i18nService.setCurrentLang($scope.lang);
  11081. $scope.gridOptions = {};
  11082. $scope.gridOptions.data = 'myData';
  11083. $scope.gridOptions.enableColumnResizing = true;
  11084. $scope.gridOptions.enableFiltering = true;
  11085. $scope.gridOptions.enableGridMenu = false;
  11086. $scope.gridOptions.enableRowSelection = true;
  11087. $scope.gridOptions.showGridFooter = true;
  11088. $scope.gridOptions.showColumnFooter = false;
  11089. $scope.gridOptions.fastWatch = true;
  11090. $scope.gridOptions.useExternalFiltering = true;
  11091. $scope.gridOptions.useExternalPagination = true;
  11092. $scope.gridOptions.paginationPageSizes = [10];
  11093. $scope.gridOptions.paginationPageSize = 10;
  11094. $scope.gridOptions.multiSelect = false;
  11095. $scope.gridOptions.rowIdentity = function (row) {
  11096. return row.id;
  11097. };
  11098. $scope.gridOptions.getRowIdentity = function (row) {
  11099. return row.id;
  11100. };
  11101. $scope.gridOptions.columnDefs = [{
  11102. name: 'account',
  11103. displayName: '人员编号',
  11104. width: 140
  11105. },
  11106. {
  11107. name: 'name',
  11108. displayName: '姓名',
  11109. width: 100
  11110. },
  11111. {
  11112. name: 'gender.name',
  11113. displayName: '性别',
  11114. width: 80,
  11115. enableFiltering: false
  11116. },
  11117. {
  11118. name: 'mphone',
  11119. displayName: '电话',
  11120. width: 100,
  11121. enableFiltering: false
  11122. },
  11123. {
  11124. name: 'email',
  11125. displayName: '邮件',
  11126. width: 100
  11127. },
  11128. {
  11129. name: 'areaDTO.area',
  11130. displayName: '区域',
  11131. width: 100,
  11132. enableFiltering: false
  11133. },
  11134. {
  11135. name: 'placeDTO.place',
  11136. displayName: '地点',
  11137. enableFiltering: false
  11138. }
  11139. ];
  11140. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11141. $scope.gridApi = gridApi;
  11142. // var filtersData = $scope.memoryfilterData;
  11143. // filtersData.idx = newPage - 1;
  11144. // filtersData.sum = pageSize;
  11145. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11146. var filtersData = $scope.memoryfilterData;
  11147. filtersData.idx = newPage - 1;
  11148. filtersData.sum = pageSize;
  11149. $scope.loadData(filtersData);
  11150. });
  11151. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11152. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  11153. $scope.selected.item = data.entity;
  11154. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  11155. });
  11156. gridApi.core.on.filterChanged($scope, function () {
  11157. var grid = this.grid;
  11158. var filtersData = {
  11159. idx: 0,
  11160. sum: 10
  11161. // 'requester': { 'userType': 1 }
  11162. };
  11163. angular.forEach(grid.columns, function (item) {
  11164. if (item.enableFiltering) {
  11165. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11166. if (angular.isUndefined(filtersData['requester'])) {
  11167. filtersData['requester'] = {};
  11168. }
  11169. filtersData['requester'][item.field] = item.filters[0].term;
  11170. }
  11171. }
  11172. });
  11173. $scope.memoryfilterData = filtersData;
  11174. $scope.loadData(filtersData);
  11175. });
  11176. };
  11177. $scope.memoryfilterData = defaultFilterData = {
  11178. "idx": 0,
  11179. "sum": 10
  11180. };
  11181. $scope.loadData = function (filterData) {
  11182. if (!filterData.requester) {
  11183. filterData.requester = {};
  11184. }
  11185. if (scope.roleidcode) {
  11186. angular.extend(filterData['requester'], {
  11187. 'userType': 1
  11188. });
  11189. }
  11190. items.fetchItems(filterData, APIService).then(function (data) {
  11191. var myData = Restangular.stripRestangular(data);
  11192. $scope.gridOptions.totalItems = myData.totalNum;
  11193. $scope.myData = myData.list;
  11194. });
  11195. };
  11196. // $scope.title = title;
  11197. if (searchDatas) {
  11198. $scope.loadData(searchDatas);
  11199. } else {
  11200. $scope.loadData({
  11201. idx: 0,
  11202. sum: 10,
  11203. });
  11204. }
  11205. $scope.selected = {
  11206. item: {}
  11207. };
  11208. $scope.ok = function () {
  11209. $modalInstance.close($scope.selected.item);
  11210. };
  11211. $scope.cancel = function () {
  11212. $modalInstance.dismiss('cancel');
  11213. };
  11214. },
  11215. size: size,
  11216. resolve: {
  11217. items: function () {
  11218. return {
  11219. fetchItems: function (filterData, APIService) {
  11220. filterData = filterData || {};
  11221. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  11222. filterData = {
  11223. idx: 0,
  11224. sum: 10
  11225. };
  11226. }
  11227. return options.templateOptions.fetchItems(filterData, APIService);
  11228. }
  11229. };
  11230. },
  11231. title: function () {
  11232. return options.templateOptions.modalTitle;
  11233. },
  11234. Restangular: function () {
  11235. return options.templateOptions.Restangular;
  11236. },
  11237. APIService: function () {
  11238. return options.templateOptions.ApiService;
  11239. },
  11240. language: function () {
  11241. return options.templateOptions.language;
  11242. },
  11243. searchDatas: function () {
  11244. return filterSearchData;
  11245. },
  11246. scope: function () {
  11247. return $scope;
  11248. }
  11249. }
  11250. });
  11251. modalInstance.result.then(function (selectedItem) {
  11252. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11253. selectedItem.telephone = $scope.model.incident.contactsInformation;
  11254. }
  11255. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  11256. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  11257. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  11258. if ($scope.model) {
  11259. if ($scope.model.incident.place) {
  11260. $scope.model.incident.place.id = '';
  11261. }
  11262. if ($scope.model.area) {
  11263. $scope.model.incident.area.id = '';
  11264. }
  11265. $scope.model.incident.contacts = selectedItem.name;
  11266. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11267. $scope.model.incident.contactsInformation = selectedItem.mphone;
  11268. } else {
  11269. $scope.model.incident.contactsInformation = selectedItem.telephone;
  11270. }
  11271. $scope.model.incident.houseNumber = '';
  11272. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11273. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11274. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11275. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11276. }
  11277. }
  11278. $scope.options.value(selectedItem);
  11279. $scope.searchData = selectedItem.account;
  11280. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11281. $scope.model.incident.place.id = selectedItem.placeDTO.id
  11282. }
  11283. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11284. $scope.model.incident.area.id = selectedItem.areaDTO.id
  11285. }
  11286. if (selectedItem.houseNumber) {
  11287. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  11288. }
  11289. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11290. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11291. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11292. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11293. }
  11294. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  11295. options.templateOptions.callback(selectedItem, options);
  11296. }
  11297. if (!$scope.roleidcode) {
  11298. $scope.charging(selectedItem, modal)
  11299. }
  11300. $scope.recentlyincident(selectedItem);
  11301. }, function () {
  11302. //console.log('Modal dismissed at: ' + new Date());
  11303. });
  11304. }
  11305. searchModal();
  11306. // }
  11307. }
  11308. }
  11309. };
  11310. },
  11311. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  11312. $scope.roleidcode = true;
  11313. // $scope.options.initialValue = undefined;
  11314. if ($rootScope.user && $rootScope.user.role) {
  11315. angular.forEach($rootScope.user.role, function (item) {
  11316. if (item.rolecode == "call center") {
  11317. $scope.roleidcode = false;
  11318. }
  11319. })
  11320. }
  11321. $scope.recently = false;
  11322. $scope.recentlyincident = function (key, model) { //关联事件
  11323. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  11324. "idx": 0,
  11325. "sum": 4,
  11326. incident: {
  11327. requester: {
  11328. id: key.id
  11329. }
  11330. }
  11331. }).then(function (response) {
  11332. if (response.status == 200) {
  11333. $scope.recently = true;
  11334. $scope.recentincident = response.list;
  11335. } else {
  11336. $scope.recently = false;
  11337. }
  11338. })
  11339. $scope.bodyHeight = window.innerHeight - 100;
  11340. $(window).resize(function () {
  11341. $scope.bodyHeight = window.innerHeight - 100;
  11342. });
  11343. // $scope.shows = false;
  11344. $scope.tempData = {};
  11345. $scope.close = function () {
  11346. $scope.changes = !$scope.changes;
  11347. event.preventDefault();
  11348. }
  11349. }
  11350. $scope.charging = function (key, model) { //计费弹出框
  11351. //用户信息
  11352. $scope.information = {};
  11353. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  11354. "userId": key.account
  11355. }).then(function (response) {
  11356. // if (response.status == 200) {
  11357. if (response && response.data) {
  11358. angular.extend($scope.information, response.data[0]);
  11359. // $scope.information = response.data[0];
  11360. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  11361. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  11362. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  11363. } else if (response.err) {
  11364. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  11365. }
  11366. // }
  11367. })
  11368. //上网明细
  11369. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  11370. "userId": key.account,
  11371. "limit": "10",
  11372. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  11373. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  11374. }).then(function (response) {
  11375. // if (response.status == 200) {
  11376. if (response && response.data) {
  11377. angular.forEach(response.data, function (item, index) {
  11378. if (item.logoutTime) {
  11379. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  11380. }
  11381. if (item.loginTime) {
  11382. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  11383. }
  11384. })
  11385. $scope.logininform = response.data;
  11386. } else if (response.err) {
  11387. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  11388. }
  11389. })
  11390. //黑名单
  11391. // $scope.information.blacklist = "否"
  11392. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  11393. "userId": key.account
  11394. }).then(function (response) {
  11395. // if (response.status == 200) {
  11396. // $scope.logininformation = response.data;
  11397. if (response) {
  11398. if (response.data || response.data != null) {
  11399. $scope.information.blacklist = "是"
  11400. } else {
  11401. if (response.err) {
  11402. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  11403. } else {
  11404. $scope.information.blacklist = "否"
  11405. }
  11406. }
  11407. }
  11408. // }
  11409. })
  11410. $scope.bodyHeight = window.innerHeight - 100;
  11411. $(window).resize(function () {
  11412. $scope.bodyHeight = window.innerHeight - 100;
  11413. });
  11414. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  11415. // $scope.closepages = function(e) {
  11416. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  11417. // event.preventDefault();
  11418. // };
  11419. // $scope.shows = false;
  11420. $scope.tempData = {};
  11421. $scope.close = function () {
  11422. $scope.changes = !$scope.changes;
  11423. event.preventDefault();
  11424. }
  11425. }
  11426. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  11427. idx: 0,
  11428. sum: 100
  11429. }).then(function (response) {
  11430. if (response.status == 200) {
  11431. $scope.networktypes = response.list;
  11432. } else {
  11433. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  11434. }
  11435. })
  11436. function serchdata(searchKey) {
  11437. if (searchKey) {
  11438. var filterData = {
  11439. 'requester': {
  11440. 'searchKey': searchKey
  11441. // 'userType': 1
  11442. },
  11443. idx: 0,
  11444. sum: 10
  11445. };
  11446. } else {
  11447. var filterData = {
  11448. 'idx': 0,
  11449. 'requester': {},
  11450. 'sum': 10
  11451. };
  11452. }
  11453. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  11454. angular.extend(filterData.requester, {
  11455. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  11456. });
  11457. if (!$scope.options.model.contactsInformation) {
  11458. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  11459. }
  11460. }
  11461. if ($scope.roleidcode) {
  11462. angular.extend(filterData['requester'], {
  11463. 'userType': 1
  11464. });
  11465. }
  11466. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  11467. var myData = response;
  11468. $scope.myData = myData.list;
  11469. });
  11470. }
  11471. $scope.searchData = {};
  11472. $scope.refreshUser = function (searchKey) { //请求人搜索
  11473. if (searchKey && searchKey != "") {
  11474. serchdata(searchKey);
  11475. }
  11476. }
  11477. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  11478. if (!$scope.roleidcode) {
  11479. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  11480. }
  11481. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  11482. }
  11483. $scope.onChange = function (searchData) {
  11484. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11485. searchData.telephone = $scope.model.incident.contactsInformation;;
  11486. }
  11487. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  11488. if (!$scope.roleidcode) {
  11489. $scope.charging(searchData);
  11490. }
  11491. $scope.recentlyincident(searchData);
  11492. $scope.accountshow = false;
  11493. if ($scope.model.incident) {
  11494. if ($scope.model.incident.place) {
  11495. $scope.model.incident.place.id = '';
  11496. }
  11497. if ($scope.model.incident.area) {
  11498. $scope.model.incident.area.id = '';
  11499. }
  11500. $scope.model.incident.contacts = searchData.name;
  11501. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  11502. $scope.model.incident.contactsInformation = searchData.mphone;
  11503. } else {
  11504. $scope.model.incident.contactsInformation = searchData.telephone;
  11505. }
  11506. $scope.model.incident.houseNumber = '';
  11507. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11508. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11509. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11510. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11511. }
  11512. }
  11513. $scope.options.value(searchData);
  11514. $scope.searchKey = searchData.account;
  11515. if (searchData.placeDTO && searchData.placeDTO.id) {
  11516. $scope.model.incident.place.id = searchData.placeDTO.id
  11517. }
  11518. if (searchData.areaDTO && searchData.areaDTO.id) {
  11519. $scope.model.incident.area.id = searchData.areaDTO.id
  11520. }
  11521. if (searchData.houseNumber) {
  11522. $scope.model.incident.houseNumber = searchData.houseNumber;
  11523. }
  11524. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11525. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11526. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11527. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11528. }
  11529. }
  11530. }]
  11531. });
  11532. //ui-grid-table展示控件
  11533. formlyConfigProvider.setType({
  11534. name: 'ui-grid-table',
  11535. // extends: 'multiCheckbox',//去掉冒号
  11536. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  11537. defaultOptions: function (options) {
  11538. return {
  11539. templateOptions: {
  11540. linkage: function () { },
  11541. },
  11542. };
  11543. },
  11544. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  11545. var loginUser = $rootScope.user;
  11546. $scope.langs = i18nService.getAllLangs();
  11547. $scope.lang = 'zh-cn';
  11548. i18nService.setCurrentLang($scope.lang);
  11549. $scope.gridOptions = {};
  11550. $scope.gridOptions.data = 'myData';
  11551. $scope.gridOptions.enableColumnResizing = true;
  11552. $scope.gridOptions.enableGridMenu = false;
  11553. $scope.gridOptions.enableRowSelection = true;
  11554. $scope.gridOptions.showGridFooter = false;
  11555. $scope.gridOptions.showColumnFooter = false;
  11556. $scope.gridOptions.fastWatch = true;
  11557. $scope.gridOptions.useExternalFiltering = true;
  11558. $scope.gridOptions.useExternalPagination = false;
  11559. $scope.gridOptions.paginationPageSizes = [10];
  11560. $scope.gridOptions.paginationPageSize = 3;
  11561. $scope.gridOptions.multiSelect = false;
  11562. $scope.gridOptions.rowIdentity = function (row) {
  11563. return row.id;
  11564. };
  11565. $scope.gridOptions.getRowIdentity = function (row) {
  11566. return row.id;
  11567. };
  11568. $scope.gridOptions.columnDefs = [{
  11569. name: 'item',
  11570. displayName: '序号',
  11571. width: 80,
  11572. enableFiltering: false
  11573. },
  11574. {
  11575. name: 'incidentsign',
  11576. displayName: '单号',
  11577. width: 80,
  11578. enableFiltering: false
  11579. },
  11580. {
  11581. name: 'description',
  11582. displayName: '主题',
  11583. width: 80,
  11584. enableFiltering: false
  11585. },
  11586. {
  11587. name: 'state.name',
  11588. displayName: '状态',
  11589. width: 110,
  11590. enableFiltering: false
  11591. },
  11592. {
  11593. name: 'acceptDate',
  11594. displayName: '创建时间',
  11595. width: 160,
  11596. enableFiltering: false
  11597. },
  11598. {
  11599. name: 'requester.name',
  11600. displayName: '请求人',
  11601. width: 80,
  11602. enableFiltering: false
  11603. },
  11604. {
  11605. name: 'handlingPersonnelUser.name',
  11606. displayName: '处理人',
  11607. width: 160,
  11608. enableFiltering: false
  11609. },
  11610. {
  11611. name: 'place.place',
  11612. displayName: '区域地点',
  11613. width: 160,
  11614. enableFiltering: false
  11615. },
  11616. ];
  11617. // var defaultFilterData = {
  11618. // "idx": 0,
  11619. // "sum": 3
  11620. // };
  11621. // // //分页控制
  11622. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11623. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11624. var filtersData = $scope.memoryfilterData;
  11625. filtersData.idx = newPage - 1;
  11626. filtersData.sum = pageSize;
  11627. $scope.refreshData('expand-right', filtersData);
  11628. });
  11629. // 表格单选事件
  11630. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11631. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  11632. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  11633. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  11634. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  11635. str = str.split("").reverse().join("");
  11636. var del = addstr.split("").reverse().join("");
  11637. // console.log(del);
  11638. var reg = new RegExp(del);
  11639. str = str.replace(reg, '');
  11640. str = str.split("").reverse().join("")
  11641. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  11642. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  11643. str += data.entity.description;
  11644. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  11645. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  11646. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  11647. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  11648. }
  11649. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  11650. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  11651. });
  11652. };
  11653. // 刷新表格
  11654. setInterval(function () {
  11655. // console.log($scope.myData);
  11656. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  11657. // console.log($scope.myData);
  11658. if ($scope.myData != null) {
  11659. for (var i = 0; i < $scope.myData.length; i++) {
  11660. //添加序号
  11661. $scope.myData[i]['item'] = i + 1;
  11662. }
  11663. }
  11664. }, 1000)
  11665. }
  11666. });
  11667. //处理人信息
  11668. formlyConfigProvider.setType({
  11669. name: "ui-userinformation",
  11670. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  11671. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11672. defaultOptions: function (options) {
  11673. return {
  11674. templateOptions: {}
  11675. };
  11676. },
  11677. controller: ['$scope', function ($scope) {
  11678. $scope.group = "";
  11679. $scope.role = "";
  11680. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11681. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11682. } else {
  11683. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11684. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11685. }
  11686. }
  11687. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  11688. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  11689. } else {
  11690. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  11691. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  11692. }
  11693. }
  11694. $scope.options.templateOptions.that = $scope;
  11695. }]
  11696. });
  11697. //处理界面处理人信息
  11698. formlyConfigProvider.setType({
  11699. name: "ui-handler",
  11700. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  11701. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11702. defaultOptions: function (options) {
  11703. return {
  11704. templateOptions: {}
  11705. };
  11706. },
  11707. controller: ['$scope', function ($scope) {
  11708. $scope.group = "";
  11709. // $scope.role="";
  11710. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11711. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11712. } else {
  11713. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11714. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11715. }
  11716. }
  11717. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  11718. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  11719. // }else{
  11720. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  11721. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  11722. // }
  11723. // }
  11724. $scope.options.templateOptions.that = $scope;
  11725. }]
  11726. });
  11727. //微信事件流程
  11728. formlyConfigProvider.setType({
  11729. name: "ui-wxIncidentProcess",
  11730. templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
  11731. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11732. defaultOptions: function (options) {
  11733. return {
  11734. templateOptions: {}
  11735. };
  11736. },
  11737. controller: ['$scope', function ($scope) {
  11738. console.log($scope.model);
  11739. $scope.pingjia = false;
  11740. $scope.jiejue = false;
  11741. if ($scope.model.incidentState.value == "3") {
  11742. $scope.pingjia = true
  11743. } else if ($scope.model.incidentState.value == "4") {
  11744. $scope.jiejue = true;
  11745. }
  11746. }]
  11747. });
  11748. //打电话
  11749. formlyConfigProvider.setType({
  11750. name: "ui-inputcall",
  11751. extends: 'input',
  11752. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  11753. defaultOptions: function (options) {
  11754. return {
  11755. templateOptions: {
  11756. transform: function (value) { }
  11757. }
  11758. };
  11759. },
  11760. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  11761. $scope.dialout = function (teleno) {
  11762. var gid = "@0"
  11763. var telephone = '9' + teleno
  11764. $rootScope.callout = 2;
  11765. if ($rootScope.takes) {
  11766. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11767. if (data.errno == 0) {
  11768. $rootScope.status = 6;
  11769. }
  11770. })
  11771. } else {
  11772. SweetAlert.swal({
  11773. title: "呼叫失败",
  11774. text: "请先签入呼叫中心!",
  11775. type: "error",
  11776. confirmButtonColor: "#DD6B55"
  11777. });
  11778. }
  11779. }
  11780. $scope.options.templateOptions.that = $scope;
  11781. }]
  11782. });
  11783. //关闭界面处理人信息
  11784. formlyConfigProvider.setType({
  11785. name: "ui-closehandler",
  11786. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  11787. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11788. defaultOptions: function (options) {
  11789. return {
  11790. templateOptions: {}
  11791. };
  11792. },
  11793. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  11794. $scope.dialout = function (teleno) {
  11795. var gid = "@0"
  11796. var telephone = '9' + teleno
  11797. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11798. if (data.errno == 0) {
  11799. $rootScope.status = 6;
  11800. }
  11801. })
  11802. }
  11803. $scope.options.templateOptions.that = $scope;
  11804. }]
  11805. });
  11806. //用户单选控件
  11807. formlyConfigProvider.setType({
  11808. name: "ui-userselect",
  11809. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  11810. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11811. defaultOptions: function (options) {
  11812. return {
  11813. templateOptions: {
  11814. openModal: function (size, options, modal) {
  11815. var modalInstance = modal.open({
  11816. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11817. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  11818. $scope.langs = i18nService.getAllLangs();
  11819. $scope.lang = 'zh-cn';
  11820. i18nService.setCurrentLang($scope.lang);
  11821. $scope.gridOptions = {};
  11822. $scope.gridOptions.data = 'myData';
  11823. $scope.gridOptions.enableColumnResizing = true;
  11824. $scope.gridOptions.enableFiltering = true;
  11825. $scope.gridOptions.enableGridMenu = false;
  11826. $scope.gridOptions.showGridFooter = true;
  11827. $scope.gridOptions.showColumnFooter = false;
  11828. $scope.gridOptions.fastWatch = true;
  11829. $scope.gridOptions.useExternalFiltering = true;
  11830. $scope.gridOptions.useExternalPagination = true;
  11831. $scope.gridOptions.paginationPageSizes = [10];
  11832. $scope.gridOptions.paginationPageSize = 10;
  11833. $scope.gridOptions.multiSelect = false;
  11834. $scope.gridOptions.rowIdentity = function (row) {
  11835. return row.id;
  11836. };
  11837. $scope.gridOptions.getRowIdentity = function (row) {
  11838. return row.id;
  11839. };
  11840. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  11841. $scope.gridOptions.columnDefs = [{
  11842. name: 'account',
  11843. displayName: '人员编号',
  11844. width: 120
  11845. },
  11846. {
  11847. name: 'name',
  11848. displayName: '姓名',
  11849. width: 100,
  11850. cellTemplate: '<div>' +
  11851. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  11852. '</div>'
  11853. },
  11854. // {
  11855. // name: 'gender.name',
  11856. // displayName: '性别',
  11857. // width: 80,
  11858. // enableFiltering: false
  11859. // },
  11860. {
  11861. name: 'phone',
  11862. displayName: '电话',
  11863. width: 230,
  11864. enableFiltering: false
  11865. },
  11866. {
  11867. name: 'email',
  11868. displayName: '邮箱',
  11869. width: 180,
  11870. enableFiltering: false
  11871. },
  11872. {
  11873. name: 'dept.dept',
  11874. displayName: '科室',
  11875. width: 130,
  11876. enableFiltering: false
  11877. },
  11878. {
  11879. name: 'taskCount',
  11880. displayName: '处理中事件数',
  11881. enableFiltering: false
  11882. }
  11883. ];
  11884. // $scope.selectButtonClick
  11885. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11886. $scope.gridApi = gridApi;
  11887. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11888. var filtersData = $scope.memoryfilterData;
  11889. filtersData.idx = newPage - 1;
  11890. filtersData.sum = pageSize;
  11891. $scope.loadData(filtersData);
  11892. //console.log(pageSize);
  11893. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  11894. });
  11895. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11896. $scope.selected.items = data.entity;
  11897. //console.log(data);
  11898. });
  11899. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  11900. $scope.selected.items = data.entity;
  11901. //console.log(data);
  11902. });
  11903. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  11904. // // if (row.entity.age > 45) {
  11905. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11906. // // }
  11907. // };
  11908. gridApi.core.on.filterChanged($scope, function () {
  11909. var grid = this.grid;
  11910. var filtersData = {
  11911. idx: 0,
  11912. sum: 10,
  11913. "user": {
  11914. "roledata": {
  11915. "rolecode": "roleset"
  11916. },
  11917. "selectType": "1"
  11918. }
  11919. };
  11920. angular.forEach(grid.columns, function (item) {
  11921. if (item.enableFiltering) {
  11922. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  11923. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11924. if (angular.isUndefined(filtersData['user'])) {
  11925. filtersData['user'] = {};
  11926. }
  11927. filtersData['user'][item.field] = item.filters[0].term;
  11928. }
  11929. }
  11930. });
  11931. $scope.memoryfilterData = filtersData;
  11932. $scope.loadData(filtersData);
  11933. });
  11934. };
  11935. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  11936. // if (row.entity.age > 45) {
  11937. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11938. // }
  11939. // },
  11940. $scope.onDblClick = function (data, event) {
  11941. // $scope.selected.items = data.entity;
  11942. $scope.selectButtonClick(data, event);
  11943. };
  11944. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  11945. // $scope.selected.items = data.entity;
  11946. // })
  11947. // };
  11948. $scope.memoryfilterData = {
  11949. "idx": 0,
  11950. "sum": 10,
  11951. "user": {
  11952. "roledata": {
  11953. "rolecode": "roleset"
  11954. },
  11955. "selectType": "1"
  11956. }
  11957. }
  11958. $scope.loadData = function (filterData) {
  11959. // console.log("filtersData=111" + JSON.stringify(filterData))
  11960. items.fetchItems(filterData, APIService).then(function (data) {
  11961. var myData = Restangular.stripRestangular(data);
  11962. $scope.gridOptions.totalItems = myData.totalNum;
  11963. $scope.myData = myData.list;
  11964. });
  11965. };
  11966. // $scope.title = title;
  11967. $scope.loadData({
  11968. idx: 0,
  11969. sum: 10,
  11970. "user": {
  11971. "roledata": {
  11972. "rolecode": "roleset"
  11973. },
  11974. "selectType": "1"
  11975. }
  11976. });
  11977. $scope.selected = {
  11978. items: {}
  11979. };
  11980. $scope.ok = function () {
  11981. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  11982. // onDataCallback($scope.selected.item, parentScope);
  11983. // }
  11984. $modalInstance.close($scope.selected.items);
  11985. };
  11986. $scope.cancel = function () {
  11987. $modalInstance.dismiss('cancel');
  11988. };
  11989. },
  11990. size: size,
  11991. resolve: {
  11992. items: function () {
  11993. return {
  11994. fetchItems: function (filterData, APIService) {
  11995. filterData = filterData || {};
  11996. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  11997. filterData = {
  11998. idx: 0,
  11999. sum: 10,
  12000. "user": {
  12001. "roledata": {
  12002. "rolecode": "roleset"
  12003. },
  12004. "selectType": "1"
  12005. }
  12006. };
  12007. }
  12008. return options.templateOptions.fetchItems(filterData, APIService);
  12009. }
  12010. };
  12011. },
  12012. title: function () {
  12013. return options.templateOptions.label;
  12014. },
  12015. Restangular: function () {
  12016. return options.templateOptions.Restangular;
  12017. },
  12018. APIService: function () {
  12019. return options.templateOptions.ApiService;
  12020. },
  12021. onDataCallback: function () {
  12022. return options.templateOptions.callback;
  12023. },
  12024. parentScope: function () {
  12025. return options.templateOptions.that;
  12026. }
  12027. }
  12028. });
  12029. modalInstance.result.then(function (selectedItem) {
  12030. // console.log(selectedItem);
  12031. options.value(selectedItem);
  12032. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12033. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12034. }
  12035. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12036. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12037. }
  12038. }, function () {
  12039. //console.log('Modal dismissed at: ' + new Date());
  12040. });
  12041. }
  12042. }
  12043. };
  12044. },
  12045. controller: ['$scope', function ($scope) {
  12046. $scope.options.templateOptions.that = $scope;
  12047. // $scope.options.model[$scope.options.key] = {}
  12048. }]
  12049. });
  12050. //用户单选控件(dd 单选input带搜索)
  12051. formlyConfigProvider.setType({
  12052. name: "ui-userselectSearch",
  12053. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  12054. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12055. defaultOptions: function (options) {
  12056. return {
  12057. templateOptions: {
  12058. openModal: function (size, options, modal) {
  12059. var modalInstance = modal.open({
  12060. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12061. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  12062. $scope.langs = i18nService.getAllLangs();
  12063. $scope.lang = 'zh-cn';
  12064. i18nService.setCurrentLang($scope.lang);
  12065. $scope.gridOptions = {};
  12066. $scope.gridOptions.data = 'myData';
  12067. $scope.gridOptions.enableColumnResizing = true;
  12068. $scope.gridOptions.enableFiltering = true;
  12069. $scope.gridOptions.enableGridMenu = false;
  12070. $scope.gridOptions.showGridFooter = true;
  12071. $scope.gridOptions.showColumnFooter = false;
  12072. $scope.gridOptions.fastWatch = true;
  12073. $scope.gridOptions.useExternalFiltering = true;
  12074. $scope.gridOptions.useExternalPagination = true;
  12075. $scope.gridOptions.paginationPageSizes = [10];
  12076. $scope.gridOptions.paginationPageSize = 10;
  12077. $scope.gridOptions.multiSelect = false;
  12078. $scope.gridOptions.rowIdentity = function (row) {
  12079. return row.id;
  12080. };
  12081. $scope.gridOptions.getRowIdentity = function (row) {
  12082. return row.id;
  12083. };
  12084. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  12085. $scope.gridOptions.columnDefs = [{
  12086. name: 'account',
  12087. displayName: '人员编号',
  12088. width: 120
  12089. },
  12090. {
  12091. name: 'name',
  12092. displayName: '姓名',
  12093. width: 100,
  12094. cellTemplate: '<div>' +
  12095. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  12096. '</div>'
  12097. },
  12098. // {
  12099. // name: 'gender.name',
  12100. // displayName: '性别',
  12101. // width: 80,
  12102. // enableFiltering: false
  12103. // },
  12104. {
  12105. name: 'phone',
  12106. displayName: '电话',
  12107. width: 230,
  12108. enableFiltering: false
  12109. },
  12110. {
  12111. name: 'email',
  12112. displayName: '邮箱',
  12113. width: 180,
  12114. enableFiltering: false
  12115. },
  12116. {
  12117. name: 'dept.dept',
  12118. displayName: '科室',
  12119. width: 130,
  12120. enableFiltering: false
  12121. },
  12122. {
  12123. name: 'taskCount',
  12124. displayName: '处理中事件数',
  12125. enableFiltering: false
  12126. }
  12127. ];
  12128. // $scope.selectButtonClick
  12129. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12130. $scope.gridApi = gridApi;
  12131. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12132. var filtersData = $scope.memoryfilterData;
  12133. filtersData.idx = newPage - 1;
  12134. filtersData.sum = pageSize;
  12135. $scope.loadData(filtersData);
  12136. //console.log(pageSize);
  12137. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12138. });
  12139. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12140. $scope.selected.items = data.entity;
  12141. //console.log(data);
  12142. });
  12143. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  12144. $scope.selected.items = data.entity;
  12145. //console.log(data);
  12146. });
  12147. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  12148. // // if (row.entity.age > 45) {
  12149. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12150. // // }
  12151. // };
  12152. gridApi.core.on.filterChanged($scope, function () {
  12153. var grid = this.grid;
  12154. var filtersData = {
  12155. idx: 0,
  12156. sum: 10,
  12157. user: {
  12158. roledata: {
  12159. rolecode: "first-line support"
  12160. },
  12161. selectType: "1"
  12162. }
  12163. };
  12164. angular.forEach(grid.columns, function (item) {
  12165. if (item.enableFiltering) {
  12166. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  12167. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12168. if (angular.isUndefined(filtersData['user'])) {
  12169. filtersData['user'] = {};
  12170. }
  12171. filtersData['user'][item.field] = item.filters[0].term;
  12172. }
  12173. }
  12174. });
  12175. $scope.memoryfilterData = filtersData;
  12176. $scope.loadData(filtersData);
  12177. });
  12178. };
  12179. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  12180. // if (row.entity.age > 45) {
  12181. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12182. // }
  12183. // },
  12184. $scope.onDblClick = function (data, event) {
  12185. // $scope.selected.items = data.entity;
  12186. $scope.selectButtonClick(data, event);
  12187. };
  12188. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  12189. // $scope.selected.items = data.entity;
  12190. // })
  12191. // };
  12192. $scope.memoryfilterData = {
  12193. idx: 0,
  12194. sum: 10,
  12195. user: {
  12196. roledata: {
  12197. rolecode: "first-line support"
  12198. },
  12199. selectType: "1"
  12200. }
  12201. }
  12202. $scope.loadData = function (filterData) {
  12203. // console.log("filtersData=111" + JSON.stringify(filterData))
  12204. items.fetchItems(filterData, APIService).then(function (data) {
  12205. var myData = Restangular.stripRestangular(data);
  12206. $scope.gridOptions.totalItems = myData.totalNum;
  12207. $scope.myData = myData.list;
  12208. });
  12209. };
  12210. $scope.title = title;
  12211. $scope.loadData({
  12212. idx: 0,
  12213. sum: 10,
  12214. user: {
  12215. roledata: {
  12216. rolecode: "first-line support"
  12217. },
  12218. selectType: "1"
  12219. }
  12220. });
  12221. $scope.selected = {
  12222. items: {}
  12223. };
  12224. $scope.ok = function () {
  12225. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12226. // onDataCallback($scope.selected.item, parentScope);
  12227. // }
  12228. $modalInstance.close($scope.selected.items);
  12229. };
  12230. $scope.cancel = function () {
  12231. $modalInstance.dismiss('cancel');
  12232. };
  12233. },
  12234. size: size,
  12235. resolve: {
  12236. items: function () {
  12237. return {
  12238. fetchItems: function (filterData, APIService) {
  12239. filterData = filterData || {};
  12240. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12241. filterData = {
  12242. idx: 0,
  12243. sum: 10,
  12244. user: {
  12245. roledata: {
  12246. rolecode: "first-line support"
  12247. },
  12248. selectType: "1"
  12249. }
  12250. };
  12251. }
  12252. return options.templateOptions.fetchItems(filterData, APIService);
  12253. }
  12254. };
  12255. },
  12256. title: function () {
  12257. return options.templateOptions.label;
  12258. },
  12259. Restangular: function () {
  12260. return options.templateOptions.Restangular;
  12261. },
  12262. APIService: function () {
  12263. return options.templateOptions.ApiService;
  12264. },
  12265. onDataCallback: function () {
  12266. return options.templateOptions.callback;
  12267. },
  12268. parentScope: function () {
  12269. return options.templateOptions.that;
  12270. }
  12271. }
  12272. });
  12273. modalInstance.result.then(function (selectedItem) {
  12274. // console.log(selectedItem);
  12275. options.value(selectedItem);
  12276. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12277. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12278. }
  12279. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12280. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12281. }
  12282. }, function () {
  12283. //console.log('Modal dismissed at: ' + new Date());
  12284. });
  12285. }
  12286. }
  12287. };
  12288. },
  12289. controller: ['$scope', function ($scope) {
  12290. $scope.options.templateOptions.that = $scope;
  12291. }]
  12292. });
  12293. //用户多选控件
  12294. formlyConfigProvider.setType({
  12295. name: "ui-multiuserselect",
  12296. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  12297. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12298. defaultOptions: function (options) {
  12299. return {
  12300. templateOptions: {
  12301. openModal: function (size, options, modal, model) {
  12302. var modalInstance = modal.open({
  12303. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12304. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  12305. $scope.langs = i18nService.getAllLangs();
  12306. $scope.lang = 'zh-cn';
  12307. i18nService.setCurrentLang($scope.lang);
  12308. $scope.gridOptions = {};
  12309. $scope.gridOptions.data = 'myData';
  12310. $scope.gridOptions.enableColumnResizing = true;
  12311. $scope.gridOptions.enableFiltering = true;
  12312. $scope.gridOptions.enableGridMenu = true;
  12313. $scope.gridOptions.showGridFooter = true;
  12314. $scope.gridOptions.showColumnFooter = true;
  12315. $scope.gridOptions.fastWatch = true;
  12316. $scope.gridOptions.useExternalFiltering = true;
  12317. $scope.gridOptions.useExternalPagination = true;
  12318. $scope.gridOptions.paginationPageSizes = [10];
  12319. $scope.gridOptions.paginationPageSize = 10;
  12320. $scope.gridOptions.multiSelect = true;
  12321. $scope.gridOptions.rowIdentity = function (row) {
  12322. return row.id;
  12323. };
  12324. $scope.gridOptions.getRowIdentity = function (row) {
  12325. return row.id;
  12326. };
  12327. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12328. $scope.gridOptions.columnDefs = [
  12329. // { name:'id', width:80, enableFiltering:false},
  12330. {
  12331. name: 'account',
  12332. displayName: '账号',
  12333. width: 140
  12334. },
  12335. {
  12336. name: 'name',
  12337. displayName: '名称',
  12338. width: 100
  12339. },
  12340. {
  12341. name: 'gender.name',
  12342. displayName: '性别',
  12343. width: 140,
  12344. enableFiltering: false
  12345. },
  12346. {
  12347. name: 'phone',
  12348. displayName: '电话',
  12349. width: 100,
  12350. enableFiltering: false
  12351. },
  12352. {
  12353. name: 'email',
  12354. displayName: '邮件',
  12355. width: 100,
  12356. enableFiltering: false
  12357. },
  12358. {
  12359. name: 'dept.dept',
  12360. displayName: '科室',
  12361. width: 100,
  12362. enableFiltering: false
  12363. },
  12364. {
  12365. name: 'group[0].groupName',
  12366. displayName: '职位',
  12367. width: 100,
  12368. enableFiltering: false
  12369. }
  12370. ];
  12371. $scope.selected = {
  12372. items: selectItems
  12373. };
  12374. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12375. $scope.gridApi = gridApi;
  12376. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12377. var filtersData = $scope.memoryfilterData;
  12378. filtersData.idx = newPage - 1;
  12379. filtersData.sum = pageSize;
  12380. $scope.loadData(filtersData);
  12381. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12382. });
  12383. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  12384. var j = 0;
  12385. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  12386. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  12387. j++;
  12388. break;
  12389. }
  12390. }
  12391. if (j == 1) {
  12392. scope.grid.appScope.selected.items.splice(i, 1);
  12393. } else {
  12394. scope.grid.appScope.selected.items.push(scope.entity)
  12395. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  12396. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  12397. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  12398. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  12399. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  12400. scope.grid.appScope.selected.items.splice(i, 1);
  12401. }
  12402. }
  12403. }
  12404. }
  12405. });
  12406. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  12407. // $scope.grid.appScope.selected.items.push($scope.entity);
  12408. // });
  12409. gridApi.core.on.filterChanged($scope, function () {
  12410. var grid = this.grid;
  12411. var filtersData = {
  12412. idx: 0,
  12413. sum: 10,
  12414. "user": {
  12415. "roledata": {
  12416. "rolecode": options.model.currentRole
  12417. },
  12418. "selectType": "1"
  12419. }
  12420. };
  12421. angular.forEach(grid.columns, function (item) {
  12422. if (item.enableFiltering) {
  12423. //console.log("filtersData="+JSON.stringify(filtersData))
  12424. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12425. if (angular.isUndefined(filtersData['user'])) {
  12426. filtersData['user'] = {};
  12427. }
  12428. filtersData['user'][item.field] = item.filters[0].term;
  12429. }
  12430. }
  12431. });
  12432. $scope.memoryfilterData = filtersData;
  12433. $scope.loadData(filtersData);
  12434. });
  12435. };
  12436. if (!options.model) {
  12437. var mouse = {
  12438. "model": {
  12439. "currentRole": ""
  12440. }
  12441. };
  12442. angular.extend(options, mouse);
  12443. }
  12444. $scope.memoryfilterData = {
  12445. "idx": 0,
  12446. "sum": 10,
  12447. "user": {
  12448. "roledata": {
  12449. "rolecode": options.model.currentRole
  12450. },
  12451. "selectType": "1"
  12452. }
  12453. }
  12454. $scope.loadData = function (filterData) {
  12455. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  12456. items.fetchItems(filterData, APIService).then(function (data) {
  12457. var myData = Restangular.stripRestangular(data);
  12458. $scope.gridOptions.totalItems = myData.totalNum;
  12459. $scope.myData = myData.list;
  12460. //console.log($scope.gridOptions.pagination.getTotalPages());
  12461. // if($scope.selected.items){
  12462. // angular.forEach($scope.selected.items,function(selectItem){
  12463. // $scope.gridApi.selection.selectRow(selectItem);
  12464. // });
  12465. // }
  12466. });
  12467. };
  12468. // $scope.title = title;
  12469. $scope.loadData({
  12470. idx: 0,
  12471. sum: 10,
  12472. "user": {
  12473. "roledata": {
  12474. "rolecode": options.model.currentRole
  12475. },
  12476. "selectType": "1"
  12477. }
  12478. });
  12479. // $timeout(function(){
  12480. // if($scope.selected.items){
  12481. // angular.forEach($scope.selected.items,function(selectItem){
  12482. // $scope.gridApi.selection.selectRow(selectItem);
  12483. // });
  12484. // }
  12485. // },2000)
  12486. $scope.ok = function () {
  12487. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  12488. $modalInstance.close($scope.selected.items);
  12489. };
  12490. $scope.cancel = function () {
  12491. $modalInstance.dismiss('cancel');
  12492. };
  12493. },
  12494. size: size,
  12495. resolve: {
  12496. items: function () {
  12497. return {
  12498. fetchItems: function (filterData, APIService) {
  12499. filterData = filterData || {};
  12500. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12501. filterData = {
  12502. idx: 0,
  12503. sum: 10,
  12504. "user": {
  12505. "roledata": {
  12506. "rolecode": options.model.incident.currentRole
  12507. },
  12508. "selectType": "1"
  12509. }
  12510. };
  12511. }
  12512. return options.templateOptions.fetchItems(filterData, APIService);
  12513. }
  12514. };
  12515. },
  12516. title: function () {
  12517. return options.templateOptions.modalTitle;
  12518. },
  12519. Restangular: function () {
  12520. return options.templateOptions.Restangular;
  12521. },
  12522. APIService: function () {
  12523. return options.templateOptions.ApiService;
  12524. },
  12525. selectItems: function () {
  12526. return model || [];
  12527. }
  12528. }
  12529. });
  12530. modalInstance.result.then(function (selectedItem) {
  12531. options.value(selectedItem);
  12532. options.formControl.$validate();
  12533. }, function () {
  12534. //console.log('Modal dismissed at: ' + new Date());
  12535. });
  12536. }
  12537. },
  12538. validators: {
  12539. required: {
  12540. expression: function (viewValue, modelValue) {
  12541. var value = modelValue || viewValue;
  12542. return value.length >= 1;
  12543. }
  12544. }
  12545. }
  12546. };
  12547. },
  12548. controller: ['$scope', function ($scope) {
  12549. $scope.model[$scope.options.key] = [];
  12550. $scope.remove = function (itemId) {
  12551. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  12552. if (entry.id == itemId) {
  12553. $scope.model[$scope.options.key].splice(index, 1);
  12554. // console.log($scope.options.formControl)
  12555. $scope.options.formControl.$validate();
  12556. } else {
  12557. }
  12558. });
  12559. }
  12560. }]
  12561. });
  12562. //用户多选控件-字符串展示
  12563. formlyConfigProvider.setType({
  12564. name: 'ui-stringuserselect',
  12565. extends: 'input',
  12566. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  12567. defaultOptions: function (options) {
  12568. return {
  12569. templateOptions: {
  12570. translate: '',
  12571. refreshDelay: 0
  12572. }
  12573. }
  12574. },
  12575. controller: ['$scope', function ($scope) {
  12576. var keydata = "";
  12577. if (angular.isArray($scope.model)) {
  12578. angular.forEach($scope.model, function (item) {
  12579. keydata = keydata + "," + item.name;
  12580. })
  12581. }
  12582. // $scope.model[$scope.options.key] = [];
  12583. }]
  12584. });
  12585. //重复事件
  12586. formlyConfigProvider.setType({
  12587. name: "ui-incidentmodelselect",
  12588. extends: 'input',
  12589. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12590. defaultOptions: function (options) {
  12591. return {
  12592. templateOptions: {
  12593. openModal: function (size, options, modal) {
  12594. var modalInstance = modal.open({
  12595. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12596. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  12597. $scope.langs = i18nService.getAllLangs();
  12598. $scope.lang = 'zh-cn';
  12599. i18nService.setCurrentLang($scope.lang);
  12600. $scope.gridOptions = {};
  12601. $scope.gridOptions.data = 'myData';
  12602. $scope.gridOptions.enableColumnResizing = true;
  12603. $scope.gridOptions.enableFiltering = true;
  12604. $scope.gridOptions.enableGridMenu = false;
  12605. $scope.gridOptions.enableRowSelection = true;
  12606. $scope.gridOptions.showGridFooter = true;
  12607. $scope.gridOptions.showColumnFooter = false;
  12608. $scope.gridOptions.fastWatch = true;
  12609. $scope.gridOptions.useExternalFiltering = true;
  12610. $scope.gridOptions.useExternalPagination = true;
  12611. $scope.gridOptions.paginationPageSizes = [10];
  12612. $scope.gridOptions.paginationPageSize = 10;
  12613. $scope.gridOptions.multiSelect = false;
  12614. var mun = $scope.gridOptions.paginationPageSize;
  12615. $scope.gridOptions.rowIdentity = function (row) {
  12616. return row.id;
  12617. };
  12618. $scope.gridOptions.getRowIdentity = function (row) {
  12619. return row.id;
  12620. };
  12621. $scope.gridOptions.columnDefs = items.columnDefs();
  12622. $scope.transferTime = function (time) {
  12623. return moment(time).format('YYYY-MM-DD HH:mm');
  12624. }
  12625. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12626. $scope.gridApi = gridApi;
  12627. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12628. // console.log(newPage);
  12629. // console.log(pageSize);
  12630. $scope.loadData({
  12631. "idx": newPage - 1,
  12632. "sum": pageSize
  12633. });
  12634. });
  12635. gridApi.core.on.filterChanged($scope, function () {
  12636. var grid = this.grid;
  12637. var filtersData = {
  12638. idx: 0,
  12639. sum: 100
  12640. };
  12641. angular.forEach(grid.columns, function (item) {
  12642. if (item.enableFiltering) {
  12643. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12644. // console.log("filtersData="+JSON.stringify(filtersData))
  12645. if (angular.isUndefined(filtersData['incident'])) {
  12646. filtersData['incident'] = {};
  12647. }
  12648. filtersData['incident'][item.field] = item.filters[0].term;
  12649. if (angular.isUndefined(filtersData['problem'])) {
  12650. filtersData['problem'] = {};
  12651. }
  12652. filtersData['problem'][item.field] = item.filters[0].term;
  12653. if (angular.isUndefined(filtersData['change'])) {
  12654. filtersData['change'] = {};
  12655. }
  12656. filtersData['change'][item.field] = item.filters[0].term;
  12657. if (angular.isUndefined(filtersData['release'])) {
  12658. filtersData['release'] = {};
  12659. }
  12660. filtersData['release'][item.field] = item.filters[0].term;
  12661. }
  12662. }
  12663. });
  12664. $scope.loadData(filtersData);
  12665. });
  12666. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12667. $scope.selected.item = data.entity;
  12668. //console.log(data);
  12669. });
  12670. };
  12671. //资产
  12672. $scope.cmdb = {}
  12673. //资产状态
  12674. $scope.state_data = [{
  12675. "name": "全部状态",
  12676. "value": ""
  12677. },
  12678. {
  12679. "name": "在库",
  12680. "value": "1"
  12681. },
  12682. {
  12683. "name": "在线",
  12684. "value": "2"
  12685. },
  12686. {
  12687. "name": "借出",
  12688. "value": "3"
  12689. },
  12690. {
  12691. "name": "报修",
  12692. "value": "4"
  12693. },
  12694. {
  12695. "name": "报废",
  12696. "value": "5"
  12697. },
  12698. {
  12699. "name": "备用",
  12700. "value": "6"
  12701. },
  12702. ]
  12703. //资产类型
  12704. $scope.wt_zcfl = function () {
  12705. api_configure_data.fetchDataList('ciclassify', {
  12706. idx: 0,
  12707. sum: 100
  12708. }).then(function (data) {
  12709. console.log(data);
  12710. // $scope.wt_zclx = data.list;
  12711. console.log(data);
  12712. $scope.wtData = []
  12713. if (data.status == 200) {
  12714. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12715. var root = null; //Initially set our loop to null
  12716. var parentNode = null;
  12717. //loop over data
  12718. // $scope.wtData=data.list;
  12719. data = data.list;
  12720. //知识库分类数据三级处理
  12721. for (var i = 0; i < data.length; i++) {
  12722. // console.log(data[i])
  12723. var datum = data[i];
  12724. //each node will have children, so let's give it a "children" poperty
  12725. // console.log(datum);
  12726. datum.children = [];
  12727. if (!datum.parent) {
  12728. $scope.wtData.push(datum);
  12729. // console.log($scope.wtData)
  12730. } else {
  12731. if ($scope.wtData[0]) {
  12732. if ($scope.wtData[0].id == datum.parent.id) {
  12733. $scope.wtData[0].children.push(datum);
  12734. }
  12735. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  12736. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  12737. $scope.wtData[0].children[j].children.push(datum);
  12738. }
  12739. };
  12740. }
  12741. if ($scope.wtData[1]) {
  12742. if ($scope.wtData[1].id == datum.parent.id) {
  12743. $scope.wtData[1].children.push(datum);
  12744. }
  12745. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  12746. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  12747. $scope.wtData[1].children[j].children.push(datum);
  12748. }
  12749. };
  12750. }
  12751. if ($scope.wtData[2]) {
  12752. if ($scope.wtData[2].id == datum.parent.id) {
  12753. $scope.wtData[2].children.push(datum);
  12754. }
  12755. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  12756. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  12757. $scope.wtData[2].children[j].children.push(datum);
  12758. }
  12759. };
  12760. }
  12761. }
  12762. // console.log($scope.wtData)
  12763. idToNodeMap[datum.id] = datum;
  12764. root = datum;
  12765. // treeMap[datum.id] = root;
  12766. }
  12767. }
  12768. });
  12769. }
  12770. $scope.wt_zcfl();
  12771. //事件
  12772. //受理人,处理人
  12773. $scope.searchkeys = {};
  12774. var fieldata = {
  12775. "idx": 0,
  12776. "sum": 100,
  12777. "flag": -1
  12778. };
  12779. getUser(fieldata, 3);
  12780. function getUser(fieldatas, it) {
  12781. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  12782. if (it == 1) {
  12783. $scope.acceptUser = data.list;
  12784. } else if (it == 2) {
  12785. $scope.handlingPersonnelUser = data.list;
  12786. } else if (it == 3) {
  12787. $scope.acceptUser = data.list;
  12788. $scope.handlingPersonnelUser = data.list;
  12789. }
  12790. });
  12791. }
  12792. //状态
  12793. $scope.othcode = {};
  12794. api_bpm_data.fetchDataList('incidentstatus', {
  12795. "idx": 0,
  12796. "sum": 100
  12797. }).then(function (response) {
  12798. if (response) {
  12799. if (response.status = 200) {
  12800. $scope.state = response.list;
  12801. }
  12802. }
  12803. })
  12804. var defaultFilterData = {
  12805. "assignee": $rootScope.user.id,
  12806. "searchType": "todo",
  12807. "idx": 0,
  12808. "sum": mun
  12809. };
  12810. var defaultFilterData1 = {
  12811. // "searchType": "todo",
  12812. "idx": 0,
  12813. "sum": mun
  12814. };
  12815. //搜索
  12816. $scope.chiceIncident = function (parameters, item, stateid) {
  12817. console.log(item, stateid);
  12818. console.log($scope);
  12819. if ($scope.title == '关联资产编号') {
  12820. // alert('222222222222');
  12821. var fildata = defaultFilterData1;
  12822. $scope.gridOptions.paginationCurrentPage = 1;
  12823. var transitiondata = angular.copy(item);
  12824. angular.extend(fildata, transitiondata);
  12825. if (fildata.hw_state) {
  12826. fildata.hw_state = fildata.hw_state.name;
  12827. }
  12828. if (fildata.sign) {
  12829. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  12830. fildata.sign = fildata.sign.split(';');
  12831. fildata.sign = fildata.sign.join('');
  12832. fildata.sign = fildata.sign.toLowerCase()
  12833. }
  12834. if (fildata.keys) {
  12835. fildata['searchCriteria'] = 'uuid';
  12836. }
  12837. console.log(fildata);
  12838. $scope.loadData(fildata);
  12839. }
  12840. if ($scope.title == '关联事件工单') {
  12841. // alert('3333333333333333')
  12842. if (stateid && stateid.code) {
  12843. item.statusId = stateid.code;
  12844. }
  12845. var fildata = defaultFilterData;
  12846. // $scope.memoryfilterData = fildata;
  12847. if (!fildata.incident) {
  12848. fildata['incident'] = {};
  12849. }
  12850. $scope.gridOptions.paginationCurrentPage = 1;
  12851. var transitiondata = angular.copy(item);
  12852. angular.extend(fildata.incident, transitiondata);
  12853. console.log(fildata)
  12854. // $scope.loadData(fildata);
  12855. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  12856. console.log(data)
  12857. if (data) {
  12858. $scope.myData = data.list;
  12859. $scope.gridOptions.totalItems = data.totalNum;
  12860. }
  12861. })
  12862. }
  12863. }
  12864. //重置
  12865. $scope.replacement = function (parameters, searchkeys, othcode) {
  12866. // console.log(parameters, searchkeys, othcode);
  12867. delete (defaultFilterData.incident);
  12868. console.log(defaultFilterData)
  12869. $scope.parameters = null;
  12870. $scope.searchkeys = {};
  12871. $scope.othcode = {};
  12872. $scope.wt_zcfl();
  12873. }
  12874. $scope.loadData = function (filterData) {
  12875. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  12876. var myData = Restangular.stripRestangular(data);
  12877. if (myData.data && myData.data.node) {
  12878. $scope.gridOptions.totalItems = myData.total;
  12879. $scope.myData = myData.data.node;
  12880. } else {
  12881. if (myData.resultCount) {
  12882. $scope.gridOptions['totalItems'] = myData.resultCount;
  12883. } else {
  12884. $scope.gridOptions.totalItems = myData.totalNum;
  12885. }
  12886. if (myData.list) {
  12887. $scope.myData = myData.list;
  12888. } else {
  12889. $scope.myData = myData.data;
  12890. }
  12891. }
  12892. });
  12893. };
  12894. $scope.title = title;
  12895. $scope.loadData({
  12896. idx: 0,
  12897. sum: 10
  12898. });
  12899. $scope.selected = {
  12900. item: {}
  12901. };
  12902. $scope.ok = function () {
  12903. //console.log($scope.selected.item);
  12904. $modalInstance.close($scope.selected.item);
  12905. };
  12906. $scope.cancel = function () {
  12907. $modalInstance.dismiss('cancel');
  12908. };
  12909. },
  12910. size: size,
  12911. resolve: {
  12912. items: function () {
  12913. return {
  12914. fetchItems: function (filterData, APIService, $rootScope) {
  12915. filterData = filterData || {};
  12916. // if(!filterData.idx){
  12917. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12918. filterData = {
  12919. idx: 0,
  12920. sum: 10
  12921. };
  12922. }
  12923. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  12924. },
  12925. columnDefs: function () {
  12926. return options.templateOptions.columnDefs;
  12927. }
  12928. };
  12929. },
  12930. title: function () {
  12931. return options.templateOptions.modalTitle;
  12932. },
  12933. Restangular: function () {
  12934. return options.templateOptions.Restangular;
  12935. },
  12936. APIService: function () {
  12937. return options.templateOptions.ApiService;
  12938. }
  12939. }
  12940. });
  12941. modalInstance.result.then(function (selectedItem) {
  12942. var selectitem = {
  12943. title: selectedItem.title,
  12944. description: selectedItem.description
  12945. }
  12946. if (options.key == "chuku") {
  12947. if (selectedItem.assets) {
  12948. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  12949. }
  12950. if (selectedItem.consumables) {
  12951. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  12952. }
  12953. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  12954. options.value(selectedItem);
  12955. // options.model.consumables = JSON.parse(consumables);
  12956. } else if (options.templateOptions.pkey == "change") {
  12957. console.log(options)
  12958. angular.extend(options.model);
  12959. options.value(selectedItem);
  12960. } else if (options.key == "cmdbCode") {
  12961. var zc_selectitem = selectedItem.uuid;
  12962. // angular.extend(options.model,zc_selectitem);
  12963. options.model.cmdbCode = zc_selectitem;
  12964. // angular.extend(options.model,zc_selectitem);
  12965. // options.templateOptions.displayName=zc_selectitem;
  12966. options.value(selectedItem);
  12967. console.log(options.model)
  12968. } else {
  12969. angular.extend(options.model, selectitem);
  12970. options.value(selectedItem);
  12971. }
  12972. }, function () {
  12973. //console.log('Modal dismissed at: ' + new Date());
  12974. });
  12975. }
  12976. }
  12977. };
  12978. }
  12979. });
  12980. //选项选择控件
  12981. formlyConfigProvider.setType({
  12982. name: "ui-modelselect",
  12983. extends: 'input',
  12984. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12985. defaultOptions: function (options) {
  12986. return {
  12987. templateOptions: {
  12988. openModal: function (size, options, modal) {
  12989. var modalInstance = modal.open({
  12990. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12991. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  12992. $scope.langs = i18nService.getAllLangs();
  12993. $scope.lang = 'zh-cn';
  12994. i18nService.setCurrentLang($scope.lang);
  12995. $scope.gridOptions = {};
  12996. $scope.gridOptions.data = 'myData';
  12997. $scope.gridOptions.enableColumnResizing = true;
  12998. $scope.gridOptions.enableFiltering = true;
  12999. $scope.gridOptions.enableGridMenu = false;
  13000. $scope.gridOptions.enableRowSelection = true;
  13001. $scope.gridOptions.showGridFooter = true;
  13002. $scope.gridOptions.showColumnFooter = true;
  13003. $scope.gridOptions.fastWatch = true;
  13004. $scope.gridOptions.useExternalFiltering = true;
  13005. $scope.gridOptions.useExternalPagination = true;
  13006. $scope.gridOptions.paginationPageSizes = [10];
  13007. $scope.gridOptions.paginationPageSize = 10;
  13008. $scope.gridOptions.multiSelect = false;
  13009. $scope.gridOptions.rowIdentity = function (row) {
  13010. return row.id;
  13011. };
  13012. $scope.gridOptions.getRowIdentity = function (row) {
  13013. return row.id;
  13014. };
  13015. $scope.gridOptions.columnDefs = items.columnDefs();
  13016. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13017. $scope.gridApi = gridApi;
  13018. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  13019. // console.log(newPage);
  13020. // console.log(pageSize);
  13021. $scope.loadData({
  13022. "idx": newPage - 1,
  13023. "sum": pageSize
  13024. });
  13025. });
  13026. gridApi.core.on.filterChanged($scope, function () {
  13027. var grid = this.grid;
  13028. var filtersData = {
  13029. idx: 0,
  13030. sum: 10
  13031. };
  13032. angular.forEach(grid.columns, function (item) {
  13033. if (item.enableFiltering) {
  13034. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  13035. // console.log("filtersData="+JSON.stringify(filtersData))
  13036. if (angular.isUndefined(filtersData['incident'])) {
  13037. filtersData['incident'] = {};
  13038. }
  13039. filtersData['incident'][item.field] = item.filters[0].term;
  13040. if (angular.isUndefined(filtersData['problem'])) {
  13041. filtersData['problem'] = {};
  13042. }
  13043. filtersData['problem'][item.field] = item.filters[0].term;
  13044. if (angular.isUndefined(filtersData['change'])) {
  13045. filtersData['change'] = {};
  13046. }
  13047. filtersData['change'][item.field] = item.filters[0].term;
  13048. if (angular.isUndefined(filtersData['release'])) {
  13049. filtersData['release'] = {};
  13050. }
  13051. filtersData['release'][item.field] = item.filters[0].term;
  13052. }
  13053. }
  13054. });
  13055. $scope.loadData(filtersData);
  13056. });
  13057. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13058. $scope.selected.item = data.entity;
  13059. //console.log(data);
  13060. });
  13061. };
  13062. $scope.loadData = function (filterData) {
  13063. items.fetchItems(filterData, APIService).then(function (data) {
  13064. var myData = Restangular.stripRestangular(data);
  13065. $scope.gridOptions.totalItems = myData.totalNum;
  13066. $scope.myData = myData.list;
  13067. });
  13068. };
  13069. $scope.title = title;
  13070. $scope.loadData({
  13071. idx: 0,
  13072. sum: 10
  13073. });
  13074. $scope.selected = {
  13075. item: {}
  13076. };
  13077. $scope.ok = function () {
  13078. if ($scope.selected.item.scheduleOrder) {
  13079. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  13080. }
  13081. //console.log($scope.selected.item);
  13082. $modalInstance.close($scope.selected.item);
  13083. };
  13084. $scope.cancel = function () {
  13085. $modalInstance.dismiss('cancel');
  13086. };
  13087. },
  13088. size: size,
  13089. resolve: {
  13090. items: function () {
  13091. return {
  13092. fetchItems: function (filterData, APIService) {
  13093. filterData = filterData || {};
  13094. // if(!filterData.idx){
  13095. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  13096. filterData = {
  13097. idx: 0,
  13098. sum: 10
  13099. };
  13100. }
  13101. return options.templateOptions.fetchItems(filterData, APIService, options);
  13102. },
  13103. columnDefs: function () {
  13104. return options.templateOptions.columnDefs;
  13105. }
  13106. };
  13107. },
  13108. title: function () {
  13109. return options.templateOptions.modalTitle;
  13110. },
  13111. Restangular: function () {
  13112. return options.templateOptions.Restangular;
  13113. },
  13114. APIService: function () {
  13115. return options.templateOptions.ApiService;
  13116. }
  13117. }
  13118. });
  13119. modalInstance.result.then(function (selectedItem) {
  13120. options.value(selectedItem);
  13121. }, function () {
  13122. //console.log('Modal dismissed at: ' + new Date());
  13123. });
  13124. }
  13125. }
  13126. };
  13127. }
  13128. });
  13129. formlyConfigProvider.setType({
  13130. name: 'ui-requestform',
  13131. extends: 'input',
  13132. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  13133. controller: ['$scope', function ($scope) {
  13134. setTimeout(function () {
  13135. var filterData = {
  13136. "idx": 0,
  13137. "sum": 5,
  13138. "incident": {
  13139. "requester": {
  13140. "id": ""
  13141. }
  13142. }
  13143. }
  13144. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  13145. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13146. });
  13147. }, 1000);
  13148. }]
  13149. });
  13150. //报修图片展示
  13151. formlyConfigProvider.setType({
  13152. name: 'ui-repair-photos',
  13153. // extends: 'label',
  13154. templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
  13155. controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
  13156. console.log($scope);
  13157. $scope.fileUrls = [];
  13158. if ($scope.model.wxFile) {
  13159. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
  13160. $scope.fileUrls = res.data
  13161. })
  13162. }
  13163. console.log($stateParams);
  13164. if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
  13165. api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
  13166. $scope.fileUrls = res.data
  13167. })
  13168. }
  13169. if ($scope.model.flow) {
  13170. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
  13171. $scope.fileUrls = res.data
  13172. })
  13173. }
  13174. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13175. // // setTimeout(function () {
  13176. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13177. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13178. // // if (modelData.status == 200) {
  13179. // // $scope.model[$scope.options.key] = modelData.data;
  13180. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  13181. // // }
  13182. // // });
  13183. // // }, 1000);
  13184. // }
  13185. $scope.showBigImg = false;
  13186. $scope.showBigImgCli = function (data) {
  13187. $scope.showBigImg = true;
  13188. $scope.bigImgUrl = data
  13189. }
  13190. $scope.closeBigImg = function () {
  13191. $scope.showBigImg = false
  13192. }
  13193. }]
  13194. });
  13195. //图片展示
  13196. formlyConfigProvider.setType({
  13197. name: 'ui-showImgs',
  13198. templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
  13199. defaultOptions: function (options) {
  13200. return {
  13201. templateOptions: {
  13202. refresh: function (APIService, processInstanceId, data) {
  13203. return APIService.listAttachments(processInstanceId);
  13204. },
  13205. downloadUri: function (APIService, contentId) {
  13206. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13207. },
  13208. view: function (APIService, contentId) {
  13209. return APIService.attachmentsPreviewUrl(contentId);
  13210. },
  13211. download: function (APIService, contentId, item) {
  13212. var item = {
  13213. 'url': APIService.download(contentId),
  13214. 'headers': headers
  13215. };
  13216. return item;
  13217. },
  13218. refreshDelay: 0
  13219. }
  13220. };
  13221. },
  13222. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13223. var _refreshDelayPromise;
  13224. /**
  13225. * refresh
  13226. */
  13227. $scope._refresh = function (refreshAttr) {
  13228. $scope.attachments = [];
  13229. if (refreshAttr !== undefined) {
  13230. if (_refreshDelayPromise) {
  13231. $timeout.cancel(_refreshDelayPromise);
  13232. }
  13233. _refreshDelayPromise = $timeout(function () {
  13234. // 暂存附件
  13235. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13236. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13237. $scope.options.templateOptions.processInstanceId, {
  13238. 'idx': 0,
  13239. 'sum': 1000
  13240. }).then(function (response) {
  13241. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13242. if (myData) {
  13243. for (var i = 0; i < myData.data.length; i++) {
  13244. $scope.attachments.push(myData.data[i]);
  13245. }
  13246. };
  13247. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13248. $scope.$parent.$parent.$parent.model.save_fileId, {
  13249. 'idx': 0,
  13250. 'sum': 1000
  13251. }).then(function (response2) {
  13252. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13253. if (myData2) {
  13254. for (var i = 0; i < myData2.data.length; i++) {
  13255. $scope.attachments.push(myData2.data[i]);
  13256. }
  13257. };
  13258. console.log($scope.attachments)
  13259. });
  13260. });
  13261. // 正常附件
  13262. } else {
  13263. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13264. $scope.options.templateOptions.processInstanceId, {
  13265. 'idx': 0,
  13266. 'sum': 1000
  13267. }).then(function (response) {
  13268. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13269. if (myData) {
  13270. $scope.attachments = [];
  13271. $scope.imgs = []
  13272. myData.data.forEach(e => {
  13273. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13274. $scope.imgs.push(e)
  13275. }
  13276. })
  13277. $scope.imgs = $scope.imgs.splice(0, 3);
  13278. console.log($scope.imgs)
  13279. }
  13280. });
  13281. }
  13282. }, $scope.options.templateOptions.refreshDelay);
  13283. }
  13284. }
  13285. $scope._refresh({});
  13286. // $scope.attachments = $scope.model[$scope.options.key]
  13287. // 预览
  13288. $scope.preview = function (url, idx) {
  13289. var title = $scope.imgs[idx].title
  13290. $modal.open({
  13291. backdrop: false,
  13292. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13293. controller: function ($scope, scope, $modalInstance) {
  13294. $scope.title = title;
  13295. $scope.imageurl = url;
  13296. $scope.cancel = function () {
  13297. $modalInstance.dismiss('cancel');
  13298. }
  13299. },
  13300. resolve: {
  13301. scope: function () {
  13302. return $scope;
  13303. }
  13304. }
  13305. });
  13306. }
  13307. }]
  13308. });
  13309. //工单/受理人控件
  13310. formlyConfigProvider.setType({
  13311. name: 'ui-workernumbersign',
  13312. // extends: 'label',
  13313. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  13314. controller: ['$scope', function ($scope) {
  13315. // 2020年4月24日13:20:40
  13316. console.log($scope,'docu');
  13317. // 左侧事件工单区域地点填充
  13318. $scope.model.selecthouseNumber = $scope.model.place;
  13319. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13320. setTimeout(function () {
  13321. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13322. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13323. if (modelData.status == 200) {
  13324. $scope.model[$scope.options.key] = modelData.data;
  13325. $scope.options.initialValue = $scope.model[$scope.options.key];
  13326. }
  13327. });
  13328. }, 1000);
  13329. }
  13330. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  13331. if (angular.isFunction($scope.options.templateOptions.transform)) {
  13332. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  13333. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  13334. // }
  13335. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13336. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13337. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  13338. }
  13339. $scope.model.acceptUser = $scope.options.templateOptions.user;
  13340. // $scope.options.initialValue = $scope.model.acceptUser;
  13341. }
  13342. }]
  13343. });
  13344. //工单控件-only number
  13345. formlyConfigProvider.setType({
  13346. name: 'ui-workernumber',
  13347. extends: 'input',
  13348. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13349. controller: ['$scope', function ($scope) {
  13350. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13351. setTimeout(function () {
  13352. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13353. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13354. if (modelData.status == 200) {
  13355. $scope.model[$scope.options.key] = modelData.data;
  13356. $scope.options.initialValue = $scope.model[$scope.options.key];
  13357. }
  13358. });
  13359. }, 1000);
  13360. }
  13361. }]
  13362. });
  13363. //cmdb工单
  13364. formlyConfigProvider.setType({
  13365. name: 'ui-cmdbworkernumber',
  13366. extends: 'input',
  13367. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13368. controller: ['$scope', function ($scope) {
  13369. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13370. setTimeout(function () {
  13371. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  13372. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13373. // if(modelData.status==200){
  13374. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  13375. $scope.options.initialValue = $scope.model[$scope.options.key];
  13376. // }
  13377. });
  13378. }, 1000);
  13379. }
  13380. }]
  13381. });
  13382. //简易上传图片组件
  13383. formlyConfigProvider.setType({
  13384. name: 'ui-uploadImgs',
  13385. templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
  13386. wrapper: ['bootstrapHasError'],
  13387. controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
  13388. $scope.imgshows = [];
  13389. $scope.uploadimgs = [];
  13390. var model = $parse('upload_img');
  13391. var modelSetter = model.assign;
  13392. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13393. uploader.filters.push({
  13394. name: 'customFilter',
  13395. fn: function (item /*{File|FileLikeObject}*/, options) {
  13396. return this.queue.length < 10;
  13397. }
  13398. });
  13399. // 添加
  13400. $scope.change = function (event) {
  13401. var element = $('.upinp')
  13402. modelSetter($scope, element[0].files[0]);
  13403. //附件预览
  13404. $scope.imgupload = event.files[0];
  13405. getFile($scope.imgupload, $scope);
  13406. //获得预览图地址并且把file对象放入上传合集内
  13407. function getFile(imgupload, $scope) {
  13408. if (!imgupload) {
  13409. return;
  13410. }
  13411. fileReader.readAsDataUrl(imgupload, $scope)
  13412. .then(function (result) {
  13413. $scope.imgshows.push(result)
  13414. var file = document.querySelector('input[type=file]').files[0];
  13415. $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
  13416. console.log($scope.imgshows, $scope.uploadimgs)
  13417. if ($scope.imgshows.length < 3) {
  13418. $('#upup').show()
  13419. } else {
  13420. $('#upup').hide()
  13421. }
  13422. });
  13423. };
  13424. }
  13425. // 删除
  13426. $scope.uploadimg_del = function (index, imgs) {
  13427. console.log(index, imgs)
  13428. $scope.imgshows.splice(index, 1);
  13429. $scope.uploadimgs.splice(index, 1);
  13430. if ($scope.imgshows.length < 3) {
  13431. $('#upup').show()
  13432. } else {
  13433. $('#upup').hide()
  13434. }
  13435. }
  13436. // 预览
  13437. $scope.preview = function (url, idx) {
  13438. var name = $scope.uploadimgs[idx].name
  13439. $modal.open({
  13440. backdrop: false,
  13441. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13442. controller: function ($scope, scope, $modalInstance) {
  13443. $scope.title = name;
  13444. $scope.imageurl = url;
  13445. $scope.cancel = function () {
  13446. $modalInstance.dismiss('cancel');
  13447. }
  13448. },
  13449. resolve: {
  13450. scope: function () {
  13451. return $scope;
  13452. }
  13453. }
  13454. });
  13455. }
  13456. if (uploader) {
  13457. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13458. console.info('onWhenAddingFileFailed', item, filter, options);
  13459. };
  13460. uploader.onAfterAddingFile = function (fileItem) {
  13461. console.info('onAfterAddingFile', fileItem);
  13462. };
  13463. uploader.onAfterAddingAll = function (addedFileItems) {
  13464. console.info('onAfterAddingAll', addedFileItems);
  13465. };
  13466. uploader.onBeforeUploadItem = function (item) {
  13467. console.info('onBeforeUploadItem', item);
  13468. };
  13469. uploader.onProgressItem = function (fileItem, progress) {
  13470. console.info('onProgressItem', fileItem, progress);
  13471. };
  13472. uploader.onProgressAll = function (progress) {
  13473. console.info('onProgressAll', progress);
  13474. };
  13475. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13476. console.info('onSuccessItem', fileItem, response, status, headers);
  13477. };
  13478. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13479. console.info('onErrorItem', fileItem, response, status, headers);
  13480. };
  13481. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13482. console.info('onCancelItem', fileItem, response, status, headers);
  13483. };
  13484. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13485. console.info('onCompleteItem', fileItem, response, status, headers);
  13486. };
  13487. uploader.onCompleteAll = function () {
  13488. console.info('onCompleteAll');
  13489. };
  13490. }
  13491. // console.log(modelSetter)
  13492. }]
  13493. });
  13494. //jry-上传下载一体
  13495. formlyConfigProvider.setType({
  13496. name: 'ui-upDropFile',
  13497. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  13498. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13499. defaultOptions: function (options) {
  13500. return {
  13501. templateOptions: {
  13502. view: function (APIService, contentId) {
  13503. return APIService.downloadAttachment(contentId);
  13504. },
  13505. // ApiService: 'api_wechatfile',
  13506. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  13507. // upUrl: 'common/common/uploadAttachment',
  13508. // listAttachmentUrl: 'common/common/listAttachment',
  13509. // downUrl: 'common/common/downloadAttachment',
  13510. // bindType: 'incident',
  13511. // bindId: 2323
  13512. },
  13513. // validators: {
  13514. // required: {
  13515. // expression: function(viewValue, modelValue) {
  13516. // var value = modelValue || viewValue;
  13517. // return value.length >= 1;
  13518. // }
  13519. // }
  13520. // }
  13521. };
  13522. },
  13523. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  13524. console.log($scope);
  13525. $scope.showFileUp = true;
  13526. if ($scope.model.isKnowledge_detail) {
  13527. $scope.showFileUp = false;
  13528. }
  13529. if (angular.isUndefined($scope.form.dropState)) {
  13530. $scope.form.dropState = false;
  13531. }
  13532. if ($scope.model.incident) {
  13533. if ($scope.model.incident.alarm) {
  13534. console.log($scope)
  13535. if ($scope.model.incident.alarm) {
  13536. if ($scope.model.incident.alarm.alarmExtension) {
  13537. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  13538. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  13539. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  13540. console.log($scope.model.incident.description)
  13541. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  13542. } else {
  13543. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  13544. }
  13545. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  13546. console.log($scope.model.incident.description)
  13547. };
  13548. }
  13549. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  13550. console.log(wt_data);
  13551. if (wt_data) {
  13552. $rootScope.wt_category = wt_data.data;
  13553. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  13554. $rootScope.wt_child = wt_data.child
  13555. }
  13556. })
  13557. if ($scope.model.titleName == '接单') {
  13558. $scope.model.receive_code = 'handler'
  13559. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  13560. $scope.model.isHandlerUser = true;
  13561. }
  13562. }
  13563. if ($scope.model.titleName == '事件处理') {
  13564. console.log($scope.model.cmdbCode)
  13565. if ($scope.model.cmdbCode) {
  13566. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  13567. }
  13568. }
  13569. } else {
  13570. $rootScope.wt_category = '';
  13571. }
  13572. //附件上传数据
  13573. if ($scope.options.templateOptions.fileUploader) {
  13574. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13575. //$scope.options.templateOptions.uploader();
  13576. console.log(uploader)
  13577. // FILTERS
  13578. uploader.filters.push({
  13579. name: 'customFilter',
  13580. fn: function (item /*{File|FileLikeObject}*/, options) {
  13581. return this.queue.length < 10;
  13582. }
  13583. });
  13584. }
  13585. var to = $scope.options.templateOptions;
  13586. // var bindType = $scope.model.bindType;
  13587. if (to.bindType == 'incident') {
  13588. var bindId = $scope.model[to.bindType].processInstanceId;
  13589. } else if (to.bindType == 'change') {
  13590. var bindId = $scope.model[to.bindType].processInstanceId;
  13591. } else {
  13592. var bindId = $scope.model[to.bindType].id;
  13593. }
  13594. //获取附件列表
  13595. $scope.listAttachmen = function () {
  13596. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  13597. var myData = Restangular.stripRestangular(result);
  13598. // $scope.listAttachmens = myData;
  13599. $scope.attachments = myData.data;
  13600. });
  13601. };
  13602. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  13603. $scope.listAttachmen();
  13604. } else if (to.bindType && $scope.model[to.bindType].id) {
  13605. $scope.listAttachmen();
  13606. }
  13607. //附件上传
  13608. $scope.isUpfload = to.isUpfload;
  13609. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13610. uploader.onBeforeUploadItem = function (item) {
  13611. angular.extend(item.headers, $rootScope.getSession());
  13612. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  13613. item.formData.push({
  13614. 'filename': item.file.name
  13615. });
  13616. };
  13617. uploader.uploadAll();
  13618. }
  13619. //附件下载
  13620. $scope.download = function (token, filename) {
  13621. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  13622. // window.open(downUrl);
  13623. var a = document.createElement('a');
  13624. a.href = downUrl;
  13625. a.target = '_blank';
  13626. a.download = filename;
  13627. document.body.appendChild(a);
  13628. a.click();
  13629. };
  13630. //附件预览
  13631. $scope.view = function (id, previewUrl) {
  13632. if (previewUrl) {
  13633. window.open(previewUrl);
  13634. }
  13635. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  13636. // if (response.state == 200) {
  13637. // window.open(response.previewUrl);
  13638. // }
  13639. // })
  13640. };
  13641. // CALLBACKS
  13642. if (uploader) {
  13643. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13644. console.info('onWhenAddingFileFailed', item, filter, options);
  13645. };
  13646. uploader.onAfterAddingFile = function (fileItem) {
  13647. console.info('onAfterAddingFile', fileItem);
  13648. };
  13649. uploader.onAfterAddingAll = function (addedFileItems) {
  13650. console.info('onAfterAddingAll', addedFileItems);
  13651. };
  13652. uploader.onBeforeUploadItem = function (item) {
  13653. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13654. // // $scope.uploader.options.url();
  13655. // $scope.uploader.onBeforeUploadItem = function(item) {
  13656. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13657. // console.info('onBeforeUploadItem', item);
  13658. // };
  13659. // $scope.uploader.uploadAll();
  13660. // }
  13661. console.info('onBeforeUploadItem', item);
  13662. };
  13663. uploader.onProgressItem = function (fileItem, progress) {
  13664. console.info('onProgressItem', fileItem, progress);
  13665. };
  13666. uploader.onProgressAll = function (progress) {
  13667. console.info('onProgressAll', progress);
  13668. };
  13669. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13670. console.info('onSuccessItem', fileItem, response, status, headers);
  13671. if (response.status == 200) {
  13672. $scope.listAttachmen();
  13673. }
  13674. };
  13675. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13676. console.info('onErrorItem', fileItem, response, status, headers);
  13677. };
  13678. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13679. console.info('onCancelItem', fileItem, response, status, headers);
  13680. };
  13681. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13682. console.info('onCompleteItem', fileItem, response, status, headers);
  13683. };
  13684. uploader.onCompleteAll = function () {
  13685. console.info('onCompleteAll');
  13686. };
  13687. }
  13688. }]
  13689. });
  13690. //简易上传下载附件组件
  13691. formlyConfigProvider.setType({
  13692. name: 'ui-upDownFiles',
  13693. templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
  13694. wrapper: ['bootstrapHasError'],
  13695. defaultOptions: function (options) {
  13696. return {
  13697. templateOptions: {
  13698. refresh: function (APIService, processInstanceId, data) {
  13699. return APIService.listAttachments(processInstanceId);
  13700. },
  13701. downloadUri: function (APIService, contentId) {
  13702. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13703. },
  13704. view: function (APIService, contentId) {
  13705. return APIService.attachmentsPreviewUrl(contentId);
  13706. },
  13707. download: function (APIService, contentId, item) {
  13708. var item = {
  13709. 'url': APIService.download(contentId),
  13710. 'headers': headers
  13711. };
  13712. return item;
  13713. },
  13714. refreshDelay: 0
  13715. }
  13716. };
  13717. },
  13718. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13719. if (angular.isUndefined($scope.form.dropState)) {
  13720. $scope.form.dropState = false;
  13721. }
  13722. //附件上传数据
  13723. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13724. //$scope.options.templateOptions.uploader();
  13725. // FILTERS
  13726. uploader.filters.push({
  13727. name: 'customFilter',
  13728. fn: function (item /*{File|FileLikeObject}*/, options) {
  13729. return this.queue.length < 10;
  13730. }
  13731. });
  13732. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13733. // uploader.onBeforeUploadItem = function (item) {
  13734. // angular.extend(item.headers, $rootScope.getSession());
  13735. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13736. // item.formData.push({
  13737. // 'fileName': item.file.name
  13738. // });
  13739. // console.info('onBeforeUploadItem', item);
  13740. // };
  13741. // }
  13742. // CALLBACKS
  13743. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13744. console.info('onWhenAddingFileFailed', item, filter, options);
  13745. };
  13746. uploader.onAfterAddingFile = function (fileItem) {
  13747. console.info('onAfterAddingFile', fileItem);
  13748. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13749. alert('文件过大');
  13750. fileItem.uploader.queue.pop()
  13751. console.log($scope);
  13752. }
  13753. };
  13754. uploader.onAfterAddingAll = function (addedFileItems) {
  13755. // console.info('onAfterAddingAll', addedFileItems);
  13756. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13757. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13758. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13759. // console.log(123)
  13760. };
  13761. uploader.onBeforeUploadItem = function (item) {
  13762. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13763. // // $scope.uploader.options.url();
  13764. // $scope.uploader.onBeforeUploadItem = function(item) {
  13765. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13766. // console.info('onBeforeUploadItem', item);
  13767. // };
  13768. // $scope.uploader.uploadAll();
  13769. // }
  13770. console.info('onBeforeUploadItem', item);
  13771. };
  13772. uploader.onProgressItem = function (fileItem, progress) {
  13773. console.info('onProgressItem', fileItem, progress);
  13774. };
  13775. uploader.onProgressAll = function (progress) {
  13776. console.info('onProgressAll', progress);
  13777. };
  13778. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13779. console.info('onSuccessItem', fileItem, response, status, headers);
  13780. };
  13781. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13782. console.info('onErrorItem', fileItem, response, status, headers);
  13783. };
  13784. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13785. console.info('onCancelItem', fileItem, response, status, headers);
  13786. };
  13787. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13788. console.info('onCompleteItem', fileItem, response, status, headers);
  13789. };
  13790. uploader.onCompleteAll = function () {
  13791. console.info('onCompleteAll');
  13792. };
  13793. var _refreshDelayPromise;
  13794. // 下载
  13795. $scope.download = function (contentId, filename, token) {
  13796. // console.log(contentId, filename, token)
  13797. //附件下载
  13798. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  13799. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  13800. // console.log(downUrl)
  13801. var a = document.createElement('a');
  13802. a.href = downUrl;
  13803. a.target = '_blank';
  13804. a.download = filename;
  13805. document.body.appendChild(a);
  13806. a.click();
  13807. };
  13808. $scope._refresh = function (refreshAttr) {
  13809. $scope.attachments = [];
  13810. if (refreshAttr !== undefined) {
  13811. if (_refreshDelayPromise) {
  13812. $timeout.cancel(_refreshDelayPromise);
  13813. }
  13814. _refreshDelayPromise = $timeout(function () {
  13815. // 暂存附件
  13816. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13817. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13818. $scope.options.templateOptions.processInstanceId, {
  13819. 'idx': 0,
  13820. 'sum': 1000
  13821. }).then(function (response) {
  13822. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13823. if (myData) {
  13824. for (var i = 0; i < myData.data.length; i++) {
  13825. $scope.attachments.push(myData.data[i]);
  13826. }
  13827. };
  13828. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13829. $scope.$parent.$parent.$parent.model.save_fileId, {
  13830. 'idx': 0,
  13831. 'sum': 1000
  13832. }).then(function (response2) {
  13833. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13834. if (myData2) {
  13835. for (var i = 0; i < myData2.data.length; i++) {
  13836. $scope.attachments.push(myData2.data[i]);
  13837. }
  13838. // 只展示除图片以外的附件
  13839. var a = [];
  13840. $scope.attachments.forEach(e => {
  13841. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13842. // $scope.imgs.push(e)
  13843. } else {
  13844. a.push(e)
  13845. }
  13846. })
  13847. $scope.attachments = a;
  13848. };
  13849. console.log($scope.attachments)
  13850. });
  13851. });
  13852. // 正常附件
  13853. } else {
  13854. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13855. $scope.options.templateOptions.processInstanceId, {
  13856. 'idx': 0,
  13857. 'sum': 1000
  13858. }).then(function (response) {
  13859. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13860. if (myData) {
  13861. $scope.attachments = myData.data;
  13862. // 只展示除图片以外的附件
  13863. var a = [];
  13864. $scope.attachments.forEach(e => {
  13865. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13866. // $scope.imgs.push(e)
  13867. } else {
  13868. a.push(e)
  13869. }
  13870. })
  13871. $scope.attachments = a;
  13872. }
  13873. });
  13874. }
  13875. }, $scope.options.templateOptions.refreshDelay);
  13876. }
  13877. }
  13878. $scope._refresh({});
  13879. }]
  13880. });
  13881. //简易上传附件组件
  13882. formlyConfigProvider.setType({
  13883. name: 'ui-uploadFiles',
  13884. templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
  13885. wrapper: ['bootstrapHasError'],
  13886. controller: ['$scope', function ($scope) {
  13887. if (angular.isUndefined($scope.form.dropState)) {
  13888. $scope.form.dropState = false;
  13889. }
  13890. //附件上传数据
  13891. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13892. //$scope.options.templateOptions.uploader();
  13893. // FILTERS
  13894. uploader.filters.push({
  13895. name: 'customFilter',
  13896. fn: function (item /*{File|FileLikeObject}*/, options) {
  13897. return this.queue.length < 10;
  13898. }
  13899. });
  13900. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13901. uploader.onBeforeUploadItem = function (item) {
  13902. angular.extend(item.headers, $rootScope.getSession());
  13903. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13904. item.formData.push({
  13905. 'fileName': item.file.name
  13906. });
  13907. console.info('onBeforeUploadItem', item);
  13908. };
  13909. }
  13910. // CALLBACKS
  13911. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13912. console.info('onWhenAddingFileFailed', item, filter, options);
  13913. };
  13914. uploader.onAfterAddingFile = function (fileItem) {
  13915. console.info('onAfterAddingFile', fileItem);
  13916. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13917. alert('文件过大');
  13918. fileItem.uploader.queue.pop()
  13919. console.log($scope);
  13920. }
  13921. };
  13922. uploader.onAfterAddingAll = function (addedFileItems) {
  13923. // console.info('onAfterAddingAll', addedFileItems);
  13924. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13925. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13926. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13927. // console.log(123)
  13928. };
  13929. uploader.onBeforeUploadItem = function (item) {
  13930. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13931. // // $scope.uploader.options.url();
  13932. // $scope.uploader.onBeforeUploadItem = function(item) {
  13933. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13934. // console.info('onBeforeUploadItem', item);
  13935. // };
  13936. // $scope.uploader.uploadAll();
  13937. // }
  13938. console.info('onBeforeUploadItem', item);
  13939. };
  13940. uploader.onProgressItem = function (fileItem, progress) {
  13941. console.info('onProgressItem', fileItem, progress);
  13942. };
  13943. uploader.onProgressAll = function (progress) {
  13944. console.info('onProgressAll', progress);
  13945. };
  13946. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13947. console.info('onSuccessItem', fileItem, response, status, headers);
  13948. };
  13949. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13950. console.info('onErrorItem', fileItem, response, status, headers);
  13951. };
  13952. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13953. console.info('onCancelItem', fileItem, response, status, headers);
  13954. };
  13955. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13956. console.info('onCompleteItem', fileItem, response, status, headers);
  13957. };
  13958. uploader.onCompleteAll = function () {
  13959. console.info('onCompleteAll');
  13960. };
  13961. }]
  13962. });
  13963. //无上传按钮附件上传组件
  13964. formlyConfigProvider.setType({
  13965. name: 'ui-dropfilenotup',
  13966. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  13967. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13968. controller: ['$scope', function ($scope) {
  13969. if (angular.isUndefined($scope.form.dropState)) {
  13970. $scope.form.dropState = false;
  13971. }
  13972. //附件上传数据
  13973. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13974. //$scope.options.templateOptions.uploader();
  13975. // FILTERS
  13976. uploader.filters.push({
  13977. name: 'customFilter',
  13978. fn: function (item /*{File|FileLikeObject}*/, options) {
  13979. return this.queue.length < 10;
  13980. }
  13981. });
  13982. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13983. uploader.onBeforeUploadItem = function (item) {
  13984. angular.extend(item.headers, $rootScope.getSession());
  13985. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13986. item.formData.push({
  13987. 'fileName': item.file.name
  13988. });
  13989. console.info('onBeforeUploadItem', item);
  13990. };
  13991. uploader.uploadAll();
  13992. }
  13993. // CALLBACKS
  13994. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13995. console.info('onWhenAddingFileFailed', item, filter, options);
  13996. };
  13997. uploader.onAfterAddingFile = function (fileItem) {
  13998. console.info('onAfterAddingFile', fileItem);
  13999. };
  14000. uploader.onAfterAddingAll = function (addedFileItems) {
  14001. console.info('onAfterAddingAll', addedFileItems);
  14002. };
  14003. uploader.onBeforeUploadItem = function (item) {
  14004. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14005. // // $scope.uploader.options.url();
  14006. // $scope.uploader.onBeforeUploadItem = function(item) {
  14007. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14008. // console.info('onBeforeUploadItem', item);
  14009. // };
  14010. // $scope.uploader.uploadAll();
  14011. // }
  14012. console.info('onBeforeUploadItem', item);
  14013. };
  14014. uploader.onProgressItem = function (fileItem, progress) {
  14015. console.info('onProgressItem', fileItem, progress);
  14016. };
  14017. uploader.onProgressAll = function (progress) {
  14018. console.info('onProgressAll', progress);
  14019. };
  14020. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14021. console.info('onSuccessItem', fileItem, response, status, headers);
  14022. };
  14023. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14024. console.info('onErrorItem', fileItem, response, status, headers);
  14025. };
  14026. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14027. console.info('onCancelItem', fileItem, response, status, headers);
  14028. };
  14029. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14030. console.info('onCompleteItem', fileItem, response, status, headers);
  14031. };
  14032. uploader.onCompleteAll = function () {
  14033. console.info('onCompleteAll');
  14034. };
  14035. }]
  14036. });
  14037. //无按钮知识库上传
  14038. formlyConfigProvider.setType({
  14039. name: 'ui-dropfielkn',
  14040. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14041. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14042. controller: ['$scope', function ($scope) {
  14043. if (angular.isUndefined($scope.form.dropState)) {
  14044. $scope.form.dropState = false;
  14045. }
  14046. //附件上传数据
  14047. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14048. //$scope.options.templateOptions.uploader();
  14049. // FILTERS
  14050. uploader.filters.push({
  14051. name: 'customFilter',
  14052. fn: function (item /*{File|FileLikeObject}*/, options) {
  14053. return this.queue.length < 10;
  14054. }
  14055. });
  14056. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14057. uploader.onBeforeUploadItem = function (item) {
  14058. angular.extend(item.headers, $rootScope.getSession());
  14059. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  14060. item.formData.push({
  14061. 'fileName': item.file.name
  14062. });
  14063. console.info('onBeforeUploadItem', item);
  14064. };
  14065. uploader.uploadAll();
  14066. }
  14067. // CALLBACKS
  14068. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14069. console.info('onWhenAddingFileFailed', item, filter, options);
  14070. };
  14071. uploader.onAfterAddingFile = function (fileItem) {
  14072. console.info('onAfterAddingFile', fileItem);
  14073. };
  14074. uploader.onAfterAddingAll = function (addedFileItems) {
  14075. console.info('onAfterAddingAll', addedFileItems);
  14076. };
  14077. uploader.onBeforeUploadItem = function (item) {
  14078. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14079. // // $scope.uploader.options.url();
  14080. // $scope.uploader.onBeforeUploadItem = function(item) {
  14081. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14082. // console.info('onBeforeUploadItem', item);
  14083. // };
  14084. // $scope.uploader.uploadAll();
  14085. // }
  14086. console.info('onBeforeUploadItem', item);
  14087. };
  14088. uploader.onProgressItem = function (fileItem, progress) {
  14089. console.info('onProgressItem', fileItem, progress);
  14090. };
  14091. uploader.onProgressAll = function (progress) {
  14092. console.info('onProgressAll', progress);
  14093. };
  14094. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14095. console.info('onSuccessItem', fileItem, response, status, headers);
  14096. };
  14097. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14098. console.info('onErrorItem', fileItem, response, status, headers);
  14099. };
  14100. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14101. console.info('onCancelItem', fileItem, response, status, headers);
  14102. };
  14103. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14104. console.info('onCompleteItem', fileItem, response, status, headers);
  14105. };
  14106. uploader.onCompleteAll = function () {
  14107. console.info('onCompleteAll');
  14108. };
  14109. }]
  14110. });
  14111. //附件上传列表组件
  14112. formlyConfigProvider.setType({
  14113. name: 'ui-dropfile',
  14114. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14115. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14116. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14117. if (angular.isUndefined($scope.form.dropState)) {
  14118. $scope.form.dropState = false;
  14119. }
  14120. //附件上传数据
  14121. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14122. //$scope.options.templateOptions.uploader();
  14123. // FILTERS
  14124. uploader.filters.push({
  14125. name: 'customFilter',
  14126. fn: function (item /*{File|FileLikeObject}*/, options) {
  14127. return this.queue.length < 10;
  14128. }
  14129. });
  14130. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14131. uploader.onBeforeUploadItem = function (item) {
  14132. angular.extend(item.headers, $rootScope.getSession());
  14133. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  14134. // if ($scope.options.templateOptions.formket) {
  14135. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  14136. // } else {
  14137. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  14138. // }
  14139. } else {
  14140. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14141. }
  14142. item.formData.push({
  14143. 'filename': item.file.name
  14144. });
  14145. console.info('onBeforeUploadItem', item);
  14146. };
  14147. uploader.uploadAll();
  14148. }
  14149. // CALLBACKS
  14150. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14151. console.info('onWhenAddingFileFailed', item, filter, options);
  14152. };
  14153. uploader.onAfterAddingFile = function (fileItem) {
  14154. console.info('onAfterAddingFile', fileItem);
  14155. };
  14156. uploader.onAfterAddingAll = function (addedFileItems) {
  14157. console.info('onAfterAddingAll', addedFileItems);
  14158. };
  14159. uploader.onBeforeUploadItem = function (item) {
  14160. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14161. // // $scope.uploader.options.url();
  14162. // $scope.uploader.onBeforeUploadItem = function(item) {
  14163. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14164. // console.info('onBeforeUploadItem', item);
  14165. // };
  14166. // $scope.uploader.uploadAll();
  14167. // }
  14168. console.info('onBeforeUploadItem', item);
  14169. };
  14170. uploader.onProgressItem = function (fileItem, progress) {
  14171. console.info('onProgressItem', fileItem, progress);
  14172. };
  14173. uploader.onProgressAll = function (progress) {
  14174. console.info('onProgressAll', progress);
  14175. };
  14176. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14177. console.info('onSuccessItem', fileItem, response, status, headers);
  14178. };
  14179. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14180. console.info('onErrorItem', fileItem, response, status, headers);
  14181. };
  14182. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14183. console.info('onCancelItem', fileItem, response, status, headers);
  14184. };
  14185. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14186. console.info('onCompleteItem', fileItem, response, status, headers);
  14187. };
  14188. uploader.onCompleteAll = function () {
  14189. console.info('onCompleteAll');
  14190. };
  14191. }]
  14192. });
  14193. //简易附件展示下载列表组件
  14194. formlyConfigProvider.setType({
  14195. name: 'ui-dropFiles',
  14196. templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
  14197. defaultOptions: function (options) {
  14198. return {
  14199. templateOptions: {
  14200. refresh: function (APIService, processInstanceId, data) {
  14201. return APIService.listAttachments(processInstanceId);
  14202. },
  14203. downloadUri: function (APIService, contentId) {
  14204. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14205. },
  14206. view: function (APIService, contentId) {
  14207. return APIService.attachmentsPreviewUrl(contentId);
  14208. },
  14209. download: function (APIService, contentId, item) {
  14210. var item = {
  14211. 'url': APIService.download(contentId),
  14212. 'headers': headers
  14213. };
  14214. return item;
  14215. },
  14216. refreshDelay: 0
  14217. }
  14218. };
  14219. },
  14220. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  14221. var _refreshDelayPromise;
  14222. // $scope.downloadUrl = function(contentId){
  14223. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14224. // };
  14225. $scope.download = function (contentId, filename, token) {
  14226. // console.log(contentId, filename, token)
  14227. //附件下载
  14228. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  14229. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  14230. // console.log(downUrl)
  14231. var a = document.createElement('a');
  14232. a.href = downUrl;
  14233. a.target = '_blank';
  14234. a.download = filename;
  14235. document.body.appendChild(a);
  14236. a.click();
  14237. };
  14238. $scope.view = function (contentId, token, filename, type) {
  14239. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14240. if (response.state == 200) {
  14241. window.open(response.previewUrl);
  14242. }
  14243. })
  14244. };
  14245. /**
  14246. * refresh
  14247. */
  14248. $scope._refresh = function (refreshAttr) {
  14249. $scope.attachments = [];
  14250. if (refreshAttr !== undefined) {
  14251. if (_refreshDelayPromise) {
  14252. $timeout.cancel(_refreshDelayPromise);
  14253. }
  14254. _refreshDelayPromise = $timeout(function () {
  14255. // 暂存附件
  14256. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  14257. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14258. $scope.options.templateOptions.processInstanceId, {
  14259. 'idx': 0,
  14260. 'sum': 1000
  14261. }).then(function (response) {
  14262. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14263. if (myData) {
  14264. for (var i = 0; i < myData.data.length; i++) {
  14265. $scope.attachments.push(myData.data[i]);
  14266. }
  14267. };
  14268. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14269. $scope.$parent.$parent.$parent.model.save_fileId, {
  14270. 'idx': 0,
  14271. 'sum': 1000
  14272. }).then(function (response2) {
  14273. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  14274. if (myData2) {
  14275. for (var i = 0; i < myData2.data.length; i++) {
  14276. $scope.attachments.push(myData2.data[i]);
  14277. }
  14278. // 只展示除图片以外的附件
  14279. var a = [];
  14280. $scope.attachments.forEach(e => {
  14281. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14282. // $scope.imgs.push(e)
  14283. } else {
  14284. a.push(e)
  14285. }
  14286. })
  14287. $scope.attachments = a;
  14288. };
  14289. console.log($scope.attachments)
  14290. });
  14291. });
  14292. // 正常附件
  14293. } else {
  14294. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14295. $scope.options.templateOptions.processInstanceId, {
  14296. 'idx': 0,
  14297. 'sum': 1000
  14298. }).then(function (response) {
  14299. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14300. if (myData) {
  14301. $scope.attachments = myData.data;
  14302. // 只展示除图片以外的附件
  14303. var a = [];
  14304. $scope.attachments.forEach(e => {
  14305. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14306. // $scope.imgs.push(e)
  14307. } else {
  14308. a.push(e)
  14309. }
  14310. })
  14311. $scope.attachments = a;
  14312. console.log($scope.attachments)
  14313. }
  14314. });
  14315. }
  14316. }, $scope.options.templateOptions.refreshDelay);
  14317. }
  14318. }
  14319. $scope._refresh({});
  14320. // $scope.attachments = $scope.model[$scope.options.key]
  14321. }]
  14322. });
  14323. //知识库附件上传
  14324. formlyConfigProvider.setType({
  14325. name: 'ui-dropfielknow',
  14326. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14327. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14328. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14329. if (angular.isUndefined($scope.form.dropState)) {
  14330. $scope.form.dropState = false;
  14331. }
  14332. //附件上传数据
  14333. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14334. //$scope.options.templateOptions.uploader();
  14335. // FILTERS
  14336. uploader.filters.push({
  14337. name: 'customFilter',
  14338. fn: function (item /*{File|FileLikeObject}*/, options) {
  14339. return this.queue.length < 10;
  14340. }
  14341. });
  14342. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14343. uploader.onBeforeUploadItem = function (item) {
  14344. angular.extend(item.headers, $rootScope.getSession());
  14345. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  14346. item.formData.push({
  14347. 'fileName': item.file.name,
  14348. 'type': 'solution',
  14349. 'solutionId': $scope.model.knowledge.id
  14350. });
  14351. console.info('onBeforeUploadItem', item);
  14352. };
  14353. uploader.uploadAll();
  14354. }
  14355. // CALLBACKS
  14356. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14357. console.info('onWhenAddingFileFailed', item, filter, options);
  14358. };
  14359. uploader.onAfterAddingFile = function (fileItem) {
  14360. console.info('onAfterAddingFile', fileItem);
  14361. };
  14362. uploader.onAfterAddingAll = function (addedFileItems) {
  14363. console.info('onAfterAddingAll', addedFileItems);
  14364. };
  14365. uploader.onBeforeUploadItem = function (item) {
  14366. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14367. // // $scope.uploader.options.url();
  14368. // $scope.uploader.onBeforeUploadItem = function(item) {
  14369. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14370. // console.info('onBeforeUploadItem', item);
  14371. // };
  14372. // $scope.uploader.uploadAll();
  14373. // }
  14374. console.info('onBeforeUploadItem', item);
  14375. };
  14376. uploader.onProgressItem = function (fileItem, progress) {
  14377. console.info('onProgressItem', fileItem, progress);
  14378. };
  14379. uploader.onProgressAll = function (progress) {
  14380. console.info('onProgressAll', progress);
  14381. };
  14382. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14383. console.info('onSuccessItem', fileItem, response, status, headers);
  14384. };
  14385. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14386. console.info('onErrorItem', fileItem, response, status, headers);
  14387. };
  14388. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14389. console.info('onCancelItem', fileItem, response, status, headers);
  14390. };
  14391. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14392. console.info('onCompleteItem', fileItem, response, status, headers);
  14393. };
  14394. uploader.onCompleteAll = function () {
  14395. console.info('onCompleteAll');
  14396. };
  14397. }]
  14398. });
  14399. //知识库附件下载列表
  14400. formlyConfigProvider.setType({
  14401. name: 'ui-dropfileknowledge',
  14402. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  14403. defaultOptions: function (options) {
  14404. return {
  14405. templateOptions: {
  14406. refresh: function (APIService, contentId, data) {
  14407. return APIService.fetchDataList(contentId, data);
  14408. },
  14409. downloadUri: function (APIService, contentId) {
  14410. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14411. },
  14412. download: function (APIService, contentId) {
  14413. return APIService.getSolutionDowpath(contentId);
  14414. },
  14415. view: function (attachmentId) {
  14416. // return APIService.attachmentsPreviewUrl(contentId);
  14417. },
  14418. refreshDelay: 0
  14419. }
  14420. };
  14421. },
  14422. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  14423. var _refreshDelayPromise;
  14424. $scope.attachments = [];
  14425. $scope.downloadUrl = function (contentId) {
  14426. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  14427. };
  14428. $scope.download = function (contentId, filename) {
  14429. $http({
  14430. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  14431. method: 'GET',
  14432. headers: {
  14433. //'Content-type' : 'application/xls',
  14434. 'Accept': '*/*'
  14435. },
  14436. responseType: 'arraybuffer'
  14437. }).success(function (data, status, headers, config) {
  14438. var file = new Blob([data], {
  14439. type: 'application/octet-stream'
  14440. });
  14441. //trick to download store a file having its URL
  14442. var fileURL = URL.createObjectURL(file);
  14443. var a = document.createElement('a');
  14444. a.href = fileURL;
  14445. a.target = '_blank';
  14446. a.download = filename;
  14447. document.body.appendChild(a);
  14448. a.click();
  14449. }).error(function (data, status, headers, config) {
  14450. // console.log(data);
  14451. });
  14452. }
  14453. $scope.view = function (contentId, filename, attachment) {
  14454. var index = filename.indexOf(".");
  14455. var type = filename.substring(index + 1);
  14456. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14457. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  14458. // var modalInstance = $modal.open({
  14459. // backdrop: false,
  14460. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14461. // controller: function($scope, scope, $modalInstance, filename) {
  14462. // $scope.title = filename;
  14463. // $scope.imageurl = scope.imageurl;
  14464. // $scope.cancel = function() {
  14465. // $modalInstance.dismiss('cancel');
  14466. // }
  14467. // },
  14468. // resolve: {
  14469. // scope: function() {
  14470. // return $scope;
  14471. // },
  14472. // filename: function() {
  14473. // return filename;
  14474. // }
  14475. // }
  14476. // });
  14477. // event.preventDefault();
  14478. // } else {
  14479. // for (var i = 0; i < $scope.attachments.length; i++) {
  14480. // if ($scope.attachments[i].id == attachmentId) {
  14481. window.open(attachment.previewUrl);
  14482. // }
  14483. // }
  14484. // }
  14485. };
  14486. $scope._refresh = function (refreshAttr) {
  14487. if (refreshAttr !== undefined) {
  14488. if (_refreshDelayPromise) {
  14489. $timeout.cancel(_refreshDelayPromise);
  14490. }
  14491. _refreshDelayPromise = $timeout(function () {
  14492. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14493. 'file', {
  14494. "file": {
  14495. "solutionId": $scope.model.knowledge.id
  14496. },
  14497. "idx": "0",
  14498. "sum": "1000"
  14499. }).then(function (response) {
  14500. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14501. if (myData) {
  14502. $scope.attachments = myData.list;
  14503. // $scope.view = function(attachmentId) {
  14504. // for (var i = 0; i < $scope.attachments.length; i++) {
  14505. // if ($scope.attachments[i].id == attachmentId) {
  14506. // window.open($scope.attachments[i].previewUrl);
  14507. // // var modalInstance = $modal.open({
  14508. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  14509. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  14510. // // }
  14511. // // });
  14512. // }
  14513. // }
  14514. // };
  14515. }
  14516. });
  14517. }, $scope.options.templateOptions.refreshDelay);
  14518. }
  14519. }
  14520. $scope._refresh({});
  14521. // $scope.attachments = $scope.model[$scope.options.key]
  14522. }]
  14523. });
  14524. //附件图片下载
  14525. formlyConfigProvider.setType({
  14526. name: 'ui-downimage',
  14527. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  14528. defaultOptions: function (options) {
  14529. return {
  14530. templateOptions: {
  14531. refresh: function (APIService, processInstanceId, data) {
  14532. return APIService.listAttachments(processInstanceId, data);
  14533. },
  14534. downloadUri: function (APIService, contentId) {
  14535. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14536. },
  14537. view: function (APIService, contentId) {
  14538. return APIService.attachmentsPreviewUrl(contentId);
  14539. },
  14540. download: function (APIService, contentId, item) {
  14541. var item = {
  14542. 'url': APIService.download(contentId),
  14543. 'headers': headers
  14544. };
  14545. return item;
  14546. },
  14547. refreshDelay: 0
  14548. }
  14549. };
  14550. },
  14551. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  14552. var _refreshDelayPromise;
  14553. // $scope.downloadUrl = function(contentId){
  14554. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14555. // };
  14556. $scope.download = function (contentId, filename) {
  14557. // var headers=
  14558. $http({
  14559. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14560. method: 'GET',
  14561. headers: {
  14562. //'Content-type' : 'application/xls',
  14563. 'Accept': '*/*'
  14564. },
  14565. responseType: 'arraybuffer'
  14566. }).success(function (data, status, headers, config) {
  14567. var file = new Blob([data], {
  14568. type: 'application/octet-stream'
  14569. });
  14570. //trick to download store a file having its URL
  14571. var fileURL = URL.createObjectURL(file);
  14572. var a = document.createElement('a');
  14573. a.href = fileURL;
  14574. a.target = '_blank';
  14575. a.download = filename;
  14576. document.body.appendChild(a);
  14577. a.click();
  14578. }).error(function (data, status, headers, config) {
  14579. // console.log(data);
  14580. });
  14581. };
  14582. $scope.view = function (contentId) {
  14583. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14584. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  14585. // if (response.state == 200) {
  14586. // window.open(response.previewUrl);
  14587. // }
  14588. // })
  14589. };
  14590. /**
  14591. * refresh
  14592. */
  14593. $scope._refresh = function (refreshAttr) {
  14594. if (refreshAttr !== undefined) {
  14595. if (_refreshDelayPromise) {
  14596. $timeout.cancel(_refreshDelayPromise);
  14597. }
  14598. _refreshDelayPromise = $timeout(function () {
  14599. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14600. $scope.options.templateOptions.processInstanceId, {
  14601. 'idx': 0,
  14602. 'sum': 1000
  14603. }).then(function (response) {
  14604. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14605. if (myData) {
  14606. $scope.attachments = myData.data;
  14607. }
  14608. });
  14609. }, $scope.options.templateOptions.refreshDelay);
  14610. }
  14611. }
  14612. $scope._refresh({});
  14613. // $scope.attachments = $scope.model[$scope.options.key]
  14614. }]
  14615. });
  14616. //附件下载列表组件
  14617. formlyConfigProvider.setType({
  14618. name: 'ui-dropfiletable',
  14619. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  14620. defaultOptions: function (options) {
  14621. return {
  14622. templateOptions: {
  14623. refresh: function (APIService, processInstanceId, data) {
  14624. return APIService.listAttachments(processInstanceId, data);
  14625. },
  14626. downloadUri: function (APIService, contentId) {
  14627. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14628. },
  14629. view: function (APIService, contentId) {
  14630. return APIService.attachmentsPreviewUrl(contentId);
  14631. },
  14632. download: function (APIService, contentId, item) {
  14633. var item = {
  14634. 'url': APIService.download(contentId),
  14635. 'headers': headers
  14636. };
  14637. return item;
  14638. },
  14639. refreshDelay: 0
  14640. }
  14641. };
  14642. },
  14643. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  14644. var _refreshDelayPromise;
  14645. // $scope.downloadUrl = function(contentId){
  14646. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14647. // };
  14648. $scope.download = function (contentId, filename) {
  14649. // var headers=
  14650. $http({
  14651. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14652. method: 'GET',
  14653. headers: {
  14654. //'Content-type' : 'application/xls',
  14655. 'Accept': '*/*'
  14656. },
  14657. responseType: 'arraybuffer'
  14658. }).success(function (data, status, headers, config) {
  14659. var file = new Blob([data], {
  14660. type: 'application/octet-stream'
  14661. });
  14662. //trick to download store a file having its URL
  14663. var fileURL = URL.createObjectURL(file);
  14664. var a = document.createElement('a');
  14665. a.href = fileURL;
  14666. a.target = '_blank';
  14667. a.download = filename;
  14668. document.body.appendChild(a);
  14669. a.click();
  14670. }).error(function (data, status, headers, config) {
  14671. // console.log(data);
  14672. });
  14673. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  14674. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  14675. // var file = new Blob([response], {
  14676. // type : 'application/octet-stream'
  14677. // });
  14678. // // var filename = filename;
  14679. // //var file = new Blob([response], {type: 'application/pdf'});
  14680. // var fileURL = URL.createObjectURL(file);
  14681. // var a = document.createElement('a');
  14682. // a.href = fileURL;
  14683. // a.target = '_blank';
  14684. // a.download = filename ;
  14685. // document.body.appendChild(a);
  14686. // a.click();
  14687. // })
  14688. };
  14689. $scope.view = function (contentId, token, filename, type) {
  14690. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14691. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14692. // var modalInstance = $modal.open({
  14693. // backdrop: false,
  14694. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14695. // controller: function($scope, scope, $modalInstance, filename) {
  14696. // $scope.title = filename;
  14697. // $scope.imageurl = scope.imageurl;
  14698. // $scope.cancel = function() {
  14699. // $modalInstance.dismiss('cancel');
  14700. // }
  14701. // },
  14702. // resolve: {
  14703. // scope: function() {
  14704. // return $scope;
  14705. // },
  14706. // filename: function() {
  14707. // return filename;
  14708. // }
  14709. // }
  14710. // });
  14711. // event.preventDefault();
  14712. // } else {
  14713. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14714. if (response.state == 200) {
  14715. window.open(response.previewUrl);
  14716. }
  14717. })
  14718. // }
  14719. };
  14720. /**
  14721. * refresh
  14722. */
  14723. $scope._refresh = function (refreshAttr) {
  14724. if (refreshAttr !== undefined) {
  14725. if (_refreshDelayPromise) {
  14726. $timeout.cancel(_refreshDelayPromise);
  14727. }
  14728. _refreshDelayPromise = $timeout(function () {
  14729. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14730. $scope.options.templateOptions.processInstanceId, {
  14731. 'idx': 0,
  14732. 'sum': 1000
  14733. }).then(function (response) {
  14734. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14735. if (myData) {
  14736. $scope.attachments = myData.data;
  14737. }
  14738. });
  14739. }, $scope.options.templateOptions.refreshDelay);
  14740. }
  14741. }
  14742. $scope._refresh({});
  14743. // $scope.attachments = $scope.model[$scope.options.key]
  14744. }]
  14745. });
  14746. //微信附件下载列表组件
  14747. formlyConfigProvider.setType({
  14748. name: 'ui-dropfilewechat',
  14749. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  14750. defaultOptions: function (options) {
  14751. return {
  14752. templateOptions: {
  14753. // refresh: function(APIService, processInstanceId, data) {
  14754. // return APIService.listAttachments(processInstanceId, data);
  14755. // },
  14756. // downloadUri: function(APIService, contentId) {
  14757. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  14758. // },
  14759. view: function (APIService, contentId) {
  14760. // return APIService.attachmentsPreviewUrl(contentId);
  14761. return APIService.attachmentsPreviewUrl(contentId);
  14762. },
  14763. download: function (APIService, contentId, item) {
  14764. var item = {
  14765. 'url': APIService.download(contentId),
  14766. 'headers': headers
  14767. };
  14768. return item;
  14769. },
  14770. // download: function(APIService, contentId, item) {
  14771. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  14772. // return item;
  14773. // },
  14774. refreshDelay: 0
  14775. }
  14776. };
  14777. },
  14778. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  14779. var _refreshDelayPromise;
  14780. // $scope.downloadUrl = function(contentId){
  14781. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14782. // };
  14783. $scope.attachments = {};
  14784. $scope.previewUrl = '';
  14785. $scope.download = function (token, filename) {
  14786. // var headers=
  14787. console.log($scope);
  14788. $http({
  14789. url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
  14790. method: 'GET',
  14791. headers: {
  14792. //'Content-type' : 'application/xls',
  14793. 'Accept': '*/*'
  14794. },
  14795. responseType: 'arraybuffer'
  14796. }).success(function (data, status, headers, config) {
  14797. var file = new Blob([data], {
  14798. type: 'application/octet-stream'
  14799. });
  14800. //trick to download store a file having its URL
  14801. var fileURL = URL.createObjectURL(file);
  14802. var a = document.createElement('a');
  14803. a.href = fileURL;
  14804. a.target = '_blank';
  14805. a.download = filename;
  14806. document.body.appendChild(a);
  14807. a.click();
  14808. }).error(function (data, status, headers, config) {
  14809. // console.log(data);
  14810. });
  14811. };
  14812. $scope.view = function (contentId, token, filename, type, previewUrl) {
  14813. // if (type) {
  14814. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  14815. // var modalInstance = $modal.open({
  14816. // backdrop: false,
  14817. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14818. // controller: function($scope, scope, $modalInstance, filename) {
  14819. // $scope.title = filename;
  14820. // $scope.imageurl = scope.imageurl;
  14821. // $scope.cancel = function() {
  14822. // $modalInstance.dismiss('cancel');
  14823. // }
  14824. // },
  14825. // resolve: {
  14826. // scope: function() {
  14827. // return $scope;
  14828. // },
  14829. // filename: function() {
  14830. // return filename;
  14831. // }
  14832. // }
  14833. // });
  14834. // event.preventDefault();
  14835. // } else {
  14836. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  14837. // if (response.state == 200) {
  14838. // window.open(response.previewUrl);
  14839. // }
  14840. // })
  14841. window.open(previewUrl);
  14842. // }
  14843. };
  14844. /**
  14845. * refresh
  14846. */
  14847. $scope._refresh = function (refreshAttr) {
  14848. if (refreshAttr !== undefined) {
  14849. if (_refreshDelayPromise) {
  14850. $timeout.cancel(_refreshDelayPromise);
  14851. }
  14852. _refreshDelayPromise = $timeout(function () {
  14853. // console.log(JSON.parse($stateParams.model))
  14854. var incidentChart = {};
  14855. if ($stateParams.model) {
  14856. incidentChart = JSON.parse($stateParams.model).model;
  14857. }
  14858. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14859. $scope.model).then(function (response) {
  14860. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14861. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  14862. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14863. if (myData) {
  14864. $scope.attachments = myData.data;
  14865. }
  14866. });
  14867. }, $scope.options.templateOptions.refreshDelay);
  14868. }
  14869. }
  14870. $scope._refresh({});
  14871. // $scope.attachments = $scope.model[$scope.options.key]
  14872. }]
  14873. });
  14874. formlyConfigProvider.setType({
  14875. name: 'ui-paralleltask',
  14876. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  14877. defaultOptions: function (options) {
  14878. return {
  14879. templateOptions: {
  14880. refresh: function (APIService, processInstanceId, data) {
  14881. //return APIService.listAttachments(processInstanceId, data);
  14882. },
  14883. refreshDelay: 0
  14884. }
  14885. };
  14886. },
  14887. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  14888. });
  14889. //repeatSection
  14890. //
  14891. formlyConfigProvider.setType({
  14892. name: 'ui-repeatSection',
  14893. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  14894. defaultOptions: function (options) {
  14895. return {
  14896. templateOptions: {
  14897. unique: 1,
  14898. initDisplay: false
  14899. }
  14900. };
  14901. },
  14902. controller: function ($scope) {
  14903. //$scope.options.templateOptions.unique;
  14904. $scope.formOptions = {
  14905. formState: $scope.formState
  14906. };
  14907. $scope.addNew = addNew;
  14908. $scope.copyFields = copyFields;
  14909. function copyFields(fields) {
  14910. fields = angular.copy(fields);
  14911. addRandomIds(fields);
  14912. return fields;
  14913. }
  14914. function addNew() {
  14915. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  14916. var repeatsection = $scope.model[$scope.options.key];
  14917. var lastSection = repeatsection[repeatsection.length - 1];
  14918. var newsection = {};
  14919. repeatsection.push(newsection);
  14920. }
  14921. function addRandomIds(fields) {
  14922. $scope.options.templateOptions.unique++;
  14923. angular.forEach(fields, function (field, index) {
  14924. if (field.fieldGroup) {
  14925. addRandomIds(field.fieldGroup);
  14926. return; // fieldGroups don't need an ID
  14927. }
  14928. if (field.templateOptions && field.templateOptions.fields) {
  14929. addRandomIds(field.templateOptions.fields);
  14930. }
  14931. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  14932. });
  14933. }
  14934. function getRandomInt(min, max) {
  14935. return Math.floor(Math.random() * (max - min)) + min;
  14936. }
  14937. if ($scope.options.templateOptions.initDisplay) {
  14938. addNew();
  14939. }
  14940. }
  14941. });
  14942. //时间轴任务列表组件
  14943. //cmdb控件
  14944. formlyConfigProvider.setType({
  14945. name: 'ui-cmdb',
  14946. extends: 'input',
  14947. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  14948. defaultOptions: function (options) {
  14949. return {
  14950. templateOptions: {
  14951. onClick: function (size, options, modal, event, model) {
  14952. var modalInstance = modal.open({
  14953. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  14954. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  14955. var width = $scope.width = 600;
  14956. var height = $scope.height = 400;
  14957. var tree;
  14958. var d3 = window.d3;
  14959. $scope.my_tree_handler = function (branch) {
  14960. //var _ref;
  14961. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  14962. APIService.query({
  14963. 'sign': classify
  14964. }).then(function (data) {
  14965. var myData = Restangular.stripRestangular(data);
  14966. // console.log(myData.data.node);
  14967. if (myData.data && myData.status == 200) {
  14968. var ret = myData.data;
  14969. redrawSvg(myData);
  14970. }
  14971. });
  14972. };
  14973. $scope.my_data = [];
  14974. function convertListToTree(data, treeMap) {
  14975. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  14976. var root = null; //Initially set our loop to null
  14977. var parentNode = null;
  14978. //loop over data
  14979. for (var i = 0; i < data.length; i++) {
  14980. var datum = data[i];
  14981. //each node will have children, so let's give it a "children" poperty
  14982. datum.children = [];
  14983. //add an entry for this node to the map so that any future children can
  14984. //lookup the parent
  14985. idToNodeMap[datum.id] = datum;
  14986. //Does this node have a parent?
  14987. if (typeof datum.parent === "undefined" || datum.parent == null) {
  14988. //Doesn't look like it, so this node is the root of the tree
  14989. root = datum;
  14990. treeMap[datum.id] = root;
  14991. } else {
  14992. //This node has a parent, so let's look it up using the id
  14993. parentNode = idToNodeMap[datum.parent.id];
  14994. //We don't need this property, so let's delete it.
  14995. delete datum.parent;
  14996. //Let's add the current node as a child of the parent node.
  14997. parentNode.children.push(datum);
  14998. }
  14999. }
  15000. return root;
  15001. }
  15002. function convertParentToChildList(data) {
  15003. var treeMap = {};
  15004. var list = [];
  15005. convertListToTree(data, treeMap);
  15006. angular.forEach(treeMap, function (item) {
  15007. list.push(item);
  15008. });
  15009. return list;
  15010. }
  15011. $scope.my_tree = tree = {};
  15012. $scope.try_async_load = function () {
  15013. $scope.my_data = [];
  15014. $scope.select_treedata = [];
  15015. $scope.doing_async = true;
  15016. ConfigDataService.fetchDataList('ciclassify', {
  15017. 'idx': 0,
  15018. 'sum': 100
  15019. }).then(function (result) {
  15020. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15021. $scope.doing_async = false;
  15022. });
  15023. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  15024. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15025. // $scope.doing_async = false;
  15026. // });
  15027. };
  15028. $scope.select_treedata = [];
  15029. $scope.propTypeOptions = [];
  15030. $scope.try_async_load();
  15031. $scope.onFilterCallback = function (item) {
  15032. //console.log(item);
  15033. if (angular.isDefined(item.children) && item.children.length >= 1) {
  15034. //not valid
  15035. } else {
  15036. var tempclassify = item.prefix.toLowerCase() + item.sign;
  15037. $scope.cifilter_classic = tempclassify;
  15038. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  15039. var myData = Restangular.stripRestangular(data);
  15040. $scope.propTypeOptions = myData;
  15041. });
  15042. }
  15043. }
  15044. $scope.onPropTypeChange = function (form) {
  15045. $scope.propOptions = form.fields;
  15046. }
  15047. $scope.onPropChange = function (prop) {
  15048. $scope.cifilter_prop = prop;
  15049. }
  15050. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  15051. //if(searchKey!=null&&searchKey.length>1){
  15052. var searchData = {};
  15053. if (angular.isUndefined(propObj)) {
  15054. propObj = $scope.cifilter_prop;
  15055. }
  15056. if (angular.isUndefined(ciclassify)) {
  15057. ciclassify = $scope.cifilter_classic;
  15058. }
  15059. searchData['sign'] = ciclassify;
  15060. if (angular.isDefined(propObj)) {
  15061. searchData[propObj.key] = searchKey;
  15062. }
  15063. APIService.query(searchData).then(function (response) {
  15064. var data = Restangular.stripRestangular(response);
  15065. //此处不清空nodes
  15066. var node = data.data.node;
  15067. var tempNode = [];
  15068. //nodes 或者links 要去重
  15069. for (var i = 0; i < node.length; i++) {
  15070. var tmp = 0;
  15071. for (var j = 0; j < nodes.length; j++) {
  15072. if (node[i].uuid == nodes[j].uuid) {
  15073. tmp++;
  15074. break;
  15075. }
  15076. }
  15077. if (tmp == 0) {
  15078. tempNode.push(node[i]);
  15079. }
  15080. }
  15081. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15082. nodes.push(tempNode[i]);
  15083. }
  15084. restart();
  15085. })
  15086. }
  15087. $scope.refresh = function () {
  15088. nodes.length = 0;
  15089. links.length = 0;
  15090. restart();
  15091. }
  15092. $scope.traversal = function () {
  15093. if ($scope.selected_node == null) {
  15094. SweetAlert.swal({
  15095. title: "错误的操作!",
  15096. text: "没有配置项被选中!",
  15097. type: "error"
  15098. });
  15099. } else {
  15100. var uuid = $scope.selected_node.uuid;
  15101. APIService.traversal(uuid).then(function (response) {
  15102. var d = response.data;
  15103. var node = d.node;
  15104. var link = d.edge;
  15105. var tempNode = [];
  15106. var tempLink = [];
  15107. //nodes 或者links 要去重
  15108. for (var i = 0; i < node.length; i++) {
  15109. var tmp = 0;
  15110. for (var j = 0; j < nodes.length; j++) {
  15111. if (node[i].id == nodes[j].id) {
  15112. tmp++;
  15113. break;
  15114. }
  15115. }
  15116. if (tmp == 0) {
  15117. tempNode.push(node[i]);
  15118. }
  15119. }
  15120. for (var i = 0; i < link.length; i++) {
  15121. var tmp = 0;
  15122. for (var j = 0; j < links.length; j++) {
  15123. if (link[i].id == links[j].id) {
  15124. tmp++;
  15125. break;
  15126. }
  15127. }
  15128. if (tmp == 0) {
  15129. tempLink.push(link[i]);
  15130. }
  15131. }
  15132. //数据写入页面
  15133. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15134. nodes.push(tempNode[i]);
  15135. }
  15136. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15137. links.push(tempLink[i]);
  15138. }
  15139. //links转换
  15140. for (var i = 0; i < links.length; i++) {
  15141. for (var j = 0; j < nodes.length; j++) {
  15142. if (links[i].source == nodes[j].id) {
  15143. links[i].source = nodes[j];
  15144. }
  15145. if (links[i].target == nodes[j].id) {
  15146. links[i].target = nodes[j];
  15147. }
  15148. }
  15149. }
  15150. restart();
  15151. })
  15152. }
  15153. }
  15154. var svg;
  15155. var force;
  15156. var drag_line, path, circle;
  15157. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  15158. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15159. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15160. var nodes = [],
  15161. links = [];
  15162. var treeNodes = [];
  15163. //读取labels (node)
  15164. var labels = [];
  15165. function redrawSvg(json) {
  15166. nodes.length = 0; //先清空
  15167. links.length = 0;
  15168. var data = json.data;
  15169. for (var i = 0; i < data.node.length; i++) {
  15170. nodes.push(data.node[i]);
  15171. }
  15172. restart();
  15173. }
  15174. //读取status (节点 连线)
  15175. var statuses = [];
  15176. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  15177. // if (result && result.status == 200) {
  15178. // d3.select('#nodeStatus').selectAll('option')
  15179. // .data(statuses).enter()
  15180. // .append('option')
  15181. // .attr('value', function(d) { return d.code; })
  15182. // .html(function(d) { return d.desc; });
  15183. // } else {
  15184. // SweetAlert.swal({
  15185. // title: "提示!",
  15186. // text: "服务器请求异常!",
  15187. // type: "error"
  15188. // });
  15189. // }
  15190. // });
  15191. api_wechatfile.getDictionary({
  15192. 'key': 'cmdb_status',
  15193. 'type': 'list'
  15194. }).then(function (result) {
  15195. if (result) {
  15196. d3.select('#nodeStatus').selectAll('option')
  15197. .data(statuses).enter()
  15198. .append('option')
  15199. .attr('value', function (d) {
  15200. return d.code;
  15201. })
  15202. .html(function (d) {
  15203. return d.desc;
  15204. });
  15205. } else {
  15206. SweetAlert.swal({
  15207. title: "提示!",
  15208. text: "服务器请求异常!",
  15209. type: "error"
  15210. });
  15211. }
  15212. });
  15213. //查询relationship_type表 name 为表里的type,label为显示值
  15214. var linkType = [];
  15215. function fetchEdgeTypes() {
  15216. ConfigDataService.fetchDataList('ciedgetype', {
  15217. 'idx': 0,
  15218. 'sum': 100
  15219. }).then(function (response) {
  15220. if (response) {
  15221. if (response['list']) {
  15222. linkType = response['list'];
  15223. // d3.select('#linkName').selectAll('option')
  15224. // .data(linkType).enter()
  15225. // .append('option')
  15226. // .attr('value',function(d){return d.type;})
  15227. // .html(function(d){ return d.label;});
  15228. } else {
  15229. SweetAlert.swal({
  15230. title: "提示!",
  15231. text: "服务器请求异常!",
  15232. type: "error"
  15233. });
  15234. }
  15235. } else {
  15236. SweetAlert.swal({
  15237. title: "提示!",
  15238. text: "服务器请求异常!",
  15239. type: "error"
  15240. });
  15241. }
  15242. })
  15243. }
  15244. // fetchEdgeTypes();
  15245. /*
  15246. // init D3 force layout
  15247. var force = d3.layout.force()
  15248. .nodes(nodes)
  15249. .links(links)
  15250. .size([width, height])
  15251. .gravity(.05)
  15252. .linkDistance(150)
  15253. .linkStrength(2)
  15254. .charge(-500)
  15255. .on('tick', tick);
  15256. // define arrow markers for graph links
  15257. svg.append('svg:defs').append('svg:marker')
  15258. .attr('id', 'end-arrow')
  15259. .attr('viewBox', '0 -5 10 10')
  15260. .attr('refX', 6)
  15261. .attr('markerWidth', 3)
  15262. .attr('markerHeight', 3)
  15263. .attr('orient', 'auto')
  15264. .append('svg:path')
  15265. .attr('d', 'M0,-5L10,0L0,5')
  15266. .attr('fill', '#000');
  15267. svg.append('svg:defs').append('svg:marker')
  15268. .attr('id', 'start-arrow')
  15269. .attr('viewBox', '0 -5 10 10')
  15270. .attr('refX', 4)
  15271. .attr('markerWidth', 3)
  15272. .attr('markerHeight', 3)
  15273. .attr('orient', 'auto')
  15274. .append('svg:path')
  15275. .attr('d', 'M10,-5L0,0L10,5')
  15276. .attr('fill', '#000');
  15277. // line displayed when dragging new nodes
  15278. var drag_line = svg.append('svg:path')
  15279. .attr('class', 'link dragline hidden')
  15280. .attr('d', 'M0,0L0,0');
  15281. // handles to link and node element groups
  15282. //(1)var path = svg.append('svg:g').selectAll('g')
  15283. var path = svg.append('svg:g').selectAll('g'),
  15284. circle = svg.append('svg:g').selectAll('g');
  15285. */
  15286. // mouse event vars
  15287. var selected_node = null,
  15288. selected_link = null,
  15289. mousedown_link = null,
  15290. mousedown_node = null,
  15291. mouseup_node = null;
  15292. function resetMouseVars() {
  15293. mousedown_node = null;
  15294. mouseup_node = null;
  15295. mousedown_link = null;
  15296. }
  15297. // update force layout (called automatically each iteration)
  15298. function tick() {
  15299. // draw directed edges with proper padding from node centers
  15300. path.selectAll('path').attr('d', function (d) {
  15301. var deltaX = d.target.x - d.source.x,
  15302. deltaY = d.target.y - d.source.y,
  15303. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  15304. normX = deltaX / dist,
  15305. normY = deltaY / dist,
  15306. sourcePadding = d.left ? 27 : 22,
  15307. targetPadding = d.right ? 27 : 22,
  15308. sourceX = d.source.x + (sourcePadding * normX),
  15309. sourceY = d.source.y + (sourcePadding * normY),
  15310. targetX = d.target.x - (targetPadding * normX),
  15311. targetY = d.target.y - (targetPadding * normY);
  15312. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  15313. });
  15314. circle.attr('transform', function (d) {
  15315. return 'translate(' + d.x + ',' + d.y + ')';
  15316. });
  15317. }
  15318. // update graph (called when needed)
  15319. function restart() {
  15320. //绑定link 数据
  15321. path.datum(links);
  15322. // path (link) group
  15323. path = path.data(links, function (d) {
  15324. return d.id;
  15325. });
  15326. var p = path.enter().append('svg:g');
  15327. //update existing links
  15328. path.selectAll('path').classed('selected', function (d) {
  15329. return d === selected_link;
  15330. })
  15331. .style('marker-start', function (d) {
  15332. return d.left ? 'url(#start-arrow)' : '';
  15333. })
  15334. .style('marker-end', function (d) {
  15335. return d.right ? 'url(#end-arrow)' : '';
  15336. });
  15337. // add new links
  15338. p.append('svg:path')
  15339. .attr('class', 'link')
  15340. .attr('id', function (d) {
  15341. return "path_" + d.id;
  15342. })
  15343. // .attr('startOffset', '0%')
  15344. .classed('selected', function (d) {
  15345. return d === selected_link;
  15346. })
  15347. .style('marker-start', function (d) {
  15348. return d.left ? 'url(#start-arrow)' : '';
  15349. })
  15350. .style('marker-end', function (d) {
  15351. return d.right ? 'url(#end-arrow)' : '';
  15352. })
  15353. .on('mousedown', function (d) {
  15354. if (d3.event.ctrlKey) return;
  15355. //去除没有提交的连线
  15356. for (var i = 0; i < links.length; i++) {
  15357. if (links[i].id == -1 && d.id != -1) {
  15358. links.splice(i, 1);
  15359. }
  15360. }
  15361. // select link
  15362. mousedown_link = d;
  15363. if (mousedown_link === selected_link) {
  15364. selected_link = $scope.selected_link = null;
  15365. selected_node = $scope.selected_node = null;
  15366. // d3.select("#linkDetail").attr('style','display:none');
  15367. //hideLinkForm(true);//return ;
  15368. } else {
  15369. selected_link = $scope.selected_link = mousedown_link;
  15370. selected_node = $scope.selected_node = null;
  15371. }
  15372. selected_node = $scope.selected_node = null;
  15373. restart();
  15374. });
  15375. p.append('svg:text')
  15376. .attr('x', 30)
  15377. .attr('y', 20)
  15378. .attr('class', 'fontM')
  15379. .append('textPath')
  15380. .attr('xlink:xlink:href', function (d, i) {
  15381. return "#path_" + d.id;
  15382. })
  15383. .html(function (d) {
  15384. for (var i = 0; i < linkType.length; i++) {
  15385. if (linkType[i].type == d.name) {
  15386. return linkType[i].label;
  15387. }
  15388. }
  15389. });
  15390. // remove old links
  15391. path.exit().remove();
  15392. // circle (node) group
  15393. // NB: the function arg is crucial here! nodes are known by id, not by index!
  15394. circle.datum(nodes);
  15395. circle = circle.data(nodes, function (d) {
  15396. return d.id;
  15397. });
  15398. // update existing nodes (reflexive & selected visual states)
  15399. circle.selectAll('circle')
  15400. .style('fill', function (d) {
  15401. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15402. })
  15403. .style('fill-opacity', 0.75) // add by xi
  15404. .classed('reflexive', function (d) {
  15405. return d.reflexive;
  15406. });
  15407. // add new nodes
  15408. var g = circle.enter().append('svg:g');
  15409. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  15410. //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');
  15411. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  15412. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  15413. }).style('stroke', function (d) {
  15414. return d3.rgb(colors(d.label)).darker().toString();
  15415. }).style('stroke-width', '2');
  15416. g.append('svg:circle')
  15417. .attr('class', 'node')
  15418. .attr('r', 18)
  15419. .style('fill', function (d) {
  15420. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15421. })
  15422. .style('stroke', function (d) {
  15423. return d3.rgb(colors(d.label)).darker().toString();
  15424. })
  15425. .style('fill-opacity', 0.25) //add by xj
  15426. .style('stroke-opacity', 0.5) //add by xj
  15427. .classed('reflexive', function (d) {
  15428. return d.reflexive;
  15429. });
  15430. g.on('mouseover', function (d) {
  15431. //if(!mousedown_node || d === mousedown_node) return;
  15432. // enlarge target node
  15433. //d3.select(this).attr('transform', 'scale(1.1)');
  15434. })
  15435. .on('mouseout', function (d) {
  15436. //if(!mousedown_node || d === mousedown_node) return;
  15437. // unenlarge target node
  15438. //d3.select(this).attr('transform', '');
  15439. })
  15440. .on('mousedown', function (d) {
  15441. if (d3.event.ctrlKey) return;
  15442. //hideLinkForm(true);
  15443. //去除没有提交的连线
  15444. for (var i = 0; i < links.length; i++) {
  15445. if (links[i].id == -1) {
  15446. links.splice(i, 1);
  15447. }
  15448. }
  15449. // select node
  15450. mousedown_node = d;
  15451. if (mousedown_node === selected_node) {
  15452. selected_node = $scope.selected_node = null;
  15453. } else {
  15454. selected_node = $scope.selected_node = mousedown_node;
  15455. selected_link = $scope.selected_link = null;
  15456. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  15457. APIService.findRefById(selected_node.id).then(function (result) {
  15458. var d = result.data;
  15459. var node = d.node;
  15460. var link = d.edge;
  15461. var tempNode = [];
  15462. var tempLink = [];
  15463. //nodes 或者links 要去重
  15464. for (var i = 0; i < node.length; i++) {
  15465. var tmp = 0;
  15466. for (var j = 0; j < nodes.length; j++) {
  15467. if (node[i].id == nodes[j].id) {
  15468. tmp++;
  15469. break;
  15470. }
  15471. }
  15472. if (tmp == 0) {
  15473. tempNode.push(node[i]);
  15474. }
  15475. }
  15476. for (var i = 0; i < link.length; i++) {
  15477. var tmp = 0;
  15478. for (var j = 0; j < links.length; j++) {
  15479. if (link[i].id == links[j].id) {
  15480. tmp++;
  15481. break;
  15482. }
  15483. }
  15484. if (tmp == 0) {
  15485. tempLink.push(link[i]);
  15486. }
  15487. }
  15488. //数据写入页面
  15489. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15490. nodes.push(tempNode[i]);
  15491. }
  15492. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15493. links.push(tempLink[i]);
  15494. }
  15495. //links转换
  15496. for (var i = 0; i < links.length; i++) {
  15497. for (var j = 0; j < nodes.length; j++) {
  15498. if (links[i].source == nodes[j].id) {
  15499. links[i].source = nodes[j];
  15500. }
  15501. if (links[i].target == nodes[j].id) {
  15502. links[i].target = nodes[j];
  15503. }
  15504. }
  15505. }
  15506. restart();
  15507. });
  15508. }
  15509. // reposition drag line
  15510. drag_line
  15511. .style('marker-end', 'url(#end-arrow)')
  15512. .classed('hidden', false)
  15513. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  15514. restart();
  15515. })
  15516. .on('mouseup', function (d) {
  15517. if (!mousedown_node) return;
  15518. });
  15519. // show node name
  15520. g.append('svg:text')
  15521. .attr('x', 0)
  15522. .attr('y', 34)
  15523. .attr('class', 'id')
  15524. .text(function (d) {
  15525. return d.name;
  15526. }); //TODO 改为 d.name
  15527. //设置图片
  15528. g.append('svg:foreignObject')
  15529. .attr("width", 32)
  15530. .attr("height", 32)
  15531. .attr('x', "-16px")
  15532. .attr('y', "-11px")
  15533. .html(function (d) {
  15534. for (var i = 0; i < labels.length; i++) {
  15535. if (d.label == labels[i].sign) {
  15536. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  15537. }
  15538. }
  15539. });
  15540. // remove old nodes
  15541. circle.exit().remove();
  15542. // set the graph in motion
  15543. force.start();
  15544. }
  15545. function mousedown() {
  15546. // prevent I-bar on drag
  15547. //d3.event.preventDefault();
  15548. // because :active only works in WebKit?
  15549. svg.classed('active', true);
  15550. if (mousedown_node) {
  15551. viewNode(mousedown_node);
  15552. }
  15553. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  15554. restart();
  15555. }
  15556. function mousemove() {
  15557. if (!mousedown_node) return;
  15558. // update drag line
  15559. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  15560. //restart();
  15561. }
  15562. function mouseup() {
  15563. if (mousedown_node) {
  15564. // hide drag line
  15565. drag_line
  15566. .classed('hidden', true)
  15567. .style('marker-end', '');
  15568. }
  15569. // because :active only works in WebKit?
  15570. svg.classed('active', false);
  15571. // clear mouse event vars
  15572. resetMouseVars();
  15573. }
  15574. function spliceLinksForNode(node) {
  15575. var toSplice = links.filter(function (l) {
  15576. return (l.source === node || l.target === node);
  15577. });
  15578. toSplice.map(function (l) {
  15579. links.splice(links.indexOf(l), 1);
  15580. });
  15581. }
  15582. // only respond once per keydown
  15583. var lastKeyDown = -1;
  15584. function keydown() {
  15585. //d3.event.preventDefault();
  15586. if (lastKeyDown !== -1) return;
  15587. lastKeyDown = d3.event.keyCode;
  15588. // ctrl
  15589. if (d3.event.keyCode === 17) {
  15590. circle.call(force.drag);
  15591. svg.classed('ctrl', true);
  15592. }
  15593. if (!selected_node && !selected_link) return;
  15594. switch (d3.event.keyCode) {
  15595. case 8: // backspace
  15596. case 66: // B
  15597. if (selected_link) {
  15598. // set link direction to both left and right
  15599. selected_link.left = true;
  15600. selected_link.right = true;
  15601. }
  15602. restart();
  15603. break;
  15604. case 76: // L
  15605. if (selected_link) {
  15606. // set link direction to left only
  15607. selected_link.left = true;
  15608. selected_link.right = false;
  15609. }
  15610. restart();
  15611. break;
  15612. case 82: // R
  15613. if (selected_node) {
  15614. // toggle node reflexivity
  15615. selected_node.reflexive = !selected_node.reflexive;
  15616. } else if (selected_link) {
  15617. // set link direction to right only
  15618. selected_link.left = false;
  15619. selected_link.right = true;
  15620. }
  15621. restart();
  15622. break;
  15623. }
  15624. }
  15625. function keyup() {
  15626. lastKeyDown = -1;
  15627. // ctrl
  15628. if (d3.event.keyCode === 17) {
  15629. circle
  15630. .on('mousedown.drag', null)
  15631. .on('touchstart.drag', null);
  15632. svg.classed('ctrl', false);
  15633. }
  15634. }
  15635. function viewNode(node) {
  15636. // console.log(svg.attr('left'));
  15637. //var el = angular.element('div.modal-dialog')[0];
  15638. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  15639. if (!$scope.selected_node.props.state) {
  15640. $scope.selected_node.props.state = "空"
  15641. } else if ($scope.selected_node.props.state) {
  15642. if ($scope.selected_node.props.state == "1") {
  15643. $scope.selected_node.props.state = "未审核"
  15644. } else if ($scope.selected_node.props.state == "2") {
  15645. $scope.selected_node.props.state = "已审核"
  15646. } else if ($scope.selected_node.props.state == "3") {
  15647. $scope.selected_node.props.state = "不匹配"
  15648. } else if ($scope.selected_node.props.state == "4") {
  15649. $scope.selected_node.props.state = "丢失"
  15650. }
  15651. };
  15652. if (!$scope.selected_node.name) {
  15653. $scope.selected_node.name = "空"
  15654. }
  15655. if (!$scope.selected_node.status) {
  15656. $scope.selected_node.statu = "空"
  15657. }
  15658. if (!$scope.selected_node.props.useradmin) {
  15659. $scope.selected_node.props.useradmin = "空"
  15660. }
  15661. Toaster.pop({
  15662. // type: 'info',
  15663. // title: title,
  15664. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  15665. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  15666. '<p>状态:' + $scope.selected_node.status + '</p>' +
  15667. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  15668. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  15669. bodyOutputType: 'trustedHtml',
  15670. timeout: 3000
  15671. })
  15672. }
  15673. //GT 颜色与数值对照表
  15674. function colors(sign) {
  15675. //num=num>20?num%20:parseInt(num);
  15676. for (var i = 0; i < labels.length; i++) {
  15677. var entity = labels[i];
  15678. if (sign == entity.sign) {
  15679. return entity.color;
  15680. }
  15681. if (i == labels.length - 1 && sign != entity.sign) {
  15682. return '#ffeeee';
  15683. }
  15684. }
  15685. }
  15686. $scope.init = function () {
  15687. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15688. // init D3 force layout
  15689. force = d3.layout.force()
  15690. .nodes(nodes)
  15691. .links(links)
  15692. .size([width, height])
  15693. .gravity(.05)
  15694. .linkDistance(150)
  15695. .linkStrength(2)
  15696. .charge(-500)
  15697. .on('tick', tick);
  15698. // define arrow markers for graph links
  15699. svg.append('svg:defs').append('svg:marker')
  15700. .attr('id', 'end-arrow')
  15701. .attr('viewBox', '0 -5 10 10')
  15702. .attr('refX', 6)
  15703. .attr('markerWidth', 3)
  15704. .attr('markerHeight', 3)
  15705. .attr('orient', 'auto')
  15706. .append('svg:path')
  15707. .attr('d', 'M0,-5L10,0L0,5')
  15708. .attr('fill', '#000');
  15709. svg.append('svg:defs').append('svg:marker')
  15710. .attr('id', 'start-arrow')
  15711. .attr('viewBox', '0 -5 10 10')
  15712. .attr('refX', 4)
  15713. .attr('markerWidth', 3)
  15714. .attr('markerHeight', 3)
  15715. .attr('orient', 'auto')
  15716. .append('svg:path')
  15717. .attr('d', 'M10,-5L0,0L10,5')
  15718. .attr('fill', '#000');
  15719. // line displayed when dragging new nodes
  15720. drag_line = svg.append('svg:path')
  15721. .attr('class', 'link dragline hidden')
  15722. .attr('d', 'M0,0L0,0');
  15723. // handles to link and node element groups
  15724. //(1)var path = svg.append('svg:g').selectAll('g')
  15725. path = svg.append('svg:g').selectAll('g');
  15726. circle = svg.append('svg:g').selectAll('g');
  15727. svg.on('mousedown', mousedown)
  15728. .on('mousemove', mousemove)
  15729. .on('mouseup', mouseup);
  15730. d3.select(window)
  15731. .on('keydown', keydown)
  15732. .on('keyup', keyup);
  15733. }
  15734. var CI = {};
  15735. window.CI = CI;
  15736. $scope.ok = function () {
  15737. $modalInstance.close($scope.selected_node);
  15738. };
  15739. $scope.cancel = function () {
  15740. $modalInstance.dismiss('cancel');
  15741. };
  15742. },
  15743. size: size,
  15744. resolve: {
  15745. title: function () {
  15746. return options.templateOptions.title;
  15747. },
  15748. Restangular: function () {
  15749. return options.templateOptions.Restangular;
  15750. },
  15751. APIService: function () {
  15752. return options.templateOptions.ApiService;
  15753. },
  15754. ConfigDataService: function () {
  15755. return options.templateOptions.ConfigDataService;
  15756. },
  15757. ConfigFormService: function () {
  15758. return options.templateOptions.ConfigFormService;
  15759. },
  15760. SweetAlert: function () {
  15761. return options.templateOptions.Alert;
  15762. },
  15763. Toaster: function () {
  15764. return options.templateOptions.toaster;
  15765. }
  15766. }
  15767. });
  15768. modalInstance.result.then(function (selectedItem) {
  15769. options.value(selectedItem.name + '-' + selectedItem.uuid);
  15770. }, function () {
  15771. //console.log('Modal dismissed at: ' + new Date());
  15772. });
  15773. }
  15774. }
  15775. }
  15776. },
  15777. controller: ['$scope', function ($scope) {
  15778. // setTimeout(function(){
  15779. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  15780. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  15781. // if(modelData.status==200){
  15782. // $scope.model[$scope.options.key] = modelData.data;
  15783. // $scope.options.initialValue = $scope.model[$scope.options.key];
  15784. // }
  15785. // });
  15786. // },1000);
  15787. }]
  15788. });
  15789. });
  15790. appFormly.run(function (formlyConfig, $parse) {
  15791. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  15792. var removeOnHideTransformer = function (fields, model) {
  15793. return fields.map(function (field) {
  15794. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  15795. addFieldRemoveOnHideWatcher(field);
  15796. }
  15797. if (field.type == "ui-title") {
  15798. addFieldRemoveOnHideWatcher(field);
  15799. }
  15800. return field;
  15801. });
  15802. };
  15803. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  15804. function addFieldRemoveOnHideWatcher(field) {
  15805. var watcher = getWatcher();
  15806. if (field.watcher) {
  15807. if (!angular.isArray(field.watcher)) {
  15808. field.watcher = [field.watcher];
  15809. }
  15810. field.watcher.push(watcher);
  15811. } else {
  15812. field.watcher = watcher;
  15813. }
  15814. }
  15815. function getWatcher() {
  15816. return {
  15817. expression: function (field) {
  15818. return field.hide;
  15819. },
  15820. listener: function (field, newHide, oldHide, scope) {
  15821. if (field.hide) {
  15822. if (field.templateOptions.pkey) {
  15823. if (field.key == 'transferuser') {
  15824. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  15825. }
  15826. } else {
  15827. $parse(field.key).assign(scope.model, undefined);
  15828. }
  15829. }
  15830. if (field.type == "ui-title") {
  15831. $parse(field.key).assign(scope.model, undefined);
  15832. }
  15833. }
  15834. };
  15835. }
  15836. });
  15837. appFormly.controller('CustomformCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'Restangular', 'UserRestangular', 'BpmRestangular', 'WechatRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_statistic', 'up_down_file', 'fileReader',
  15838. function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, Restangular, UserRestangular, BpmRestangular, WechatRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, api_statistic, up_down_file, fileReader) {
  15839. //console.log($parse('Restangular')($scope));
  15840. //console.log($injector.get('Restangular'));
  15841. //console.log($stateParams);
  15842. //保存报修主体
  15843. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15844. $scope.imgUrlList = [];
  15845. $scope.uploadimg_del = function () {
  15846. console.log(123)
  15847. };
  15848. var vm = this;
  15849. vm.options = {};
  15850. vm.exampleTitle = ['expressionProperties', 'model property'];
  15851. vm.fields = [];
  15852. vm.model = {};
  15853. $scope.langs = i18nService.getAllLangs();
  15854. $scope.lang = 'zh-cn';
  15855. i18nService.setCurrentLang($scope.lang);
  15856. //alert($rootScope.user.id,null,2);
  15857. vm.model["loginUser"] = $rootScope.user;
  15858. var loginUser = $rootScope.user;
  15859. // console.log(vm);
  15860. var that = $injector;
  15861. var parse = $parse;
  15862. var formKey = "";
  15863. var pdKey = "";
  15864. var modelWatch = "";
  15865. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  15866. modelWatch = JSON.parse($stateParams.model);
  15867. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  15868. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  15869. console.log(modelWatch,$rootScope)
  15870. // if(modelWatch.model.incident){
  15871. // if(modelWatch.model.incident.place){
  15872. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  15873. // }else{
  15874. // $rootScope.selecthouseNumber = undefined;
  15875. // }
  15876. // }
  15877. }
  15878. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  15879. pdKey = $state.current.pdKey;
  15880. } else if ($stateParams.pdKey) {
  15881. pdKey = $stateParams.pdKey;
  15882. }
  15883. // console.log("pdKey::" + JSON.stringify($state.current.title));
  15884. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  15885. formKey = $stateParams.formKey;
  15886. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  15887. }
  15888. if (angular.isDefined($stateParams.model)) {
  15889. var formModel = $stateParams.model;
  15890. }
  15891. //用户测试数据,后续从header的auth中获取
  15892. var userId = 2;
  15893. userId = $rootScope.user.id;
  15894. //==============处理表单设计数据 开始====================
  15895. //处理组件加载后台数据选项的方法
  15896. function refreshSelectOptions(searchVal, field) {
  15897. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  15898. var process = BpmRestangular.all("");
  15899. if (field.templateOptions.ApiService) {
  15900. process = UserRestangular.all("");
  15901. }
  15902. if (field.templateOptions.Apicommon) {
  15903. process = WechatRestangular.all("");
  15904. }
  15905. var datakey = {
  15906. "idx": 0,
  15907. "sum": 1000
  15908. };
  15909. if (field.templateOptions.modelreasondata) {
  15910. datakey = field.templateOptions.modelreasondata
  15911. }
  15912. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  15913. if (!field.templateOptions.options) {
  15914. field.templateOptions.options = [];
  15915. }
  15916. if (field.templateOptions.optionsDataKey) {
  15917. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  15918. } else {
  15919. field.templateOptions.options = result;
  15920. }
  15921. });
  15922. }
  15923. }
  15924. //获取表单后数据处理
  15925. function formfield(field, result) {
  15926. // angular.forEach(fields.fields, function(field) {
  15927. if (field.key == "") {
  15928. delete field.key;
  15929. }
  15930. if (angular.isDefined(field.extjson)) {
  15931. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  15932. angular.extend(field.templateOptions, extObj.templateOptions);
  15933. delete extObj.templateOptions;
  15934. for (var prop in extObj) {
  15935. if (new RegExp("Expression").test(prop)) {
  15936. //var obj = $scope.$eval(extObj[prop]);
  15937. //extObj[prop] = $scope.$eval(extObj[prop]);
  15938. if (extObj[prop] != null) {
  15939. if (new RegExp("function").test(extObj[prop])) {
  15940. var propValue = eval(extObj[prop]);
  15941. extObj[prop] = propValue;
  15942. } else {
  15943. //console.log(extObj[prop]);
  15944. var obj = $scope.$eval(extObj[prop]);
  15945. extObj[prop] = obj;
  15946. //console.log(obj);
  15947. }
  15948. }
  15949. } else if (new RegExp("expressionProperties").test(prop)) {
  15950. for (var p in extObj[prop]) {
  15951. if (new RegExp("function").test(extObj[prop][p])) {
  15952. var propValue = eval(extObj[prop][p]);
  15953. extObj[prop][p] = propValue;
  15954. } else {
  15955. //if(p.indexOf("'")>=0){
  15956. // var obj = $scope.$eval(extObj[prop][p]);
  15957. // extObj[prop][$scope.$eval(p)]=obj;
  15958. //}
  15959. }
  15960. }
  15961. } else if ("watcher" == prop) {
  15962. if (angular.isArray(extObj[prop])) {
  15963. angular.forEach(extObj[prop], function (item, index) {
  15964. for (var p in item) {
  15965. if (new RegExp("function").test(item[p])) {
  15966. var propValue = eval(item[p]);
  15967. extObj[prop][index][p] = propValue;
  15968. }
  15969. }
  15970. });
  15971. } else if (angular.isObject(extObj[prop])) {
  15972. for (var p in extObj[prop]) {
  15973. if (new RegExp("function").test(extObj[prop][p])) {
  15974. var propValue = eval(extObj[prop][p]);
  15975. extObj[prop][p] = propValue;
  15976. }
  15977. }
  15978. }
  15979. }
  15980. }
  15981. angular.extend(field, extObj);
  15982. delete field.extjson;
  15983. }
  15984. if (angular.isDefined(field.templateOptions)) {
  15985. var templateOs = field.templateOptions;
  15986. // console.log(templateOs,'come')
  15987. for (var property in templateOs) {
  15988. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  15989. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  15990. if (new RegExp("function").test(templateOs[property])) {
  15991. var propValue = eval(templateOs[property]);
  15992. field.templateOptions[property] = propValue;
  15993. } else {
  15994. if (that.has(templateOs[property])) {
  15995. field.templateOptions[property] = that.get(templateOs[property]);
  15996. } else {
  15997. field.templateOptions[property] = templateOs[property];
  15998. }
  15999. }
  16000. } else if (templateOs[property] == null) {
  16001. //delete field.templateOptions[property];
  16002. } else { }
  16003. }
  16004. }
  16005. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  16006. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  16007. angular.extend(field.templateOptions, extObj);
  16008. delete field.templateOptions.extjson;
  16009. }
  16010. // ...
  16011. if (field.templateOptions) {
  16012. //处理远程获取数据控件方法调用
  16013. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  16014. // if (!field.templateOptions.isnoreash) {
  16015. field.templateOptions.refresh = refreshSelectOptions;
  16016. // }
  16017. }
  16018. //处理嵌套属性数据绑定/
  16019. if (field.templateOptions.pkey) {
  16020. var pmodel, i = 0;
  16021. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  16022. if (i == 0) {
  16023. if (result.model[p] == null) {
  16024. result.model[p] = {};
  16025. }
  16026. pmodel = result.model[p];
  16027. i++;
  16028. } else {
  16029. if (pmodel[p] == null) {
  16030. pmodel[p] = {};
  16031. }
  16032. pmodel = pmodel[p];
  16033. }
  16034. });
  16035. if (pmodel != null) {
  16036. field.model = pmodel;
  16037. if (pmodel[field.key] == null) {
  16038. pmodel[field.key] = null;
  16039. }
  16040. }
  16041. } else {
  16042. if (result.model[field.key] == null) {
  16043. result.model[field.key] = null;
  16044. }
  16045. }
  16046. //处理弹出框组件初始化
  16047. if (field.type == "ui-input-selectmodal") {
  16048. field.templateOptions.modal = $modal;
  16049. //field.templateOptions.Restangular = Restangular;
  16050. } else if (field.type == "ui-requesterselect") {
  16051. //field.templateOptions.language = $scope.lang;
  16052. field.templateOptions.modal = $modal;
  16053. field.templateOptions.UserService = api_user_data;
  16054. } else if (field.type == "ui-deptinformation") {
  16055. field.templateOptions.modal = $modal;
  16056. field.templateOptions.UserService = api_user_data;
  16057. } else if (field.type == "ui-requesterinformation") {
  16058. field.templateOptions.modal = $modal;
  16059. field.templateOptions.UserService = api_user_data;
  16060. } else if (field.type == "ui-userselect") {
  16061. field.templateOptions.modal = $modal;
  16062. //field.templateOptions.Restangular = Restangular;
  16063. } else if (field.type == "ui-userselectSearch") {
  16064. field.templateOptions.modal = $modal;
  16065. //field.templateOptions.Restangular = Restangular;
  16066. } else if (field.type == "ui-multiuserselect") {
  16067. field.templateOptions.modal = $modal;
  16068. } else if (field.type == "ui-stringuserselect") {
  16069. field.templateOptions.modal = $modal;
  16070. } else if (field.type == "ui-search") {
  16071. field.templateOptions.modal = $modal;
  16072. } else if (field.type == "ui-modelselect") {
  16073. field.templateOptions.modal = $modal;
  16074. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16075. field.templateOptions.loginUser = $rootScope.user;
  16076. //field.templateOptions.Restangular = Restangular;
  16077. } else if (field.type == "ui-incidentmodelselect") {
  16078. field.templateOptions.modal = $modal;
  16079. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16080. field.templateOptions.loginUser = $rootScope.user;
  16081. //field.templateOptions.Restangular = Restangular;
  16082. } else if (field.type == "ui-dropfile") {
  16083. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16084. url: '/uploader'
  16085. });
  16086. field.templateOptions.taskId = $stateParams.taskId;
  16087. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16088. field.templateOptions.userId = $rootScope.user.id;
  16089. } else if (field.type == "ui-dropfielknow") {
  16090. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16091. url: '/uploader'
  16092. });
  16093. field.templateOptions.taskId = $stateParams.taskId;
  16094. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16095. field.templateOptions.userId = $rootScope.user.id;
  16096. } else if (field.type == "ui-upDropFile") {
  16097. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16098. url: '/uploader'
  16099. });
  16100. field.templateOptions.taskId = $stateParams.taskId;
  16101. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16102. field.templateOptions.userId = $rootScope.user.id;
  16103. } else if (field.type == "ui-dropfilenotup") {
  16104. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16105. url: '/uploader'
  16106. });
  16107. field.templateOptions.taskId = $stateParams.taskId;
  16108. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16109. field.templateOptions.userId = $rootScope.user.id;
  16110. //field.ApiService=api_bpm_domain;
  16111. } else if (field.type == "ui-uploadFiles") {
  16112. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16113. url: '/uploader'
  16114. });
  16115. field.templateOptions.taskId = $stateParams.taskId;
  16116. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16117. field.templateOptions.userId = $rootScope.user.id;
  16118. //field.ApiService=api_bpm_domain;
  16119. } else if (field.type == "ui-upDownFiles") {
  16120. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16121. url: '/uploader'
  16122. });
  16123. field.templateOptions.taskId = $stateParams.taskId;
  16124. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16125. field.templateOptions.userId = $rootScope.user.id;
  16126. //field.ApiService=api_bpm_domain;
  16127. } else if (field.type == "ui-uploadImgs") {
  16128. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16129. url: '/uploader'
  16130. });
  16131. field.templateOptions.taskId = $stateParams.taskId;
  16132. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16133. field.templateOptions.userId = $rootScope.user.id;
  16134. //field.ApiService=api_bpm_domain;
  16135. } else if (field.type == "ui-dropfiletable") {
  16136. if (field.templateOptions.processInstanceId) {
  16137. } else {
  16138. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16139. }
  16140. } else if (field.type == "ui-dropFiles") {
  16141. if (field.templateOptions.processInstanceId) {
  16142. } else {
  16143. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16144. }
  16145. } else if (field.type == "ui-showImgs") {
  16146. if (field.templateOptions.processInstanceId) {
  16147. } else {
  16148. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16149. }
  16150. } else if (field.type == "ui-repeatSection") {
  16151. var repeatForm = {
  16152. model: {
  16153. },
  16154. fields: field.templateOptions.fields
  16155. };
  16156. repeatForm.model[field.key] = [];
  16157. decodeVMForm(repeatForm);
  16158. } else if (field.type == "ui-currentuser") {
  16159. field.templateOptions.user = vm.model["loginUser"];
  16160. } else if (field.type == "ui-workernumbersign") {
  16161. field.templateOptions.user = vm.model["loginUser"];
  16162. } else if (field.type == "ui-repair-photos") {
  16163. field.templateOptions.user = vm.model["loginUser"];
  16164. }
  16165. }
  16166. }
  16167. //解析自定义表单设计数据
  16168. $scope.oldfromtype = true;
  16169. function decodeVMForm(vmForm) {
  16170. if (vmForm.formType == "1") {
  16171. $scope.oldfromtype = false;
  16172. } else {
  16173. $scope.oldfromtype = true;
  16174. }
  16175. var result = {
  16176. model: {},
  16177. fields: []
  16178. };
  16179. //设置模型实体数据 begin
  16180. // var mdata = vmForm.model;
  16181. //解析数据实体
  16182. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  16183. angular.extend(result.model, mdata);
  16184. if (modelWatch != null && modelWatch != '') {
  16185. //angular.extend(result.model.incident,modelWatch.incident);
  16186. //result.model.alarmType = modelWatch.alarmType;
  16187. // vmForm.cancelUrl = modelWatch.cancelUrl;
  16188. // console.log(modelWatch.cancelUrl)
  16189. for (var index in modelWatch.model) {
  16190. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  16191. if (result.model[index] != null) {
  16192. angular.extend(result.model[index], modelWatch.model[index]);
  16193. } else {
  16194. result.model[index] = modelWatch.model[index];
  16195. }
  16196. }
  16197. }
  16198. //设置模型实体数据 end
  16199. //解析设计数据生成表单项 begin
  16200. var fields = [];
  16201. //处理修改设计数据中展示设置
  16202. angular.forEach(vmForm.fields, function (fields) {
  16203. if (vmForm.formType == "1") {
  16204. angular.forEach(fields.fields, function (field) {
  16205. formfield(field, result);
  16206. });
  16207. } else {
  16208. formfield(fields, result);
  16209. }
  16210. // console.log(field);
  16211. result.fields.push(fields);
  16212. });
  16213. angular.extend($scope.vm.fields, result.fields);
  16214. angular.extend($scope.vm.model, result.model);
  16215. vm.model["loginUser"] = $rootScope.user;
  16216. //增加识别报修主体seimin
  16217. vm.model.repairType = $scope.repairMain.valueconfig;
  16218. if(vm.model.incident){
  16219. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  16220. }
  16221. console.log(vm, 'repairType')//lmm
  16222. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  16223. vmForm.cancelUrl = modelWatch.cancelUrl;
  16224. }
  16225. $scope.formData = vmForm;
  16226. console.log($scope.formData,4444444)
  16227. // console.log($scope.formData.url);
  16228. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  16229. if ($scope.formData.url == "start") {
  16230. $scope.Reset = true;
  16231. $scope.close = true;
  16232. $rootScope.isMask = false;
  16233. } else if ($scope.formData.url == "complete") {
  16234. $scope.Reset = false;
  16235. $scope.close = true;
  16236. }
  16237. //解析设计数据生成表单项 end
  16238. return result;
  16239. }
  16240. //======================处理表单设计数据 结束========================
  16241. $scope.ldloading = {};
  16242. function filter(obj) {
  16243. angular.forEach(obj, function (key, value) {
  16244. if (value === "" || value === null) {
  16245. delete obj[key];
  16246. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  16247. filter(value);
  16248. } else if (angular.isArray(value)) {
  16249. angular.forEach(value, function (item) {
  16250. filter(item);
  16251. });
  16252. }
  16253. });
  16254. }
  16255. $scope.closeModel = function () {
  16256. // console.log($stateParams);
  16257. $state.go($scope.formData.cancelUrl, {});
  16258. event.preventDefault();
  16259. };
  16260. // console.log(vm);
  16261. // 暂存
  16262. $scope.save = function (data) {
  16263. console.log(vm)
  16264. if (vm.model.startSave) {
  16265. vm.model["initUser"] = $rootScope.user.id;
  16266. vm.model.start_code = "temporary";
  16267. //处理请求数据0327
  16268. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16269. delete data0327.repairType;
  16270. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16271. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16272. data0327.incident.place = {
  16273. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16274. }
  16275. }
  16276. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16277. if (response) {
  16278. var resData = Restangular.stripRestangular(response);
  16279. if (resData) {
  16280. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16281. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16282. angular.extend(item.headers, $rootScope.getSession());
  16283. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16284. item.formData.push({
  16285. 'fileName': item.file.name
  16286. });
  16287. //console.log();
  16288. };
  16289. $scope.fileUploader.uploadAll();
  16290. }
  16291. }
  16292. SweetAlert.swal({
  16293. title: "提交成功!",
  16294. type: "success",
  16295. confirmButtonColor: "#007AFF"
  16296. }, function () {
  16297. $state.go($scope.formData.cancelUrl);
  16298. });
  16299. } else {
  16300. SweetAlert.swal({
  16301. title: "系统错误",
  16302. text: "系统错误,请稍后重试!",
  16303. type: "error",
  16304. confirmButtonColor: "#DD6B55"
  16305. });
  16306. }
  16307. $scope.ldloading[style.replace('-', '_')] = false;
  16308. });
  16309. event.preventDefault();
  16310. } else if (vm.model.saveAgain) {
  16311. var toData = {
  16312. "incident": vm.model.incident
  16313. };
  16314. api_user_data.updData("incident", toData).then(function (response) {
  16315. if (response) {
  16316. var resData = Restangular.stripRestangular(response);
  16317. SweetAlert.swal({
  16318. title: "提交成功!",
  16319. type: "success",
  16320. confirmButtonColor: "#007AFF"
  16321. }, function () {
  16322. $state.go($scope.formData.cancelUrl);
  16323. });
  16324. } else {
  16325. SweetAlert.swal({
  16326. title: "系统错误",
  16327. text: "系统错误,请稍后重试!",
  16328. type: "error",
  16329. confirmButtonColor: "#DD6B55"
  16330. });
  16331. }
  16332. $scope.ldloading[style.replace('-', '_')] = false;
  16333. });
  16334. event.preventDefault();
  16335. } else {
  16336. SweetAlert.swal({
  16337. title: "系统错误",
  16338. text: "系统错误,请稍后重试!",
  16339. type: "error",
  16340. confirmButtonColor: "#DD6B55"
  16341. });
  16342. }
  16343. }
  16344. // 巡检生成事件
  16345. $scope.inspectionToIncident = function () {
  16346. var userData = {
  16347. "idx": 0,
  16348. "sum": 10,
  16349. "requester": {
  16350. "name": loginUser.name
  16351. }
  16352. }
  16353. api_user_data.fetchDataList("requester", userData).then(function (res) {
  16354. console.log(res);
  16355. var toUser = {};
  16356. if (res.list.length > 0) {
  16357. toUser = res.list[0]
  16358. } else {
  16359. toUser = loginUser
  16360. }
  16361. console.log(vm);
  16362. var incidentDescription = "";
  16363. console.log($stateParams.formUiEdit);
  16364. if ($stateParams.formUiEdit == "inspection_confirm") {
  16365. if (vm.model.wnCheckEnable) {
  16366. incidentDescription = incidentDescription.concat(" 机房温度检查异常")
  16367. }
  16368. if (vm.model.sdCheckEnable) {
  16369. incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
  16370. }
  16371. if (vm.model.xfjCheckEnable) {
  16372. incidentDescription = incidentDescription.concat(" 新风机检查异常")
  16373. }
  16374. if (vm.model.lsCheckEnable) {
  16375. incidentDescription = incidentDescription.concat(" 漏水检查异常")
  16376. }
  16377. if (vm.model.xfCheckEnable) {
  16378. incidentDescription = incidentDescription.concat(" 消防检查异常")
  16379. }
  16380. if (vm.model.upsCheckEnable) {
  16381. incidentDescription = incidentDescription.concat(" UPS供电检查异常")
  16382. }
  16383. if (vm.model.dcCheckEnable) {
  16384. incidentDescription = incidentDescription.concat(" 电池连接检查异常")
  16385. }
  16386. if (vm.model.plCheckEnable) {
  16387. incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
  16388. }
  16389. if (vm.model.wjtdCheckEnable) {
  16390. incidentDescription = incidentDescription.concat(" 外机通道检查异常")
  16391. }
  16392. if (vm.model.descriptionTextarea) {
  16393. incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
  16394. }
  16395. }
  16396. // console.log(incidentDescription)
  16397. var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
  16398. var formdata = {
  16399. 'model': {
  16400. // 'isInspection': true,
  16401. // 'start_code':'assignment',
  16402. // 'isHandlerUser':false,
  16403. 'incident': {
  16404. 'requester':bxr ,
  16405. // 'area': data.incident.place.area,
  16406. // 'place': data.incident.place,
  16407. // 'houseNumber': data.incident.address,
  16408. 'contacts': bxr.name,
  16409. 'contactsInformation': bxr.mphone,
  16410. // 'category': data.wxIncidentClassifyDTO.category,
  16411. 'description': incidentDescription,
  16412. 'source': {
  16413. 'id': 1552
  16414. },
  16415. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  16416. // 'sourceType': data.incident.sourceType,
  16417. // 'fileUrl': data.incident.fileUrl
  16418. },
  16419. // 'requestershow': toUser,//2020年4月27日22:29:15
  16420. // 'flow': data.incident.id
  16421. // 'assignee': loginUser.id//2020年4月27日22:29:25
  16422. }
  16423. }
  16424. // console.log(formdata,toUser,'1111');
  16425. console.log(formdata,'1111');
  16426. // return;
  16427. $state.go("app.incident.chart", {
  16428. 'model': JSON.stringify(formdata)
  16429. });
  16430. })
  16431. // var formdata = {
  16432. // model:$rootScope.login_requester
  16433. // };
  16434. // console.log(formdata,'00000')
  16435. // return;
  16436. // $state.go("app.incident.chart", {
  16437. // 'model': JSON.stringify(formdata)
  16438. // });
  16439. event.preventDefault();
  16440. };
  16441. // console.log(vm);
  16442. // 创建事件seimin
  16443. vm.submit = function (data, style) {
  16444. console.log(vm,22222);
  16445. if (vm.model.handler_code == undefined) {
  16446. vm.model.handler_code = "resolve";
  16447. }
  16448. if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
  16449. delete vm.model.change.requestingPerson.menu;
  16450. }
  16451. // var pdKey = $stateParams.pdKey;
  16452. if (vm.form.$valid) {
  16453. if (data.incident && data.incident.synergetic) {
  16454. console.log(data.incident.synergetic);
  16455. var synergetic = [];
  16456. for (var i = 0; i < data.incident.synergetic.length; i++) {
  16457. synergetic.push({
  16458. id: data.incident.synergetic[i]
  16459. });
  16460. }
  16461. data.incident.synergetic = synergetic;
  16462. vm.model.incident.synergetic = synergetic;
  16463. }
  16464. $scope.ldloading[style.replace('-', '_')] = true;
  16465. var startsub = true;
  16466. if (pdKey == 'bpm_incident') {
  16467. angular.forEach(vm.fields, function (item) {
  16468. angular.forEach(item.fields, function (index) {
  16469. if (index.templateOptions.required && !index.hide) {
  16470. if (index.model) {
  16471. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  16472. if (index.model[index.key].id && index.model[index.key].id == '') {
  16473. startsub = false;
  16474. $scope.ldloading.expand_right = false;
  16475. SweetAlert.swal({
  16476. title: index.templateOptions.label + '未填',
  16477. text: "请填写此项!",
  16478. type: "error",
  16479. confirmButtonColor: "#DD6B55"
  16480. });
  16481. } else { }
  16482. } else {
  16483. startsub = false;
  16484. $scope.ldloading.expand_right = false;
  16485. SweetAlert.swal({
  16486. title: index.templateOptions.label + '未填',
  16487. text: "请填写此项!",
  16488. type: "error",
  16489. confirmButtonColor: "#DD6B55"
  16490. });
  16491. }
  16492. } else {
  16493. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  16494. } else {
  16495. startsub = false;
  16496. $scope.ldloading.expand_right = false;
  16497. SweetAlert.swal({
  16498. title: index.templateOptions.label + '未填',
  16499. text: "请填写此项!",
  16500. type: "error",
  16501. confirmButtonColor: "#DD6B55"
  16502. });
  16503. }
  16504. }
  16505. }
  16506. })
  16507. })
  16508. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  16509. // startsub = false;
  16510. // $scope.ldloading.expand_right = false;
  16511. // SweetAlert.swal({
  16512. // title: '保修人未填',
  16513. // text: "请填写此项!",
  16514. // type: "error",
  16515. // confirmButtonColor: "#DD6B55"
  16516. // });
  16517. // }
  16518. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  16519. // } else {
  16520. // startsub = false;
  16521. // $scope.ldloading.expand_right = false;
  16522. // SweetAlert.swal({
  16523. // title: '事件分类未填',
  16524. // text: "请填写此项!",
  16525. // type: "error",
  16526. // confirmButtonColor: "#DD6B55"
  16527. // });
  16528. // }
  16529. }
  16530. if (startsub) {
  16531. $scope.ldloading[style.replace('-', '_')] = true;
  16532. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  16533. // console.log("vm.options:"+ JSON.stringify(vm.options));
  16534. vm.options.updateInitialValue();
  16535. // console.log("dfjkasdhfkhskjf ")
  16536. var _ = window._;
  16537. vm.model = (function filter(obj) {
  16538. var dateTransKeys = [];
  16539. var filtered = _.pick(obj, function (v, k, obj) {
  16540. if (_.isDate(v)) {
  16541. dateTransKeys.push(k);
  16542. }
  16543. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  16544. });
  16545. return _.cloneDeep(filtered, function (v, index, object) {
  16546. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  16547. angular.forEach(dateTransKeys, function (item) {
  16548. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  16549. })
  16550. dateTransKey = [];
  16551. return v;
  16552. }
  16553. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  16554. });
  16555. })(vm.model);
  16556. if (pdKey != "") {
  16557. if ($scope.oprcode == "save") { //保存
  16558. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  16559. if (response) {
  16560. var resData = Restangular.stripRestangular(response);
  16561. SweetAlert.swal({
  16562. title: "保存成功!",
  16563. confirmButtonColor: "#007AFF"
  16564. }, function () {
  16565. $state.go($scope.formData.cancelUri);
  16566. });
  16567. // if(resData.status){
  16568. // resData
  16569. // }
  16570. } else {
  16571. SweetAlert.swal({
  16572. title: "系统错误",
  16573. text: "系统错误,请稍后重试!",
  16574. type: "error",
  16575. confirmButtonColor: "#DD6B55"
  16576. });
  16577. }
  16578. $scope.ldloading[style.replace('-', '_')] = false;
  16579. });
  16580. } else {
  16581. console.log($scope.formData.url,'zzzz')
  16582. switch ($scope.formData.url) {
  16583. case "start":
  16584. vm.model["initUser"] = $rootScope.user.id;
  16585. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  16586. } else {
  16587. vm.model["assignee"] = $rootScope.user.id;
  16588. }
  16589. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  16590. vm.model.candidateGroups = vm.model.candidateGroups.id;
  16591. }
  16592. if (pdKey == 'bpm_service_request') {
  16593. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  16594. angular.extend(vm.model.serviceCatalogueProcessActual, {
  16595. 'category': {
  16596. 'id': $stateParams.userId
  16597. }
  16598. });
  16599. }
  16600. if (vm.model.schedule && vm.model.schedule.initUser) {
  16601. delete vm.model.schedule.initUser.menu
  16602. }
  16603. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16604. delete vm.model.candidateGroups
  16605. }
  16606. if (vm.model.start_code == 'close') {
  16607. // 直接处理
  16608. vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
  16609. delete vm.model.incident.handlerUser
  16610. delete vm.model.candidateGroups;
  16611. } else if (vm.model.start_code == 'assignment') {
  16612. // 派单
  16613. delete vm.model.incident.handlingPersonnelUser
  16614. }
  16615. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  16616. $scope.jry_processInstanceId = $stateParams.processInstanceId;
  16617. }
  16618. if ($scope.jry_processInstanceId) {
  16619. vm.model["save_fileId"] = $scope.jry_processInstanceId
  16620. }
  16621. //事件暂存判断
  16622. if (vm.model.saveAgain) {
  16623. if (vm.model.directClose == "1" || vm.model.directClose == true) {
  16624. vm.model.start_code = "assignment";
  16625. vm.model.temporary_code = "assignment";
  16626. } else {
  16627. vm.model.start_code = "close";
  16628. vm.model.temporary_code = "close"
  16629. };
  16630. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16631. delete vm.model.candidateGroups
  16632. }
  16633. }
  16634. //处理请求数据0327
  16635. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16636. delete data0327.repairType;
  16637. // 增加地点的请求参数2020年4月24日10:44:36
  16638. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16639. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16640. data0327.incident.place = {
  16641. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16642. }
  16643. }
  16644. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16645. // console.log("response="+JSON.stringify(response));
  16646. if (response) {
  16647. var resData = Restangular.stripRestangular(response);
  16648. if (resData) {
  16649. if (resData) {
  16650. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16651. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16652. angular.extend(item.headers, $rootScope.getSession());
  16653. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16654. item.formData.push({
  16655. 'fileName': item.file.name
  16656. });
  16657. //console.log();
  16658. };
  16659. $scope.fileUploader.uploadAll();
  16660. }
  16661. }
  16662. }
  16663. SweetAlert.swal({
  16664. title: "提交成功!",
  16665. type: "success",
  16666. confirmButtonColor: "#007AFF"
  16667. }, function () {
  16668. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  16669. $rootScope.app.layout.isSidebarClosed = false;
  16670. if ($scope.login && !$rootScope.busy) {
  16671. $rootScope.setidle();
  16672. }
  16673. }
  16674. $state.go($scope.formData.cancelUrl);
  16675. });
  16676. } else {
  16677. SweetAlert.swal({
  16678. title: "系统错误",
  16679. text: "系统错误,请稍后重试!",
  16680. type: "error",
  16681. confirmButtonColor: "#DD6B55"
  16682. });
  16683. }
  16684. $scope.ldloading[style.replace('-', '_')] = false;
  16685. });
  16686. break;
  16687. case "complete":
  16688. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  16689. //console.log("complete taskId::"+$stateParams.taskId);
  16690. if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
  16691. SweetAlert.swal({
  16692. title: "处理人未填",
  16693. text: "请填写此项!",
  16694. type: "error",
  16695. confirmButtonColor: "#DD6B55"
  16696. });
  16697. return;
  16698. }
  16699. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  16700. if (response) {
  16701. var resData = Restangular.stripRestangular(response);
  16702. SweetAlert.swal({
  16703. title: "提交成功!",
  16704. type: "success",
  16705. confirmButtonColor: "#007AFF"
  16706. }, function () {
  16707. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
  16708. console.log(vm);
  16709. if (vm.model.incident) {
  16710. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  16711. // angular.extend(item.headers, $rootScope.getSession());
  16712. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16713. // item.formData.push({
  16714. // 'fileName': item.file.name
  16715. // });
  16716. // };
  16717. // $scope.fileUploader.uploadAll();
  16718. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16719. angular.extend(item.headers, $rootScope.getSession());
  16720. item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
  16721. item.formData.push({
  16722. 'fileName': item.file.name
  16723. });
  16724. //console.log();
  16725. };
  16726. $scope.fileUploader.uploadAll();
  16727. } else if (vm.model.problem) {
  16728. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16729. angular.extend(item.headers, $rootScope.getSession());
  16730. item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16731. item.formData.push({
  16732. 'fileName': item.file.name
  16733. });
  16734. };
  16735. $scope.fileUploader.uploadAll();
  16736. } else if (vm.model.change) {
  16737. }
  16738. }
  16739. $state.go($scope.formData.cancelUrl);
  16740. });
  16741. } else {
  16742. SweetAlert.swal({
  16743. title: "系统错误",
  16744. text: "系统错误,请稍后重试!",
  16745. type: "error",
  16746. confirmButtonColor: "#DD6B55"
  16747. });
  16748. }
  16749. $scope.ldloading[style.replace('-', '_')] = false;
  16750. });
  16751. break;
  16752. case "back":
  16753. $state.go($scope.formData.cancelUrl);
  16754. break;
  16755. default:
  16756. $scope.ldloading[style.replace('-', '_')] = false;
  16757. break;
  16758. }
  16759. }
  16760. // var submitFunc = api_bpm_domain[$scope.formData.url]
  16761. // if(anuglar.isFunction(submitFunc)){
  16762. // submitFunc.apply(null, pdKey)
  16763. // }
  16764. }
  16765. }
  16766. } else {
  16767. // console.log(data)
  16768. // angular.forEach(vm.form.$error.required, function(item){
  16769. // var i=(item.$name).substring(item.$name.length-2)
  16770. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  16771. // for(var i=0;i<vm.fields.length;i++){
  16772. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  16773. SweetAlert.swal({
  16774. title: vm.fields[i].templateOptions.label + '未填',
  16775. text: "请填写此项!",
  16776. type: "error",
  16777. confirmButtonColor: "#DD6B55"
  16778. });
  16779. }
  16780. // }
  16781. // angular.forEach(vm.fields,function(f){
  16782. // if(f.name == item.$name){
  16783. // f.validation.show = true;
  16784. // SweetAlert.swal({
  16785. // title: f.templateOptions.label+'未填',
  16786. // text: "请填写此项!",
  16787. // type: "error",
  16788. // confirmButtonColor: "#DD6B55"
  16789. // });
  16790. // }
  16791. // });
  16792. // })
  16793. }
  16794. };
  16795. $scope.vm = vm;
  16796. console.log($stateParams,pdKey,88888)
  16797. console.log($scope.vm,'assdfsdf')
  16798. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  16799. var processInstanceId = $stateParams.processInstanceId;
  16800. var itemId = $stateParams.dataId;
  16801. console.log($stateParams)
  16802. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  16803. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
  16804. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16805. var vmForm = Restangular.stripRestangular(responseData);
  16806. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16807. decodeVMForm(vmForm);
  16808. }
  16809. }
  16810. });
  16811. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  16812. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  16813. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16814. var vmForm = Restangular.stripRestangular(responseData);
  16815. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16816. decodeVMForm(vmForm);
  16817. }
  16818. }
  16819. });
  16820. } else {
  16821. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  16822. if (response) {
  16823. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  16824. api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
  16825. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16826. var vmForm = Restangular.stripRestangular(responseData);
  16827. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16828. decodeVMForm(vmForm);
  16829. console.log(vmForm,111111);
  16830. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  16831. console.log($scope,'今天')//2020年4月24日11:40:55
  16832. }
  16833. }
  16834. });
  16835. }
  16836. })
  16837. }
  16838. } else {
  16839. // create process instance
  16840. if (pdKey != "") { //for process
  16841. if (pdKey == 'bpm_service_request') {
  16842. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  16843. if (responseData) {
  16844. var vmForm = Restangular.stripRestangular(responseData);
  16845. if (vmForm) {
  16846. decodeVMForm(vmForm);
  16847. }
  16848. }
  16849. });
  16850. } else {
  16851. api_bpm_domain.startformkey(pdKey).then(function (response) {
  16852. if (response) {
  16853. var myData = Restangular.stripRestangular(response);
  16854. //myData.data = "arrangeform";
  16855. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  16856. if (responseData) {
  16857. var vmForm = Restangular.stripRestangular(responseData);
  16858. if (vmForm) {
  16859. decodeVMForm(vmForm);
  16860. }
  16861. }
  16862. });
  16863. }
  16864. });
  16865. }
  16866. } else { //for form
  16867. //TODO
  16868. //测试数据 开始
  16869. var testJson = {
  16870. fields: [{
  16871. fields: [{
  16872. className: "col-xs-12",
  16873. noFormControl: true,
  16874. key: "formtitle",
  16875. templateOptions: {
  16876. readOnly: false,
  16877. placeholder: "新建事件单",
  16878. hidden: false,
  16879. label: "事件工单",
  16880. required: false
  16881. },
  16882. type: "ui-title"
  16883. }]
  16884. }, {
  16885. fields: [{
  16886. key: 'selectUser',
  16887. type: 'ui-deptinformation',
  16888. className: 'col-xs-12',
  16889. templateOptions: {
  16890. label: '请求人信息',
  16891. modalTitle: '请求人列表',
  16892. fetchItems: function (filterData, APIService) {
  16893. return APIService.fetchDataList('requester', filterData);
  16894. },
  16895. Restangular: Restangular,
  16896. ApiService: api_user_data
  16897. // onClick:function(val, options, field, event , model){
  16898. // console.log(options);
  16899. // }
  16900. }
  16901. }]
  16902. }, {
  16903. fields: [{
  16904. key: 'first',
  16905. type: 'ui-workernumber',
  16906. className: 'col-xs-12',
  16907. templateOptions: {
  16908. type: 'input',
  16909. label: '事件单号',
  16910. pkey: 'name'
  16911. }
  16912. }]
  16913. }, {
  16914. fields: [{
  16915. type: 'ui-header',
  16916. key: 'title',
  16917. className: 'col-xs-12',
  16918. templateOptions: {
  16919. label: '报修人',
  16920. pkey: 'change'
  16921. }
  16922. }, {
  16923. type: 'ui-input',
  16924. key: 'title',
  16925. className: 'col-xs-4',
  16926. templateOptions: {
  16927. label: '报修人',
  16928. pkey: 'change'
  16929. }
  16930. }, {
  16931. type: 'ui-input',
  16932. key: 'title',
  16933. className: 'col-xs-4',
  16934. templateOptions: {
  16935. label: '联系人',
  16936. pkey: 'change'
  16937. }
  16938. }, {
  16939. type: 'ui-input',
  16940. key: 'title',
  16941. className: 'col-xs-4',
  16942. templateOptions: {
  16943. label: '联系电话',
  16944. pkey: 'change'
  16945. }
  16946. }]
  16947. }, {
  16948. fields: [{
  16949. type: 'ui-header',
  16950. key: 'title1',
  16951. className: 'col-xs-12',
  16952. templateOptions: {
  16953. label: '报修人',
  16954. pkey: 'change'
  16955. }
  16956. }, {
  16957. type: 'ui-input',
  16958. key: 'title2',
  16959. className: 'col-xs-4',
  16960. templateOptions: {
  16961. label: '报修人',
  16962. pkey: 'change'
  16963. }
  16964. }, {
  16965. type: 'ui-input',
  16966. key: 'title3',
  16967. className: 'col-xs-4',
  16968. templateOptions: {
  16969. label: '联系人',
  16970. pkey: 'change'
  16971. }
  16972. }, {
  16973. type: 'ui-input',
  16974. key: 'title4',
  16975. className: 'col-xs-4',
  16976. templateOptions: {
  16977. label: '联系电话',
  16978. pkey: 'change'
  16979. }
  16980. }]
  16981. }],
  16982. model: [{
  16983. username: "robin lau",
  16984. password: "123456",
  16985. chkme: false,
  16986. start_code: 0,
  16987. formtitle: "Hey!I am title value!",
  16988. name: {
  16989. first: "robin",
  16990. last: "lau"
  16991. },
  16992. multiselectItem: []
  16993. //date:"2015-09-15 00:00:00"
  16994. }]
  16995. // }
  16996. };
  16997. setTimeout(function () {
  16998. decodeVMForm(testJson);
  16999. $scope.$apply();
  17000. }, 500);
  17001. //测试数据结束
  17002. }
  17003. }
  17004. //console.log("end decode");
  17005. }
  17006. ]);