customformCtrl.js 960 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817
  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.filter('minutesToHours', function() { //分钟转小时
  42. return function(num) {
  43. var hour = parseInt(num / 60);
  44. var minute = num % 60;
  45. return hour + '小时' + minute + '分钟';
  46. }
  47. });
  48. appFormly.config(
  49. function config(formlyConfigProvider) {
  50. //格式转换方法 XXX-XXX转驼峰命名
  51. function camelize(string) {
  52. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  53. return chr ? chr.toUpperCase() : '';
  54. });
  55. // Ensure 1st char is always lowercase
  56. return string.replace(/^([A-Z])/, function (match, chr) {
  57. return chr ? chr.toLowerCase() : '';
  58. });
  59. }
  60. //获取ngModelAttr对象设置
  61. function getNgModelAttr(attrs, bindings) {
  62. var ngModelAttrs = {};
  63. angular.forEach(attrs, function (attr) {
  64. ngModelAttrs[camelize(attr)] = {
  65. attribute: attr
  66. };
  67. });
  68. angular.forEach(bindings, function (binding) {
  69. ngModelAttrs[camelize(binding)] = {
  70. bound: binding
  71. };
  72. });
  73. return ngModelAttrs;
  74. }
  75. formlyConfigProvider.setWrapper({
  76. name: 'bootstrapLabel',
  77. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  78. });
  79. //流程图
  80. formlyConfigProvider.setType({
  81. name: 'ui-process',
  82. templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
  83. defaultOptions: function (options) {
  84. return {
  85. templateOptions: {
  86. refresh: function () { },
  87. refreshDelay: 0
  88. }
  89. };
  90. },
  91. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  92. $scope.processdata = [];
  93. api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function (data) {
  94. console.log(data)
  95. $scope.processdata = data.data;
  96. })
  97. }]
  98. });
  99. //出库单详情
  100. formlyConfigProvider.setType({
  101. name: 'ui-getoutinform',
  102. extends: 'radio',
  103. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
  104. defaultOptions: function (options) {
  105. return {
  106. templateOptions: {
  107. refresh: function () { },
  108. refreshDelay: 0
  109. }
  110. };
  111. },
  112. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  113. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  114. if ($scope.model.type.id = 0) {
  115. $scope.model.type.name = "新资产入库";
  116. } else if ($scope.model.type.id = 1) {
  117. $scope.model.type.name = "新设备领用出库";
  118. } else if ($scope.model.type.id = 2) {
  119. $scope.model.type.name = "资产归还";
  120. } else if ($scope.model.type.id = 4) {
  121. $scope.model.type.name = "设备更换";
  122. }
  123. }
  124. }]
  125. });
  126. //多选框组件
  127. formlyConfigProvider.setType({
  128. name: 'ui-checkboxmore',
  129. extends: 'radio',
  130. templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
  131. defaultOptions: function (options) {
  132. return {
  133. templateOptions: {
  134. refresh: function () { },
  135. refreshDelay: 0
  136. }
  137. };
  138. },
  139. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  140. $scope.options.initialValue = $scope.model[$scope.options.key];
  141. }]
  142. });
  143. //入库单详情
  144. formlyConfigProvider.setType({
  145. name: 'ui-getininform',
  146. extends: 'radio',
  147. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
  148. defaultOptions: function (options) {
  149. return {
  150. templateOptions: {
  151. refresh: function () { },
  152. refreshDelay: 0
  153. }
  154. };
  155. },
  156. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  157. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  158. if ($scope.model.type.id = 0) {
  159. $scope.model.type.name = "新资产入库";
  160. } else if ($scope.model.type.id = 1) {
  161. $scope.model.type.name = "新设备领用出库";
  162. } else if ($scope.model.type.id = 2) {
  163. $scope.model.type.name = "资产归还";
  164. } else if ($scope.model.type.id = 4) {
  165. $scope.model.type.name = "设备更换";
  166. }
  167. }
  168. }]
  169. });
  170. //申请人详情
  171. formlyConfigProvider.setType({
  172. name: 'ui-requsterinfom',
  173. extends: 'radio',
  174. templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
  175. defaultOptions: function (options) {
  176. return {
  177. templateOptions: {
  178. refresh: function () { },
  179. refreshDelay: 0
  180. }
  181. };
  182. }
  183. });
  184. //设备耗材list组件
  185. formlyConfigProvider.setType({
  186. name: 'ui-uplodchange',
  187. templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
  188. defaultOptions: function (options) {
  189. return {
  190. templateOptions: {
  191. refresh: function () { },
  192. refreshDelay: 0,
  193. view: function (APIService, contentId) {
  194. return APIService.downloadAttachment(contentId);
  195. }
  196. }
  197. };
  198. },
  199. controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  200. // var data = { "haodata": [], "shedata": [] };
  201. var haodata = [];
  202. var shedata = [];
  203. if ($scope.model.consumables) {
  204. if (angular.isArray($scope.model.consumables)) {
  205. haodata = $scope.model.consumables;
  206. } else {
  207. haodata = JSON.parse($scope.model.consumables);
  208. }
  209. $scope.model.consumables = haodata;
  210. angular.forEach(haodata, function (item, index) {
  211. haodata[index].item = index + 1;
  212. })
  213. }
  214. if ($scope.model.assets) {
  215. if (angular.isArray($scope.model.assets)) {
  216. shedata = $scope.model.assets;
  217. } else {
  218. shedata = JSON.parse($scope.model.assets);
  219. }
  220. $scope.model.assets = shedata;
  221. angular.forEach(shedata, function (item, index) {
  222. shedata[index].item = index + 1;
  223. })
  224. }
  225. $scope.tableParamshao = new ngTableParams({
  226. page: 1,
  227. count: 5
  228. }, {
  229. total: haodata.length,
  230. getData: function ($defer, params) {
  231. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  232. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  233. }
  234. });
  235. $scope.tableParamsshe = new ngTableParams({
  236. page: 1,
  237. count: 5
  238. }, {
  239. total: shedata.length,
  240. getData: function ($defer, params) {
  241. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  242. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  243. }
  244. });
  245. $scope.editId = -1;
  246. $scope.setEditId = function (pid) {
  247. $scope.editId = pid;
  248. };
  249. if (angular.isUndefined($scope.form.dropState)) {
  250. $scope.form.dropState = false;
  251. }
  252. var to = $scope.options.templateOptions;
  253. var bindId = $scope.model.processInstanceId;
  254. //获取附件列表
  255. $scope.listAttachmen = function () {
  256. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  257. var myData = Restangular.stripRestangular(result);
  258. // $scope.listAttachmens = myData;
  259. $scope.attachments = myData.data;
  260. });
  261. };
  262. $scope.listAttachmen();
  263. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  264. // $scope.listAttachmen();
  265. // } else if (to.bindType && $scope.model[to.bindType].id) {
  266. // $scope.listAttachmen();
  267. // }
  268. //附件下载
  269. $scope.download = function (token, filename) {
  270. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  271. // window.open(downUrl);
  272. var a = document.createElement('a');
  273. a.href = downUrl;
  274. a.target = '_blank';
  275. a.download = filename;
  276. document.body.appendChild(a);
  277. a.click();
  278. };
  279. //附件预览
  280. $scope.view = function (id, previewUrl) {
  281. if (previewUrl) {
  282. window.open(previewUrl);
  283. }
  284. };
  285. }]
  286. });
  287. //多选框组件
  288. formlyConfigProvider.setType({
  289. name: 'ui-nodataimage',
  290. templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
  291. defaultOptions: function (options) {
  292. return {
  293. templateOptions: {
  294. refresh: function () { },
  295. refreshDelay: 0
  296. }
  297. };
  298. }
  299. });
  300. //ui-grid list
  301. formlyConfigProvider.setType({
  302. name: "ui-gridtwolist",
  303. // extends: 'input',
  304. templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
  305. defaultOptions: function (options, $scope) {
  306. return {
  307. templateOptions: {}
  308. };
  309. },
  310. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  311. //gridone
  312. $scope.langs = i18nService.getAllLangs();
  313. $scope.lang = 'zh-cn';
  314. i18nService.setCurrentLang($scope.lang);
  315. $scope.gridOptions = {};
  316. $scope.gridOptions.data = 'myDatagrid';
  317. $scope.gridOptions.enableColumnResizing = true;
  318. $scope.gridOptions.enableFiltering = true;
  319. $scope.gridOptions.enableGridMenu = false;
  320. $scope.gridOptions.enableRowSelection = true;
  321. $scope.gridOptions.showGridFooter = true;
  322. $scope.gridOptions.showColumnFooter = false;
  323. $scope.gridOptions.fastWatch = true;
  324. $scope.gridOptions.useExternalFiltering = false;
  325. $scope.gridOptions.useExternalPagination = true;
  326. $scope.gridOptions.paginationPageSizes = [10];
  327. $scope.gridOptions.paginationPageSize = 10;
  328. $scope.gridOptions.multiSelect = false;
  329. $scope.myDatagrid = [];
  330. $scope.myDatagridall = [];
  331. $scope.selected = {
  332. item: {}
  333. };
  334. $scope.memoryfilterDatagrid = {
  335. idx: 0,
  336. sum: 10
  337. }
  338. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  339. filterData = {
  340. idx: 0,
  341. sum: 10
  342. };
  343. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  344. }
  345. $scope.gridOptions.rowIdentity = function (row) {
  346. return row.id;
  347. };
  348. $scope.gridOptions.getRowIdentity = function (row) {
  349. return row.id;
  350. };
  351. // $scope.gridOptions.columnDefs = items.columnDefs();
  352. $scope.interceptMydata = function (mydate, idx, sum) {
  353. return mydate.slice(idx * sum, (idx + 1) * sum)
  354. }
  355. $scope.gridOptions.onRegisterApi = function (gridApi) {
  356. $scope.gridApi = gridApi;
  357. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  358. $scope.memoryfilterDatagrid.idx = newPage - 1;
  359. $scope.memoryfilterDatagrid.sum = pageSize;
  360. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  361. $scope.loadData({
  362. "idx": newPage - 1,
  363. "sum": pageSize
  364. });
  365. });
  366. gridApi.core.on.filterChanged($scope, function () { });
  367. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  368. $scope.selected.item = data.entity;
  369. //console.log(data);
  370. });
  371. };
  372. $scope.loadData = function (mydate, idx, sum) {
  373. angular.forEach($scope.myDatagrid, function (item, index) {
  374. $scope.myDatagrid[index].item = index;
  375. })
  376. $scope.gridOptions.totalItems = mydate.length;
  377. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  378. }
  379. if ($scope.model.assets) {
  380. $scope.myDatagridall = $scope.model.assets;
  381. $scope.loadData($scope.model.assets, 0, 10)
  382. }
  383. $scope.saveData = function (itemin) {
  384. event.preventDefault();
  385. var modalInstance = $modal.open({
  386. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  387. controller: function ($scope, $modalInstance, SweetAlert) {
  388. // $scope.consumptive = {};
  389. $scope.title = "填写领用设备信息";
  390. // if (items.name) {
  391. // $scope.consumptive.name = items.name.name;
  392. // }
  393. $scope.placechange = angular.copy(itemin);
  394. $scope.ok = function (item) {
  395. 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) {
  396. $modalInstance.close(item);
  397. } else {
  398. SweetAlert.swal({
  399. title: "数据填写不完整!",
  400. text: "请检查数据然后提交!",
  401. type: "error"
  402. });
  403. }
  404. };
  405. $scope.cancel = function () {
  406. $modalInstance.dismiss('cancel');
  407. };
  408. },
  409. resolve: {
  410. SweetAlert: function () {
  411. return SweetAlert;
  412. }
  413. }
  414. });
  415. modalInstance.result.then(function (selectedItem) {
  416. angular.forEach($scope.myDatagrid, function (item, index) {
  417. // $scope.myDatagrid[index].props.hw_state = "在线";
  418. if (item.id == selectedItem.id) {
  419. // $scope.myDatagrid[index] = selectedItem;
  420. angular.extend($scope.myDatagrid[index], selectedItem)
  421. }
  422. })
  423. // $scope.myData3.push(selectedItem);
  424. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  425. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  426. }
  427. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  428. })
  429. }
  430. //gridtwo
  431. $scope.langs = i18nService.getAllLangs();
  432. $scope.lang = 'zh-cn';
  433. i18nService.setCurrentLang($scope.lang);
  434. $scope.gridOptions2 = {};
  435. $scope.gridOptions2.data = 'myDatagridold';
  436. $scope.gridOptions2.enableColumnResizing = true;
  437. $scope.gridOptions2.enableFiltering = true;
  438. $scope.gridOptions2.enableGridMenu = false;
  439. $scope.gridOptions2.enableRowSelection = true;
  440. $scope.gridOptions2.showGridFooter = true;
  441. $scope.gridOptions2.showColumnFooter = false;
  442. $scope.gridOptions2.fastWatch = true;
  443. $scope.gridOptions2.useExternalFiltering = false;
  444. $scope.gridOptions.useExternalPagination = true;
  445. $scope.gridOptions2.paginationPageSizes = [10];
  446. $scope.gridOptions2.paginationPageSize = 10;
  447. $scope.gridOptions2.multiSelect = false;
  448. $scope.myDatagridold = [];
  449. $scope.myDatagridoldall = [];
  450. $scope.selected = {
  451. item: {}
  452. };
  453. $scope.memoryfilterDatagridold = {
  454. idx: 0,
  455. sum: 10
  456. }
  457. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  458. filterData = {
  459. idx: 0,
  460. sum: 10
  461. };
  462. $scope.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
  463. }
  464. $scope.gridOptions2.rowIdentity = function (row) {
  465. return row.id;
  466. };
  467. $scope.gridOptions2.getRowIdentity = function (row) {
  468. return row.id;
  469. };
  470. // $scope.gridOptions.columnDefs = items.columnDefs();
  471. $scope.interceptMydata = function (mydate, idx, sum) {
  472. return mydate.slice(idx * sum, (idx + 1) * sum)
  473. }
  474. if ($scope.model.oldAssets) {
  475. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  476. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
  477. }
  478. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  479. $scope.gridApi = gridApi;
  480. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  481. $scope.memoryfilterDatagridold.idx = newPage - 1;
  482. $scope.memoryfilterDatagridold.sum = pageSize;
  483. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
  484. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  485. });
  486. gridApi.core.on.filterChanged($scope, function () { });
  487. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  488. $scope.selected.item = data.entity;
  489. //console.log(data);
  490. });
  491. };
  492. // $scope.loadData = function(mydate, idx, sum) {
  493. // angular.forEach($scope.myDatagridold, function(item, index) {
  494. // $scope.myDatagridold[index].item = index;
  495. // })
  496. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  497. // }
  498. // if ($scope.model.assets) {
  499. // $scope.myDatagridallold = $scope.model.assets;
  500. // $scope.loadData($scope.model.assets, 0, 10)
  501. // }
  502. // $scope.addoldassets = function(itemin) {
  503. // event.preventDefault();
  504. // var modalInstance = $modal.open({
  505. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  506. // controller: function($scope, $modalInstance, SweetAlert) {
  507. // // $scope.consumptive = {};
  508. // $scope.title = "填写领用设备信息";
  509. // // if (items.name) {
  510. // // $scope.consumptive.name = items.name.name;
  511. // // }
  512. // $scope.placechange = itemin;
  513. // $scope.ok = function(item) {
  514. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  515. // $modalInstance.close(item);
  516. // } else {
  517. // SweetAlert.swal({
  518. // title: "数据填写不完整!",
  519. // text: "请检查数据然后提交!",
  520. // type: "error"
  521. // });
  522. // }
  523. // };
  524. // $scope.cancel = function() {
  525. // $modalInstance.dismiss('cancel');
  526. // };
  527. // },
  528. // resolve: {
  529. // SweetAlert: function() {
  530. // return SweetAlert;
  531. // }
  532. // }
  533. // });
  534. $scope.interceptMydata = function (mydate, idx, sum) {
  535. return mydate.slice(idx * sum, (idx + 1) * sum)
  536. }
  537. $scope.addshebei = function () {
  538. event.preventDefault();
  539. var modalInstance = $modal.open({
  540. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  541. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
  542. $scope.langs = i18nService.getAllLangs();
  543. $scope.lang = 'zh-cn';
  544. i18nService.setCurrentLang($scope.lang);
  545. $scope.gridOptions = {};
  546. $scope.gridOptions.data = 'myDatatwo';
  547. $scope.gridOptions.enableColumnResizing = true;
  548. $scope.gridOptions.enableFiltering = false;
  549. $scope.gridOptions.enableGridMenu = false;
  550. $scope.gridOptions.showGridFooter = true;
  551. $scope.gridOptions.showColumnFooter = false;
  552. $scope.gridOptions.fastWatch = true;
  553. $scope.gridOptions.useExternalFiltering = true;
  554. $scope.gridOptions.useExternalPagination = true;
  555. $scope.gridOptions.paginationPageSizes = [10];
  556. $scope.gridOptions.paginationPageSize = 10;
  557. $scope.gridOptions.multiSelect = true;
  558. $scope.gridOptions.rowIdentity = function (row) {
  559. return row.id;
  560. };
  561. $scope.gridOptions.getRowIdentity = function (row) {
  562. return row.id;
  563. };
  564. $scope.gridOptions.columnDefs = [{
  565. name: 'item',
  566. displayName: '序号',
  567. width: 80,
  568. enableFiltering: false
  569. },
  570. {
  571. name: 'uuid',
  572. displayName: '内部编号',
  573. width: 150
  574. },
  575. {
  576. name: 'props.hw_mingcheng',
  577. displayName: '资产名称',
  578. width: 100
  579. },
  580. {
  581. name: 'props.hw_cifilterClassic',
  582. displayName: '资产类型',
  583. width: 120,
  584. enableFiltering: false
  585. },
  586. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  587. {
  588. name: 'props.hw_state',
  589. displayName: '资产状态',
  590. width: 150,
  591. enableFiltering: false
  592. },
  593. {
  594. name: 'props.hwnw_area',
  595. displayName: '资产地点',
  596. width: 130,
  597. enableFiltering: false
  598. },
  599. {
  600. name: 'createtime',
  601. displayName: '申请时间',
  602. enableFiltering: false
  603. }
  604. ];
  605. // $scope.selectButtonClick
  606. var defaultFilterData = {
  607. // "assignee":2,
  608. // "applicationForm": { "hw_state": "在线" },
  609. "hw_state": "在线",
  610. "idx": 0,
  611. "sum": 10
  612. };
  613. $scope.memoryfilterData = {
  614. // "assignee":2,
  615. // "applicationForm": { "hw_state": "在线" },
  616. "hw_state": "在线",
  617. "idx": 0,
  618. "sum": 10
  619. }
  620. $scope.refreshData = function (style, filterData) {
  621. if (angular.isUndefined(filterData)) {
  622. filterData = defaultFilterData;
  623. }
  624. $scope.myDatatwo = [];
  625. // $scope.gridOptions['sum']=filterData.sum;
  626. api_cmdb.query(filterData).then(function (data) {
  627. // $scope.callsPending--;
  628. var myDatatwo = Restangular.stripRestangular(data);
  629. $scope.gridOptions['totalItems'] = data.total;
  630. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  631. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  632. }
  633. $scope.myDatatwo = myDatatwo.data.node;
  634. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  635. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  636. }
  637. }, function () { });
  638. };
  639. $scope.refreshData('expand-right', defaultFilterData);
  640. $scope.gridOptions.onRegisterApi = function (gridApi) {
  641. $scope.gridApi = gridApi;
  642. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  643. var filtersData = $scope.memoryfilterData;
  644. filtersData.idx = newPage - 1;
  645. filtersData.sum = pageSize;
  646. // $scope.loadData(filtersData);
  647. $scope.refreshData('expand-right', filtersData);
  648. //console.log(pageSize);
  649. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  650. });
  651. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  652. // $scope.selected.items.push(data.entity);
  653. //console.log(data);
  654. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  655. if (scope.isSelected) {
  656. scope.grid.appScope.selected.items.push(scope.entity)
  657. } else {
  658. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  659. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  660. scope.grid.appScope.selected.items.splice(i, 1);
  661. break;
  662. }
  663. }
  664. }
  665. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  666. });
  667. // });
  668. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  669. // $scope.selected.items = data.entity;
  670. //console.log(data);
  671. var selectitem = [];
  672. selectitem = angular.copy($scope.selected.items);
  673. for (var j = 0; j < rows.length; j++) {
  674. if (rows[j].isSelected == true) {
  675. selectitem.push(rows[j].entity);
  676. } else {
  677. delete selectitem[j];
  678. // rows.splice(j, 1);
  679. }
  680. }
  681. $scope.selected.items = [];
  682. for (var i = 0; i < selectitem.length; i++) {
  683. if (selectitem[i]) {
  684. $scope.selected.items.push(selectitem[i]);
  685. }
  686. }
  687. });
  688. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  689. // // if (row.entity.age > 45) {
  690. // row.grid.api.selection.selectRow(row.entity); // 选中行
  691. // // }
  692. // };
  693. gridApi.core.on.filterChanged($scope, function () {
  694. var grid = this.grid;
  695. var filtersData = {
  696. idx: 0,
  697. sum: 10,
  698. "user": {
  699. "roledata": {
  700. "rolecode": "roleset"
  701. },
  702. "selectType": "1"
  703. }
  704. };
  705. angular.forEach(grid.columns, function (item) {
  706. if (item.enableFiltering) {
  707. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  708. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  709. if (angular.isUndefined(filtersData['user'])) {
  710. filtersData['user'] = {};
  711. }
  712. filtersData['user'][item.field] = item.filters[0].term;
  713. }
  714. }
  715. });
  716. $scope.memoryfilterData = filtersData;
  717. // $scope.loadData(filtersData);
  718. });
  719. };
  720. $scope.onDblClick = function (data, event) {
  721. // $scope.selected.items = data.entity;
  722. $scope.selectButtonClick(data, event);
  723. };
  724. $scope.title = title;
  725. //树形图
  726. var apple_selected, tree, treedata_avm, treedata_geography;
  727. $scope.my_tree_handler = function (branch) {
  728. //var _ref;
  729. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  730. api_cmdb.query({
  731. 'sign': classify
  732. }).then(function (data) {
  733. var myDatalingbei = Restangular.stripRestangular(data);
  734. // console.log(myData.data.node);
  735. if (myDatalingbei.data && myDatalingbei.status == 200) {
  736. var ret = myDatalingbei.data;
  737. redrawSvg(myDatalingbei);
  738. }
  739. });
  740. };
  741. $scope.my_data = [];
  742. function convertListToTree(data, treeMap) {
  743. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  744. var root = null; //Initially set our loop to null
  745. var parentNode = null;
  746. //loop over data
  747. for (var i = 0; i < data.length; i++) {
  748. var datum = data[i];
  749. //each node will have children, so let's give it a "children" poperty
  750. datum.children = [];
  751. //add an entry for this node to the map so that any future children can
  752. //lookup the parent
  753. idToNodeMap[datum.id] = datum;
  754. //Does this node have a parent?
  755. if (typeof datum.parent === "undefined" || datum.parent == null) {
  756. //Doesn't look like it, so this node is the root of the tree
  757. root = datum;
  758. treeMap[datum.id] = root;
  759. } else {
  760. //This node has a parent, so let's look it up using the id
  761. parentNode = idToNodeMap[datum.parent.id];
  762. //We don't need this property, so let's delete it.
  763. delete datum.parent;
  764. //Let's add the current node as a child of the parent node.
  765. parentNode.children.push(datum);
  766. }
  767. }
  768. return root;
  769. }
  770. function convertParentToChildList(data) {
  771. var treeMap = {};
  772. var list = [];
  773. convertListToTree(data, treeMap);
  774. angular.forEach(treeMap, function (item) {
  775. list.push(item);
  776. });
  777. return list;
  778. }
  779. $scope.my_tree = tree = {};
  780. $scope.try_async_load = function () {
  781. $scope.my_data = [];
  782. $scope.select_treedata = [];
  783. $scope.doing_async = true;
  784. api_configure_data.fetchDataList('ciclassify', {
  785. 'idx': 0,
  786. 'sum': 100
  787. }).then(function (result) {
  788. //console.log(result['list']);
  789. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  790. $scope.doing_async = false;
  791. // tree.expand_all();
  792. //console.log(treelist);
  793. });
  794. };
  795. $scope.select_treedata = [];
  796. $scope.propTypeOptions = [];
  797. $scope.try_async_load();
  798. $scope.onFilterremove = function (item) {
  799. console.log(item)
  800. }
  801. $scope.searchdata = {};
  802. $scope.clear = function () {
  803. $scope.searchdata = {};
  804. $scope.cifilter_classic = {};
  805. $scope.try_async_load();
  806. var fildata = {
  807. idx: 0,
  808. sum: 10,
  809. 'hw_state': '在线'
  810. }
  811. $scope.memoryfilterData = fildata;
  812. $scope.refreshData('expand-right', fildata);
  813. }
  814. $scope.chiceIncident = function (item) {
  815. var fildata = $scope.memoryfilterData;
  816. // fildata.applicationForm = {};
  817. // if (item.alltitle && item.alldata) {
  818. // fildata.applicationForm[item.alltitle.key] = item.alldata
  819. // }
  820. if (item && item.id) {
  821. var classify = item.prefix.toLowerCase() + item.sign;
  822. fildata.sign = classify
  823. }
  824. $scope.gridOptions.paginationCurrentPage = 1;
  825. var transitiondata = angular.copy(item);
  826. $scope.refreshData('expand-right', fildata);
  827. }
  828. $scope.applicadata = [];
  829. $scope.onFilterCallback = function (item) {
  830. var tempclassify = item.prefix.toLowerCase() + item.sign;
  831. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  832. var myData = Restangular.stripRestangular(data);
  833. $scope.applicadata = myData[0].form.fields;
  834. });
  835. // }
  836. }
  837. // $scope.loadData({
  838. // idx: 0,
  839. // sum: 10,
  840. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  841. // });
  842. $scope.selected = {
  843. items: []
  844. };
  845. $scope.ok = function () {
  846. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  847. // onDataCallback($scope.selected.item, parentScope);
  848. // }
  849. $modalInstance.close($scope.selected.items);
  850. };
  851. $scope.cancel = function () {
  852. $modalInstance.dismiss('cancel');
  853. };
  854. },
  855. size: 'lg',
  856. resolve: {
  857. items: function () {
  858. return {
  859. fetchItems: function (filterData, APIService) {
  860. filterData = filterData || {};
  861. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  862. filterData = {
  863. idx: 0,
  864. sum: 10,
  865. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  866. };
  867. }
  868. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  869. }
  870. };
  871. },
  872. title: function () {
  873. return $scope.options.templateOptions.label;
  874. },
  875. Restangular: function () {
  876. return $scope.options.templateOptions.Restangular;
  877. },
  878. APIService: function () {
  879. return $scope.options.templateOptions.ApiService;
  880. },
  881. onDataCallback: function () {
  882. return $scope.options.templateOptions.callback;
  883. },
  884. parentScope: function () {
  885. return $scope.options.templateOptions.that;
  886. }
  887. }
  888. });
  889. modalInstance.result.then(function (selectedItem) {
  890. $scope.myDatagridoldall = selectedItem;
  891. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  892. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  893. }
  894. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  895. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  896. // $scope.model.oldAssets = $scope.myDatagridoldall;
  897. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  898. $scope.options.initialValue = $scope.model.oldAssets;
  899. });
  900. // }
  901. }
  902. $scope.changestate = function (itemin) {
  903. event.preventDefault();
  904. var modalInstance = $modal.open({
  905. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
  906. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  907. $scope.title = '旧设备状态修改';
  908. $scope.stateshe = [{
  909. "id": 2,
  910. "name": "在库"
  911. }, {
  912. "id": 4,
  913. "name": "报修"
  914. }, {
  915. "id": 3,
  916. "name": "报废"
  917. }];
  918. $scope.hw_state = {};
  919. $scope.ok = function (item) {
  920. $modalInstance.close(item.id);
  921. };
  922. $scope.cancel = function () {
  923. $modalInstance.dismiss('cancel');
  924. };
  925. },
  926. size: 'sm',
  927. resolve: {
  928. scope: function () {
  929. return $scope;
  930. }
  931. }
  932. });
  933. modalInstance.result.then(function (selectedItem) {
  934. if (selectedItem) {
  935. angular.forEach($scope.myDatagridallold, function (item, index) {
  936. if (item.id == itemin.id) {
  937. $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
  938. }
  939. })
  940. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  941. $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  942. }
  943. $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
  944. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
  945. // $scope.model.oldAssets = $scope.myDatagridallold;
  946. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
  947. $scope.options.initialValue = $scope.model.oldAssets;
  948. }
  949. })
  950. }
  951. $scope.savedata = function (data) {
  952. event.preventDefault();
  953. var modalInstance = $modal.open({
  954. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
  955. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  956. $scope.title = '设备编辑';
  957. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  958. $scope.ok = function (item) {
  959. $modalInstance.close(item);
  960. };
  961. $scope.cancel = function () {
  962. $modalInstance.dismiss('cancel');
  963. };
  964. },
  965. size: 'sm',
  966. resolve: {
  967. scope: function () {
  968. return $scope;
  969. }
  970. }
  971. });
  972. modalInstance.result.then(function (selectedItem) {
  973. if (selectedItem) {
  974. angular.forEach($scope.myDatagridoldall, function (item, index) {
  975. if (item.id == data.id) {
  976. $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
  977. }
  978. })
  979. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  980. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  981. }
  982. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  983. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  984. // $scope.model.oldAssets = $scope.myDatagridoldall;
  985. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  986. $scope.options.initialValue = $scope.model.oldAssets;
  987. }
  988. })
  989. }
  990. $scope.removeold = function (data) {
  991. event.preventDefault();
  992. var modalInstance = $modal.open({
  993. templateUrl: 'assets/views/delete.html',
  994. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  995. $scope.title = '设备删除';
  996. $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  997. $scope.ok = function () {
  998. $modalInstance.close(data);
  999. };
  1000. $scope.cancel = function () {
  1001. $modalInstance.dismiss('cancel');
  1002. };
  1003. },
  1004. size: 'sm',
  1005. resolve: {
  1006. scope: function () {
  1007. return $scope;
  1008. }
  1009. }
  1010. });
  1011. modalInstance.result.then(function (selectedItem) {
  1012. if (selectedItem) {
  1013. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1014. if (item.id == selectedItem.id) {
  1015. $scope.myDatagridoldall.splice(index, 1);
  1016. }
  1017. })
  1018. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1019. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  1020. }
  1021. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  1022. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  1023. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1024. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  1025. $scope.options.initialValue = $scope.model.oldAssets;
  1026. }
  1027. })
  1028. }
  1029. }]
  1030. });
  1031. //ui-grid list
  1032. formlyConfigProvider.setType({
  1033. name: "ui-gridlist",
  1034. extends: 'input',
  1035. templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
  1036. defaultOptions: function (options, $scope) {
  1037. return {
  1038. templateOptions: {}
  1039. };
  1040. },
  1041. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  1042. //gridone
  1043. $scope.langs = i18nService.getAllLangs();
  1044. $scope.lang = 'zh-cn';
  1045. i18nService.setCurrentLang($scope.lang);
  1046. $scope.gridOptions = {};
  1047. $scope.gridOptions.data = 'myDatagrid';
  1048. $scope.gridOptions.enableColumnResizing = true;
  1049. $scope.gridOptions.enableFiltering = true;
  1050. $scope.gridOptions.enableGridMenu = false;
  1051. $scope.gridOptions.enableRowSelection = true;
  1052. $scope.gridOptions.showGridFooter = true;
  1053. $scope.gridOptions.showColumnFooter = false;
  1054. $scope.gridOptions.fastWatch = true;
  1055. $scope.gridOptions.useExternalFiltering = false;
  1056. // $scope.gridOptions.useExternalPagination = true;
  1057. $scope.gridOptions.paginationPageSizes = [10];
  1058. $scope.gridOptions.paginationPageSize = 10;
  1059. $scope.gridOptions.multiSelect = false;
  1060. $scope.myDatagrid = [];
  1061. $scope.myDatagridall = [];
  1062. $scope.selected = {
  1063. item: {}
  1064. };
  1065. $scope.memoryfilterDatagrid = {
  1066. idx: 0,
  1067. sum: 10
  1068. }
  1069. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1070. filterData = {
  1071. idx: 0,
  1072. sum: 10
  1073. };
  1074. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  1075. }
  1076. $scope.gridOptions.rowIdentity = function (row) {
  1077. return row.id;
  1078. };
  1079. $scope.gridOptions.getRowIdentity = function (row) {
  1080. return row.id;
  1081. };
  1082. // $scope.gridOptions.columnDefs = items.columnDefs();
  1083. $scope.interceptMydata = function (mydate, idx, sum) {
  1084. return mydate.slice(idx * sum, (idx + 1) * sum)
  1085. }
  1086. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1087. $scope.gridApi = gridApi;
  1088. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1089. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1090. $scope.memoryfilterDatagrid.sum = pageSize;
  1091. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  1092. $scope.loadData({
  1093. "idx": newPage - 1,
  1094. "sum": pageSize
  1095. });
  1096. });
  1097. gridApi.core.on.filterChanged($scope, function () { });
  1098. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1099. $scope.selected.item = data.entity;
  1100. //console.log(data);
  1101. });
  1102. };
  1103. $scope.loadData = function (mydate, idx, sum) {
  1104. angular.forEach($scope.myDatagrid, function (item, index) {
  1105. $scope.myDatagrid[index].item = index;
  1106. })
  1107. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  1108. }
  1109. if ($scope.model.assets) {
  1110. $scope.myDatagridall = $scope.model.assets;
  1111. $scope.loadData($scope.model.assets, 0, 10)
  1112. }
  1113. $scope.saveData = function (itemin) {
  1114. event.preventDefault();
  1115. var modalInstance = $modal.open({
  1116. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  1117. controller: function ($scope, $modalInstance, SweetAlert) {
  1118. // $scope.consumptive = {};
  1119. $scope.title = "填写领用设备信息";
  1120. // if (items.name) {
  1121. // $scope.consumptive.name = items.name.name;
  1122. // }
  1123. $scope.placechange = angular.copy(itemin);
  1124. $scope.ok = function (item) {
  1125. 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) {
  1126. $modalInstance.close(item);
  1127. } else {
  1128. SweetAlert.swal({
  1129. title: "数据填写不完整!",
  1130. text: "请检查数据然后提交!",
  1131. type: "error"
  1132. });
  1133. }
  1134. };
  1135. $scope.cancel = function () {
  1136. $modalInstance.dismiss('cancel');
  1137. };
  1138. },
  1139. resolve: {
  1140. SweetAlert: function () {
  1141. return SweetAlert;
  1142. }
  1143. }
  1144. });
  1145. modalInstance.result.then(function (selectedItem) {
  1146. angular.forEach($scope.myDatagrid, function (item, index) {
  1147. if (item.id == selectedItem.id) {
  1148. angular.extend($scope.myDatagrid[index], selectedItem)
  1149. }
  1150. })
  1151. // $scope.myData3.push(selectedItem);
  1152. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1153. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  1154. }
  1155. // $scope.model.assets = $scope.myDatagridall;
  1156. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  1157. })
  1158. }
  1159. }]
  1160. });
  1161. //设备耗材list组件
  1162. formlyConfigProvider.setType({
  1163. name: 'ui-shehaolist',
  1164. // extends: 'radio',
  1165. templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
  1166. defaultOptions: function (options) {
  1167. return {
  1168. templateOptions: {
  1169. refresh: function () { },
  1170. refreshDelay: 0
  1171. }
  1172. };
  1173. },
  1174. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1175. // var data = { "haodata": [], "shedata": [] };
  1176. var haodata = [];
  1177. var shedata = [];
  1178. if ($scope.model.consumables) {
  1179. if (angular.isArray($scope.model.consumables)) {
  1180. haodata = $scope.model.consumables;
  1181. } else {
  1182. haodata = JSON.parse($scope.model.consumables);
  1183. }
  1184. $scope.model.consumables = haodata;
  1185. angular.forEach(haodata, function (item, index) {
  1186. haodata[index].item = index + 1;
  1187. })
  1188. }
  1189. if ($scope.model.assets) {
  1190. if (angular.isArray($scope.model.assets)) {
  1191. shedata = $scope.model.assets;
  1192. } else {
  1193. shedata = JSON.parse($scope.model.assets);
  1194. }
  1195. $scope.model.assets = shedata;
  1196. angular.forEach(shedata, function (item, index) {
  1197. shedata[index].item = index + 1;
  1198. })
  1199. }
  1200. $scope.tableParamshao = new ngTableParams({
  1201. page: 1,
  1202. count: 5
  1203. }, {
  1204. total: haodata.length,
  1205. getData: function ($defer, params) {
  1206. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  1207. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1208. }
  1209. });
  1210. $scope.tableParamsshe = new ngTableParams({
  1211. page: 1,
  1212. count: 5
  1213. }, {
  1214. total: shedata.length,
  1215. getData: function ($defer, params) {
  1216. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  1217. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1218. }
  1219. });
  1220. $scope.editId = -1;
  1221. $scope.setEditId = function (pid) {
  1222. $scope.editId = pid;
  1223. };
  1224. if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
  1225. $scope.isAgree = "同意";
  1226. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
  1227. $scope.isAgree = "同意";
  1228. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
  1229. $scope.isAgree = "返回修改";
  1230. }
  1231. }]
  1232. });
  1233. //关联资产出库
  1234. formlyConfigProvider.setType({
  1235. name: "ui-meansmodelselect",
  1236. extends: 'input',
  1237. templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
  1238. defaultOptions: function (options) {
  1239. return {
  1240. templateOptions: {}
  1241. };
  1242. },
  1243. controller: ['$scope', '$modal', function ($scope, $modal) {
  1244. $scope.openModal = function (size, options, modal) {
  1245. var modalInstance = $modal.open({
  1246. templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
  1247. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService, api_wechatfile) {
  1248. $scope.langs = i18nService.getAllLangs();
  1249. $scope.lang = 'zh-cn';
  1250. i18nService.setCurrentLang($scope.lang);
  1251. $scope.gridOptions = {};
  1252. $scope.gridOptions.data = 'myData';
  1253. $scope.gridOptions.enableColumnResizing = true;
  1254. $scope.gridOptions.enableFiltering = false;
  1255. $scope.gridOptions.enableGridMenu = false;
  1256. $scope.gridOptions.showGridFooter = true;
  1257. $scope.gridOptions.showColumnFooter = false;
  1258. $scope.gridOptions.fastWatch = true;
  1259. $scope.gridOptions.useExternalFiltering = true;
  1260. $scope.gridOptions.useExternalPagination = true;
  1261. $scope.gridOptions.paginationPageSizes = [10];
  1262. $scope.gridOptions.paginationPageSize = 10;
  1263. $scope.gridOptions.multiSelect = false;
  1264. $scope.gridOptions.rowIdentity = function (row) {
  1265. return row.id;
  1266. };
  1267. $scope.gridOptions.getRowIdentity = function (row) {
  1268. return row.id;
  1269. };
  1270. // $scope.states = [{
  1271. // id: 0,
  1272. // name: '待批准'
  1273. // },
  1274. // {
  1275. // id: 1,
  1276. // name: '已驳回'
  1277. // },
  1278. // {
  1279. // id: 2,
  1280. // name: '待出库'
  1281. // },
  1282. // {
  1283. // id: 3,
  1284. // name: '信息更新'
  1285. // },
  1286. // {
  1287. // id: 4,
  1288. // name: '信息确认'
  1289. // },
  1290. // {
  1291. // id: 5,
  1292. // name: '已关闭'
  1293. // }
  1294. // ];
  1295. $scope.getStatesDictionary = function () {
  1296. var data = {
  1297. "key": "applicationForm_status",
  1298. "type": "list"
  1299. }
  1300. api_wechatfile.getDictionary(data).then(function (res) {
  1301. $scope.states = res
  1302. })
  1303. };
  1304. $scope.getStatesDictionary();
  1305. $scope.type = [{
  1306. id: 1,
  1307. name: '资产入库'
  1308. },
  1309. {
  1310. id: 2,
  1311. name: '资产归还'
  1312. },
  1313. {
  1314. id: 3,
  1315. name: '资产领用'
  1316. },
  1317. {
  1318. id: 4,
  1319. name: '资产更换'
  1320. }
  1321. ];
  1322. $scope.typedata = function (row) {
  1323. if (row.type == 0) {
  1324. return "资产入库";
  1325. } else if (row.type == 2) {
  1326. return "资产归还";
  1327. } else if (row.type == 1) {
  1328. return "资产领用";
  1329. } else if (row.type == 4) {
  1330. return "资产更换";
  1331. }
  1332. };
  1333. $scope.statedata = function (row) {
  1334. if (row.status == 0) {
  1335. return "待批准";
  1336. } else if (row.status == 1) {
  1337. return "已驳回";
  1338. } else if (row.status == 2) {
  1339. return "待出库";
  1340. } else if (row.status == 3) {
  1341. return "信息更新";
  1342. } else if (row.status == 4) {
  1343. return "信息确认";
  1344. } else if (row.status == 5) {
  1345. return "已关闭";
  1346. }
  1347. };
  1348. $scope.transferTime = function (time) {
  1349. return moment(time).format('YYYY-MM-DD HH:mm');
  1350. }
  1351. $scope.application = [{
  1352. value: "serialNumbe",
  1353. name: '申请单编号'
  1354. },
  1355. // { value: "proposer", name: '申请人' },
  1356. {
  1357. value: "purpose",
  1358. name: '领用用途'
  1359. },
  1360. // { value: "cmdbsign", name: '设备编号' }
  1361. ];
  1362. $scope.parameters = null;
  1363. $scope.open = function ($event) {
  1364. $event.preventDefault();
  1365. $event.stopPropagation();
  1366. $scope.opened = !$scope.opened;
  1367. };
  1368. $scope.endOpen = function ($event) {
  1369. $event.preventDefault();
  1370. $event.stopPropagation();
  1371. $scope.startOpened = false;
  1372. $scope.endOpened = !$scope.endOpened;
  1373. };
  1374. $scope.startOpen = function ($event) {
  1375. $event.preventDefault();
  1376. $event.stopPropagation();
  1377. $scope.endOpened = false;
  1378. $scope.startOpened = !$scope.startOpened;
  1379. };
  1380. $scope.othcode = {};
  1381. $scope.searchkeys = {};
  1382. $scope.parameters = {};
  1383. $scope.memoryfilterData = {
  1384. "assignee": $rootScope.user.id,
  1385. "candidateGroups": $rootScope.user.group[0].id,
  1386. "searchType": "todo",
  1387. idx: 0,
  1388. sum: 10
  1389. }
  1390. $scope.clear = function () {
  1391. $scope.searchkeys = {};
  1392. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1393. // $scope.othcode = {};
  1394. $scope.parameters = {};
  1395. var fildata = {
  1396. "assignee": $rootScope.user.id,
  1397. "candidateGroups": $rootScope.user.group[0].id,
  1398. "searchType": "todo",
  1399. idx: 0,
  1400. sum: 10
  1401. }
  1402. // sessionStorage.removeItem("searchincident");
  1403. $scope.memoryfilterData = fildata;
  1404. $scope.loadData(fildata);
  1405. }
  1406. $scope.chiceIncident = function (parameters, item, stateid) {
  1407. var fildata = {
  1408. "assignee": $rootScope.user.id,
  1409. "candidateGroups": 1,
  1410. "searchType": "todo",
  1411. "idx": 0,
  1412. "sum": 10
  1413. };
  1414. if (item) {
  1415. fildata.applicationForm = {};
  1416. if (item.alltitle && item.alldata) {
  1417. fildata.applicationForm[item.alltitle.value] = item.alldata
  1418. }
  1419. if (item.linkProposer) {
  1420. fildata.applicationForm.linkProposer = item.linkProposer
  1421. }
  1422. if (item.proposer) {
  1423. fildata.applicationForm.proposer = item.proposer
  1424. }
  1425. if (item.status) {
  1426. fildata.applicationForm['status'] = {
  1427. id: item.status.id
  1428. };
  1429. }
  1430. if (item.type) {
  1431. fildata.applicationForm['type'] = {
  1432. id: item.type.id
  1433. };
  1434. }
  1435. }
  1436. $scope.gridOptions.paginationCurrentPage = 1;
  1437. if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
  1438. angular.extend(fildata, {
  1439. 'idx': 0,
  1440. 'sum': $scope.gridOptions.paginationPageSize
  1441. })
  1442. angular.extend(fildata.applicationForm, {
  1443. 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'),
  1444. 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59')
  1445. })
  1446. }
  1447. var transitiondata = angular.copy(item);
  1448. // angular.extend(fildata.applicationForm, transitiondata)
  1449. $scope.loadData(fildata);
  1450. }
  1451. $scope.key = {};
  1452. api_user_data.fetchDataList('user', {
  1453. "idx": 0,
  1454. "sum": 1000,
  1455. "flag": -1
  1456. }).then(function (data) {
  1457. $scope.handlingPersonnelUser = data.list;
  1458. });
  1459. $scope.gridOptions.columnDefs = items.columnDefs();
  1460. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1461. $scope.gridApi = gridApi;
  1462. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1463. // console.log(newPage);
  1464. // console.log(pageSize);
  1465. $scope.loadData({
  1466. "idx": newPage - 1,
  1467. "sum": pageSize
  1468. });
  1469. });
  1470. gridApi.core.on.filterChanged($scope, function () {
  1471. });
  1472. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1473. $scope.selected.item = data.entity;
  1474. //console.log(data);
  1475. });
  1476. };
  1477. $scope.loadData = function (filterData) {
  1478. items.fetchItems(filterData, APIService).then(function (data) {
  1479. var myData = Restangular.stripRestangular(data);
  1480. $scope.gridOptions.totalItems = myData.totalNum;
  1481. $scope.myData = myData.list;
  1482. for (var i = 0; i < $scope.myData.length; i++) {
  1483. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  1484. }
  1485. });
  1486. };
  1487. $scope.title = title;
  1488. $scope.loadData({
  1489. idx: 0,
  1490. sum: 10,
  1491. "assignee": $rootScope.user.id,
  1492. "candidateGroups": $rootScope.user.group[0].id,
  1493. "searchType": "todo",
  1494. });
  1495. $scope.selected = {
  1496. item: {}
  1497. };
  1498. $scope.ok = function () {
  1499. //console.log($scope.selected.item);
  1500. $modalInstance.close($scope.selected.item);
  1501. };
  1502. $scope.cancel = function () {
  1503. $modalInstance.dismiss('cancel');
  1504. };
  1505. },
  1506. size: 'lg',
  1507. resolve: {
  1508. items: function () {
  1509. return {
  1510. fetchItems: function (filterData, APIService) {
  1511. filterData = filterData || {};
  1512. // if(!filterData.idx){
  1513. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  1514. filterData = {
  1515. idx: 0,
  1516. sum: 10
  1517. };
  1518. }
  1519. return options.templateOptions.fetchItems(filterData, APIService, options);
  1520. },
  1521. columnDefs: function () {
  1522. return options.templateOptions.columnDefs;
  1523. }
  1524. };
  1525. },
  1526. title: function () {
  1527. return options.templateOptions.modalTitle;
  1528. },
  1529. Restangular: function () {
  1530. return options.templateOptions.Restangular;
  1531. },
  1532. APIService: function () {
  1533. return options.templateOptions.ApiService;
  1534. }
  1535. }
  1536. });
  1537. modalInstance.result.then(function (selectedItem) {
  1538. var selectitem = {
  1539. title: selectedItem.title,
  1540. description: selectedItem.description
  1541. }
  1542. if (options.key == "chuku") {
  1543. if (selectedItem.assets) {
  1544. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  1545. }
  1546. if (selectedItem.consumables) {
  1547. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  1548. }
  1549. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  1550. options.value(selectedItem);
  1551. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1552. } else {
  1553. angular.extend(options.model, selectitem);
  1554. options.value(selectedItem);
  1555. }
  1556. }, function () {
  1557. //console.log('Modal dismissed at: ' + new Date());
  1558. });
  1559. }
  1560. }]
  1561. });
  1562. //文本框
  1563. formlyConfigProvider.setType({
  1564. name: 'ui-textcmdb',
  1565. extends: '',
  1566. templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
  1567. defaultOptions: function (options) {
  1568. return {
  1569. templateOptions: {
  1570. transform: function (model, value) {
  1571. return value;
  1572. },
  1573. },
  1574. validation: {
  1575. messages: {
  1576. maxlength: function (viewValue, modelValue, scope) {
  1577. if (viewValue != null) {
  1578. if (viewValue.length > scope.to.maxlength) {
  1579. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1580. } else {
  1581. return "";
  1582. }
  1583. }
  1584. },
  1585. }
  1586. }
  1587. }
  1588. },
  1589. controller: ['$scope', function ($scope) {
  1590. var value = $scope.model[$scope.options.key];
  1591. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1592. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1593. }
  1594. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1595. $scope.options.templateOptions.felditem($scope);
  1596. }
  1597. }]
  1598. });
  1599. //设备组件
  1600. formlyConfigProvider.setType({
  1601. name: 'ui-applist',
  1602. extends: 'radio',
  1603. templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
  1604. defaultOptions: function (options) {
  1605. return {
  1606. templateOptions: {
  1607. refresh: function () { },
  1608. refreshDelay: 0
  1609. }
  1610. };
  1611. },
  1612. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1613. var data = [];
  1614. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1615. // data = JSON.parse($scope.model.consumables);
  1616. if (angular.isArray($scope.model.consumables)) {
  1617. data = $scope.model.consumables;
  1618. } else {
  1619. data = JSON.parse($scope.model.consumables);
  1620. }
  1621. $scope.model.consumables = data;
  1622. angular.forEach(data, function (item, index) {
  1623. data[index].item = index + 1;
  1624. })
  1625. }
  1626. if ($scope.model.assets && $scope.options.key == "assets") {
  1627. if (angular.isArray($scope.model.assets)) {
  1628. data = $scope.model.assets;
  1629. } else {
  1630. data = JSON.parse($scope.model.assets);
  1631. }
  1632. // data = JSON.parse($scope.model.assets);
  1633. $scope.model.assets = data;
  1634. angular.forEach(data, function (item, index) {
  1635. data[index].item = index + 1;
  1636. })
  1637. }
  1638. $scope.tableParams = new ngTableParams({
  1639. page: 1,
  1640. count: 5
  1641. }, {
  1642. total: data.length,
  1643. getData: function ($defer, params) {
  1644. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1645. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1646. }
  1647. });
  1648. $scope.editId = -1;
  1649. $scope.setEditId = function (pid) {
  1650. $scope.editId = pid;
  1651. };
  1652. }]
  1653. });
  1654. //list组件
  1655. formlyConfigProvider.setType({
  1656. name: 'ui-gudinglist',
  1657. extends: 'radio',
  1658. templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
  1659. defaultOptions: function (options) {
  1660. return {
  1661. templateOptions: {
  1662. refresh: function () { },
  1663. refreshDelay: 0
  1664. }
  1665. };
  1666. },
  1667. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1668. var data = [];
  1669. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1670. // data = JSON.parse($scope.model.consumables);
  1671. if (angular.isArray($scope.model.consumables)) {
  1672. data = $scope.model.consumables;
  1673. } else {
  1674. data = JSON.parse($scope.model.consumables);
  1675. }
  1676. $scope.model.consumables = data;
  1677. angular.forEach(data, function (item, index) {
  1678. data[index].item = index + 1;
  1679. })
  1680. }
  1681. if ($scope.model.assets && $scope.options.key == "assets") {
  1682. if (angular.isArray($scope.model.assets)) {
  1683. data = $scope.model.assets;
  1684. } else {
  1685. data = JSON.parse($scope.model.assets);
  1686. }
  1687. // data = JSON.parse($scope.model.assets);
  1688. $scope.model.assets = data;
  1689. angular.forEach(data, function (item, index) {
  1690. data[index].item = index + 1;
  1691. })
  1692. }
  1693. $scope.tableParams = new ngTableParams({
  1694. page: 1,
  1695. count: 5
  1696. }, {
  1697. total: data.length,
  1698. getData: function ($defer, params) {
  1699. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1700. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1701. }
  1702. });
  1703. $scope.editId = -1;
  1704. $scope.setEditId = function (pid) {
  1705. $scope.editId = pid;
  1706. };
  1707. }]
  1708. });
  1709. //other list tab组件
  1710. formlyConfigProvider.setType({
  1711. name: 'ui-otherlisttab',
  1712. extends: '',
  1713. templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
  1714. defaultOptions: function (options) {
  1715. return {
  1716. templateOptions: {
  1717. refresh: function () { },
  1718. refreshDelay: 0
  1719. }
  1720. };
  1721. },
  1722. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1723. }]
  1724. });
  1725. //审核查看组件
  1726. formlyConfigProvider.setType({
  1727. name: 'ui-aprovelist',
  1728. extends: '',
  1729. templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
  1730. defaultOptions: function (options) {
  1731. return {
  1732. templateOptions: {
  1733. refresh: function () { },
  1734. refreshDelay: 0
  1735. }
  1736. };
  1737. },
  1738. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1739. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  1740. $scope.isAgree = "同意";
  1741. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  1742. $scope.isAgree = "同意";
  1743. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  1744. $scope.isAgree = "返回修改";
  1745. }
  1746. }]
  1747. });
  1748. //other list组件
  1749. formlyConfigProvider.setType({
  1750. name: 'ui-otherlist',
  1751. extends: '',
  1752. templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
  1753. defaultOptions: function (options) {
  1754. return {
  1755. templateOptions: {
  1756. refresh: function () { },
  1757. refreshDelay: 0
  1758. }
  1759. };
  1760. },
  1761. 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) {
  1762. console.log("哈哈");
  1763. console.log($scope);
  1764. $scope.langs = i18nService.getAllLangs();
  1765. $scope.lang = 'zh-cn';
  1766. i18nService.setCurrentLang($scope.lang);
  1767. var vm = this;
  1768. vm.options = {};
  1769. vm.exampleTitle = ['expressionProperties', 'model property'];
  1770. vm.fields = [];
  1771. vm.models = {};
  1772. // vm.models["loginUser"] = $rootScope.user;
  1773. var that = $injector;
  1774. var parse = $parse;
  1775. var formKey = "";
  1776. var pdKey = "";
  1777. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1778. pdKey = $state.current.pdKey;
  1779. //console.log("pdKey::"+$state.current.pdKey);
  1780. }
  1781. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1782. formKey = $stateParams.formKey;
  1783. //console.log("formKey::"+$stateParams.formKey);
  1784. }
  1785. //用户测试数据,后续从header的auth中获取
  1786. var userId = 2;
  1787. userId = $rootScope.user.id;
  1788. //==============处理表单设计数据 开始====================
  1789. //处理组件加载后台数据选项的方法
  1790. function refreshSelectOptions(searchVal, field) {
  1791. if (field.templateOptions.optionsUrl) {
  1792. var process = BpmRestangular.all("");
  1793. if (field.templateOptions.ApiService) {
  1794. process = UserRestangular.all("");
  1795. }
  1796. process.customPOST({
  1797. "idx": 0,
  1798. "sum": 1000
  1799. }, field.templateOptions.optionsUrl).then(function (result) {
  1800. if (!field.templateOptions.options) {
  1801. field.templateOptions.options = [];
  1802. }
  1803. if (field.templateOptions.optionsDataKey) {
  1804. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  1805. } else {
  1806. field.templateOptions.options = result;
  1807. }
  1808. });
  1809. }
  1810. }
  1811. function decodeVMTabForm(model, tabs) {
  1812. var result = {
  1813. model: {},
  1814. tabs: []
  1815. };
  1816. var mdata = angular.fromJson(model);
  1817. angular.extend(result.model, mdata);
  1818. angular.forEach(tabs, function (tab) {
  1819. tab.form.model = vm.models;
  1820. angular.forEach(tab.form.fields, function (field) {
  1821. if (field.key == "") {
  1822. delete field.key;
  1823. }
  1824. field.type = "ui-otherlisttab";
  1825. if (angular.isDefined(field.extjson) && field.extjson != "") {
  1826. var extObj = angular.fromJson(field.extjson);
  1827. angular.extend(field.templateOptions, extObj.templateOptions);
  1828. delete extObj.templateOptions;
  1829. for (var prop in extObj) {
  1830. if (new RegExp("Expression").test(prop)) {
  1831. //var obj = $scope.$eval(extObj[prop]);
  1832. //extObj[prop] = $scope.$eval(extObj[prop]);
  1833. if (extObj[prop] != null) {
  1834. if (new RegExp("function").test(extObj[prop])) {
  1835. var propValue = eval(extObj[prop]);
  1836. extObj[prop] = propValue;
  1837. } else {
  1838. //console.log(extObj[prop]);
  1839. var obj = $scope.$eval(extObj[prop]);
  1840. extObj[prop] = obj;
  1841. //console.log(obj);
  1842. }
  1843. }
  1844. } else if (new RegExp("expressionProperties").test(prop)) {
  1845. for (var p in extObj[prop]) {
  1846. if (new RegExp("function").test(extObj[prop][p])) {
  1847. var propValue = eval(extObj[prop][p]);
  1848. extObj[prop][p] = propValue;
  1849. } else {
  1850. //if(p.indexOf("'")>=0){
  1851. // var obj = $scope.$eval(extObj[prop][p]);
  1852. // extObj[prop][$scope.$eval(p)]=obj;
  1853. //}
  1854. }
  1855. }
  1856. } else if ("watcher" == prop) {
  1857. if (angular.isArray(extObj[prop])) {
  1858. angular.forEach(extObj[prop], function (item, index) {
  1859. for (var p in item) {
  1860. if (new RegExp("function").test(item[p])) {
  1861. var propValue = eval(item[p]);
  1862. extObj[prop][index][p] = propValue;
  1863. }
  1864. }
  1865. });
  1866. } else if (angular.isObject(extObj[prop])) {
  1867. for (var p in extObj[prop]) {
  1868. if (new RegExp("function").test(extObj[prop][p])) {
  1869. var propValue = eval(extObj[prop][p]);
  1870. extObj[prop][p] = propValue;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. }
  1876. angular.extend(field, extObj);
  1877. delete field.extjson;
  1878. }
  1879. if (field.extjson == "") {
  1880. delete field.extjson;
  1881. }
  1882. if (angular.isDefined(field.templateOptions)) {
  1883. var templateOs = field.templateOptions;
  1884. for (var property in templateOs) {
  1885. //console.log(property);
  1886. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  1887. if (new RegExp("function").test(templateOs[property])) {
  1888. var propValue = eval(templateOs[property]);
  1889. field.templateOptions[property] = propValue;
  1890. } else {
  1891. if (that.has(templateOs[property])) {
  1892. field.templateOptions[property] = that.get(templateOs[property]);
  1893. } else {
  1894. field.templateOptions[property] = templateOs[property];
  1895. }
  1896. }
  1897. } else if (templateOs[property] == null) {
  1898. //delete field.templateOptions[property];
  1899. } else { }
  1900. }
  1901. }
  1902. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  1903. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  1904. angular.extend(field.templateOptions, extObj);
  1905. delete field.templateOptions.extjson;
  1906. }
  1907. //...
  1908. if (field.templateOptions) {
  1909. //处理远程获取数据控件方法调用
  1910. if (field.templateOptions.optionsUrl) {
  1911. field.templateOptions.refresh = refreshSelectOptions;
  1912. }
  1913. //处理嵌套属性数据绑定/
  1914. if (field.templateOptions.pkey) {
  1915. var pmodel, i = 0;
  1916. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  1917. if (i == 0) {
  1918. if (result.model[p] == null) {
  1919. result.model[p] = {};
  1920. }
  1921. pmodel = result.model[p];
  1922. i++;
  1923. } else {
  1924. if (pmodel[p] == null) {
  1925. pmodel[p] = {};
  1926. }
  1927. pmodel = pmodel[p];
  1928. }
  1929. });
  1930. if (pmodel != null) {
  1931. field.model = pmodel;
  1932. if (pmodel[field.key] == null) {
  1933. pmodel[field.key] = null;
  1934. }
  1935. }
  1936. } else {
  1937. if (result.model[field.key] == null) {
  1938. result.model[field.key] = null;
  1939. }
  1940. }
  1941. //处理弹出框组件初始化
  1942. if (field.type == "ui-input-selectmodal") {
  1943. field.templateOptions.modal = $modal;
  1944. //field.templateOptions.Restangular = Restangular;
  1945. } else if (field.type == "ui-userselect") {
  1946. field.templateOptions.modal = $modal;
  1947. //field.templateOptions.Restangular = Restangular;
  1948. } else if (field.type == "ui-multiuserselect") {
  1949. field.templateOptions.modal = $modal;
  1950. } else if (field.type == "ui-modelselect") {
  1951. field.templateOptions.modal = $modal;
  1952. //field.templateOptions.Restangular = Restangular;
  1953. } else if (field.type == "ui-cmdbuplode") {
  1954. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  1955. url: '/uploader',
  1956. queueLimit: 1, //文件个数
  1957. autoUpload: true
  1958. });
  1959. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  1960. } else if (field.type == "ui-dropfile") {
  1961. field.templateOptions.fileUploader = new FileUploader({
  1962. url: '/uploader'
  1963. });
  1964. field.templateOptions.taskId = $stateParams.taskId;
  1965. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1966. field.templateOptions.userId = $rootScope.user.id;
  1967. //field.ApiService=api_bpm_domain;
  1968. } else if (field.type == "ui-dropfiletable") {
  1969. if (field.templateOptions.processInstanceId) {
  1970. } else {
  1971. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1972. }
  1973. } else if (field.type == "ui-repeatSection") {
  1974. var repeatForm = {
  1975. model: {
  1976. },
  1977. fields: field.templateOptions.fields
  1978. };
  1979. repeatForm.model[field.key] = [];
  1980. decodeVMTabForm(repeatForm);
  1981. }
  1982. }
  1983. // console.log(field);
  1984. //field
  1985. //result.fields.push(field);
  1986. })
  1987. });
  1988. vm.originalTabs = angular.copy(vm.form);
  1989. }
  1990. //======================处理表单设计数据 结束========================
  1991. $scope.ldloading = {};
  1992. function filter(obj) {
  1993. angular.forEach(obj, function (key, value) {
  1994. if (value === "" || value === null) {
  1995. delete obj[key];
  1996. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1997. filter(value);
  1998. } else if (angular.isArray(value)) {
  1999. angular.forEach(value, function (item) {
  2000. filter(item);
  2001. });
  2002. }
  2003. });
  2004. }
  2005. function invokeOnAllFormOptions(fn) {
  2006. angular.forEach(vm.tabs, function (tab) {
  2007. if (tab.form.options && tab.form.options[fn]) {
  2008. tab.form.options[fn]();
  2009. }
  2010. });
  2011. }
  2012. function encodeCIData(data, ciId) {
  2013. /*
  2014. create/update state:未审核
  2015. create createtime:系统时间
  2016. create/update lastupdatetime : 系统时间
  2017. label:ci分类
  2018. */
  2019. if (ciId) {
  2020. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2021. var extraprop = 'props';
  2022. data[extraprop] = {};
  2023. for (var key in data) {
  2024. console.log(data[key]);
  2025. if (_.indexOf(baseprop, key) >= 0) {
  2026. continue;
  2027. } else {
  2028. data[extraprop][key] = data[key];
  2029. delete data[key];
  2030. }
  2031. }
  2032. if ($rootScope.user) {
  2033. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2034. data[extraprop]['configperson'] = $rootScope.user.name;
  2035. var isCMAdminFlag = false;
  2036. angular.forEach($rootScope.user.role, function (roleItem) {
  2037. if (roleItem.rolecode == "cmdb charge") {
  2038. isCMAdminFlag = true;
  2039. }
  2040. })
  2041. if (!isCMAdminFlag) {
  2042. data[extraprop]['state'] = '1';
  2043. }
  2044. }
  2045. if (data.props.id) {
  2046. } else {
  2047. data.label = ciId;
  2048. }
  2049. return data;
  2050. }
  2051. return undefined;
  2052. }
  2053. function decodeCIModel(data) {
  2054. var extraprop = 'props';
  2055. if (data[extraprop]) {
  2056. for (var key in data[extraprop]) {
  2057. data[key] = data[extraprop][key];
  2058. }
  2059. delete data[extraprop];
  2060. }
  2061. data['iscmadmin'] = false;
  2062. angular.forEach($rootScope.user.role, function (roleItem) {
  2063. if (roleItem.rolecode == "cmdb charge") {
  2064. data['iscmadmin'] = true;
  2065. }
  2066. })
  2067. return data;
  2068. }
  2069. function formValid() {
  2070. angular.forEach(vm.tabs, function (item) {
  2071. //item.
  2072. })
  2073. }
  2074. $scope.vm = vm;
  2075. $scope.refreshcmdbform = function (item) {
  2076. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2077. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2078. var myData = Restangular.stripRestangular(data);
  2079. $scope.propTypeOptions = myData;
  2080. $scope.templateProps = myData;
  2081. $scope.vm.tabs = myData;
  2082. if ($scope.model.assets) {
  2083. vm.models = JSON.parse($scope.model.assets);
  2084. }
  2085. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2086. if (vm.models.vtvmvtm_kaiji) {
  2087. vm.models.vtvmvtm_kaiji = "是";
  2088. } else {
  2089. vm.models.vtvmvtm_kaiji = "否";
  2090. }
  2091. }
  2092. decodeVMTabForm(vm.models, vm.tabs);
  2093. });
  2094. // }
  2095. }
  2096. var cifilterClassic = {};
  2097. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2098. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2099. $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
  2100. // } else {}
  2101. }]
  2102. });
  2103. //固定资产下载
  2104. formlyConfigProvider.setType({
  2105. name: 'ui-dropupload',
  2106. templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
  2107. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2108. defaultOptions: function (options) {
  2109. return {
  2110. templateOptions: {
  2111. view: function (APIService, contentId) {
  2112. return APIService.downloadAttachment(contentId);
  2113. },
  2114. },
  2115. };
  2116. },
  2117. controller: ['$scope', '$rootScope', 'Restangular', function ($scope, $rootScope, Restangular) {
  2118. if (angular.isUndefined($scope.form.dropState)) {
  2119. $scope.form.dropState = false;
  2120. }
  2121. var to = $scope.options.templateOptions;
  2122. var bindId = $scope.model[to.bindType].processInstanceId;
  2123. //获取附件列表
  2124. $scope.listAttachmen = function () {
  2125. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  2126. var myData = Restangular.stripRestangular(result);
  2127. // $scope.listAttachmens = myData;
  2128. $scope.attachments = myData.data;
  2129. });
  2130. };
  2131. $scope.listAttachmen();
  2132. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2133. // $scope.listAttachmen();
  2134. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2135. // $scope.listAttachmen();
  2136. // }
  2137. //附件下载
  2138. $scope.download = function (token, filename) {
  2139. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  2140. var a = document.createElement('a');
  2141. a.href = downUrl;
  2142. a.target = '_blank';
  2143. a.download = filename;
  2144. document.body.appendChild(a);
  2145. a.click();
  2146. };
  2147. //附件预览
  2148. $scope.view = function (id, previewUrl) {
  2149. if (previewUrl) {
  2150. window.open(previewUrl);
  2151. }
  2152. };
  2153. }]
  2154. });
  2155. formlyConfigProvider.setType({
  2156. name: 'ui-form',
  2157. templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
  2158. defaultOptions: function (options) {
  2159. return {
  2160. templateOptions: {
  2161. // link: function() {}
  2162. }
  2163. };
  2164. },
  2165. 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) {
  2166. $scope.langs = i18nService.getAllLangs();
  2167. $scope.lang = 'zh-cn';
  2168. i18nService.setCurrentLang($scope.lang);
  2169. var vm = this;
  2170. vm.options = {};
  2171. vm.exampleTitle = ['expressionProperties', 'model property'];
  2172. vm.fields = [];
  2173. vm.models = {};
  2174. // vm.models["loginUser"] = $rootScope.user;
  2175. var that = $injector;
  2176. var parse = $parse;
  2177. var formKey = "";
  2178. var pdKey = "";
  2179. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  2180. pdKey = $state.current.pdKey;
  2181. //console.log("pdKey::"+$state.current.pdKey);
  2182. }
  2183. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2184. formKey = $stateParams.formKey;
  2185. //console.log("formKey::"+$stateParams.formKey);
  2186. }
  2187. //用户测试数据,后续从header的auth中获取
  2188. var userId = 2;
  2189. userId = $rootScope.user.id;
  2190. //==============处理表单设计数据 开始====================
  2191. //处理组件加载后台数据选项的方法
  2192. function refreshSelectOptions(searchVal, field) {
  2193. if (field.templateOptions.optionsUrl) {
  2194. var process = BpmRestangular.all("");
  2195. if (field.templateOptions.ApiService) {
  2196. process = UserRestangular.all("");
  2197. }
  2198. process.customPOST({
  2199. "idx": 0,
  2200. "sum": 1000
  2201. }, field.templateOptions.optionsUrl).then(function (result) {
  2202. if (!field.templateOptions.options) {
  2203. field.templateOptions.options = [];
  2204. }
  2205. if (field.templateOptions.optionsDataKey) {
  2206. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  2207. } else {
  2208. field.templateOptions.options = result;
  2209. }
  2210. });
  2211. }
  2212. }
  2213. function decodeVMTabForm(model, tabs) {
  2214. var result = {
  2215. model: {},
  2216. tabs: []
  2217. };
  2218. var mdata = angular.fromJson(model);
  2219. angular.extend(result.model, mdata);
  2220. angular.forEach(tabs, function (tab) {
  2221. tab.form.model = vm.models;
  2222. angular.forEach(tab.form.fields, function (field) {
  2223. if (field.key == "") {
  2224. delete field.key;
  2225. }
  2226. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2227. var extObj = angular.fromJson(field.extjson);
  2228. angular.extend(field.templateOptions, extObj.templateOptions);
  2229. delete extObj.templateOptions;
  2230. for (var prop in extObj) {
  2231. if (new RegExp("Expression").test(prop)) {
  2232. //var obj = $scope.$eval(extObj[prop]);
  2233. //extObj[prop] = $scope.$eval(extObj[prop]);
  2234. if (extObj[prop] != null) {
  2235. if (new RegExp("function").test(extObj[prop])) {
  2236. var propValue = eval(extObj[prop]);
  2237. extObj[prop] = propValue;
  2238. } else {
  2239. //console.log(extObj[prop]);
  2240. var obj = $scope.$eval(extObj[prop]);
  2241. extObj[prop] = obj;
  2242. //console.log(obj);
  2243. }
  2244. }
  2245. } else if (new RegExp("expressionProperties").test(prop)) {
  2246. for (var p in extObj[prop]) {
  2247. if (new RegExp("function").test(extObj[prop][p])) {
  2248. var propValue = eval(extObj[prop][p]);
  2249. extObj[prop][p] = propValue;
  2250. } else {
  2251. //if(p.indexOf("'")>=0){
  2252. // var obj = $scope.$eval(extObj[prop][p]);
  2253. // extObj[prop][$scope.$eval(p)]=obj;
  2254. //}
  2255. }
  2256. }
  2257. } else if ("watcher" == prop) {
  2258. if (angular.isArray(extObj[prop])) {
  2259. angular.forEach(extObj[prop], function (item, index) {
  2260. for (var p in item) {
  2261. if (new RegExp("function").test(item[p])) {
  2262. var propValue = eval(item[p]);
  2263. extObj[prop][index][p] = propValue;
  2264. }
  2265. }
  2266. });
  2267. } else if (angular.isObject(extObj[prop])) {
  2268. for (var p in extObj[prop]) {
  2269. if (new RegExp("function").test(extObj[prop][p])) {
  2270. var propValue = eval(extObj[prop][p]);
  2271. extObj[prop][p] = propValue;
  2272. }
  2273. }
  2274. }
  2275. }
  2276. }
  2277. angular.extend(field, extObj);
  2278. delete field.extjson;
  2279. }
  2280. if (field.extjson == "") {
  2281. delete field.extjson;
  2282. }
  2283. if (angular.isDefined(field.templateOptions)) {
  2284. var templateOs = field.templateOptions;
  2285. for (var property in templateOs) {
  2286. //console.log(property);
  2287. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2288. if (new RegExp("function").test(templateOs[property])) {
  2289. var propValue = eval(templateOs[property]);
  2290. field.templateOptions[property] = propValue;
  2291. } else {
  2292. if (that.has(templateOs[property])) {
  2293. field.templateOptions[property] = that.get(templateOs[property]);
  2294. } else {
  2295. field.templateOptions[property] = templateOs[property];
  2296. }
  2297. }
  2298. } else if (templateOs[property] == null) {
  2299. //delete field.templateOptions[property];
  2300. } else { }
  2301. }
  2302. }
  2303. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2304. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2305. angular.extend(field.templateOptions, extObj);
  2306. delete field.templateOptions.extjson;
  2307. }
  2308. //...
  2309. if (field.templateOptions) {
  2310. //处理远程获取数据控件方法调用
  2311. if (field.templateOptions.optionsUrl) {
  2312. field.templateOptions.refresh = refreshSelectOptions;
  2313. }
  2314. //处理嵌套属性数据绑定/
  2315. if (field.templateOptions.pkey) {
  2316. var pmodel, i = 0;
  2317. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2318. if (i == 0) {
  2319. if (result.model[p] == null) {
  2320. result.model[p] = {};
  2321. }
  2322. pmodel = result.model[p];
  2323. i++;
  2324. } else {
  2325. if (pmodel[p] == null) {
  2326. pmodel[p] = {};
  2327. }
  2328. pmodel = pmodel[p];
  2329. }
  2330. });
  2331. if (pmodel != null) {
  2332. field.model = pmodel;
  2333. if (pmodel[field.key] == null) {
  2334. pmodel[field.key] = null;
  2335. }
  2336. }
  2337. } else {
  2338. if (result.model[field.key] == null) {
  2339. result.model[field.key] = null;
  2340. }
  2341. }
  2342. //处理弹出框组件初始化
  2343. if (field.type == "ui-input-selectmodal") {
  2344. field.templateOptions.modal = $modal;
  2345. //field.templateOptions.Restangular = Restangular;
  2346. } else if (field.type == "ui-userselect") {
  2347. field.templateOptions.modal = $modal;
  2348. //field.templateOptions.Restangular = Restangular;
  2349. } else if (field.type == "ui-multiuserselect") {
  2350. field.templateOptions.modal = $modal;
  2351. } else if (field.type == "ui-modelselect") {
  2352. field.templateOptions.modal = $modal;
  2353. //field.templateOptions.Restangular = Restangular;
  2354. } else if (field.type == "ui-dropfile") {
  2355. field.templateOptions.fileUploader = new FileUploader({
  2356. url: '/uploader'
  2357. });
  2358. field.templateOptions.taskId = $stateParams.taskId;
  2359. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2360. field.templateOptions.userId = $rootScope.user.id;
  2361. //field.ApiService=api_bpm_domain;
  2362. // }else if (field.type == "ui-uploadFile") {
  2363. // field.templateOptions.fileUploader = new FileUploader({
  2364. // url: '/uploader'
  2365. // });
  2366. // field.templateOptions.taskId = $stateParams.taskId;
  2367. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2368. // field.templateOptions.userId = $rootScope.user.id;
  2369. //field.ApiService=api_bpm_domain;
  2370. } else if (field.type == "ui-dropfiletable") {
  2371. if (field.templateOptions.processInstanceId) {
  2372. } else {
  2373. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2374. }
  2375. } else if (field.type == "ui-dropFiles") {
  2376. if (field.templateOptions.processInstanceId) {
  2377. } else {
  2378. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2379. }
  2380. } else if (field.type == "ui-showImgs") {
  2381. if (field.templateOptions.processInstanceId) {
  2382. } else {
  2383. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2384. }
  2385. } else if (field.type == "ui-repeatSection") {
  2386. var repeatForm = {
  2387. model: {
  2388. },
  2389. fields: field.templateOptions.fields
  2390. };
  2391. repeatForm.model[field.key] = [];
  2392. decodeVMTabForm(repeatForm);
  2393. }
  2394. }
  2395. // console.log(field);
  2396. //field
  2397. //result.fields.push(field);
  2398. })
  2399. });
  2400. vm.originalTabs = angular.copy(vm.form);
  2401. }
  2402. //解析自定义表单设计数据
  2403. function decodeVMForm(vmForm) {
  2404. var result = {
  2405. model: {},
  2406. tabs: []
  2407. };
  2408. //设置模型实体数据 begin
  2409. // var mdata = vmForm.model;
  2410. //解析数据实体
  2411. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2412. angular.extend(result.model, mdata);
  2413. //设置模型实体数据 end
  2414. //解析设计数据生成表单项 begin
  2415. var fields = [];
  2416. //处理修改设计数据中展示设置
  2417. angular.forEach(vmForm.tabs, function (field) {
  2418. if (field.key == "") {
  2419. delete field.key;
  2420. }
  2421. if (angular.isDefined(field.extjson)) {
  2422. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2423. angular.extend(field.templateOptions, extObj.templateOptions);
  2424. delete extObj.templateOptions;
  2425. for (var prop in extObj) {
  2426. if (new RegExp("Expression").test(prop)) {
  2427. //var obj = $scope.$eval(extObj[prop]);
  2428. //extObj[prop] = $scope.$eval(extObj[prop]);
  2429. if (extObj[prop] != null) {
  2430. if (new RegExp("function").test(extObj[prop])) {
  2431. var propValue = eval(extObj[prop]);
  2432. extObj[prop] = propValue;
  2433. } else {
  2434. //console.log(extObj[prop]);
  2435. var obj = $scope.$eval(extObj[prop]);
  2436. extObj[prop] = obj;
  2437. //console.log(obj);
  2438. }
  2439. }
  2440. } else if (new RegExp("expressionProperties").test(prop)) {
  2441. for (var p in extObj[prop]) {
  2442. if (new RegExp("function").test(extObj[prop][p])) {
  2443. var propValue = eval(extObj[prop][p]);
  2444. extObj[prop][p] = propValue;
  2445. } else {
  2446. //if(p.indexOf("'")>=0){
  2447. // var obj = $scope.$eval(extObj[prop][p]);
  2448. // extObj[prop][$scope.$eval(p)]=obj;
  2449. //}
  2450. }
  2451. }
  2452. } else if ("watcher" == prop) {
  2453. if (angular.isArray(extObj[prop])) {
  2454. angular.forEach(extObj[prop], function (item, index) {
  2455. for (var p in item) {
  2456. if (new RegExp("function").test(item[p])) {
  2457. var propValue = eval(item[p]);
  2458. extObj[prop][index][p] = propValue;
  2459. }
  2460. }
  2461. });
  2462. } else if (angular.isObject(extObj[prop])) {
  2463. for (var p in extObj[prop]) {
  2464. if (new RegExp("function").test(extObj[prop][p])) {
  2465. var propValue = eval(extObj[prop][p]);
  2466. extObj[prop][p] = propValue;
  2467. }
  2468. }
  2469. }
  2470. }
  2471. }
  2472. angular.extend(field, extObj);
  2473. delete field.extjson;
  2474. }
  2475. if (angular.isDefined(field.templateOptions)) {
  2476. var templateOs = field.templateOptions;
  2477. for (var property in templateOs) {
  2478. //console.log(property);
  2479. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2480. if (new RegExp("function").test(templateOs[property])) {
  2481. var propValue = eval(templateOs[property]);
  2482. field.templateOptions[property] = propValue;
  2483. } else {
  2484. if (that.has(templateOs[property])) {
  2485. field.templateOptions[property] = that.get(templateOs[property]);
  2486. } else {
  2487. field.templateOptions[property] = templateOs[property];
  2488. }
  2489. }
  2490. } else if (templateOs[property] == null) {
  2491. //delete field.templateOptions[property];
  2492. } else { }
  2493. }
  2494. }
  2495. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2496. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2497. angular.extend(field.templateOptions, extObj);
  2498. delete field.templateOptions.extjson;
  2499. }
  2500. //...
  2501. if (field.templateOptions) {
  2502. //处理远程获取数据控件方法调用
  2503. if (field.templateOptions.optionsUrl) {
  2504. field.templateOptions.refresh = refreshSelectOptions;
  2505. }
  2506. //处理嵌套属性数据绑定/
  2507. if (field.templateOptions.pkey) {
  2508. var pmodel, i = 0;
  2509. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2510. if (i == 0) {
  2511. if (result.model[p] == null) {
  2512. result.model[p] = {};
  2513. }
  2514. pmodel = result.model[p];
  2515. i++;
  2516. } else {
  2517. if (pmodel[p] == null) {
  2518. pmodel[p] = {};
  2519. }
  2520. pmodel = pmodel[p];
  2521. }
  2522. });
  2523. if (pmodel != null) {
  2524. field.model = pmodel;
  2525. if (pmodel[field.key] == null) {
  2526. pmodel[field.key] = null;
  2527. }
  2528. }
  2529. } else {
  2530. if (result.model[field.key] == null) {
  2531. result.model[field.key] = null;
  2532. }
  2533. }
  2534. //处理弹出框组件初始化
  2535. if (field.type == "ui-input-selectmodal") {
  2536. field.templateOptions.modal = $modal;
  2537. //field.templateOptions.Restangular = Restangular;
  2538. } else if (field.type == "ui-userselect") {
  2539. field.templateOptions.modal = $modal;
  2540. //field.templateOptions.Restangular = Restangular;
  2541. } else if (field.type == "ui-multiuserselect") {
  2542. field.templateOptions.modal = $modal;
  2543. } else if (field.type == "ui-modelselect") {
  2544. field.templateOptions.modal = $modal;
  2545. //field.templateOptions.Restangular = Restangular;
  2546. } else if (field.type == "ui-dropfile") {
  2547. field.templateOptions.fileUploader = new FileUploader({
  2548. url: '/uploader'
  2549. });
  2550. field.templateOptions.taskId = $stateParams.taskId;
  2551. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2552. field.templateOptions.userId = $rootScope.user.id;
  2553. //field.ApiService=api_bpm_domain;
  2554. } else if (field.type == "ui-dropfiletable") {
  2555. if (field.templateOptions.processInstanceId) {
  2556. } else {
  2557. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2558. }
  2559. } else if (field.type == "ui-dropFiles") {
  2560. if (field.templateOptions.processInstanceId) {
  2561. } else {
  2562. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2563. }
  2564. } else if (field.type == "ui-showImgs") {
  2565. if (field.templateOptions.processInstanceId) {
  2566. } else {
  2567. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2568. }
  2569. } else if (field.type == "ui-repeatSection") {
  2570. var repeatForm = {
  2571. model: {
  2572. },
  2573. fields: field.templateOptions.fields
  2574. };
  2575. repeatForm.model[field.key] = [];
  2576. decodeVMForm(repeatForm);
  2577. }
  2578. }
  2579. // console.log(field);
  2580. result.fields.push(field);
  2581. });
  2582. angular.extend($scope.vm.fields, result.fields);
  2583. angular.extend($scope.vm.models, result.model);
  2584. $scope.formData = vmForm;
  2585. //console.log($scope.vm);
  2586. //解析设计数据生成表单项 end
  2587. return result;
  2588. }
  2589. //======================处理表单设计数据 结束========================
  2590. $scope.ldloading = {};
  2591. function filter(obj) {
  2592. angular.forEach(obj, function (key, value) {
  2593. if (value === "" || value === null) {
  2594. delete obj[key];
  2595. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  2596. filter(value);
  2597. } else if (angular.isArray(value)) {
  2598. angular.forEach(value, function (item) {
  2599. filter(item);
  2600. });
  2601. }
  2602. });
  2603. }
  2604. function invokeOnAllFormOptions(fn) {
  2605. angular.forEach(vm.tabs, function (tab) {
  2606. if (tab.form.options && tab.form.options[fn]) {
  2607. tab.form.options[fn]();
  2608. }
  2609. });
  2610. }
  2611. function encodeCIData(data, ciId) {
  2612. /*
  2613. create/update state:未审核
  2614. create createtime:系统时间
  2615. create/update lastupdatetime : 系统时间
  2616. label:ci分类
  2617. */
  2618. if (ciId) {
  2619. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2620. var extraprop = 'props';
  2621. data[extraprop] = {};
  2622. for (var key in data) {
  2623. console.log(data[key]);
  2624. if (_.indexOf(baseprop, key) >= 0) {
  2625. continue;
  2626. } else {
  2627. data[extraprop][key] = data[key];
  2628. delete data[key];
  2629. }
  2630. }
  2631. if ($rootScope.user) {
  2632. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2633. data[extraprop]['configperson'] = $rootScope.user.name;
  2634. var isCMAdminFlag = false;
  2635. angular.forEach($rootScope.user.role, function (roleItem) {
  2636. if (roleItem.rolecode == "cmdb charge") {
  2637. isCMAdminFlag = true;
  2638. }
  2639. })
  2640. if (!isCMAdminFlag) {
  2641. data[extraprop]['state'] = '1';
  2642. }
  2643. }
  2644. if (data.props.id) {
  2645. } else {
  2646. data.label = ciId;
  2647. }
  2648. return data;
  2649. }
  2650. return undefined;
  2651. }
  2652. function decodeCIModel(data) {
  2653. var extraprop = 'props';
  2654. if (data[extraprop]) {
  2655. for (var key in data[extraprop]) {
  2656. data[key] = data[extraprop][key];
  2657. }
  2658. delete data[extraprop];
  2659. }
  2660. data['iscmadmin'] = false;
  2661. angular.forEach($rootScope.user.role, function (roleItem) {
  2662. if (roleItem.rolecode == "cmdb charge") {
  2663. data['iscmadmin'] = true;
  2664. }
  2665. })
  2666. return data;
  2667. }
  2668. vm.remove = function (data, style) {
  2669. $scope.ldloading[style.replace('-', '_')] = true;
  2670. var modalInstance = $modal.open({
  2671. templateUrl: 'assets/views/delete.html',
  2672. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  2673. var cidata = {
  2674. label: data.label,
  2675. id: data.id,
  2676. uuid: data.uuid,
  2677. name: data.name,
  2678. props: {}
  2679. };
  2680. if (cidata.id) {
  2681. cidata.props['removeflag'] = true;
  2682. cidata.props['lastupdateperson'] = vm.models.loginUser;
  2683. $scope.ok = function () {
  2684. $modalInstance.close(cidata);
  2685. };
  2686. $scope.cancel = function () {
  2687. $modalInstance.dismiss('cancel');
  2688. };
  2689. }
  2690. },
  2691. size: 'sm',
  2692. resolve: {
  2693. scope: function () {
  2694. return $scope;
  2695. }
  2696. }
  2697. });
  2698. modalInstance.result.then(function (selectedItem) {
  2699. if (selectedItem) {
  2700. // if (selectedItem.length > 0) {
  2701. api_cmdb.put(selectedItem, selectedItem.id).then(function (response) {
  2702. if (response) {
  2703. var resData = Restangular.stripRestangular(response);
  2704. SweetAlert.swal({
  2705. title: "删除成功!",
  2706. confirmButtonColor: "#007AFF"
  2707. }, function () {
  2708. $state.go("app.means.list");
  2709. // $scope.refreshform();
  2710. // reinitTabForm($scope.classify);
  2711. });
  2712. } else {
  2713. SweetAlert.swal({
  2714. title: "系统错误",
  2715. text: "系统错误,请稍后重试!",
  2716. type: "error",
  2717. confirmButtonColor: "#DD6B55"
  2718. });
  2719. }
  2720. $scope.ldloading[style.replace('-', '_')] = false;
  2721. });
  2722. }
  2723. })
  2724. }
  2725. function formValid() {
  2726. angular.forEach(vm.tabs, function (item) {
  2727. //item.
  2728. })
  2729. }
  2730. $scope.closeModel = function () {
  2731. console.log($stateParams);
  2732. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2733. if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
  2734. $state.go('app.means.list', {});
  2735. }
  2736. event.preventDefault();
  2737. }
  2738. }
  2739. // setInterval(function() {
  2740. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  2741. // cifilter_classic = $scope.model.cifilter_classic;
  2742. // $scope.refreshcmdbform(cifilter_classic);
  2743. // } else {}
  2744. // }, 100);
  2745. vm.models = (function filter(obj) {
  2746. var filtered = _.pick(obj, function (v) {
  2747. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2748. });
  2749. return _.cloneDeep(filtered, function (v) {
  2750. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2751. });
  2752. })(vm.models);
  2753. // setInterval(function() {
  2754. // if ($scope.model.type == 0) {
  2755. // $scope.model[$scope.options.key] = vm.models;
  2756. // }
  2757. // }, 100);
  2758. setInterval(function () {
  2759. if (vm.form && vm.form.$$parentForm.$valid) {
  2760. if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
  2761. vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2762. $scope.model[$scope.options.key] = vm.models;
  2763. }
  2764. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2765. // $scope.model[$scope.options.key] = vm.models;
  2766. }
  2767. }, 100);
  2768. vm.submit = function (data, ciId, templateitem, style) {
  2769. // $scope.ldloading[style.replace('-', '_')] = true;
  2770. console.log(vm.form.$$parentForm.$valid);
  2771. if (vm.form.$$parentForm.$valid) {
  2772. invokeOnAllFormOptions('updateInitialValue');
  2773. //alert(JSON.stringify(vm.model), null, 2);
  2774. //vm.options.updateInitialValue();
  2775. //console.log(vm.model);
  2776. var cidata = encodeCIData(vm.models, ciId);
  2777. if (cidata) {
  2778. //var cidata = ;
  2779. if (cidata.props.id) {
  2780. //修改
  2781. api_cmdb.put(cidata, ciId).then(function (response) {
  2782. if (response) {
  2783. var resData = Restangular.stripRestangular(response);
  2784. SweetAlert.swal({
  2785. title: "保存成功!",
  2786. confirmButtonColor: "#007AFF"
  2787. }, function () {
  2788. $scope.ldloading[style.replace('-', '_')] = false;
  2789. // $scope.refreshform();
  2790. $state.go("app.means.list");
  2791. });
  2792. } else {
  2793. SweetAlert.swal({
  2794. title: "系统错误",
  2795. text: "系统错误,请稍后重试!",
  2796. type: "error",
  2797. confirmButtonColor: "#DD6B55"
  2798. });
  2799. }
  2800. $scope.ldloading[style.replace('-', '_')] = false;
  2801. });
  2802. } else {
  2803. //新建
  2804. var type = 2;
  2805. api_sysinfo.getSerialnumber(type, templateitem.id).then(function (data) {
  2806. if (data && data.status == 200) {
  2807. cidata.uuid = data.uuid;
  2808. api_cmdb.create(cidata).then(function (response) {
  2809. if (response) {
  2810. var resData = Restangular.stripRestangular(response);
  2811. SweetAlert.swal({
  2812. title: "保存成功!",
  2813. text: "内部编号:" + cidata.uuid,
  2814. confirmButtonColor: "#007AFF"
  2815. }, function () {
  2816. $state.go("app.means.list");
  2817. });
  2818. // if(resData.status){
  2819. // resData
  2820. // }
  2821. } else {
  2822. SweetAlert.swal({
  2823. title: "系统错误",
  2824. text: "系统错误,请稍后重试!",
  2825. type: "error",
  2826. confirmButtonColor: "#DD6B55"
  2827. });
  2828. }
  2829. $scope.ldloading[style.replace('-', '_')] = false;
  2830. });
  2831. } else {
  2832. SweetAlert.swal({
  2833. title: "系统错误",
  2834. text: "内部编号生成出错!",
  2835. type: "error",
  2836. confirmButtonColor: "#DD6B55"
  2837. });
  2838. }
  2839. })
  2840. }
  2841. } else {
  2842. SweetAlert.swal({
  2843. title: "错误",
  2844. text: "错误,请选择资产分类!",
  2845. type: "error",
  2846. confirmButtonColor: "#DD6B55"
  2847. });
  2848. }
  2849. //alert(JSON.stringify(cidata), null, 2);
  2850. $scope.ldloading[style.replace('-', '_')] = true;
  2851. return;
  2852. var _ = window._;
  2853. vm.models = (function filter(obj) {
  2854. var filtered = _.pick(obj, function (v) {
  2855. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2856. });
  2857. return _.cloneDeep(filtered, function (v) {
  2858. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2859. });
  2860. })(vm.models);
  2861. } else {
  2862. if (vm.form.$$parentForm.$error) {
  2863. SweetAlert.swal({
  2864. title: "校验错误",
  2865. text: "请填写必填项!",
  2866. type: "error",
  2867. confirmButtonColor: "#DD6B55"
  2868. });
  2869. angular.forEach(vm.form.$$parentForm.$error.required, function (item) {
  2870. angular.forEach(vm.tabs, function (tab) {
  2871. angular.forEach(tab.form.fields, function (f) {
  2872. if (f.name == item.$name) {
  2873. f.validation.show = true;
  2874. tab.active = true;
  2875. }
  2876. })
  2877. })
  2878. });
  2879. $scope.ldloading[style.replace('-', '_')] = false;
  2880. }
  2881. }
  2882. };
  2883. $scope.vm = vm;
  2884. $scope.refreshcmdbform = function (item) {
  2885. // if ($stateParams.model) {
  2886. // var modeldata = JSON.parse($stateParams.model)
  2887. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2888. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2889. var myData = Restangular.stripRestangular(data);
  2890. $scope.propTypeOptions = myData;
  2891. $scope.templateProps = myData;
  2892. $scope.vm.tabs = myData;
  2893. if ($scope.model.asset && $scope.model.asset.length != "") {
  2894. vm.models = JSON.parse($scope.model.asset);
  2895. }
  2896. decodeVMTabForm(vm.models, vm.tabs);
  2897. });
  2898. // }
  2899. }
  2900. var cifilterClassic = {};
  2901. setInterval(function () {
  2902. 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) {
  2903. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  2904. cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2905. $scope.refreshcmdbform(cifilterClassic);
  2906. } else { }
  2907. }, 100);
  2908. }]
  2909. });
  2910. //请求人信息
  2911. formlyConfigProvider.setType({
  2912. name: 'ui-cmdbinformation',
  2913. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
  2914. wrapper: ['bootstrapHasError'],
  2915. defaultOptions: function (options, $scope) {
  2916. return {
  2917. templateOptions: {
  2918. // checkform: function(options) {
  2919. // if (options.model.requester) {
  2920. // options.value(options.model.requester);
  2921. // }
  2922. // },
  2923. }
  2924. };
  2925. },
  2926. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2927. if ($scope.options.templateOptions.loginUser) {
  2928. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
  2929. } else {
  2930. $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
  2931. }
  2932. $scope.options.initialValue = $scope.model[$scope.options.key];
  2933. }
  2934. }]
  2935. });
  2936. //资产属性
  2937. formlyConfigProvider.setType({
  2938. name: 'ui-cmdbtype',
  2939. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
  2940. wrapper: ['bootstrapHasError'],
  2941. defaultOptions: function (options, $scope) {
  2942. return {
  2943. templateOptions: {
  2944. // checkform: function(options) {
  2945. // if (options.model.requester) {
  2946. // options.value(options.model.requester);
  2947. // }
  2948. // },
  2949. }
  2950. };
  2951. },
  2952. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2953. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2954. $scope.property = {
  2955. 'hw_change': $scope.to.loginUser,
  2956. 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
  2957. 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
  2958. }
  2959. if ($scope.$parent.$parent.$parent.model.assets) {
  2960. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  2961. }
  2962. }]
  2963. });
  2964. //申请单信息
  2965. formlyConfigProvider.setType({
  2966. name: 'ui-cmdbformimform',
  2967. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
  2968. wrapper: ['bootstrapHasError'],
  2969. defaultOptions: function (options, $scope) {
  2970. return {
  2971. templateOptions: {
  2972. // checkform: function(options) {
  2973. // if (options.model.requester) {
  2974. // options.value(options.model.requester);
  2975. // }
  2976. // },
  2977. }
  2978. };
  2979. },
  2980. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2981. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2982. $scope.getininform = {
  2983. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2984. time: $scope.$parent.$parent.$parent.model.applicationForm.time
  2985. };
  2986. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  2987. $scope.getininform.types = "新资产入库";
  2988. } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
  2989. $scope.getininform.types = "资产归还";
  2990. }
  2991. }]
  2992. });
  2993. //出库单信息
  2994. formlyConfigProvider.setType({
  2995. name: 'ui-outinformation',
  2996. templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
  2997. wrapper: ['bootstrapHasError'],
  2998. defaultOptions: function (options, $scope) {
  2999. return {
  3000. templateOptions: {
  3001. // checkform: function(options) {
  3002. // if (options.model.requester) {
  3003. // options.value(options.model.requester);
  3004. // }
  3005. // },
  3006. }
  3007. };
  3008. },
  3009. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  3010. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3011. $scope.getininform = {
  3012. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3013. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3014. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3015. sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3016. describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
  3017. };
  3018. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3019. $scope.getininform.types = "新设备领用出库";
  3020. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3021. $scope.getininform.types = "设备更换";
  3022. }
  3023. $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.value;
  3024. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3025. $scope.getininform.source = "事件";
  3026. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3027. $scope.getininform.source = "变更";
  3028. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3029. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3030. $scope.getininform.source = "其它";
  3031. }
  3032. }]
  3033. });
  3034. //资产附件上传
  3035. formlyConfigProvider.setType({
  3036. name: 'ui-cmdbuplode',
  3037. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
  3038. wrapper: ['bootstrapHasError'],
  3039. defaultOptions: function (options, $scope) {
  3040. return {
  3041. templateOptions: {
  3042. // checkform: function(options) {
  3043. // if (options.model.requester) {
  3044. // options.value(options.model.requester);
  3045. // }
  3046. // },
  3047. }
  3048. };
  3049. },
  3050. 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) {
  3051. $scope.state = 1;
  3052. $scope.myData3all = [];
  3053. $scope.myData3 = [];
  3054. $scope.memoryfilterDatahao = {
  3055. "idx": 0,
  3056. "sum": 10,
  3057. }
  3058. $scope.selected = {
  3059. items: []
  3060. };
  3061. $scope.interceptMydata = function (mydate, idx, sum) {
  3062. return mydate.slice(idx * sum, (idx + 1) * sum)
  3063. }
  3064. // $scope.importnext = function() {
  3065. // $scope.state = 2;
  3066. // event.preventDefault();
  3067. // }
  3068. $scope.workspaces = [];
  3069. $scope.options.templateOptions.getpush = function (item) {
  3070. $scope.workspaces = [];
  3071. if (item.gu) {
  3072. $scope.workspaces.push({
  3073. id: 1,
  3074. name: "固定资产",
  3075. active: true,
  3076. contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html'
  3077. })
  3078. }
  3079. if (item.hao) {
  3080. $scope.workspaces.push({
  3081. id: 2,
  3082. name: "耗材资产",
  3083. active: true,
  3084. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  3085. })
  3086. }
  3087. };
  3088. //获取附件列表
  3089. $scope.listAttachmen = function () {
  3090. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  3091. var myData = Restangular.stripRestangular(result);
  3092. // $scope.listAttachmens = myData;
  3093. $scope.attachments = myData.data;
  3094. });
  3095. };
  3096. //附件列表
  3097. if ($scope.options.templateOptions.bindType) {
  3098. if (angular.isUndefined($scope.form.dropState)) {
  3099. $scope.form.dropState = false;
  3100. }
  3101. var to = $scope.options.templateOptions;
  3102. var bindId = $scope.model[to.bindType].processInstanceId;
  3103. $scope.listAttachmen();
  3104. }
  3105. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3106. // $scope.listAttachmen();
  3107. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3108. // $scope.listAttachmen();
  3109. // }
  3110. //附件下载
  3111. $scope.download = function (token, filename) {
  3112. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  3113. // window.open(downUrl);
  3114. var a = document.createElement('a');
  3115. a.href = downUrl;
  3116. a.target = '_blank';
  3117. a.download = filename;
  3118. document.body.appendChild(a);
  3119. a.click();
  3120. };
  3121. //附件预览
  3122. $scope.view = function (id, previewUrl) {
  3123. if (previewUrl) {
  3124. window.open(previewUrl);
  3125. }
  3126. };
  3127. //下载资产模版
  3128. $scope.filenum = 0;
  3129. $scope.openmeans = function () {
  3130. var modalInstance = $modal.open({
  3131. templateUrl: 'assets/views/means/tpl/meansdown.html',
  3132. controller: function ($scope, scope, $modalInstance) {
  3133. $scope.item = {};
  3134. $scope.title = "选择下载模版";
  3135. $scope.lable = "资产模版下载";
  3136. function foreachdata(my_datas) {
  3137. // angular.forEach(my_datas, function(item, index) {
  3138. // if (item.children && item.children.length > 0) {
  3139. // foreachdata(item.children);
  3140. // } else {
  3141. // my_datas[index].checks = true;
  3142. // }
  3143. // })
  3144. for (var i = 0; i < my_datas.length; i++) {
  3145. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3146. foreachdata(my_datas[i].children);
  3147. console.log($scope);
  3148. } else {
  3149. my_datas[i].checks = true;
  3150. }
  3151. }
  3152. }
  3153. function foreachtree(data) {
  3154. angular.forEach(data, function (item) {
  3155. // if (item.checks != true) {
  3156. item.checks = true;
  3157. item.expanded = true;
  3158. if (item.children && item.children.length > 0) {
  3159. foreachtree(item.children)
  3160. } else {
  3161. $scope.getslowtree.push(item)
  3162. }
  3163. // }
  3164. })
  3165. }
  3166. $scope.getslowtree = [];
  3167. $scope.slowtree = function (tree) {
  3168. foreachtree(tree)
  3169. return $scope.getslowtree
  3170. }
  3171. $scope.all = function (c, v) { //全选
  3172. if (c == true) {
  3173. $scope.formdashboard($scope.slowtree(v));
  3174. } else {
  3175. $scope.my_data_after = [];
  3176. angular.forEach($scope.my_data, function (item, index) {
  3177. $scope.my_data[index].checks = false;
  3178. $scope.my_data[index].expanded = false;
  3179. if (item.children && item.children.length > 0) {
  3180. angular.forEach(item.children, function (itemone, indexone) {
  3181. $scope.my_data[index].children[indexone].checks = false;
  3182. $scope.my_data[index].children[indexone].expanded = false;
  3183. if (itemone.children && itemone.children.length > 0) {
  3184. angular.forEach(itemone.children, function (itemtwo, indextwo) {
  3185. $scope.my_data[index].children[indexone].children[indextwo].checks = false;
  3186. })
  3187. } else { }
  3188. })
  3189. } else { }
  3190. })
  3191. $scope.mydatacate = [];
  3192. $scope.getslowtree = [];
  3193. // }
  3194. }
  3195. };
  3196. // $scope.searchone = function(search) {
  3197. // angular.forEach($scope.my_data, function(item) {
  3198. // if (item.indexOf(search) > 0) {
  3199. // }
  3200. // })
  3201. // }
  3202. $scope.checkall = function () {
  3203. angular.forEach($scope.my_data, function (item, index) {
  3204. scope.my_data[index].checks = true;
  3205. })
  3206. }
  3207. $scope.selectitem = [];
  3208. $scope.choiceitem = function (item) {
  3209. // if (item.checkeds) {
  3210. // item.checkeds = false;
  3211. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3212. // // if ($scope.selectitem[i].id == item.id) {
  3213. // // $scope.selectitem.splice(i, 1)
  3214. // // }
  3215. // // }
  3216. // for (var i = 0; i < $scope.my_data_after; i++) {
  3217. // if ($scope.my_data_after[i].id == item.id) {
  3218. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3219. // // $scope.selectitem.splice(i, 1)
  3220. // }
  3221. // }
  3222. // } else {
  3223. // item.checkeds = true;
  3224. // $scope.selectitem.push(item)
  3225. // }
  3226. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3227. if ($scope.my_data_after[i].id == item.id) {
  3228. $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3229. }
  3230. }
  3231. }
  3232. $scope.remove = function (removeitem) {
  3233. var realdat = angular.copy($scope.my_data_after)
  3234. // angular.extend(realdat, $scope.selectitem);
  3235. $scope.my_data_after = [];
  3236. angular.forEach(realdat, function (item) {
  3237. if (!item.checkeds) {
  3238. $scope.my_data_after.push(item)
  3239. }
  3240. })
  3241. $scope.mydatacate = angular.copy($scope.my_data_after);
  3242. }
  3243. $scope.try_async_loads = function (item, search) {
  3244. var fildatas = {
  3245. 'idx': 0,
  3246. 'sum': 1000
  3247. };
  3248. $scope.my_data = [];
  3249. // $scope.try_async_load = true;
  3250. if (item) {
  3251. angular.extend(fildatas, item)
  3252. }
  3253. api_configure_data.fetchDataList('ciclassify', fildatas).then(function (response) {
  3254. if (response.status == 200) {
  3255. var data = response.list;
  3256. var objects = [];
  3257. for (var i = 0; i < data.length; i++) {
  3258. var object = {};
  3259. object.id = data[i].id;
  3260. if (search) {
  3261. delete data[i].parent
  3262. } else {
  3263. if (data[i].parent && data[i].parent.id != 0) {
  3264. object.parent = data[i].parent.id;
  3265. }
  3266. }
  3267. angular.extend(object, data[i]);
  3268. objects.push(object);
  3269. }
  3270. $scope.my_data = convertParentToChildList(objects);
  3271. $scope.tree_data = angular.copy($scope.my_data);
  3272. if ($scope.my_data.length > 0) {
  3273. $scope.try_async_load = false;
  3274. }
  3275. } else {
  3276. SweetAlert.swal({
  3277. title: "系统错误!",
  3278. text: "请刷新重试!",
  3279. type: "error"
  3280. });
  3281. }
  3282. });
  3283. };
  3284. function convertListToTree(data, treeMap) {
  3285. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3286. var root = null; //Initially set our loop to null
  3287. //loop over data
  3288. for (var i = 0; i < data.length; i++) {
  3289. var datum = data[i];
  3290. //each node will have children, so let's give it a "children" poperty
  3291. datum.children = [];
  3292. //add an entry for this node to the map so that any future children can
  3293. //lookup the parent
  3294. idToNodeMap[datum.id] = datum;
  3295. //Does this node have a parent?
  3296. // console.log("datum="+JSON.stringify(datum))
  3297. if (typeof datum.parent === "undefined" || datum.parent === null) {
  3298. //Doesn't look like it, so this node is the root of the tree
  3299. root = datum;
  3300. treeMap[datum.id] = root;
  3301. } else {
  3302. //This node has a parent, so let's look it up using the id
  3303. parentNode = idToNodeMap[datum.parent.id];
  3304. //We don't need this property, so let's delete it.
  3305. // delete datum.parent;
  3306. //Let's add the current node as a child of the parent node.
  3307. parentNode.children.push(datum);
  3308. }
  3309. }
  3310. return root;
  3311. }
  3312. function convertParentToChildList(data) {
  3313. var treeMap = {};
  3314. var list = [];
  3315. convertListToTree(data, treeMap);
  3316. angular.forEach(treeMap, function (item) {
  3317. list.push(item);
  3318. });
  3319. return list;
  3320. }
  3321. function convertParentToChild(datato) {
  3322. var treeMapto = {};
  3323. var listto = [];
  3324. convertListToTree(datato, treeMapto);
  3325. angular.forEach(treeMapto, function (items) {
  3326. listto.push(items);
  3327. });
  3328. return listto;
  3329. }
  3330. $scope.try_async_loads();
  3331. $scope.searchdown = function (key) {
  3332. if (key && key != '') {
  3333. $scope.try_async_loads({
  3334. 'ciclassify': {
  3335. "label": key
  3336. }
  3337. }, 'search')
  3338. } else {
  3339. $scope.try_async_loads()
  3340. }
  3341. // var mydatacatedown = angular.copy($scope.my_data);
  3342. // $scope.my_data = [];
  3343. // var objects = [];
  3344. // angular.forEach(mydatacatedown, function(item) {
  3345. // if (item.label.match(key)) {
  3346. // objects.push(item)
  3347. // } else {
  3348. // // $scope.my_data_after.push(item)
  3349. // }
  3350. // })
  3351. // $scope.my_data = convertParentToChildList(objects);
  3352. // $scope.tree_data = angular.copy($scope.my_data);
  3353. }
  3354. $scope.mydatacate = [];
  3355. $scope.searchup = function (key) {
  3356. // var mydatacate = angular.copy($scope.my_data_after);
  3357. $scope.my_data_after = [];
  3358. angular.forEach($scope.mydatacate, function (item) {
  3359. if (item.label.match(key)) {
  3360. $scope.my_data_after.push(item)
  3361. } else { }
  3362. })
  3363. }
  3364. //角色树
  3365. $scope.my_tree = [];
  3366. $scope.tree_data_after = [];
  3367. $scope.my_data = [];
  3368. $scope.my_data_after = [];
  3369. $scope.formdashboard = function (item) {
  3370. $scope.my_data_after = [];
  3371. angular.forEach(item, function (infox) {
  3372. if (infox.children.length == 0) {
  3373. $scope.my_data_after.push(infox);
  3374. }
  3375. })
  3376. $scope.mydatacate = angular.copy($scope.my_data_after);
  3377. }
  3378. $scope.ok = function (item) {
  3379. $modalInstance.close(item);
  3380. };
  3381. $scope.cancel = function () {
  3382. $modalInstance.dismiss('cancel');
  3383. };
  3384. },
  3385. // size: 'sm',
  3386. resolve: {
  3387. scope: function () {
  3388. return $scope;
  3389. }
  3390. }
  3391. });
  3392. modalInstance.result.then(function (selectedItem) {
  3393. // $rootScope.isMask = true;
  3394. if (selectedItem) {
  3395. var type = 1;
  3396. var fildat = {
  3397. 'configure': selectedItem
  3398. };
  3399. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  3400. // // if (data.errno == 0) {
  3401. // var file = new Blob([data], {
  3402. // // 'Accept': '*/*'
  3403. // type: 'application/octet-stream'
  3404. // // type: 'application/vnd.ms-excel'
  3405. // });
  3406. // //trick to download store a file having its URL
  3407. // var fileURL = URL.createObjectURL(file);
  3408. // var a = document.createElement('a');
  3409. // a.href = fileURL;
  3410. // a.target = '_blank';
  3411. // a.download = "资产导入模版.xlsx";
  3412. // document.body.appendChild(a);
  3413. // a.click();
  3414. // // }
  3415. // })
  3416. $http({
  3417. url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
  3418. method: 'POST',
  3419. data: JSON.stringify(fildat),
  3420. headers: {
  3421. // 'Content-type': 'application/xls',
  3422. 'Accept': '*/*'
  3423. },
  3424. responseType: 'arraybuffer'
  3425. }).success(function (data, status, headers, config) {
  3426. $rootScope.isMask = false;
  3427. var file = new Blob([data], {
  3428. type: 'application/octet-stream'
  3429. // type : 'application/vnd.ms-excel'
  3430. });
  3431. //trick to download store a file having its URL
  3432. var fileURL = URL.createObjectURL(file);
  3433. var a = document.createElement('a');
  3434. a.href = fileURL;
  3435. a.target = '_blank';
  3436. a.download = "资产导入模版.xlsx";
  3437. document.body.appendChild(a);
  3438. a.click();
  3439. }).error(function (data, status, headers, config) {
  3440. // console.log(data);
  3441. $rootScope.isMask = false;
  3442. });
  3443. // break;
  3444. // }
  3445. // }
  3446. // }
  3447. // })
  3448. } else {
  3449. SweetAlert.swal({
  3450. title: "未选择资产分类!",
  3451. text: "请选择资产分类",
  3452. type: "error"
  3453. }, function () {
  3454. $rootScope.isMask = false;
  3455. });
  3456. }
  3457. // }
  3458. });
  3459. }
  3460. $scope.wrongdata = [];
  3461. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3462. var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
  3463. $scope.importopen = function () { //导入触发事件
  3464. if (angular.isUndefined($scope.form.dropState)) {
  3465. $scope.form.dropState = false;
  3466. }
  3467. //附件上传数据
  3468. //$scope.options.templateOptions.uploader();
  3469. // FILTERS
  3470. uploader.filters.push({
  3471. name: 'customFilter',
  3472. fn: function (item /*{File|FileLikeObject}*/, options) {
  3473. return this.queue.length < 2;
  3474. }
  3475. });
  3476. // CALLBACKS
  3477. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  3478. console.info('onWhenAddingFileFailed', item, filter, options);
  3479. };
  3480. uploader.onAfterAddingFile = function (fileItem) {
  3481. console.info('onAfterAddingFile', fileItem);
  3482. };
  3483. uploader.onAfterAddingAll = function (addedFileItems) {
  3484. console.info('onAfterAddingAll', addedFileItems);
  3485. };
  3486. uploader.onBeforeUploadItem = function (item) {
  3487. console.info('onBeforeUploadItem', item);
  3488. };
  3489. uploader.onProgressItem = function (fileItem, progress) {
  3490. console.info('onProgressItem', fileItem, progress);
  3491. };
  3492. uploader.onProgressAll = function (progress) {
  3493. console.info('onProgressAll', progress);
  3494. };
  3495. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3496. // console.info('onSuccessItem', fileItem, response, status, headers);
  3497. // };
  3498. uploader.onErrorItem = function (fileItem, response, status, headers) {
  3499. console.info('onErrorItem', fileItem, response, status, headers);
  3500. };
  3501. uploader.onCancelItem = function (fileItem, response, status, headers) {
  3502. console.info('onCancelItem', fileItem, response, status, headers);
  3503. };
  3504. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  3505. console.info('onCompleteItem', fileItem, response, status, headers);
  3506. };
  3507. uploader.onCompleteAll = function () {
  3508. console.info('onCompleteAll');
  3509. };
  3510. }
  3511. // $scope.importnext = function() {
  3512. // $scope.state = 2;
  3513. // event.preventDefault();
  3514. // }
  3515. $scope.importnext = function () {
  3516. event.preventDefault();
  3517. // $rootScope.isMask = true;
  3518. $rootScope.loading = true;
  3519. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3520. uploader.onBeforeUploadItem = function (item) {
  3521. angular.extend(item.headers, $rootScope.getSession());
  3522. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3523. // if (item.index > 1) {
  3524. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3525. // }
  3526. // item.index = 1;
  3527. item.formData = [{
  3528. 'filename': item.file.name
  3529. }];
  3530. console.info('onBeforeUploadItem', item);
  3531. };
  3532. uploader.uploadAll();
  3533. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3534. if (response.status == 200) {
  3535. $scope.wrongdata = [];
  3536. $rootScope.loading = false;
  3537. if (response.abnormal) {
  3538. $scope.state = 2;
  3539. angular.forEach(response.msg, function (item) {
  3540. $scope.wrongdata.push({
  3541. 'name': item.assetName,
  3542. 'line': item.row,
  3543. 'cmdbname': item.name,
  3544. 'errotip': [{
  3545. 'label': item.msg
  3546. }]
  3547. })
  3548. })
  3549. } else {
  3550. $scope.state = 3;
  3551. }
  3552. } else {
  3553. $rootScope.loading = false;
  3554. $scope.state = 2;
  3555. }
  3556. }
  3557. }
  3558. $scope.clearItems = function () { //重新选择文件时,清空队列,达到覆盖文件的效果
  3559. uploader.clearQueue();
  3560. // uploader.remove();
  3561. // uploader.cancel();
  3562. // uploader.onChange();
  3563. }
  3564. uploader.onAfterAddingFile = function (fileItem) {
  3565. $scope.fileItem = fileItem._file;
  3566. // $scope.$apply();
  3567. // $scope.fileItem = filenum;
  3568. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  3569. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  3570. $scope.filenum++;
  3571. };
  3572. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3573. $scope.uploadStatus = true; //上传成功则把状态改为true
  3574. // alert(response.path);
  3575. };
  3576. $scope.importnext = function () {
  3577. event.preventDefault();
  3578. // uploader.onChange();
  3579. $rootScope.loading = true;
  3580. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3581. uploader.onBeforeUploadItem = function (item) {
  3582. angular.extend(item.headers, $rootScope.getSession());
  3583. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3584. // if (item.index > 1) {
  3585. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3586. // }
  3587. // item.index = 1;
  3588. item.formData = [{
  3589. 'filename': item.file.name
  3590. }];
  3591. console.info('onBeforeUploadItem', item);
  3592. };
  3593. uploader.uploadAll();
  3594. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3595. if (response.status == 200) {
  3596. $scope.wrongdata = [];
  3597. // uploader.queue = [];
  3598. $rootScope.loading = false;
  3599. if (response.abnormal) {
  3600. $scope.state = 2;
  3601. uploader.clearQueue();
  3602. angular.forEach(response.msg, function (item) {
  3603. $scope.wrongdata.push({
  3604. 'name': item.assetName,
  3605. 'line': item.row,
  3606. 'cmdbname': item.name,
  3607. 'errotip': [{
  3608. 'label': item.msg
  3609. }]
  3610. })
  3611. })
  3612. } else {
  3613. $scope.state = 3;
  3614. }
  3615. } else {
  3616. uploader.clearQueue();
  3617. $rootScope.loading = false;
  3618. $scope.state = 2;
  3619. }
  3620. }
  3621. }
  3622. var setAllInactive = function () {
  3623. angular.forEach($scope.workspaces, function (workspace) {
  3624. workspace.active = false;
  3625. });
  3626. };
  3627. //添加
  3628. var addNewWorkspace = function (name, contentUrl) {
  3629. var id = $scope.workspaces.length + 1;
  3630. $scope.workspaces.push({
  3631. id: id,
  3632. name: name,
  3633. active: true,
  3634. contentUrl: 'main/html/content.html'
  3635. });
  3636. };
  3637. //关闭
  3638. $scope.closeopen = function (closedata) {
  3639. event.preventDefault();
  3640. angular.forEach($scope.workspaces, function (item, index) {
  3641. if (closedata.id == item.id) {
  3642. if (closedata.id == 1) {
  3643. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  3644. } else {
  3645. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  3646. }
  3647. $scope.workspaces.splice(index, 1);
  3648. }
  3649. })
  3650. }
  3651. // $scope.workspaces = [
  3652. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  3653. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3654. // ];
  3655. $scope.addWorkspace = function (contentUrl, name) {
  3656. setAllInactive();
  3657. addNewWorkspace(name, contentUrl);
  3658. };
  3659. // $rootScope.addWorkspace = $scope.addWorkspace;
  3660. $scope.close = function (idNumber) {
  3661. var index = 0; //记录当前元素下标
  3662. angular.forEach($scope.workspaces, function (workspace) {
  3663. if (workspace.id === idNumber) {
  3664. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3665. }
  3666. index++;
  3667. });
  3668. };
  3669. //grid2
  3670. $scope.langs = i18nService.getAllLangs();
  3671. $scope.lang = 'zh-cn';
  3672. i18nService.setCurrentLang($scope.lang);
  3673. $scope.gridOptions2 = {};
  3674. $scope.gridOptions2.data = 'myData3';
  3675. $scope.gridOptions2.enableColumnResizing = true;
  3676. $scope.gridOptions2.enableFiltering = false;
  3677. $scope.gridOptions2.enableGridMenu = false;
  3678. $scope.gridOptions2.showGridFooter = true;
  3679. $scope.gridOptions2.showColumnFooter = false;
  3680. $scope.gridOptions2.fastWatch = true;
  3681. $scope.gridOptions2.useExternalFiltering = true;
  3682. $scope.gridOptions2.useExternalPagination = true;
  3683. $scope.gridOptions2.paginationPageSizes = [10];
  3684. $scope.gridOptions2.paginationPageSize = 10;
  3685. $scope.gridOptions2.multiSelect = false;
  3686. // $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>";
  3687. $scope.gridOptions2.columnDefs = [{
  3688. name: 'item',
  3689. displayName: '序号',
  3690. width: 120
  3691. },
  3692. {
  3693. name: 'name',
  3694. displayName: '耗材名称',
  3695. width: 80,
  3696. enableFiltering: false
  3697. },
  3698. {
  3699. name: 'model',
  3700. displayName: '品牌/型号',
  3701. width: 100,
  3702. enableFiltering: false
  3703. },
  3704. {
  3705. name: 'Specifications',
  3706. displayName: '规格',
  3707. width: 150,
  3708. enableFiltering: false
  3709. },
  3710. {
  3711. name: 'sum',
  3712. displayName: '数量',
  3713. enableFiltering: false
  3714. },
  3715. {
  3716. name: '操作',
  3717. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3718. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  3719. '</div></div>',
  3720. enableFiltering: false
  3721. },
  3722. ];
  3723. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  3724. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  3725. $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
  3726. for (var i = 0; i < $scope.myData3all.length; i++) {
  3727. $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  3728. }
  3729. // $scope.model.consumables = $scope.myDataone;
  3730. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3731. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
  3732. $scope.model.applicationForm.consumables = $scope.myData3all;
  3733. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3734. $scope.options.templateOptions.getpush({
  3735. "hao": true,
  3736. "gu": true
  3737. });
  3738. } else {
  3739. $scope.options.templateOptions.getpush({
  3740. "hao": true
  3741. });
  3742. }
  3743. } else {
  3744. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3745. $scope.options.templateOptions.getpush({
  3746. "gu": true
  3747. });
  3748. }
  3749. }
  3750. }
  3751. $scope.options.templateOptions.workspaces = $scope.workspaces;
  3752. $scope.changecai = function (item) {
  3753. event.preventDefault();
  3754. var modalInstance = $modal.open({
  3755. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  3756. controller: function ($scope, $modalInstance) {
  3757. $scope.title = "修改耗材数量";
  3758. $scope.consumptive = angular.copy(item);
  3759. $scope.ok = function () {
  3760. $modalInstance.close($scope.consumptive);
  3761. };
  3762. $scope.cancel = function () {
  3763. $modalInstance.dismiss('cancel');
  3764. };
  3765. },
  3766. size: 'sm'
  3767. });
  3768. modalInstance.result.then(function (selectedItem) {
  3769. // angular.forEach($scope.myData3, function(items, index) {
  3770. // if (items.id == selectedItem.id) {
  3771. // $scope.myData3[index] = selectedItem;
  3772. // }
  3773. // })
  3774. // // $scope.myData3.push(selectedItem);
  3775. // $scope.model.applicationForm.consumables = $scope.myData3;
  3776. angular.forEach($scope.myData3all, function (items, index) {
  3777. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  3778. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  3779. angular.extend($scope.myData3all[index], selectedItem)
  3780. }
  3781. })
  3782. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3783. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3784. $scope.model.applicationForm.consumables = $scope.myData3all;
  3785. })
  3786. }
  3787. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  3788. $scope.gridApi = gridApi;
  3789. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  3790. // var filtersData = $scope.memoryfilterDatahao;
  3791. // filtersData.idx = newPage - 1;
  3792. // filtersData.sum = pageSize;
  3793. // $scope.loadData(filtersData);
  3794. $scope.memoryfilterDatahao.idx = newPage - 1;
  3795. $scope.memoryfilterDatahao.sum = pageSize;
  3796. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
  3797. });
  3798. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  3799. $scope.selected.items = data.entity;
  3800. //console.log(data);
  3801. });
  3802. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  3803. $scope.selected.items = data.entity;
  3804. //console.log(data);
  3805. });
  3806. gridApi.core.on.filterChanged($scope, function () {
  3807. var grid = this.grid;
  3808. var filtersData = {
  3809. idx: 0,
  3810. sum: 10,
  3811. };
  3812. $scope.memoryfilterDatahao = filtersData;
  3813. // $scope.loadData(filtersData);
  3814. // $scope.memoryfilterDatahao.idx = newPage - 1;
  3815. // $scope.memoryfilterDatahao.sum = pageSize;
  3816. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3817. });
  3818. };
  3819. $scope.haocaiopen = function (items) {
  3820. event.preventDefault();
  3821. var modalInstance = $modal.open({
  3822. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3823. controller: function ($scope, $modalInstance, SweetAlert) {
  3824. $scope.consumptive = {};
  3825. $scope.title = "新增耗材";
  3826. if (items.name) {
  3827. $scope.consumptive.name = items.name.name;
  3828. }
  3829. $scope.clearNoNum = function (obj, attr) {
  3830. //先把非数字的都替换掉,除了数字和.
  3831. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3832. //必须保证第一个为数字而不是.
  3833. obj[attr] = obj[attr].replace(/^\./g, "");
  3834. //保证只有出现一个.而没有多个.
  3835. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3836. //保证.只出现一次,而不能出现两次以上
  3837. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3838. //小于最大值
  3839. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3840. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3841. // obj[attr] = '';
  3842. // }
  3843. }
  3844. $scope.ok = function (item) {
  3845. // if (item.name && item.model && item.Specifications && item.sum) {
  3846. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3847. $modalInstance.close(item);
  3848. } else {
  3849. SweetAlert.swal({
  3850. title: "数据填写不完整!",
  3851. text: "请检查数据然后提交!",
  3852. type: "error"
  3853. });
  3854. }
  3855. };
  3856. $scope.cancel = function () {
  3857. $modalInstance.dismiss('cancel');
  3858. };
  3859. },
  3860. size: 'sm',
  3861. resolve: {
  3862. SweetAlert: function () {
  3863. return SweetAlert;
  3864. }
  3865. }
  3866. });
  3867. modalInstance.result.then(function (selectedItem) {
  3868. api_sysinfo.addData('dictionaryTree', {
  3869. // "type": "list",
  3870. "key": "haocaifenlei",
  3871. "name": selectedItem.name,
  3872. "parent": selectedItem.id,
  3873. "value": selectedItem.name,
  3874. "deleted": false,
  3875. "level": 1
  3876. }).then(function (data) {
  3877. // $scope.haocainame.name = data.list;
  3878. api_sysinfo.addData('dictionaryTree', {
  3879. // "type": "list",
  3880. "key": "pinpai",
  3881. "name": selectedItem.model,
  3882. "parent": data.id,
  3883. "value": selectedItem.model,
  3884. "deleted": false,
  3885. "level": 2
  3886. }).then(function (data) {
  3887. // $scope.haocainame = data.list;
  3888. })
  3889. api_sysinfo.addData({
  3890. // "type": "list",
  3891. "key": "guige",
  3892. "name": selectedItem.Specifications,
  3893. "parent": data.id,
  3894. "value": selectedItem.Specifications,
  3895. "deleted": false,
  3896. "level": 2
  3897. }).then(function (data) {
  3898. // $scope.haocainame = data.list;
  3899. })
  3900. })
  3901. // $scope.myData3.push(selectedItem);
  3902. // for (var i = 0; i < $scope.myData3.length; i++) {
  3903. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3904. // }
  3905. // $scope.model.applicationForm.consumables = $scope.myData3;
  3906. $scope.myData3all.push(selectedItem);
  3907. for (var i = 0; i < $scope.myData3all.length; i++) {
  3908. $scope.myData3all[i]['item'] = i + 1
  3909. }
  3910. // $scope.model.consumables = $scope.myDataone;
  3911. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3912. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3913. $scope.model.applicationForm.consumables = $scope.myData3all;
  3914. })
  3915. }
  3916. $scope.haocaiadd = function () {
  3917. event.preventDefault();
  3918. var modalInstance = $modal.open({
  3919. templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
  3920. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  3921. $scope.haocainame = [];
  3922. $scope.pinpai = [];
  3923. $scope.guige = [];
  3924. $scope.consumptive = {};
  3925. $scope.consumpall = {};
  3926. $scope.title = "添加耗材";
  3927. api_wechatfile.getDictionary({
  3928. "key": "haocaifenlei",
  3929. "type": "tree"
  3930. }).then(function (data) {
  3931. $scope.haocainame = data;
  3932. })
  3933. $scope.clearNoNum = function (obj, attr) {
  3934. //先把非数字的都替换掉,除了数字和.
  3935. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3936. //必须保证第一个为数字而不是.
  3937. obj[attr] = obj[attr].replace(/^\./g, "");
  3938. //保证只有出现一个.而没有多个.
  3939. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3940. //保证.只出现一次,而不能出现两次以上
  3941. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3942. //小于最大值
  3943. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3944. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3945. // obj[attr] = '';
  3946. // }
  3947. }
  3948. $scope.onChange = function (parent) {
  3949. $scope.consumptive.model = {};
  3950. $scope.consumptive.Specifications = {};
  3951. api_wechatfile.getDictionaryForList({
  3952. "key": "pinpai",
  3953. "parent": parent.id
  3954. }).then(function (data) {
  3955. $scope.pinpai = data;
  3956. })
  3957. api_wechatfile.getDictionaryForList({
  3958. "key": "guige",
  3959. "parent": parent.id
  3960. }).then(function (data) {
  3961. $scope.guige = data;
  3962. })
  3963. }
  3964. $scope.addhaocai = function () {
  3965. $modalInstance.dismiss('cancel');
  3966. scope.haocaiopen($scope.consumptive);
  3967. }
  3968. $scope.ok = function (item) {
  3969. var items = {};
  3970. var submittrue = true;
  3971. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3972. items = {
  3973. "modelid": item.model.id,
  3974. "nameid": item.name.id,
  3975. "Specificationsid": item.Specifications.id,
  3976. "name": item.name.name,
  3977. "model": item.model.name,
  3978. "Specifications": item.Specifications.name,
  3979. "sum": item.sum
  3980. }
  3981. angular.forEach(scope.myData3all, function (itemsdata) {
  3982. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  3983. submittrue = false;
  3984. }
  3985. })
  3986. if (submittrue) {
  3987. $modalInstance.close(items);
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "该耗材已有添加",
  3991. text: "请检查数据然后提交!",
  3992. type: "error"
  3993. });
  3994. }
  3995. } else {
  3996. SweetAlert.swal({
  3997. title: "数据填写不完整!",
  3998. text: "请检查数据然后提交!",
  3999. type: "error"
  4000. });
  4001. }
  4002. // var isold = false;
  4003. // if (item.name && item.model && item.Specifications && item.sum) {
  4004. // for (var i = 0; i < scope.myData3all.length; i++) {
  4005. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4006. // isold = true;
  4007. // }
  4008. // }
  4009. // if (isold) {
  4010. // SweetAlert.swal({
  4011. // title: "该耗材已添加!",
  4012. // text: "请不要重复添加耗材!",
  4013. // type: "error"
  4014. // });
  4015. // } else {
  4016. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4017. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4018. // $scope.consumpall.sum = item.sum;
  4019. // delete $scope.consumpall.brandModel;
  4020. // delete $scope.consumpall.specification;
  4021. // $modalInstance.close($scope.consumpall);
  4022. // }
  4023. // } else {
  4024. // SweetAlert.swal({
  4025. // title: "数据填写不完整!",
  4026. // text: "请检查数据然后提交!",
  4027. // type: "error"
  4028. // });
  4029. // }
  4030. };
  4031. $scope.cancel = function () {
  4032. $modalInstance.dismiss('cancel');
  4033. };
  4034. },
  4035. size: 'sm',
  4036. resolve: {
  4037. scope: function () {
  4038. return $scope;
  4039. }
  4040. }
  4041. });
  4042. modalInstance.result.then(function (selectedItem) {
  4043. $scope.myData3all.push(selectedItem);
  4044. for (var i = 0; i < $scope.myData3all.length; i++) {
  4045. $scope.myData3all[i]['item'] = i + 1
  4046. }
  4047. // $scope.model.consumables = $scope.myDataone;
  4048. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  4049. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  4050. $scope.model.applicationForm.consumables = $scope.myData3all;
  4051. })
  4052. }
  4053. $scope.onDblClick = function (data, event) {
  4054. $scope.selectButtonClick(data, event);
  4055. };
  4056. // $scope.memoryfilterDatahao = {
  4057. // "idx": 0,
  4058. // "sum": 10,
  4059. // }
  4060. // $scope.loadData = function(filterData) {};
  4061. // $scope.title = title;
  4062. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4063. $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
  4064. }
  4065. }]
  4066. });
  4067. //归还设备耗材tab
  4068. formlyConfigProvider.setType({
  4069. name: 'ui-cmdbreturntab',
  4070. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
  4071. wrapper: ['bootstrapHasError'],
  4072. defaultOptions: function (options, $scope) {
  4073. return {
  4074. templateOptions: {
  4075. // checkform: function(options) {
  4076. // if (options.model.requester) {
  4077. // options.value(options.model.requester);
  4078. // }
  4079. // },
  4080. }
  4081. };
  4082. },
  4083. controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function ($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
  4084. var setAllInactive = function () {
  4085. angular.forEach($scope.workspaces, function (workspace) {
  4086. workspace.active = false;
  4087. });
  4088. };
  4089. $scope.memoryfilterData = {
  4090. "idx": 0,
  4091. "sum": 10,
  4092. }
  4093. //添加
  4094. var addNewWorkspace = function (name, contentUrl) {
  4095. var id = $scope.workspaces.length + 1;
  4096. $scope.workspaces.push({
  4097. id: id,
  4098. name: name,
  4099. active: true,
  4100. contentUrl: 'main/html/content.html'
  4101. });
  4102. };
  4103. $scope.workspaces = [{
  4104. id: 1,
  4105. name: "归还设备",
  4106. active: true,
  4107. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4108. },
  4109. {
  4110. id: 2,
  4111. name: "归还耗材",
  4112. active: true,
  4113. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4114. }
  4115. ];
  4116. $scope.addWorkspace = function (contentUrl, name) {
  4117. setAllInactive();
  4118. addNewWorkspace(name, contentUrl);
  4119. };
  4120. // $rootScope.addWorkspace = $scope.addWorkspace;
  4121. $scope.close = function (idNumber) {
  4122. var index = 0; //记录当前元素下标
  4123. angular.forEach($scope.workspaces, function (workspace) {
  4124. if (workspace.id === idNumber) {
  4125. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4126. }
  4127. index++;
  4128. });
  4129. };
  4130. $scope.memoryfilterDataguishe = {
  4131. "idx": 0,
  4132. "sum": 10,
  4133. }
  4134. //grid1
  4135. $scope.langs = i18nService.getAllLangs();
  4136. $scope.lang = 'zh-cn';
  4137. i18nService.setCurrentLang($scope.lang);
  4138. $scope.gridOptions1 = {};
  4139. $scope.gridOptions1.data = 'myData1';
  4140. $scope.gridOptions1.enableColumnResizing = true;
  4141. $scope.gridOptions1.enableFiltering = false;
  4142. $scope.gridOptions1.enableGridMenu = false;
  4143. $scope.gridOptions1.showGridFooter = true;
  4144. $scope.gridOptions1.showColumnFooter = false;
  4145. $scope.gridOptions1.fastWatch = true;
  4146. $scope.gridOptions1.useExternalFiltering = true;
  4147. $scope.gridOptions1.useExternalPagination = true;
  4148. $scope.gridOptions1.paginationPageSizes = [10];
  4149. $scope.gridOptions1.paginationPageSize = 10;
  4150. $scope.gridOptions1.multiSelect = false;
  4151. // $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>";
  4152. $scope.gridOptions1.columnDefs = [{
  4153. name: 'item',
  4154. displayName: '序号',
  4155. width: 120
  4156. },
  4157. {
  4158. name: 'props.hw_cifilterClassic',
  4159. displayName: '设备类型',
  4160. width: 150,
  4161. enableFiltering: false
  4162. },
  4163. {
  4164. name: 'props.hw_mingcheng',
  4165. displayName: '设备名称',
  4166. width: 180,
  4167. enableFiltering: false
  4168. },
  4169. {
  4170. name: 'uuid',
  4171. displayName: '设备编号',
  4172. width: 180,
  4173. enableFiltering: false
  4174. },
  4175. {
  4176. name: 'props.hw_state',
  4177. width: 150,
  4178. displayName: '状态',
  4179. enableFiltering: false
  4180. },
  4181. {
  4182. name: '操作',
  4183. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4184. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  4185. '</div></div>',
  4186. enableFiltering: false
  4187. },
  4188. ];
  4189. // $scope.selectButtonClick
  4190. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4191. $scope.gridApi = gridApi;
  4192. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4193. // var filtersData = $scope.memoryfilterData;
  4194. // filtersData.idx = newPage - 1;
  4195. // filtersData.sum = pageSize;
  4196. // $scope.loadData(filtersData);
  4197. $scope.memoryfilterDataguishe.idx = newPage - 1;
  4198. $scope.memoryfilterDataguishe.sum = pageSize;
  4199. $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
  4200. });
  4201. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4202. $scope.selected.items = data.entity;
  4203. //console.log(data);
  4204. });
  4205. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4206. $scope.selected.items = data.entity;
  4207. //console.log(data);
  4208. });
  4209. gridApi.core.on.filterChanged($scope, function () {
  4210. // var grid = this.grid;
  4211. // var filtersData = {
  4212. // idx: 0,
  4213. // sum: 20,
  4214. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4215. // };
  4216. // angular.forEach(grid.columns, function(item) {
  4217. // if (item.enableFiltering) {
  4218. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4219. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4220. // if (angular.isUndefined(filtersData['user'])) {
  4221. // filtersData['user'] = {};
  4222. // }
  4223. // filtersData['user'][item.field] = item.filters[0].term;
  4224. // }
  4225. // }
  4226. // });
  4227. // $scope.memoryfilterData = filtersData;
  4228. // $scope.loadData(filtersData);
  4229. });
  4230. };
  4231. $scope.changegu = function (item) {
  4232. event.preventDefault();
  4233. var modalInstance = $modal.open({
  4234. templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
  4235. controller: function ($scope, $modalInstance) {
  4236. $scope.title = "修改设备状态";
  4237. $scope.hw_state = {};;
  4238. if (item.status) {
  4239. $scope.hw_state.name = item.hw_state;
  4240. }
  4241. // $scope.consumptive = item;
  4242. $scope.stateshe = [{
  4243. "id": 2,
  4244. "name": "在库"
  4245. }, {
  4246. "id": 4,
  4247. "name": "报修"
  4248. }, {
  4249. "id": 3,
  4250. "name": "报废"
  4251. }]
  4252. $scope.ok = function (item) {
  4253. $modalInstance.close($scope.hw_state);
  4254. };
  4255. $scope.cancel = function () {
  4256. $modalInstance.dismiss('cancel');
  4257. };
  4258. },
  4259. size: 'sm'
  4260. });
  4261. modalInstance.result.then(function (selectedItem) {
  4262. angular.forEach($scope.myData1, function (items, index) {
  4263. if (items.id == item.id) {
  4264. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  4265. }
  4266. })
  4267. $scope.model.assets = $scope.myData1;
  4268. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
  4269. })
  4270. }
  4271. $scope.onDblClick = function (data, event) {
  4272. $scope.selectButtonClick(data, event);
  4273. };
  4274. $scope.memoryfilterData = {
  4275. "idx": 0,
  4276. "sum": 10,
  4277. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4278. }
  4279. // $scope.myData = {};
  4280. $scope.loadData = function (filterData) { };
  4281. // $scope.title = title;
  4282. $scope.loadData({
  4283. idx: 0,
  4284. sum: 10,
  4285. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4286. });
  4287. $scope.selected = {
  4288. items: []
  4289. };
  4290. $scope.myData2 = [];
  4291. $scope.consumptive = {};
  4292. $scope.myDataguibeiall = [];
  4293. $scope.haocaiopen = function (items) {
  4294. event.preventDefault();
  4295. var modalInstance = $modal.open({
  4296. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  4297. controller: function ($scope, $modalInstance, SweetAlert, api_wechatfile, api_sysinfo) {
  4298. $scope.consumptive = {};
  4299. $scope.title = "新增耗材";
  4300. if (items.name) {
  4301. $scope.consumptive.name = items.name.name;
  4302. }
  4303. $scope.ok = function (item) {
  4304. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4305. $modalInstance.close(item);
  4306. } else {
  4307. SweetAlert.swal({
  4308. title: "数据填写不完整!",
  4309. text: "请检查数据然后提交!",
  4310. type: "error"
  4311. });
  4312. }
  4313. };
  4314. $scope.cancel = function () {
  4315. $modalInstance.dismiss('cancel');
  4316. };
  4317. },
  4318. size: 'sm'
  4319. });
  4320. modalInstance.result.then(function (selectedItem) {
  4321. api_sysinfo.addData({
  4322. "type": "list",
  4323. "key": "haocaifenlei",
  4324. "name": selectedItem.name,
  4325. "parent": selectedItem.id,
  4326. "value": "1"
  4327. }).then(function (data) {
  4328. // $scope.haocainame.name = data.list;
  4329. api_wechatfile.addDictionary({
  4330. "type": "list",
  4331. "key": "pinpai",
  4332. "name": selectedItem.model,
  4333. "parent": data.id,
  4334. "value": "1"
  4335. }).then(function (data) {
  4336. // $scope.haocainame = data.list;
  4337. })
  4338. api_wechatfile.addDictionary({
  4339. "type": "list",
  4340. "key": "guige",
  4341. "name": selectedItem.Specifications,
  4342. "parent": data.id,
  4343. "value": "1"
  4344. }).then(function (data) {
  4345. // $scope.haocainame = data.list;
  4346. })
  4347. })
  4348. $scope.myData2.push(selectedItem);
  4349. for (var i = 0; i < $scope.myData2.length; i++) {
  4350. $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4351. }
  4352. // $scope.model.applicationForm.consumables = $scope.myData2;
  4353. angular.forEach($scope.myDataguibeiall, function (items, index) {
  4354. if (items.id == selectedItem.id) {
  4355. $scope.myDataguibeiall.splice(index, 1);
  4356. }
  4357. })
  4358. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
  4359. $scope.model.consumables = $scope.myDataguibeiall;
  4360. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4361. $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
  4362. })
  4363. }
  4364. //grid2
  4365. $scope.langs = i18nService.getAllLangs();
  4366. $scope.lang = 'zh-cn';
  4367. i18nService.setCurrentLang($scope.lang);
  4368. $scope.gridOptions2 = {};
  4369. $scope.gridOptions2.data = 'myData2';
  4370. $scope.gridOptions2.enableColumnResizing = true;
  4371. $scope.gridOptions2.enableFiltering = false;
  4372. $scope.gridOptions2.enableGridMenu = false;
  4373. $scope.gridOptions2.showGridFooter = true;
  4374. $scope.gridOptions2.showColumnFooter = false;
  4375. $scope.gridOptions2.fastWatch = true;
  4376. $scope.gridOptions2.useExternalFiltering = true;
  4377. $scope.gridOptions2.useExternalPagination = true;
  4378. $scope.gridOptions2.paginationPageSizes = [10];
  4379. $scope.gridOptions2.paginationPageSize = 10;
  4380. $scope.gridOptions2.multiSelect = false;
  4381. // $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>";
  4382. $scope.modelcons = {};
  4383. $scope.modelass = {};
  4384. $scope.myData2all = [];
  4385. $scope.myData1all = [];
  4386. $scope.memoryfilterDatagui = {
  4387. "idx": 0,
  4388. "sum": 10
  4389. }
  4390. setInterval(function () {
  4391. if ($scope.model.assets) {
  4392. if ($scope.model.assets != $scope.modelass && typeof ($scope.model.assets) == 'string') {
  4393. $scope.modelass = $scope.model.assets;
  4394. if (JSON.stringify($scope.model.assets) == "{}") {
  4395. $scope.model.assets = []
  4396. } else {
  4397. $scope.model.assets = JSON.parse($scope.model.assets);
  4398. }
  4399. // $scope.myData1 = $scope.model.assets;
  4400. // for (var i = 0; i < $scope.myData1.length; i++) {
  4401. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4402. // }
  4403. $scope.myData1all = $scope.model.assets;
  4404. for (var i = 0; i < $scope.myData1all.length; i++) {
  4405. $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4406. }
  4407. $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
  4408. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
  4409. }
  4410. }
  4411. if ($scope.model.consumables) {
  4412. if ($scope.model.consumables != $scope.modelcons && typeof ($scope.model.consumables) == 'string') {
  4413. $scope.modelass = $scope.model.consumables;
  4414. if (JSON.stringify($scope.model.consumables) == "{}") {
  4415. $scope.model.consumables = [];
  4416. } else {
  4417. $scope.model.consumables = JSON.parse($scope.model.consumables);
  4418. }
  4419. // $scope.myData2 = $scope.model.consumables;
  4420. // for (var i = 0; i < $scope.myData2.length; i++) {
  4421. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4422. // }
  4423. $scope.myData2all = $scope.model.consumables;
  4424. for (var i = 0; i < $scope.myData2all.length; i++) {
  4425. $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4426. }
  4427. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4428. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
  4429. // $scope.model.consumables = $scope.myData2all;
  4430. }
  4431. }
  4432. }, 100);
  4433. $scope.gridOptions2.columnDefs = [{
  4434. name: 'item',
  4435. displayName: '序号',
  4436. width: 120
  4437. },
  4438. {
  4439. name: 'name',
  4440. displayName: '耗材名称',
  4441. width: 180,
  4442. enableFiltering: false
  4443. },
  4444. {
  4445. name: 'model',
  4446. displayName: '品牌/型号',
  4447. width: 180,
  4448. enableFiltering: false
  4449. },
  4450. {
  4451. name: 'Specifications',
  4452. displayName: '规格',
  4453. width: 150,
  4454. enableFiltering: false
  4455. },
  4456. {
  4457. name: 'sum',
  4458. width: 150,
  4459. displayName: '数量',
  4460. enableFiltering: false
  4461. },
  4462. {
  4463. name: '操作',
  4464. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4465. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4466. '</div></div>',
  4467. enableFiltering: false
  4468. },
  4469. ];
  4470. // $scope.selectButtonClick
  4471. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4472. $scope.gridApi = gridApi;
  4473. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4474. // var filtersData = $scope.memoryfilterDatagui;
  4475. // filtersData.idx = newPage - 1;
  4476. // filtersData.sum = pageSize;
  4477. $scope.memoryfilterDatagui.idx = newPage - 1;
  4478. $scope.memoryfilterDatagui.sum = pageSize;
  4479. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4480. });
  4481. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4482. $scope.selected.items = data.entity;
  4483. //console.log(data);
  4484. });
  4485. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4486. $scope.selected.items = data.entity;
  4487. //console.log(data);
  4488. });
  4489. gridApi.core.on.filterChanged($scope, function () {
  4490. var grid = this.grid;
  4491. var filtersData = {
  4492. idx: 0,
  4493. sum: 10,
  4494. };
  4495. angular.forEach(grid.columns, function (item) {
  4496. if (item.enableFiltering) {
  4497. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4498. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4499. if (angular.isUndefined(filtersData['user'])) {
  4500. filtersData['user'] = {};
  4501. }
  4502. filtersData['user'][item.field] = item.filters[0].term;
  4503. }
  4504. }
  4505. });
  4506. $scope.memoryfilterData = filtersData;
  4507. $scope.loadData(filtersData);
  4508. });
  4509. };
  4510. $scope.changecai = function (item) {
  4511. event.preventDefault();
  4512. var modalInstance = $modal.open({
  4513. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4514. controller: function ($scope, $modalInstance) {
  4515. $scope.title = "修改耗材数量";
  4516. $scope.consumptive = angular.copy(item);
  4517. // $scope.consumptive = item;
  4518. $scope.maxsum = item.inventoryNum;
  4519. $scope.clearNoNum = function (obj, attr) {
  4520. //先把非数字的都替换掉,除了数字和.
  4521. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4522. //必须保证第一个为数字而不是.
  4523. obj[attr] = obj[attr].replace(/^\./g, "");
  4524. //保证只有出现一个.而没有多个.
  4525. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4526. //保证.只出现一次,而不能出现两次以上
  4527. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4528. //小于最大值
  4529. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4530. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4531. // obj[attr] = '';
  4532. // }
  4533. }
  4534. $scope.ok = function () {
  4535. $modalInstance.close($scope.consumptive);
  4536. };
  4537. $scope.cancel = function () {
  4538. $modalInstance.dismiss('cancel');
  4539. };
  4540. },
  4541. size: 'sm'
  4542. });
  4543. modalInstance.result.then(function (selectedItem) {
  4544. angular.forEach($scope.myData2all, function (items, index) {
  4545. // if (items.id == selectedItem.id) {
  4546. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  4547. angular.extend($scope.myData2all[index], selectedItem)
  4548. }
  4549. })
  4550. // $scope.model.consumables = $scope.myData2;
  4551. // $scope.myData2 = $scope.model.consumables;
  4552. // $scope.myData2all.push(selectedItem);
  4553. // for (var i = 0; i < $scope.myData2all.length; i++) {
  4554. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4555. // }
  4556. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4557. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4558. $scope.model.consumables = $scope.myData2all;
  4559. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4560. })
  4561. }
  4562. $scope.interceptMydata = function (mydate, idx, sum) {
  4563. return mydate.slice(idx * sum, (idx + 1) * sum)
  4564. }
  4565. $scope.haocaiadd = function () {
  4566. event.preventDefault();
  4567. var modalInstance = $modal.open({
  4568. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  4569. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
  4570. $scope.haocainame = [];
  4571. $scope.pinpai = [];
  4572. $scope.guige = [];
  4573. $scope.consumptive = {};
  4574. $scope.consumptiveall = {};
  4575. $scope.title = "添加耗材";
  4576. api_wechatfile.getDictionaryForList({
  4577. "key": "haocaifenlei"
  4578. }).then(function (data) {
  4579. $scope.haocainame = data;
  4580. })
  4581. $scope.clearNoNum = function (obj, attr) {
  4582. //先把非数字的都替换掉,除了数字和.
  4583. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4584. //必须保证第一个为数字而不是.
  4585. obj[attr] = obj[attr].replace(/^\./g, "");
  4586. //保证只有出现一个.而没有多个.
  4587. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4588. //保证.只出现一次,而不能出现两次以上
  4589. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4590. //小于最大值
  4591. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4592. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4593. obj[attr] = '';
  4594. }
  4595. }
  4596. $scope.onChange = function (parent) {
  4597. $scope.consumptive.model = {};
  4598. $scope.consumptive.Specifications = {};
  4599. api_wechatfile.getDictionaryForList({
  4600. "key": "pinpai",
  4601. "parent": parent.id
  4602. }).then(function (data) {
  4603. $scope.pinpai = data;
  4604. })
  4605. api_wechatfile.getDictionaryForList({
  4606. "key": "guige",
  4607. "parent": parent.id
  4608. }).then(function (data) {
  4609. $scope.guige = data;
  4610. })
  4611. }
  4612. // $scope.onChangesum = function(item) {
  4613. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  4614. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  4615. // $scope.consumptiveall = data1;
  4616. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  4617. // // if (data.list && data.list.length != 0) {
  4618. // // var myData = data.list;
  4619. // // $scope.consumptiveall = myData[0];
  4620. // // $scope.maxsum = myData[0].inventoryNum;
  4621. // // } else if (data.list && data.list.length == 0) {
  4622. // // SweetAlert.swal({
  4623. // // title: "库存数据存在问题!",
  4624. // // text: "请检查库存数据!",
  4625. // // type: "error"
  4626. // // });
  4627. // // }
  4628. // // });
  4629. // }
  4630. // }
  4631. $scope.addhaocai = function () {
  4632. $modalInstance.dismiss('cancel');
  4633. scope.haocaiopen($scope.consumptive);
  4634. }
  4635. $scope.ok = function (item) {
  4636. var submittrue = true;
  4637. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4638. var data = {
  4639. "modelid": item.model.id,
  4640. "nameid": item.name.id,
  4641. "Specificationsid": item.Specifications.id,
  4642. "name": item.name.name,
  4643. "model": item.model.name,
  4644. "Specifications": item.Specifications.name,
  4645. "sum": item.sum
  4646. }
  4647. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4648. // $modalInstance.close(data);
  4649. angular.forEach(scope.myData2all, function (itemsdata) {
  4650. // if (item.model.id == itemsdata.id) {
  4651. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  4652. submittrue = false;
  4653. }
  4654. })
  4655. if (submittrue) {
  4656. $modalInstance.close(data);
  4657. } else {
  4658. SweetAlert.swal({
  4659. title: "该耗材已有添加",
  4660. text: "请检查数据然后提交!",
  4661. type: "error"
  4662. });
  4663. }
  4664. } else {
  4665. SweetAlert.swal({
  4666. title: "数据填写不完整!",
  4667. text: "请检查数据然后提交!",
  4668. type: "error"
  4669. });
  4670. }
  4671. };
  4672. $scope.cancel = function () {
  4673. $modalInstance.dismiss('cancel');
  4674. };
  4675. },
  4676. size: 'sm',
  4677. resolve: {
  4678. scope: function () {
  4679. return $scope;
  4680. }
  4681. }
  4682. });
  4683. modalInstance.result.then(function (selectedItem) {
  4684. // $scope.myData2.push(selectedItem);
  4685. // for (var i = 0; i < $scope.myData2.length; i++) {
  4686. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4687. // }
  4688. // $scope.model.consumables = $scope.myData2;
  4689. $scope.myData2all.push(selectedItem);
  4690. for (var i = 0; i < $scope.myData2all.length; i++) {
  4691. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4692. $scope.myData2all[i]['item'] = i + 1
  4693. }
  4694. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4695. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4696. $scope.model.consumables = $scope.myData2all;
  4697. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4698. })
  4699. }
  4700. $scope.onDblClick = function (data, event) {
  4701. $scope.selectButtonClick(data, event);
  4702. };
  4703. $scope.memoryfilterData = {
  4704. "idx": 0,
  4705. "sum": 20,
  4706. "user": {
  4707. "roledata": {
  4708. "rolecode": "roleset"
  4709. },
  4710. "selectType": "1"
  4711. }
  4712. }
  4713. $scope.myData = {};
  4714. $scope.loadData = function (filterData) { };
  4715. // $scope.title = title;
  4716. $scope.loadData({
  4717. idx: 0,
  4718. sum: 20,
  4719. "user": {
  4720. "roledata": {
  4721. "rolecode": "roleset"
  4722. },
  4723. "selectType": "1"
  4724. }
  4725. });
  4726. $scope.selected = {
  4727. items: {}
  4728. };
  4729. }]
  4730. });
  4731. //tab 列表
  4732. formlyConfigProvider.setType({
  4733. name: 'ui-cmdbtab',
  4734. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
  4735. wrapper: ['bootstrapHasError'],
  4736. defaultOptions: function (options, $scope) {
  4737. return {
  4738. templateOptions: {}
  4739. };
  4740. },
  4741. controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  4742. $scope.memoryfilterDatashe = {
  4743. "idx": 0,
  4744. "sum": 10
  4745. }
  4746. $scope.myDataoneall = [];
  4747. var setAllInactive = function () {
  4748. angular.forEach($scope.workspaces, function (workspace) {
  4749. workspace.active = false;
  4750. });
  4751. };
  4752. //添加
  4753. var addNewWorkspace = function (name, contentUrl) {
  4754. var id = $scope.workspaces.length + 1;
  4755. $scope.workspaces.push({
  4756. id: id,
  4757. name: name,
  4758. active: true,
  4759. contentUrl: 'main/html/content.html'
  4760. });
  4761. };
  4762. //关闭
  4763. $scope.remove = function (closedata) {
  4764. event.preventDefault();
  4765. angular.forEach($scope.workspaces, function (item, index) {
  4766. if (closedata.id == item.id) {
  4767. if (closedata.id == 1) {
  4768. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  4769. } else {
  4770. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  4771. }
  4772. $scope.workspaces.splice(index, 1);
  4773. }
  4774. })
  4775. }
  4776. $scope.workspaces = [];
  4777. $scope.options.templateOptions.getpush = function (item) {
  4778. $scope.workspaces = [];
  4779. if (item.gu) {
  4780. $scope.workspaces.push({
  4781. id: 1,
  4782. name: "领用设备",
  4783. active: true,
  4784. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4785. })
  4786. }
  4787. if (item.hao) {
  4788. $scope.workspaces.push({
  4789. id: 2,
  4790. name: "领用耗材",
  4791. active: true,
  4792. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4793. })
  4794. }
  4795. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4796. };
  4797. $scope.addWorkspace = function (contentUrl, name) {
  4798. setAllInactive();
  4799. addNewWorkspace(name, contentUrl);
  4800. };
  4801. // $rootScope.addWorkspace = $scope.addWorkspace;
  4802. // $scope.remove = function(idNumber) {
  4803. // var index = 0; //记录当前元素下标
  4804. // angular.forEach($scope.workspaces, function(workspace) {
  4805. // if (workspace.id === idNumber.id) {
  4806. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4807. // }
  4808. // index++;
  4809. // });
  4810. // };
  4811. // setInterval(function() {
  4812. // if ($scope.model.assets) {
  4813. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4814. // $scope.modelass = $scope.model.assets;
  4815. // if (JSON.stringify($scope.model.assets) == "{}") {
  4816. // $scope.model.assets = []
  4817. // } else {
  4818. // $scope.model.assets = JSON.parse($scope.model.assets);
  4819. // }
  4820. // $scope.myDatalingbeiall = $scope.model.assets;
  4821. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4822. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4823. // }
  4824. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4825. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4826. // }
  4827. // }
  4828. // if ($scope.model.consumables) {
  4829. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4830. // $scope.modelass = $scope.model.consumables;
  4831. // if (JSON.stringify($scope.model.consumables) == "{}") {
  4832. // $scope.model.consumables = [];
  4833. // } else {
  4834. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  4835. // }
  4836. // $scope.myDatalingbeiall = $scope.model.consumables;
  4837. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4838. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4839. // }
  4840. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  4841. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4842. // // $scope.model.consumables = $scope.myData2all;
  4843. // }
  4844. // }
  4845. // }, 100);
  4846. //grid1
  4847. $scope.langs = i18nService.getAllLangs();
  4848. $scope.lang = 'zh-cn';
  4849. i18nService.setCurrentLang($scope.lang);
  4850. $scope.gridOptions1 = {};
  4851. $scope.gridOptions1.data = 'myDatalingbei';
  4852. $scope.gridOptions1.enableColumnResizing = true;
  4853. $scope.gridOptions1.enableFiltering = false;
  4854. $scope.gridOptions1.enableGridMenu = false;
  4855. $scope.gridOptions1.showGridFooter = true;
  4856. $scope.gridOptions1.showColumnFooter = false;
  4857. $scope.gridOptions1.fastWatch = true;
  4858. $scope.gridOptions1.useExternalFiltering = true;
  4859. $scope.gridOptions1.useExternalPagination = true;
  4860. $scope.gridOptions1.paginationPageSizes = [10];
  4861. $scope.gridOptions1.paginationPageSize = 10;
  4862. $scope.gridOptions1.multiSelect = false;
  4863. // $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>";
  4864. $scope.gridOptions1.columnDefs = [{
  4865. name: 'item',
  4866. displayName: '序号',
  4867. width: 120
  4868. },
  4869. {
  4870. name: 'props.hw_cifilterClassic',
  4871. displayName: '设备类型',
  4872. width: 150,
  4873. enableFiltering: false
  4874. },
  4875. {
  4876. name: 'props.hw_mingcheng',
  4877. displayName: '设备名称',
  4878. width: 100,
  4879. enableFiltering: false
  4880. },
  4881. {
  4882. name: 'uuid',
  4883. displayName: '设备编号',
  4884. enableFiltering: false
  4885. }
  4886. ];
  4887. $scope.myDatalingbeiall = [];
  4888. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4889. $scope.gridApi = gridApi;
  4890. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4891. // var filtersData = $scope.memoryfilterData;
  4892. // filtersData.idx = newPage - 1;
  4893. // filtersData.sum = pageSize;
  4894. // $scope.loadData(filtersData);
  4895. $scope.memoryfilterDatashe.idx = newPage - 1;
  4896. $scope.memoryfilterDatashe.sum = pageSize;
  4897. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
  4898. });
  4899. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4900. $scope.selected.items = data.entity;
  4901. //console.log(data);
  4902. });
  4903. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4904. $scope.selected.items = data.entity;
  4905. //console.log(data);
  4906. });
  4907. gridApi.core.on.filterChanged($scope, function () {
  4908. var grid = this.grid;
  4909. var filtersData = {
  4910. idx: 0,
  4911. sum: 20,
  4912. "user": {
  4913. "roledata": {
  4914. "rolecode": "roleset"
  4915. },
  4916. "selectType": "1"
  4917. }
  4918. };
  4919. angular.forEach(grid.columns, function (item) {
  4920. if (item.enableFiltering) {
  4921. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4922. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4923. if (angular.isUndefined(filtersData['user'])) {
  4924. filtersData['user'] = {};
  4925. }
  4926. filtersData['user'][item.field] = item.filters[0].term;
  4927. }
  4928. }
  4929. });
  4930. $scope.memoryfilterDatashe = filtersData;
  4931. // $scope.loadData(filtersData);
  4932. });
  4933. };
  4934. $scope.interceptMydata = function (mydate, idx, sum) {
  4935. return mydate.slice(idx * sum, (idx + 1) * sum)
  4936. }
  4937. $scope.removeshebei = function (item) {
  4938. event.preventDefault();
  4939. var modalInstance = $modal.open({
  4940. templateUrl: 'assets/views/delete.html',
  4941. controller: function ($scope, $modalInstance, scope) {
  4942. $scope.title = '设备移除';
  4943. $scope.connect = '确定要移除此设备?';
  4944. $scope.consumptive = scope.selected.items;
  4945. $scope.ok = function () {
  4946. $modalInstance.close($scope.consumptive);
  4947. };
  4948. $scope.cancel = function () {
  4949. $modalInstance.dismiss('cancel');
  4950. };
  4951. },
  4952. size: 'sm',
  4953. resolve: {
  4954. scope: function () {
  4955. return $scope;
  4956. },
  4957. }
  4958. });
  4959. modalInstance.result.then(function (selectedItem) {
  4960. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  4961. if (items.id == selectedItem.id) {
  4962. $scope.myDatalingbeiall.splice(index, 1);
  4963. }
  4964. })
  4965. // $scope.myData3.push(selectedItem);
  4966. $scope.model.consumables = $scope.myDatalingbeiall;
  4967. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
  4968. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4970. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
  4971. }
  4972. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4973. })
  4974. }
  4975. $scope.addshebei = function () {
  4976. event.preventDefault();
  4977. var modalInstance = $modal.open({
  4978. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  4979. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
  4980. $scope.langs = i18nService.getAllLangs();
  4981. $scope.lang = 'zh-cn';
  4982. i18nService.setCurrentLang($scope.lang);
  4983. $scope.gridOptions = {};
  4984. $scope.gridOptions.data = 'myDatatwo';
  4985. $scope.gridOptions.enableColumnResizing = true;
  4986. $scope.gridOptions.enableFiltering = false;
  4987. $scope.gridOptions.enableGridMenu = false;
  4988. $scope.gridOptions.showGridFooter = true;
  4989. $scope.gridOptions.showColumnFooter = false;
  4990. $scope.gridOptions.fastWatch = true;
  4991. $scope.gridOptions.useExternalFiltering = true;
  4992. $scope.gridOptions.useExternalPagination = true;
  4993. $scope.gridOptions.paginationPageSizes = [10];
  4994. $scope.gridOptions.paginationPageSize = 10;
  4995. $scope.gridOptions.multiSelect = true;
  4996. $scope.gridOptions.rowIdentity = function (row) {
  4997. return row.id;
  4998. };
  4999. $scope.gridOptions.getRowIdentity = function (row) {
  5000. return row.id;
  5001. };
  5002. // $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>";
  5003. $scope.gridOptions.columnDefs = [{
  5004. name: 'item',
  5005. displayName: '序号',
  5006. width: 80,
  5007. enableFiltering: false
  5008. },
  5009. {
  5010. name: 'uuid',
  5011. displayName: '内部编号',
  5012. width: 175
  5013. },
  5014. {
  5015. name: 'props.hw_mingcheng',
  5016. displayName: '资产名称',
  5017. width: 120
  5018. },
  5019. {
  5020. name: 'props.hw_cifilterClassic',
  5021. displayName: '资产类型',
  5022. width: 80,
  5023. enableFiltering: false
  5024. },
  5025. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  5026. {
  5027. name: 'props.hw_state',
  5028. displayName: '资产状态',
  5029. width: 150,
  5030. enableFiltering: false
  5031. },
  5032. {
  5033. name: 'props.hwnw_area',
  5034. displayName: '资产地点',
  5035. width: 130,
  5036. enableFiltering: false
  5037. },
  5038. {
  5039. name: 'createtime',
  5040. displayName: '申请时间',
  5041. enableFiltering: false
  5042. }
  5043. ];
  5044. // $scope.selectButtonClick
  5045. var defaultFilterData = {
  5046. // "assignee":2,
  5047. // "sign":"basehwitndl",
  5048. // "applicationForm": { "hw_state": "在线" },
  5049. "hw_state": "在库",
  5050. "idx": 0,
  5051. "sum": 10
  5052. };
  5053. $scope.memoryfilterData = {
  5054. // "assignee":2,
  5055. // "sign":"basehwitndl",
  5056. // "applicationForm": { "hw_state": "在线" },
  5057. "hw_state": "在库",
  5058. "idx": 0,
  5059. "sum": 10
  5060. }
  5061. $scope.refreshData = function (style, filterData) {
  5062. if (angular.isUndefined(filterData)) {
  5063. filterData = defaultFilterData;
  5064. }
  5065. $scope.myDatatwo = [];
  5066. // $scope.gridOptions['sum']=filterData.sum;
  5067. api_cmdb.query(filterData).then(function (data) {
  5068. // $scope.callsPending--;
  5069. var filterData = $scope.memoryfilterData;
  5070. var myDatatwo = Restangular.stripRestangular(data);
  5071. $scope.gridOptions['totalItems'] = data.total;
  5072. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  5073. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  5074. }
  5075. $scope.myDatatwo = myDatatwo.data.node;
  5076. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  5077. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5078. }
  5079. }, function () { });
  5080. };
  5081. $scope.refreshData('expand-right', defaultFilterData);
  5082. $scope.gridOptions.onRegisterApi = function (gridApi) {
  5083. $scope.gridApi = gridApi;
  5084. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5085. var filtersData = $scope.memoryfilterData;
  5086. filtersData.idx = newPage - 1;
  5087. filtersData.sum = pageSize;
  5088. // $scope.loadData(filtersData);
  5089. $scope.refreshData('expand-right', filtersData);
  5090. //console.log(pageSize);
  5091. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  5092. });
  5093. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  5094. // $scope.selected.items.push(data.entity);
  5095. //console.log(data);
  5096. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  5097. if (scope.isSelected) {
  5098. scope.grid.appScope.selected.items.push(scope.entity)
  5099. } else {
  5100. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  5101. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  5102. scope.grid.appScope.selected.items.splice(i, 1);
  5103. break;
  5104. }
  5105. }
  5106. }
  5107. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  5108. });
  5109. // });
  5110. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  5111. // $scope.selected.items = data.entity;
  5112. //console.log(data);
  5113. var selectitem = [];
  5114. selectitem = angular.copy($scope.selected.items);
  5115. for (var j = 0; j < rows.length; j++) {
  5116. if (rows[j].isSelected == true) {
  5117. selectitem.push(rows[j].entity);
  5118. } else {
  5119. delete selectitem[j];
  5120. // rows.splice(j, 1);
  5121. }
  5122. }
  5123. $scope.selected.items = [];
  5124. for (var i = 0; i < selectitem.length; i++) {
  5125. if (selectitem[i]) {
  5126. $scope.selected.items.push(selectitem[i]);
  5127. }
  5128. }
  5129. });
  5130. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  5131. // // if (row.entity.age > 45) {
  5132. // row.grid.api.selection.selectRow(row.entity); // 选中行
  5133. // // }
  5134. // };
  5135. gridApi.core.on.filterChanged($scope, function () {
  5136. var grid = this.grid;
  5137. var filtersData = {
  5138. idx: 0,
  5139. sum: 10,
  5140. "user": {
  5141. "roledata": {
  5142. "rolecode": "roleset"
  5143. },
  5144. "selectType": "1"
  5145. }
  5146. };
  5147. angular.forEach(grid.columns, function (item) {
  5148. if (item.enableFiltering) {
  5149. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5150. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5151. if (angular.isUndefined(filtersData['user'])) {
  5152. filtersData['user'] = {};
  5153. }
  5154. filtersData['user'][item.field] = item.filters[0].term;
  5155. }
  5156. }
  5157. });
  5158. $scope.memoryfilterData = filtersData;
  5159. // $scope.loadData(filtersData);
  5160. });
  5161. };
  5162. $scope.onDblClick = function (data, event) {
  5163. // $scope.selected.items = data.entity;
  5164. $scope.selectButtonClick(data, event);
  5165. };
  5166. // $scope.loadData = function(filterData) {
  5167. // // console.log("filtersData=111" + JSON.stringify(filterData))
  5168. // items.fetchItems(filterData, APIService).then(function(data) {
  5169. // var myDatatwo = Restangular.stripRestangular(data);
  5170. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  5171. // $scope.myDatatwo = myDatatwo.list;
  5172. // });
  5173. // };
  5174. $scope.title = title;
  5175. //树形图
  5176. var apple_selected, tree, treedata_avm, treedata_geography;
  5177. $scope.my_tree_handler = function (branch) {
  5178. //var _ref;
  5179. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  5180. api_cmdb.query({
  5181. 'sign': classify
  5182. }).then(function (data) {
  5183. var myDatalingbei = Restangular.stripRestangular(data);
  5184. // console.log(myData.data.node);
  5185. if (myDatalingbei.data && myDatalingbei.status == 200) {
  5186. var ret = myDatalingbei.data;
  5187. redrawSvg(myDatalingbei);
  5188. }
  5189. });
  5190. };
  5191. $scope.my_data = [];
  5192. function convertListToTree(data, treeMap) {
  5193. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  5194. var root = null; //Initially set our loop to null
  5195. var parentNode = null;
  5196. //loop over data
  5197. for (var i = 0; i < data.length; i++) {
  5198. var datum = data[i];
  5199. //each node will have children, so let's give it a "children" poperty
  5200. datum.children = [];
  5201. //add an entry for this node to the map so that any future children can
  5202. //lookup the parent
  5203. idToNodeMap[datum.id] = datum;
  5204. //Does this node have a parent?
  5205. if (typeof datum.parent === "undefined" || datum.parent == null) {
  5206. //Doesn't look like it, so this node is the root of the tree
  5207. root = datum;
  5208. treeMap[datum.id] = root;
  5209. } else {
  5210. //This node has a parent, so let's look it up using the id
  5211. parentNode = idToNodeMap[datum.parent.id];
  5212. //We don't need this property, so let's delete it.
  5213. delete datum.parent;
  5214. //Let's add the current node as a child of the parent node.
  5215. parentNode.children.push(datum);
  5216. }
  5217. }
  5218. return root;
  5219. }
  5220. function convertParentToChildList(data) {
  5221. var treeMap = {};
  5222. var list = [];
  5223. convertListToTree(data, treeMap);
  5224. angular.forEach(treeMap, function (item) {
  5225. list.push(item);
  5226. });
  5227. return list;
  5228. }
  5229. $scope.my_tree = tree = {};
  5230. $scope.try_async_load = function () {
  5231. $scope.my_data = [];
  5232. $scope.select_treedata = [];
  5233. $scope.doing_async = true;
  5234. api_configure_data.fetchDataList('ciclassify', {
  5235. 'idx': 0,
  5236. 'sum': 100
  5237. }).then(function (result) {
  5238. //console.log(result['list']);
  5239. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  5240. $scope.doing_async = false;
  5241. // tree.expand_all();
  5242. //console.log(treelist);
  5243. });
  5244. };
  5245. $scope.select_treedata = [];
  5246. $scope.propTypeOptions = [];
  5247. $scope.try_async_load();
  5248. $scope.onFilterremove = function (item) {
  5249. console.log(item)
  5250. }
  5251. $scope.searchdata = {};
  5252. $scope.clear = function () {
  5253. $scope.searchdata = {};
  5254. $scope.cifilter_classic = {};
  5255. $scope.try_async_load();
  5256. var fildata = {
  5257. idx: 0,
  5258. sum: 10,
  5259. 'hw_state': '在库'
  5260. }
  5261. $scope.memoryfilterData = fildata;
  5262. $scope.refreshData('expand-right', fildata);
  5263. }
  5264. $scope.cifilter_classic = {};
  5265. $scope.chiceIncident = function (item) {
  5266. var fildata = defaultFilterData;
  5267. // fildata.applicationForm = {};
  5268. // sign: basehwnwswt
  5269. if (item && item.id) {
  5270. var classify = item.prefix.toLowerCase() + item.sign;
  5271. fildata.sign = classify
  5272. } else {
  5273. delete fildata.sign
  5274. }
  5275. $scope.gridOptions.paginationCurrentPage = 1;
  5276. var transitiondata = angular.copy(item);
  5277. $scope.refreshData('expand-right', fildata);
  5278. }
  5279. $scope.applicadata = [];
  5280. $scope.onFilterCallback = function (item) {
  5281. var tempclassify = item.prefix.toLowerCase() + item.sign;
  5282. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  5283. var myData = Restangular.stripRestangular(data);
  5284. $scope.applicadata = myData[0].form.fields;
  5285. });
  5286. // }
  5287. }
  5288. // $scope.loadData({
  5289. // idx: 0,
  5290. // sum: 10,
  5291. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5292. // });
  5293. $scope.selected = {
  5294. items: []
  5295. };
  5296. $scope.ok = function () {
  5297. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  5298. // onDataCallback($scope.selected.item, parentScope);
  5299. // }
  5300. $modalInstance.close($scope.selected.items);
  5301. };
  5302. $scope.cancel = function () {
  5303. $modalInstance.dismiss('cancel');
  5304. };
  5305. },
  5306. size: 'lg',
  5307. resolve: {
  5308. items: function () {
  5309. return {
  5310. fetchItems: function (filterData, APIService) {
  5311. filterData = filterData || {};
  5312. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  5313. filterData = {
  5314. idx: 0,
  5315. sum: 10,
  5316. "user": {
  5317. "roledata": {
  5318. "rolecode": "roleset"
  5319. },
  5320. "selectType": "1"
  5321. }
  5322. };
  5323. }
  5324. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  5325. }
  5326. };
  5327. },
  5328. title: function () {
  5329. return $scope.options.templateOptions.label;
  5330. },
  5331. Restangular: function () {
  5332. return $scope.options.templateOptions.Restangular;
  5333. },
  5334. APIService: function () {
  5335. return $scope.options.templateOptions.ApiService;
  5336. },
  5337. onDataCallback: function () {
  5338. return $scope.options.templateOptions.callback;
  5339. },
  5340. parentScope: function () {
  5341. return $scope.options.templateOptions.that;
  5342. }
  5343. }
  5344. });
  5345. modalInstance.result.then(function (selectedItem) {
  5346. // console.log(selectedItem);
  5347. // options.value(selectedItem);
  5348. var filterData = $scope.memoryfilterDatashe;
  5349. $scope.myDatalingbeiall = selectedItem;
  5350. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5351. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5352. $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5353. }
  5354. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5355. $scope.model.assets = $scope.myDatalingbeiall;
  5356. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
  5357. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  5358. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  5359. // }
  5360. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  5361. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  5362. // }
  5363. }, function () {
  5364. //console.log('Modal dismissed at: ' + new Date());
  5365. });
  5366. }
  5367. $scope.onDblClick = function (data, event) {
  5368. $scope.selectButtonClick(data, event);
  5369. };
  5370. // $scope.loadData = function(filterData) {};
  5371. // $scope.title = title;
  5372. // $scope.loadData({
  5373. // idx: 0,
  5374. // sum: 20,
  5375. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5376. // });
  5377. $scope.selected = {
  5378. items: []
  5379. };
  5380. //grid2
  5381. $scope.langs = i18nService.getAllLangs();
  5382. $scope.lang = 'zh-cn';
  5383. i18nService.setCurrentLang($scope.lang);
  5384. $scope.gridOptions2 = {};
  5385. $scope.gridOptions2.data = 'myDataone';
  5386. $scope.gridOptions2.enableColumnResizing = true;
  5387. $scope.gridOptions2.enableFiltering = false;
  5388. $scope.gridOptions2.enableGridMenu = false;
  5389. $scope.gridOptions2.showGridFooter = true;
  5390. $scope.gridOptions2.showColumnFooter = false;
  5391. $scope.gridOptions2.fastWatch = true;
  5392. $scope.gridOptions2.useExternalFiltering = true;
  5393. $scope.gridOptions2.useExternalPagination = true;
  5394. $scope.gridOptions2.paginationPageSizes = [10];
  5395. $scope.gridOptions2.paginationPageSize = 10;
  5396. $scope.gridOptions2.multiSelect = false;
  5397. // $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>";
  5398. $scope.gridOptions2.columnDefs = [{
  5399. name: 'item',
  5400. displayName: '序号',
  5401. width: 120
  5402. },
  5403. {
  5404. name: 'name',
  5405. displayName: '耗材名称',
  5406. width: 150,
  5407. enableFiltering: false
  5408. },
  5409. {
  5410. name: 'model',
  5411. displayName: '品牌/型号',
  5412. width: 100,
  5413. enableFiltering: false
  5414. },
  5415. {
  5416. name: 'Specifications',
  5417. displayName: '规格',
  5418. width: 150,
  5419. enableFiltering: false
  5420. },
  5421. {
  5422. name: 'sum',
  5423. displayName: '领用数量',
  5424. enableFiltering: false
  5425. }
  5426. ];
  5427. // $scope.selectButtonClick
  5428. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5429. $scope.gridApi = gridApi;
  5430. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5431. // var filtersData = $scope.memoryfilterData;
  5432. // filtersData.idx = newPage - 1;
  5433. // filtersData.sum = pageSize;
  5434. // $scope.loadData(filtersData);
  5435. $scope.memoryfilterDatahao.idx = newPage - 1;
  5436. $scope.memoryfilterDatahao.sum = pageSize;
  5437. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
  5438. });
  5439. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5440. $scope.selected.items.push(data.entity);
  5441. //console.log(data);
  5442. });
  5443. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  5444. $scope.selected.items.push(data.entity);
  5445. //console.log(data);
  5446. });
  5447. gridApi.core.on.filterChanged($scope, function () {
  5448. var grid = this.grid;
  5449. var filtersData = {
  5450. idx: 0,
  5451. sum: 10,
  5452. "user": {
  5453. "roledata": {
  5454. "rolecode": "roleset"
  5455. },
  5456. "selectType": "1"
  5457. }
  5458. };
  5459. angular.forEach(grid.columns, function (item) {
  5460. if (item.enableFiltering) {
  5461. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5462. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5463. if (angular.isUndefined(filtersData['user'])) {
  5464. filtersData['user'] = {};
  5465. }
  5466. filtersData['user'][item.field] = item.filters[0].term;
  5467. }
  5468. }
  5469. });
  5470. $scope.memoryfilterDatahao = filtersData;
  5471. $scope.loadData(filtersData);
  5472. });
  5473. };
  5474. $scope.removehaocai = function (item) {
  5475. event.preventDefault();
  5476. // var modalInstance = $modal.open({
  5477. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  5478. // controller: function($scope, $modalInstance) {
  5479. // $scope.title = "修改耗材数量";
  5480. // $scope.consumptive = item;
  5481. // $scope.ok = function() {
  5482. // $modalInstance.close($scope.consumptive);
  5483. // };
  5484. // $scope.cancel = function() {
  5485. // $modalInstance.dismiss('cancel');
  5486. // };
  5487. // },
  5488. // size: 'sm'
  5489. // });
  5490. var modalInstance = $modal.open({
  5491. templateUrl: 'assets/views/delete.html',
  5492. controller: function ($scope, $modalInstance, scope) {
  5493. $scope.title = '耗材移除';
  5494. $scope.connect = '确定要移除此设备?';
  5495. $scope.consumptive = scope.selected.items[0];
  5496. $scope.ok = function () {
  5497. $modalInstance.close($scope.consumptive);
  5498. };
  5499. $scope.cancel = function () {
  5500. $modalInstance.dismiss('cancel');
  5501. };
  5502. },
  5503. size: 'sm',
  5504. resolve: {
  5505. scope: function () {
  5506. return $scope;
  5507. },
  5508. }
  5509. });
  5510. modalInstance.result.then(function (selectedItem) {
  5511. // angular.forEach($scope.myData3, function(items, index) {
  5512. // if (items.id == selectedItem.id) {
  5513. // $scope.myData3[index] = selectedItem;
  5514. // }
  5515. // })
  5516. // $scope.model.applicationForm.consumables = $scope.myData3;
  5517. angular.forEach($scope.myDataoneall, function (items, index) {
  5518. if (items.id == selectedItem.id) {
  5519. $scope.myDataoneall.splice(index, 1);
  5520. }
  5521. })
  5522. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5523. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5524. }
  5525. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5526. $scope.model.consumables = $scope.myDataoneall;
  5527. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5528. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5529. $scope.selected = {
  5530. items: []
  5531. };
  5532. })
  5533. }
  5534. $scope.haocaiadd = function () {
  5535. event.preventDefault();
  5536. var modalInstance = $modal.open({
  5537. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  5538. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  5539. $scope.haocainame = [];
  5540. $scope.pinpai = [];
  5541. $scope.guige = [];
  5542. $scope.consumptive = {};
  5543. $scope.consumpall = {};
  5544. $scope.title = "添加耗材";
  5545. api_wechatfile.getDictionaryForList({
  5546. "key": "haocaifenlei"
  5547. }).then(function (data) {
  5548. $scope.haocainame = data;
  5549. })
  5550. $scope.clearNoNum = function (obj, attr) {
  5551. //先把非数字的都替换掉,除了数字和.
  5552. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5553. //必须保证第一个为数字而不是.
  5554. obj[attr] = obj[attr].replace(/^\./g, "");
  5555. //保证只有出现一个.而没有多个.
  5556. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5557. //保证.只出现一次,而不能出现两次以上
  5558. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  5559. //小于最大值
  5560. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5561. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5562. obj[attr] = '';
  5563. }
  5564. }
  5565. $scope.onChange = function (parent) {
  5566. $scope.consumptive.model = {};
  5567. $scope.consumptive.Specifications = {};
  5568. api_wechatfile.getDictionaryForList({
  5569. "key": "pinpai",
  5570. "parent": parent.id
  5571. }).then(function (data) {
  5572. $scope.pinpai = data;
  5573. })
  5574. api_wechatfile.getDictionaryForList({
  5575. "key": "guige",
  5576. "parent": parent.id
  5577. }).then(function (data) {
  5578. $scope.guige = data;
  5579. })
  5580. }
  5581. $scope.onChangesum = function (item) {
  5582. if (item.name && item.model.id && item.Specifications.id) {
  5583. $scope.consumptive.sum = "";
  5584. var data1 = {
  5585. "idx": 0,
  5586. "sum": 10,
  5587. "consumable": {
  5588. "name": item.name.name,
  5589. "brandModel": item.model.name,
  5590. "specification": item.Specifications.name
  5591. }
  5592. }
  5593. api_cmdb3.fetchDataList('consumable', data1).then(function (data) {
  5594. if (data.status == 200 && data.list.length > 0) {
  5595. var myData = data.list;
  5596. $scope.consumpall = myData[0];
  5597. $scope.maxsum = myData[0].inventoryNum;
  5598. } else {
  5599. SweetAlert.swal({
  5600. title: "不存在该耗材",
  5601. text: "请检查库存后重新填写!",
  5602. type: "error"
  5603. });
  5604. }
  5605. });
  5606. }
  5607. }
  5608. $scope.addhaocai = function () {
  5609. $modalInstance.dismiss('cancel');
  5610. scope.haocaiopen($scope.consumptive);
  5611. }
  5612. $scope.ok = function (item) {
  5613. var items = {};
  5614. // if (item.name && item.model && item.Specifications && item.sum) {
  5615. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5616. // $scope.consumpall.model = $scope.consumpall.brandModel;
  5617. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  5618. // $scope.consumpall.sum = item.sum;
  5619. // delete $scope.consumpall.brandModel;
  5620. // delete $scope.consumpall.specification;
  5621. // $modalInstance.close($scope.consumpall);
  5622. // } else {
  5623. // SweetAlert.swal({
  5624. // title: "数据填写不完整!",
  5625. // text: "请检查数据然后提交!",
  5626. // type: "error"
  5627. // });
  5628. // }
  5629. var isold = false;
  5630. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  5631. for (var i = 0; i < scope.myDataoneall.length; i++) {
  5632. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  5633. isold = true;
  5634. }
  5635. }
  5636. if (isold) {
  5637. SweetAlert.swal({
  5638. title: "该耗材已添加!",
  5639. text: "请不要重复添加耗材!",
  5640. type: "error"
  5641. });
  5642. } else {
  5643. $scope.consumpall.model = $scope.consumpall.brandModel;
  5644. $scope.consumpall.Specifications = $scope.consumpall.specification;
  5645. $scope.consumpall.sum = item.sum;
  5646. delete $scope.consumpall.brandModel;
  5647. delete $scope.consumpall.specification;
  5648. $modalInstance.close($scope.consumpall);
  5649. }
  5650. } else {
  5651. SweetAlert.swal({
  5652. title: "数据填写不完整!",
  5653. text: "请检查数据然后提交!",
  5654. type: "error"
  5655. });
  5656. }
  5657. // $modalInstance.close(item);
  5658. };
  5659. $scope.cancel = function () {
  5660. $modalInstance.dismiss('cancel');
  5661. };
  5662. },
  5663. size: 'sm',
  5664. resolve: {
  5665. scope: function () {
  5666. return $scope;
  5667. }
  5668. }
  5669. });
  5670. modalInstance.result.then(function (selectedItem) {
  5671. $scope.myDataoneall.push(selectedItem);
  5672. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5673. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5674. }
  5675. // $scope.model.consumables = $scope.myDataone;
  5676. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5677. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5678. $scope.model.consumables = $scope.myDataoneall;
  5679. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5680. })
  5681. }
  5682. $scope.onDblClick = function (data, event) {
  5683. $scope.selectButtonClick(data, event);
  5684. };
  5685. $scope.memoryfilterDatahao = {
  5686. "idx": 0,
  5687. "sum": 10,
  5688. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5689. }
  5690. $scope.myDataone = [];
  5691. $scope.loadData = function (filterData) { };
  5692. // $scope.title = title;
  5693. $scope.ldloading = {};
  5694. $scope.selected = {
  5695. items: []
  5696. };
  5697. if ($scope.$parent.$parent.$parent.model.gettype) {
  5698. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  5699. if ($scope.model.assets) {
  5700. if (JSON.stringify($scope.model.assets) == "{}") {
  5701. $scope.model.assets = []
  5702. } else {
  5703. $scope.model.assets = JSON.parse($scope.model.assets);
  5704. }
  5705. $scope.myDatalingbeiall = $scope.model.assets;
  5706. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5707. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
  5708. }
  5709. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5710. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5711. }
  5712. if ($scope.model.consumables) {
  5713. if (JSON.stringify($scope.model.consumables) == "{}") {
  5714. $scope.model.consumables = []
  5715. } else {
  5716. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5717. }
  5718. $scope.myDataoneall = $scope.model.consumables;
  5719. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5720. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5721. }
  5722. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5723. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5724. }
  5725. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5726. $scope.options.templateOptions.getpush({
  5727. "hao": true,
  5728. "gu": true
  5729. });
  5730. } else {
  5731. $scope.options.templateOptions.getpush({
  5732. "hao": true
  5733. });
  5734. }
  5735. } else {
  5736. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5737. $scope.options.templateOptions.getpush({
  5738. "gu": true
  5739. });
  5740. }
  5741. }
  5742. }
  5743. }]
  5744. });
  5745. formlyConfigProvider.setType({
  5746. name: 'ui-panel',
  5747. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  5748. });
  5749. formlyConfigProvider.setType({
  5750. name: 'ui-currentuser',
  5751. extends: 'input',
  5752. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  5753. defaultOptions: function (options) {
  5754. return {
  5755. templateOptions: {
  5756. // link: function() {}
  5757. }
  5758. };
  5759. },
  5760. controller: ['$scope', function ($scope) {
  5761. if ($scope.options.templateOptions.user) {
  5762. if (angular.isFunction($scope.options.templateOptions.transform)) {
  5763. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  5764. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  5765. // }
  5766. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5767. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5768. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  5769. }
  5770. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  5771. $scope.options.initialValue = $scope.model[$scope.options.key];
  5772. }
  5773. }]
  5774. });
  5775. //仪表盘
  5776. //待处理变更列表
  5777. formlyConfigProvider.setType({
  5778. name: 'ui-ngpchangetable',
  5779. templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
  5780. defaultOptions: function (options) {
  5781. return {
  5782. templateOptions: {
  5783. // relationAction: function() {
  5784. // options.hideExpression = true
  5785. // }
  5786. }
  5787. };
  5788. },
  5789. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5790. // var filterData = {
  5791. // "assignee": $rootScope.user.id,
  5792. // "searchtype": "all",
  5793. // "idx": "0",
  5794. // "sum": "10"
  5795. // };
  5796. var filterData = {
  5797. "idx": "0",
  5798. "sum": "10",
  5799. "assignee": 2,
  5800. "searchType": "todo"
  5801. }
  5802. $scope.incidentprocess = function (item) {
  5803. $state.go('app.wt_change.add', {
  5804. taskId: item.taskId,
  5805. processInstanceId: item.processInstanceId
  5806. });
  5807. }
  5808. $scope.more = function () {
  5809. $state.go('app.wt_change.list', {})
  5810. }
  5811. api_bpm_domain.fetchtask('bpm_change', filterData).then(function (data) {
  5812. if (data.data) {
  5813. $scope.myData = data.data;
  5814. } else {
  5815. SweetAlert.swal({
  5816. title: "操作异常!",
  5817. text: "系统异常,请稍后重试,或者联系管理员!",
  5818. type: "error"
  5819. });
  5820. }
  5821. })
  5822. $scope.removes = function () {
  5823. var modalInstance = $modal.open({
  5824. templateUrl: 'assets/views/delete.html',
  5825. controller: function ($scope, $modalInstance) {
  5826. $scope.ok = function () {
  5827. $modalInstance.close();
  5828. };
  5829. $scope.cancel = function () {
  5830. $modalInstance.dismiss('cancel');
  5831. };
  5832. },
  5833. size: 'sm'
  5834. });
  5835. modalInstance.result.then(function () {
  5836. console.log($scope.$parent.$parent.$parent.$parent)
  5837. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5838. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5839. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5840. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5841. break;
  5842. }
  5843. }
  5844. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5845. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5846. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5847. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5848. }
  5849. })
  5850. }
  5851. }]
  5852. });
  5853. //待处理问题列表
  5854. formlyConfigProvider.setType({
  5855. name: 'ui-ngproblemtable',
  5856. templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
  5857. defaultOptions: function (options) {
  5858. return {
  5859. templateOptions: {
  5860. // relationAction: function() {
  5861. // options.hideExpression = true
  5862. // }
  5863. }
  5864. };
  5865. },
  5866. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
  5867. var filterData = {
  5868. "assignee": $rootScope.user.id,
  5869. "candidateGroups": $rootScope.user.group[0].id,
  5870. "searchtype": "todo",
  5871. "idx": 0,
  5872. "sum": 10
  5873. };
  5874. $scope.incidentprocess = function (item) {
  5875. $state.go('app.wt_change.add', {
  5876. taskId: item.taskId,
  5877. processInstanceId: item.processInstanceId
  5878. });
  5879. }
  5880. $scope.more = function () {
  5881. $state.go('app.wt_change.list', {})
  5882. }
  5883. api_bpm_data.fetchDataList('changeclassify', filterData).then(function (data) {
  5884. if (data.data) {
  5885. $scope.myData = data.data;
  5886. } else {
  5887. SweetAlert.swal({
  5888. title: "操作异常!",
  5889. text: "系统异常,请稍后重试,或者联系管理员!",
  5890. type: "error"
  5891. });
  5892. }
  5893. })
  5894. $scope.removes = function () {
  5895. var modalInstance = $modal.open({
  5896. templateUrl: 'assets/views/delete.html',
  5897. controller: function ($scope, $modalInstance) {
  5898. $scope.ok = function () {
  5899. $modalInstance.close();
  5900. };
  5901. $scope.cancel = function () {
  5902. $modalInstance.dismiss('cancel');
  5903. };
  5904. },
  5905. size: 'sm'
  5906. });
  5907. modalInstance.result.then(function () {
  5908. console.log($scope.$parent.$parent.$parent.$parent)
  5909. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5910. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5911. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5912. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5913. break;
  5914. }
  5915. }
  5916. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5917. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5918. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5919. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5920. }
  5921. })
  5922. }
  5923. }]
  5924. });
  5925. //待处理事件列表
  5926. formlyConfigProvider.setType({
  5927. name: 'ui-ngtable',
  5928. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  5929. defaultOptions: function (options) {
  5930. return {
  5931. templateOptions: {
  5932. // relationAction: function() {
  5933. // options.hideExpression = true
  5934. // }
  5935. }
  5936. };
  5937. },
  5938. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5939. var filterData = {
  5940. "assignee": $rootScope.user.id,
  5941. "candidateGroups": $rootScope.user.group[0].id,
  5942. "searchtype": "done",
  5943. "idx": 0,
  5944. "sum": 10
  5945. };
  5946. $scope.incidentprocess = function (item) {
  5947. $state.go('app.incident.editor', {
  5948. taskId: item.taskId,
  5949. processInstanceId: item.processInstanceId
  5950. });
  5951. }
  5952. $scope.more = function () {
  5953. $state.go('app.incident.list', {})
  5954. }
  5955. api_bpm_domain.fetchtask('bpm_incident', filterData).then(function (data) {
  5956. if (data.data) {
  5957. $scope.myData = data.data;
  5958. } else {
  5959. SweetAlert.swal({
  5960. title: "操作异常!",
  5961. text: "系统异常,请稍后重试,或者联系管理员!",
  5962. type: "error"
  5963. });
  5964. }
  5965. })
  5966. $scope.removes = function () {
  5967. var modalInstance = $modal.open({
  5968. templateUrl: 'assets/views/delete.html',
  5969. controller: function ($scope, $modalInstance) {
  5970. $scope.ok = function () {
  5971. $modalInstance.close();
  5972. };
  5973. $scope.cancel = function () {
  5974. $modalInstance.dismiss('cancel');
  5975. };
  5976. },
  5977. size: 'sm'
  5978. });
  5979. modalInstance.result.then(function () {
  5980. console.log($scope.$parent.$parent.$parent.$parent)
  5981. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5982. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5983. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5984. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5985. break;
  5986. }
  5987. }
  5988. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5989. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5990. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5991. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5992. }
  5993. })
  5994. }
  5995. }]
  5996. });
  5997. //知识库列表
  5998. formlyConfigProvider.setType({
  5999. name: 'ui-knowledge',
  6000. templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
  6001. defaultOptions: function (options) {
  6002. return {
  6003. templateOptions: {
  6004. // relationAction: function() {
  6005. // options.hideExpression = true
  6006. // }
  6007. }
  6008. };
  6009. },
  6010. controller: ['$scope', '$modal', '$timeout', 'api_solution', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, api_solution, $rootScope, ngTableParams, $filter, $state) {
  6011. var filterData = {
  6012. "key": "null",
  6013. "pageIndex": 0,
  6014. "pageSum": 6,
  6015. "status": 0,
  6016. "userId": $rootScope.user.id
  6017. };
  6018. $scope.model.removereport = false;
  6019. $scope.removes = function () {
  6020. $scope.model.removereport = true;
  6021. }
  6022. $scope.more = function () {
  6023. $state.go('app.knowledge.manager', {});
  6024. }
  6025. api_solution.findSolutionByKeys(filterData).then(function (data) {
  6026. if (data.status == 200) {
  6027. $scope.myData = data.list
  6028. }
  6029. })
  6030. $scope.removes = function () {
  6031. var modalInstance = $modal.open({
  6032. templateUrl: 'assets/views/delete.html',
  6033. controller: function ($scope, $modalInstance) {
  6034. $scope.ok = function () {
  6035. $modalInstance.close();
  6036. };
  6037. $scope.cancel = function () {
  6038. $modalInstance.dismiss('cancel');
  6039. };
  6040. },
  6041. size: 'sm'
  6042. });
  6043. modalInstance.result.then(function () {
  6044. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6045. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6046. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6047. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6048. break;
  6049. }
  6050. }
  6051. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6052. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6053. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6054. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6055. }
  6056. })
  6057. }
  6058. }]
  6059. });
  6060. //公告列表
  6061. formlyConfigProvider.setType({
  6062. name: 'ui-ngnotice',
  6063. templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
  6064. defaultOptions: function (options) {
  6065. return {
  6066. templateOptions: {
  6067. // relationAction: function() {
  6068. // options.hideExpression = true
  6069. // }
  6070. }
  6071. };
  6072. },
  6073. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
  6074. var filterData = {
  6075. "idx": 0,
  6076. "sum": 10
  6077. };
  6078. // $scope.$scope.model.className = "col-xs-12";
  6079. api_user_data.fetchDataList('notice', filterData).then(function (data) {
  6080. if (data) {
  6081. $scope.myData = data.data;
  6082. } else {
  6083. SweetAlert.swal({
  6084. title: "操作异常!",
  6085. text: "系统异常,请稍后重试,或者联系管理员!",
  6086. type: "error"
  6087. });
  6088. }
  6089. })
  6090. $scope.more = function () {
  6091. $state.go('app.system.notice.list', {});
  6092. }
  6093. $scope.removes = function () {
  6094. var modalInstance = $modal.open({
  6095. templateUrl: 'assets/views/delete.html',
  6096. controller: function ($scope, $modalInstance) {
  6097. $scope.ok = function () {
  6098. $modalInstance.close();
  6099. };
  6100. $scope.cancel = function () {
  6101. $modalInstance.dismiss('cancel');
  6102. };
  6103. },
  6104. size: 'sm'
  6105. });
  6106. modalInstance.result.then(function () {
  6107. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6108. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6109. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6110. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6111. break;
  6112. }
  6113. }
  6114. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6115. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6116. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6117. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6118. }
  6119. })
  6120. }
  6121. }]
  6122. });
  6123. //事件统计图
  6124. formlyConfigProvider.setType({
  6125. name: 'ui-incidentreport',
  6126. templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
  6127. defaultOptions: function (options) {
  6128. return {
  6129. templateOptions: {
  6130. // relationAction: function() {
  6131. // options.hideExpression = true
  6132. // }
  6133. }
  6134. };
  6135. },
  6136. controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function ($scope, $modal, moment, api_report, $cookieStore) {
  6137. api_report.getLicenseKey().then(function (response) {
  6138. $cookieStore.put('Auth-Token', response.token);
  6139. $scope.try_async_load();
  6140. });
  6141. $scope.try_async_load = function () {
  6142. $scope.my_data = [];
  6143. api_report.list().then(function (response) {
  6144. var dataList = response;
  6145. getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
  6146. $scope.repoRoot.name = "事件报表"
  6147. convertRepoObject($scope.repoRoot);
  6148. $scope.my_data.push($scope.repoRoot);
  6149. });
  6150. };
  6151. var workspace = {};
  6152. $scope.repoRoot = null;
  6153. function getRepoRoot(repo, path) {
  6154. angular.forEach(repo, function (value, key) {
  6155. if (value.path == path) {
  6156. $scope.repoRoot = value;
  6157. } else {
  6158. if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
  6159. getRepoRoot(value.repoObjects, path);
  6160. } else {
  6161. }
  6162. }
  6163. });
  6164. }
  6165. function convertRepoObject(repo) {
  6166. if (angular.isArray(repo)) {
  6167. angular.forEach(repo, function (value, key) {
  6168. convertRepoObject(value);
  6169. })
  6170. } else {
  6171. if (angular.isDefined(repo.name)) {
  6172. if (repo.name.indexOf(".") >= 0) {
  6173. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  6174. } else {
  6175. repo.label = repo.name;
  6176. }
  6177. //delete repo.name;
  6178. }
  6179. if (angular.isDefined(repo.repoObjects)) {
  6180. repo.children = [];
  6181. repo.children = repo.repoObjects;
  6182. delete repo.repoObjects;
  6183. convertRepoObject(repo.children);
  6184. }
  6185. }
  6186. }
  6187. function parseDateParameter(parameters) {
  6188. var result = undefined;
  6189. if (angular.isArray(parameters)) {
  6190. // angular.forEach(parmeters,function(param){
  6191. // param.
  6192. // })
  6193. } else {
  6194. result = {};
  6195. for (var k in parameters) {
  6196. if (k.indexOf("Date") > 0) {
  6197. if (angular.isString(parameters[k])) {
  6198. result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
  6199. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  6200. }
  6201. }
  6202. }
  6203. }
  6204. return result;
  6205. }
  6206. function ConvertDateParameter(parameters) {
  6207. var result = undefined;
  6208. if (angular.isArray(parameters)) {
  6209. //
  6210. } else {
  6211. result = {};
  6212. for (var k in parameters) {
  6213. if (k.indexOf("Date") > 0) {
  6214. if (angular.isDate(parameters[k])) {
  6215. result[k] = moment(parameters[k]).format("YYYYMMDD");
  6216. } else if (angular.isString(parameters[k])) {
  6217. result[k] = parameters[k];
  6218. }
  6219. }
  6220. }
  6221. }
  6222. return result;
  6223. }
  6224. var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  6225. var queryUUID;
  6226. function genUUID() {
  6227. var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
  6228. function (c) {
  6229. var r = Math.random() * 16 | 0,
  6230. v = c == 'x' ? r : (r & 0x3 | 0x8);
  6231. return v.toString(16);
  6232. }).toUpperCase();
  6233. return uuid;
  6234. }
  6235. queryUUID = genUUID();
  6236. var pathincidenttimekey = [];
  6237. var incidenttime = {
  6238. 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
  6239. 'endtimes': moment(new Date()).format('YYYYMMDD')
  6240. };
  6241. var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
  6242. var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
  6243. var averages = [
  6244. [thisdaymine - 86400000 * 14, 0],
  6245. [thisdaymine - 86400000 * 13, 0],
  6246. [thisdaymine - 86400000 * 12, 0],
  6247. [thisdaymine - 86400000 * 11, 0],
  6248. [thisdaymine - 86400000 * 10, 0],
  6249. [thisdaymine - 86400000 * 9, 0],
  6250. [thisdaymine - 86400000 * 8, 0],
  6251. [thisdaymine - 86400000 * 7, 0],
  6252. [thisdaymine - 86400000 * 6, 0],
  6253. [thisdaymine - 86400000 * 5, 0],
  6254. [thisdaymine - 86400000 * 4, 0],
  6255. [thisdaymine - 86400000 * 3, 0],
  6256. [thisdaymine - 86400000 * 2, 0],
  6257. [thisdaymine - 86400000 * 1, 0],
  6258. [thisdaymine, 0]
  6259. ];
  6260. var getreportdata = function (incidenttime, path) {
  6261. api_report.getMdx(path, queryUUID).then(function (response) {
  6262. var mdxquery = response;
  6263. workspace.query = mdxquery;
  6264. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  6265. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  6266. $scope.parameters = parseDateParameter(workspace.query.parameters);
  6267. weekuser(mdxquery);
  6268. });
  6269. }
  6270. getreportdata(incidenttime, incidentchart);
  6271. var weekuser = function (mdxquery) {
  6272. var key = [];
  6273. api_report.execute(mdxquery).then(function (data) {
  6274. $scope.rheaders = [];
  6275. $scope.rRows = [];
  6276. var reportData = data;
  6277. if (reportData.cellset == null || reportData.cellset.length == 0) {
  6278. $scope.shows = true;
  6279. $scope.empty = "数据为空!"
  6280. } else {
  6281. angular.forEach(reportData.cellset, function (item, i) {
  6282. angular.forEach(averages, function (index, j) {
  6283. // angular.forEach(averages, function(item, index) {
  6284. if (item.length > 1 && i > 0 && item[1].value != '') {
  6285. if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
  6286. index[1] = Number(item[1].value);
  6287. }
  6288. // 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)]);
  6289. }
  6290. // })
  6291. })
  6292. })
  6293. incidentchartfun(averages);
  6294. }
  6295. })
  6296. }
  6297. var incidentchartfun = function (incidentchartkey) {
  6298. // $scope.isMaskincident = false;
  6299. Highcharts.chart('incidentchart', {
  6300. title: {
  6301. text: '事件近15天趋势图'
  6302. },
  6303. xAxis: {
  6304. type: 'datetime',
  6305. labels: {
  6306. align: 'left',
  6307. step: 1
  6308. }
  6309. },
  6310. yAxis: {
  6311. title: {
  6312. text: null
  6313. }
  6314. },
  6315. tooltip: {
  6316. crosshairs: true,
  6317. shared: true,
  6318. valueSuffix: '条'
  6319. },
  6320. legend: {},
  6321. series: [{
  6322. name: '生成事件',
  6323. data: incidentchartkey,
  6324. zIndex: 1,
  6325. marker: {
  6326. fillColor: 'white',
  6327. lineWidth: 2,
  6328. lineColor: Highcharts.getOptions().colors[0]
  6329. }
  6330. }]
  6331. });
  6332. }
  6333. $scope.data = {
  6334. labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
  6335. datasets: [{
  6336. label: '新增事件数量',
  6337. fillColor: 'rgba(220,220,220,0.2)',
  6338. strokeColor: 'rgba(220,220,220,1)',
  6339. pointColor: 'rgba(220,220,220,1)',
  6340. pointStrokeColor: '#fff',
  6341. pointHighlightFill: '#fff',
  6342. pointHighlightStroke: 'rgba(220,220,220,1)',
  6343. data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
  6344. },
  6345. {
  6346. label: '已解决事件数量',
  6347. fillColor: 'rgba(151,187,205,0.2)',
  6348. strokeColor: 'rgba(151,187,205,1)',
  6349. pointColor: 'rgba(151,187,205,1)',
  6350. pointStrokeColor: '#fff',
  6351. pointHighlightFill: '#fff',
  6352. pointHighlightStroke: 'rgba(151,187,205,1)',
  6353. data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
  6354. }
  6355. ]
  6356. };
  6357. $scope.removes = function () {
  6358. var modalInstance = $modal.open({
  6359. templateUrl: 'assets/views/delete.html',
  6360. controller: function ($scope, $modalInstance) {
  6361. $scope.ok = function () {
  6362. $modalInstance.close();
  6363. };
  6364. $scope.cancel = function () {
  6365. $modalInstance.dismiss('cancel');
  6366. };
  6367. },
  6368. size: 'sm'
  6369. });
  6370. modalInstance.result.then(function () {
  6371. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6372. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6373. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6374. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6375. break;
  6376. }
  6377. }
  6378. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6379. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6380. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6381. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6382. }
  6383. })
  6384. }
  6385. var addDatas = 0;
  6386. var resolve = 0;
  6387. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  6388. addDatas = addDatas + $scope.data.datasets[0].data[i];
  6389. }
  6390. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  6391. resolve = resolve + $scope.data.datasets[1].data[i];
  6392. }
  6393. $scope.resolution = (resolve / addDatas * 100).toFixed(2);
  6394. $scope.opt = {
  6395. maintainAspectRatio: false,
  6396. // Sets the chart to be responsive
  6397. responsive: true,
  6398. ///Boolean - Whether grid lines are shown across the chart
  6399. scaleShowGridLines: true,
  6400. //String - Colour of the grid lines
  6401. scaleGridLineColor: 'rgba(0,0,0,.05)',
  6402. //Number - Width of the grid lines
  6403. scaleGridLineWidth: 1,
  6404. //Boolean - Whether the line is curved between points
  6405. bezierCurve: false,
  6406. //Number - Tension of the bezier curve between points
  6407. bezierCurveTension: 0.4,
  6408. //Boolean - Whether to show a dot for each point
  6409. pointDot: true,
  6410. //Number - Radius of each point dot in pixels
  6411. pointDotRadius: 4,
  6412. //Number - Pixel width of point dot stroke
  6413. pointDotStrokeWidth: 1,
  6414. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  6415. pointHitDetectionRadius: 20,
  6416. //Boolean - Whether to show a stroke for datasets
  6417. datasetStroke: true,
  6418. //Number - Pixel width of dataset stroke
  6419. datasetStrokeWidth: 2,
  6420. //Boolean - Whether to fill the dataset with a colour
  6421. datasetFill: true,
  6422. // Function - on animation progress
  6423. onAnimationProgress: function () { },
  6424. // Function - on animation complete
  6425. onAnimationComplete: function () { },
  6426. //String - A legend template
  6427. 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>'
  6428. };
  6429. angular.extend($scope.options, $scope.opt)
  6430. $scope.datamonth = {
  6431. labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
  6432. datasets: [{
  6433. label: '新增事件数量',
  6434. fillColor: 'rgba(220,220,220,0.5)',
  6435. strokeColor: 'rgba(220,220,220,0.8)',
  6436. highlightFill: 'rgba(220,220,220,0.75)',
  6437. highlightStroke: 'rgba(220,220,220,1)',
  6438. data: [65, 59, 80, 81, 56, 55]
  6439. },
  6440. {
  6441. label: '已解决事件数量',
  6442. fillColor: 'rgba(151,187,205,0.5)',
  6443. strokeColor: 'rgba(151,187,205,0.8)',
  6444. highlightFill: 'rgba(151,187,205,0.75)',
  6445. highlightStroke: 'rgba(151,187,205,1)',
  6446. data: [28, 48, 40, 19, 86, 27]
  6447. }
  6448. ]
  6449. };
  6450. // Chart.js Options
  6451. $scope.taption = {
  6452. maintainAspectRatio: false,
  6453. // Sets the chart to be responsive
  6454. responsive: true,
  6455. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  6456. scaleBeginAtZero: true,
  6457. //Boolean - Whether grid lines are shown across the chart
  6458. scaleShowGridLines: true,
  6459. //String - Colour of the grid lines
  6460. scaleGridLineColor: "rgba(0,0,0,.05)",
  6461. //Number - Width of the grid lines
  6462. scaleGridLineWidth: 1,
  6463. //Boolean - If there is a stroke on each bar
  6464. barShowStroke: true,
  6465. //Number - Pixel width of the bar stroke
  6466. barStrokeWidth: 2,
  6467. //Number - Spacing between each of the X value sets
  6468. barValueSpacing: 5,
  6469. //Number - Spacing between data sets within X values
  6470. barDatasetSpacing: 1,
  6471. //String - A legend template
  6472. 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>'
  6473. };
  6474. }]
  6475. });
  6476. //排版日历
  6477. formlyConfigProvider.setType({
  6478. name: 'ui-dashcalendar',
  6479. templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
  6480. defaultOptions: function (options) {
  6481. return {
  6482. templateOptions: {
  6483. // relationAction: function() {
  6484. // options.hideExpression = true
  6485. // }
  6486. }
  6487. };
  6488. },
  6489. 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) {
  6490. var loginUser = $rootScope.user;
  6491. calendarConfig.dateFormatter = 'moment';
  6492. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  6493. calendarConfig.i18nStrings.timeLabel = '时间';
  6494. calendarConfig.i18nStrings.weekNumber = '{week}周';
  6495. calendarConfig.allDateFormats = {
  6496. angular: {
  6497. date: {
  6498. hour: 'ha',
  6499. day: 'd MMM',
  6500. month: 'MMMM',
  6501. weekDay: 'EEEE',
  6502. time: 'HH:mm',
  6503. datetime: 'MMM d, h:mm a'
  6504. },
  6505. title: {
  6506. day: 'yyyy MMMM EEEE d',
  6507. week: '{year}年第{week}周',
  6508. month: 'yyyy MMMM',
  6509. year: 'yyyy'
  6510. }
  6511. },
  6512. moment: {
  6513. date: {
  6514. hour: 'ha',
  6515. day: 'MMMDD日',
  6516. month: 'MMMM',
  6517. weekDay: 'dddd',
  6518. time: 'HH:mm',
  6519. datetime: 'MMM D, h:mm a'
  6520. },
  6521. title: {
  6522. day: 'YYYY年MMMMDD日, dddd ',
  6523. week: '{year}年第{week}周',
  6524. month: 'YYYY年MMMM',
  6525. year: 'YYYY'
  6526. }
  6527. }
  6528. };
  6529. moment.locale('zh_cn', {
  6530. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  6531. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  6532. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6533. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6534. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6535. longDateFormat: {
  6536. LT: 'Ah点mm分',
  6537. LTS: 'Ah点m分s秒',
  6538. L: 'YYYY-MM-DD',
  6539. LL: 'YYYY年MMMD日',
  6540. LLL: 'YYYY年MMMD日Ah点mm分',
  6541. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  6542. l: 'YYYY-MM-DD',
  6543. ll: 'YYYY年MMMD日',
  6544. lll: 'YYYY年MMMD日Ah点mm分',
  6545. llll: 'YYYY年MMMD日ddddAh点mm分'
  6546. },
  6547. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6548. meridiemHour: function (hour, meridiem) {
  6549. if (hour === 12) {
  6550. hour = 0;
  6551. }
  6552. if (meridiem === '凌晨' || meridiem === '早上' ||
  6553. meridiem === '上午') {
  6554. return hour;
  6555. } else if (meridiem === '下午' || meridiem === '晚上') {
  6556. return hour + 12;
  6557. } else {
  6558. // '中午'
  6559. return hour >= 11 ? hour : hour + 12;
  6560. }
  6561. },
  6562. meridiem: function (hour, minute, isLower) {
  6563. var hm = hour * 100 + minute;
  6564. if (hm < 600) {
  6565. return '凌晨';
  6566. } else if (hm < 900) {
  6567. return '早上';
  6568. } else if (hm < 1130) {
  6569. return '上午';
  6570. } else if (hm < 1230) {
  6571. return '中午';
  6572. } else if (hm < 1800) {
  6573. return '下午';
  6574. } else {
  6575. return '晚上';
  6576. }
  6577. },
  6578. calendar: {
  6579. sameDay: function () {
  6580. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  6581. },
  6582. nextDay: function () {
  6583. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  6584. },
  6585. lastDay: function () {
  6586. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  6587. },
  6588. nextWeek: function () {
  6589. var startOfWeek, prefix;
  6590. startOfWeek = moment().startOf('week');
  6591. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  6592. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6593. },
  6594. lastWeek: function () {
  6595. var startOfWeek, prefix;
  6596. startOfWeek = moment().startOf('week');
  6597. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  6598. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6599. },
  6600. sameElse: 'LL'
  6601. },
  6602. ordinalParse: /\d{1,2}(日|月|周)/,
  6603. ordinal: function (number, period) {
  6604. switch (period) {
  6605. case 'd':
  6606. case 'D':
  6607. case 'DDD':
  6608. return number + '日';
  6609. case 'M':
  6610. return number + '月';
  6611. case 'w':
  6612. case 'W':
  6613. return number + '周';
  6614. default:
  6615. return number;
  6616. }
  6617. },
  6618. relativeTime: {
  6619. future: '%s内',
  6620. past: '%s前',
  6621. s: '几秒',
  6622. m: '1 分钟',
  6623. mm: '%d 分钟',
  6624. h: '1 小时',
  6625. hh: '%d 小时',
  6626. d: '1 天',
  6627. dd: '%d 天',
  6628. M: '1 个月',
  6629. MM: '%d 个月',
  6630. y: '1 年',
  6631. yy: '%d 年'
  6632. },
  6633. week: {
  6634. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6635. dow: 1, // Monday is the first day of the week.
  6636. doy: 4 // The week that contains Jan 4th is the first week of the year.
  6637. }
  6638. });
  6639. var date = new Date();
  6640. var d = date.getDate();
  6641. var m = date.getMonth();
  6642. var y = date.getFullYear();
  6643. var filterData = {
  6644. "userId": loginUser.id,
  6645. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  6646. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  6647. };
  6648. var load = $scope.load = function (filterData) {
  6649. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function (response) {
  6650. if (response.status == 200) {
  6651. $scope.events = [];
  6652. var myData = response.list;
  6653. angular.forEach(myData, function (item) {
  6654. var eventTemp = {};
  6655. eventTemp.title = item.description;
  6656. eventTemp.type = item.scheduleClass.code;
  6657. eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
  6658. eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
  6659. eventTemp.startTime = item['scheduleOrderDTO'].startTime;
  6660. eventTemp.endTime = item['scheduleOrderDTO'].endTime;
  6661. //eventTemp.ends_at = moment(item.endTime).toDate();
  6662. eventTemp.id = item.id;
  6663. eventTemp.deletable = false;
  6664. eventTemp.user = item.user;
  6665. $scope.events.push(eventTemp);
  6666. })
  6667. }
  6668. });
  6669. }
  6670. // var load = $scope.load = function(filterData){
  6671. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  6672. // console.log("response="+JSON.stringify(response));
  6673. // if(response.status==200){
  6674. // $scope.events = [];
  6675. // console.log(response.list);
  6676. // var myData = response.list;
  6677. // angular.forEach(myData,function(item){
  6678. // var eventTemp = {};
  6679. // eventTemp.title = item.description;
  6680. // eventTemp.type = item.scheduleClass.code;
  6681. // eventTemp.startsAt = moment(item.startTime).toDate();
  6682. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  6683. // eventTemp.startTime = item.startTime;
  6684. // eventTemp.endTime = item.endTime;
  6685. // //eventTemp.ends_at = moment(item.endTime).toDate();
  6686. // eventTemp.id = item.id;
  6687. // eventTemp.deletable = false;
  6688. // eventTemp.users = item.users;
  6689. // $scope.events.push(eventTemp);
  6690. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  6691. // })
  6692. // }
  6693. // });
  6694. // }
  6695. $scope.scheduleClass = {};
  6696. var convertEvent = function (scheduleorder) {
  6697. var eventTemp = {};
  6698. eventTemp.title = scheduleorder.description;
  6699. eventTemp.type = scheduleorder.scheduleClass.code;
  6700. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  6701. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  6702. eventTemp.id = scheduleorder.id;
  6703. eventTemp.user = scheduleorder.user;
  6704. eventTemp.deletable = false;
  6705. return eventTemp;
  6706. }
  6707. // var convertEvent = function(scheduleorder){
  6708. // var eventTemp = {};
  6709. // eventTemp.title = scheduleorder.description;
  6710. // eventTemp.type = scheduleorder.scheduleClass.code;
  6711. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  6712. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  6713. // eventTemp.id = scheduleorder.id;
  6714. // eventTemp.users = scheduleorder.users;
  6715. // eventTemp.deletable = false;
  6716. // return eventTemp;
  6717. // }
  6718. api_bpm_schedule.getScheduleClass().then(function (response) {
  6719. if (response.status == 200) {
  6720. var scheduleClassList = response.list;
  6721. angular.forEach(scheduleClassList, function (item) {
  6722. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  6723. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  6724. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  6725. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  6726. $scope.scheduleClass[item['code']] = item;
  6727. })
  6728. }
  6729. })
  6730. $scope.events = [];
  6731. $scope.calendarView = 'month';
  6732. //$scope.calendarDay = new Date();
  6733. $scope.calendarDate = moment().startOf('month').toDate();
  6734. $scope.timeLabel = "时间";
  6735. $scope.eventLabel = "描述";
  6736. function showModal(action, event) {
  6737. // console.log("action="+JSON.stringify(action))
  6738. var modalInstance = $aside.open({
  6739. templateUrl: 'scheduleEvent.html',
  6740. placement: 'right',
  6741. size: 'sm',
  6742. backdrop: true,
  6743. controller: function ($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  6744. $scope.$modalInstance = $modalInstance;
  6745. $scope.action = action;
  6746. $scope.event = event;
  6747. $scope.scheduleClassic = scheduleClass;
  6748. $scope.$watch('event.type', function (newvalue, oldvalue) {
  6749. // if(oldvalue == newvalue) return;
  6750. // if(scheduleClass[newvalue]){
  6751. var sm = MementFormat(scheduleClass[newvalue].startTime);
  6752. var em = MementFormat(scheduleClass[newvalue].endTime);
  6753. console.log("sm=" + JSON.stringify(sm))
  6754. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  6755. console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  6756. if (sm.hour() > em.hour()) {
  6757. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6758. console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  6759. } else {
  6760. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6761. console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  6762. }
  6763. // }
  6764. });
  6765. // $scope.ok = function (event) {
  6766. // console.log("event="+JSON.stringify(event))
  6767. // event.action = action;
  6768. // $modalInstance.close(event);
  6769. // };
  6770. $scope.cancel = function (event) {
  6771. $modalInstance.dismiss();
  6772. };
  6773. var acUserSelect = $scope.refreshUser = function (key) {
  6774. //for test
  6775. // $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":"管理层"}]}];
  6776. // return;
  6777. var data = {
  6778. "idx": "0",
  6779. "sum": "5"
  6780. };
  6781. if (key) {
  6782. data['user'] = {
  6783. 'name': key
  6784. };
  6785. }
  6786. APIService.fetchDataList('user', data).then(function (response) {
  6787. if (response) {
  6788. if (response.status = 200) {
  6789. $scope.users = response.list;
  6790. console.log($scope.users);
  6791. }
  6792. }
  6793. })
  6794. };
  6795. if (angular.isDefined(event.users) && event.users.length > 0) {
  6796. }
  6797. $scope.users = [event.user];
  6798. acUserSelect();
  6799. },
  6800. resolve: {
  6801. scheduleClass: function () {
  6802. return $scope.scheduleClass;
  6803. },
  6804. APIService: function () {
  6805. return api_user_data;
  6806. },
  6807. MementFormat: function () {
  6808. return moment;
  6809. }
  6810. }
  6811. });
  6812. modalInstance.result.then(function (selectedEvent) {
  6813. if (selectedEvent.action == 'Clicked') {
  6814. // var data = {
  6815. // "scheduleorder":{
  6816. // "id":selectedEvent.id,
  6817. // "description":selectedEvent.title,
  6818. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  6819. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  6820. // "users":selectedEvent.users,
  6821. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  6822. // }
  6823. // };
  6824. // api_bpm_schedule.update(data).then(function(response){
  6825. // if(response.status==200){
  6826. // SweetAlert.swal({
  6827. // title: "操作成功!",
  6828. // text: "排班更新成功!",
  6829. // type: "succes"
  6830. // });
  6831. // angular.forEach($scope.events,function(item){
  6832. // if(item.id==selectedEvent.id){
  6833. // item = selectedEvent;
  6834. // }
  6835. // })
  6836. // }else{
  6837. // SweetAlert.swal({
  6838. // title: "操作失败",
  6839. // text: "排班更新失败,请稍后重试!",
  6840. // type: "error"
  6841. // })
  6842. // }
  6843. // })
  6844. } else {
  6845. //
  6846. }
  6847. });
  6848. }
  6849. $scope.moment = function (string) {
  6850. return moment(string);
  6851. }
  6852. $scope.eventClicked = function (event) {
  6853. // console.log("event="+JSON.stringify(event))
  6854. showModal('Clicked', event);
  6855. };
  6856. $scope.eventEdited = function (event) {
  6857. showModal('Edited', event);
  6858. };
  6859. var updateView = function (newvalue, oldvalue) {
  6860. if (oldvalue == newvalue) return;
  6861. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  6862. if ($scope.calendarView == "year") {
  6863. } else if ($scope.calendarView == "month") {
  6864. timeStart = moment(newvalue).startOf('month');
  6865. timeEnd = moment(newvalue).endOf('month');
  6866. } else if ($scope.calendarView == "week") {
  6867. timeStart = moment(newvalue).startOf('week');
  6868. timeEnd = moment(newvalue).endOf('week');
  6869. } else if ($scope.calendarView == "Day") {
  6870. timeStart = moment(newvalue).startOf('day');
  6871. timeEnd = moment(newvalue).endOf('day');
  6872. }
  6873. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  6874. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  6875. filterData["startTime"] = timeStartSpan;
  6876. filterData["endTime"] = timeEndSpan;
  6877. load(filterData);
  6878. }
  6879. $scope.$watch('calendarDate', updateView)
  6880. $scope.next = function () {
  6881. $scope.calendarControl.next();
  6882. }
  6883. $scope.prev = function () {
  6884. $scope.calendarControl.prev();
  6885. }
  6886. $scope.setCalendarToToday = function () {
  6887. $scope.calendarDay = new Date();
  6888. };
  6889. $scope.toggle = function ($event, field, event) {
  6890. $event.preventDefault();
  6891. $event.stopPropagation();
  6892. event[field] = !event[field];
  6893. };
  6894. $scope.load(filterData);
  6895. $scope.more = function () {
  6896. $state.go('app.scheduling.myscheduling', {});
  6897. }
  6898. $scope.removes = function () {
  6899. var modalInstance = $modal.open({
  6900. templateUrl: 'assets/views/delete.html',
  6901. controller: function ($scope, $modalInstance) {
  6902. $scope.ok = function () {
  6903. $modalInstance.close();
  6904. };
  6905. $scope.cancel = function () {
  6906. $modalInstance.dismiss('cancel');
  6907. };
  6908. },
  6909. size: 'sm'
  6910. });
  6911. modalInstance.result.then(function () {
  6912. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6913. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6914. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6915. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6916. break;
  6917. }
  6918. }
  6919. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6920. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6921. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6922. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6923. }
  6924. })
  6925. }
  6926. }]
  6927. });
  6928. //空格组件
  6929. formlyConfigProvider.setType({
  6930. name: 'ui-black',
  6931. /*extends: 'input',*/
  6932. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  6933. });
  6934. //请求人最近事件
  6935. formlyConfigProvider.setType({
  6936. name: 'ui-recentIncident',
  6937. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  6938. controller: ['$scope', '$modal', 'api_solution', function ($scope, $modal, api_solution) {
  6939. var filterData = {
  6940. 'incident': {
  6941. 'requester': {
  6942. 'id': ''
  6943. }
  6944. },
  6945. idx: 0,
  6946. sum: 3
  6947. };
  6948. setInterval(function () {
  6949. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  6950. var requester = $scope.model.requester;
  6951. if (requester != null && angular.isDefined(requester.id)) {
  6952. filterData.incident.requester.id = $scope.model.requester.id;
  6953. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  6954. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  6955. if (modelData.status == 200) {
  6956. $scope.lastrequst = modelData.list;
  6957. }
  6958. });
  6959. requester = null
  6960. } else { }
  6961. } else { }
  6962. }, 1000);
  6963. $scope.detail = function (data) {
  6964. var modalInstance = $modal.open({
  6965. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  6966. controller: function ($scope, $modalInstance) {
  6967. $scope.entity = {};
  6968. $scope.entity = data;
  6969. $scope.cancel = function () {
  6970. $modalInstance.dismiss('cancel');
  6971. };
  6972. },
  6973. size: 'lg',
  6974. });
  6975. }
  6976. }]
  6977. });
  6978. //参数列表
  6979. formlyConfigProvider.setType({
  6980. name: "ui-listinput",
  6981. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  6982. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6983. defaultOptions: function (options) {
  6984. return {
  6985. templateOptions: {}
  6986. };
  6987. },
  6988. controller: ['$scope', function ($scope) {
  6989. }]
  6990. });
  6991. //时间段控件(分)
  6992. formlyConfigProvider.setType({
  6993. name: 'ui-timeslot',
  6994. extends: 'input',
  6995. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6996. controller: ['$scope', function ($scope) { }]
  6997. });
  6998. //优先级级联-逾期时间
  6999. formlyConfigProvider.setType({
  7000. name: 'ui-overtime',
  7001. extends: 'input',
  7002. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  7003. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7004. var filteData = {};
  7005. var datas = {}
  7006. setInterval(function () {
  7007. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7008. filteData = "L" + $scope.model.priority.id;
  7009. datas = $scope.model.priority.id;
  7010. // console.log($scope.options.templateOptions)
  7011. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7012. // var overtime=requester.date;
  7013. if (requester.state == 200) {
  7014. // if($scope.options.key=="date"){
  7015. $scope.model[$scope.options.key] = requester.date
  7016. // }
  7017. }
  7018. })
  7019. }
  7020. }, 1000);
  7021. }]
  7022. });
  7023. formlyConfigProvider.setType({
  7024. name: 'ui-responsetime',
  7025. extends: 'input',
  7026. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  7027. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7028. var filteData = {};
  7029. var datas = {}
  7030. setInterval(function () {
  7031. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7032. filteData = "L" + $scope.model.priority.id;
  7033. datas = $scope.model.priority.id;
  7034. // console.log($scope.options.templateOptions)
  7035. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7036. // var overtime=requester.date;
  7037. if (requester.state == 200) {
  7038. var keyName = {};
  7039. // $scope.model.overdueTime = requester.date;
  7040. if ($scope.options.key == "expectIntroTime") {
  7041. keyName = "resolveTime";
  7042. } else if ($scope.options.key == "expectResponseTime") {
  7043. keyName = "responseTime";
  7044. }
  7045. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  7046. // }
  7047. console.log($scope.$parent.$parent.$parent.model)
  7048. }
  7049. if (requester.date1) {
  7050. $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
  7051. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
  7052. $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
  7053. $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
  7054. }
  7055. })
  7056. }
  7057. }, 1000);
  7058. }]
  7059. });
  7060. //知识库按钮组件
  7061. formlyConfigProvider.setType({
  7062. name: 'ui-discasecade',
  7063. extends: 'input',
  7064. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  7065. defaultOptions: function (options) {
  7066. return {
  7067. templateOptions: {
  7068. relationAction: function (fields, modelscope, item) { }
  7069. },
  7070. validators: {
  7071. required: {
  7072. expression: function (viewValue, modelValue) {
  7073. var value = modelValue || viewValue;
  7074. // return value = "true";
  7075. }
  7076. }
  7077. }
  7078. }
  7079. },
  7080. 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) {
  7081. // $scope.options.initialValue = $scope.model[$scope.options.key];
  7082. $scope.searchField = $scope.options.model[$scope.options.key];
  7083. $scope.searchData = "";
  7084. $scope.onChangeadd = function (searchData) {
  7085. $scope.searchKey = searchData.account;
  7086. // $scope.searchDataadd = searchData;
  7087. var requesdata = angular.copy(searchData)
  7088. $scope.requester = requesdata;
  7089. }
  7090. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7091. $scope.searchData = searchKey;
  7092. reashdata($scope.searchData);
  7093. }
  7094. $scope.getMydata = function (x) {
  7095. $scope.model[$scope.options.key] = JSON.parse(x).title;
  7096. $scope.searchField = $scope.model[$scope.options.key];
  7097. }
  7098. $scope.getMydataone = function (x) {
  7099. $scope.model[$scope.options.key] = x;
  7100. $scope.searchField = $scope.model[$scope.options.key];
  7101. }
  7102. $scope.fildata = {
  7103. "idx": 0,
  7104. "sum": 10
  7105. // 'incident': { 'tilte': item }
  7106. }
  7107. function reashdata(item) {
  7108. if (item && item != "") {
  7109. angular.extend($scope.fildata, {
  7110. 'incident': {
  7111. 'title': item
  7112. }
  7113. })
  7114. } else {
  7115. delete $scope.fildata.incident;
  7116. }
  7117. api_bpm_data.fetchDataList('incident', $scope.fildata).then(function (response) {
  7118. if (response) {
  7119. if (response.status = 200) {
  7120. var myData = response;
  7121. $scope.myData = myData.list;
  7122. }
  7123. }
  7124. })
  7125. }
  7126. function delHtmlTag(str) {
  7127. return str.replace(/<[^>]+>/g, "");
  7128. }
  7129. // reashdata();
  7130. var changedata = {};
  7131. setInterval(function () {
  7132. if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
  7133. $scope.searchData = {};
  7134. changedata = angular.copy($scope.model.category);
  7135. if ($scope.options.key == "title") {
  7136. var filterData = {
  7137. "idx": 0,
  7138. "sum": 1000
  7139. };
  7140. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function (data) {
  7141. var datalist = data.list;
  7142. angular.forEach(datalist, function (item) {
  7143. if (item.id == $scope.model.category.id) {
  7144. $scope.model[$scope.options.key] = item.category;
  7145. $scope.searchField = $scope.options.model[$scope.options.key];
  7146. $scope.titles = item.category;
  7147. titles = $scope.model.category;
  7148. }
  7149. })
  7150. })
  7151. }
  7152. }
  7153. }, 1000);
  7154. $scope.open = function (key, options, fildata, $event, model) {
  7155. if (key && key.length > 1) {
  7156. api_zsk.solutionData({
  7157. "solution": {
  7158. "searchWord": key
  7159. },
  7160. "idx": "0",
  7161. "sum": "1000"
  7162. }, 'solution').then(function (response) {
  7163. if (response && response.list.length > 0) {
  7164. $scope.dlideboxslide = true
  7165. angular.forEach(response, function (item) {
  7166. console.log(response)
  7167. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  7168. // if (response.status == 200) {
  7169. // var quote = { 'totalNum': response.totalNum }
  7170. // item = angular.extend(item, quote)
  7171. // }
  7172. // })
  7173. $scope.searchData = response.list;
  7174. console.log($scope.searchData)
  7175. })
  7176. $scope.changes = false;
  7177. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  7178. // $scope.closepages = function(e) {
  7179. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  7180. // event.preventDefault();
  7181. // };
  7182. $scope.shows = false;
  7183. $scope.tempData = {};
  7184. $scope.showpage = function (item) {
  7185. item.content = delHtmlTag(item.content);
  7186. $scope.shows = true;
  7187. $scope.tempData = item;
  7188. if (item.content != null) {
  7189. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  7190. }
  7191. $scope.knowledgedata = item;
  7192. $scope.pageid = item.id;
  7193. $scope.changes = !$scope.changes;
  7194. api_bpm_domain.listAttachments(item.id)
  7195. // api_solution.fetchDataList('file', {
  7196. // "file": {
  7197. // "solutionId": item.id
  7198. // },
  7199. // "idx": "0",
  7200. // "sum": "1000"
  7201. // })
  7202. .then(function (data) {
  7203. if (data) {
  7204. $scope.attachments = data.list;
  7205. $scope.view = function (attachmentId) {
  7206. for (var i = 0; i < $scope.attachments.length; i++) {
  7207. if ($scope.attachments[i].id == attachmentId) {
  7208. window.open($scope.attachments[i].previewUrl);
  7209. }
  7210. }
  7211. };
  7212. $scope.download = function (contentId, filename) {
  7213. api_solution.getSolutionDowpath(contentId).then(function (response) {
  7214. var file = new Blob([response], {
  7215. type: 'application/octet-stream'
  7216. });
  7217. // var filename = filename;
  7218. var fileURL = URL.createObjectURL(file);
  7219. var a = document.createElement('a');
  7220. a.href = fileURL;
  7221. a.target = '_blank';
  7222. a.download = filename;
  7223. document.body.appendChild(a);
  7224. a.click();
  7225. })
  7226. };
  7227. }
  7228. })
  7229. }
  7230. $scope.related = function (item) {
  7231. if (item.content != null) {
  7232. item.content = item.content.replace("<p>", "").replace("</p>", "")
  7233. }
  7234. // fildata.$parent.$parent.$parent.model.directClose = 0;
  7235. options.model.handleDescription = item.content;
  7236. var data = {
  7237. 'solutionQuote': {
  7238. 'solutionId': item.id,
  7239. 'incidentsign': options.model.incidentsign
  7240. }
  7241. };
  7242. api_zsk.solutionQuote(item.id).then(function (response) {
  7243. if (response.status == 200) {
  7244. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7245. fildata.$parent.$parent.$parent.$parent.model.start_code = 'close';
  7246. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  7247. } else {
  7248. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7249. };
  7250. })
  7251. }
  7252. $scope.close = function () {
  7253. $scope.changes = !$scope.changes;
  7254. event.preventDefault();
  7255. }
  7256. }
  7257. });
  7258. }
  7259. };
  7260. }]
  7261. });
  7262. //侧滑选择重复事件
  7263. formlyConfigProvider.setType({
  7264. name: 'ui-repeatIncidentbtn',
  7265. templateUrl: 'assets/views/customform/tpl/ui-repeatIncidentbtn.html',
  7266. defaultOptions: function (options) {
  7267. return {
  7268. templateOptions: {
  7269. relationAction: function (fields, modelscope, item) { }
  7270. },
  7271. validators: {
  7272. required: {
  7273. expression: function (viewValue, modelValue) {
  7274. // var value = modelValue || viewValue;
  7275. }
  7276. }
  7277. }
  7278. }
  7279. },
  7280. 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) {
  7281. console.log($scope)
  7282. $scope.selection = {
  7283. id: ''
  7284. };
  7285. //认证计费数据获取
  7286. $scope.sumInfo = {};
  7287. function getSumInfo() {
  7288. api_bpm_data.sumInfo($scope.model.incident.account).then(function (data) {
  7289. console.log(data)
  7290. if (data) {
  7291. $scope.sumInfo = data.data||{};
  7292. }
  7293. })
  7294. }
  7295. getSumInfo();
  7296. // 收起重复事件侧滑框
  7297. function reashdata(item) {
  7298. var fildata = {
  7299. idx: 0,
  7300. incident: {
  7301. department: {
  7302. id: $scope.model.incident.department.id,
  7303. },
  7304. },
  7305. sum: 3
  7306. }
  7307. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  7308. console.log(data)
  7309. if (data) {
  7310. $scope.repeatData = data.list;
  7311. }
  7312. })
  7313. }
  7314. reashdata();
  7315. // 确认选中的重复事件
  7316. $scope.repeatIncidentOk = function () {
  7317. if ($scope.selection.id) {
  7318. $scope.model.incident.repeat = $scope.selection;
  7319. $scope.model.isRepeat = true; //隐藏处理信息
  7320. console.log($scope.model);
  7321. }
  7322. angular.element('#repeatIncident').removeClass('active');
  7323. }
  7324. // 取消选中的重复事件
  7325. $scope.repeatIncidentCancle = function () {
  7326. angular.element('#repeatIncident').removeClass('active');
  7327. return;
  7328. }
  7329. }]
  7330. });
  7331. //侧滑选择知识库查询
  7332. formlyConfigProvider.setType({
  7333. name: 'ui-knowledgebtn',
  7334. templateUrl: 'assets/views/customform/tpl/ui-knowledgebtn.html',
  7335. defaultOptions: function (options) {
  7336. return {
  7337. templateOptions: {
  7338. relationAction: function (fields, modelscope, item) { }
  7339. },
  7340. validators: {
  7341. required: {
  7342. expression: function (viewValue, modelValue) {
  7343. // var value = modelValue || viewValue;
  7344. }
  7345. }
  7346. }
  7347. }
  7348. },
  7349. 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) {
  7350. // 引用知识库点击
  7351. $scope.searchKeyWord = '';
  7352. $scope.openModel = function (key) {
  7353. // alert(1)//重点
  7354. $scope.searchKeyWord = key;
  7355. if (key) {
  7356. api_zsk.solutionData({
  7357. "solution": {
  7358. threeSearch: key,
  7359. status: { id: 72 },//已发布
  7360. selectType: "keySearch"
  7361. },
  7362. "idx": "0",
  7363. "sum": "1000"
  7364. }, 'solution').then(function (response) {
  7365. $scope.searchData = response.list;
  7366. });
  7367. }
  7368. };
  7369. $scope.openModel($scope.model.incident.description)
  7370. // 展开/收起
  7371. $scope.showId = '';
  7372. $scope.ifshow = false;
  7373. $scope.showAll = function (id) {
  7374. $scope.attachments = []
  7375. if ($scope.showId == id) {
  7376. $scope.ifshow = !$scope.ifshow;
  7377. } else {
  7378. $scope.ifshow = true;
  7379. }
  7380. $scope.showId = id;
  7381. // 获取附件
  7382. api_wechatfile.listAttachments('knowledge', $scope.showId).then(function (data) {
  7383. $scope.attachments = data.data;
  7384. $scope.download = function (token, filename) {
  7385. var downUrl = up_down_file.downloadAttachment('common/common/downloadAttachment', token).getRequestedUrl();
  7386. // window.open(downUrl);
  7387. var a = document.createElement('a');
  7388. a.href = downUrl;
  7389. a.target = '_blank';
  7390. a.download = filename;
  7391. document.body.appendChild(a);
  7392. a.click();
  7393. };
  7394. })
  7395. }
  7396. // 引用
  7397. $scope.related = function (item) {
  7398. console.log(item,'引用名')
  7399. if (item.content) {
  7400. item.content = item.content.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/&nbsp;/g, '')
  7401. }
  7402. $scope.model.incident.handleDescription = item.content;
  7403. $scope.model.incident.category = item.category;
  7404. $scope.model.incident.priority.id = item.category.priority.id;
  7405. $scope.model.incident.title = $scope.model.incident.description = item.title;
  7406. item.category.label = item.category.category;
  7407. var categoryId = item.category.id;
  7408. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  7409. function getres(nodes) {
  7410. if (!nodes || nodes.length == 0) {
  7411. return;
  7412. }
  7413. nodes.forEach(e => {
  7414. e.selected = false;
  7415. if (e.id == categoryId) {
  7416. e.selected = true;
  7417. return false;
  7418. }
  7419. getres(e.children)
  7420. })
  7421. }
  7422. var categorys = [];
  7423. $scope.fields.forEach((e, i) => {
  7424. if (e.key == 'category') {
  7425. categorys = e.templateOptions.options;
  7426. if (categorys.length) {
  7427. getres(categorys);
  7428. $scope.fields[i].templateOptions.options = categorys;
  7429. $scope.$root.refreshSelectedItems();
  7430. }
  7431. return false;
  7432. }
  7433. })
  7434. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  7435. $scope.model.candidateGroups = item.category.group
  7436. // 携带关联优先级,事件工单信息的时间
  7437. if ($scope.model && $scope.model.incident && item.category && item.category.priority && item.category.priority.id) {
  7438. api_bpm_domain.expectedTime('L' + (item.category.priority.id - 1559)).then(function (res) {
  7439. $scope.model.incident.expectResponseTime = $scope.$parent.$parent.$parent.model.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  7440. $scope.model.incident.expectIntroTime = $scope.$parent.$parent.$parent.model.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  7441. $scope.model.incident.overdueTime = $scope.$parent.$parent.$parent.model.incident.overdueTime = res.date;
  7442. })
  7443. }
  7444. api_zsk.solutionQuote(item.id).then(function (response) {
  7445. if (response.status == 200) {
  7446. $('#seachknowledge').removeClass('active')
  7447. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7448. $scope.$parent.$parent.$parent.model.start_code = 'close';
  7449. $scope.$parent.$parent.$parent.model.directClose = 0;
  7450. console.log($scope.model)
  7451. } else {
  7452. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7453. };
  7454. })
  7455. }
  7456. }]
  7457. });
  7458. //下拉输入组件
  7459. formlyConfigProvider.setType({
  7460. name: 'ui-selectinput',
  7461. extends: 'input',
  7462. templateUrl: 'assets/views/customform/tpl/selectinput.html',
  7463. defaultOptions: function (options) {
  7464. return {
  7465. templateOptions: {
  7466. refresh: function () { },
  7467. refreshDelay: 0,
  7468. linkage: function (modelName, data) {
  7469. }
  7470. },
  7471. }
  7472. },
  7473. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  7474. $scope.searchData = "";
  7475. $scope.onChangeadd = function (searchData) {
  7476. // $scope.searchKey = searchData.account;
  7477. // var requesdata = angular.copy(searchData)
  7478. // $scope.requester = requesdata;
  7479. }
  7480. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7481. // $scope.searchData = searchKey;
  7482. // reashdata($scope.searchData);
  7483. }
  7484. $scope.getMydata = function (x) {
  7485. $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
  7486. $scope.searchField = $scope.model[$scope.options.key];
  7487. }
  7488. $scope.getMydataone = function (x) {
  7489. $scope.model[$scope.options.key] = x;
  7490. $scope.searchField = $scope.model[$scope.options.key];
  7491. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
  7492. $scope.hidden = false;
  7493. } else {
  7494. $scope.hidden = true;
  7495. }
  7496. }
  7497. function reashdata(item) {
  7498. $scope.myData = $scope.options.templateOptions.mydata;
  7499. }
  7500. reashdata()
  7501. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  7502. $scope.options.templateOptions.fetchItems($scope);
  7503. }
  7504. }]
  7505. });
  7506. //重构组件模板
  7507. //获取当前人
  7508. formlyConfigProvider.setType({
  7509. name: 'ui-users',
  7510. extends: 'input',
  7511. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7512. defaultOptions: function (options) {
  7513. return {
  7514. templateOptions: {
  7515. translate: '',
  7516. refreshDelay: 0
  7517. }
  7518. }
  7519. },
  7520. controller: ['$scope', function ($scope) {
  7521. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  7522. $scope.options.templateOptions.translate = $scope.$root.user.name;
  7523. }]
  7524. });
  7525. //只读控件
  7526. formlyConfigProvider.setType({
  7527. name: 'ui-label',
  7528. extends: 'input',
  7529. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7530. defaultOptions: function (options) {
  7531. return {
  7532. templateOptions: {
  7533. translate: '',
  7534. refreshDelay: 0
  7535. }
  7536. }
  7537. },
  7538. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  7539. // console.log($scope.options.templateOptions)
  7540. // console.log($scope.options,'options1122');
  7541. $scope.isSolutionLabel = false;
  7542. $scope.solutionLabelStr = "";
  7543. // console.log($scope.options.templateOptions.solotinLabel);
  7544. if ($scope.options.templateOptions.solotinLabel) {
  7545. $scope.isSolutionLabel = true;
  7546. if ($scope.model[$scope.options.key]) {
  7547. var solutionArr = $scope.model[$scope.options.key].split("/");
  7548. $scope.solutionLabelStr = solutionArr.join(" ");
  7549. }
  7550. }
  7551. var value = $scope.model[$scope.options.key];
  7552. // ----------------
  7553. // ----------------
  7554. // console.log(value, 'pppp')
  7555. function treeDesc(children, key, label) {
  7556. if (label == "") {
  7557. label = children[key];
  7558. } else {
  7559. label = children[key] + "-" + label;
  7560. }
  7561. if (angular.isDefined(children.parent)) {
  7562. treeDesc(children.parent, key, label);
  7563. } else {
  7564. return label;
  7565. }
  7566. }
  7567. if (angular.isArray(value)) {
  7568. var tempValue = "";
  7569. angular.forEach(value, function (item) {
  7570. if (tempValue != "") {
  7571. tempValue = tempValue + ",";
  7572. }
  7573. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  7574. });
  7575. $scope.options.templateOptions.translate = tempValue;
  7576. } else if (angular.isObject(value)) {
  7577. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  7578. //tree
  7579. // console.log("value.parent="+JSON.stringify(value.parent))
  7580. var nameLabel = value[$scope.options.templateOptions.labelProp];
  7581. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  7582. $scope.options.templateOptions.translate = nameLabel;
  7583. } else {
  7584. $scope.options.templateOptions.translate = value;
  7585. }
  7586. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  7587. // console.log("value=" + value);
  7588. $scope.options.templateOptions.translate = value;
  7589. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  7590. // console.log("value="+value);
  7591. // $scope.options.templateOptions.translate = value;
  7592. } else {
  7593. // var datasdf = JSON.parse(value);
  7594. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  7595. $scope.options.templateOptions.translate = value;
  7596. }
  7597. if (angular.isFunction($scope.options.templateOptions.transform)) {
  7598. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  7599. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
  7600. }
  7601. // console.log($scope.options.templateOptions.translate,99999);
  7602. }]
  7603. });
  7604. //小标题组件
  7605. formlyConfigProvider.setType({
  7606. name: 'ui-header',
  7607. 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>'
  7608. });
  7609. //标题组件
  7610. formlyConfigProvider.setType({
  7611. name: 'ui-title',
  7612. 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>'
  7613. });
  7614. //标栏是否展示
  7615. formlyConfigProvider.setType({
  7616. name: 'ui-orshow',
  7617. 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>',
  7618. controller: ['$scope', function ($scope) {
  7619. $scope.clickshow = function (key) {
  7620. // $scope.model[$scope.options.key] != key;
  7621. if (key == false) {
  7622. $scope.model[$scope.options.key] = true
  7623. } else {
  7624. $scope.model[$scope.options.key] = false
  7625. }
  7626. }
  7627. }]
  7628. });
  7629. //按钮组
  7630. formlyConfigProvider.setType({
  7631. name: 'ui-button',
  7632. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  7633. defaultOptions: function (options) {
  7634. return {
  7635. noFormControl: true
  7636. }
  7637. }
  7638. });
  7639. //3d组link
  7640. formlyConfigProvider.setType({
  7641. name: 'ui-link',
  7642. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  7643. defaultOptions: function (options) {
  7644. return {
  7645. noFormControl: true
  7646. }
  7647. }
  7648. });
  7649. //隐藏域组件
  7650. formlyConfigProvider.setType({
  7651. name: 'ui-hidden',
  7652. extends: 'input',
  7653. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  7654. defaultOptions: function (options) {
  7655. return {
  7656. // noFormControl: true
  7657. };
  7658. }
  7659. });
  7660. //文本框组件
  7661. formlyConfigProvider.setType({
  7662. name: 'ui-input',
  7663. extends: 'input',
  7664. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7665. defaultOptions: function (options) {
  7666. return {
  7667. templateOptions: {
  7668. transform: function (value) { }
  7669. }
  7670. };
  7671. },
  7672. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7673. // console.log($scope.model[$scope.options.key]);
  7674. // console.log($scope.options)
  7675. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7676. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7677. }
  7678. }]
  7679. });
  7680. //搜索下拉框-故障地点seimin
  7681. formlyConfigProvider.setType({
  7682. name: 'ui-select-search',
  7683. extends: 'input',
  7684. templateUrl: 'assets/views/customform/tpl/ui-select-search.html',
  7685. defaultOptions: function (options) {
  7686. return {
  7687. templateOptions: {
  7688. transform: function (value) { }
  7689. }
  7690. };
  7691. },
  7692. controller: ['$scope','$rootScope', 'api_search_area', function ($scope,$rootScope, api_search_area) {
  7693. // console.log($scope.options, $scope.model)
  7694. // ----------------分割线 start-----------------
  7695. // 故障地点下拉
  7696. $scope.address_arr = [];//故障地点所有数据
  7697. $scope.addressFlag = false;//默认下拉框列表隐藏
  7698. //点击文本框
  7699. $scope.AddressClickHandle = function () {
  7700. $scope.getDepartmentList();
  7701. angular.element('#bx_address_ul').scrollTop(0);
  7702. }
  7703. //修改文字,实时监听
  7704. $scope.ksChangeHandle = _.debounce(function () {
  7705. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === undefined ? '' : $scope.model[$scope.options.key];
  7706. $scope.getDepartmentList();
  7707. angular.element('#bx_address_ul').scrollTop(0);
  7708. }, 500)
  7709. //获取故障地点seimin
  7710. $scope.getDepartmentList = function () {
  7711. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === null ? '' : $scope.model[$scope.options.key];
  7712. api_search_area.getAreaList({ "searchKey": $scope.model[$scope.options.key] })
  7713. .then(res => {
  7714. if (res.state == 200) {
  7715. $scope.address_arr = res.result;
  7716. $scope.addressFlag = true;//显示
  7717. }
  7718. })
  7719. .catch(err => {
  7720. console.log(err);
  7721. })
  7722. }
  7723. // $scope.getDepartmentList();
  7724. // console.log($scope.model[$scope.options.key])
  7725. //下拉框列表选中
  7726. $scope.addressItemClick = function (obj) {
  7727. $scope.addressFlag = false;//隐藏
  7728. $scope.model[$scope.options.key] = obj.place ? obj.area.area + obj.place : obj.area;
  7729. //选择故障地点后带入区域地点2020年4月23日15:20:44
  7730. $scope.model.selecthouseNumber = obj;
  7731. console.log($scope,77777)
  7732. $scope.$root.selecthouseNumber = obj;
  7733. }
  7734. //点击空白处隐藏
  7735. angular.element(document).on('click', function (e) {
  7736. if (e.target !== angular.element('#bx_address').get(0)) {
  7737. $scope.addressFlag = false;//隐藏
  7738. //模拟placeholder
  7739. // if ($('#bx_address').val() == '') {
  7740. // $('#bx_address').val('请选择报修科室');
  7741. // }
  7742. }
  7743. })
  7744. // -----------------分割线 end----------------
  7745. }]
  7746. });
  7747. //知识库关键字组件
  7748. formlyConfigProvider.setType({
  7749. name: 'ui-knowledgeKeywords',
  7750. extends: 'input',
  7751. templateUrl: 'assets/views/customform/tpl/ui-knowledgeKeywords.html',
  7752. defaultOptions: function (options) {
  7753. return {
  7754. templateOptions: {
  7755. transform: function (value) { }
  7756. }
  7757. };
  7758. },
  7759. controller: ['$scope', '$timeout', 'SweetAlert', function ($scope, $timeout, SweetAlert) {
  7760. $scope.valueLength = [{
  7761. "value": ""
  7762. }];
  7763. $scope.valueAll = [];
  7764. if ($scope.model[$scope.options.key]) {
  7765. var valueArr = $scope.model[$scope.options.key].split("/");
  7766. $scope.valueLength = [];
  7767. for (var i = 0; i < valueArr.length; i++) {
  7768. $scope.valueLength.push({
  7769. "value": valueArr[i]
  7770. })
  7771. }
  7772. }
  7773. $scope.addIpt = function () {
  7774. if ($scope.valueLength.length < 5) {
  7775. $scope.valueLength.push({
  7776. "value": ""
  7777. })
  7778. } else {
  7779. SweetAlert.swal({
  7780. title: "添加失败",
  7781. text: "关键字不能超过5个!",
  7782. type: "error",
  7783. confirmButtonColor: "#DD6B55"
  7784. });
  7785. }
  7786. };
  7787. $scope.closeIpt = function (data) {
  7788. $scope.valueLength.splice(data, 1)
  7789. }
  7790. $scope.toOption = function () {
  7791. $scope.valueAll = [];
  7792. for (var i = 0; i < $scope.valueLength.length; i++) {
  7793. if ($scope.valueLength[i].value != "") {
  7794. $scope.valueAll.push($scope.valueLength[i].value)
  7795. }
  7796. }
  7797. $scope.model.label = $scope.valueAll.join("/")
  7798. }
  7799. }]
  7800. });
  7801. //文本框组件
  7802. formlyConfigProvider.setType({
  7803. name: 'ui-num',
  7804. extends: 'input',
  7805. templateUrl: 'assets/views/customform/tpl/ui-num.html',
  7806. defaultOptions: function (options) {
  7807. return {
  7808. templateOptions: {
  7809. transform: function (value) { }
  7810. }
  7811. };
  7812. },
  7813. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7814. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7815. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7816. }
  7817. $scope.clearNoNum = function (obj, attr) {
  7818. //先把非数字的都替换掉,除了数字和.
  7819. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  7820. //必须保证第一个为数字而不是.
  7821. obj[attr] = obj[attr].replace(/^\./g, "");
  7822. //保证只有出现一个.而没有多个.
  7823. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  7824. //保证.只出现一次,而不能出现两次以上
  7825. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  7826. //小于最大值
  7827. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  7828. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  7829. // obj[attr] = '';
  7830. // }
  7831. }
  7832. }]
  7833. });
  7834. // //关联请求人文本框组件
  7835. // formlyConfigProvider.setType({
  7836. // name: 'ui-requestinput',
  7837. // extends: 'input',
  7838. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7839. // defaultOptions: function(options) {
  7840. // return {
  7841. // templateOptions: {
  7842. // transform: function(value) {},
  7843. // linkData: function(options) {}
  7844. // }
  7845. // };
  7846. // }
  7847. // });
  7848. //只读文本
  7849. formlyConfigProvider.setType({
  7850. name: 'ui-disableinput',
  7851. extends: 'input',
  7852. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  7853. defaultOptions: function (options) {
  7854. return {
  7855. templateOptions: {
  7856. transform: function (value) {
  7857. var ret = "";
  7858. if (value) {
  7859. ret = "已删除";
  7860. } else {
  7861. ret = "正常";
  7862. }
  7863. return ret;
  7864. }
  7865. }
  7866. };
  7867. }
  7868. });
  7869. formlyConfigProvider.setType({
  7870. name: 'ui-disinput',
  7871. extends: 'input',
  7872. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  7873. defaultOptions: function (options) {
  7874. return {
  7875. templateOptions: {}
  7876. };
  7877. }
  7878. });
  7879. //数字组件
  7880. formlyConfigProvider.setType({
  7881. name: 'ui-number',
  7882. extends: 'input',
  7883. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  7884. defaultOptions: function (options) {
  7885. return {
  7886. templateOptions: {}
  7887. };
  7888. },
  7889. controller: ['$scope', function ($scope) { }]
  7890. });
  7891. //含有周的日期
  7892. formlyConfigProvider.setType({
  7893. name: 'ui-datepickerweek',
  7894. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  7895. extends: 'input',
  7896. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  7897. defaultOptions: {
  7898. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  7899. templateOptions: {
  7900. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  7901. }
  7902. },
  7903. controller: ['$scope', '$filter', function ($scope, $filter) {
  7904. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  7905. if ($scope.model[$scope.options.key]) {
  7906. } else {
  7907. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  7908. }
  7909. $scope.options.initialValue = $scope.model[$scope.options.key];
  7910. $scope.endOpen = true;
  7911. $scope.datepicker = {};
  7912. $scope.datepicker.opened = false;
  7913. $scope.datepicker.open = function ($event) {
  7914. $scope.datepicker.opened = true;
  7915. };
  7916. }]
  7917. });
  7918. //lmm
  7919. //分配任务列表
  7920. formlyConfigProvider.setType({
  7921. name: 'jry_taskDistributionList',
  7922. templateUrl: 'assets/views/customform/tpl/jry_taskDistributionList.html',
  7923. wrapper: ['bootstrapHasError'],
  7924. defaultOptions: function (options, $scope) {
  7925. return {
  7926. templateOptions: {
  7927. }
  7928. };
  7929. },
  7930. controller: function ($rootScope, $scope, api_user_data, $modal, api_doc_data, i18nService, SweetAlert, api_wechatfile) {
  7931. // 获取状态
  7932. $scope.stateListData = {};
  7933. $scope.getStateData = function () {//lyl
  7934. var data = {
  7935. "key": 'task_sub_state',
  7936. "type": 'list'
  7937. }
  7938. api_wechatfile.getDictionary(data).then(function (res) {
  7939. angular.forEach(res, function (v, i) {
  7940. $scope.stateListData[v.value] = v.id;
  7941. })
  7942. })
  7943. }
  7944. $scope.getStateData();
  7945. var loginUser = $rootScope.user;
  7946. $scope.langs = i18nService.getAllLangs();
  7947. $scope.lang = 'zh-cn';
  7948. i18nService.setCurrentLang($scope.lang);
  7949. $scope.gridOptions = {};
  7950. $scope.gridOptions.data = 'myData';
  7951. $scope.gridOptions.enableColumnResizing = true;
  7952. $scope.gridOptions.enableGridMenu = false;
  7953. $scope.gridOptions.enableRowSelection = true;
  7954. $scope.gridOptions.showGridFooter = true;
  7955. $scope.gridOptions.showColumnFooter = false;
  7956. $scope.gridOptions.fastWatch = true;
  7957. $scope.gridOptions.useExternalFiltering = true;
  7958. $scope.gridOptions.useExternalPagination = true;
  7959. $scope.gridOptions.paginationPageSizes = [10];
  7960. $scope.gridOptions.paginationPageSize = 10;
  7961. $scope.gridOptions.multiSelect = true;
  7962. $scope.gridOptions.rowIdentity = function (row) {
  7963. return row.id;
  7964. };
  7965. $scope.gridOptions.getRowIdentity = function (row) {
  7966. return row.id;
  7967. };
  7968. // console.log($scope.model);//lmmmm
  7969. $scope.gridOptions.columnDefs = [{
  7970. name: 'item',
  7971. displayName: '序号',
  7972. width: "10%",
  7973. cellTemplate: '<div>' +
  7974. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  7975. '</div>'
  7976. },
  7977. {
  7978. name: 'taskDescribe',
  7979. displayName: '任务说明',
  7980. width: "25%",
  7981. enableFiltering: false,
  7982. cellTemplate: '<div>' +
  7983. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  7984. '</div>'
  7985. },
  7986. {
  7987. name: 'assign.name',
  7988. displayName: '指派人',
  7989. width: "5%",
  7990. enableFiltering: false,
  7991. cellTemplate: '<div>' +
  7992. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  7993. '</div>'
  7994. },
  7995. {
  7996. name: 'startTime',
  7997. displayName: '开始时间',
  7998. width: '13%',
  7999. enableFiltering: false,
  8000. cellTemplate: '<div>' +
  8001. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  8002. '</div>'
  8003. },
  8004. {
  8005. name: 'endTime',
  8006. displayName: '结束时间',
  8007. width: '13%',
  8008. enableFiltering: false,
  8009. cellTemplate: '<div>' +
  8010. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  8011. '</div>'
  8012. },
  8013. {
  8014. name: 'priority.name',
  8015. displayName: '优先级',
  8016. width: "5%",
  8017. enableFiltering: false,
  8018. cellTemplate: '<div>' +
  8019. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  8020. '</div>'
  8021. },
  8022. {
  8023. name: 'state.name',
  8024. displayName: '状态',
  8025. width: "5%",
  8026. enableFiltering: false,
  8027. cellTemplate: '<div>' +
  8028. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  8029. '</div>'
  8030. },
  8031. {
  8032. name: '操作',//lmmm
  8033. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  8034. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  8035. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  8036. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  8037. '<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>' +
  8038. '</div></div>',
  8039. enableFiltering: false
  8040. }
  8041. ];
  8042. // 查看
  8043. $scope.see = function (data) {
  8044. $scope.seeData = data;
  8045. var modalInstance = $modal.open({
  8046. backdrop: false,
  8047. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8048. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8049. $scope.personData = {}; //指派人
  8050. $scope.priorityData = {}; //优先级
  8051. $scope.personListData = {}; //指派人下拉数据
  8052. $scope.priorityListData = {}; //优先级下拉数据
  8053. $scope.startTime = ""; //开始时间
  8054. $scope.releaseShow = "no";
  8055. $scope.subShow = "no";
  8056. $scope.onlySee = "ok";
  8057. $scope.endTime = ""; //结束时间
  8058. $scope.taskDescribe = ""; //任务描述
  8059. $scope.taskDescribe = scope.seeData.taskDescribe;
  8060. $scope.personData.data = scope.seeData.assign;
  8061. $scope.priorityData.data = scope.seeData.priority;
  8062. $scope.startTime = scope.seeData.startTime;
  8063. $scope.endTime = scope.seeData.endTime;
  8064. $scope.done = scope.seeData.done;
  8065. $scope.feedback = scope.seeData.feedback;
  8066. $scope.cancel = function () {
  8067. $modalInstance.dismiss('cancel');
  8068. }
  8069. },
  8070. size: 'sm',
  8071. resolve: {
  8072. scope: function () {
  8073. return $scope;
  8074. },
  8075. },
  8076. backdrop: true
  8077. });
  8078. }
  8079. // 编辑
  8080. $scope.edit = function (data) {
  8081. $scope.editData = data;
  8082. var modalInstance = $modal.open({
  8083. backdrop: false,
  8084. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8085. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8086. console.log(scope.editData);
  8087. $scope.personData = {}; //指派人
  8088. $scope.priorityData = {}; //优先级
  8089. $scope.personListData = {}; //指派人下拉数据
  8090. $scope.priorityListData = {}; //优先级下拉数据
  8091. $scope.startTime = ""; //开始时间
  8092. $scope.releaseShow = "no";
  8093. $scope.endTime = ""; //结束时间
  8094. $scope.taskDescribe = ""; //任务描述
  8095. $scope.taskDescribe = scope.editData.taskDescribe;
  8096. $scope.personData.data = scope.editData.assign;
  8097. $scope.priorityData.data = scope.editData.priority;
  8098. $scope.startTime = scope.editData.startTime;
  8099. $scope.endTime = scope.editData.endTime;
  8100. // 指派人下拉框数据
  8101. $scope.getPersonData = function () {
  8102. var data = {
  8103. "idx": 0,
  8104. "sum": 1000
  8105. }
  8106. api_user_data.fetchDataList("user", data).then(function (res) {
  8107. $scope.personListData = res.list;
  8108. })
  8109. }
  8110. $scope.getPersonData();
  8111. //优先级下拉数据
  8112. $scope.getPriorityData = function () {
  8113. var data = {
  8114. "key": "change_rick_level",
  8115. "type": "list"
  8116. }
  8117. api_wechatfile.getDictionary(data).then(function (res) {
  8118. $scope.priorityListData = res
  8119. })
  8120. }
  8121. $scope.getPriorityData();
  8122. // 获取状态-lmm
  8123. $scope.stateListData = {};
  8124. $scope.getStateData = function () {//lyl
  8125. var data = {
  8126. "key": 'task_sub_state',
  8127. "type": 'list'
  8128. }
  8129. api_wechatfile.getDictionary(data).then(function (res) {
  8130. angular.forEach(res, function (v, i) {
  8131. $scope.stateListData[v.value] = v.id;
  8132. })
  8133. })
  8134. }
  8135. $scope.getStateData();
  8136. //时间控件
  8137. $scope.open = function ($event) {
  8138. $event.preventDefault();
  8139. $event.stopPropagation();
  8140. $scope.opened = !$scope.opened;
  8141. };
  8142. $scope.endOpen = function ($event) {
  8143. $event.preventDefault();
  8144. $event.stopPropagation();
  8145. $scope.startOpened = false;
  8146. $scope.endOpened = !$scope.endOpened;
  8147. };
  8148. $scope.startOpen = function ($event) {
  8149. $event.preventDefault();
  8150. $event.stopPropagation();
  8151. $scope.endOpened = false;
  8152. $scope.startOpened = !$scope.startOpened;
  8153. };
  8154. // 确定
  8155. $scope.ok = function (item) {
  8156. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8157. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8158. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8159. $scope.addData = {
  8160. "taskSub": {
  8161. "taskDescribe": $scope.taskDescribe,
  8162. "assign": $scope.personData.data,
  8163. "priority": $scope.priorityData.data,
  8164. "startTime": $scope.startTime,
  8165. "endTime": $scope.endTime,
  8166. "taskMonth": {
  8167. "id": scope.model.taskMonth.id
  8168. },
  8169. "id": scope.editData.id
  8170. }
  8171. }
  8172. $scope.addData.taskSub["state"] = {
  8173. "id": $scope.stateListData[1]
  8174. };
  8175. api_user_data.updData('taskSub', $scope.addData).then(function (res) {
  8176. if (res.status == 200) {
  8177. SweetAlert.swal({
  8178. title: "修改成功!",
  8179. type: "success",
  8180. confirmButtonColor: "#007AFF"
  8181. });
  8182. scope.refreshData(scope.jry_filterdata);
  8183. $modalInstance.dismiss('cancel');
  8184. } else {
  8185. SweetAlert.swal({
  8186. title: "修改失败",
  8187. text: "系统错误,请重试!",
  8188. type: "error"
  8189. });
  8190. $modalInstance.dismiss('cancel');
  8191. }
  8192. })
  8193. } else {
  8194. SweetAlert.swal({
  8195. title: "修改失败",
  8196. text: "必填项不能为空!",
  8197. type: "error"
  8198. });
  8199. }
  8200. };
  8201. $scope.cancel = function () {
  8202. $modalInstance.dismiss('cancel');
  8203. }
  8204. },
  8205. size: 'sm',
  8206. resolve: {
  8207. scope: function () {
  8208. return $scope;
  8209. },
  8210. },
  8211. backdrop: true
  8212. });
  8213. }
  8214. // 发布
  8215. $scope.release = function (data) {
  8216. SweetAlert.swal({
  8217. title: "确认发布?",
  8218. text: "请确定发布操作!",
  8219. type: "warning",
  8220. showCancelButton: true,
  8221. confirmButtonColor: "#DD6B55",
  8222. confirmButtonText: "确定",
  8223. cancelButtonText: "取消",
  8224. closeOnConfirm: false,
  8225. closeOnCancel: false
  8226. }, function (isConfirm) {
  8227. if (isConfirm) {
  8228. data.state.id = $scope.stateListData[2];
  8229. delete data.item;
  8230. api_user_data.updData("taskSub", {
  8231. taskSub: data
  8232. }).then(function (res) {
  8233. if (res.status == 200) {
  8234. SweetAlert.swal({
  8235. title: "发布成功!",
  8236. type: "success",
  8237. confirmButtonColor: "#007AFF"
  8238. });
  8239. $scope.refreshData($scope.jry_filterdata);
  8240. } else {
  8241. SweetAlert.swal({
  8242. title: "删除失败",
  8243. text: "系统错误,请重试!",
  8244. type: "error"
  8245. });
  8246. }
  8247. })
  8248. } else {
  8249. SweetAlert.swal("操作取消", "发布取消", "error");
  8250. }
  8251. });
  8252. }
  8253. // 删除
  8254. $scope.remove = function (data) {
  8255. SweetAlert.swal({
  8256. title: "确认删除?",
  8257. text: "删除的数据不可恢复,请确认继续操作!",
  8258. type: "warning",
  8259. showCancelButton: true,
  8260. confirmButtonColor: "#DD6B55",
  8261. confirmButtonText: "继续删除",
  8262. cancelButtonText: "取消操作",
  8263. closeOnConfirm: false,
  8264. closeOnCancel: false
  8265. }, function (isConfirm) {
  8266. if (isConfirm) {
  8267. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  8268. if (res.status == 200) {
  8269. SweetAlert.swal({
  8270. title: "删除成功!",
  8271. type: "success",
  8272. confirmButtonColor: "#007AFF"
  8273. });
  8274. $scope.refreshData($scope.jry_filterdata);
  8275. } else {
  8276. SweetAlert.swal({
  8277. title: "删除失败",
  8278. text: "系统错误,请重试!",
  8279. type: "error"
  8280. });
  8281. }
  8282. })
  8283. } else {
  8284. SweetAlert.swal("操作取消", "数据安全", "error");
  8285. }
  8286. });
  8287. }
  8288. $scope.refreshData = function (filterData) {
  8289. // $scope.ldloading[style.replace('-', '_')] = true;
  8290. if (angular.isUndefined(filterData)) {
  8291. filterData = defaultFilterData;
  8292. }
  8293. $scope.myData = [];
  8294. $scope.memoryfilterData = filterData;
  8295. api_doc_data.fetchDataList('taskSub', filterData).then(function (data) {
  8296. var myData = data;
  8297. $scope.gridOptions.totalItems = myData.totalNum;
  8298. $scope.removeFileNum = myData.totalNum;
  8299. if (angular.isArray(myData.list)) {
  8300. $scope.myData = myData.list;
  8301. for (var i = 0; i < $scope.myData.length; i++) {
  8302. //添加序号
  8303. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  8304. $scope.myData[i].startTime = moment($scope.myData[i].startTime).format('YYYY-MM-DD HH:mm:ss');
  8305. $scope.myData[i].endTime = moment($scope.myData[i].endTime).format('YYYY-MM-DD HH:mm:ss');
  8306. }
  8307. }
  8308. }, function () {
  8309. // $scope.ldloading[style.replace('-', '_')] = false;
  8310. });
  8311. };
  8312. //分页控制
  8313. $scope.gridOptions.onRegisterApi = function (gridApi) {
  8314. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  8315. $scope.jry_filterdata.idx = newPage - 1;
  8316. $scope.fenye = newPage - 1;
  8317. $scope.jry_filterdata.sum = pageSize;
  8318. $scope.refreshData($scope.jry_filterdata);
  8319. });
  8320. }
  8321. $scope.fenye = 0;
  8322. if ($scope.model.label == "分配任务") {
  8323. $scope.jry_filterdata = {
  8324. "idx": $scope.fenye,
  8325. "sum": 10,
  8326. "taskSub": {
  8327. "taskMonth": {
  8328. "id": $scope.model.taskMonth.id
  8329. },
  8330. "userid": loginUser.id,
  8331. "role": loginUser.role
  8332. }
  8333. };
  8334. } else {
  8335. $scope.jry_filterdata = {
  8336. "idx": $scope.fenye,
  8337. "sum": 10,
  8338. "taskSub": {
  8339. "taskMonth": {
  8340. "id": $scope.model.taskMonth.id
  8341. },
  8342. "userid": loginUser.id,
  8343. "role": loginUser.role,
  8344. "type": 1
  8345. }
  8346. };
  8347. }
  8348. $scope.refreshData($scope.jry_filterdata);
  8349. //新增模态框
  8350. $scope.newDistribution = function () {
  8351. var modalInstance = $modal.open({
  8352. backdrop: false,
  8353. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8354. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8355. $scope.personData = {}; //指派人
  8356. $scope.priorityData = {}; //优先级
  8357. $scope.personListData = {}; //指派人下拉数据
  8358. $scope.priorityListData = {}; //优先级下拉数据
  8359. $scope.startTime = ""; //开始时间
  8360. $scope.endTime = ""; //结束时间
  8361. $scope.taskDescribe = ""; //任务描述
  8362. $scope.motaikuang = "";
  8363. $scope.shijian = "哈哈";
  8364. // 指派人下拉框数据
  8365. $scope.getPersonData = function () {
  8366. var data = {
  8367. "idx": 0,
  8368. "sum": 1000
  8369. }
  8370. api_user_data.fetchDataList("user", data).then(function (res) {
  8371. $scope.personListData = res.list;
  8372. })
  8373. }
  8374. $scope.getPersonData();
  8375. //优先级下拉数据
  8376. $scope.getPriorityData = function () {
  8377. var data = {
  8378. "key": "change_rick_level",
  8379. "type": "list"
  8380. }
  8381. api_wechatfile.getDictionary(data).then(function (res) {
  8382. $scope.priorityListData = res
  8383. })
  8384. }
  8385. // 控制结束时间的最大时间
  8386. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  8387. // 控制结束时间的最小时间
  8388. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  8389. $scope.$watch('startTime', function (n, o) {
  8390. if (n) {
  8391. if (n > scope.model.taskMonth.startTime) {
  8392. $scope.jryEndMinTime = n
  8393. }
  8394. }
  8395. })
  8396. // 控制开始时间的最小时间
  8397. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  8398. // 控制开始时间的最大时间
  8399. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  8400. $scope.$watch('endTime', function (n, o) {
  8401. if (n) {
  8402. if (n < scope.model.taskMonth.endTime) {
  8403. $scope.jryStartMaxTime = n
  8404. }
  8405. }
  8406. })
  8407. $scope.getPriorityData();
  8408. //时间控件
  8409. $scope.open = function ($event) {
  8410. $event.preventDefault();
  8411. $event.stopPropagation();
  8412. $scope.opened = !$scope.opened;
  8413. };
  8414. $scope.endOpen = function ($event) {
  8415. $event.preventDefault();
  8416. $event.stopPropagation();
  8417. $scope.startOpened = false;
  8418. $scope.endOpened = !$scope.endOpened;
  8419. };
  8420. $scope.startOpen = function ($event) {
  8421. $event.preventDefault();
  8422. $event.stopPropagation();
  8423. $scope.endOpened = false;
  8424. $scope.startOpened = !$scope.startOpened;
  8425. };
  8426. $scope.datepickerPopup = 'yyyy-MM-dd HH:mm:ss';
  8427. // 获取状态-lmm
  8428. $scope.stateListData = {};
  8429. $scope.getStateData = function () {//lyl
  8430. var data = {
  8431. "key": 'task_sub_state',
  8432. "type": 'list'
  8433. }
  8434. api_wechatfile.getDictionary(data).then(function (res) {
  8435. angular.forEach(res, function (v, i) {
  8436. $scope.stateListData[v.value] = v.id;
  8437. })
  8438. })
  8439. }
  8440. $scope.getStateData();
  8441. // 草稿保存
  8442. $scope.ok = function (item) {
  8443. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8444. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8445. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8446. $scope.addData = {
  8447. "taskSub": {
  8448. "taskDescribe": $scope.taskDescribe,
  8449. "assign": $scope.personData.data,
  8450. "priority": $scope.priorityData.data,
  8451. "startTime": $scope.startTime,
  8452. "endTime": $scope.endTime,
  8453. "taskMonth": {
  8454. "id": scope.model.taskMonth.id
  8455. }
  8456. }
  8457. }
  8458. $scope.addData.taskSub["state"] = {
  8459. "id": $scope.stateListData[1]
  8460. };
  8461. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8462. if (res.status == 200) {
  8463. SweetAlert.swal({
  8464. title: "保存成功!",
  8465. type: "success",
  8466. confirmButtonColor: "#007AFF"
  8467. });
  8468. scope.refreshData(scope.jry_filterdata);
  8469. $modalInstance.dismiss('cancel');
  8470. } else {
  8471. SweetAlert.swal({
  8472. title: "保存失败",
  8473. text: "系统错误,请重试!",
  8474. type: "error"
  8475. });
  8476. $modalInstance.dismiss('cancel');
  8477. }
  8478. })
  8479. } else {
  8480. SweetAlert.swal({
  8481. title: "保存失败",
  8482. text: "必填项不能为空!",
  8483. type: "error"
  8484. });
  8485. }
  8486. };
  8487. // 发布
  8488. $scope.release = function () {
  8489. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8490. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8491. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8492. $scope.addData = {
  8493. "taskSub": {
  8494. "taskDescribe": $scope.taskDescribe,
  8495. "assign": $scope.personData.data,
  8496. "priority": $scope.priorityData.data,
  8497. "startTime": $scope.startTime,
  8498. "endTime": $scope.endTime,
  8499. "taskMonth": {
  8500. "id": scope.model.taskMonth.id
  8501. }
  8502. }
  8503. }
  8504. $scope.addData.taskSub["state"] = {
  8505. "id": $scope.stateListData[1]
  8506. };
  8507. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8508. if (res.status == 200) {
  8509. SweetAlert.swal({
  8510. title: "保存成功!",
  8511. type: "success",
  8512. confirmButtonColor: "#007AFF"
  8513. });
  8514. scope.refreshData(scope.jry_filterdata);
  8515. $modalInstance.dismiss('cancel');
  8516. } else {
  8517. SweetAlert.swal({
  8518. title: "保存失败",
  8519. text: "系统错误,请重试!",
  8520. type: "error"
  8521. });
  8522. $modalInstance.dismiss('cancel');
  8523. }
  8524. })
  8525. } else {
  8526. SweetAlert.swal({
  8527. title: "保存失败",
  8528. text: "必填项不能为空!",
  8529. type: "error"
  8530. });
  8531. }
  8532. }
  8533. $scope.cancel = function () {
  8534. $modalInstance.dismiss('cancel');
  8535. }
  8536. },
  8537. size: 'sm',
  8538. resolve: {
  8539. scope: function () {
  8540. return $scope;
  8541. },
  8542. },
  8543. backdrop: true
  8544. });
  8545. }
  8546. }
  8547. });
  8548. // 多次反馈文本域组件--jry
  8549. formlyConfigProvider.setType({
  8550. name: 'ui-feedbacktTextarea',
  8551. extends: 'textarea',
  8552. templateUrl: 'assets/views/customform/tpl/ui-feedbacktTextarea.html',
  8553. defaultOptions: function (options) {
  8554. return {
  8555. templateOptions: {
  8556. transform: function (model, value) {
  8557. return value;
  8558. },
  8559. },
  8560. validation: {
  8561. messages: {
  8562. maxlength: function (viewValue, modelValue, scope) {
  8563. if (viewValue != null) {
  8564. if (viewValue.length > scope.to.maxlength) {
  8565. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8566. } else {
  8567. return "";
  8568. }
  8569. }
  8570. },
  8571. }
  8572. }
  8573. }
  8574. },
  8575. controller: ['$scope', 'moment', function ($scope, moment) {
  8576. // console.log($scope);
  8577. var timeKey = $scope.options.templateOptions.time;
  8578. $scope.time = moment($scope.model[timeKey]).format('YYYY-MM-DD HH:mm:ss');
  8579. var value = $scope.model[$scope.options.key];
  8580. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8581. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8582. }
  8583. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  8584. $scope.options.templateOptions.felditem($scope);
  8585. }
  8586. }]
  8587. });
  8588. //任务管理开始时间--jry
  8589. formlyConfigProvider.setType({
  8590. name: 'ui-jryStartdatepicker',
  8591. templateUrl: 'assets/views/customform/tpl/ui-jryStartdatepicker.html',
  8592. extends: 'input',
  8593. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8594. defaultOptions: {
  8595. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8596. templateOptions: {
  8597. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8598. }
  8599. },
  8600. controller: ['$scope', '$filter', function ($scope, $filter) {
  8601. // console.log($scope.model[$scope.options.key],'lmm');
  8602. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8603. if ($scope.model[$scope.options.key]) {
  8604. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8605. }
  8606. // console.log($scope.model[$scope.options.key],'lmm');
  8607. // console.log($scope.model,'lmm',$scope.options.key);
  8608. $scope.options.initialValue = $scope.model[$scope.options.key];
  8609. $scope.endOpen = true;
  8610. $scope.datepicker = {};
  8611. $scope.datepicker.opened = false;
  8612. $scope.datepicker.open = function ($event) {
  8613. $scope.datepicker.opened = true;
  8614. };
  8615. }]
  8616. });
  8617. //任务管理结束时间--jry
  8618. formlyConfigProvider.setType({
  8619. name: 'ui-jryEnddatepicker',
  8620. templateUrl: 'assets/views/customform/tpl/ui-jryEnddatepicker.html',
  8621. extends: 'input',
  8622. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8623. defaultOptions: {
  8624. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8625. templateOptions: {
  8626. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8627. }
  8628. },
  8629. controller: ['$scope', '$filter', function ($scope, $filter) {
  8630. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8631. if ($scope.model[$scope.options.key]) {
  8632. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8633. }
  8634. $scope.options.initialValue = $scope.model[$scope.options.key];
  8635. $scope.endOpen = true;
  8636. $scope.datepicker = {};
  8637. $scope.datepicker.opened = false;
  8638. $scope.datepicker.open = function ($event) {
  8639. $scope.datepicker.opened = true;
  8640. };
  8641. }]
  8642. });
  8643. //下拉多选框灵活组件--jry
  8644. formlyConfigProvider.setType({
  8645. name: 'ui-jry_multiselectplus',
  8646. extends: 'multiCheckbox',
  8647. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8648. defaultOptions: function (options) {
  8649. return {
  8650. templateOptions: {
  8651. refreshData: function (search, options, model, that) {
  8652. // var process = options.templateOptions.ApiService.all("");
  8653. if (search) {
  8654. } else {
  8655. }
  8656. var postData = options.templateOptions.optionsPostData;
  8657. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8658. postData = options.templateOptions.optionsPostData(options, model, that);
  8659. }
  8660. options.templateOptions.ApiService.fetchDataList(options.templateOptions.optionsUrl, options.templateOptions.optionsPostData).then(function (result) {
  8661. // if (!options.templateOptions.options) {
  8662. // options.templateOptions.options = [];
  8663. // }
  8664. if (options.templateOptions.optionsDataKey) {
  8665. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8666. } else {
  8667. options.templateOptions.options = result;
  8668. }
  8669. if (options.templateOptions.optionsChecked) {
  8670. // return options.value = null;
  8671. options.value(options.model[options.key]);
  8672. }
  8673. });
  8674. },
  8675. refreshDelay: 0,
  8676. // },
  8677. validators: {
  8678. required: {
  8679. expression: function (viewValue, modelValue) {
  8680. var value = modelValue || viewValue;
  8681. return value != null;
  8682. // return value.length>=1;
  8683. // if (modelValue && viewValue) {
  8684. // return value != null;
  8685. // } else {
  8686. // var value = modelValue || viewValue;
  8687. // return value.length > 0;
  8688. // }
  8689. }
  8690. }
  8691. }
  8692. }
  8693. };
  8694. },
  8695. controller: ['$scope', function ($scope) {
  8696. console.log($scope.to);
  8697. if (angular.isArray($scope.model[$scope.options.key])) {
  8698. } else {
  8699. $scope.model[$scope.options.key] = [];
  8700. }
  8701. }]
  8702. });
  8703. //下拉框组件
  8704. formlyConfigProvider.setType({
  8705. name: 'ui-select',
  8706. extends: 'select',
  8707. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  8708. defaultOptions: function (options, scope) {
  8709. return {
  8710. templateOptions: {
  8711. // refresh: function() {},
  8712. refreshDelay: 0,
  8713. linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
  8714. console.log(model,'model')
  8715. angular.extend(data, {
  8716. "idx": 0,
  8717. "sum": 1000
  8718. });
  8719. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  8720. var myData = options.templateOptions.Restangular.stripRestangular(response);
  8721. var list = myData.list;
  8722. console.log(myData)
  8723. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  8724. // console.log('balabalabala');
  8725. // console.log(res);
  8726. // })
  8727. if (list.length == 1) {
  8728. if (options.templateOptions.APIport) {
  8729. options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
  8730. if (response.state == "200") {
  8731. // if (model.$parent.model && model.$parent.model.incident) {
  8732. // } else {
  8733. // model.$parent.model = { 'incident': {} };
  8734. // }
  8735. var myDatas = response.serviceLevelAgreement;
  8736. //逾期
  8737. scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
  8738. //解决
  8739. scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
  8740. //响应
  8741. scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
  8742. } else {
  8743. }
  8744. });
  8745. }
  8746. angular.forEach(model.fields, function (item) {
  8747. angular.forEach(model.fields, function (item) {
  8748. if (item.templateOptions.pkey == modelKey + "." + key) {
  8749. item.model.id = "";
  8750. if (key == "place") {
  8751. item.templateOptions.options = list;
  8752. } else if (key == "placeDTO") {
  8753. item.templateOptions.options = list;
  8754. } else if (key == "requester") {
  8755. } else {
  8756. item.value(list[0][key][item.key]);
  8757. }
  8758. }
  8759. })
  8760. })
  8761. } else {
  8762. if (model.fields) {
  8763. angular.forEach(model.fields, function (item) {
  8764. angular.forEach(model.fields, function (item) {
  8765. if (item.templateOptions.pkey == modelKey + "." + key) {
  8766. item.model.id = "";
  8767. if (key == "place") {
  8768. item.templateOptions.isnosearch = true;
  8769. item.templateOptions.options = list;
  8770. }
  8771. if (key == "placeDTO") {
  8772. item.templateOptions.options = list;
  8773. }
  8774. if (key == "requester") {
  8775. }
  8776. }
  8777. })
  8778. })
  8779. } else {
  8780. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8781. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8782. if (item.templateOptions.pkey == modelKey + "." + key) {
  8783. if (key == "place") {
  8784. item.templateOptions.isnosearch = true;
  8785. item.templateOptions.options = list;
  8786. scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
  8787. }
  8788. if (key == "placeDTO") {
  8789. item.templateOptions.options = list;
  8790. }
  8791. if (key == "requester") {
  8792. }
  8793. }
  8794. })
  8795. })
  8796. }
  8797. }
  8798. console.log(key)
  8799. //报修科室
  8800. if (key == 'dept') {
  8801. // 报修科室单选
  8802. scope.$parent.$parent.$parent.model.incident.department = response.list[0];
  8803. scope.$parent.$parent.$parent.model.incident.contactsInformation = response.list[0].phone;
  8804. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  8805. // 选择重复事件侧滑框
  8806. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  8807. setTimeout(() => {
  8808. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  8809. }, 500);
  8810. }
  8811. // 报修人
  8812. if (key == 'requester') {
  8813. // 报修人单选
  8814. scope.$parent.$parent.$parent.model.incident.requester = response.list[
  8815. 0];
  8816. console.log(scope.$parent.$parent.$parent.model)
  8817. scope.$parent.$parent.$parent.model.incident.account = response.list[
  8818. 0].account;
  8819. var selectedItem = response.list[
  8820. 0];
  8821. var data = {
  8822. 'requester': selectedItem
  8823. };
  8824. scope.$parent.$parent.$parent.model[
  8825. 'requestershow'] = selectedItem;
  8826. console.log(selectedItem, '----------------------')
  8827. // if (selectedItem.dept.place.place) {
  8828. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  8829. // }
  8830. scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.houseNumber?selectedItem.houseNumber:'';
  8831. scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place?selectedItem.place.area.id:null;
  8832. scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place?selectedItem.place.id:null;
  8833. console.log(scope,89898998)
  8834. // console.log(scope.formData,'接单页面');
  8835. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  8836. scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8837. scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8838. options.templateOptions.ApiService.addData('requester',
  8839. data).then(function (response) {
  8840. if (response.status == 200) {
  8841. if (scope.$parent.$parent.$parent) {
  8842. if (scope.$parent.$parent.$parent.place) {
  8843. scope.$parent.$parent.$parent.place.id = '';
  8844. }
  8845. if (scope.$parent.$parent.$parent.area) {
  8846. scope.$parent.$parent.$parent.area.id = '';
  8847. }
  8848. scope.$parent.$parent.$parent.model.incident.contacts = selectedItem.name;
  8849. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8850. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.mphone;
  8851. } else {
  8852. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.telephone;
  8853. }
  8854. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8855. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8856. }
  8857. }
  8858. if (!response.data.id) {
  8859. response.data.id = selectedItem.id
  8860. }
  8861. console.log(scope);
  8862. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  8863. // if (selectedItem.place && selectedItem.place.id) {
  8864. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8865. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  8866. // };
  8867. // } else {
  8868. // if (selectedItem.place && selectedItem.place.id) {
  8869. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8870. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  8871. // };
  8872. // }
  8873. // if(scope.$parent.$parent.$parent.model.incident.area){
  8874. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  8875. // }
  8876. if (selectedItem.id) {
  8877. scope.$parent.$parent.$parent.model.incident.account = selectedItem.account;
  8878. }
  8879. // 选择重复事件侧滑框
  8880. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  8881. scope.$parent.$parent.$parent.model[
  8882. 'repeatIncidentShow'] = false;
  8883. setTimeout(() => {
  8884. scope.$parent.$parent.$parent.model[
  8885. 'repeatIncidentShow'] = true;
  8886. },
  8887. 500);
  8888. // }
  8889. }
  8890. })
  8891. }
  8892. });
  8893. },
  8894. validators: {
  8895. required: {
  8896. expression: function (viewValue, modelValue) {
  8897. var value = modelValue || viewValue;
  8898. return value != null;
  8899. // return value.length>=1;
  8900. // if (modelValue && viewValue) {
  8901. // return value != null;
  8902. // } else {
  8903. // var value = modelValue || viewValue;
  8904. // return value.length > 0;
  8905. // }
  8906. }
  8907. }
  8908. }
  8909. },
  8910. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  8911. // $scope.myFilter = function(item) {
  8912. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  8913. // }
  8914. // console.log($scope,'风浪')
  8915. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  8916. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  8917. $scope.options.templateOptions.linkage("place", {
  8918. "place": {
  8919. "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
  8920. // area:{
  8921. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  8922. // }
  8923. }
  8924. }, $scope.$parent.$parent.$parent.model, "incident", "place");
  8925. }
  8926. }
  8927. $scope.myFilter = $scope;
  8928. // console.log($scope.options.templateOptions)
  8929. console.log($scope,77777)
  8930. //处理人根据事件分类自动带入
  8931. if($scope.options.templateOptions.pkey == "incident.handlerUser"){
  8932. if($scope.$parent.$parent.$parent.model.incident.handlerUser){
  8933. if($scope.$parent.$parent.$parent.model.incident.handlerUser.id){
  8934. $scope.options.model.id = $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  8935. }
  8936. }
  8937. }
  8938. // 关闭事件页面满意度评价下拉框处理
  8939. if($scope.options.templateOptions.onlyKey=="close_degree"){
  8940. $scope.model.id = $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id
  8941. }
  8942. if($scope.options.templateOptions.initData == 1){
  8943. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8944. }
  8945. if ($scope.options.templateOptions.transform) {
  8946. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8947. }
  8948. if (angular.isFunction($scope.options.templateOptions.translate)) {
  8949. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  8950. }
  8951. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  8952. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  8953. }
  8954. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  8955. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  8956. }
  8957. }]
  8958. };
  8959. }
  8960. });
  8961. //下拉多选框组件
  8962. formlyConfigProvider.setType({
  8963. name: 'ui-multiselect',
  8964. extends: 'select',
  8965. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  8966. defaultOptions: function (options) {
  8967. return {
  8968. templateOptions: {
  8969. refresh: function () { },
  8970. refreshDelay: 1000
  8971. }
  8972. };
  8973. },
  8974. controller: ['$scope', function ($scope) {
  8975. $scope.model[$scope.options.key] = [];
  8976. }]
  8977. });
  8978. //下拉多选框灵活组件
  8979. formlyConfigProvider.setType({
  8980. name: 'ui-multiselectplus',
  8981. extends: 'multiCheckbox',
  8982. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8983. defaultOptions: function (options, $scope) {
  8984. return {
  8985. templateOptions: {
  8986. refreshData: function (search, options, model, that) {
  8987. var process = options.templateOptions.ApiService.all("");
  8988. if (search) {
  8989. } else {
  8990. }
  8991. var postData = options.templateOptions.optionsPostData;
  8992. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8993. postData = options.templateOptions.optionsPostData(options, model, that);
  8994. }
  8995. if (options.templateOptions.modelreasondata) {
  8996. postData = options.templateOptions.modelreasondata
  8997. }
  8998. process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
  8999. // if (!options.templateOptions.options) {
  9000. // options.templateOptions.options = [];
  9001. // }
  9002. // 过滤下拉列表已选择的值
  9003. var modelVal = $scope.model[$scope.options.key];
  9004. for (var i = 0; i < result.list.length; i++) {
  9005. for (var j = 0; j < modelVal.length; j++) {
  9006. if (result.list[i].id == modelVal[j].id) {
  9007. result.list.splice(i, 1)
  9008. }
  9009. }
  9010. }
  9011. if (options.templateOptions.optionsDataKey) {
  9012. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  9013. } else {
  9014. options.templateOptions.options = result;
  9015. }
  9016. if (options.templateOptions.optionsChecked) {
  9017. // return options.value = null;
  9018. options.value(options.model[options.key]);
  9019. }
  9020. });
  9021. },
  9022. refreshDelay: 0,
  9023. // },
  9024. // validators: {
  9025. // required: {
  9026. // expression: function(viewValue, modelValue) {
  9027. // var value = modelValue || viewValue;
  9028. // // return value.length>=1;
  9029. // // if (modelValue && viewValue) {
  9030. // // return value != null;
  9031. // // } else {
  9032. // // var value = modelValue || viewValue;
  9033. // // return value.length > 0;
  9034. // // }
  9035. // }
  9036. // }
  9037. }
  9038. };
  9039. },
  9040. controller: ['$scope', function ($scope) {
  9041. if (angular.isArray($scope.model[$scope.options.key])) {
  9042. } else {
  9043. $scope.model[$scope.options.key] = [];
  9044. }
  9045. }]
  9046. });
  9047. //下拉树形多选组件
  9048. formlyConfigProvider.setType({
  9049. name: 'ui-multiselect-tree',
  9050. extends: 'multiCheckbox',
  9051. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9052. defaultOptions: function (options) {
  9053. return {
  9054. templateOptions: {
  9055. linkage: function (modelName, data, model, modelKey, key) {
  9056. angular.extend(data, {
  9057. "idx": 0,
  9058. "sum": 10
  9059. });
  9060. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9061. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9062. var list = myData.list;
  9063. if (list.length == 1) {
  9064. angular.forEach(model.fields, function (item) {
  9065. angular.forEach(model.fields, function (item) {
  9066. if (item.templateOptions.pkey == modelKey + "." + key) {
  9067. item.model.id = "";
  9068. if (key == "place") {
  9069. item.templateOptions.options = list;
  9070. } else {
  9071. item.value(list[0][key][item.key]);
  9072. }
  9073. }
  9074. })
  9075. })
  9076. }
  9077. });
  9078. },
  9079. // my_tree_handler : function(items) {
  9080. // },
  9081. // onFilterCallback : function(items) {
  9082. // },
  9083. // onFilterCallback : function(items) {
  9084. // },
  9085. refresh: function (items) {
  9086. var treedata = [];
  9087. function convertListToTree(data, treeMap) {
  9088. treedata = data;
  9089. for (var i = 0; i < data.length; i++) {
  9090. for (var j = 0; j < data.length; j++) {
  9091. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9092. if (data[i].pid == data[j].id) {
  9093. data[i].parent = data[j];
  9094. }
  9095. }
  9096. }
  9097. }
  9098. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9099. var root = null; //Initially set our loop to null
  9100. //loop over data
  9101. for (var i = 0; i < data.length; i++) {
  9102. var datum = data[i];
  9103. //each node will have children, so let's give it a "children" poperty
  9104. datum.children = [];
  9105. //add an entry for this node to the map so that any future children can
  9106. //lookup the parent
  9107. idToNodeMap[datum.id] = datum;
  9108. //Does this node have a parent?
  9109. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9110. //Doesn't look like it, so this node is the root of the tree
  9111. root = datum;
  9112. treeMap[datum.id] = root;
  9113. } else {
  9114. //This node has a parent, so let's look it up using the id
  9115. parentNode = idToNodeMap[datum.parent.id];
  9116. //We don't need this property, so let's delete it.
  9117. delete datum.parent;
  9118. //Let's add the current node as a child of the parent node.
  9119. parentNode.children.push(datum);
  9120. }
  9121. }
  9122. return root;
  9123. }
  9124. function convertParentToChildList(data) {
  9125. // console.log("data="+JSON.stringify(data))
  9126. var treeMap = {};
  9127. var list = [];
  9128. convertListToTree(data, treeMap);
  9129. angular.forEach(treeMap, function (item) {
  9130. list.push(item);
  9131. });
  9132. return list;
  9133. }
  9134. function selectItem(pmodel, childrens) {
  9135. if (angular.isArray(pmodel)) {
  9136. angular.forEach(pmodel, function (index) {
  9137. if (index && index.id) {
  9138. angular.forEach(childrens, function (item) {
  9139. if (item.id == index.id) {
  9140. item.selected = true;
  9141. }
  9142. if (item && item.children) {
  9143. selectItem(pmodel, item.children);
  9144. }
  9145. });
  9146. }
  9147. })
  9148. } else {
  9149. if (pmodel && pmodel.id) {
  9150. angular.forEach(childrens, function (item) {
  9151. if (item.id == pmodel.id) {
  9152. item.selected = true;
  9153. }
  9154. if (item && item.children) {
  9155. selectItem(pmodel, item.children);
  9156. }
  9157. });
  9158. }
  9159. }
  9160. }
  9161. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9162. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9163. if (result.status == 200) {
  9164. if (!options.templateOptions.options) {
  9165. options.templateOptions.options = [];
  9166. }
  9167. if (options.templateOptions.optionsDataKey) {
  9168. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9169. } else {
  9170. options.templateOptions.options = convertParentToChildList(result);
  9171. }
  9172. //set default value
  9173. var pmodel, i = 0;
  9174. if (options.templateOptions.pkey) {
  9175. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9176. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9177. if (i == 0) {
  9178. if (options.model[p] == null) {
  9179. options.model[p] = {};
  9180. }
  9181. pmodel = options.model[p];
  9182. i++;
  9183. } else {
  9184. if (pmodel[p] == null) {
  9185. pmodel[p] = {};
  9186. }
  9187. pmodel = pmodel[p];
  9188. }
  9189. });
  9190. } else {
  9191. pmodel = options.model;
  9192. }
  9193. }
  9194. if (pmodel) {
  9195. pmodel = pmodel[options.key];
  9196. } else if (options.model) {
  9197. pmodel = options.model[options.key];
  9198. } else {
  9199. pmodel = options.templateOptions.options;
  9200. }
  9201. if (angular.isArray(pmodel)) {
  9202. if (pmodel) {
  9203. // if(options.templateOptions.isMultiSelect==true){
  9204. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  9205. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  9206. // })
  9207. // }else{
  9208. selectItem(pmodel, options.templateOptions.options);
  9209. // }
  9210. }
  9211. } else {
  9212. if (pmodel && pmodel.id) {
  9213. selectItem(pmodel, options.templateOptions.options);
  9214. }
  9215. }
  9216. items.inputModel = options.templateOptions.options;
  9217. }
  9218. });
  9219. }
  9220. },
  9221. validators: {
  9222. required: {
  9223. expression: function (viewValue, modelValue) {
  9224. var value = modelValue || viewValue;
  9225. if (angular.isArray(value)) {
  9226. for (var i = 0; i < value.length; i++) {
  9227. value[i] = {
  9228. id: value[i].id
  9229. }
  9230. }
  9231. return value.length > 0
  9232. } else {
  9233. // console.log(options)
  9234. // return value = "true";
  9235. return value != null;
  9236. }
  9237. }
  9238. }
  9239. }
  9240. }
  9241. },
  9242. controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
  9243. if ($scope.options.templateOptions.isMultiSelect) {
  9244. // console.log($scope);
  9245. } else {
  9246. if ($scope.model[$scope.options.key]) {
  9247. }
  9248. }
  9249. }]
  9250. });
  9251. //多选下拉框组件
  9252. formlyConfigProvider.setType({
  9253. name: 'ui-multi-select-tree',
  9254. extends: 'input',
  9255. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9256. defaultOptions: function (options) {
  9257. return {
  9258. templateOptions: {
  9259. linkage: function (modelName, data, model, modelKey, key) {
  9260. angular.extend(data, {
  9261. "idx": 0,
  9262. "sum": 10
  9263. });
  9264. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9265. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9266. var list = myData.list;
  9267. if (list.length == 1) {
  9268. angular.forEach(model.fields, function (item) {
  9269. angular.forEach(model.fields, function (item) {
  9270. if (item.templateOptions.pkey == modelKey + "." + key) {
  9271. item.model.id = "";
  9272. if (key == "place") {
  9273. item.templateOptions.options = list;
  9274. } else {
  9275. item.value(list[0][key][item.key]);
  9276. }
  9277. }
  9278. })
  9279. })
  9280. }
  9281. });
  9282. },
  9283. getparentdata: function (items) {
  9284. // console.log(items)
  9285. },
  9286. refresh: function (items, search, fn) {
  9287. console.log(items);
  9288. var treedata = [];
  9289. function convertListToTree(data, treeMap) {
  9290. // console.log(data)
  9291. treedata = data;
  9292. for (var i = 0; i < data.length; i++) {
  9293. for (var j = 0; j < data.length; j++) {
  9294. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9295. if (data[i].pid == data[j].id) {
  9296. data[i].parent = data[j];
  9297. }
  9298. }
  9299. // if (data[i].id) {
  9300. // if (data[i].id== data[j].id) {
  9301. // data[i].parent = data[j];
  9302. // }
  9303. // }
  9304. }
  9305. }
  9306. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9307. var root = []; //Initially set our loop to null
  9308. if (search == 'search' && items.filterKeyword) {
  9309. function transform(nodes) {
  9310. var treeConverter = {
  9311. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  9312. attributeName: 'id', //节点唯一标识符
  9313. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  9314. transform: function (node) { //转化递归函数,参数:一个待插入节点
  9315. if (node.parent != null) { //该节点有父节点
  9316. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  9317. if (this.needFind) {
  9318. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  9319. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  9320. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9321. }
  9322. }
  9323. }
  9324. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  9325. // delete node.parent; //删除该节点的parent属性,如果有的话
  9326. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  9327. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  9328. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  9329. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  9330. // delete node.parent; //删除该节点的parent属性,如果有的话
  9331. if (this.result == null) { //根节点不存在
  9332. node.children = []; //给该节点增加children:[]属性
  9333. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9334. } else {
  9335. node.children = [];
  9336. // 顶级去重
  9337. for (var i = 0; i < this.result.children.length; i++) {
  9338. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  9339. return this.result.children[i];
  9340. }
  9341. }
  9342. this.result.children.push(node)
  9343. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9344. }
  9345. }
  9346. },
  9347. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  9348. var _node = {};
  9349. _node.children = [];
  9350. this.result = _node; //重置根节点
  9351. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  9352. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  9353. nodes.forEach(item => { //循环调用转化方法
  9354. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  9355. this.transform(item);
  9356. })
  9357. return this.result; //返回根节点
  9358. }
  9359. }
  9360. var result = treeConverter.getWhole(nodes); //调用
  9361. return result;
  9362. }
  9363. var li = transform(data).children;
  9364. // li=[...new Set(li)]
  9365. console.log(li)
  9366. treeMap = li;
  9367. fn(li);
  9368. return li;
  9369. } else {
  9370. //loop over data
  9371. for (var i = 0; i < data.length; i++) {
  9372. var datum = data[i];
  9373. //each node will have children, so let's give it a "children" poperty
  9374. datum.children = [];
  9375. //add an entry for this node to the map so that any future children can
  9376. //lookup the parent
  9377. idToNodeMap[datum.id] = datum;
  9378. //Does this node have a parent?
  9379. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9380. //Doesn't look like it, so this node is the root of the tree
  9381. root = datum;
  9382. treeMap[datum.id] = root;
  9383. } else {
  9384. //This node has a parent, so let's look it up using the id
  9385. parentNode = idToNodeMap[datum.parent.id];
  9386. //We don't need this property, so let's delete it.
  9387. // delete datum.parent;
  9388. //Let's add the current node as a child of the parent node.
  9389. parentNode.children.push(datum);
  9390. }
  9391. }
  9392. }
  9393. return root;
  9394. }
  9395. function convertParentToChildList(data) {
  9396. var treeMap = {};
  9397. var list = [];
  9398. if (search == 'search' && items.filterKeyword) {
  9399. var lis = convertListToTree(data, treeMap)
  9400. return lis;
  9401. } else {
  9402. if (data[0] && data[0].orders) {
  9403. list = data;
  9404. } else {
  9405. convertListToTree(data, treeMap);
  9406. angular.forEach(treeMap, function (item) {
  9407. // console.log("item="+JSON.stringify(item))
  9408. list.push(item);
  9409. });
  9410. }
  9411. return list;
  9412. }
  9413. }
  9414. function selectItem(pmodel, childrens) {
  9415. if (angular.isArray(pmodel)) {
  9416. angular.forEach(pmodel, function (index) {
  9417. if (index && index.id) {
  9418. angular.forEach(childrens, function (item) {
  9419. if (item.id == index.id) {
  9420. item.selected = true;
  9421. }
  9422. if (item && item.children) {
  9423. selectItem(pmodel, item.children);
  9424. }
  9425. });
  9426. // angular.forEach(treedata,function(parentdata){
  9427. // if(parentdata.id == index.id){
  9428. // if(parentdata.parent&&parentdata.parent.id){
  9429. // parentdata.parent.$
  9430. // }
  9431. // item.selected = true;
  9432. // }
  9433. // if (item && item.children) {
  9434. // selectItem(pmodel ,item.children);
  9435. // }
  9436. // });
  9437. }
  9438. })
  9439. } else {
  9440. if (pmodel && pmodel.id) {
  9441. angular.forEach(childrens, function (item, index) {
  9442. if (item.id == pmodel.id) {
  9443. item.selected = true;
  9444. delete item.children;
  9445. }
  9446. if (item && item.children) {
  9447. selectItem(pmodel, item.children);
  9448. }
  9449. });
  9450. }
  9451. }
  9452. }
  9453. function selectItemchild(pmodel, childrens) {
  9454. if (angular.isArray(pmodel)) {
  9455. angular.forEach(pmodel, function (index) {
  9456. if (index && index.id) {
  9457. angular.forEach(childrens, function (item) {
  9458. if (item.id == index.id) {
  9459. item.selected = true;
  9460. }
  9461. if (item && item.children) {
  9462. selectItem(pmodel, item.children);
  9463. }
  9464. });
  9465. }
  9466. })
  9467. } else {
  9468. if (pmodel && pmodel.id) {
  9469. angular.forEach(childrens, function (item, index) {
  9470. if (item.id == pmodel.id) {
  9471. item.selected = true;
  9472. childrens[index].selected = true;
  9473. }
  9474. if (item && item.children) {
  9475. selectItem(pmodel, item.children);
  9476. }
  9477. });
  9478. }
  9479. }
  9480. }
  9481. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9482. if (search === 'search' && items.filterKeyword) {
  9483. // bala:树形模糊搜索
  9484. options.templateOptions.bala(options.templateOptions.APIService, items.filterKeyword).then(function (result) {
  9485. result.list = [...new Set(result.list)]; //去重
  9486. if (!options.templateOptions.options) {
  9487. options.templateOptions.options = [];
  9488. }
  9489. if (options.templateOptions.optionsDataKey) {
  9490. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9491. } else {
  9492. options.templateOptions.options = convertParentToChildList(result);
  9493. }
  9494. //set default value
  9495. var pmodel, i = 0;
  9496. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9497. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9498. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9499. if (i == 0) {
  9500. if (options.model[p] == null) {
  9501. options.model[p] = {};
  9502. }
  9503. pmodel = options.model[p];
  9504. i++;
  9505. } else {
  9506. if (pmodel[p] == null) {
  9507. pmodel[p] = {};
  9508. }
  9509. pmodel = pmodel[p];
  9510. }
  9511. });
  9512. } else {
  9513. pmodel = options.model;
  9514. }
  9515. }
  9516. var topdata = angular.copy(options.templateOptions.options);
  9517. if (pmodel) {
  9518. pmodel = pmodel[options.key];
  9519. } else if (options.model) {
  9520. pmodel = options.model[options.key];
  9521. }
  9522. if (angular.isArray(pmodel)) {
  9523. if (pmodel) {
  9524. items.inputModel = angular.copy(options.templateOptions.options);
  9525. selectItem(pmodel, options.templateOptions.options);
  9526. }
  9527. } else {
  9528. if (pmodel && pmodel.id) {
  9529. items.inputModel = angular.copy(options.templateOptions.options);
  9530. selectItem(pmodel, options.templateOptions.options);
  9531. } else {
  9532. // items.inputModel = options.templateOptions.options;
  9533. }
  9534. }
  9535. // items.inputModel = options.templateOptions.options;
  9536. items.selectModel = options.templateOptions.options;
  9537. // 可在此展开
  9538. if (!items.inputModel) {
  9539. items.inputModel = items.selectModel;
  9540. } else {
  9541. selectItemchild(pmodel, items.inputModel);
  9542. // for (var i = 0; i < items.inputModel.length; i++) {
  9543. // items.inputModel[i].
  9544. // for (var j = 0; j < items.selectModel.length; j++) {
  9545. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9546. // items.inputModel[i].selected = true;
  9547. // }
  9548. // }
  9549. // }
  9550. }
  9551. return items.inputModel;
  9552. // options.templateOptions.options = angular.copy(topdata);
  9553. // console.log(model);
  9554. // console.log(options);
  9555. });
  9556. } else {
  9557. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9558. if (!options.templateOptions.options) {
  9559. options.templateOptions.options = [];
  9560. }
  9561. if (options.templateOptions.optionsDataKey) {
  9562. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9563. } else {
  9564. options.templateOptions.options = convertParentToChildList(result);
  9565. }
  9566. //set default value
  9567. var pmodel, i = 0;
  9568. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9569. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9570. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9571. if (i == 0) {
  9572. if (options.model[p] == null) {
  9573. options.model[p] = {};
  9574. }
  9575. pmodel = options.model[p];
  9576. i++;
  9577. } else {
  9578. if (pmodel[p] == null) {
  9579. pmodel[p] = {};
  9580. }
  9581. pmodel = pmodel[p];
  9582. }
  9583. });
  9584. } else {
  9585. pmodel = options.model;
  9586. }
  9587. }
  9588. var topdata = angular.copy(options.templateOptions.options);
  9589. if (pmodel) {
  9590. pmodel = pmodel[options.key];
  9591. } else if (options.model) {
  9592. pmodel = options.model[options.key];
  9593. }
  9594. if (angular.isArray(pmodel)) {
  9595. if (pmodel) {
  9596. items.inputModel = angular.copy(options.templateOptions.options);
  9597. selectItem(pmodel, options.templateOptions.options);
  9598. }
  9599. } else {
  9600. if (pmodel && pmodel.id) {
  9601. items.inputModel = angular.copy(options.templateOptions.options);
  9602. selectItem(pmodel, options.templateOptions.options);
  9603. } else {
  9604. // items.inputModel = options.templateOptions.options;
  9605. }
  9606. }
  9607. // items.inputModel = options.templateOptions.options;
  9608. items.selectModel = options.templateOptions.options;
  9609. if (!items.inputModel) {
  9610. items.inputModel = items.selectModel;
  9611. } else {
  9612. selectItemchild(pmodel, items.inputModel);
  9613. // for (var i = 0; i < items.inputModel.length; i++) {
  9614. // for (var j = 0; j < items.selectModel.length; j++) {
  9615. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9616. // items.inputModel[i].selected = true;
  9617. // }
  9618. // }
  9619. // }
  9620. }
  9621. // options.templateOptions.options = angular.copy(topdata);
  9622. // console.log(model);
  9623. // console.log(options);
  9624. });
  9625. }
  9626. }
  9627. },
  9628. validators: {
  9629. required: {
  9630. expression: function (viewValue, modelValue) {
  9631. var value = modelValue || viewValue;
  9632. if (angular.isArray(value)) {
  9633. return value.length > 0
  9634. } else {
  9635. // console.log(options)
  9636. if (options.templateOptions.required && !value) {
  9637. // return value != null;
  9638. } else {
  9639. return value;
  9640. }
  9641. // return value = "true";
  9642. }
  9643. }
  9644. }
  9645. }
  9646. }
  9647. },
  9648. controller: ['$scope', '$rootScope', 'api_configure_form', 'api_bpm_domain', function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  9649. $rootScope.checkClicked = function (item) {
  9650. angular.forEach($scope.to.options, function (itemone) {
  9651. if (!item.parent) {
  9652. if (item.id == itemone.id) {
  9653. // itemone.isExpanded = true;
  9654. } else {
  9655. itemone.isExpanded = false;
  9656. }
  9657. } else {
  9658. if (item.parent.id == itemone.id) {
  9659. angular.forEach(itemone.children, function (itemtwo) {
  9660. if (item.id == itemtwo.id) { } else {
  9661. itemtwo.isExpanded = false;
  9662. }
  9663. })
  9664. }
  9665. }
  9666. })
  9667. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  9668. console.log($scope,'gsm');
  9669. if ($scope.originalModel && $scope.originalModel.incident && item.category && (!item.children || !item.children.length) && item.priority && item.priority.id) {
  9670. api_bpm_domain.expectedTime('L' + (item.priority.id - 1559)).then(function (res) {
  9671. $scope.originalModel.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  9672. $scope.originalModel.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  9673. $scope.originalModel.incident.overdueTime = res.date;
  9674. })
  9675. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9676. // setTimeout(() => {
  9677. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9678. // }, 500);
  9679. // console.log($scope.$parent.$parent.$parent)
  9680. }
  9681. }
  9682. if ($scope.options.templateOptions.isMultiSelect) {
  9683. // console.log($scope);
  9684. } else {
  9685. if ($scope.model[$scope.options.key]) {
  9686. }
  9687. }
  9688. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  9689. // console.log(item)
  9690. // // if(){
  9691. // // }
  9692. // // $scope.model[$scope.options.key]=item.id;
  9693. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  9694. // $scope.propTypeOptions = data;
  9695. // });
  9696. // }
  9697. // $scope.model[$scope.options.key]=[];
  9698. // $scope.fn
  9699. $rootScope.bala1 = function (items, fn) {
  9700. // $scope.fn = fn;
  9701. console.log(items)
  9702. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  9703. $scope.options.templateOptions.refresh(items, 'search', fn)
  9704. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  9705. // // return res.list;
  9706. // console.log(666)
  9707. // fn(res.list)
  9708. // })
  9709. }
  9710. }]
  9711. });
  9712. //勾选组件
  9713. formlyConfigProvider.setType({
  9714. name: 'ui-checkbox',
  9715. extends: 'checkbox',
  9716. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  9717. controller: ['$scope', function ($scope) {
  9718. // 巡检生成事件,默认派单
  9719. if ($scope.model.isInspection) {
  9720. $scope.model[$scope.options.key] = true;
  9721. };
  9722. if ($scope.model[$scope.options.key] == "true") {
  9723. $scope.model[$scope.options.key] = true;
  9724. };
  9725. if ($scope.model[$scope.options.key] == "false") {
  9726. $scope.model[$scope.options.key] = false;
  9727. };
  9728. }]
  9729. });
  9730. //换行组件
  9731. formlyConfigProvider.setType({
  9732. name: 'ui-nextLine',
  9733. /*extends: 'input',*/
  9734. template: '<div></div>',
  9735. });
  9736. //多选框组件
  9737. formlyConfigProvider.setType({
  9738. name: 'ui-checklist',
  9739. extends: 'multiCheckbox',
  9740. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  9741. defaultOptions: function (options) {
  9742. return {
  9743. templateOptions: {
  9744. refresh: function () { },
  9745. refreshDelay: 0
  9746. }
  9747. };
  9748. }
  9749. });
  9750. //单选框组件
  9751. formlyConfigProvider.setType({
  9752. name: 'ui-radio',
  9753. extends: 'radio',
  9754. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  9755. defaultOptions: function (options) {
  9756. return {
  9757. templateOptions: {
  9758. refresh: function () { },
  9759. refreshDelay: 0
  9760. }
  9761. };
  9762. },
  9763. controller: ['$scope', function ($scope) {
  9764. // 巡检生成事件,默认派单
  9765. if ($scope.model.isInspection) {
  9766. $scope.model[$scope.options.key] = true;
  9767. // $scope.model.isHandlerUser=true;
  9768. $scope.model.start_code = "assignment";
  9769. console.log($scope.model);
  9770. };
  9771. //多次暂存配置
  9772. // console.log($scope);
  9773. if ($scope.model.saveAgain) {
  9774. if ($scope.model.directClose == "1" || $scope.model.directClose == true) {
  9775. $scope.model[$scope.options.key] = true;
  9776. // if($scope.model.incident.handlingPersonnelUser){
  9777. // delete $scope.model.incident.handlingPersonnelUser;
  9778. // };
  9779. if ($scope.model.incident.handleDescription) {
  9780. delete $scope.model.incident.handleDescription
  9781. };
  9782. if ($scope.model.incident.closecode) {
  9783. delete $scope.model.incident.closecode
  9784. };
  9785. if ($scope.model.incident.degree) {
  9786. delete $scope.model.incident.degree
  9787. }
  9788. } else {
  9789. $scope.model.incident.handlingPersonnelUser = $scope.model.incident.acceptUser;
  9790. $scope.model[$scope.options.key] = false
  9791. }
  9792. }
  9793. }]
  9794. });
  9795. //文本域组件
  9796. formlyConfigProvider.setWrapper({
  9797. name: 'validation',
  9798. types: ['ui-textarea'],
  9799. 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>"
  9800. });
  9801. formlyConfigProvider.setType({
  9802. name: 'ui-textarea',
  9803. extends: 'textarea',
  9804. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  9805. defaultOptions: function (options) {
  9806. return {
  9807. templateOptions: {
  9808. transform: function (model, value) {
  9809. return value;
  9810. },
  9811. },
  9812. validation: {
  9813. messages: {
  9814. maxlength: function (viewValue, modelValue, scope) {
  9815. if (viewValue != null) {
  9816. if (viewValue.length > scope.to.maxlength) {
  9817. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9818. } else {
  9819. return "";
  9820. }
  9821. }
  9822. },
  9823. }
  9824. }
  9825. }
  9826. },
  9827. controller: ['$scope', function ($scope) {
  9828. var value = $scope.model[$scope.options.key];
  9829. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9830. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9831. }
  9832. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9833. $scope.options.templateOptions.felditem($scope);
  9834. }
  9835. }]
  9836. });
  9837. // div版的textarea(展示富文本框内容用)
  9838. formlyConfigProvider.setType({
  9839. name: 'ui-divTextarea',
  9840. extends: 'textarea',
  9841. templateUrl: 'assets/views/customform/tpl/ui-divTextarea.html',
  9842. defaultOptions: function (options) {
  9843. return {
  9844. templateOptions: {
  9845. transform: function (model, value) {
  9846. return value;
  9847. },
  9848. },
  9849. validation: {
  9850. messages: {
  9851. // maxlength: function (viewValue, modelValue, scope) {
  9852. // if (viewValue != null) {
  9853. // if (viewValue.length > scope.to.maxlength) {
  9854. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9855. // } else {
  9856. // return "";
  9857. // }
  9858. // }
  9859. // },
  9860. }
  9861. }
  9862. }
  9863. },
  9864. controller: ['$scope', function ($scope) {
  9865. var value = $scope.model[$scope.options.key];
  9866. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9867. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9868. }
  9869. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9870. $scope.options.templateOptions.felditem($scope);
  9871. }
  9872. }]
  9873. });
  9874. // 带有知识库引用的textarea
  9875. formlyConfigProvider.setType({
  9876. name: 'ui-textAreaKnowledge',
  9877. // extends: 'textarea',
  9878. templateUrl: 'assets/views/customform/tpl/ui-textAreaKnowledge.html',
  9879. defaultOptions: function (options) {
  9880. return {
  9881. templateOptions: {
  9882. transform: function (model, value) {
  9883. return value;
  9884. },
  9885. },
  9886. validation: {
  9887. messages: {
  9888. maxlength: function (viewValue, modelValue, scope) {
  9889. if (viewValue != null) {
  9890. if (viewValue.length > scope.to.maxlength) {
  9891. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9892. } else {
  9893. return "";
  9894. }
  9895. }
  9896. },
  9897. }
  9898. }
  9899. }
  9900. },
  9901. 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) {
  9902. // console.log($scope);
  9903. var value = $scope.model[$scope.options.key];
  9904. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9905. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9906. }
  9907. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9908. $scope.options.templateOptions.felditem($scope);
  9909. }
  9910. // 引用知识库点击
  9911. $scope.openSolution = function () {
  9912. $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9913. setTimeout(() => {
  9914. $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9915. }, 100);
  9916. }
  9917. }]
  9918. });
  9919. //常用语句选择textarea
  9920. formlyConfigProvider.setType({
  9921. name: 'ui-textselect',
  9922. extends: 'textarea',
  9923. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  9924. defaultOptions: function (options) {
  9925. return {
  9926. templateOptions: {
  9927. transform: function (model, value) {
  9928. return value;
  9929. },
  9930. },
  9931. validation: {
  9932. messages: {
  9933. maxlength: function (viewValue, modelValue, scope) {
  9934. if (viewValue != null) {
  9935. if (viewValue.length > scope.to.maxlength) {
  9936. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9937. } else {
  9938. return "";
  9939. }
  9940. }
  9941. },
  9942. }
  9943. }
  9944. }
  9945. },
  9946. controller: ['$scope', function ($scope) {
  9947. var value = $scope.model[$scope.options.key];
  9948. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9949. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9950. }
  9951. }]
  9952. });
  9953. //改动的组件 ckeditor封装后的组件
  9954. formlyConfigProvider.setType({
  9955. name: 'ui-text-check',
  9956. extends: 'textarea',
  9957. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  9958. defaultOptions: function (options) {
  9959. return {
  9960. templateOptions: {
  9961. extraPlugins: 'uploadimage',
  9962. uploadimageConfig: {
  9963. backend: 'basic',
  9964. settings: {
  9965. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  9966. headers: '',
  9967. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  9968. }
  9969. },
  9970. refresh: function (APIService, contentId, data) {
  9971. return APIService.fetchDataList(contentId, data);
  9972. },
  9973. downloadUri: function (APIService, contentId) {
  9974. return APIService.downloadAttachment(contentId).getRequestedUrl();
  9975. },
  9976. upload: function (APIService, contentId) {
  9977. return APIService.getSolutionDowpath(contentId);
  9978. },
  9979. view: function (attachmentId) {
  9980. // return APIService.attachmentsPreviewUrl(contentId);
  9981. },
  9982. refreshDelay: 0,
  9983. transform: function (model, value) {
  9984. return value;
  9985. },
  9986. },
  9987. validation: {
  9988. messages: {
  9989. maxlength: function (viewValue, modelValue, scope) {
  9990. if (viewValue != null) {
  9991. if (viewValue.length > scope.to.maxlength) {
  9992. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9993. } else {
  9994. return "";
  9995. }
  9996. }
  9997. },
  9998. }
  9999. }
  10000. }
  10001. },
  10002. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10003. var value = $scope.model[$scope.options.key];
  10004. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10005. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10006. }
  10007. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10008. //var expiry={'expiry':14804244006};
  10009. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10010. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10011. $scope.upload = function (contentId, filename) {
  10012. var filename = filename;
  10013. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  10014. var file = new Blob([response], {
  10015. type: 'application/octet-stream'
  10016. });
  10017. // var filename = filename;
  10018. var fileURL = URL.createObjectURL(file);
  10019. var a = document.createElement('a');
  10020. a.href = fileURL;
  10021. a.target = '_blank';
  10022. a.download = filename;
  10023. document.body.appendChild(a);
  10024. a.click();
  10025. })
  10026. };
  10027. }]
  10028. });
  10029. //改动的组件 ckeditor封装后的附文本组件
  10030. formlyConfigProvider.setType({
  10031. name: 'ui-fuwenben',
  10032. extends: 'textarea',
  10033. templateUrl: 'assets/views/customform/tpl/ui-fuwenben.html',
  10034. defaultOptions: function (options) {
  10035. return {
  10036. templateOptions: {
  10037. allowedContent: 'img[!src]',//允许展示源码的标签,否则会被富文本框强制删除
  10038. extraPlugins: 'uploadimage',
  10039. uploadimageConfig: {
  10040. backend: 'basic',
  10041. settings: {
  10042. uploadUrl: options.templateOptions.APIService.upload(-110).getRequestedUrl(),
  10043. headers: '',
  10044. downloadUrl: options.templateOptions.APIService.uploadResponseUri()
  10045. }
  10046. },
  10047. refresh: function (APIService, contentId, data) {
  10048. return APIService.fetchDataList(-110, data);
  10049. },
  10050. downloadUri: function (APIService, contentId) {
  10051. return APIService.downloadAttachment(-110).getRequestedUrl();
  10052. },
  10053. upload: function (APIService, contentId) {
  10054. return APIService.getSolutionDowpath(-110);
  10055. },
  10056. view: function (attachmentId) {
  10057. // return APIService.attachmentsPreviewUrl(contentId);
  10058. },
  10059. refreshDelay: 0,
  10060. transform: function (model, value) {
  10061. return value;
  10062. },
  10063. },
  10064. validation: {
  10065. messages: {
  10066. maxlength: function (viewValue, modelValue, scope) {
  10067. if (viewValue != null) {
  10068. if (viewValue.length > scope.to.maxlength) {
  10069. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  10070. } else {
  10071. return "";
  10072. }
  10073. }
  10074. },
  10075. }
  10076. }
  10077. }
  10078. },
  10079. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10080. var value = $scope.model[$scope.options.key];
  10081. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10082. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10083. }
  10084. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10085. //var expiry={'expiry':14804244006};
  10086. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10087. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10088. $scope.upload = function (contentId, filename) {
  10089. var filename = filename;
  10090. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, -110).then(function (response) {
  10091. var file = new Blob([response], {
  10092. type: 'application/octet-stream'
  10093. });
  10094. // var filename = filename;
  10095. var fileURL = URL.createObjectURL(file);
  10096. var a = document.createElement('a');
  10097. a.href = fileURL;
  10098. a.target = '_blank';
  10099. a.download = filename;
  10100. document.body.appendChild(a);
  10101. a.click();
  10102. })
  10103. };
  10104. }]
  10105. });
  10106. //ui-grid展示控件
  10107. formlyConfigProvider.setType({
  10108. name: 'ui-grid-show',
  10109. extends: 'multiCheckbox',
  10110. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  10111. defaultOptions: function (options) {
  10112. return {
  10113. templateOptions: {
  10114. linkage: function () {
  10115. },
  10116. },
  10117. };
  10118. },
  10119. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  10120. var loginUser = $rootScope.user;
  10121. $scope.langs = i18nService.getAllLangs();
  10122. $scope.lang = 'zh-cn';
  10123. i18nService.setCurrentLang($scope.lang);
  10124. $scope.gridOptions = {};
  10125. $scope.gridOptions.data = 'myData';
  10126. $scope.gridOptions.enableColumnResizing = true;
  10127. // $scope.gridOptions.enableFiltering = true;
  10128. $scope.gridOptions.enableGridMenu = false;
  10129. $scope.gridOptions.enableRowSelection = true;
  10130. $scope.gridOptions.showGridFooter = true;
  10131. $scope.gridOptions.showColumnFooter = false;
  10132. $scope.gridOptions.fastWatch = true;
  10133. $scope.gridOptions.useExternalFiltering = true;
  10134. $scope.gridOptions.useExternalPagination = true;
  10135. $scope.gridOptions.paginationPageSizes = [10];
  10136. $scope.gridOptions.paginationPageSize = 10;
  10137. $scope.gridOptions.multiSelect = true;
  10138. $scope.gridOptions.rowIdentity = function (row) {
  10139. return row.id;
  10140. };
  10141. $scope.gridOptions.getRowIdentity = function (row) {
  10142. return row.id;
  10143. };
  10144. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10145. $scope.gridOptions.columnDefs = [
  10146. // { name:'id', width:80, enableFiltering:false},
  10147. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  10148. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  10149. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  10150. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  10151. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  10152. {
  10153. name: 'inspection.title',
  10154. displayName: '计划主题',
  10155. width: 120,
  10156. enableFiltering: false
  10157. },
  10158. {
  10159. name: 'stateName',
  10160. displayName: '状态',
  10161. width: 80,
  10162. enableFiltering: false
  10163. },
  10164. {
  10165. name: 'processUser.name',
  10166. displayName: '处理人',
  10167. width: 80,
  10168. enableFiltering: false
  10169. },
  10170. {
  10171. name: 'startDate',
  10172. displayName: '开始时间',
  10173. width: 160,
  10174. enableFiltering: false
  10175. },
  10176. {
  10177. name: 'overdueTime',
  10178. displayName: '逾期时间',
  10179. width: 160,
  10180. enableFiltering: false
  10181. },
  10182. ];
  10183. var defaultFilterData = {
  10184. "idx": 0,
  10185. "sum": 10
  10186. };
  10187. //分页控制
  10188. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10189. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10190. var filtersData = $scope.memoryfilterData;
  10191. filtersData.idx = newPage - 1;
  10192. filtersData.sum = pageSize;
  10193. $scope.refreshData('expand-right', filtersData);
  10194. });
  10195. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10196. data.grid.appScope.selected.items = data.entity
  10197. });
  10198. };
  10199. //页面获取数据
  10200. $scope.refreshData = function (style, filterData) {
  10201. // $scope.ldloading[style.replace('-', '_')] = true;
  10202. if (angular.isUndefined(filterData)) {
  10203. filterData = defaultFilterData;
  10204. }
  10205. $scope.myData = [];
  10206. angular.extend(filterData, {
  10207. inspectionProcessActual: {
  10208. "inspectionid": $scope.model.id
  10209. }
  10210. })
  10211. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
  10212. var myData = Restangular.stripRestangular(data);
  10213. $scope.gridOptions.totalItems = myData.totalNum;
  10214. $scope.myData = myData.list;
  10215. for (var i = 0; i < $scope.myData.length; i++) {
  10216. //添加序号
  10217. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  10218. }
  10219. // $scope.ldloading[style.replace('-', '_')] = false;
  10220. }, function () {
  10221. // $scope.ldloading[style.replace('-', '_')] = false;
  10222. });
  10223. };
  10224. $scope.refreshData('expand-right', defaultFilterData);
  10225. }
  10226. });
  10227. //文本框自定义选择面板组件
  10228. formlyConfigProvider.setType({
  10229. name: 'ui-input-selectmodal',
  10230. extends: 'input',
  10231. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  10232. defaultOptions: function (options) {
  10233. return {
  10234. templateOptions: {
  10235. openModal: function (size, options, modal) {
  10236. var modalInstance = modal.open({
  10237. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  10238. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  10239. size: size,
  10240. resolve: options.templateOptions.modalParam
  10241. });
  10242. modalInstance.result.then(function (selectedItem) {
  10243. options.value(selectedItem);
  10244. }, function () {
  10245. //console.log('Modal dismissed at: ' + new Date());
  10246. });
  10247. }
  10248. }
  10249. };
  10250. }
  10251. });
  10252. //日期控件
  10253. var datepicker_attr = [
  10254. 'date-disabled',
  10255. 'custom-class',
  10256. 'show-weeks',
  10257. 'starting-day',
  10258. 'init-date',
  10259. 'min-mode',
  10260. 'max-mode',
  10261. 'format-day',
  10262. 'format-month',
  10263. 'format-year',
  10264. 'format-day-header',
  10265. 'format-day-title',
  10266. 'format-month-title',
  10267. 'year-range',
  10268. 'shortcut-propagation',
  10269. 'datepicker-popup',
  10270. 'show-button-bar',
  10271. 'current-text',
  10272. 'clear-text',
  10273. 'close-text',
  10274. 'close-on-date-selection',
  10275. 'datepicker-append-to-body'
  10276. ];
  10277. var datepicker_bindings = [
  10278. 'datepicker-mode',
  10279. 'min-date',
  10280. 'max-date'
  10281. ];
  10282. formlyConfigProvider.setType({
  10283. name: 'ui-datetime',
  10284. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  10285. extends: 'input',
  10286. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10287. defaultOptions: {
  10288. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10289. templateOptions: {
  10290. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10291. }
  10292. },
  10293. controller: ['$scope', '$filter', function ($scope, $filter) {
  10294. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10295. $scope.options.initialValue = $scope.model[$scope.options.key];
  10296. }]
  10297. });
  10298. //日期控件
  10299. formlyConfigProvider.setType({
  10300. name: 'ui-datepicker',
  10301. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  10302. extends: 'input',
  10303. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10304. defaultOptions: {
  10305. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10306. templateOptions: {
  10307. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10308. }
  10309. },
  10310. controller: ['$scope', '$filter', function ($scope, $filter) {
  10311. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  10312. if ($scope.model[$scope.options.key]) {
  10313. } else {
  10314. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10315. }
  10316. $scope.options.initialValue = $scope.model[$scope.options.key];
  10317. $scope.endOpen = true;
  10318. $scope.datepicker = {};
  10319. $scope.datepicker.opened = false;
  10320. $scope.datepicker.open = function ($event) {
  10321. $scope.datepicker.opened = true;
  10322. };
  10323. }]
  10324. });
  10325. //时分控件
  10326. formlyConfigProvider.setType({
  10327. name: 'ui-datehourtime',
  10328. extends: 'input',
  10329. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  10330. defaultOptions: function (options) {
  10331. return {
  10332. noFormControl: true,
  10333. // validators:{
  10334. // required:{
  10335. // expression:function(viewValue, modelValue){
  10336. // console.log(options)
  10337. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  10338. // // var value = modelValue.getHours() || viewValue.getHours();
  10339. // return value.length>=1;
  10340. // }
  10341. // }
  10342. // }
  10343. }
  10344. },
  10345. controller: ['$scope', '$log', function ($scope, $log) {
  10346. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  10347. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  10348. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  10349. }]
  10350. });
  10351. //状态追踪
  10352. formlyConfigProvider.setType({
  10353. name: 'ui-followStatus',
  10354. templateUrl: 'assets/views/customform/tpl/ui-followStatus.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. if (dataId) {
  10360. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10361. if (response) {
  10362. var myData = Restangular.stripRestangular(response);
  10363. var processInstanceId = myData.data.processInstanceId;
  10364. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10365. if (result.status == 200) {
  10366. var newData = Restangular.stripRestangular(result);
  10367. $scope.followData = newData.data;
  10368. }
  10369. });
  10370. }
  10371. })
  10372. }
  10373. }, 10);
  10374. }]
  10375. });
  10376. //历史记录
  10377. formlyConfigProvider.setType({
  10378. name: 'ui-history',
  10379. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  10380. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10381. setTimeout(function () {
  10382. var pkey = $scope.options.templateOptions.pkey;
  10383. var dataId = $scope.model.id;
  10384. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10385. if (response) {
  10386. var myData = Restangular.stripRestangular(response);
  10387. var processInstanceId = myData.data.processInstanceId;
  10388. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10389. if (result.status == 200) {
  10390. var newData = Restangular.stripRestangular(result);
  10391. var long = newData.data.length - 1;
  10392. $scope.followData = newData.data[long];
  10393. }
  10394. });
  10395. }
  10396. })
  10397. }, 10);
  10398. }]
  10399. });
  10400. // //请求人信息显示
  10401. // formlyConfigProvider.setType({
  10402. // name: "ui-disrequester",
  10403. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  10404. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10405. // defaultOptions: function(options) {
  10406. // return {
  10407. // templateOptions: {}
  10408. // };
  10409. // },
  10410. // controller: ['$scope', function($scope) {
  10411. // $scope.options.templateOptions.that = $scope;
  10412. // }]
  10413. // });
  10414. //退回人信息显示
  10415. formlyConfigProvider.setType({
  10416. name: "ui-returnperson",
  10417. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  10418. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10419. defaultOptions: function (options) {
  10420. return {
  10421. templateOptions: {}
  10422. };
  10423. },
  10424. controller: ['$scope', function ($scope) {
  10425. $scope.group = "";
  10426. $scope.role = "";
  10427. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10428. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10429. } else {
  10430. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10431. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10432. }
  10433. }
  10434. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10435. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10436. } else {
  10437. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10438. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10439. }
  10440. }
  10441. $scope.options.templateOptions.that = $scope;
  10442. $scope.options.templateOptions.that = $scope;
  10443. }]
  10444. });
  10445. //退回人信息显示(去掉工作组&角色)
  10446. formlyConfigProvider.setType({
  10447. name: "ui-returnpersonNoGroup",
  10448. templateUrl: 'assets/views/customform/tpl/ui-returnpersonNoGroup.html',
  10449. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10450. defaultOptions: function (options) {
  10451. return {
  10452. templateOptions: {}
  10453. };
  10454. },
  10455. controller: ['$scope', function ($scope) {
  10456. $scope.group = "";
  10457. $scope.role = "";
  10458. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10459. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10460. } else {
  10461. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10462. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10463. }
  10464. }
  10465. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10466. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10467. } else {
  10468. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10469. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10470. }
  10471. }
  10472. $scope.options.templateOptions.that = $scope;
  10473. $scope.options.templateOptions.that = $scope;
  10474. }]
  10475. });
  10476. //指派技术人员
  10477. formlyConfigProvider.setType({
  10478. name: "ui-apiontperson",
  10479. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  10480. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10481. defaultOptions: function (options) {
  10482. return {
  10483. templateOptions: {
  10484. transtlara: function (value, $scope) { }
  10485. }
  10486. };
  10487. },
  10488. controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
  10489. var filterData = {
  10490. "idx": 0,
  10491. "sum": 1000
  10492. }
  10493. api_user_data.fetchDataList('group', filterData).then(function (response) {
  10494. if (response.status == 200) {
  10495. $scope.select = {};
  10496. $scope.multipleDemo = {};
  10497. $scope.userdata = {};
  10498. var data = response.list;
  10499. var item = [];
  10500. $scope.multipleDemo = data;
  10501. $scope.multipleDemo;
  10502. }
  10503. })
  10504. $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
  10505. if (groupdata.option) {
  10506. $scope.model[$scope.options.key] = {};
  10507. var fildate = {
  10508. "idx": 0,
  10509. "sum": 1000,
  10510. "user": {
  10511. "roledata": {
  10512. "rolecode": model.currentRole
  10513. },
  10514. "selectType": "1",
  10515. "groupdata": {
  10516. "id": groupdata.option.id
  10517. }
  10518. }
  10519. }
  10520. api_user_data.fetchDataList('user', fildate).then(function (response) {
  10521. if (response.status == 200) {
  10522. $scope.userdata = {};
  10523. $scope.userdata = response.list;
  10524. }
  10525. })
  10526. } else {
  10527. $scope.model[$scope.options.key] = {
  10528. id: groupdata.id.id
  10529. }
  10530. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  10531. }
  10532. }
  10533. // }
  10534. }]
  10535. });
  10536. //请求科室信息(小蓝框) lmm
  10537. formlyConfigProvider.setType({
  10538. name: 'ui-deptinformation',
  10539. templateUrl: 'assets/views/customform/tpl/ui-deptinformation.html',
  10540. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10541. return {
  10542. templateOptions: {
  10543. checkform: function (options) {
  10544. }
  10545. }
  10546. };
  10547. },
  10548. controller: ['$scope', 'api_statistic', function ($scope, api_statistic) {
  10549. // console.log($scope)
  10550. }]
  10551. });
  10552. //请求人信息
  10553. formlyConfigProvider.setType({
  10554. name: 'ui-requesterinformation',
  10555. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  10556. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10557. return {
  10558. templateOptions: {
  10559. checkform: function (options) {
  10560. if (options.model.requester) {
  10561. options.value(options.model.requester);
  10562. }
  10563. },
  10564. addRequeter: function (size, options, modal) {
  10565. event.preventDefault();
  10566. var modalInstance = modal.open({
  10567. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  10568. controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
  10569. $scope.title = "新增报修人";
  10570. $scope.requester = {};
  10571. $scope.searchData = {};
  10572. $scope.onChangeadd = function (searchData) {
  10573. $scope.searchKey = searchData.account;
  10574. // $scope.searchDataadd = searchData;
  10575. var requesdata = angular.copy(searchData)
  10576. if (requesdata.mphone) {
  10577. delete requesdata.mphone;
  10578. }
  10579. $scope.requester = requesdata;
  10580. console.log($scope.requester)
  10581. }
  10582. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10583. $scope.requester.account = searchKey;
  10584. $scope.searchData = searchKey;
  10585. serchdataadd(searchKey);
  10586. }
  10587. $scope.getMydata = function (x) {
  10588. $scope.searchField = JSON.parse(x[0]).account;
  10589. $scope.requester = JSON.parse(x[0]);
  10590. console.log($scope.requester)
  10591. }
  10592. $scope.getMydataone = function (x) {
  10593. $scope.searchField = x;
  10594. $scope.requester.account = x;
  10595. }
  10596. serchdataadd();
  10597. api_wechatfile.getDictionary({
  10598. "type": "list",
  10599. "key": "male"
  10600. }).then(function (data) {
  10601. if (data.status == 200) {
  10602. requester.gender = data.list;
  10603. }
  10604. })
  10605. function serchdataadd(searchKey) {
  10606. if (searchKey) {
  10607. var filterData = {
  10608. 'requester': {
  10609. 'searchKey': searchKey,
  10610. },
  10611. idx: 0,
  10612. sum: 10
  10613. };
  10614. } else {
  10615. var filterData = {
  10616. idx: 0,
  10617. sum: 10
  10618. };
  10619. }
  10620. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10621. var myData = response;
  10622. $scope.myData = myData.list;
  10623. });
  10624. }
  10625. api_user_data.fetchDataList('area', {
  10626. idx: 0,
  10627. sum: 1000
  10628. }).then(function (response) {
  10629. if (response.status == 200) {
  10630. $scope.areas = response.list;
  10631. }
  10632. })
  10633. api_wechatfile.getDictionary({
  10634. key: "requester_type",
  10635. type: "list"
  10636. }, {
  10637. idx: 0,
  10638. sum: 100
  10639. }).then(function (response) {
  10640. if (response) {
  10641. $scope.networktypes = response;
  10642. }
  10643. })
  10644. $scope.requesterAreaid = "";
  10645. $scope.onChange = function (item) {
  10646. $scope.requesterAreaid = item.id;
  10647. api_user_data.fetchDataList('place', {
  10648. place: {
  10649. area: {
  10650. id: item.id
  10651. }
  10652. },
  10653. idx: 0,
  10654. sum: 1000
  10655. }).then(function (response) {
  10656. if (response.status == 200) {
  10657. $scope.places = response.list;
  10658. delete $scope.requester.placeDTO;
  10659. }
  10660. })
  10661. }
  10662. $scope.refresh = function (searchVal) {
  10663. var faildata = {};
  10664. if ($scope.requesterAreaid) {
  10665. faildata = {
  10666. 'idx': 0,
  10667. 'sum': 1000,
  10668. 'place': {
  10669. 'areaId': $scope.requesterAreaid,
  10670. 'place': searchVal,
  10671. 'selectType': 'pinyin_qs'
  10672. }
  10673. }
  10674. } else {
  10675. faildata = {
  10676. 'idx': 0,
  10677. 'sum': 1000,
  10678. 'place': {
  10679. 'place': searchVal,
  10680. 'selectType': 'pinyin_qs'
  10681. }
  10682. }
  10683. }
  10684. api_user_data.fetchDataList('place', faildata).then(function (response) {
  10685. $scope.places = response.list;
  10686. delete $scope.requester.placeDTO;
  10687. })
  10688. }
  10689. $scope.refreshDepts = function (key) {
  10690. var filterData = {
  10691. 'idx': 0,
  10692. 'sum': 5,
  10693. 'dept': {
  10694. 'name': key
  10695. }
  10696. };
  10697. UserService.fetchDataList('department', filterData).then(function (response) {
  10698. if (response.status == 200) {
  10699. $scope.depts = response.list;
  10700. }
  10701. })
  10702. }
  10703. $scope.ok = function () {
  10704. if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  10705. SweetAlert.swal("报修人员编号未填!", "请填写报修人员编号", "error");
  10706. } else if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  10707. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  10708. } else if (angular.isUndefined($scope.requester.requesterType) || $scope.requester.requesterType == null || $scope.requester.requesterTypeDTO == "") {
  10709. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  10710. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  10711. SweetAlert.swal("报修人联系电话未填!", "请填写报修人联系电话", "error");
  10712. } else {
  10713. $scope.requesterId = $scope.requester.id;
  10714. var data = {
  10715. incident: {
  10716. requester: {
  10717. id: $scope.requesterId
  10718. }
  10719. },
  10720. idx: 0,
  10721. sum: 3
  10722. };
  10723. api_statistic.tableData(data, 'incident').then(function (data) {
  10724. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  10725. })
  10726. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  10727. if (newObj != oldObj) {
  10728. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  10729. }
  10730. })//lmm
  10731. console.log($scope.requester)
  10732. $modalInstance.close($scope.requester);
  10733. }
  10734. };
  10735. $scope.cancel = function () {
  10736. $modalInstance.dismiss('cancel');
  10737. };
  10738. },
  10739. resolve: {
  10740. items: function () {
  10741. return {
  10742. fetchItems: function (filterData, APIService) {
  10743. filterData = filterData || {};
  10744. if (!filterData.idx) {
  10745. filterData = {
  10746. idx: 0,
  10747. sum: 10
  10748. };
  10749. }
  10750. return options.templateOptions.fetchItems(filterData, APIService);
  10751. }
  10752. };
  10753. },
  10754. title: function () {
  10755. return options.templateOptions.modalTitle;
  10756. },
  10757. Restangular: function () {
  10758. return options.templateOptions.Restangular;
  10759. },
  10760. APIService: function () {
  10761. return options.templateOptions.ApiService;
  10762. },
  10763. UserService: function () {
  10764. return options.templateOptions.UserService;
  10765. },
  10766. sco: function () {
  10767. return $scope;
  10768. }
  10769. }
  10770. });
  10771. modalInstance.result.then(function (selectedItem) {
  10772. console.log(selectedItem)
  10773. if (selectedItem) {
  10774. var data = {
  10775. 'requester': selectedItem
  10776. };
  10777. $scope.searchKey = selectedItem.account;
  10778. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  10779. // if (selectedItem.place && selectedItem.place.place) {
  10780. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  10781. // }
  10782. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  10783. if (response.status == 200) {
  10784. if (options.model) {
  10785. options.model.requester = response.data
  10786. $scope.$parent.$parent.$parent.model.incident.requester = response.data;
  10787. $scope.$parent.$parent.$parent.model.requestershow = response.data;
  10788. if (options.model.place) {
  10789. options.model.place.id = '';
  10790. }
  10791. if (options.model.area) {
  10792. options.model.area.id = '';
  10793. }
  10794. options.model.contacts = selectedItem.name;
  10795. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  10796. options.model.contactsInformation = selectedItem.mphone;
  10797. } else {
  10798. options.model.contactsInformation = selectedItem.telephone;
  10799. }
  10800. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  10801. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10802. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  10803. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  10804. }
  10805. }
  10806. if (!response.data.id) {
  10807. response.data.id = selectedItem.id
  10808. }
  10809. options.value(response.data);
  10810. options.value(response.data);
  10811. console.log($scope,'0000000');
  10812. //新增报修人带入区域地点2020年4月23日19:48:15
  10813. $scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10814. $scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10815. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  10816. if (selectedItem.place && selectedItem.place.id) {
  10817. options.model.place.id = selectedItem.place.id
  10818. options.model.place.area.id = selectedItem.place.area.id
  10819. };
  10820. } else {
  10821. if (selectedItem.place && selectedItem.place.id) {
  10822. options.model.place.id = selectedItem.place.id
  10823. options.model.area.id = selectedItem.place.area.id
  10824. };
  10825. }
  10826. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  10827. // options.model.area.id = selectedItem.place.area.id
  10828. // }
  10829. if (selectedItem.houseNumber) {
  10830. options.model.houseNumber = selectedItem.houseNumber
  10831. }
  10832. // if (selectedItem.id) {
  10833. options.model.account = selectedItem.account;
  10834. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  10835. var baoxiuFields = $scope.$parent.$parent.$parent.$parent.$parent.vm.fields[1].fields;
  10836. var baoxiurenTo;
  10837. baoxiuFields.forEach((e, i) => {
  10838. if (e.key == 'account') {
  10839. baoxiurenTo = e.templateOptions
  10840. baoxiurenTo.APIService.fetchDataList('requester', {
  10841. "idx": 0,
  10842. "sum": 20,
  10843. requester: {
  10844. searchKey: selectedItem.account
  10845. }
  10846. }).then(res => {
  10847. baoxiurenTo.options = res.list;
  10848. options.model.account = selectedItem.account;
  10849. })
  10850. }
  10851. })
  10852. // }
  10853. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  10854. // 选择重复事件侧滑框
  10855. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  10856. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  10857. setTimeout(() => {
  10858. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  10859. }, 500);
  10860. // }
  10861. }
  10862. })
  10863. }
  10864. }, function () { });
  10865. },
  10866. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  10867. var modalInstance = modal.open({
  10868. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  10869. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  10870. $scope.title = "修改报修人";
  10871. $scope.requester = {
  10872. id: modeldata.requester.id,
  10873. account: modeldata.requester.account,
  10874. name: modeldata.requester.name,
  10875. gender: modeldata.requester.gender,
  10876. email: modeldata.requester.email,
  10877. deptName: modeldata.requester.deptName,
  10878. mphone: modeldata.requester.mphone,
  10879. telephone: modeldata.requester.telephone,
  10880. studentNo: modeldata.requester.studentNo,
  10881. areaDTO: modeldata.requester.areaDTO,
  10882. placeDTO: modeldata.requester.placeDTO,
  10883. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  10884. };
  10885. $scope.onChangeadd = function (searchData) {
  10886. console.log(searchData)
  10887. $scope.searchKey = searchData.account;
  10888. var requesdata = angular.copy(searchData)
  10889. if (requesdata.mphone) {
  10890. delete requesdata.mphone;
  10891. }
  10892. $scope.requester = requesdata;
  10893. }
  10894. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10895. $scope.requester.account = searchKey;
  10896. $scope.searchData = searchKey;
  10897. serchdataadd(searchKey);
  10898. }
  10899. $scope.getMydata = function (x) {
  10900. $scope.searchField = JSON.parse(x[0]).account;
  10901. $scope.requester = JSON.parse(x[0]);
  10902. }
  10903. $scope.getMydataone = function (x) {
  10904. $scope.searchField = x;
  10905. $scope.requester.account = x;
  10906. }
  10907. serchdataadd();
  10908. function serchdataadd(searchKey) {
  10909. if (searchKey) {
  10910. var filterData = {
  10911. 'requester': {
  10912. 'searchKey': searchKey,
  10913. },
  10914. idx: 0,
  10915. sum: 10
  10916. };
  10917. } else {
  10918. var filterData = {
  10919. idx: 0,
  10920. sum: 10
  10921. };
  10922. }
  10923. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10924. var myData = response;
  10925. $scope.myData = myData.list;
  10926. });
  10927. }
  10928. api_user_data.fetchDataList('area', {
  10929. idx: 0,
  10930. sum: 1000
  10931. }).then(function (response) {
  10932. if (response.status == 200) {
  10933. $scope.areas = response.list;
  10934. }
  10935. })
  10936. api_user_data.fetchDataList('requesterType', {
  10937. idx: 0,
  10938. sum: 100
  10939. }).then(function (response) {
  10940. if (response.status == 200) {
  10941. $scope.networktypes = response.list;
  10942. }
  10943. })
  10944. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  10945. api_user_data.fetchDataList('place', {
  10946. place: {
  10947. areaId: $scope.requester.areaDTO.id
  10948. },
  10949. idx: 0,
  10950. sum: 1000
  10951. }).then(function (response) {
  10952. if (response.status == 200) {
  10953. $scope.places = response.list;
  10954. }
  10955. })
  10956. }
  10957. $scope.onChange = function (item) {
  10958. $scope.requester.placeDTO = {};
  10959. api_user_data.fetchDataList('place', {
  10960. place: {
  10961. areaId: item.id
  10962. },
  10963. idx: 0,
  10964. sum: 1000
  10965. }).then(function (response) {
  10966. if (response.status == 200) {
  10967. $scope.places = response.list;
  10968. }
  10969. })
  10970. }
  10971. $scope.refreshDepts = function (key) {
  10972. var filterData = {
  10973. 'idx': 0,
  10974. 'sum': 5,
  10975. 'dept': {
  10976. 'name': key
  10977. }
  10978. };
  10979. UserService.fetchDataList('department', filterData).then(function (response) {
  10980. if (response.status == 200) {
  10981. $scope.depts = response.list;
  10982. }
  10983. })
  10984. }
  10985. $scope.ok = function () {
  10986. if ($scope.requester.account == "" || $scope.requester.name == "") {
  10987. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  10988. } else {
  10989. $modalInstance.close($scope.requester);
  10990. }
  10991. };
  10992. $scope.cancel = function () {
  10993. $modalInstance.dismiss('cancel');
  10994. };
  10995. },
  10996. resolve: {
  10997. items: function () {
  10998. return {
  10999. fetchItems: function (filterData, APIService) {
  11000. filterData = filterData || {};
  11001. if (!filterData.idx) {
  11002. filterData = {
  11003. idx: 0,
  11004. sum: 10
  11005. };
  11006. }
  11007. return options.templateOptions.fetchItems(filterData, APIService);
  11008. }
  11009. };
  11010. },
  11011. title: function () {
  11012. return options.templateOptions.modalTitle;
  11013. },
  11014. Restangular: function () {
  11015. return options.templateOptions.Restangular;
  11016. },
  11017. APIService: function () {
  11018. return options.templateOptions.ApiService;
  11019. },
  11020. UserService: function () {
  11021. return options.templateOptions.UserService;
  11022. }
  11023. }
  11024. });
  11025. modalInstance.result.then(function (selectedItem) {
  11026. console.log(selectedItem)
  11027. if (selectedItem) {
  11028. if (options.model) {
  11029. if (options.model.place) {
  11030. options.model.place.id = '';
  11031. }
  11032. if (options.model.area) {
  11033. options.model.area.id = '';
  11034. }
  11035. options.model.contacts = selectedItem.name;
  11036. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11037. options.model.contactsInformation = selectedItem.mphone;
  11038. } else {
  11039. options.model.contactsInformation = selectedItem.telephone;
  11040. }
  11041. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11042. options.model.place.id = selectedItem.placeDTO.id
  11043. }
  11044. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11045. options.model.area.id = selectedItem.areaDTO.id
  11046. }
  11047. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11048. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11049. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11050. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11051. }
  11052. }
  11053. var data = {
  11054. 'requester': selectedItem
  11055. };
  11056. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  11057. if (response.status == 200) {
  11058. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  11059. options.value(response.data);
  11060. } else { }
  11061. })
  11062. }
  11063. }, function () { });
  11064. event.preventDefault();
  11065. }
  11066. }
  11067. };
  11068. },
  11069. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  11070. $scope.options.initialValue = $scope.model[$scope.options.key];
  11071. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  11072. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11073. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11074. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11075. }
  11076. }]
  11077. });
  11078. // 请求人选控件
  11079. formlyConfigProvider.setType({
  11080. name: "ui-requesterselect",
  11081. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  11082. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11083. defaultOptions: function (options, $scope) {
  11084. return {
  11085. templateOptions: {
  11086. // checkform: function(options) {
  11087. // if (options.model.requestershow) {
  11088. // options.value(options.model.requestershow);
  11089. // }
  11090. // },
  11091. validators: {
  11092. required: {
  11093. expression: function (viewValue, modelValue) {
  11094. var value = modelValue || viewValue;
  11095. return value.length >= 1;
  11096. }
  11097. }
  11098. },
  11099. openModal: function (size, options, modal) { //查找弹出框
  11100. var modelObject = options.value();
  11101. var searchModal = function (filterSearchData) {
  11102. var modalInstance = modal.open({
  11103. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11104. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  11105. $scope.langs = i18nService.getAllLangs();
  11106. $scope.lang = 'zh-cn';
  11107. i18nService.setCurrentLang($scope.lang);
  11108. $scope.gridOptions = {};
  11109. $scope.gridOptions.data = 'myData';
  11110. $scope.gridOptions.enableColumnResizing = true;
  11111. $scope.gridOptions.enableFiltering = true;
  11112. $scope.gridOptions.enableGridMenu = false;
  11113. $scope.gridOptions.enableRowSelection = true;
  11114. $scope.gridOptions.showGridFooter = true;
  11115. $scope.gridOptions.showColumnFooter = false;
  11116. $scope.gridOptions.fastWatch = true;
  11117. $scope.gridOptions.useExternalFiltering = true;
  11118. $scope.gridOptions.useExternalPagination = true;
  11119. $scope.gridOptions.paginationPageSizes = [10];
  11120. $scope.gridOptions.paginationPageSize = 10;
  11121. $scope.gridOptions.multiSelect = false;
  11122. $scope.gridOptions.rowIdentity = function (row) {
  11123. return row.id;
  11124. };
  11125. $scope.gridOptions.getRowIdentity = function (row) {
  11126. return row.id;
  11127. };
  11128. $scope.gridOptions.columnDefs = [{
  11129. name: 'account',
  11130. displayName: '人员编号',
  11131. width: 140
  11132. },
  11133. {
  11134. name: 'name',
  11135. displayName: '姓名',
  11136. width: 100
  11137. },
  11138. {
  11139. name: 'gender.name',
  11140. displayName: '性别',
  11141. width: 80,
  11142. enableFiltering: false
  11143. },
  11144. {
  11145. name: 'mphone',
  11146. displayName: '电话',
  11147. width: 100,
  11148. enableFiltering: false
  11149. },
  11150. {
  11151. name: 'email',
  11152. displayName: '邮件',
  11153. width: 100
  11154. },
  11155. {
  11156. name: 'areaDTO.area',
  11157. displayName: '区域',
  11158. width: 100,
  11159. enableFiltering: false
  11160. },
  11161. {
  11162. name: 'placeDTO.place',
  11163. displayName: '地点',
  11164. enableFiltering: false
  11165. }
  11166. ];
  11167. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11168. $scope.gridApi = gridApi;
  11169. // var filtersData = $scope.memoryfilterData;
  11170. // filtersData.idx = newPage - 1;
  11171. // filtersData.sum = pageSize;
  11172. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11173. var filtersData = $scope.memoryfilterData;
  11174. filtersData.idx = newPage - 1;
  11175. filtersData.sum = pageSize;
  11176. $scope.loadData(filtersData);
  11177. });
  11178. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11179. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  11180. $scope.selected.item = data.entity;
  11181. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  11182. });
  11183. gridApi.core.on.filterChanged($scope, function () {
  11184. var grid = this.grid;
  11185. var filtersData = {
  11186. idx: 0,
  11187. sum: 10
  11188. // 'requester': { 'userType': 1 }
  11189. };
  11190. angular.forEach(grid.columns, function (item) {
  11191. if (item.enableFiltering) {
  11192. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11193. if (angular.isUndefined(filtersData['requester'])) {
  11194. filtersData['requester'] = {};
  11195. }
  11196. filtersData['requester'][item.field] = item.filters[0].term;
  11197. }
  11198. }
  11199. });
  11200. $scope.memoryfilterData = filtersData;
  11201. $scope.loadData(filtersData);
  11202. });
  11203. };
  11204. $scope.memoryfilterData = defaultFilterData = {
  11205. "idx": 0,
  11206. "sum": 10
  11207. };
  11208. $scope.loadData = function (filterData) {
  11209. if (!filterData.requester) {
  11210. filterData.requester = {};
  11211. }
  11212. if (scope.roleidcode) {
  11213. angular.extend(filterData['requester'], {
  11214. 'userType': 1
  11215. });
  11216. }
  11217. items.fetchItems(filterData, APIService).then(function (data) {
  11218. var myData = Restangular.stripRestangular(data);
  11219. $scope.gridOptions.totalItems = myData.totalNum;
  11220. $scope.myData = myData.list;
  11221. });
  11222. };
  11223. // $scope.title = title;
  11224. if (searchDatas) {
  11225. $scope.loadData(searchDatas);
  11226. } else {
  11227. $scope.loadData({
  11228. idx: 0,
  11229. sum: 10,
  11230. });
  11231. }
  11232. $scope.selected = {
  11233. item: {}
  11234. };
  11235. $scope.ok = function () {
  11236. $modalInstance.close($scope.selected.item);
  11237. };
  11238. $scope.cancel = function () {
  11239. $modalInstance.dismiss('cancel');
  11240. };
  11241. },
  11242. size: size,
  11243. resolve: {
  11244. items: function () {
  11245. return {
  11246. fetchItems: function (filterData, APIService) {
  11247. filterData = filterData || {};
  11248. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  11249. filterData = {
  11250. idx: 0,
  11251. sum: 10
  11252. };
  11253. }
  11254. return options.templateOptions.fetchItems(filterData, APIService);
  11255. }
  11256. };
  11257. },
  11258. title: function () {
  11259. return options.templateOptions.modalTitle;
  11260. },
  11261. Restangular: function () {
  11262. return options.templateOptions.Restangular;
  11263. },
  11264. APIService: function () {
  11265. return options.templateOptions.ApiService;
  11266. },
  11267. language: function () {
  11268. return options.templateOptions.language;
  11269. },
  11270. searchDatas: function () {
  11271. return filterSearchData;
  11272. },
  11273. scope: function () {
  11274. return $scope;
  11275. }
  11276. }
  11277. });
  11278. modalInstance.result.then(function (selectedItem) {
  11279. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11280. selectedItem.telephone = $scope.model.incident.contactsInformation;
  11281. }
  11282. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  11283. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  11284. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  11285. if ($scope.model) {
  11286. if ($scope.model.incident.place) {
  11287. $scope.model.incident.place.id = '';
  11288. }
  11289. if ($scope.model.area) {
  11290. $scope.model.incident.area.id = '';
  11291. }
  11292. $scope.model.incident.contacts = selectedItem.name;
  11293. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11294. $scope.model.incident.contactsInformation = selectedItem.mphone;
  11295. } else {
  11296. $scope.model.incident.contactsInformation = selectedItem.telephone;
  11297. }
  11298. $scope.model.incident.houseNumber = '';
  11299. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11300. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11301. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11302. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11303. }
  11304. }
  11305. $scope.options.value(selectedItem);
  11306. $scope.searchData = selectedItem.account;
  11307. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11308. $scope.model.incident.place.id = selectedItem.placeDTO.id
  11309. }
  11310. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11311. $scope.model.incident.area.id = selectedItem.areaDTO.id
  11312. }
  11313. if (selectedItem.houseNumber) {
  11314. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  11315. }
  11316. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11317. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11318. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11319. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11320. }
  11321. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  11322. options.templateOptions.callback(selectedItem, options);
  11323. }
  11324. if (!$scope.roleidcode) {
  11325. $scope.charging(selectedItem, modal)
  11326. }
  11327. $scope.recentlyincident(selectedItem);
  11328. }, function () {
  11329. //console.log('Modal dismissed at: ' + new Date());
  11330. });
  11331. }
  11332. searchModal();
  11333. // }
  11334. }
  11335. }
  11336. };
  11337. },
  11338. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  11339. $scope.roleidcode = true;
  11340. // $scope.options.initialValue = undefined;
  11341. if ($rootScope.user && $rootScope.user.role) {
  11342. angular.forEach($rootScope.user.role, function (item) {
  11343. if (item.rolecode == "call center") {
  11344. $scope.roleidcode = false;
  11345. }
  11346. })
  11347. }
  11348. $scope.recently = false;
  11349. $scope.recentlyincident = function (key, model) { //关联事件
  11350. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  11351. "idx": 0,
  11352. "sum": 4,
  11353. incident: {
  11354. requester: {
  11355. id: key.id
  11356. }
  11357. }
  11358. }).then(function (response) {
  11359. if (response.status == 200) {
  11360. $scope.recently = true;
  11361. $scope.recentincident = response.list;
  11362. } else {
  11363. $scope.recently = false;
  11364. }
  11365. })
  11366. $scope.bodyHeight = window.innerHeight - 100;
  11367. $(window).resize(function () {
  11368. $scope.bodyHeight = window.innerHeight - 100;
  11369. });
  11370. // $scope.shows = false;
  11371. $scope.tempData = {};
  11372. $scope.close = function () {
  11373. $scope.changes = !$scope.changes;
  11374. event.preventDefault();
  11375. }
  11376. }
  11377. $scope.charging = function (key, model) { //计费弹出框
  11378. //用户信息
  11379. $scope.information = {};
  11380. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  11381. "userId": key.account
  11382. }).then(function (response) {
  11383. // if (response.status == 200) {
  11384. if (response && response.data) {
  11385. angular.extend($scope.information, response.data[0]);
  11386. // $scope.information = response.data[0];
  11387. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  11388. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  11389. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  11390. } else if (response.err) {
  11391. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  11392. }
  11393. // }
  11394. })
  11395. //上网明细
  11396. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  11397. "userId": key.account,
  11398. "limit": "10",
  11399. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  11400. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  11401. }).then(function (response) {
  11402. // if (response.status == 200) {
  11403. if (response && response.data) {
  11404. angular.forEach(response.data, function (item, index) {
  11405. if (item.logoutTime) {
  11406. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  11407. }
  11408. if (item.loginTime) {
  11409. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  11410. }
  11411. })
  11412. $scope.logininform = response.data;
  11413. } else if (response.err) {
  11414. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  11415. }
  11416. })
  11417. //黑名单
  11418. // $scope.information.blacklist = "否"
  11419. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  11420. "userId": key.account
  11421. }).then(function (response) {
  11422. // if (response.status == 200) {
  11423. // $scope.logininformation = response.data;
  11424. if (response) {
  11425. if (response.data || response.data != null) {
  11426. $scope.information.blacklist = "是"
  11427. } else {
  11428. if (response.err) {
  11429. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  11430. } else {
  11431. $scope.information.blacklist = "否"
  11432. }
  11433. }
  11434. }
  11435. // }
  11436. })
  11437. $scope.bodyHeight = window.innerHeight - 100;
  11438. $(window).resize(function () {
  11439. $scope.bodyHeight = window.innerHeight - 100;
  11440. });
  11441. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  11442. // $scope.closepages = function(e) {
  11443. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  11444. // event.preventDefault();
  11445. // };
  11446. // $scope.shows = false;
  11447. $scope.tempData = {};
  11448. $scope.close = function () {
  11449. $scope.changes = !$scope.changes;
  11450. event.preventDefault();
  11451. }
  11452. }
  11453. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  11454. idx: 0,
  11455. sum: 100
  11456. }).then(function (response) {
  11457. if (response.status == 200) {
  11458. $scope.networktypes = response.list;
  11459. } else {
  11460. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  11461. }
  11462. })
  11463. function serchdata(searchKey) {
  11464. if (searchKey) {
  11465. var filterData = {
  11466. 'requester': {
  11467. 'searchKey': searchKey
  11468. // 'userType': 1
  11469. },
  11470. idx: 0,
  11471. sum: 10
  11472. };
  11473. } else {
  11474. var filterData = {
  11475. 'idx': 0,
  11476. 'requester': {},
  11477. 'sum': 10
  11478. };
  11479. }
  11480. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  11481. angular.extend(filterData.requester, {
  11482. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  11483. });
  11484. if (!$scope.options.model.contactsInformation) {
  11485. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  11486. }
  11487. }
  11488. if ($scope.roleidcode) {
  11489. angular.extend(filterData['requester'], {
  11490. 'userType': 1
  11491. });
  11492. }
  11493. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  11494. var myData = response;
  11495. $scope.myData = myData.list;
  11496. });
  11497. }
  11498. $scope.searchData = {};
  11499. $scope.refreshUser = function (searchKey) { //请求人搜索
  11500. if (searchKey && searchKey != "") {
  11501. serchdata(searchKey);
  11502. }
  11503. }
  11504. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  11505. if (!$scope.roleidcode) {
  11506. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  11507. }
  11508. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  11509. }
  11510. $scope.onChange = function (searchData) {
  11511. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11512. searchData.telephone = $scope.model.incident.contactsInformation;;
  11513. }
  11514. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  11515. if (!$scope.roleidcode) {
  11516. $scope.charging(searchData);
  11517. }
  11518. $scope.recentlyincident(searchData);
  11519. $scope.accountshow = false;
  11520. if ($scope.model.incident) {
  11521. if ($scope.model.incident.place) {
  11522. $scope.model.incident.place.id = '';
  11523. }
  11524. if ($scope.model.incident.area) {
  11525. $scope.model.incident.area.id = '';
  11526. }
  11527. $scope.model.incident.contacts = searchData.name;
  11528. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  11529. $scope.model.incident.contactsInformation = searchData.mphone;
  11530. } else {
  11531. $scope.model.incident.contactsInformation = searchData.telephone;
  11532. }
  11533. $scope.model.incident.houseNumber = '';
  11534. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11535. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11536. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11537. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11538. }
  11539. }
  11540. $scope.options.value(searchData);
  11541. $scope.searchKey = searchData.account;
  11542. if (searchData.placeDTO && searchData.placeDTO.id) {
  11543. $scope.model.incident.place.id = searchData.placeDTO.id
  11544. }
  11545. if (searchData.areaDTO && searchData.areaDTO.id) {
  11546. $scope.model.incident.area.id = searchData.areaDTO.id
  11547. }
  11548. if (searchData.houseNumber) {
  11549. $scope.model.incident.houseNumber = searchData.houseNumber;
  11550. }
  11551. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11552. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11553. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11554. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11555. }
  11556. }
  11557. }]
  11558. });
  11559. //ui-grid-table展示控件
  11560. formlyConfigProvider.setType({
  11561. name: 'ui-grid-table',
  11562. // extends: 'multiCheckbox',//去掉冒号
  11563. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  11564. defaultOptions: function (options) {
  11565. return {
  11566. templateOptions: {
  11567. linkage: function () { },
  11568. },
  11569. };
  11570. },
  11571. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  11572. var loginUser = $rootScope.user;
  11573. $scope.langs = i18nService.getAllLangs();
  11574. $scope.lang = 'zh-cn';
  11575. i18nService.setCurrentLang($scope.lang);
  11576. $scope.gridOptions = {};
  11577. $scope.gridOptions.data = 'myData';
  11578. $scope.gridOptions.enableColumnResizing = true;
  11579. $scope.gridOptions.enableGridMenu = false;
  11580. $scope.gridOptions.enableRowSelection = true;
  11581. $scope.gridOptions.showGridFooter = false;
  11582. $scope.gridOptions.showColumnFooter = false;
  11583. $scope.gridOptions.fastWatch = true;
  11584. $scope.gridOptions.useExternalFiltering = true;
  11585. $scope.gridOptions.useExternalPagination = false;
  11586. $scope.gridOptions.paginationPageSizes = [10];
  11587. $scope.gridOptions.paginationPageSize = 3;
  11588. $scope.gridOptions.multiSelect = false;
  11589. $scope.gridOptions.rowIdentity = function (row) {
  11590. return row.id;
  11591. };
  11592. $scope.gridOptions.getRowIdentity = function (row) {
  11593. return row.id;
  11594. };
  11595. $scope.gridOptions.columnDefs = [{
  11596. name: 'item',
  11597. displayName: '序号',
  11598. width: 80,
  11599. enableFiltering: false
  11600. },
  11601. {
  11602. name: 'incidentsign',
  11603. displayName: '单号',
  11604. width: 80,
  11605. enableFiltering: false
  11606. },
  11607. {
  11608. name: 'description',
  11609. displayName: '主题',
  11610. width: 80,
  11611. enableFiltering: false
  11612. },
  11613. {
  11614. name: 'state.name',
  11615. displayName: '状态',
  11616. width: 110,
  11617. enableFiltering: false
  11618. },
  11619. {
  11620. name: 'acceptDate',
  11621. displayName: '创建时间',
  11622. width: 160,
  11623. enableFiltering: false
  11624. },
  11625. {
  11626. name: 'requester.name',
  11627. displayName: '请求人',
  11628. width: 80,
  11629. enableFiltering: false
  11630. },
  11631. {
  11632. name: 'handlingPersonnelUser.name',
  11633. displayName: '处理人',
  11634. width: 160,
  11635. enableFiltering: false
  11636. },
  11637. {
  11638. name: 'place.place',
  11639. displayName: '区域地点',
  11640. width: 160,
  11641. enableFiltering: false
  11642. },
  11643. ];
  11644. // var defaultFilterData = {
  11645. // "idx": 0,
  11646. // "sum": 3
  11647. // };
  11648. // // //分页控制
  11649. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11650. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11651. var filtersData = $scope.memoryfilterData;
  11652. filtersData.idx = newPage - 1;
  11653. filtersData.sum = pageSize;
  11654. $scope.refreshData('expand-right', filtersData);
  11655. });
  11656. // 表格单选事件
  11657. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11658. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  11659. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  11660. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  11661. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  11662. str = str.split("").reverse().join("");
  11663. var del = addstr.split("").reverse().join("");
  11664. // console.log(del);
  11665. var reg = new RegExp(del);
  11666. str = str.replace(reg, '');
  11667. str = str.split("").reverse().join("")
  11668. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  11669. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  11670. str += data.entity.description;
  11671. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  11672. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  11673. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  11674. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  11675. }
  11676. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  11677. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  11678. });
  11679. };
  11680. // 刷新表格
  11681. setInterval(function () {
  11682. // console.log($scope.myData);
  11683. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  11684. // console.log($scope.myData);
  11685. if ($scope.myData != null) {
  11686. for (var i = 0; i < $scope.myData.length; i++) {
  11687. //添加序号
  11688. $scope.myData[i]['item'] = i + 1;
  11689. }
  11690. }
  11691. }, 1000)
  11692. }
  11693. });
  11694. //处理人信息
  11695. formlyConfigProvider.setType({
  11696. name: "ui-userinformation",
  11697. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  11698. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11699. defaultOptions: function (options) {
  11700. return {
  11701. templateOptions: {}
  11702. };
  11703. },
  11704. controller: ['$scope', function ($scope) {
  11705. $scope.group = "";
  11706. $scope.role = "";
  11707. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11708. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11709. } else {
  11710. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11711. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11712. }
  11713. }
  11714. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  11715. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  11716. } else {
  11717. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  11718. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  11719. }
  11720. }
  11721. $scope.options.templateOptions.that = $scope;
  11722. }]
  11723. });
  11724. //处理界面处理人信息
  11725. formlyConfigProvider.setType({
  11726. name: "ui-handler",
  11727. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  11728. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11729. defaultOptions: function (options) {
  11730. return {
  11731. templateOptions: {}
  11732. };
  11733. },
  11734. controller: ['$scope', function ($scope) {
  11735. $scope.group = "";
  11736. // $scope.role="";
  11737. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11738. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11739. } else {
  11740. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11741. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11742. }
  11743. }
  11744. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  11745. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  11746. // }else{
  11747. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  11748. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  11749. // }
  11750. // }
  11751. $scope.options.templateOptions.that = $scope;
  11752. }]
  11753. });
  11754. //微信事件流程
  11755. formlyConfigProvider.setType({
  11756. name: "ui-wxIncidentProcess",
  11757. templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
  11758. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11759. defaultOptions: function (options) {
  11760. return {
  11761. templateOptions: {}
  11762. };
  11763. },
  11764. controller: ['$scope', function ($scope) {
  11765. console.log($scope.model);
  11766. $scope.pingjia = false;
  11767. $scope.jiejue = false;
  11768. if ($scope.model.incidentState.value == "3") {
  11769. $scope.pingjia = true
  11770. } else if ($scope.model.incidentState.value == "4") {
  11771. $scope.jiejue = true;
  11772. }
  11773. }]
  11774. });
  11775. //打电话
  11776. formlyConfigProvider.setType({
  11777. name: "ui-inputcall",
  11778. extends: 'input',
  11779. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  11780. defaultOptions: function (options) {
  11781. return {
  11782. templateOptions: {
  11783. transform: function (value) { }
  11784. }
  11785. };
  11786. },
  11787. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  11788. $scope.dialout = function (teleno) {
  11789. var gid = "@0"
  11790. var telephone = '9' + teleno
  11791. $rootScope.callout = 2;
  11792. if ($rootScope.takes) {
  11793. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11794. if (data.errno == 0) {
  11795. $rootScope.status = 6;
  11796. }
  11797. })
  11798. } else {
  11799. SweetAlert.swal({
  11800. title: "呼叫失败",
  11801. text: "请先签入呼叫中心!",
  11802. type: "error",
  11803. confirmButtonColor: "#DD6B55"
  11804. });
  11805. }
  11806. }
  11807. $scope.options.templateOptions.that = $scope;
  11808. }]
  11809. });
  11810. //关闭界面处理人信息
  11811. formlyConfigProvider.setType({
  11812. name: "ui-closehandler",
  11813. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  11814. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11815. defaultOptions: function (options) {
  11816. return {
  11817. templateOptions: {}
  11818. };
  11819. },
  11820. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  11821. $scope.dialout = function (teleno) {
  11822. var gid = "@0"
  11823. var telephone = '9' + teleno
  11824. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11825. if (data.errno == 0) {
  11826. $rootScope.status = 6;
  11827. }
  11828. })
  11829. }
  11830. $scope.options.templateOptions.that = $scope;
  11831. }]
  11832. });
  11833. //用户单选控件
  11834. formlyConfigProvider.setType({
  11835. name: "ui-userselect",
  11836. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  11837. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11838. defaultOptions: function (options) {
  11839. return {
  11840. templateOptions: {
  11841. openModal: function (size, options, modal) {
  11842. var modalInstance = modal.open({
  11843. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11844. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  11845. $scope.langs = i18nService.getAllLangs();
  11846. $scope.lang = 'zh-cn';
  11847. i18nService.setCurrentLang($scope.lang);
  11848. $scope.gridOptions = {};
  11849. $scope.gridOptions.data = 'myData';
  11850. $scope.gridOptions.enableColumnResizing = true;
  11851. $scope.gridOptions.enableFiltering = true;
  11852. $scope.gridOptions.enableGridMenu = false;
  11853. $scope.gridOptions.showGridFooter = true;
  11854. $scope.gridOptions.showColumnFooter = false;
  11855. $scope.gridOptions.fastWatch = true;
  11856. $scope.gridOptions.useExternalFiltering = true;
  11857. $scope.gridOptions.useExternalPagination = true;
  11858. $scope.gridOptions.paginationPageSizes = [10];
  11859. $scope.gridOptions.paginationPageSize = 10;
  11860. $scope.gridOptions.multiSelect = false;
  11861. $scope.gridOptions.rowIdentity = function (row) {
  11862. return row.id;
  11863. };
  11864. $scope.gridOptions.getRowIdentity = function (row) {
  11865. return row.id;
  11866. };
  11867. $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>";
  11868. $scope.gridOptions.columnDefs = [{
  11869. name: 'account',
  11870. displayName: '人员编号',
  11871. width: 120
  11872. },
  11873. {
  11874. name: 'name',
  11875. displayName: '姓名',
  11876. width: 100,
  11877. cellTemplate: '<div>' +
  11878. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  11879. '</div>'
  11880. },
  11881. // {
  11882. // name: 'gender.name',
  11883. // displayName: '性别',
  11884. // width: 80,
  11885. // enableFiltering: false
  11886. // },
  11887. {
  11888. name: 'phone',
  11889. displayName: '电话',
  11890. width: 230,
  11891. enableFiltering: false
  11892. },
  11893. {
  11894. name: 'email',
  11895. displayName: '邮箱',
  11896. width: 180,
  11897. enableFiltering: false
  11898. },
  11899. {
  11900. name: 'dept.dept',
  11901. displayName: '科室',
  11902. width: 130,
  11903. enableFiltering: false
  11904. },
  11905. {
  11906. name: 'taskCount',
  11907. displayName: '处理中事件数',
  11908. enableFiltering: false
  11909. }
  11910. ];
  11911. // $scope.selectButtonClick
  11912. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11913. $scope.gridApi = gridApi;
  11914. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11915. var filtersData = $scope.memoryfilterData;
  11916. filtersData.idx = newPage - 1;
  11917. filtersData.sum = pageSize;
  11918. $scope.loadData(filtersData);
  11919. //console.log(pageSize);
  11920. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  11921. });
  11922. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11923. $scope.selected.items = data.entity;
  11924. //console.log(data);
  11925. });
  11926. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  11927. $scope.selected.items = data.entity;
  11928. //console.log(data);
  11929. });
  11930. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  11931. // // if (row.entity.age > 45) {
  11932. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11933. // // }
  11934. // };
  11935. gridApi.core.on.filterChanged($scope, function () {
  11936. var grid = this.grid;
  11937. var filtersData = {
  11938. idx: 0,
  11939. sum: 10,
  11940. "user": {
  11941. "roledata": {
  11942. "rolecode": "roleset"
  11943. },
  11944. "selectType": "1"
  11945. }
  11946. };
  11947. angular.forEach(grid.columns, function (item) {
  11948. if (item.enableFiltering) {
  11949. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  11950. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11951. if (angular.isUndefined(filtersData['user'])) {
  11952. filtersData['user'] = {};
  11953. }
  11954. filtersData['user'][item.field] = item.filters[0].term;
  11955. }
  11956. }
  11957. });
  11958. $scope.memoryfilterData = filtersData;
  11959. $scope.loadData(filtersData);
  11960. });
  11961. };
  11962. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  11963. // if (row.entity.age > 45) {
  11964. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11965. // }
  11966. // },
  11967. $scope.onDblClick = function (data, event) {
  11968. // $scope.selected.items = data.entity;
  11969. $scope.selectButtonClick(data, event);
  11970. };
  11971. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  11972. // $scope.selected.items = data.entity;
  11973. // })
  11974. // };
  11975. $scope.memoryfilterData = {
  11976. "idx": 0,
  11977. "sum": 10,
  11978. "user": {
  11979. "roledata": {
  11980. "rolecode": "roleset"
  11981. },
  11982. "selectType": "1"
  11983. }
  11984. }
  11985. $scope.loadData = function (filterData) {
  11986. // console.log("filtersData=111" + JSON.stringify(filterData))
  11987. items.fetchItems(filterData, APIService).then(function (data) {
  11988. var myData = Restangular.stripRestangular(data);
  11989. $scope.gridOptions.totalItems = myData.totalNum;
  11990. $scope.myData = myData.list;
  11991. });
  11992. };
  11993. // $scope.title = title;
  11994. $scope.loadData({
  11995. idx: 0,
  11996. sum: 10,
  11997. "user": {
  11998. "roledata": {
  11999. "rolecode": "roleset"
  12000. },
  12001. "selectType": "1"
  12002. }
  12003. });
  12004. $scope.selected = {
  12005. items: {}
  12006. };
  12007. $scope.ok = function () {
  12008. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12009. // onDataCallback($scope.selected.item, parentScope);
  12010. // }
  12011. $modalInstance.close($scope.selected.items);
  12012. };
  12013. $scope.cancel = function () {
  12014. $modalInstance.dismiss('cancel');
  12015. };
  12016. },
  12017. size: size,
  12018. resolve: {
  12019. items: function () {
  12020. return {
  12021. fetchItems: function (filterData, APIService) {
  12022. filterData = filterData || {};
  12023. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12024. filterData = {
  12025. idx: 0,
  12026. sum: 10,
  12027. "user": {
  12028. "roledata": {
  12029. "rolecode": "roleset"
  12030. },
  12031. "selectType": "1"
  12032. }
  12033. };
  12034. }
  12035. return options.templateOptions.fetchItems(filterData, APIService);
  12036. }
  12037. };
  12038. },
  12039. title: function () {
  12040. return options.templateOptions.label;
  12041. },
  12042. Restangular: function () {
  12043. return options.templateOptions.Restangular;
  12044. },
  12045. APIService: function () {
  12046. return options.templateOptions.ApiService;
  12047. },
  12048. onDataCallback: function () {
  12049. return options.templateOptions.callback;
  12050. },
  12051. parentScope: function () {
  12052. return options.templateOptions.that;
  12053. }
  12054. }
  12055. });
  12056. modalInstance.result.then(function (selectedItem) {
  12057. // console.log(selectedItem);
  12058. options.value(selectedItem);
  12059. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12060. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12061. }
  12062. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12063. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12064. }
  12065. }, function () {
  12066. //console.log('Modal dismissed at: ' + new Date());
  12067. });
  12068. }
  12069. }
  12070. };
  12071. },
  12072. controller: ['$scope', function ($scope) {
  12073. $scope.options.templateOptions.that = $scope;
  12074. // $scope.options.model[$scope.options.key] = {}
  12075. }]
  12076. });
  12077. //用户单选控件(dd 单选input带搜索)
  12078. formlyConfigProvider.setType({
  12079. name: "ui-userselectSearch",
  12080. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  12081. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12082. defaultOptions: function (options) {
  12083. return {
  12084. templateOptions: {
  12085. openModal: function (size, options, modal) {
  12086. var modalInstance = modal.open({
  12087. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12088. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  12089. $scope.langs = i18nService.getAllLangs();
  12090. $scope.lang = 'zh-cn';
  12091. i18nService.setCurrentLang($scope.lang);
  12092. $scope.gridOptions = {};
  12093. $scope.gridOptions.data = 'myData';
  12094. $scope.gridOptions.enableColumnResizing = true;
  12095. $scope.gridOptions.enableFiltering = true;
  12096. $scope.gridOptions.enableGridMenu = false;
  12097. $scope.gridOptions.showGridFooter = true;
  12098. $scope.gridOptions.showColumnFooter = false;
  12099. $scope.gridOptions.fastWatch = true;
  12100. $scope.gridOptions.useExternalFiltering = true;
  12101. $scope.gridOptions.useExternalPagination = true;
  12102. $scope.gridOptions.paginationPageSizes = [10];
  12103. $scope.gridOptions.paginationPageSize = 10;
  12104. $scope.gridOptions.multiSelect = false;
  12105. $scope.gridOptions.rowIdentity = function (row) {
  12106. return row.id;
  12107. };
  12108. $scope.gridOptions.getRowIdentity = function (row) {
  12109. return row.id;
  12110. };
  12111. $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>";
  12112. $scope.gridOptions.columnDefs = [{
  12113. name: 'account',
  12114. displayName: '人员编号',
  12115. width: 120
  12116. },
  12117. {
  12118. name: 'name',
  12119. displayName: '姓名',
  12120. width: 100,
  12121. cellTemplate: '<div>' +
  12122. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  12123. '</div>'
  12124. },
  12125. // {
  12126. // name: 'gender.name',
  12127. // displayName: '性别',
  12128. // width: 80,
  12129. // enableFiltering: false
  12130. // },
  12131. {
  12132. name: 'phone',
  12133. displayName: '电话',
  12134. width: 230,
  12135. enableFiltering: false
  12136. },
  12137. {
  12138. name: 'email',
  12139. displayName: '邮箱',
  12140. width: 180,
  12141. enableFiltering: false
  12142. },
  12143. {
  12144. name: 'dept.dept',
  12145. displayName: '科室',
  12146. width: 130,
  12147. enableFiltering: false
  12148. },
  12149. {
  12150. name: 'taskCount',
  12151. displayName: '处理中事件数',
  12152. enableFiltering: false
  12153. }
  12154. ];
  12155. // $scope.selectButtonClick
  12156. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12157. $scope.gridApi = gridApi;
  12158. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12159. var filtersData = $scope.memoryfilterData;
  12160. filtersData.idx = newPage - 1;
  12161. filtersData.sum = pageSize;
  12162. $scope.loadData(filtersData);
  12163. //console.log(pageSize);
  12164. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12165. });
  12166. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12167. $scope.selected.items = data.entity;
  12168. //console.log(data);
  12169. });
  12170. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  12171. $scope.selected.items = data.entity;
  12172. //console.log(data);
  12173. });
  12174. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  12175. // // if (row.entity.age > 45) {
  12176. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12177. // // }
  12178. // };
  12179. gridApi.core.on.filterChanged($scope, function () {
  12180. var grid = this.grid;
  12181. var filtersData = {
  12182. idx: 0,
  12183. sum: 10,
  12184. user: {
  12185. roledata: {
  12186. rolecode: "first-line support"
  12187. },
  12188. selectType: "1"
  12189. }
  12190. };
  12191. angular.forEach(grid.columns, function (item) {
  12192. if (item.enableFiltering) {
  12193. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  12194. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12195. if (angular.isUndefined(filtersData['user'])) {
  12196. filtersData['user'] = {};
  12197. }
  12198. filtersData['user'][item.field] = item.filters[0].term;
  12199. }
  12200. }
  12201. });
  12202. $scope.memoryfilterData = filtersData;
  12203. $scope.loadData(filtersData);
  12204. });
  12205. };
  12206. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  12207. // if (row.entity.age > 45) {
  12208. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12209. // }
  12210. // },
  12211. $scope.onDblClick = function (data, event) {
  12212. // $scope.selected.items = data.entity;
  12213. $scope.selectButtonClick(data, event);
  12214. };
  12215. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  12216. // $scope.selected.items = data.entity;
  12217. // })
  12218. // };
  12219. $scope.memoryfilterData = {
  12220. idx: 0,
  12221. sum: 10,
  12222. user: {
  12223. roledata: {
  12224. rolecode: "first-line support"
  12225. },
  12226. selectType: "1"
  12227. }
  12228. }
  12229. $scope.loadData = function (filterData) {
  12230. // console.log("filtersData=111" + JSON.stringify(filterData))
  12231. items.fetchItems(filterData, APIService).then(function (data) {
  12232. var myData = Restangular.stripRestangular(data);
  12233. $scope.gridOptions.totalItems = myData.totalNum;
  12234. $scope.myData = myData.list;
  12235. });
  12236. };
  12237. $scope.title = title;
  12238. $scope.loadData({
  12239. idx: 0,
  12240. sum: 10,
  12241. user: {
  12242. roledata: {
  12243. rolecode: "first-line support"
  12244. },
  12245. selectType: "1"
  12246. }
  12247. });
  12248. $scope.selected = {
  12249. items: {}
  12250. };
  12251. $scope.ok = function () {
  12252. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12253. // onDataCallback($scope.selected.item, parentScope);
  12254. // }
  12255. $modalInstance.close($scope.selected.items);
  12256. };
  12257. $scope.cancel = function () {
  12258. $modalInstance.dismiss('cancel');
  12259. };
  12260. },
  12261. size: size,
  12262. resolve: {
  12263. items: function () {
  12264. return {
  12265. fetchItems: function (filterData, APIService) {
  12266. filterData = filterData || {};
  12267. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12268. filterData = {
  12269. idx: 0,
  12270. sum: 10,
  12271. user: {
  12272. roledata: {
  12273. rolecode: "first-line support"
  12274. },
  12275. selectType: "1"
  12276. }
  12277. };
  12278. }
  12279. return options.templateOptions.fetchItems(filterData, APIService);
  12280. }
  12281. };
  12282. },
  12283. title: function () {
  12284. return options.templateOptions.label;
  12285. },
  12286. Restangular: function () {
  12287. return options.templateOptions.Restangular;
  12288. },
  12289. APIService: function () {
  12290. return options.templateOptions.ApiService;
  12291. },
  12292. onDataCallback: function () {
  12293. return options.templateOptions.callback;
  12294. },
  12295. parentScope: function () {
  12296. return options.templateOptions.that;
  12297. }
  12298. }
  12299. });
  12300. modalInstance.result.then(function (selectedItem) {
  12301. // console.log(selectedItem);
  12302. options.value(selectedItem);
  12303. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12304. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12305. }
  12306. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12307. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12308. }
  12309. }, function () {
  12310. //console.log('Modal dismissed at: ' + new Date());
  12311. });
  12312. }
  12313. }
  12314. };
  12315. },
  12316. controller: ['$scope', function ($scope) {
  12317. $scope.options.templateOptions.that = $scope;
  12318. }]
  12319. });
  12320. //用户多选控件
  12321. formlyConfigProvider.setType({
  12322. name: "ui-multiuserselect",
  12323. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  12324. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12325. defaultOptions: function (options) {
  12326. return {
  12327. templateOptions: {
  12328. openModal: function (size, options, modal, model) {
  12329. var modalInstance = modal.open({
  12330. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12331. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  12332. $scope.langs = i18nService.getAllLangs();
  12333. $scope.lang = 'zh-cn';
  12334. i18nService.setCurrentLang($scope.lang);
  12335. $scope.gridOptions = {};
  12336. $scope.gridOptions.data = 'myData';
  12337. $scope.gridOptions.enableColumnResizing = true;
  12338. $scope.gridOptions.enableFiltering = true;
  12339. $scope.gridOptions.enableGridMenu = true;
  12340. $scope.gridOptions.showGridFooter = true;
  12341. $scope.gridOptions.showColumnFooter = true;
  12342. $scope.gridOptions.fastWatch = true;
  12343. $scope.gridOptions.useExternalFiltering = true;
  12344. $scope.gridOptions.useExternalPagination = true;
  12345. $scope.gridOptions.paginationPageSizes = [10];
  12346. $scope.gridOptions.paginationPageSize = 10;
  12347. $scope.gridOptions.multiSelect = true;
  12348. $scope.gridOptions.rowIdentity = function (row) {
  12349. return row.id;
  12350. };
  12351. $scope.gridOptions.getRowIdentity = function (row) {
  12352. return row.id;
  12353. };
  12354. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12355. $scope.gridOptions.columnDefs = [
  12356. // { name:'id', width:80, enableFiltering:false},
  12357. {
  12358. name: 'account',
  12359. displayName: '账号',
  12360. width: 140
  12361. },
  12362. {
  12363. name: 'name',
  12364. displayName: '名称',
  12365. width: 100
  12366. },
  12367. {
  12368. name: 'gender.name',
  12369. displayName: '性别',
  12370. width: 140,
  12371. enableFiltering: false
  12372. },
  12373. {
  12374. name: 'phone',
  12375. displayName: '电话',
  12376. width: 100,
  12377. enableFiltering: false
  12378. },
  12379. {
  12380. name: 'email',
  12381. displayName: '邮件',
  12382. width: 100,
  12383. enableFiltering: false
  12384. },
  12385. {
  12386. name: 'dept.dept',
  12387. displayName: '科室',
  12388. width: 100,
  12389. enableFiltering: false
  12390. },
  12391. {
  12392. name: 'group[0].groupName',
  12393. displayName: '职位',
  12394. width: 100,
  12395. enableFiltering: false
  12396. }
  12397. ];
  12398. $scope.selected = {
  12399. items: selectItems
  12400. };
  12401. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12402. $scope.gridApi = gridApi;
  12403. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12404. var filtersData = $scope.memoryfilterData;
  12405. filtersData.idx = newPage - 1;
  12406. filtersData.sum = pageSize;
  12407. $scope.loadData(filtersData);
  12408. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12409. });
  12410. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  12411. var j = 0;
  12412. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  12413. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  12414. j++;
  12415. break;
  12416. }
  12417. }
  12418. if (j == 1) {
  12419. scope.grid.appScope.selected.items.splice(i, 1);
  12420. } else {
  12421. scope.grid.appScope.selected.items.push(scope.entity)
  12422. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  12423. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  12424. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  12425. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  12426. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  12427. scope.grid.appScope.selected.items.splice(i, 1);
  12428. }
  12429. }
  12430. }
  12431. }
  12432. });
  12433. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  12434. // $scope.grid.appScope.selected.items.push($scope.entity);
  12435. // });
  12436. gridApi.core.on.filterChanged($scope, function () {
  12437. var grid = this.grid;
  12438. var filtersData = {
  12439. idx: 0,
  12440. sum: 10,
  12441. "user": {
  12442. "roledata": {
  12443. "rolecode": options.model.currentRole
  12444. },
  12445. "selectType": "1"
  12446. }
  12447. };
  12448. angular.forEach(grid.columns, function (item) {
  12449. if (item.enableFiltering) {
  12450. //console.log("filtersData="+JSON.stringify(filtersData))
  12451. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12452. if (angular.isUndefined(filtersData['user'])) {
  12453. filtersData['user'] = {};
  12454. }
  12455. filtersData['user'][item.field] = item.filters[0].term;
  12456. }
  12457. }
  12458. });
  12459. $scope.memoryfilterData = filtersData;
  12460. $scope.loadData(filtersData);
  12461. });
  12462. };
  12463. if (!options.model) {
  12464. var mouse = {
  12465. "model": {
  12466. "currentRole": ""
  12467. }
  12468. };
  12469. angular.extend(options, mouse);
  12470. }
  12471. $scope.memoryfilterData = {
  12472. "idx": 0,
  12473. "sum": 10,
  12474. "user": {
  12475. "roledata": {
  12476. "rolecode": options.model.currentRole
  12477. },
  12478. "selectType": "1"
  12479. }
  12480. }
  12481. $scope.loadData = function (filterData) {
  12482. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  12483. items.fetchItems(filterData, APIService).then(function (data) {
  12484. var myData = Restangular.stripRestangular(data);
  12485. $scope.gridOptions.totalItems = myData.totalNum;
  12486. $scope.myData = myData.list;
  12487. //console.log($scope.gridOptions.pagination.getTotalPages());
  12488. // if($scope.selected.items){
  12489. // angular.forEach($scope.selected.items,function(selectItem){
  12490. // $scope.gridApi.selection.selectRow(selectItem);
  12491. // });
  12492. // }
  12493. });
  12494. };
  12495. // $scope.title = title;
  12496. $scope.loadData({
  12497. idx: 0,
  12498. sum: 10,
  12499. "user": {
  12500. "roledata": {
  12501. "rolecode": options.model.currentRole
  12502. },
  12503. "selectType": "1"
  12504. }
  12505. });
  12506. // $timeout(function(){
  12507. // if($scope.selected.items){
  12508. // angular.forEach($scope.selected.items,function(selectItem){
  12509. // $scope.gridApi.selection.selectRow(selectItem);
  12510. // });
  12511. // }
  12512. // },2000)
  12513. $scope.ok = function () {
  12514. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  12515. $modalInstance.close($scope.selected.items);
  12516. };
  12517. $scope.cancel = function () {
  12518. $modalInstance.dismiss('cancel');
  12519. };
  12520. },
  12521. size: size,
  12522. resolve: {
  12523. items: function () {
  12524. return {
  12525. fetchItems: function (filterData, APIService) {
  12526. filterData = filterData || {};
  12527. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12528. filterData = {
  12529. idx: 0,
  12530. sum: 10,
  12531. "user": {
  12532. "roledata": {
  12533. "rolecode": options.model.incident.currentRole
  12534. },
  12535. "selectType": "1"
  12536. }
  12537. };
  12538. }
  12539. return options.templateOptions.fetchItems(filterData, APIService);
  12540. }
  12541. };
  12542. },
  12543. title: function () {
  12544. return options.templateOptions.modalTitle;
  12545. },
  12546. Restangular: function () {
  12547. return options.templateOptions.Restangular;
  12548. },
  12549. APIService: function () {
  12550. return options.templateOptions.ApiService;
  12551. },
  12552. selectItems: function () {
  12553. return model || [];
  12554. }
  12555. }
  12556. });
  12557. modalInstance.result.then(function (selectedItem) {
  12558. options.value(selectedItem);
  12559. options.formControl.$validate();
  12560. }, function () {
  12561. //console.log('Modal dismissed at: ' + new Date());
  12562. });
  12563. }
  12564. },
  12565. validators: {
  12566. required: {
  12567. expression: function (viewValue, modelValue) {
  12568. var value = modelValue || viewValue;
  12569. return value.length >= 1;
  12570. }
  12571. }
  12572. }
  12573. };
  12574. },
  12575. controller: ['$scope', function ($scope) {
  12576. $scope.model[$scope.options.key] = [];
  12577. $scope.remove = function (itemId) {
  12578. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  12579. if (entry.id == itemId) {
  12580. $scope.model[$scope.options.key].splice(index, 1);
  12581. // console.log($scope.options.formControl)
  12582. $scope.options.formControl.$validate();
  12583. } else {
  12584. }
  12585. });
  12586. }
  12587. }]
  12588. });
  12589. //用户多选控件-字符串展示
  12590. formlyConfigProvider.setType({
  12591. name: 'ui-stringuserselect',
  12592. extends: 'input',
  12593. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  12594. defaultOptions: function (options) {
  12595. return {
  12596. templateOptions: {
  12597. translate: '',
  12598. refreshDelay: 0
  12599. }
  12600. }
  12601. },
  12602. controller: ['$scope', function ($scope) {
  12603. var keydata = "";
  12604. if (angular.isArray($scope.model)) {
  12605. angular.forEach($scope.model, function (item) {
  12606. keydata = keydata + "," + item.name;
  12607. })
  12608. }
  12609. // $scope.model[$scope.options.key] = [];
  12610. }]
  12611. });
  12612. //重复事件
  12613. formlyConfigProvider.setType({
  12614. name: "ui-incidentmodelselect",
  12615. extends: 'input',
  12616. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12617. defaultOptions: function (options) {
  12618. return {
  12619. templateOptions: {
  12620. openModal: function (size, options, modal) {
  12621. var modalInstance = modal.open({
  12622. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12623. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  12624. $scope.langs = i18nService.getAllLangs();
  12625. $scope.lang = 'zh-cn';
  12626. i18nService.setCurrentLang($scope.lang);
  12627. $scope.gridOptions = {};
  12628. $scope.gridOptions.data = 'myData';
  12629. $scope.gridOptions.enableColumnResizing = true;
  12630. $scope.gridOptions.enableFiltering = true;
  12631. $scope.gridOptions.enableGridMenu = false;
  12632. $scope.gridOptions.enableRowSelection = true;
  12633. $scope.gridOptions.showGridFooter = true;
  12634. $scope.gridOptions.showColumnFooter = false;
  12635. $scope.gridOptions.fastWatch = true;
  12636. $scope.gridOptions.useExternalFiltering = true;
  12637. $scope.gridOptions.useExternalPagination = true;
  12638. $scope.gridOptions.paginationPageSizes = [10];
  12639. $scope.gridOptions.paginationPageSize = 10;
  12640. $scope.gridOptions.multiSelect = false;
  12641. var mun = $scope.gridOptions.paginationPageSize;
  12642. $scope.gridOptions.rowIdentity = function (row) {
  12643. return row.id;
  12644. };
  12645. $scope.gridOptions.getRowIdentity = function (row) {
  12646. return row.id;
  12647. };
  12648. $scope.gridOptions.columnDefs = items.columnDefs();
  12649. $scope.transferTime = function (time) {
  12650. return moment(time).format('YYYY-MM-DD HH:mm');
  12651. }
  12652. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12653. $scope.gridApi = gridApi;
  12654. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12655. // console.log(newPage);
  12656. // console.log(pageSize);
  12657. $scope.loadData({
  12658. "idx": newPage - 1,
  12659. "sum": pageSize
  12660. });
  12661. });
  12662. gridApi.core.on.filterChanged($scope, function () {
  12663. var grid = this.grid;
  12664. var filtersData = {
  12665. idx: 0,
  12666. sum: 100
  12667. };
  12668. angular.forEach(grid.columns, function (item) {
  12669. if (item.enableFiltering) {
  12670. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12671. // console.log("filtersData="+JSON.stringify(filtersData))
  12672. if (angular.isUndefined(filtersData['incident'])) {
  12673. filtersData['incident'] = {};
  12674. }
  12675. filtersData['incident'][item.field] = item.filters[0].term;
  12676. if (angular.isUndefined(filtersData['problem'])) {
  12677. filtersData['problem'] = {};
  12678. }
  12679. filtersData['problem'][item.field] = item.filters[0].term;
  12680. if (angular.isUndefined(filtersData['change'])) {
  12681. filtersData['change'] = {};
  12682. }
  12683. filtersData['change'][item.field] = item.filters[0].term;
  12684. if (angular.isUndefined(filtersData['release'])) {
  12685. filtersData['release'] = {};
  12686. }
  12687. filtersData['release'][item.field] = item.filters[0].term;
  12688. }
  12689. }
  12690. });
  12691. $scope.loadData(filtersData);
  12692. });
  12693. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12694. $scope.selected.item = data.entity;
  12695. //console.log(data);
  12696. });
  12697. };
  12698. //资产
  12699. $scope.cmdb = {}
  12700. //资产状态
  12701. $scope.state_data = [{
  12702. "name": "全部状态",
  12703. "value": ""
  12704. },
  12705. {
  12706. "name": "在库",
  12707. "value": "1"
  12708. },
  12709. {
  12710. "name": "在线",
  12711. "value": "2"
  12712. },
  12713. {
  12714. "name": "借出",
  12715. "value": "3"
  12716. },
  12717. {
  12718. "name": "报修",
  12719. "value": "4"
  12720. },
  12721. {
  12722. "name": "报废",
  12723. "value": "5"
  12724. },
  12725. {
  12726. "name": "备用",
  12727. "value": "6"
  12728. },
  12729. ]
  12730. //资产类型
  12731. $scope.wt_zcfl = function () {
  12732. api_configure_data.fetchDataList('ciclassify', {
  12733. idx: 0,
  12734. sum: 100
  12735. }).then(function (data) {
  12736. console.log(data);
  12737. // $scope.wt_zclx = data.list;
  12738. console.log(data);
  12739. $scope.wtData = []
  12740. if (data.status == 200) {
  12741. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12742. var root = null; //Initially set our loop to null
  12743. var parentNode = null;
  12744. //loop over data
  12745. // $scope.wtData=data.list;
  12746. data = data.list;
  12747. //知识库分类数据三级处理
  12748. for (var i = 0; i < data.length; i++) {
  12749. // console.log(data[i])
  12750. var datum = data[i];
  12751. //each node will have children, so let's give it a "children" poperty
  12752. // console.log(datum);
  12753. datum.children = [];
  12754. if (!datum.parent) {
  12755. $scope.wtData.push(datum);
  12756. // console.log($scope.wtData)
  12757. } else {
  12758. if ($scope.wtData[0]) {
  12759. if ($scope.wtData[0].id == datum.parent.id) {
  12760. $scope.wtData[0].children.push(datum);
  12761. }
  12762. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  12763. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  12764. $scope.wtData[0].children[j].children.push(datum);
  12765. }
  12766. };
  12767. }
  12768. if ($scope.wtData[1]) {
  12769. if ($scope.wtData[1].id == datum.parent.id) {
  12770. $scope.wtData[1].children.push(datum);
  12771. }
  12772. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  12773. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  12774. $scope.wtData[1].children[j].children.push(datum);
  12775. }
  12776. };
  12777. }
  12778. if ($scope.wtData[2]) {
  12779. if ($scope.wtData[2].id == datum.parent.id) {
  12780. $scope.wtData[2].children.push(datum);
  12781. }
  12782. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  12783. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  12784. $scope.wtData[2].children[j].children.push(datum);
  12785. }
  12786. };
  12787. }
  12788. }
  12789. // console.log($scope.wtData)
  12790. idToNodeMap[datum.id] = datum;
  12791. root = datum;
  12792. // treeMap[datum.id] = root;
  12793. }
  12794. }
  12795. });
  12796. }
  12797. $scope.wt_zcfl();
  12798. //事件
  12799. //受理人,处理人
  12800. $scope.searchkeys = {};
  12801. var fieldata = {
  12802. "idx": 0,
  12803. "sum": 100,
  12804. "flag": -1
  12805. };
  12806. getUser(fieldata, 3);
  12807. function getUser(fieldatas, it) {
  12808. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  12809. if (it == 1) {
  12810. $scope.acceptUser = data.list;
  12811. } else if (it == 2) {
  12812. $scope.handlingPersonnelUser = data.list;
  12813. } else if (it == 3) {
  12814. $scope.acceptUser = data.list;
  12815. $scope.handlingPersonnelUser = data.list;
  12816. }
  12817. });
  12818. }
  12819. //状态
  12820. $scope.othcode = {};
  12821. api_bpm_data.fetchDataList('incidentstatus', {
  12822. "idx": 0,
  12823. "sum": 100
  12824. }).then(function (response) {
  12825. if (response) {
  12826. if (response.status = 200) {
  12827. $scope.state = response.list;
  12828. }
  12829. }
  12830. })
  12831. var defaultFilterData = {
  12832. "assignee": $rootScope.user.id,
  12833. "searchType": "todo",
  12834. "idx": 0,
  12835. "sum": mun
  12836. };
  12837. var defaultFilterData1 = {
  12838. // "searchType": "todo",
  12839. "idx": 0,
  12840. "sum": mun
  12841. };
  12842. //搜索
  12843. $scope.chiceIncident = function (parameters, item, stateid) {
  12844. console.log(item, stateid);
  12845. console.log($scope);
  12846. if ($scope.title == '关联资产编号') {
  12847. // alert('222222222222');
  12848. var fildata = defaultFilterData1;
  12849. $scope.gridOptions.paginationCurrentPage = 1;
  12850. var transitiondata = angular.copy(item);
  12851. angular.extend(fildata, transitiondata);
  12852. if (fildata.hw_state) {
  12853. fildata.hw_state = fildata.hw_state.name;
  12854. }
  12855. if (fildata.sign) {
  12856. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  12857. fildata.sign = fildata.sign.split(';');
  12858. fildata.sign = fildata.sign.join('');
  12859. fildata.sign = fildata.sign.toLowerCase()
  12860. }
  12861. if (fildata.keys) {
  12862. fildata['searchCriteria'] = 'uuid';
  12863. }
  12864. console.log(fildata);
  12865. $scope.loadData(fildata);
  12866. }
  12867. if ($scope.title == '关联事件工单') {
  12868. // alert('3333333333333333')
  12869. if (stateid && stateid.code) {
  12870. item.statusId = stateid.code;
  12871. }
  12872. var fildata = defaultFilterData;
  12873. // $scope.memoryfilterData = fildata;
  12874. if (!fildata.incident) {
  12875. fildata['incident'] = {};
  12876. }
  12877. $scope.gridOptions.paginationCurrentPage = 1;
  12878. var transitiondata = angular.copy(item);
  12879. angular.extend(fildata.incident, transitiondata);
  12880. console.log(fildata)
  12881. // $scope.loadData(fildata);
  12882. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  12883. console.log(data)
  12884. if (data) {
  12885. $scope.myData = data.list;
  12886. $scope.gridOptions.totalItems = data.totalNum;
  12887. }
  12888. })
  12889. }
  12890. }
  12891. //重置
  12892. $scope.replacement = function (parameters, searchkeys, othcode) {
  12893. // console.log(parameters, searchkeys, othcode);
  12894. delete (defaultFilterData.incident);
  12895. console.log(defaultFilterData)
  12896. $scope.parameters = null;
  12897. $scope.searchkeys = {};
  12898. $scope.othcode = {};
  12899. $scope.wt_zcfl();
  12900. }
  12901. $scope.loadData = function (filterData) {
  12902. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  12903. var myData = Restangular.stripRestangular(data);
  12904. if (myData.data && myData.data.node) {
  12905. $scope.gridOptions.totalItems = myData.total;
  12906. $scope.myData = myData.data.node;
  12907. } else {
  12908. if (myData.resultCount) {
  12909. $scope.gridOptions['totalItems'] = myData.resultCount;
  12910. } else {
  12911. $scope.gridOptions.totalItems = myData.totalNum;
  12912. }
  12913. if (myData.list) {
  12914. $scope.myData = myData.list;
  12915. } else {
  12916. $scope.myData = myData.data;
  12917. }
  12918. }
  12919. });
  12920. };
  12921. $scope.title = title;
  12922. $scope.loadData({
  12923. idx: 0,
  12924. sum: 10
  12925. });
  12926. $scope.selected = {
  12927. item: {}
  12928. };
  12929. $scope.ok = function () {
  12930. //console.log($scope.selected.item);
  12931. $modalInstance.close($scope.selected.item);
  12932. };
  12933. $scope.cancel = function () {
  12934. $modalInstance.dismiss('cancel');
  12935. };
  12936. },
  12937. size: size,
  12938. resolve: {
  12939. items: function () {
  12940. return {
  12941. fetchItems: function (filterData, APIService, $rootScope) {
  12942. filterData = filterData || {};
  12943. // if(!filterData.idx){
  12944. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12945. filterData = {
  12946. idx: 0,
  12947. sum: 10
  12948. };
  12949. }
  12950. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  12951. },
  12952. columnDefs: function () {
  12953. return options.templateOptions.columnDefs;
  12954. }
  12955. };
  12956. },
  12957. title: function () {
  12958. return options.templateOptions.modalTitle;
  12959. },
  12960. Restangular: function () {
  12961. return options.templateOptions.Restangular;
  12962. },
  12963. APIService: function () {
  12964. return options.templateOptions.ApiService;
  12965. }
  12966. }
  12967. });
  12968. modalInstance.result.then(function (selectedItem) {
  12969. var selectitem = {
  12970. title: selectedItem.title,
  12971. description: selectedItem.description
  12972. }
  12973. if (options.key == "chuku") {
  12974. if (selectedItem.assets) {
  12975. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  12976. }
  12977. if (selectedItem.consumables) {
  12978. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  12979. }
  12980. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  12981. options.value(selectedItem);
  12982. // options.model.consumables = JSON.parse(consumables);
  12983. } else if (options.templateOptions.pkey == "change") {
  12984. console.log(options)
  12985. angular.extend(options.model);
  12986. options.value(selectedItem);
  12987. } else if (options.key == "cmdbCode") {
  12988. var zc_selectitem = selectedItem.uuid;
  12989. // angular.extend(options.model,zc_selectitem);
  12990. options.model.cmdbCode = zc_selectitem;
  12991. // angular.extend(options.model,zc_selectitem);
  12992. // options.templateOptions.displayName=zc_selectitem;
  12993. options.value(selectedItem);
  12994. console.log(options.model)
  12995. } else {
  12996. angular.extend(options.model, selectitem);
  12997. options.value(selectedItem);
  12998. }
  12999. }, function () {
  13000. //console.log('Modal dismissed at: ' + new Date());
  13001. });
  13002. }
  13003. }
  13004. };
  13005. }
  13006. });
  13007. //选项选择控件
  13008. formlyConfigProvider.setType({
  13009. name: "ui-modelselect",
  13010. extends: 'input',
  13011. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  13012. defaultOptions: function (options) {
  13013. return {
  13014. templateOptions: {
  13015. openModal: function (size, options, modal) {
  13016. var modalInstance = modal.open({
  13017. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  13018. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  13019. $scope.langs = i18nService.getAllLangs();
  13020. $scope.lang = 'zh-cn';
  13021. i18nService.setCurrentLang($scope.lang);
  13022. $scope.gridOptions = {};
  13023. $scope.gridOptions.data = 'myData';
  13024. $scope.gridOptions.enableColumnResizing = true;
  13025. $scope.gridOptions.enableFiltering = true;
  13026. $scope.gridOptions.enableGridMenu = false;
  13027. $scope.gridOptions.enableRowSelection = true;
  13028. $scope.gridOptions.showGridFooter = true;
  13029. $scope.gridOptions.showColumnFooter = true;
  13030. $scope.gridOptions.fastWatch = true;
  13031. $scope.gridOptions.useExternalFiltering = true;
  13032. $scope.gridOptions.useExternalPagination = true;
  13033. $scope.gridOptions.paginationPageSizes = [10];
  13034. $scope.gridOptions.paginationPageSize = 10;
  13035. $scope.gridOptions.multiSelect = false;
  13036. $scope.gridOptions.rowIdentity = function (row) {
  13037. return row.id;
  13038. };
  13039. $scope.gridOptions.getRowIdentity = function (row) {
  13040. return row.id;
  13041. };
  13042. $scope.gridOptions.columnDefs = items.columnDefs();
  13043. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13044. $scope.gridApi = gridApi;
  13045. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  13046. // console.log(newPage);
  13047. // console.log(pageSize);
  13048. $scope.loadData({
  13049. "idx": newPage - 1,
  13050. "sum": pageSize
  13051. });
  13052. });
  13053. gridApi.core.on.filterChanged($scope, function () {
  13054. var grid = this.grid;
  13055. var filtersData = {
  13056. idx: 0,
  13057. sum: 10
  13058. };
  13059. angular.forEach(grid.columns, function (item) {
  13060. if (item.enableFiltering) {
  13061. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  13062. // console.log("filtersData="+JSON.stringify(filtersData))
  13063. if (angular.isUndefined(filtersData['incident'])) {
  13064. filtersData['incident'] = {};
  13065. }
  13066. filtersData['incident'][item.field] = item.filters[0].term;
  13067. if (angular.isUndefined(filtersData['problem'])) {
  13068. filtersData['problem'] = {};
  13069. }
  13070. filtersData['problem'][item.field] = item.filters[0].term;
  13071. if (angular.isUndefined(filtersData['change'])) {
  13072. filtersData['change'] = {};
  13073. }
  13074. filtersData['change'][item.field] = item.filters[0].term;
  13075. if (angular.isUndefined(filtersData['release'])) {
  13076. filtersData['release'] = {};
  13077. }
  13078. filtersData['release'][item.field] = item.filters[0].term;
  13079. }
  13080. }
  13081. });
  13082. $scope.loadData(filtersData);
  13083. });
  13084. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13085. $scope.selected.item = data.entity;
  13086. //console.log(data);
  13087. });
  13088. };
  13089. $scope.loadData = function (filterData) {
  13090. items.fetchItems(filterData, APIService).then(function (data) {
  13091. var myData = Restangular.stripRestangular(data);
  13092. $scope.gridOptions.totalItems = myData.totalNum;
  13093. $scope.myData = myData.list;
  13094. });
  13095. };
  13096. $scope.title = title;
  13097. $scope.loadData({
  13098. idx: 0,
  13099. sum: 10
  13100. });
  13101. $scope.selected = {
  13102. item: {}
  13103. };
  13104. $scope.ok = function () {
  13105. if ($scope.selected.item.scheduleOrder) {
  13106. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  13107. }
  13108. //console.log($scope.selected.item);
  13109. $modalInstance.close($scope.selected.item);
  13110. };
  13111. $scope.cancel = function () {
  13112. $modalInstance.dismiss('cancel');
  13113. };
  13114. },
  13115. size: size,
  13116. resolve: {
  13117. items: function () {
  13118. return {
  13119. fetchItems: function (filterData, APIService) {
  13120. filterData = filterData || {};
  13121. // if(!filterData.idx){
  13122. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  13123. filterData = {
  13124. idx: 0,
  13125. sum: 10
  13126. };
  13127. }
  13128. return options.templateOptions.fetchItems(filterData, APIService, options);
  13129. },
  13130. columnDefs: function () {
  13131. return options.templateOptions.columnDefs;
  13132. }
  13133. };
  13134. },
  13135. title: function () {
  13136. return options.templateOptions.modalTitle;
  13137. },
  13138. Restangular: function () {
  13139. return options.templateOptions.Restangular;
  13140. },
  13141. APIService: function () {
  13142. return options.templateOptions.ApiService;
  13143. }
  13144. }
  13145. });
  13146. modalInstance.result.then(function (selectedItem) {
  13147. options.value(selectedItem);
  13148. }, function () {
  13149. //console.log('Modal dismissed at: ' + new Date());
  13150. });
  13151. }
  13152. }
  13153. };
  13154. }
  13155. });
  13156. formlyConfigProvider.setType({
  13157. name: 'ui-requestform',
  13158. extends: 'input',
  13159. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  13160. controller: ['$scope', function ($scope) {
  13161. setTimeout(function () {
  13162. var filterData = {
  13163. "idx": 0,
  13164. "sum": 5,
  13165. "incident": {
  13166. "requester": {
  13167. "id": ""
  13168. }
  13169. }
  13170. }
  13171. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  13172. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13173. });
  13174. }, 1000);
  13175. }]
  13176. });
  13177. //报修图片展示
  13178. formlyConfigProvider.setType({
  13179. name: 'ui-repair-photos',
  13180. // extends: 'label',
  13181. templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
  13182. controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
  13183. console.log($scope);
  13184. $scope.fileUrls = [];
  13185. if ($scope.model.wxFile) {
  13186. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
  13187. $scope.fileUrls = res.data
  13188. })
  13189. }
  13190. console.log($stateParams);
  13191. if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
  13192. api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
  13193. $scope.fileUrls = res.data
  13194. })
  13195. }
  13196. if ($scope.model.flow) {
  13197. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
  13198. $scope.fileUrls = res.data
  13199. })
  13200. }
  13201. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13202. // // setTimeout(function () {
  13203. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13204. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13205. // // if (modelData.status == 200) {
  13206. // // $scope.model[$scope.options.key] = modelData.data;
  13207. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  13208. // // }
  13209. // // });
  13210. // // }, 1000);
  13211. // }
  13212. $scope.showBigImg = false;
  13213. $scope.showBigImgCli = function (data) {
  13214. $scope.showBigImg = true;
  13215. $scope.bigImgUrl = data
  13216. }
  13217. $scope.closeBigImg = function () {
  13218. $scope.showBigImg = false
  13219. }
  13220. }]
  13221. });
  13222. //图片展示
  13223. formlyConfigProvider.setType({
  13224. name: 'ui-showImgs',
  13225. templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
  13226. defaultOptions: function (options) {
  13227. return {
  13228. templateOptions: {
  13229. refresh: function (APIService, processInstanceId, data) {
  13230. return APIService.listAttachments(processInstanceId);
  13231. },
  13232. downloadUri: function (APIService, contentId) {
  13233. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13234. },
  13235. view: function (APIService, contentId) {
  13236. return APIService.attachmentsPreviewUrl(contentId);
  13237. },
  13238. download: function (APIService, contentId, item) {
  13239. var item = {
  13240. 'url': APIService.download(contentId),
  13241. 'headers': headers
  13242. };
  13243. return item;
  13244. },
  13245. refreshDelay: 0
  13246. }
  13247. };
  13248. },
  13249. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13250. var _refreshDelayPromise;
  13251. /**
  13252. * refresh
  13253. */
  13254. $scope._refresh = function (refreshAttr) {
  13255. $scope.attachments = [];
  13256. if (refreshAttr !== undefined) {
  13257. if (_refreshDelayPromise) {
  13258. $timeout.cancel(_refreshDelayPromise);
  13259. }
  13260. _refreshDelayPromise = $timeout(function () {
  13261. // 暂存附件
  13262. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13263. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13264. $scope.options.templateOptions.processInstanceId, {
  13265. 'idx': 0,
  13266. 'sum': 1000
  13267. }).then(function (response) {
  13268. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13269. if (myData) {
  13270. for (var i = 0; i < myData.data.length; i++) {
  13271. $scope.attachments.push(myData.data[i]);
  13272. }
  13273. };
  13274. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13275. $scope.$parent.$parent.$parent.model.save_fileId, {
  13276. 'idx': 0,
  13277. 'sum': 1000
  13278. }).then(function (response2) {
  13279. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13280. if (myData2) {
  13281. for (var i = 0; i < myData2.data.length; i++) {
  13282. $scope.attachments.push(myData2.data[i]);
  13283. }
  13284. };
  13285. console.log($scope.attachments)
  13286. });
  13287. });
  13288. // 正常附件
  13289. } else {
  13290. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13291. $scope.options.templateOptions.processInstanceId, {
  13292. 'idx': 0,
  13293. 'sum': 1000
  13294. }).then(function (response) {
  13295. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13296. if (myData) {
  13297. $scope.attachments = [];
  13298. $scope.imgs = []
  13299. myData.data.forEach(e => {
  13300. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13301. $scope.imgs.push(e)
  13302. }
  13303. })
  13304. $scope.imgs = $scope.imgs.splice(0, 3);
  13305. console.log($scope.imgs)
  13306. }
  13307. });
  13308. }
  13309. }, $scope.options.templateOptions.refreshDelay);
  13310. }
  13311. }
  13312. $scope._refresh({});
  13313. // $scope.attachments = $scope.model[$scope.options.key]
  13314. // 预览
  13315. $scope.preview = function (url, idx) {
  13316. var title = $scope.imgs[idx].title
  13317. $modal.open({
  13318. backdrop: false,
  13319. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13320. controller: function ($scope, scope, $modalInstance) {
  13321. $scope.title = title;
  13322. $scope.imageurl = url;
  13323. $scope.cancel = function () {
  13324. $modalInstance.dismiss('cancel');
  13325. }
  13326. },
  13327. resolve: {
  13328. scope: function () {
  13329. return $scope;
  13330. }
  13331. }
  13332. });
  13333. }
  13334. }]
  13335. });
  13336. //工单/受理人控件
  13337. formlyConfigProvider.setType({
  13338. name: 'ui-workernumbersign',
  13339. // extends: 'label',
  13340. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  13341. controller: ['$scope', function ($scope) {
  13342. // 2020年4月24日13:20:40
  13343. console.log($scope,'docu');
  13344. // 左侧事件工单区域地点填充
  13345. $scope.model.selecthouseNumber = $scope.model.place;
  13346. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13347. setTimeout(function () {
  13348. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13349. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13350. if (modelData.status == 200) {
  13351. $scope.model[$scope.options.key] = modelData.data;
  13352. $scope.options.initialValue = $scope.model[$scope.options.key];
  13353. }
  13354. });
  13355. }, 1000);
  13356. }
  13357. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  13358. if (angular.isFunction($scope.options.templateOptions.transform)) {
  13359. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  13360. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  13361. // }
  13362. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13363. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13364. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  13365. }
  13366. $scope.model.acceptUser = $scope.options.templateOptions.user;
  13367. // $scope.options.initialValue = $scope.model.acceptUser;
  13368. }
  13369. }]
  13370. });
  13371. //工单控件-only number
  13372. formlyConfigProvider.setType({
  13373. name: 'ui-workernumber',
  13374. extends: 'input',
  13375. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13376. controller: ['$scope', function ($scope) {
  13377. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13378. setTimeout(function () {
  13379. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13380. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13381. if (modelData.status == 200) {
  13382. $scope.model[$scope.options.key] = modelData.data;
  13383. $scope.options.initialValue = $scope.model[$scope.options.key];
  13384. }
  13385. });
  13386. }, 1000);
  13387. }
  13388. }]
  13389. });
  13390. //cmdb工单
  13391. formlyConfigProvider.setType({
  13392. name: 'ui-cmdbworkernumber',
  13393. extends: 'input',
  13394. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13395. controller: ['$scope', function ($scope) {
  13396. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13397. setTimeout(function () {
  13398. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  13399. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13400. // if(modelData.status==200){
  13401. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  13402. $scope.options.initialValue = $scope.model[$scope.options.key];
  13403. // }
  13404. });
  13405. }, 1000);
  13406. }
  13407. }]
  13408. });
  13409. //简易上传图片组件
  13410. formlyConfigProvider.setType({
  13411. name: 'ui-uploadImgs',
  13412. templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
  13413. wrapper: ['bootstrapHasError'],
  13414. controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
  13415. $scope.imgshows = [];
  13416. $scope.uploadimgs = [];
  13417. var model = $parse('upload_img');
  13418. var modelSetter = model.assign;
  13419. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13420. uploader.filters.push({
  13421. name: 'customFilter',
  13422. fn: function (item /*{File|FileLikeObject}*/, options) {
  13423. return this.queue.length < 10;
  13424. }
  13425. });
  13426. // 添加
  13427. $scope.change = function (event) {
  13428. var element = $('.upinp')
  13429. modelSetter($scope, element[0].files[0]);
  13430. //附件预览
  13431. $scope.imgupload = event.files[0];
  13432. getFile($scope.imgupload, $scope);
  13433. //获得预览图地址并且把file对象放入上传合集内
  13434. function getFile(imgupload, $scope) {
  13435. if (!imgupload) {
  13436. return;
  13437. }
  13438. fileReader.readAsDataUrl(imgupload, $scope)
  13439. .then(function (result) {
  13440. $scope.imgshows.push(result)
  13441. var file = document.querySelector('input[type=file]').files[0];
  13442. $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
  13443. console.log($scope.imgshows, $scope.uploadimgs)
  13444. if ($scope.imgshows.length < 3) {
  13445. $('#upup').show()
  13446. } else {
  13447. $('#upup').hide()
  13448. }
  13449. });
  13450. };
  13451. }
  13452. // 删除
  13453. $scope.uploadimg_del = function (index, imgs) {
  13454. console.log(index, imgs)
  13455. $scope.imgshows.splice(index, 1);
  13456. $scope.uploadimgs.splice(index, 1);
  13457. if ($scope.imgshows.length < 3) {
  13458. $('#upup').show()
  13459. } else {
  13460. $('#upup').hide()
  13461. }
  13462. }
  13463. // 预览
  13464. $scope.preview = function (url, idx) {
  13465. var name = $scope.uploadimgs[idx].name
  13466. $modal.open({
  13467. backdrop: false,
  13468. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13469. controller: function ($scope, scope, $modalInstance) {
  13470. $scope.title = name;
  13471. $scope.imageurl = url;
  13472. $scope.cancel = function () {
  13473. $modalInstance.dismiss('cancel');
  13474. }
  13475. },
  13476. resolve: {
  13477. scope: function () {
  13478. return $scope;
  13479. }
  13480. }
  13481. });
  13482. }
  13483. if (uploader) {
  13484. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13485. console.info('onWhenAddingFileFailed', item, filter, options);
  13486. };
  13487. uploader.onAfterAddingFile = function (fileItem) {
  13488. console.info('onAfterAddingFile', fileItem);
  13489. };
  13490. uploader.onAfterAddingAll = function (addedFileItems) {
  13491. console.info('onAfterAddingAll', addedFileItems);
  13492. };
  13493. uploader.onBeforeUploadItem = function (item) {
  13494. console.info('onBeforeUploadItem', item);
  13495. };
  13496. uploader.onProgressItem = function (fileItem, progress) {
  13497. console.info('onProgressItem', fileItem, progress);
  13498. };
  13499. uploader.onProgressAll = function (progress) {
  13500. console.info('onProgressAll', progress);
  13501. };
  13502. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13503. console.info('onSuccessItem', fileItem, response, status, headers);
  13504. };
  13505. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13506. console.info('onErrorItem', fileItem, response, status, headers);
  13507. };
  13508. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13509. console.info('onCancelItem', fileItem, response, status, headers);
  13510. };
  13511. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13512. console.info('onCompleteItem', fileItem, response, status, headers);
  13513. };
  13514. uploader.onCompleteAll = function () {
  13515. console.info('onCompleteAll');
  13516. };
  13517. }
  13518. // console.log(modelSetter)
  13519. }]
  13520. });
  13521. //jry-上传下载一体
  13522. formlyConfigProvider.setType({
  13523. name: 'ui-upDropFile',
  13524. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  13525. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13526. defaultOptions: function (options) {
  13527. return {
  13528. templateOptions: {
  13529. view: function (APIService, contentId) {
  13530. return APIService.downloadAttachment(contentId);
  13531. },
  13532. // ApiService: 'api_wechatfile',
  13533. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  13534. // upUrl: 'common/common/uploadAttachment',
  13535. // listAttachmentUrl: 'common/common/listAttachment',
  13536. // downUrl: 'common/common/downloadAttachment',
  13537. // bindType: 'incident',
  13538. // bindId: 2323
  13539. },
  13540. // validators: {
  13541. // required: {
  13542. // expression: function(viewValue, modelValue) {
  13543. // var value = modelValue || viewValue;
  13544. // return value.length >= 1;
  13545. // }
  13546. // }
  13547. // }
  13548. };
  13549. },
  13550. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  13551. console.log($scope);
  13552. $scope.showFileUp = true;
  13553. if ($scope.model.isKnowledge_detail) {
  13554. $scope.showFileUp = false;
  13555. }
  13556. if (angular.isUndefined($scope.form.dropState)) {
  13557. $scope.form.dropState = false;
  13558. }
  13559. if ($scope.model.incident) {
  13560. if ($scope.model.incident.alarm) {
  13561. console.log($scope)
  13562. if ($scope.model.incident.alarm) {
  13563. if ($scope.model.incident.alarm.alarmExtension) {
  13564. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  13565. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  13566. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  13567. console.log($scope.model.incident.description)
  13568. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  13569. } else {
  13570. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  13571. }
  13572. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  13573. console.log($scope.model.incident.description)
  13574. };
  13575. }
  13576. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  13577. console.log(wt_data);
  13578. if (wt_data) {
  13579. $rootScope.wt_category = wt_data.data;
  13580. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  13581. $rootScope.wt_child = wt_data.child
  13582. }
  13583. })
  13584. if ($scope.model.titleName == '接单') {
  13585. $scope.model.receive_code = 'handler'
  13586. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  13587. $scope.model.isHandlerUser = true;
  13588. }
  13589. }
  13590. if ($scope.model.titleName == '事件处理') {
  13591. console.log($scope.model.cmdbCode)
  13592. if ($scope.model.cmdbCode) {
  13593. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  13594. }
  13595. }
  13596. } else {
  13597. $rootScope.wt_category = '';
  13598. }
  13599. //附件上传数据
  13600. if ($scope.options.templateOptions.fileUploader) {
  13601. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13602. //$scope.options.templateOptions.uploader();
  13603. console.log(uploader)
  13604. // FILTERS
  13605. uploader.filters.push({
  13606. name: 'customFilter',
  13607. fn: function (item /*{File|FileLikeObject}*/, options) {
  13608. return this.queue.length < 10;
  13609. }
  13610. });
  13611. }
  13612. var to = $scope.options.templateOptions;
  13613. // var bindType = $scope.model.bindType;
  13614. if (to.bindType == 'incident') {
  13615. var bindId = $scope.model[to.bindType].processInstanceId;
  13616. } else if (to.bindType == 'change') {
  13617. var bindId = $scope.model[to.bindType].processInstanceId;
  13618. } else {
  13619. var bindId = $scope.model[to.bindType].id;
  13620. }
  13621. //获取附件列表
  13622. $scope.listAttachmen = function () {
  13623. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  13624. var myData = Restangular.stripRestangular(result);
  13625. // $scope.listAttachmens = myData;
  13626. $scope.attachments = myData.data;
  13627. });
  13628. };
  13629. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  13630. $scope.listAttachmen();
  13631. } else if (to.bindType && $scope.model[to.bindType].id) {
  13632. $scope.listAttachmen();
  13633. }
  13634. //附件上传
  13635. $scope.isUpfload = to.isUpfload;
  13636. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13637. uploader.onBeforeUploadItem = function (item) {
  13638. angular.extend(item.headers, $rootScope.getSession());
  13639. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  13640. item.formData.push({
  13641. 'filename': item.file.name
  13642. });
  13643. };
  13644. uploader.uploadAll();
  13645. }
  13646. //附件下载
  13647. $scope.download = function (token, filename) {
  13648. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  13649. // window.open(downUrl);
  13650. var a = document.createElement('a');
  13651. a.href = downUrl;
  13652. a.target = '_blank';
  13653. a.download = filename;
  13654. document.body.appendChild(a);
  13655. a.click();
  13656. };
  13657. //附件预览
  13658. $scope.view = function (id, previewUrl) {
  13659. if (previewUrl) {
  13660. window.open(previewUrl);
  13661. }
  13662. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  13663. // if (response.state == 200) {
  13664. // window.open(response.previewUrl);
  13665. // }
  13666. // })
  13667. };
  13668. // CALLBACKS
  13669. if (uploader) {
  13670. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13671. console.info('onWhenAddingFileFailed', item, filter, options);
  13672. };
  13673. uploader.onAfterAddingFile = function (fileItem) {
  13674. console.info('onAfterAddingFile', fileItem);
  13675. };
  13676. uploader.onAfterAddingAll = function (addedFileItems) {
  13677. console.info('onAfterAddingAll', addedFileItems);
  13678. };
  13679. uploader.onBeforeUploadItem = function (item) {
  13680. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13681. // // $scope.uploader.options.url();
  13682. // $scope.uploader.onBeforeUploadItem = function(item) {
  13683. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13684. // console.info('onBeforeUploadItem', item);
  13685. // };
  13686. // $scope.uploader.uploadAll();
  13687. // }
  13688. console.info('onBeforeUploadItem', item);
  13689. };
  13690. uploader.onProgressItem = function (fileItem, progress) {
  13691. console.info('onProgressItem', fileItem, progress);
  13692. };
  13693. uploader.onProgressAll = function (progress) {
  13694. console.info('onProgressAll', progress);
  13695. };
  13696. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13697. console.info('onSuccessItem', fileItem, response, status, headers);
  13698. if (response.status == 200) {
  13699. $scope.listAttachmen();
  13700. }
  13701. };
  13702. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13703. console.info('onErrorItem', fileItem, response, status, headers);
  13704. };
  13705. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13706. console.info('onCancelItem', fileItem, response, status, headers);
  13707. };
  13708. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13709. console.info('onCompleteItem', fileItem, response, status, headers);
  13710. };
  13711. uploader.onCompleteAll = function () {
  13712. console.info('onCompleteAll');
  13713. };
  13714. }
  13715. }]
  13716. });
  13717. //简易上传下载附件组件
  13718. formlyConfigProvider.setType({
  13719. name: 'ui-upDownFiles',
  13720. templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
  13721. wrapper: ['bootstrapHasError'],
  13722. defaultOptions: function (options) {
  13723. return {
  13724. templateOptions: {
  13725. refresh: function (APIService, processInstanceId, data) {
  13726. return APIService.listAttachments(processInstanceId);
  13727. },
  13728. downloadUri: function (APIService, contentId) {
  13729. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13730. },
  13731. view: function (APIService, contentId) {
  13732. return APIService.attachmentsPreviewUrl(contentId);
  13733. },
  13734. download: function (APIService, contentId, item) {
  13735. var item = {
  13736. 'url': APIService.download(contentId),
  13737. 'headers': headers
  13738. };
  13739. return item;
  13740. },
  13741. refreshDelay: 0
  13742. }
  13743. };
  13744. },
  13745. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13746. if (angular.isUndefined($scope.form.dropState)) {
  13747. $scope.form.dropState = false;
  13748. }
  13749. //附件上传数据
  13750. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13751. //$scope.options.templateOptions.uploader();
  13752. // FILTERS
  13753. uploader.filters.push({
  13754. name: 'customFilter',
  13755. fn: function (item /*{File|FileLikeObject}*/, options) {
  13756. return this.queue.length < 10;
  13757. }
  13758. });
  13759. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13760. // uploader.onBeforeUploadItem = function (item) {
  13761. // angular.extend(item.headers, $rootScope.getSession());
  13762. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13763. // item.formData.push({
  13764. // 'fileName': item.file.name
  13765. // });
  13766. // console.info('onBeforeUploadItem', item);
  13767. // };
  13768. // }
  13769. // CALLBACKS
  13770. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13771. console.info('onWhenAddingFileFailed', item, filter, options);
  13772. };
  13773. uploader.onAfterAddingFile = function (fileItem) {
  13774. console.info('onAfterAddingFile', fileItem);
  13775. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13776. alert('文件过大');
  13777. fileItem.uploader.queue.pop()
  13778. console.log($scope);
  13779. }
  13780. };
  13781. uploader.onAfterAddingAll = function (addedFileItems) {
  13782. // console.info('onAfterAddingAll', addedFileItems);
  13783. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13784. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13785. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13786. // console.log(123)
  13787. };
  13788. uploader.onBeforeUploadItem = function (item) {
  13789. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13790. // // $scope.uploader.options.url();
  13791. // $scope.uploader.onBeforeUploadItem = function(item) {
  13792. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13793. // console.info('onBeforeUploadItem', item);
  13794. // };
  13795. // $scope.uploader.uploadAll();
  13796. // }
  13797. console.info('onBeforeUploadItem', item);
  13798. };
  13799. uploader.onProgressItem = function (fileItem, progress) {
  13800. console.info('onProgressItem', fileItem, progress);
  13801. };
  13802. uploader.onProgressAll = function (progress) {
  13803. console.info('onProgressAll', progress);
  13804. };
  13805. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13806. console.info('onSuccessItem', fileItem, response, status, headers);
  13807. };
  13808. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13809. console.info('onErrorItem', fileItem, response, status, headers);
  13810. };
  13811. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13812. console.info('onCancelItem', fileItem, response, status, headers);
  13813. };
  13814. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13815. console.info('onCompleteItem', fileItem, response, status, headers);
  13816. };
  13817. uploader.onCompleteAll = function () {
  13818. console.info('onCompleteAll');
  13819. };
  13820. var _refreshDelayPromise;
  13821. // 下载
  13822. $scope.download = function (contentId, filename, token) {
  13823. // console.log(contentId, filename, token)
  13824. //附件下载
  13825. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  13826. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  13827. // console.log(downUrl)
  13828. var a = document.createElement('a');
  13829. a.href = downUrl;
  13830. a.target = '_blank';
  13831. a.download = filename;
  13832. document.body.appendChild(a);
  13833. a.click();
  13834. };
  13835. $scope._refresh = function (refreshAttr) {
  13836. $scope.attachments = [];
  13837. if (refreshAttr !== undefined) {
  13838. if (_refreshDelayPromise) {
  13839. $timeout.cancel(_refreshDelayPromise);
  13840. }
  13841. _refreshDelayPromise = $timeout(function () {
  13842. // 暂存附件
  13843. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13844. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13845. $scope.options.templateOptions.processInstanceId, {
  13846. 'idx': 0,
  13847. 'sum': 1000
  13848. }).then(function (response) {
  13849. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13850. if (myData) {
  13851. for (var i = 0; i < myData.data.length; i++) {
  13852. $scope.attachments.push(myData.data[i]);
  13853. }
  13854. };
  13855. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13856. $scope.$parent.$parent.$parent.model.save_fileId, {
  13857. 'idx': 0,
  13858. 'sum': 1000
  13859. }).then(function (response2) {
  13860. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13861. if (myData2) {
  13862. for (var i = 0; i < myData2.data.length; i++) {
  13863. $scope.attachments.push(myData2.data[i]);
  13864. }
  13865. // 只展示除图片以外的附件
  13866. var a = [];
  13867. $scope.attachments.forEach(e => {
  13868. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13869. // $scope.imgs.push(e)
  13870. } else {
  13871. a.push(e)
  13872. }
  13873. })
  13874. $scope.attachments = a;
  13875. };
  13876. console.log($scope.attachments)
  13877. });
  13878. });
  13879. // 正常附件
  13880. } else {
  13881. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13882. $scope.options.templateOptions.processInstanceId, {
  13883. 'idx': 0,
  13884. 'sum': 1000
  13885. }).then(function (response) {
  13886. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13887. if (myData) {
  13888. $scope.attachments = myData.data;
  13889. // 只展示除图片以外的附件
  13890. var a = [];
  13891. $scope.attachments.forEach(e => {
  13892. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13893. // $scope.imgs.push(e)
  13894. } else {
  13895. a.push(e)
  13896. }
  13897. })
  13898. $scope.attachments = a;
  13899. }
  13900. });
  13901. }
  13902. }, $scope.options.templateOptions.refreshDelay);
  13903. }
  13904. }
  13905. $scope._refresh({});
  13906. }]
  13907. });
  13908. //简易上传附件组件
  13909. formlyConfigProvider.setType({
  13910. name: 'ui-uploadFiles',
  13911. templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
  13912. wrapper: ['bootstrapHasError'],
  13913. controller: ['$scope', function ($scope) {
  13914. if (angular.isUndefined($scope.form.dropState)) {
  13915. $scope.form.dropState = false;
  13916. }
  13917. //附件上传数据
  13918. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13919. //$scope.options.templateOptions.uploader();
  13920. // FILTERS
  13921. uploader.filters.push({
  13922. name: 'customFilter',
  13923. fn: function (item /*{File|FileLikeObject}*/, options) {
  13924. return this.queue.length < 10;
  13925. }
  13926. });
  13927. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13928. uploader.onBeforeUploadItem = function (item) {
  13929. angular.extend(item.headers, $rootScope.getSession());
  13930. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13931. item.formData.push({
  13932. 'fileName': item.file.name
  13933. });
  13934. console.info('onBeforeUploadItem', item);
  13935. };
  13936. }
  13937. // CALLBACKS
  13938. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13939. console.info('onWhenAddingFileFailed', item, filter, options);
  13940. };
  13941. uploader.onAfterAddingFile = function (fileItem) {
  13942. console.info('onAfterAddingFile', fileItem);
  13943. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13944. alert('文件过大');
  13945. fileItem.uploader.queue.pop()
  13946. console.log($scope);
  13947. }
  13948. };
  13949. uploader.onAfterAddingAll = function (addedFileItems) {
  13950. // console.info('onAfterAddingAll', addedFileItems);
  13951. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13952. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13953. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13954. // console.log(123)
  13955. };
  13956. uploader.onBeforeUploadItem = function (item) {
  13957. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13958. // // $scope.uploader.options.url();
  13959. // $scope.uploader.onBeforeUploadItem = function(item) {
  13960. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13961. // console.info('onBeforeUploadItem', item);
  13962. // };
  13963. // $scope.uploader.uploadAll();
  13964. // }
  13965. console.info('onBeforeUploadItem', item);
  13966. };
  13967. uploader.onProgressItem = function (fileItem, progress) {
  13968. console.info('onProgressItem', fileItem, progress);
  13969. };
  13970. uploader.onProgressAll = function (progress) {
  13971. console.info('onProgressAll', progress);
  13972. };
  13973. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13974. console.info('onSuccessItem', fileItem, response, status, headers);
  13975. };
  13976. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13977. console.info('onErrorItem', fileItem, response, status, headers);
  13978. };
  13979. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13980. console.info('onCancelItem', fileItem, response, status, headers);
  13981. };
  13982. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13983. console.info('onCompleteItem', fileItem, response, status, headers);
  13984. };
  13985. uploader.onCompleteAll = function () {
  13986. console.info('onCompleteAll');
  13987. };
  13988. }]
  13989. });
  13990. //无上传按钮附件上传组件
  13991. formlyConfigProvider.setType({
  13992. name: 'ui-dropfilenotup',
  13993. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  13994. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13995. controller: ['$scope', function ($scope) {
  13996. if (angular.isUndefined($scope.form.dropState)) {
  13997. $scope.form.dropState = false;
  13998. }
  13999. //附件上传数据
  14000. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14001. //$scope.options.templateOptions.uploader();
  14002. // FILTERS
  14003. uploader.filters.push({
  14004. name: 'customFilter',
  14005. fn: function (item /*{File|FileLikeObject}*/, options) {
  14006. return this.queue.length < 10;
  14007. }
  14008. });
  14009. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14010. uploader.onBeforeUploadItem = function (item) {
  14011. angular.extend(item.headers, $rootScope.getSession());
  14012. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14013. item.formData.push({
  14014. 'fileName': item.file.name
  14015. });
  14016. console.info('onBeforeUploadItem', item);
  14017. };
  14018. uploader.uploadAll();
  14019. }
  14020. // CALLBACKS
  14021. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14022. console.info('onWhenAddingFileFailed', item, filter, options);
  14023. };
  14024. uploader.onAfterAddingFile = function (fileItem) {
  14025. console.info('onAfterAddingFile', fileItem);
  14026. };
  14027. uploader.onAfterAddingAll = function (addedFileItems) {
  14028. console.info('onAfterAddingAll', addedFileItems);
  14029. };
  14030. uploader.onBeforeUploadItem = function (item) {
  14031. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14032. // // $scope.uploader.options.url();
  14033. // $scope.uploader.onBeforeUploadItem = function(item) {
  14034. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14035. // console.info('onBeforeUploadItem', item);
  14036. // };
  14037. // $scope.uploader.uploadAll();
  14038. // }
  14039. console.info('onBeforeUploadItem', item);
  14040. };
  14041. uploader.onProgressItem = function (fileItem, progress) {
  14042. console.info('onProgressItem', fileItem, progress);
  14043. };
  14044. uploader.onProgressAll = function (progress) {
  14045. console.info('onProgressAll', progress);
  14046. };
  14047. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14048. console.info('onSuccessItem', fileItem, response, status, headers);
  14049. };
  14050. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14051. console.info('onErrorItem', fileItem, response, status, headers);
  14052. };
  14053. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14054. console.info('onCancelItem', fileItem, response, status, headers);
  14055. };
  14056. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14057. console.info('onCompleteItem', fileItem, response, status, headers);
  14058. };
  14059. uploader.onCompleteAll = function () {
  14060. console.info('onCompleteAll');
  14061. };
  14062. }]
  14063. });
  14064. //无按钮知识库上传
  14065. formlyConfigProvider.setType({
  14066. name: 'ui-dropfielkn',
  14067. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14068. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14069. controller: ['$scope', function ($scope) {
  14070. if (angular.isUndefined($scope.form.dropState)) {
  14071. $scope.form.dropState = false;
  14072. }
  14073. //附件上传数据
  14074. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14075. //$scope.options.templateOptions.uploader();
  14076. // FILTERS
  14077. uploader.filters.push({
  14078. name: 'customFilter',
  14079. fn: function (item /*{File|FileLikeObject}*/, options) {
  14080. return this.queue.length < 10;
  14081. }
  14082. });
  14083. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14084. uploader.onBeforeUploadItem = function (item) {
  14085. angular.extend(item.headers, $rootScope.getSession());
  14086. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  14087. item.formData.push({
  14088. 'fileName': item.file.name
  14089. });
  14090. console.info('onBeforeUploadItem', item);
  14091. };
  14092. uploader.uploadAll();
  14093. }
  14094. // CALLBACKS
  14095. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14096. console.info('onWhenAddingFileFailed', item, filter, options);
  14097. };
  14098. uploader.onAfterAddingFile = function (fileItem) {
  14099. console.info('onAfterAddingFile', fileItem);
  14100. };
  14101. uploader.onAfterAddingAll = function (addedFileItems) {
  14102. console.info('onAfterAddingAll', addedFileItems);
  14103. };
  14104. uploader.onBeforeUploadItem = function (item) {
  14105. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14106. // // $scope.uploader.options.url();
  14107. // $scope.uploader.onBeforeUploadItem = function(item) {
  14108. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14109. // console.info('onBeforeUploadItem', item);
  14110. // };
  14111. // $scope.uploader.uploadAll();
  14112. // }
  14113. console.info('onBeforeUploadItem', item);
  14114. };
  14115. uploader.onProgressItem = function (fileItem, progress) {
  14116. console.info('onProgressItem', fileItem, progress);
  14117. };
  14118. uploader.onProgressAll = function (progress) {
  14119. console.info('onProgressAll', progress);
  14120. };
  14121. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14122. console.info('onSuccessItem', fileItem, response, status, headers);
  14123. };
  14124. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14125. console.info('onErrorItem', fileItem, response, status, headers);
  14126. };
  14127. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14128. console.info('onCancelItem', fileItem, response, status, headers);
  14129. };
  14130. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14131. console.info('onCompleteItem', fileItem, response, status, headers);
  14132. };
  14133. uploader.onCompleteAll = function () {
  14134. console.info('onCompleteAll');
  14135. };
  14136. }]
  14137. });
  14138. //附件上传列表组件
  14139. formlyConfigProvider.setType({
  14140. name: 'ui-dropfile',
  14141. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14142. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14143. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14144. if (angular.isUndefined($scope.form.dropState)) {
  14145. $scope.form.dropState = false;
  14146. }
  14147. //附件上传数据
  14148. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14149. //$scope.options.templateOptions.uploader();
  14150. // FILTERS
  14151. uploader.filters.push({
  14152. name: 'customFilter',
  14153. fn: function (item /*{File|FileLikeObject}*/, options) {
  14154. return this.queue.length < 10;
  14155. }
  14156. });
  14157. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14158. uploader.onBeforeUploadItem = function (item) {
  14159. angular.extend(item.headers, $rootScope.getSession());
  14160. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  14161. // if ($scope.options.templateOptions.formket) {
  14162. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  14163. // } else {
  14164. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  14165. // }
  14166. } else {
  14167. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14168. }
  14169. item.formData.push({
  14170. 'filename': item.file.name
  14171. });
  14172. console.info('onBeforeUploadItem', item);
  14173. };
  14174. uploader.uploadAll();
  14175. }
  14176. // CALLBACKS
  14177. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14178. console.info('onWhenAddingFileFailed', item, filter, options);
  14179. };
  14180. uploader.onAfterAddingFile = function (fileItem) {
  14181. console.info('onAfterAddingFile', fileItem);
  14182. };
  14183. uploader.onAfterAddingAll = function (addedFileItems) {
  14184. console.info('onAfterAddingAll', addedFileItems);
  14185. };
  14186. uploader.onBeforeUploadItem = function (item) {
  14187. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14188. // // $scope.uploader.options.url();
  14189. // $scope.uploader.onBeforeUploadItem = function(item) {
  14190. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14191. // console.info('onBeforeUploadItem', item);
  14192. // };
  14193. // $scope.uploader.uploadAll();
  14194. // }
  14195. console.info('onBeforeUploadItem', item);
  14196. };
  14197. uploader.onProgressItem = function (fileItem, progress) {
  14198. console.info('onProgressItem', fileItem, progress);
  14199. };
  14200. uploader.onProgressAll = function (progress) {
  14201. console.info('onProgressAll', progress);
  14202. };
  14203. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14204. console.info('onSuccessItem', fileItem, response, status, headers);
  14205. };
  14206. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14207. console.info('onErrorItem', fileItem, response, status, headers);
  14208. };
  14209. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14210. console.info('onCancelItem', fileItem, response, status, headers);
  14211. };
  14212. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14213. console.info('onCompleteItem', fileItem, response, status, headers);
  14214. };
  14215. uploader.onCompleteAll = function () {
  14216. console.info('onCompleteAll');
  14217. };
  14218. }]
  14219. });
  14220. //简易附件展示下载列表组件
  14221. formlyConfigProvider.setType({
  14222. name: 'ui-dropFiles',
  14223. templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
  14224. defaultOptions: function (options) {
  14225. return {
  14226. templateOptions: {
  14227. refresh: function (APIService, processInstanceId, data) {
  14228. return APIService.listAttachments(processInstanceId);
  14229. },
  14230. downloadUri: function (APIService, contentId) {
  14231. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14232. },
  14233. view: function (APIService, contentId) {
  14234. return APIService.attachmentsPreviewUrl(contentId);
  14235. },
  14236. download: function (APIService, contentId, item) {
  14237. var item = {
  14238. 'url': APIService.download(contentId),
  14239. 'headers': headers
  14240. };
  14241. return item;
  14242. },
  14243. refreshDelay: 0
  14244. }
  14245. };
  14246. },
  14247. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  14248. var _refreshDelayPromise;
  14249. // $scope.downloadUrl = function(contentId){
  14250. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14251. // };
  14252. $scope.download = function (contentId, filename, token) {
  14253. // console.log(contentId, filename, token)
  14254. //附件下载
  14255. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  14256. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  14257. // console.log(downUrl)
  14258. var a = document.createElement('a');
  14259. a.href = downUrl;
  14260. a.target = '_blank';
  14261. a.download = filename;
  14262. document.body.appendChild(a);
  14263. a.click();
  14264. };
  14265. $scope.view = function (contentId, token, filename, type) {
  14266. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14267. if (response.state == 200) {
  14268. window.open(response.previewUrl);
  14269. }
  14270. })
  14271. };
  14272. /**
  14273. * refresh
  14274. */
  14275. $scope._refresh = function (refreshAttr) {
  14276. $scope.attachments = [];
  14277. if (refreshAttr !== undefined) {
  14278. if (_refreshDelayPromise) {
  14279. $timeout.cancel(_refreshDelayPromise);
  14280. }
  14281. _refreshDelayPromise = $timeout(function () {
  14282. // 暂存附件
  14283. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  14284. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14285. $scope.options.templateOptions.processInstanceId, {
  14286. 'idx': 0,
  14287. 'sum': 1000
  14288. }).then(function (response) {
  14289. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14290. if (myData) {
  14291. for (var i = 0; i < myData.data.length; i++) {
  14292. $scope.attachments.push(myData.data[i]);
  14293. }
  14294. };
  14295. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14296. $scope.$parent.$parent.$parent.model.save_fileId, {
  14297. 'idx': 0,
  14298. 'sum': 1000
  14299. }).then(function (response2) {
  14300. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  14301. if (myData2) {
  14302. for (var i = 0; i < myData2.data.length; i++) {
  14303. $scope.attachments.push(myData2.data[i]);
  14304. }
  14305. // 只展示除图片以外的附件
  14306. var a = [];
  14307. $scope.attachments.forEach(e => {
  14308. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14309. // $scope.imgs.push(e)
  14310. } else {
  14311. a.push(e)
  14312. }
  14313. })
  14314. $scope.attachments = a;
  14315. };
  14316. console.log($scope.attachments)
  14317. });
  14318. });
  14319. // 正常附件
  14320. } else {
  14321. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14322. $scope.options.templateOptions.processInstanceId, {
  14323. 'idx': 0,
  14324. 'sum': 1000
  14325. }).then(function (response) {
  14326. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14327. if (myData) {
  14328. $scope.attachments = myData.data;
  14329. // 只展示除图片以外的附件
  14330. var a = [];
  14331. $scope.attachments.forEach(e => {
  14332. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14333. // $scope.imgs.push(e)
  14334. } else {
  14335. a.push(e)
  14336. }
  14337. })
  14338. $scope.attachments = a;
  14339. console.log($scope.attachments)
  14340. }
  14341. });
  14342. }
  14343. }, $scope.options.templateOptions.refreshDelay);
  14344. }
  14345. }
  14346. $scope._refresh({});
  14347. // $scope.attachments = $scope.model[$scope.options.key]
  14348. }]
  14349. });
  14350. //知识库附件上传
  14351. formlyConfigProvider.setType({
  14352. name: 'ui-dropfielknow',
  14353. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14354. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14355. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14356. if (angular.isUndefined($scope.form.dropState)) {
  14357. $scope.form.dropState = false;
  14358. }
  14359. //附件上传数据
  14360. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14361. //$scope.options.templateOptions.uploader();
  14362. // FILTERS
  14363. uploader.filters.push({
  14364. name: 'customFilter',
  14365. fn: function (item /*{File|FileLikeObject}*/, options) {
  14366. return this.queue.length < 10;
  14367. }
  14368. });
  14369. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14370. uploader.onBeforeUploadItem = function (item) {
  14371. angular.extend(item.headers, $rootScope.getSession());
  14372. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  14373. item.formData.push({
  14374. 'fileName': item.file.name,
  14375. 'type': 'solution',
  14376. 'solutionId': $scope.model.knowledge.id
  14377. });
  14378. console.info('onBeforeUploadItem', item);
  14379. };
  14380. uploader.uploadAll();
  14381. }
  14382. // CALLBACKS
  14383. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14384. console.info('onWhenAddingFileFailed', item, filter, options);
  14385. };
  14386. uploader.onAfterAddingFile = function (fileItem) {
  14387. console.info('onAfterAddingFile', fileItem);
  14388. };
  14389. uploader.onAfterAddingAll = function (addedFileItems) {
  14390. console.info('onAfterAddingAll', addedFileItems);
  14391. };
  14392. uploader.onBeforeUploadItem = function (item) {
  14393. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14394. // // $scope.uploader.options.url();
  14395. // $scope.uploader.onBeforeUploadItem = function(item) {
  14396. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14397. // console.info('onBeforeUploadItem', item);
  14398. // };
  14399. // $scope.uploader.uploadAll();
  14400. // }
  14401. console.info('onBeforeUploadItem', item);
  14402. };
  14403. uploader.onProgressItem = function (fileItem, progress) {
  14404. console.info('onProgressItem', fileItem, progress);
  14405. };
  14406. uploader.onProgressAll = function (progress) {
  14407. console.info('onProgressAll', progress);
  14408. };
  14409. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14410. console.info('onSuccessItem', fileItem, response, status, headers);
  14411. };
  14412. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14413. console.info('onErrorItem', fileItem, response, status, headers);
  14414. };
  14415. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14416. console.info('onCancelItem', fileItem, response, status, headers);
  14417. };
  14418. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14419. console.info('onCompleteItem', fileItem, response, status, headers);
  14420. };
  14421. uploader.onCompleteAll = function () {
  14422. console.info('onCompleteAll');
  14423. };
  14424. }]
  14425. });
  14426. //知识库附件下载列表
  14427. formlyConfigProvider.setType({
  14428. name: 'ui-dropfileknowledge',
  14429. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  14430. defaultOptions: function (options) {
  14431. return {
  14432. templateOptions: {
  14433. refresh: function (APIService, contentId, data) {
  14434. return APIService.fetchDataList(contentId, data);
  14435. },
  14436. downloadUri: function (APIService, contentId) {
  14437. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14438. },
  14439. download: function (APIService, contentId) {
  14440. return APIService.getSolutionDowpath(contentId);
  14441. },
  14442. view: function (attachmentId) {
  14443. // return APIService.attachmentsPreviewUrl(contentId);
  14444. },
  14445. refreshDelay: 0
  14446. }
  14447. };
  14448. },
  14449. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  14450. var _refreshDelayPromise;
  14451. $scope.attachments = [];
  14452. $scope.downloadUrl = function (contentId) {
  14453. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  14454. };
  14455. $scope.download = function (contentId, filename) {
  14456. $http({
  14457. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  14458. method: 'GET',
  14459. headers: {
  14460. //'Content-type' : 'application/xls',
  14461. 'Accept': '*/*'
  14462. },
  14463. responseType: 'arraybuffer'
  14464. }).success(function (data, status, headers, config) {
  14465. var file = new Blob([data], {
  14466. type: 'application/octet-stream'
  14467. });
  14468. //trick to download store a file having its URL
  14469. var fileURL = URL.createObjectURL(file);
  14470. var a = document.createElement('a');
  14471. a.href = fileURL;
  14472. a.target = '_blank';
  14473. a.download = filename;
  14474. document.body.appendChild(a);
  14475. a.click();
  14476. }).error(function (data, status, headers, config) {
  14477. // console.log(data);
  14478. });
  14479. }
  14480. $scope.view = function (contentId, filename, attachment) {
  14481. var index = filename.indexOf(".");
  14482. var type = filename.substring(index + 1);
  14483. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14484. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  14485. // var modalInstance = $modal.open({
  14486. // backdrop: false,
  14487. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14488. // controller: function($scope, scope, $modalInstance, filename) {
  14489. // $scope.title = filename;
  14490. // $scope.imageurl = scope.imageurl;
  14491. // $scope.cancel = function() {
  14492. // $modalInstance.dismiss('cancel');
  14493. // }
  14494. // },
  14495. // resolve: {
  14496. // scope: function() {
  14497. // return $scope;
  14498. // },
  14499. // filename: function() {
  14500. // return filename;
  14501. // }
  14502. // }
  14503. // });
  14504. // event.preventDefault();
  14505. // } else {
  14506. // for (var i = 0; i < $scope.attachments.length; i++) {
  14507. // if ($scope.attachments[i].id == attachmentId) {
  14508. window.open(attachment.previewUrl);
  14509. // }
  14510. // }
  14511. // }
  14512. };
  14513. $scope._refresh = function (refreshAttr) {
  14514. if (refreshAttr !== undefined) {
  14515. if (_refreshDelayPromise) {
  14516. $timeout.cancel(_refreshDelayPromise);
  14517. }
  14518. _refreshDelayPromise = $timeout(function () {
  14519. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14520. 'file', {
  14521. "file": {
  14522. "solutionId": $scope.model.knowledge.id
  14523. },
  14524. "idx": "0",
  14525. "sum": "1000"
  14526. }).then(function (response) {
  14527. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14528. if (myData) {
  14529. $scope.attachments = myData.list;
  14530. // $scope.view = function(attachmentId) {
  14531. // for (var i = 0; i < $scope.attachments.length; i++) {
  14532. // if ($scope.attachments[i].id == attachmentId) {
  14533. // window.open($scope.attachments[i].previewUrl);
  14534. // // var modalInstance = $modal.open({
  14535. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  14536. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  14537. // // }
  14538. // // });
  14539. // }
  14540. // }
  14541. // };
  14542. }
  14543. });
  14544. }, $scope.options.templateOptions.refreshDelay);
  14545. }
  14546. }
  14547. $scope._refresh({});
  14548. // $scope.attachments = $scope.model[$scope.options.key]
  14549. }]
  14550. });
  14551. //附件图片下载
  14552. formlyConfigProvider.setType({
  14553. name: 'ui-downimage',
  14554. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  14555. defaultOptions: function (options) {
  14556. return {
  14557. templateOptions: {
  14558. refresh: function (APIService, processInstanceId, data) {
  14559. return APIService.listAttachments(processInstanceId, data);
  14560. },
  14561. downloadUri: function (APIService, contentId) {
  14562. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14563. },
  14564. view: function (APIService, contentId) {
  14565. return APIService.attachmentsPreviewUrl(contentId);
  14566. },
  14567. download: function (APIService, contentId, item) {
  14568. var item = {
  14569. 'url': APIService.download(contentId),
  14570. 'headers': headers
  14571. };
  14572. return item;
  14573. },
  14574. refreshDelay: 0
  14575. }
  14576. };
  14577. },
  14578. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  14579. var _refreshDelayPromise;
  14580. // $scope.downloadUrl = function(contentId){
  14581. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14582. // };
  14583. $scope.download = function (contentId, filename) {
  14584. // var headers=
  14585. $http({
  14586. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14587. method: 'GET',
  14588. headers: {
  14589. //'Content-type' : 'application/xls',
  14590. 'Accept': '*/*'
  14591. },
  14592. responseType: 'arraybuffer'
  14593. }).success(function (data, status, headers, config) {
  14594. var file = new Blob([data], {
  14595. type: 'application/octet-stream'
  14596. });
  14597. //trick to download store a file having its URL
  14598. var fileURL = URL.createObjectURL(file);
  14599. var a = document.createElement('a');
  14600. a.href = fileURL;
  14601. a.target = '_blank';
  14602. a.download = filename;
  14603. document.body.appendChild(a);
  14604. a.click();
  14605. }).error(function (data, status, headers, config) {
  14606. // console.log(data);
  14607. });
  14608. };
  14609. $scope.view = function (contentId) {
  14610. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14611. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  14612. // if (response.state == 200) {
  14613. // window.open(response.previewUrl);
  14614. // }
  14615. // })
  14616. };
  14617. /**
  14618. * refresh
  14619. */
  14620. $scope._refresh = function (refreshAttr) {
  14621. if (refreshAttr !== undefined) {
  14622. if (_refreshDelayPromise) {
  14623. $timeout.cancel(_refreshDelayPromise);
  14624. }
  14625. _refreshDelayPromise = $timeout(function () {
  14626. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14627. $scope.options.templateOptions.processInstanceId, {
  14628. 'idx': 0,
  14629. 'sum': 1000
  14630. }).then(function (response) {
  14631. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14632. if (myData) {
  14633. $scope.attachments = myData.data;
  14634. }
  14635. });
  14636. }, $scope.options.templateOptions.refreshDelay);
  14637. }
  14638. }
  14639. $scope._refresh({});
  14640. // $scope.attachments = $scope.model[$scope.options.key]
  14641. }]
  14642. });
  14643. //附件下载列表组件
  14644. formlyConfigProvider.setType({
  14645. name: 'ui-dropfiletable',
  14646. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  14647. defaultOptions: function (options) {
  14648. return {
  14649. templateOptions: {
  14650. refresh: function (APIService, processInstanceId, data) {
  14651. return APIService.listAttachments(processInstanceId, data);
  14652. },
  14653. downloadUri: function (APIService, contentId) {
  14654. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14655. },
  14656. view: function (APIService, contentId) {
  14657. return APIService.attachmentsPreviewUrl(contentId);
  14658. },
  14659. download: function (APIService, contentId, item) {
  14660. var item = {
  14661. 'url': APIService.download(contentId),
  14662. 'headers': headers
  14663. };
  14664. return item;
  14665. },
  14666. refreshDelay: 0
  14667. }
  14668. };
  14669. },
  14670. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  14671. var _refreshDelayPromise;
  14672. // $scope.downloadUrl = function(contentId){
  14673. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14674. // };
  14675. $scope.download = function (contentId, filename) {
  14676. // var headers=
  14677. $http({
  14678. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14679. method: 'GET',
  14680. headers: {
  14681. //'Content-type' : 'application/xls',
  14682. 'Accept': '*/*'
  14683. },
  14684. responseType: 'arraybuffer'
  14685. }).success(function (data, status, headers, config) {
  14686. var file = new Blob([data], {
  14687. type: 'application/octet-stream'
  14688. });
  14689. //trick to download store a file having its URL
  14690. var fileURL = URL.createObjectURL(file);
  14691. var a = document.createElement('a');
  14692. a.href = fileURL;
  14693. a.target = '_blank';
  14694. a.download = filename;
  14695. document.body.appendChild(a);
  14696. a.click();
  14697. }).error(function (data, status, headers, config) {
  14698. // console.log(data);
  14699. });
  14700. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  14701. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  14702. // var file = new Blob([response], {
  14703. // type : 'application/octet-stream'
  14704. // });
  14705. // // var filename = filename;
  14706. // //var file = new Blob([response], {type: 'application/pdf'});
  14707. // var fileURL = URL.createObjectURL(file);
  14708. // var a = document.createElement('a');
  14709. // a.href = fileURL;
  14710. // a.target = '_blank';
  14711. // a.download = filename ;
  14712. // document.body.appendChild(a);
  14713. // a.click();
  14714. // })
  14715. };
  14716. $scope.view = function (contentId, token, filename, type) {
  14717. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14718. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14719. // var modalInstance = $modal.open({
  14720. // backdrop: false,
  14721. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14722. // controller: function($scope, scope, $modalInstance, filename) {
  14723. // $scope.title = filename;
  14724. // $scope.imageurl = scope.imageurl;
  14725. // $scope.cancel = function() {
  14726. // $modalInstance.dismiss('cancel');
  14727. // }
  14728. // },
  14729. // resolve: {
  14730. // scope: function() {
  14731. // return $scope;
  14732. // },
  14733. // filename: function() {
  14734. // return filename;
  14735. // }
  14736. // }
  14737. // });
  14738. // event.preventDefault();
  14739. // } else {
  14740. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14741. if (response.state == 200) {
  14742. window.open(response.previewUrl);
  14743. }
  14744. })
  14745. // }
  14746. };
  14747. /**
  14748. * refresh
  14749. */
  14750. $scope._refresh = function (refreshAttr) {
  14751. if (refreshAttr !== undefined) {
  14752. if (_refreshDelayPromise) {
  14753. $timeout.cancel(_refreshDelayPromise);
  14754. }
  14755. _refreshDelayPromise = $timeout(function () {
  14756. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14757. $scope.options.templateOptions.processInstanceId, {
  14758. 'idx': 0,
  14759. 'sum': 1000
  14760. }).then(function (response) {
  14761. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14762. if (myData) {
  14763. $scope.attachments = myData.data;
  14764. }
  14765. });
  14766. }, $scope.options.templateOptions.refreshDelay);
  14767. }
  14768. }
  14769. $scope._refresh({});
  14770. // $scope.attachments = $scope.model[$scope.options.key]
  14771. }]
  14772. });
  14773. //微信附件下载列表组件
  14774. formlyConfigProvider.setType({
  14775. name: 'ui-dropfilewechat',
  14776. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  14777. defaultOptions: function (options) {
  14778. return {
  14779. templateOptions: {
  14780. // refresh: function(APIService, processInstanceId, data) {
  14781. // return APIService.listAttachments(processInstanceId, data);
  14782. // },
  14783. // downloadUri: function(APIService, contentId) {
  14784. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  14785. // },
  14786. view: function (APIService, contentId) {
  14787. // return APIService.attachmentsPreviewUrl(contentId);
  14788. return APIService.attachmentsPreviewUrl(contentId);
  14789. },
  14790. download: function (APIService, contentId, item) {
  14791. var item = {
  14792. 'url': APIService.download(contentId),
  14793. 'headers': headers
  14794. };
  14795. return item;
  14796. },
  14797. // download: function(APIService, contentId, item) {
  14798. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  14799. // return item;
  14800. // },
  14801. refreshDelay: 0
  14802. }
  14803. };
  14804. },
  14805. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  14806. var _refreshDelayPromise;
  14807. // $scope.downloadUrl = function(contentId){
  14808. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14809. // };
  14810. $scope.attachments = {};
  14811. $scope.previewUrl = '';
  14812. $scope.download = function (token, filename) {
  14813. // var headers=
  14814. console.log($scope);
  14815. $http({
  14816. url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
  14817. method: 'GET',
  14818. headers: {
  14819. //'Content-type' : 'application/xls',
  14820. 'Accept': '*/*'
  14821. },
  14822. responseType: 'arraybuffer'
  14823. }).success(function (data, status, headers, config) {
  14824. var file = new Blob([data], {
  14825. type: 'application/octet-stream'
  14826. });
  14827. //trick to download store a file having its URL
  14828. var fileURL = URL.createObjectURL(file);
  14829. var a = document.createElement('a');
  14830. a.href = fileURL;
  14831. a.target = '_blank';
  14832. a.download = filename;
  14833. document.body.appendChild(a);
  14834. a.click();
  14835. }).error(function (data, status, headers, config) {
  14836. // console.log(data);
  14837. });
  14838. };
  14839. $scope.view = function (contentId, token, filename, type, previewUrl) {
  14840. // if (type) {
  14841. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  14842. // var modalInstance = $modal.open({
  14843. // backdrop: false,
  14844. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14845. // controller: function($scope, scope, $modalInstance, filename) {
  14846. // $scope.title = filename;
  14847. // $scope.imageurl = scope.imageurl;
  14848. // $scope.cancel = function() {
  14849. // $modalInstance.dismiss('cancel');
  14850. // }
  14851. // },
  14852. // resolve: {
  14853. // scope: function() {
  14854. // return $scope;
  14855. // },
  14856. // filename: function() {
  14857. // return filename;
  14858. // }
  14859. // }
  14860. // });
  14861. // event.preventDefault();
  14862. // } else {
  14863. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  14864. // if (response.state == 200) {
  14865. // window.open(response.previewUrl);
  14866. // }
  14867. // })
  14868. window.open(previewUrl);
  14869. // }
  14870. };
  14871. /**
  14872. * refresh
  14873. */
  14874. $scope._refresh = function (refreshAttr) {
  14875. if (refreshAttr !== undefined) {
  14876. if (_refreshDelayPromise) {
  14877. $timeout.cancel(_refreshDelayPromise);
  14878. }
  14879. _refreshDelayPromise = $timeout(function () {
  14880. // console.log(JSON.parse($stateParams.model))
  14881. var incidentChart = {};
  14882. if ($stateParams.model) {
  14883. incidentChart = JSON.parse($stateParams.model).model;
  14884. }
  14885. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14886. $scope.model).then(function (response) {
  14887. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14888. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  14889. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14890. if (myData) {
  14891. $scope.attachments = myData.data;
  14892. }
  14893. });
  14894. }, $scope.options.templateOptions.refreshDelay);
  14895. }
  14896. }
  14897. $scope._refresh({});
  14898. // $scope.attachments = $scope.model[$scope.options.key]
  14899. }]
  14900. });
  14901. formlyConfigProvider.setType({
  14902. name: 'ui-paralleltask',
  14903. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  14904. defaultOptions: function (options) {
  14905. return {
  14906. templateOptions: {
  14907. refresh: function (APIService, processInstanceId, data) {
  14908. //return APIService.listAttachments(processInstanceId, data);
  14909. },
  14910. refreshDelay: 0
  14911. }
  14912. };
  14913. },
  14914. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  14915. });
  14916. //repeatSection
  14917. //
  14918. formlyConfigProvider.setType({
  14919. name: 'ui-repeatSection',
  14920. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  14921. defaultOptions: function (options) {
  14922. return {
  14923. templateOptions: {
  14924. unique: 1,
  14925. initDisplay: false
  14926. }
  14927. };
  14928. },
  14929. controller: function ($scope) {
  14930. //$scope.options.templateOptions.unique;
  14931. $scope.formOptions = {
  14932. formState: $scope.formState
  14933. };
  14934. $scope.addNew = addNew;
  14935. $scope.copyFields = copyFields;
  14936. function copyFields(fields) {
  14937. fields = angular.copy(fields);
  14938. addRandomIds(fields);
  14939. return fields;
  14940. }
  14941. function addNew() {
  14942. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  14943. var repeatsection = $scope.model[$scope.options.key];
  14944. var lastSection = repeatsection[repeatsection.length - 1];
  14945. var newsection = {};
  14946. repeatsection.push(newsection);
  14947. }
  14948. function addRandomIds(fields) {
  14949. $scope.options.templateOptions.unique++;
  14950. angular.forEach(fields, function (field, index) {
  14951. if (field.fieldGroup) {
  14952. addRandomIds(field.fieldGroup);
  14953. return; // fieldGroups don't need an ID
  14954. }
  14955. if (field.templateOptions && field.templateOptions.fields) {
  14956. addRandomIds(field.templateOptions.fields);
  14957. }
  14958. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  14959. });
  14960. }
  14961. function getRandomInt(min, max) {
  14962. return Math.floor(Math.random() * (max - min)) + min;
  14963. }
  14964. if ($scope.options.templateOptions.initDisplay) {
  14965. addNew();
  14966. }
  14967. }
  14968. });
  14969. //时间轴任务列表组件
  14970. //cmdb控件
  14971. formlyConfigProvider.setType({
  14972. name: 'ui-cmdb',
  14973. extends: 'input',
  14974. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  14975. defaultOptions: function (options) {
  14976. return {
  14977. templateOptions: {
  14978. onClick: function (size, options, modal, event, model) {
  14979. var modalInstance = modal.open({
  14980. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  14981. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  14982. var width = $scope.width = 600;
  14983. var height = $scope.height = 400;
  14984. var tree;
  14985. var d3 = window.d3;
  14986. $scope.my_tree_handler = function (branch) {
  14987. //var _ref;
  14988. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  14989. APIService.query({
  14990. 'sign': classify
  14991. }).then(function (data) {
  14992. var myData = Restangular.stripRestangular(data);
  14993. // console.log(myData.data.node);
  14994. if (myData.data && myData.status == 200) {
  14995. var ret = myData.data;
  14996. redrawSvg(myData);
  14997. }
  14998. });
  14999. };
  15000. $scope.my_data = [];
  15001. function convertListToTree(data, treeMap) {
  15002. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  15003. var root = null; //Initially set our loop to null
  15004. var parentNode = null;
  15005. //loop over data
  15006. for (var i = 0; i < data.length; i++) {
  15007. var datum = data[i];
  15008. //each node will have children, so let's give it a "children" poperty
  15009. datum.children = [];
  15010. //add an entry for this node to the map so that any future children can
  15011. //lookup the parent
  15012. idToNodeMap[datum.id] = datum;
  15013. //Does this node have a parent?
  15014. if (typeof datum.parent === "undefined" || datum.parent == null) {
  15015. //Doesn't look like it, so this node is the root of the tree
  15016. root = datum;
  15017. treeMap[datum.id] = root;
  15018. } else {
  15019. //This node has a parent, so let's look it up using the id
  15020. parentNode = idToNodeMap[datum.parent.id];
  15021. //We don't need this property, so let's delete it.
  15022. delete datum.parent;
  15023. //Let's add the current node as a child of the parent node.
  15024. parentNode.children.push(datum);
  15025. }
  15026. }
  15027. return root;
  15028. }
  15029. function convertParentToChildList(data) {
  15030. var treeMap = {};
  15031. var list = [];
  15032. convertListToTree(data, treeMap);
  15033. angular.forEach(treeMap, function (item) {
  15034. list.push(item);
  15035. });
  15036. return list;
  15037. }
  15038. $scope.my_tree = tree = {};
  15039. $scope.try_async_load = function () {
  15040. $scope.my_data = [];
  15041. $scope.select_treedata = [];
  15042. $scope.doing_async = true;
  15043. ConfigDataService.fetchDataList('ciclassify', {
  15044. 'idx': 0,
  15045. 'sum': 100
  15046. }).then(function (result) {
  15047. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15048. $scope.doing_async = false;
  15049. });
  15050. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  15051. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15052. // $scope.doing_async = false;
  15053. // });
  15054. };
  15055. $scope.select_treedata = [];
  15056. $scope.propTypeOptions = [];
  15057. $scope.try_async_load();
  15058. $scope.onFilterCallback = function (item) {
  15059. //console.log(item);
  15060. if (angular.isDefined(item.children) && item.children.length >= 1) {
  15061. //not valid
  15062. } else {
  15063. var tempclassify = item.prefix.toLowerCase() + item.sign;
  15064. $scope.cifilter_classic = tempclassify;
  15065. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  15066. var myData = Restangular.stripRestangular(data);
  15067. $scope.propTypeOptions = myData;
  15068. });
  15069. }
  15070. }
  15071. $scope.onPropTypeChange = function (form) {
  15072. $scope.propOptions = form.fields;
  15073. }
  15074. $scope.onPropChange = function (prop) {
  15075. $scope.cifilter_prop = prop;
  15076. }
  15077. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  15078. //if(searchKey!=null&&searchKey.length>1){
  15079. var searchData = {};
  15080. if (angular.isUndefined(propObj)) {
  15081. propObj = $scope.cifilter_prop;
  15082. }
  15083. if (angular.isUndefined(ciclassify)) {
  15084. ciclassify = $scope.cifilter_classic;
  15085. }
  15086. searchData['sign'] = ciclassify;
  15087. if (angular.isDefined(propObj)) {
  15088. searchData[propObj.key] = searchKey;
  15089. }
  15090. APIService.query(searchData).then(function (response) {
  15091. var data = Restangular.stripRestangular(response);
  15092. //此处不清空nodes
  15093. var node = data.data.node;
  15094. var tempNode = [];
  15095. //nodes 或者links 要去重
  15096. for (var i = 0; i < node.length; i++) {
  15097. var tmp = 0;
  15098. for (var j = 0; j < nodes.length; j++) {
  15099. if (node[i].uuid == nodes[j].uuid) {
  15100. tmp++;
  15101. break;
  15102. }
  15103. }
  15104. if (tmp == 0) {
  15105. tempNode.push(node[i]);
  15106. }
  15107. }
  15108. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15109. nodes.push(tempNode[i]);
  15110. }
  15111. restart();
  15112. })
  15113. }
  15114. $scope.refresh = function () {
  15115. nodes.length = 0;
  15116. links.length = 0;
  15117. restart();
  15118. }
  15119. $scope.traversal = function () {
  15120. if ($scope.selected_node == null) {
  15121. SweetAlert.swal({
  15122. title: "错误的操作!",
  15123. text: "没有配置项被选中!",
  15124. type: "error"
  15125. });
  15126. } else {
  15127. var uuid = $scope.selected_node.uuid;
  15128. APIService.traversal(uuid).then(function (response) {
  15129. var d = response.data;
  15130. var node = d.node;
  15131. var link = d.edge;
  15132. var tempNode = [];
  15133. var tempLink = [];
  15134. //nodes 或者links 要去重
  15135. for (var i = 0; i < node.length; i++) {
  15136. var tmp = 0;
  15137. for (var j = 0; j < nodes.length; j++) {
  15138. if (node[i].id == nodes[j].id) {
  15139. tmp++;
  15140. break;
  15141. }
  15142. }
  15143. if (tmp == 0) {
  15144. tempNode.push(node[i]);
  15145. }
  15146. }
  15147. for (var i = 0; i < link.length; i++) {
  15148. var tmp = 0;
  15149. for (var j = 0; j < links.length; j++) {
  15150. if (link[i].id == links[j].id) {
  15151. tmp++;
  15152. break;
  15153. }
  15154. }
  15155. if (tmp == 0) {
  15156. tempLink.push(link[i]);
  15157. }
  15158. }
  15159. //数据写入页面
  15160. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15161. nodes.push(tempNode[i]);
  15162. }
  15163. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15164. links.push(tempLink[i]);
  15165. }
  15166. //links转换
  15167. for (var i = 0; i < links.length; i++) {
  15168. for (var j = 0; j < nodes.length; j++) {
  15169. if (links[i].source == nodes[j].id) {
  15170. links[i].source = nodes[j];
  15171. }
  15172. if (links[i].target == nodes[j].id) {
  15173. links[i].target = nodes[j];
  15174. }
  15175. }
  15176. }
  15177. restart();
  15178. })
  15179. }
  15180. }
  15181. var svg;
  15182. var force;
  15183. var drag_line, path, circle;
  15184. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  15185. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15186. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15187. var nodes = [],
  15188. links = [];
  15189. var treeNodes = [];
  15190. //读取labels (node)
  15191. var labels = [];
  15192. function redrawSvg(json) {
  15193. nodes.length = 0; //先清空
  15194. links.length = 0;
  15195. var data = json.data;
  15196. for (var i = 0; i < data.node.length; i++) {
  15197. nodes.push(data.node[i]);
  15198. }
  15199. restart();
  15200. }
  15201. //读取status (节点 连线)
  15202. var statuses = [];
  15203. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  15204. // if (result && result.status == 200) {
  15205. // d3.select('#nodeStatus').selectAll('option')
  15206. // .data(statuses).enter()
  15207. // .append('option')
  15208. // .attr('value', function(d) { return d.code; })
  15209. // .html(function(d) { return d.desc; });
  15210. // } else {
  15211. // SweetAlert.swal({
  15212. // title: "提示!",
  15213. // text: "服务器请求异常!",
  15214. // type: "error"
  15215. // });
  15216. // }
  15217. // });
  15218. api_wechatfile.getDictionary({
  15219. 'key': 'cmdb_status',
  15220. 'type': 'list'
  15221. }).then(function (result) {
  15222. if (result) {
  15223. d3.select('#nodeStatus').selectAll('option')
  15224. .data(statuses).enter()
  15225. .append('option')
  15226. .attr('value', function (d) {
  15227. return d.code;
  15228. })
  15229. .html(function (d) {
  15230. return d.desc;
  15231. });
  15232. } else {
  15233. SweetAlert.swal({
  15234. title: "提示!",
  15235. text: "服务器请求异常!",
  15236. type: "error"
  15237. });
  15238. }
  15239. });
  15240. //查询relationship_type表 name 为表里的type,label为显示值
  15241. var linkType = [];
  15242. function fetchEdgeTypes() {
  15243. ConfigDataService.fetchDataList('ciedgetype', {
  15244. 'idx': 0,
  15245. 'sum': 100
  15246. }).then(function (response) {
  15247. if (response) {
  15248. if (response['list']) {
  15249. linkType = response['list'];
  15250. // d3.select('#linkName').selectAll('option')
  15251. // .data(linkType).enter()
  15252. // .append('option')
  15253. // .attr('value',function(d){return d.type;})
  15254. // .html(function(d){ return d.label;});
  15255. } else {
  15256. SweetAlert.swal({
  15257. title: "提示!",
  15258. text: "服务器请求异常!",
  15259. type: "error"
  15260. });
  15261. }
  15262. } else {
  15263. SweetAlert.swal({
  15264. title: "提示!",
  15265. text: "服务器请求异常!",
  15266. type: "error"
  15267. });
  15268. }
  15269. })
  15270. }
  15271. // fetchEdgeTypes();
  15272. /*
  15273. // init D3 force layout
  15274. var force = d3.layout.force()
  15275. .nodes(nodes)
  15276. .links(links)
  15277. .size([width, height])
  15278. .gravity(.05)
  15279. .linkDistance(150)
  15280. .linkStrength(2)
  15281. .charge(-500)
  15282. .on('tick', tick);
  15283. // define arrow markers for graph links
  15284. svg.append('svg:defs').append('svg:marker')
  15285. .attr('id', 'end-arrow')
  15286. .attr('viewBox', '0 -5 10 10')
  15287. .attr('refX', 6)
  15288. .attr('markerWidth', 3)
  15289. .attr('markerHeight', 3)
  15290. .attr('orient', 'auto')
  15291. .append('svg:path')
  15292. .attr('d', 'M0,-5L10,0L0,5')
  15293. .attr('fill', '#000');
  15294. svg.append('svg:defs').append('svg:marker')
  15295. .attr('id', 'start-arrow')
  15296. .attr('viewBox', '0 -5 10 10')
  15297. .attr('refX', 4)
  15298. .attr('markerWidth', 3)
  15299. .attr('markerHeight', 3)
  15300. .attr('orient', 'auto')
  15301. .append('svg:path')
  15302. .attr('d', 'M10,-5L0,0L10,5')
  15303. .attr('fill', '#000');
  15304. // line displayed when dragging new nodes
  15305. var drag_line = svg.append('svg:path')
  15306. .attr('class', 'link dragline hidden')
  15307. .attr('d', 'M0,0L0,0');
  15308. // handles to link and node element groups
  15309. //(1)var path = svg.append('svg:g').selectAll('g')
  15310. var path = svg.append('svg:g').selectAll('g'),
  15311. circle = svg.append('svg:g').selectAll('g');
  15312. */
  15313. // mouse event vars
  15314. var selected_node = null,
  15315. selected_link = null,
  15316. mousedown_link = null,
  15317. mousedown_node = null,
  15318. mouseup_node = null;
  15319. function resetMouseVars() {
  15320. mousedown_node = null;
  15321. mouseup_node = null;
  15322. mousedown_link = null;
  15323. }
  15324. // update force layout (called automatically each iteration)
  15325. function tick() {
  15326. // draw directed edges with proper padding from node centers
  15327. path.selectAll('path').attr('d', function (d) {
  15328. var deltaX = d.target.x - d.source.x,
  15329. deltaY = d.target.y - d.source.y,
  15330. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  15331. normX = deltaX / dist,
  15332. normY = deltaY / dist,
  15333. sourcePadding = d.left ? 27 : 22,
  15334. targetPadding = d.right ? 27 : 22,
  15335. sourceX = d.source.x + (sourcePadding * normX),
  15336. sourceY = d.source.y + (sourcePadding * normY),
  15337. targetX = d.target.x - (targetPadding * normX),
  15338. targetY = d.target.y - (targetPadding * normY);
  15339. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  15340. });
  15341. circle.attr('transform', function (d) {
  15342. return 'translate(' + d.x + ',' + d.y + ')';
  15343. });
  15344. }
  15345. // update graph (called when needed)
  15346. function restart() {
  15347. //绑定link 数据
  15348. path.datum(links);
  15349. // path (link) group
  15350. path = path.data(links, function (d) {
  15351. return d.id;
  15352. });
  15353. var p = path.enter().append('svg:g');
  15354. //update existing links
  15355. path.selectAll('path').classed('selected', function (d) {
  15356. return d === selected_link;
  15357. })
  15358. .style('marker-start', function (d) {
  15359. return d.left ? 'url(#start-arrow)' : '';
  15360. })
  15361. .style('marker-end', function (d) {
  15362. return d.right ? 'url(#end-arrow)' : '';
  15363. });
  15364. // add new links
  15365. p.append('svg:path')
  15366. .attr('class', 'link')
  15367. .attr('id', function (d) {
  15368. return "path_" + d.id;
  15369. })
  15370. // .attr('startOffset', '0%')
  15371. .classed('selected', function (d) {
  15372. return d === selected_link;
  15373. })
  15374. .style('marker-start', function (d) {
  15375. return d.left ? 'url(#start-arrow)' : '';
  15376. })
  15377. .style('marker-end', function (d) {
  15378. return d.right ? 'url(#end-arrow)' : '';
  15379. })
  15380. .on('mousedown', function (d) {
  15381. if (d3.event.ctrlKey) return;
  15382. //去除没有提交的连线
  15383. for (var i = 0; i < links.length; i++) {
  15384. if (links[i].id == -1 && d.id != -1) {
  15385. links.splice(i, 1);
  15386. }
  15387. }
  15388. // select link
  15389. mousedown_link = d;
  15390. if (mousedown_link === selected_link) {
  15391. selected_link = $scope.selected_link = null;
  15392. selected_node = $scope.selected_node = null;
  15393. // d3.select("#linkDetail").attr('style','display:none');
  15394. //hideLinkForm(true);//return ;
  15395. } else {
  15396. selected_link = $scope.selected_link = mousedown_link;
  15397. selected_node = $scope.selected_node = null;
  15398. }
  15399. selected_node = $scope.selected_node = null;
  15400. restart();
  15401. });
  15402. p.append('svg:text')
  15403. .attr('x', 30)
  15404. .attr('y', 20)
  15405. .attr('class', 'fontM')
  15406. .append('textPath')
  15407. .attr('xlink:xlink:href', function (d, i) {
  15408. return "#path_" + d.id;
  15409. })
  15410. .html(function (d) {
  15411. for (var i = 0; i < linkType.length; i++) {
  15412. if (linkType[i].type == d.name) {
  15413. return linkType[i].label;
  15414. }
  15415. }
  15416. });
  15417. // remove old links
  15418. path.exit().remove();
  15419. // circle (node) group
  15420. // NB: the function arg is crucial here! nodes are known by id, not by index!
  15421. circle.datum(nodes);
  15422. circle = circle.data(nodes, function (d) {
  15423. return d.id;
  15424. });
  15425. // update existing nodes (reflexive & selected visual states)
  15426. circle.selectAll('circle')
  15427. .style('fill', function (d) {
  15428. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15429. })
  15430. .style('fill-opacity', 0.75) // add by xi
  15431. .classed('reflexive', function (d) {
  15432. return d.reflexive;
  15433. });
  15434. // add new nodes
  15435. var g = circle.enter().append('svg:g');
  15436. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  15437. //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');
  15438. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  15439. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  15440. }).style('stroke', function (d) {
  15441. return d3.rgb(colors(d.label)).darker().toString();
  15442. }).style('stroke-width', '2');
  15443. g.append('svg:circle')
  15444. .attr('class', 'node')
  15445. .attr('r', 18)
  15446. .style('fill', function (d) {
  15447. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15448. })
  15449. .style('stroke', function (d) {
  15450. return d3.rgb(colors(d.label)).darker().toString();
  15451. })
  15452. .style('fill-opacity', 0.25) //add by xj
  15453. .style('stroke-opacity', 0.5) //add by xj
  15454. .classed('reflexive', function (d) {
  15455. return d.reflexive;
  15456. });
  15457. g.on('mouseover', function (d) {
  15458. //if(!mousedown_node || d === mousedown_node) return;
  15459. // enlarge target node
  15460. //d3.select(this).attr('transform', 'scale(1.1)');
  15461. })
  15462. .on('mouseout', function (d) {
  15463. //if(!mousedown_node || d === mousedown_node) return;
  15464. // unenlarge target node
  15465. //d3.select(this).attr('transform', '');
  15466. })
  15467. .on('mousedown', function (d) {
  15468. if (d3.event.ctrlKey) return;
  15469. //hideLinkForm(true);
  15470. //去除没有提交的连线
  15471. for (var i = 0; i < links.length; i++) {
  15472. if (links[i].id == -1) {
  15473. links.splice(i, 1);
  15474. }
  15475. }
  15476. // select node
  15477. mousedown_node = d;
  15478. if (mousedown_node === selected_node) {
  15479. selected_node = $scope.selected_node = null;
  15480. } else {
  15481. selected_node = $scope.selected_node = mousedown_node;
  15482. selected_link = $scope.selected_link = null;
  15483. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  15484. APIService.findRefById(selected_node.id).then(function (result) {
  15485. var d = result.data;
  15486. var node = d.node;
  15487. var link = d.edge;
  15488. var tempNode = [];
  15489. var tempLink = [];
  15490. //nodes 或者links 要去重
  15491. for (var i = 0; i < node.length; i++) {
  15492. var tmp = 0;
  15493. for (var j = 0; j < nodes.length; j++) {
  15494. if (node[i].id == nodes[j].id) {
  15495. tmp++;
  15496. break;
  15497. }
  15498. }
  15499. if (tmp == 0) {
  15500. tempNode.push(node[i]);
  15501. }
  15502. }
  15503. for (var i = 0; i < link.length; i++) {
  15504. var tmp = 0;
  15505. for (var j = 0; j < links.length; j++) {
  15506. if (link[i].id == links[j].id) {
  15507. tmp++;
  15508. break;
  15509. }
  15510. }
  15511. if (tmp == 0) {
  15512. tempLink.push(link[i]);
  15513. }
  15514. }
  15515. //数据写入页面
  15516. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15517. nodes.push(tempNode[i]);
  15518. }
  15519. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15520. links.push(tempLink[i]);
  15521. }
  15522. //links转换
  15523. for (var i = 0; i < links.length; i++) {
  15524. for (var j = 0; j < nodes.length; j++) {
  15525. if (links[i].source == nodes[j].id) {
  15526. links[i].source = nodes[j];
  15527. }
  15528. if (links[i].target == nodes[j].id) {
  15529. links[i].target = nodes[j];
  15530. }
  15531. }
  15532. }
  15533. restart();
  15534. });
  15535. }
  15536. // reposition drag line
  15537. drag_line
  15538. .style('marker-end', 'url(#end-arrow)')
  15539. .classed('hidden', false)
  15540. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  15541. restart();
  15542. })
  15543. .on('mouseup', function (d) {
  15544. if (!mousedown_node) return;
  15545. });
  15546. // show node name
  15547. g.append('svg:text')
  15548. .attr('x', 0)
  15549. .attr('y', 34)
  15550. .attr('class', 'id')
  15551. .text(function (d) {
  15552. return d.name;
  15553. }); //TODO 改为 d.name
  15554. //设置图片
  15555. g.append('svg:foreignObject')
  15556. .attr("width", 32)
  15557. .attr("height", 32)
  15558. .attr('x', "-16px")
  15559. .attr('y', "-11px")
  15560. .html(function (d) {
  15561. for (var i = 0; i < labels.length; i++) {
  15562. if (d.label == labels[i].sign) {
  15563. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  15564. }
  15565. }
  15566. });
  15567. // remove old nodes
  15568. circle.exit().remove();
  15569. // set the graph in motion
  15570. force.start();
  15571. }
  15572. function mousedown() {
  15573. // prevent I-bar on drag
  15574. //d3.event.preventDefault();
  15575. // because :active only works in WebKit?
  15576. svg.classed('active', true);
  15577. if (mousedown_node) {
  15578. viewNode(mousedown_node);
  15579. }
  15580. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  15581. restart();
  15582. }
  15583. function mousemove() {
  15584. if (!mousedown_node) return;
  15585. // update drag line
  15586. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  15587. //restart();
  15588. }
  15589. function mouseup() {
  15590. if (mousedown_node) {
  15591. // hide drag line
  15592. drag_line
  15593. .classed('hidden', true)
  15594. .style('marker-end', '');
  15595. }
  15596. // because :active only works in WebKit?
  15597. svg.classed('active', false);
  15598. // clear mouse event vars
  15599. resetMouseVars();
  15600. }
  15601. function spliceLinksForNode(node) {
  15602. var toSplice = links.filter(function (l) {
  15603. return (l.source === node || l.target === node);
  15604. });
  15605. toSplice.map(function (l) {
  15606. links.splice(links.indexOf(l), 1);
  15607. });
  15608. }
  15609. // only respond once per keydown
  15610. var lastKeyDown = -1;
  15611. function keydown() {
  15612. //d3.event.preventDefault();
  15613. if (lastKeyDown !== -1) return;
  15614. lastKeyDown = d3.event.keyCode;
  15615. // ctrl
  15616. if (d3.event.keyCode === 17) {
  15617. circle.call(force.drag);
  15618. svg.classed('ctrl', true);
  15619. }
  15620. if (!selected_node && !selected_link) return;
  15621. switch (d3.event.keyCode) {
  15622. case 8: // backspace
  15623. case 66: // B
  15624. if (selected_link) {
  15625. // set link direction to both left and right
  15626. selected_link.left = true;
  15627. selected_link.right = true;
  15628. }
  15629. restart();
  15630. break;
  15631. case 76: // L
  15632. if (selected_link) {
  15633. // set link direction to left only
  15634. selected_link.left = true;
  15635. selected_link.right = false;
  15636. }
  15637. restart();
  15638. break;
  15639. case 82: // R
  15640. if (selected_node) {
  15641. // toggle node reflexivity
  15642. selected_node.reflexive = !selected_node.reflexive;
  15643. } else if (selected_link) {
  15644. // set link direction to right only
  15645. selected_link.left = false;
  15646. selected_link.right = true;
  15647. }
  15648. restart();
  15649. break;
  15650. }
  15651. }
  15652. function keyup() {
  15653. lastKeyDown = -1;
  15654. // ctrl
  15655. if (d3.event.keyCode === 17) {
  15656. circle
  15657. .on('mousedown.drag', null)
  15658. .on('touchstart.drag', null);
  15659. svg.classed('ctrl', false);
  15660. }
  15661. }
  15662. function viewNode(node) {
  15663. // console.log(svg.attr('left'));
  15664. //var el = angular.element('div.modal-dialog')[0];
  15665. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  15666. if (!$scope.selected_node.props.state) {
  15667. $scope.selected_node.props.state = "空"
  15668. } else if ($scope.selected_node.props.state) {
  15669. if ($scope.selected_node.props.state == "1") {
  15670. $scope.selected_node.props.state = "未审核"
  15671. } else if ($scope.selected_node.props.state == "2") {
  15672. $scope.selected_node.props.state = "已审核"
  15673. } else if ($scope.selected_node.props.state == "3") {
  15674. $scope.selected_node.props.state = "不匹配"
  15675. } else if ($scope.selected_node.props.state == "4") {
  15676. $scope.selected_node.props.state = "丢失"
  15677. }
  15678. };
  15679. if (!$scope.selected_node.name) {
  15680. $scope.selected_node.name = "空"
  15681. }
  15682. if (!$scope.selected_node.status) {
  15683. $scope.selected_node.statu = "空"
  15684. }
  15685. if (!$scope.selected_node.props.useradmin) {
  15686. $scope.selected_node.props.useradmin = "空"
  15687. }
  15688. Toaster.pop({
  15689. // type: 'info',
  15690. // title: title,
  15691. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  15692. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  15693. '<p>状态:' + $scope.selected_node.status + '</p>' +
  15694. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  15695. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  15696. bodyOutputType: 'trustedHtml',
  15697. timeout: 3000
  15698. })
  15699. }
  15700. //GT 颜色与数值对照表
  15701. function colors(sign) {
  15702. //num=num>20?num%20:parseInt(num);
  15703. for (var i = 0; i < labels.length; i++) {
  15704. var entity = labels[i];
  15705. if (sign == entity.sign) {
  15706. return entity.color;
  15707. }
  15708. if (i == labels.length - 1 && sign != entity.sign) {
  15709. return '#ffeeee';
  15710. }
  15711. }
  15712. }
  15713. $scope.init = function () {
  15714. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15715. // init D3 force layout
  15716. force = d3.layout.force()
  15717. .nodes(nodes)
  15718. .links(links)
  15719. .size([width, height])
  15720. .gravity(.05)
  15721. .linkDistance(150)
  15722. .linkStrength(2)
  15723. .charge(-500)
  15724. .on('tick', tick);
  15725. // define arrow markers for graph links
  15726. svg.append('svg:defs').append('svg:marker')
  15727. .attr('id', 'end-arrow')
  15728. .attr('viewBox', '0 -5 10 10')
  15729. .attr('refX', 6)
  15730. .attr('markerWidth', 3)
  15731. .attr('markerHeight', 3)
  15732. .attr('orient', 'auto')
  15733. .append('svg:path')
  15734. .attr('d', 'M0,-5L10,0L0,5')
  15735. .attr('fill', '#000');
  15736. svg.append('svg:defs').append('svg:marker')
  15737. .attr('id', 'start-arrow')
  15738. .attr('viewBox', '0 -5 10 10')
  15739. .attr('refX', 4)
  15740. .attr('markerWidth', 3)
  15741. .attr('markerHeight', 3)
  15742. .attr('orient', 'auto')
  15743. .append('svg:path')
  15744. .attr('d', 'M10,-5L0,0L10,5')
  15745. .attr('fill', '#000');
  15746. // line displayed when dragging new nodes
  15747. drag_line = svg.append('svg:path')
  15748. .attr('class', 'link dragline hidden')
  15749. .attr('d', 'M0,0L0,0');
  15750. // handles to link and node element groups
  15751. //(1)var path = svg.append('svg:g').selectAll('g')
  15752. path = svg.append('svg:g').selectAll('g');
  15753. circle = svg.append('svg:g').selectAll('g');
  15754. svg.on('mousedown', mousedown)
  15755. .on('mousemove', mousemove)
  15756. .on('mouseup', mouseup);
  15757. d3.select(window)
  15758. .on('keydown', keydown)
  15759. .on('keyup', keyup);
  15760. }
  15761. var CI = {};
  15762. window.CI = CI;
  15763. $scope.ok = function () {
  15764. $modalInstance.close($scope.selected_node);
  15765. };
  15766. $scope.cancel = function () {
  15767. $modalInstance.dismiss('cancel');
  15768. };
  15769. },
  15770. size: size,
  15771. resolve: {
  15772. title: function () {
  15773. return options.templateOptions.title;
  15774. },
  15775. Restangular: function () {
  15776. return options.templateOptions.Restangular;
  15777. },
  15778. APIService: function () {
  15779. return options.templateOptions.ApiService;
  15780. },
  15781. ConfigDataService: function () {
  15782. return options.templateOptions.ConfigDataService;
  15783. },
  15784. ConfigFormService: function () {
  15785. return options.templateOptions.ConfigFormService;
  15786. },
  15787. SweetAlert: function () {
  15788. return options.templateOptions.Alert;
  15789. },
  15790. Toaster: function () {
  15791. return options.templateOptions.toaster;
  15792. }
  15793. }
  15794. });
  15795. modalInstance.result.then(function (selectedItem) {
  15796. options.value(selectedItem.name + '-' + selectedItem.uuid);
  15797. }, function () {
  15798. //console.log('Modal dismissed at: ' + new Date());
  15799. });
  15800. }
  15801. }
  15802. }
  15803. },
  15804. controller: ['$scope', function ($scope) {
  15805. // setTimeout(function(){
  15806. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  15807. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  15808. // if(modelData.status==200){
  15809. // $scope.model[$scope.options.key] = modelData.data;
  15810. // $scope.options.initialValue = $scope.model[$scope.options.key];
  15811. // }
  15812. // });
  15813. // },1000);
  15814. }]
  15815. });
  15816. });
  15817. appFormly.run(function (formlyConfig, $parse) {
  15818. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  15819. var removeOnHideTransformer = function (fields, model) {
  15820. return fields.map(function (field) {
  15821. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  15822. addFieldRemoveOnHideWatcher(field);
  15823. }
  15824. if (field.type == "ui-title") {
  15825. addFieldRemoveOnHideWatcher(field);
  15826. }
  15827. return field;
  15828. });
  15829. };
  15830. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  15831. function addFieldRemoveOnHideWatcher(field) {
  15832. var watcher = getWatcher();
  15833. if (field.watcher) {
  15834. if (!angular.isArray(field.watcher)) {
  15835. field.watcher = [field.watcher];
  15836. }
  15837. field.watcher.push(watcher);
  15838. } else {
  15839. field.watcher = watcher;
  15840. }
  15841. }
  15842. function getWatcher() {
  15843. return {
  15844. expression: function (field) {
  15845. return field.hide;
  15846. },
  15847. listener: function (field, newHide, oldHide, scope) {
  15848. if (field.hide) {
  15849. if (field.templateOptions.pkey) {
  15850. if (field.key == 'transferuser') {
  15851. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  15852. }
  15853. } else {
  15854. $parse(field.key).assign(scope.model, undefined);
  15855. }
  15856. }
  15857. if (field.type == "ui-title") {
  15858. $parse(field.key).assign(scope.model, undefined);
  15859. }
  15860. }
  15861. };
  15862. }
  15863. });
  15864. 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',
  15865. 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) {
  15866. //console.log($parse('Restangular')($scope));
  15867. //console.log($injector.get('Restangular'));
  15868. //console.log($stateParams);
  15869. //保存报修主体
  15870. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15871. $scope.imgUrlList = [];
  15872. $scope.uploadimg_del = function () {
  15873. console.log(123)
  15874. };
  15875. var vm = this;
  15876. vm.options = {};
  15877. vm.exampleTitle = ['expressionProperties', 'model property'];
  15878. vm.fields = [];
  15879. vm.model = {};
  15880. $scope.langs = i18nService.getAllLangs();
  15881. $scope.lang = 'zh-cn';
  15882. i18nService.setCurrentLang($scope.lang);
  15883. //alert($rootScope.user.id,null,2);
  15884. vm.model["loginUser"] = $rootScope.user;
  15885. var loginUser = $rootScope.user;
  15886. // console.log(vm);
  15887. var that = $injector;
  15888. var parse = $parse;
  15889. var formKey = "";
  15890. var pdKey = "";
  15891. var modelWatch = "";
  15892. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  15893. modelWatch = JSON.parse($stateParams.model);
  15894. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  15895. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  15896. console.log(modelWatch,$rootScope)
  15897. // if(modelWatch.model.incident){
  15898. // if(modelWatch.model.incident.place){
  15899. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  15900. // }else{
  15901. // $rootScope.selecthouseNumber = undefined;
  15902. // }
  15903. // }
  15904. }
  15905. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  15906. pdKey = $state.current.pdKey;
  15907. } else if ($stateParams.pdKey) {
  15908. pdKey = $stateParams.pdKey;
  15909. }
  15910. // console.log("pdKey::" + JSON.stringify($state.current.title));
  15911. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  15912. formKey = $stateParams.formKey;
  15913. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  15914. }
  15915. if (angular.isDefined($stateParams.model)) {
  15916. var formModel = $stateParams.model;
  15917. }
  15918. //用户测试数据,后续从header的auth中获取
  15919. var userId = 2;
  15920. userId = $rootScope.user.id;
  15921. //==============处理表单设计数据 开始====================
  15922. //处理组件加载后台数据选项的方法
  15923. function refreshSelectOptions(searchVal, field) {
  15924. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  15925. var process = BpmRestangular.all("");
  15926. if (field.templateOptions.ApiService) {
  15927. process = UserRestangular.all("");
  15928. }
  15929. if (field.templateOptions.Apicommon) {
  15930. process = WechatRestangular.all("");
  15931. }
  15932. var datakey = {
  15933. "idx": 0,
  15934. "sum": 1000
  15935. };
  15936. if (field.templateOptions.modelreasondata) {
  15937. datakey = field.templateOptions.modelreasondata
  15938. }
  15939. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  15940. if (!field.templateOptions.options) {
  15941. field.templateOptions.options = [];
  15942. }
  15943. if (field.templateOptions.optionsDataKey) {
  15944. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  15945. } else {
  15946. field.templateOptions.options = result;
  15947. }
  15948. });
  15949. }
  15950. }
  15951. //获取表单后数据处理
  15952. function formfield(field, result) {
  15953. // angular.forEach(fields.fields, function(field) {
  15954. if (field.key == "") {
  15955. delete field.key;
  15956. }
  15957. if (angular.isDefined(field.extjson)) {
  15958. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  15959. angular.extend(field.templateOptions, extObj.templateOptions);
  15960. delete extObj.templateOptions;
  15961. for (var prop in extObj) {
  15962. if (new RegExp("Expression").test(prop)) {
  15963. //var obj = $scope.$eval(extObj[prop]);
  15964. //extObj[prop] = $scope.$eval(extObj[prop]);
  15965. if (extObj[prop] != null) {
  15966. if (new RegExp("function").test(extObj[prop])) {
  15967. var propValue = eval(extObj[prop]);
  15968. extObj[prop] = propValue;
  15969. } else {
  15970. //console.log(extObj[prop]);
  15971. var obj = $scope.$eval(extObj[prop]);
  15972. extObj[prop] = obj;
  15973. //console.log(obj);
  15974. }
  15975. }
  15976. } else if (new RegExp("expressionProperties").test(prop)) {
  15977. for (var p in extObj[prop]) {
  15978. if (new RegExp("function").test(extObj[prop][p])) {
  15979. var propValue = eval(extObj[prop][p]);
  15980. extObj[prop][p] = propValue;
  15981. } else {
  15982. //if(p.indexOf("'")>=0){
  15983. // var obj = $scope.$eval(extObj[prop][p]);
  15984. // extObj[prop][$scope.$eval(p)]=obj;
  15985. //}
  15986. }
  15987. }
  15988. } else if ("watcher" == prop) {
  15989. if (angular.isArray(extObj[prop])) {
  15990. angular.forEach(extObj[prop], function (item, index) {
  15991. for (var p in item) {
  15992. if (new RegExp("function").test(item[p])) {
  15993. var propValue = eval(item[p]);
  15994. extObj[prop][index][p] = propValue;
  15995. }
  15996. }
  15997. });
  15998. } else if (angular.isObject(extObj[prop])) {
  15999. for (var p in extObj[prop]) {
  16000. if (new RegExp("function").test(extObj[prop][p])) {
  16001. var propValue = eval(extObj[prop][p]);
  16002. extObj[prop][p] = propValue;
  16003. }
  16004. }
  16005. }
  16006. }
  16007. }
  16008. angular.extend(field, extObj);
  16009. delete field.extjson;
  16010. }
  16011. if (angular.isDefined(field.templateOptions)) {
  16012. var templateOs = field.templateOptions;
  16013. // console.log(templateOs,'come')
  16014. for (var property in templateOs) {
  16015. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  16016. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  16017. if (new RegExp("function").test(templateOs[property])) {
  16018. var propValue = eval(templateOs[property]);
  16019. field.templateOptions[property] = propValue;
  16020. } else {
  16021. if (that.has(templateOs[property])) {
  16022. field.templateOptions[property] = that.get(templateOs[property]);
  16023. } else {
  16024. field.templateOptions[property] = templateOs[property];
  16025. }
  16026. }
  16027. } else if (templateOs[property] == null) {
  16028. //delete field.templateOptions[property];
  16029. } else { }
  16030. }
  16031. }
  16032. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  16033. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  16034. angular.extend(field.templateOptions, extObj);
  16035. delete field.templateOptions.extjson;
  16036. }
  16037. // ...
  16038. if (field.templateOptions) {
  16039. //处理远程获取数据控件方法调用
  16040. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  16041. // if (!field.templateOptions.isnoreash) {
  16042. field.templateOptions.refresh = refreshSelectOptions;
  16043. // }
  16044. }
  16045. //处理嵌套属性数据绑定/
  16046. if (field.templateOptions.pkey) {
  16047. var pmodel, i = 0;
  16048. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  16049. if (i == 0) {
  16050. if (result.model[p] == null) {
  16051. result.model[p] = {};
  16052. }
  16053. pmodel = result.model[p];
  16054. i++;
  16055. } else {
  16056. if (pmodel[p] == null) {
  16057. pmodel[p] = {};
  16058. }
  16059. pmodel = pmodel[p];
  16060. }
  16061. });
  16062. if (pmodel != null) {
  16063. field.model = pmodel;
  16064. if (pmodel[field.key] == null) {
  16065. pmodel[field.key] = null;
  16066. }
  16067. }
  16068. } else {
  16069. if (result.model[field.key] == null) {
  16070. result.model[field.key] = null;
  16071. }
  16072. }
  16073. //处理弹出框组件初始化
  16074. if (field.type == "ui-input-selectmodal") {
  16075. field.templateOptions.modal = $modal;
  16076. //field.templateOptions.Restangular = Restangular;
  16077. } else if (field.type == "ui-requesterselect") {
  16078. //field.templateOptions.language = $scope.lang;
  16079. field.templateOptions.modal = $modal;
  16080. field.templateOptions.UserService = api_user_data;
  16081. } else if (field.type == "ui-deptinformation") {
  16082. field.templateOptions.modal = $modal;
  16083. field.templateOptions.UserService = api_user_data;
  16084. } else if (field.type == "ui-requesterinformation") {
  16085. field.templateOptions.modal = $modal;
  16086. field.templateOptions.UserService = api_user_data;
  16087. } else if (field.type == "ui-userselect") {
  16088. field.templateOptions.modal = $modal;
  16089. //field.templateOptions.Restangular = Restangular;
  16090. } else if (field.type == "ui-userselectSearch") {
  16091. field.templateOptions.modal = $modal;
  16092. //field.templateOptions.Restangular = Restangular;
  16093. } else if (field.type == "ui-multiuserselect") {
  16094. field.templateOptions.modal = $modal;
  16095. } else if (field.type == "ui-stringuserselect") {
  16096. field.templateOptions.modal = $modal;
  16097. } else if (field.type == "ui-search") {
  16098. field.templateOptions.modal = $modal;
  16099. } else if (field.type == "ui-modelselect") {
  16100. field.templateOptions.modal = $modal;
  16101. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16102. field.templateOptions.loginUser = $rootScope.user;
  16103. //field.templateOptions.Restangular = Restangular;
  16104. } else if (field.type == "ui-incidentmodelselect") {
  16105. field.templateOptions.modal = $modal;
  16106. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16107. field.templateOptions.loginUser = $rootScope.user;
  16108. //field.templateOptions.Restangular = Restangular;
  16109. } else if (field.type == "ui-dropfile") {
  16110. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16111. url: '/uploader'
  16112. });
  16113. field.templateOptions.taskId = $stateParams.taskId;
  16114. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16115. field.templateOptions.userId = $rootScope.user.id;
  16116. } else if (field.type == "ui-dropfielknow") {
  16117. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16118. url: '/uploader'
  16119. });
  16120. field.templateOptions.taskId = $stateParams.taskId;
  16121. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16122. field.templateOptions.userId = $rootScope.user.id;
  16123. } else if (field.type == "ui-upDropFile") {
  16124. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16125. url: '/uploader'
  16126. });
  16127. field.templateOptions.taskId = $stateParams.taskId;
  16128. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16129. field.templateOptions.userId = $rootScope.user.id;
  16130. } else if (field.type == "ui-dropfilenotup") {
  16131. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16132. url: '/uploader'
  16133. });
  16134. field.templateOptions.taskId = $stateParams.taskId;
  16135. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16136. field.templateOptions.userId = $rootScope.user.id;
  16137. //field.ApiService=api_bpm_domain;
  16138. } else if (field.type == "ui-uploadFiles") {
  16139. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16140. url: '/uploader'
  16141. });
  16142. field.templateOptions.taskId = $stateParams.taskId;
  16143. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16144. field.templateOptions.userId = $rootScope.user.id;
  16145. //field.ApiService=api_bpm_domain;
  16146. } else if (field.type == "ui-upDownFiles") {
  16147. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16148. url: '/uploader'
  16149. });
  16150. field.templateOptions.taskId = $stateParams.taskId;
  16151. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16152. field.templateOptions.userId = $rootScope.user.id;
  16153. //field.ApiService=api_bpm_domain;
  16154. } else if (field.type == "ui-uploadImgs") {
  16155. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16156. url: '/uploader'
  16157. });
  16158. field.templateOptions.taskId = $stateParams.taskId;
  16159. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16160. field.templateOptions.userId = $rootScope.user.id;
  16161. //field.ApiService=api_bpm_domain;
  16162. } else if (field.type == "ui-dropfiletable") {
  16163. if (field.templateOptions.processInstanceId) {
  16164. } else {
  16165. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16166. }
  16167. } else if (field.type == "ui-dropFiles") {
  16168. if (field.templateOptions.processInstanceId) {
  16169. } else {
  16170. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16171. }
  16172. } else if (field.type == "ui-showImgs") {
  16173. if (field.templateOptions.processInstanceId) {
  16174. } else {
  16175. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16176. }
  16177. } else if (field.type == "ui-repeatSection") {
  16178. var repeatForm = {
  16179. model: {
  16180. },
  16181. fields: field.templateOptions.fields
  16182. };
  16183. repeatForm.model[field.key] = [];
  16184. decodeVMForm(repeatForm);
  16185. } else if (field.type == "ui-currentuser") {
  16186. field.templateOptions.user = vm.model["loginUser"];
  16187. } else if (field.type == "ui-workernumbersign") {
  16188. field.templateOptions.user = vm.model["loginUser"];
  16189. } else if (field.type == "ui-repair-photos") {
  16190. field.templateOptions.user = vm.model["loginUser"];
  16191. }
  16192. }
  16193. }
  16194. //解析自定义表单设计数据
  16195. $scope.oldfromtype = true;
  16196. function decodeVMForm(vmForm) {
  16197. if (vmForm.formType == "1") {
  16198. $scope.oldfromtype = false;
  16199. } else {
  16200. $scope.oldfromtype = true;
  16201. }
  16202. var result = {
  16203. model: {},
  16204. fields: []
  16205. };
  16206. //设置模型实体数据 begin
  16207. // var mdata = vmForm.model;
  16208. //解析数据实体
  16209. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  16210. angular.extend(result.model, mdata);
  16211. if (modelWatch != null && modelWatch != '') {
  16212. //angular.extend(result.model.incident,modelWatch.incident);
  16213. //result.model.alarmType = modelWatch.alarmType;
  16214. // vmForm.cancelUrl = modelWatch.cancelUrl;
  16215. // console.log(modelWatch.cancelUrl)
  16216. for (var index in modelWatch.model) {
  16217. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  16218. if (result.model[index] != null) {
  16219. angular.extend(result.model[index], modelWatch.model[index]);
  16220. } else {
  16221. result.model[index] = modelWatch.model[index];
  16222. }
  16223. }
  16224. }
  16225. //设置模型实体数据 end
  16226. //解析设计数据生成表单项 begin
  16227. var fields = [];
  16228. //处理修改设计数据中展示设置
  16229. angular.forEach(vmForm.fields, function (fields) {
  16230. if (vmForm.formType == "1") {
  16231. angular.forEach(fields.fields, function (field) {
  16232. formfield(field, result);
  16233. });
  16234. } else {
  16235. formfield(fields, result);
  16236. }
  16237. // console.log(field);
  16238. result.fields.push(fields);
  16239. });
  16240. angular.extend($scope.vm.fields, result.fields);
  16241. angular.extend($scope.vm.model, result.model);
  16242. vm.model["loginUser"] = $rootScope.user;
  16243. //增加识别报修主体seimin
  16244. vm.model.repairType = $scope.repairMain.valueconfig;
  16245. if(vm.model.incident){
  16246. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  16247. }
  16248. console.log(vm, 'repairType')//lmm
  16249. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  16250. vmForm.cancelUrl = modelWatch.cancelUrl;
  16251. }
  16252. $scope.formData = vmForm;
  16253. console.log($scope.formData,4444444)
  16254. // console.log($scope.formData.url);
  16255. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  16256. if ($scope.formData.url == "start") {
  16257. $scope.Reset = true;
  16258. $scope.close = true;
  16259. $rootScope.isMask = false;
  16260. } else if ($scope.formData.url == "complete") {
  16261. $scope.Reset = false;
  16262. $scope.close = true;
  16263. }
  16264. //解析设计数据生成表单项 end
  16265. return result;
  16266. }
  16267. //======================处理表单设计数据 结束========================
  16268. $scope.ldloading = {};
  16269. function filter(obj) {
  16270. angular.forEach(obj, function (key, value) {
  16271. if (value === "" || value === null) {
  16272. delete obj[key];
  16273. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  16274. filter(value);
  16275. } else if (angular.isArray(value)) {
  16276. angular.forEach(value, function (item) {
  16277. filter(item);
  16278. });
  16279. }
  16280. });
  16281. }
  16282. $scope.closeModel = function () {
  16283. // console.log($stateParams);
  16284. $state.go($scope.formData.cancelUrl, {});
  16285. event.preventDefault();
  16286. };
  16287. // console.log(vm);
  16288. // 暂存
  16289. $scope.save = function (data) {
  16290. console.log(vm)
  16291. if (vm.model.startSave) {
  16292. vm.model["initUser"] = $rootScope.user.id;
  16293. vm.model.start_code = "temporary";
  16294. //处理请求数据0327
  16295. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16296. delete data0327.repairType;
  16297. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16298. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16299. data0327.incident.place = {
  16300. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16301. }
  16302. }
  16303. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16304. if (response) {
  16305. var resData = Restangular.stripRestangular(response);
  16306. if (resData) {
  16307. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16308. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16309. angular.extend(item.headers, $rootScope.getSession());
  16310. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16311. item.formData.push({
  16312. 'fileName': item.file.name
  16313. });
  16314. //console.log();
  16315. };
  16316. $scope.fileUploader.uploadAll();
  16317. }
  16318. }
  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 if (vm.model.saveAgain) {
  16338. var toData = {
  16339. "incident": vm.model.incident
  16340. };
  16341. api_user_data.updData("incident", toData).then(function (response) {
  16342. if (response) {
  16343. var resData = Restangular.stripRestangular(response);
  16344. SweetAlert.swal({
  16345. title: "提交成功!",
  16346. type: "success",
  16347. confirmButtonColor: "#007AFF"
  16348. }, function () {
  16349. $state.go($scope.formData.cancelUrl);
  16350. });
  16351. } else {
  16352. SweetAlert.swal({
  16353. title: "系统错误",
  16354. text: "系统错误,请稍后重试!",
  16355. type: "error",
  16356. confirmButtonColor: "#DD6B55"
  16357. });
  16358. }
  16359. $scope.ldloading[style.replace('-', '_')] = false;
  16360. });
  16361. event.preventDefault();
  16362. } else {
  16363. SweetAlert.swal({
  16364. title: "系统错误",
  16365. text: "系统错误,请稍后重试!",
  16366. type: "error",
  16367. confirmButtonColor: "#DD6B55"
  16368. });
  16369. }
  16370. }
  16371. // 巡检生成事件
  16372. $scope.inspectionToIncident = function () {
  16373. var userData = {
  16374. "idx": 0,
  16375. "sum": 10,
  16376. "requester": {
  16377. "name": loginUser.name
  16378. }
  16379. }
  16380. api_user_data.fetchDataList("requester", userData).then(function (res) {
  16381. console.log(res);
  16382. var toUser = {};
  16383. if (res.list.length > 0) {
  16384. toUser = res.list[0]
  16385. } else {
  16386. toUser = loginUser
  16387. }
  16388. console.log(vm);
  16389. var incidentDescription = "";
  16390. console.log($stateParams.formUiEdit);
  16391. if ($stateParams.formUiEdit == "inspection_confirm") {
  16392. if (vm.model.wnCheckEnable) {
  16393. incidentDescription = incidentDescription.concat(" 机房温度检查异常")
  16394. }
  16395. if (vm.model.sdCheckEnable) {
  16396. incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
  16397. }
  16398. if (vm.model.xfjCheckEnable) {
  16399. incidentDescription = incidentDescription.concat(" 新风机检查异常")
  16400. }
  16401. if (vm.model.lsCheckEnable) {
  16402. incidentDescription = incidentDescription.concat(" 漏水检查异常")
  16403. }
  16404. if (vm.model.xfCheckEnable) {
  16405. incidentDescription = incidentDescription.concat(" 消防检查异常")
  16406. }
  16407. if (vm.model.upsCheckEnable) {
  16408. incidentDescription = incidentDescription.concat(" UPS供电检查异常")
  16409. }
  16410. if (vm.model.dcCheckEnable) {
  16411. incidentDescription = incidentDescription.concat(" 电池连接检查异常")
  16412. }
  16413. if (vm.model.plCheckEnable) {
  16414. incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
  16415. }
  16416. if (vm.model.wjtdCheckEnable) {
  16417. incidentDescription = incidentDescription.concat(" 外机通道检查异常")
  16418. }
  16419. if (vm.model.descriptionTextarea) {
  16420. incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
  16421. }
  16422. }
  16423. // console.log(incidentDescription)
  16424. var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
  16425. var formdata = {
  16426. 'model': {
  16427. // 'isInspection': true,
  16428. // 'start_code':'assignment',
  16429. // 'isHandlerUser':false,
  16430. 'incident': {
  16431. 'requester':bxr ,
  16432. 'area': bxr.place.area,
  16433. 'place': bxr.place,
  16434. 'houseNumber': bxr.houseNumber,
  16435. 'contacts': bxr.name,
  16436. 'contactsInformation': bxr.mphone,
  16437. // 'category': data.wxIncidentClassifyDTO.category,
  16438. 'description': incidentDescription,
  16439. 'source': {
  16440. 'id': 1552
  16441. },
  16442. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  16443. // 'sourceType': data.incident.sourceType,
  16444. // 'fileUrl': data.incident.fileUrl
  16445. },
  16446. // 'requestershow': toUser,//2020年4月27日22:29:15
  16447. // 'flow': data.incident.id
  16448. // 'assignee': loginUser.id//2020年4月27日22:29:25
  16449. }
  16450. }
  16451. // console.log(formdata,toUser,'1111');
  16452. console.log(formdata,'1111');
  16453. // return;
  16454. $state.go("app.incident.chart", {
  16455. 'model': JSON.stringify(formdata)
  16456. });
  16457. })
  16458. // var formdata = {
  16459. // model:$rootScope.login_requester
  16460. // };
  16461. // console.log(formdata,'00000')
  16462. // return;
  16463. // $state.go("app.incident.chart", {
  16464. // 'model': JSON.stringify(formdata)
  16465. // });
  16466. event.preventDefault();
  16467. };
  16468. // console.log(vm);
  16469. // 创建事件seimin
  16470. vm.submit = function (data, style) {
  16471. console.log(vm,22222);
  16472. if (vm.model.handler_code == undefined) {
  16473. vm.model.handler_code = "resolve";
  16474. }
  16475. if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
  16476. delete vm.model.change.requestingPerson.menu;
  16477. }
  16478. // var pdKey = $stateParams.pdKey;
  16479. if (vm.form.$valid) {
  16480. if (data.incident && data.incident.synergetic) {
  16481. console.log(data.incident.synergetic);
  16482. var synergetic = [];
  16483. for (var i = 0; i < data.incident.synergetic.length; i++) {
  16484. synergetic.push({
  16485. id: data.incident.synergetic[i]
  16486. });
  16487. }
  16488. data.incident.synergetic = synergetic;
  16489. vm.model.incident.synergetic = synergetic;
  16490. }
  16491. $scope.ldloading[style.replace('-', '_')] = true;
  16492. var startsub = true;
  16493. if (pdKey == 'bpm_incident') {
  16494. angular.forEach(vm.fields, function (item) {
  16495. angular.forEach(item.fields, function (index) {
  16496. if (index.templateOptions.required && !index.hide) {
  16497. if (index.model) {
  16498. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  16499. if (index.model[index.key].id && index.model[index.key].id == '') {
  16500. startsub = false;
  16501. $scope.ldloading.expand_right = false;
  16502. SweetAlert.swal({
  16503. title: index.templateOptions.label + '未填',
  16504. text: "请填写此项!",
  16505. type: "error",
  16506. confirmButtonColor: "#DD6B55"
  16507. });
  16508. } else { }
  16509. } else {
  16510. startsub = false;
  16511. $scope.ldloading.expand_right = false;
  16512. SweetAlert.swal({
  16513. title: index.templateOptions.label + '未填',
  16514. text: "请填写此项!",
  16515. type: "error",
  16516. confirmButtonColor: "#DD6B55"
  16517. });
  16518. }
  16519. } else {
  16520. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  16521. } else {
  16522. startsub = false;
  16523. $scope.ldloading.expand_right = false;
  16524. SweetAlert.swal({
  16525. title: index.templateOptions.label + '未填',
  16526. text: "请填写此项!",
  16527. type: "error",
  16528. confirmButtonColor: "#DD6B55"
  16529. });
  16530. }
  16531. }
  16532. }
  16533. })
  16534. })
  16535. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  16536. // startsub = false;
  16537. // $scope.ldloading.expand_right = false;
  16538. // SweetAlert.swal({
  16539. // title: '保修人未填',
  16540. // text: "请填写此项!",
  16541. // type: "error",
  16542. // confirmButtonColor: "#DD6B55"
  16543. // });
  16544. // }
  16545. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  16546. // } else {
  16547. // startsub = false;
  16548. // $scope.ldloading.expand_right = false;
  16549. // SweetAlert.swal({
  16550. // title: '事件分类未填',
  16551. // text: "请填写此项!",
  16552. // type: "error",
  16553. // confirmButtonColor: "#DD6B55"
  16554. // });
  16555. // }
  16556. }
  16557. if (startsub) {
  16558. $scope.ldloading[style.replace('-', '_')] = true;
  16559. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  16560. // console.log("vm.options:"+ JSON.stringify(vm.options));
  16561. vm.options.updateInitialValue();
  16562. // console.log("dfjkasdhfkhskjf ")
  16563. var _ = window._;
  16564. vm.model = (function filter(obj) {
  16565. var dateTransKeys = [];
  16566. var filtered = _.pick(obj, function (v, k, obj) {
  16567. if (_.isDate(v)) {
  16568. dateTransKeys.push(k);
  16569. }
  16570. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  16571. });
  16572. return _.cloneDeep(filtered, function (v, index, object) {
  16573. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  16574. angular.forEach(dateTransKeys, function (item) {
  16575. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  16576. })
  16577. dateTransKey = [];
  16578. return v;
  16579. }
  16580. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  16581. });
  16582. })(vm.model);
  16583. if (pdKey != "") {
  16584. if ($scope.oprcode == "save") { //保存
  16585. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  16586. if (response) {
  16587. var resData = Restangular.stripRestangular(response);
  16588. SweetAlert.swal({
  16589. title: "保存成功!",
  16590. confirmButtonColor: "#007AFF"
  16591. }, function () {
  16592. $state.go($scope.formData.cancelUri);
  16593. });
  16594. // if(resData.status){
  16595. // resData
  16596. // }
  16597. } else {
  16598. SweetAlert.swal({
  16599. title: "系统错误",
  16600. text: "系统错误,请稍后重试!",
  16601. type: "error",
  16602. confirmButtonColor: "#DD6B55"
  16603. });
  16604. }
  16605. $scope.ldloading[style.replace('-', '_')] = false;
  16606. });
  16607. } else {
  16608. console.log($scope.formData.url,'zzzz')
  16609. switch ($scope.formData.url) {
  16610. case "start":
  16611. vm.model["initUser"] = $rootScope.user.id;
  16612. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  16613. } else {
  16614. vm.model["assignee"] = $rootScope.user.id;
  16615. }
  16616. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  16617. vm.model.candidateGroups = vm.model.candidateGroups.id;
  16618. }
  16619. if (pdKey == 'bpm_service_request') {
  16620. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  16621. angular.extend(vm.model.serviceCatalogueProcessActual, {
  16622. 'category': {
  16623. 'id': $stateParams.userId
  16624. }
  16625. });
  16626. }
  16627. if (vm.model.schedule && vm.model.schedule.initUser) {
  16628. delete vm.model.schedule.initUser.menu
  16629. }
  16630. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16631. delete vm.model.candidateGroups
  16632. }
  16633. if (vm.model.start_code == 'close') {
  16634. // 直接处理
  16635. vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
  16636. delete vm.model.incident.handlerUser
  16637. delete vm.model.candidateGroups;
  16638. } else if (vm.model.start_code == 'assignment') {
  16639. // 派单
  16640. delete vm.model.incident.handlingPersonnelUser
  16641. }
  16642. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  16643. $scope.jry_processInstanceId = $stateParams.processInstanceId;
  16644. }
  16645. if ($scope.jry_processInstanceId) {
  16646. vm.model["save_fileId"] = $scope.jry_processInstanceId
  16647. }
  16648. //事件暂存判断
  16649. if (vm.model.saveAgain) {
  16650. if (vm.model.directClose == "1" || vm.model.directClose == true) {
  16651. vm.model.start_code = "assignment";
  16652. vm.model.temporary_code = "assignment";
  16653. } else {
  16654. vm.model.start_code = "close";
  16655. vm.model.temporary_code = "close"
  16656. };
  16657. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16658. delete vm.model.candidateGroups
  16659. }
  16660. }
  16661. //处理请求数据0327
  16662. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16663. delete data0327.repairType;
  16664. // 增加地点的请求参数2020年4月24日10:44:36
  16665. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16666. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16667. data0327.incident.place = {
  16668. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16669. }
  16670. }
  16671. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16672. // console.log("response="+JSON.stringify(response));
  16673. if (response) {
  16674. var resData = Restangular.stripRestangular(response);
  16675. if (resData) {
  16676. if (resData) {
  16677. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16678. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16679. angular.extend(item.headers, $rootScope.getSession());
  16680. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16681. item.formData.push({
  16682. 'fileName': item.file.name
  16683. });
  16684. //console.log();
  16685. };
  16686. $scope.fileUploader.uploadAll();
  16687. }
  16688. }
  16689. }
  16690. SweetAlert.swal({
  16691. title: "提交成功!",
  16692. type: "success",
  16693. confirmButtonColor: "#007AFF"
  16694. }, function () {
  16695. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  16696. $rootScope.app.layout.isSidebarClosed = false;
  16697. if ($scope.login && !$rootScope.busy) {
  16698. $rootScope.setidle();
  16699. }
  16700. }
  16701. $state.go($scope.formData.cancelUrl);
  16702. });
  16703. } else {
  16704. SweetAlert.swal({
  16705. title: "系统错误",
  16706. text: "系统错误,请稍后重试!",
  16707. type: "error",
  16708. confirmButtonColor: "#DD6B55"
  16709. });
  16710. }
  16711. $scope.ldloading[style.replace('-', '_')] = false;
  16712. });
  16713. break;
  16714. case "complete":
  16715. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  16716. //console.log("complete taskId::"+$stateParams.taskId);
  16717. if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
  16718. SweetAlert.swal({
  16719. title: "处理人未填",
  16720. text: "请填写此项!",
  16721. type: "error",
  16722. confirmButtonColor: "#DD6B55"
  16723. });
  16724. return;
  16725. }
  16726. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  16727. if (response) {
  16728. var resData = Restangular.stripRestangular(response);
  16729. SweetAlert.swal({
  16730. title: "提交成功!",
  16731. type: "success",
  16732. confirmButtonColor: "#007AFF"
  16733. }, function () {
  16734. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
  16735. console.log(vm);
  16736. if (vm.model.incident) {
  16737. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  16738. // angular.extend(item.headers, $rootScope.getSession());
  16739. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16740. // item.formData.push({
  16741. // 'fileName': item.file.name
  16742. // });
  16743. // };
  16744. // $scope.fileUploader.uploadAll();
  16745. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16746. angular.extend(item.headers, $rootScope.getSession());
  16747. item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
  16748. item.formData.push({
  16749. 'fileName': item.file.name
  16750. });
  16751. //console.log();
  16752. };
  16753. $scope.fileUploader.uploadAll();
  16754. } else if (vm.model.problem) {
  16755. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16756. angular.extend(item.headers, $rootScope.getSession());
  16757. item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16758. item.formData.push({
  16759. 'fileName': item.file.name
  16760. });
  16761. };
  16762. $scope.fileUploader.uploadAll();
  16763. } else if (vm.model.change) {
  16764. }
  16765. }
  16766. $state.go($scope.formData.cancelUrl);
  16767. });
  16768. } else {
  16769. SweetAlert.swal({
  16770. title: "系统错误",
  16771. text: "系统错误,请稍后重试!",
  16772. type: "error",
  16773. confirmButtonColor: "#DD6B55"
  16774. });
  16775. }
  16776. $scope.ldloading[style.replace('-', '_')] = false;
  16777. });
  16778. break;
  16779. case "back":
  16780. $state.go($scope.formData.cancelUrl);
  16781. break;
  16782. default:
  16783. $scope.ldloading[style.replace('-', '_')] = false;
  16784. break;
  16785. }
  16786. }
  16787. // var submitFunc = api_bpm_domain[$scope.formData.url]
  16788. // if(anuglar.isFunction(submitFunc)){
  16789. // submitFunc.apply(null, pdKey)
  16790. // }
  16791. }
  16792. }
  16793. } else {
  16794. // console.log(data)
  16795. // angular.forEach(vm.form.$error.required, function(item){
  16796. // var i=(item.$name).substring(item.$name.length-2)
  16797. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  16798. // for(var i=0;i<vm.fields.length;i++){
  16799. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  16800. SweetAlert.swal({
  16801. title: vm.fields[i].templateOptions.label + '未填',
  16802. text: "请填写此项!",
  16803. type: "error",
  16804. confirmButtonColor: "#DD6B55"
  16805. });
  16806. }
  16807. // }
  16808. // angular.forEach(vm.fields,function(f){
  16809. // if(f.name == item.$name){
  16810. // f.validation.show = true;
  16811. // SweetAlert.swal({
  16812. // title: f.templateOptions.label+'未填',
  16813. // text: "请填写此项!",
  16814. // type: "error",
  16815. // confirmButtonColor: "#DD6B55"
  16816. // });
  16817. // }
  16818. // });
  16819. // })
  16820. }
  16821. };
  16822. $scope.vm = vm;
  16823. console.log($stateParams,pdKey,88888)
  16824. console.log($scope.vm,'assdfsdf')
  16825. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  16826. var processInstanceId = $stateParams.processInstanceId;
  16827. var itemId = $stateParams.dataId;
  16828. console.log($stateParams)
  16829. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  16830. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
  16831. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16832. var vmForm = Restangular.stripRestangular(responseData);
  16833. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16834. decodeVMForm(vmForm);
  16835. }
  16836. }
  16837. });
  16838. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  16839. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  16840. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16841. var vmForm = Restangular.stripRestangular(responseData);
  16842. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16843. decodeVMForm(vmForm);
  16844. }
  16845. }
  16846. });
  16847. } else {
  16848. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  16849. if (response) {
  16850. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  16851. api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
  16852. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16853. var vmForm = Restangular.stripRestangular(responseData);
  16854. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16855. decodeVMForm(vmForm);
  16856. console.log(vmForm,111111);
  16857. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  16858. console.log($scope,'今天')//2020年4月24日11:40:55
  16859. }
  16860. }
  16861. });
  16862. }
  16863. })
  16864. }
  16865. } else {
  16866. // create process instance
  16867. if (pdKey != "") { //for process
  16868. if (pdKey == 'bpm_service_request') {
  16869. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  16870. if (responseData) {
  16871. var vmForm = Restangular.stripRestangular(responseData);
  16872. if (vmForm) {
  16873. decodeVMForm(vmForm);
  16874. }
  16875. }
  16876. });
  16877. } else {
  16878. api_bpm_domain.startformkey(pdKey).then(function (response) {
  16879. if (response) {
  16880. var myData = Restangular.stripRestangular(response);
  16881. //myData.data = "arrangeform";
  16882. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  16883. if (responseData) {
  16884. var vmForm = Restangular.stripRestangular(responseData);
  16885. if (vmForm) {
  16886. decodeVMForm(vmForm);
  16887. }
  16888. }
  16889. });
  16890. }
  16891. });
  16892. }
  16893. } else { //for form
  16894. //TODO
  16895. //测试数据 开始
  16896. var testJson = {
  16897. fields: [{
  16898. fields: [{
  16899. className: "col-xs-12",
  16900. noFormControl: true,
  16901. key: "formtitle",
  16902. templateOptions: {
  16903. readOnly: false,
  16904. placeholder: "新建事件单",
  16905. hidden: false,
  16906. label: "事件工单",
  16907. required: false
  16908. },
  16909. type: "ui-title"
  16910. }]
  16911. }, {
  16912. fields: [{
  16913. key: 'selectUser',
  16914. type: 'ui-deptinformation',
  16915. className: 'col-xs-12',
  16916. templateOptions: {
  16917. label: '请求人信息',
  16918. modalTitle: '请求人列表',
  16919. fetchItems: function (filterData, APIService) {
  16920. return APIService.fetchDataList('requester', filterData);
  16921. },
  16922. Restangular: Restangular,
  16923. ApiService: api_user_data
  16924. // onClick:function(val, options, field, event , model){
  16925. // console.log(options);
  16926. // }
  16927. }
  16928. }]
  16929. }, {
  16930. fields: [{
  16931. key: 'first',
  16932. type: 'ui-workernumber',
  16933. className: 'col-xs-12',
  16934. templateOptions: {
  16935. type: 'input',
  16936. label: '事件单号',
  16937. pkey: 'name'
  16938. }
  16939. }]
  16940. }, {
  16941. fields: [{
  16942. type: 'ui-header',
  16943. key: 'title',
  16944. className: 'col-xs-12',
  16945. templateOptions: {
  16946. label: '报修人',
  16947. pkey: 'change'
  16948. }
  16949. }, {
  16950. type: 'ui-input',
  16951. key: 'title',
  16952. className: 'col-xs-4',
  16953. templateOptions: {
  16954. label: '报修人',
  16955. pkey: 'change'
  16956. }
  16957. }, {
  16958. type: 'ui-input',
  16959. key: 'title',
  16960. className: 'col-xs-4',
  16961. templateOptions: {
  16962. label: '联系人',
  16963. pkey: 'change'
  16964. }
  16965. }, {
  16966. type: 'ui-input',
  16967. key: 'title',
  16968. className: 'col-xs-4',
  16969. templateOptions: {
  16970. label: '联系电话',
  16971. pkey: 'change'
  16972. }
  16973. }]
  16974. }, {
  16975. fields: [{
  16976. type: 'ui-header',
  16977. key: 'title1',
  16978. className: 'col-xs-12',
  16979. templateOptions: {
  16980. label: '报修人',
  16981. pkey: 'change'
  16982. }
  16983. }, {
  16984. type: 'ui-input',
  16985. key: 'title2',
  16986. className: 'col-xs-4',
  16987. templateOptions: {
  16988. label: '报修人',
  16989. pkey: 'change'
  16990. }
  16991. }, {
  16992. type: 'ui-input',
  16993. key: 'title3',
  16994. className: 'col-xs-4',
  16995. templateOptions: {
  16996. label: '联系人',
  16997. pkey: 'change'
  16998. }
  16999. }, {
  17000. type: 'ui-input',
  17001. key: 'title4',
  17002. className: 'col-xs-4',
  17003. templateOptions: {
  17004. label: '联系电话',
  17005. pkey: 'change'
  17006. }
  17007. }]
  17008. }],
  17009. model: [{
  17010. username: "robin lau",
  17011. password: "123456",
  17012. chkme: false,
  17013. start_code: 0,
  17014. formtitle: "Hey!I am title value!",
  17015. name: {
  17016. first: "robin",
  17017. last: "lau"
  17018. },
  17019. multiselectItem: []
  17020. //date:"2015-09-15 00:00:00"
  17021. }]
  17022. // }
  17023. };
  17024. setTimeout(function () {
  17025. decodeVMForm(testJson);
  17026. $scope.$apply();
  17027. }, 500);
  17028. //测试数据结束
  17029. }
  17030. }
  17031. //console.log("end decode");
  17032. }
  17033. ]);