customformCtrl.js 958 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795
  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. if(selectedItem.houseNumber){//微信web报障传过来的
  8812. scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.houseNumber;
  8813. }else if (selectedItem.place&&selectedItem.place.place) {
  8814. scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  8815. }
  8816. console.log(scope,89898998)
  8817. // console.log(scope.formData,'接单页面');
  8818. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  8819. scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8820. scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8821. options.templateOptions.ApiService.addData('requester',
  8822. data).then(function (response) {
  8823. if (response.status == 200) {
  8824. if (scope.$parent.$parent.$parent) {
  8825. if (scope.$parent.$parent.$parent.place) {
  8826. scope.$parent.$parent.$parent.place.id = '';
  8827. }
  8828. if (scope.$parent.$parent.$parent.area) {
  8829. scope.$parent.$parent.$parent.area.id = '';
  8830. }
  8831. scope.$parent.$parent.$parent.model.incident.contacts = selectedItem.name;
  8832. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8833. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.mphone;
  8834. } else {
  8835. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.telephone;
  8836. }
  8837. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8838. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8839. }
  8840. }
  8841. if (!response.data.id) {
  8842. response.data.id = selectedItem.id
  8843. }
  8844. console.log(scope);
  8845. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  8846. // if (selectedItem.place && selectedItem.place.id) {
  8847. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8848. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  8849. // };
  8850. // } else {
  8851. // if (selectedItem.place && selectedItem.place.id) {
  8852. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8853. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  8854. // };
  8855. // }
  8856. if(scope.$parent.$parent.$parent.model.incident.area){
  8857. scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  8858. }
  8859. if (selectedItem.id) {
  8860. scope.$parent.$parent.$parent.model.incident.account = selectedItem.account;
  8861. }
  8862. // 选择重复事件侧滑框
  8863. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  8864. scope.$parent.$parent.$parent.model[
  8865. 'repeatIncidentShow'] = false;
  8866. setTimeout(() => {
  8867. scope.$parent.$parent.$parent.model[
  8868. 'repeatIncidentShow'] = true;
  8869. },
  8870. 500);
  8871. // }
  8872. }
  8873. })
  8874. }
  8875. });
  8876. },
  8877. validators: {
  8878. required: {
  8879. expression: function (viewValue, modelValue) {
  8880. var value = modelValue || viewValue;
  8881. return value != null;
  8882. // return value.length>=1;
  8883. // if (modelValue && viewValue) {
  8884. // return value != null;
  8885. // } else {
  8886. // var value = modelValue || viewValue;
  8887. // return value.length > 0;
  8888. // }
  8889. }
  8890. }
  8891. }
  8892. },
  8893. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  8894. // $scope.myFilter = function(item) {
  8895. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  8896. // }
  8897. // console.log($scope,'风浪')
  8898. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  8899. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  8900. $scope.options.templateOptions.linkage("place", {
  8901. "place": {
  8902. // "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
  8903. area:{
  8904. id:$scope.$parent.$parent.$parent.model.incident.area.id
  8905. }
  8906. }
  8907. }, $scope.$parent.$parent.$parent.model, "incident", "place");
  8908. }
  8909. }
  8910. $scope.myFilter = $scope;
  8911. // console.log($scope.options.templateOptions)
  8912. console.log($scope,77777)
  8913. // 关闭事件页面满意度评价下拉框处理
  8914. if($scope.options.templateOptions.onlyKey=="close_degree"){
  8915. $scope.model.id = $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id
  8916. }
  8917. if($scope.options.templateOptions.initData == 1){
  8918. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8919. }
  8920. if ($scope.options.templateOptions.transform) {
  8921. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8922. }
  8923. if (angular.isFunction($scope.options.templateOptions.translate)) {
  8924. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  8925. }
  8926. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  8927. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  8928. }
  8929. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  8930. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  8931. }
  8932. }]
  8933. };
  8934. }
  8935. });
  8936. //下拉多选框组件
  8937. formlyConfigProvider.setType({
  8938. name: 'ui-multiselect',
  8939. extends: 'select',
  8940. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  8941. defaultOptions: function (options) {
  8942. return {
  8943. templateOptions: {
  8944. refresh: function () { },
  8945. refreshDelay: 1000
  8946. }
  8947. };
  8948. },
  8949. controller: ['$scope', function ($scope) {
  8950. $scope.model[$scope.options.key] = [];
  8951. }]
  8952. });
  8953. //下拉多选框灵活组件
  8954. formlyConfigProvider.setType({
  8955. name: 'ui-multiselectplus',
  8956. extends: 'multiCheckbox',
  8957. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8958. defaultOptions: function (options, $scope) {
  8959. return {
  8960. templateOptions: {
  8961. refreshData: function (search, options, model, that) {
  8962. var process = options.templateOptions.ApiService.all("");
  8963. if (search) {
  8964. } else {
  8965. }
  8966. var postData = options.templateOptions.optionsPostData;
  8967. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8968. postData = options.templateOptions.optionsPostData(options, model, that);
  8969. }
  8970. if (options.templateOptions.modelreasondata) {
  8971. postData = options.templateOptions.modelreasondata
  8972. }
  8973. process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
  8974. // if (!options.templateOptions.options) {
  8975. // options.templateOptions.options = [];
  8976. // }
  8977. // 过滤下拉列表已选择的值
  8978. var modelVal = $scope.model[$scope.options.key];
  8979. for (var i = 0; i < result.list.length; i++) {
  8980. for (var j = 0; j < modelVal.length; j++) {
  8981. if (result.list[i].id == modelVal[j].id) {
  8982. result.list.splice(i, 1)
  8983. }
  8984. }
  8985. }
  8986. if (options.templateOptions.optionsDataKey) {
  8987. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8988. } else {
  8989. options.templateOptions.options = result;
  8990. }
  8991. if (options.templateOptions.optionsChecked) {
  8992. // return options.value = null;
  8993. options.value(options.model[options.key]);
  8994. }
  8995. });
  8996. },
  8997. refreshDelay: 0,
  8998. // },
  8999. // validators: {
  9000. // required: {
  9001. // expression: function(viewValue, modelValue) {
  9002. // var value = modelValue || viewValue;
  9003. // // return value.length>=1;
  9004. // // if (modelValue && viewValue) {
  9005. // // return value != null;
  9006. // // } else {
  9007. // // var value = modelValue || viewValue;
  9008. // // return value.length > 0;
  9009. // // }
  9010. // }
  9011. // }
  9012. }
  9013. };
  9014. },
  9015. controller: ['$scope', function ($scope) {
  9016. if (angular.isArray($scope.model[$scope.options.key])) {
  9017. } else {
  9018. $scope.model[$scope.options.key] = [];
  9019. }
  9020. }]
  9021. });
  9022. //下拉树形多选组件
  9023. formlyConfigProvider.setType({
  9024. name: 'ui-multiselect-tree',
  9025. extends: 'multiCheckbox',
  9026. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9027. defaultOptions: function (options) {
  9028. return {
  9029. templateOptions: {
  9030. linkage: function (modelName, data, model, modelKey, key) {
  9031. angular.extend(data, {
  9032. "idx": 0,
  9033. "sum": 10
  9034. });
  9035. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9036. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9037. var list = myData.list;
  9038. if (list.length == 1) {
  9039. angular.forEach(model.fields, function (item) {
  9040. angular.forEach(model.fields, function (item) {
  9041. if (item.templateOptions.pkey == modelKey + "." + key) {
  9042. item.model.id = "";
  9043. if (key == "place") {
  9044. item.templateOptions.options = list;
  9045. } else {
  9046. item.value(list[0][key][item.key]);
  9047. }
  9048. }
  9049. })
  9050. })
  9051. }
  9052. });
  9053. },
  9054. // my_tree_handler : function(items) {
  9055. // },
  9056. // onFilterCallback : function(items) {
  9057. // },
  9058. // onFilterCallback : function(items) {
  9059. // },
  9060. refresh: function (items) {
  9061. var treedata = [];
  9062. function convertListToTree(data, treeMap) {
  9063. treedata = data;
  9064. for (var i = 0; i < data.length; i++) {
  9065. for (var j = 0; j < data.length; j++) {
  9066. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9067. if (data[i].pid == data[j].id) {
  9068. data[i].parent = data[j];
  9069. }
  9070. }
  9071. }
  9072. }
  9073. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9074. var root = null; //Initially set our loop to null
  9075. //loop over data
  9076. for (var i = 0; i < data.length; i++) {
  9077. var datum = data[i];
  9078. //each node will have children, so let's give it a "children" poperty
  9079. datum.children = [];
  9080. //add an entry for this node to the map so that any future children can
  9081. //lookup the parent
  9082. idToNodeMap[datum.id] = datum;
  9083. //Does this node have a parent?
  9084. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9085. //Doesn't look like it, so this node is the root of the tree
  9086. root = datum;
  9087. treeMap[datum.id] = root;
  9088. } else {
  9089. //This node has a parent, so let's look it up using the id
  9090. parentNode = idToNodeMap[datum.parent.id];
  9091. //We don't need this property, so let's delete it.
  9092. delete datum.parent;
  9093. //Let's add the current node as a child of the parent node.
  9094. parentNode.children.push(datum);
  9095. }
  9096. }
  9097. return root;
  9098. }
  9099. function convertParentToChildList(data) {
  9100. // console.log("data="+JSON.stringify(data))
  9101. var treeMap = {};
  9102. var list = [];
  9103. convertListToTree(data, treeMap);
  9104. angular.forEach(treeMap, function (item) {
  9105. list.push(item);
  9106. });
  9107. return list;
  9108. }
  9109. function selectItem(pmodel, childrens) {
  9110. if (angular.isArray(pmodel)) {
  9111. angular.forEach(pmodel, function (index) {
  9112. if (index && index.id) {
  9113. angular.forEach(childrens, function (item) {
  9114. if (item.id == index.id) {
  9115. item.selected = true;
  9116. }
  9117. if (item && item.children) {
  9118. selectItem(pmodel, item.children);
  9119. }
  9120. });
  9121. }
  9122. })
  9123. } else {
  9124. if (pmodel && pmodel.id) {
  9125. angular.forEach(childrens, function (item) {
  9126. if (item.id == pmodel.id) {
  9127. item.selected = true;
  9128. }
  9129. if (item && item.children) {
  9130. selectItem(pmodel, item.children);
  9131. }
  9132. });
  9133. }
  9134. }
  9135. }
  9136. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9137. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9138. if (result.status == 200) {
  9139. if (!options.templateOptions.options) {
  9140. options.templateOptions.options = [];
  9141. }
  9142. if (options.templateOptions.optionsDataKey) {
  9143. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9144. } else {
  9145. options.templateOptions.options = convertParentToChildList(result);
  9146. }
  9147. //set default value
  9148. var pmodel, i = 0;
  9149. if (options.templateOptions.pkey) {
  9150. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9151. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9152. if (i == 0) {
  9153. if (options.model[p] == null) {
  9154. options.model[p] = {};
  9155. }
  9156. pmodel = options.model[p];
  9157. i++;
  9158. } else {
  9159. if (pmodel[p] == null) {
  9160. pmodel[p] = {};
  9161. }
  9162. pmodel = pmodel[p];
  9163. }
  9164. });
  9165. } else {
  9166. pmodel = options.model;
  9167. }
  9168. }
  9169. if (pmodel) {
  9170. pmodel = pmodel[options.key];
  9171. } else if (options.model) {
  9172. pmodel = options.model[options.key];
  9173. } else {
  9174. pmodel = options.templateOptions.options;
  9175. }
  9176. if (angular.isArray(pmodel)) {
  9177. if (pmodel) {
  9178. // if(options.templateOptions.isMultiSelect==true){
  9179. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  9180. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  9181. // })
  9182. // }else{
  9183. selectItem(pmodel, options.templateOptions.options);
  9184. // }
  9185. }
  9186. } else {
  9187. if (pmodel && pmodel.id) {
  9188. selectItem(pmodel, options.templateOptions.options);
  9189. }
  9190. }
  9191. items.inputModel = options.templateOptions.options;
  9192. }
  9193. });
  9194. }
  9195. },
  9196. validators: {
  9197. required: {
  9198. expression: function (viewValue, modelValue) {
  9199. var value = modelValue || viewValue;
  9200. if (angular.isArray(value)) {
  9201. for (var i = 0; i < value.length; i++) {
  9202. value[i] = {
  9203. id: value[i].id
  9204. }
  9205. }
  9206. return value.length > 0
  9207. } else {
  9208. // console.log(options)
  9209. // return value = "true";
  9210. return value != null;
  9211. }
  9212. }
  9213. }
  9214. }
  9215. }
  9216. },
  9217. controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
  9218. if ($scope.options.templateOptions.isMultiSelect) {
  9219. // console.log($scope);
  9220. } else {
  9221. if ($scope.model[$scope.options.key]) {
  9222. }
  9223. }
  9224. }]
  9225. });
  9226. //多选下拉框组件
  9227. formlyConfigProvider.setType({
  9228. name: 'ui-multi-select-tree',
  9229. extends: 'input',
  9230. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9231. defaultOptions: function (options) {
  9232. return {
  9233. templateOptions: {
  9234. linkage: function (modelName, data, model, modelKey, key) {
  9235. angular.extend(data, {
  9236. "idx": 0,
  9237. "sum": 10
  9238. });
  9239. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9240. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9241. var list = myData.list;
  9242. if (list.length == 1) {
  9243. angular.forEach(model.fields, function (item) {
  9244. angular.forEach(model.fields, function (item) {
  9245. if (item.templateOptions.pkey == modelKey + "." + key) {
  9246. item.model.id = "";
  9247. if (key == "place") {
  9248. item.templateOptions.options = list;
  9249. } else {
  9250. item.value(list[0][key][item.key]);
  9251. }
  9252. }
  9253. })
  9254. })
  9255. }
  9256. });
  9257. },
  9258. getparentdata: function (items) {
  9259. // console.log(items)
  9260. },
  9261. refresh: function (items, search, fn) {
  9262. console.log(items);
  9263. var treedata = [];
  9264. function convertListToTree(data, treeMap) {
  9265. // console.log(data)
  9266. treedata = data;
  9267. for (var i = 0; i < data.length; i++) {
  9268. for (var j = 0; j < data.length; j++) {
  9269. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9270. if (data[i].pid == data[j].id) {
  9271. data[i].parent = data[j];
  9272. }
  9273. }
  9274. // if (data[i].id) {
  9275. // if (data[i].id== data[j].id) {
  9276. // data[i].parent = data[j];
  9277. // }
  9278. // }
  9279. }
  9280. }
  9281. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9282. var root = []; //Initially set our loop to null
  9283. if (search == 'search' && items.filterKeyword) {
  9284. function transform(nodes) {
  9285. var treeConverter = {
  9286. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  9287. attributeName: 'id', //节点唯一标识符
  9288. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  9289. transform: function (node) { //转化递归函数,参数:一个待插入节点
  9290. if (node.parent != null) { //该节点有父节点
  9291. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  9292. if (this.needFind) {
  9293. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  9294. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  9295. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9296. }
  9297. }
  9298. }
  9299. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  9300. // delete node.parent; //删除该节点的parent属性,如果有的话
  9301. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  9302. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  9303. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  9304. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  9305. // delete node.parent; //删除该节点的parent属性,如果有的话
  9306. if (this.result == null) { //根节点不存在
  9307. node.children = []; //给该节点增加children:[]属性
  9308. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9309. } else {
  9310. node.children = [];
  9311. // 顶级去重
  9312. for (var i = 0; i < this.result.children.length; i++) {
  9313. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  9314. return this.result.children[i];
  9315. }
  9316. }
  9317. this.result.children.push(node)
  9318. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9319. }
  9320. }
  9321. },
  9322. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  9323. var _node = {};
  9324. _node.children = [];
  9325. this.result = _node; //重置根节点
  9326. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  9327. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  9328. nodes.forEach(item => { //循环调用转化方法
  9329. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  9330. this.transform(item);
  9331. })
  9332. return this.result; //返回根节点
  9333. }
  9334. }
  9335. var result = treeConverter.getWhole(nodes); //调用
  9336. return result;
  9337. }
  9338. var li = transform(data).children;
  9339. // li=[...new Set(li)]
  9340. console.log(li)
  9341. treeMap = li;
  9342. fn(li);
  9343. return li;
  9344. } else {
  9345. //loop over data
  9346. for (var i = 0; i < data.length; i++) {
  9347. var datum = data[i];
  9348. //each node will have children, so let's give it a "children" poperty
  9349. datum.children = [];
  9350. //add an entry for this node to the map so that any future children can
  9351. //lookup the parent
  9352. idToNodeMap[datum.id] = datum;
  9353. //Does this node have a parent?
  9354. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9355. //Doesn't look like it, so this node is the root of the tree
  9356. root = datum;
  9357. treeMap[datum.id] = root;
  9358. } else {
  9359. //This node has a parent, so let's look it up using the id
  9360. parentNode = idToNodeMap[datum.parent.id];
  9361. //We don't need this property, so let's delete it.
  9362. // delete datum.parent;
  9363. //Let's add the current node as a child of the parent node.
  9364. parentNode.children.push(datum);
  9365. }
  9366. }
  9367. }
  9368. return root;
  9369. }
  9370. function convertParentToChildList(data) {
  9371. var treeMap = {};
  9372. var list = [];
  9373. if (search == 'search' && items.filterKeyword) {
  9374. var lis = convertListToTree(data, treeMap)
  9375. return lis;
  9376. } else {
  9377. if (data[0] && data[0].orders) {
  9378. list = data;
  9379. } else {
  9380. convertListToTree(data, treeMap);
  9381. angular.forEach(treeMap, function (item) {
  9382. // console.log("item="+JSON.stringify(item))
  9383. list.push(item);
  9384. });
  9385. }
  9386. return list;
  9387. }
  9388. }
  9389. function selectItem(pmodel, childrens) {
  9390. if (angular.isArray(pmodel)) {
  9391. angular.forEach(pmodel, function (index) {
  9392. if (index && index.id) {
  9393. angular.forEach(childrens, function (item) {
  9394. if (item.id == index.id) {
  9395. item.selected = true;
  9396. }
  9397. if (item && item.children) {
  9398. selectItem(pmodel, item.children);
  9399. }
  9400. });
  9401. // angular.forEach(treedata,function(parentdata){
  9402. // if(parentdata.id == index.id){
  9403. // if(parentdata.parent&&parentdata.parent.id){
  9404. // parentdata.parent.$
  9405. // }
  9406. // item.selected = true;
  9407. // }
  9408. // if (item && item.children) {
  9409. // selectItem(pmodel ,item.children);
  9410. // }
  9411. // });
  9412. }
  9413. })
  9414. } else {
  9415. if (pmodel && pmodel.id) {
  9416. angular.forEach(childrens, function (item, index) {
  9417. if (item.id == pmodel.id) {
  9418. item.selected = true;
  9419. delete item.children;
  9420. }
  9421. if (item && item.children) {
  9422. selectItem(pmodel, item.children);
  9423. }
  9424. });
  9425. }
  9426. }
  9427. }
  9428. function selectItemchild(pmodel, childrens) {
  9429. if (angular.isArray(pmodel)) {
  9430. angular.forEach(pmodel, function (index) {
  9431. if (index && index.id) {
  9432. angular.forEach(childrens, function (item) {
  9433. if (item.id == index.id) {
  9434. item.selected = true;
  9435. }
  9436. if (item && item.children) {
  9437. selectItem(pmodel, item.children);
  9438. }
  9439. });
  9440. }
  9441. })
  9442. } else {
  9443. if (pmodel && pmodel.id) {
  9444. angular.forEach(childrens, function (item, index) {
  9445. if (item.id == pmodel.id) {
  9446. item.selected = true;
  9447. childrens[index].selected = true;
  9448. }
  9449. if (item && item.children) {
  9450. selectItem(pmodel, item.children);
  9451. }
  9452. });
  9453. }
  9454. }
  9455. }
  9456. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9457. if (search === 'search' && items.filterKeyword) {
  9458. // bala:树形模糊搜索
  9459. options.templateOptions.bala(options.templateOptions.APIService, items.filterKeyword).then(function (result) {
  9460. result.list = [...new Set(result.list)]; //去重
  9461. if (!options.templateOptions.options) {
  9462. options.templateOptions.options = [];
  9463. }
  9464. if (options.templateOptions.optionsDataKey) {
  9465. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9466. } else {
  9467. options.templateOptions.options = convertParentToChildList(result);
  9468. }
  9469. //set default value
  9470. var pmodel, i = 0;
  9471. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9472. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9473. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9474. if (i == 0) {
  9475. if (options.model[p] == null) {
  9476. options.model[p] = {};
  9477. }
  9478. pmodel = options.model[p];
  9479. i++;
  9480. } else {
  9481. if (pmodel[p] == null) {
  9482. pmodel[p] = {};
  9483. }
  9484. pmodel = pmodel[p];
  9485. }
  9486. });
  9487. } else {
  9488. pmodel = options.model;
  9489. }
  9490. }
  9491. var topdata = angular.copy(options.templateOptions.options);
  9492. if (pmodel) {
  9493. pmodel = pmodel[options.key];
  9494. } else if (options.model) {
  9495. pmodel = options.model[options.key];
  9496. }
  9497. if (angular.isArray(pmodel)) {
  9498. if (pmodel) {
  9499. items.inputModel = angular.copy(options.templateOptions.options);
  9500. selectItem(pmodel, options.templateOptions.options);
  9501. }
  9502. } else {
  9503. if (pmodel && pmodel.id) {
  9504. items.inputModel = angular.copy(options.templateOptions.options);
  9505. selectItem(pmodel, options.templateOptions.options);
  9506. } else {
  9507. // items.inputModel = options.templateOptions.options;
  9508. }
  9509. }
  9510. // items.inputModel = options.templateOptions.options;
  9511. items.selectModel = options.templateOptions.options;
  9512. // 可在此展开
  9513. if (!items.inputModel) {
  9514. items.inputModel = items.selectModel;
  9515. } else {
  9516. selectItemchild(pmodel, items.inputModel);
  9517. // for (var i = 0; i < items.inputModel.length; i++) {
  9518. // items.inputModel[i].
  9519. // for (var j = 0; j < items.selectModel.length; j++) {
  9520. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9521. // items.inputModel[i].selected = true;
  9522. // }
  9523. // }
  9524. // }
  9525. }
  9526. return items.inputModel;
  9527. // options.templateOptions.options = angular.copy(topdata);
  9528. // console.log(model);
  9529. // console.log(options);
  9530. });
  9531. } else {
  9532. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9533. if (!options.templateOptions.options) {
  9534. options.templateOptions.options = [];
  9535. }
  9536. if (options.templateOptions.optionsDataKey) {
  9537. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9538. } else {
  9539. options.templateOptions.options = convertParentToChildList(result);
  9540. }
  9541. //set default value
  9542. var pmodel, i = 0;
  9543. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9544. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9545. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9546. if (i == 0) {
  9547. if (options.model[p] == null) {
  9548. options.model[p] = {};
  9549. }
  9550. pmodel = options.model[p];
  9551. i++;
  9552. } else {
  9553. if (pmodel[p] == null) {
  9554. pmodel[p] = {};
  9555. }
  9556. pmodel = pmodel[p];
  9557. }
  9558. });
  9559. } else {
  9560. pmodel = options.model;
  9561. }
  9562. }
  9563. var topdata = angular.copy(options.templateOptions.options);
  9564. if (pmodel) {
  9565. pmodel = pmodel[options.key];
  9566. } else if (options.model) {
  9567. pmodel = options.model[options.key];
  9568. }
  9569. if (angular.isArray(pmodel)) {
  9570. if (pmodel) {
  9571. items.inputModel = angular.copy(options.templateOptions.options);
  9572. selectItem(pmodel, options.templateOptions.options);
  9573. }
  9574. } else {
  9575. if (pmodel && pmodel.id) {
  9576. items.inputModel = angular.copy(options.templateOptions.options);
  9577. selectItem(pmodel, options.templateOptions.options);
  9578. } else {
  9579. // items.inputModel = options.templateOptions.options;
  9580. }
  9581. }
  9582. // items.inputModel = options.templateOptions.options;
  9583. items.selectModel = options.templateOptions.options;
  9584. if (!items.inputModel) {
  9585. items.inputModel = items.selectModel;
  9586. } else {
  9587. selectItemchild(pmodel, items.inputModel);
  9588. // for (var i = 0; i < items.inputModel.length; i++) {
  9589. // for (var j = 0; j < items.selectModel.length; j++) {
  9590. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9591. // items.inputModel[i].selected = true;
  9592. // }
  9593. // }
  9594. // }
  9595. }
  9596. // options.templateOptions.options = angular.copy(topdata);
  9597. // console.log(model);
  9598. // console.log(options);
  9599. });
  9600. }
  9601. }
  9602. },
  9603. validators: {
  9604. required: {
  9605. expression: function (viewValue, modelValue) {
  9606. var value = modelValue || viewValue;
  9607. if (angular.isArray(value)) {
  9608. return value.length > 0
  9609. } else {
  9610. // console.log(options)
  9611. if (options.templateOptions.required && !value) {
  9612. // return value != null;
  9613. } else {
  9614. return value;
  9615. }
  9616. // return value = "true";
  9617. }
  9618. }
  9619. }
  9620. }
  9621. }
  9622. },
  9623. controller: ['$scope', '$rootScope', 'api_configure_form', 'api_bpm_domain', function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  9624. $rootScope.checkClicked = function (item) {
  9625. angular.forEach($scope.to.options, function (itemone) {
  9626. if (!item.parent) {
  9627. if (item.id == itemone.id) {
  9628. // itemone.isExpanded = true;
  9629. } else {
  9630. itemone.isExpanded = false;
  9631. }
  9632. } else {
  9633. if (item.parent.id == itemone.id) {
  9634. angular.forEach(itemone.children, function (itemtwo) {
  9635. if (item.id == itemtwo.id) { } else {
  9636. itemtwo.isExpanded = false;
  9637. }
  9638. })
  9639. }
  9640. }
  9641. })
  9642. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  9643. console.log($scope,'gsm');
  9644. if ($scope.originalModel && $scope.originalModel.incident && item.category && (!item.children || !item.children.length) && item.priority && item.priority.id) {
  9645. api_bpm_domain.expectedTime('L' + (item.priority.id - 1559)).then(function (res) {
  9646. $scope.originalModel.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  9647. $scope.originalModel.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  9648. $scope.originalModel.incident.overdueTime = res.date;
  9649. })
  9650. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9651. // setTimeout(() => {
  9652. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9653. // }, 500);
  9654. // console.log($scope.$parent.$parent.$parent)
  9655. }
  9656. }
  9657. if ($scope.options.templateOptions.isMultiSelect) {
  9658. // console.log($scope);
  9659. } else {
  9660. if ($scope.model[$scope.options.key]) {
  9661. }
  9662. }
  9663. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  9664. // console.log(item)
  9665. // // if(){
  9666. // // }
  9667. // // $scope.model[$scope.options.key]=item.id;
  9668. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  9669. // $scope.propTypeOptions = data;
  9670. // });
  9671. // }
  9672. // $scope.model[$scope.options.key]=[];
  9673. // $scope.fn
  9674. $rootScope.bala1 = function (items, fn) {
  9675. // $scope.fn = fn;
  9676. console.log(items)
  9677. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  9678. $scope.options.templateOptions.refresh(items, 'search', fn)
  9679. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  9680. // // return res.list;
  9681. // console.log(666)
  9682. // fn(res.list)
  9683. // })
  9684. }
  9685. }]
  9686. });
  9687. //勾选组件
  9688. formlyConfigProvider.setType({
  9689. name: 'ui-checkbox',
  9690. extends: 'checkbox',
  9691. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  9692. controller: ['$scope', function ($scope) {
  9693. // 巡检生成事件,默认派单
  9694. if ($scope.model.isInspection) {
  9695. $scope.model[$scope.options.key] = true;
  9696. };
  9697. if ($scope.model[$scope.options.key] == "true") {
  9698. $scope.model[$scope.options.key] = true;
  9699. };
  9700. if ($scope.model[$scope.options.key] == "false") {
  9701. $scope.model[$scope.options.key] = false;
  9702. };
  9703. }]
  9704. });
  9705. //换行组件
  9706. formlyConfigProvider.setType({
  9707. name: 'ui-nextLine',
  9708. /*extends: 'input',*/
  9709. template: '<div></div>',
  9710. });
  9711. //多选框组件
  9712. formlyConfigProvider.setType({
  9713. name: 'ui-checklist',
  9714. extends: 'multiCheckbox',
  9715. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  9716. defaultOptions: function (options) {
  9717. return {
  9718. templateOptions: {
  9719. refresh: function () { },
  9720. refreshDelay: 0
  9721. }
  9722. };
  9723. }
  9724. });
  9725. //单选框组件
  9726. formlyConfigProvider.setType({
  9727. name: 'ui-radio',
  9728. extends: 'radio',
  9729. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  9730. defaultOptions: function (options) {
  9731. return {
  9732. templateOptions: {
  9733. refresh: function () { },
  9734. refreshDelay: 0
  9735. }
  9736. };
  9737. },
  9738. controller: ['$scope', function ($scope) {
  9739. // 巡检生成事件,默认派单
  9740. if ($scope.model.isInspection) {
  9741. $scope.model[$scope.options.key] = true;
  9742. // $scope.model.isHandlerUser=true;
  9743. $scope.model.start_code = "assignment";
  9744. console.log($scope.model);
  9745. };
  9746. //多次暂存配置
  9747. // console.log($scope);
  9748. if ($scope.model.saveAgain) {
  9749. if ($scope.model.directClose == "1" || $scope.model.directClose == true) {
  9750. $scope.model[$scope.options.key] = true;
  9751. // if($scope.model.incident.handlingPersonnelUser){
  9752. // delete $scope.model.incident.handlingPersonnelUser;
  9753. // };
  9754. if ($scope.model.incident.handleDescription) {
  9755. delete $scope.model.incident.handleDescription
  9756. };
  9757. if ($scope.model.incident.closecode) {
  9758. delete $scope.model.incident.closecode
  9759. };
  9760. if ($scope.model.incident.degree) {
  9761. delete $scope.model.incident.degree
  9762. }
  9763. } else {
  9764. $scope.model.incident.handlingPersonnelUser = $scope.model.incident.acceptUser;
  9765. $scope.model[$scope.options.key] = false
  9766. }
  9767. }
  9768. }]
  9769. });
  9770. //文本域组件
  9771. formlyConfigProvider.setWrapper({
  9772. name: 'validation',
  9773. types: ['ui-textarea'],
  9774. 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>"
  9775. });
  9776. formlyConfigProvider.setType({
  9777. name: 'ui-textarea',
  9778. extends: 'textarea',
  9779. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  9780. defaultOptions: function (options) {
  9781. return {
  9782. templateOptions: {
  9783. transform: function (model, value) {
  9784. return value;
  9785. },
  9786. },
  9787. validation: {
  9788. messages: {
  9789. maxlength: function (viewValue, modelValue, scope) {
  9790. if (viewValue != null) {
  9791. if (viewValue.length > scope.to.maxlength) {
  9792. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9793. } else {
  9794. return "";
  9795. }
  9796. }
  9797. },
  9798. }
  9799. }
  9800. }
  9801. },
  9802. controller: ['$scope', function ($scope) {
  9803. var value = $scope.model[$scope.options.key];
  9804. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9805. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9806. }
  9807. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9808. $scope.options.templateOptions.felditem($scope);
  9809. }
  9810. }]
  9811. });
  9812. // div版的textarea(展示富文本框内容用)
  9813. formlyConfigProvider.setType({
  9814. name: 'ui-divTextarea',
  9815. extends: 'textarea',
  9816. templateUrl: 'assets/views/customform/tpl/ui-divTextarea.html',
  9817. defaultOptions: function (options) {
  9818. return {
  9819. templateOptions: {
  9820. transform: function (model, value) {
  9821. return value;
  9822. },
  9823. },
  9824. validation: {
  9825. messages: {
  9826. // maxlength: function (viewValue, modelValue, scope) {
  9827. // if (viewValue != null) {
  9828. // if (viewValue.length > scope.to.maxlength) {
  9829. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9830. // } else {
  9831. // return "";
  9832. // }
  9833. // }
  9834. // },
  9835. }
  9836. }
  9837. }
  9838. },
  9839. controller: ['$scope', function ($scope) {
  9840. var value = $scope.model[$scope.options.key];
  9841. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9842. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9843. }
  9844. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9845. $scope.options.templateOptions.felditem($scope);
  9846. }
  9847. }]
  9848. });
  9849. // 带有知识库引用的textarea
  9850. formlyConfigProvider.setType({
  9851. name: 'ui-textAreaKnowledge',
  9852. // extends: 'textarea',
  9853. templateUrl: 'assets/views/customform/tpl/ui-textAreaKnowledge.html',
  9854. defaultOptions: function (options) {
  9855. return {
  9856. templateOptions: {
  9857. transform: function (model, value) {
  9858. return value;
  9859. },
  9860. },
  9861. validation: {
  9862. messages: {
  9863. maxlength: function (viewValue, modelValue, scope) {
  9864. if (viewValue != null) {
  9865. if (viewValue.length > scope.to.maxlength) {
  9866. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9867. } else {
  9868. return "";
  9869. }
  9870. }
  9871. },
  9872. }
  9873. }
  9874. }
  9875. },
  9876. 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) {
  9877. // console.log($scope);
  9878. var value = $scope.model[$scope.options.key];
  9879. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9880. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9881. }
  9882. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9883. $scope.options.templateOptions.felditem($scope);
  9884. }
  9885. // 引用知识库点击
  9886. $scope.openSolution = function () {
  9887. $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9888. setTimeout(() => {
  9889. $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9890. }, 100);
  9891. }
  9892. }]
  9893. });
  9894. //常用语句选择textarea
  9895. formlyConfigProvider.setType({
  9896. name: 'ui-textselect',
  9897. extends: 'textarea',
  9898. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  9899. defaultOptions: function (options) {
  9900. return {
  9901. templateOptions: {
  9902. transform: function (model, value) {
  9903. return value;
  9904. },
  9905. },
  9906. validation: {
  9907. messages: {
  9908. maxlength: function (viewValue, modelValue, scope) {
  9909. if (viewValue != null) {
  9910. if (viewValue.length > scope.to.maxlength) {
  9911. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9912. } else {
  9913. return "";
  9914. }
  9915. }
  9916. },
  9917. }
  9918. }
  9919. }
  9920. },
  9921. controller: ['$scope', function ($scope) {
  9922. var value = $scope.model[$scope.options.key];
  9923. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9924. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9925. }
  9926. }]
  9927. });
  9928. //改动的组件 ckeditor封装后的组件
  9929. formlyConfigProvider.setType({
  9930. name: 'ui-text-check',
  9931. extends: 'textarea',
  9932. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  9933. defaultOptions: function (options) {
  9934. return {
  9935. templateOptions: {
  9936. extraPlugins: 'uploadimage',
  9937. uploadimageConfig: {
  9938. backend: 'basic',
  9939. settings: {
  9940. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  9941. headers: '',
  9942. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  9943. }
  9944. },
  9945. refresh: function (APIService, contentId, data) {
  9946. return APIService.fetchDataList(contentId, data);
  9947. },
  9948. downloadUri: function (APIService, contentId) {
  9949. return APIService.downloadAttachment(contentId).getRequestedUrl();
  9950. },
  9951. upload: function (APIService, contentId) {
  9952. return APIService.getSolutionDowpath(contentId);
  9953. },
  9954. view: function (attachmentId) {
  9955. // return APIService.attachmentsPreviewUrl(contentId);
  9956. },
  9957. refreshDelay: 0,
  9958. transform: function (model, value) {
  9959. return value;
  9960. },
  9961. },
  9962. validation: {
  9963. messages: {
  9964. maxlength: function (viewValue, modelValue, scope) {
  9965. if (viewValue != null) {
  9966. if (viewValue.length > scope.to.maxlength) {
  9967. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9968. } else {
  9969. return "";
  9970. }
  9971. }
  9972. },
  9973. }
  9974. }
  9975. }
  9976. },
  9977. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  9978. var value = $scope.model[$scope.options.key];
  9979. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9980. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9981. }
  9982. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  9983. //var expiry={'expiry':14804244006};
  9984. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  9985. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  9986. $scope.upload = function (contentId, filename) {
  9987. var filename = filename;
  9988. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  9989. var file = new Blob([response], {
  9990. type: 'application/octet-stream'
  9991. });
  9992. // var filename = filename;
  9993. var fileURL = URL.createObjectURL(file);
  9994. var a = document.createElement('a');
  9995. a.href = fileURL;
  9996. a.target = '_blank';
  9997. a.download = filename;
  9998. document.body.appendChild(a);
  9999. a.click();
  10000. })
  10001. };
  10002. }]
  10003. });
  10004. //改动的组件 ckeditor封装后的附文本组件
  10005. formlyConfigProvider.setType({
  10006. name: 'ui-fuwenben',
  10007. extends: 'textarea',
  10008. templateUrl: 'assets/views/customform/tpl/ui-fuwenben.html',
  10009. defaultOptions: function (options) {
  10010. return {
  10011. templateOptions: {
  10012. allowedContent: 'img[!src]',//允许展示源码的标签,否则会被富文本框强制删除
  10013. extraPlugins: 'uploadimage',
  10014. uploadimageConfig: {
  10015. backend: 'basic',
  10016. settings: {
  10017. uploadUrl: options.templateOptions.APIService.upload(-110).getRequestedUrl(),
  10018. headers: '',
  10019. downloadUrl: options.templateOptions.APIService.uploadResponseUri()
  10020. }
  10021. },
  10022. refresh: function (APIService, contentId, data) {
  10023. return APIService.fetchDataList(-110, data);
  10024. },
  10025. downloadUri: function (APIService, contentId) {
  10026. return APIService.downloadAttachment(-110).getRequestedUrl();
  10027. },
  10028. upload: function (APIService, contentId) {
  10029. return APIService.getSolutionDowpath(-110);
  10030. },
  10031. view: function (attachmentId) {
  10032. // return APIService.attachmentsPreviewUrl(contentId);
  10033. },
  10034. refreshDelay: 0,
  10035. transform: function (model, value) {
  10036. return value;
  10037. },
  10038. },
  10039. validation: {
  10040. messages: {
  10041. maxlength: function (viewValue, modelValue, scope) {
  10042. if (viewValue != null) {
  10043. if (viewValue.length > scope.to.maxlength) {
  10044. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  10045. } else {
  10046. return "";
  10047. }
  10048. }
  10049. },
  10050. }
  10051. }
  10052. }
  10053. },
  10054. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10055. var value = $scope.model[$scope.options.key];
  10056. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10057. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10058. }
  10059. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10060. //var expiry={'expiry':14804244006};
  10061. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10062. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10063. $scope.upload = function (contentId, filename) {
  10064. var filename = filename;
  10065. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, -110).then(function (response) {
  10066. var file = new Blob([response], {
  10067. type: 'application/octet-stream'
  10068. });
  10069. // var filename = filename;
  10070. var fileURL = URL.createObjectURL(file);
  10071. var a = document.createElement('a');
  10072. a.href = fileURL;
  10073. a.target = '_blank';
  10074. a.download = filename;
  10075. document.body.appendChild(a);
  10076. a.click();
  10077. })
  10078. };
  10079. }]
  10080. });
  10081. //ui-grid展示控件
  10082. formlyConfigProvider.setType({
  10083. name: 'ui-grid-show',
  10084. extends: 'multiCheckbox',
  10085. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  10086. defaultOptions: function (options) {
  10087. return {
  10088. templateOptions: {
  10089. linkage: function () {
  10090. },
  10091. },
  10092. };
  10093. },
  10094. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  10095. var loginUser = $rootScope.user;
  10096. $scope.langs = i18nService.getAllLangs();
  10097. $scope.lang = 'zh-cn';
  10098. i18nService.setCurrentLang($scope.lang);
  10099. $scope.gridOptions = {};
  10100. $scope.gridOptions.data = 'myData';
  10101. $scope.gridOptions.enableColumnResizing = true;
  10102. // $scope.gridOptions.enableFiltering = true;
  10103. $scope.gridOptions.enableGridMenu = false;
  10104. $scope.gridOptions.enableRowSelection = true;
  10105. $scope.gridOptions.showGridFooter = true;
  10106. $scope.gridOptions.showColumnFooter = false;
  10107. $scope.gridOptions.fastWatch = true;
  10108. $scope.gridOptions.useExternalFiltering = true;
  10109. $scope.gridOptions.useExternalPagination = true;
  10110. $scope.gridOptions.paginationPageSizes = [10];
  10111. $scope.gridOptions.paginationPageSize = 10;
  10112. $scope.gridOptions.multiSelect = true;
  10113. $scope.gridOptions.rowIdentity = function (row) {
  10114. return row.id;
  10115. };
  10116. $scope.gridOptions.getRowIdentity = function (row) {
  10117. return row.id;
  10118. };
  10119. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10120. $scope.gridOptions.columnDefs = [
  10121. // { name:'id', width:80, enableFiltering:false},
  10122. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  10123. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  10124. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  10125. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  10126. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  10127. {
  10128. name: 'inspection.title',
  10129. displayName: '计划主题',
  10130. width: 120,
  10131. enableFiltering: false
  10132. },
  10133. {
  10134. name: 'stateName',
  10135. displayName: '状态',
  10136. width: 80,
  10137. enableFiltering: false
  10138. },
  10139. {
  10140. name: 'processUser.name',
  10141. displayName: '处理人',
  10142. width: 80,
  10143. enableFiltering: false
  10144. },
  10145. {
  10146. name: 'startDate',
  10147. displayName: '开始时间',
  10148. width: 160,
  10149. enableFiltering: false
  10150. },
  10151. {
  10152. name: 'overdueTime',
  10153. displayName: '逾期时间',
  10154. width: 160,
  10155. enableFiltering: false
  10156. },
  10157. ];
  10158. var defaultFilterData = {
  10159. "idx": 0,
  10160. "sum": 10
  10161. };
  10162. //分页控制
  10163. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10164. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10165. var filtersData = $scope.memoryfilterData;
  10166. filtersData.idx = newPage - 1;
  10167. filtersData.sum = pageSize;
  10168. $scope.refreshData('expand-right', filtersData);
  10169. });
  10170. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10171. data.grid.appScope.selected.items = data.entity
  10172. });
  10173. };
  10174. //页面获取数据
  10175. $scope.refreshData = function (style, filterData) {
  10176. // $scope.ldloading[style.replace('-', '_')] = true;
  10177. if (angular.isUndefined(filterData)) {
  10178. filterData = defaultFilterData;
  10179. }
  10180. $scope.myData = [];
  10181. angular.extend(filterData, {
  10182. inspectionProcessActual: {
  10183. "inspectionid": $scope.model.id
  10184. }
  10185. })
  10186. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
  10187. var myData = Restangular.stripRestangular(data);
  10188. $scope.gridOptions.totalItems = myData.totalNum;
  10189. $scope.myData = myData.list;
  10190. for (var i = 0; i < $scope.myData.length; i++) {
  10191. //添加序号
  10192. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  10193. }
  10194. // $scope.ldloading[style.replace('-', '_')] = false;
  10195. }, function () {
  10196. // $scope.ldloading[style.replace('-', '_')] = false;
  10197. });
  10198. };
  10199. $scope.refreshData('expand-right', defaultFilterData);
  10200. }
  10201. });
  10202. //文本框自定义选择面板组件
  10203. formlyConfigProvider.setType({
  10204. name: 'ui-input-selectmodal',
  10205. extends: 'input',
  10206. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  10207. defaultOptions: function (options) {
  10208. return {
  10209. templateOptions: {
  10210. openModal: function (size, options, modal) {
  10211. var modalInstance = modal.open({
  10212. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  10213. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  10214. size: size,
  10215. resolve: options.templateOptions.modalParam
  10216. });
  10217. modalInstance.result.then(function (selectedItem) {
  10218. options.value(selectedItem);
  10219. }, function () {
  10220. //console.log('Modal dismissed at: ' + new Date());
  10221. });
  10222. }
  10223. }
  10224. };
  10225. }
  10226. });
  10227. //日期控件
  10228. var datepicker_attr = [
  10229. 'date-disabled',
  10230. 'custom-class',
  10231. 'show-weeks',
  10232. 'starting-day',
  10233. 'init-date',
  10234. 'min-mode',
  10235. 'max-mode',
  10236. 'format-day',
  10237. 'format-month',
  10238. 'format-year',
  10239. 'format-day-header',
  10240. 'format-day-title',
  10241. 'format-month-title',
  10242. 'year-range',
  10243. 'shortcut-propagation',
  10244. 'datepicker-popup',
  10245. 'show-button-bar',
  10246. 'current-text',
  10247. 'clear-text',
  10248. 'close-text',
  10249. 'close-on-date-selection',
  10250. 'datepicker-append-to-body'
  10251. ];
  10252. var datepicker_bindings = [
  10253. 'datepicker-mode',
  10254. 'min-date',
  10255. 'max-date'
  10256. ];
  10257. formlyConfigProvider.setType({
  10258. name: 'ui-datetime',
  10259. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  10260. extends: 'input',
  10261. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10262. defaultOptions: {
  10263. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10264. templateOptions: {
  10265. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10266. }
  10267. },
  10268. controller: ['$scope', '$filter', function ($scope, $filter) {
  10269. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10270. $scope.options.initialValue = $scope.model[$scope.options.key];
  10271. }]
  10272. });
  10273. //日期控件
  10274. formlyConfigProvider.setType({
  10275. name: 'ui-datepicker',
  10276. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  10277. extends: 'input',
  10278. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10279. defaultOptions: {
  10280. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10281. templateOptions: {
  10282. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10283. }
  10284. },
  10285. controller: ['$scope', '$filter', function ($scope, $filter) {
  10286. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  10287. if ($scope.model[$scope.options.key]) {
  10288. } else {
  10289. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10290. }
  10291. $scope.options.initialValue = $scope.model[$scope.options.key];
  10292. $scope.endOpen = true;
  10293. $scope.datepicker = {};
  10294. $scope.datepicker.opened = false;
  10295. $scope.datepicker.open = function ($event) {
  10296. $scope.datepicker.opened = true;
  10297. };
  10298. }]
  10299. });
  10300. //时分控件
  10301. formlyConfigProvider.setType({
  10302. name: 'ui-datehourtime',
  10303. extends: 'input',
  10304. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  10305. defaultOptions: function (options) {
  10306. return {
  10307. noFormControl: true,
  10308. // validators:{
  10309. // required:{
  10310. // expression:function(viewValue, modelValue){
  10311. // console.log(options)
  10312. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  10313. // // var value = modelValue.getHours() || viewValue.getHours();
  10314. // return value.length>=1;
  10315. // }
  10316. // }
  10317. // }
  10318. }
  10319. },
  10320. controller: ['$scope', '$log', function ($scope, $log) {
  10321. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  10322. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  10323. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  10324. }]
  10325. });
  10326. //状态追踪
  10327. formlyConfigProvider.setType({
  10328. name: 'ui-followStatus',
  10329. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  10330. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10331. setTimeout(function () {
  10332. var pkey = $scope.options.templateOptions.pkey;
  10333. var dataId = $scope.model.id;
  10334. if (dataId) {
  10335. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10336. if (response) {
  10337. var myData = Restangular.stripRestangular(response);
  10338. var processInstanceId = myData.data.processInstanceId;
  10339. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10340. if (result.status == 200) {
  10341. var newData = Restangular.stripRestangular(result);
  10342. $scope.followData = newData.data;
  10343. }
  10344. });
  10345. }
  10346. })
  10347. }
  10348. }, 10);
  10349. }]
  10350. });
  10351. //历史记录
  10352. formlyConfigProvider.setType({
  10353. name: 'ui-history',
  10354. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  10355. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10356. setTimeout(function () {
  10357. var pkey = $scope.options.templateOptions.pkey;
  10358. var dataId = $scope.model.id;
  10359. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10360. if (response) {
  10361. var myData = Restangular.stripRestangular(response);
  10362. var processInstanceId = myData.data.processInstanceId;
  10363. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10364. if (result.status == 200) {
  10365. var newData = Restangular.stripRestangular(result);
  10366. var long = newData.data.length - 1;
  10367. $scope.followData = newData.data[long];
  10368. }
  10369. });
  10370. }
  10371. })
  10372. }, 10);
  10373. }]
  10374. });
  10375. // //请求人信息显示
  10376. // formlyConfigProvider.setType({
  10377. // name: "ui-disrequester",
  10378. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  10379. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10380. // defaultOptions: function(options) {
  10381. // return {
  10382. // templateOptions: {}
  10383. // };
  10384. // },
  10385. // controller: ['$scope', function($scope) {
  10386. // $scope.options.templateOptions.that = $scope;
  10387. // }]
  10388. // });
  10389. //退回人信息显示
  10390. formlyConfigProvider.setType({
  10391. name: "ui-returnperson",
  10392. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  10393. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10394. defaultOptions: function (options) {
  10395. return {
  10396. templateOptions: {}
  10397. };
  10398. },
  10399. controller: ['$scope', function ($scope) {
  10400. $scope.group = "";
  10401. $scope.role = "";
  10402. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10403. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10404. } else {
  10405. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10406. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10407. }
  10408. }
  10409. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10410. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10411. } else {
  10412. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10413. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10414. }
  10415. }
  10416. $scope.options.templateOptions.that = $scope;
  10417. $scope.options.templateOptions.that = $scope;
  10418. }]
  10419. });
  10420. //退回人信息显示(去掉工作组&角色)
  10421. formlyConfigProvider.setType({
  10422. name: "ui-returnpersonNoGroup",
  10423. templateUrl: 'assets/views/customform/tpl/ui-returnpersonNoGroup.html',
  10424. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10425. defaultOptions: function (options) {
  10426. return {
  10427. templateOptions: {}
  10428. };
  10429. },
  10430. controller: ['$scope', function ($scope) {
  10431. $scope.group = "";
  10432. $scope.role = "";
  10433. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10434. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10435. } else {
  10436. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10437. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10438. }
  10439. }
  10440. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10441. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10442. } else {
  10443. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10444. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10445. }
  10446. }
  10447. $scope.options.templateOptions.that = $scope;
  10448. $scope.options.templateOptions.that = $scope;
  10449. }]
  10450. });
  10451. //指派技术人员
  10452. formlyConfigProvider.setType({
  10453. name: "ui-apiontperson",
  10454. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  10455. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10456. defaultOptions: function (options) {
  10457. return {
  10458. templateOptions: {
  10459. transtlara: function (value, $scope) { }
  10460. }
  10461. };
  10462. },
  10463. controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
  10464. var filterData = {
  10465. "idx": 0,
  10466. "sum": 1000
  10467. }
  10468. api_user_data.fetchDataList('group', filterData).then(function (response) {
  10469. if (response.status == 200) {
  10470. $scope.select = {};
  10471. $scope.multipleDemo = {};
  10472. $scope.userdata = {};
  10473. var data = response.list;
  10474. var item = [];
  10475. $scope.multipleDemo = data;
  10476. $scope.multipleDemo;
  10477. }
  10478. })
  10479. $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
  10480. if (groupdata.option) {
  10481. $scope.model[$scope.options.key] = {};
  10482. var fildate = {
  10483. "idx": 0,
  10484. "sum": 1000,
  10485. "user": {
  10486. "roledata": {
  10487. "rolecode": model.currentRole
  10488. },
  10489. "selectType": "1",
  10490. "groupdata": {
  10491. "id": groupdata.option.id
  10492. }
  10493. }
  10494. }
  10495. api_user_data.fetchDataList('user', fildate).then(function (response) {
  10496. if (response.status == 200) {
  10497. $scope.userdata = {};
  10498. $scope.userdata = response.list;
  10499. }
  10500. })
  10501. } else {
  10502. $scope.model[$scope.options.key] = {
  10503. id: groupdata.id.id
  10504. }
  10505. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  10506. }
  10507. }
  10508. // }
  10509. }]
  10510. });
  10511. //请求科室信息(小蓝框) lmm
  10512. formlyConfigProvider.setType({
  10513. name: 'ui-deptinformation',
  10514. templateUrl: 'assets/views/customform/tpl/ui-deptinformation.html',
  10515. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10516. return {
  10517. templateOptions: {
  10518. checkform: function (options) {
  10519. }
  10520. }
  10521. };
  10522. },
  10523. controller: ['$scope', 'api_statistic', function ($scope, api_statistic) {
  10524. // console.log($scope)
  10525. }]
  10526. });
  10527. //请求人信息
  10528. formlyConfigProvider.setType({
  10529. name: 'ui-requesterinformation',
  10530. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  10531. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10532. return {
  10533. templateOptions: {
  10534. checkform: function (options) {
  10535. if (options.model.requester) {
  10536. options.value(options.model.requester);
  10537. }
  10538. },
  10539. addRequeter: function (size, options, modal) {
  10540. event.preventDefault();
  10541. var modalInstance = modal.open({
  10542. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  10543. controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
  10544. $scope.title = "新增报修人";
  10545. $scope.requester = {};
  10546. $scope.searchData = {};
  10547. $scope.onChangeadd = function (searchData) {
  10548. $scope.searchKey = searchData.account;
  10549. // $scope.searchDataadd = searchData;
  10550. var requesdata = angular.copy(searchData)
  10551. if (requesdata.mphone) {
  10552. delete requesdata.mphone;
  10553. }
  10554. $scope.requester = requesdata;
  10555. console.log($scope.requester)
  10556. }
  10557. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10558. $scope.requester.account = searchKey;
  10559. $scope.searchData = searchKey;
  10560. serchdataadd(searchKey);
  10561. }
  10562. $scope.getMydata = function (x) {
  10563. $scope.searchField = JSON.parse(x[0]).account;
  10564. $scope.requester = JSON.parse(x[0]);
  10565. console.log($scope.requester)
  10566. }
  10567. $scope.getMydataone = function (x) {
  10568. $scope.searchField = x;
  10569. $scope.requester.account = x;
  10570. }
  10571. serchdataadd();
  10572. api_wechatfile.getDictionary({
  10573. "type": "list",
  10574. "key": "male"
  10575. }).then(function (data) {
  10576. if (data.status == 200) {
  10577. requester.gender = data.list;
  10578. }
  10579. })
  10580. function serchdataadd(searchKey) {
  10581. if (searchKey) {
  10582. var filterData = {
  10583. 'requester': {
  10584. 'searchKey': searchKey,
  10585. },
  10586. idx: 0,
  10587. sum: 10
  10588. };
  10589. } else {
  10590. var filterData = {
  10591. idx: 0,
  10592. sum: 10
  10593. };
  10594. }
  10595. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10596. var myData = response;
  10597. $scope.myData = myData.list;
  10598. });
  10599. }
  10600. api_user_data.fetchDataList('area', {
  10601. idx: 0,
  10602. sum: 1000
  10603. }).then(function (response) {
  10604. if (response.status == 200) {
  10605. $scope.areas = response.list;
  10606. }
  10607. })
  10608. api_wechatfile.getDictionary({
  10609. key: "requester_type",
  10610. type: "list"
  10611. }, {
  10612. idx: 0,
  10613. sum: 100
  10614. }).then(function (response) {
  10615. if (response) {
  10616. $scope.networktypes = response;
  10617. }
  10618. })
  10619. $scope.requesterAreaid = "";
  10620. $scope.onChange = function (item) {
  10621. $scope.requesterAreaid = item.id;
  10622. api_user_data.fetchDataList('place', {
  10623. place: {
  10624. area: {
  10625. id: item.id
  10626. }
  10627. },
  10628. idx: 0,
  10629. sum: 1000
  10630. }).then(function (response) {
  10631. if (response.status == 200) {
  10632. $scope.places = response.list;
  10633. delete $scope.requester.placeDTO;
  10634. }
  10635. })
  10636. }
  10637. $scope.refresh = function (searchVal) {
  10638. var faildata = {};
  10639. if ($scope.requesterAreaid) {
  10640. faildata = {
  10641. 'idx': 0,
  10642. 'sum': 1000,
  10643. 'place': {
  10644. 'areaId': $scope.requesterAreaid,
  10645. 'place': searchVal,
  10646. 'selectType': 'pinyin_qs'
  10647. }
  10648. }
  10649. } else {
  10650. faildata = {
  10651. 'idx': 0,
  10652. 'sum': 1000,
  10653. 'place': {
  10654. 'place': searchVal,
  10655. 'selectType': 'pinyin_qs'
  10656. }
  10657. }
  10658. }
  10659. api_user_data.fetchDataList('place', faildata).then(function (response) {
  10660. $scope.places = response.list;
  10661. delete $scope.requester.placeDTO;
  10662. })
  10663. }
  10664. $scope.refreshDepts = function (key) {
  10665. var filterData = {
  10666. 'idx': 0,
  10667. 'sum': 5,
  10668. 'dept': {
  10669. 'name': key
  10670. }
  10671. };
  10672. UserService.fetchDataList('department', filterData).then(function (response) {
  10673. if (response.status == 200) {
  10674. $scope.depts = response.list;
  10675. }
  10676. })
  10677. }
  10678. $scope.ok = function () {
  10679. if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  10680. SweetAlert.swal("报修人员编号未填!", "请填写报修人员编号", "error");
  10681. } else if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  10682. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  10683. } else if (angular.isUndefined($scope.requester.requesterType) || $scope.requester.requesterType == null || $scope.requester.requesterTypeDTO == "") {
  10684. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  10685. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  10686. SweetAlert.swal("报修人联系电话未填!", "请填写报修人联系电话", "error");
  10687. } else {
  10688. $scope.requesterId = $scope.requester.id;
  10689. var data = {
  10690. incident: {
  10691. requester: {
  10692. id: $scope.requesterId
  10693. }
  10694. },
  10695. idx: 0,
  10696. sum: 3
  10697. };
  10698. api_statistic.tableData(data, 'incident').then(function (data) {
  10699. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  10700. })
  10701. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  10702. if (newObj != oldObj) {
  10703. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  10704. }
  10705. })//lmm
  10706. console.log($scope.requester)
  10707. $modalInstance.close($scope.requester);
  10708. }
  10709. };
  10710. $scope.cancel = function () {
  10711. $modalInstance.dismiss('cancel');
  10712. };
  10713. },
  10714. resolve: {
  10715. items: function () {
  10716. return {
  10717. fetchItems: function (filterData, APIService) {
  10718. filterData = filterData || {};
  10719. if (!filterData.idx) {
  10720. filterData = {
  10721. idx: 0,
  10722. sum: 10
  10723. };
  10724. }
  10725. return options.templateOptions.fetchItems(filterData, APIService);
  10726. }
  10727. };
  10728. },
  10729. title: function () {
  10730. return options.templateOptions.modalTitle;
  10731. },
  10732. Restangular: function () {
  10733. return options.templateOptions.Restangular;
  10734. },
  10735. APIService: function () {
  10736. return options.templateOptions.ApiService;
  10737. },
  10738. UserService: function () {
  10739. return options.templateOptions.UserService;
  10740. },
  10741. sco: function () {
  10742. return $scope;
  10743. }
  10744. }
  10745. });
  10746. modalInstance.result.then(function (selectedItem) {
  10747. console.log(selectedItem)
  10748. if (selectedItem) {
  10749. var data = {
  10750. 'requester': selectedItem
  10751. };
  10752. $scope.searchKey = selectedItem.account;
  10753. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  10754. if (selectedItem.place && selectedItem.place.place) {
  10755. $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  10756. }
  10757. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  10758. if (response.status == 200) {
  10759. if (options.model) {
  10760. options.model.requester = response.data
  10761. $scope.$parent.$parent.$parent.model.incident.requester = response.data;
  10762. $scope.$parent.$parent.$parent.model.requestershow = response.data;
  10763. if (options.model.place) {
  10764. options.model.place.id = '';
  10765. }
  10766. if (options.model.area) {
  10767. options.model.area.id = '';
  10768. }
  10769. options.model.contacts = selectedItem.name;
  10770. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  10771. options.model.contactsInformation = selectedItem.mphone;
  10772. } else {
  10773. options.model.contactsInformation = selectedItem.telephone;
  10774. }
  10775. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  10776. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10777. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  10778. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  10779. }
  10780. }
  10781. if (!response.data.id) {
  10782. response.data.id = selectedItem.id
  10783. }
  10784. options.value(response.data);
  10785. options.value(response.data);
  10786. console.log($scope,'0000000');
  10787. //新增报修人带入区域地点2020年4月23日19:48:15
  10788. $scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10789. $scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10790. // if ($scope.$parent.$parent.$parent.model.saveAgain) {
  10791. // if (selectedItem.place && selectedItem.place.id) {
  10792. // options.model.place.id = selectedItem.place.id
  10793. // options.model.place.area.id = selectedItem.place.area.id
  10794. // };
  10795. // } else {
  10796. // if (selectedItem.place && selectedItem.place.id) {
  10797. // options.model.place.id = selectedItem.place.id
  10798. // options.model.area.id = selectedItem.place.area.id
  10799. // };
  10800. // }
  10801. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  10802. // options.model.area.id = selectedItem.place.area.id
  10803. // }
  10804. // if (selectedItem.houseNumber) {
  10805. // options.model.houseNumber = selectedItem.houseNumber
  10806. // }
  10807. // if (selectedItem.id) {
  10808. options.model.account = selectedItem.account;
  10809. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  10810. var baoxiuFields = $scope.$parent.$parent.$parent.$parent.$parent.vm.fields[1].fields;
  10811. var baoxiurenTo;
  10812. baoxiuFields.forEach((e, i) => {
  10813. if (e.key == 'account') {
  10814. baoxiurenTo = e.templateOptions
  10815. baoxiurenTo.APIService.fetchDataList('requester', {
  10816. "idx": 0,
  10817. "sum": 20,
  10818. requester: {
  10819. searchKey: selectedItem.account
  10820. }
  10821. }).then(res => {
  10822. baoxiurenTo.options = res.list;
  10823. options.model.account = selectedItem.account;
  10824. })
  10825. }
  10826. })
  10827. // }
  10828. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  10829. // 选择重复事件侧滑框
  10830. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  10831. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  10832. setTimeout(() => {
  10833. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  10834. }, 500);
  10835. // }
  10836. }
  10837. })
  10838. }
  10839. }, function () { });
  10840. },
  10841. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  10842. var modalInstance = modal.open({
  10843. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  10844. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  10845. $scope.title = "修改报修人";
  10846. $scope.requester = {
  10847. id: modeldata.requester.id,
  10848. account: modeldata.requester.account,
  10849. name: modeldata.requester.name,
  10850. gender: modeldata.requester.gender,
  10851. email: modeldata.requester.email,
  10852. deptName: modeldata.requester.deptName,
  10853. mphone: modeldata.requester.mphone,
  10854. telephone: modeldata.requester.telephone,
  10855. studentNo: modeldata.requester.studentNo,
  10856. areaDTO: modeldata.requester.areaDTO,
  10857. placeDTO: modeldata.requester.placeDTO,
  10858. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  10859. };
  10860. $scope.onChangeadd = function (searchData) {
  10861. console.log(searchData)
  10862. $scope.searchKey = searchData.account;
  10863. var requesdata = angular.copy(searchData)
  10864. if (requesdata.mphone) {
  10865. delete requesdata.mphone;
  10866. }
  10867. $scope.requester = requesdata;
  10868. }
  10869. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10870. $scope.requester.account = searchKey;
  10871. $scope.searchData = searchKey;
  10872. serchdataadd(searchKey);
  10873. }
  10874. $scope.getMydata = function (x) {
  10875. $scope.searchField = JSON.parse(x[0]).account;
  10876. $scope.requester = JSON.parse(x[0]);
  10877. }
  10878. $scope.getMydataone = function (x) {
  10879. $scope.searchField = x;
  10880. $scope.requester.account = x;
  10881. }
  10882. serchdataadd();
  10883. function serchdataadd(searchKey) {
  10884. if (searchKey) {
  10885. var filterData = {
  10886. 'requester': {
  10887. 'searchKey': searchKey,
  10888. },
  10889. idx: 0,
  10890. sum: 10
  10891. };
  10892. } else {
  10893. var filterData = {
  10894. idx: 0,
  10895. sum: 10
  10896. };
  10897. }
  10898. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10899. var myData = response;
  10900. $scope.myData = myData.list;
  10901. });
  10902. }
  10903. api_user_data.fetchDataList('area', {
  10904. idx: 0,
  10905. sum: 1000
  10906. }).then(function (response) {
  10907. if (response.status == 200) {
  10908. $scope.areas = response.list;
  10909. }
  10910. })
  10911. api_user_data.fetchDataList('requesterType', {
  10912. idx: 0,
  10913. sum: 100
  10914. }).then(function (response) {
  10915. if (response.status == 200) {
  10916. $scope.networktypes = response.list;
  10917. }
  10918. })
  10919. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  10920. api_user_data.fetchDataList('place', {
  10921. place: {
  10922. areaId: $scope.requester.areaDTO.id
  10923. },
  10924. idx: 0,
  10925. sum: 1000
  10926. }).then(function (response) {
  10927. if (response.status == 200) {
  10928. $scope.places = response.list;
  10929. }
  10930. })
  10931. }
  10932. $scope.onChange = function (item) {
  10933. $scope.requester.placeDTO = {};
  10934. api_user_data.fetchDataList('place', {
  10935. place: {
  10936. areaId: item.id
  10937. },
  10938. idx: 0,
  10939. sum: 1000
  10940. }).then(function (response) {
  10941. if (response.status == 200) {
  10942. $scope.places = response.list;
  10943. }
  10944. })
  10945. }
  10946. $scope.refreshDepts = function (key) {
  10947. var filterData = {
  10948. 'idx': 0,
  10949. 'sum': 5,
  10950. 'dept': {
  10951. 'name': key
  10952. }
  10953. };
  10954. UserService.fetchDataList('department', filterData).then(function (response) {
  10955. if (response.status == 200) {
  10956. $scope.depts = response.list;
  10957. }
  10958. })
  10959. }
  10960. $scope.ok = function () {
  10961. if ($scope.requester.account == "" || $scope.requester.name == "") {
  10962. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  10963. } else {
  10964. $modalInstance.close($scope.requester);
  10965. }
  10966. };
  10967. $scope.cancel = function () {
  10968. $modalInstance.dismiss('cancel');
  10969. };
  10970. },
  10971. resolve: {
  10972. items: function () {
  10973. return {
  10974. fetchItems: function (filterData, APIService) {
  10975. filterData = filterData || {};
  10976. if (!filterData.idx) {
  10977. filterData = {
  10978. idx: 0,
  10979. sum: 10
  10980. };
  10981. }
  10982. return options.templateOptions.fetchItems(filterData, APIService);
  10983. }
  10984. };
  10985. },
  10986. title: function () {
  10987. return options.templateOptions.modalTitle;
  10988. },
  10989. Restangular: function () {
  10990. return options.templateOptions.Restangular;
  10991. },
  10992. APIService: function () {
  10993. return options.templateOptions.ApiService;
  10994. },
  10995. UserService: function () {
  10996. return options.templateOptions.UserService;
  10997. }
  10998. }
  10999. });
  11000. modalInstance.result.then(function (selectedItem) {
  11001. console.log(selectedItem)
  11002. if (selectedItem) {
  11003. if (options.model) {
  11004. if (options.model.place) {
  11005. options.model.place.id = '';
  11006. }
  11007. if (options.model.area) {
  11008. options.model.area.id = '';
  11009. }
  11010. options.model.contacts = selectedItem.name;
  11011. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11012. options.model.contactsInformation = selectedItem.mphone;
  11013. } else {
  11014. options.model.contactsInformation = selectedItem.telephone;
  11015. }
  11016. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11017. options.model.place.id = selectedItem.placeDTO.id
  11018. }
  11019. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11020. options.model.area.id = selectedItem.areaDTO.id
  11021. }
  11022. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11023. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11024. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11025. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11026. }
  11027. }
  11028. var data = {
  11029. 'requester': selectedItem
  11030. };
  11031. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  11032. if (response.status == 200) {
  11033. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  11034. options.value(response.data);
  11035. } else { }
  11036. })
  11037. }
  11038. }, function () { });
  11039. event.preventDefault();
  11040. }
  11041. }
  11042. };
  11043. },
  11044. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  11045. $scope.options.initialValue = $scope.model[$scope.options.key];
  11046. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  11047. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11048. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11049. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11050. }
  11051. }]
  11052. });
  11053. // 请求人选控件
  11054. formlyConfigProvider.setType({
  11055. name: "ui-requesterselect",
  11056. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  11057. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11058. defaultOptions: function (options, $scope) {
  11059. return {
  11060. templateOptions: {
  11061. // checkform: function(options) {
  11062. // if (options.model.requestershow) {
  11063. // options.value(options.model.requestershow);
  11064. // }
  11065. // },
  11066. validators: {
  11067. required: {
  11068. expression: function (viewValue, modelValue) {
  11069. var value = modelValue || viewValue;
  11070. return value.length >= 1;
  11071. }
  11072. }
  11073. },
  11074. openModal: function (size, options, modal) { //查找弹出框
  11075. var modelObject = options.value();
  11076. var searchModal = function (filterSearchData) {
  11077. var modalInstance = modal.open({
  11078. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11079. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  11080. $scope.langs = i18nService.getAllLangs();
  11081. $scope.lang = 'zh-cn';
  11082. i18nService.setCurrentLang($scope.lang);
  11083. $scope.gridOptions = {};
  11084. $scope.gridOptions.data = 'myData';
  11085. $scope.gridOptions.enableColumnResizing = true;
  11086. $scope.gridOptions.enableFiltering = true;
  11087. $scope.gridOptions.enableGridMenu = false;
  11088. $scope.gridOptions.enableRowSelection = true;
  11089. $scope.gridOptions.showGridFooter = true;
  11090. $scope.gridOptions.showColumnFooter = false;
  11091. $scope.gridOptions.fastWatch = true;
  11092. $scope.gridOptions.useExternalFiltering = true;
  11093. $scope.gridOptions.useExternalPagination = true;
  11094. $scope.gridOptions.paginationPageSizes = [10];
  11095. $scope.gridOptions.paginationPageSize = 10;
  11096. $scope.gridOptions.multiSelect = false;
  11097. $scope.gridOptions.rowIdentity = function (row) {
  11098. return row.id;
  11099. };
  11100. $scope.gridOptions.getRowIdentity = function (row) {
  11101. return row.id;
  11102. };
  11103. $scope.gridOptions.columnDefs = [{
  11104. name: 'account',
  11105. displayName: '人员编号',
  11106. width: 140
  11107. },
  11108. {
  11109. name: 'name',
  11110. displayName: '姓名',
  11111. width: 100
  11112. },
  11113. {
  11114. name: 'gender.name',
  11115. displayName: '性别',
  11116. width: 80,
  11117. enableFiltering: false
  11118. },
  11119. {
  11120. name: 'mphone',
  11121. displayName: '电话',
  11122. width: 100,
  11123. enableFiltering: false
  11124. },
  11125. {
  11126. name: 'email',
  11127. displayName: '邮件',
  11128. width: 100
  11129. },
  11130. {
  11131. name: 'areaDTO.area',
  11132. displayName: '区域',
  11133. width: 100,
  11134. enableFiltering: false
  11135. },
  11136. {
  11137. name: 'placeDTO.place',
  11138. displayName: '地点',
  11139. enableFiltering: false
  11140. }
  11141. ];
  11142. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11143. $scope.gridApi = gridApi;
  11144. // var filtersData = $scope.memoryfilterData;
  11145. // filtersData.idx = newPage - 1;
  11146. // filtersData.sum = pageSize;
  11147. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11148. var filtersData = $scope.memoryfilterData;
  11149. filtersData.idx = newPage - 1;
  11150. filtersData.sum = pageSize;
  11151. $scope.loadData(filtersData);
  11152. });
  11153. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11154. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  11155. $scope.selected.item = data.entity;
  11156. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  11157. });
  11158. gridApi.core.on.filterChanged($scope, function () {
  11159. var grid = this.grid;
  11160. var filtersData = {
  11161. idx: 0,
  11162. sum: 10
  11163. // 'requester': { 'userType': 1 }
  11164. };
  11165. angular.forEach(grid.columns, function (item) {
  11166. if (item.enableFiltering) {
  11167. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11168. if (angular.isUndefined(filtersData['requester'])) {
  11169. filtersData['requester'] = {};
  11170. }
  11171. filtersData['requester'][item.field] = item.filters[0].term;
  11172. }
  11173. }
  11174. });
  11175. $scope.memoryfilterData = filtersData;
  11176. $scope.loadData(filtersData);
  11177. });
  11178. };
  11179. $scope.memoryfilterData = defaultFilterData = {
  11180. "idx": 0,
  11181. "sum": 10
  11182. };
  11183. $scope.loadData = function (filterData) {
  11184. if (!filterData.requester) {
  11185. filterData.requester = {};
  11186. }
  11187. if (scope.roleidcode) {
  11188. angular.extend(filterData['requester'], {
  11189. 'userType': 1
  11190. });
  11191. }
  11192. items.fetchItems(filterData, APIService).then(function (data) {
  11193. var myData = Restangular.stripRestangular(data);
  11194. $scope.gridOptions.totalItems = myData.totalNum;
  11195. $scope.myData = myData.list;
  11196. });
  11197. };
  11198. // $scope.title = title;
  11199. if (searchDatas) {
  11200. $scope.loadData(searchDatas);
  11201. } else {
  11202. $scope.loadData({
  11203. idx: 0,
  11204. sum: 10,
  11205. });
  11206. }
  11207. $scope.selected = {
  11208. item: {}
  11209. };
  11210. $scope.ok = function () {
  11211. $modalInstance.close($scope.selected.item);
  11212. };
  11213. $scope.cancel = function () {
  11214. $modalInstance.dismiss('cancel');
  11215. };
  11216. },
  11217. size: size,
  11218. resolve: {
  11219. items: function () {
  11220. return {
  11221. fetchItems: function (filterData, APIService) {
  11222. filterData = filterData || {};
  11223. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  11224. filterData = {
  11225. idx: 0,
  11226. sum: 10
  11227. };
  11228. }
  11229. return options.templateOptions.fetchItems(filterData, APIService);
  11230. }
  11231. };
  11232. },
  11233. title: function () {
  11234. return options.templateOptions.modalTitle;
  11235. },
  11236. Restangular: function () {
  11237. return options.templateOptions.Restangular;
  11238. },
  11239. APIService: function () {
  11240. return options.templateOptions.ApiService;
  11241. },
  11242. language: function () {
  11243. return options.templateOptions.language;
  11244. },
  11245. searchDatas: function () {
  11246. return filterSearchData;
  11247. },
  11248. scope: function () {
  11249. return $scope;
  11250. }
  11251. }
  11252. });
  11253. modalInstance.result.then(function (selectedItem) {
  11254. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11255. selectedItem.telephone = $scope.model.incident.contactsInformation;
  11256. }
  11257. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  11258. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  11259. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  11260. if ($scope.model) {
  11261. if ($scope.model.incident.place) {
  11262. $scope.model.incident.place.id = '';
  11263. }
  11264. if ($scope.model.area) {
  11265. $scope.model.incident.area.id = '';
  11266. }
  11267. $scope.model.incident.contacts = selectedItem.name;
  11268. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11269. $scope.model.incident.contactsInformation = selectedItem.mphone;
  11270. } else {
  11271. $scope.model.incident.contactsInformation = selectedItem.telephone;
  11272. }
  11273. $scope.model.incident.houseNumber = '';
  11274. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11275. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11276. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11277. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11278. }
  11279. }
  11280. $scope.options.value(selectedItem);
  11281. $scope.searchData = selectedItem.account;
  11282. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11283. $scope.model.incident.place.id = selectedItem.placeDTO.id
  11284. }
  11285. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11286. $scope.model.incident.area.id = selectedItem.areaDTO.id
  11287. }
  11288. if (selectedItem.houseNumber) {
  11289. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  11290. }
  11291. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11292. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11293. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11294. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11295. }
  11296. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  11297. options.templateOptions.callback(selectedItem, options);
  11298. }
  11299. if (!$scope.roleidcode) {
  11300. $scope.charging(selectedItem, modal)
  11301. }
  11302. $scope.recentlyincident(selectedItem);
  11303. }, function () {
  11304. //console.log('Modal dismissed at: ' + new Date());
  11305. });
  11306. }
  11307. searchModal();
  11308. // }
  11309. }
  11310. }
  11311. };
  11312. },
  11313. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  11314. $scope.roleidcode = true;
  11315. // $scope.options.initialValue = undefined;
  11316. if ($rootScope.user && $rootScope.user.role) {
  11317. angular.forEach($rootScope.user.role, function (item) {
  11318. if (item.rolecode == "call center") {
  11319. $scope.roleidcode = false;
  11320. }
  11321. })
  11322. }
  11323. $scope.recently = false;
  11324. $scope.recentlyincident = function (key, model) { //关联事件
  11325. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  11326. "idx": 0,
  11327. "sum": 4,
  11328. incident: {
  11329. requester: {
  11330. id: key.id
  11331. }
  11332. }
  11333. }).then(function (response) {
  11334. if (response.status == 200) {
  11335. $scope.recently = true;
  11336. $scope.recentincident = response.list;
  11337. } else {
  11338. $scope.recently = false;
  11339. }
  11340. })
  11341. $scope.bodyHeight = window.innerHeight - 100;
  11342. $(window).resize(function () {
  11343. $scope.bodyHeight = window.innerHeight - 100;
  11344. });
  11345. // $scope.shows = false;
  11346. $scope.tempData = {};
  11347. $scope.close = function () {
  11348. $scope.changes = !$scope.changes;
  11349. event.preventDefault();
  11350. }
  11351. }
  11352. $scope.charging = function (key, model) { //计费弹出框
  11353. //用户信息
  11354. $scope.information = {};
  11355. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  11356. "userId": key.account
  11357. }).then(function (response) {
  11358. // if (response.status == 200) {
  11359. if (response && response.data) {
  11360. angular.extend($scope.information, response.data[0]);
  11361. // $scope.information = response.data[0];
  11362. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  11363. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  11364. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  11365. } else if (response.err) {
  11366. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  11367. }
  11368. // }
  11369. })
  11370. //上网明细
  11371. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  11372. "userId": key.account,
  11373. "limit": "10",
  11374. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  11375. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  11376. }).then(function (response) {
  11377. // if (response.status == 200) {
  11378. if (response && response.data) {
  11379. angular.forEach(response.data, function (item, index) {
  11380. if (item.logoutTime) {
  11381. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  11382. }
  11383. if (item.loginTime) {
  11384. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  11385. }
  11386. })
  11387. $scope.logininform = response.data;
  11388. } else if (response.err) {
  11389. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  11390. }
  11391. })
  11392. //黑名单
  11393. // $scope.information.blacklist = "否"
  11394. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  11395. "userId": key.account
  11396. }).then(function (response) {
  11397. // if (response.status == 200) {
  11398. // $scope.logininformation = response.data;
  11399. if (response) {
  11400. if (response.data || response.data != null) {
  11401. $scope.information.blacklist = "是"
  11402. } else {
  11403. if (response.err) {
  11404. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  11405. } else {
  11406. $scope.information.blacklist = "否"
  11407. }
  11408. }
  11409. }
  11410. // }
  11411. })
  11412. $scope.bodyHeight = window.innerHeight - 100;
  11413. $(window).resize(function () {
  11414. $scope.bodyHeight = window.innerHeight - 100;
  11415. });
  11416. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  11417. // $scope.closepages = function(e) {
  11418. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  11419. // event.preventDefault();
  11420. // };
  11421. // $scope.shows = false;
  11422. $scope.tempData = {};
  11423. $scope.close = function () {
  11424. $scope.changes = !$scope.changes;
  11425. event.preventDefault();
  11426. }
  11427. }
  11428. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  11429. idx: 0,
  11430. sum: 100
  11431. }).then(function (response) {
  11432. if (response.status == 200) {
  11433. $scope.networktypes = response.list;
  11434. } else {
  11435. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  11436. }
  11437. })
  11438. function serchdata(searchKey) {
  11439. if (searchKey) {
  11440. var filterData = {
  11441. 'requester': {
  11442. 'searchKey': searchKey
  11443. // 'userType': 1
  11444. },
  11445. idx: 0,
  11446. sum: 10
  11447. };
  11448. } else {
  11449. var filterData = {
  11450. 'idx': 0,
  11451. 'requester': {},
  11452. 'sum': 10
  11453. };
  11454. }
  11455. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  11456. angular.extend(filterData.requester, {
  11457. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  11458. });
  11459. if (!$scope.options.model.contactsInformation) {
  11460. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  11461. }
  11462. }
  11463. if ($scope.roleidcode) {
  11464. angular.extend(filterData['requester'], {
  11465. 'userType': 1
  11466. });
  11467. }
  11468. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  11469. var myData = response;
  11470. $scope.myData = myData.list;
  11471. });
  11472. }
  11473. $scope.searchData = {};
  11474. $scope.refreshUser = function (searchKey) { //请求人搜索
  11475. if (searchKey && searchKey != "") {
  11476. serchdata(searchKey);
  11477. }
  11478. }
  11479. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  11480. if (!$scope.roleidcode) {
  11481. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  11482. }
  11483. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  11484. }
  11485. $scope.onChange = function (searchData) {
  11486. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11487. searchData.telephone = $scope.model.incident.contactsInformation;;
  11488. }
  11489. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  11490. if (!$scope.roleidcode) {
  11491. $scope.charging(searchData);
  11492. }
  11493. $scope.recentlyincident(searchData);
  11494. $scope.accountshow = false;
  11495. if ($scope.model.incident) {
  11496. if ($scope.model.incident.place) {
  11497. $scope.model.incident.place.id = '';
  11498. }
  11499. if ($scope.model.incident.area) {
  11500. $scope.model.incident.area.id = '';
  11501. }
  11502. $scope.model.incident.contacts = searchData.name;
  11503. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  11504. $scope.model.incident.contactsInformation = searchData.mphone;
  11505. } else {
  11506. $scope.model.incident.contactsInformation = searchData.telephone;
  11507. }
  11508. $scope.model.incident.houseNumber = '';
  11509. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11510. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11511. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11512. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11513. }
  11514. }
  11515. $scope.options.value(searchData);
  11516. $scope.searchKey = searchData.account;
  11517. if (searchData.placeDTO && searchData.placeDTO.id) {
  11518. $scope.model.incident.place.id = searchData.placeDTO.id
  11519. }
  11520. if (searchData.areaDTO && searchData.areaDTO.id) {
  11521. $scope.model.incident.area.id = searchData.areaDTO.id
  11522. }
  11523. if (searchData.houseNumber) {
  11524. $scope.model.incident.houseNumber = searchData.houseNumber;
  11525. }
  11526. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11527. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11528. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11529. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11530. }
  11531. }
  11532. }]
  11533. });
  11534. //ui-grid-table展示控件
  11535. formlyConfigProvider.setType({
  11536. name: 'ui-grid-table',
  11537. // extends: 'multiCheckbox',//去掉冒号
  11538. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  11539. defaultOptions: function (options) {
  11540. return {
  11541. templateOptions: {
  11542. linkage: function () { },
  11543. },
  11544. };
  11545. },
  11546. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  11547. var loginUser = $rootScope.user;
  11548. $scope.langs = i18nService.getAllLangs();
  11549. $scope.lang = 'zh-cn';
  11550. i18nService.setCurrentLang($scope.lang);
  11551. $scope.gridOptions = {};
  11552. $scope.gridOptions.data = 'myData';
  11553. $scope.gridOptions.enableColumnResizing = true;
  11554. $scope.gridOptions.enableGridMenu = false;
  11555. $scope.gridOptions.enableRowSelection = true;
  11556. $scope.gridOptions.showGridFooter = false;
  11557. $scope.gridOptions.showColumnFooter = false;
  11558. $scope.gridOptions.fastWatch = true;
  11559. $scope.gridOptions.useExternalFiltering = true;
  11560. $scope.gridOptions.useExternalPagination = false;
  11561. $scope.gridOptions.paginationPageSizes = [10];
  11562. $scope.gridOptions.paginationPageSize = 3;
  11563. $scope.gridOptions.multiSelect = false;
  11564. $scope.gridOptions.rowIdentity = function (row) {
  11565. return row.id;
  11566. };
  11567. $scope.gridOptions.getRowIdentity = function (row) {
  11568. return row.id;
  11569. };
  11570. $scope.gridOptions.columnDefs = [{
  11571. name: 'item',
  11572. displayName: '序号',
  11573. width: 80,
  11574. enableFiltering: false
  11575. },
  11576. {
  11577. name: 'incidentsign',
  11578. displayName: '单号',
  11579. width: 80,
  11580. enableFiltering: false
  11581. },
  11582. {
  11583. name: 'description',
  11584. displayName: '主题',
  11585. width: 80,
  11586. enableFiltering: false
  11587. },
  11588. {
  11589. name: 'state.name',
  11590. displayName: '状态',
  11591. width: 110,
  11592. enableFiltering: false
  11593. },
  11594. {
  11595. name: 'acceptDate',
  11596. displayName: '创建时间',
  11597. width: 160,
  11598. enableFiltering: false
  11599. },
  11600. {
  11601. name: 'requester.name',
  11602. displayName: '请求人',
  11603. width: 80,
  11604. enableFiltering: false
  11605. },
  11606. {
  11607. name: 'handlingPersonnelUser.name',
  11608. displayName: '处理人',
  11609. width: 160,
  11610. enableFiltering: false
  11611. },
  11612. {
  11613. name: 'place.place',
  11614. displayName: '区域地点',
  11615. width: 160,
  11616. enableFiltering: false
  11617. },
  11618. ];
  11619. // var defaultFilterData = {
  11620. // "idx": 0,
  11621. // "sum": 3
  11622. // };
  11623. // // //分页控制
  11624. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11625. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11626. var filtersData = $scope.memoryfilterData;
  11627. filtersData.idx = newPage - 1;
  11628. filtersData.sum = pageSize;
  11629. $scope.refreshData('expand-right', filtersData);
  11630. });
  11631. // 表格单选事件
  11632. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11633. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  11634. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  11635. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  11636. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  11637. str = str.split("").reverse().join("");
  11638. var del = addstr.split("").reverse().join("");
  11639. // console.log(del);
  11640. var reg = new RegExp(del);
  11641. str = str.replace(reg, '');
  11642. str = str.split("").reverse().join("")
  11643. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  11644. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  11645. str += data.entity.description;
  11646. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  11647. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  11648. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  11649. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  11650. }
  11651. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  11652. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  11653. });
  11654. };
  11655. // 刷新表格
  11656. setInterval(function () {
  11657. // console.log($scope.myData);
  11658. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  11659. // console.log($scope.myData);
  11660. if ($scope.myData != null) {
  11661. for (var i = 0; i < $scope.myData.length; i++) {
  11662. //添加序号
  11663. $scope.myData[i]['item'] = i + 1;
  11664. }
  11665. }
  11666. }, 1000)
  11667. }
  11668. });
  11669. //处理人信息
  11670. formlyConfigProvider.setType({
  11671. name: "ui-userinformation",
  11672. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  11673. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11674. defaultOptions: function (options) {
  11675. return {
  11676. templateOptions: {}
  11677. };
  11678. },
  11679. controller: ['$scope', function ($scope) {
  11680. $scope.group = "";
  11681. $scope.role = "";
  11682. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11683. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11684. } else {
  11685. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11686. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11687. }
  11688. }
  11689. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  11690. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  11691. } else {
  11692. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  11693. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  11694. }
  11695. }
  11696. $scope.options.templateOptions.that = $scope;
  11697. }]
  11698. });
  11699. //处理界面处理人信息
  11700. formlyConfigProvider.setType({
  11701. name: "ui-handler",
  11702. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  11703. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11704. defaultOptions: function (options) {
  11705. return {
  11706. templateOptions: {}
  11707. };
  11708. },
  11709. controller: ['$scope', function ($scope) {
  11710. $scope.group = "";
  11711. // $scope.role="";
  11712. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11713. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11714. } else {
  11715. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11716. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11717. }
  11718. }
  11719. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  11720. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  11721. // }else{
  11722. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  11723. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  11724. // }
  11725. // }
  11726. $scope.options.templateOptions.that = $scope;
  11727. }]
  11728. });
  11729. //微信事件流程
  11730. formlyConfigProvider.setType({
  11731. name: "ui-wxIncidentProcess",
  11732. templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
  11733. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11734. defaultOptions: function (options) {
  11735. return {
  11736. templateOptions: {}
  11737. };
  11738. },
  11739. controller: ['$scope', function ($scope) {
  11740. console.log($scope.model);
  11741. $scope.pingjia = false;
  11742. $scope.jiejue = false;
  11743. if ($scope.model.incidentState.value == "3") {
  11744. $scope.pingjia = true
  11745. } else if ($scope.model.incidentState.value == "4") {
  11746. $scope.jiejue = true;
  11747. }
  11748. }]
  11749. });
  11750. //打电话
  11751. formlyConfigProvider.setType({
  11752. name: "ui-inputcall",
  11753. extends: 'input',
  11754. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  11755. defaultOptions: function (options) {
  11756. return {
  11757. templateOptions: {
  11758. transform: function (value) { }
  11759. }
  11760. };
  11761. },
  11762. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  11763. $scope.dialout = function (teleno) {
  11764. var gid = "@0"
  11765. var telephone = '9' + teleno
  11766. $rootScope.callout = 2;
  11767. if ($rootScope.takes) {
  11768. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11769. if (data.errno == 0) {
  11770. $rootScope.status = 6;
  11771. }
  11772. })
  11773. } else {
  11774. SweetAlert.swal({
  11775. title: "呼叫失败",
  11776. text: "请先签入呼叫中心!",
  11777. type: "error",
  11778. confirmButtonColor: "#DD6B55"
  11779. });
  11780. }
  11781. }
  11782. $scope.options.templateOptions.that = $scope;
  11783. }]
  11784. });
  11785. //关闭界面处理人信息
  11786. formlyConfigProvider.setType({
  11787. name: "ui-closehandler",
  11788. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  11789. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11790. defaultOptions: function (options) {
  11791. return {
  11792. templateOptions: {}
  11793. };
  11794. },
  11795. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  11796. $scope.dialout = function (teleno) {
  11797. var gid = "@0"
  11798. var telephone = '9' + teleno
  11799. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11800. if (data.errno == 0) {
  11801. $rootScope.status = 6;
  11802. }
  11803. })
  11804. }
  11805. $scope.options.templateOptions.that = $scope;
  11806. }]
  11807. });
  11808. //用户单选控件
  11809. formlyConfigProvider.setType({
  11810. name: "ui-userselect",
  11811. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  11812. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11813. defaultOptions: function (options) {
  11814. return {
  11815. templateOptions: {
  11816. openModal: function (size, options, modal) {
  11817. var modalInstance = modal.open({
  11818. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11819. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  11820. $scope.langs = i18nService.getAllLangs();
  11821. $scope.lang = 'zh-cn';
  11822. i18nService.setCurrentLang($scope.lang);
  11823. $scope.gridOptions = {};
  11824. $scope.gridOptions.data = 'myData';
  11825. $scope.gridOptions.enableColumnResizing = true;
  11826. $scope.gridOptions.enableFiltering = true;
  11827. $scope.gridOptions.enableGridMenu = false;
  11828. $scope.gridOptions.showGridFooter = true;
  11829. $scope.gridOptions.showColumnFooter = false;
  11830. $scope.gridOptions.fastWatch = true;
  11831. $scope.gridOptions.useExternalFiltering = true;
  11832. $scope.gridOptions.useExternalPagination = true;
  11833. $scope.gridOptions.paginationPageSizes = [10];
  11834. $scope.gridOptions.paginationPageSize = 10;
  11835. $scope.gridOptions.multiSelect = false;
  11836. $scope.gridOptions.rowIdentity = function (row) {
  11837. return row.id;
  11838. };
  11839. $scope.gridOptions.getRowIdentity = function (row) {
  11840. return row.id;
  11841. };
  11842. $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>";
  11843. $scope.gridOptions.columnDefs = [{
  11844. name: 'account',
  11845. displayName: '人员编号',
  11846. width: 120
  11847. },
  11848. {
  11849. name: 'name',
  11850. displayName: '姓名',
  11851. width: 100,
  11852. cellTemplate: '<div>' +
  11853. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  11854. '</div>'
  11855. },
  11856. // {
  11857. // name: 'gender.name',
  11858. // displayName: '性别',
  11859. // width: 80,
  11860. // enableFiltering: false
  11861. // },
  11862. {
  11863. name: 'phone',
  11864. displayName: '电话',
  11865. width: 230,
  11866. enableFiltering: false
  11867. },
  11868. {
  11869. name: 'email',
  11870. displayName: '邮箱',
  11871. width: 180,
  11872. enableFiltering: false
  11873. },
  11874. {
  11875. name: 'dept.dept',
  11876. displayName: '科室',
  11877. width: 130,
  11878. enableFiltering: false
  11879. },
  11880. {
  11881. name: 'taskCount',
  11882. displayName: '处理中事件数',
  11883. enableFiltering: false
  11884. }
  11885. ];
  11886. // $scope.selectButtonClick
  11887. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11888. $scope.gridApi = gridApi;
  11889. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11890. var filtersData = $scope.memoryfilterData;
  11891. filtersData.idx = newPage - 1;
  11892. filtersData.sum = pageSize;
  11893. $scope.loadData(filtersData);
  11894. //console.log(pageSize);
  11895. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  11896. });
  11897. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11898. $scope.selected.items = data.entity;
  11899. //console.log(data);
  11900. });
  11901. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  11902. $scope.selected.items = data.entity;
  11903. //console.log(data);
  11904. });
  11905. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  11906. // // if (row.entity.age > 45) {
  11907. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11908. // // }
  11909. // };
  11910. gridApi.core.on.filterChanged($scope, function () {
  11911. var grid = this.grid;
  11912. var filtersData = {
  11913. idx: 0,
  11914. sum: 10,
  11915. "user": {
  11916. "roledata": {
  11917. "rolecode": "roleset"
  11918. },
  11919. "selectType": "1"
  11920. }
  11921. };
  11922. angular.forEach(grid.columns, function (item) {
  11923. if (item.enableFiltering) {
  11924. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  11925. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11926. if (angular.isUndefined(filtersData['user'])) {
  11927. filtersData['user'] = {};
  11928. }
  11929. filtersData['user'][item.field] = item.filters[0].term;
  11930. }
  11931. }
  11932. });
  11933. $scope.memoryfilterData = filtersData;
  11934. $scope.loadData(filtersData);
  11935. });
  11936. };
  11937. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  11938. // if (row.entity.age > 45) {
  11939. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11940. // }
  11941. // },
  11942. $scope.onDblClick = function (data, event) {
  11943. // $scope.selected.items = data.entity;
  11944. $scope.selectButtonClick(data, event);
  11945. };
  11946. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  11947. // $scope.selected.items = data.entity;
  11948. // })
  11949. // };
  11950. $scope.memoryfilterData = {
  11951. "idx": 0,
  11952. "sum": 10,
  11953. "user": {
  11954. "roledata": {
  11955. "rolecode": "roleset"
  11956. },
  11957. "selectType": "1"
  11958. }
  11959. }
  11960. $scope.loadData = function (filterData) {
  11961. // console.log("filtersData=111" + JSON.stringify(filterData))
  11962. items.fetchItems(filterData, APIService).then(function (data) {
  11963. var myData = Restangular.stripRestangular(data);
  11964. $scope.gridOptions.totalItems = myData.totalNum;
  11965. $scope.myData = myData.list;
  11966. });
  11967. };
  11968. // $scope.title = title;
  11969. $scope.loadData({
  11970. idx: 0,
  11971. sum: 10,
  11972. "user": {
  11973. "roledata": {
  11974. "rolecode": "roleset"
  11975. },
  11976. "selectType": "1"
  11977. }
  11978. });
  11979. $scope.selected = {
  11980. items: {}
  11981. };
  11982. $scope.ok = function () {
  11983. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  11984. // onDataCallback($scope.selected.item, parentScope);
  11985. // }
  11986. $modalInstance.close($scope.selected.items);
  11987. };
  11988. $scope.cancel = function () {
  11989. $modalInstance.dismiss('cancel');
  11990. };
  11991. },
  11992. size: size,
  11993. resolve: {
  11994. items: function () {
  11995. return {
  11996. fetchItems: function (filterData, APIService) {
  11997. filterData = filterData || {};
  11998. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  11999. filterData = {
  12000. idx: 0,
  12001. sum: 10,
  12002. "user": {
  12003. "roledata": {
  12004. "rolecode": "roleset"
  12005. },
  12006. "selectType": "1"
  12007. }
  12008. };
  12009. }
  12010. return options.templateOptions.fetchItems(filterData, APIService);
  12011. }
  12012. };
  12013. },
  12014. title: function () {
  12015. return options.templateOptions.label;
  12016. },
  12017. Restangular: function () {
  12018. return options.templateOptions.Restangular;
  12019. },
  12020. APIService: function () {
  12021. return options.templateOptions.ApiService;
  12022. },
  12023. onDataCallback: function () {
  12024. return options.templateOptions.callback;
  12025. },
  12026. parentScope: function () {
  12027. return options.templateOptions.that;
  12028. }
  12029. }
  12030. });
  12031. modalInstance.result.then(function (selectedItem) {
  12032. // console.log(selectedItem);
  12033. options.value(selectedItem);
  12034. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12035. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12036. }
  12037. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12038. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12039. }
  12040. }, function () {
  12041. //console.log('Modal dismissed at: ' + new Date());
  12042. });
  12043. }
  12044. }
  12045. };
  12046. },
  12047. controller: ['$scope', function ($scope) {
  12048. $scope.options.templateOptions.that = $scope;
  12049. // $scope.options.model[$scope.options.key] = {}
  12050. }]
  12051. });
  12052. //用户单选控件(dd 单选input带搜索)
  12053. formlyConfigProvider.setType({
  12054. name: "ui-userselectSearch",
  12055. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  12056. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12057. defaultOptions: function (options) {
  12058. return {
  12059. templateOptions: {
  12060. openModal: function (size, options, modal) {
  12061. var modalInstance = modal.open({
  12062. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12063. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  12064. $scope.langs = i18nService.getAllLangs();
  12065. $scope.lang = 'zh-cn';
  12066. i18nService.setCurrentLang($scope.lang);
  12067. $scope.gridOptions = {};
  12068. $scope.gridOptions.data = 'myData';
  12069. $scope.gridOptions.enableColumnResizing = true;
  12070. $scope.gridOptions.enableFiltering = true;
  12071. $scope.gridOptions.enableGridMenu = false;
  12072. $scope.gridOptions.showGridFooter = true;
  12073. $scope.gridOptions.showColumnFooter = false;
  12074. $scope.gridOptions.fastWatch = true;
  12075. $scope.gridOptions.useExternalFiltering = true;
  12076. $scope.gridOptions.useExternalPagination = true;
  12077. $scope.gridOptions.paginationPageSizes = [10];
  12078. $scope.gridOptions.paginationPageSize = 10;
  12079. $scope.gridOptions.multiSelect = false;
  12080. $scope.gridOptions.rowIdentity = function (row) {
  12081. return row.id;
  12082. };
  12083. $scope.gridOptions.getRowIdentity = function (row) {
  12084. return row.id;
  12085. };
  12086. $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>";
  12087. $scope.gridOptions.columnDefs = [{
  12088. name: 'account',
  12089. displayName: '人员编号',
  12090. width: 120
  12091. },
  12092. {
  12093. name: 'name',
  12094. displayName: '姓名',
  12095. width: 100,
  12096. cellTemplate: '<div>' +
  12097. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  12098. '</div>'
  12099. },
  12100. // {
  12101. // name: 'gender.name',
  12102. // displayName: '性别',
  12103. // width: 80,
  12104. // enableFiltering: false
  12105. // },
  12106. {
  12107. name: 'phone',
  12108. displayName: '电话',
  12109. width: 230,
  12110. enableFiltering: false
  12111. },
  12112. {
  12113. name: 'email',
  12114. displayName: '邮箱',
  12115. width: 180,
  12116. enableFiltering: false
  12117. },
  12118. {
  12119. name: 'dept.dept',
  12120. displayName: '科室',
  12121. width: 130,
  12122. enableFiltering: false
  12123. },
  12124. {
  12125. name: 'taskCount',
  12126. displayName: '处理中事件数',
  12127. enableFiltering: false
  12128. }
  12129. ];
  12130. // $scope.selectButtonClick
  12131. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12132. $scope.gridApi = gridApi;
  12133. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12134. var filtersData = $scope.memoryfilterData;
  12135. filtersData.idx = newPage - 1;
  12136. filtersData.sum = pageSize;
  12137. $scope.loadData(filtersData);
  12138. //console.log(pageSize);
  12139. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12140. });
  12141. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12142. $scope.selected.items = data.entity;
  12143. //console.log(data);
  12144. });
  12145. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  12146. $scope.selected.items = data.entity;
  12147. //console.log(data);
  12148. });
  12149. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  12150. // // if (row.entity.age > 45) {
  12151. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12152. // // }
  12153. // };
  12154. gridApi.core.on.filterChanged($scope, function () {
  12155. var grid = this.grid;
  12156. var filtersData = {
  12157. idx: 0,
  12158. sum: 10,
  12159. user: {
  12160. roledata: {
  12161. rolecode: "first-line support"
  12162. },
  12163. selectType: "1"
  12164. }
  12165. };
  12166. angular.forEach(grid.columns, function (item) {
  12167. if (item.enableFiltering) {
  12168. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  12169. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12170. if (angular.isUndefined(filtersData['user'])) {
  12171. filtersData['user'] = {};
  12172. }
  12173. filtersData['user'][item.field] = item.filters[0].term;
  12174. }
  12175. }
  12176. });
  12177. $scope.memoryfilterData = filtersData;
  12178. $scope.loadData(filtersData);
  12179. });
  12180. };
  12181. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  12182. // if (row.entity.age > 45) {
  12183. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12184. // }
  12185. // },
  12186. $scope.onDblClick = function (data, event) {
  12187. // $scope.selected.items = data.entity;
  12188. $scope.selectButtonClick(data, event);
  12189. };
  12190. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  12191. // $scope.selected.items = data.entity;
  12192. // })
  12193. // };
  12194. $scope.memoryfilterData = {
  12195. idx: 0,
  12196. sum: 10,
  12197. user: {
  12198. roledata: {
  12199. rolecode: "first-line support"
  12200. },
  12201. selectType: "1"
  12202. }
  12203. }
  12204. $scope.loadData = function (filterData) {
  12205. // console.log("filtersData=111" + JSON.stringify(filterData))
  12206. items.fetchItems(filterData, APIService).then(function (data) {
  12207. var myData = Restangular.stripRestangular(data);
  12208. $scope.gridOptions.totalItems = myData.totalNum;
  12209. $scope.myData = myData.list;
  12210. });
  12211. };
  12212. $scope.title = title;
  12213. $scope.loadData({
  12214. idx: 0,
  12215. sum: 10,
  12216. user: {
  12217. roledata: {
  12218. rolecode: "first-line support"
  12219. },
  12220. selectType: "1"
  12221. }
  12222. });
  12223. $scope.selected = {
  12224. items: {}
  12225. };
  12226. $scope.ok = function () {
  12227. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12228. // onDataCallback($scope.selected.item, parentScope);
  12229. // }
  12230. $modalInstance.close($scope.selected.items);
  12231. };
  12232. $scope.cancel = function () {
  12233. $modalInstance.dismiss('cancel');
  12234. };
  12235. },
  12236. size: size,
  12237. resolve: {
  12238. items: function () {
  12239. return {
  12240. fetchItems: function (filterData, APIService) {
  12241. filterData = filterData || {};
  12242. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12243. filterData = {
  12244. idx: 0,
  12245. sum: 10,
  12246. user: {
  12247. roledata: {
  12248. rolecode: "first-line support"
  12249. },
  12250. selectType: "1"
  12251. }
  12252. };
  12253. }
  12254. return options.templateOptions.fetchItems(filterData, APIService);
  12255. }
  12256. };
  12257. },
  12258. title: function () {
  12259. return options.templateOptions.label;
  12260. },
  12261. Restangular: function () {
  12262. return options.templateOptions.Restangular;
  12263. },
  12264. APIService: function () {
  12265. return options.templateOptions.ApiService;
  12266. },
  12267. onDataCallback: function () {
  12268. return options.templateOptions.callback;
  12269. },
  12270. parentScope: function () {
  12271. return options.templateOptions.that;
  12272. }
  12273. }
  12274. });
  12275. modalInstance.result.then(function (selectedItem) {
  12276. // console.log(selectedItem);
  12277. options.value(selectedItem);
  12278. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12279. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12280. }
  12281. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12282. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12283. }
  12284. }, function () {
  12285. //console.log('Modal dismissed at: ' + new Date());
  12286. });
  12287. }
  12288. }
  12289. };
  12290. },
  12291. controller: ['$scope', function ($scope) {
  12292. $scope.options.templateOptions.that = $scope;
  12293. }]
  12294. });
  12295. //用户多选控件
  12296. formlyConfigProvider.setType({
  12297. name: "ui-multiuserselect",
  12298. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  12299. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12300. defaultOptions: function (options) {
  12301. return {
  12302. templateOptions: {
  12303. openModal: function (size, options, modal, model) {
  12304. var modalInstance = modal.open({
  12305. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12306. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  12307. $scope.langs = i18nService.getAllLangs();
  12308. $scope.lang = 'zh-cn';
  12309. i18nService.setCurrentLang($scope.lang);
  12310. $scope.gridOptions = {};
  12311. $scope.gridOptions.data = 'myData';
  12312. $scope.gridOptions.enableColumnResizing = true;
  12313. $scope.gridOptions.enableFiltering = true;
  12314. $scope.gridOptions.enableGridMenu = true;
  12315. $scope.gridOptions.showGridFooter = true;
  12316. $scope.gridOptions.showColumnFooter = true;
  12317. $scope.gridOptions.fastWatch = true;
  12318. $scope.gridOptions.useExternalFiltering = true;
  12319. $scope.gridOptions.useExternalPagination = true;
  12320. $scope.gridOptions.paginationPageSizes = [10];
  12321. $scope.gridOptions.paginationPageSize = 10;
  12322. $scope.gridOptions.multiSelect = true;
  12323. $scope.gridOptions.rowIdentity = function (row) {
  12324. return row.id;
  12325. };
  12326. $scope.gridOptions.getRowIdentity = function (row) {
  12327. return row.id;
  12328. };
  12329. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12330. $scope.gridOptions.columnDefs = [
  12331. // { name:'id', width:80, enableFiltering:false},
  12332. {
  12333. name: 'account',
  12334. displayName: '账号',
  12335. width: 140
  12336. },
  12337. {
  12338. name: 'name',
  12339. displayName: '名称',
  12340. width: 100
  12341. },
  12342. {
  12343. name: 'gender.name',
  12344. displayName: '性别',
  12345. width: 140,
  12346. enableFiltering: false
  12347. },
  12348. {
  12349. name: 'phone',
  12350. displayName: '电话',
  12351. width: 100,
  12352. enableFiltering: false
  12353. },
  12354. {
  12355. name: 'email',
  12356. displayName: '邮件',
  12357. width: 100,
  12358. enableFiltering: false
  12359. },
  12360. {
  12361. name: 'dept.dept',
  12362. displayName: '科室',
  12363. width: 100,
  12364. enableFiltering: false
  12365. },
  12366. {
  12367. name: 'group[0].groupName',
  12368. displayName: '职位',
  12369. width: 100,
  12370. enableFiltering: false
  12371. }
  12372. ];
  12373. $scope.selected = {
  12374. items: selectItems
  12375. };
  12376. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12377. $scope.gridApi = gridApi;
  12378. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12379. var filtersData = $scope.memoryfilterData;
  12380. filtersData.idx = newPage - 1;
  12381. filtersData.sum = pageSize;
  12382. $scope.loadData(filtersData);
  12383. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12384. });
  12385. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  12386. var j = 0;
  12387. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  12388. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  12389. j++;
  12390. break;
  12391. }
  12392. }
  12393. if (j == 1) {
  12394. scope.grid.appScope.selected.items.splice(i, 1);
  12395. } else {
  12396. scope.grid.appScope.selected.items.push(scope.entity)
  12397. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  12398. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  12399. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  12400. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  12401. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  12402. scope.grid.appScope.selected.items.splice(i, 1);
  12403. }
  12404. }
  12405. }
  12406. }
  12407. });
  12408. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  12409. // $scope.grid.appScope.selected.items.push($scope.entity);
  12410. // });
  12411. gridApi.core.on.filterChanged($scope, function () {
  12412. var grid = this.grid;
  12413. var filtersData = {
  12414. idx: 0,
  12415. sum: 10,
  12416. "user": {
  12417. "roledata": {
  12418. "rolecode": options.model.currentRole
  12419. },
  12420. "selectType": "1"
  12421. }
  12422. };
  12423. angular.forEach(grid.columns, function (item) {
  12424. if (item.enableFiltering) {
  12425. //console.log("filtersData="+JSON.stringify(filtersData))
  12426. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12427. if (angular.isUndefined(filtersData['user'])) {
  12428. filtersData['user'] = {};
  12429. }
  12430. filtersData['user'][item.field] = item.filters[0].term;
  12431. }
  12432. }
  12433. });
  12434. $scope.memoryfilterData = filtersData;
  12435. $scope.loadData(filtersData);
  12436. });
  12437. };
  12438. if (!options.model) {
  12439. var mouse = {
  12440. "model": {
  12441. "currentRole": ""
  12442. }
  12443. };
  12444. angular.extend(options, mouse);
  12445. }
  12446. $scope.memoryfilterData = {
  12447. "idx": 0,
  12448. "sum": 10,
  12449. "user": {
  12450. "roledata": {
  12451. "rolecode": options.model.currentRole
  12452. },
  12453. "selectType": "1"
  12454. }
  12455. }
  12456. $scope.loadData = function (filterData) {
  12457. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  12458. items.fetchItems(filterData, APIService).then(function (data) {
  12459. var myData = Restangular.stripRestangular(data);
  12460. $scope.gridOptions.totalItems = myData.totalNum;
  12461. $scope.myData = myData.list;
  12462. //console.log($scope.gridOptions.pagination.getTotalPages());
  12463. // if($scope.selected.items){
  12464. // angular.forEach($scope.selected.items,function(selectItem){
  12465. // $scope.gridApi.selection.selectRow(selectItem);
  12466. // });
  12467. // }
  12468. });
  12469. };
  12470. // $scope.title = title;
  12471. $scope.loadData({
  12472. idx: 0,
  12473. sum: 10,
  12474. "user": {
  12475. "roledata": {
  12476. "rolecode": options.model.currentRole
  12477. },
  12478. "selectType": "1"
  12479. }
  12480. });
  12481. // $timeout(function(){
  12482. // if($scope.selected.items){
  12483. // angular.forEach($scope.selected.items,function(selectItem){
  12484. // $scope.gridApi.selection.selectRow(selectItem);
  12485. // });
  12486. // }
  12487. // },2000)
  12488. $scope.ok = function () {
  12489. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  12490. $modalInstance.close($scope.selected.items);
  12491. };
  12492. $scope.cancel = function () {
  12493. $modalInstance.dismiss('cancel');
  12494. };
  12495. },
  12496. size: size,
  12497. resolve: {
  12498. items: function () {
  12499. return {
  12500. fetchItems: function (filterData, APIService) {
  12501. filterData = filterData || {};
  12502. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12503. filterData = {
  12504. idx: 0,
  12505. sum: 10,
  12506. "user": {
  12507. "roledata": {
  12508. "rolecode": options.model.incident.currentRole
  12509. },
  12510. "selectType": "1"
  12511. }
  12512. };
  12513. }
  12514. return options.templateOptions.fetchItems(filterData, APIService);
  12515. }
  12516. };
  12517. },
  12518. title: function () {
  12519. return options.templateOptions.modalTitle;
  12520. },
  12521. Restangular: function () {
  12522. return options.templateOptions.Restangular;
  12523. },
  12524. APIService: function () {
  12525. return options.templateOptions.ApiService;
  12526. },
  12527. selectItems: function () {
  12528. return model || [];
  12529. }
  12530. }
  12531. });
  12532. modalInstance.result.then(function (selectedItem) {
  12533. options.value(selectedItem);
  12534. options.formControl.$validate();
  12535. }, function () {
  12536. //console.log('Modal dismissed at: ' + new Date());
  12537. });
  12538. }
  12539. },
  12540. validators: {
  12541. required: {
  12542. expression: function (viewValue, modelValue) {
  12543. var value = modelValue || viewValue;
  12544. return value.length >= 1;
  12545. }
  12546. }
  12547. }
  12548. };
  12549. },
  12550. controller: ['$scope', function ($scope) {
  12551. $scope.model[$scope.options.key] = [];
  12552. $scope.remove = function (itemId) {
  12553. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  12554. if (entry.id == itemId) {
  12555. $scope.model[$scope.options.key].splice(index, 1);
  12556. // console.log($scope.options.formControl)
  12557. $scope.options.formControl.$validate();
  12558. } else {
  12559. }
  12560. });
  12561. }
  12562. }]
  12563. });
  12564. //用户多选控件-字符串展示
  12565. formlyConfigProvider.setType({
  12566. name: 'ui-stringuserselect',
  12567. extends: 'input',
  12568. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  12569. defaultOptions: function (options) {
  12570. return {
  12571. templateOptions: {
  12572. translate: '',
  12573. refreshDelay: 0
  12574. }
  12575. }
  12576. },
  12577. controller: ['$scope', function ($scope) {
  12578. var keydata = "";
  12579. if (angular.isArray($scope.model)) {
  12580. angular.forEach($scope.model, function (item) {
  12581. keydata = keydata + "," + item.name;
  12582. })
  12583. }
  12584. // $scope.model[$scope.options.key] = [];
  12585. }]
  12586. });
  12587. //重复事件
  12588. formlyConfigProvider.setType({
  12589. name: "ui-incidentmodelselect",
  12590. extends: 'input',
  12591. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12592. defaultOptions: function (options) {
  12593. return {
  12594. templateOptions: {
  12595. openModal: function (size, options, modal) {
  12596. var modalInstance = modal.open({
  12597. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12598. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  12599. $scope.langs = i18nService.getAllLangs();
  12600. $scope.lang = 'zh-cn';
  12601. i18nService.setCurrentLang($scope.lang);
  12602. $scope.gridOptions = {};
  12603. $scope.gridOptions.data = 'myData';
  12604. $scope.gridOptions.enableColumnResizing = true;
  12605. $scope.gridOptions.enableFiltering = true;
  12606. $scope.gridOptions.enableGridMenu = false;
  12607. $scope.gridOptions.enableRowSelection = true;
  12608. $scope.gridOptions.showGridFooter = true;
  12609. $scope.gridOptions.showColumnFooter = false;
  12610. $scope.gridOptions.fastWatch = true;
  12611. $scope.gridOptions.useExternalFiltering = true;
  12612. $scope.gridOptions.useExternalPagination = true;
  12613. $scope.gridOptions.paginationPageSizes = [10];
  12614. $scope.gridOptions.paginationPageSize = 10;
  12615. $scope.gridOptions.multiSelect = false;
  12616. var mun = $scope.gridOptions.paginationPageSize;
  12617. $scope.gridOptions.rowIdentity = function (row) {
  12618. return row.id;
  12619. };
  12620. $scope.gridOptions.getRowIdentity = function (row) {
  12621. return row.id;
  12622. };
  12623. $scope.gridOptions.columnDefs = items.columnDefs();
  12624. $scope.transferTime = function (time) {
  12625. return moment(time).format('YYYY-MM-DD HH:mm');
  12626. }
  12627. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12628. $scope.gridApi = gridApi;
  12629. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12630. // console.log(newPage);
  12631. // console.log(pageSize);
  12632. $scope.loadData({
  12633. "idx": newPage - 1,
  12634. "sum": pageSize
  12635. });
  12636. });
  12637. gridApi.core.on.filterChanged($scope, function () {
  12638. var grid = this.grid;
  12639. var filtersData = {
  12640. idx: 0,
  12641. sum: 100
  12642. };
  12643. angular.forEach(grid.columns, function (item) {
  12644. if (item.enableFiltering) {
  12645. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12646. // console.log("filtersData="+JSON.stringify(filtersData))
  12647. if (angular.isUndefined(filtersData['incident'])) {
  12648. filtersData['incident'] = {};
  12649. }
  12650. filtersData['incident'][item.field] = item.filters[0].term;
  12651. if (angular.isUndefined(filtersData['problem'])) {
  12652. filtersData['problem'] = {};
  12653. }
  12654. filtersData['problem'][item.field] = item.filters[0].term;
  12655. if (angular.isUndefined(filtersData['change'])) {
  12656. filtersData['change'] = {};
  12657. }
  12658. filtersData['change'][item.field] = item.filters[0].term;
  12659. if (angular.isUndefined(filtersData['release'])) {
  12660. filtersData['release'] = {};
  12661. }
  12662. filtersData['release'][item.field] = item.filters[0].term;
  12663. }
  12664. }
  12665. });
  12666. $scope.loadData(filtersData);
  12667. });
  12668. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12669. $scope.selected.item = data.entity;
  12670. //console.log(data);
  12671. });
  12672. };
  12673. //资产
  12674. $scope.cmdb = {}
  12675. //资产状态
  12676. $scope.state_data = [{
  12677. "name": "全部状态",
  12678. "value": ""
  12679. },
  12680. {
  12681. "name": "在库",
  12682. "value": "1"
  12683. },
  12684. {
  12685. "name": "在线",
  12686. "value": "2"
  12687. },
  12688. {
  12689. "name": "借出",
  12690. "value": "3"
  12691. },
  12692. {
  12693. "name": "报修",
  12694. "value": "4"
  12695. },
  12696. {
  12697. "name": "报废",
  12698. "value": "5"
  12699. },
  12700. {
  12701. "name": "备用",
  12702. "value": "6"
  12703. },
  12704. ]
  12705. //资产类型
  12706. $scope.wt_zcfl = function () {
  12707. api_configure_data.fetchDataList('ciclassify', {
  12708. idx: 0,
  12709. sum: 100
  12710. }).then(function (data) {
  12711. console.log(data);
  12712. // $scope.wt_zclx = data.list;
  12713. console.log(data);
  12714. $scope.wtData = []
  12715. if (data.status == 200) {
  12716. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12717. var root = null; //Initially set our loop to null
  12718. var parentNode = null;
  12719. //loop over data
  12720. // $scope.wtData=data.list;
  12721. data = data.list;
  12722. //知识库分类数据三级处理
  12723. for (var i = 0; i < data.length; i++) {
  12724. // console.log(data[i])
  12725. var datum = data[i];
  12726. //each node will have children, so let's give it a "children" poperty
  12727. // console.log(datum);
  12728. datum.children = [];
  12729. if (!datum.parent) {
  12730. $scope.wtData.push(datum);
  12731. // console.log($scope.wtData)
  12732. } else {
  12733. if ($scope.wtData[0]) {
  12734. if ($scope.wtData[0].id == datum.parent.id) {
  12735. $scope.wtData[0].children.push(datum);
  12736. }
  12737. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  12738. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  12739. $scope.wtData[0].children[j].children.push(datum);
  12740. }
  12741. };
  12742. }
  12743. if ($scope.wtData[1]) {
  12744. if ($scope.wtData[1].id == datum.parent.id) {
  12745. $scope.wtData[1].children.push(datum);
  12746. }
  12747. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  12748. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  12749. $scope.wtData[1].children[j].children.push(datum);
  12750. }
  12751. };
  12752. }
  12753. if ($scope.wtData[2]) {
  12754. if ($scope.wtData[2].id == datum.parent.id) {
  12755. $scope.wtData[2].children.push(datum);
  12756. }
  12757. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  12758. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  12759. $scope.wtData[2].children[j].children.push(datum);
  12760. }
  12761. };
  12762. }
  12763. }
  12764. // console.log($scope.wtData)
  12765. idToNodeMap[datum.id] = datum;
  12766. root = datum;
  12767. // treeMap[datum.id] = root;
  12768. }
  12769. }
  12770. });
  12771. }
  12772. $scope.wt_zcfl();
  12773. //事件
  12774. //受理人,处理人
  12775. $scope.searchkeys = {};
  12776. var fieldata = {
  12777. "idx": 0,
  12778. "sum": 100,
  12779. "flag": -1
  12780. };
  12781. getUser(fieldata, 3);
  12782. function getUser(fieldatas, it) {
  12783. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  12784. if (it == 1) {
  12785. $scope.acceptUser = data.list;
  12786. } else if (it == 2) {
  12787. $scope.handlingPersonnelUser = data.list;
  12788. } else if (it == 3) {
  12789. $scope.acceptUser = data.list;
  12790. $scope.handlingPersonnelUser = data.list;
  12791. }
  12792. });
  12793. }
  12794. //状态
  12795. $scope.othcode = {};
  12796. api_bpm_data.fetchDataList('incidentstatus', {
  12797. "idx": 0,
  12798. "sum": 100
  12799. }).then(function (response) {
  12800. if (response) {
  12801. if (response.status = 200) {
  12802. $scope.state = response.list;
  12803. }
  12804. }
  12805. })
  12806. var defaultFilterData = {
  12807. "assignee": $rootScope.user.id,
  12808. "searchType": "todo",
  12809. "idx": 0,
  12810. "sum": mun
  12811. };
  12812. var defaultFilterData1 = {
  12813. // "searchType": "todo",
  12814. "idx": 0,
  12815. "sum": mun
  12816. };
  12817. //搜索
  12818. $scope.chiceIncident = function (parameters, item, stateid) {
  12819. console.log(item, stateid);
  12820. console.log($scope);
  12821. if ($scope.title == '关联资产编号') {
  12822. // alert('222222222222');
  12823. var fildata = defaultFilterData1;
  12824. $scope.gridOptions.paginationCurrentPage = 1;
  12825. var transitiondata = angular.copy(item);
  12826. angular.extend(fildata, transitiondata);
  12827. if (fildata.hw_state) {
  12828. fildata.hw_state = fildata.hw_state.name;
  12829. }
  12830. if (fildata.sign) {
  12831. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  12832. fildata.sign = fildata.sign.split(';');
  12833. fildata.sign = fildata.sign.join('');
  12834. fildata.sign = fildata.sign.toLowerCase()
  12835. }
  12836. if (fildata.keys) {
  12837. fildata['searchCriteria'] = 'uuid';
  12838. }
  12839. console.log(fildata);
  12840. $scope.loadData(fildata);
  12841. }
  12842. if ($scope.title == '关联事件工单') {
  12843. // alert('3333333333333333')
  12844. if (stateid && stateid.code) {
  12845. item.statusId = stateid.code;
  12846. }
  12847. var fildata = defaultFilterData;
  12848. // $scope.memoryfilterData = fildata;
  12849. if (!fildata.incident) {
  12850. fildata['incident'] = {};
  12851. }
  12852. $scope.gridOptions.paginationCurrentPage = 1;
  12853. var transitiondata = angular.copy(item);
  12854. angular.extend(fildata.incident, transitiondata);
  12855. console.log(fildata)
  12856. // $scope.loadData(fildata);
  12857. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  12858. console.log(data)
  12859. if (data) {
  12860. $scope.myData = data.list;
  12861. $scope.gridOptions.totalItems = data.totalNum;
  12862. }
  12863. })
  12864. }
  12865. }
  12866. //重置
  12867. $scope.replacement = function (parameters, searchkeys, othcode) {
  12868. // console.log(parameters, searchkeys, othcode);
  12869. delete (defaultFilterData.incident);
  12870. console.log(defaultFilterData)
  12871. $scope.parameters = null;
  12872. $scope.searchkeys = {};
  12873. $scope.othcode = {};
  12874. $scope.wt_zcfl();
  12875. }
  12876. $scope.loadData = function (filterData) {
  12877. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  12878. var myData = Restangular.stripRestangular(data);
  12879. if (myData.data && myData.data.node) {
  12880. $scope.gridOptions.totalItems = myData.total;
  12881. $scope.myData = myData.data.node;
  12882. } else {
  12883. if (myData.resultCount) {
  12884. $scope.gridOptions['totalItems'] = myData.resultCount;
  12885. } else {
  12886. $scope.gridOptions.totalItems = myData.totalNum;
  12887. }
  12888. if (myData.list) {
  12889. $scope.myData = myData.list;
  12890. } else {
  12891. $scope.myData = myData.data;
  12892. }
  12893. }
  12894. });
  12895. };
  12896. $scope.title = title;
  12897. $scope.loadData({
  12898. idx: 0,
  12899. sum: 10
  12900. });
  12901. $scope.selected = {
  12902. item: {}
  12903. };
  12904. $scope.ok = function () {
  12905. //console.log($scope.selected.item);
  12906. $modalInstance.close($scope.selected.item);
  12907. };
  12908. $scope.cancel = function () {
  12909. $modalInstance.dismiss('cancel');
  12910. };
  12911. },
  12912. size: size,
  12913. resolve: {
  12914. items: function () {
  12915. return {
  12916. fetchItems: function (filterData, APIService, $rootScope) {
  12917. filterData = filterData || {};
  12918. // if(!filterData.idx){
  12919. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12920. filterData = {
  12921. idx: 0,
  12922. sum: 10
  12923. };
  12924. }
  12925. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  12926. },
  12927. columnDefs: function () {
  12928. return options.templateOptions.columnDefs;
  12929. }
  12930. };
  12931. },
  12932. title: function () {
  12933. return options.templateOptions.modalTitle;
  12934. },
  12935. Restangular: function () {
  12936. return options.templateOptions.Restangular;
  12937. },
  12938. APIService: function () {
  12939. return options.templateOptions.ApiService;
  12940. }
  12941. }
  12942. });
  12943. modalInstance.result.then(function (selectedItem) {
  12944. var selectitem = {
  12945. title: selectedItem.title,
  12946. description: selectedItem.description
  12947. }
  12948. if (options.key == "chuku") {
  12949. if (selectedItem.assets) {
  12950. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  12951. }
  12952. if (selectedItem.consumables) {
  12953. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  12954. }
  12955. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  12956. options.value(selectedItem);
  12957. // options.model.consumables = JSON.parse(consumables);
  12958. } else if (options.templateOptions.pkey == "change") {
  12959. console.log(options)
  12960. angular.extend(options.model);
  12961. options.value(selectedItem);
  12962. } else if (options.key == "cmdbCode") {
  12963. var zc_selectitem = selectedItem.uuid;
  12964. // angular.extend(options.model,zc_selectitem);
  12965. options.model.cmdbCode = zc_selectitem;
  12966. // angular.extend(options.model,zc_selectitem);
  12967. // options.templateOptions.displayName=zc_selectitem;
  12968. options.value(selectedItem);
  12969. console.log(options.model)
  12970. } else {
  12971. angular.extend(options.model, selectitem);
  12972. options.value(selectedItem);
  12973. }
  12974. }, function () {
  12975. //console.log('Modal dismissed at: ' + new Date());
  12976. });
  12977. }
  12978. }
  12979. };
  12980. }
  12981. });
  12982. //选项选择控件
  12983. formlyConfigProvider.setType({
  12984. name: "ui-modelselect",
  12985. extends: 'input',
  12986. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12987. defaultOptions: function (options) {
  12988. return {
  12989. templateOptions: {
  12990. openModal: function (size, options, modal) {
  12991. var modalInstance = modal.open({
  12992. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12993. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  12994. $scope.langs = i18nService.getAllLangs();
  12995. $scope.lang = 'zh-cn';
  12996. i18nService.setCurrentLang($scope.lang);
  12997. $scope.gridOptions = {};
  12998. $scope.gridOptions.data = 'myData';
  12999. $scope.gridOptions.enableColumnResizing = true;
  13000. $scope.gridOptions.enableFiltering = true;
  13001. $scope.gridOptions.enableGridMenu = false;
  13002. $scope.gridOptions.enableRowSelection = true;
  13003. $scope.gridOptions.showGridFooter = true;
  13004. $scope.gridOptions.showColumnFooter = true;
  13005. $scope.gridOptions.fastWatch = true;
  13006. $scope.gridOptions.useExternalFiltering = true;
  13007. $scope.gridOptions.useExternalPagination = true;
  13008. $scope.gridOptions.paginationPageSizes = [10];
  13009. $scope.gridOptions.paginationPageSize = 10;
  13010. $scope.gridOptions.multiSelect = false;
  13011. $scope.gridOptions.rowIdentity = function (row) {
  13012. return row.id;
  13013. };
  13014. $scope.gridOptions.getRowIdentity = function (row) {
  13015. return row.id;
  13016. };
  13017. $scope.gridOptions.columnDefs = items.columnDefs();
  13018. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13019. $scope.gridApi = gridApi;
  13020. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  13021. // console.log(newPage);
  13022. // console.log(pageSize);
  13023. $scope.loadData({
  13024. "idx": newPage - 1,
  13025. "sum": pageSize
  13026. });
  13027. });
  13028. gridApi.core.on.filterChanged($scope, function () {
  13029. var grid = this.grid;
  13030. var filtersData = {
  13031. idx: 0,
  13032. sum: 10
  13033. };
  13034. angular.forEach(grid.columns, function (item) {
  13035. if (item.enableFiltering) {
  13036. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  13037. // console.log("filtersData="+JSON.stringify(filtersData))
  13038. if (angular.isUndefined(filtersData['incident'])) {
  13039. filtersData['incident'] = {};
  13040. }
  13041. filtersData['incident'][item.field] = item.filters[0].term;
  13042. if (angular.isUndefined(filtersData['problem'])) {
  13043. filtersData['problem'] = {};
  13044. }
  13045. filtersData['problem'][item.field] = item.filters[0].term;
  13046. if (angular.isUndefined(filtersData['change'])) {
  13047. filtersData['change'] = {};
  13048. }
  13049. filtersData['change'][item.field] = item.filters[0].term;
  13050. if (angular.isUndefined(filtersData['release'])) {
  13051. filtersData['release'] = {};
  13052. }
  13053. filtersData['release'][item.field] = item.filters[0].term;
  13054. }
  13055. }
  13056. });
  13057. $scope.loadData(filtersData);
  13058. });
  13059. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13060. $scope.selected.item = data.entity;
  13061. //console.log(data);
  13062. });
  13063. };
  13064. $scope.loadData = function (filterData) {
  13065. items.fetchItems(filterData, APIService).then(function (data) {
  13066. var myData = Restangular.stripRestangular(data);
  13067. $scope.gridOptions.totalItems = myData.totalNum;
  13068. $scope.myData = myData.list;
  13069. });
  13070. };
  13071. $scope.title = title;
  13072. $scope.loadData({
  13073. idx: 0,
  13074. sum: 10
  13075. });
  13076. $scope.selected = {
  13077. item: {}
  13078. };
  13079. $scope.ok = function () {
  13080. if ($scope.selected.item.scheduleOrder) {
  13081. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  13082. }
  13083. //console.log($scope.selected.item);
  13084. $modalInstance.close($scope.selected.item);
  13085. };
  13086. $scope.cancel = function () {
  13087. $modalInstance.dismiss('cancel');
  13088. };
  13089. },
  13090. size: size,
  13091. resolve: {
  13092. items: function () {
  13093. return {
  13094. fetchItems: function (filterData, APIService) {
  13095. filterData = filterData || {};
  13096. // if(!filterData.idx){
  13097. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  13098. filterData = {
  13099. idx: 0,
  13100. sum: 10
  13101. };
  13102. }
  13103. return options.templateOptions.fetchItems(filterData, APIService, options);
  13104. },
  13105. columnDefs: function () {
  13106. return options.templateOptions.columnDefs;
  13107. }
  13108. };
  13109. },
  13110. title: function () {
  13111. return options.templateOptions.modalTitle;
  13112. },
  13113. Restangular: function () {
  13114. return options.templateOptions.Restangular;
  13115. },
  13116. APIService: function () {
  13117. return options.templateOptions.ApiService;
  13118. }
  13119. }
  13120. });
  13121. modalInstance.result.then(function (selectedItem) {
  13122. options.value(selectedItem);
  13123. }, function () {
  13124. //console.log('Modal dismissed at: ' + new Date());
  13125. });
  13126. }
  13127. }
  13128. };
  13129. }
  13130. });
  13131. formlyConfigProvider.setType({
  13132. name: 'ui-requestform',
  13133. extends: 'input',
  13134. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  13135. controller: ['$scope', function ($scope) {
  13136. setTimeout(function () {
  13137. var filterData = {
  13138. "idx": 0,
  13139. "sum": 5,
  13140. "incident": {
  13141. "requester": {
  13142. "id": ""
  13143. }
  13144. }
  13145. }
  13146. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  13147. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13148. });
  13149. }, 1000);
  13150. }]
  13151. });
  13152. //报修图片展示
  13153. formlyConfigProvider.setType({
  13154. name: 'ui-repair-photos',
  13155. // extends: 'label',
  13156. templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
  13157. controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
  13158. console.log($scope);
  13159. $scope.fileUrls = [];
  13160. if ($scope.model.wxFile) {
  13161. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
  13162. $scope.fileUrls = res.data
  13163. })
  13164. }
  13165. console.log($stateParams);
  13166. if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
  13167. api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
  13168. $scope.fileUrls = res.data
  13169. })
  13170. }
  13171. if ($scope.model.flow) {
  13172. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
  13173. $scope.fileUrls = res.data
  13174. })
  13175. }
  13176. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13177. // // setTimeout(function () {
  13178. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13179. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13180. // // if (modelData.status == 200) {
  13181. // // $scope.model[$scope.options.key] = modelData.data;
  13182. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  13183. // // }
  13184. // // });
  13185. // // }, 1000);
  13186. // }
  13187. $scope.showBigImg = false;
  13188. $scope.showBigImgCli = function (data) {
  13189. $scope.showBigImg = true;
  13190. $scope.bigImgUrl = data
  13191. }
  13192. $scope.closeBigImg = function () {
  13193. $scope.showBigImg = false
  13194. }
  13195. }]
  13196. });
  13197. //图片展示
  13198. formlyConfigProvider.setType({
  13199. name: 'ui-showImgs',
  13200. templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
  13201. defaultOptions: function (options) {
  13202. return {
  13203. templateOptions: {
  13204. refresh: function (APIService, processInstanceId, data) {
  13205. return APIService.listAttachments(processInstanceId);
  13206. },
  13207. downloadUri: function (APIService, contentId) {
  13208. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13209. },
  13210. view: function (APIService, contentId) {
  13211. return APIService.attachmentsPreviewUrl(contentId);
  13212. },
  13213. download: function (APIService, contentId, item) {
  13214. var item = {
  13215. 'url': APIService.download(contentId),
  13216. 'headers': headers
  13217. };
  13218. return item;
  13219. },
  13220. refreshDelay: 0
  13221. }
  13222. };
  13223. },
  13224. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13225. var _refreshDelayPromise;
  13226. /**
  13227. * refresh
  13228. */
  13229. $scope._refresh = function (refreshAttr) {
  13230. $scope.attachments = [];
  13231. if (refreshAttr !== undefined) {
  13232. if (_refreshDelayPromise) {
  13233. $timeout.cancel(_refreshDelayPromise);
  13234. }
  13235. _refreshDelayPromise = $timeout(function () {
  13236. // 暂存附件
  13237. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13238. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13239. $scope.options.templateOptions.processInstanceId, {
  13240. 'idx': 0,
  13241. 'sum': 1000
  13242. }).then(function (response) {
  13243. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13244. if (myData) {
  13245. for (var i = 0; i < myData.data.length; i++) {
  13246. $scope.attachments.push(myData.data[i]);
  13247. }
  13248. };
  13249. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13250. $scope.$parent.$parent.$parent.model.save_fileId, {
  13251. 'idx': 0,
  13252. 'sum': 1000
  13253. }).then(function (response2) {
  13254. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13255. if (myData2) {
  13256. for (var i = 0; i < myData2.data.length; i++) {
  13257. $scope.attachments.push(myData2.data[i]);
  13258. }
  13259. };
  13260. console.log($scope.attachments)
  13261. });
  13262. });
  13263. // 正常附件
  13264. } else {
  13265. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13266. $scope.options.templateOptions.processInstanceId, {
  13267. 'idx': 0,
  13268. 'sum': 1000
  13269. }).then(function (response) {
  13270. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13271. if (myData) {
  13272. $scope.attachments = [];
  13273. $scope.imgs = []
  13274. myData.data.forEach(e => {
  13275. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13276. $scope.imgs.push(e)
  13277. }
  13278. })
  13279. $scope.imgs = $scope.imgs.splice(0, 3);
  13280. console.log($scope.imgs)
  13281. }
  13282. });
  13283. }
  13284. }, $scope.options.templateOptions.refreshDelay);
  13285. }
  13286. }
  13287. $scope._refresh({});
  13288. // $scope.attachments = $scope.model[$scope.options.key]
  13289. // 预览
  13290. $scope.preview = function (url, idx) {
  13291. var title = $scope.imgs[idx].title
  13292. $modal.open({
  13293. backdrop: false,
  13294. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13295. controller: function ($scope, scope, $modalInstance) {
  13296. $scope.title = title;
  13297. $scope.imageurl = url;
  13298. $scope.cancel = function () {
  13299. $modalInstance.dismiss('cancel');
  13300. }
  13301. },
  13302. resolve: {
  13303. scope: function () {
  13304. return $scope;
  13305. }
  13306. }
  13307. });
  13308. }
  13309. }]
  13310. });
  13311. //工单/受理人控件
  13312. formlyConfigProvider.setType({
  13313. name: 'ui-workernumbersign',
  13314. // extends: 'label',
  13315. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  13316. controller: ['$scope', function ($scope) {
  13317. // 2020年4月24日13:20:40
  13318. console.log($scope,'docu');
  13319. // 左侧事件工单区域地点填充
  13320. $scope.model.selecthouseNumber = $scope.model.place;
  13321. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13322. setTimeout(function () {
  13323. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13324. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13325. if (modelData.status == 200) {
  13326. $scope.model[$scope.options.key] = modelData.data;
  13327. $scope.options.initialValue = $scope.model[$scope.options.key];
  13328. }
  13329. });
  13330. }, 1000);
  13331. }
  13332. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  13333. if (angular.isFunction($scope.options.templateOptions.transform)) {
  13334. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  13335. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  13336. // }
  13337. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13338. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13339. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  13340. }
  13341. $scope.model.acceptUser = $scope.options.templateOptions.user;
  13342. // $scope.options.initialValue = $scope.model.acceptUser;
  13343. }
  13344. }]
  13345. });
  13346. //工单控件-only number
  13347. formlyConfigProvider.setType({
  13348. name: 'ui-workernumber',
  13349. extends: 'input',
  13350. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13351. controller: ['$scope', function ($scope) {
  13352. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13353. setTimeout(function () {
  13354. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13355. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13356. if (modelData.status == 200) {
  13357. $scope.model[$scope.options.key] = modelData.data;
  13358. $scope.options.initialValue = $scope.model[$scope.options.key];
  13359. }
  13360. });
  13361. }, 1000);
  13362. }
  13363. }]
  13364. });
  13365. //cmdb工单
  13366. formlyConfigProvider.setType({
  13367. name: 'ui-cmdbworkernumber',
  13368. extends: 'input',
  13369. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13370. controller: ['$scope', function ($scope) {
  13371. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13372. setTimeout(function () {
  13373. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  13374. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13375. // if(modelData.status==200){
  13376. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  13377. $scope.options.initialValue = $scope.model[$scope.options.key];
  13378. // }
  13379. });
  13380. }, 1000);
  13381. }
  13382. }]
  13383. });
  13384. //简易上传图片组件
  13385. formlyConfigProvider.setType({
  13386. name: 'ui-uploadImgs',
  13387. templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
  13388. wrapper: ['bootstrapHasError'],
  13389. controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
  13390. $scope.imgshows = [];
  13391. $scope.uploadimgs = [];
  13392. var model = $parse('upload_img');
  13393. var modelSetter = model.assign;
  13394. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13395. uploader.filters.push({
  13396. name: 'customFilter',
  13397. fn: function (item /*{File|FileLikeObject}*/, options) {
  13398. return this.queue.length < 10;
  13399. }
  13400. });
  13401. // 添加
  13402. $scope.change = function (event) {
  13403. var element = $('.upinp')
  13404. modelSetter($scope, element[0].files[0]);
  13405. //附件预览
  13406. $scope.imgupload = event.files[0];
  13407. getFile($scope.imgupload, $scope);
  13408. //获得预览图地址并且把file对象放入上传合集内
  13409. function getFile(imgupload, $scope) {
  13410. if (!imgupload) {
  13411. return;
  13412. }
  13413. fileReader.readAsDataUrl(imgupload, $scope)
  13414. .then(function (result) {
  13415. $scope.imgshows.push(result)
  13416. var file = document.querySelector('input[type=file]').files[0];
  13417. $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
  13418. console.log($scope.imgshows, $scope.uploadimgs)
  13419. if ($scope.imgshows.length < 3) {
  13420. $('#upup').show()
  13421. } else {
  13422. $('#upup').hide()
  13423. }
  13424. });
  13425. };
  13426. }
  13427. // 删除
  13428. $scope.uploadimg_del = function (index, imgs) {
  13429. console.log(index, imgs)
  13430. $scope.imgshows.splice(index, 1);
  13431. $scope.uploadimgs.splice(index, 1);
  13432. if ($scope.imgshows.length < 3) {
  13433. $('#upup').show()
  13434. } else {
  13435. $('#upup').hide()
  13436. }
  13437. }
  13438. // 预览
  13439. $scope.preview = function (url, idx) {
  13440. var name = $scope.uploadimgs[idx].name
  13441. $modal.open({
  13442. backdrop: false,
  13443. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13444. controller: function ($scope, scope, $modalInstance) {
  13445. $scope.title = name;
  13446. $scope.imageurl = url;
  13447. $scope.cancel = function () {
  13448. $modalInstance.dismiss('cancel');
  13449. }
  13450. },
  13451. resolve: {
  13452. scope: function () {
  13453. return $scope;
  13454. }
  13455. }
  13456. });
  13457. }
  13458. if (uploader) {
  13459. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13460. console.info('onWhenAddingFileFailed', item, filter, options);
  13461. };
  13462. uploader.onAfterAddingFile = function (fileItem) {
  13463. console.info('onAfterAddingFile', fileItem);
  13464. };
  13465. uploader.onAfterAddingAll = function (addedFileItems) {
  13466. console.info('onAfterAddingAll', addedFileItems);
  13467. };
  13468. uploader.onBeforeUploadItem = function (item) {
  13469. console.info('onBeforeUploadItem', item);
  13470. };
  13471. uploader.onProgressItem = function (fileItem, progress) {
  13472. console.info('onProgressItem', fileItem, progress);
  13473. };
  13474. uploader.onProgressAll = function (progress) {
  13475. console.info('onProgressAll', progress);
  13476. };
  13477. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13478. console.info('onSuccessItem', fileItem, response, status, headers);
  13479. };
  13480. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13481. console.info('onErrorItem', fileItem, response, status, headers);
  13482. };
  13483. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13484. console.info('onCancelItem', fileItem, response, status, headers);
  13485. };
  13486. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13487. console.info('onCompleteItem', fileItem, response, status, headers);
  13488. };
  13489. uploader.onCompleteAll = function () {
  13490. console.info('onCompleteAll');
  13491. };
  13492. }
  13493. // console.log(modelSetter)
  13494. }]
  13495. });
  13496. //jry-上传下载一体
  13497. formlyConfigProvider.setType({
  13498. name: 'ui-upDropFile',
  13499. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  13500. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13501. defaultOptions: function (options) {
  13502. return {
  13503. templateOptions: {
  13504. view: function (APIService, contentId) {
  13505. return APIService.downloadAttachment(contentId);
  13506. },
  13507. // ApiService: 'api_wechatfile',
  13508. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  13509. // upUrl: 'common/common/uploadAttachment',
  13510. // listAttachmentUrl: 'common/common/listAttachment',
  13511. // downUrl: 'common/common/downloadAttachment',
  13512. // bindType: 'incident',
  13513. // bindId: 2323
  13514. },
  13515. // validators: {
  13516. // required: {
  13517. // expression: function(viewValue, modelValue) {
  13518. // var value = modelValue || viewValue;
  13519. // return value.length >= 1;
  13520. // }
  13521. // }
  13522. // }
  13523. };
  13524. },
  13525. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  13526. console.log($scope);
  13527. $scope.showFileUp = true;
  13528. if ($scope.model.isKnowledge_detail) {
  13529. $scope.showFileUp = false;
  13530. }
  13531. if (angular.isUndefined($scope.form.dropState)) {
  13532. $scope.form.dropState = false;
  13533. }
  13534. if ($scope.model.incident) {
  13535. if ($scope.model.incident.alarm) {
  13536. console.log($scope)
  13537. if ($scope.model.incident.alarm) {
  13538. if ($scope.model.incident.alarm.alarmExtension) {
  13539. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  13540. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  13541. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  13542. console.log($scope.model.incident.description)
  13543. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  13544. } else {
  13545. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  13546. }
  13547. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  13548. console.log($scope.model.incident.description)
  13549. };
  13550. }
  13551. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  13552. console.log(wt_data);
  13553. if (wt_data) {
  13554. $rootScope.wt_category = wt_data.data;
  13555. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  13556. $rootScope.wt_child = wt_data.child
  13557. }
  13558. })
  13559. if ($scope.model.titleName == '接单') {
  13560. $scope.model.receive_code = 'handler'
  13561. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  13562. $scope.model.isHandlerUser = true;
  13563. }
  13564. }
  13565. if ($scope.model.titleName == '事件处理') {
  13566. console.log($scope.model.cmdbCode)
  13567. if ($scope.model.cmdbCode) {
  13568. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  13569. }
  13570. }
  13571. } else {
  13572. $rootScope.wt_category = '';
  13573. }
  13574. //附件上传数据
  13575. if ($scope.options.templateOptions.fileUploader) {
  13576. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13577. //$scope.options.templateOptions.uploader();
  13578. console.log(uploader)
  13579. // FILTERS
  13580. uploader.filters.push({
  13581. name: 'customFilter',
  13582. fn: function (item /*{File|FileLikeObject}*/, options) {
  13583. return this.queue.length < 10;
  13584. }
  13585. });
  13586. }
  13587. var to = $scope.options.templateOptions;
  13588. // var bindType = $scope.model.bindType;
  13589. if (to.bindType == 'incident') {
  13590. var bindId = $scope.model[to.bindType].processInstanceId;
  13591. } else if (to.bindType == 'change') {
  13592. var bindId = $scope.model[to.bindType].processInstanceId;
  13593. } else {
  13594. var bindId = $scope.model[to.bindType].id;
  13595. }
  13596. //获取附件列表
  13597. $scope.listAttachmen = function () {
  13598. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  13599. var myData = Restangular.stripRestangular(result);
  13600. // $scope.listAttachmens = myData;
  13601. $scope.attachments = myData.data;
  13602. });
  13603. };
  13604. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  13605. $scope.listAttachmen();
  13606. } else if (to.bindType && $scope.model[to.bindType].id) {
  13607. $scope.listAttachmen();
  13608. }
  13609. //附件上传
  13610. $scope.isUpfload = to.isUpfload;
  13611. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13612. uploader.onBeforeUploadItem = function (item) {
  13613. angular.extend(item.headers, $rootScope.getSession());
  13614. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  13615. item.formData.push({
  13616. 'filename': item.file.name
  13617. });
  13618. };
  13619. uploader.uploadAll();
  13620. }
  13621. //附件下载
  13622. $scope.download = function (token, filename) {
  13623. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  13624. // window.open(downUrl);
  13625. var a = document.createElement('a');
  13626. a.href = downUrl;
  13627. a.target = '_blank';
  13628. a.download = filename;
  13629. document.body.appendChild(a);
  13630. a.click();
  13631. };
  13632. //附件预览
  13633. $scope.view = function (id, previewUrl) {
  13634. if (previewUrl) {
  13635. window.open(previewUrl);
  13636. }
  13637. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  13638. // if (response.state == 200) {
  13639. // window.open(response.previewUrl);
  13640. // }
  13641. // })
  13642. };
  13643. // CALLBACKS
  13644. if (uploader) {
  13645. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13646. console.info('onWhenAddingFileFailed', item, filter, options);
  13647. };
  13648. uploader.onAfterAddingFile = function (fileItem) {
  13649. console.info('onAfterAddingFile', fileItem);
  13650. };
  13651. uploader.onAfterAddingAll = function (addedFileItems) {
  13652. console.info('onAfterAddingAll', addedFileItems);
  13653. };
  13654. uploader.onBeforeUploadItem = function (item) {
  13655. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13656. // // $scope.uploader.options.url();
  13657. // $scope.uploader.onBeforeUploadItem = function(item) {
  13658. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13659. // console.info('onBeforeUploadItem', item);
  13660. // };
  13661. // $scope.uploader.uploadAll();
  13662. // }
  13663. console.info('onBeforeUploadItem', item);
  13664. };
  13665. uploader.onProgressItem = function (fileItem, progress) {
  13666. console.info('onProgressItem', fileItem, progress);
  13667. };
  13668. uploader.onProgressAll = function (progress) {
  13669. console.info('onProgressAll', progress);
  13670. };
  13671. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13672. console.info('onSuccessItem', fileItem, response, status, headers);
  13673. if (response.status == 200) {
  13674. $scope.listAttachmen();
  13675. }
  13676. };
  13677. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13678. console.info('onErrorItem', fileItem, response, status, headers);
  13679. };
  13680. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13681. console.info('onCancelItem', fileItem, response, status, headers);
  13682. };
  13683. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13684. console.info('onCompleteItem', fileItem, response, status, headers);
  13685. };
  13686. uploader.onCompleteAll = function () {
  13687. console.info('onCompleteAll');
  13688. };
  13689. }
  13690. }]
  13691. });
  13692. //简易上传下载附件组件
  13693. formlyConfigProvider.setType({
  13694. name: 'ui-upDownFiles',
  13695. templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
  13696. wrapper: ['bootstrapHasError'],
  13697. defaultOptions: function (options) {
  13698. return {
  13699. templateOptions: {
  13700. refresh: function (APIService, processInstanceId, data) {
  13701. return APIService.listAttachments(processInstanceId);
  13702. },
  13703. downloadUri: function (APIService, contentId) {
  13704. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13705. },
  13706. view: function (APIService, contentId) {
  13707. return APIService.attachmentsPreviewUrl(contentId);
  13708. },
  13709. download: function (APIService, contentId, item) {
  13710. var item = {
  13711. 'url': APIService.download(contentId),
  13712. 'headers': headers
  13713. };
  13714. return item;
  13715. },
  13716. refreshDelay: 0
  13717. }
  13718. };
  13719. },
  13720. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13721. if (angular.isUndefined($scope.form.dropState)) {
  13722. $scope.form.dropState = false;
  13723. }
  13724. //附件上传数据
  13725. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13726. //$scope.options.templateOptions.uploader();
  13727. // FILTERS
  13728. uploader.filters.push({
  13729. name: 'customFilter',
  13730. fn: function (item /*{File|FileLikeObject}*/, options) {
  13731. return this.queue.length < 10;
  13732. }
  13733. });
  13734. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13735. // uploader.onBeforeUploadItem = function (item) {
  13736. // angular.extend(item.headers, $rootScope.getSession());
  13737. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13738. // item.formData.push({
  13739. // 'fileName': item.file.name
  13740. // });
  13741. // console.info('onBeforeUploadItem', item);
  13742. // };
  13743. // }
  13744. // CALLBACKS
  13745. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13746. console.info('onWhenAddingFileFailed', item, filter, options);
  13747. };
  13748. uploader.onAfterAddingFile = function (fileItem) {
  13749. console.info('onAfterAddingFile', fileItem);
  13750. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13751. alert('文件过大');
  13752. fileItem.uploader.queue.pop()
  13753. console.log($scope);
  13754. }
  13755. };
  13756. uploader.onAfterAddingAll = function (addedFileItems) {
  13757. // console.info('onAfterAddingAll', addedFileItems);
  13758. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13759. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13760. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13761. // console.log(123)
  13762. };
  13763. uploader.onBeforeUploadItem = function (item) {
  13764. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13765. // // $scope.uploader.options.url();
  13766. // $scope.uploader.onBeforeUploadItem = function(item) {
  13767. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13768. // console.info('onBeforeUploadItem', item);
  13769. // };
  13770. // $scope.uploader.uploadAll();
  13771. // }
  13772. console.info('onBeforeUploadItem', item);
  13773. };
  13774. uploader.onProgressItem = function (fileItem, progress) {
  13775. console.info('onProgressItem', fileItem, progress);
  13776. };
  13777. uploader.onProgressAll = function (progress) {
  13778. console.info('onProgressAll', progress);
  13779. };
  13780. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13781. console.info('onSuccessItem', fileItem, response, status, headers);
  13782. };
  13783. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13784. console.info('onErrorItem', fileItem, response, status, headers);
  13785. };
  13786. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13787. console.info('onCancelItem', fileItem, response, status, headers);
  13788. };
  13789. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13790. console.info('onCompleteItem', fileItem, response, status, headers);
  13791. };
  13792. uploader.onCompleteAll = function () {
  13793. console.info('onCompleteAll');
  13794. };
  13795. var _refreshDelayPromise;
  13796. // 下载
  13797. $scope.download = function (contentId, filename, token) {
  13798. // console.log(contentId, filename, token)
  13799. //附件下载
  13800. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  13801. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  13802. // console.log(downUrl)
  13803. var a = document.createElement('a');
  13804. a.href = downUrl;
  13805. a.target = '_blank';
  13806. a.download = filename;
  13807. document.body.appendChild(a);
  13808. a.click();
  13809. };
  13810. $scope._refresh = function (refreshAttr) {
  13811. $scope.attachments = [];
  13812. if (refreshAttr !== undefined) {
  13813. if (_refreshDelayPromise) {
  13814. $timeout.cancel(_refreshDelayPromise);
  13815. }
  13816. _refreshDelayPromise = $timeout(function () {
  13817. // 暂存附件
  13818. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13819. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13820. $scope.options.templateOptions.processInstanceId, {
  13821. 'idx': 0,
  13822. 'sum': 1000
  13823. }).then(function (response) {
  13824. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13825. if (myData) {
  13826. for (var i = 0; i < myData.data.length; i++) {
  13827. $scope.attachments.push(myData.data[i]);
  13828. }
  13829. };
  13830. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13831. $scope.$parent.$parent.$parent.model.save_fileId, {
  13832. 'idx': 0,
  13833. 'sum': 1000
  13834. }).then(function (response2) {
  13835. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13836. if (myData2) {
  13837. for (var i = 0; i < myData2.data.length; i++) {
  13838. $scope.attachments.push(myData2.data[i]);
  13839. }
  13840. // 只展示除图片以外的附件
  13841. var a = [];
  13842. $scope.attachments.forEach(e => {
  13843. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13844. // $scope.imgs.push(e)
  13845. } else {
  13846. a.push(e)
  13847. }
  13848. })
  13849. $scope.attachments = a;
  13850. };
  13851. console.log($scope.attachments)
  13852. });
  13853. });
  13854. // 正常附件
  13855. } else {
  13856. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13857. $scope.options.templateOptions.processInstanceId, {
  13858. 'idx': 0,
  13859. 'sum': 1000
  13860. }).then(function (response) {
  13861. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13862. if (myData) {
  13863. $scope.attachments = myData.data;
  13864. // 只展示除图片以外的附件
  13865. var a = [];
  13866. $scope.attachments.forEach(e => {
  13867. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13868. // $scope.imgs.push(e)
  13869. } else {
  13870. a.push(e)
  13871. }
  13872. })
  13873. $scope.attachments = a;
  13874. }
  13875. });
  13876. }
  13877. }, $scope.options.templateOptions.refreshDelay);
  13878. }
  13879. }
  13880. $scope._refresh({});
  13881. }]
  13882. });
  13883. //简易上传附件组件
  13884. formlyConfigProvider.setType({
  13885. name: 'ui-uploadFiles',
  13886. templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
  13887. wrapper: ['bootstrapHasError'],
  13888. controller: ['$scope', function ($scope) {
  13889. if (angular.isUndefined($scope.form.dropState)) {
  13890. $scope.form.dropState = false;
  13891. }
  13892. //附件上传数据
  13893. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13894. //$scope.options.templateOptions.uploader();
  13895. // FILTERS
  13896. uploader.filters.push({
  13897. name: 'customFilter',
  13898. fn: function (item /*{File|FileLikeObject}*/, options) {
  13899. return this.queue.length < 10;
  13900. }
  13901. });
  13902. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13903. uploader.onBeforeUploadItem = function (item) {
  13904. angular.extend(item.headers, $rootScope.getSession());
  13905. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13906. item.formData.push({
  13907. 'fileName': item.file.name
  13908. });
  13909. console.info('onBeforeUploadItem', item);
  13910. };
  13911. }
  13912. // CALLBACKS
  13913. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13914. console.info('onWhenAddingFileFailed', item, filter, options);
  13915. };
  13916. uploader.onAfterAddingFile = function (fileItem) {
  13917. console.info('onAfterAddingFile', fileItem);
  13918. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13919. alert('文件过大');
  13920. fileItem.uploader.queue.pop()
  13921. console.log($scope);
  13922. }
  13923. };
  13924. uploader.onAfterAddingAll = function (addedFileItems) {
  13925. // console.info('onAfterAddingAll', addedFileItems);
  13926. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13927. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13928. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13929. // console.log(123)
  13930. };
  13931. uploader.onBeforeUploadItem = function (item) {
  13932. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13933. // // $scope.uploader.options.url();
  13934. // $scope.uploader.onBeforeUploadItem = function(item) {
  13935. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13936. // console.info('onBeforeUploadItem', item);
  13937. // };
  13938. // $scope.uploader.uploadAll();
  13939. // }
  13940. console.info('onBeforeUploadItem', item);
  13941. };
  13942. uploader.onProgressItem = function (fileItem, progress) {
  13943. console.info('onProgressItem', fileItem, progress);
  13944. };
  13945. uploader.onProgressAll = function (progress) {
  13946. console.info('onProgressAll', progress);
  13947. };
  13948. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13949. console.info('onSuccessItem', fileItem, response, status, headers);
  13950. };
  13951. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13952. console.info('onErrorItem', fileItem, response, status, headers);
  13953. };
  13954. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13955. console.info('onCancelItem', fileItem, response, status, headers);
  13956. };
  13957. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13958. console.info('onCompleteItem', fileItem, response, status, headers);
  13959. };
  13960. uploader.onCompleteAll = function () {
  13961. console.info('onCompleteAll');
  13962. };
  13963. }]
  13964. });
  13965. //无上传按钮附件上传组件
  13966. formlyConfigProvider.setType({
  13967. name: 'ui-dropfilenotup',
  13968. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  13969. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13970. controller: ['$scope', function ($scope) {
  13971. if (angular.isUndefined($scope.form.dropState)) {
  13972. $scope.form.dropState = false;
  13973. }
  13974. //附件上传数据
  13975. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13976. //$scope.options.templateOptions.uploader();
  13977. // FILTERS
  13978. uploader.filters.push({
  13979. name: 'customFilter',
  13980. fn: function (item /*{File|FileLikeObject}*/, options) {
  13981. return this.queue.length < 10;
  13982. }
  13983. });
  13984. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13985. uploader.onBeforeUploadItem = function (item) {
  13986. angular.extend(item.headers, $rootScope.getSession());
  13987. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13988. item.formData.push({
  13989. 'fileName': item.file.name
  13990. });
  13991. console.info('onBeforeUploadItem', item);
  13992. };
  13993. uploader.uploadAll();
  13994. }
  13995. // CALLBACKS
  13996. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13997. console.info('onWhenAddingFileFailed', item, filter, options);
  13998. };
  13999. uploader.onAfterAddingFile = function (fileItem) {
  14000. console.info('onAfterAddingFile', fileItem);
  14001. };
  14002. uploader.onAfterAddingAll = function (addedFileItems) {
  14003. console.info('onAfterAddingAll', addedFileItems);
  14004. };
  14005. uploader.onBeforeUploadItem = function (item) {
  14006. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14007. // // $scope.uploader.options.url();
  14008. // $scope.uploader.onBeforeUploadItem = function(item) {
  14009. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14010. // console.info('onBeforeUploadItem', item);
  14011. // };
  14012. // $scope.uploader.uploadAll();
  14013. // }
  14014. console.info('onBeforeUploadItem', item);
  14015. };
  14016. uploader.onProgressItem = function (fileItem, progress) {
  14017. console.info('onProgressItem', fileItem, progress);
  14018. };
  14019. uploader.onProgressAll = function (progress) {
  14020. console.info('onProgressAll', progress);
  14021. };
  14022. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14023. console.info('onSuccessItem', fileItem, response, status, headers);
  14024. };
  14025. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14026. console.info('onErrorItem', fileItem, response, status, headers);
  14027. };
  14028. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14029. console.info('onCancelItem', fileItem, response, status, headers);
  14030. };
  14031. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14032. console.info('onCompleteItem', fileItem, response, status, headers);
  14033. };
  14034. uploader.onCompleteAll = function () {
  14035. console.info('onCompleteAll');
  14036. };
  14037. }]
  14038. });
  14039. //无按钮知识库上传
  14040. formlyConfigProvider.setType({
  14041. name: 'ui-dropfielkn',
  14042. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14043. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14044. controller: ['$scope', function ($scope) {
  14045. if (angular.isUndefined($scope.form.dropState)) {
  14046. $scope.form.dropState = false;
  14047. }
  14048. //附件上传数据
  14049. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14050. //$scope.options.templateOptions.uploader();
  14051. // FILTERS
  14052. uploader.filters.push({
  14053. name: 'customFilter',
  14054. fn: function (item /*{File|FileLikeObject}*/, options) {
  14055. return this.queue.length < 10;
  14056. }
  14057. });
  14058. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14059. uploader.onBeforeUploadItem = function (item) {
  14060. angular.extend(item.headers, $rootScope.getSession());
  14061. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  14062. item.formData.push({
  14063. 'fileName': item.file.name
  14064. });
  14065. console.info('onBeforeUploadItem', item);
  14066. };
  14067. uploader.uploadAll();
  14068. }
  14069. // CALLBACKS
  14070. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14071. console.info('onWhenAddingFileFailed', item, filter, options);
  14072. };
  14073. uploader.onAfterAddingFile = function (fileItem) {
  14074. console.info('onAfterAddingFile', fileItem);
  14075. };
  14076. uploader.onAfterAddingAll = function (addedFileItems) {
  14077. console.info('onAfterAddingAll', addedFileItems);
  14078. };
  14079. uploader.onBeforeUploadItem = function (item) {
  14080. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14081. // // $scope.uploader.options.url();
  14082. // $scope.uploader.onBeforeUploadItem = function(item) {
  14083. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14084. // console.info('onBeforeUploadItem', item);
  14085. // };
  14086. // $scope.uploader.uploadAll();
  14087. // }
  14088. console.info('onBeforeUploadItem', item);
  14089. };
  14090. uploader.onProgressItem = function (fileItem, progress) {
  14091. console.info('onProgressItem', fileItem, progress);
  14092. };
  14093. uploader.onProgressAll = function (progress) {
  14094. console.info('onProgressAll', progress);
  14095. };
  14096. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14097. console.info('onSuccessItem', fileItem, response, status, headers);
  14098. };
  14099. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14100. console.info('onErrorItem', fileItem, response, status, headers);
  14101. };
  14102. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14103. console.info('onCancelItem', fileItem, response, status, headers);
  14104. };
  14105. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14106. console.info('onCompleteItem', fileItem, response, status, headers);
  14107. };
  14108. uploader.onCompleteAll = function () {
  14109. console.info('onCompleteAll');
  14110. };
  14111. }]
  14112. });
  14113. //附件上传列表组件
  14114. formlyConfigProvider.setType({
  14115. name: 'ui-dropfile',
  14116. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14117. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14118. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14119. if (angular.isUndefined($scope.form.dropState)) {
  14120. $scope.form.dropState = false;
  14121. }
  14122. //附件上传数据
  14123. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14124. //$scope.options.templateOptions.uploader();
  14125. // FILTERS
  14126. uploader.filters.push({
  14127. name: 'customFilter',
  14128. fn: function (item /*{File|FileLikeObject}*/, options) {
  14129. return this.queue.length < 10;
  14130. }
  14131. });
  14132. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14133. uploader.onBeforeUploadItem = function (item) {
  14134. angular.extend(item.headers, $rootScope.getSession());
  14135. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  14136. // if ($scope.options.templateOptions.formket) {
  14137. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  14138. // } else {
  14139. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  14140. // }
  14141. } else {
  14142. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14143. }
  14144. item.formData.push({
  14145. 'filename': item.file.name
  14146. });
  14147. console.info('onBeforeUploadItem', item);
  14148. };
  14149. uploader.uploadAll();
  14150. }
  14151. // CALLBACKS
  14152. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14153. console.info('onWhenAddingFileFailed', item, filter, options);
  14154. };
  14155. uploader.onAfterAddingFile = function (fileItem) {
  14156. console.info('onAfterAddingFile', fileItem);
  14157. };
  14158. uploader.onAfterAddingAll = function (addedFileItems) {
  14159. console.info('onAfterAddingAll', addedFileItems);
  14160. };
  14161. uploader.onBeforeUploadItem = function (item) {
  14162. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14163. // // $scope.uploader.options.url();
  14164. // $scope.uploader.onBeforeUploadItem = function(item) {
  14165. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14166. // console.info('onBeforeUploadItem', item);
  14167. // };
  14168. // $scope.uploader.uploadAll();
  14169. // }
  14170. console.info('onBeforeUploadItem', item);
  14171. };
  14172. uploader.onProgressItem = function (fileItem, progress) {
  14173. console.info('onProgressItem', fileItem, progress);
  14174. };
  14175. uploader.onProgressAll = function (progress) {
  14176. console.info('onProgressAll', progress);
  14177. };
  14178. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14179. console.info('onSuccessItem', fileItem, response, status, headers);
  14180. };
  14181. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14182. console.info('onErrorItem', fileItem, response, status, headers);
  14183. };
  14184. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14185. console.info('onCancelItem', fileItem, response, status, headers);
  14186. };
  14187. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14188. console.info('onCompleteItem', fileItem, response, status, headers);
  14189. };
  14190. uploader.onCompleteAll = function () {
  14191. console.info('onCompleteAll');
  14192. };
  14193. }]
  14194. });
  14195. //简易附件展示下载列表组件
  14196. formlyConfigProvider.setType({
  14197. name: 'ui-dropFiles',
  14198. templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
  14199. defaultOptions: function (options) {
  14200. return {
  14201. templateOptions: {
  14202. refresh: function (APIService, processInstanceId, data) {
  14203. return APIService.listAttachments(processInstanceId);
  14204. },
  14205. downloadUri: function (APIService, contentId) {
  14206. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14207. },
  14208. view: function (APIService, contentId) {
  14209. return APIService.attachmentsPreviewUrl(contentId);
  14210. },
  14211. download: function (APIService, contentId, item) {
  14212. var item = {
  14213. 'url': APIService.download(contentId),
  14214. 'headers': headers
  14215. };
  14216. return item;
  14217. },
  14218. refreshDelay: 0
  14219. }
  14220. };
  14221. },
  14222. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  14223. var _refreshDelayPromise;
  14224. // $scope.downloadUrl = function(contentId){
  14225. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14226. // };
  14227. $scope.download = function (contentId, filename, token) {
  14228. // console.log(contentId, filename, token)
  14229. //附件下载
  14230. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  14231. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  14232. // console.log(downUrl)
  14233. var a = document.createElement('a');
  14234. a.href = downUrl;
  14235. a.target = '_blank';
  14236. a.download = filename;
  14237. document.body.appendChild(a);
  14238. a.click();
  14239. };
  14240. $scope.view = function (contentId, token, filename, type) {
  14241. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14242. if (response.state == 200) {
  14243. window.open(response.previewUrl);
  14244. }
  14245. })
  14246. };
  14247. /**
  14248. * refresh
  14249. */
  14250. $scope._refresh = function (refreshAttr) {
  14251. $scope.attachments = [];
  14252. if (refreshAttr !== undefined) {
  14253. if (_refreshDelayPromise) {
  14254. $timeout.cancel(_refreshDelayPromise);
  14255. }
  14256. _refreshDelayPromise = $timeout(function () {
  14257. // 暂存附件
  14258. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  14259. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14260. $scope.options.templateOptions.processInstanceId, {
  14261. 'idx': 0,
  14262. 'sum': 1000
  14263. }).then(function (response) {
  14264. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14265. if (myData) {
  14266. for (var i = 0; i < myData.data.length; i++) {
  14267. $scope.attachments.push(myData.data[i]);
  14268. }
  14269. };
  14270. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14271. $scope.$parent.$parent.$parent.model.save_fileId, {
  14272. 'idx': 0,
  14273. 'sum': 1000
  14274. }).then(function (response2) {
  14275. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  14276. if (myData2) {
  14277. for (var i = 0; i < myData2.data.length; i++) {
  14278. $scope.attachments.push(myData2.data[i]);
  14279. }
  14280. // 只展示除图片以外的附件
  14281. var a = [];
  14282. $scope.attachments.forEach(e => {
  14283. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14284. // $scope.imgs.push(e)
  14285. } else {
  14286. a.push(e)
  14287. }
  14288. })
  14289. $scope.attachments = a;
  14290. };
  14291. console.log($scope.attachments)
  14292. });
  14293. });
  14294. // 正常附件
  14295. } else {
  14296. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14297. $scope.options.templateOptions.processInstanceId, {
  14298. 'idx': 0,
  14299. 'sum': 1000
  14300. }).then(function (response) {
  14301. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14302. if (myData) {
  14303. $scope.attachments = myData.data;
  14304. // 只展示除图片以外的附件
  14305. var a = [];
  14306. $scope.attachments.forEach(e => {
  14307. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14308. // $scope.imgs.push(e)
  14309. } else {
  14310. a.push(e)
  14311. }
  14312. })
  14313. $scope.attachments = a;
  14314. console.log($scope.attachments)
  14315. }
  14316. });
  14317. }
  14318. }, $scope.options.templateOptions.refreshDelay);
  14319. }
  14320. }
  14321. $scope._refresh({});
  14322. // $scope.attachments = $scope.model[$scope.options.key]
  14323. }]
  14324. });
  14325. //知识库附件上传
  14326. formlyConfigProvider.setType({
  14327. name: 'ui-dropfielknow',
  14328. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14329. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14330. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14331. if (angular.isUndefined($scope.form.dropState)) {
  14332. $scope.form.dropState = false;
  14333. }
  14334. //附件上传数据
  14335. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14336. //$scope.options.templateOptions.uploader();
  14337. // FILTERS
  14338. uploader.filters.push({
  14339. name: 'customFilter',
  14340. fn: function (item /*{File|FileLikeObject}*/, options) {
  14341. return this.queue.length < 10;
  14342. }
  14343. });
  14344. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14345. uploader.onBeforeUploadItem = function (item) {
  14346. angular.extend(item.headers, $rootScope.getSession());
  14347. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  14348. item.formData.push({
  14349. 'fileName': item.file.name,
  14350. 'type': 'solution',
  14351. 'solutionId': $scope.model.knowledge.id
  14352. });
  14353. console.info('onBeforeUploadItem', item);
  14354. };
  14355. uploader.uploadAll();
  14356. }
  14357. // CALLBACKS
  14358. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14359. console.info('onWhenAddingFileFailed', item, filter, options);
  14360. };
  14361. uploader.onAfterAddingFile = function (fileItem) {
  14362. console.info('onAfterAddingFile', fileItem);
  14363. };
  14364. uploader.onAfterAddingAll = function (addedFileItems) {
  14365. console.info('onAfterAddingAll', addedFileItems);
  14366. };
  14367. uploader.onBeforeUploadItem = function (item) {
  14368. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14369. // // $scope.uploader.options.url();
  14370. // $scope.uploader.onBeforeUploadItem = function(item) {
  14371. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14372. // console.info('onBeforeUploadItem', item);
  14373. // };
  14374. // $scope.uploader.uploadAll();
  14375. // }
  14376. console.info('onBeforeUploadItem', item);
  14377. };
  14378. uploader.onProgressItem = function (fileItem, progress) {
  14379. console.info('onProgressItem', fileItem, progress);
  14380. };
  14381. uploader.onProgressAll = function (progress) {
  14382. console.info('onProgressAll', progress);
  14383. };
  14384. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14385. console.info('onSuccessItem', fileItem, response, status, headers);
  14386. };
  14387. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14388. console.info('onErrorItem', fileItem, response, status, headers);
  14389. };
  14390. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14391. console.info('onCancelItem', fileItem, response, status, headers);
  14392. };
  14393. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14394. console.info('onCompleteItem', fileItem, response, status, headers);
  14395. };
  14396. uploader.onCompleteAll = function () {
  14397. console.info('onCompleteAll');
  14398. };
  14399. }]
  14400. });
  14401. //知识库附件下载列表
  14402. formlyConfigProvider.setType({
  14403. name: 'ui-dropfileknowledge',
  14404. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  14405. defaultOptions: function (options) {
  14406. return {
  14407. templateOptions: {
  14408. refresh: function (APIService, contentId, data) {
  14409. return APIService.fetchDataList(contentId, data);
  14410. },
  14411. downloadUri: function (APIService, contentId) {
  14412. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14413. },
  14414. download: function (APIService, contentId) {
  14415. return APIService.getSolutionDowpath(contentId);
  14416. },
  14417. view: function (attachmentId) {
  14418. // return APIService.attachmentsPreviewUrl(contentId);
  14419. },
  14420. refreshDelay: 0
  14421. }
  14422. };
  14423. },
  14424. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  14425. var _refreshDelayPromise;
  14426. $scope.attachments = [];
  14427. $scope.downloadUrl = function (contentId) {
  14428. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  14429. };
  14430. $scope.download = function (contentId, filename) {
  14431. $http({
  14432. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  14433. method: 'GET',
  14434. headers: {
  14435. //'Content-type' : 'application/xls',
  14436. 'Accept': '*/*'
  14437. },
  14438. responseType: 'arraybuffer'
  14439. }).success(function (data, status, headers, config) {
  14440. var file = new Blob([data], {
  14441. type: 'application/octet-stream'
  14442. });
  14443. //trick to download store a file having its URL
  14444. var fileURL = URL.createObjectURL(file);
  14445. var a = document.createElement('a');
  14446. a.href = fileURL;
  14447. a.target = '_blank';
  14448. a.download = filename;
  14449. document.body.appendChild(a);
  14450. a.click();
  14451. }).error(function (data, status, headers, config) {
  14452. // console.log(data);
  14453. });
  14454. }
  14455. $scope.view = function (contentId, filename, attachment) {
  14456. var index = filename.indexOf(".");
  14457. var type = filename.substring(index + 1);
  14458. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14459. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  14460. // var modalInstance = $modal.open({
  14461. // backdrop: false,
  14462. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14463. // controller: function($scope, scope, $modalInstance, filename) {
  14464. // $scope.title = filename;
  14465. // $scope.imageurl = scope.imageurl;
  14466. // $scope.cancel = function() {
  14467. // $modalInstance.dismiss('cancel');
  14468. // }
  14469. // },
  14470. // resolve: {
  14471. // scope: function() {
  14472. // return $scope;
  14473. // },
  14474. // filename: function() {
  14475. // return filename;
  14476. // }
  14477. // }
  14478. // });
  14479. // event.preventDefault();
  14480. // } else {
  14481. // for (var i = 0; i < $scope.attachments.length; i++) {
  14482. // if ($scope.attachments[i].id == attachmentId) {
  14483. window.open(attachment.previewUrl);
  14484. // }
  14485. // }
  14486. // }
  14487. };
  14488. $scope._refresh = function (refreshAttr) {
  14489. if (refreshAttr !== undefined) {
  14490. if (_refreshDelayPromise) {
  14491. $timeout.cancel(_refreshDelayPromise);
  14492. }
  14493. _refreshDelayPromise = $timeout(function () {
  14494. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14495. 'file', {
  14496. "file": {
  14497. "solutionId": $scope.model.knowledge.id
  14498. },
  14499. "idx": "0",
  14500. "sum": "1000"
  14501. }).then(function (response) {
  14502. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14503. if (myData) {
  14504. $scope.attachments = myData.list;
  14505. // $scope.view = function(attachmentId) {
  14506. // for (var i = 0; i < $scope.attachments.length; i++) {
  14507. // if ($scope.attachments[i].id == attachmentId) {
  14508. // window.open($scope.attachments[i].previewUrl);
  14509. // // var modalInstance = $modal.open({
  14510. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  14511. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  14512. // // }
  14513. // // });
  14514. // }
  14515. // }
  14516. // };
  14517. }
  14518. });
  14519. }, $scope.options.templateOptions.refreshDelay);
  14520. }
  14521. }
  14522. $scope._refresh({});
  14523. // $scope.attachments = $scope.model[$scope.options.key]
  14524. }]
  14525. });
  14526. //附件图片下载
  14527. formlyConfigProvider.setType({
  14528. name: 'ui-downimage',
  14529. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  14530. defaultOptions: function (options) {
  14531. return {
  14532. templateOptions: {
  14533. refresh: function (APIService, processInstanceId, data) {
  14534. return APIService.listAttachments(processInstanceId, data);
  14535. },
  14536. downloadUri: function (APIService, contentId) {
  14537. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14538. },
  14539. view: function (APIService, contentId) {
  14540. return APIService.attachmentsPreviewUrl(contentId);
  14541. },
  14542. download: function (APIService, contentId, item) {
  14543. var item = {
  14544. 'url': APIService.download(contentId),
  14545. 'headers': headers
  14546. };
  14547. return item;
  14548. },
  14549. refreshDelay: 0
  14550. }
  14551. };
  14552. },
  14553. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  14554. var _refreshDelayPromise;
  14555. // $scope.downloadUrl = function(contentId){
  14556. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14557. // };
  14558. $scope.download = function (contentId, filename) {
  14559. // var headers=
  14560. $http({
  14561. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14562. method: 'GET',
  14563. headers: {
  14564. //'Content-type' : 'application/xls',
  14565. 'Accept': '*/*'
  14566. },
  14567. responseType: 'arraybuffer'
  14568. }).success(function (data, status, headers, config) {
  14569. var file = new Blob([data], {
  14570. type: 'application/octet-stream'
  14571. });
  14572. //trick to download store a file having its URL
  14573. var fileURL = URL.createObjectURL(file);
  14574. var a = document.createElement('a');
  14575. a.href = fileURL;
  14576. a.target = '_blank';
  14577. a.download = filename;
  14578. document.body.appendChild(a);
  14579. a.click();
  14580. }).error(function (data, status, headers, config) {
  14581. // console.log(data);
  14582. });
  14583. };
  14584. $scope.view = function (contentId) {
  14585. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14586. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  14587. // if (response.state == 200) {
  14588. // window.open(response.previewUrl);
  14589. // }
  14590. // })
  14591. };
  14592. /**
  14593. * refresh
  14594. */
  14595. $scope._refresh = function (refreshAttr) {
  14596. if (refreshAttr !== undefined) {
  14597. if (_refreshDelayPromise) {
  14598. $timeout.cancel(_refreshDelayPromise);
  14599. }
  14600. _refreshDelayPromise = $timeout(function () {
  14601. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14602. $scope.options.templateOptions.processInstanceId, {
  14603. 'idx': 0,
  14604. 'sum': 1000
  14605. }).then(function (response) {
  14606. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14607. if (myData) {
  14608. $scope.attachments = myData.data;
  14609. }
  14610. });
  14611. }, $scope.options.templateOptions.refreshDelay);
  14612. }
  14613. }
  14614. $scope._refresh({});
  14615. // $scope.attachments = $scope.model[$scope.options.key]
  14616. }]
  14617. });
  14618. //附件下载列表组件
  14619. formlyConfigProvider.setType({
  14620. name: 'ui-dropfiletable',
  14621. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  14622. defaultOptions: function (options) {
  14623. return {
  14624. templateOptions: {
  14625. refresh: function (APIService, processInstanceId, data) {
  14626. return APIService.listAttachments(processInstanceId, data);
  14627. },
  14628. downloadUri: function (APIService, contentId) {
  14629. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14630. },
  14631. view: function (APIService, contentId) {
  14632. return APIService.attachmentsPreviewUrl(contentId);
  14633. },
  14634. download: function (APIService, contentId, item) {
  14635. var item = {
  14636. 'url': APIService.download(contentId),
  14637. 'headers': headers
  14638. };
  14639. return item;
  14640. },
  14641. refreshDelay: 0
  14642. }
  14643. };
  14644. },
  14645. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  14646. var _refreshDelayPromise;
  14647. // $scope.downloadUrl = function(contentId){
  14648. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14649. // };
  14650. $scope.download = function (contentId, filename) {
  14651. // var headers=
  14652. $http({
  14653. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14654. method: 'GET',
  14655. headers: {
  14656. //'Content-type' : 'application/xls',
  14657. 'Accept': '*/*'
  14658. },
  14659. responseType: 'arraybuffer'
  14660. }).success(function (data, status, headers, config) {
  14661. var file = new Blob([data], {
  14662. type: 'application/octet-stream'
  14663. });
  14664. //trick to download store a file having its URL
  14665. var fileURL = URL.createObjectURL(file);
  14666. var a = document.createElement('a');
  14667. a.href = fileURL;
  14668. a.target = '_blank';
  14669. a.download = filename;
  14670. document.body.appendChild(a);
  14671. a.click();
  14672. }).error(function (data, status, headers, config) {
  14673. // console.log(data);
  14674. });
  14675. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  14676. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  14677. // var file = new Blob([response], {
  14678. // type : 'application/octet-stream'
  14679. // });
  14680. // // var filename = filename;
  14681. // //var file = new Blob([response], {type: 'application/pdf'});
  14682. // var fileURL = URL.createObjectURL(file);
  14683. // var a = document.createElement('a');
  14684. // a.href = fileURL;
  14685. // a.target = '_blank';
  14686. // a.download = filename ;
  14687. // document.body.appendChild(a);
  14688. // a.click();
  14689. // })
  14690. };
  14691. $scope.view = function (contentId, token, filename, type) {
  14692. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14693. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14694. // var modalInstance = $modal.open({
  14695. // backdrop: false,
  14696. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14697. // controller: function($scope, scope, $modalInstance, filename) {
  14698. // $scope.title = filename;
  14699. // $scope.imageurl = scope.imageurl;
  14700. // $scope.cancel = function() {
  14701. // $modalInstance.dismiss('cancel');
  14702. // }
  14703. // },
  14704. // resolve: {
  14705. // scope: function() {
  14706. // return $scope;
  14707. // },
  14708. // filename: function() {
  14709. // return filename;
  14710. // }
  14711. // }
  14712. // });
  14713. // event.preventDefault();
  14714. // } else {
  14715. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14716. if (response.state == 200) {
  14717. window.open(response.previewUrl);
  14718. }
  14719. })
  14720. // }
  14721. };
  14722. /**
  14723. * refresh
  14724. */
  14725. $scope._refresh = function (refreshAttr) {
  14726. if (refreshAttr !== undefined) {
  14727. if (_refreshDelayPromise) {
  14728. $timeout.cancel(_refreshDelayPromise);
  14729. }
  14730. _refreshDelayPromise = $timeout(function () {
  14731. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14732. $scope.options.templateOptions.processInstanceId, {
  14733. 'idx': 0,
  14734. 'sum': 1000
  14735. }).then(function (response) {
  14736. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14737. if (myData) {
  14738. $scope.attachments = myData.data;
  14739. }
  14740. });
  14741. }, $scope.options.templateOptions.refreshDelay);
  14742. }
  14743. }
  14744. $scope._refresh({});
  14745. // $scope.attachments = $scope.model[$scope.options.key]
  14746. }]
  14747. });
  14748. //微信附件下载列表组件
  14749. formlyConfigProvider.setType({
  14750. name: 'ui-dropfilewechat',
  14751. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  14752. defaultOptions: function (options) {
  14753. return {
  14754. templateOptions: {
  14755. // refresh: function(APIService, processInstanceId, data) {
  14756. // return APIService.listAttachments(processInstanceId, data);
  14757. // },
  14758. // downloadUri: function(APIService, contentId) {
  14759. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  14760. // },
  14761. view: function (APIService, contentId) {
  14762. // return APIService.attachmentsPreviewUrl(contentId);
  14763. return APIService.attachmentsPreviewUrl(contentId);
  14764. },
  14765. download: function (APIService, contentId, item) {
  14766. var item = {
  14767. 'url': APIService.download(contentId),
  14768. 'headers': headers
  14769. };
  14770. return item;
  14771. },
  14772. // download: function(APIService, contentId, item) {
  14773. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  14774. // return item;
  14775. // },
  14776. refreshDelay: 0
  14777. }
  14778. };
  14779. },
  14780. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  14781. var _refreshDelayPromise;
  14782. // $scope.downloadUrl = function(contentId){
  14783. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14784. // };
  14785. $scope.attachments = {};
  14786. $scope.previewUrl = '';
  14787. $scope.download = function (token, filename) {
  14788. // var headers=
  14789. console.log($scope);
  14790. $http({
  14791. url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
  14792. method: 'GET',
  14793. headers: {
  14794. //'Content-type' : 'application/xls',
  14795. 'Accept': '*/*'
  14796. },
  14797. responseType: 'arraybuffer'
  14798. }).success(function (data, status, headers, config) {
  14799. var file = new Blob([data], {
  14800. type: 'application/octet-stream'
  14801. });
  14802. //trick to download store a file having its URL
  14803. var fileURL = URL.createObjectURL(file);
  14804. var a = document.createElement('a');
  14805. a.href = fileURL;
  14806. a.target = '_blank';
  14807. a.download = filename;
  14808. document.body.appendChild(a);
  14809. a.click();
  14810. }).error(function (data, status, headers, config) {
  14811. // console.log(data);
  14812. });
  14813. };
  14814. $scope.view = function (contentId, token, filename, type, previewUrl) {
  14815. // if (type) {
  14816. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  14817. // var modalInstance = $modal.open({
  14818. // backdrop: false,
  14819. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14820. // controller: function($scope, scope, $modalInstance, filename) {
  14821. // $scope.title = filename;
  14822. // $scope.imageurl = scope.imageurl;
  14823. // $scope.cancel = function() {
  14824. // $modalInstance.dismiss('cancel');
  14825. // }
  14826. // },
  14827. // resolve: {
  14828. // scope: function() {
  14829. // return $scope;
  14830. // },
  14831. // filename: function() {
  14832. // return filename;
  14833. // }
  14834. // }
  14835. // });
  14836. // event.preventDefault();
  14837. // } else {
  14838. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  14839. // if (response.state == 200) {
  14840. // window.open(response.previewUrl);
  14841. // }
  14842. // })
  14843. window.open(previewUrl);
  14844. // }
  14845. };
  14846. /**
  14847. * refresh
  14848. */
  14849. $scope._refresh = function (refreshAttr) {
  14850. if (refreshAttr !== undefined) {
  14851. if (_refreshDelayPromise) {
  14852. $timeout.cancel(_refreshDelayPromise);
  14853. }
  14854. _refreshDelayPromise = $timeout(function () {
  14855. // console.log(JSON.parse($stateParams.model))
  14856. var incidentChart = {};
  14857. if ($stateParams.model) {
  14858. incidentChart = JSON.parse($stateParams.model).model;
  14859. }
  14860. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14861. $scope.model).then(function (response) {
  14862. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14863. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  14864. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14865. if (myData) {
  14866. $scope.attachments = myData.data;
  14867. }
  14868. });
  14869. }, $scope.options.templateOptions.refreshDelay);
  14870. }
  14871. }
  14872. $scope._refresh({});
  14873. // $scope.attachments = $scope.model[$scope.options.key]
  14874. }]
  14875. });
  14876. formlyConfigProvider.setType({
  14877. name: 'ui-paralleltask',
  14878. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  14879. defaultOptions: function (options) {
  14880. return {
  14881. templateOptions: {
  14882. refresh: function (APIService, processInstanceId, data) {
  14883. //return APIService.listAttachments(processInstanceId, data);
  14884. },
  14885. refreshDelay: 0
  14886. }
  14887. };
  14888. },
  14889. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  14890. });
  14891. //repeatSection
  14892. //
  14893. formlyConfigProvider.setType({
  14894. name: 'ui-repeatSection',
  14895. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  14896. defaultOptions: function (options) {
  14897. return {
  14898. templateOptions: {
  14899. unique: 1,
  14900. initDisplay: false
  14901. }
  14902. };
  14903. },
  14904. controller: function ($scope) {
  14905. //$scope.options.templateOptions.unique;
  14906. $scope.formOptions = {
  14907. formState: $scope.formState
  14908. };
  14909. $scope.addNew = addNew;
  14910. $scope.copyFields = copyFields;
  14911. function copyFields(fields) {
  14912. fields = angular.copy(fields);
  14913. addRandomIds(fields);
  14914. return fields;
  14915. }
  14916. function addNew() {
  14917. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  14918. var repeatsection = $scope.model[$scope.options.key];
  14919. var lastSection = repeatsection[repeatsection.length - 1];
  14920. var newsection = {};
  14921. repeatsection.push(newsection);
  14922. }
  14923. function addRandomIds(fields) {
  14924. $scope.options.templateOptions.unique++;
  14925. angular.forEach(fields, function (field, index) {
  14926. if (field.fieldGroup) {
  14927. addRandomIds(field.fieldGroup);
  14928. return; // fieldGroups don't need an ID
  14929. }
  14930. if (field.templateOptions && field.templateOptions.fields) {
  14931. addRandomIds(field.templateOptions.fields);
  14932. }
  14933. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  14934. });
  14935. }
  14936. function getRandomInt(min, max) {
  14937. return Math.floor(Math.random() * (max - min)) + min;
  14938. }
  14939. if ($scope.options.templateOptions.initDisplay) {
  14940. addNew();
  14941. }
  14942. }
  14943. });
  14944. //时间轴任务列表组件
  14945. //cmdb控件
  14946. formlyConfigProvider.setType({
  14947. name: 'ui-cmdb',
  14948. extends: 'input',
  14949. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  14950. defaultOptions: function (options) {
  14951. return {
  14952. templateOptions: {
  14953. onClick: function (size, options, modal, event, model) {
  14954. var modalInstance = modal.open({
  14955. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  14956. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  14957. var width = $scope.width = 600;
  14958. var height = $scope.height = 400;
  14959. var tree;
  14960. var d3 = window.d3;
  14961. $scope.my_tree_handler = function (branch) {
  14962. //var _ref;
  14963. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  14964. APIService.query({
  14965. 'sign': classify
  14966. }).then(function (data) {
  14967. var myData = Restangular.stripRestangular(data);
  14968. // console.log(myData.data.node);
  14969. if (myData.data && myData.status == 200) {
  14970. var ret = myData.data;
  14971. redrawSvg(myData);
  14972. }
  14973. });
  14974. };
  14975. $scope.my_data = [];
  14976. function convertListToTree(data, treeMap) {
  14977. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  14978. var root = null; //Initially set our loop to null
  14979. var parentNode = null;
  14980. //loop over data
  14981. for (var i = 0; i < data.length; i++) {
  14982. var datum = data[i];
  14983. //each node will have children, so let's give it a "children" poperty
  14984. datum.children = [];
  14985. //add an entry for this node to the map so that any future children can
  14986. //lookup the parent
  14987. idToNodeMap[datum.id] = datum;
  14988. //Does this node have a parent?
  14989. if (typeof datum.parent === "undefined" || datum.parent == null) {
  14990. //Doesn't look like it, so this node is the root of the tree
  14991. root = datum;
  14992. treeMap[datum.id] = root;
  14993. } else {
  14994. //This node has a parent, so let's look it up using the id
  14995. parentNode = idToNodeMap[datum.parent.id];
  14996. //We don't need this property, so let's delete it.
  14997. delete datum.parent;
  14998. //Let's add the current node as a child of the parent node.
  14999. parentNode.children.push(datum);
  15000. }
  15001. }
  15002. return root;
  15003. }
  15004. function convertParentToChildList(data) {
  15005. var treeMap = {};
  15006. var list = [];
  15007. convertListToTree(data, treeMap);
  15008. angular.forEach(treeMap, function (item) {
  15009. list.push(item);
  15010. });
  15011. return list;
  15012. }
  15013. $scope.my_tree = tree = {};
  15014. $scope.try_async_load = function () {
  15015. $scope.my_data = [];
  15016. $scope.select_treedata = [];
  15017. $scope.doing_async = true;
  15018. ConfigDataService.fetchDataList('ciclassify', {
  15019. 'idx': 0,
  15020. 'sum': 100
  15021. }).then(function (result) {
  15022. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15023. $scope.doing_async = false;
  15024. });
  15025. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  15026. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15027. // $scope.doing_async = false;
  15028. // });
  15029. };
  15030. $scope.select_treedata = [];
  15031. $scope.propTypeOptions = [];
  15032. $scope.try_async_load();
  15033. $scope.onFilterCallback = function (item) {
  15034. //console.log(item);
  15035. if (angular.isDefined(item.children) && item.children.length >= 1) {
  15036. //not valid
  15037. } else {
  15038. var tempclassify = item.prefix.toLowerCase() + item.sign;
  15039. $scope.cifilter_classic = tempclassify;
  15040. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  15041. var myData = Restangular.stripRestangular(data);
  15042. $scope.propTypeOptions = myData;
  15043. });
  15044. }
  15045. }
  15046. $scope.onPropTypeChange = function (form) {
  15047. $scope.propOptions = form.fields;
  15048. }
  15049. $scope.onPropChange = function (prop) {
  15050. $scope.cifilter_prop = prop;
  15051. }
  15052. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  15053. //if(searchKey!=null&&searchKey.length>1){
  15054. var searchData = {};
  15055. if (angular.isUndefined(propObj)) {
  15056. propObj = $scope.cifilter_prop;
  15057. }
  15058. if (angular.isUndefined(ciclassify)) {
  15059. ciclassify = $scope.cifilter_classic;
  15060. }
  15061. searchData['sign'] = ciclassify;
  15062. if (angular.isDefined(propObj)) {
  15063. searchData[propObj.key] = searchKey;
  15064. }
  15065. APIService.query(searchData).then(function (response) {
  15066. var data = Restangular.stripRestangular(response);
  15067. //此处不清空nodes
  15068. var node = data.data.node;
  15069. var tempNode = [];
  15070. //nodes 或者links 要去重
  15071. for (var i = 0; i < node.length; i++) {
  15072. var tmp = 0;
  15073. for (var j = 0; j < nodes.length; j++) {
  15074. if (node[i].uuid == nodes[j].uuid) {
  15075. tmp++;
  15076. break;
  15077. }
  15078. }
  15079. if (tmp == 0) {
  15080. tempNode.push(node[i]);
  15081. }
  15082. }
  15083. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15084. nodes.push(tempNode[i]);
  15085. }
  15086. restart();
  15087. })
  15088. }
  15089. $scope.refresh = function () {
  15090. nodes.length = 0;
  15091. links.length = 0;
  15092. restart();
  15093. }
  15094. $scope.traversal = function () {
  15095. if ($scope.selected_node == null) {
  15096. SweetAlert.swal({
  15097. title: "错误的操作!",
  15098. text: "没有配置项被选中!",
  15099. type: "error"
  15100. });
  15101. } else {
  15102. var uuid = $scope.selected_node.uuid;
  15103. APIService.traversal(uuid).then(function (response) {
  15104. var d = response.data;
  15105. var node = d.node;
  15106. var link = d.edge;
  15107. var tempNode = [];
  15108. var tempLink = [];
  15109. //nodes 或者links 要去重
  15110. for (var i = 0; i < node.length; i++) {
  15111. var tmp = 0;
  15112. for (var j = 0; j < nodes.length; j++) {
  15113. if (node[i].id == nodes[j].id) {
  15114. tmp++;
  15115. break;
  15116. }
  15117. }
  15118. if (tmp == 0) {
  15119. tempNode.push(node[i]);
  15120. }
  15121. }
  15122. for (var i = 0; i < link.length; i++) {
  15123. var tmp = 0;
  15124. for (var j = 0; j < links.length; j++) {
  15125. if (link[i].id == links[j].id) {
  15126. tmp++;
  15127. break;
  15128. }
  15129. }
  15130. if (tmp == 0) {
  15131. tempLink.push(link[i]);
  15132. }
  15133. }
  15134. //数据写入页面
  15135. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15136. nodes.push(tempNode[i]);
  15137. }
  15138. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15139. links.push(tempLink[i]);
  15140. }
  15141. //links转换
  15142. for (var i = 0; i < links.length; i++) {
  15143. for (var j = 0; j < nodes.length; j++) {
  15144. if (links[i].source == nodes[j].id) {
  15145. links[i].source = nodes[j];
  15146. }
  15147. if (links[i].target == nodes[j].id) {
  15148. links[i].target = nodes[j];
  15149. }
  15150. }
  15151. }
  15152. restart();
  15153. })
  15154. }
  15155. }
  15156. var svg;
  15157. var force;
  15158. var drag_line, path, circle;
  15159. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  15160. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15161. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15162. var nodes = [],
  15163. links = [];
  15164. var treeNodes = [];
  15165. //读取labels (node)
  15166. var labels = [];
  15167. function redrawSvg(json) {
  15168. nodes.length = 0; //先清空
  15169. links.length = 0;
  15170. var data = json.data;
  15171. for (var i = 0; i < data.node.length; i++) {
  15172. nodes.push(data.node[i]);
  15173. }
  15174. restart();
  15175. }
  15176. //读取status (节点 连线)
  15177. var statuses = [];
  15178. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  15179. // if (result && result.status == 200) {
  15180. // d3.select('#nodeStatus').selectAll('option')
  15181. // .data(statuses).enter()
  15182. // .append('option')
  15183. // .attr('value', function(d) { return d.code; })
  15184. // .html(function(d) { return d.desc; });
  15185. // } else {
  15186. // SweetAlert.swal({
  15187. // title: "提示!",
  15188. // text: "服务器请求异常!",
  15189. // type: "error"
  15190. // });
  15191. // }
  15192. // });
  15193. api_wechatfile.getDictionary({
  15194. 'key': 'cmdb_status',
  15195. 'type': 'list'
  15196. }).then(function (result) {
  15197. if (result) {
  15198. d3.select('#nodeStatus').selectAll('option')
  15199. .data(statuses).enter()
  15200. .append('option')
  15201. .attr('value', function (d) {
  15202. return d.code;
  15203. })
  15204. .html(function (d) {
  15205. return d.desc;
  15206. });
  15207. } else {
  15208. SweetAlert.swal({
  15209. title: "提示!",
  15210. text: "服务器请求异常!",
  15211. type: "error"
  15212. });
  15213. }
  15214. });
  15215. //查询relationship_type表 name 为表里的type,label为显示值
  15216. var linkType = [];
  15217. function fetchEdgeTypes() {
  15218. ConfigDataService.fetchDataList('ciedgetype', {
  15219. 'idx': 0,
  15220. 'sum': 100
  15221. }).then(function (response) {
  15222. if (response) {
  15223. if (response['list']) {
  15224. linkType = response['list'];
  15225. // d3.select('#linkName').selectAll('option')
  15226. // .data(linkType).enter()
  15227. // .append('option')
  15228. // .attr('value',function(d){return d.type;})
  15229. // .html(function(d){ return d.label;});
  15230. } else {
  15231. SweetAlert.swal({
  15232. title: "提示!",
  15233. text: "服务器请求异常!",
  15234. type: "error"
  15235. });
  15236. }
  15237. } else {
  15238. SweetAlert.swal({
  15239. title: "提示!",
  15240. text: "服务器请求异常!",
  15241. type: "error"
  15242. });
  15243. }
  15244. })
  15245. }
  15246. // fetchEdgeTypes();
  15247. /*
  15248. // init D3 force layout
  15249. var force = d3.layout.force()
  15250. .nodes(nodes)
  15251. .links(links)
  15252. .size([width, height])
  15253. .gravity(.05)
  15254. .linkDistance(150)
  15255. .linkStrength(2)
  15256. .charge(-500)
  15257. .on('tick', tick);
  15258. // define arrow markers for graph links
  15259. svg.append('svg:defs').append('svg:marker')
  15260. .attr('id', 'end-arrow')
  15261. .attr('viewBox', '0 -5 10 10')
  15262. .attr('refX', 6)
  15263. .attr('markerWidth', 3)
  15264. .attr('markerHeight', 3)
  15265. .attr('orient', 'auto')
  15266. .append('svg:path')
  15267. .attr('d', 'M0,-5L10,0L0,5')
  15268. .attr('fill', '#000');
  15269. svg.append('svg:defs').append('svg:marker')
  15270. .attr('id', 'start-arrow')
  15271. .attr('viewBox', '0 -5 10 10')
  15272. .attr('refX', 4)
  15273. .attr('markerWidth', 3)
  15274. .attr('markerHeight', 3)
  15275. .attr('orient', 'auto')
  15276. .append('svg:path')
  15277. .attr('d', 'M10,-5L0,0L10,5')
  15278. .attr('fill', '#000');
  15279. // line displayed when dragging new nodes
  15280. var drag_line = svg.append('svg:path')
  15281. .attr('class', 'link dragline hidden')
  15282. .attr('d', 'M0,0L0,0');
  15283. // handles to link and node element groups
  15284. //(1)var path = svg.append('svg:g').selectAll('g')
  15285. var path = svg.append('svg:g').selectAll('g'),
  15286. circle = svg.append('svg:g').selectAll('g');
  15287. */
  15288. // mouse event vars
  15289. var selected_node = null,
  15290. selected_link = null,
  15291. mousedown_link = null,
  15292. mousedown_node = null,
  15293. mouseup_node = null;
  15294. function resetMouseVars() {
  15295. mousedown_node = null;
  15296. mouseup_node = null;
  15297. mousedown_link = null;
  15298. }
  15299. // update force layout (called automatically each iteration)
  15300. function tick() {
  15301. // draw directed edges with proper padding from node centers
  15302. path.selectAll('path').attr('d', function (d) {
  15303. var deltaX = d.target.x - d.source.x,
  15304. deltaY = d.target.y - d.source.y,
  15305. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  15306. normX = deltaX / dist,
  15307. normY = deltaY / dist,
  15308. sourcePadding = d.left ? 27 : 22,
  15309. targetPadding = d.right ? 27 : 22,
  15310. sourceX = d.source.x + (sourcePadding * normX),
  15311. sourceY = d.source.y + (sourcePadding * normY),
  15312. targetX = d.target.x - (targetPadding * normX),
  15313. targetY = d.target.y - (targetPadding * normY);
  15314. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  15315. });
  15316. circle.attr('transform', function (d) {
  15317. return 'translate(' + d.x + ',' + d.y + ')';
  15318. });
  15319. }
  15320. // update graph (called when needed)
  15321. function restart() {
  15322. //绑定link 数据
  15323. path.datum(links);
  15324. // path (link) group
  15325. path = path.data(links, function (d) {
  15326. return d.id;
  15327. });
  15328. var p = path.enter().append('svg:g');
  15329. //update existing links
  15330. path.selectAll('path').classed('selected', function (d) {
  15331. return d === selected_link;
  15332. })
  15333. .style('marker-start', function (d) {
  15334. return d.left ? 'url(#start-arrow)' : '';
  15335. })
  15336. .style('marker-end', function (d) {
  15337. return d.right ? 'url(#end-arrow)' : '';
  15338. });
  15339. // add new links
  15340. p.append('svg:path')
  15341. .attr('class', 'link')
  15342. .attr('id', function (d) {
  15343. return "path_" + d.id;
  15344. })
  15345. // .attr('startOffset', '0%')
  15346. .classed('selected', function (d) {
  15347. return d === selected_link;
  15348. })
  15349. .style('marker-start', function (d) {
  15350. return d.left ? 'url(#start-arrow)' : '';
  15351. })
  15352. .style('marker-end', function (d) {
  15353. return d.right ? 'url(#end-arrow)' : '';
  15354. })
  15355. .on('mousedown', function (d) {
  15356. if (d3.event.ctrlKey) return;
  15357. //去除没有提交的连线
  15358. for (var i = 0; i < links.length; i++) {
  15359. if (links[i].id == -1 && d.id != -1) {
  15360. links.splice(i, 1);
  15361. }
  15362. }
  15363. // select link
  15364. mousedown_link = d;
  15365. if (mousedown_link === selected_link) {
  15366. selected_link = $scope.selected_link = null;
  15367. selected_node = $scope.selected_node = null;
  15368. // d3.select("#linkDetail").attr('style','display:none');
  15369. //hideLinkForm(true);//return ;
  15370. } else {
  15371. selected_link = $scope.selected_link = mousedown_link;
  15372. selected_node = $scope.selected_node = null;
  15373. }
  15374. selected_node = $scope.selected_node = null;
  15375. restart();
  15376. });
  15377. p.append('svg:text')
  15378. .attr('x', 30)
  15379. .attr('y', 20)
  15380. .attr('class', 'fontM')
  15381. .append('textPath')
  15382. .attr('xlink:xlink:href', function (d, i) {
  15383. return "#path_" + d.id;
  15384. })
  15385. .html(function (d) {
  15386. for (var i = 0; i < linkType.length; i++) {
  15387. if (linkType[i].type == d.name) {
  15388. return linkType[i].label;
  15389. }
  15390. }
  15391. });
  15392. // remove old links
  15393. path.exit().remove();
  15394. // circle (node) group
  15395. // NB: the function arg is crucial here! nodes are known by id, not by index!
  15396. circle.datum(nodes);
  15397. circle = circle.data(nodes, function (d) {
  15398. return d.id;
  15399. });
  15400. // update existing nodes (reflexive & selected visual states)
  15401. circle.selectAll('circle')
  15402. .style('fill', function (d) {
  15403. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15404. })
  15405. .style('fill-opacity', 0.75) // add by xi
  15406. .classed('reflexive', function (d) {
  15407. return d.reflexive;
  15408. });
  15409. // add new nodes
  15410. var g = circle.enter().append('svg:g');
  15411. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  15412. //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');
  15413. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  15414. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  15415. }).style('stroke', function (d) {
  15416. return d3.rgb(colors(d.label)).darker().toString();
  15417. }).style('stroke-width', '2');
  15418. g.append('svg:circle')
  15419. .attr('class', 'node')
  15420. .attr('r', 18)
  15421. .style('fill', function (d) {
  15422. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15423. })
  15424. .style('stroke', function (d) {
  15425. return d3.rgb(colors(d.label)).darker().toString();
  15426. })
  15427. .style('fill-opacity', 0.25) //add by xj
  15428. .style('stroke-opacity', 0.5) //add by xj
  15429. .classed('reflexive', function (d) {
  15430. return d.reflexive;
  15431. });
  15432. g.on('mouseover', function (d) {
  15433. //if(!mousedown_node || d === mousedown_node) return;
  15434. // enlarge target node
  15435. //d3.select(this).attr('transform', 'scale(1.1)');
  15436. })
  15437. .on('mouseout', function (d) {
  15438. //if(!mousedown_node || d === mousedown_node) return;
  15439. // unenlarge target node
  15440. //d3.select(this).attr('transform', '');
  15441. })
  15442. .on('mousedown', function (d) {
  15443. if (d3.event.ctrlKey) return;
  15444. //hideLinkForm(true);
  15445. //去除没有提交的连线
  15446. for (var i = 0; i < links.length; i++) {
  15447. if (links[i].id == -1) {
  15448. links.splice(i, 1);
  15449. }
  15450. }
  15451. // select node
  15452. mousedown_node = d;
  15453. if (mousedown_node === selected_node) {
  15454. selected_node = $scope.selected_node = null;
  15455. } else {
  15456. selected_node = $scope.selected_node = mousedown_node;
  15457. selected_link = $scope.selected_link = null;
  15458. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  15459. APIService.findRefById(selected_node.id).then(function (result) {
  15460. var d = result.data;
  15461. var node = d.node;
  15462. var link = d.edge;
  15463. var tempNode = [];
  15464. var tempLink = [];
  15465. //nodes 或者links 要去重
  15466. for (var i = 0; i < node.length; i++) {
  15467. var tmp = 0;
  15468. for (var j = 0; j < nodes.length; j++) {
  15469. if (node[i].id == nodes[j].id) {
  15470. tmp++;
  15471. break;
  15472. }
  15473. }
  15474. if (tmp == 0) {
  15475. tempNode.push(node[i]);
  15476. }
  15477. }
  15478. for (var i = 0; i < link.length; i++) {
  15479. var tmp = 0;
  15480. for (var j = 0; j < links.length; j++) {
  15481. if (link[i].id == links[j].id) {
  15482. tmp++;
  15483. break;
  15484. }
  15485. }
  15486. if (tmp == 0) {
  15487. tempLink.push(link[i]);
  15488. }
  15489. }
  15490. //数据写入页面
  15491. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15492. nodes.push(tempNode[i]);
  15493. }
  15494. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15495. links.push(tempLink[i]);
  15496. }
  15497. //links转换
  15498. for (var i = 0; i < links.length; i++) {
  15499. for (var j = 0; j < nodes.length; j++) {
  15500. if (links[i].source == nodes[j].id) {
  15501. links[i].source = nodes[j];
  15502. }
  15503. if (links[i].target == nodes[j].id) {
  15504. links[i].target = nodes[j];
  15505. }
  15506. }
  15507. }
  15508. restart();
  15509. });
  15510. }
  15511. // reposition drag line
  15512. drag_line
  15513. .style('marker-end', 'url(#end-arrow)')
  15514. .classed('hidden', false)
  15515. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  15516. restart();
  15517. })
  15518. .on('mouseup', function (d) {
  15519. if (!mousedown_node) return;
  15520. });
  15521. // show node name
  15522. g.append('svg:text')
  15523. .attr('x', 0)
  15524. .attr('y', 34)
  15525. .attr('class', 'id')
  15526. .text(function (d) {
  15527. return d.name;
  15528. }); //TODO 改为 d.name
  15529. //设置图片
  15530. g.append('svg:foreignObject')
  15531. .attr("width", 32)
  15532. .attr("height", 32)
  15533. .attr('x', "-16px")
  15534. .attr('y', "-11px")
  15535. .html(function (d) {
  15536. for (var i = 0; i < labels.length; i++) {
  15537. if (d.label == labels[i].sign) {
  15538. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  15539. }
  15540. }
  15541. });
  15542. // remove old nodes
  15543. circle.exit().remove();
  15544. // set the graph in motion
  15545. force.start();
  15546. }
  15547. function mousedown() {
  15548. // prevent I-bar on drag
  15549. //d3.event.preventDefault();
  15550. // because :active only works in WebKit?
  15551. svg.classed('active', true);
  15552. if (mousedown_node) {
  15553. viewNode(mousedown_node);
  15554. }
  15555. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  15556. restart();
  15557. }
  15558. function mousemove() {
  15559. if (!mousedown_node) return;
  15560. // update drag line
  15561. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  15562. //restart();
  15563. }
  15564. function mouseup() {
  15565. if (mousedown_node) {
  15566. // hide drag line
  15567. drag_line
  15568. .classed('hidden', true)
  15569. .style('marker-end', '');
  15570. }
  15571. // because :active only works in WebKit?
  15572. svg.classed('active', false);
  15573. // clear mouse event vars
  15574. resetMouseVars();
  15575. }
  15576. function spliceLinksForNode(node) {
  15577. var toSplice = links.filter(function (l) {
  15578. return (l.source === node || l.target === node);
  15579. });
  15580. toSplice.map(function (l) {
  15581. links.splice(links.indexOf(l), 1);
  15582. });
  15583. }
  15584. // only respond once per keydown
  15585. var lastKeyDown = -1;
  15586. function keydown() {
  15587. //d3.event.preventDefault();
  15588. if (lastKeyDown !== -1) return;
  15589. lastKeyDown = d3.event.keyCode;
  15590. // ctrl
  15591. if (d3.event.keyCode === 17) {
  15592. circle.call(force.drag);
  15593. svg.classed('ctrl', true);
  15594. }
  15595. if (!selected_node && !selected_link) return;
  15596. switch (d3.event.keyCode) {
  15597. case 8: // backspace
  15598. case 66: // B
  15599. if (selected_link) {
  15600. // set link direction to both left and right
  15601. selected_link.left = true;
  15602. selected_link.right = true;
  15603. }
  15604. restart();
  15605. break;
  15606. case 76: // L
  15607. if (selected_link) {
  15608. // set link direction to left only
  15609. selected_link.left = true;
  15610. selected_link.right = false;
  15611. }
  15612. restart();
  15613. break;
  15614. case 82: // R
  15615. if (selected_node) {
  15616. // toggle node reflexivity
  15617. selected_node.reflexive = !selected_node.reflexive;
  15618. } else if (selected_link) {
  15619. // set link direction to right only
  15620. selected_link.left = false;
  15621. selected_link.right = true;
  15622. }
  15623. restart();
  15624. break;
  15625. }
  15626. }
  15627. function keyup() {
  15628. lastKeyDown = -1;
  15629. // ctrl
  15630. if (d3.event.keyCode === 17) {
  15631. circle
  15632. .on('mousedown.drag', null)
  15633. .on('touchstart.drag', null);
  15634. svg.classed('ctrl', false);
  15635. }
  15636. }
  15637. function viewNode(node) {
  15638. // console.log(svg.attr('left'));
  15639. //var el = angular.element('div.modal-dialog')[0];
  15640. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  15641. if (!$scope.selected_node.props.state) {
  15642. $scope.selected_node.props.state = "空"
  15643. } else if ($scope.selected_node.props.state) {
  15644. if ($scope.selected_node.props.state == "1") {
  15645. $scope.selected_node.props.state = "未审核"
  15646. } else if ($scope.selected_node.props.state == "2") {
  15647. $scope.selected_node.props.state = "已审核"
  15648. } else if ($scope.selected_node.props.state == "3") {
  15649. $scope.selected_node.props.state = "不匹配"
  15650. } else if ($scope.selected_node.props.state == "4") {
  15651. $scope.selected_node.props.state = "丢失"
  15652. }
  15653. };
  15654. if (!$scope.selected_node.name) {
  15655. $scope.selected_node.name = "空"
  15656. }
  15657. if (!$scope.selected_node.status) {
  15658. $scope.selected_node.statu = "空"
  15659. }
  15660. if (!$scope.selected_node.props.useradmin) {
  15661. $scope.selected_node.props.useradmin = "空"
  15662. }
  15663. Toaster.pop({
  15664. // type: 'info',
  15665. // title: title,
  15666. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  15667. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  15668. '<p>状态:' + $scope.selected_node.status + '</p>' +
  15669. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  15670. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  15671. bodyOutputType: 'trustedHtml',
  15672. timeout: 3000
  15673. })
  15674. }
  15675. //GT 颜色与数值对照表
  15676. function colors(sign) {
  15677. //num=num>20?num%20:parseInt(num);
  15678. for (var i = 0; i < labels.length; i++) {
  15679. var entity = labels[i];
  15680. if (sign == entity.sign) {
  15681. return entity.color;
  15682. }
  15683. if (i == labels.length - 1 && sign != entity.sign) {
  15684. return '#ffeeee';
  15685. }
  15686. }
  15687. }
  15688. $scope.init = function () {
  15689. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15690. // init D3 force layout
  15691. force = d3.layout.force()
  15692. .nodes(nodes)
  15693. .links(links)
  15694. .size([width, height])
  15695. .gravity(.05)
  15696. .linkDistance(150)
  15697. .linkStrength(2)
  15698. .charge(-500)
  15699. .on('tick', tick);
  15700. // define arrow markers for graph links
  15701. svg.append('svg:defs').append('svg:marker')
  15702. .attr('id', 'end-arrow')
  15703. .attr('viewBox', '0 -5 10 10')
  15704. .attr('refX', 6)
  15705. .attr('markerWidth', 3)
  15706. .attr('markerHeight', 3)
  15707. .attr('orient', 'auto')
  15708. .append('svg:path')
  15709. .attr('d', 'M0,-5L10,0L0,5')
  15710. .attr('fill', '#000');
  15711. svg.append('svg:defs').append('svg:marker')
  15712. .attr('id', 'start-arrow')
  15713. .attr('viewBox', '0 -5 10 10')
  15714. .attr('refX', 4)
  15715. .attr('markerWidth', 3)
  15716. .attr('markerHeight', 3)
  15717. .attr('orient', 'auto')
  15718. .append('svg:path')
  15719. .attr('d', 'M10,-5L0,0L10,5')
  15720. .attr('fill', '#000');
  15721. // line displayed when dragging new nodes
  15722. drag_line = svg.append('svg:path')
  15723. .attr('class', 'link dragline hidden')
  15724. .attr('d', 'M0,0L0,0');
  15725. // handles to link and node element groups
  15726. //(1)var path = svg.append('svg:g').selectAll('g')
  15727. path = svg.append('svg:g').selectAll('g');
  15728. circle = svg.append('svg:g').selectAll('g');
  15729. svg.on('mousedown', mousedown)
  15730. .on('mousemove', mousemove)
  15731. .on('mouseup', mouseup);
  15732. d3.select(window)
  15733. .on('keydown', keydown)
  15734. .on('keyup', keyup);
  15735. }
  15736. var CI = {};
  15737. window.CI = CI;
  15738. $scope.ok = function () {
  15739. $modalInstance.close($scope.selected_node);
  15740. };
  15741. $scope.cancel = function () {
  15742. $modalInstance.dismiss('cancel');
  15743. };
  15744. },
  15745. size: size,
  15746. resolve: {
  15747. title: function () {
  15748. return options.templateOptions.title;
  15749. },
  15750. Restangular: function () {
  15751. return options.templateOptions.Restangular;
  15752. },
  15753. APIService: function () {
  15754. return options.templateOptions.ApiService;
  15755. },
  15756. ConfigDataService: function () {
  15757. return options.templateOptions.ConfigDataService;
  15758. },
  15759. ConfigFormService: function () {
  15760. return options.templateOptions.ConfigFormService;
  15761. },
  15762. SweetAlert: function () {
  15763. return options.templateOptions.Alert;
  15764. },
  15765. Toaster: function () {
  15766. return options.templateOptions.toaster;
  15767. }
  15768. }
  15769. });
  15770. modalInstance.result.then(function (selectedItem) {
  15771. options.value(selectedItem.name + '-' + selectedItem.uuid);
  15772. }, function () {
  15773. //console.log('Modal dismissed at: ' + new Date());
  15774. });
  15775. }
  15776. }
  15777. }
  15778. },
  15779. controller: ['$scope', function ($scope) {
  15780. // setTimeout(function(){
  15781. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  15782. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  15783. // if(modelData.status==200){
  15784. // $scope.model[$scope.options.key] = modelData.data;
  15785. // $scope.options.initialValue = $scope.model[$scope.options.key];
  15786. // }
  15787. // });
  15788. // },1000);
  15789. }]
  15790. });
  15791. });
  15792. appFormly.run(function (formlyConfig, $parse) {
  15793. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  15794. var removeOnHideTransformer = function (fields, model) {
  15795. return fields.map(function (field) {
  15796. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  15797. addFieldRemoveOnHideWatcher(field);
  15798. }
  15799. if (field.type == "ui-title") {
  15800. addFieldRemoveOnHideWatcher(field);
  15801. }
  15802. return field;
  15803. });
  15804. };
  15805. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  15806. function addFieldRemoveOnHideWatcher(field) {
  15807. var watcher = getWatcher();
  15808. if (field.watcher) {
  15809. if (!angular.isArray(field.watcher)) {
  15810. field.watcher = [field.watcher];
  15811. }
  15812. field.watcher.push(watcher);
  15813. } else {
  15814. field.watcher = watcher;
  15815. }
  15816. }
  15817. function getWatcher() {
  15818. return {
  15819. expression: function (field) {
  15820. return field.hide;
  15821. },
  15822. listener: function (field, newHide, oldHide, scope) {
  15823. if (field.hide) {
  15824. if (field.templateOptions.pkey) {
  15825. if (field.key == 'transferuser') {
  15826. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  15827. }
  15828. } else {
  15829. $parse(field.key).assign(scope.model, undefined);
  15830. }
  15831. }
  15832. if (field.type == "ui-title") {
  15833. $parse(field.key).assign(scope.model, undefined);
  15834. }
  15835. }
  15836. };
  15837. }
  15838. });
  15839. 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',
  15840. 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) {
  15841. //console.log($parse('Restangular')($scope));
  15842. //console.log($injector.get('Restangular'));
  15843. //console.log($stateParams);
  15844. //保存报修主体
  15845. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15846. $scope.imgUrlList = [];
  15847. $scope.uploadimg_del = function () {
  15848. console.log(123)
  15849. };
  15850. var vm = this;
  15851. vm.options = {};
  15852. vm.exampleTitle = ['expressionProperties', 'model property'];
  15853. vm.fields = [];
  15854. vm.model = {};
  15855. $scope.langs = i18nService.getAllLangs();
  15856. $scope.lang = 'zh-cn';
  15857. i18nService.setCurrentLang($scope.lang);
  15858. //alert($rootScope.user.id,null,2);
  15859. vm.model["loginUser"] = $rootScope.user;
  15860. var loginUser = $rootScope.user;
  15861. // console.log(vm);
  15862. var that = $injector;
  15863. var parse = $parse;
  15864. var formKey = "";
  15865. var pdKey = "";
  15866. var modelWatch = "";
  15867. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  15868. modelWatch = JSON.parse($stateParams.model);
  15869. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  15870. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  15871. console.log(modelWatch,$rootScope)
  15872. if(modelWatch.model.incident){
  15873. if(modelWatch.model.incident.place){
  15874. $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  15875. }else{
  15876. $rootScope.selecthouseNumber = undefined;
  15877. }
  15878. }
  15879. }
  15880. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  15881. pdKey = $state.current.pdKey;
  15882. } else if ($stateParams.pdKey) {
  15883. pdKey = $stateParams.pdKey;
  15884. }
  15885. // console.log("pdKey::" + JSON.stringify($state.current.title));
  15886. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  15887. formKey = $stateParams.formKey;
  15888. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  15889. }
  15890. if (angular.isDefined($stateParams.model)) {
  15891. var formModel = $stateParams.model;
  15892. }
  15893. //用户测试数据,后续从header的auth中获取
  15894. var userId = 2;
  15895. userId = $rootScope.user.id;
  15896. //==============处理表单设计数据 开始====================
  15897. //处理组件加载后台数据选项的方法
  15898. function refreshSelectOptions(searchVal, field) {
  15899. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  15900. var process = BpmRestangular.all("");
  15901. if (field.templateOptions.ApiService) {
  15902. process = UserRestangular.all("");
  15903. }
  15904. if (field.templateOptions.Apicommon) {
  15905. process = WechatRestangular.all("");
  15906. }
  15907. var datakey = {
  15908. "idx": 0,
  15909. "sum": 1000
  15910. };
  15911. if (field.templateOptions.modelreasondata) {
  15912. datakey = field.templateOptions.modelreasondata
  15913. }
  15914. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  15915. if (!field.templateOptions.options) {
  15916. field.templateOptions.options = [];
  15917. }
  15918. if (field.templateOptions.optionsDataKey) {
  15919. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  15920. } else {
  15921. field.templateOptions.options = result;
  15922. }
  15923. });
  15924. }
  15925. }
  15926. //获取表单后数据处理
  15927. function formfield(field, result) {
  15928. // angular.forEach(fields.fields, function(field) {
  15929. if (field.key == "") {
  15930. delete field.key;
  15931. }
  15932. if (angular.isDefined(field.extjson)) {
  15933. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  15934. angular.extend(field.templateOptions, extObj.templateOptions);
  15935. delete extObj.templateOptions;
  15936. for (var prop in extObj) {
  15937. if (new RegExp("Expression").test(prop)) {
  15938. //var obj = $scope.$eval(extObj[prop]);
  15939. //extObj[prop] = $scope.$eval(extObj[prop]);
  15940. if (extObj[prop] != null) {
  15941. if (new RegExp("function").test(extObj[prop])) {
  15942. var propValue = eval(extObj[prop]);
  15943. extObj[prop] = propValue;
  15944. } else {
  15945. //console.log(extObj[prop]);
  15946. var obj = $scope.$eval(extObj[prop]);
  15947. extObj[prop] = obj;
  15948. //console.log(obj);
  15949. }
  15950. }
  15951. } else if (new RegExp("expressionProperties").test(prop)) {
  15952. for (var p in extObj[prop]) {
  15953. if (new RegExp("function").test(extObj[prop][p])) {
  15954. var propValue = eval(extObj[prop][p]);
  15955. extObj[prop][p] = propValue;
  15956. } else {
  15957. //if(p.indexOf("'")>=0){
  15958. // var obj = $scope.$eval(extObj[prop][p]);
  15959. // extObj[prop][$scope.$eval(p)]=obj;
  15960. //}
  15961. }
  15962. }
  15963. } else if ("watcher" == prop) {
  15964. if (angular.isArray(extObj[prop])) {
  15965. angular.forEach(extObj[prop], function (item, index) {
  15966. for (var p in item) {
  15967. if (new RegExp("function").test(item[p])) {
  15968. var propValue = eval(item[p]);
  15969. extObj[prop][index][p] = propValue;
  15970. }
  15971. }
  15972. });
  15973. } else if (angular.isObject(extObj[prop])) {
  15974. for (var p in extObj[prop]) {
  15975. if (new RegExp("function").test(extObj[prop][p])) {
  15976. var propValue = eval(extObj[prop][p]);
  15977. extObj[prop][p] = propValue;
  15978. }
  15979. }
  15980. }
  15981. }
  15982. }
  15983. angular.extend(field, extObj);
  15984. delete field.extjson;
  15985. }
  15986. if (angular.isDefined(field.templateOptions)) {
  15987. var templateOs = field.templateOptions;
  15988. // console.log(templateOs,'come')
  15989. for (var property in templateOs) {
  15990. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  15991. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  15992. if (new RegExp("function").test(templateOs[property])) {
  15993. var propValue = eval(templateOs[property]);
  15994. field.templateOptions[property] = propValue;
  15995. } else {
  15996. if (that.has(templateOs[property])) {
  15997. field.templateOptions[property] = that.get(templateOs[property]);
  15998. } else {
  15999. field.templateOptions[property] = templateOs[property];
  16000. }
  16001. }
  16002. } else if (templateOs[property] == null) {
  16003. //delete field.templateOptions[property];
  16004. } else { }
  16005. }
  16006. }
  16007. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  16008. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  16009. angular.extend(field.templateOptions, extObj);
  16010. delete field.templateOptions.extjson;
  16011. }
  16012. // ...
  16013. if (field.templateOptions) {
  16014. //处理远程获取数据控件方法调用
  16015. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  16016. // if (!field.templateOptions.isnoreash) {
  16017. field.templateOptions.refresh = refreshSelectOptions;
  16018. // }
  16019. }
  16020. //处理嵌套属性数据绑定/
  16021. if (field.templateOptions.pkey) {
  16022. var pmodel, i = 0;
  16023. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  16024. if (i == 0) {
  16025. if (result.model[p] == null) {
  16026. result.model[p] = {};
  16027. }
  16028. pmodel = result.model[p];
  16029. i++;
  16030. } else {
  16031. if (pmodel[p] == null) {
  16032. pmodel[p] = {};
  16033. }
  16034. pmodel = pmodel[p];
  16035. }
  16036. });
  16037. if (pmodel != null) {
  16038. field.model = pmodel;
  16039. if (pmodel[field.key] == null) {
  16040. pmodel[field.key] = null;
  16041. }
  16042. }
  16043. } else {
  16044. if (result.model[field.key] == null) {
  16045. result.model[field.key] = null;
  16046. }
  16047. }
  16048. //处理弹出框组件初始化
  16049. if (field.type == "ui-input-selectmodal") {
  16050. field.templateOptions.modal = $modal;
  16051. //field.templateOptions.Restangular = Restangular;
  16052. } else if (field.type == "ui-requesterselect") {
  16053. //field.templateOptions.language = $scope.lang;
  16054. field.templateOptions.modal = $modal;
  16055. field.templateOptions.UserService = api_user_data;
  16056. } else if (field.type == "ui-deptinformation") {
  16057. field.templateOptions.modal = $modal;
  16058. field.templateOptions.UserService = api_user_data;
  16059. } else if (field.type == "ui-requesterinformation") {
  16060. field.templateOptions.modal = $modal;
  16061. field.templateOptions.UserService = api_user_data;
  16062. } else if (field.type == "ui-userselect") {
  16063. field.templateOptions.modal = $modal;
  16064. //field.templateOptions.Restangular = Restangular;
  16065. } else if (field.type == "ui-userselectSearch") {
  16066. field.templateOptions.modal = $modal;
  16067. //field.templateOptions.Restangular = Restangular;
  16068. } else if (field.type == "ui-multiuserselect") {
  16069. field.templateOptions.modal = $modal;
  16070. } else if (field.type == "ui-stringuserselect") {
  16071. field.templateOptions.modal = $modal;
  16072. } else if (field.type == "ui-search") {
  16073. field.templateOptions.modal = $modal;
  16074. } else if (field.type == "ui-modelselect") {
  16075. field.templateOptions.modal = $modal;
  16076. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16077. field.templateOptions.loginUser = $rootScope.user;
  16078. //field.templateOptions.Restangular = Restangular;
  16079. } else if (field.type == "ui-incidentmodelselect") {
  16080. field.templateOptions.modal = $modal;
  16081. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16082. field.templateOptions.loginUser = $rootScope.user;
  16083. //field.templateOptions.Restangular = Restangular;
  16084. } else if (field.type == "ui-dropfile") {
  16085. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16086. url: '/uploader'
  16087. });
  16088. field.templateOptions.taskId = $stateParams.taskId;
  16089. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16090. field.templateOptions.userId = $rootScope.user.id;
  16091. } else if (field.type == "ui-dropfielknow") {
  16092. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16093. url: '/uploader'
  16094. });
  16095. field.templateOptions.taskId = $stateParams.taskId;
  16096. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16097. field.templateOptions.userId = $rootScope.user.id;
  16098. } else if (field.type == "ui-upDropFile") {
  16099. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16100. url: '/uploader'
  16101. });
  16102. field.templateOptions.taskId = $stateParams.taskId;
  16103. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16104. field.templateOptions.userId = $rootScope.user.id;
  16105. } else if (field.type == "ui-dropfilenotup") {
  16106. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16107. url: '/uploader'
  16108. });
  16109. field.templateOptions.taskId = $stateParams.taskId;
  16110. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16111. field.templateOptions.userId = $rootScope.user.id;
  16112. //field.ApiService=api_bpm_domain;
  16113. } else if (field.type == "ui-uploadFiles") {
  16114. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16115. url: '/uploader'
  16116. });
  16117. field.templateOptions.taskId = $stateParams.taskId;
  16118. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16119. field.templateOptions.userId = $rootScope.user.id;
  16120. //field.ApiService=api_bpm_domain;
  16121. } else if (field.type == "ui-upDownFiles") {
  16122. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16123. url: '/uploader'
  16124. });
  16125. field.templateOptions.taskId = $stateParams.taskId;
  16126. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16127. field.templateOptions.userId = $rootScope.user.id;
  16128. //field.ApiService=api_bpm_domain;
  16129. } else if (field.type == "ui-uploadImgs") {
  16130. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16131. url: '/uploader'
  16132. });
  16133. field.templateOptions.taskId = $stateParams.taskId;
  16134. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16135. field.templateOptions.userId = $rootScope.user.id;
  16136. //field.ApiService=api_bpm_domain;
  16137. } else if (field.type == "ui-dropfiletable") {
  16138. if (field.templateOptions.processInstanceId) {
  16139. } else {
  16140. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16141. }
  16142. } else if (field.type == "ui-dropFiles") {
  16143. if (field.templateOptions.processInstanceId) {
  16144. } else {
  16145. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16146. }
  16147. } else if (field.type == "ui-showImgs") {
  16148. if (field.templateOptions.processInstanceId) {
  16149. } else {
  16150. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16151. }
  16152. } else if (field.type == "ui-repeatSection") {
  16153. var repeatForm = {
  16154. model: {
  16155. },
  16156. fields: field.templateOptions.fields
  16157. };
  16158. repeatForm.model[field.key] = [];
  16159. decodeVMForm(repeatForm);
  16160. } else if (field.type == "ui-currentuser") {
  16161. field.templateOptions.user = vm.model["loginUser"];
  16162. } else if (field.type == "ui-workernumbersign") {
  16163. field.templateOptions.user = vm.model["loginUser"];
  16164. } else if (field.type == "ui-repair-photos") {
  16165. field.templateOptions.user = vm.model["loginUser"];
  16166. }
  16167. }
  16168. }
  16169. //解析自定义表单设计数据
  16170. $scope.oldfromtype = true;
  16171. function decodeVMForm(vmForm) {
  16172. if (vmForm.formType == "1") {
  16173. $scope.oldfromtype = false;
  16174. } else {
  16175. $scope.oldfromtype = true;
  16176. }
  16177. var result = {
  16178. model: {},
  16179. fields: []
  16180. };
  16181. //设置模型实体数据 begin
  16182. // var mdata = vmForm.model;
  16183. //解析数据实体
  16184. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  16185. angular.extend(result.model, mdata);
  16186. if (modelWatch != null && modelWatch != '') {
  16187. //angular.extend(result.model.incident,modelWatch.incident);
  16188. //result.model.alarmType = modelWatch.alarmType;
  16189. // vmForm.cancelUrl = modelWatch.cancelUrl;
  16190. // console.log(modelWatch.cancelUrl)
  16191. for (var index in modelWatch.model) {
  16192. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  16193. if (result.model[index] != null) {
  16194. angular.extend(result.model[index], modelWatch.model[index]);
  16195. } else {
  16196. result.model[index] = modelWatch.model[index];
  16197. }
  16198. }
  16199. }
  16200. //设置模型实体数据 end
  16201. //解析设计数据生成表单项 begin
  16202. var fields = [];
  16203. //处理修改设计数据中展示设置
  16204. angular.forEach(vmForm.fields, function (fields) {
  16205. if (vmForm.formType == "1") {
  16206. angular.forEach(fields.fields, function (field) {
  16207. formfield(field, result);
  16208. });
  16209. } else {
  16210. formfield(fields, result);
  16211. }
  16212. // console.log(field);
  16213. result.fields.push(fields);
  16214. });
  16215. angular.extend($scope.vm.fields, result.fields);
  16216. angular.extend($scope.vm.model, result.model);
  16217. vm.model["loginUser"] = $rootScope.user;
  16218. //增加识别报修主体seimin
  16219. vm.model.repairType = $scope.repairMain.valueconfig;
  16220. if(vm.model.incident){
  16221. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  16222. }
  16223. console.log(vm, 'repairType')//lmm
  16224. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  16225. vmForm.cancelUrl = modelWatch.cancelUrl;
  16226. }
  16227. $scope.formData = vmForm;
  16228. console.log($scope.formData,4444444)
  16229. // console.log($scope.formData.url);
  16230. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  16231. if ($scope.formData.url == "start") {
  16232. $scope.Reset = true;
  16233. $scope.close = true;
  16234. $rootScope.isMask = false;
  16235. } else if ($scope.formData.url == "complete") {
  16236. $scope.Reset = false;
  16237. $scope.close = true;
  16238. }
  16239. //解析设计数据生成表单项 end
  16240. return result;
  16241. }
  16242. //======================处理表单设计数据 结束========================
  16243. $scope.ldloading = {};
  16244. function filter(obj) {
  16245. angular.forEach(obj, function (key, value) {
  16246. if (value === "" || value === null) {
  16247. delete obj[key];
  16248. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  16249. filter(value);
  16250. } else if (angular.isArray(value)) {
  16251. angular.forEach(value, function (item) {
  16252. filter(item);
  16253. });
  16254. }
  16255. });
  16256. }
  16257. $scope.closeModel = function () {
  16258. // console.log($stateParams);
  16259. $state.go($scope.formData.cancelUrl, {});
  16260. event.preventDefault();
  16261. };
  16262. // console.log(vm);
  16263. // 暂存
  16264. $scope.save = function (data) {
  16265. console.log(vm)
  16266. if (vm.model.startSave) {
  16267. vm.model["initUser"] = $rootScope.user.id;
  16268. vm.model.start_code = "temporary";
  16269. //处理请求数据0327
  16270. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16271. delete data0327.repairType;
  16272. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16273. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16274. data0327.incident.place = {
  16275. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16276. }
  16277. }
  16278. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16279. if (response) {
  16280. var resData = Restangular.stripRestangular(response);
  16281. if (resData) {
  16282. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16283. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16284. angular.extend(item.headers, $rootScope.getSession());
  16285. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16286. item.formData.push({
  16287. 'fileName': item.file.name
  16288. });
  16289. //console.log();
  16290. };
  16291. $scope.fileUploader.uploadAll();
  16292. }
  16293. }
  16294. SweetAlert.swal({
  16295. title: "提交成功!",
  16296. type: "success",
  16297. confirmButtonColor: "#007AFF"
  16298. }, function () {
  16299. $state.go($scope.formData.cancelUrl);
  16300. });
  16301. } else {
  16302. SweetAlert.swal({
  16303. title: "系统错误",
  16304. text: "系统错误,请稍后重试!",
  16305. type: "error",
  16306. confirmButtonColor: "#DD6B55"
  16307. });
  16308. }
  16309. $scope.ldloading[style.replace('-', '_')] = false;
  16310. });
  16311. event.preventDefault();
  16312. } else if (vm.model.saveAgain) {
  16313. var toData = {
  16314. "incident": vm.model.incident
  16315. };
  16316. api_user_data.updData("incident", toData).then(function (response) {
  16317. if (response) {
  16318. var resData = Restangular.stripRestangular(response);
  16319. SweetAlert.swal({
  16320. title: "提交成功!",
  16321. type: "success",
  16322. confirmButtonColor: "#007AFF"
  16323. }, function () {
  16324. $state.go($scope.formData.cancelUrl);
  16325. });
  16326. } else {
  16327. SweetAlert.swal({
  16328. title: "系统错误",
  16329. text: "系统错误,请稍后重试!",
  16330. type: "error",
  16331. confirmButtonColor: "#DD6B55"
  16332. });
  16333. }
  16334. $scope.ldloading[style.replace('-', '_')] = false;
  16335. });
  16336. event.preventDefault();
  16337. } else {
  16338. SweetAlert.swal({
  16339. title: "系统错误",
  16340. text: "系统错误,请稍后重试!",
  16341. type: "error",
  16342. confirmButtonColor: "#DD6B55"
  16343. });
  16344. }
  16345. }
  16346. // 巡检生成事件
  16347. $scope.inspectionToIncident = function () {
  16348. var userData = {
  16349. "idx": 0,
  16350. "sum": 10,
  16351. "requester": {
  16352. "name": loginUser.name
  16353. }
  16354. }
  16355. api_user_data.fetchDataList("requester", userData).then(function (res) {
  16356. console.log(res);
  16357. var toUser = {};
  16358. if (res.list.length > 0) {
  16359. toUser = res.list[0]
  16360. } else {
  16361. toUser = loginUser
  16362. }
  16363. console.log(vm);
  16364. var incidentDescription = "";
  16365. console.log($stateParams.formUiEdit);
  16366. if ($stateParams.formUiEdit == "inspection_confirm") {
  16367. if (vm.model.wnCheckEnable) {
  16368. incidentDescription = incidentDescription.concat(" 机房温度检查异常")
  16369. }
  16370. if (vm.model.sdCheckEnable) {
  16371. incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
  16372. }
  16373. if (vm.model.xfjCheckEnable) {
  16374. incidentDescription = incidentDescription.concat(" 新风机检查异常")
  16375. }
  16376. if (vm.model.lsCheckEnable) {
  16377. incidentDescription = incidentDescription.concat(" 漏水检查异常")
  16378. }
  16379. if (vm.model.xfCheckEnable) {
  16380. incidentDescription = incidentDescription.concat(" 消防检查异常")
  16381. }
  16382. if (vm.model.upsCheckEnable) {
  16383. incidentDescription = incidentDescription.concat(" UPS供电检查异常")
  16384. }
  16385. if (vm.model.dcCheckEnable) {
  16386. incidentDescription = incidentDescription.concat(" 电池连接检查异常")
  16387. }
  16388. if (vm.model.plCheckEnable) {
  16389. incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
  16390. }
  16391. if (vm.model.wjtdCheckEnable) {
  16392. incidentDescription = incidentDescription.concat(" 外机通道检查异常")
  16393. }
  16394. if (vm.model.descriptionTextarea) {
  16395. incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
  16396. }
  16397. }
  16398. // console.log(incidentDescription)
  16399. var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
  16400. var formdata = {
  16401. 'model': {
  16402. // 'isInspection': true,
  16403. // 'start_code':'assignment',
  16404. // 'isHandlerUser':false,
  16405. 'incident': {
  16406. 'requester':bxr ,
  16407. // 'area': data.incident.place.area,
  16408. // 'place': data.incident.place,
  16409. // 'houseNumber': data.incident.address,
  16410. 'contacts': bxr.name,
  16411. 'contactsInformation': bxr.mphone,
  16412. // 'category': data.wxIncidentClassifyDTO.category,
  16413. 'description': incidentDescription,
  16414. 'source': {
  16415. 'id': 1552
  16416. },
  16417. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  16418. // 'sourceType': data.incident.sourceType,
  16419. // 'fileUrl': data.incident.fileUrl
  16420. },
  16421. // 'requestershow': toUser,//2020年4月27日22:29:15
  16422. // 'flow': data.incident.id
  16423. // 'assignee': loginUser.id//2020年4月27日22:29:25
  16424. }
  16425. }
  16426. // console.log(formdata,toUser,'1111');
  16427. console.log(formdata,'1111');
  16428. // return;
  16429. $state.go("app.incident.chart", {
  16430. 'model': JSON.stringify(formdata)
  16431. });
  16432. })
  16433. // var formdata = {
  16434. // model:$rootScope.login_requester
  16435. // };
  16436. // console.log(formdata,'00000')
  16437. // return;
  16438. // $state.go("app.incident.chart", {
  16439. // 'model': JSON.stringify(formdata)
  16440. // });
  16441. event.preventDefault();
  16442. };
  16443. // console.log(vm);
  16444. // 创建事件seimin
  16445. vm.submit = function (data, style) {
  16446. console.log(vm,22222);
  16447. if (vm.model.handler_code == undefined) {
  16448. vm.model.handler_code = "resolve";
  16449. }
  16450. if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
  16451. delete vm.model.change.requestingPerson.menu;
  16452. }
  16453. // var pdKey = $stateParams.pdKey;
  16454. if (vm.form.$valid) {
  16455. if (data.incident && data.incident.synergetic) {
  16456. console.log(data.incident.synergetic);
  16457. var synergetic = [];
  16458. for (var i = 0; i < data.incident.synergetic.length; i++) {
  16459. synergetic.push({
  16460. id: data.incident.synergetic[i]
  16461. });
  16462. }
  16463. data.incident.synergetic = synergetic;
  16464. vm.model.incident.synergetic = synergetic;
  16465. }
  16466. $scope.ldloading[style.replace('-', '_')] = true;
  16467. var startsub = true;
  16468. if (pdKey == 'bpm_incident') {
  16469. angular.forEach(vm.fields, function (item) {
  16470. angular.forEach(item.fields, function (index) {
  16471. if (index.templateOptions.required && !index.hide) {
  16472. if (index.model) {
  16473. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  16474. if (index.model[index.key].id && index.model[index.key].id == '') {
  16475. startsub = false;
  16476. $scope.ldloading.expand_right = false;
  16477. SweetAlert.swal({
  16478. title: index.templateOptions.label + '未填',
  16479. text: "请填写此项!",
  16480. type: "error",
  16481. confirmButtonColor: "#DD6B55"
  16482. });
  16483. } else { }
  16484. } else {
  16485. startsub = false;
  16486. $scope.ldloading.expand_right = false;
  16487. SweetAlert.swal({
  16488. title: index.templateOptions.label + '未填',
  16489. text: "请填写此项!",
  16490. type: "error",
  16491. confirmButtonColor: "#DD6B55"
  16492. });
  16493. }
  16494. } else {
  16495. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  16496. } else {
  16497. startsub = false;
  16498. $scope.ldloading.expand_right = false;
  16499. SweetAlert.swal({
  16500. title: index.templateOptions.label + '未填',
  16501. text: "请填写此项!",
  16502. type: "error",
  16503. confirmButtonColor: "#DD6B55"
  16504. });
  16505. }
  16506. }
  16507. }
  16508. })
  16509. })
  16510. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  16511. // startsub = false;
  16512. // $scope.ldloading.expand_right = false;
  16513. // SweetAlert.swal({
  16514. // title: '保修人未填',
  16515. // text: "请填写此项!",
  16516. // type: "error",
  16517. // confirmButtonColor: "#DD6B55"
  16518. // });
  16519. // }
  16520. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  16521. // } else {
  16522. // startsub = false;
  16523. // $scope.ldloading.expand_right = false;
  16524. // SweetAlert.swal({
  16525. // title: '事件分类未填',
  16526. // text: "请填写此项!",
  16527. // type: "error",
  16528. // confirmButtonColor: "#DD6B55"
  16529. // });
  16530. // }
  16531. }
  16532. if (startsub) {
  16533. $scope.ldloading[style.replace('-', '_')] = true;
  16534. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  16535. // console.log("vm.options:"+ JSON.stringify(vm.options));
  16536. vm.options.updateInitialValue();
  16537. // console.log("dfjkasdhfkhskjf ")
  16538. var _ = window._;
  16539. vm.model = (function filter(obj) {
  16540. var dateTransKeys = [];
  16541. var filtered = _.pick(obj, function (v, k, obj) {
  16542. if (_.isDate(v)) {
  16543. dateTransKeys.push(k);
  16544. }
  16545. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  16546. });
  16547. return _.cloneDeep(filtered, function (v, index, object) {
  16548. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  16549. angular.forEach(dateTransKeys, function (item) {
  16550. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  16551. })
  16552. dateTransKey = [];
  16553. return v;
  16554. }
  16555. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  16556. });
  16557. })(vm.model);
  16558. if (pdKey != "") {
  16559. if ($scope.oprcode == "save") { //保存
  16560. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  16561. if (response) {
  16562. var resData = Restangular.stripRestangular(response);
  16563. SweetAlert.swal({
  16564. title: "保存成功!",
  16565. confirmButtonColor: "#007AFF"
  16566. }, function () {
  16567. $state.go($scope.formData.cancelUri);
  16568. });
  16569. // if(resData.status){
  16570. // resData
  16571. // }
  16572. } else {
  16573. SweetAlert.swal({
  16574. title: "系统错误",
  16575. text: "系统错误,请稍后重试!",
  16576. type: "error",
  16577. confirmButtonColor: "#DD6B55"
  16578. });
  16579. }
  16580. $scope.ldloading[style.replace('-', '_')] = false;
  16581. });
  16582. } else {
  16583. console.log($scope.formData.url,'zzzz')
  16584. switch ($scope.formData.url) {
  16585. case "start":
  16586. vm.model["initUser"] = $rootScope.user.id;
  16587. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  16588. } else {
  16589. vm.model["assignee"] = $rootScope.user.id;
  16590. }
  16591. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  16592. vm.model.candidateGroups = vm.model.candidateGroups.id;
  16593. }
  16594. if (pdKey == 'bpm_service_request') {
  16595. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  16596. angular.extend(vm.model.serviceCatalogueProcessActual, {
  16597. 'category': {
  16598. 'id': $stateParams.userId
  16599. }
  16600. });
  16601. }
  16602. if (vm.model.schedule && vm.model.schedule.initUser) {
  16603. delete vm.model.schedule.initUser.menu
  16604. }
  16605. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16606. delete vm.model.candidateGroups
  16607. }
  16608. if (vm.model.start_code == 'close') {
  16609. // 直接处理
  16610. vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
  16611. delete vm.model.incident.handlerUser
  16612. delete vm.model.candidateGroups;
  16613. } else if (vm.model.start_code == 'assignment') {
  16614. // 派单
  16615. delete vm.model.incident.handlingPersonnelUser
  16616. }
  16617. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  16618. $scope.jry_processInstanceId = $stateParams.processInstanceId;
  16619. }
  16620. if ($scope.jry_processInstanceId) {
  16621. vm.model["save_fileId"] = $scope.jry_processInstanceId
  16622. }
  16623. //事件暂存判断
  16624. if (vm.model.saveAgain) {
  16625. if (vm.model.directClose == "1" || vm.model.directClose == true) {
  16626. vm.model.start_code = "assignment";
  16627. vm.model.temporary_code = "assignment";
  16628. } else {
  16629. vm.model.start_code = "close";
  16630. vm.model.temporary_code = "close"
  16631. };
  16632. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16633. delete vm.model.candidateGroups
  16634. }
  16635. }
  16636. //处理请求数据0327
  16637. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16638. delete data0327.repairType;
  16639. // 增加地点的请求参数2020年4月24日10:44:36
  16640. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16641. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16642. data0327.incident.place = {
  16643. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16644. }
  16645. }
  16646. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16647. // console.log("response="+JSON.stringify(response));
  16648. if (response) {
  16649. var resData = Restangular.stripRestangular(response);
  16650. if (resData) {
  16651. if (resData) {
  16652. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16653. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16654. angular.extend(item.headers, $rootScope.getSession());
  16655. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16656. item.formData.push({
  16657. 'fileName': item.file.name
  16658. });
  16659. //console.log();
  16660. };
  16661. $scope.fileUploader.uploadAll();
  16662. }
  16663. }
  16664. }
  16665. SweetAlert.swal({
  16666. title: "提交成功!",
  16667. type: "success",
  16668. confirmButtonColor: "#007AFF"
  16669. }, function () {
  16670. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  16671. $rootScope.app.layout.isSidebarClosed = false;
  16672. if ($scope.login && !$rootScope.busy) {
  16673. $rootScope.setidle();
  16674. }
  16675. }
  16676. $state.go($scope.formData.cancelUrl);
  16677. });
  16678. } else {
  16679. SweetAlert.swal({
  16680. title: "系统错误",
  16681. text: "系统错误,请稍后重试!",
  16682. type: "error",
  16683. confirmButtonColor: "#DD6B55"
  16684. });
  16685. }
  16686. $scope.ldloading[style.replace('-', '_')] = false;
  16687. });
  16688. break;
  16689. case "complete":
  16690. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  16691. //console.log("complete taskId::"+$stateParams.taskId);
  16692. if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
  16693. SweetAlert.swal({
  16694. title: "处理人未填",
  16695. text: "请填写此项!",
  16696. type: "error",
  16697. confirmButtonColor: "#DD6B55"
  16698. });
  16699. return;
  16700. }
  16701. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  16702. if (response) {
  16703. var resData = Restangular.stripRestangular(response);
  16704. SweetAlert.swal({
  16705. title: "提交成功!",
  16706. type: "success",
  16707. confirmButtonColor: "#007AFF"
  16708. }, function () {
  16709. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
  16710. console.log(vm);
  16711. if (vm.model.incident) {
  16712. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  16713. // angular.extend(item.headers, $rootScope.getSession());
  16714. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16715. // item.formData.push({
  16716. // 'fileName': item.file.name
  16717. // });
  16718. // };
  16719. // $scope.fileUploader.uploadAll();
  16720. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16721. angular.extend(item.headers, $rootScope.getSession());
  16722. item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
  16723. item.formData.push({
  16724. 'fileName': item.file.name
  16725. });
  16726. //console.log();
  16727. };
  16728. $scope.fileUploader.uploadAll();
  16729. } else if (vm.model.problem) {
  16730. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16731. angular.extend(item.headers, $rootScope.getSession());
  16732. item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16733. item.formData.push({
  16734. 'fileName': item.file.name
  16735. });
  16736. };
  16737. $scope.fileUploader.uploadAll();
  16738. } else if (vm.model.change) {
  16739. }
  16740. }
  16741. $state.go($scope.formData.cancelUrl);
  16742. });
  16743. } else {
  16744. SweetAlert.swal({
  16745. title: "系统错误",
  16746. text: "系统错误,请稍后重试!",
  16747. type: "error",
  16748. confirmButtonColor: "#DD6B55"
  16749. });
  16750. }
  16751. $scope.ldloading[style.replace('-', '_')] = false;
  16752. });
  16753. break;
  16754. case "back":
  16755. $state.go($scope.formData.cancelUrl);
  16756. break;
  16757. default:
  16758. $scope.ldloading[style.replace('-', '_')] = false;
  16759. break;
  16760. }
  16761. }
  16762. // var submitFunc = api_bpm_domain[$scope.formData.url]
  16763. // if(anuglar.isFunction(submitFunc)){
  16764. // submitFunc.apply(null, pdKey)
  16765. // }
  16766. }
  16767. }
  16768. } else {
  16769. // console.log(data)
  16770. // angular.forEach(vm.form.$error.required, function(item){
  16771. // var i=(item.$name).substring(item.$name.length-2)
  16772. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  16773. // for(var i=0;i<vm.fields.length;i++){
  16774. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  16775. SweetAlert.swal({
  16776. title: vm.fields[i].templateOptions.label + '未填',
  16777. text: "请填写此项!",
  16778. type: "error",
  16779. confirmButtonColor: "#DD6B55"
  16780. });
  16781. }
  16782. // }
  16783. // angular.forEach(vm.fields,function(f){
  16784. // if(f.name == item.$name){
  16785. // f.validation.show = true;
  16786. // SweetAlert.swal({
  16787. // title: f.templateOptions.label+'未填',
  16788. // text: "请填写此项!",
  16789. // type: "error",
  16790. // confirmButtonColor: "#DD6B55"
  16791. // });
  16792. // }
  16793. // });
  16794. // })
  16795. }
  16796. };
  16797. $scope.vm = vm;
  16798. console.log($stateParams,pdKey,88888)
  16799. console.log($scope.vm,'assdfsdf')
  16800. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  16801. var processInstanceId = $stateParams.processInstanceId;
  16802. var itemId = $stateParams.dataId;
  16803. console.log($stateParams)
  16804. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  16805. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
  16806. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16807. var vmForm = Restangular.stripRestangular(responseData);
  16808. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16809. decodeVMForm(vmForm);
  16810. }
  16811. }
  16812. });
  16813. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  16814. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  16815. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16816. var vmForm = Restangular.stripRestangular(responseData);
  16817. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16818. decodeVMForm(vmForm);
  16819. }
  16820. }
  16821. });
  16822. } else {
  16823. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  16824. if (response) {
  16825. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  16826. api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
  16827. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16828. var vmForm = Restangular.stripRestangular(responseData);
  16829. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16830. decodeVMForm(vmForm);
  16831. console.log(vmForm,111111);
  16832. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  16833. console.log($scope,'今天')//2020年4月24日11:40:55
  16834. }
  16835. }
  16836. });
  16837. }
  16838. })
  16839. }
  16840. } else {
  16841. // create process instance
  16842. if (pdKey != "") { //for process
  16843. if (pdKey == 'bpm_service_request') {
  16844. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  16845. if (responseData) {
  16846. var vmForm = Restangular.stripRestangular(responseData);
  16847. if (vmForm) {
  16848. decodeVMForm(vmForm);
  16849. }
  16850. }
  16851. });
  16852. } else {
  16853. api_bpm_domain.startformkey(pdKey).then(function (response) {
  16854. if (response) {
  16855. var myData = Restangular.stripRestangular(response);
  16856. //myData.data = "arrangeform";
  16857. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  16858. if (responseData) {
  16859. var vmForm = Restangular.stripRestangular(responseData);
  16860. if (vmForm) {
  16861. decodeVMForm(vmForm);
  16862. }
  16863. }
  16864. });
  16865. }
  16866. });
  16867. }
  16868. } else { //for form
  16869. //TODO
  16870. //测试数据 开始
  16871. var testJson = {
  16872. fields: [{
  16873. fields: [{
  16874. className: "col-xs-12",
  16875. noFormControl: true,
  16876. key: "formtitle",
  16877. templateOptions: {
  16878. readOnly: false,
  16879. placeholder: "新建事件单",
  16880. hidden: false,
  16881. label: "事件工单",
  16882. required: false
  16883. },
  16884. type: "ui-title"
  16885. }]
  16886. }, {
  16887. fields: [{
  16888. key: 'selectUser',
  16889. type: 'ui-deptinformation',
  16890. className: 'col-xs-12',
  16891. templateOptions: {
  16892. label: '请求人信息',
  16893. modalTitle: '请求人列表',
  16894. fetchItems: function (filterData, APIService) {
  16895. return APIService.fetchDataList('requester', filterData);
  16896. },
  16897. Restangular: Restangular,
  16898. ApiService: api_user_data
  16899. // onClick:function(val, options, field, event , model){
  16900. // console.log(options);
  16901. // }
  16902. }
  16903. }]
  16904. }, {
  16905. fields: [{
  16906. key: 'first',
  16907. type: 'ui-workernumber',
  16908. className: 'col-xs-12',
  16909. templateOptions: {
  16910. type: 'input',
  16911. label: '事件单号',
  16912. pkey: 'name'
  16913. }
  16914. }]
  16915. }, {
  16916. fields: [{
  16917. type: 'ui-header',
  16918. key: 'title',
  16919. className: 'col-xs-12',
  16920. templateOptions: {
  16921. label: '报修人',
  16922. pkey: 'change'
  16923. }
  16924. }, {
  16925. type: 'ui-input',
  16926. key: 'title',
  16927. className: 'col-xs-4',
  16928. templateOptions: {
  16929. label: '报修人',
  16930. pkey: 'change'
  16931. }
  16932. }, {
  16933. type: 'ui-input',
  16934. key: 'title',
  16935. className: 'col-xs-4',
  16936. templateOptions: {
  16937. label: '联系人',
  16938. pkey: 'change'
  16939. }
  16940. }, {
  16941. type: 'ui-input',
  16942. key: 'title',
  16943. className: 'col-xs-4',
  16944. templateOptions: {
  16945. label: '联系电话',
  16946. pkey: 'change'
  16947. }
  16948. }]
  16949. }, {
  16950. fields: [{
  16951. type: 'ui-header',
  16952. key: 'title1',
  16953. className: 'col-xs-12',
  16954. templateOptions: {
  16955. label: '报修人',
  16956. pkey: 'change'
  16957. }
  16958. }, {
  16959. type: 'ui-input',
  16960. key: 'title2',
  16961. className: 'col-xs-4',
  16962. templateOptions: {
  16963. label: '报修人',
  16964. pkey: 'change'
  16965. }
  16966. }, {
  16967. type: 'ui-input',
  16968. key: 'title3',
  16969. className: 'col-xs-4',
  16970. templateOptions: {
  16971. label: '联系人',
  16972. pkey: 'change'
  16973. }
  16974. }, {
  16975. type: 'ui-input',
  16976. key: 'title4',
  16977. className: 'col-xs-4',
  16978. templateOptions: {
  16979. label: '联系电话',
  16980. pkey: 'change'
  16981. }
  16982. }]
  16983. }],
  16984. model: [{
  16985. username: "robin lau",
  16986. password: "123456",
  16987. chkme: false,
  16988. start_code: 0,
  16989. formtitle: "Hey!I am title value!",
  16990. name: {
  16991. first: "robin",
  16992. last: "lau"
  16993. },
  16994. multiselectItem: []
  16995. //date:"2015-09-15 00:00:00"
  16996. }]
  16997. // }
  16998. };
  16999. setTimeout(function () {
  17000. decodeVMForm(testJson);
  17001. $scope.$apply();
  17002. }, 500);
  17003. //测试数据结束
  17004. }
  17005. }
  17006. //console.log("end decode");
  17007. }
  17008. ]);