customformCtrl.js 793 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. overwriteOk: true,
  85. name: "bootstrapLabel",
  86. templateUrl: "assets/views/customform/tpl/normal-label.html",
  87. });
  88. //流程图
  89. formlyConfigProvider.setType({
  90. name: "ui-process",
  91. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () { },
  96. refreshDelay: 0,
  97. },
  98. };
  99. },
  100. controller: [
  101. "$scope",
  102. "$modal",
  103. "SweetAlert",
  104. "api_bpm_domain",
  105. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. $scope.processdata = [];
  107. api_bpm_domain
  108. .flowTracing($scope.model.applicationForm.processInstanceId)
  109. .then(function (data) {
  110. console.log(data);
  111. $scope.processdata = data.data;
  112. });
  113. },
  114. ],
  115. });
  116. //出库单详情
  117. formlyConfigProvider.setType({
  118. name: "ui-getoutinform",
  119. extends: "radio",
  120. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  121. defaultOptions: function (options) {
  122. return {
  123. templateOptions: {
  124. refresh: function () { },
  125. refreshDelay: 0,
  126. },
  127. };
  128. },
  129. controller: [
  130. "$scope",
  131. "$modal",
  132. "SweetAlert",
  133. "api_bpm_domain",
  134. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  135. if (
  136. angular.isDefined($scope.model.type.id) &&
  137. !$scope.model.type.name
  138. ) {
  139. if (($scope.model.type.id = 0)) {
  140. $scope.model.type.name = "新资产入库";
  141. } else if (($scope.model.type.id = 1)) {
  142. $scope.model.type.name = "新设备领用出库";
  143. } else if (($scope.model.type.id = 2)) {
  144. $scope.model.type.name = "资产归还";
  145. } else if (($scope.model.type.id = 4)) {
  146. $scope.model.type.name = "设备更换";
  147. }
  148. }
  149. },
  150. ],
  151. });
  152. //多选框组件
  153. formlyConfigProvider.setType({
  154. name: "ui-checkboxmore",
  155. extends: "radio",
  156. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  157. defaultOptions: function (options) {
  158. return {
  159. templateOptions: {
  160. refresh: function () { },
  161. refreshDelay: 0,
  162. },
  163. };
  164. },
  165. controller: [
  166. "$scope",
  167. "$modal",
  168. "SweetAlert",
  169. "api_bpm_domain",
  170. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  171. $scope.options.initialValue = $scope.model[$scope.options.key];
  172. },
  173. ],
  174. });
  175. //入库单详情
  176. formlyConfigProvider.setType({
  177. name: "ui-getininform",
  178. extends: "radio",
  179. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  180. defaultOptions: function (options) {
  181. return {
  182. templateOptions: {
  183. refresh: function () { },
  184. refreshDelay: 0,
  185. },
  186. };
  187. },
  188. controller: [
  189. "$scope",
  190. "$modal",
  191. "SweetAlert",
  192. "api_bpm_domain",
  193. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  194. if (
  195. angular.isDefined($scope.model.type.id) &&
  196. !$scope.model.type.name
  197. ) {
  198. if (($scope.model.type.id = 0)) {
  199. $scope.model.type.name = "新资产入库";
  200. } else if (($scope.model.type.id = 1)) {
  201. $scope.model.type.name = "新设备领用出库";
  202. } else if (($scope.model.type.id = 2)) {
  203. $scope.model.type.name = "资产归还";
  204. } else if (($scope.model.type.id = 4)) {
  205. $scope.model.type.name = "设备更换";
  206. }
  207. }
  208. },
  209. ],
  210. });
  211. //申请人详情
  212. formlyConfigProvider.setType({
  213. name: "ui-requsterinfom",
  214. extends: "radio",
  215. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  216. defaultOptions: function (options) {
  217. return {
  218. templateOptions: {
  219. refresh: function () { },
  220. refreshDelay: 0,
  221. },
  222. };
  223. },
  224. });
  225. //设备耗材list组件
  226. formlyConfigProvider.setType({
  227. name: "ui-uplodchange",
  228. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  229. defaultOptions: function (options) {
  230. return {
  231. templateOptions: {
  232. refresh: function () { },
  233. refreshDelay: 0,
  234. view: function (APIService, contentId) {
  235. return APIService.downloadAttachment(contentId);
  236. },
  237. },
  238. };
  239. },
  240. controller: [
  241. "$scope",
  242. "$filter",
  243. "ngTableParams",
  244. "$rootScope",
  245. "Restangular",
  246. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  247. // var data = { "haodata": [], "shedata": [] };
  248. var haodata = [];
  249. var shedata = [];
  250. if ($scope.model.consumables) {
  251. if (angular.isArray($scope.model.consumables)) {
  252. haodata = $scope.model.consumables;
  253. } else {
  254. haodata = JSON.parse($scope.model.consumables);
  255. }
  256. $scope.model.consumables = haodata;
  257. angular.forEach(haodata, function (item, index) {
  258. haodata[index].item = index + 1;
  259. });
  260. }
  261. if ($scope.model.assets) {
  262. if (angular.isArray($scope.model.assets)) {
  263. shedata = $scope.model.assets;
  264. } else {
  265. shedata = JSON.parse($scope.model.assets);
  266. }
  267. $scope.model.assets = shedata;
  268. angular.forEach(shedata, function (item, index) {
  269. shedata[index].item = index + 1;
  270. });
  271. }
  272. $scope.tableParamshao = new ngTableParams(
  273. {
  274. page: 1,
  275. count: 5,
  276. },
  277. {
  278. total: haodata.length,
  279. getData: function ($defer, params) {
  280. var orderedData = params.sorting()
  281. ? $filter("orderBy")(haodata, params.orderBy())
  282. : haodata;
  283. $defer.resolve(
  284. orderedData.slice(
  285. (params.page() - 1) * params.count(),
  286. params.page() * params.count()
  287. )
  288. );
  289. },
  290. }
  291. );
  292. $scope.tableParamsshe = new ngTableParams(
  293. {
  294. page: 1,
  295. count: 5,
  296. },
  297. {
  298. total: shedata.length,
  299. getData: function ($defer, params) {
  300. var orderedData = params.sorting()
  301. ? $filter("orderBy")(shedata, params.orderBy())
  302. : shedata;
  303. $defer.resolve(
  304. orderedData.slice(
  305. (params.page() - 1) * params.count(),
  306. params.page() * params.count()
  307. )
  308. );
  309. },
  310. }
  311. );
  312. $scope.editId = -1;
  313. $scope.setEditId = function (pid) {
  314. $scope.editId = pid;
  315. };
  316. if (angular.isUndefined($scope.form.dropState)) {
  317. $scope.form.dropState = false;
  318. }
  319. var to = $scope.options.templateOptions;
  320. var bindId = $scope.model.processInstanceId;
  321. //获取附件列表
  322. $scope.listAttachmen = function () {
  323. to.ApiService.listAttachment(
  324. to.listAttachmentUrl,
  325. to.bindType,
  326. bindId
  327. ).then(function (result) {
  328. var myData = Restangular.stripRestangular(result);
  329. // $scope.listAttachmens = myData;
  330. $scope.attachments = myData.data;
  331. });
  332. };
  333. $scope.listAttachmen();
  334. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  335. // $scope.listAttachmen();
  336. // } else if (to.bindType && $scope.model[to.bindType].id) {
  337. // $scope.listAttachmen();
  338. // }
  339. //附件下载
  340. $scope.download = function (token, filename) {
  341. var downUrl = to.ApiService.downloadAttachment(
  342. to.downUrl,
  343. token
  344. ).getRequestedUrl();
  345. // window.open(downUrl);
  346. var a = document.createElement("a");
  347. a.href = downUrl;
  348. a.target = "_blank";
  349. a.download = filename;
  350. document.body.appendChild(a);
  351. a.click();
  352. };
  353. //附件预览
  354. $scope.view = function (id, previewUrl) {
  355. if (previewUrl) {
  356. window.open(previewUrl);
  357. }
  358. };
  359. },
  360. ],
  361. });
  362. //多选框组件
  363. formlyConfigProvider.setType({
  364. name: "ui-nodataimage",
  365. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  366. defaultOptions: function (options) {
  367. return {
  368. templateOptions: {
  369. refresh: function () { },
  370. refreshDelay: 0,
  371. },
  372. };
  373. },
  374. });
  375. //ui-grid list
  376. formlyConfigProvider.setType({
  377. name: "ui-gridtwolist",
  378. // extends: 'input',
  379. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  380. defaultOptions: function (options, $scope) {
  381. return {
  382. templateOptions: {},
  383. };
  384. },
  385. controller: [
  386. "$scope",
  387. "$modal",
  388. "i18nService",
  389. "SweetAlert",
  390. function ($scope, $modal, i18nService, SweetAlert) {
  391. //gridone
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = "zh-cn";
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions = {};
  396. $scope.gridOptions.data = "myDatagrid";
  397. $scope.gridOptions.enableColumnResizing = true;
  398. $scope.gridOptions.enableFiltering = true;
  399. $scope.gridOptions.enableGridMenu = false;
  400. $scope.gridOptions.enableRowSelection = true;
  401. $scope.gridOptions.showGridFooter = true;
  402. $scope.gridOptions.showColumnFooter = false;
  403. $scope.gridOptions.fastWatch = true;
  404. $scope.gridOptions.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  407. $scope.gridOptions.paginationPageSize = 10;
  408. $scope.gridOptions.multiSelect = false;
  409. $scope.myDatagrid = [];
  410. $scope.myDatagridall = [];
  411. $scope.selected = {
  412. item: {},
  413. };
  414. $scope.memoryfilterDatagrid = {
  415. idx: 0,
  416. sum: 10,
  417. };
  418. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  419. filterData = {
  420. idx: 0,
  421. sum: 10,
  422. };
  423. $scope.gridOptions.columnDefs =
  424. $scope.options.templateOptions.columnDefs;
  425. }
  426. $scope.gridOptions.rowIdentity = function (row) {
  427. return row.id;
  428. };
  429. $scope.gridOptions.getRowIdentity = function (row) {
  430. return row.id;
  431. };
  432. // $scope.gridOptions.columnDefs = items.columnDefs();
  433. $scope.interceptMydata = function (mydate, idx, sum) {
  434. return mydate.slice(idx * sum, (idx + 1) * sum);
  435. };
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged(
  439. $scope,
  440. function (newPage, pageSize) {
  441. $scope.memoryfilterDatagrid.idx = newPage - 1;
  442. $scope.memoryfilterDatagrid.sum = pageSize;
  443. $scope.myDatagrid = $scope.interceptMydata(
  444. $scope.myDatagridall,
  445. $scope.memoryfilterDatagrid.idx,
  446. 10
  447. );
  448. $scope.loadData({
  449. idx: newPage - 1,
  450. sum: pageSize,
  451. });
  452. }
  453. );
  454. gridApi.core.on.filterChanged($scope, function () { });
  455. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  456. $scope.selected.item = data.entity;
  457. //console.log(data);
  458. });
  459. };
  460. $scope.loadData = function (mydate, idx, sum) {
  461. angular.forEach($scope.myDatagrid, function (item, index) {
  462. $scope.myDatagrid[index].item = index;
  463. });
  464. $scope.gridOptions.totalItems = mydate.length;
  465. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  466. };
  467. if ($scope.model.assets) {
  468. $scope.myDatagridall = $scope.model.assets;
  469. $scope.loadData($scope.model.assets, 0, 10);
  470. }
  471. $scope.saveData = function (itemin) {
  472. event.preventDefault();
  473. var modalInstance = $modal.open({
  474. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  475. controller: function ($scope, $modalInstance, SweetAlert) {
  476. // $scope.consumptive = {};
  477. $scope.title = "填写领用设备信息";
  478. // if (items.name) {
  479. // $scope.consumptive.name = items.name.name;
  480. // }
  481. $scope.placechange = angular.copy(itemin);
  482. $scope.ok = function (item) {
  483. if (
  484. item.props &&
  485. item.props.hwnw_area &&
  486. item.props.hwnw_place &&
  487. item.props.hwnw_room &&
  488. item.props.hwnwswt_jiguihao &&
  489. item.props.hwnwswt_Ushu &&
  490. item.props.snnum
  491. ) {
  492. $modalInstance.close(item);
  493. } else {
  494. SweetAlert.swal({
  495. title: "数据填写不完整!",
  496. text: "请检查数据然后提交!",
  497. type: "error",
  498. });
  499. }
  500. };
  501. $scope.cancel = function () {
  502. $modalInstance.dismiss("cancel");
  503. };
  504. },
  505. resolve: {
  506. SweetAlert: function () {
  507. return SweetAlert;
  508. },
  509. },
  510. });
  511. modalInstance.result.then(function (selectedItem) {
  512. angular.forEach($scope.myDatagrid, function (item, index) {
  513. // $scope.myDatagrid[index].props.hw_state = "在线";
  514. if (item.id == selectedItem.id) {
  515. // $scope.myDatagrid[index] = selectedItem;
  516. angular.extend($scope.myDatagrid[index], selectedItem);
  517. }
  518. });
  519. // $scope.myData3.push(selectedItem);
  520. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  521. $scope.myDatagrid[i]["item"] =
  522. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  523. }
  524. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  525. $scope.myDatagridall;
  526. });
  527. };
  528. //gridtwo
  529. $scope.langs = i18nService.getAllLangs();
  530. $scope.lang = "zh-cn";
  531. i18nService.setCurrentLang($scope.lang);
  532. $scope.gridOptions2 = {};
  533. $scope.gridOptions2.data = "myDatagridold";
  534. $scope.gridOptions2.enableColumnResizing = true;
  535. $scope.gridOptions2.enableFiltering = true;
  536. $scope.gridOptions2.enableGridMenu = false;
  537. $scope.gridOptions2.enableRowSelection = true;
  538. $scope.gridOptions2.showGridFooter = true;
  539. $scope.gridOptions2.showColumnFooter = false;
  540. $scope.gridOptions2.fastWatch = true;
  541. $scope.gridOptions2.useExternalFiltering = false;
  542. $scope.gridOptions.useExternalPagination = true;
  543. $scope.gridOptions2.paginationPageSizes = [10];
  544. $scope.gridOptions2.paginationPageSize = 10;
  545. $scope.gridOptions2.multiSelect = false;
  546. $scope.myDatagridold = [];
  547. $scope.myDatagridoldall = [];
  548. $scope.selected = {
  549. item: {},
  550. };
  551. $scope.memoryfilterDatagridold = {
  552. idx: 0,
  553. sum: 10,
  554. };
  555. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  556. filterData = {
  557. idx: 0,
  558. sum: 10,
  559. };
  560. $scope.gridOptions2.columnDefs =
  561. $scope.options.templateOptions.columnDefstwo;
  562. }
  563. $scope.gridOptions2.rowIdentity = function (row) {
  564. return row.id;
  565. };
  566. $scope.gridOptions2.getRowIdentity = function (row) {
  567. return row.id;
  568. };
  569. // $scope.gridOptions.columnDefs = items.columnDefs();
  570. $scope.interceptMydata = function (mydate, idx, sum) {
  571. return mydate.slice(idx * sum, (idx + 1) * sum);
  572. };
  573. if ($scope.model.oldAssets) {
  574. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  575. $scope.myDatagridold = $scope.interceptMydata(
  576. $scope.myDatagridallold,
  577. $scope.memoryfilterDatagridold.idx,
  578. 10
  579. );
  580. }
  581. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  582. $scope.gridApi = gridApi;
  583. gridApi.pagination.on.paginationChanged(
  584. $scope,
  585. function (newPage, pageSize) {
  586. $scope.memoryfilterDatagridold.idx = newPage - 1;
  587. $scope.memoryfilterDatagridold.sum = pageSize;
  588. $scope.myDatagridold = $scope.interceptMydata(
  589. $scope.myDatagridallold,
  590. $scope.memoryfilterDatagridold.idx,
  591. 10
  592. );
  593. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  594. }
  595. );
  596. gridApi.core.on.filterChanged($scope, function () { });
  597. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  598. $scope.selected.item = data.entity;
  599. //console.log(data);
  600. });
  601. };
  602. // $scope.loadData = function(mydate, idx, sum) {
  603. // angular.forEach($scope.myDatagridold, function(item, index) {
  604. // $scope.myDatagridold[index].item = index;
  605. // })
  606. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  607. // }
  608. // if ($scope.model.assets) {
  609. // $scope.myDatagridallold = $scope.model.assets;
  610. // $scope.loadData($scope.model.assets, 0, 10)
  611. // }
  612. // $scope.addoldassets = function(itemin) {
  613. // event.preventDefault();
  614. // var modalInstance = $modal.open({
  615. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  616. // controller: function($scope, $modalInstance, SweetAlert) {
  617. // // $scope.consumptive = {};
  618. // $scope.title = "填写领用设备信息";
  619. // // if (items.name) {
  620. // // $scope.consumptive.name = items.name.name;
  621. // // }
  622. // $scope.placechange = itemin;
  623. // $scope.ok = function(item) {
  624. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  625. // $modalInstance.close(item);
  626. // } else {
  627. // SweetAlert.swal({
  628. // title: "数据填写不完整!",
  629. // text: "请检查数据然后提交!",
  630. // type: "error"
  631. // });
  632. // }
  633. // };
  634. // $scope.cancel = function() {
  635. // $modalInstance.dismiss('cancel');
  636. // };
  637. // },
  638. // resolve: {
  639. // SweetAlert: function() {
  640. // return SweetAlert;
  641. // }
  642. // }
  643. // });
  644. $scope.interceptMydata = function (mydate, idx, sum) {
  645. return mydate.slice(idx * sum, (idx + 1) * sum);
  646. };
  647. $scope.addshebei = function () {
  648. event.preventDefault();
  649. var modalInstance = $modal.open({
  650. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  651. controller: function (
  652. $scope,
  653. i18nService,
  654. $modalInstance,
  655. items,
  656. title,
  657. Restangular,
  658. APIService,
  659. onDataCallback,
  660. parentScope,
  661. api_configure_data,
  662. api_configure_form,
  663. api_cmdb
  664. ) {
  665. $scope.langs = i18nService.getAllLangs();
  666. $scope.lang = "zh-cn";
  667. i18nService.setCurrentLang($scope.lang);
  668. $scope.gridOptions = {};
  669. $scope.gridOptions.data = "myDatatwo";
  670. $scope.gridOptions.enableColumnResizing = true;
  671. $scope.gridOptions.enableFiltering = false;
  672. $scope.gridOptions.enableGridMenu = false;
  673. $scope.gridOptions.showGridFooter = true;
  674. $scope.gridOptions.showColumnFooter = false;
  675. $scope.gridOptions.fastWatch = true;
  676. $scope.gridOptions.useExternalFiltering = true;
  677. $scope.gridOptions.useExternalPagination = true;
  678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  679. $scope.gridOptions.paginationPageSize = 10;
  680. $scope.gridOptions.multiSelect = true;
  681. $scope.gridOptions.rowIdentity = function (row) {
  682. return row.id;
  683. };
  684. $scope.gridOptions.getRowIdentity = function (row) {
  685. return row.id;
  686. };
  687. $scope.gridOptions.columnDefs = [
  688. {
  689. name: "item",
  690. displayName: "序号",
  691. width: 80,
  692. enableFiltering: false,
  693. },
  694. {
  695. name: "uuid",
  696. displayName: "内部编号",
  697. width: 150,
  698. },
  699. {
  700. name: "props.hw_mingcheng",
  701. displayName: "资产名称",
  702. width: 100,
  703. },
  704. {
  705. name: "props.hw_cifilterClassic",
  706. displayName: "资产类型",
  707. width: 120,
  708. enableFiltering: false,
  709. },
  710. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  711. {
  712. name: "props.hw_state",
  713. displayName: "资产状态",
  714. width: 150,
  715. enableFiltering: false,
  716. },
  717. {
  718. name: "props.hwnw_area",
  719. displayName: "资产地点",
  720. width: 130,
  721. enableFiltering: false,
  722. },
  723. {
  724. name: "createtime",
  725. displayName: "申请时间",
  726. enableFiltering: false,
  727. },
  728. ];
  729. // $scope.selectButtonClick
  730. var defaultFilterData = {
  731. // "assignee":2,
  732. // "applicationForm": { "hw_state": "在线" },
  733. hw_state: "在线",
  734. idx: 0,
  735. sum: 10,
  736. };
  737. $scope.memoryfilterData = {
  738. // "assignee":2,
  739. // "applicationForm": { "hw_state": "在线" },
  740. hw_state: "在线",
  741. idx: 0,
  742. sum: 10,
  743. };
  744. $scope.refreshData = function (style, filterData) {
  745. if (angular.isUndefined(filterData)) {
  746. filterData = defaultFilterData;
  747. }
  748. $scope.myDatatwo = [];
  749. // $scope.gridOptions['sum']=filterData.sum;
  750. api_cmdb.query(filterData).then(
  751. function (data) {
  752. // $scope.callsPending--;
  753. var myDatatwo = Restangular.stripRestangular(data);
  754. $scope.gridOptions["totalItems"] = data.total;
  755. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  756. myDatatwo.data.node[i].createtime = moment(
  757. myDatatwo.data.node[i].createtime
  758. ).format("YYYY-MM-DD");
  759. }
  760. $scope.myDatatwo = myDatatwo.data.node;
  761. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  762. $scope.myDatatwo[i]["item"] =
  763. i + 1 + filterData.idx * filterData.sum;
  764. }
  765. },
  766. function () { }
  767. );
  768. };
  769. $scope.refreshData("expand-right", defaultFilterData);
  770. $scope.gridOptions.onRegisterApi = function (gridApi) {
  771. $scope.gridApi = gridApi;
  772. gridApi.pagination.on.paginationChanged(
  773. $scope,
  774. function (newPage, pageSize) {
  775. var filtersData = $scope.memoryfilterData;
  776. filtersData.idx = newPage - 1;
  777. filtersData.sum = pageSize;
  778. // $scope.loadData(filtersData);
  779. $scope.refreshData("expand-right", filtersData);
  780. //console.log(pageSize);
  781. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  782. }
  783. );
  784. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  785. // $scope.selected.items.push(data.entity);
  786. //console.log(data);
  787. gridApi.selection.on.rowSelectionChanged(
  788. $scope,
  789. function (scope, ect) {
  790. if (scope.isSelected) {
  791. scope.grid.appScope.selected.items.push(scope.entity);
  792. } else {
  793. for (
  794. var i = 0;
  795. i <= scope.grid.appScope.selected.items.length;
  796. i++
  797. ) {
  798. if (
  799. scope.grid.appScope.selected.items[i].id ==
  800. scope.entity.id
  801. ) {
  802. scope.grid.appScope.selected.items.splice(i, 1);
  803. break;
  804. }
  805. }
  806. }
  807. $scope.mySelectedRows =
  808. $scope.gridApi.selection.getSelectedRows();
  809. }
  810. );
  811. // });
  812. gridApi.selection.on.rowSelectionChangedBatch(
  813. $scope,
  814. function (rows) {
  815. // $scope.selected.items = data.entity;
  816. //console.log(data);
  817. var selectitem = [];
  818. selectitem = angular.copy($scope.selected.items);
  819. for (var j = 0; j < rows.length; j++) {
  820. if (rows[j].isSelected == true) {
  821. selectitem.push(rows[j].entity);
  822. } else {
  823. delete selectitem[j];
  824. // rows.splice(j, 1);
  825. }
  826. }
  827. $scope.selected.items = [];
  828. for (var i = 0; i < selectitem.length; i++) {
  829. if (selectitem[i]) {
  830. $scope.selected.items.push(selectitem[i]);
  831. }
  832. }
  833. }
  834. );
  835. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  836. // // if (row.entity.age > 45) {
  837. // row.grid.api.selection.selectRow(row.entity); // 选中行
  838. // // }
  839. // };
  840. gridApi.core.on.filterChanged($scope, function () {
  841. var grid = this.grid;
  842. var filtersData = {
  843. idx: 0,
  844. sum: 10,
  845. user: {
  846. roledata: {
  847. rolecode: "roleset",
  848. },
  849. selectType: "1",
  850. },
  851. };
  852. angular.forEach(grid.columns, function (item) {
  853. if (item.enableFiltering) {
  854. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  855. if (
  856. angular.isDefined(item.filters[0].term) &&
  857. item.filters[0].term != ""
  858. ) {
  859. if (angular.isUndefined(filtersData["user"])) {
  860. filtersData["user"] = {};
  861. }
  862. filtersData["user"][item.field] = item.filters[0].term;
  863. }
  864. }
  865. });
  866. $scope.memoryfilterData = filtersData;
  867. // $scope.loadData(filtersData);
  868. });
  869. };
  870. $scope.onDblClick = function (data, event) {
  871. // $scope.selected.items = data.entity;
  872. $scope.selectButtonClick(data, event);
  873. };
  874. $scope.title = title;
  875. //树形图
  876. var apple_selected, tree, treedata_avm, treedata_geography;
  877. $scope.my_tree_handler = function (branch) {
  878. //var _ref;
  879. var classify = ($scope.classify =
  880. branch.prefix.toLowerCase() + branch.sign);
  881. api_cmdb
  882. .query({
  883. sign: classify,
  884. })
  885. .then(function (data) {
  886. var myDatalingbei = Restangular.stripRestangular(data);
  887. // console.log(myData.data.node);
  888. if (myDatalingbei.data && myDatalingbei.status == 200) {
  889. var ret = myDatalingbei.data;
  890. redrawSvg(myDatalingbei);
  891. }
  892. });
  893. };
  894. $scope.my_data = [];
  895. function convertListToTree(data, treeMap) {
  896. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  897. var root = null; //Initially set our loop to null
  898. var parentNode = null;
  899. //loop over data
  900. for (var i = 0; i < data.length; i++) {
  901. var datum = data[i];
  902. //each node will have children, so let's give it a "children" poperty
  903. datum.children = [];
  904. //add an entry for this node to the map so that any future children can
  905. //lookup the parent
  906. idToNodeMap[datum.id] = datum;
  907. //Does this node have a parent?
  908. if (
  909. typeof datum.parent === "undefined" ||
  910. datum.parent == null
  911. ) {
  912. //Doesn't look like it, so this node is the root of the tree
  913. root = datum;
  914. treeMap[datum.id] = root;
  915. } else {
  916. //This node has a parent, so let's look it up using the id
  917. parentNode = idToNodeMap[datum.parent.id];
  918. //We don't need this property, so let's delete it.
  919. delete datum.parent;
  920. //Let's add the current node as a child of the parent node.
  921. parentNode.children.push(datum);
  922. }
  923. }
  924. return root;
  925. }
  926. function convertParentToChildList(data) {
  927. var treeMap = {};
  928. var list = [];
  929. convertListToTree(data, treeMap);
  930. angular.forEach(treeMap, function (item) {
  931. list.push(item);
  932. });
  933. return list;
  934. }
  935. $scope.my_tree = tree = {};
  936. $scope.try_async_load = function () {
  937. $scope.my_data = [];
  938. $scope.select_treedata = [];
  939. $scope.doing_async = true;
  940. api_configure_data
  941. .fetchDataList("ciclassify", {
  942. idx: 0,
  943. sum: 100,
  944. })
  945. .then(function (result) {
  946. //console.log(result['list']);
  947. $scope.select_treedata = $scope.my_data =
  948. convertParentToChildList(result["list"]);
  949. $scope.doing_async = false;
  950. // tree.expand_all();
  951. //console.log(treelist);
  952. });
  953. };
  954. $scope.select_treedata = [];
  955. $scope.propTypeOptions = [];
  956. $scope.try_async_load();
  957. $scope.onFilterremove = function (item) {
  958. console.log(item);
  959. };
  960. $scope.searchdata = {};
  961. $scope.clear = function () {
  962. $scope.searchdata = {};
  963. $scope.cifilter_classic = {};
  964. $scope.try_async_load();
  965. var fildata = {
  966. idx: 0,
  967. sum: 10,
  968. hw_state: "在线",
  969. };
  970. $scope.memoryfilterData = fildata;
  971. $scope.refreshData("expand-right", fildata);
  972. };
  973. $scope.chiceIncident = function (item) {
  974. var fildata = $scope.memoryfilterData;
  975. // fildata.applicationForm = {};
  976. // if (item.alltitle && item.alldata) {
  977. // fildata.applicationForm[item.alltitle.key] = item.alldata
  978. // }
  979. if (item && item.id) {
  980. var classify = item.prefix.toLowerCase() + item.sign;
  981. fildata.sign = classify;
  982. }
  983. $scope.gridOptions.paginationCurrentPage = 1;
  984. var transitiondata = angular.copy(item);
  985. $scope.refreshData("expand-right", fildata);
  986. };
  987. $scope.applicadata = [];
  988. $scope.onFilterCallback = function (item) {
  989. var tempclassify = item.prefix.toLowerCase() + item.sign;
  990. api_configure_form
  991. .renderTabForm(tempclassify)
  992. .then(function (data) {
  993. var myData = Restangular.stripRestangular(data);
  994. $scope.applicadata = myData[0].form.fields;
  995. });
  996. // }
  997. };
  998. // $scope.loadData({
  999. // idx: 0,
  1000. // sum: 10,
  1001. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1002. // });
  1003. $scope.selected = {
  1004. items: [],
  1005. };
  1006. $scope.ok = function () {
  1007. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1008. // onDataCallback($scope.selected.item, parentScope);
  1009. // }
  1010. $modalInstance.close($scope.selected.items);
  1011. };
  1012. $scope.cancel = function () {
  1013. $modalInstance.dismiss("cancel");
  1014. };
  1015. },
  1016. size: "lg",
  1017. resolve: {
  1018. items: function () {
  1019. return {
  1020. fetchItems: function (filterData, APIService) {
  1021. filterData = filterData || {};
  1022. if (
  1023. angular.isDefined(filterData.idx) &&
  1024. filterData.idx == null
  1025. ) {
  1026. filterData = {
  1027. idx: 0,
  1028. sum: 10,
  1029. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1030. };
  1031. }
  1032. return $scope.options.templateOptions.fetchItems(
  1033. filterData,
  1034. APIService
  1035. );
  1036. },
  1037. };
  1038. },
  1039. title: function () {
  1040. return $scope.options.templateOptions.label;
  1041. },
  1042. Restangular: function () {
  1043. return $scope.options.templateOptions.Restangular;
  1044. },
  1045. APIService: function () {
  1046. return $scope.options.templateOptions.ApiService;
  1047. },
  1048. onDataCallback: function () {
  1049. return $scope.options.templateOptions.callback;
  1050. },
  1051. parentScope: function () {
  1052. return $scope.options.templateOptions.that;
  1053. },
  1054. },
  1055. });
  1056. modalInstance.result.then(function (selectedItem) {
  1057. $scope.myDatagridoldall = selectedItem;
  1058. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1059. $scope.myDatagridoldall[i]["item"] =
  1060. i +
  1061. 1 +
  1062. $scope.memoryfilterDatagridold.idx *
  1063. $scope.memoryfilterDatagridold.sum;
  1064. }
  1065. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1066. $scope.myDatagridold = $scope.interceptMydata(
  1067. $scope.myDatagridoldall,
  1068. 0,
  1069. 10
  1070. );
  1071. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1072. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1073. $scope.myDatagridoldall;
  1074. $scope.options.initialValue = $scope.model.oldAssets;
  1075. });
  1076. // }
  1077. };
  1078. $scope.changestate = function (itemin) {
  1079. event.preventDefault();
  1080. var modalInstance = $modal.open({
  1081. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1082. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1083. $scope.title = "旧设备状态修改";
  1084. $scope.stateshe = [
  1085. {
  1086. id: 2,
  1087. name: "在库",
  1088. },
  1089. {
  1090. id: 4,
  1091. name: "报修",
  1092. },
  1093. {
  1094. id: 3,
  1095. name: "报废",
  1096. },
  1097. ];
  1098. $scope.hw_state = {};
  1099. $scope.ok = function (item) {
  1100. $modalInstance.close(item.id);
  1101. };
  1102. $scope.cancel = function () {
  1103. $modalInstance.dismiss("cancel");
  1104. };
  1105. },
  1106. size: "sm",
  1107. resolve: {
  1108. scope: function () {
  1109. return $scope;
  1110. },
  1111. },
  1112. });
  1113. modalInstance.result.then(function (selectedItem) {
  1114. if (selectedItem) {
  1115. angular.forEach($scope.myDatagridallold, function (item, index) {
  1116. if (item.id == itemin.id) {
  1117. $scope.myDatagridallold[index].props.hw_state =
  1118. selectedItem.name;
  1119. }
  1120. });
  1121. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1122. $scope.myDatagridallold[i]["item"] =
  1123. i +
  1124. 1 +
  1125. $scope.memoryfilterDatagridold.idx *
  1126. $scope.memoryfilterDatagridold.sum;
  1127. }
  1128. $scope.gridOptions2["totalItems"] =
  1129. $scope.myDatagridallold.length;
  1130. $scope.myDatagridold = $scope.interceptMydata(
  1131. $scope.myDatagridallold,
  1132. $scope.memoryfilterDatagridold.idx,
  1133. $scope.memoryfilterDatagridold.sum
  1134. );
  1135. // $scope.model.oldAssets = $scope.myDatagridallold;
  1136. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1137. $scope.myDatagridallold;
  1138. $scope.options.initialValue = $scope.model.oldAssets;
  1139. }
  1140. });
  1141. };
  1142. $scope.savedata = function (data) {
  1143. event.preventDefault();
  1144. var modalInstance = $modal.open({
  1145. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1146. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1147. $scope.title = "设备编辑";
  1148. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1149. $scope.ok = function (item) {
  1150. $modalInstance.close(item);
  1151. };
  1152. $scope.cancel = function () {
  1153. $modalInstance.dismiss("cancel");
  1154. };
  1155. },
  1156. size: "sm",
  1157. resolve: {
  1158. scope: function () {
  1159. return $scope;
  1160. },
  1161. },
  1162. });
  1163. modalInstance.result.then(function (selectedItem) {
  1164. if (selectedItem) {
  1165. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1166. if (item.id == data.id) {
  1167. $scope.myDatagridoldall[index].olddecription =
  1168. selectedItem.olddecription;
  1169. }
  1170. });
  1171. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1172. $scope.myDatagridoldall[i]["item"] =
  1173. i +
  1174. 1 +
  1175. $scope.memoryfilterDatagridold.idx *
  1176. $scope.memoryfilterDatagridold.sum;
  1177. }
  1178. $scope.gridOptions2["totalItems"] =
  1179. $scope.myDatagridoldall.length;
  1180. $scope.myDatagridold = $scope.interceptMydata(
  1181. $scope.myDatagridoldall,
  1182. 0,
  1183. 10
  1184. );
  1185. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1186. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1187. $scope.myDatagridoldall;
  1188. $scope.options.initialValue = $scope.model.oldAssets;
  1189. }
  1190. });
  1191. };
  1192. $scope.removeold = function (data) {
  1193. event.preventDefault();
  1194. var modalInstance = $modal.open({
  1195. templateUrl: "assets/views/delete.html",
  1196. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1197. $scope.title = "设备删除";
  1198. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1199. $scope.ok = function () {
  1200. $modalInstance.close(data);
  1201. };
  1202. $scope.cancel = function () {
  1203. $modalInstance.dismiss("cancel");
  1204. };
  1205. },
  1206. size: "sm",
  1207. resolve: {
  1208. scope: function () {
  1209. return $scope;
  1210. },
  1211. },
  1212. });
  1213. modalInstance.result.then(function (selectedItem) {
  1214. if (selectedItem) {
  1215. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1216. if (item.id == selectedItem.id) {
  1217. $scope.myDatagridoldall.splice(index, 1);
  1218. }
  1219. });
  1220. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1221. $scope.myDatagridoldall[i]["item"] =
  1222. i +
  1223. 1 +
  1224. $scope.memoryfilterDatagridold.idx *
  1225. $scope.memoryfilterDatagridold.sum;
  1226. }
  1227. $scope.gridOptions2["totalItems"] =
  1228. $scope.myDatagridoldall.length;
  1229. $scope.myDatagridold = $scope.interceptMydata(
  1230. $scope.myDatagridoldall,
  1231. 0,
  1232. 10
  1233. );
  1234. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1235. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1236. $scope.myDatagridoldall;
  1237. $scope.options.initialValue = $scope.model.oldAssets;
  1238. }
  1239. });
  1240. };
  1241. },
  1242. ],
  1243. });
  1244. //ui-grid list
  1245. formlyConfigProvider.setType({
  1246. name: "ui-gridlist",
  1247. extends: "input",
  1248. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1249. defaultOptions: function (options, $scope) {
  1250. return {
  1251. templateOptions: {},
  1252. };
  1253. },
  1254. controller: [
  1255. "$scope",
  1256. "$modal",
  1257. "i18nService",
  1258. "SweetAlert",
  1259. function ($scope, $modal, i18nService, SweetAlert) {
  1260. //gridone
  1261. $scope.langs = i18nService.getAllLangs();
  1262. $scope.lang = "zh-cn";
  1263. i18nService.setCurrentLang($scope.lang);
  1264. $scope.gridOptions = {};
  1265. $scope.gridOptions.data = "myDatagrid";
  1266. $scope.gridOptions.enableColumnResizing = true;
  1267. $scope.gridOptions.enableFiltering = true;
  1268. $scope.gridOptions.enableGridMenu = false;
  1269. $scope.gridOptions.enableRowSelection = true;
  1270. $scope.gridOptions.showGridFooter = true;
  1271. $scope.gridOptions.showColumnFooter = false;
  1272. $scope.gridOptions.fastWatch = true;
  1273. $scope.gridOptions.useExternalFiltering = false;
  1274. // $scope.gridOptions.useExternalPagination = true;
  1275. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1276. $scope.gridOptions.paginationPageSize = 10;
  1277. $scope.gridOptions.multiSelect = false;
  1278. $scope.myDatagrid = [];
  1279. $scope.myDatagridall = [];
  1280. $scope.selected = {
  1281. item: {},
  1282. };
  1283. $scope.memoryfilterDatagrid = {
  1284. idx: 0,
  1285. sum: 10,
  1286. };
  1287. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1288. filterData = {
  1289. idx: 0,
  1290. sum: 10,
  1291. };
  1292. $scope.gridOptions.columnDefs =
  1293. $scope.options.templateOptions.columnDefs;
  1294. }
  1295. $scope.gridOptions.rowIdentity = function (row) {
  1296. return row.id;
  1297. };
  1298. $scope.gridOptions.getRowIdentity = function (row) {
  1299. return row.id;
  1300. };
  1301. // $scope.gridOptions.columnDefs = items.columnDefs();
  1302. $scope.interceptMydata = function (mydate, idx, sum) {
  1303. return mydate.slice(idx * sum, (idx + 1) * sum);
  1304. };
  1305. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1306. $scope.gridApi = gridApi;
  1307. gridApi.pagination.on.paginationChanged(
  1308. $scope,
  1309. function (newPage, pageSize) {
  1310. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1311. $scope.memoryfilterDatagrid.sum = pageSize;
  1312. $scope.myDatagrid = $scope.interceptMydata(
  1313. $scope.myDatagridall,
  1314. $scope.memoryfilterDatagrid.idx,
  1315. 10
  1316. );
  1317. $scope.loadData({
  1318. idx: newPage - 1,
  1319. sum: pageSize,
  1320. });
  1321. }
  1322. );
  1323. gridApi.core.on.filterChanged($scope, function () { });
  1324. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1325. $scope.selected.item = data.entity;
  1326. //console.log(data);
  1327. });
  1328. };
  1329. $scope.loadData = function (mydate, idx, sum) {
  1330. angular.forEach($scope.myDatagrid, function (item, index) {
  1331. $scope.myDatagrid[index].item = index;
  1332. });
  1333. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1334. };
  1335. if ($scope.model.assets) {
  1336. $scope.myDatagridall = $scope.model.assets;
  1337. $scope.loadData($scope.model.assets, 0, 10);
  1338. }
  1339. $scope.saveData = function (itemin) {
  1340. event.preventDefault();
  1341. var modalInstance = $modal.open({
  1342. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1343. controller: function ($scope, $modalInstance, SweetAlert) {
  1344. // $scope.consumptive = {};
  1345. $scope.title = "填写领用设备信息";
  1346. // if (items.name) {
  1347. // $scope.consumptive.name = items.name.name;
  1348. // }
  1349. $scope.placechange = angular.copy(itemin);
  1350. $scope.ok = function (item) {
  1351. if (
  1352. item.props &&
  1353. item.props.hwnw_area &&
  1354. item.props.hwnw_place &&
  1355. item.props.hwnw_room &&
  1356. item.props.hwnwswt_jiguihao &&
  1357. item.props.hwnwswt_Ushu &&
  1358. item.props.snnum
  1359. ) {
  1360. $modalInstance.close(item);
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "数据填写不完整!",
  1364. text: "请检查数据然后提交!",
  1365. type: "error",
  1366. });
  1367. }
  1368. };
  1369. $scope.cancel = function () {
  1370. $modalInstance.dismiss("cancel");
  1371. };
  1372. },
  1373. resolve: {
  1374. SweetAlert: function () {
  1375. return SweetAlert;
  1376. },
  1377. },
  1378. });
  1379. modalInstance.result.then(function (selectedItem) {
  1380. angular.forEach($scope.myDatagrid, function (item, index) {
  1381. if (item.id == selectedItem.id) {
  1382. angular.extend($scope.myDatagrid[index], selectedItem);
  1383. }
  1384. });
  1385. // $scope.myData3.push(selectedItem);
  1386. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1387. $scope.myDatagrid[i]["item"] =
  1388. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1389. }
  1390. // $scope.model.assets = $scope.myDatagridall;
  1391. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1392. $scope.myDatagridall;
  1393. });
  1394. };
  1395. },
  1396. ],
  1397. });
  1398. //设备耗材list组件
  1399. formlyConfigProvider.setType({
  1400. name: "ui-shehaolist",
  1401. // extends: 'radio',
  1402. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1403. defaultOptions: function (options) {
  1404. return {
  1405. templateOptions: {
  1406. refresh: function () { },
  1407. refreshDelay: 0,
  1408. },
  1409. };
  1410. },
  1411. controller: [
  1412. "$scope",
  1413. "$filter",
  1414. "ngTableParams",
  1415. function ($scope, $filter, ngTableParams) {
  1416. // var data = { "haodata": [], "shedata": [] };
  1417. var haodata = [];
  1418. var shedata = [];
  1419. if ($scope.model.consumables) {
  1420. if (angular.isArray($scope.model.consumables)) {
  1421. haodata = $scope.model.consumables;
  1422. } else {
  1423. haodata = JSON.parse($scope.model.consumables);
  1424. }
  1425. $scope.model.consumables = haodata;
  1426. angular.forEach(haodata, function (item, index) {
  1427. haodata[index].item = index + 1;
  1428. });
  1429. }
  1430. if ($scope.model.assets) {
  1431. if (angular.isArray($scope.model.assets)) {
  1432. shedata = $scope.model.assets;
  1433. } else {
  1434. shedata = JSON.parse($scope.model.assets);
  1435. }
  1436. $scope.model.assets = shedata;
  1437. angular.forEach(shedata, function (item, index) {
  1438. shedata[index].item = index + 1;
  1439. });
  1440. }
  1441. $scope.tableParamshao = new ngTableParams(
  1442. {
  1443. page: 1,
  1444. count: 5,
  1445. },
  1446. {
  1447. total: haodata.length,
  1448. getData: function ($defer, params) {
  1449. var orderedData = params.sorting()
  1450. ? $filter("orderBy")(haodata, params.orderBy())
  1451. : haodata;
  1452. $defer.resolve(
  1453. orderedData.slice(
  1454. (params.page() - 1) * params.count(),
  1455. params.page() * params.count()
  1456. )
  1457. );
  1458. },
  1459. }
  1460. );
  1461. $scope.tableParamsshe = new ngTableParams(
  1462. {
  1463. page: 1,
  1464. count: 5,
  1465. },
  1466. {
  1467. total: shedata.length,
  1468. getData: function ($defer, params) {
  1469. var orderedData = params.sorting()
  1470. ? $filter("orderBy")(shedata, params.orderBy())
  1471. : shedata;
  1472. $defer.resolve(
  1473. orderedData.slice(
  1474. (params.page() - 1) * params.count(),
  1475. params.page() * params.count()
  1476. )
  1477. );
  1478. },
  1479. }
  1480. );
  1481. $scope.editId = -1;
  1482. $scope.setEditId = function (pid) {
  1483. $scope.editId = pid;
  1484. };
  1485. if (
  1486. $scope.$parent.$parent.$parent.model.isAgree &&
  1487. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1488. ) {
  1489. $scope.isAgree = "同意";
  1490. } else if (
  1491. $scope.$parent.$parent.$parent.model.isAgree &&
  1492. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1493. ) {
  1494. $scope.isAgree = "同意";
  1495. } else if (
  1496. $scope.$parent.$parent.$parent.model.isAgree &&
  1497. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1498. ) {
  1499. $scope.isAgree = "返回修改";
  1500. }
  1501. },
  1502. ],
  1503. });
  1504. //关联资产出库
  1505. formlyConfigProvider.setType({
  1506. name: "ui-meansmodelselect",
  1507. extends: "input",
  1508. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1509. defaultOptions: function (options) {
  1510. return {
  1511. templateOptions: {},
  1512. };
  1513. },
  1514. controller: [
  1515. "$scope",
  1516. "$modal",
  1517. function ($scope, $modal) {
  1518. $scope.openModal = function (size, options, modal) {
  1519. var modalInstance = $modal.open({
  1520. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1521. controller: function (
  1522. $scope,
  1523. $rootScope,
  1524. $modalInstance,
  1525. items,
  1526. title,
  1527. Restangular,
  1528. APIService,
  1529. api_user_data,
  1530. i18nService,
  1531. api_wechatfile
  1532. ) {
  1533. $scope.langs = i18nService.getAllLangs();
  1534. $scope.lang = "zh-cn";
  1535. i18nService.setCurrentLang($scope.lang);
  1536. $scope.gridOptions = {};
  1537. $scope.gridOptions.data = "myData";
  1538. $scope.gridOptions.enableColumnResizing = true;
  1539. $scope.gridOptions.enableFiltering = false;
  1540. $scope.gridOptions.enableGridMenu = false;
  1541. $scope.gridOptions.showGridFooter = true;
  1542. $scope.gridOptions.showColumnFooter = false;
  1543. $scope.gridOptions.fastWatch = true;
  1544. $scope.gridOptions.useExternalFiltering = true;
  1545. $scope.gridOptions.useExternalPagination = true;
  1546. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1547. $scope.gridOptions.paginationPageSize = 10;
  1548. $scope.gridOptions.multiSelect = false;
  1549. $scope.gridOptions.rowIdentity = function (row) {
  1550. return row.id;
  1551. };
  1552. $scope.gridOptions.getRowIdentity = function (row) {
  1553. return row.id;
  1554. };
  1555. // $scope.states = [{
  1556. // id: 0,
  1557. // name: '待批准'
  1558. // },
  1559. // {
  1560. // id: 1,
  1561. // name: '已驳回'
  1562. // },
  1563. // {
  1564. // id: 2,
  1565. // name: '待出库'
  1566. // },
  1567. // {
  1568. // id: 3,
  1569. // name: '信息更新'
  1570. // },
  1571. // {
  1572. // id: 4,
  1573. // name: '信息确认'
  1574. // },
  1575. // {
  1576. // id: 5,
  1577. // name: '已关闭'
  1578. // }
  1579. // ];
  1580. $scope.getStatesDictionary = function () {
  1581. var data = {
  1582. key: "applicationForm_status",
  1583. type: "list",
  1584. };
  1585. api_wechatfile.getDictionary(data).then(function (res) {
  1586. $scope.states = res;
  1587. });
  1588. };
  1589. $scope.getStatesDictionary();
  1590. $scope.type = [
  1591. {
  1592. id: 1,
  1593. name: "资产入库",
  1594. },
  1595. {
  1596. id: 2,
  1597. name: "资产归还",
  1598. },
  1599. {
  1600. id: 3,
  1601. name: "资产领用",
  1602. },
  1603. {
  1604. id: 4,
  1605. name: "资产更换",
  1606. },
  1607. ];
  1608. $scope.typedata = function (row) {
  1609. if (row.type == 0) {
  1610. return "资产入库";
  1611. } else if (row.type == 2) {
  1612. return "资产归还";
  1613. } else if (row.type == 1) {
  1614. return "资产领用";
  1615. } else if (row.type == 4) {
  1616. return "资产更换";
  1617. }
  1618. };
  1619. $scope.statedata = function (row) {
  1620. if (row.status == 0) {
  1621. return "待批准";
  1622. } else if (row.status == 1) {
  1623. return "已驳回";
  1624. } else if (row.status == 2) {
  1625. return "待出库";
  1626. } else if (row.status == 3) {
  1627. return "信息更新";
  1628. } else if (row.status == 4) {
  1629. return "信息确认";
  1630. } else if (row.status == 5) {
  1631. return "已关闭";
  1632. }
  1633. };
  1634. $scope.transferTime = function (time) {
  1635. return moment(time).format("YYYY-MM-DD HH:mm");
  1636. };
  1637. $scope.application = [
  1638. {
  1639. value: "serialNumbe",
  1640. name: "申请单编号",
  1641. },
  1642. // { value: "proposer", name: '申请人' },
  1643. {
  1644. value: "purpose",
  1645. name: "领用用途",
  1646. },
  1647. // { value: "cmdbsign", name: '设备编号' }
  1648. ];
  1649. $scope.parameters = null;
  1650. $scope.open = function ($event) {
  1651. $event.preventDefault();
  1652. $event.stopPropagation();
  1653. $scope.opened = !$scope.opened;
  1654. };
  1655. $scope.endOpen = function ($event) {
  1656. $event.preventDefault();
  1657. $event.stopPropagation();
  1658. $scope.startOpened = false;
  1659. $scope.endOpened = !$scope.endOpened;
  1660. };
  1661. $scope.startOpen = function ($event) {
  1662. $event.preventDefault();
  1663. $event.stopPropagation();
  1664. $scope.endOpened = false;
  1665. $scope.startOpened = !$scope.startOpened;
  1666. };
  1667. $scope.othcode = {};
  1668. $scope.searchkeys = {};
  1669. $scope.parameters = {};
  1670. $scope.memoryfilterData = {
  1671. assignee: $rootScope.user.id,
  1672. candidateGroups: $rootScope.user.group[0].id,
  1673. searchType: "todo",
  1674. idx: 0,
  1675. sum: 10,
  1676. };
  1677. $scope.clear = function () {
  1678. $scope.searchkeys = {};
  1679. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1680. // $scope.othcode = {};
  1681. $scope.parameters = {};
  1682. var fildata = {
  1683. assignee: $rootScope.user.id,
  1684. candidateGroups: $rootScope.user.group[0].id,
  1685. searchType: "todo",
  1686. idx: 0,
  1687. sum: 10,
  1688. };
  1689. // sessionStorage.removeItem("searchincident");
  1690. $scope.memoryfilterData = fildata;
  1691. $scope.loadData(fildata);
  1692. };
  1693. $scope.chiceIncident = function (parameters, item, stateid) {
  1694. var fildata = {
  1695. assignee: $rootScope.user.id,
  1696. candidateGroups: 1,
  1697. searchType: "todo",
  1698. idx: 0,
  1699. sum: 10,
  1700. };
  1701. if (item) {
  1702. fildata.applicationForm = {};
  1703. if (item.alltitle && item.alldata) {
  1704. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1705. }
  1706. if (item.linkProposer) {
  1707. fildata.applicationForm.linkProposer = item.linkProposer;
  1708. }
  1709. if (item.proposer) {
  1710. fildata.applicationForm.proposer = item.proposer;
  1711. }
  1712. if (item.status) {
  1713. fildata.applicationForm["status"] = {
  1714. id: item.status.id,
  1715. };
  1716. }
  1717. if (item.type) {
  1718. fildata.applicationForm["type"] = {
  1719. id: item.type.id,
  1720. };
  1721. }
  1722. }
  1723. $scope.gridOptions.paginationCurrentPage = 1;
  1724. if (
  1725. parameters &&
  1726. parameters.paramDateFrom &&
  1727. parameters.paramDateTo
  1728. ) {
  1729. angular.extend(fildata, {
  1730. idx: 0,
  1731. sum: $scope.gridOptions.paginationPageSize,
  1732. });
  1733. angular.extend(fildata.applicationForm, {
  1734. startDate: moment(parameters.paramDateFrom).format(
  1735. "YYYY-MM-DD HH:mm:ss"
  1736. ),
  1737. endDate: moment(parameters.paramDateTo).format(
  1738. "YYYY-MM-DD 23:59:59"
  1739. ),
  1740. });
  1741. }
  1742. var transitiondata = angular.copy(item);
  1743. // angular.extend(fildata.applicationForm, transitiondata)
  1744. $scope.loadData(fildata);
  1745. };
  1746. $scope.key = {};
  1747. api_user_data
  1748. .fetchDataList("user", {
  1749. idx: 0,
  1750. sum: 1000,
  1751. flag: -1,
  1752. })
  1753. .then(function (data) {
  1754. $scope.handlingPersonnelUser = data.list;
  1755. });
  1756. $scope.gridOptions.columnDefs = items.columnDefs();
  1757. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1758. $scope.gridApi = gridApi;
  1759. gridApi.pagination.on.paginationChanged(
  1760. $scope,
  1761. function (newPage, pageSize) {
  1762. // console.log(newPage);
  1763. // console.log(pageSize);
  1764. $scope.loadData({
  1765. idx: newPage - 1,
  1766. sum: pageSize,
  1767. });
  1768. }
  1769. );
  1770. gridApi.core.on.filterChanged($scope, function () { });
  1771. gridApi.selection.on.rowSelectionChanged(
  1772. $scope,
  1773. function (data) {
  1774. $scope.selected.item = data.entity;
  1775. //console.log(data);
  1776. }
  1777. );
  1778. };
  1779. $scope.loadData = function (filterData) {
  1780. items.fetchItems(filterData, APIService).then(function (data) {
  1781. var myData = Restangular.stripRestangular(data);
  1782. $scope.gridOptions.totalItems = myData.totalNum;
  1783. $scope.myData = myData.list;
  1784. for (var i = 0; i < $scope.myData.length; i++) {
  1785. $scope.myData[i]["item"] =
  1786. i + 1 + filterData.idx * filterData.sum;
  1787. }
  1788. });
  1789. };
  1790. $scope.title = title;
  1791. $scope.loadData({
  1792. idx: 0,
  1793. sum: 10,
  1794. assignee: $rootScope.user.id,
  1795. candidateGroups: $rootScope.user.group[0].id,
  1796. searchType: "todo",
  1797. });
  1798. $scope.selected = {
  1799. item: {},
  1800. };
  1801. $scope.ok = function () {
  1802. //console.log($scope.selected.item);
  1803. $modalInstance.close($scope.selected.item);
  1804. };
  1805. $scope.cancel = function () {
  1806. $modalInstance.dismiss("cancel");
  1807. };
  1808. },
  1809. size: "lg",
  1810. resolve: {
  1811. items: function () {
  1812. return {
  1813. fetchItems: function (filterData, APIService) {
  1814. filterData = filterData || {};
  1815. // if(!filterData.idx){
  1816. if (
  1817. angular.isDefined(filterData.idx) &&
  1818. filterData.idx == null
  1819. ) {
  1820. filterData = {
  1821. idx: 0,
  1822. sum: 10,
  1823. };
  1824. }
  1825. return options.templateOptions.fetchItems(
  1826. filterData,
  1827. APIService,
  1828. options
  1829. );
  1830. },
  1831. columnDefs: function () {
  1832. return options.templateOptions.columnDefs;
  1833. },
  1834. };
  1835. },
  1836. title: function () {
  1837. return options.templateOptions.modalTitle;
  1838. },
  1839. Restangular: function () {
  1840. return options.templateOptions.Restangular;
  1841. },
  1842. APIService: function () {
  1843. return options.templateOptions.ApiService;
  1844. },
  1845. },
  1846. });
  1847. modalInstance.result.then(
  1848. function (selectedItem) {
  1849. var selectitem = {
  1850. title: selectedItem.title,
  1851. description: selectedItem.description,
  1852. };
  1853. if (options.key == "chuku") {
  1854. if (selectedItem.assets) {
  1855. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1856. selectedItem.assets;
  1857. }
  1858. if (selectedItem.consumables) {
  1859. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1860. selectedItem.consumables;
  1861. }
  1862. angular.extend(
  1863. $scope.$parent.$parent.$parent.model,
  1864. selectitem
  1865. );
  1866. options.value(selectedItem);
  1867. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1868. } else {
  1869. angular.extend(options.model, selectitem);
  1870. options.value(selectedItem);
  1871. }
  1872. },
  1873. function () {
  1874. //console.log('Modal dismissed at: ' + new Date());
  1875. }
  1876. );
  1877. };
  1878. },
  1879. ],
  1880. });
  1881. //文本框
  1882. formlyConfigProvider.setType({
  1883. name: "ui-textcmdb",
  1884. extends: "",
  1885. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1886. defaultOptions: function (options) {
  1887. return {
  1888. templateOptions: {
  1889. transform: function (model, value) {
  1890. return value;
  1891. },
  1892. },
  1893. validation: {
  1894. messages: {
  1895. maxlength: function (viewValue, modelValue, scope) {
  1896. if (viewValue != null) {
  1897. if (viewValue.length > scope.to.maxlength) {
  1898. return (
  1899. scope.to.label +
  1900. " 字数(" +
  1901. viewValue.length +
  1902. ")超限(" +
  1903. scope.to.maxlength +
  1904. ")"
  1905. );
  1906. } else {
  1907. return "";
  1908. }
  1909. }
  1910. },
  1911. },
  1912. },
  1913. };
  1914. },
  1915. controller: [
  1916. "$scope",
  1917. function ($scope) {
  1918. var value = $scope.model[$scope.options.key];
  1919. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1920. $scope.model[$scope.options.key] =
  1921. $scope.options.templateOptions.transform(
  1922. $scope.originalModel,
  1923. value
  1924. );
  1925. }
  1926. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1927. $scope.options.templateOptions.felditem($scope);
  1928. }
  1929. },
  1930. ],
  1931. });
  1932. //设备组件
  1933. formlyConfigProvider.setType({
  1934. name: "ui-applist",
  1935. extends: "radio",
  1936. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1937. defaultOptions: function (options) {
  1938. return {
  1939. templateOptions: {
  1940. refresh: function () { },
  1941. refreshDelay: 0,
  1942. },
  1943. };
  1944. },
  1945. controller: [
  1946. "$scope",
  1947. "$filter",
  1948. "ngTableParams",
  1949. function ($scope, $filter, ngTableParams) {
  1950. var data = [];
  1951. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1952. // data = JSON.parse($scope.model.consumables);
  1953. if (angular.isArray($scope.model.consumables)) {
  1954. data = $scope.model.consumables;
  1955. } else {
  1956. data = JSON.parse($scope.model.consumables);
  1957. }
  1958. $scope.model.consumables = data;
  1959. angular.forEach(data, function (item, index) {
  1960. data[index].item = index + 1;
  1961. });
  1962. }
  1963. if ($scope.model.assets && $scope.options.key == "assets") {
  1964. if (angular.isArray($scope.model.assets)) {
  1965. data = $scope.model.assets;
  1966. } else {
  1967. data = JSON.parse($scope.model.assets);
  1968. }
  1969. // data = JSON.parse($scope.model.assets);
  1970. $scope.model.assets = data;
  1971. angular.forEach(data, function (item, index) {
  1972. data[index].item = index + 1;
  1973. });
  1974. }
  1975. $scope.tableParams = new ngTableParams(
  1976. {
  1977. page: 1,
  1978. count: 5,
  1979. },
  1980. {
  1981. total: data.length,
  1982. getData: function ($defer, params) {
  1983. var orderedData = params.sorting()
  1984. ? $filter("orderBy")(data, params.orderBy())
  1985. : data;
  1986. $defer.resolve(
  1987. orderedData.slice(
  1988. (params.page() - 1) * params.count(),
  1989. params.page() * params.count()
  1990. )
  1991. );
  1992. },
  1993. }
  1994. );
  1995. $scope.editId = -1;
  1996. $scope.setEditId = function (pid) {
  1997. $scope.editId = pid;
  1998. };
  1999. },
  2000. ],
  2001. });
  2002. //list组件
  2003. formlyConfigProvider.setType({
  2004. name: "ui-gudinglist",
  2005. extends: "radio",
  2006. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2007. defaultOptions: function (options) {
  2008. return {
  2009. templateOptions: {
  2010. refresh: function () { },
  2011. refreshDelay: 0,
  2012. },
  2013. };
  2014. },
  2015. controller: [
  2016. "$scope",
  2017. "$filter",
  2018. "ngTableParams",
  2019. function ($scope, $filter, ngTableParams) {
  2020. var data = [];
  2021. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2022. // data = JSON.parse($scope.model.consumables);
  2023. if (angular.isArray($scope.model.consumables)) {
  2024. data = $scope.model.consumables;
  2025. } else {
  2026. data = JSON.parse($scope.model.consumables);
  2027. }
  2028. $scope.model.consumables = data;
  2029. angular.forEach(data, function (item, index) {
  2030. data[index].item = index + 1;
  2031. });
  2032. }
  2033. if ($scope.model.assets && $scope.options.key == "assets") {
  2034. if (angular.isArray($scope.model.assets)) {
  2035. data = $scope.model.assets;
  2036. } else {
  2037. data = JSON.parse($scope.model.assets);
  2038. }
  2039. // data = JSON.parse($scope.model.assets);
  2040. $scope.model.assets = data;
  2041. angular.forEach(data, function (item, index) {
  2042. data[index].item = index + 1;
  2043. });
  2044. }
  2045. $scope.tableParams = new ngTableParams(
  2046. {
  2047. page: 1,
  2048. count: 5,
  2049. },
  2050. {
  2051. total: data.length,
  2052. getData: function ($defer, params) {
  2053. var orderedData = params.sorting()
  2054. ? $filter("orderBy")(data, params.orderBy())
  2055. : data;
  2056. $defer.resolve(
  2057. orderedData.slice(
  2058. (params.page() - 1) * params.count(),
  2059. params.page() * params.count()
  2060. )
  2061. );
  2062. },
  2063. }
  2064. );
  2065. $scope.editId = -1;
  2066. $scope.setEditId = function (pid) {
  2067. $scope.editId = pid;
  2068. };
  2069. },
  2070. ],
  2071. });
  2072. //other list tab组件
  2073. formlyConfigProvider.setType({
  2074. name: "ui-otherlisttab",
  2075. extends: "",
  2076. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2077. defaultOptions: function (options) {
  2078. return {
  2079. templateOptions: {
  2080. refresh: function () { },
  2081. refreshDelay: 0,
  2082. },
  2083. };
  2084. },
  2085. controller: [
  2086. "$scope",
  2087. "$filter",
  2088. "ngTableParams",
  2089. function ($scope, $filter, ngTableParams) { },
  2090. ],
  2091. });
  2092. //审核查看组件
  2093. formlyConfigProvider.setType({
  2094. name: "ui-aprovelist",
  2095. extends: "",
  2096. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2097. defaultOptions: function (options) {
  2098. return {
  2099. templateOptions: {
  2100. refresh: function () { },
  2101. refreshDelay: 0,
  2102. },
  2103. };
  2104. },
  2105. controller: [
  2106. "$scope",
  2107. "$filter",
  2108. "ngTableParams",
  2109. function ($scope, $filter, ngTableParams) {
  2110. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2111. $scope.isAgree = "同意";
  2112. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2113. $scope.isAgree = "同意";
  2114. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2115. $scope.isAgree = "返回修改";
  2116. }
  2117. },
  2118. ],
  2119. });
  2120. //other list组件
  2121. formlyConfigProvider.setType({
  2122. name: "ui-otherlist",
  2123. extends: "",
  2124. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2125. defaultOptions: function (options) {
  2126. return {
  2127. templateOptions: {
  2128. refresh: function () { },
  2129. refreshDelay: 0,
  2130. },
  2131. };
  2132. },
  2133. controller: [
  2134. "$rootScope",
  2135. "$scope",
  2136. "$parse",
  2137. "$injector",
  2138. "$http",
  2139. "$q",
  2140. "$state",
  2141. "$stateParams",
  2142. "$modal",
  2143. "$timeout",
  2144. "$interval",
  2145. "i18nService",
  2146. "SweetAlert",
  2147. "FileUploader",
  2148. "Restangular",
  2149. "UserRestangular",
  2150. "BpmRestangular",
  2151. "api_configure_form",
  2152. "api_configure_data",
  2153. "api_bpm_domain",
  2154. "api_bpm_data",
  2155. "api_user_data",
  2156. "api_cmdb",
  2157. "api_sysinfo",
  2158. function (
  2159. $rootScope,
  2160. $scope,
  2161. $parse,
  2162. $injector,
  2163. $http,
  2164. $q,
  2165. $state,
  2166. $stateParams,
  2167. $modal,
  2168. $timeout,
  2169. $interval,
  2170. i18nService,
  2171. SweetAlert,
  2172. FileUploader,
  2173. Restangular,
  2174. UserRestangular,
  2175. BpmRestangular,
  2176. api_configure_form,
  2177. api_configure_data,
  2178. api_bpm_domain,
  2179. api_bpm_data,
  2180. api_user_data,
  2181. api_cmdb,
  2182. api_sysinfo
  2183. ) {
  2184. console.log("哈哈");
  2185. console.log($scope);
  2186. $scope.langs = i18nService.getAllLangs();
  2187. $scope.lang = "zh-cn";
  2188. i18nService.setCurrentLang($scope.lang);
  2189. var vm = this;
  2190. vm.options = {};
  2191. vm.exampleTitle = ["expressionProperties", "model property"];
  2192. vm.fields = [];
  2193. vm.models = {};
  2194. // vm.models["loginUser"] = $rootScope.user;
  2195. var that = $injector;
  2196. var parse = $parse;
  2197. var formKey = "";
  2198. var pdKey = "";
  2199. if (
  2200. angular.isDefined($state.current.pdKey) &&
  2201. $state.current.pdKey != ""
  2202. ) {
  2203. pdKey = $state.current.pdKey;
  2204. //console.log("pdKey::"+$state.current.pdKey);
  2205. }
  2206. if (
  2207. angular.isDefined($stateParams.formKey) &&
  2208. $stateParams.formKey != ""
  2209. ) {
  2210. formKey = $stateParams.formKey;
  2211. //console.log("formKey::"+$stateParams.formKey);
  2212. }
  2213. //用户测试数据,后续从header的auth中获取
  2214. var userId = 2;
  2215. userId = $rootScope.user.id;
  2216. //==============处理表单设计数据 开始====================
  2217. //处理组件加载后台数据选项的方法
  2218. function refreshSelectOptions(searchVal, field) {
  2219. if (field.templateOptions.optionsUrl) {
  2220. var process = BpmRestangular.all("");
  2221. if (field.templateOptions.ApiService) {
  2222. process = UserRestangular.all("");
  2223. }
  2224. process
  2225. .customPOST(
  2226. {
  2227. idx: 0,
  2228. sum: 1000,
  2229. },
  2230. field.templateOptions.optionsUrl
  2231. )
  2232. .then(function (result) {
  2233. if (!field.templateOptions.options) {
  2234. field.templateOptions.options = [];
  2235. }
  2236. if (field.templateOptions.optionsDataKey) {
  2237. field.templateOptions.options =
  2238. result[field.templateOptions.optionsDataKey];
  2239. } else {
  2240. field.templateOptions.options = result;
  2241. }
  2242. });
  2243. }
  2244. }
  2245. function decodeVMTabForm(model, tabs) {
  2246. var result = {
  2247. model: {},
  2248. tabs: [],
  2249. };
  2250. var mdata = angular.fromJson(model);
  2251. angular.extend(result.model, mdata);
  2252. angular.forEach(tabs, function (tab) {
  2253. tab.form.model = vm.models;
  2254. angular.forEach(tab.form.fields, function (field) {
  2255. if (field.key == "") {
  2256. delete field.key;
  2257. }
  2258. field.type = "ui-otherlisttab";
  2259. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2260. var extObj = angular.fromJson(field.extjson);
  2261. angular.extend(field.templateOptions, extObj.templateOptions);
  2262. delete extObj.templateOptions;
  2263. for (var prop in extObj) {
  2264. if (new RegExp("Expression").test(prop)) {
  2265. //var obj = $scope.$eval(extObj[prop]);
  2266. //extObj[prop] = $scope.$eval(extObj[prop]);
  2267. if (extObj[prop] != null) {
  2268. if (new RegExp("function").test(extObj[prop])) {
  2269. var propValue = eval(extObj[prop]);
  2270. extObj[prop] = propValue;
  2271. } else {
  2272. //console.log(extObj[prop]);
  2273. var obj = $scope.$eval(extObj[prop]);
  2274. extObj[prop] = obj;
  2275. //console.log(obj);
  2276. }
  2277. }
  2278. } else if (new RegExp("expressionProperties").test(prop)) {
  2279. for (var p in extObj[prop]) {
  2280. if (new RegExp("function").test(extObj[prop][p])) {
  2281. var propValue = eval(extObj[prop][p]);
  2282. extObj[prop][p] = propValue;
  2283. } else {
  2284. //if(p.indexOf("'")>=0){
  2285. // var obj = $scope.$eval(extObj[prop][p]);
  2286. // extObj[prop][$scope.$eval(p)]=obj;
  2287. //}
  2288. }
  2289. }
  2290. } else if ("watcher" == prop) {
  2291. if (angular.isArray(extObj[prop])) {
  2292. angular.forEach(extObj[prop], function (item, index) {
  2293. for (var p in item) {
  2294. if (new RegExp("function").test(item[p])) {
  2295. var propValue = eval(item[p]);
  2296. extObj[prop][index][p] = propValue;
  2297. }
  2298. }
  2299. });
  2300. } else if (angular.isObject(extObj[prop])) {
  2301. for (var p in extObj[prop]) {
  2302. if (new RegExp("function").test(extObj[prop][p])) {
  2303. var propValue = eval(extObj[prop][p]);
  2304. extObj[prop][p] = propValue;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. }
  2310. angular.extend(field, extObj);
  2311. delete field.extjson;
  2312. }
  2313. if (field.extjson == "") {
  2314. delete field.extjson;
  2315. }
  2316. if (angular.isDefined(field.templateOptions)) {
  2317. var templateOs = field.templateOptions;
  2318. for (var property in templateOs) {
  2319. //console.log(property);
  2320. if (
  2321. angular.isString(templateOs[property]) &&
  2322. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2323. ) {
  2324. if (new RegExp("function").test(templateOs[property])) {
  2325. var propValue = eval(templateOs[property]);
  2326. field.templateOptions[property] = propValue;
  2327. } else {
  2328. if (that.has(templateOs[property])) {
  2329. field.templateOptions[property] = that.get(
  2330. templateOs[property]
  2331. );
  2332. } else {
  2333. field.templateOptions[property] = templateOs[property];
  2334. }
  2335. }
  2336. } else if (templateOs[property] == null) {
  2337. //delete field.templateOptions[property];
  2338. } else {
  2339. }
  2340. }
  2341. }
  2342. if (
  2343. angular.isDefined(field.templateOptions) &&
  2344. angular.isDefined(field.templateOptions.extjson)
  2345. ) {
  2346. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2347. angular.extend(field.templateOptions, extObj);
  2348. delete field.templateOptions.extjson;
  2349. }
  2350. //...
  2351. if (field.templateOptions) {
  2352. //处理远程获取数据控件方法调用
  2353. if (field.templateOptions.optionsUrl) {
  2354. field.templateOptions.refresh = refreshSelectOptions;
  2355. }
  2356. //处理嵌套属性数据绑定/
  2357. if (field.templateOptions.pkey) {
  2358. var pmodel,
  2359. i = 0;
  2360. angular.forEach(
  2361. field.templateOptions.pkey.split("."),
  2362. function (p) {
  2363. if (i == 0) {
  2364. if (result.model[p] == null) {
  2365. result.model[p] = {};
  2366. }
  2367. pmodel = result.model[p];
  2368. i++;
  2369. } else {
  2370. if (pmodel[p] == null) {
  2371. pmodel[p] = {};
  2372. }
  2373. pmodel = pmodel[p];
  2374. }
  2375. }
  2376. );
  2377. if (pmodel != null) {
  2378. field.model = pmodel;
  2379. if (pmodel[field.key] == null) {
  2380. pmodel[field.key] = null;
  2381. }
  2382. }
  2383. } else {
  2384. if (result.model[field.key] == null) {
  2385. result.model[field.key] = null;
  2386. }
  2387. }
  2388. //处理弹出框组件初始化
  2389. if (field.type == "ui-input-selectmodal") {
  2390. field.templateOptions.modal = $modal;
  2391. //field.templateOptions.Restangular = Restangular;
  2392. } else if (field.type == "ui-userselect") {
  2393. field.templateOptions.modal = $modal;
  2394. //field.templateOptions.Restangular = Restangular;
  2395. } else if (field.type == "ui-multiuserselect") {
  2396. field.templateOptions.modal = $modal;
  2397. } else if (field.type == "ui-modelselect") {
  2398. field.templateOptions.modal = $modal;
  2399. //field.templateOptions.Restangular = Restangular;
  2400. } else if (field.type == "ui-cmdbuplode") {
  2401. $scope.fileUploader = field.templateOptions.fileUploader =
  2402. new FileUploader({
  2403. url: "/uploader",
  2404. queueLimit: 1, //文件个数
  2405. autoUpload: true,
  2406. });
  2407. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2408. } else if (field.type == "ui-dropfile") {
  2409. field.templateOptions.fileUploader = new FileUploader({
  2410. url: "/uploader",
  2411. });
  2412. field.templateOptions.taskId = $stateParams.taskId;
  2413. field.templateOptions.processInstanceId =
  2414. $stateParams.processInstanceId;
  2415. field.templateOptions.userId = $rootScope.user.id;
  2416. //field.ApiService=api_bpm_domain;
  2417. } else if (field.type == "ui-dropfiletable") {
  2418. if (field.templateOptions.processInstanceId) {
  2419. } else {
  2420. field.templateOptions.processInstanceId =
  2421. $stateParams.processInstanceId;
  2422. }
  2423. } else if (field.type == "ui-repeatSection") {
  2424. var repeatForm = {
  2425. model: {},
  2426. fields: field.templateOptions.fields,
  2427. };
  2428. repeatForm.model[field.key] = [];
  2429. decodeVMTabForm(repeatForm);
  2430. }
  2431. }
  2432. // console.log(field);
  2433. //field
  2434. //result.fields.push(field);
  2435. });
  2436. });
  2437. vm.originalTabs = angular.copy(vm.form);
  2438. }
  2439. //======================处理表单设计数据 结束========================
  2440. $scope.ldloading = {};
  2441. function filter(obj) {
  2442. angular.forEach(obj, function (key, value) {
  2443. if (value === "" || value === null) {
  2444. delete obj[key];
  2445. } else if (
  2446. Object.prototype.toString.call(value) === "[object Object]"
  2447. ) {
  2448. filter(value);
  2449. } else if (angular.isArray(value)) {
  2450. angular.forEach(value, function (item) {
  2451. filter(item);
  2452. });
  2453. }
  2454. });
  2455. }
  2456. function invokeOnAllFormOptions(fn) {
  2457. angular.forEach(vm.tabs, function (tab) {
  2458. if (tab.form.options && tab.form.options[fn]) {
  2459. tab.form.options[fn]();
  2460. }
  2461. });
  2462. }
  2463. function encodeCIData(data, ciId) {
  2464. /*
  2465. create/update state:未审核
  2466. create createtime:系统时间
  2467. create/update lastupdatetime : 系统时间
  2468. label:ci分类
  2469. */
  2470. if (ciId) {
  2471. var baseprop = [
  2472. "uuid",
  2473. "name",
  2474. "type",
  2475. "label",
  2476. "status",
  2477. "createtime",
  2478. "lastupdatetime",
  2479. "props",
  2480. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2481. var extraprop = "props";
  2482. data[extraprop] = {};
  2483. for (var key in data) {
  2484. console.log(data[key]);
  2485. if (_.indexOf(baseprop, key) >= 0) {
  2486. continue;
  2487. } else {
  2488. data[extraprop][key] = data[key];
  2489. delete data[key];
  2490. }
  2491. }
  2492. if ($rootScope.user) {
  2493. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2494. data[extraprop]["configperson"] = $rootScope.user.name;
  2495. var isCMAdminFlag = false;
  2496. angular.forEach($rootScope.user.role, function (roleItem) {
  2497. if (roleItem.rolecode == "cmdb charge") {
  2498. isCMAdminFlag = true;
  2499. }
  2500. });
  2501. if (!isCMAdminFlag) {
  2502. data[extraprop]["state"] = "1";
  2503. }
  2504. }
  2505. if (data.props.id) {
  2506. } else {
  2507. data.label = ciId;
  2508. }
  2509. return data;
  2510. }
  2511. return undefined;
  2512. }
  2513. function decodeCIModel(data) {
  2514. var extraprop = "props";
  2515. if (data[extraprop]) {
  2516. for (var key in data[extraprop]) {
  2517. data[key] = data[extraprop][key];
  2518. }
  2519. delete data[extraprop];
  2520. }
  2521. data["iscmadmin"] = false;
  2522. angular.forEach($rootScope.user.role, function (roleItem) {
  2523. if (roleItem.rolecode == "cmdb charge") {
  2524. data["iscmadmin"] = true;
  2525. }
  2526. });
  2527. return data;
  2528. }
  2529. function formValid() {
  2530. angular.forEach(vm.tabs, function (item) {
  2531. //item.
  2532. });
  2533. }
  2534. $scope.vm = vm;
  2535. $scope.refreshcmdbform = function (item) {
  2536. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2537. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2538. var myData = Restangular.stripRestangular(data);
  2539. $scope.propTypeOptions = myData;
  2540. $scope.templateProps = myData;
  2541. $scope.vm.tabs = myData;
  2542. if ($scope.model.assets) {
  2543. vm.models = JSON.parse($scope.model.assets);
  2544. }
  2545. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2546. if (vm.models.vtvmvtm_kaiji) {
  2547. vm.models.vtvmvtm_kaiji = "是";
  2548. } else {
  2549. vm.models.vtvmvtm_kaiji = "否";
  2550. }
  2551. }
  2552. decodeVMTabForm(vm.models, vm.tabs);
  2553. });
  2554. // }
  2555. };
  2556. var cifilterClassic = {};
  2557. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2558. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2559. $scope.refreshcmdbform(
  2560. $scope.$parent.$parent.$parent.model.cifilterClassic
  2561. );
  2562. // } else {}
  2563. },
  2564. ],
  2565. });
  2566. //固定资产下载
  2567. formlyConfigProvider.setType({
  2568. name: "ui-dropupload",
  2569. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2570. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2571. defaultOptions: function (options) {
  2572. return {
  2573. templateOptions: {
  2574. view: function (APIService, contentId) {
  2575. return APIService.downloadAttachment(contentId);
  2576. },
  2577. },
  2578. };
  2579. },
  2580. controller: [
  2581. "$scope",
  2582. "$rootScope",
  2583. "Restangular",
  2584. function ($scope, $rootScope, Restangular) {
  2585. if (angular.isUndefined($scope.form.dropState)) {
  2586. $scope.form.dropState = false;
  2587. }
  2588. var to = $scope.options.templateOptions;
  2589. var bindId = $scope.model[to.bindType].processInstanceId;
  2590. //获取附件列表
  2591. $scope.listAttachmen = function () {
  2592. to.ApiService.listAttachment(
  2593. to.listAttachmentUrl,
  2594. to.bindType,
  2595. bindId
  2596. ).then(function (result) {
  2597. var myData = Restangular.stripRestangular(result);
  2598. // $scope.listAttachmens = myData;
  2599. $scope.attachments = myData.data;
  2600. });
  2601. };
  2602. $scope.listAttachmen();
  2603. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2604. // $scope.listAttachmen();
  2605. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2606. // $scope.listAttachmen();
  2607. // }
  2608. //附件下载
  2609. $scope.download = function (token, filename) {
  2610. var downUrl = to.ApiService.downloadAttachment(
  2611. to.downUrl,
  2612. token
  2613. ).getRequestedUrl();
  2614. var a = document.createElement("a");
  2615. a.href = downUrl;
  2616. a.target = "_blank";
  2617. a.download = filename;
  2618. document.body.appendChild(a);
  2619. a.click();
  2620. };
  2621. //附件预览
  2622. $scope.view = function (id, previewUrl) {
  2623. if (previewUrl) {
  2624. window.open(previewUrl);
  2625. }
  2626. };
  2627. },
  2628. ],
  2629. });
  2630. formlyConfigProvider.setType({
  2631. name: "ui-form",
  2632. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2633. defaultOptions: function (options) {
  2634. return {
  2635. templateOptions: {
  2636. // link: function() {}
  2637. },
  2638. };
  2639. },
  2640. controller: [
  2641. "$rootScope",
  2642. "$scope",
  2643. "$parse",
  2644. "$injector",
  2645. "$http",
  2646. "$q",
  2647. "$state",
  2648. "$stateParams",
  2649. "$modal",
  2650. "$timeout",
  2651. "$interval",
  2652. "i18nService",
  2653. "SweetAlert",
  2654. "FileUploader",
  2655. "Restangular",
  2656. "UserRestangular",
  2657. "BpmRestangular",
  2658. "api_configure_form",
  2659. "api_configure_data",
  2660. "api_bpm_domain",
  2661. "api_bpm_data",
  2662. "api_user_data",
  2663. "api_cmdb",
  2664. "api_sysinfo",
  2665. function (
  2666. $rootScope,
  2667. $scope,
  2668. $parse,
  2669. $injector,
  2670. $http,
  2671. $q,
  2672. $state,
  2673. $stateParams,
  2674. $modal,
  2675. $timeout,
  2676. $interval,
  2677. i18nService,
  2678. SweetAlert,
  2679. FileUploader,
  2680. Restangular,
  2681. UserRestangular,
  2682. BpmRestangular,
  2683. api_configure_form,
  2684. api_configure_data,
  2685. api_bpm_domain,
  2686. api_bpm_data,
  2687. api_user_data,
  2688. api_cmdb,
  2689. api_sysinfo
  2690. ) {
  2691. $scope.langs = i18nService.getAllLangs();
  2692. $scope.lang = "zh-cn";
  2693. i18nService.setCurrentLang($scope.lang);
  2694. var vm = this;
  2695. vm.options = {};
  2696. vm.exampleTitle = ["expressionProperties", "model property"];
  2697. vm.fields = [];
  2698. vm.models = {};
  2699. // vm.models["loginUser"] = $rootScope.user;
  2700. var that = $injector;
  2701. var parse = $parse;
  2702. var formKey = "";
  2703. var pdKey = "";
  2704. if (
  2705. angular.isDefined($state.current.pdKey) &&
  2706. $state.current.pdKey != ""
  2707. ) {
  2708. pdKey = $state.current.pdKey;
  2709. //console.log("pdKey::"+$state.current.pdKey);
  2710. }
  2711. if (
  2712. angular.isDefined($stateParams.formKey) &&
  2713. $stateParams.formKey != ""
  2714. ) {
  2715. formKey = $stateParams.formKey;
  2716. //console.log("formKey::"+$stateParams.formKey);
  2717. }
  2718. //用户测试数据,后续从header的auth中获取
  2719. var userId = 2;
  2720. userId = $rootScope.user.id;
  2721. //==============处理表单设计数据 开始====================
  2722. //处理组件加载后台数据选项的方法
  2723. function refreshSelectOptions(searchVal, field) {
  2724. if (field.templateOptions.optionsUrl) {
  2725. var process = BpmRestangular.all("");
  2726. if (field.templateOptions.ApiService) {
  2727. process = UserRestangular.all("");
  2728. }
  2729. process
  2730. .customPOST(
  2731. {
  2732. idx: 0,
  2733. sum: 1000,
  2734. },
  2735. field.templateOptions.optionsUrl
  2736. )
  2737. .then(function (result) {
  2738. if (!field.templateOptions.options) {
  2739. field.templateOptions.options = [];
  2740. }
  2741. if (field.templateOptions.optionsDataKey) {
  2742. field.templateOptions.options =
  2743. result[field.templateOptions.optionsDataKey];
  2744. } else {
  2745. field.templateOptions.options = result;
  2746. }
  2747. });
  2748. }
  2749. }
  2750. function decodeVMTabForm(model, tabs) {
  2751. var result = {
  2752. model: {},
  2753. tabs: [],
  2754. };
  2755. var mdata = angular.fromJson(model);
  2756. angular.extend(result.model, mdata);
  2757. angular.forEach(tabs, function (tab) {
  2758. tab.form.model = vm.models;
  2759. angular.forEach(tab.form.fields, function (field) {
  2760. if (field.key == "") {
  2761. delete field.key;
  2762. }
  2763. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2764. var extObj = angular.fromJson(field.extjson);
  2765. angular.extend(field.templateOptions, extObj.templateOptions);
  2766. delete extObj.templateOptions;
  2767. for (var prop in extObj) {
  2768. if (new RegExp("Expression").test(prop)) {
  2769. //var obj = $scope.$eval(extObj[prop]);
  2770. //extObj[prop] = $scope.$eval(extObj[prop]);
  2771. if (extObj[prop] != null) {
  2772. if (new RegExp("function").test(extObj[prop])) {
  2773. var propValue = eval(extObj[prop]);
  2774. extObj[prop] = propValue;
  2775. } else {
  2776. //console.log(extObj[prop]);
  2777. var obj = $scope.$eval(extObj[prop]);
  2778. extObj[prop] = obj;
  2779. //console.log(obj);
  2780. }
  2781. }
  2782. } else if (new RegExp("expressionProperties").test(prop)) {
  2783. for (var p in extObj[prop]) {
  2784. if (new RegExp("function").test(extObj[prop][p])) {
  2785. var propValue = eval(extObj[prop][p]);
  2786. extObj[prop][p] = propValue;
  2787. } else {
  2788. //if(p.indexOf("'")>=0){
  2789. // var obj = $scope.$eval(extObj[prop][p]);
  2790. // extObj[prop][$scope.$eval(p)]=obj;
  2791. //}
  2792. }
  2793. }
  2794. } else if ("watcher" == prop) {
  2795. if (angular.isArray(extObj[prop])) {
  2796. angular.forEach(extObj[prop], function (item, index) {
  2797. for (var p in item) {
  2798. if (new RegExp("function").test(item[p])) {
  2799. var propValue = eval(item[p]);
  2800. extObj[prop][index][p] = propValue;
  2801. }
  2802. }
  2803. });
  2804. } else if (angular.isObject(extObj[prop])) {
  2805. for (var p in extObj[prop]) {
  2806. if (new RegExp("function").test(extObj[prop][p])) {
  2807. var propValue = eval(extObj[prop][p]);
  2808. extObj[prop][p] = propValue;
  2809. }
  2810. }
  2811. }
  2812. }
  2813. }
  2814. angular.extend(field, extObj);
  2815. delete field.extjson;
  2816. }
  2817. if (field.extjson == "") {
  2818. delete field.extjson;
  2819. }
  2820. if (angular.isDefined(field.templateOptions)) {
  2821. var templateOs = field.templateOptions;
  2822. for (var property in templateOs) {
  2823. //console.log(property);
  2824. if (
  2825. angular.isString(templateOs[property]) &&
  2826. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2827. ) {
  2828. if (new RegExp("function").test(templateOs[property])) {
  2829. var propValue = eval(templateOs[property]);
  2830. field.templateOptions[property] = propValue;
  2831. } else {
  2832. if (that.has(templateOs[property])) {
  2833. field.templateOptions[property] = that.get(
  2834. templateOs[property]
  2835. );
  2836. } else {
  2837. field.templateOptions[property] = templateOs[property];
  2838. }
  2839. }
  2840. } else if (templateOs[property] == null) {
  2841. //delete field.templateOptions[property];
  2842. } else {
  2843. }
  2844. }
  2845. }
  2846. if (
  2847. angular.isDefined(field.templateOptions) &&
  2848. angular.isDefined(field.templateOptions.extjson)
  2849. ) {
  2850. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2851. angular.extend(field.templateOptions, extObj);
  2852. delete field.templateOptions.extjson;
  2853. }
  2854. //...
  2855. if (field.templateOptions) {
  2856. //处理远程获取数据控件方法调用
  2857. if (field.templateOptions.optionsUrl) {
  2858. field.templateOptions.refresh = refreshSelectOptions;
  2859. }
  2860. //处理嵌套属性数据绑定/
  2861. if (field.templateOptions.pkey) {
  2862. var pmodel,
  2863. i = 0;
  2864. angular.forEach(
  2865. field.templateOptions.pkey.split("."),
  2866. function (p) {
  2867. if (i == 0) {
  2868. if (result.model[p] == null) {
  2869. result.model[p] = {};
  2870. }
  2871. pmodel = result.model[p];
  2872. i++;
  2873. } else {
  2874. if (pmodel[p] == null) {
  2875. pmodel[p] = {};
  2876. }
  2877. pmodel = pmodel[p];
  2878. }
  2879. }
  2880. );
  2881. if (pmodel != null) {
  2882. field.model = pmodel;
  2883. if (pmodel[field.key] == null) {
  2884. pmodel[field.key] = null;
  2885. }
  2886. }
  2887. } else {
  2888. if (result.model[field.key] == null) {
  2889. result.model[field.key] = null;
  2890. }
  2891. }
  2892. //处理弹出框组件初始化
  2893. if (field.type == "ui-input-selectmodal") {
  2894. field.templateOptions.modal = $modal;
  2895. //field.templateOptions.Restangular = Restangular;
  2896. } else if (field.type == "ui-userselect") {
  2897. field.templateOptions.modal = $modal;
  2898. //field.templateOptions.Restangular = Restangular;
  2899. } else if (field.type == "ui-multiuserselect") {
  2900. field.templateOptions.modal = $modal;
  2901. } else if (field.type == "ui-modelselect") {
  2902. field.templateOptions.modal = $modal;
  2903. //field.templateOptions.Restangular = Restangular;
  2904. } else if (field.type == "ui-dropfile") {
  2905. field.templateOptions.fileUploader = new FileUploader({
  2906. url: "/uploader",
  2907. });
  2908. field.templateOptions.taskId = $stateParams.taskId;
  2909. field.templateOptions.processInstanceId =
  2910. $stateParams.processInstanceId;
  2911. field.templateOptions.userId = $rootScope.user.id;
  2912. //field.ApiService=api_bpm_domain;
  2913. // }else if (field.type == "ui-uploadFile") {
  2914. // field.templateOptions.fileUploader = new FileUploader({
  2915. // url: '/uploader'
  2916. // });
  2917. // field.templateOptions.taskId = $stateParams.taskId;
  2918. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2919. // field.templateOptions.userId = $rootScope.user.id;
  2920. //field.ApiService=api_bpm_domain;
  2921. } else if (field.type == "ui-dropfiletable") {
  2922. if (field.templateOptions.processInstanceId) {
  2923. } else {
  2924. field.templateOptions.processInstanceId =
  2925. $stateParams.processInstanceId;
  2926. }
  2927. } else if (field.type == "ui-dropFiles") {
  2928. if (field.templateOptions.processInstanceId) {
  2929. } else {
  2930. field.templateOptions.processInstanceId =
  2931. $stateParams.processInstanceId;
  2932. }
  2933. } else if (field.type == "ui-showImgs") {
  2934. if (field.templateOptions.processInstanceId) {
  2935. } else {
  2936. field.templateOptions.processInstanceId =
  2937. $stateParams.processInstanceId;
  2938. }
  2939. } else if (field.type == "ui-repeatSection") {
  2940. var repeatForm = {
  2941. model: {},
  2942. fields: field.templateOptions.fields,
  2943. };
  2944. repeatForm.model[field.key] = [];
  2945. decodeVMTabForm(repeatForm);
  2946. }
  2947. }
  2948. // console.log(field);
  2949. //field
  2950. //result.fields.push(field);
  2951. });
  2952. });
  2953. vm.originalTabs = angular.copy(vm.form);
  2954. }
  2955. //解析自定义表单设计数据
  2956. function decodeVMForm(vmForm) {
  2957. var result = {
  2958. model: {},
  2959. tabs: [],
  2960. };
  2961. //设置模型实体数据 begin
  2962. // var mdata = vmForm.model;
  2963. //解析数据实体
  2964. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2965. angular.extend(result.model, mdata);
  2966. //设置模型实体数据 end
  2967. //解析设计数据生成表单项 begin
  2968. var fields = [];
  2969. //处理修改设计数据中展示设置
  2970. angular.forEach(vmForm.tabs, function (field) {
  2971. if (field.key == "") {
  2972. delete field.key;
  2973. }
  2974. if (angular.isDefined(field.extjson)) {
  2975. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2976. angular.extend(field.templateOptions, extObj.templateOptions);
  2977. delete extObj.templateOptions;
  2978. for (var prop in extObj) {
  2979. if (new RegExp("Expression").test(prop)) {
  2980. //var obj = $scope.$eval(extObj[prop]);
  2981. //extObj[prop] = $scope.$eval(extObj[prop]);
  2982. if (extObj[prop] != null) {
  2983. if (new RegExp("function").test(extObj[prop])) {
  2984. var propValue = eval(extObj[prop]);
  2985. extObj[prop] = propValue;
  2986. } else {
  2987. //console.log(extObj[prop]);
  2988. var obj = $scope.$eval(extObj[prop]);
  2989. extObj[prop] = obj;
  2990. //console.log(obj);
  2991. }
  2992. }
  2993. } else if (new RegExp("expressionProperties").test(prop)) {
  2994. for (var p in extObj[prop]) {
  2995. if (new RegExp("function").test(extObj[prop][p])) {
  2996. var propValue = eval(extObj[prop][p]);
  2997. extObj[prop][p] = propValue;
  2998. } else {
  2999. //if(p.indexOf("'")>=0){
  3000. // var obj = $scope.$eval(extObj[prop][p]);
  3001. // extObj[prop][$scope.$eval(p)]=obj;
  3002. //}
  3003. }
  3004. }
  3005. } else if ("watcher" == prop) {
  3006. if (angular.isArray(extObj[prop])) {
  3007. angular.forEach(extObj[prop], function (item, index) {
  3008. for (var p in item) {
  3009. if (new RegExp("function").test(item[p])) {
  3010. var propValue = eval(item[p]);
  3011. extObj[prop][index][p] = propValue;
  3012. }
  3013. }
  3014. });
  3015. } else if (angular.isObject(extObj[prop])) {
  3016. for (var p in extObj[prop]) {
  3017. if (new RegExp("function").test(extObj[prop][p])) {
  3018. var propValue = eval(extObj[prop][p]);
  3019. extObj[prop][p] = propValue;
  3020. }
  3021. }
  3022. }
  3023. }
  3024. }
  3025. angular.extend(field, extObj);
  3026. delete field.extjson;
  3027. }
  3028. if (angular.isDefined(field.templateOptions)) {
  3029. var templateOs = field.templateOptions;
  3030. for (var property in templateOs) {
  3031. //console.log(property);
  3032. if (
  3033. angular.isString(templateOs[property]) &&
  3034. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3035. ) {
  3036. if (new RegExp("function").test(templateOs[property])) {
  3037. var propValue = eval(templateOs[property]);
  3038. field.templateOptions[property] = propValue;
  3039. } else {
  3040. if (that.has(templateOs[property])) {
  3041. field.templateOptions[property] = that.get(
  3042. templateOs[property]
  3043. );
  3044. } else {
  3045. field.templateOptions[property] = templateOs[property];
  3046. }
  3047. }
  3048. } else if (templateOs[property] == null) {
  3049. //delete field.templateOptions[property];
  3050. } else {
  3051. }
  3052. }
  3053. }
  3054. if (
  3055. angular.isDefined(field.templateOptions) &&
  3056. angular.isDefined(field.templateOptions.extjson)
  3057. ) {
  3058. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3059. angular.extend(field.templateOptions, extObj);
  3060. delete field.templateOptions.extjson;
  3061. }
  3062. //...
  3063. if (field.templateOptions) {
  3064. //处理远程获取数据控件方法调用
  3065. if (field.templateOptions.optionsUrl) {
  3066. field.templateOptions.refresh = refreshSelectOptions;
  3067. }
  3068. //处理嵌套属性数据绑定/
  3069. if (field.templateOptions.pkey) {
  3070. var pmodel,
  3071. i = 0;
  3072. angular.forEach(
  3073. field.templateOptions.pkey.split("."),
  3074. function (p) {
  3075. if (i == 0) {
  3076. if (result.model[p] == null) {
  3077. result.model[p] = {};
  3078. }
  3079. pmodel = result.model[p];
  3080. i++;
  3081. } else {
  3082. if (pmodel[p] == null) {
  3083. pmodel[p] = {};
  3084. }
  3085. pmodel = pmodel[p];
  3086. }
  3087. }
  3088. );
  3089. if (pmodel != null) {
  3090. field.model = pmodel;
  3091. if (pmodel[field.key] == null) {
  3092. pmodel[field.key] = null;
  3093. }
  3094. }
  3095. } else {
  3096. if (result.model[field.key] == null) {
  3097. result.model[field.key] = null;
  3098. }
  3099. }
  3100. //处理弹出框组件初始化
  3101. if (field.type == "ui-input-selectmodal") {
  3102. field.templateOptions.modal = $modal;
  3103. //field.templateOptions.Restangular = Restangular;
  3104. } else if (field.type == "ui-userselect") {
  3105. field.templateOptions.modal = $modal;
  3106. //field.templateOptions.Restangular = Restangular;
  3107. } else if (field.type == "ui-multiuserselect") {
  3108. field.templateOptions.modal = $modal;
  3109. } else if (field.type == "ui-modelselect") {
  3110. field.templateOptions.modal = $modal;
  3111. //field.templateOptions.Restangular = Restangular;
  3112. } else if (field.type == "ui-dropfile") {
  3113. field.templateOptions.fileUploader = new FileUploader({
  3114. url: "/uploader",
  3115. });
  3116. field.templateOptions.taskId = $stateParams.taskId;
  3117. field.templateOptions.processInstanceId =
  3118. $stateParams.processInstanceId;
  3119. field.templateOptions.userId = $rootScope.user.id;
  3120. //field.ApiService=api_bpm_domain;
  3121. } else if (field.type == "ui-dropfiletable") {
  3122. if (field.templateOptions.processInstanceId) {
  3123. } else {
  3124. field.templateOptions.processInstanceId =
  3125. $stateParams.processInstanceId;
  3126. }
  3127. } else if (field.type == "ui-dropFiles") {
  3128. if (field.templateOptions.processInstanceId) {
  3129. } else {
  3130. field.templateOptions.processInstanceId =
  3131. $stateParams.processInstanceId;
  3132. }
  3133. } else if (field.type == "ui-showImgs") {
  3134. if (field.templateOptions.processInstanceId) {
  3135. } else {
  3136. field.templateOptions.processInstanceId =
  3137. $stateParams.processInstanceId;
  3138. }
  3139. } else if (field.type == "ui-repeatSection") {
  3140. var repeatForm = {
  3141. model: {},
  3142. fields: field.templateOptions.fields,
  3143. };
  3144. repeatForm.model[field.key] = [];
  3145. decodeVMForm(repeatForm);
  3146. }
  3147. }
  3148. // console.log(field);
  3149. result.fields.push(field);
  3150. });
  3151. angular.extend($scope.vm.fields, result.fields);
  3152. angular.extend($scope.vm.models, result.model);
  3153. $scope.formData = vmForm;
  3154. //console.log($scope.vm);
  3155. //解析设计数据生成表单项 end
  3156. return result;
  3157. }
  3158. //======================处理表单设计数据 结束========================
  3159. $scope.ldloading = {};
  3160. function filter(obj) {
  3161. angular.forEach(obj, function (key, value) {
  3162. if (value === "" || value === null) {
  3163. delete obj[key];
  3164. } else if (
  3165. Object.prototype.toString.call(value) === "[object Object]"
  3166. ) {
  3167. filter(value);
  3168. } else if (angular.isArray(value)) {
  3169. angular.forEach(value, function (item) {
  3170. filter(item);
  3171. });
  3172. }
  3173. });
  3174. }
  3175. function invokeOnAllFormOptions(fn) {
  3176. angular.forEach(vm.tabs, function (tab) {
  3177. if (tab.form.options && tab.form.options[fn]) {
  3178. tab.form.options[fn]();
  3179. }
  3180. });
  3181. }
  3182. function encodeCIData(data, ciId) {
  3183. /*
  3184. create/update state:未审核
  3185. create createtime:系统时间
  3186. create/update lastupdatetime : 系统时间
  3187. label:ci分类
  3188. */
  3189. if (ciId) {
  3190. var baseprop = [
  3191. "uuid",
  3192. "name",
  3193. "type",
  3194. "label",
  3195. "status",
  3196. "createtime",
  3197. "lastupdatetime",
  3198. "props",
  3199. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3200. var extraprop = "props";
  3201. data[extraprop] = {};
  3202. for (var key in data) {
  3203. console.log(data[key]);
  3204. if (_.indexOf(baseprop, key) >= 0) {
  3205. continue;
  3206. } else {
  3207. data[extraprop][key] = data[key];
  3208. delete data[key];
  3209. }
  3210. }
  3211. if ($rootScope.user) {
  3212. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3213. data[extraprop]["configperson"] = $rootScope.user.name;
  3214. var isCMAdminFlag = false;
  3215. angular.forEach($rootScope.user.role, function (roleItem) {
  3216. if (roleItem.rolecode == "cmdb charge") {
  3217. isCMAdminFlag = true;
  3218. }
  3219. });
  3220. if (!isCMAdminFlag) {
  3221. data[extraprop]["state"] = "1";
  3222. }
  3223. }
  3224. if (data.props.id) {
  3225. } else {
  3226. data.label = ciId;
  3227. }
  3228. return data;
  3229. }
  3230. return undefined;
  3231. }
  3232. function decodeCIModel(data) {
  3233. var extraprop = "props";
  3234. if (data[extraprop]) {
  3235. for (var key in data[extraprop]) {
  3236. data[key] = data[extraprop][key];
  3237. }
  3238. delete data[extraprop];
  3239. }
  3240. data["iscmadmin"] = false;
  3241. angular.forEach($rootScope.user.role, function (roleItem) {
  3242. if (roleItem.rolecode == "cmdb charge") {
  3243. data["iscmadmin"] = true;
  3244. }
  3245. });
  3246. return data;
  3247. }
  3248. vm.remove = function (data, style) {
  3249. $scope.ldloading[style.replace("-", "_")] = true;
  3250. var modalInstance = $modal.open({
  3251. templateUrl: "assets/views/delete.html",
  3252. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3253. var cidata = {
  3254. label: data.label,
  3255. id: data.id,
  3256. uuid: data.uuid,
  3257. name: data.name,
  3258. props: {},
  3259. };
  3260. if (cidata.id) {
  3261. cidata.props["removeflag"] = true;
  3262. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3263. $scope.ok = function () {
  3264. $modalInstance.close(cidata);
  3265. };
  3266. $scope.cancel = function () {
  3267. $modalInstance.dismiss("cancel");
  3268. };
  3269. }
  3270. },
  3271. size: "sm",
  3272. resolve: {
  3273. scope: function () {
  3274. return $scope;
  3275. },
  3276. },
  3277. });
  3278. modalInstance.result.then(function (selectedItem) {
  3279. if (selectedItem) {
  3280. // if (selectedItem.length > 0) {
  3281. api_cmdb
  3282. .put(selectedItem, selectedItem.id)
  3283. .then(function (response) {
  3284. if (response) {
  3285. var resData = Restangular.stripRestangular(response);
  3286. SweetAlert.swal(
  3287. {
  3288. title: "删除成功!",
  3289. confirmButtonColor: "#007AFF",
  3290. },
  3291. function () {
  3292. $state.go("app.means.list");
  3293. // $scope.refreshform();
  3294. // reinitTabForm($scope.classify);
  3295. }
  3296. );
  3297. } else {
  3298. SweetAlert.swal({
  3299. title: "系统错误",
  3300. text: "系统错误,请稍后重试!",
  3301. type: "error",
  3302. confirmButtonColor: "#DD6B55",
  3303. });
  3304. }
  3305. $scope.ldloading[style.replace("-", "_")] = false;
  3306. });
  3307. }
  3308. });
  3309. };
  3310. function formValid() {
  3311. angular.forEach(vm.tabs, function (item) {
  3312. //item.
  3313. });
  3314. }
  3315. $scope.closeModel = function () {
  3316. console.log($stateParams);
  3317. if (
  3318. angular.isDefined($stateParams.formKey) &&
  3319. $stateParams.formKey != ""
  3320. ) {
  3321. if (
  3322. $stateParams.formKey == "means_editor" ||
  3323. $stateParams.formKey == "means_edit"
  3324. ) {
  3325. $state.go("app.means.list", {});
  3326. }
  3327. event.preventDefault();
  3328. }
  3329. };
  3330. // setInterval(function() {
  3331. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3332. // cifilter_classic = $scope.model.cifilter_classic;
  3333. // $scope.refreshcmdbform(cifilter_classic);
  3334. // } else {}
  3335. // }, 100);
  3336. vm.models = (function filter(obj) {
  3337. var filtered = _.pick(obj, function (v) {
  3338. return (
  3339. angular.isDefined(v) &&
  3340. v !== null &&
  3341. (angular.isArray(v) ? v.length > 0 : true) &&
  3342. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3343. );
  3344. });
  3345. return _.cloneDeep(filtered, function (v) {
  3346. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3347. });
  3348. })(vm.models);
  3349. // setInterval(function() {
  3350. // if ($scope.model.type == 0) {
  3351. // $scope.model[$scope.options.key] = vm.models;
  3352. // }
  3353. // }, 100);
  3354. setInterval(function () {
  3355. if (vm.form && vm.form.$$parentForm.$valid) {
  3356. if (
  3357. $scope.$parent &&
  3358. $scope.$parent.$parent &&
  3359. $scope.$parent.$parent.$parent &&
  3360. $scope.$parent.$parent.$parent.model
  3361. ) {
  3362. vm.models.hw_cifilterClassic =
  3363. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3364. $scope.model[$scope.options.key] = vm.models;
  3365. }
  3366. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3367. // $scope.model[$scope.options.key] = vm.models;
  3368. }
  3369. }, 100);
  3370. vm.submit = function (data, ciId, templateitem, style) {
  3371. // $scope.ldloading[style.replace('-', '_')] = true;
  3372. console.log(vm.form.$$parentForm.$valid);
  3373. if (vm.form.$$parentForm.$valid) {
  3374. invokeOnAllFormOptions("updateInitialValue");
  3375. //alert(JSON.stringify(vm.model), null, 2);
  3376. //vm.options.updateInitialValue();
  3377. //console.log(vm.model);
  3378. var cidata = encodeCIData(vm.models, ciId);
  3379. if (cidata) {
  3380. //var cidata = ;
  3381. if (cidata.props.id) {
  3382. //修改
  3383. api_cmdb.put(cidata, ciId).then(function (response) {
  3384. if (response) {
  3385. var resData = Restangular.stripRestangular(response);
  3386. SweetAlert.swal(
  3387. {
  3388. title: "保存成功!",
  3389. confirmButtonColor: "#007AFF",
  3390. },
  3391. function () {
  3392. $scope.ldloading[style.replace("-", "_")] = false;
  3393. // $scope.refreshform();
  3394. $state.go("app.means.list");
  3395. }
  3396. );
  3397. } else {
  3398. SweetAlert.swal({
  3399. title: "系统错误",
  3400. text: "系统错误,请稍后重试!",
  3401. type: "error",
  3402. confirmButtonColor: "#DD6B55",
  3403. });
  3404. }
  3405. $scope.ldloading[style.replace("-", "_")] = false;
  3406. });
  3407. } else {
  3408. //新建
  3409. var type = 2;
  3410. api_sysinfo
  3411. .getSerialnumber(type, templateitem.id)
  3412. .then(function (data) {
  3413. if (data && data.status == 200) {
  3414. cidata.uuid = data.uuid;
  3415. api_cmdb.create(cidata).then(function (response) {
  3416. if (response) {
  3417. var resData = Restangular.stripRestangular(response);
  3418. SweetAlert.swal(
  3419. {
  3420. title: "保存成功!",
  3421. text: "内部编号:" + cidata.uuid,
  3422. confirmButtonColor: "#007AFF",
  3423. },
  3424. function () {
  3425. $state.go("app.means.list");
  3426. }
  3427. );
  3428. // if(resData.status){
  3429. // resData
  3430. // }
  3431. } else {
  3432. SweetAlert.swal({
  3433. title: "系统错误",
  3434. text: "系统错误,请稍后重试!",
  3435. type: "error",
  3436. confirmButtonColor: "#DD6B55",
  3437. });
  3438. }
  3439. $scope.ldloading[style.replace("-", "_")] = false;
  3440. });
  3441. } else {
  3442. SweetAlert.swal({
  3443. title: "系统错误",
  3444. text: "内部编号生成出错!",
  3445. type: "error",
  3446. confirmButtonColor: "#DD6B55",
  3447. });
  3448. }
  3449. });
  3450. }
  3451. } else {
  3452. SweetAlert.swal({
  3453. title: "错误",
  3454. text: "错误,请选择资产分类!",
  3455. type: "error",
  3456. confirmButtonColor: "#DD6B55",
  3457. });
  3458. }
  3459. //alert(JSON.stringify(cidata), null, 2);
  3460. $scope.ldloading[style.replace("-", "_")] = true;
  3461. return;
  3462. var _ = window._;
  3463. vm.models = (function filter(obj) {
  3464. var filtered = _.pick(obj, function (v) {
  3465. return (
  3466. angular.isDefined(v) &&
  3467. v !== null &&
  3468. (angular.isArray(v) ? v.length > 0 : true) &&
  3469. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3470. );
  3471. });
  3472. return _.cloneDeep(filtered, function (v) {
  3473. return v !== filtered && _.isPlainObject(v)
  3474. ? filter(v)
  3475. : undefined;
  3476. });
  3477. })(vm.models);
  3478. } else {
  3479. if (vm.form.$$parentForm.$error) {
  3480. SweetAlert.swal({
  3481. title: "校验错误",
  3482. text: "请填写必填项!",
  3483. type: "error",
  3484. confirmButtonColor: "#DD6B55",
  3485. });
  3486. angular.forEach(
  3487. vm.form.$$parentForm.$error.required,
  3488. function (item) {
  3489. angular.forEach(vm.tabs, function (tab) {
  3490. angular.forEach(tab.form.fields, function (f) {
  3491. if (f.name == item.$name) {
  3492. f.validation.show = true;
  3493. tab.active = true;
  3494. }
  3495. });
  3496. });
  3497. }
  3498. );
  3499. $scope.ldloading[style.replace("-", "_")] = false;
  3500. }
  3501. }
  3502. };
  3503. $scope.vm = vm;
  3504. $scope.refreshcmdbform = function (item) {
  3505. // if ($stateParams.model) {
  3506. // var modeldata = JSON.parse($stateParams.model)
  3507. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3508. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3509. var myData = Restangular.stripRestangular(data);
  3510. $scope.propTypeOptions = myData;
  3511. $scope.templateProps = myData;
  3512. $scope.vm.tabs = myData;
  3513. if ($scope.model.asset && $scope.model.asset.length != "") {
  3514. vm.models = JSON.parse($scope.model.asset);
  3515. }
  3516. decodeVMTabForm(vm.models, vm.tabs);
  3517. });
  3518. // }
  3519. };
  3520. var cifilterClassic = {};
  3521. setInterval(function () {
  3522. if (
  3523. $scope.$parent.$parent &&
  3524. $scope.$parent.$parent.$parent &&
  3525. $scope.$parent.$parent.$parent.model &&
  3526. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3527. cifilterClassic.id !=
  3528. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3529. ) {
  3530. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3531. cifilterClassic =
  3532. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3533. $scope.refreshcmdbform(cifilterClassic);
  3534. } else {
  3535. }
  3536. }, 100);
  3537. },
  3538. ],
  3539. });
  3540. //请求人信息
  3541. formlyConfigProvider.setType({
  3542. name: "ui-cmdbinformation",
  3543. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3544. wrapper: ["bootstrapHasError"],
  3545. defaultOptions: function (options, $scope) {
  3546. return {
  3547. templateOptions: {
  3548. // checkform: function(options) {
  3549. // if (options.model.requester) {
  3550. // options.value(options.model.requester);
  3551. // }
  3552. // },
  3553. },
  3554. };
  3555. },
  3556. controller: [
  3557. "$scope",
  3558. "api_user_data",
  3559. function ($scope, api_user_data) {
  3560. if ($scope.options.templateOptions.loginUser) {
  3561. if (
  3562. $scope.model[$scope.options.key] &&
  3563. $scope.model[$scope.options.key].id
  3564. ) {
  3565. } else {
  3566. $scope.model[$scope.options.key] =
  3567. $scope.options.templateOptions.loginUser;
  3568. }
  3569. $scope.options.initialValue = $scope.model[$scope.options.key];
  3570. }
  3571. },
  3572. ],
  3573. });
  3574. //资产属性
  3575. formlyConfigProvider.setType({
  3576. name: "ui-cmdbtype",
  3577. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3578. wrapper: ["bootstrapHasError"],
  3579. defaultOptions: function (options, $scope) {
  3580. return {
  3581. templateOptions: {
  3582. // checkform: function(options) {
  3583. // if (options.model.requester) {
  3584. // options.value(options.model.requester);
  3585. // }
  3586. // },
  3587. },
  3588. };
  3589. },
  3590. controller: [
  3591. "$scope",
  3592. "api_user_data",
  3593. function ($scope, api_user_data) {
  3594. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3595. $scope.property = {
  3596. hw_change: $scope.to.loginUser,
  3597. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3598. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3599. };
  3600. if ($scope.$parent.$parent.$parent.model.assets) {
  3601. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3602. }
  3603. },
  3604. ],
  3605. });
  3606. //申请单信息
  3607. formlyConfigProvider.setType({
  3608. name: "ui-cmdbformimform",
  3609. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3610. wrapper: ["bootstrapHasError"],
  3611. defaultOptions: function (options, $scope) {
  3612. return {
  3613. templateOptions: {
  3614. // checkform: function(options) {
  3615. // if (options.model.requester) {
  3616. // options.value(options.model.requester);
  3617. // }
  3618. // },
  3619. },
  3620. };
  3621. },
  3622. controller: [
  3623. "$scope",
  3624. "api_user_data",
  3625. function ($scope, api_user_data) {
  3626. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3627. $scope.getininform = {
  3628. serialNumbe:
  3629. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3630. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3631. };
  3632. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3633. $scope.getininform.types = "新资产入库";
  3634. } else if (
  3635. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3636. ) {
  3637. $scope.getininform.types = "资产归还";
  3638. }
  3639. },
  3640. ],
  3641. });
  3642. //出库单信息
  3643. formlyConfigProvider.setType({
  3644. name: "ui-outinformation",
  3645. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3646. wrapper: ["bootstrapHasError"],
  3647. defaultOptions: function (options, $scope) {
  3648. return {
  3649. templateOptions: {
  3650. // checkform: function(options) {
  3651. // if (options.model.requester) {
  3652. // options.value(options.model.requester);
  3653. // }
  3654. // },
  3655. },
  3656. };
  3657. },
  3658. controller: [
  3659. "$scope",
  3660. "api_user_data",
  3661. function ($scope, api_user_data) {
  3662. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3663. $scope.getininform = {
  3664. serialNumbe:
  3665. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3666. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3667. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3668. sourceId:
  3669. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3670. describe:
  3671. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3672. };
  3673. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3674. $scope.getininform.types = "新设备领用出库";
  3675. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3676. $scope.getininform.types = "设备更换";
  3677. }
  3678. $scope.getininform.source_id =
  3679. $scope.$parent.$parent.$parent.model.source.value;
  3680. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3681. $scope.getininform.source = "事件";
  3682. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3683. $scope.getininform.source = "变更";
  3684. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3685. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3686. $scope.getininform.source = "其它";
  3687. }
  3688. },
  3689. ],
  3690. });
  3691. //资产附件上传
  3692. formlyConfigProvider.setType({
  3693. name: "ui-cmdbuplode",
  3694. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3695. wrapper: ["bootstrapHasError"],
  3696. defaultOptions: function (options, $scope) {
  3697. return {
  3698. templateOptions: {
  3699. // checkform: function(options) {
  3700. // if (options.model.requester) {
  3701. // options.value(options.model.requester);
  3702. // }
  3703. // },
  3704. },
  3705. };
  3706. },
  3707. controller: [
  3708. "$scope",
  3709. "$rootScope",
  3710. "$http",
  3711. "SweetAlert",
  3712. "FileUploader",
  3713. "api_user_data",
  3714. "i18nService",
  3715. "$modal",
  3716. "Restangular",
  3717. "api_configure_data",
  3718. "api_cmdb",
  3719. "api_cmdb_new",
  3720. "api_wechatfile",
  3721. "api_sysinfo",
  3722. function (
  3723. $scope,
  3724. $rootScope,
  3725. $http,
  3726. SweetAlert,
  3727. FileUploader,
  3728. api_user_data,
  3729. i18nService,
  3730. $modal,
  3731. Restangular,
  3732. api_configure_data,
  3733. api_cmdb,
  3734. api_cmdb_new,
  3735. api_wechatfile,
  3736. api_sysinfo
  3737. ) {
  3738. $scope.state = 1;
  3739. $scope.myData3all = [];
  3740. $scope.myData3 = [];
  3741. $scope.memoryfilterDatahao = {
  3742. idx: 0,
  3743. sum: 10,
  3744. };
  3745. $scope.selected = {
  3746. items: [],
  3747. };
  3748. $scope.interceptMydata = function (mydate, idx, sum) {
  3749. return mydate.slice(idx * sum, (idx + 1) * sum);
  3750. };
  3751. // $scope.importnext = function() {
  3752. // $scope.state = 2;
  3753. // event.preventDefault();
  3754. // }
  3755. $scope.workspaces = [];
  3756. $scope.options.templateOptions.getpush = function (item) {
  3757. $scope.workspaces = [];
  3758. if (item.gu) {
  3759. $scope.workspaces.push({
  3760. id: 1,
  3761. name: "固定资产",
  3762. active: true,
  3763. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3764. });
  3765. }
  3766. if (item.hao) {
  3767. $scope.workspaces.push({
  3768. id: 2,
  3769. name: "耗材资产",
  3770. active: true,
  3771. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3772. });
  3773. }
  3774. };
  3775. //获取附件列表
  3776. $scope.listAttachmen = function () {
  3777. to.ApiService.listAttachment(
  3778. to.listAttachmentUrl,
  3779. to.bindType,
  3780. bindId
  3781. ).then(function (result) {
  3782. var myData = Restangular.stripRestangular(result);
  3783. // $scope.listAttachmens = myData;
  3784. $scope.attachments = myData.data;
  3785. });
  3786. };
  3787. //附件列表
  3788. if ($scope.options.templateOptions.bindType) {
  3789. if (angular.isUndefined($scope.form.dropState)) {
  3790. $scope.form.dropState = false;
  3791. }
  3792. var to = $scope.options.templateOptions;
  3793. var bindId = $scope.model[to.bindType].processInstanceId;
  3794. $scope.listAttachmen();
  3795. }
  3796. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3797. // $scope.listAttachmen();
  3798. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3799. // $scope.listAttachmen();
  3800. // }
  3801. //附件下载
  3802. $scope.download = function (token, filename) {
  3803. var downUrl = to.ApiService.downloadAttachment(
  3804. to.downUrl,
  3805. token
  3806. ).getRequestedUrl();
  3807. // window.open(downUrl);
  3808. var a = document.createElement("a");
  3809. a.href = downUrl;
  3810. a.target = "_blank";
  3811. a.download = filename;
  3812. document.body.appendChild(a);
  3813. a.click();
  3814. };
  3815. //附件预览
  3816. $scope.view = function (id, previewUrl) {
  3817. if (previewUrl) {
  3818. window.open(previewUrl);
  3819. }
  3820. };
  3821. //下载资产模版
  3822. $scope.filenum = 0;
  3823. $scope.openmeans = function () {
  3824. var modalInstance = $modal.open({
  3825. templateUrl: "assets/views/means/tpl/meansdown.html",
  3826. controller: function ($scope, scope, $modalInstance) {
  3827. $scope.item = {};
  3828. $scope.title = "选择下载模版";
  3829. $scope.lable = "资产模版下载";
  3830. function foreachdata(my_datas) {
  3831. // angular.forEach(my_datas, function(item, index) {
  3832. // if (item.children && item.children.length > 0) {
  3833. // foreachdata(item.children);
  3834. // } else {
  3835. // my_datas[index].checks = true;
  3836. // }
  3837. // })
  3838. for (var i = 0; i < my_datas.length; i++) {
  3839. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3840. foreachdata(my_datas[i].children);
  3841. console.log($scope);
  3842. } else {
  3843. my_datas[i].checks = true;
  3844. }
  3845. }
  3846. }
  3847. function foreachtree(data) {
  3848. angular.forEach(data, function (item) {
  3849. // if (item.checks != true) {
  3850. item.checks = true;
  3851. item.expanded = true;
  3852. if (item.children && item.children.length > 0) {
  3853. foreachtree(item.children);
  3854. } else {
  3855. $scope.getslowtree.push(item);
  3856. }
  3857. // }
  3858. });
  3859. }
  3860. $scope.getslowtree = [];
  3861. $scope.slowtree = function (tree) {
  3862. foreachtree(tree);
  3863. return $scope.getslowtree;
  3864. };
  3865. $scope.all = function (c, v) {
  3866. //全选
  3867. if (c == true) {
  3868. $scope.formdashboard($scope.slowtree(v));
  3869. } else {
  3870. $scope.my_data_after = [];
  3871. angular.forEach($scope.my_data, function (item, index) {
  3872. $scope.my_data[index].checks = false;
  3873. $scope.my_data[index].expanded = false;
  3874. if (item.children && item.children.length > 0) {
  3875. angular.forEach(
  3876. item.children,
  3877. function (itemone, indexone) {
  3878. $scope.my_data[index].children[
  3879. indexone
  3880. ].checks = false;
  3881. $scope.my_data[index].children[
  3882. indexone
  3883. ].expanded = false;
  3884. if (itemone.children && itemone.children.length > 0) {
  3885. angular.forEach(
  3886. itemone.children,
  3887. function (itemtwo, indextwo) {
  3888. $scope.my_data[index].children[
  3889. indexone
  3890. ].children[indextwo].checks = false;
  3891. }
  3892. );
  3893. } else {
  3894. }
  3895. }
  3896. );
  3897. } else {
  3898. }
  3899. });
  3900. $scope.mydatacate = [];
  3901. $scope.getslowtree = [];
  3902. // }
  3903. }
  3904. };
  3905. // $scope.searchone = function(search) {
  3906. // angular.forEach($scope.my_data, function(item) {
  3907. // if (item.indexOf(search) > 0) {
  3908. // }
  3909. // })
  3910. // }
  3911. $scope.checkall = function () {
  3912. angular.forEach($scope.my_data, function (item, index) {
  3913. scope.my_data[index].checks = true;
  3914. });
  3915. };
  3916. $scope.selectitem = [];
  3917. $scope.choiceitem = function (item) {
  3918. // if (item.checkeds) {
  3919. // item.checkeds = false;
  3920. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3921. // // if ($scope.selectitem[i].id == item.id) {
  3922. // // $scope.selectitem.splice(i, 1)
  3923. // // }
  3924. // // }
  3925. // for (var i = 0; i < $scope.my_data_after; i++) {
  3926. // if ($scope.my_data_after[i].id == item.id) {
  3927. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3928. // // $scope.selectitem.splice(i, 1)
  3929. // }
  3930. // }
  3931. // } else {
  3932. // item.checkeds = true;
  3933. // $scope.selectitem.push(item)
  3934. // }
  3935. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3936. if ($scope.my_data_after[i].id == item.id) {
  3937. $scope.my_data_after[i].checkeds
  3938. ? ($scope.my_data_after[i].checkeds = false)
  3939. : ($scope.my_data_after[i].checkeds = true);
  3940. }
  3941. }
  3942. };
  3943. $scope.remove = function (removeitem) {
  3944. var realdat = angular.copy($scope.my_data_after);
  3945. // angular.extend(realdat, $scope.selectitem);
  3946. $scope.my_data_after = [];
  3947. angular.forEach(realdat, function (item) {
  3948. if (!item.checkeds) {
  3949. $scope.my_data_after.push(item);
  3950. }
  3951. });
  3952. $scope.mydatacate = angular.copy($scope.my_data_after);
  3953. };
  3954. $scope.try_async_loads = function (item, search) {
  3955. var fildatas = {
  3956. idx: 0,
  3957. sum: 1000,
  3958. };
  3959. $scope.my_data = [];
  3960. // $scope.try_async_load = true;
  3961. if (item) {
  3962. angular.extend(fildatas, item);
  3963. }
  3964. api_configure_data
  3965. .fetchDataList("ciclassify", fildatas)
  3966. .then(function (response) {
  3967. if (response.status == 200) {
  3968. var data = response.list;
  3969. var objects = [];
  3970. for (var i = 0; i < data.length; i++) {
  3971. var object = {};
  3972. object.id = data[i].id;
  3973. if (search) {
  3974. delete data[i].parent;
  3975. } else {
  3976. if (data[i].parent && data[i].parent.id != 0) {
  3977. object.parent = data[i].parent.id;
  3978. }
  3979. }
  3980. angular.extend(object, data[i]);
  3981. objects.push(object);
  3982. }
  3983. $scope.my_data = convertParentToChildList(objects);
  3984. $scope.tree_data = angular.copy($scope.my_data);
  3985. if ($scope.my_data.length > 0) {
  3986. $scope.try_async_load = false;
  3987. }
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "系统错误!",
  3991. text: "请刷新重试!",
  3992. type: "error",
  3993. });
  3994. }
  3995. });
  3996. };
  3997. function convertListToTree(data, treeMap) {
  3998. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3999. var root = null; //Initially set our loop to null
  4000. //loop over data
  4001. for (var i = 0; i < data.length; i++) {
  4002. var datum = data[i];
  4003. //each node will have children, so let's give it a "children" poperty
  4004. datum.children = [];
  4005. //add an entry for this node to the map so that any future children can
  4006. //lookup the parent
  4007. idToNodeMap[datum.id] = datum;
  4008. //Does this node have a parent?
  4009. // console.log("datum="+JSON.stringify(datum))
  4010. if (
  4011. typeof datum.parent === "undefined" ||
  4012. datum.parent === null
  4013. ) {
  4014. //Doesn't look like it, so this node is the root of the tree
  4015. root = datum;
  4016. treeMap[datum.id] = root;
  4017. } else {
  4018. //This node has a parent, so let's look it up using the id
  4019. parentNode = idToNodeMap[datum.parent.id];
  4020. //We don't need this property, so let's delete it.
  4021. // delete datum.parent;
  4022. //Let's add the current node as a child of the parent node.
  4023. parentNode.children.push(datum);
  4024. }
  4025. }
  4026. return root;
  4027. }
  4028. function convertParentToChildList(data) {
  4029. var treeMap = {};
  4030. var list = [];
  4031. convertListToTree(data, treeMap);
  4032. angular.forEach(treeMap, function (item) {
  4033. list.push(item);
  4034. });
  4035. return list;
  4036. }
  4037. function convertParentToChild(datato) {
  4038. var treeMapto = {};
  4039. var listto = [];
  4040. convertListToTree(datato, treeMapto);
  4041. angular.forEach(treeMapto, function (items) {
  4042. listto.push(items);
  4043. });
  4044. return listto;
  4045. }
  4046. $scope.try_async_loads();
  4047. $scope.searchdown = function (key) {
  4048. if (key && key != "") {
  4049. $scope.try_async_loads(
  4050. {
  4051. ciclassify: {
  4052. label: key,
  4053. },
  4054. },
  4055. "search"
  4056. );
  4057. } else {
  4058. $scope.try_async_loads();
  4059. }
  4060. // var mydatacatedown = angular.copy($scope.my_data);
  4061. // $scope.my_data = [];
  4062. // var objects = [];
  4063. // angular.forEach(mydatacatedown, function(item) {
  4064. // if (item.label.match(key)) {
  4065. // objects.push(item)
  4066. // } else {
  4067. // // $scope.my_data_after.push(item)
  4068. // }
  4069. // })
  4070. // $scope.my_data = convertParentToChildList(objects);
  4071. // $scope.tree_data = angular.copy($scope.my_data);
  4072. };
  4073. $scope.mydatacate = [];
  4074. $scope.searchup = function (key) {
  4075. // var mydatacate = angular.copy($scope.my_data_after);
  4076. $scope.my_data_after = [];
  4077. angular.forEach($scope.mydatacate, function (item) {
  4078. if (item.label.match(key)) {
  4079. $scope.my_data_after.push(item);
  4080. } else {
  4081. }
  4082. });
  4083. };
  4084. //角色树
  4085. $scope.my_tree = [];
  4086. $scope.tree_data_after = [];
  4087. $scope.my_data = [];
  4088. $scope.my_data_after = [];
  4089. $scope.formdashboard = function (item) {
  4090. $scope.my_data_after = [];
  4091. angular.forEach(item, function (infox) {
  4092. if (infox.children.length == 0) {
  4093. $scope.my_data_after.push(infox);
  4094. }
  4095. });
  4096. $scope.mydatacate = angular.copy($scope.my_data_after);
  4097. };
  4098. $scope.ok = function (item) {
  4099. $modalInstance.close(item);
  4100. };
  4101. $scope.cancel = function () {
  4102. $modalInstance.dismiss("cancel");
  4103. };
  4104. },
  4105. // size: 'sm',
  4106. resolve: {
  4107. scope: function () {
  4108. return $scope;
  4109. },
  4110. },
  4111. });
  4112. modalInstance.result.then(function (selectedItem) {
  4113. // $rootScope.isMask = true;
  4114. if (selectedItem) {
  4115. var type = 1;
  4116. var fildat = {
  4117. configure: selectedItem,
  4118. };
  4119. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4120. // // if (data.errno == 0) {
  4121. // var file = new Blob([data], {
  4122. // // 'Accept': '*/*'
  4123. // type: 'application/octet-stream'
  4124. // // type: 'application/vnd.ms-excel'
  4125. // });
  4126. // //trick to download store a file having its URL
  4127. // var fileURL = URL.createObjectURL(file);
  4128. // var a = document.createElement('a');
  4129. // a.href = fileURL;
  4130. // a.target = '_blank';
  4131. // a.download = "资产导入模版.xlsx";
  4132. // document.body.appendChild(a);
  4133. // a.click();
  4134. // // }
  4135. // })
  4136. $http({
  4137. url: api_configure_data
  4138. .downModels("export/cmdb", fildat)
  4139. .getRequestedUrl(),
  4140. method: "POST",
  4141. data: JSON.stringify(fildat),
  4142. headers: {
  4143. // 'Content-type': 'application/xls',
  4144. Accept: "*/*",
  4145. },
  4146. responseType: "arraybuffer",
  4147. })
  4148. .success(function (data, status, headers, config) {
  4149. $rootScope.isMask = false;
  4150. var file = new Blob([data], {
  4151. type: "application/octet-stream",
  4152. // type : 'application/vnd.ms-excel'
  4153. });
  4154. //trick to download store a file having its URL
  4155. var fileURL = URL.createObjectURL(file);
  4156. var a = document.createElement("a");
  4157. a.href = fileURL;
  4158. a.target = "_blank";
  4159. a.download = "资产导入模版.xlsx";
  4160. document.body.appendChild(a);
  4161. a.click();
  4162. })
  4163. .error(function (data, status, headers, config) {
  4164. // console.log(data);
  4165. $rootScope.isMask = false;
  4166. });
  4167. // break;
  4168. // }
  4169. // }
  4170. // }
  4171. // })
  4172. } else {
  4173. SweetAlert.swal(
  4174. {
  4175. title: "未选择资产分类!",
  4176. text: "请选择资产分类",
  4177. type: "error",
  4178. },
  4179. function () {
  4180. $rootScope.isMask = false;
  4181. }
  4182. );
  4183. }
  4184. // }
  4185. });
  4186. };
  4187. $scope.wrongdata = [];
  4188. var uploader = ($scope.uploader =
  4189. $scope.options.templateOptions.fileUploader);
  4190. var uploadermeans = ($scope.uploadermeans =
  4191. $scope.options.templateOptions.fileUploadermeans);
  4192. $scope.importopen = function () {
  4193. //导入触发事件
  4194. if (angular.isUndefined($scope.form.dropState)) {
  4195. $scope.form.dropState = false;
  4196. }
  4197. //附件上传数据
  4198. //$scope.options.templateOptions.uploader();
  4199. // FILTERS
  4200. uploader.filters.push({
  4201. name: "customFilter",
  4202. fn: function (item /*{File|FileLikeObject}*/, options) {
  4203. return this.queue.length < 2;
  4204. },
  4205. });
  4206. // CALLBACKS
  4207. uploader.onWhenAddingFileFailed = function (
  4208. item /*{File|FileLikeObject}*/,
  4209. filter,
  4210. options
  4211. ) {
  4212. console.info("onWhenAddingFileFailed", item, filter, options);
  4213. };
  4214. uploader.onAfterAddingFile = function (fileItem) {
  4215. console.info("onAfterAddingFile", fileItem);
  4216. };
  4217. uploader.onAfterAddingAll = function (addedFileItems) {
  4218. console.info("onAfterAddingAll", addedFileItems);
  4219. };
  4220. uploader.onBeforeUploadItem = function (item) {
  4221. console.info("onBeforeUploadItem", item);
  4222. };
  4223. uploader.onProgressItem = function (fileItem, progress) {
  4224. console.info("onProgressItem", fileItem, progress);
  4225. };
  4226. uploader.onProgressAll = function (progress) {
  4227. console.info("onProgressAll", progress);
  4228. };
  4229. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4230. // console.info('onSuccessItem', fileItem, response, status, headers);
  4231. // };
  4232. uploader.onErrorItem = function (
  4233. fileItem,
  4234. response,
  4235. status,
  4236. headers
  4237. ) {
  4238. console.info("onErrorItem", fileItem, response, status, headers);
  4239. };
  4240. uploader.onCancelItem = function (
  4241. fileItem,
  4242. response,
  4243. status,
  4244. headers
  4245. ) {
  4246. console.info("onCancelItem", fileItem, response, status, headers);
  4247. };
  4248. uploader.onCompleteItem = function (
  4249. fileItem,
  4250. response,
  4251. status,
  4252. headers
  4253. ) {
  4254. console.info("onCompleteItem", fileItem, response, status, headers);
  4255. };
  4256. uploader.onCompleteAll = function () {
  4257. console.info("onCompleteAll");
  4258. };
  4259. };
  4260. // $scope.importnext = function() {
  4261. // $scope.state = 2;
  4262. // event.preventDefault();
  4263. // }
  4264. $scope.importnext = function () {
  4265. event.preventDefault();
  4266. // $rootScope.isMask = true;
  4267. $rootScope.loading = true;
  4268. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4269. uploader.onBeforeUploadItem = function (item) {
  4270. angular.extend(item.headers, $rootScope.getSession());
  4271. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4272. // if (item.index > 1) {
  4273. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4274. // }
  4275. // item.index = 1;
  4276. item.formData = [
  4277. {
  4278. filename: item.file.name,
  4279. },
  4280. ];
  4281. console.info("onBeforeUploadItem", item);
  4282. };
  4283. uploader.uploadAll();
  4284. uploader.onSuccessItem = function (
  4285. fileItem,
  4286. response,
  4287. status,
  4288. headers
  4289. ) {
  4290. if (response.status == 200) {
  4291. $scope.wrongdata = [];
  4292. $rootScope.loading = false;
  4293. if (response.abnormal) {
  4294. $scope.state = 2;
  4295. angular.forEach(response.msg, function (item) {
  4296. $scope.wrongdata.push({
  4297. name: item.assetName,
  4298. line: item.row,
  4299. cmdbname: item.name,
  4300. errotip: [
  4301. {
  4302. label: item.msg,
  4303. },
  4304. ],
  4305. });
  4306. });
  4307. } else {
  4308. $scope.state = 3;
  4309. }
  4310. } else {
  4311. $rootScope.loading = false;
  4312. $scope.state = 2;
  4313. }
  4314. };
  4315. };
  4316. $scope.clearItems = function () {
  4317. //重新选择文件时,清空队列,达到覆盖文件的效果
  4318. uploader.clearQueue();
  4319. // uploader.remove();
  4320. // uploader.cancel();
  4321. // uploader.onChange();
  4322. };
  4323. uploader.onAfterAddingFile = function (fileItem) {
  4324. $scope.fileItem = fileItem._file;
  4325. // $scope.$apply();
  4326. // $scope.fileItem = filenum;
  4327. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4328. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4329. $scope.filenum++;
  4330. };
  4331. uploader.onSuccessItem = function (
  4332. fileItem,
  4333. response,
  4334. status,
  4335. headers
  4336. ) {
  4337. $scope.uploadStatus = true; //上传成功则把状态改为true
  4338. // alert(response.path);
  4339. };
  4340. $scope.importnext = function () {
  4341. event.preventDefault();
  4342. // uploader.onChange();
  4343. $rootScope.loading = true;
  4344. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4345. uploader.onBeforeUploadItem = function (item) {
  4346. angular.extend(item.headers, $rootScope.getSession());
  4347. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4348. // if (item.index > 1) {
  4349. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4350. // }
  4351. // item.index = 1;
  4352. item.formData = [
  4353. {
  4354. filename: item.file.name,
  4355. },
  4356. ];
  4357. console.info("onBeforeUploadItem", item);
  4358. };
  4359. uploader.uploadAll();
  4360. uploader.onSuccessItem = function (
  4361. fileItem,
  4362. response,
  4363. status,
  4364. headers
  4365. ) {
  4366. if (response.status == 200) {
  4367. $scope.wrongdata = [];
  4368. // uploader.queue = [];
  4369. $rootScope.loading = false;
  4370. if (response.abnormal) {
  4371. $scope.state = 2;
  4372. uploader.clearQueue();
  4373. angular.forEach(response.msg, function (item) {
  4374. $scope.wrongdata.push({
  4375. name: item.assetName,
  4376. line: item.row,
  4377. cmdbname: item.name,
  4378. errotip: [
  4379. {
  4380. label: item.msg,
  4381. },
  4382. ],
  4383. });
  4384. });
  4385. } else {
  4386. $scope.state = 3;
  4387. }
  4388. } else {
  4389. uploader.clearQueue();
  4390. $rootScope.loading = false;
  4391. $scope.state = 2;
  4392. }
  4393. };
  4394. };
  4395. var setAllInactive = function () {
  4396. angular.forEach($scope.workspaces, function (workspace) {
  4397. workspace.active = false;
  4398. });
  4399. };
  4400. //添加
  4401. var addNewWorkspace = function (name, contentUrl) {
  4402. var id = $scope.workspaces.length + 1;
  4403. $scope.workspaces.push({
  4404. id: id,
  4405. name: name,
  4406. active: true,
  4407. contentUrl: "main/html/content.html",
  4408. });
  4409. };
  4410. //关闭
  4411. $scope.closeopen = function (closedata) {
  4412. event.preventDefault();
  4413. angular.forEach($scope.workspaces, function (item, index) {
  4414. if (closedata.id == item.id) {
  4415. if (closedata.id == 1) {
  4416. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4417. } else {
  4418. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4419. }
  4420. $scope.workspaces.splice(index, 1);
  4421. }
  4422. });
  4423. };
  4424. // $scope.workspaces = [
  4425. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4426. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4427. // ];
  4428. $scope.addWorkspace = function (contentUrl, name) {
  4429. setAllInactive();
  4430. addNewWorkspace(name, contentUrl);
  4431. };
  4432. // $rootScope.addWorkspace = $scope.addWorkspace;
  4433. $scope.close = function (idNumber) {
  4434. var index = 0; //记录当前元素下标
  4435. angular.forEach($scope.workspaces, function (workspace) {
  4436. if (workspace.id === idNumber) {
  4437. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4438. }
  4439. index++;
  4440. });
  4441. };
  4442. //grid2
  4443. $scope.langs = i18nService.getAllLangs();
  4444. $scope.lang = "zh-cn";
  4445. i18nService.setCurrentLang($scope.lang);
  4446. $scope.gridOptions2 = {};
  4447. $scope.gridOptions2.data = "myData3";
  4448. $scope.gridOptions2.enableColumnResizing = true;
  4449. $scope.gridOptions2.enableFiltering = false;
  4450. $scope.gridOptions2.enableGridMenu = false;
  4451. $scope.gridOptions2.showGridFooter = true;
  4452. $scope.gridOptions2.showColumnFooter = false;
  4453. $scope.gridOptions2.fastWatch = true;
  4454. $scope.gridOptions2.useExternalFiltering = true;
  4455. $scope.gridOptions2.useExternalPagination = true;
  4456. $scope.gridOptions2.paginationPageSizes = [10];
  4457. $scope.gridOptions2.paginationPageSize = 10;
  4458. $scope.gridOptions2.multiSelect = false;
  4459. // $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>";
  4460. $scope.gridOptions2.columnDefs = [
  4461. {
  4462. name: "item",
  4463. displayName: "序号",
  4464. width: 120,
  4465. },
  4466. {
  4467. name: "name",
  4468. displayName: "耗材名称",
  4469. width: 80,
  4470. enableFiltering: false,
  4471. },
  4472. {
  4473. name: "model",
  4474. displayName: "品牌/型号",
  4475. width: 100,
  4476. enableFiltering: false,
  4477. },
  4478. {
  4479. name: "Specifications",
  4480. displayName: "规格",
  4481. width: 150,
  4482. enableFiltering: false,
  4483. },
  4484. {
  4485. name: "sum",
  4486. displayName: "数量",
  4487. enableFiltering: false,
  4488. },
  4489. {
  4490. name: "操作",
  4491. cellTemplate:
  4492. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4493. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4494. "</div></div>",
  4495. enableFiltering: false,
  4496. },
  4497. ];
  4498. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4499. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4500. $scope.myData3all = JSON.parse(
  4501. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4502. );
  4503. for (var i = 0; i < $scope.myData3all.length; i++) {
  4504. $scope.myData3all[i]["item"] =
  4505. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4506. }
  4507. // $scope.model.consumables = $scope.myDataone;
  4508. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4509. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4510. $scope.model.applicationForm.consumables = $scope.myData3all;
  4511. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4512. $scope.options.templateOptions.getpush({
  4513. hao: true,
  4514. gu: true,
  4515. });
  4516. } else {
  4517. $scope.options.templateOptions.getpush({
  4518. hao: true,
  4519. });
  4520. }
  4521. } else {
  4522. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4523. $scope.options.templateOptions.getpush({
  4524. gu: true,
  4525. });
  4526. }
  4527. }
  4528. }
  4529. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4530. $scope.changecai = function (item) {
  4531. event.preventDefault();
  4532. var modalInstance = $modal.open({
  4533. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4534. controller: function ($scope, $modalInstance) {
  4535. $scope.title = "修改耗材数量";
  4536. $scope.consumptive = angular.copy(item);
  4537. $scope.ok = function () {
  4538. $modalInstance.close($scope.consumptive);
  4539. };
  4540. $scope.cancel = function () {
  4541. $modalInstance.dismiss("cancel");
  4542. };
  4543. },
  4544. size: "sm",
  4545. });
  4546. modalInstance.result.then(function (selectedItem) {
  4547. // angular.forEach($scope.myData3, function(items, index) {
  4548. // if (items.id == selectedItem.id) {
  4549. // $scope.myData3[index] = selectedItem;
  4550. // }
  4551. // })
  4552. // // $scope.myData3.push(selectedItem);
  4553. // $scope.model.applicationForm.consumables = $scope.myData3;
  4554. angular.forEach($scope.myData3all, function (items, index) {
  4555. if (
  4556. items.modelid == selectedItem.modelid &&
  4557. items.nameid == selectedItem.nameid &&
  4558. items.Specificationsid == selectedItem.Specificationsid
  4559. ) {
  4560. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4561. angular.extend($scope.myData3all[index], selectedItem);
  4562. }
  4563. });
  4564. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4565. $scope.myData3 = $scope.interceptMydata(
  4566. $scope.myData3all,
  4567. $scope.memoryfilterDatahao.idx,
  4568. 10
  4569. );
  4570. $scope.model.applicationForm.consumables = $scope.myData3all;
  4571. });
  4572. };
  4573. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4574. $scope.gridApi = gridApi;
  4575. gridApi.pagination.on.paginationChanged(
  4576. $scope,
  4577. function (newPage, pageSize) {
  4578. // var filtersData = $scope.memoryfilterDatahao;
  4579. // filtersData.idx = newPage - 1;
  4580. // filtersData.sum = pageSize;
  4581. // $scope.loadData(filtersData);
  4582. $scope.memoryfilterDatahao.idx = newPage - 1;
  4583. $scope.memoryfilterDatahao.sum = pageSize;
  4584. $scope.myData3 = $scope.interceptMydata(
  4585. $scope.myData3all,
  4586. $scope.memoryfilterDatahao.idx,
  4587. 10
  4588. );
  4589. }
  4590. );
  4591. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4592. $scope.selected.items = data.entity;
  4593. //console.log(data);
  4594. });
  4595. gridApi.selection.on.rowSelectionChangedBatch(
  4596. $scope,
  4597. function (data) {
  4598. $scope.selected.items = data.entity;
  4599. //console.log(data);
  4600. }
  4601. );
  4602. gridApi.core.on.filterChanged($scope, function () {
  4603. var grid = this.grid;
  4604. var filtersData = {
  4605. idx: 0,
  4606. sum: 10,
  4607. };
  4608. $scope.memoryfilterDatahao = filtersData;
  4609. // $scope.loadData(filtersData);
  4610. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4611. // $scope.memoryfilterDatahao.sum = pageSize;
  4612. $scope.myData3 = $scope.interceptMydata(
  4613. $scope.myData3all,
  4614. $scope.memoryfilterDatahao.idx,
  4615. 10
  4616. );
  4617. });
  4618. };
  4619. $scope.haocaiopen = function (items) {
  4620. event.preventDefault();
  4621. var modalInstance = $modal.open({
  4622. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4623. controller: function ($scope, $modalInstance, SweetAlert) {
  4624. $scope.consumptive = {};
  4625. $scope.title = "新增耗材";
  4626. if (items.name) {
  4627. $scope.consumptive.name = items.name.name;
  4628. }
  4629. $scope.clearNoNum = function (obj, attr) {
  4630. //先把非数字的都替换掉,除了数字和.
  4631. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4632. //必须保证第一个为数字而不是.
  4633. obj[attr] = obj[attr].replace(/^\./g, "");
  4634. //保证只有出现一个.而没有多个.
  4635. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4636. //保证.只出现一次,而不能出现两次以上
  4637. obj[attr] = obj[attr]
  4638. .replace(".", "$#$")
  4639. .replace(/\./g, "")
  4640. .replace("$#$", ".");
  4641. //小于最大值
  4642. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4643. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4644. // obj[attr] = '';
  4645. // }
  4646. };
  4647. $scope.ok = function (item) {
  4648. // if (item.name && item.model && item.Specifications && item.sum) {
  4649. if (
  4650. item.name &&
  4651. item.model &&
  4652. JSON.stringify(item.model) != "{}" &&
  4653. item.Specifications &&
  4654. JSON.stringify(item.Specifications) != "{}" &&
  4655. item.sum
  4656. ) {
  4657. $modalInstance.close(item);
  4658. } else {
  4659. SweetAlert.swal({
  4660. title: "数据填写不完整!",
  4661. text: "请检查数据然后提交!",
  4662. type: "error",
  4663. });
  4664. }
  4665. };
  4666. $scope.cancel = function () {
  4667. $modalInstance.dismiss("cancel");
  4668. };
  4669. },
  4670. size: "sm",
  4671. resolve: {
  4672. SweetAlert: function () {
  4673. return SweetAlert;
  4674. },
  4675. },
  4676. });
  4677. modalInstance.result.then(function (selectedItem) {
  4678. api_sysinfo
  4679. .addData("dictionaryTree", {
  4680. // "type": "list",
  4681. key: "haocaifenlei",
  4682. name: selectedItem.name,
  4683. parent: selectedItem.id,
  4684. value: selectedItem.name,
  4685. deleted: false,
  4686. level: 1,
  4687. })
  4688. .then(function (data) {
  4689. // $scope.haocainame.name = data.list;
  4690. api_sysinfo
  4691. .addData("dictionaryTree", {
  4692. // "type": "list",
  4693. key: "pinpai",
  4694. name: selectedItem.model,
  4695. parent: data.id,
  4696. value: selectedItem.model,
  4697. deleted: false,
  4698. level: 2,
  4699. })
  4700. .then(function (data) {
  4701. // $scope.haocainame = data.list;
  4702. });
  4703. api_sysinfo
  4704. .addData({
  4705. // "type": "list",
  4706. key: "guige",
  4707. name: selectedItem.Specifications,
  4708. parent: data.id,
  4709. value: selectedItem.Specifications,
  4710. deleted: false,
  4711. level: 2,
  4712. })
  4713. .then(function (data) {
  4714. // $scope.haocainame = data.list;
  4715. });
  4716. });
  4717. // $scope.myData3.push(selectedItem);
  4718. // for (var i = 0; i < $scope.myData3.length; i++) {
  4719. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4720. // }
  4721. // $scope.model.applicationForm.consumables = $scope.myData3;
  4722. $scope.myData3all.push(selectedItem);
  4723. for (var i = 0; i < $scope.myData3all.length; i++) {
  4724. $scope.myData3all[i]["item"] = i + 1;
  4725. }
  4726. // $scope.model.consumables = $scope.myDataone;
  4727. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4728. $scope.myData3 = $scope.interceptMydata(
  4729. $scope.myData3all,
  4730. $scope.memoryfilterDatahao.idx,
  4731. 10
  4732. );
  4733. $scope.model.applicationForm.consumables = $scope.myData3all;
  4734. });
  4735. };
  4736. $scope.haocaiadd = function () {
  4737. event.preventDefault();
  4738. var modalInstance = $modal.open({
  4739. templateUrl:
  4740. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4741. controller: function (
  4742. $scope,
  4743. scope,
  4744. $modalInstance,
  4745. api_wechatfile,
  4746. SweetAlert,
  4747. api_cmdb3
  4748. ) {
  4749. $scope.haocainame = [];
  4750. $scope.pinpai = [];
  4751. $scope.guige = [];
  4752. $scope.consumptive = {};
  4753. $scope.consumpall = {};
  4754. $scope.title = "添加耗材";
  4755. api_wechatfile
  4756. .getDictionary({
  4757. key: "haocaifenlei",
  4758. type: "tree",
  4759. })
  4760. .then(function (data) {
  4761. $scope.haocainame = data;
  4762. });
  4763. $scope.clearNoNum = function (obj, attr) {
  4764. //先把非数字的都替换掉,除了数字和.
  4765. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4766. //必须保证第一个为数字而不是.
  4767. obj[attr] = obj[attr].replace(/^\./g, "");
  4768. //保证只有出现一个.而没有多个.
  4769. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4770. //保证.只出现一次,而不能出现两次以上
  4771. obj[attr] = obj[attr]
  4772. .replace(".", "$#$")
  4773. .replace(/\./g, "")
  4774. .replace("$#$", ".");
  4775. //小于最大值
  4776. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4777. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4778. // obj[attr] = '';
  4779. // }
  4780. };
  4781. $scope.onChange = function (parent) {
  4782. $scope.consumptive.model = {};
  4783. $scope.consumptive.Specifications = {};
  4784. api_wechatfile
  4785. .getDictionaryForList({
  4786. key: "pinpai",
  4787. parent: parent.id,
  4788. })
  4789. .then(function (data) {
  4790. $scope.pinpai = data;
  4791. });
  4792. api_wechatfile
  4793. .getDictionaryForList({
  4794. key: "guige",
  4795. parent: parent.id,
  4796. })
  4797. .then(function (data) {
  4798. $scope.guige = data;
  4799. });
  4800. };
  4801. $scope.addhaocai = function () {
  4802. $modalInstance.dismiss("cancel");
  4803. scope.haocaiopen($scope.consumptive);
  4804. };
  4805. $scope.ok = function (item) {
  4806. var items = {};
  4807. var submittrue = true;
  4808. if (
  4809. item.name &&
  4810. item.model &&
  4811. JSON.stringify(item.model) != "{}" &&
  4812. item.Specifications &&
  4813. JSON.stringify(item.Specifications) != "{}" &&
  4814. item.sum
  4815. ) {
  4816. items = {
  4817. modelid: item.model.id,
  4818. nameid: item.name.id,
  4819. Specificationsid: item.Specifications.id,
  4820. name: item.name.name,
  4821. model: item.model.name,
  4822. Specifications: item.Specifications.name,
  4823. sum: item.sum,
  4824. };
  4825. angular.forEach(scope.myData3all, function (itemsdata) {
  4826. if (
  4827. item.model.id == itemsdata.modelid &&
  4828. item.name.id == itemsdata.nameid &&
  4829. item.Specifications.id == itemsdata.Specificationsid
  4830. ) {
  4831. submittrue = false;
  4832. }
  4833. });
  4834. if (submittrue) {
  4835. $modalInstance.close(items);
  4836. } else {
  4837. SweetAlert.swal({
  4838. title: "该耗材已有添加",
  4839. text: "请检查数据然后提交!",
  4840. type: "error",
  4841. });
  4842. }
  4843. } else {
  4844. SweetAlert.swal({
  4845. title: "数据填写不完整!",
  4846. text: "请检查数据然后提交!",
  4847. type: "error",
  4848. });
  4849. }
  4850. // var isold = false;
  4851. // if (item.name && item.model && item.Specifications && item.sum) {
  4852. // for (var i = 0; i < scope.myData3all.length; i++) {
  4853. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4854. // isold = true;
  4855. // }
  4856. // }
  4857. // if (isold) {
  4858. // SweetAlert.swal({
  4859. // title: "该耗材已添加!",
  4860. // text: "请不要重复添加耗材!",
  4861. // type: "error"
  4862. // });
  4863. // } else {
  4864. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4865. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4866. // $scope.consumpall.sum = item.sum;
  4867. // delete $scope.consumpall.brandModel;
  4868. // delete $scope.consumpall.specification;
  4869. // $modalInstance.close($scope.consumpall);
  4870. // }
  4871. // } else {
  4872. // SweetAlert.swal({
  4873. // title: "数据填写不完整!",
  4874. // text: "请检查数据然后提交!",
  4875. // type: "error"
  4876. // });
  4877. // }
  4878. };
  4879. $scope.cancel = function () {
  4880. $modalInstance.dismiss("cancel");
  4881. };
  4882. },
  4883. size: "sm",
  4884. resolve: {
  4885. scope: function () {
  4886. return $scope;
  4887. },
  4888. },
  4889. });
  4890. modalInstance.result.then(function (selectedItem) {
  4891. $scope.myData3all.push(selectedItem);
  4892. for (var i = 0; i < $scope.myData3all.length; i++) {
  4893. $scope.myData3all[i]["item"] = i + 1;
  4894. }
  4895. // $scope.model.consumables = $scope.myDataone;
  4896. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4897. $scope.myData3 = $scope.interceptMydata(
  4898. $scope.myData3all,
  4899. $scope.memoryfilterDatahao.idx,
  4900. 10
  4901. );
  4902. $scope.model.applicationForm.consumables = $scope.myData3all;
  4903. });
  4904. };
  4905. $scope.onDblClick = function (data, event) {
  4906. $scope.selectButtonClick(data, event);
  4907. };
  4908. // $scope.memoryfilterDatahao = {
  4909. // "idx": 0,
  4910. // "sum": 10,
  4911. // }
  4912. // $scope.loadData = function(filterData) {};
  4913. // $scope.title = title;
  4914. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4915. $scope.options.templateOptions.transform(
  4916. $scope.options,
  4917. $rootScope,
  4918. $scope
  4919. );
  4920. }
  4921. },
  4922. ],
  4923. });
  4924. //归还设备耗材tab
  4925. formlyConfigProvider.setType({
  4926. name: "ui-cmdbreturntab",
  4927. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4928. wrapper: ["bootstrapHasError"],
  4929. defaultOptions: function (options, $scope) {
  4930. return {
  4931. templateOptions: {
  4932. // checkform: function(options) {
  4933. // if (options.model.requester) {
  4934. // options.value(options.model.requester);
  4935. // }
  4936. // },
  4937. },
  4938. };
  4939. },
  4940. controller: [
  4941. "$scope",
  4942. "$modal",
  4943. "api_user_data",
  4944. "i18nService",
  4945. "api_wechatfile",
  4946. "api_cmdb3",
  4947. function (
  4948. $scope,
  4949. $modal,
  4950. api_user_data,
  4951. i18nService,
  4952. api_wechatfile,
  4953. api_cmdb3
  4954. ) {
  4955. var setAllInactive = function () {
  4956. angular.forEach($scope.workspaces, function (workspace) {
  4957. workspace.active = false;
  4958. });
  4959. };
  4960. $scope.memoryfilterData = {
  4961. idx: 0,
  4962. sum: 10,
  4963. };
  4964. //添加
  4965. var addNewWorkspace = function (name, contentUrl) {
  4966. var id = $scope.workspaces.length + 1;
  4967. $scope.workspaces.push({
  4968. id: id,
  4969. name: name,
  4970. active: true,
  4971. contentUrl: "main/html/content.html",
  4972. });
  4973. };
  4974. $scope.workspaces = [
  4975. {
  4976. id: 1,
  4977. name: "归还设备",
  4978. active: true,
  4979. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4980. },
  4981. {
  4982. id: 2,
  4983. name: "归还耗材",
  4984. active: true,
  4985. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4986. },
  4987. ];
  4988. $scope.addWorkspace = function (contentUrl, name) {
  4989. setAllInactive();
  4990. addNewWorkspace(name, contentUrl);
  4991. };
  4992. // $rootScope.addWorkspace = $scope.addWorkspace;
  4993. $scope.close = function (idNumber) {
  4994. var index = 0; //记录当前元素下标
  4995. angular.forEach($scope.workspaces, function (workspace) {
  4996. if (workspace.id === idNumber) {
  4997. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4998. }
  4999. index++;
  5000. });
  5001. };
  5002. $scope.memoryfilterDataguishe = {
  5003. idx: 0,
  5004. sum: 10,
  5005. };
  5006. //grid1
  5007. $scope.langs = i18nService.getAllLangs();
  5008. $scope.lang = "zh-cn";
  5009. i18nService.setCurrentLang($scope.lang);
  5010. $scope.gridOptions1 = {};
  5011. $scope.gridOptions1.data = "myData1";
  5012. $scope.gridOptions1.enableColumnResizing = true;
  5013. $scope.gridOptions1.enableFiltering = false;
  5014. $scope.gridOptions1.enableGridMenu = false;
  5015. $scope.gridOptions1.showGridFooter = true;
  5016. $scope.gridOptions1.showColumnFooter = false;
  5017. $scope.gridOptions1.fastWatch = true;
  5018. $scope.gridOptions1.useExternalFiltering = true;
  5019. $scope.gridOptions1.useExternalPagination = true;
  5020. $scope.gridOptions1.paginationPageSizes = [10];
  5021. $scope.gridOptions1.paginationPageSize = 10;
  5022. $scope.gridOptions1.multiSelect = false;
  5023. // $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>";
  5024. $scope.gridOptions1.columnDefs = [
  5025. {
  5026. name: "item",
  5027. displayName: "序号",
  5028. width: 120,
  5029. },
  5030. {
  5031. name: "props.hw_cifilterClassic",
  5032. displayName: "设备类型",
  5033. width: 150,
  5034. enableFiltering: false,
  5035. },
  5036. {
  5037. name: "props.hw_mingcheng",
  5038. displayName: "设备名称",
  5039. width: 180,
  5040. enableFiltering: false,
  5041. },
  5042. {
  5043. name: "uuid",
  5044. displayName: "设备编号",
  5045. width: 180,
  5046. enableFiltering: false,
  5047. },
  5048. {
  5049. name: "props.hw_state",
  5050. width: 150,
  5051. displayName: "状态",
  5052. enableFiltering: false,
  5053. },
  5054. {
  5055. name: "操作",
  5056. cellTemplate:
  5057. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5058. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5059. "</div></div>",
  5060. enableFiltering: false,
  5061. },
  5062. ];
  5063. // $scope.selectButtonClick
  5064. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5065. $scope.gridApi = gridApi;
  5066. gridApi.pagination.on.paginationChanged(
  5067. $scope,
  5068. function (newPage, pageSize) {
  5069. // var filtersData = $scope.memoryfilterData;
  5070. // filtersData.idx = newPage - 1;
  5071. // filtersData.sum = pageSize;
  5072. // $scope.loadData(filtersData);
  5073. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5074. $scope.memoryfilterDataguishe.sum = pageSize;
  5075. $scope.myData1 = $scope.interceptMydata(
  5076. $scope.myData2all,
  5077. $scope.memoryfilterDataguishe.idx,
  5078. 10
  5079. );
  5080. }
  5081. );
  5082. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5083. $scope.selected.items = data.entity;
  5084. //console.log(data);
  5085. });
  5086. gridApi.selection.on.rowSelectionChangedBatch(
  5087. $scope,
  5088. function (data) {
  5089. $scope.selected.items = data.entity;
  5090. //console.log(data);
  5091. }
  5092. );
  5093. gridApi.core.on.filterChanged($scope, function () {
  5094. // var grid = this.grid;
  5095. // var filtersData = {
  5096. // idx: 0,
  5097. // sum: 20,
  5098. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5099. // };
  5100. // angular.forEach(grid.columns, function(item) {
  5101. // if (item.enableFiltering) {
  5102. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5103. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5104. // if (angular.isUndefined(filtersData['user'])) {
  5105. // filtersData['user'] = {};
  5106. // }
  5107. // filtersData['user'][item.field] = item.filters[0].term;
  5108. // }
  5109. // }
  5110. // });
  5111. // $scope.memoryfilterData = filtersData;
  5112. // $scope.loadData(filtersData);
  5113. });
  5114. };
  5115. $scope.changegu = function (item) {
  5116. event.preventDefault();
  5117. var modalInstance = $modal.open({
  5118. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5119. controller: function ($scope, $modalInstance) {
  5120. $scope.title = "修改设备状态";
  5121. $scope.hw_state = {};
  5122. if (item.status) {
  5123. $scope.hw_state.name = item.hw_state;
  5124. }
  5125. // $scope.consumptive = item;
  5126. $scope.stateshe = [
  5127. {
  5128. id: 2,
  5129. name: "在库",
  5130. },
  5131. {
  5132. id: 4,
  5133. name: "报修",
  5134. },
  5135. {
  5136. id: 3,
  5137. name: "报废",
  5138. },
  5139. ];
  5140. $scope.ok = function (item) {
  5141. $modalInstance.close($scope.hw_state);
  5142. };
  5143. $scope.cancel = function () {
  5144. $modalInstance.dismiss("cancel");
  5145. };
  5146. },
  5147. size: "sm",
  5148. });
  5149. modalInstance.result.then(function (selectedItem) {
  5150. angular.forEach($scope.myData1, function (items, index) {
  5151. if (items.id == item.id) {
  5152. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5153. }
  5154. });
  5155. $scope.model.assets = $scope.myData1;
  5156. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5157. $scope.model.assets;
  5158. });
  5159. };
  5160. $scope.onDblClick = function (data, event) {
  5161. $scope.selectButtonClick(data, event);
  5162. };
  5163. $scope.memoryfilterData = {
  5164. idx: 0,
  5165. sum: 10,
  5166. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5167. };
  5168. // $scope.myData = {};
  5169. $scope.loadData = function (filterData) { };
  5170. // $scope.title = title;
  5171. $scope.loadData({
  5172. idx: 0,
  5173. sum: 10,
  5174. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5175. });
  5176. $scope.selected = {
  5177. items: [],
  5178. };
  5179. $scope.myData2 = [];
  5180. $scope.consumptive = {};
  5181. $scope.myDataguibeiall = [];
  5182. $scope.haocaiopen = function (items) {
  5183. event.preventDefault();
  5184. var modalInstance = $modal.open({
  5185. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5186. controller: function (
  5187. $scope,
  5188. $modalInstance,
  5189. SweetAlert,
  5190. api_wechatfile,
  5191. api_sysinfo
  5192. ) {
  5193. $scope.consumptive = {};
  5194. $scope.title = "新增耗材";
  5195. if (items.name) {
  5196. $scope.consumptive.name = items.name.name;
  5197. }
  5198. $scope.ok = function (item) {
  5199. if (
  5200. item.name &&
  5201. item.model &&
  5202. JSON.stringify(item.model) != "{}" &&
  5203. item.Specifications &&
  5204. JSON.stringify(item.Specifications) != "{}" &&
  5205. item.sum
  5206. ) {
  5207. $modalInstance.close(item);
  5208. } else {
  5209. SweetAlert.swal({
  5210. title: "数据填写不完整!",
  5211. text: "请检查数据然后提交!",
  5212. type: "error",
  5213. });
  5214. }
  5215. };
  5216. $scope.cancel = function () {
  5217. $modalInstance.dismiss("cancel");
  5218. };
  5219. },
  5220. size: "sm",
  5221. });
  5222. modalInstance.result.then(function (selectedItem) {
  5223. api_sysinfo
  5224. .addData({
  5225. type: "list",
  5226. key: "haocaifenlei",
  5227. name: selectedItem.name,
  5228. parent: selectedItem.id,
  5229. value: "1",
  5230. })
  5231. .then(function (data) {
  5232. // $scope.haocainame.name = data.list;
  5233. api_wechatfile
  5234. .addDictionary({
  5235. type: "list",
  5236. key: "pinpai",
  5237. name: selectedItem.model,
  5238. parent: data.id,
  5239. value: "1",
  5240. })
  5241. .then(function (data) {
  5242. // $scope.haocainame = data.list;
  5243. });
  5244. api_wechatfile
  5245. .addDictionary({
  5246. type: "list",
  5247. key: "guige",
  5248. name: selectedItem.Specifications,
  5249. parent: data.id,
  5250. value: "1",
  5251. })
  5252. .then(function (data) {
  5253. // $scope.haocainame = data.list;
  5254. });
  5255. });
  5256. $scope.myData2.push(selectedItem);
  5257. for (var i = 0; i < $scope.myData2.length; i++) {
  5258. $scope.myData2[i]["item"] =
  5259. i + 1 + $scope.memoryfilterData.idx * 10;
  5260. }
  5261. // $scope.model.applicationForm.consumables = $scope.myData2;
  5262. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5263. if (items.id == selectedItem.id) {
  5264. $scope.myDataguibeiall.splice(index, 1);
  5265. }
  5266. });
  5267. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5268. $scope.model.consumables = $scope.myDataguibeiall;
  5269. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5270. $scope.model.consumables;
  5271. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5272. });
  5273. };
  5274. //grid2
  5275. $scope.langs = i18nService.getAllLangs();
  5276. $scope.lang = "zh-cn";
  5277. i18nService.setCurrentLang($scope.lang);
  5278. $scope.gridOptions2 = {};
  5279. $scope.gridOptions2.data = "myData2";
  5280. $scope.gridOptions2.enableColumnResizing = true;
  5281. $scope.gridOptions2.enableFiltering = false;
  5282. $scope.gridOptions2.enableGridMenu = false;
  5283. $scope.gridOptions2.showGridFooter = true;
  5284. $scope.gridOptions2.showColumnFooter = false;
  5285. $scope.gridOptions2.fastWatch = true;
  5286. $scope.gridOptions2.useExternalFiltering = true;
  5287. $scope.gridOptions2.useExternalPagination = true;
  5288. $scope.gridOptions2.paginationPageSizes = [10];
  5289. $scope.gridOptions2.paginationPageSize = 10;
  5290. $scope.gridOptions2.multiSelect = false;
  5291. // $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>";
  5292. $scope.modelcons = {};
  5293. $scope.modelass = {};
  5294. $scope.myData2all = [];
  5295. $scope.myData1all = [];
  5296. $scope.memoryfilterDatagui = {
  5297. idx: 0,
  5298. sum: 10,
  5299. };
  5300. setInterval(function () {
  5301. if ($scope.model.assets) {
  5302. if (
  5303. $scope.model.assets != $scope.modelass &&
  5304. typeof $scope.model.assets == "string"
  5305. ) {
  5306. $scope.modelass = $scope.model.assets;
  5307. if (JSON.stringify($scope.model.assets) == "{}") {
  5308. $scope.model.assets = [];
  5309. } else {
  5310. $scope.model.assets = JSON.parse($scope.model.assets);
  5311. }
  5312. // $scope.myData1 = $scope.model.assets;
  5313. // for (var i = 0; i < $scope.myData1.length; i++) {
  5314. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5315. // }
  5316. $scope.myData1all = $scope.model.assets;
  5317. for (var i = 0; i < $scope.myData1all.length; i++) {
  5318. $scope.myData1all[i]["item"] =
  5319. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5320. }
  5321. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5322. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5323. }
  5324. }
  5325. if ($scope.model.consumables) {
  5326. if (
  5327. $scope.model.consumables != $scope.modelcons &&
  5328. typeof $scope.model.consumables == "string"
  5329. ) {
  5330. $scope.modelass = $scope.model.consumables;
  5331. if (JSON.stringify($scope.model.consumables) == "{}") {
  5332. $scope.model.consumables = [];
  5333. } else {
  5334. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5335. }
  5336. // $scope.myData2 = $scope.model.consumables;
  5337. // for (var i = 0; i < $scope.myData2.length; i++) {
  5338. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5339. // }
  5340. $scope.myData2all = $scope.model.consumables;
  5341. for (var i = 0; i < $scope.myData2all.length; i++) {
  5342. $scope.myData2all[i]["item"] =
  5343. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5344. }
  5345. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5346. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5347. // $scope.model.consumables = $scope.myData2all;
  5348. }
  5349. }
  5350. }, 100);
  5351. $scope.gridOptions2.columnDefs = [
  5352. {
  5353. name: "item",
  5354. displayName: "序号",
  5355. width: 120,
  5356. },
  5357. {
  5358. name: "name",
  5359. displayName: "耗材名称",
  5360. width: 180,
  5361. enableFiltering: false,
  5362. },
  5363. {
  5364. name: "model",
  5365. displayName: "品牌/型号",
  5366. width: 180,
  5367. enableFiltering: false,
  5368. },
  5369. {
  5370. name: "Specifications",
  5371. displayName: "规格",
  5372. width: 150,
  5373. enableFiltering: false,
  5374. },
  5375. {
  5376. name: "sum",
  5377. width: 150,
  5378. displayName: "数量",
  5379. enableFiltering: false,
  5380. },
  5381. {
  5382. name: "操作",
  5383. cellTemplate:
  5384. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5385. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5386. "</div></div>",
  5387. enableFiltering: false,
  5388. },
  5389. ];
  5390. // $scope.selectButtonClick
  5391. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5392. $scope.gridApi = gridApi;
  5393. gridApi.pagination.on.paginationChanged(
  5394. $scope,
  5395. function (newPage, pageSize) {
  5396. // var filtersData = $scope.memoryfilterDatagui;
  5397. // filtersData.idx = newPage - 1;
  5398. // filtersData.sum = pageSize;
  5399. $scope.memoryfilterDatagui.idx = newPage - 1;
  5400. $scope.memoryfilterDatagui.sum = pageSize;
  5401. $scope.myData2 = $scope.interceptMydata(
  5402. $scope.myData2all,
  5403. $scope.memoryfilterDatagui.idx,
  5404. 10
  5405. );
  5406. }
  5407. );
  5408. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5409. $scope.selected.items = data.entity;
  5410. //console.log(data);
  5411. });
  5412. gridApi.selection.on.rowSelectionChangedBatch(
  5413. $scope,
  5414. function (data) {
  5415. $scope.selected.items = data.entity;
  5416. //console.log(data);
  5417. }
  5418. );
  5419. gridApi.core.on.filterChanged($scope, function () {
  5420. var grid = this.grid;
  5421. var filtersData = {
  5422. idx: 0,
  5423. sum: 10,
  5424. };
  5425. angular.forEach(grid.columns, function (item) {
  5426. if (item.enableFiltering) {
  5427. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5428. if (
  5429. angular.isDefined(item.filters[0].term) &&
  5430. item.filters[0].term != ""
  5431. ) {
  5432. if (angular.isUndefined(filtersData["user"])) {
  5433. filtersData["user"] = {};
  5434. }
  5435. filtersData["user"][item.field] = item.filters[0].term;
  5436. }
  5437. }
  5438. });
  5439. $scope.memoryfilterData = filtersData;
  5440. $scope.loadData(filtersData);
  5441. });
  5442. };
  5443. $scope.changecai = function (item) {
  5444. event.preventDefault();
  5445. var modalInstance = $modal.open({
  5446. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5447. controller: function ($scope, $modalInstance) {
  5448. $scope.title = "修改耗材数量";
  5449. $scope.consumptive = angular.copy(item);
  5450. // $scope.consumptive = item;
  5451. $scope.maxsum = item.inventoryNum;
  5452. $scope.clearNoNum = function (obj, attr) {
  5453. //先把非数字的都替换掉,除了数字和.
  5454. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5455. //必须保证第一个为数字而不是.
  5456. obj[attr] = obj[attr].replace(/^\./g, "");
  5457. //保证只有出现一个.而没有多个.
  5458. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5459. //保证.只出现一次,而不能出现两次以上
  5460. obj[attr] = obj[attr]
  5461. .replace(".", "$#$")
  5462. .replace(/\./g, "")
  5463. .replace("$#$", ".");
  5464. //小于最大值
  5465. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5466. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5467. // obj[attr] = '';
  5468. // }
  5469. };
  5470. $scope.ok = function () {
  5471. $modalInstance.close($scope.consumptive);
  5472. };
  5473. $scope.cancel = function () {
  5474. $modalInstance.dismiss("cancel");
  5475. };
  5476. },
  5477. size: "sm",
  5478. });
  5479. modalInstance.result.then(function (selectedItem) {
  5480. angular.forEach($scope.myData2all, function (items, index) {
  5481. // if (items.id == selectedItem.id) {
  5482. if (
  5483. items.modelid == selectedItem.modelid &&
  5484. items.nameid == selectedItem.nameid &&
  5485. items.Specificationsid == selectedItem.Specificationsid
  5486. ) {
  5487. angular.extend($scope.myData2all[index], selectedItem);
  5488. }
  5489. });
  5490. // $scope.model.consumables = $scope.myData2;
  5491. // $scope.myData2 = $scope.model.consumables;
  5492. // $scope.myData2all.push(selectedItem);
  5493. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5494. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5495. // }
  5496. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5497. $scope.myData2 = $scope.interceptMydata(
  5498. $scope.myData2all,
  5499. $scope.memoryfilterDatagui.idx,
  5500. 10
  5501. );
  5502. $scope.model.consumables = $scope.myData2all;
  5503. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5504. $scope.model.consumables;
  5505. });
  5506. };
  5507. $scope.interceptMydata = function (mydate, idx, sum) {
  5508. return mydate.slice(idx * sum, (idx + 1) * sum);
  5509. };
  5510. $scope.haocaiadd = function () {
  5511. event.preventDefault();
  5512. var modalInstance = $modal.open({
  5513. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5514. controller: function (
  5515. $scope,
  5516. scope,
  5517. $modalInstance,
  5518. api_wechatfile,
  5519. SweetAlert
  5520. ) {
  5521. $scope.haocainame = [];
  5522. $scope.pinpai = [];
  5523. $scope.guige = [];
  5524. $scope.consumptive = {};
  5525. $scope.consumptiveall = {};
  5526. $scope.title = "添加耗材";
  5527. api_wechatfile
  5528. .getDictionaryForList({
  5529. key: "haocaifenlei",
  5530. })
  5531. .then(function (data) {
  5532. $scope.haocainame = data;
  5533. });
  5534. $scope.clearNoNum = function (obj, attr) {
  5535. //先把非数字的都替换掉,除了数字和.
  5536. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5537. //必须保证第一个为数字而不是.
  5538. obj[attr] = obj[attr].replace(/^\./g, "");
  5539. //保证只有出现一个.而没有多个.
  5540. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5541. //保证.只出现一次,而不能出现两次以上
  5542. obj[attr] = obj[attr]
  5543. .replace(".", "$#$")
  5544. .replace(/\./g, "")
  5545. .replace("$#$", ".");
  5546. //小于最大值
  5547. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5548. alert(
  5549. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5550. );
  5551. obj[attr] = "";
  5552. }
  5553. };
  5554. $scope.onChange = function (parent) {
  5555. $scope.consumptive.model = {};
  5556. $scope.consumptive.Specifications = {};
  5557. api_wechatfile
  5558. .getDictionaryForList({
  5559. key: "pinpai",
  5560. parent: parent.id,
  5561. })
  5562. .then(function (data) {
  5563. $scope.pinpai = data;
  5564. });
  5565. api_wechatfile
  5566. .getDictionaryForList({
  5567. key: "guige",
  5568. parent: parent.id,
  5569. })
  5570. .then(function (data) {
  5571. $scope.guige = data;
  5572. });
  5573. };
  5574. // $scope.onChangesum = function(item) {
  5575. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5576. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5577. // $scope.consumptiveall = data1;
  5578. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5579. // // if (data.list && data.list.length != 0) {
  5580. // // var myData = data.list;
  5581. // // $scope.consumptiveall = myData[0];
  5582. // // $scope.maxsum = myData[0].inventoryNum;
  5583. // // } else if (data.list && data.list.length == 0) {
  5584. // // SweetAlert.swal({
  5585. // // title: "库存数据存在问题!",
  5586. // // text: "请检查库存数据!",
  5587. // // type: "error"
  5588. // // });
  5589. // // }
  5590. // // });
  5591. // }
  5592. // }
  5593. $scope.addhaocai = function () {
  5594. $modalInstance.dismiss("cancel");
  5595. scope.haocaiopen($scope.consumptive);
  5596. };
  5597. $scope.ok = function (item) {
  5598. var submittrue = true;
  5599. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5600. var data = {
  5601. modelid: item.model.id,
  5602. nameid: item.name.id,
  5603. Specificationsid: item.Specifications.id,
  5604. name: item.name.name,
  5605. model: item.model.name,
  5606. Specifications: item.Specifications.name,
  5607. sum: item.sum,
  5608. };
  5609. if (
  5610. item.name &&
  5611. item.model &&
  5612. JSON.stringify(item.model) != "{}" &&
  5613. item.Specifications &&
  5614. JSON.stringify(item.Specifications) != "{}" &&
  5615. item.sum
  5616. ) {
  5617. // $modalInstance.close(data);
  5618. angular.forEach(scope.myData2all, function (itemsdata) {
  5619. // if (item.model.id == itemsdata.id) {
  5620. if (
  5621. item.model.id == itemsdata.modelid &&
  5622. item.name.id == itemsdata.nameid &&
  5623. item.Specifications.id == itemsdata.Specificationsid
  5624. ) {
  5625. submittrue = false;
  5626. }
  5627. });
  5628. if (submittrue) {
  5629. $modalInstance.close(data);
  5630. } else {
  5631. SweetAlert.swal({
  5632. title: "该耗材已有添加",
  5633. text: "请检查数据然后提交!",
  5634. type: "error",
  5635. });
  5636. }
  5637. } else {
  5638. SweetAlert.swal({
  5639. title: "数据填写不完整!",
  5640. text: "请检查数据然后提交!",
  5641. type: "error",
  5642. });
  5643. }
  5644. };
  5645. $scope.cancel = function () {
  5646. $modalInstance.dismiss("cancel");
  5647. };
  5648. },
  5649. size: "sm",
  5650. resolve: {
  5651. scope: function () {
  5652. return $scope;
  5653. },
  5654. },
  5655. });
  5656. modalInstance.result.then(function (selectedItem) {
  5657. // $scope.myData2.push(selectedItem);
  5658. // for (var i = 0; i < $scope.myData2.length; i++) {
  5659. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5660. // }
  5661. // $scope.model.consumables = $scope.myData2;
  5662. $scope.myData2all.push(selectedItem);
  5663. for (var i = 0; i < $scope.myData2all.length; i++) {
  5664. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5665. $scope.myData2all[i]["item"] = i + 1;
  5666. }
  5667. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5668. $scope.myData2 = $scope.interceptMydata(
  5669. $scope.myData2all,
  5670. $scope.memoryfilterDatagui.idx,
  5671. 10
  5672. );
  5673. $scope.model.consumables = $scope.myData2all;
  5674. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5675. $scope.model.consumables;
  5676. });
  5677. };
  5678. $scope.onDblClick = function (data, event) {
  5679. $scope.selectButtonClick(data, event);
  5680. };
  5681. $scope.memoryfilterData = {
  5682. idx: 0,
  5683. sum: 20,
  5684. user: {
  5685. roledata: {
  5686. rolecode: "roleset",
  5687. },
  5688. selectType: "1",
  5689. },
  5690. };
  5691. $scope.myData = {};
  5692. $scope.loadData = function (filterData) { };
  5693. // $scope.title = title;
  5694. $scope.loadData({
  5695. idx: 0,
  5696. sum: 20,
  5697. user: {
  5698. roledata: {
  5699. rolecode: "roleset",
  5700. },
  5701. selectType: "1",
  5702. },
  5703. });
  5704. $scope.selected = {
  5705. items: {},
  5706. };
  5707. },
  5708. ],
  5709. });
  5710. //tab 列表
  5711. formlyConfigProvider.setType({
  5712. name: "ui-cmdbtab",
  5713. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5714. wrapper: ["bootstrapHasError"],
  5715. defaultOptions: function (options, $scope) {
  5716. return {
  5717. templateOptions: {},
  5718. };
  5719. },
  5720. controller: [
  5721. "$scope",
  5722. "api_user_data",
  5723. "i18nService",
  5724. "$modal",
  5725. "api_cmdb",
  5726. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5727. $scope.memoryfilterDatashe = {
  5728. idx: 0,
  5729. sum: 10,
  5730. };
  5731. $scope.myDataoneall = [];
  5732. var setAllInactive = function () {
  5733. angular.forEach($scope.workspaces, function (workspace) {
  5734. workspace.active = false;
  5735. });
  5736. };
  5737. //添加
  5738. var addNewWorkspace = function (name, contentUrl) {
  5739. var id = $scope.workspaces.length + 1;
  5740. $scope.workspaces.push({
  5741. id: id,
  5742. name: name,
  5743. active: true,
  5744. contentUrl: "main/html/content.html",
  5745. });
  5746. };
  5747. //关闭
  5748. $scope.remove = function (closedata) {
  5749. event.preventDefault();
  5750. angular.forEach($scope.workspaces, function (item, index) {
  5751. if (closedata.id == item.id) {
  5752. if (closedata.id == 1) {
  5753. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5754. } else {
  5755. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5756. }
  5757. $scope.workspaces.splice(index, 1);
  5758. }
  5759. });
  5760. };
  5761. $scope.workspaces = [];
  5762. $scope.options.templateOptions.getpush = function (item) {
  5763. $scope.workspaces = [];
  5764. if (item.gu) {
  5765. $scope.workspaces.push({
  5766. id: 1,
  5767. name: "领用设备",
  5768. active: true,
  5769. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5770. });
  5771. }
  5772. if (item.hao) {
  5773. $scope.workspaces.push({
  5774. id: 2,
  5775. name: "领用耗材",
  5776. active: true,
  5777. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5778. });
  5779. }
  5780. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5781. };
  5782. $scope.addWorkspace = function (contentUrl, name) {
  5783. setAllInactive();
  5784. addNewWorkspace(name, contentUrl);
  5785. };
  5786. // $rootScope.addWorkspace = $scope.addWorkspace;
  5787. // $scope.remove = function(idNumber) {
  5788. // var index = 0; //记录当前元素下标
  5789. // angular.forEach($scope.workspaces, function(workspace) {
  5790. // if (workspace.id === idNumber.id) {
  5791. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5792. // }
  5793. // index++;
  5794. // });
  5795. // };
  5796. // setInterval(function() {
  5797. // if ($scope.model.assets) {
  5798. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5799. // $scope.modelass = $scope.model.assets;
  5800. // if (JSON.stringify($scope.model.assets) == "{}") {
  5801. // $scope.model.assets = []
  5802. // } else {
  5803. // $scope.model.assets = JSON.parse($scope.model.assets);
  5804. // }
  5805. // $scope.myDatalingbeiall = $scope.model.assets;
  5806. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5807. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5808. // }
  5809. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5810. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5811. // }
  5812. // }
  5813. // if ($scope.model.consumables) {
  5814. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5815. // $scope.modelass = $scope.model.consumables;
  5816. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5817. // $scope.model.consumables = [];
  5818. // } else {
  5819. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5820. // }
  5821. // $scope.myDatalingbeiall = $scope.model.consumables;
  5822. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5823. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5824. // }
  5825. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5826. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5827. // // $scope.model.consumables = $scope.myData2all;
  5828. // }
  5829. // }
  5830. // }, 100);
  5831. //grid1
  5832. $scope.langs = i18nService.getAllLangs();
  5833. $scope.lang = "zh-cn";
  5834. i18nService.setCurrentLang($scope.lang);
  5835. $scope.gridOptions1 = {};
  5836. $scope.gridOptions1.data = "myDatalingbei";
  5837. $scope.gridOptions1.enableColumnResizing = true;
  5838. $scope.gridOptions1.enableFiltering = false;
  5839. $scope.gridOptions1.enableGridMenu = false;
  5840. $scope.gridOptions1.showGridFooter = true;
  5841. $scope.gridOptions1.showColumnFooter = false;
  5842. $scope.gridOptions1.fastWatch = true;
  5843. $scope.gridOptions1.useExternalFiltering = true;
  5844. $scope.gridOptions1.useExternalPagination = true;
  5845. $scope.gridOptions1.paginationPageSizes = [10];
  5846. $scope.gridOptions1.paginationPageSize = 10;
  5847. $scope.gridOptions1.multiSelect = false;
  5848. // $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>";
  5849. $scope.gridOptions1.columnDefs = [
  5850. {
  5851. name: "item",
  5852. displayName: "序号",
  5853. width: 120,
  5854. },
  5855. {
  5856. name: "props.hw_cifilterClassic",
  5857. displayName: "设备类型",
  5858. width: 150,
  5859. enableFiltering: false,
  5860. },
  5861. {
  5862. name: "props.hw_mingcheng",
  5863. displayName: "设备名称",
  5864. width: 100,
  5865. enableFiltering: false,
  5866. },
  5867. {
  5868. name: "uuid",
  5869. displayName: "设备编号",
  5870. enableFiltering: false,
  5871. },
  5872. ];
  5873. $scope.myDatalingbeiall = [];
  5874. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5875. $scope.gridApi = gridApi;
  5876. gridApi.pagination.on.paginationChanged(
  5877. $scope,
  5878. function (newPage, pageSize) {
  5879. // var filtersData = $scope.memoryfilterData;
  5880. // filtersData.idx = newPage - 1;
  5881. // filtersData.sum = pageSize;
  5882. // $scope.loadData(filtersData);
  5883. $scope.memoryfilterDatashe.idx = newPage - 1;
  5884. $scope.memoryfilterDatashe.sum = pageSize;
  5885. $scope.myDatalingbei = $scope.interceptMydata(
  5886. $scope.myDatalingbeiall,
  5887. $scope.memoryfilterDatashe.idx,
  5888. 10
  5889. );
  5890. }
  5891. );
  5892. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5893. $scope.selected.items = data.entity;
  5894. //console.log(data);
  5895. });
  5896. gridApi.selection.on.rowSelectionChangedBatch(
  5897. $scope,
  5898. function (data) {
  5899. $scope.selected.items = data.entity;
  5900. //console.log(data);
  5901. }
  5902. );
  5903. gridApi.core.on.filterChanged($scope, function () {
  5904. var grid = this.grid;
  5905. var filtersData = {
  5906. idx: 0,
  5907. sum: 20,
  5908. user: {
  5909. roledata: {
  5910. rolecode: "roleset",
  5911. },
  5912. selectType: "1",
  5913. },
  5914. };
  5915. angular.forEach(grid.columns, function (item) {
  5916. if (item.enableFiltering) {
  5917. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5918. if (
  5919. angular.isDefined(item.filters[0].term) &&
  5920. item.filters[0].term != ""
  5921. ) {
  5922. if (angular.isUndefined(filtersData["user"])) {
  5923. filtersData["user"] = {};
  5924. }
  5925. filtersData["user"][item.field] = item.filters[0].term;
  5926. }
  5927. }
  5928. });
  5929. $scope.memoryfilterDatashe = filtersData;
  5930. // $scope.loadData(filtersData);
  5931. });
  5932. };
  5933. $scope.interceptMydata = function (mydate, idx, sum) {
  5934. return mydate.slice(idx * sum, (idx + 1) * sum);
  5935. };
  5936. $scope.removeshebei = function (item) {
  5937. event.preventDefault();
  5938. var modalInstance = $modal.open({
  5939. templateUrl: "assets/views/delete.html",
  5940. controller: function ($scope, $modalInstance, scope) {
  5941. $scope.title = "设备移除";
  5942. $scope.connect = "确定要移除此设备?";
  5943. $scope.consumptive = scope.selected.items;
  5944. $scope.ok = function () {
  5945. $modalInstance.close($scope.consumptive);
  5946. };
  5947. $scope.cancel = function () {
  5948. $modalInstance.dismiss("cancel");
  5949. };
  5950. },
  5951. size: "sm",
  5952. resolve: {
  5953. scope: function () {
  5954. return $scope;
  5955. },
  5956. },
  5957. });
  5958. modalInstance.result.then(function (selectedItem) {
  5959. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5960. if (items.id == selectedItem.id) {
  5961. $scope.myDatalingbeiall.splice(index, 1);
  5962. }
  5963. });
  5964. // $scope.myData3.push(selectedItem);
  5965. $scope.model.consumables = $scope.myDatalingbeiall;
  5966. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5967. $scope.myDatalingbeiall;
  5968. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5970. $scope.myDatalingbeiall[i]["item"] =
  5971. i +
  5972. 1 +
  5973. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5974. }
  5975. $scope.myDatalingbei = $scope.interceptMydata(
  5976. $scope.myDatalingbeiall,
  5977. 0,
  5978. 10
  5979. );
  5980. });
  5981. };
  5982. $scope.addshebei = function () {
  5983. event.preventDefault();
  5984. var modalInstance = $modal.open({
  5985. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5986. controller: function (
  5987. $scope,
  5988. i18nService,
  5989. $modalInstance,
  5990. items,
  5991. title,
  5992. Restangular,
  5993. APIService,
  5994. onDataCallback,
  5995. parentScope,
  5996. api_configure_data,
  5997. api_configure_form
  5998. ) {
  5999. $scope.langs = i18nService.getAllLangs();
  6000. $scope.lang = "zh-cn";
  6001. i18nService.setCurrentLang($scope.lang);
  6002. $scope.gridOptions = {};
  6003. $scope.gridOptions.data = "myDatatwo";
  6004. $scope.gridOptions.enableColumnResizing = true;
  6005. $scope.gridOptions.enableFiltering = false;
  6006. $scope.gridOptions.enableGridMenu = false;
  6007. $scope.gridOptions.showGridFooter = true;
  6008. $scope.gridOptions.showColumnFooter = false;
  6009. $scope.gridOptions.fastWatch = true;
  6010. $scope.gridOptions.useExternalFiltering = true;
  6011. $scope.gridOptions.useExternalPagination = true;
  6012. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6013. $scope.gridOptions.paginationPageSize = 10;
  6014. $scope.gridOptions.multiSelect = true;
  6015. $scope.gridOptions.rowIdentity = function (row) {
  6016. return row.id;
  6017. };
  6018. $scope.gridOptions.getRowIdentity = function (row) {
  6019. return row.id;
  6020. };
  6021. // $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>";
  6022. $scope.gridOptions.columnDefs = [
  6023. {
  6024. name: "item",
  6025. displayName: "序号",
  6026. width: 80,
  6027. enableFiltering: false,
  6028. },
  6029. {
  6030. name: "uuid",
  6031. displayName: "内部编号",
  6032. width: 175,
  6033. },
  6034. {
  6035. name: "props.hw_mingcheng",
  6036. displayName: "资产名称",
  6037. width: 120,
  6038. },
  6039. {
  6040. name: "props.hw_cifilterClassic",
  6041. displayName: "资产类型",
  6042. width: 80,
  6043. enableFiltering: false,
  6044. },
  6045. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6046. {
  6047. name: "props.hw_state",
  6048. displayName: "资产状态",
  6049. width: 150,
  6050. enableFiltering: false,
  6051. },
  6052. {
  6053. name: "props.hwnw_area",
  6054. displayName: "资产地点",
  6055. width: 130,
  6056. enableFiltering: false,
  6057. },
  6058. {
  6059. name: "createtime",
  6060. displayName: "申请时间",
  6061. enableFiltering: false,
  6062. },
  6063. ];
  6064. // $scope.selectButtonClick
  6065. var defaultFilterData = {
  6066. // "assignee":2,
  6067. // "sign":"basehwitndl",
  6068. // "applicationForm": { "hw_state": "在线" },
  6069. hw_state: "在库",
  6070. idx: 0,
  6071. sum: 10,
  6072. };
  6073. $scope.memoryfilterData = {
  6074. // "assignee":2,
  6075. // "sign":"basehwitndl",
  6076. // "applicationForm": { "hw_state": "在线" },
  6077. hw_state: "在库",
  6078. idx: 0,
  6079. sum: 10,
  6080. };
  6081. $scope.refreshData = function (style, filterData) {
  6082. if (angular.isUndefined(filterData)) {
  6083. filterData = defaultFilterData;
  6084. }
  6085. $scope.myDatatwo = [];
  6086. // $scope.gridOptions['sum']=filterData.sum;
  6087. api_cmdb.query(filterData).then(
  6088. function (data) {
  6089. // $scope.callsPending--;
  6090. var filterData = $scope.memoryfilterData;
  6091. var myDatatwo = Restangular.stripRestangular(data);
  6092. $scope.gridOptions["totalItems"] = data.total;
  6093. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6094. myDatatwo.data.node[i].createtime = moment(
  6095. myDatatwo.data.node[i].createtime
  6096. ).format("YYYY-MM-DD");
  6097. }
  6098. $scope.myDatatwo = myDatatwo.data.node;
  6099. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6100. $scope.myDatatwo[i]["item"] =
  6101. i + 1 + filterData.idx * filterData.sum;
  6102. }
  6103. },
  6104. function () { }
  6105. );
  6106. };
  6107. $scope.refreshData("expand-right", defaultFilterData);
  6108. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6109. $scope.gridApi = gridApi;
  6110. gridApi.pagination.on.paginationChanged(
  6111. $scope,
  6112. function (newPage, pageSize) {
  6113. var filtersData = $scope.memoryfilterData;
  6114. filtersData.idx = newPage - 1;
  6115. filtersData.sum = pageSize;
  6116. // $scope.loadData(filtersData);
  6117. $scope.refreshData("expand-right", filtersData);
  6118. //console.log(pageSize);
  6119. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6120. }
  6121. );
  6122. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6123. // $scope.selected.items.push(data.entity);
  6124. //console.log(data);
  6125. gridApi.selection.on.rowSelectionChanged(
  6126. $scope,
  6127. function (scope, ect) {
  6128. if (scope.isSelected) {
  6129. scope.grid.appScope.selected.items.push(scope.entity);
  6130. } else {
  6131. for (
  6132. var i = 0;
  6133. i <= scope.grid.appScope.selected.items.length;
  6134. i++
  6135. ) {
  6136. if (
  6137. scope.grid.appScope.selected.items[i].id ==
  6138. scope.entity.id
  6139. ) {
  6140. scope.grid.appScope.selected.items.splice(i, 1);
  6141. break;
  6142. }
  6143. }
  6144. }
  6145. $scope.mySelectedRows =
  6146. $scope.gridApi.selection.getSelectedRows();
  6147. }
  6148. );
  6149. // });
  6150. gridApi.selection.on.rowSelectionChangedBatch(
  6151. $scope,
  6152. function (rows) {
  6153. // $scope.selected.items = data.entity;
  6154. //console.log(data);
  6155. var selectitem = [];
  6156. selectitem = angular.copy($scope.selected.items);
  6157. for (var j = 0; j < rows.length; j++) {
  6158. if (rows[j].isSelected == true) {
  6159. selectitem.push(rows[j].entity);
  6160. } else {
  6161. delete selectitem[j];
  6162. // rows.splice(j, 1);
  6163. }
  6164. }
  6165. $scope.selected.items = [];
  6166. for (var i = 0; i < selectitem.length; i++) {
  6167. if (selectitem[i]) {
  6168. $scope.selected.items.push(selectitem[i]);
  6169. }
  6170. }
  6171. }
  6172. );
  6173. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6174. // // if (row.entity.age > 45) {
  6175. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6176. // // }
  6177. // };
  6178. gridApi.core.on.filterChanged($scope, function () {
  6179. var grid = this.grid;
  6180. var filtersData = {
  6181. idx: 0,
  6182. sum: 10,
  6183. user: {
  6184. roledata: {
  6185. rolecode: "roleset",
  6186. },
  6187. selectType: "1",
  6188. },
  6189. };
  6190. angular.forEach(grid.columns, function (item) {
  6191. if (item.enableFiltering) {
  6192. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6193. if (
  6194. angular.isDefined(item.filters[0].term) &&
  6195. item.filters[0].term != ""
  6196. ) {
  6197. if (angular.isUndefined(filtersData["user"])) {
  6198. filtersData["user"] = {};
  6199. }
  6200. filtersData["user"][item.field] = item.filters[0].term;
  6201. }
  6202. }
  6203. });
  6204. $scope.memoryfilterData = filtersData;
  6205. // $scope.loadData(filtersData);
  6206. });
  6207. };
  6208. $scope.onDblClick = function (data, event) {
  6209. // $scope.selected.items = data.entity;
  6210. $scope.selectButtonClick(data, event);
  6211. };
  6212. // $scope.loadData = function(filterData) {
  6213. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6214. // items.fetchItems(filterData, APIService).then(function(data) {
  6215. // var myDatatwo = Restangular.stripRestangular(data);
  6216. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6217. // $scope.myDatatwo = myDatatwo.list;
  6218. // });
  6219. // };
  6220. $scope.title = title;
  6221. //树形图
  6222. var apple_selected, tree, treedata_avm, treedata_geography;
  6223. $scope.my_tree_handler = function (branch) {
  6224. //var _ref;
  6225. var classify = ($scope.classify =
  6226. branch.prefix.toLowerCase() + branch.sign);
  6227. api_cmdb
  6228. .query({
  6229. sign: classify,
  6230. })
  6231. .then(function (data) {
  6232. var myDatalingbei = Restangular.stripRestangular(data);
  6233. // console.log(myData.data.node);
  6234. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6235. var ret = myDatalingbei.data;
  6236. redrawSvg(myDatalingbei);
  6237. }
  6238. });
  6239. };
  6240. $scope.my_data = [];
  6241. function convertListToTree(data, treeMap) {
  6242. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6243. var root = null; //Initially set our loop to null
  6244. var parentNode = null;
  6245. //loop over data
  6246. for (var i = 0; i < data.length; i++) {
  6247. var datum = data[i];
  6248. //each node will have children, so let's give it a "children" poperty
  6249. datum.children = [];
  6250. //add an entry for this node to the map so that any future children can
  6251. //lookup the parent
  6252. idToNodeMap[datum.id] = datum;
  6253. //Does this node have a parent?
  6254. if (
  6255. typeof datum.parent === "undefined" ||
  6256. datum.parent == null
  6257. ) {
  6258. //Doesn't look like it, so this node is the root of the tree
  6259. root = datum;
  6260. treeMap[datum.id] = root;
  6261. } else {
  6262. //This node has a parent, so let's look it up using the id
  6263. parentNode = idToNodeMap[datum.parent.id];
  6264. //We don't need this property, so let's delete it.
  6265. delete datum.parent;
  6266. //Let's add the current node as a child of the parent node.
  6267. parentNode.children.push(datum);
  6268. }
  6269. }
  6270. return root;
  6271. }
  6272. function convertParentToChildList(data) {
  6273. var treeMap = {};
  6274. var list = [];
  6275. convertListToTree(data, treeMap);
  6276. angular.forEach(treeMap, function (item) {
  6277. list.push(item);
  6278. });
  6279. return list;
  6280. }
  6281. $scope.my_tree = tree = {};
  6282. $scope.try_async_load = function () {
  6283. $scope.my_data = [];
  6284. $scope.select_treedata = [];
  6285. $scope.doing_async = true;
  6286. api_configure_data
  6287. .fetchDataList("ciclassify", {
  6288. idx: 0,
  6289. sum: 100,
  6290. })
  6291. .then(function (result) {
  6292. //console.log(result['list']);
  6293. $scope.select_treedata = $scope.my_data =
  6294. convertParentToChildList(result["list"]);
  6295. $scope.doing_async = false;
  6296. // tree.expand_all();
  6297. //console.log(treelist);
  6298. });
  6299. };
  6300. $scope.select_treedata = [];
  6301. $scope.propTypeOptions = [];
  6302. $scope.try_async_load();
  6303. $scope.onFilterremove = function (item) {
  6304. console.log(item);
  6305. };
  6306. $scope.searchdata = {};
  6307. $scope.clear = function () {
  6308. $scope.searchdata = {};
  6309. $scope.cifilter_classic = {};
  6310. $scope.try_async_load();
  6311. var fildata = {
  6312. idx: 0,
  6313. sum: 10,
  6314. hw_state: "在库",
  6315. };
  6316. $scope.memoryfilterData = fildata;
  6317. $scope.refreshData("expand-right", fildata);
  6318. };
  6319. $scope.cifilter_classic = {};
  6320. $scope.chiceIncident = function (item) {
  6321. var fildata = defaultFilterData;
  6322. // fildata.applicationForm = {};
  6323. // sign: basehwnwswt
  6324. if (item && item.id) {
  6325. var classify = item.prefix.toLowerCase() + item.sign;
  6326. fildata.sign = classify;
  6327. } else {
  6328. delete fildata.sign;
  6329. }
  6330. $scope.gridOptions.paginationCurrentPage = 1;
  6331. var transitiondata = angular.copy(item);
  6332. $scope.refreshData("expand-right", fildata);
  6333. };
  6334. $scope.applicadata = [];
  6335. $scope.onFilterCallback = function (item) {
  6336. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6337. api_configure_form
  6338. .renderTabForm(tempclassify)
  6339. .then(function (data) {
  6340. var myData = Restangular.stripRestangular(data);
  6341. $scope.applicadata = myData[0].form.fields;
  6342. });
  6343. // }
  6344. };
  6345. // $scope.loadData({
  6346. // idx: 0,
  6347. // sum: 10,
  6348. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6349. // });
  6350. $scope.selected = {
  6351. items: [],
  6352. };
  6353. $scope.ok = function () {
  6354. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6355. // onDataCallback($scope.selected.item, parentScope);
  6356. // }
  6357. $modalInstance.close($scope.selected.items);
  6358. };
  6359. $scope.cancel = function () {
  6360. $modalInstance.dismiss("cancel");
  6361. };
  6362. },
  6363. size: "lg",
  6364. resolve: {
  6365. items: function () {
  6366. return {
  6367. fetchItems: function (filterData, APIService) {
  6368. filterData = filterData || {};
  6369. if (
  6370. angular.isDefined(filterData.idx) &&
  6371. filterData.idx == null
  6372. ) {
  6373. filterData = {
  6374. idx: 0,
  6375. sum: 10,
  6376. user: {
  6377. roledata: {
  6378. rolecode: "roleset",
  6379. },
  6380. selectType: "1",
  6381. },
  6382. };
  6383. }
  6384. return $scope.options.templateOptions.fetchItems(
  6385. filterData,
  6386. APIService
  6387. );
  6388. },
  6389. };
  6390. },
  6391. title: function () {
  6392. return $scope.options.templateOptions.label;
  6393. },
  6394. Restangular: function () {
  6395. return $scope.options.templateOptions.Restangular;
  6396. },
  6397. APIService: function () {
  6398. return $scope.options.templateOptions.ApiService;
  6399. },
  6400. onDataCallback: function () {
  6401. return $scope.options.templateOptions.callback;
  6402. },
  6403. parentScope: function () {
  6404. return $scope.options.templateOptions.that;
  6405. },
  6406. },
  6407. });
  6408. modalInstance.result.then(
  6409. function (selectedItem) {
  6410. // console.log(selectedItem);
  6411. // options.value(selectedItem);
  6412. var filterData = $scope.memoryfilterDatashe;
  6413. $scope.myDatalingbeiall = selectedItem;
  6414. $scope.gridOptions1["totalItems"] =
  6415. $scope.myDatalingbeiall.length;
  6416. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6417. $scope.myDatalingbeiall[i]["item"] =
  6418. i + 1 + filterData.idx * filterData.sum;
  6419. }
  6420. $scope.myDatalingbei = $scope.interceptMydata(
  6421. $scope.myDatalingbeiall,
  6422. 0,
  6423. 10
  6424. );
  6425. $scope.model.assets = $scope.myDatalingbeiall;
  6426. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6427. $scope.myDatalingbeiall;
  6428. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6429. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6430. // }
  6431. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6432. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6433. // }
  6434. },
  6435. function () {
  6436. //console.log('Modal dismissed at: ' + new Date());
  6437. }
  6438. );
  6439. };
  6440. $scope.onDblClick = function (data, event) {
  6441. $scope.selectButtonClick(data, event);
  6442. };
  6443. // $scope.loadData = function(filterData) {};
  6444. // $scope.title = title;
  6445. // $scope.loadData({
  6446. // idx: 0,
  6447. // sum: 20,
  6448. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6449. // });
  6450. $scope.selected = {
  6451. items: [],
  6452. };
  6453. //grid2
  6454. $scope.langs = i18nService.getAllLangs();
  6455. $scope.lang = "zh-cn";
  6456. i18nService.setCurrentLang($scope.lang);
  6457. $scope.gridOptions2 = {};
  6458. $scope.gridOptions2.data = "myDataone";
  6459. $scope.gridOptions2.enableColumnResizing = true;
  6460. $scope.gridOptions2.enableFiltering = false;
  6461. $scope.gridOptions2.enableGridMenu = false;
  6462. $scope.gridOptions2.showGridFooter = true;
  6463. $scope.gridOptions2.showColumnFooter = false;
  6464. $scope.gridOptions2.fastWatch = true;
  6465. $scope.gridOptions2.useExternalFiltering = true;
  6466. $scope.gridOptions2.useExternalPagination = true;
  6467. $scope.gridOptions2.paginationPageSizes = [10];
  6468. $scope.gridOptions2.paginationPageSize = 10;
  6469. $scope.gridOptions2.multiSelect = false;
  6470. // $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>";
  6471. $scope.gridOptions2.columnDefs = [
  6472. {
  6473. name: "item",
  6474. displayName: "序号",
  6475. width: 120,
  6476. },
  6477. {
  6478. name: "name",
  6479. displayName: "耗材名称",
  6480. width: 150,
  6481. enableFiltering: false,
  6482. },
  6483. {
  6484. name: "model",
  6485. displayName: "品牌/型号",
  6486. width: 100,
  6487. enableFiltering: false,
  6488. },
  6489. {
  6490. name: "Specifications",
  6491. displayName: "规格",
  6492. width: 150,
  6493. enableFiltering: false,
  6494. },
  6495. {
  6496. name: "sum",
  6497. displayName: "领用数量",
  6498. enableFiltering: false,
  6499. },
  6500. ];
  6501. // $scope.selectButtonClick
  6502. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6503. $scope.gridApi = gridApi;
  6504. gridApi.pagination.on.paginationChanged(
  6505. $scope,
  6506. function (newPage, pageSize) {
  6507. // var filtersData = $scope.memoryfilterData;
  6508. // filtersData.idx = newPage - 1;
  6509. // filtersData.sum = pageSize;
  6510. // $scope.loadData(filtersData);
  6511. $scope.memoryfilterDatahao.idx = newPage - 1;
  6512. $scope.memoryfilterDatahao.sum = pageSize;
  6513. $scope.myDataone = $scope.interceptMydata(
  6514. $scope.myDataoneall,
  6515. $scope.memoryfilterDatahao.idx,
  6516. 10
  6517. );
  6518. }
  6519. );
  6520. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6521. $scope.selected.items.push(data.entity);
  6522. //console.log(data);
  6523. });
  6524. gridApi.selection.on.rowSelectionChangedBatch(
  6525. $scope,
  6526. function (data) {
  6527. $scope.selected.items.push(data.entity);
  6528. //console.log(data);
  6529. }
  6530. );
  6531. gridApi.core.on.filterChanged($scope, function () {
  6532. var grid = this.grid;
  6533. var filtersData = {
  6534. idx: 0,
  6535. sum: 10,
  6536. user: {
  6537. roledata: {
  6538. rolecode: "roleset",
  6539. },
  6540. selectType: "1",
  6541. },
  6542. };
  6543. angular.forEach(grid.columns, function (item) {
  6544. if (item.enableFiltering) {
  6545. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6546. if (
  6547. angular.isDefined(item.filters[0].term) &&
  6548. item.filters[0].term != ""
  6549. ) {
  6550. if (angular.isUndefined(filtersData["user"])) {
  6551. filtersData["user"] = {};
  6552. }
  6553. filtersData["user"][item.field] = item.filters[0].term;
  6554. }
  6555. }
  6556. });
  6557. $scope.memoryfilterDatahao = filtersData;
  6558. $scope.loadData(filtersData);
  6559. });
  6560. };
  6561. $scope.removehaocai = function (item) {
  6562. event.preventDefault();
  6563. // var modalInstance = $modal.open({
  6564. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6565. // controller: function($scope, $modalInstance) {
  6566. // $scope.title = "修改耗材数量";
  6567. // $scope.consumptive = item;
  6568. // $scope.ok = function() {
  6569. // $modalInstance.close($scope.consumptive);
  6570. // };
  6571. // $scope.cancel = function() {
  6572. // $modalInstance.dismiss('cancel');
  6573. // };
  6574. // },
  6575. // size: 'sm'
  6576. // });
  6577. var modalInstance = $modal.open({
  6578. templateUrl: "assets/views/delete.html",
  6579. controller: function ($scope, $modalInstance, scope) {
  6580. $scope.title = "耗材移除";
  6581. $scope.connect = "确定要移除此设备?";
  6582. $scope.consumptive = scope.selected.items[0];
  6583. $scope.ok = function () {
  6584. $modalInstance.close($scope.consumptive);
  6585. };
  6586. $scope.cancel = function () {
  6587. $modalInstance.dismiss("cancel");
  6588. };
  6589. },
  6590. size: "sm",
  6591. resolve: {
  6592. scope: function () {
  6593. return $scope;
  6594. },
  6595. },
  6596. });
  6597. modalInstance.result.then(function (selectedItem) {
  6598. // angular.forEach($scope.myData3, function(items, index) {
  6599. // if (items.id == selectedItem.id) {
  6600. // $scope.myData3[index] = selectedItem;
  6601. // }
  6602. // })
  6603. // $scope.model.applicationForm.consumables = $scope.myData3;
  6604. angular.forEach($scope.myDataoneall, function (items, index) {
  6605. if (items.id == selectedItem.id) {
  6606. $scope.myDataoneall.splice(index, 1);
  6607. }
  6608. });
  6609. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6610. $scope.myDataoneall[i]["item"] =
  6611. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6612. }
  6613. $scope.myDataone = $scope.interceptMydata(
  6614. $scope.myDataoneall,
  6615. 0,
  6616. 10
  6617. );
  6618. $scope.model.consumables = $scope.myDataoneall;
  6619. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6620. $scope.myDataoneall;
  6621. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6622. $scope.selected = {
  6623. items: [],
  6624. };
  6625. });
  6626. };
  6627. $scope.haocaiadd = function () {
  6628. event.preventDefault();
  6629. var modalInstance = $modal.open({
  6630. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6631. controller: function (
  6632. $scope,
  6633. scope,
  6634. $modalInstance,
  6635. api_wechatfile,
  6636. SweetAlert,
  6637. api_cmdb3
  6638. ) {
  6639. $scope.haocainame = [];
  6640. $scope.pinpai = [];
  6641. $scope.guige = [];
  6642. $scope.consumptive = {};
  6643. $scope.consumpall = {};
  6644. $scope.title = "添加耗材";
  6645. api_wechatfile
  6646. .getDictionaryForList({
  6647. key: "haocaifenlei",
  6648. })
  6649. .then(function (data) {
  6650. $scope.haocainame = data;
  6651. });
  6652. $scope.clearNoNum = function (obj, attr) {
  6653. //先把非数字的都替换掉,除了数字和.
  6654. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6655. //必须保证第一个为数字而不是.
  6656. obj[attr] = obj[attr].replace(/^\./g, "");
  6657. //保证只有出现一个.而没有多个.
  6658. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6659. //保证.只出现一次,而不能出现两次以上
  6660. obj[attr] = obj[attr]
  6661. .replace(".", "$#$")
  6662. .replace(/\./g, "")
  6663. .replace("$#$", ".");
  6664. //小于最大值
  6665. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6666. alert(
  6667. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6668. );
  6669. obj[attr] = "";
  6670. }
  6671. };
  6672. $scope.onChange = function (parent) {
  6673. $scope.consumptive.model = {};
  6674. $scope.consumptive.Specifications = {};
  6675. api_wechatfile
  6676. .getDictionaryForList({
  6677. key: "pinpai",
  6678. parent: parent.id,
  6679. })
  6680. .then(function (data) {
  6681. $scope.pinpai = data;
  6682. });
  6683. api_wechatfile
  6684. .getDictionaryForList({
  6685. key: "guige",
  6686. parent: parent.id,
  6687. })
  6688. .then(function (data) {
  6689. $scope.guige = data;
  6690. });
  6691. };
  6692. $scope.onChangesum = function (item) {
  6693. if (item.name && item.model.id && item.Specifications.id) {
  6694. $scope.consumptive.sum = "";
  6695. var data1 = {
  6696. idx: 0,
  6697. sum: 10,
  6698. consumable: {
  6699. name: item.name.name,
  6700. brandModel: item.model.name,
  6701. specification: item.Specifications.name,
  6702. },
  6703. };
  6704. api_cmdb3
  6705. .fetchDataList("consumable", data1)
  6706. .then(function (data) {
  6707. if (data.status == 200 && data.list.length > 0) {
  6708. var myData = data.list;
  6709. $scope.consumpall = myData[0];
  6710. $scope.maxsum = myData[0].inventoryNum;
  6711. } else {
  6712. SweetAlert.swal({
  6713. title: "不存在该耗材",
  6714. text: "请检查库存后重新填写!",
  6715. type: "error",
  6716. });
  6717. }
  6718. });
  6719. }
  6720. };
  6721. $scope.addhaocai = function () {
  6722. $modalInstance.dismiss("cancel");
  6723. scope.haocaiopen($scope.consumptive);
  6724. };
  6725. $scope.ok = function (item) {
  6726. var items = {};
  6727. // if (item.name && item.model && item.Specifications && item.sum) {
  6728. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6729. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6730. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6731. // $scope.consumpall.sum = item.sum;
  6732. // delete $scope.consumpall.brandModel;
  6733. // delete $scope.consumpall.specification;
  6734. // $modalInstance.close($scope.consumpall);
  6735. // } else {
  6736. // SweetAlert.swal({
  6737. // title: "数据填写不完整!",
  6738. // text: "请检查数据然后提交!",
  6739. // type: "error"
  6740. // });
  6741. // }
  6742. var isold = false;
  6743. if (
  6744. item.name &&
  6745. item.model &&
  6746. JSON.stringify(item.model) != "{}" &&
  6747. item.Specifications &&
  6748. JSON.stringify(item.Specifications) != "{}" &&
  6749. item.sum
  6750. ) {
  6751. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6752. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6753. isold = true;
  6754. }
  6755. }
  6756. if (isold) {
  6757. SweetAlert.swal({
  6758. title: "该耗材已添加!",
  6759. text: "请不要重复添加耗材!",
  6760. type: "error",
  6761. });
  6762. } else {
  6763. $scope.consumpall.model = $scope.consumpall.brandModel;
  6764. $scope.consumpall.Specifications =
  6765. $scope.consumpall.specification;
  6766. $scope.consumpall.sum = item.sum;
  6767. delete $scope.consumpall.brandModel;
  6768. delete $scope.consumpall.specification;
  6769. $modalInstance.close($scope.consumpall);
  6770. }
  6771. } else {
  6772. SweetAlert.swal({
  6773. title: "数据填写不完整!",
  6774. text: "请检查数据然后提交!",
  6775. type: "error",
  6776. });
  6777. }
  6778. // $modalInstance.close(item);
  6779. };
  6780. $scope.cancel = function () {
  6781. $modalInstance.dismiss("cancel");
  6782. };
  6783. },
  6784. size: "sm",
  6785. resolve: {
  6786. scope: function () {
  6787. return $scope;
  6788. },
  6789. },
  6790. });
  6791. modalInstance.result.then(function (selectedItem) {
  6792. $scope.myDataoneall.push(selectedItem);
  6793. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6794. $scope.myDataoneall[i]["item"] =
  6795. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6796. }
  6797. // $scope.model.consumables = $scope.myDataone;
  6798. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6799. $scope.myDataone = $scope.interceptMydata(
  6800. $scope.myDataoneall,
  6801. 0,
  6802. 10
  6803. );
  6804. $scope.model.consumables = $scope.myDataoneall;
  6805. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6806. $scope.myDataoneall;
  6807. });
  6808. };
  6809. $scope.onDblClick = function (data, event) {
  6810. $scope.selectButtonClick(data, event);
  6811. };
  6812. $scope.memoryfilterDatahao = {
  6813. idx: 0,
  6814. sum: 10,
  6815. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6816. };
  6817. $scope.myDataone = [];
  6818. $scope.loadData = function (filterData) { };
  6819. // $scope.title = title;
  6820. $scope.ldloading = {};
  6821. $scope.selected = {
  6822. items: [],
  6823. };
  6824. if ($scope.$parent.$parent.$parent.model.gettype) {
  6825. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6826. if ($scope.model.assets) {
  6827. if (JSON.stringify($scope.model.assets) == "{}") {
  6828. $scope.model.assets = [];
  6829. } else {
  6830. $scope.model.assets = JSON.parse($scope.model.assets);
  6831. }
  6832. $scope.myDatalingbeiall = $scope.model.assets;
  6833. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6834. $scope.myDatalingbeiall[i]["item"] =
  6835. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6836. }
  6837. $scope.gridOptions1["totalItems"] =
  6838. $scope.myDatalingbeiall.length;
  6839. $scope.myDatalingbei = $scope.interceptMydata(
  6840. $scope.myDatalingbeiall,
  6841. 0,
  6842. 10
  6843. );
  6844. }
  6845. if ($scope.model.consumables) {
  6846. if (JSON.stringify($scope.model.consumables) == "{}") {
  6847. $scope.model.consumables = [];
  6848. } else {
  6849. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6850. }
  6851. $scope.myDataoneall = $scope.model.consumables;
  6852. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6853. $scope.myDataoneall[i]["item"] =
  6854. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6855. }
  6856. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6857. $scope.myDataone = $scope.interceptMydata(
  6858. $scope.myDataoneall,
  6859. 0,
  6860. 10
  6861. );
  6862. }
  6863. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6864. $scope.options.templateOptions.getpush({
  6865. hao: true,
  6866. gu: true,
  6867. });
  6868. } else {
  6869. $scope.options.templateOptions.getpush({
  6870. hao: true,
  6871. });
  6872. }
  6873. } else {
  6874. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6875. $scope.options.templateOptions.getpush({
  6876. gu: true,
  6877. });
  6878. }
  6879. }
  6880. }
  6881. },
  6882. ],
  6883. });
  6884. formlyConfigProvider.setType({
  6885. name: "ui-panel",
  6886. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6887. });
  6888. formlyConfigProvider.setType({
  6889. name: "ui-currentuser",
  6890. extends: "input",
  6891. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6892. defaultOptions: function (options) {
  6893. return {
  6894. templateOptions: {
  6895. // link: function() {}
  6896. },
  6897. };
  6898. },
  6899. controller: [
  6900. "$scope",
  6901. function ($scope) {
  6902. if ($scope.options.templateOptions.user) {
  6903. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6904. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6905. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6906. // }
  6907. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6908. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6909. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6910. }
  6911. $scope.model[$scope.options.key] =
  6912. $scope.options.templateOptions.user;
  6913. $scope.options.initialValue = $scope.model[$scope.options.key];
  6914. }
  6915. },
  6916. ],
  6917. });
  6918. //仪表盘
  6919. //待处理变更列表
  6920. formlyConfigProvider.setType({
  6921. name: "ui-ngpchangetable",
  6922. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6923. defaultOptions: function (options) {
  6924. return {
  6925. templateOptions: {
  6926. // relationAction: function() {
  6927. // options.hideExpression = true
  6928. // }
  6929. },
  6930. };
  6931. },
  6932. controller: [
  6933. "$scope",
  6934. "$modal",
  6935. "$timeout",
  6936. "SweetAlert",
  6937. "api_bpm_domain",
  6938. "$rootScope",
  6939. "ngTableParams",
  6940. "$filter",
  6941. "$state",
  6942. function (
  6943. $scope,
  6944. $modal,
  6945. $timeout,
  6946. SweetAlert,
  6947. api_bpm_domain,
  6948. $rootScope,
  6949. ngTableParams,
  6950. $filter,
  6951. $state
  6952. ) {
  6953. // var filterData = {
  6954. // "assignee": $rootScope.user.id,
  6955. // "searchtype": "all",
  6956. // "idx": "0",
  6957. // "sum": "10"
  6958. // };
  6959. var filterData = {
  6960. idx: "0",
  6961. sum: "10",
  6962. assignee: 2,
  6963. searchType: "todo",
  6964. };
  6965. $scope.incidentprocess = function (item) {
  6966. $state.go("app.wt_change.add", {
  6967. taskId: item.taskId,
  6968. processInstanceId: item.processInstanceId,
  6969. });
  6970. };
  6971. $scope.more = function () {
  6972. $state.go("app.wt_change.list", {});
  6973. };
  6974. api_bpm_domain
  6975. .fetchtask("bpm_change", filterData)
  6976. .then(function (data) {
  6977. if (data.data) {
  6978. $scope.myData = data.data;
  6979. } else {
  6980. SweetAlert.swal({
  6981. title: "操作异常!",
  6982. text: "系统异常,请稍后重试,或者联系管理员!",
  6983. type: "error",
  6984. });
  6985. }
  6986. });
  6987. $scope.removes = function () {
  6988. var modalInstance = $modal.open({
  6989. templateUrl: "assets/views/delete.html",
  6990. controller: function ($scope, $modalInstance) {
  6991. $scope.ok = function () {
  6992. $modalInstance.close();
  6993. };
  6994. $scope.cancel = function () {
  6995. $modalInstance.dismiss("cancel");
  6996. };
  6997. },
  6998. size: "sm",
  6999. });
  7000. modalInstance.result.then(function () {
  7001. console.log($scope.$parent.$parent.$parent.$parent);
  7002. for (
  7003. var i = 0;
  7004. i <
  7005. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7006. i++
  7007. ) {
  7008. if (
  7009. $scope.fields.type ==
  7010. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7011. .type
  7012. ) {
  7013. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7014. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7015. i,
  7016. 1
  7017. );
  7018. break;
  7019. }
  7020. }
  7021. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7022. if (vmForm) {
  7023. //console.log("vmForm>>>");//console.log(vmForm);
  7024. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7025. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7026. }
  7027. });
  7028. };
  7029. },
  7030. ],
  7031. });
  7032. //待处理问题列表
  7033. formlyConfigProvider.setType({
  7034. name: "ui-ngproblemtable",
  7035. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7036. defaultOptions: function (options) {
  7037. return {
  7038. templateOptions: {
  7039. // relationAction: function() {
  7040. // options.hideExpression = true
  7041. // }
  7042. },
  7043. };
  7044. },
  7045. controller: [
  7046. "$scope",
  7047. "$modal",
  7048. "$timeout",
  7049. "SweetAlert",
  7050. "api_bpm_data",
  7051. "$rootScope",
  7052. "ngTableParams",
  7053. "$filter",
  7054. "$state",
  7055. function (
  7056. $scope,
  7057. $modal,
  7058. $timeout,
  7059. SweetAlert,
  7060. api_bpm_data,
  7061. $rootScope,
  7062. ngTableParams,
  7063. $filter,
  7064. $state
  7065. ) {
  7066. var filterData = {
  7067. assignee: $rootScope.user.id,
  7068. candidateGroups: $rootScope.user.group[0].id,
  7069. searchtype: "todo",
  7070. idx: 0,
  7071. sum: 10,
  7072. };
  7073. $scope.incidentprocess = function (item) {
  7074. $state.go("app.wt_change.add", {
  7075. taskId: item.taskId,
  7076. processInstanceId: item.processInstanceId,
  7077. });
  7078. };
  7079. $scope.more = function () {
  7080. $state.go("app.wt_change.list", {});
  7081. };
  7082. api_bpm_data
  7083. .fetchDataList("changeclassify", filterData)
  7084. .then(function (data) {
  7085. if (data.data) {
  7086. $scope.myData = data.data;
  7087. } else {
  7088. SweetAlert.swal({
  7089. title: "操作异常!",
  7090. text: "系统异常,请稍后重试,或者联系管理员!",
  7091. type: "error",
  7092. });
  7093. }
  7094. });
  7095. $scope.removes = function () {
  7096. var modalInstance = $modal.open({
  7097. templateUrl: "assets/views/delete.html",
  7098. controller: function ($scope, $modalInstance) {
  7099. $scope.ok = function () {
  7100. $modalInstance.close();
  7101. };
  7102. $scope.cancel = function () {
  7103. $modalInstance.dismiss("cancel");
  7104. };
  7105. },
  7106. size: "sm",
  7107. });
  7108. modalInstance.result.then(function () {
  7109. console.log($scope.$parent.$parent.$parent.$parent);
  7110. for (
  7111. var i = 0;
  7112. i <
  7113. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7114. i++
  7115. ) {
  7116. if (
  7117. $scope.fields.type ==
  7118. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7119. .type
  7120. ) {
  7121. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7122. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7123. i,
  7124. 1
  7125. );
  7126. break;
  7127. }
  7128. }
  7129. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7130. if (vmForm) {
  7131. //console.log("vmForm>>>");//console.log(vmForm);
  7132. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7133. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7134. }
  7135. });
  7136. };
  7137. },
  7138. ],
  7139. });
  7140. //待处理事件列表
  7141. formlyConfigProvider.setType({
  7142. name: "ui-ngtable",
  7143. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7144. defaultOptions: function (options) {
  7145. return {
  7146. templateOptions: {
  7147. // relationAction: function() {
  7148. // options.hideExpression = true
  7149. // }
  7150. },
  7151. };
  7152. },
  7153. controller: [
  7154. "$scope",
  7155. "$modal",
  7156. "$timeout",
  7157. "SweetAlert",
  7158. "api_bpm_domain",
  7159. "$rootScope",
  7160. "ngTableParams",
  7161. "$filter",
  7162. "$state",
  7163. function (
  7164. $scope,
  7165. $modal,
  7166. $timeout,
  7167. SweetAlert,
  7168. api_bpm_domain,
  7169. $rootScope,
  7170. ngTableParams,
  7171. $filter,
  7172. $state
  7173. ) {
  7174. var filterData = {
  7175. assignee: $rootScope.user.id,
  7176. candidateGroups: $rootScope.user.group[0].id,
  7177. searchtype: "done",
  7178. idx: 0,
  7179. sum: 10,
  7180. };
  7181. $scope.incidentprocess = function (item) {
  7182. $state.go("app.incident.editor", {
  7183. taskId: item.taskId,
  7184. processInstanceId: item.processInstanceId,
  7185. });
  7186. };
  7187. $scope.more = function () {
  7188. $state.go("app.incident.list", {});
  7189. };
  7190. api_bpm_domain
  7191. .fetchtask("bpm_incident", filterData)
  7192. .then(function (data) {
  7193. if (data.data) {
  7194. $scope.myData = data.data;
  7195. } else {
  7196. SweetAlert.swal({
  7197. title: "操作异常!",
  7198. text: "系统异常,请稍后重试,或者联系管理员!",
  7199. type: "error",
  7200. });
  7201. }
  7202. });
  7203. $scope.removes = function () {
  7204. var modalInstance = $modal.open({
  7205. templateUrl: "assets/views/delete.html",
  7206. controller: function ($scope, $modalInstance) {
  7207. $scope.ok = function () {
  7208. $modalInstance.close();
  7209. };
  7210. $scope.cancel = function () {
  7211. $modalInstance.dismiss("cancel");
  7212. };
  7213. },
  7214. size: "sm",
  7215. });
  7216. modalInstance.result.then(function () {
  7217. console.log($scope.$parent.$parent.$parent.$parent);
  7218. for (
  7219. var i = 0;
  7220. i <
  7221. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7222. i++
  7223. ) {
  7224. if (
  7225. $scope.fields.type ==
  7226. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7227. .type
  7228. ) {
  7229. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7230. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7231. i,
  7232. 1
  7233. );
  7234. break;
  7235. }
  7236. }
  7237. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7238. if (vmForm) {
  7239. //console.log("vmForm>>>");//console.log(vmForm);
  7240. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7241. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7242. }
  7243. });
  7244. };
  7245. },
  7246. ],
  7247. });
  7248. //知识库列表
  7249. formlyConfigProvider.setType({
  7250. name: "ui-knowledge",
  7251. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7252. defaultOptions: function (options) {
  7253. return {
  7254. templateOptions: {
  7255. // relationAction: function() {
  7256. // options.hideExpression = true
  7257. // }
  7258. },
  7259. };
  7260. },
  7261. controller: [
  7262. "$scope",
  7263. "$modal",
  7264. "$timeout",
  7265. "api_solution",
  7266. "$rootScope",
  7267. "ngTableParams",
  7268. "$filter",
  7269. "$state",
  7270. function (
  7271. $scope,
  7272. $modal,
  7273. $timeout,
  7274. api_solution,
  7275. $rootScope,
  7276. ngTableParams,
  7277. $filter,
  7278. $state
  7279. ) {
  7280. var filterData = {
  7281. key: "null",
  7282. pageIndex: 0,
  7283. pageSum: 6,
  7284. status: 0,
  7285. userId: $rootScope.user.id,
  7286. };
  7287. $scope.model.removereport = false;
  7288. $scope.removes = function () {
  7289. $scope.model.removereport = true;
  7290. };
  7291. $scope.more = function () {
  7292. $state.go("app.knowledge.manager", {});
  7293. };
  7294. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7295. if (data.status == 200) {
  7296. $scope.myData = data.list;
  7297. }
  7298. });
  7299. $scope.removes = function () {
  7300. var modalInstance = $modal.open({
  7301. templateUrl: "assets/views/delete.html",
  7302. controller: function ($scope, $modalInstance) {
  7303. $scope.ok = function () {
  7304. $modalInstance.close();
  7305. };
  7306. $scope.cancel = function () {
  7307. $modalInstance.dismiss("cancel");
  7308. };
  7309. },
  7310. size: "sm",
  7311. });
  7312. modalInstance.result.then(function () {
  7313. for (
  7314. var i = 0;
  7315. i <
  7316. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7317. i++
  7318. ) {
  7319. if (
  7320. $scope.fields.type ==
  7321. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7322. .type
  7323. ) {
  7324. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7325. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7326. i,
  7327. 1
  7328. );
  7329. break;
  7330. }
  7331. }
  7332. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7333. if (vmForm) {
  7334. //console.log("vmForm>>>");//console.log(vmForm);
  7335. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7336. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7337. }
  7338. });
  7339. };
  7340. },
  7341. ],
  7342. });
  7343. //公告列表
  7344. formlyConfigProvider.setType({
  7345. name: "ui-ngnotice",
  7346. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7347. defaultOptions: function (options) {
  7348. return {
  7349. templateOptions: {
  7350. // relationAction: function() {
  7351. // options.hideExpression = true
  7352. // }
  7353. },
  7354. };
  7355. },
  7356. controller: [
  7357. "$scope",
  7358. "$modal",
  7359. "$timeout",
  7360. "SweetAlert",
  7361. "api_user_data",
  7362. "$rootScope",
  7363. "ngTableParams",
  7364. "$filter",
  7365. "$state",
  7366. function (
  7367. $scope,
  7368. $modal,
  7369. $timeout,
  7370. SweetAlert,
  7371. api_user_data,
  7372. $rootScope,
  7373. ngTableParams,
  7374. $filter,
  7375. $state
  7376. ) {
  7377. var filterData = {
  7378. idx: 0,
  7379. sum: 10,
  7380. };
  7381. // $scope.$scope.model.className = "col-xs-12";
  7382. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7383. if (data) {
  7384. $scope.myData = data.data;
  7385. } else {
  7386. SweetAlert.swal({
  7387. title: "操作异常!",
  7388. text: "系统异常,请稍后重试,或者联系管理员!",
  7389. type: "error",
  7390. });
  7391. }
  7392. });
  7393. $scope.more = function () {
  7394. $state.go("app.system.notice.list", {});
  7395. };
  7396. $scope.removes = function () {
  7397. var modalInstance = $modal.open({
  7398. templateUrl: "assets/views/delete.html",
  7399. controller: function ($scope, $modalInstance) {
  7400. $scope.ok = function () {
  7401. $modalInstance.close();
  7402. };
  7403. $scope.cancel = function () {
  7404. $modalInstance.dismiss("cancel");
  7405. };
  7406. },
  7407. size: "sm",
  7408. });
  7409. modalInstance.result.then(function () {
  7410. for (
  7411. var i = 0;
  7412. i <
  7413. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7414. i++
  7415. ) {
  7416. if (
  7417. $scope.fields.type ==
  7418. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7419. .type
  7420. ) {
  7421. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7422. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7423. i,
  7424. 1
  7425. );
  7426. break;
  7427. }
  7428. }
  7429. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7430. if (vmForm) {
  7431. //console.log("vmForm>>>");//console.log(vmForm);
  7432. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7433. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7434. }
  7435. });
  7436. };
  7437. },
  7438. ],
  7439. });
  7440. //事件统计图
  7441. formlyConfigProvider.setType({
  7442. name: "ui-incidentreport",
  7443. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7444. defaultOptions: function (options) {
  7445. return {
  7446. templateOptions: {
  7447. // relationAction: function() {
  7448. // options.hideExpression = true
  7449. // }
  7450. },
  7451. };
  7452. },
  7453. controller: [
  7454. "$scope",
  7455. "$modal",
  7456. "moment",
  7457. "api_report",
  7458. "$cookieStore",
  7459. function ($scope, $modal, moment, api_report, $cookieStore) {
  7460. api_report.getLicenseKey().then(function (response) {
  7461. $cookieStore.put("Auth-Token", response.token);
  7462. $scope.try_async_load();
  7463. });
  7464. $scope.try_async_load = function () {
  7465. $scope.my_data = [];
  7466. api_report.list().then(function (response) {
  7467. var dataList = response;
  7468. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7469. $scope.repoRoot.name = "事件报表";
  7470. convertRepoObject($scope.repoRoot);
  7471. $scope.my_data.push($scope.repoRoot);
  7472. });
  7473. };
  7474. var workspace = {};
  7475. $scope.repoRoot = null;
  7476. function getRepoRoot(repo, path) {
  7477. angular.forEach(repo, function (value, key) {
  7478. if (value.path == path) {
  7479. $scope.repoRoot = value;
  7480. } else {
  7481. if (
  7482. $scope.repoRoot == null &&
  7483. angular.isDefined(value.repoObjects)
  7484. ) {
  7485. getRepoRoot(value.repoObjects, path);
  7486. } else {
  7487. }
  7488. }
  7489. });
  7490. }
  7491. function convertRepoObject(repo) {
  7492. if (angular.isArray(repo)) {
  7493. angular.forEach(repo, function (value, key) {
  7494. convertRepoObject(value);
  7495. });
  7496. } else {
  7497. if (angular.isDefined(repo.name)) {
  7498. if (repo.name.indexOf(".") >= 0) {
  7499. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7500. } else {
  7501. repo.label = repo.name;
  7502. }
  7503. //delete repo.name;
  7504. }
  7505. if (angular.isDefined(repo.repoObjects)) {
  7506. repo.children = [];
  7507. repo.children = repo.repoObjects;
  7508. delete repo.repoObjects;
  7509. convertRepoObject(repo.children);
  7510. }
  7511. }
  7512. }
  7513. function parseDateParameter(parameters) {
  7514. var result = undefined;
  7515. if (angular.isArray(parameters)) {
  7516. // angular.forEach(parmeters,function(param){
  7517. // param.
  7518. // })
  7519. } else {
  7520. result = {};
  7521. for (var k in parameters) {
  7522. if (k.indexOf("Date") > 0) {
  7523. if (angular.isString(parameters[k])) {
  7524. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7525. "YYYY-MM-DD"
  7526. );
  7527. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7528. }
  7529. }
  7530. }
  7531. }
  7532. return result;
  7533. }
  7534. function ConvertDateParameter(parameters) {
  7535. var result = undefined;
  7536. if (angular.isArray(parameters)) {
  7537. //
  7538. } else {
  7539. result = {};
  7540. for (var k in parameters) {
  7541. if (k.indexOf("Date") > 0) {
  7542. if (angular.isDate(parameters[k])) {
  7543. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7544. } else if (angular.isString(parameters[k])) {
  7545. result[k] = parameters[k];
  7546. }
  7547. }
  7548. }
  7549. }
  7550. return result;
  7551. }
  7552. var incidentchart =
  7553. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7554. var queryUUID;
  7555. function genUUID() {
  7556. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7557. .replace(/[xy]/g, function (c) {
  7558. var r = (Math.random() * 16) | 0,
  7559. v = c == "x" ? r : (r & 0x3) | 0x8;
  7560. return v.toString(16);
  7561. })
  7562. .toUpperCase();
  7563. return uuid;
  7564. }
  7565. queryUUID = genUUID();
  7566. var pathincidenttimekey = [];
  7567. var incidenttime = {
  7568. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7569. "YYYYMMDD"
  7570. ),
  7571. endtimes: moment(new Date()).format("YYYYMMDD"),
  7572. };
  7573. var thisday = moment(new Date().getTime() + 86400000).format(
  7574. "YYYYMMDD"
  7575. );
  7576. var thisdaymine = Date.parse(
  7577. thisday.substr(4, 2) +
  7578. "/" +
  7579. thisday.substr(6, 2) +
  7580. "/" +
  7581. thisday.substr(0, 4)
  7582. );
  7583. var averages = [
  7584. [thisdaymine - 86400000 * 14, 0],
  7585. [thisdaymine - 86400000 * 13, 0],
  7586. [thisdaymine - 86400000 * 12, 0],
  7587. [thisdaymine - 86400000 * 11, 0],
  7588. [thisdaymine - 86400000 * 10, 0],
  7589. [thisdaymine - 86400000 * 9, 0],
  7590. [thisdaymine - 86400000 * 8, 0],
  7591. [thisdaymine - 86400000 * 7, 0],
  7592. [thisdaymine - 86400000 * 6, 0],
  7593. [thisdaymine - 86400000 * 5, 0],
  7594. [thisdaymine - 86400000 * 4, 0],
  7595. [thisdaymine - 86400000 * 3, 0],
  7596. [thisdaymine - 86400000 * 2, 0],
  7597. [thisdaymine - 86400000 * 1, 0],
  7598. [thisdaymine, 0],
  7599. ];
  7600. var getreportdata = function (incidenttime, path) {
  7601. api_report.getMdx(path, queryUUID).then(function (response) {
  7602. var mdxquery = response;
  7603. workspace.query = mdxquery;
  7604. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7605. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7606. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7607. weekuser(mdxquery);
  7608. });
  7609. };
  7610. getreportdata(incidenttime, incidentchart);
  7611. var weekuser = function (mdxquery) {
  7612. var key = [];
  7613. api_report.execute(mdxquery).then(function (data) {
  7614. $scope.rheaders = [];
  7615. $scope.rRows = [];
  7616. var reportData = data;
  7617. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7618. $scope.shows = true;
  7619. $scope.empty = "数据为空!";
  7620. } else {
  7621. angular.forEach(reportData.cellset, function (item, i) {
  7622. angular.forEach(averages, function (index, j) {
  7623. // angular.forEach(averages, function(item, index) {
  7624. if (item.length > 1 && i > 0 && item[1].value != "") {
  7625. if (
  7626. index[0] ==
  7627. Date.parse(
  7628. item[0].value.substr(4, 2) +
  7629. "/" +
  7630. item[0].value.substr(6, 2) +
  7631. "/" +
  7632. item[0].value.substr(0, 4)
  7633. ) +
  7634. 86400000
  7635. ) {
  7636. index[1] = Number(item[1].value);
  7637. }
  7638. // 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)]);
  7639. }
  7640. // })
  7641. });
  7642. });
  7643. incidentchartfun(averages);
  7644. }
  7645. });
  7646. };
  7647. var incidentchartfun = function (incidentchartkey) {
  7648. // $scope.isMaskincident = false;
  7649. Highcharts.chart("incidentchart", {
  7650. title: {
  7651. text: "事件近15天趋势图",
  7652. },
  7653. xAxis: {
  7654. type: "datetime",
  7655. labels: {
  7656. align: "left",
  7657. step: 1,
  7658. },
  7659. },
  7660. yAxis: {
  7661. title: {
  7662. text: null,
  7663. },
  7664. },
  7665. tooltip: {
  7666. crosshairs: true,
  7667. shared: true,
  7668. valueSuffix: "条",
  7669. },
  7670. legend: {},
  7671. series: [
  7672. {
  7673. name: "生成事件",
  7674. data: incidentchartkey,
  7675. zIndex: 1,
  7676. marker: {
  7677. fillColor: "white",
  7678. lineWidth: 2,
  7679. lineColor: Highcharts.getOptions().colors[0],
  7680. },
  7681. },
  7682. ],
  7683. });
  7684. };
  7685. $scope.data = {
  7686. labels: [
  7687. "1号",
  7688. "2号",
  7689. "3号",
  7690. "4号",
  7691. "5号",
  7692. "6号",
  7693. "7号",
  7694. "8号",
  7695. "9号",
  7696. "10号",
  7697. "11号",
  7698. "12号",
  7699. "13号",
  7700. "14号",
  7701. "15号",
  7702. ],
  7703. datasets: [
  7704. {
  7705. label: "新增事件数量",
  7706. fillColor: "rgba(220,220,220,0.2)",
  7707. strokeColor: "rgba(220,220,220,1)",
  7708. pointColor: "rgba(220,220,220,1)",
  7709. pointStrokeColor: "#fff",
  7710. pointHighlightFill: "#fff",
  7711. pointHighlightStroke: "rgba(220,220,220,1)",
  7712. data: [
  7713. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7714. ],
  7715. },
  7716. {
  7717. label: "已解决事件数量",
  7718. fillColor: "rgba(151,187,205,0.2)",
  7719. strokeColor: "rgba(151,187,205,1)",
  7720. pointColor: "rgba(151,187,205,1)",
  7721. pointStrokeColor: "#fff",
  7722. pointHighlightFill: "#fff",
  7723. pointHighlightStroke: "rgba(151,187,205,1)",
  7724. data: [
  7725. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7726. ],
  7727. },
  7728. ],
  7729. };
  7730. $scope.removes = function () {
  7731. var modalInstance = $modal.open({
  7732. templateUrl: "assets/views/delete.html",
  7733. controller: function ($scope, $modalInstance) {
  7734. $scope.ok = function () {
  7735. $modalInstance.close();
  7736. };
  7737. $scope.cancel = function () {
  7738. $modalInstance.dismiss("cancel");
  7739. };
  7740. },
  7741. size: "sm",
  7742. });
  7743. modalInstance.result.then(function () {
  7744. for (
  7745. var i = 0;
  7746. i <
  7747. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7748. i++
  7749. ) {
  7750. if (
  7751. $scope.fields.type ==
  7752. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7753. .type
  7754. ) {
  7755. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7756. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7757. i,
  7758. 1
  7759. );
  7760. break;
  7761. }
  7762. }
  7763. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7764. if (vmForm) {
  7765. //console.log("vmForm>>>");//console.log(vmForm);
  7766. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7767. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7768. }
  7769. });
  7770. };
  7771. var addDatas = 0;
  7772. var resolve = 0;
  7773. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7774. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7775. }
  7776. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7777. resolve = resolve + $scope.data.datasets[1].data[i];
  7778. }
  7779. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7780. $scope.opt = {
  7781. maintainAspectRatio: false,
  7782. // Sets the chart to be responsive
  7783. responsive: true,
  7784. ///Boolean - Whether grid lines are shown across the chart
  7785. scaleShowGridLines: true,
  7786. //String - Colour of the grid lines
  7787. scaleGridLineColor: "rgba(0,0,0,.05)",
  7788. //Number - Width of the grid lines
  7789. scaleGridLineWidth: 1,
  7790. //Boolean - Whether the line is curved between points
  7791. bezierCurve: false,
  7792. //Number - Tension of the bezier curve between points
  7793. bezierCurveTension: 0.4,
  7794. //Boolean - Whether to show a dot for each point
  7795. pointDot: true,
  7796. //Number - Radius of each point dot in pixels
  7797. pointDotRadius: 4,
  7798. //Number - Pixel width of point dot stroke
  7799. pointDotStrokeWidth: 1,
  7800. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7801. pointHitDetectionRadius: 20,
  7802. //Boolean - Whether to show a stroke for datasets
  7803. datasetStroke: true,
  7804. //Number - Pixel width of dataset stroke
  7805. datasetStrokeWidth: 2,
  7806. //Boolean - Whether to fill the dataset with a colour
  7807. datasetFill: true,
  7808. // Function - on animation progress
  7809. onAnimationProgress: function () { },
  7810. // Function - on animation complete
  7811. onAnimationComplete: function () { },
  7812. //String - A legend template
  7813. legendTemplate:
  7814. '<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>',
  7815. };
  7816. angular.extend($scope.options, $scope.opt);
  7817. $scope.datamonth = {
  7818. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7819. datasets: [
  7820. {
  7821. label: "新增事件数量",
  7822. fillColor: "rgba(220,220,220,0.5)",
  7823. strokeColor: "rgba(220,220,220,0.8)",
  7824. highlightFill: "rgba(220,220,220,0.75)",
  7825. highlightStroke: "rgba(220,220,220,1)",
  7826. data: [65, 59, 80, 81, 56, 55],
  7827. },
  7828. {
  7829. label: "已解决事件数量",
  7830. fillColor: "rgba(151,187,205,0.5)",
  7831. strokeColor: "rgba(151,187,205,0.8)",
  7832. highlightFill: "rgba(151,187,205,0.75)",
  7833. highlightStroke: "rgba(151,187,205,1)",
  7834. data: [28, 48, 40, 19, 86, 27],
  7835. },
  7836. ],
  7837. };
  7838. // Chart.js Options
  7839. $scope.taption = {
  7840. maintainAspectRatio: false,
  7841. // Sets the chart to be responsive
  7842. responsive: true,
  7843. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7844. scaleBeginAtZero: true,
  7845. //Boolean - Whether grid lines are shown across the chart
  7846. scaleShowGridLines: true,
  7847. //String - Colour of the grid lines
  7848. scaleGridLineColor: "rgba(0,0,0,.05)",
  7849. //Number - Width of the grid lines
  7850. scaleGridLineWidth: 1,
  7851. //Boolean - If there is a stroke on each bar
  7852. barShowStroke: true,
  7853. //Number - Pixel width of the bar stroke
  7854. barStrokeWidth: 2,
  7855. //Number - Spacing between each of the X value sets
  7856. barValueSpacing: 5,
  7857. //Number - Spacing between data sets within X values
  7858. barDatasetSpacing: 1,
  7859. //String - A legend template
  7860. legendTemplate:
  7861. '<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>',
  7862. };
  7863. },
  7864. ],
  7865. });
  7866. //排版日历
  7867. formlyConfigProvider.setType({
  7868. name: "ui-dashcalendar",
  7869. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7870. defaultOptions: function (options) {
  7871. return {
  7872. templateOptions: {
  7873. // relationAction: function() {
  7874. // options.hideExpression = true
  7875. // }
  7876. },
  7877. };
  7878. },
  7879. controller: [
  7880. "$rootScope",
  7881. "$scope",
  7882. "$modal",
  7883. "$aside",
  7884. "calendarConfig",
  7885. "moment",
  7886. "SweetAlert",
  7887. "Restangular",
  7888. "api_bpm_schedule",
  7889. "api_user_data",
  7890. "$state",
  7891. function (
  7892. $rootScope,
  7893. $scope,
  7894. $modal,
  7895. $aside,
  7896. calendarConfig,
  7897. moment,
  7898. SweetAlert,
  7899. Restangular,
  7900. api_bpm_schedule,
  7901. api_user_data,
  7902. $state
  7903. ) {
  7904. var loginUser = $rootScope.user;
  7905. calendarConfig.dateFormatter = "moment";
  7906. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7907. calendarConfig.i18nStrings.timeLabel = "时间";
  7908. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7909. calendarConfig.allDateFormats = {
  7910. angular: {
  7911. date: {
  7912. hour: "ha",
  7913. day: "d MMM",
  7914. month: "MMMM",
  7915. weekDay: "EEEE",
  7916. time: "HH:mm",
  7917. datetime: "MMM d, h:mm a",
  7918. },
  7919. title: {
  7920. day: "yyyy MMMM EEEE d",
  7921. week: "{year}年第{week}周",
  7922. month: "yyyy MMMM",
  7923. year: "yyyy",
  7924. },
  7925. },
  7926. moment: {
  7927. date: {
  7928. hour: "ha",
  7929. day: "MMMDD日",
  7930. month: "MMMM",
  7931. weekDay: "dddd",
  7932. time: "HH:mm",
  7933. datetime: "MMM D, h:mm a",
  7934. },
  7935. title: {
  7936. day: "YYYY年MMMMDD日, dddd ",
  7937. week: "{year}年第{week}周",
  7938. month: "YYYY年MMMM",
  7939. year: "YYYY",
  7940. },
  7941. },
  7942. };
  7943. moment.locale("zh_cn", {
  7944. months:
  7945. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7946. "_"
  7947. ),
  7948. monthsShort:
  7949. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7950. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7951. "_"
  7952. ),
  7953. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7954. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7955. longDateFormat: {
  7956. LT: "Ah点mm分",
  7957. LTS: "Ah点m分s秒",
  7958. L: "YYYY-MM-DD",
  7959. LL: "YYYY年MMMD日",
  7960. LLL: "YYYY年MMMD日Ah点mm分",
  7961. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7962. l: "YYYY-MM-DD",
  7963. ll: "YYYY年MMMD日",
  7964. lll: "YYYY年MMMD日Ah点mm分",
  7965. llll: "YYYY年MMMD日ddddAh点mm分",
  7966. },
  7967. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7968. meridiemHour: function (hour, meridiem) {
  7969. if (hour === 12) {
  7970. hour = 0;
  7971. }
  7972. if (
  7973. meridiem === "凌晨" ||
  7974. meridiem === "早上" ||
  7975. meridiem === "上午"
  7976. ) {
  7977. return hour;
  7978. } else if (meridiem === "下午" || meridiem === "晚上") {
  7979. return hour + 12;
  7980. } else {
  7981. // '中午'
  7982. return hour >= 11 ? hour : hour + 12;
  7983. }
  7984. },
  7985. meridiem: function (hour, minute, isLower) {
  7986. var hm = hour * 100 + minute;
  7987. if (hm < 600) {
  7988. return "凌晨";
  7989. } else if (hm < 900) {
  7990. return "早上";
  7991. } else if (hm < 1130) {
  7992. return "上午";
  7993. } else if (hm < 1230) {
  7994. return "中午";
  7995. } else if (hm < 1800) {
  7996. return "下午";
  7997. } else {
  7998. return "晚上";
  7999. }
  8000. },
  8001. calendar: {
  8002. sameDay: function () {
  8003. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8004. },
  8005. nextDay: function () {
  8006. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8007. },
  8008. lastDay: function () {
  8009. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8010. },
  8011. nextWeek: function () {
  8012. var startOfWeek, prefix;
  8013. startOfWeek = moment().startOf("week");
  8014. prefix =
  8015. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8016. ? "[下]"
  8017. : "[本]";
  8018. return this.minutes() === 0
  8019. ? prefix + "dddAh点整"
  8020. : prefix + "dddAh点mm";
  8021. },
  8022. lastWeek: function () {
  8023. var startOfWeek, prefix;
  8024. startOfWeek = moment().startOf("week");
  8025. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8026. return this.minutes() === 0
  8027. ? prefix + "dddAh点整"
  8028. : prefix + "dddAh点mm";
  8029. },
  8030. sameElse: "LL",
  8031. },
  8032. ordinalParse: /\d{1,2}(日|月|周)/,
  8033. ordinal: function (number, period) {
  8034. switch (period) {
  8035. case "d":
  8036. case "D":
  8037. case "DDD":
  8038. return number + "日";
  8039. case "M":
  8040. return number + "月";
  8041. case "w":
  8042. case "W":
  8043. return number + "周";
  8044. default:
  8045. return number;
  8046. }
  8047. },
  8048. relativeTime: {
  8049. future: "%s内",
  8050. past: "%s前",
  8051. s: "几秒",
  8052. m: "1 分钟",
  8053. mm: "%d 分钟",
  8054. h: "1 小时",
  8055. hh: "%d 小时",
  8056. d: "1 天",
  8057. dd: "%d 天",
  8058. M: "1 个月",
  8059. MM: "%d 个月",
  8060. y: "1 年",
  8061. yy: "%d 年",
  8062. },
  8063. week: {
  8064. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8065. dow: 1, // Monday is the first day of the week.
  8066. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8067. },
  8068. });
  8069. var date = new Date();
  8070. var d = date.getDate();
  8071. var m = date.getMonth();
  8072. var y = date.getFullYear();
  8073. var filterData = {
  8074. userId: loginUser.id,
  8075. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8076. "YYYY-MM-DD HH:mm:ss"
  8077. ),
  8078. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8079. "YYYY-MM-DD HH:mm:ss"
  8080. ),
  8081. };
  8082. var load = ($scope.load = function (filterData) {
  8083. api_bpm_schedule
  8084. .fetchSchedule(
  8085. filterData.userId,
  8086. filterData.startTime,
  8087. filterData.endTime
  8088. )
  8089. .then(function (response) {
  8090. if (response.status == 200) {
  8091. $scope.events = [];
  8092. var myData = response.list;
  8093. angular.forEach(myData, function (item) {
  8094. var eventTemp = {};
  8095. eventTemp.title = item.description;
  8096. eventTemp.type = item.scheduleClass.code;
  8097. eventTemp.startsAt = moment(
  8098. item["scheduleOrderDTO"].startTime
  8099. ).toDate();
  8100. eventTemp.endsAtTime = moment(
  8101. item["scheduleOrderDTO"].endTime
  8102. ).toDate();
  8103. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8104. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8105. //eventTemp.ends_at = moment(item.endTime).toDate();
  8106. eventTemp.id = item.id;
  8107. eventTemp.deletable = false;
  8108. eventTemp.user = item.user;
  8109. $scope.events.push(eventTemp);
  8110. });
  8111. }
  8112. });
  8113. });
  8114. // var load = $scope.load = function(filterData){
  8115. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8116. // console.log("response="+JSON.stringify(response));
  8117. // if(response.status==200){
  8118. // $scope.events = [];
  8119. // console.log(response.list);
  8120. // var myData = response.list;
  8121. // angular.forEach(myData,function(item){
  8122. // var eventTemp = {};
  8123. // eventTemp.title = item.description;
  8124. // eventTemp.type = item.scheduleClass.code;
  8125. // eventTemp.startsAt = moment(item.startTime).toDate();
  8126. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8127. // eventTemp.startTime = item.startTime;
  8128. // eventTemp.endTime = item.endTime;
  8129. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8130. // eventTemp.id = item.id;
  8131. // eventTemp.deletable = false;
  8132. // eventTemp.users = item.users;
  8133. // $scope.events.push(eventTemp);
  8134. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8135. // })
  8136. // }
  8137. // });
  8138. // }
  8139. $scope.scheduleClass = {};
  8140. var convertEvent = function (scheduleorder) {
  8141. var eventTemp = {};
  8142. eventTemp.title = scheduleorder.description;
  8143. eventTemp.type = scheduleorder.scheduleClass.code;
  8144. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8145. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8146. eventTemp.id = scheduleorder.id;
  8147. eventTemp.user = scheduleorder.user;
  8148. eventTemp.deletable = false;
  8149. return eventTemp;
  8150. };
  8151. // var convertEvent = function(scheduleorder){
  8152. // var eventTemp = {};
  8153. // eventTemp.title = scheduleorder.description;
  8154. // eventTemp.type = scheduleorder.scheduleClass.code;
  8155. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8156. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8157. // eventTemp.id = scheduleorder.id;
  8158. // eventTemp.users = scheduleorder.users;
  8159. // eventTemp.deletable = false;
  8160. // return eventTemp;
  8161. // }
  8162. api_bpm_schedule.getScheduleClass().then(function (response) {
  8163. if (response.status == 200) {
  8164. var scheduleClassList = response.list;
  8165. angular.forEach(scheduleClassList, function (item) {
  8166. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8167. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8168. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8169. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8170. $scope.scheduleClass[item["code"]] = item;
  8171. });
  8172. }
  8173. });
  8174. $scope.events = [];
  8175. $scope.calendarView = "month";
  8176. //$scope.calendarDay = new Date();
  8177. $scope.calendarDate = moment().startOf("month").toDate();
  8178. $scope.timeLabel = "时间";
  8179. $scope.eventLabel = "描述";
  8180. function showModal(action, event) {
  8181. // console.log("action="+JSON.stringify(action))
  8182. var modalInstance = $aside.open({
  8183. templateUrl: "scheduleEvent.html",
  8184. placement: "right",
  8185. size: "sm",
  8186. backdrop: true,
  8187. controller: function (
  8188. $scope,
  8189. $modalInstance,
  8190. scheduleClass,
  8191. APIService,
  8192. MementFormat
  8193. ) {
  8194. $scope.$modalInstance = $modalInstance;
  8195. $scope.action = action;
  8196. $scope.event = event;
  8197. $scope.scheduleClassic = scheduleClass;
  8198. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8199. // if(oldvalue == newvalue) return;
  8200. // if(scheduleClass[newvalue]){
  8201. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8202. var em = MementFormat(scheduleClass[newvalue].endTime);
  8203. console.log("sm=" + JSON.stringify(sm));
  8204. event.starts_at = MementFormat(event.startTime)
  8205. .startOf("day")
  8206. .add(sm.hour(), "hour")
  8207. .add(sm.minute(), "minute")
  8208. .add(sm.second(), "second")
  8209. .toDate();
  8210. console.log(
  8211. "event.starts_at=" + JSON.stringify(event.starts_at)
  8212. );
  8213. if (sm.hour() > em.hour()) {
  8214. event.ends_at = MementFormat(event.startTime)
  8215. .startOf("day")
  8216. .add(1, "day")
  8217. .add(em.hour(), "hour")
  8218. .add(em.minute(), "minute")
  8219. .add(em.second(), "second")
  8220. .toDate();
  8221. console.log(
  8222. "event.ends_at=" + JSON.stringify(event.starts_at)
  8223. );
  8224. } else {
  8225. event.ends_at = MementFormat(event.startTime)
  8226. .startOf("day")
  8227. .add(em.hour(), "hour")
  8228. .add(em.minute(), "minute")
  8229. .add(em.second(), "second")
  8230. .toDate();
  8231. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8232. }
  8233. // }
  8234. });
  8235. // $scope.ok = function (event) {
  8236. // console.log("event="+JSON.stringify(event))
  8237. // event.action = action;
  8238. // $modalInstance.close(event);
  8239. // };
  8240. $scope.cancel = function (event) {
  8241. $modalInstance.dismiss();
  8242. };
  8243. var acUserSelect = ($scope.refreshUser = function (key) {
  8244. //for test
  8245. // $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":"管理层"}]}];
  8246. // return;
  8247. var data = {
  8248. idx: "0",
  8249. sum: "5",
  8250. };
  8251. if (key) {
  8252. data["user"] = {
  8253. name: key,
  8254. };
  8255. }
  8256. APIService.fetchDataList("user", data).then(function (
  8257. response
  8258. ) {
  8259. if (response) {
  8260. if ((response.status = 200)) {
  8261. $scope.users = response.list;
  8262. console.log($scope.users);
  8263. }
  8264. }
  8265. });
  8266. });
  8267. if (angular.isDefined(event.users) && event.users.length > 0) {
  8268. }
  8269. $scope.users = [event.user];
  8270. acUserSelect();
  8271. },
  8272. resolve: {
  8273. scheduleClass: function () {
  8274. return $scope.scheduleClass;
  8275. },
  8276. APIService: function () {
  8277. return api_user_data;
  8278. },
  8279. MementFormat: function () {
  8280. return moment;
  8281. },
  8282. },
  8283. });
  8284. modalInstance.result.then(function (selectedEvent) {
  8285. if (selectedEvent.action == "Clicked") {
  8286. // var data = {
  8287. // "scheduleorder":{
  8288. // "id":selectedEvent.id,
  8289. // "description":selectedEvent.title,
  8290. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8291. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8292. // "users":selectedEvent.users,
  8293. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8294. // }
  8295. // };
  8296. // api_bpm_schedule.update(data).then(function(response){
  8297. // if(response.status==200){
  8298. // SweetAlert.swal({
  8299. // title: "操作成功!",
  8300. // text: "排班更新成功!",
  8301. // type: "succes"
  8302. // });
  8303. // angular.forEach($scope.events,function(item){
  8304. // if(item.id==selectedEvent.id){
  8305. // item = selectedEvent;
  8306. // }
  8307. // })
  8308. // }else{
  8309. // SweetAlert.swal({
  8310. // title: "操作失败",
  8311. // text: "排班更新失败,请稍后重试!",
  8312. // type: "error"
  8313. // })
  8314. // }
  8315. // })
  8316. } else {
  8317. //
  8318. }
  8319. });
  8320. }
  8321. $scope.moment = function (string) {
  8322. return moment(string);
  8323. };
  8324. $scope.eventClicked = function (event) {
  8325. // console.log("event="+JSON.stringify(event))
  8326. showModal("Clicked", event);
  8327. };
  8328. $scope.eventEdited = function (event) {
  8329. showModal("Edited", event);
  8330. };
  8331. var updateView = function (newvalue, oldvalue) {
  8332. if (oldvalue == newvalue) return;
  8333. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8334. if ($scope.calendarView == "year") {
  8335. } else if ($scope.calendarView == "month") {
  8336. timeStart = moment(newvalue).startOf("month");
  8337. timeEnd = moment(newvalue).endOf("month");
  8338. } else if ($scope.calendarView == "week") {
  8339. timeStart = moment(newvalue).startOf("week");
  8340. timeEnd = moment(newvalue).endOf("week");
  8341. } else if ($scope.calendarView == "Day") {
  8342. timeStart = moment(newvalue).startOf("day");
  8343. timeEnd = moment(newvalue).endOf("day");
  8344. }
  8345. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8346. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8347. filterData["startTime"] = timeStartSpan;
  8348. filterData["endTime"] = timeEndSpan;
  8349. load(filterData);
  8350. };
  8351. $scope.$watch("calendarDate", updateView);
  8352. $scope.next = function () {
  8353. $scope.calendarControl.next();
  8354. };
  8355. $scope.prev = function () {
  8356. $scope.calendarControl.prev();
  8357. };
  8358. $scope.setCalendarToToday = function () {
  8359. $scope.calendarDay = new Date();
  8360. };
  8361. $scope.toggle = function ($event, field, event) {
  8362. $event.preventDefault();
  8363. $event.stopPropagation();
  8364. event[field] = !event[field];
  8365. };
  8366. $scope.load(filterData);
  8367. $scope.more = function () {
  8368. $state.go("app.scheduling.myscheduling", {});
  8369. };
  8370. $scope.removes = function () {
  8371. var modalInstance = $modal.open({
  8372. templateUrl: "assets/views/delete.html",
  8373. controller: function ($scope, $modalInstance) {
  8374. $scope.ok = function () {
  8375. $modalInstance.close();
  8376. };
  8377. $scope.cancel = function () {
  8378. $modalInstance.dismiss("cancel");
  8379. };
  8380. },
  8381. size: "sm",
  8382. });
  8383. modalInstance.result.then(function () {
  8384. for (
  8385. var i = 0;
  8386. i <
  8387. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8388. i++
  8389. ) {
  8390. if (
  8391. $scope.fields.type ==
  8392. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8393. .type
  8394. ) {
  8395. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8396. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8397. i,
  8398. 1
  8399. );
  8400. break;
  8401. }
  8402. }
  8403. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8404. if (vmForm) {
  8405. //console.log("vmForm>>>");//console.log(vmForm);
  8406. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8407. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8408. }
  8409. });
  8410. };
  8411. },
  8412. ],
  8413. });
  8414. //空格组件
  8415. formlyConfigProvider.setType({
  8416. name: "ui-black",
  8417. /*extends: 'input',*/
  8418. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8419. });
  8420. //请求人最近事件
  8421. formlyConfigProvider.setType({
  8422. name: "ui-recentIncident",
  8423. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8424. controller: [
  8425. "$scope",
  8426. "$modal",
  8427. "api_solution",
  8428. function ($scope, $modal, api_solution) {
  8429. var filterData = {
  8430. incident: {
  8431. requester: {
  8432. id: "",
  8433. },
  8434. },
  8435. idx: 0,
  8436. sum: 3,
  8437. };
  8438. setInterval(function () {
  8439. if (
  8440. filterData.incident.requester.id == "" ||
  8441. filterData.incident.requester.id != $scope.model.requester.id
  8442. ) {
  8443. var requester = $scope.model.requester;
  8444. if (requester != null && angular.isDefined(requester.id)) {
  8445. filterData.incident.requester.id = $scope.model.requester.id;
  8446. $scope.options.templateOptions
  8447. .getWorkernumber(
  8448. $scope.options.templateOptions.ApiService,
  8449. filterData
  8450. )
  8451. .then(function (result) {
  8452. var modelData =
  8453. $scope.options.templateOptions.Restangular.stripRestangular(
  8454. result
  8455. );
  8456. if (modelData.status == 200) {
  8457. $scope.lastrequst = modelData.list;
  8458. }
  8459. });
  8460. requester = null;
  8461. } else {
  8462. }
  8463. } else {
  8464. }
  8465. }, 1000);
  8466. $scope.detail = function (data) {
  8467. var modalInstance = $modal.open({
  8468. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8469. controller: function ($scope, $modalInstance) {
  8470. $scope.entity = {};
  8471. $scope.entity = data;
  8472. $scope.cancel = function () {
  8473. $modalInstance.dismiss("cancel");
  8474. };
  8475. },
  8476. size: "lg",
  8477. });
  8478. };
  8479. },
  8480. ],
  8481. });
  8482. //参数列表
  8483. formlyConfigProvider.setType({
  8484. name: "ui-listinput",
  8485. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8486. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8487. defaultOptions: function (options) {
  8488. return {
  8489. templateOptions: {},
  8490. };
  8491. },
  8492. controller: ["$scope", function ($scope) { }],
  8493. });
  8494. //时间段控件(分)
  8495. formlyConfigProvider.setType({
  8496. name: "ui-timeslot",
  8497. extends: "input",
  8498. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8499. controller: ["$scope", function ($scope) { }],
  8500. });
  8501. //优先级级联-逾期时间
  8502. formlyConfigProvider.setType({
  8503. name: "ui-overtime",
  8504. extends: "input",
  8505. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8506. controller: [
  8507. "$scope",
  8508. "api_bpm_domain",
  8509. function ($scope, api_bpm_domain) {
  8510. var filteData = {};
  8511. var datas = {};
  8512. setInterval(function () {
  8513. if (
  8514. $scope.model.priority &&
  8515. $scope.model.priority.id != null &&
  8516. filteData &&
  8517. datas != $scope.model.priority.id
  8518. ) {
  8519. filteData = "L" + $scope.model.priority.id;
  8520. datas = $scope.model.priority.id;
  8521. // console.log($scope.options.templateOptions)
  8522. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8523. // var overtime=requester.date;
  8524. if (requester.state == 200) {
  8525. // if($scope.options.key=="date"){
  8526. $scope.model[$scope.options.key] = requester.date;
  8527. // }
  8528. }
  8529. });
  8530. }
  8531. }, 1000);
  8532. },
  8533. ],
  8534. });
  8535. formlyConfigProvider.setType({
  8536. name: "ui-responsetime",
  8537. extends: "input",
  8538. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8539. controller: [
  8540. "$scope",
  8541. "api_bpm_domain",
  8542. function ($scope, api_bpm_domain) {
  8543. var filteData = {};
  8544. var datas = {};
  8545. setInterval(function () {
  8546. if (
  8547. $scope.model.priority &&
  8548. $scope.model.priority.id != null &&
  8549. filteData &&
  8550. datas != $scope.model.priority.id
  8551. ) {
  8552. filteData = "L" + $scope.model.priority.id;
  8553. datas = $scope.model.priority.id;
  8554. // console.log($scope.options.templateOptions)
  8555. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8556. // var overtime=requester.date;
  8557. if (requester.state == 200) {
  8558. var keyName = {};
  8559. // $scope.model.overdueTime = requester.date;
  8560. if ($scope.options.key == "expectIntroTime") {
  8561. keyName = "resolveTime";
  8562. } else if ($scope.options.key == "expectResponseTime") {
  8563. keyName = "responseTime";
  8564. }
  8565. $scope.model[$scope.options.key] =
  8566. requester.serviceLevelAgreement[keyName];
  8567. // }
  8568. console.log($scope.$parent.$parent.$parent.model);
  8569. }
  8570. if (requester.date1) {
  8571. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8572. requester.date;
  8573. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8574. requester.date1;
  8575. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8576. requester.serviceLevelAgreement.resolveTime;
  8577. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8578. requester.serviceLevelAgreement.responseTime;
  8579. }
  8580. });
  8581. }
  8582. }, 1000);
  8583. },
  8584. ],
  8585. });
  8586. //知识库按钮组件
  8587. formlyConfigProvider.setType({
  8588. name: "ui-discasecade",
  8589. extends: "input",
  8590. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8591. defaultOptions: function (options) {
  8592. return {
  8593. templateOptions: {
  8594. relationAction: function (fields, modelscope, item) { },
  8595. },
  8596. validators: {
  8597. required: {
  8598. expression: function (viewValue, modelValue) {
  8599. var value = modelValue || viewValue;
  8600. // return value = "true";
  8601. },
  8602. },
  8603. },
  8604. };
  8605. },
  8606. controller: [
  8607. "$scope",
  8608. "$rootScope",
  8609. "$modal",
  8610. "SweetAlert",
  8611. "api_bpm_data",
  8612. "api_solution",
  8613. "$aside",
  8614. "api_zsk",
  8615. "api_bpm_domain",
  8616. function (
  8617. $scope,
  8618. $rootScope,
  8619. $modal,
  8620. SweetAlert,
  8621. api_bpm_data,
  8622. api_solution,
  8623. $aside,
  8624. api_zsk,
  8625. api_bpm_domain
  8626. ) {
  8627. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8628. $scope.searchField = $scope.options.model[$scope.options.key];
  8629. $scope.searchData = "";
  8630. $scope.onChangeadd = function (searchData) {
  8631. $scope.searchKey = searchData.account;
  8632. // $scope.searchDataadd = searchData;
  8633. var requesdata = angular.copy(searchData);
  8634. $scope.requester = requesdata;
  8635. };
  8636. $scope.refreshUseradd = function (searchKey) {
  8637. //主题搜索
  8638. $scope.searchData = searchKey;
  8639. reashdata($scope.searchData);
  8640. };
  8641. $scope.getMydata = function (x) {
  8642. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8643. $scope.searchField = $scope.model[$scope.options.key];
  8644. };
  8645. $scope.getMydataone = function (x) {
  8646. $scope.model[$scope.options.key] = x;
  8647. $scope.searchField = $scope.model[$scope.options.key];
  8648. };
  8649. $scope.fildata = {
  8650. idx: 0,
  8651. sum: 10,
  8652. // 'incident': { 'tilte': item }
  8653. };
  8654. function reashdata(item) {
  8655. if (item && item != "") {
  8656. angular.extend($scope.fildata, {
  8657. incident: {
  8658. title: item,
  8659. },
  8660. });
  8661. } else {
  8662. delete $scope.fildata.incident;
  8663. }
  8664. api_bpm_data
  8665. .fetchDataList("incident", $scope.fildata)
  8666. .then(function (response) {
  8667. if (response) {
  8668. if ((response.status = 200)) {
  8669. var myData = response;
  8670. $scope.myData = myData.list;
  8671. }
  8672. }
  8673. });
  8674. }
  8675. function delHtmlTag(str) {
  8676. return str.replace(/<[^>]+>/g, "");
  8677. }
  8678. // reashdata();
  8679. var changedata = {};
  8680. setInterval(function () {
  8681. if (
  8682. $scope.model.category != null &&
  8683. $scope.model.category.id != changedata.id &&
  8684. $scope.model.titles != $scope.model.category
  8685. ) {
  8686. $scope.searchData = {};
  8687. changedata = angular.copy($scope.model.category);
  8688. if ($scope.options.key == "title") {
  8689. var filterData = {
  8690. idx: 0,
  8691. sum: 1000,
  8692. };
  8693. api_bpm_data
  8694. .fetchDataList("incidentcategory", filterData)
  8695. .then(function (data) {
  8696. var datalist = data.list;
  8697. angular.forEach(datalist, function (item) {
  8698. if (item.id == $scope.model.category.id) {
  8699. $scope.model[$scope.options.key] = item.category;
  8700. $scope.searchField =
  8701. $scope.options.model[$scope.options.key];
  8702. $scope.titles = item.category;
  8703. titles = $scope.model.category;
  8704. }
  8705. });
  8706. });
  8707. }
  8708. }
  8709. }, 1000);
  8710. $scope.open = function (key, options, fildata, $event, model) {
  8711. if (key && key.length > 1) {
  8712. api_zsk
  8713. .solutionData(
  8714. {
  8715. solution: {
  8716. searchWord: key,
  8717. },
  8718. idx: "0",
  8719. sum: "1000",
  8720. },
  8721. "solution"
  8722. )
  8723. .then(function (response) {
  8724. if (response && response.list.length > 0) {
  8725. $scope.dlideboxslide = true;
  8726. angular.forEach(response, function (item) {
  8727. console.log(response);
  8728. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8729. // if (response.status == 200) {
  8730. // var quote = { 'totalNum': response.totalNum }
  8731. // item = angular.extend(item, quote)
  8732. // }
  8733. // })
  8734. $scope.searchData = response.list;
  8735. console.log($scope.searchData);
  8736. });
  8737. $scope.changes = false;
  8738. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8739. // $scope.closepages = function(e) {
  8740. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8741. // event.preventDefault();
  8742. // };
  8743. $scope.shows = false;
  8744. $scope.tempData = {};
  8745. $scope.showpage = function (item) {
  8746. item.content = delHtmlTag(item.content);
  8747. $scope.shows = true;
  8748. $scope.tempData = item;
  8749. if (item.content != null) {
  8750. $scope.tempData.content = $scope.tempData.content
  8751. .replace("<p>", "")
  8752. .replace("</p>", "");
  8753. }
  8754. $scope.knowledgedata = item;
  8755. $scope.pageid = item.id;
  8756. $scope.changes = !$scope.changes;
  8757. api_bpm_domain
  8758. .listAttachments(item.id)
  8759. // api_solution.fetchDataList('file', {
  8760. // "file": {
  8761. // "solutionId": item.id
  8762. // },
  8763. // "idx": "0",
  8764. // "sum": "1000"
  8765. // })
  8766. .then(function (data) {
  8767. if (data) {
  8768. $scope.attachments = data.list;
  8769. $scope.view = function (attachmentId) {
  8770. for (
  8771. var i = 0;
  8772. i < $scope.attachments.length;
  8773. i++
  8774. ) {
  8775. if ($scope.attachments[i].id == attachmentId) {
  8776. window.open($scope.attachments[i].previewUrl);
  8777. }
  8778. }
  8779. };
  8780. $scope.download = function (contentId, filename) {
  8781. api_solution
  8782. .getSolutionDowpath(contentId)
  8783. .then(function (response) {
  8784. var file = new Blob([response], {
  8785. type: "application/octet-stream",
  8786. });
  8787. // var filename = filename;
  8788. var fileURL = URL.createObjectURL(file);
  8789. var a = document.createElement("a");
  8790. a.href = fileURL;
  8791. a.target = "_blank";
  8792. a.download = filename;
  8793. document.body.appendChild(a);
  8794. a.click();
  8795. });
  8796. };
  8797. }
  8798. });
  8799. };
  8800. $scope.related = function (item) {
  8801. if (item.content != null) {
  8802. item.content = item.content
  8803. .replace("<p>", "")
  8804. .replace("</p>", "");
  8805. }
  8806. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8807. options.model.handleDescription = item.content;
  8808. var data = {
  8809. solutionQuote: {
  8810. solutionId: item.id,
  8811. incidentsign: options.model.incidentsign,
  8812. },
  8813. };
  8814. api_zsk.solutionQuote(item.id).then(function (response) {
  8815. if (response.status == 200) {
  8816. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8817. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8818. "close";
  8819. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8820. } else {
  8821. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8822. }
  8823. });
  8824. };
  8825. $scope.close = function () {
  8826. $scope.changes = !$scope.changes;
  8827. event.preventDefault();
  8828. };
  8829. }
  8830. });
  8831. }
  8832. };
  8833. },
  8834. ],
  8835. });
  8836. //侧滑选择重复事件
  8837. formlyConfigProvider.setType({
  8838. name: "ui-repeatIncidentbtn",
  8839. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8840. defaultOptions: function (options) {
  8841. return {
  8842. templateOptions: {
  8843. relationAction: function (fields, modelscope, item) { },
  8844. },
  8845. validators: {
  8846. required: {
  8847. expression: function (viewValue, modelValue) {
  8848. // var value = modelValue || viewValue;
  8849. },
  8850. },
  8851. },
  8852. };
  8853. },
  8854. controller: [
  8855. "$scope",
  8856. "$rootScope",
  8857. "$modal",
  8858. "SweetAlert",
  8859. "api_bpm_data",
  8860. "api_solution",
  8861. "$aside",
  8862. "api_zsk",
  8863. "api_bpm_domain",
  8864. function (
  8865. $scope,
  8866. $rootScope,
  8867. $modal,
  8868. SweetAlert,
  8869. api_bpm_data,
  8870. api_solution,
  8871. $aside,
  8872. api_zsk,
  8873. api_bpm_domain
  8874. ) {
  8875. console.log($scope);
  8876. $scope.selection = {
  8877. id: "",
  8878. };
  8879. //认证计费数据获取
  8880. $scope.sumInfo = {};
  8881. function getSumInfo() {
  8882. api_bpm_data
  8883. .sumInfo($scope.model.incident.account)
  8884. .then(function (data) {
  8885. console.log(data);
  8886. if (data) {
  8887. $scope.sumInfo = data.data || {};
  8888. }
  8889. });
  8890. }
  8891. getSumInfo();
  8892. // 收起重复事件侧滑框
  8893. function reashdata(item) {
  8894. var fildata = {
  8895. idx: 0,
  8896. incident: {
  8897. department: {
  8898. id: $scope.model.incident.department.id,
  8899. },
  8900. },
  8901. sum: 3,
  8902. };
  8903. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8904. console.log(data);
  8905. if (data) {
  8906. $scope.repeatData = data.list;
  8907. }
  8908. });
  8909. }
  8910. reashdata();
  8911. // 确认选中的重复事件
  8912. $scope.repeatIncidentOk = function () {
  8913. if ($scope.selection.id) {
  8914. $scope.model.incident.repeat = $scope.selection;
  8915. $scope.model.isRepeat = true; //隐藏处理信息
  8916. console.log($scope.model);
  8917. }
  8918. angular.element("#repeatIncident").removeClass("active");
  8919. };
  8920. // 取消选中的重复事件
  8921. $scope.repeatIncidentCancle = function () {
  8922. angular.element("#repeatIncident").removeClass("active");
  8923. return;
  8924. };
  8925. },
  8926. ],
  8927. });
  8928. //侧滑选择知识库查询
  8929. formlyConfigProvider.setType({
  8930. name: "ui-knowledgebtn",
  8931. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8932. defaultOptions: function (options) {
  8933. return {
  8934. templateOptions: {
  8935. relationAction: function (fields, modelscope, item) { },
  8936. },
  8937. validators: {
  8938. required: {
  8939. expression: function (viewValue, modelValue) {
  8940. // var value = modelValue || viewValue;
  8941. },
  8942. },
  8943. },
  8944. };
  8945. },
  8946. controller: [
  8947. "$scope",
  8948. "$rootScope",
  8949. "$modal",
  8950. "SweetAlert",
  8951. "api_bpm_data",
  8952. "api_solution",
  8953. "$aside",
  8954. "api_zsk",
  8955. "api_bpm_domain",
  8956. "api_wechatfile",
  8957. "up_down_file",
  8958. function (
  8959. $scope,
  8960. $rootScope,
  8961. $modal,
  8962. SweetAlert,
  8963. api_bpm_data,
  8964. api_solution,
  8965. $aside,
  8966. api_zsk,
  8967. api_bpm_domain,
  8968. api_wechatfile,
  8969. up_down_file
  8970. ) {
  8971. $scope.keypressModel = function (e, key) {
  8972. if (e.keyCode === 13) {
  8973. $scope.openModel(key);
  8974. }
  8975. };
  8976. // 引用知识库点击
  8977. $scope.searchKeyWord = "";
  8978. $scope.openModel = function (key) {
  8979. // alert(1)//重点
  8980. $scope.searchKeyWord = key;
  8981. if (key) {
  8982. api_zsk
  8983. .solutionData(
  8984. {
  8985. solution: {
  8986. threeSearch: key,
  8987. status: { id: 72 }, //已发布
  8988. selectType: "keySearch",
  8989. },
  8990. idx: "0",
  8991. sum: "1000",
  8992. },
  8993. "solution"
  8994. )
  8995. .then(function (response) {
  8996. $scope.searchData = response.list;
  8997. });
  8998. }
  8999. };
  9000. $scope.openModel($scope.model.incident.description);
  9001. // 展开/收起
  9002. $scope.showId = "";
  9003. $scope.ifshow = false;
  9004. $scope.showAll = function (id) {
  9005. $scope.attachments = [];
  9006. if ($scope.showId == id) {
  9007. $scope.ifshow = !$scope.ifshow;
  9008. } else {
  9009. $scope.ifshow = true;
  9010. }
  9011. $scope.showId = id;
  9012. // 获取附件
  9013. api_wechatfile
  9014. .listAttachments("knowledge", $scope.showId)
  9015. .then(function (data) {
  9016. $scope.attachments = data.data;
  9017. $scope.download = function (token, filename) {
  9018. var downUrl = up_down_file
  9019. .downloadAttachment("common/common/downloadAttachment", token)
  9020. .getRequestedUrl();
  9021. // window.open(downUrl);
  9022. var a = document.createElement("a");
  9023. a.href = downUrl;
  9024. a.target = "_blank";
  9025. a.download = filename;
  9026. document.body.appendChild(a);
  9027. a.click();
  9028. };
  9029. });
  9030. };
  9031. // 引用
  9032. $scope.related = function (item) {
  9033. console.log(item, "引用名");
  9034. if (item.content) {
  9035. item.content = item.content
  9036. .replace(/<p>/g, "")
  9037. .replace(/<\/p>/g, "")
  9038. .replace(/&nbsp;/g, "");
  9039. }
  9040. $scope.model.incident.handleDescription = item.content;
  9041. $scope.model.incident.title = $scope.model.incident.description =
  9042. item.title;
  9043. $scope.model.incident.category = item.category;
  9044. if (item.category) {
  9045. $scope.model.incident.priority.id = item.category.priority.id;
  9046. item.category.label = item.category.category;
  9047. }
  9048. var categoryId = item.category ? item.category.id : "";
  9049. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  9050. function getres(nodes) {
  9051. if (!nodes || nodes.length == 0) {
  9052. return;
  9053. }
  9054. nodes.forEach((e) => {
  9055. e.selected = false;
  9056. if (e.id == categoryId) {
  9057. e.selected = true;
  9058. return false;
  9059. }
  9060. getres(e.children);
  9061. });
  9062. }
  9063. var categorys = [];
  9064. $scope.fields.forEach((e, i) => {
  9065. if (e.key == "category") {
  9066. categorys = e.templateOptions.options;
  9067. if (categorys.length) {
  9068. getres(categorys);
  9069. $scope.fields[i].templateOptions.options = categorys;
  9070. $scope.$root.refreshSelectedItems();
  9071. }
  9072. return false;
  9073. }
  9074. });
  9075. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9076. $scope.model.candidateGroups = item.category
  9077. ? item.category.group
  9078. : {};
  9079. // 携带关联优先级,事件工单信息的时间
  9080. if (
  9081. $scope.model &&
  9082. $scope.model.incident &&
  9083. item.category &&
  9084. item.category.priority &&
  9085. item.category.priority.id
  9086. ) {
  9087. api_bpm_domain
  9088. .expectedTime("L" + (item.category.priority.id - 1559))
  9089. .then(function (res) {
  9090. $scope.model.incident.expectResponseTime =
  9091. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9092. res.serviceLevelAgreement.responseTime;
  9093. $scope.model.incident.expectIntroTime =
  9094. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9095. res.serviceLevelAgreement.resolveTime;
  9096. $scope.model.incident.overdueTime =
  9097. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9098. res.date;
  9099. });
  9100. }
  9101. api_zsk.solutionQuote(item.id).then(function (response) {
  9102. if (response.status == 200) {
  9103. $("#seachknowledge").removeClass("active");
  9104. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9105. $scope.$parent.$parent.$parent.model.start_code = "close";
  9106. $scope.$parent.$parent.$parent.model.directClose = 0;
  9107. console.log($scope.model);
  9108. } else {
  9109. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9110. }
  9111. });
  9112. };
  9113. },
  9114. ],
  9115. });
  9116. //下拉输入组件
  9117. formlyConfigProvider.setType({
  9118. name: "ui-selectinput",
  9119. extends: "input",
  9120. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9121. defaultOptions: function (options) {
  9122. return {
  9123. templateOptions: {
  9124. refresh: function () { },
  9125. refreshDelay: 0,
  9126. linkage: function (modelName, data) { },
  9127. },
  9128. };
  9129. },
  9130. controller: [
  9131. "$scope",
  9132. "$rootScope",
  9133. "$modal",
  9134. "SweetAlert",
  9135. "api_bpm_data",
  9136. "api_solution",
  9137. "$aside",
  9138. function (
  9139. $scope,
  9140. $rootScope,
  9141. $modal,
  9142. SweetAlert,
  9143. api_bpm_data,
  9144. api_solution,
  9145. $aside
  9146. ) {
  9147. $scope.searchData = "";
  9148. $scope.onChangeadd = function (searchData) {
  9149. // $scope.searchKey = searchData.account;
  9150. // var requesdata = angular.copy(searchData)
  9151. // $scope.requester = requesdata;
  9152. };
  9153. $scope.refreshUseradd = function (searchKey) {
  9154. //主题搜索
  9155. // $scope.searchData = searchKey;
  9156. // reashdata($scope.searchData);
  9157. };
  9158. $scope.getMydata = function (x) {
  9159. $scope.model[$scope.options.key] =
  9160. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9161. $scope.searchField = $scope.model[$scope.options.key];
  9162. };
  9163. $scope.getMydataone = function (x) {
  9164. $scope.model[$scope.options.key] = x;
  9165. $scope.searchField = $scope.model[$scope.options.key];
  9166. if (
  9167. $scope.model[$scope.options.key] &&
  9168. $scope.model[$scope.options.key] != ""
  9169. ) {
  9170. $scope.hidden = false;
  9171. } else {
  9172. $scope.hidden = true;
  9173. }
  9174. };
  9175. function reashdata(item) {
  9176. $scope.myData = $scope.options.templateOptions.mydata;
  9177. }
  9178. reashdata();
  9179. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9180. $scope.options.templateOptions.fetchItems($scope);
  9181. }
  9182. },
  9183. ],
  9184. });
  9185. //重构组件模板
  9186. //获取当前人
  9187. formlyConfigProvider.setType({
  9188. name: "ui-users",
  9189. extends: "input",
  9190. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9191. defaultOptions: function (options) {
  9192. return {
  9193. templateOptions: {
  9194. translate: "",
  9195. refreshDelay: 0,
  9196. },
  9197. };
  9198. },
  9199. controller: [
  9200. "$scope",
  9201. function ($scope) {
  9202. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9203. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9204. },
  9205. ],
  9206. });
  9207. //只读控件
  9208. formlyConfigProvider.setType({
  9209. name: "ui-label",
  9210. extends: "input",
  9211. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9212. defaultOptions: function (options) {
  9213. return {
  9214. templateOptions: {
  9215. translate: "",
  9216. refreshDelay: 0,
  9217. },
  9218. };
  9219. },
  9220. controller: [
  9221. "$scope",
  9222. "$rootScope",
  9223. function ($scope, $rootScope) {
  9224. // console.log($scope.options.templateOptions)
  9225. // console.log($scope.options,'options1122');
  9226. $scope.isSolutionLabel = false;
  9227. $scope.solutionLabelStr = "";
  9228. // console.log($scope.options.templateOptions.solotinLabel);
  9229. if ($scope.options.templateOptions.solotinLabel) {
  9230. $scope.isSolutionLabel = true;
  9231. if ($scope.model[$scope.options.key]) {
  9232. var solutionArr = $scope.model[$scope.options.key].split("/");
  9233. $scope.solutionLabelStr = solutionArr.join(" ");
  9234. }
  9235. }
  9236. var value = $scope.model[$scope.options.key];
  9237. // ----------------
  9238. // ----------------
  9239. // console.log(value, 'pppp')
  9240. function treeDesc(children, key, label) {
  9241. if (label == "") {
  9242. label = children[key];
  9243. } else {
  9244. label = children[key] + "-" + label;
  9245. }
  9246. if (angular.isDefined(children.parent)) {
  9247. treeDesc(children.parent, key, label);
  9248. } else {
  9249. return label;
  9250. }
  9251. }
  9252. if (angular.isArray(value)) {
  9253. var tempValue = "";
  9254. angular.forEach(value, function (item) {
  9255. if (tempValue != "") {
  9256. tempValue = tempValue + ",";
  9257. }
  9258. tempValue =
  9259. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9260. item;
  9261. });
  9262. $scope.options.templateOptions.translate = tempValue;
  9263. } else if (angular.isObject(value)) {
  9264. if (
  9265. angular.isDefined(value.children) ||
  9266. angular.isDefined(value.parent)
  9267. ) {
  9268. //tree
  9269. // console.log("value.parent="+JSON.stringify(value.parent))
  9270. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9271. nameLabel = treeDesc(
  9272. value.parent,
  9273. $scope.options.templateOptions.labelProp,
  9274. nameLabel
  9275. );
  9276. $scope.options.templateOptions.translate = nameLabel;
  9277. } else {
  9278. $scope.options.templateOptions.translate = value;
  9279. }
  9280. } else if (
  9281. angular.isString(value) &&
  9282. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9283. ) {
  9284. // console.log("value=" + value);
  9285. $scope.options.templateOptions.translate = value;
  9286. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9287. // console.log("value="+value);
  9288. // $scope.options.templateOptions.translate = value;
  9289. } else {
  9290. // var datasdf = JSON.parse(value);
  9291. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9292. $scope.options.templateOptions.translate = value;
  9293. }
  9294. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9295. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9296. $scope.options.templateOptions.translate =
  9297. $scope.options.templateOptions.transform(
  9298. $scope.originalModel,
  9299. value,
  9300. $rootScope,
  9301. $scope
  9302. );
  9303. }
  9304. // console.log($scope.options.templateOptions.translate,99999);
  9305. },
  9306. ],
  9307. });
  9308. //小标题组件
  9309. formlyConfigProvider.setType({
  9310. name: "ui-header",
  9311. template:
  9312. '<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>',
  9313. });
  9314. //标题组件
  9315. formlyConfigProvider.setType({
  9316. name: "ui-title",
  9317. template:
  9318. '<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>',
  9319. });
  9320. //标栏是否展示
  9321. formlyConfigProvider.setType({
  9322. name: "ui-orshow",
  9323. template:
  9324. '<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>',
  9325. controller: [
  9326. "$scope",
  9327. function ($scope) {
  9328. $scope.clickshow = function (key) {
  9329. // $scope.model[$scope.options.key] != key;
  9330. if (key == false) {
  9331. $scope.model[$scope.options.key] = true;
  9332. } else {
  9333. $scope.model[$scope.options.key] = false;
  9334. }
  9335. };
  9336. },
  9337. ],
  9338. });
  9339. //按钮组
  9340. formlyConfigProvider.setType({
  9341. name: "ui-button",
  9342. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9343. defaultOptions: function (options) {
  9344. return {
  9345. noFormControl: true,
  9346. };
  9347. },
  9348. });
  9349. //3d组link
  9350. formlyConfigProvider.setType({
  9351. name: "ui-link",
  9352. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9353. defaultOptions: function (options) {
  9354. return {
  9355. noFormControl: true,
  9356. };
  9357. },
  9358. });
  9359. //隐藏域组件
  9360. formlyConfigProvider.setType({
  9361. name: "ui-hidden",
  9362. extends: "input",
  9363. template:
  9364. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9365. defaultOptions: function (options) {
  9366. return {
  9367. // noFormControl: true
  9368. };
  9369. },
  9370. });
  9371. //文本框组件
  9372. formlyConfigProvider.setType({
  9373. name: "ui-input",
  9374. extends: "input",
  9375. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9376. defaultOptions: function (options) {
  9377. return {
  9378. templateOptions: {
  9379. transform: function (value) { },
  9380. },
  9381. };
  9382. },
  9383. controller: [
  9384. "$scope",
  9385. "$timeout",
  9386. function ($scope, $timeout) {
  9387. // console.log($scope.model[$scope.options.key]);
  9388. // console.log($scope.options)
  9389. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9390. $scope.model[$scope.options.key] =
  9391. $scope.options.templateOptions.linkData($scope.model);
  9392. }
  9393. },
  9394. ],
  9395. });
  9396. //搜索下拉框-故障地点seimin
  9397. formlyConfigProvider.setType({
  9398. name: "ui-select-search",
  9399. extends: "input",
  9400. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9401. defaultOptions: function (options) {
  9402. return {
  9403. templateOptions: {
  9404. transform: function (value) { },
  9405. },
  9406. };
  9407. },
  9408. controller: [
  9409. "$scope",
  9410. "$rootScope",
  9411. "api_search_area",
  9412. function ($scope, $rootScope, api_search_area) {
  9413. // console.log($scope.options, $scope.model)
  9414. // ----------------分割线 start-----------------
  9415. // 故障地点下拉
  9416. $scope.address_arr = []; //故障地点所有数据
  9417. $scope.addressFlag = false; //默认下拉框列表隐藏
  9418. //点击文本框
  9419. $scope.AddressClickHandle = function () {
  9420. $scope.getDepartmentList();
  9421. angular.element("#bx_address_ul").scrollTop(0);
  9422. };
  9423. //修改文字,实时监听
  9424. $scope.ksChangeHandle = _.debounce(function () {
  9425. $scope.model[$scope.options.key] =
  9426. $scope.model[$scope.options.key] === undefined
  9427. ? ""
  9428. : $scope.model[$scope.options.key];
  9429. $scope.getDepartmentList();
  9430. angular.element("#bx_address_ul").scrollTop(0);
  9431. }, 500);
  9432. //获取故障地点seimin
  9433. $scope.getDepartmentList = function () {
  9434. $scope.model[$scope.options.key] =
  9435. $scope.model[$scope.options.key] === null
  9436. ? ""
  9437. : $scope.model[$scope.options.key];
  9438. api_search_area
  9439. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9440. .then((res) => {
  9441. if (res.state == 200) {
  9442. $scope.address_arr = res.result;
  9443. $scope.addressFlag = true; //显示
  9444. }
  9445. })
  9446. .catch((err) => {
  9447. console.log(err);
  9448. });
  9449. };
  9450. // $scope.getDepartmentList();
  9451. // console.log($scope.model[$scope.options.key])
  9452. //下拉框列表选中
  9453. $scope.addressItemClick = function (obj) {
  9454. $scope.addressFlag = false; //隐藏
  9455. $scope.model[$scope.options.key] = obj.place
  9456. ? obj.area.area + obj.place
  9457. : obj.area;
  9458. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9459. $scope.model.selecthouseNumber = obj;
  9460. console.log($scope, 77777);
  9461. $scope.$root.selecthouseNumber = obj;
  9462. };
  9463. //点击空白处隐藏
  9464. angular.element(document).on("click", function (e) {
  9465. if (e.target !== angular.element("#bx_address").get(0)) {
  9466. $scope.addressFlag = false; //隐藏
  9467. //模拟placeholder
  9468. // if ($('#bx_address').val() == '') {
  9469. // $('#bx_address').val('请选择报修科室');
  9470. // }
  9471. }
  9472. });
  9473. // -----------------分割线 end----------------
  9474. },
  9475. ],
  9476. });
  9477. //知识库关键字组件
  9478. formlyConfigProvider.setType({
  9479. name: "ui-knowledgeKeywords",
  9480. extends: "input",
  9481. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9482. defaultOptions: function (options) {
  9483. return {
  9484. templateOptions: {
  9485. transform: function (value) { },
  9486. },
  9487. };
  9488. },
  9489. controller: [
  9490. "$scope",
  9491. "$timeout",
  9492. "SweetAlert",
  9493. function ($scope, $timeout, SweetAlert) {
  9494. $scope.valueLength = [
  9495. {
  9496. value: "",
  9497. },
  9498. ];
  9499. $scope.valueAll = [];
  9500. if ($scope.model[$scope.options.key]) {
  9501. var valueArr = $scope.model[$scope.options.key].split("/");
  9502. $scope.valueLength = [];
  9503. for (var i = 0; i < valueArr.length; i++) {
  9504. $scope.valueLength.push({
  9505. value: valueArr[i],
  9506. });
  9507. }
  9508. }
  9509. $scope.addIpt = function () {
  9510. if ($scope.valueLength.length < 5) {
  9511. $scope.valueLength.push({
  9512. value: "",
  9513. });
  9514. } else {
  9515. SweetAlert.swal({
  9516. title: "添加失败",
  9517. text: "关键字不能超过5个!",
  9518. type: "error",
  9519. confirmButtonColor: "#DD6B55",
  9520. });
  9521. }
  9522. };
  9523. $scope.closeIpt = function (data) {
  9524. $scope.valueLength.splice(data, 1);
  9525. };
  9526. $scope.toOption = function () {
  9527. $scope.valueAll = [];
  9528. for (var i = 0; i < $scope.valueLength.length; i++) {
  9529. if ($scope.valueLength[i].value != "") {
  9530. $scope.valueAll.push($scope.valueLength[i].value);
  9531. }
  9532. }
  9533. $scope.model.label = $scope.valueAll.join("/");
  9534. };
  9535. },
  9536. ],
  9537. });
  9538. //文本框组件
  9539. formlyConfigProvider.setType({
  9540. name: "ui-num",
  9541. extends: "input",
  9542. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9543. defaultOptions: function (options) {
  9544. return {
  9545. templateOptions: {
  9546. transform: function (value) { },
  9547. },
  9548. };
  9549. },
  9550. controller: [
  9551. "$scope",
  9552. "$timeout",
  9553. function ($scope, $timeout) {
  9554. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9555. $scope.model[$scope.options.key] =
  9556. $scope.options.templateOptions.linkData($scope.model);
  9557. }
  9558. $scope.clearNoNum = function (obj, attr) {
  9559. //先把非数字的都替换掉,除了数字和.
  9560. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9561. //必须保证第一个为数字而不是.
  9562. obj[attr] = obj[attr].replace(/^\./g, "");
  9563. //保证只有出现一个.而没有多个.
  9564. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9565. //保证.只出现一次,而不能出现两次以上
  9566. obj[attr] = obj[attr]
  9567. .replace(".", "$#$")
  9568. .replace(/\./g, "")
  9569. .replace("$#$", ".");
  9570. //小于最大值
  9571. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9572. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9573. // obj[attr] = '';
  9574. // }
  9575. };
  9576. },
  9577. ],
  9578. });
  9579. // //关联请求人文本框组件
  9580. // formlyConfigProvider.setType({
  9581. // name: 'ui-requestinput',
  9582. // extends: 'input',
  9583. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9584. // defaultOptions: function(options) {
  9585. // return {
  9586. // templateOptions: {
  9587. // transform: function(value) {},
  9588. // linkData: function(options) {}
  9589. // }
  9590. // };
  9591. // }
  9592. // });
  9593. //只读文本
  9594. formlyConfigProvider.setType({
  9595. name: "ui-disableinput",
  9596. extends: "input",
  9597. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9598. defaultOptions: function (options) {
  9599. return {
  9600. templateOptions: {
  9601. transform: function (value) {
  9602. var ret = "";
  9603. if (value) {
  9604. ret = "已删除";
  9605. } else {
  9606. ret = "正常";
  9607. }
  9608. return ret;
  9609. },
  9610. },
  9611. };
  9612. },
  9613. });
  9614. formlyConfigProvider.setType({
  9615. name: "ui-disinput",
  9616. extends: "input",
  9617. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9618. defaultOptions: function (options) {
  9619. return {
  9620. templateOptions: {},
  9621. };
  9622. },
  9623. });
  9624. //数字组件
  9625. formlyConfigProvider.setType({
  9626. name: "ui-number",
  9627. extends: "input",
  9628. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9629. defaultOptions: function (options) {
  9630. return {
  9631. templateOptions: {},
  9632. };
  9633. },
  9634. controller: ["$scope", function ($scope) { }],
  9635. });
  9636. //含有周的日期
  9637. formlyConfigProvider.setType({
  9638. name: "ui-datepickerweek",
  9639. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9640. extends: "input",
  9641. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9642. defaultOptions: {
  9643. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9644. templateOptions: {
  9645. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9646. },
  9647. },
  9648. controller: [
  9649. "$scope",
  9650. "$filter",
  9651. function ($scope, $filter) {
  9652. $scope.mindata = new Date(
  9653. $scope.options.templateOptions.transform($scope.model).getTime() +
  9654. 5 * 60 * 1000
  9655. );
  9656. if ($scope.model[$scope.options.key]) {
  9657. } else {
  9658. $scope.model[$scope.options.key] = $filter("date")(
  9659. new Date(new Date().getTime()),
  9660. $scope.options.templateOptions.datepickerPopup
  9661. );
  9662. }
  9663. $scope.options.initialValue = $scope.model[$scope.options.key];
  9664. $scope.endOpen = true;
  9665. $scope.datepicker = {};
  9666. $scope.datepicker.opened = false;
  9667. $scope.datepicker.open = function ($event) {
  9668. $scope.datepicker.opened = true;
  9669. };
  9670. },
  9671. ],
  9672. });
  9673. //lmm
  9674. //分配任务列表
  9675. formlyConfigProvider.setType({
  9676. name: "jry_taskDistributionList",
  9677. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9678. wrapper: ["bootstrapHasError"],
  9679. defaultOptions: function (options, $scope) {
  9680. return {
  9681. templateOptions: {},
  9682. };
  9683. },
  9684. controller: function (
  9685. $rootScope,
  9686. $scope,
  9687. api_user_data,
  9688. $modal,
  9689. api_doc_data,
  9690. i18nService,
  9691. SweetAlert,
  9692. api_wechatfile
  9693. ) {
  9694. // 获取状态
  9695. $scope.stateListData = {};
  9696. $scope.getStateData = function () {
  9697. //lyl
  9698. var data = {
  9699. key: "task_sub_state",
  9700. type: "list",
  9701. };
  9702. api_wechatfile.getDictionary(data).then(function (res) {
  9703. angular.forEach(res, function (v, i) {
  9704. $scope.stateListData[v.value] = v.id;
  9705. });
  9706. });
  9707. };
  9708. $scope.getStateData();
  9709. var loginUser = $rootScope.user;
  9710. $scope.langs = i18nService.getAllLangs();
  9711. $scope.lang = "zh-cn";
  9712. i18nService.setCurrentLang($scope.lang);
  9713. $scope.gridOptions = {};
  9714. $scope.gridOptions.data = "myData";
  9715. $scope.gridOptions.enableColumnResizing = true;
  9716. $scope.gridOptions.enableGridMenu = false;
  9717. $scope.gridOptions.enableRowSelection = true;
  9718. $scope.gridOptions.showGridFooter = true;
  9719. $scope.gridOptions.showColumnFooter = false;
  9720. $scope.gridOptions.fastWatch = true;
  9721. $scope.gridOptions.useExternalFiltering = true;
  9722. $scope.gridOptions.useExternalPagination = true;
  9723. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9724. $scope.gridOptions.paginationPageSize = 10;
  9725. $scope.gridOptions.multiSelect = true;
  9726. $scope.gridOptions.rowIdentity = function (row) {
  9727. return row.id;
  9728. };
  9729. $scope.gridOptions.getRowIdentity = function (row) {
  9730. return row.id;
  9731. };
  9732. // console.log($scope.model);//lmmmm
  9733. $scope.gridOptions.columnDefs = [
  9734. {
  9735. name: "item",
  9736. displayName: "序号",
  9737. width: "10%",
  9738. cellTemplate:
  9739. "<div>" +
  9740. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9741. "</div>",
  9742. },
  9743. {
  9744. name: "taskDescribe",
  9745. displayName: "任务说明",
  9746. width: "25%",
  9747. enableFiltering: false,
  9748. cellTemplate:
  9749. "<div>" +
  9750. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9751. "</div>",
  9752. },
  9753. {
  9754. name: "assign.name",
  9755. displayName: "指派人",
  9756. width: "5%",
  9757. enableFiltering: false,
  9758. cellTemplate:
  9759. "<div>" +
  9760. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9761. "</div>",
  9762. },
  9763. {
  9764. name: "startTime",
  9765. displayName: "开始时间",
  9766. width: "13%",
  9767. enableFiltering: false,
  9768. cellTemplate:
  9769. "<div>" +
  9770. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9771. "</div>",
  9772. },
  9773. {
  9774. name: "endTime",
  9775. displayName: "结束时间",
  9776. width: "13%",
  9777. enableFiltering: false,
  9778. cellTemplate:
  9779. "<div>" +
  9780. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9781. "</div>",
  9782. },
  9783. {
  9784. name: "priority.name",
  9785. displayName: "优先级",
  9786. width: "5%",
  9787. enableFiltering: false,
  9788. cellTemplate:
  9789. "<div>" +
  9790. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9791. "</div>",
  9792. },
  9793. {
  9794. name: "state.name",
  9795. displayName: "状态",
  9796. width: "5%",
  9797. enableFiltering: false,
  9798. cellTemplate:
  9799. "<div>" +
  9800. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9801. "</div>",
  9802. },
  9803. {
  9804. name: "操作", //lmmm
  9805. cellTemplate:
  9806. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9807. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9808. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9809. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9810. '<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>' +
  9811. "</div></div>",
  9812. enableFiltering: false,
  9813. },
  9814. ];
  9815. // 查看
  9816. $scope.see = function (data) {
  9817. $scope.seeData = data;
  9818. var modalInstance = $modal.open({
  9819. backdrop: false,
  9820. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9821. controller: function (
  9822. $scope,
  9823. scope,
  9824. $modalInstance,
  9825. api_doc_data,
  9826. SweetAlert,
  9827. api_user_data,
  9828. api_wechatfile
  9829. ) {
  9830. $scope.personData = {}; //指派人
  9831. $scope.priorityData = {}; //优先级
  9832. $scope.personListData = {}; //指派人下拉数据
  9833. $scope.priorityListData = {}; //优先级下拉数据
  9834. $scope.startTime = ""; //开始时间
  9835. $scope.releaseShow = "no";
  9836. $scope.subShow = "no";
  9837. $scope.onlySee = "ok";
  9838. $scope.endTime = ""; //结束时间
  9839. $scope.taskDescribe = ""; //任务描述
  9840. $scope.taskDescribe = scope.seeData.taskDescribe;
  9841. $scope.personData.data = scope.seeData.assign;
  9842. $scope.priorityData.data = scope.seeData.priority;
  9843. $scope.startTime = scope.seeData.startTime;
  9844. $scope.endTime = scope.seeData.endTime;
  9845. $scope.done = scope.seeData.done;
  9846. $scope.feedback = scope.seeData.feedback;
  9847. $scope.cancel = function () {
  9848. $modalInstance.dismiss("cancel");
  9849. };
  9850. },
  9851. size: "sm",
  9852. resolve: {
  9853. scope: function () {
  9854. return $scope;
  9855. },
  9856. },
  9857. backdrop: true,
  9858. });
  9859. };
  9860. // 编辑
  9861. $scope.edit = function (data) {
  9862. $scope.editData = data;
  9863. var modalInstance = $modal.open({
  9864. backdrop: false,
  9865. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9866. controller: function (
  9867. $scope,
  9868. scope,
  9869. $modalInstance,
  9870. api_doc_data,
  9871. SweetAlert,
  9872. api_user_data,
  9873. api_wechatfile
  9874. ) {
  9875. console.log(scope.editData);
  9876. $scope.personData = {}; //指派人
  9877. $scope.priorityData = {}; //优先级
  9878. $scope.personListData = {}; //指派人下拉数据
  9879. $scope.priorityListData = {}; //优先级下拉数据
  9880. $scope.startTime = ""; //开始时间
  9881. $scope.releaseShow = "no";
  9882. $scope.endTime = ""; //结束时间
  9883. $scope.taskDescribe = ""; //任务描述
  9884. $scope.taskDescribe = scope.editData.taskDescribe;
  9885. $scope.personData.data = scope.editData.assign;
  9886. $scope.priorityData.data = scope.editData.priority;
  9887. $scope.startTime = scope.editData.startTime;
  9888. $scope.endTime = scope.editData.endTime;
  9889. // 指派人下拉框数据
  9890. $scope.getPersonData = function () {
  9891. var data = {
  9892. idx: 0,
  9893. sum: 1000,
  9894. };
  9895. api_user_data.fetchDataList("user", data).then(function (res) {
  9896. $scope.personListData = res.list;
  9897. });
  9898. };
  9899. $scope.getPersonData();
  9900. //优先级下拉数据
  9901. $scope.getPriorityData = function () {
  9902. var data = {
  9903. key: "change_rick_level",
  9904. type: "list",
  9905. };
  9906. api_wechatfile.getDictionary(data).then(function (res) {
  9907. $scope.priorityListData = res;
  9908. });
  9909. };
  9910. $scope.getPriorityData();
  9911. // 获取状态-lmm
  9912. $scope.stateListData = {};
  9913. $scope.getStateData = function () {
  9914. //lyl
  9915. var data = {
  9916. key: "task_sub_state",
  9917. type: "list",
  9918. };
  9919. api_wechatfile.getDictionary(data).then(function (res) {
  9920. angular.forEach(res, function (v, i) {
  9921. $scope.stateListData[v.value] = v.id;
  9922. });
  9923. });
  9924. };
  9925. $scope.getStateData();
  9926. //时间控件
  9927. $scope.open = function ($event) {
  9928. $event.preventDefault();
  9929. $event.stopPropagation();
  9930. $scope.opened = !$scope.opened;
  9931. };
  9932. $scope.endOpen = function ($event) {
  9933. $event.preventDefault();
  9934. $event.stopPropagation();
  9935. $scope.startOpened = false;
  9936. $scope.endOpened = !$scope.endOpened;
  9937. };
  9938. $scope.startOpen = function ($event) {
  9939. $event.preventDefault();
  9940. $event.stopPropagation();
  9941. $scope.endOpened = false;
  9942. $scope.startOpened = !$scope.startOpened;
  9943. };
  9944. // 确定
  9945. $scope.ok = function (item) {
  9946. if (
  9947. $scope.taskDescribe &&
  9948. $scope.personData.data &&
  9949. $scope.priorityData.data &&
  9950. $scope.startTime &&
  9951. $scope.endTime
  9952. ) {
  9953. $scope.startTime = moment(
  9954. new Date($scope.startTime).getTime()
  9955. ).format("YYYY-MM-DD HH:mm:ss");
  9956. $scope.endTime = moment(
  9957. new Date($scope.endTime).getTime()
  9958. ).format("YYYY-MM-DD HH:mm:ss");
  9959. $scope.addData = {
  9960. taskSub: {
  9961. taskDescribe: $scope.taskDescribe,
  9962. assign: $scope.personData.data,
  9963. priority: $scope.priorityData.data,
  9964. startTime: $scope.startTime,
  9965. endTime: $scope.endTime,
  9966. taskMonth: {
  9967. id: scope.model.taskMonth.id,
  9968. },
  9969. id: scope.editData.id,
  9970. },
  9971. };
  9972. $scope.addData.taskSub["state"] = {
  9973. id: $scope.stateListData[1],
  9974. };
  9975. api_user_data
  9976. .updData("taskSub", $scope.addData)
  9977. .then(function (res) {
  9978. if (res.status == 200) {
  9979. SweetAlert.swal({
  9980. title: "修改成功!",
  9981. type: "success",
  9982. confirmButtonColor: "#007AFF",
  9983. });
  9984. scope.refreshData(scope.jry_filterdata);
  9985. $modalInstance.dismiss("cancel");
  9986. } else {
  9987. SweetAlert.swal({
  9988. title: "修改失败",
  9989. text: "系统错误,请重试!",
  9990. type: "error",
  9991. });
  9992. $modalInstance.dismiss("cancel");
  9993. }
  9994. });
  9995. } else {
  9996. SweetAlert.swal({
  9997. title: "修改失败",
  9998. text: "必填项不能为空!",
  9999. type: "error",
  10000. });
  10001. }
  10002. };
  10003. $scope.cancel = function () {
  10004. $modalInstance.dismiss("cancel");
  10005. };
  10006. },
  10007. size: "sm",
  10008. resolve: {
  10009. scope: function () {
  10010. return $scope;
  10011. },
  10012. },
  10013. backdrop: true,
  10014. });
  10015. };
  10016. // 发布
  10017. $scope.release = function (data) {
  10018. SweetAlert.swal(
  10019. {
  10020. title: "确认发布?",
  10021. text: "请确定发布操作!",
  10022. type: "warning",
  10023. showCancelButton: true,
  10024. confirmButtonColor: "#DD6B55",
  10025. confirmButtonText: "确定",
  10026. cancelButtonText: "取消",
  10027. closeOnConfirm: false,
  10028. closeOnCancel: false,
  10029. },
  10030. function (isConfirm) {
  10031. if (isConfirm) {
  10032. data.state.id = $scope.stateListData[2];
  10033. delete data.item;
  10034. api_user_data
  10035. .updData("taskSub", {
  10036. taskSub: data,
  10037. })
  10038. .then(function (res) {
  10039. if (res.status == 200) {
  10040. SweetAlert.swal({
  10041. title: "发布成功!",
  10042. type: "success",
  10043. confirmButtonColor: "#007AFF",
  10044. });
  10045. $scope.refreshData($scope.jry_filterdata);
  10046. } else {
  10047. SweetAlert.swal({
  10048. title: "删除失败",
  10049. text: "系统错误,请重试!",
  10050. type: "error",
  10051. });
  10052. }
  10053. });
  10054. } else {
  10055. SweetAlert.swal("操作取消", "发布取消", "error");
  10056. }
  10057. }
  10058. );
  10059. };
  10060. // 删除
  10061. $scope.remove = function (data) {
  10062. SweetAlert.swal(
  10063. {
  10064. title: "确认删除?",
  10065. text: "删除的数据不可恢复,请确认继续操作!",
  10066. type: "warning",
  10067. showCancelButton: true,
  10068. confirmButtonColor: "#DD6B55",
  10069. confirmButtonText: "继续删除",
  10070. cancelButtonText: "取消操作",
  10071. closeOnConfirm: false,
  10072. closeOnCancel: false,
  10073. },
  10074. function (isConfirm) {
  10075. if (isConfirm) {
  10076. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10077. if (res.status == 200) {
  10078. SweetAlert.swal({
  10079. title: "删除成功!",
  10080. type: "success",
  10081. confirmButtonColor: "#007AFF",
  10082. });
  10083. $scope.refreshData($scope.jry_filterdata);
  10084. } else {
  10085. SweetAlert.swal({
  10086. title: "删除失败",
  10087. text: "系统错误,请重试!",
  10088. type: "error",
  10089. });
  10090. }
  10091. });
  10092. } else {
  10093. SweetAlert.swal("操作取消", "数据安全", "error");
  10094. }
  10095. }
  10096. );
  10097. };
  10098. $scope.refreshData = function (filterData) {
  10099. // $scope.ldloading[style.replace('-', '_')] = true;
  10100. if (angular.isUndefined(filterData)) {
  10101. filterData = defaultFilterData;
  10102. }
  10103. $scope.myData = [];
  10104. $scope.memoryfilterData = filterData;
  10105. api_doc_data.fetchDataList("taskSub", filterData).then(
  10106. function (data) {
  10107. var myData = data;
  10108. $scope.gridOptions.totalItems = myData.totalNum;
  10109. $scope.removeFileNum = myData.totalNum;
  10110. if (angular.isArray(myData.list)) {
  10111. $scope.myData = myData.list;
  10112. for (var i = 0; i < $scope.myData.length; i++) {
  10113. //添加序号
  10114. $scope.myData[i]["item"] =
  10115. i + 1 + filterData.idx * filterData.sum;
  10116. $scope.myData[i].startTime = moment(
  10117. $scope.myData[i].startTime
  10118. ).format("YYYY-MM-DD HH:mm:ss");
  10119. $scope.myData[i].endTime = moment(
  10120. $scope.myData[i].endTime
  10121. ).format("YYYY-MM-DD HH:mm:ss");
  10122. }
  10123. }
  10124. },
  10125. function () {
  10126. // $scope.ldloading[style.replace('-', '_')] = false;
  10127. }
  10128. );
  10129. };
  10130. //分页控制
  10131. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10132. gridApi.pagination.on.paginationChanged(
  10133. $scope,
  10134. function (newPage, pageSize) {
  10135. $scope.jry_filterdata.idx = newPage - 1;
  10136. $scope.fenye = newPage - 1;
  10137. $scope.jry_filterdata.sum = pageSize;
  10138. $scope.refreshData($scope.jry_filterdata);
  10139. }
  10140. );
  10141. };
  10142. $scope.fenye = 0;
  10143. if ($scope.model.label == "分配任务") {
  10144. $scope.jry_filterdata = {
  10145. idx: $scope.fenye,
  10146. sum: 10,
  10147. taskSub: {
  10148. taskMonth: {
  10149. id: $scope.model.taskMonth.id,
  10150. },
  10151. userid: loginUser.id,
  10152. role: loginUser.role,
  10153. },
  10154. };
  10155. } else {
  10156. $scope.jry_filterdata = {
  10157. idx: $scope.fenye,
  10158. sum: 10,
  10159. taskSub: {
  10160. taskMonth: {
  10161. id: $scope.model.taskMonth.id,
  10162. },
  10163. userid: loginUser.id,
  10164. role: loginUser.role,
  10165. type: 1,
  10166. },
  10167. };
  10168. }
  10169. $scope.refreshData($scope.jry_filterdata);
  10170. //新增模态框
  10171. $scope.newDistribution = function () {
  10172. var modalInstance = $modal.open({
  10173. backdrop: false,
  10174. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10175. controller: function (
  10176. $scope,
  10177. scope,
  10178. $modalInstance,
  10179. api_doc_data,
  10180. SweetAlert,
  10181. api_user_data,
  10182. api_wechatfile
  10183. ) {
  10184. $scope.personData = {}; //指派人
  10185. $scope.priorityData = {}; //优先级
  10186. $scope.personListData = {}; //指派人下拉数据
  10187. $scope.priorityListData = {}; //优先级下拉数据
  10188. $scope.startTime = ""; //开始时间
  10189. $scope.endTime = ""; //结束时间
  10190. $scope.taskDescribe = ""; //任务描述
  10191. $scope.motaikuang = "";
  10192. $scope.shijian = "哈哈";
  10193. // 指派人下拉框数据
  10194. $scope.getPersonData = function () {
  10195. var data = {
  10196. idx: 0,
  10197. sum: 1000,
  10198. };
  10199. api_user_data.fetchDataList("user", data).then(function (res) {
  10200. $scope.personListData = res.list;
  10201. });
  10202. };
  10203. $scope.getPersonData();
  10204. //优先级下拉数据
  10205. $scope.getPriorityData = function () {
  10206. var data = {
  10207. key: "change_rick_level",
  10208. type: "list",
  10209. };
  10210. api_wechatfile.getDictionary(data).then(function (res) {
  10211. $scope.priorityListData = res;
  10212. });
  10213. };
  10214. // 控制结束时间的最大时间
  10215. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10216. // 控制结束时间的最小时间
  10217. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10218. $scope.$watch("startTime", function (n, o) {
  10219. if (n) {
  10220. if (n > scope.model.taskMonth.startTime) {
  10221. $scope.jryEndMinTime = n;
  10222. }
  10223. }
  10224. });
  10225. // 控制开始时间的最小时间
  10226. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10227. // 控制开始时间的最大时间
  10228. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10229. $scope.$watch("endTime", function (n, o) {
  10230. if (n) {
  10231. if (n < scope.model.taskMonth.endTime) {
  10232. $scope.jryStartMaxTime = n;
  10233. }
  10234. }
  10235. });
  10236. $scope.getPriorityData();
  10237. //时间控件
  10238. $scope.open = function ($event) {
  10239. $event.preventDefault();
  10240. $event.stopPropagation();
  10241. $scope.opened = !$scope.opened;
  10242. };
  10243. $scope.endOpen = function ($event) {
  10244. $event.preventDefault();
  10245. $event.stopPropagation();
  10246. $scope.startOpened = false;
  10247. $scope.endOpened = !$scope.endOpened;
  10248. };
  10249. $scope.startOpen = function ($event) {
  10250. $event.preventDefault();
  10251. $event.stopPropagation();
  10252. $scope.endOpened = false;
  10253. $scope.startOpened = !$scope.startOpened;
  10254. };
  10255. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10256. // 获取状态-lmm
  10257. $scope.stateListData = {};
  10258. $scope.getStateData = function () {
  10259. //lyl
  10260. var data = {
  10261. key: "task_sub_state",
  10262. type: "list",
  10263. };
  10264. api_wechatfile.getDictionary(data).then(function (res) {
  10265. angular.forEach(res, function (v, i) {
  10266. $scope.stateListData[v.value] = v.id;
  10267. });
  10268. });
  10269. };
  10270. $scope.getStateData();
  10271. // 草稿保存
  10272. $scope.ok = function (item) {
  10273. if (
  10274. $scope.taskDescribe &&
  10275. $scope.personData.data &&
  10276. $scope.priorityData.data &&
  10277. $scope.startTime &&
  10278. $scope.endTime
  10279. ) {
  10280. $scope.startTime = moment(
  10281. new Date($scope.startTime).getTime()
  10282. ).format("YYYY-MM-DD HH:mm:ss");
  10283. $scope.endTime = moment(
  10284. new Date($scope.endTime).getTime()
  10285. ).format("YYYY-MM-DD HH:mm:ss");
  10286. $scope.addData = {
  10287. taskSub: {
  10288. taskDescribe: $scope.taskDescribe,
  10289. assign: $scope.personData.data,
  10290. priority: $scope.priorityData.data,
  10291. startTime: $scope.startTime,
  10292. endTime: $scope.endTime,
  10293. taskMonth: {
  10294. id: scope.model.taskMonth.id,
  10295. },
  10296. },
  10297. };
  10298. $scope.addData.taskSub["state"] = {
  10299. id: $scope.stateListData[1],
  10300. };
  10301. api_user_data
  10302. .addData("taskSub", $scope.addData)
  10303. .then(function (res) {
  10304. if (res.status == 200) {
  10305. SweetAlert.swal({
  10306. title: "保存成功!",
  10307. type: "success",
  10308. confirmButtonColor: "#007AFF",
  10309. });
  10310. scope.refreshData(scope.jry_filterdata);
  10311. $modalInstance.dismiss("cancel");
  10312. } else {
  10313. SweetAlert.swal({
  10314. title: "保存失败",
  10315. text: "系统错误,请重试!",
  10316. type: "error",
  10317. });
  10318. $modalInstance.dismiss("cancel");
  10319. }
  10320. });
  10321. } else {
  10322. SweetAlert.swal({
  10323. title: "保存失败",
  10324. text: "必填项不能为空!",
  10325. type: "error",
  10326. });
  10327. }
  10328. };
  10329. // 发布
  10330. $scope.release = function () {
  10331. if (
  10332. $scope.taskDescribe &&
  10333. $scope.personData.data &&
  10334. $scope.priorityData.data &&
  10335. $scope.startTime &&
  10336. $scope.endTime
  10337. ) {
  10338. $scope.startTime = moment(
  10339. new Date($scope.startTime).getTime()
  10340. ).format("YYYY-MM-DD HH:mm:ss");
  10341. $scope.endTime = moment(
  10342. new Date($scope.endTime).getTime()
  10343. ).format("YYYY-MM-DD HH:mm:ss");
  10344. $scope.addData = {
  10345. taskSub: {
  10346. taskDescribe: $scope.taskDescribe,
  10347. assign: $scope.personData.data,
  10348. priority: $scope.priorityData.data,
  10349. startTime: $scope.startTime,
  10350. endTime: $scope.endTime,
  10351. taskMonth: {
  10352. id: scope.model.taskMonth.id,
  10353. },
  10354. },
  10355. };
  10356. $scope.addData.taskSub["state"] = {
  10357. id: $scope.stateListData[1],
  10358. };
  10359. api_user_data
  10360. .addData("taskSub", $scope.addData)
  10361. .then(function (res) {
  10362. if (res.status == 200) {
  10363. SweetAlert.swal({
  10364. title: "保存成功!",
  10365. type: "success",
  10366. confirmButtonColor: "#007AFF",
  10367. });
  10368. scope.refreshData(scope.jry_filterdata);
  10369. $modalInstance.dismiss("cancel");
  10370. } else {
  10371. SweetAlert.swal({
  10372. title: "保存失败",
  10373. text: "系统错误,请重试!",
  10374. type: "error",
  10375. });
  10376. $modalInstance.dismiss("cancel");
  10377. }
  10378. });
  10379. } else {
  10380. SweetAlert.swal({
  10381. title: "保存失败",
  10382. text: "必填项不能为空!",
  10383. type: "error",
  10384. });
  10385. }
  10386. };
  10387. $scope.cancel = function () {
  10388. $modalInstance.dismiss("cancel");
  10389. };
  10390. },
  10391. size: "sm",
  10392. resolve: {
  10393. scope: function () {
  10394. return $scope;
  10395. },
  10396. },
  10397. backdrop: true,
  10398. });
  10399. };
  10400. },
  10401. });
  10402. // 多次反馈文本域组件--jry
  10403. formlyConfigProvider.setType({
  10404. name: "ui-feedbacktTextarea",
  10405. extends: "textarea",
  10406. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10407. defaultOptions: function (options) {
  10408. return {
  10409. templateOptions: {
  10410. transform: function (model, value) {
  10411. return value;
  10412. },
  10413. },
  10414. validation: {
  10415. messages: {
  10416. maxlength: function (viewValue, modelValue, scope) {
  10417. if (viewValue != null) {
  10418. if (viewValue.length > scope.to.maxlength) {
  10419. return (
  10420. scope.to.label +
  10421. " 字数(" +
  10422. viewValue.length +
  10423. ")超限(" +
  10424. scope.to.maxlength +
  10425. ")"
  10426. );
  10427. } else {
  10428. return "";
  10429. }
  10430. }
  10431. },
  10432. },
  10433. },
  10434. };
  10435. },
  10436. controller: [
  10437. "$scope",
  10438. "moment",
  10439. function ($scope, moment) {
  10440. // console.log($scope);
  10441. var timeKey = $scope.options.templateOptions.time;
  10442. $scope.time = moment($scope.model[timeKey]).format(
  10443. "YYYY-MM-DD HH:mm:ss"
  10444. );
  10445. var value = $scope.model[$scope.options.key];
  10446. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10447. $scope.model[$scope.options.key] =
  10448. $scope.options.templateOptions.transform(
  10449. $scope.originalModel,
  10450. value
  10451. );
  10452. }
  10453. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10454. $scope.options.templateOptions.felditem($scope);
  10455. }
  10456. },
  10457. ],
  10458. });
  10459. //任务管理开始时间--jry
  10460. formlyConfigProvider.setType({
  10461. name: "ui-jryStartdatepicker",
  10462. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10463. extends: "input",
  10464. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10465. defaultOptions: {
  10466. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10467. templateOptions: {
  10468. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10469. },
  10470. },
  10471. controller: [
  10472. "$scope",
  10473. "$filter",
  10474. function ($scope, $filter) {
  10475. // console.log($scope.model[$scope.options.key],'lmm');
  10476. $scope.mindata = new Date(
  10477. $scope.options.templateOptions.transform($scope.model).getTime() +
  10478. 5 * 60 * 1000
  10479. );
  10480. if ($scope.model[$scope.options.key]) {
  10481. $scope.model[$scope.options.key] = $filter("date")(
  10482. $scope.model[$scope.options.key],
  10483. $scope.options.templateOptions.datepickerPopup
  10484. );
  10485. }
  10486. // console.log($scope.model[$scope.options.key],'lmm');
  10487. // console.log($scope.model,'lmm',$scope.options.key);
  10488. $scope.options.initialValue = $scope.model[$scope.options.key];
  10489. $scope.endOpen = true;
  10490. $scope.datepicker = {};
  10491. $scope.datepicker.opened = false;
  10492. $scope.datepicker.open = function ($event) {
  10493. $scope.datepicker.opened = true;
  10494. };
  10495. },
  10496. ],
  10497. });
  10498. //任务管理结束时间--jry
  10499. formlyConfigProvider.setType({
  10500. name: "ui-jryEnddatepicker",
  10501. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10502. extends: "input",
  10503. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10504. defaultOptions: {
  10505. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10506. templateOptions: {
  10507. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10508. },
  10509. },
  10510. controller: [
  10511. "$scope",
  10512. "$filter",
  10513. function ($scope, $filter) {
  10514. $scope.mindata = new Date(
  10515. $scope.options.templateOptions.transform($scope.model).getTime() +
  10516. 5 * 60 * 1000
  10517. );
  10518. if ($scope.model[$scope.options.key]) {
  10519. $scope.model[$scope.options.key] = $filter("date")(
  10520. $scope.model[$scope.options.key],
  10521. $scope.options.templateOptions.datepickerPopup
  10522. );
  10523. }
  10524. $scope.options.initialValue = $scope.model[$scope.options.key];
  10525. $scope.endOpen = true;
  10526. $scope.datepicker = {};
  10527. $scope.datepicker.opened = false;
  10528. $scope.datepicker.open = function ($event) {
  10529. $scope.datepicker.opened = true;
  10530. };
  10531. },
  10532. ],
  10533. });
  10534. //下拉多选框灵活组件--jry
  10535. formlyConfigProvider.setType({
  10536. name: "ui-jry_multiselectplus",
  10537. extends: "multiCheckbox",
  10538. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10539. defaultOptions: function (options) {
  10540. return {
  10541. templateOptions: {
  10542. refreshData: function (search, options, model, that) {
  10543. // var process = options.templateOptions.ApiService.all("");
  10544. if (search) {
  10545. } else {
  10546. }
  10547. var postData = options.templateOptions.optionsPostData;
  10548. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10549. postData = options.templateOptions.optionsPostData(
  10550. options,
  10551. model,
  10552. that
  10553. );
  10554. }
  10555. options.templateOptions.ApiService.fetchDataList(
  10556. options.templateOptions.optionsUrl,
  10557. options.templateOptions.optionsPostData
  10558. ).then(function (result) {
  10559. // if (!options.templateOptions.options) {
  10560. // options.templateOptions.options = [];
  10561. // }
  10562. if (options.templateOptions.optionsDataKey) {
  10563. options.templateOptions.options =
  10564. result[options.templateOptions.optionsDataKey];
  10565. } else {
  10566. options.templateOptions.options = result;
  10567. }
  10568. if (options.templateOptions.optionsChecked) {
  10569. // return options.value = null;
  10570. options.value(options.model[options.key]);
  10571. }
  10572. });
  10573. },
  10574. refreshDelay: 0,
  10575. // },
  10576. validators: {
  10577. required: {
  10578. expression: function (viewValue, modelValue) {
  10579. var value = modelValue || viewValue;
  10580. return value != null;
  10581. // return value.length>=1;
  10582. // if (modelValue && viewValue) {
  10583. // return value != null;
  10584. // } else {
  10585. // var value = modelValue || viewValue;
  10586. // return value.length > 0;
  10587. // }
  10588. },
  10589. },
  10590. },
  10591. },
  10592. };
  10593. },
  10594. controller: [
  10595. "$scope",
  10596. function ($scope) {
  10597. console.log($scope.to);
  10598. if (angular.isArray($scope.model[$scope.options.key])) {
  10599. } else {
  10600. $scope.model[$scope.options.key] = [];
  10601. }
  10602. },
  10603. ],
  10604. });
  10605. //下拉框组件
  10606. formlyConfigProvider.setType({
  10607. name: "ui-select",
  10608. extends: "select",
  10609. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10610. defaultOptions: function (options, scope) {
  10611. return {
  10612. templateOptions: {
  10613. // refresh: function() {},
  10614. getScope: function () {
  10615. return scope;
  10616. },
  10617. refreshDelay: 0,
  10618. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10619. //POST
  10620. console.log(model, "model");
  10621. angular.extend(data, {
  10622. idx: 0,
  10623. sum: 1000,
  10624. });
  10625. options.templateOptions.APIService.fetchDataList(
  10626. modelName,
  10627. data
  10628. ).then(function (response) {
  10629. var myData =
  10630. options.templateOptions.Restangular.stripRestangular(response);
  10631. var list = myData.list;
  10632. console.log(myData);
  10633. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10634. // console.log('balabalabala');
  10635. // console.log(res);
  10636. // })
  10637. if (list.length == 1) {
  10638. if (options.templateOptions.APIport) {
  10639. options.templateOptions.APIport.expectedTime(
  10640. "L" + list[0][key].id
  10641. ).then(function (response) {
  10642. if (response.state == "200") {
  10643. // if (model.$parent.model && model.$parent.model.incident) {
  10644. // } else {
  10645. // model.$parent.model = { 'incident': {} };
  10646. // }
  10647. var myDatas = response.serviceLevelAgreement;
  10648. //逾期
  10649. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10650. response.date;
  10651. //解决
  10652. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10653. myDatas.resolveTime;
  10654. //响应
  10655. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10656. myDatas.responseTime;
  10657. } else {
  10658. }
  10659. });
  10660. }
  10661. angular.forEach(model.fields, function (item) {
  10662. angular.forEach(model.fields, function (item) {
  10663. if (item.templateOptions.pkey == modelKey + "." + key) {
  10664. item.model.id = "";
  10665. if (key == "place") {
  10666. item.templateOptions.options = list;
  10667. } else if (key == "placeDTO") {
  10668. item.templateOptions.options = list;
  10669. } else if (key == "requester") {
  10670. } else {
  10671. item.value(list[0][key][item.key]);
  10672. }
  10673. }
  10674. });
  10675. });
  10676. } else {
  10677. if (model.fields) {
  10678. angular.forEach(model.fields, function (item) {
  10679. angular.forEach(model.fields, function (item) {
  10680. if (item.templateOptions.pkey == modelKey + "." + key) {
  10681. item.model.id = "";
  10682. if (key == "place") {
  10683. item.templateOptions.isnosearch = true;
  10684. item.templateOptions.options = list;
  10685. }
  10686. if (key == "placeDTO") {
  10687. item.templateOptions.options = list;
  10688. }
  10689. if (key == "requester") {
  10690. }
  10691. }
  10692. });
  10693. });
  10694. } else {
  10695. angular.forEach(
  10696. scope.$parent.$parent.$parent.fields,
  10697. function (item) {
  10698. angular.forEach(
  10699. scope.$parent.$parent.$parent.fields,
  10700. function (item) {
  10701. if (
  10702. item.templateOptions.pkey ==
  10703. modelKey + "." + key
  10704. ) {
  10705. if (key == "place") {
  10706. item.templateOptions.isnosearch = true;
  10707. item.templateOptions.options = list;
  10708. scope.$parent.$parent.$parent.model.incident.place =
  10709. model.incident.place;
  10710. }
  10711. if (key == "placeDTO") {
  10712. item.templateOptions.options = list;
  10713. }
  10714. if (key == "requester") {
  10715. }
  10716. }
  10717. }
  10718. );
  10719. }
  10720. );
  10721. }
  10722. }
  10723. console.log(key);
  10724. //报修科室
  10725. if (key == "dept") {
  10726. // 报修科室单选
  10727. scope.$parent.$parent.$parent.model.incident.department =
  10728. response.list[0];
  10729. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10730. response.list[0].phone;
  10731. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10732. // 选择重复事件侧滑框
  10733. scope.$parent.$parent.$parent.model[
  10734. "repeatIncidentShow"
  10735. ] = false;
  10736. setTimeout(() => {
  10737. scope.$parent.$parent.$parent.model[
  10738. "repeatIncidentShow"
  10739. ] = true;
  10740. }, 500);
  10741. }
  10742. // 报修人
  10743. if (key == "requester") {
  10744. // 报修人单选
  10745. scope.$parent.$parent.$parent.model.incident.requester =
  10746. response.list[0];
  10747. console.log(scope.$parent.$parent.$parent.model);
  10748. scope.$parent.$parent.$parent.model.incident.account =
  10749. response.list[0].account;
  10750. var selectedItem = response.list[0];
  10751. var data = {
  10752. requester: selectedItem,
  10753. };
  10754. scope.$parent.$parent.$parent.model["requestershow"] =
  10755. selectedItem;
  10756. console.log(selectedItem, "----------------------");
  10757. // if (selectedItem.dept.place.place) {
  10758. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10759. // }
  10760. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10761. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10762. scope.$parent.$parent.$parent.model.incident.area.id =
  10763. selectedItem.place ? selectedItem.place.area.id : null;
  10764. scope.$parent.$parent.$parent.model.incident.place.id =
  10765. selectedItem.place ? selectedItem.place.id : null;
  10766. console.log(scope, 89898998);
  10767. // console.log(scope.formData,'接单页面');
  10768. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10769. scope.model.selecthouseNumber = selectedItem.place
  10770. ? selectedItem.place
  10771. : {};
  10772. scope.$root.selecthouseNumber = selectedItem.place
  10773. ? selectedItem.place
  10774. : {};
  10775. // options.templateOptions.ApiService.addData(
  10776. // "requester",
  10777. // data
  10778. // ).then(function (response) {
  10779. // if (response.status == 200) {
  10780. if (scope.$parent.$parent.$parent) {
  10781. if (scope.$parent.$parent.$parent.place) {
  10782. scope.$parent.$parent.$parent.place.id = "";
  10783. }
  10784. if (scope.$parent.$parent.$parent.area) {
  10785. scope.$parent.$parent.$parent.area.id = "";
  10786. }
  10787. scope.$parent.$parent.$parent.model.incident.contacts =
  10788. selectedItem.name;
  10789. if (
  10790. selectedItem.mphone &&
  10791. selectedItem.mphone != null &&
  10792. selectedItem.mphone != ""
  10793. ) {
  10794. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10795. selectedItem.mphone;
  10796. } else {
  10797. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10798. selectedItem.telephone;
  10799. }
  10800. if (
  10801. selectedItem.requesterTypeDTO &&
  10802. selectedItem.requesterTypeDTO.id == 2
  10803. ) {
  10804. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10805. }
  10806. }
  10807. // if (!response.data.id) {
  10808. // response.data.id = selectedItem.id;
  10809. // }
  10810. console.log(scope);
  10811. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10812. // if (selectedItem.place && selectedItem.place.id) {
  10813. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10814. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10815. // };
  10816. // } else {
  10817. // if (selectedItem.place && selectedItem.place.id) {
  10818. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10819. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10820. // };
  10821. // }
  10822. // if(scope.$parent.$parent.$parent.model.incident.area){
  10823. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10824. // }
  10825. if (selectedItem.id) {
  10826. scope.$parent.$parent.$parent.model.incident.account =
  10827. selectedItem.account;
  10828. }
  10829. // 选择重复事件侧滑框
  10830. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10831. scope.$parent.$parent.$parent.model[
  10832. "repeatIncidentShow"
  10833. ] = false;
  10834. setTimeout(() => {
  10835. scope.$parent.$parent.$parent.model[
  10836. "repeatIncidentShow"
  10837. ] = true;
  10838. }, 500);
  10839. // }
  10840. // }
  10841. // });
  10842. }
  10843. //新建事件,选择派单,选择工作组查找处理人baba
  10844. if (key == "handlerUser") {
  10845. model.fields.forEach(function (v) {
  10846. if (v.templateOptions.pkey == "incident.handlerUser") {
  10847. v.templateOptions.options = list;
  10848. if (model.model.incident.handlerUser) {
  10849. if (model.model.incident.handlerUser.id) {
  10850. var flag = list.some(function (v) {
  10851. return v.id == model.model.incident.handlerUser.id;
  10852. });
  10853. if (flag) {
  10854. v.model.id = model.model.incident.handlerUser.id;
  10855. }
  10856. }
  10857. }
  10858. }
  10859. });
  10860. }
  10861. });
  10862. },
  10863. validators: {
  10864. required: {
  10865. expression: function (viewValue, modelValue) {
  10866. var value = modelValue || viewValue;
  10867. return value != null;
  10868. // return value.length>=1;
  10869. // if (modelValue && viewValue) {
  10870. // return value != null;
  10871. // } else {
  10872. // var value = modelValue || viewValue;
  10873. // return value.length > 0;
  10874. // }
  10875. },
  10876. },
  10877. },
  10878. },
  10879. controller: [
  10880. "$scope",
  10881. "$rootScope",
  10882. "api_bpm_domain",
  10883. "$stateParams",
  10884. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10885. // $scope.myFilter = function(item) {
  10886. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10887. // }
  10888. console.log($scope, "风浪");
  10889. //工作组添加全部选项
  10890. // if($scope.options.templateOptions.label == '工作组'){
  10891. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10892. // $scope.model._group = 0;
  10893. // }
  10894. if (
  10895. $scope.options.templateOptions.pkey &&
  10896. $scope.options.templateOptions.pkey == "incident.place"
  10897. ) {
  10898. if (
  10899. $scope.$parent &&
  10900. $scope.$parent.$parent.$parent.model &&
  10901. $scope.$parent.$parent.$parent.model.incident.area &&
  10902. $scope.$parent.$parent.$parent.model.incident.area.id
  10903. ) {
  10904. $scope.options.templateOptions.linkage(
  10905. "place",
  10906. {
  10907. place: {
  10908. areaId:
  10909. $scope.$parent.$parent.$parent.model.incident.area.id,
  10910. // area:{
  10911. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  10912. // }
  10913. },
  10914. },
  10915. $scope.$parent.$parent.$parent.model,
  10916. "incident",
  10917. "place"
  10918. );
  10919. }
  10920. }
  10921. $scope.myFilter = $scope;
  10922. // console.log($scope.options.templateOptions)
  10923. console.log($scope, 77777);
  10924. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  10925. var paramsModel = JSON.parse($stateParams.model)
  10926. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  10927. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  10928. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  10929. }
  10930. }
  10931. //处理人根据事件分类自动带入baba
  10932. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  10933. console.log($scope.options.templateOptions.pkey);
  10934. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  10935. if (
  10936. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  10937. ) {
  10938. $scope.$parent.$parent.$parent.model.assignee =
  10939. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10940. $scope.options.model.id =
  10941. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10942. }
  10943. }
  10944. }
  10945. // 关闭事件页面满意度评价下拉框处理
  10946. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  10947. $scope.model.id =
  10948. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  10949. }
  10950. if ($scope.options.templateOptions.initData == 1) {
  10951. $scope.options.templateOptions.onChange(
  10952. $scope.model.id,
  10953. $scope.options,
  10954. $scope
  10955. );
  10956. }
  10957. if ($scope.options.templateOptions.transform) {
  10958. $scope.options.templateOptions.onChange(
  10959. $scope.model.id,
  10960. $scope.options,
  10961. $scope
  10962. );
  10963. }
  10964. if (angular.isFunction($scope.options.templateOptions.translate)) {
  10965. $scope.model[$scope.options.key] =
  10966. $scope.options.templateOptions.translate(
  10967. $scope.options,
  10968. $rootScope,
  10969. $scope
  10970. );
  10971. }
  10972. if (
  10973. angular.isFunction($scope.options.templateOptions.translatefunc)
  10974. ) {
  10975. $scope.model[$scope.options.key] =
  10976. $scope.options.templateOptions.translatefunc(
  10977. $scope.options,
  10978. $rootScope,
  10979. $scope
  10980. );
  10981. }
  10982. if (
  10983. angular.isFunction($scope.options.templateOptions.onlyfunction)
  10984. ) {
  10985. $scope.options.templateOptions.onlyfunction(
  10986. $scope.options,
  10987. $rootScope,
  10988. $scope
  10989. );
  10990. }
  10991. },
  10992. ],
  10993. };
  10994. },
  10995. });
  10996. //下拉多选框组件
  10997. formlyConfigProvider.setType({
  10998. name: "ui-multiselect",
  10999. extends: "select",
  11000. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11001. defaultOptions: function (options) {
  11002. return {
  11003. templateOptions: {
  11004. refresh: function () { },
  11005. refreshDelay: 1000,
  11006. },
  11007. };
  11008. },
  11009. controller: [
  11010. "$scope",
  11011. function ($scope) {
  11012. $scope.model[$scope.options.key] = [];
  11013. },
  11014. ],
  11015. });
  11016. //下拉多选框灵活组件
  11017. formlyConfigProvider.setType({
  11018. name: "ui-multiselectplus",
  11019. extends: "multiCheckbox",
  11020. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11021. defaultOptions: function (options, $scope) {
  11022. return {
  11023. templateOptions: {
  11024. refreshData: function (search, options, model, that) {
  11025. console.log(search, options, model, that)
  11026. var process = options.templateOptions.ApiService.all("");
  11027. if (search) {
  11028. } else {
  11029. }
  11030. var postData = options.templateOptions.optionsPostData;
  11031. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11032. postData = options.templateOptions.optionsPostData(
  11033. options,
  11034. model,
  11035. that
  11036. );
  11037. }
  11038. if (options.templateOptions.modelreasondata) {
  11039. postData = options.templateOptions.modelreasondata;
  11040. }
  11041. process
  11042. .customPOST(postData, options.templateOptions.optionsUrl)
  11043. .then(function (result) {
  11044. // if (!options.templateOptions.options) {
  11045. // options.templateOptions.options = [];
  11046. // }
  11047. // 过滤下拉列表已选择的值
  11048. var modelVal = $scope.model[$scope.options.key];
  11049. var ides = [];
  11050. var rList = result.list || result;
  11051. if ($scope.options.key == "serviceTypeIds") {
  11052. modelVal = modelVal.map(function (v) {
  11053. if (typeof v !== 'object') {
  11054. return { id: v };
  11055. } else {
  11056. return v;
  11057. }
  11058. })
  11059. }
  11060. for (var i = 0; i < modelVal.length; i++) {
  11061. for (var j = 0; j < rList.length; j++) {
  11062. if (rList[j].id == modelVal[i].id) {
  11063. ides.push(rList[j].id);
  11064. }
  11065. }
  11066. }
  11067. ides.forEach(function (v1) {
  11068. rList.forEach(function (v2) {
  11069. if (v1 == v2.id) {
  11070. rList = rList.filter(v => v.id != v2.id);
  11071. }
  11072. })
  11073. })
  11074. options.templateOptions.options = rList;
  11075. // if (options.templateOptions.optionsDataKey) {
  11076. // options.templateOptions.options =
  11077. // result[options.templateOptions.optionsDataKey];
  11078. // } else {
  11079. // options.templateOptions.options = result;
  11080. // }
  11081. if (options.templateOptions.optionsChecked) {
  11082. // return options.value = null;
  11083. options.value(options.model[options.key]);
  11084. }
  11085. });
  11086. },
  11087. refreshDelay: 0,
  11088. // },
  11089. // validators: {
  11090. // required: {
  11091. // expression: function(viewValue, modelValue) {
  11092. // var value = modelValue || viewValue;
  11093. // // return value.length>=1;
  11094. // // if (modelValue && viewValue) {
  11095. // // return value != null;
  11096. // // } else {
  11097. // // var value = modelValue || viewValue;
  11098. // // return value.length > 0;
  11099. // // }
  11100. // }
  11101. // }
  11102. },
  11103. };
  11104. },
  11105. controller: [
  11106. "$scope",
  11107. function ($scope) {
  11108. if (angular.isArray($scope.model[$scope.options.key])) {
  11109. } else {
  11110. $scope.model[$scope.options.key] = [];
  11111. }
  11112. },
  11113. ],
  11114. });
  11115. //下拉树形多选组件
  11116. formlyConfigProvider.setType({
  11117. name: "ui-multiselect-tree",
  11118. extends: "multiCheckbox",
  11119. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11120. defaultOptions: function (options) {
  11121. return {
  11122. templateOptions: {
  11123. linkage: function (modelName, data, model, modelKey, key) {
  11124. angular.extend(data, {
  11125. idx: 0,
  11126. sum: 10,
  11127. });
  11128. options.templateOptions.APIService.fetchDataList(
  11129. modelName,
  11130. data
  11131. ).then(function (response) {
  11132. var myData =
  11133. options.templateOptions.Restangular.stripRestangular(response);
  11134. var list = myData.list;
  11135. if (list.length == 1) {
  11136. angular.forEach(model.fields, function (item) {
  11137. angular.forEach(model.fields, function (item) {
  11138. if (item.templateOptions.pkey == modelKey + "." + key) {
  11139. item.model.id = "";
  11140. if (key == "place") {
  11141. item.templateOptions.options = list;
  11142. } else {
  11143. item.value(list[0][key][item.key]);
  11144. }
  11145. }
  11146. });
  11147. });
  11148. }
  11149. });
  11150. },
  11151. // my_tree_handler : function(items) {
  11152. // },
  11153. // onFilterCallback : function(items) {
  11154. // },
  11155. // onFilterCallback : function(items) {
  11156. // },
  11157. refresh: function (items) {
  11158. var treedata = [];
  11159. function convertListToTree(data, treeMap) {
  11160. treedata = data;
  11161. for (var i = 0; i < data.length; i++) {
  11162. for (var j = 0; j < data.length; j++) {
  11163. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11164. if (data[i].pid == data[j].id) {
  11165. data[i].parent = data[j];
  11166. }
  11167. }
  11168. }
  11169. }
  11170. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11171. var root = null; //Initially set our loop to null
  11172. //loop over data
  11173. for (var i = 0; i < data.length; i++) {
  11174. var datum = data[i];
  11175. //each node will have children, so let's give it a "children" poperty
  11176. datum.children = [];
  11177. //add an entry for this node to the map so that any future children can
  11178. //lookup the parent
  11179. idToNodeMap[datum.id] = datum;
  11180. //Does this node have a parent?
  11181. if (
  11182. typeof datum.parent === "undefined" ||
  11183. datum.parent === null
  11184. ) {
  11185. //Doesn't look like it, so this node is the root of the tree
  11186. root = datum;
  11187. treeMap[datum.id] = root;
  11188. } else {
  11189. //This node has a parent, so let's look it up using the id
  11190. parentNode = idToNodeMap[datum.parent.id];
  11191. //We don't need this property, so let's delete it.
  11192. delete datum.parent;
  11193. //Let's add the current node as a child of the parent node.
  11194. parentNode.children.push(datum);
  11195. }
  11196. }
  11197. return root;
  11198. }
  11199. function convertParentToChildList(data) {
  11200. // console.log("data="+JSON.stringify(data))
  11201. var treeMap = {};
  11202. var list = [];
  11203. convertListToTree(data, treeMap);
  11204. angular.forEach(treeMap, function (item) {
  11205. list.push(item);
  11206. });
  11207. return list;
  11208. }
  11209. function selectItem(pmodel, childrens) {
  11210. if (angular.isArray(pmodel)) {
  11211. angular.forEach(pmodel, function (index) {
  11212. if (index && index.id) {
  11213. angular.forEach(childrens, function (item) {
  11214. if (item.id == index.id) {
  11215. item.selected = true;
  11216. }
  11217. if (item && item.children) {
  11218. selectItem(pmodel, item.children);
  11219. }
  11220. });
  11221. }
  11222. });
  11223. } else {
  11224. if (pmodel && pmodel.id) {
  11225. angular.forEach(childrens, function (item) {
  11226. if (item.id == pmodel.id) {
  11227. item.selected = true;
  11228. }
  11229. if (item && item.children) {
  11230. selectItem(pmodel, item.children);
  11231. }
  11232. });
  11233. }
  11234. }
  11235. }
  11236. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11237. options.templateOptions
  11238. .refreshData(options.templateOptions.APIService)
  11239. .then(function (result) {
  11240. if (result.status == 200) {
  11241. if (!options.templateOptions.options) {
  11242. options.templateOptions.options = [];
  11243. }
  11244. if (options.templateOptions.optionsDataKey) {
  11245. options.templateOptions.options = convertParentToChildList(
  11246. result[options.templateOptions.optionsDataKey]
  11247. );
  11248. } else {
  11249. options.templateOptions.options =
  11250. convertParentToChildList(result);
  11251. }
  11252. //set default value
  11253. var pmodel,
  11254. i = 0;
  11255. if (options.templateOptions.pkey) {
  11256. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11257. angular.forEach(
  11258. options.templateOptions.pkey.split("."),
  11259. function (p) {
  11260. if (i == 0) {
  11261. if (options.model[p] == null) {
  11262. options.model[p] = {};
  11263. }
  11264. pmodel = options.model[p];
  11265. i++;
  11266. } else {
  11267. if (pmodel[p] == null) {
  11268. pmodel[p] = {};
  11269. }
  11270. pmodel = pmodel[p];
  11271. }
  11272. }
  11273. );
  11274. } else {
  11275. pmodel = options.model;
  11276. }
  11277. }
  11278. if (pmodel) {
  11279. pmodel = pmodel[options.key];
  11280. } else if (options.model) {
  11281. pmodel = options.model[options.key];
  11282. } else {
  11283. pmodel = options.templateOptions.options;
  11284. }
  11285. if (angular.isArray(pmodel)) {
  11286. if (pmodel) {
  11287. // if(options.templateOptions.isMultiSelect==true){
  11288. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11289. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11290. // })
  11291. // }else{
  11292. selectItem(pmodel, options.templateOptions.options);
  11293. // }
  11294. }
  11295. } else {
  11296. if (pmodel && pmodel.id) {
  11297. selectItem(pmodel, options.templateOptions.options);
  11298. }
  11299. }
  11300. items.inputModel = options.templateOptions.options;
  11301. }
  11302. });
  11303. },
  11304. },
  11305. validators: {
  11306. required: {
  11307. expression: function (viewValue, modelValue) {
  11308. var value = modelValue || viewValue;
  11309. if (angular.isArray(value)) {
  11310. for (var i = 0; i < value.length; i++) {
  11311. value[i] = {
  11312. id: value[i].id,
  11313. };
  11314. }
  11315. return value.length > 0;
  11316. } else {
  11317. // console.log(options)
  11318. // return value = "true";
  11319. return value != null;
  11320. }
  11321. },
  11322. },
  11323. },
  11324. };
  11325. },
  11326. controller: [
  11327. "$scope",
  11328. "api_configure_form",
  11329. function ($scope, api_configure_form) {
  11330. if ($scope.options.templateOptions.isMultiSelect) {
  11331. // console.log($scope);
  11332. } else {
  11333. if ($scope.model[$scope.options.key]) {
  11334. }
  11335. }
  11336. },
  11337. ],
  11338. });
  11339. //多选下拉框组件
  11340. formlyConfigProvider.setType({
  11341. name: "ui-multi-select-tree",
  11342. extends: "input",
  11343. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11344. defaultOptions: function (options) {
  11345. return {
  11346. templateOptions: {
  11347. linkage: function (modelName, data, model, modelKey, key) {
  11348. angular.extend(data, {
  11349. idx: 0,
  11350. sum: 10,
  11351. });
  11352. options.templateOptions.APIService.fetchDataList(
  11353. modelName,
  11354. data
  11355. ).then(function (response) {
  11356. var myData =
  11357. options.templateOptions.Restangular.stripRestangular(response);
  11358. var list = myData.list;
  11359. if (list.length == 1) {
  11360. angular.forEach(model.fields, function (item) {
  11361. angular.forEach(model.fields, function (item) {
  11362. if (item.templateOptions.pkey == modelKey + "." + key) {
  11363. item.model.id = "";
  11364. if (key == "place") {
  11365. item.templateOptions.options = list;
  11366. } else {
  11367. item.value(list[0][key][item.key]);
  11368. }
  11369. }
  11370. });
  11371. });
  11372. }
  11373. });
  11374. },
  11375. getparentdata: function (items) {
  11376. // console.log(items)
  11377. },
  11378. refresh: function (items, search, fn) {
  11379. console.log(items, options);
  11380. var treedata = [];
  11381. function convertListToTree(data, treeMap) {
  11382. // console.log(data)
  11383. treedata = data;
  11384. for (var i = 0; i < data.length; i++) {
  11385. for (var j = 0; j < data.length; j++) {
  11386. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11387. if (data[i].pid == data[j].id) {
  11388. data[i].parent = data[j];
  11389. }
  11390. }
  11391. // if (data[i].id) {
  11392. // if (data[i].id== data[j].id) {
  11393. // data[i].parent = data[j];
  11394. // }
  11395. // }
  11396. }
  11397. }
  11398. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11399. var root = []; //Initially set our loop to null
  11400. if (search == "search" && items.filterKeyword) {
  11401. function transform(nodes) {
  11402. var treeConverter = {
  11403. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11404. attributeName: "id", //节点唯一标识符
  11405. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11406. transform: function (node) {
  11407. //转化递归函数,参数:一个待插入节点
  11408. if (node.parent != null) {
  11409. //该节点有父节点
  11410. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11411. if (this.needFind) {
  11412. for (var i = 0; i < newNode.children.length; i++) {
  11413. //查找要插入的node子节点是否在newNode这个父节点中存在
  11414. if (
  11415. newNode.children[i][this.attributeName] ===
  11416. node[this.attributeName]
  11417. ) {
  11418. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11419. }
  11420. }
  11421. }
  11422. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11423. // delete node.parent; //删除该节点的parent属性,如果有的话
  11424. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11425. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11426. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11427. } else if (node.parent == null) {
  11428. //该叶节点没有父节点,即为根节点
  11429. // delete node.parent; //删除该节点的parent属性,如果有的话
  11430. if (this.result == null) {
  11431. //根节点不存在
  11432. node.children = []; //给该节点增加children:[]属性
  11433. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11434. } else {
  11435. node.children = [];
  11436. // 顶级去重
  11437. for (
  11438. var i = 0;
  11439. i < this.result.children.length;
  11440. i++
  11441. ) {
  11442. if (
  11443. this.result.children[i][this.attributeName] ===
  11444. node[this.attributeName]
  11445. ) {
  11446. return this.result.children[i];
  11447. }
  11448. }
  11449. this.result.children.push(node);
  11450. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11451. }
  11452. }
  11453. },
  11454. getWhole: function (nodes, attributeName) {
  11455. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11456. var _node = {};
  11457. _node.children = [];
  11458. this.result = _node; //重置根节点
  11459. this.attributeName =
  11460. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11461. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11462. nodes.forEach((item) => {
  11463. //循环调用转化方法
  11464. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11465. this.transform(item);
  11466. });
  11467. return this.result; //返回根节点
  11468. },
  11469. };
  11470. var result = treeConverter.getWhole(nodes); //调用
  11471. return result;
  11472. }
  11473. var li = transform(data).children;
  11474. // li=[...new Set(li)]
  11475. console.log(li);
  11476. treeMap = li;
  11477. fn(li);
  11478. return li;
  11479. } else {
  11480. //loop over data
  11481. for (var i = 0; i < data.length; i++) {
  11482. var datum = data[i];
  11483. //each node will have children, so let's give it a "children" poperty
  11484. datum.children = [];
  11485. //add an entry for this node to the map so that any future children can
  11486. //lookup the parent
  11487. idToNodeMap[datum.id] = datum;
  11488. //Does this node have a parent?
  11489. if (
  11490. typeof datum.parent === "undefined" ||
  11491. datum.parent === null
  11492. ) {
  11493. //Doesn't look like it, so this node is the root of the tree
  11494. root = datum;
  11495. treeMap[datum.id] = root;
  11496. } else {
  11497. //This node has a parent, so let's look it up using the id
  11498. parentNode = idToNodeMap[datum.parent.id];
  11499. //We don't need this property, so let's delete it.
  11500. // delete datum.parent;
  11501. //Let's add the current node as a child of the parent node.
  11502. parentNode.children.push(datum);
  11503. }
  11504. }
  11505. }
  11506. return root;
  11507. }
  11508. function convertParentToChildList(data) {
  11509. var treeMap = {};
  11510. var list = [];
  11511. if (search == "search" && items.filterKeyword) {
  11512. var lis = convertListToTree(data, treeMap);
  11513. return lis;
  11514. } else {
  11515. if (data[0] && data[0].orders) {
  11516. list = data;
  11517. } else {
  11518. convertListToTree(data, treeMap);
  11519. angular.forEach(treeMap, function (item) {
  11520. // console.log("item="+JSON.stringify(item))
  11521. list.push(item);
  11522. });
  11523. }
  11524. return list;
  11525. }
  11526. }
  11527. function selectItem(pmodel, childrens) {
  11528. if (angular.isArray(pmodel)) {
  11529. angular.forEach(pmodel, function (index) {
  11530. if (index && index.id) {
  11531. angular.forEach(childrens, function (item) {
  11532. if (item.id == index.id) {
  11533. item.selected = true;
  11534. }
  11535. if (item && item.children) {
  11536. selectItem(pmodel, item.children);
  11537. }
  11538. });
  11539. // angular.forEach(treedata,function(parentdata){
  11540. // if(parentdata.id == index.id){
  11541. // if(parentdata.parent&&parentdata.parent.id){
  11542. // parentdata.parent.$
  11543. // }
  11544. // item.selected = true;
  11545. // }
  11546. // if (item && item.children) {
  11547. // selectItem(pmodel ,item.children);
  11548. // }
  11549. // });
  11550. }
  11551. });
  11552. } else {
  11553. if (pmodel && pmodel.id) {
  11554. angular.forEach(childrens, function (item, index) {
  11555. if (item.id == pmodel.id) {
  11556. item.selected = true;
  11557. // delete item.children;
  11558. }
  11559. if (item && item.children) {
  11560. selectItem(pmodel, item.children);
  11561. }
  11562. });
  11563. }
  11564. }
  11565. }
  11566. function selectItemchild(pmodel, childrens) {
  11567. if (angular.isArray(pmodel)) {
  11568. angular.forEach(pmodel, function (index) {
  11569. if (index && index.id) {
  11570. angular.forEach(childrens, function (item) {
  11571. if (item.id == index.id) {
  11572. item.selected = true;
  11573. }
  11574. if (item && item.children) {
  11575. selectItem(pmodel, item.children);
  11576. }
  11577. });
  11578. }
  11579. });
  11580. } else {
  11581. if (pmodel && pmodel.id) {
  11582. angular.forEach(childrens, function (item, index) {
  11583. if (item.id == pmodel.id) {
  11584. item.selected = true;
  11585. childrens[index].selected = true;
  11586. }
  11587. if (item && item.children) {
  11588. selectItem(pmodel, item.children);
  11589. }
  11590. });
  11591. }
  11592. }
  11593. }
  11594. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11595. if (search === "search" && items.filterKeyword) {
  11596. // bala:树形模糊搜索
  11597. options.templateOptions
  11598. .bala(options.templateOptions.APIService, items.filterKeyword)
  11599. .then(function (result) {
  11600. result.list = [...new Set(result.list)]; //去重
  11601. if (!options.templateOptions.options) {
  11602. options.templateOptions.options = [];
  11603. }
  11604. if (options.templateOptions.optionsDataKey) {
  11605. options.templateOptions.options = convertParentToChildList(
  11606. result[options.templateOptions.optionsDataKey]
  11607. );
  11608. } else {
  11609. options.templateOptions.options =
  11610. convertParentToChildList(result);
  11611. }
  11612. //set default value
  11613. var pmodel,
  11614. i = 0;
  11615. if (
  11616. options.templateOptions.pkey ||
  11617. options.templateOptions.pkey != ""
  11618. ) {
  11619. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11620. angular.forEach(
  11621. options.templateOptions.pkey.split("."),
  11622. function (p) {
  11623. if (i == 0) {
  11624. if (options.model[p] == null) {
  11625. options.model[p] = {};
  11626. }
  11627. pmodel = options.model[p];
  11628. i++;
  11629. } else {
  11630. if (pmodel[p] == null) {
  11631. pmodel[p] = {};
  11632. }
  11633. pmodel = pmodel[p];
  11634. }
  11635. }
  11636. );
  11637. } else {
  11638. pmodel = options.model;
  11639. }
  11640. }
  11641. var topdata = angular.copy(options.templateOptions.options);
  11642. if (pmodel) {
  11643. pmodel = pmodel[options.key];
  11644. } else if (options.model) {
  11645. pmodel = options.model[options.key];
  11646. }
  11647. if (angular.isArray(pmodel)) {
  11648. if (pmodel) {
  11649. items.inputModel = angular.copy(
  11650. options.templateOptions.options
  11651. );
  11652. selectItem(pmodel, options.templateOptions.options);
  11653. }
  11654. } else {
  11655. if (pmodel && pmodel.id) {
  11656. items.inputModel = angular.copy(
  11657. options.templateOptions.options
  11658. );
  11659. selectItem(pmodel, options.templateOptions.options);
  11660. } else {
  11661. // items.inputModel = options.templateOptions.options;
  11662. }
  11663. }
  11664. // items.inputModel = options.templateOptions.options;
  11665. items.selectModel = options.templateOptions.options;
  11666. // 可在此展开
  11667. if (!items.inputModel) {
  11668. items.inputModel = items.selectModel;
  11669. } else {
  11670. selectItemchild(pmodel, items.inputModel);
  11671. // for (var i = 0; i < items.inputModel.length; i++) {
  11672. // items.inputModel[i].
  11673. // for (var j = 0; j < items.selectModel.length; j++) {
  11674. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11675. // items.inputModel[i].selected = true;
  11676. // }
  11677. // }
  11678. // }
  11679. }
  11680. return items.inputModel;
  11681. // options.templateOptions.options = angular.copy(topdata);
  11682. // console.log(model);
  11683. // console.log(options);
  11684. });
  11685. } else {
  11686. options.templateOptions
  11687. .refreshData(options.templateOptions.APIService)
  11688. .then(function (result) {
  11689. //回显事件分类,带出绑定的人或组start caocao
  11690. if (items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  11691. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  11692. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  11693. return v.id == items.$parent.originalModel.incident.category.id;
  11694. })
  11695. console.log(item)//11615
  11696. if (item) {
  11697. if (item.userOrGroupType === 1) {
  11698. items.$parent.originalModel.start_code = 'assignment';
  11699. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  11700. items.$parent.originalModel.directClose = true;
  11701. items.$parent.originalModel.isHandlerUser = false;
  11702. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  11703. } else if (item.userOrGroupType === 2) {
  11704. items.$parent.originalModel.start_code = 'assignment';
  11705. items.$parent.originalModel.candidateGroups = item.group;
  11706. items.$parent.originalModel.directClose = true;
  11707. items.$parent.originalModel.isHandlerUser = false;
  11708. } else {
  11709. items.$parent.originalModel.start_code = 'close';
  11710. items.$parent.originalModel.directClose = false;
  11711. items.$parent.originalModel.isHandlerUser = false;
  11712. delete items.$parent.originalModel.candidateGroups;
  11713. delete items.$parent.originalModel.incident.handlerUser
  11714. }
  11715. }
  11716. }
  11717. //回显事件分类,带出绑定的人或组end
  11718. if (!options.templateOptions.options) {
  11719. options.templateOptions.options = [];
  11720. }
  11721. if (options.templateOptions.optionsDataKey) {
  11722. options.templateOptions.options = convertParentToChildList(
  11723. result[options.templateOptions.optionsDataKey]
  11724. );
  11725. } else {
  11726. options.templateOptions.options =
  11727. convertParentToChildList(result);
  11728. }
  11729. //set default value
  11730. var pmodel,
  11731. i = 0;
  11732. if (
  11733. options.templateOptions.pkey ||
  11734. options.templateOptions.pkey != ""
  11735. ) {
  11736. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11737. angular.forEach(
  11738. options.templateOptions.pkey.split("."),
  11739. function (p) {
  11740. if (i == 0) {
  11741. if (options.model[p] == null) {
  11742. options.model[p] = {};
  11743. }
  11744. pmodel = options.model[p];
  11745. i++;
  11746. } else {
  11747. if (pmodel[p] == null) {
  11748. pmodel[p] = {};
  11749. }
  11750. pmodel = pmodel[p];
  11751. }
  11752. }
  11753. );
  11754. } else {
  11755. pmodel = options.model;
  11756. }
  11757. }
  11758. var topdata = angular.copy(options.templateOptions.options);
  11759. if (pmodel) {
  11760. pmodel = pmodel[options.key];
  11761. } else if (options.model) {
  11762. pmodel = options.model[options.key];
  11763. }
  11764. if (angular.isArray(pmodel)) {
  11765. if (pmodel) {
  11766. items.inputModel = angular.copy(
  11767. options.templateOptions.options
  11768. );
  11769. selectItem(pmodel, options.templateOptions.options);
  11770. }
  11771. } else {
  11772. if (pmodel && pmodel.id) {
  11773. items.inputModel = angular.copy(
  11774. options.templateOptions.options
  11775. );
  11776. selectItem(pmodel, options.templateOptions.options);//baba
  11777. } else {
  11778. // items.inputModel = options.templateOptions.options;
  11779. }
  11780. }
  11781. // items.inputModel = options.templateOptions.options;
  11782. items.selectModel = options.templateOptions.options;
  11783. if (!items.inputModel) {
  11784. items.inputModel = items.selectModel;
  11785. } else {
  11786. selectItemchild(pmodel, items.inputModel);
  11787. // for (var i = 0; i < items.inputModel.length; i++) {
  11788. // for (var j = 0; j < items.selectModel.length; j++) {
  11789. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11790. // items.inputModel[i].selected = true;
  11791. // }
  11792. // }
  11793. // }
  11794. }
  11795. // options.templateOptions.options = angular.copy(topdata);
  11796. // console.log(model);
  11797. // console.log(options);
  11798. });
  11799. }
  11800. },
  11801. },
  11802. validators: {
  11803. required: {
  11804. expression: function (viewValue, modelValue) {
  11805. var value = modelValue || viewValue;
  11806. if (angular.isArray(value)) {
  11807. return value.length > 0;
  11808. } else {
  11809. // console.log(options)
  11810. if (options.templateOptions.required && !value) {
  11811. // return value != null;
  11812. } else {
  11813. return value;
  11814. }
  11815. // return value = "true";
  11816. }
  11817. },
  11818. },
  11819. },
  11820. };
  11821. },
  11822. controller: [
  11823. "$scope",
  11824. "$rootScope",
  11825. "api_configure_form",
  11826. "api_bpm_domain",
  11827. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  11828. $rootScope.checkClicked = function (item) {
  11829. angular.forEach($scope.to.options, function (itemone) {
  11830. if (!item.parent) {
  11831. if (item.id == itemone.id) {
  11832. // itemone.isExpanded = true;
  11833. } else {
  11834. itemone.isExpanded = false;
  11835. }
  11836. } else {
  11837. if (item.parent.id == itemone.id) {
  11838. angular.forEach(itemone.children, function (itemtwo) {
  11839. if (item.id == itemtwo.id) {
  11840. } else {
  11841. itemtwo.isExpanded = false;
  11842. }
  11843. });
  11844. }
  11845. }
  11846. });
  11847. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  11848. console.log($scope, "gsm");
  11849. if (
  11850. $scope.originalModel &&
  11851. $scope.originalModel.incident &&
  11852. item.category &&
  11853. (!item.children || !item.children.length) &&
  11854. item.priority &&
  11855. item.priority.id
  11856. ) {
  11857. api_bpm_domain
  11858. .expectedTime("L" + (item.priority.id - 1559))
  11859. .then(function (res) {
  11860. $scope.originalModel.incident.expectResponseTime =
  11861. res.serviceLevelAgreement.responseTime;
  11862. $scope.originalModel.incident.expectIntroTime =
  11863. res.serviceLevelAgreement.resolveTime;
  11864. $scope.originalModel.incident.overdueTime = res.date;
  11865. });
  11866. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  11867. // setTimeout(() => {
  11868. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  11869. // }, 500);
  11870. // console.log($scope.$parent.$parent.$parent)
  11871. }
  11872. };
  11873. if ($scope.options.templateOptions.isMultiSelect) {
  11874. // console.log($scope);
  11875. } else {
  11876. if ($scope.model[$scope.options.key]) {
  11877. }
  11878. }
  11879. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  11880. // console.log(item)
  11881. // // if(){
  11882. // // }
  11883. // // $scope.model[$scope.options.key]=item.id;
  11884. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  11885. // $scope.propTypeOptions = data;
  11886. // });
  11887. // }
  11888. // $scope.model[$scope.options.key]=[];
  11889. // $scope.fn
  11890. $rootScope.bala1 = function (items, fn) {
  11891. // $scope.fn = fn;
  11892. console.log(items);
  11893. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  11894. $scope.options.templateOptions.refresh(items, "search", fn);
  11895. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  11896. // // return res.list;
  11897. // console.log(666)
  11898. // fn(res.list)
  11899. // })
  11900. };
  11901. },
  11902. ],
  11903. });
  11904. //勾选组件
  11905. formlyConfigProvider.setType({
  11906. name: "ui-checkbox",
  11907. extends: "checkbox",
  11908. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  11909. controller: [
  11910. "$scope",
  11911. function ($scope) {
  11912. // 巡检生成事件,默认派单
  11913. if ($scope.model.isInspection) {
  11914. $scope.model[$scope.options.key] = true;
  11915. }
  11916. if ($scope.model[$scope.options.key] == "true") {
  11917. $scope.model[$scope.options.key] = true;
  11918. }
  11919. if ($scope.model[$scope.options.key] == "false") {
  11920. $scope.model[$scope.options.key] = false;
  11921. }
  11922. },
  11923. ],
  11924. });
  11925. //换行组件
  11926. formlyConfigProvider.setType({
  11927. name: "ui-nextLine",
  11928. /*extends: 'input',*/
  11929. template: "<div></div>",
  11930. });
  11931. //多选框组件
  11932. formlyConfigProvider.setType({
  11933. name: "ui-checklist",
  11934. extends: "multiCheckbox",
  11935. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  11936. defaultOptions: function (options) {
  11937. return {
  11938. templateOptions: {
  11939. refresh: function () { },
  11940. refreshDelay: 0,
  11941. },
  11942. };
  11943. },
  11944. });
  11945. //单选框组件
  11946. formlyConfigProvider.setType({
  11947. name: "ui-radio",
  11948. extends: "radio",
  11949. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  11950. defaultOptions: function (options) {
  11951. return {
  11952. templateOptions: {
  11953. refresh: function () { },
  11954. refreshDelay: 0,
  11955. },
  11956. };
  11957. },
  11958. controller: [
  11959. "$scope",
  11960. function ($scope) {
  11961. // 巡检生成事件,默认派单
  11962. if ($scope.model.isInspection) {
  11963. $scope.model[$scope.options.key] = true;
  11964. // $scope.model.isHandlerUser=true;
  11965. $scope.model.start_code = "assignment";
  11966. console.log($scope.model);
  11967. }
  11968. //多次暂存配置
  11969. // console.log($scope);
  11970. if ($scope.model.saveAgain) {
  11971. if (
  11972. $scope.model.directClose == "1" ||
  11973. $scope.model.directClose == true
  11974. ) {
  11975. $scope.model[$scope.options.key] = true;
  11976. // if($scope.model.incident.handlingPersonnelUser){
  11977. // delete $scope.model.incident.handlingPersonnelUser;
  11978. // };
  11979. if ($scope.model.incident.handleDescription) {
  11980. delete $scope.model.incident.handleDescription;
  11981. }
  11982. if ($scope.model.incident.closecode) {
  11983. delete $scope.model.incident.closecode;
  11984. }
  11985. if ($scope.model.incident.degree) {
  11986. delete $scope.model.incident.degree;
  11987. }
  11988. } else {
  11989. $scope.model.incident.handlingPersonnelUser =
  11990. $scope.model.incident.acceptUser;
  11991. $scope.model[$scope.options.key] = false;
  11992. }
  11993. }
  11994. },
  11995. ],
  11996. });
  11997. //文本域组件
  11998. formlyConfigProvider.setWrapper({
  11999. name: "validation",
  12000. types: ["ui-textarea"],
  12001. template:
  12002. '<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>',
  12003. });
  12004. formlyConfigProvider.setType({
  12005. name: "ui-textarea",
  12006. extends: "textarea",
  12007. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12008. defaultOptions: function (options) {
  12009. return {
  12010. templateOptions: {
  12011. transform: function (model, value) {
  12012. return value;
  12013. },
  12014. },
  12015. validation: {
  12016. messages: {
  12017. maxlength: function (viewValue, modelValue, scope) {
  12018. if (viewValue != null) {
  12019. if (viewValue.length > scope.to.maxlength) {
  12020. return (
  12021. scope.to.label +
  12022. " 字数(" +
  12023. viewValue.length +
  12024. ")超限(" +
  12025. scope.to.maxlength +
  12026. ")"
  12027. );
  12028. } else {
  12029. return "";
  12030. }
  12031. }
  12032. },
  12033. },
  12034. },
  12035. };
  12036. },
  12037. controller: [
  12038. "$scope",
  12039. function ($scope) {
  12040. var value = $scope.model[$scope.options.key];
  12041. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12042. $scope.model[$scope.options.key] =
  12043. $scope.options.templateOptions.transform(
  12044. $scope.originalModel,
  12045. value
  12046. );
  12047. }
  12048. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12049. $scope.options.templateOptions.felditem($scope);
  12050. }
  12051. },
  12052. ],
  12053. });
  12054. // div版的textarea(展示富文本框内容用)
  12055. formlyConfigProvider.setType({
  12056. name: "ui-divTextarea",
  12057. extends: "textarea",
  12058. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12059. defaultOptions: function (options) {
  12060. return {
  12061. templateOptions: {
  12062. transform: function (model, value) {
  12063. return value;
  12064. },
  12065. },
  12066. validation: {
  12067. messages: {
  12068. // maxlength: function (viewValue, modelValue, scope) {
  12069. // if (viewValue != null) {
  12070. // if (viewValue.length > scope.to.maxlength) {
  12071. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12072. // } else {
  12073. // return "";
  12074. // }
  12075. // }
  12076. // },
  12077. },
  12078. },
  12079. };
  12080. },
  12081. controller: [
  12082. "$scope",
  12083. function ($scope) {
  12084. var value = $scope.model[$scope.options.key];
  12085. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12086. $scope.model[$scope.options.key] =
  12087. $scope.options.templateOptions.transform(
  12088. $scope.originalModel,
  12089. value
  12090. );
  12091. }
  12092. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12093. $scope.options.templateOptions.felditem($scope);
  12094. }
  12095. },
  12096. ],
  12097. });
  12098. // 带有知识库引用的textarea
  12099. formlyConfigProvider.setType({
  12100. name: "ui-textAreaKnowledge",
  12101. // extends: 'textarea',
  12102. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12103. defaultOptions: function (options) {
  12104. return {
  12105. templateOptions: {
  12106. transform: function (model, value) {
  12107. return value;
  12108. },
  12109. },
  12110. validation: {
  12111. messages: {
  12112. maxlength: function (viewValue, modelValue, scope) {
  12113. if (viewValue != null) {
  12114. if (viewValue.length > scope.to.maxlength) {
  12115. return (
  12116. scope.to.label +
  12117. " 字数(" +
  12118. viewValue.length +
  12119. ")超限(" +
  12120. scope.to.maxlength +
  12121. ")"
  12122. );
  12123. } else {
  12124. return "";
  12125. }
  12126. }
  12127. },
  12128. },
  12129. },
  12130. };
  12131. },
  12132. controller: [
  12133. "$scope",
  12134. "$rootScope",
  12135. "$modal",
  12136. "SweetAlert",
  12137. "api_bpm_data",
  12138. "api_bpm_domain",
  12139. "api_solution",
  12140. "$aside",
  12141. "api_zsk",
  12142. "up_down_file",
  12143. "api_wechatfile",
  12144. function (
  12145. $scope,
  12146. $rootScope,
  12147. $modal,
  12148. SweetAlert,
  12149. api_bpm_data,
  12150. api_bpm_domain,
  12151. api_solution,
  12152. $aside,
  12153. api_zsk,
  12154. up_down_file,
  12155. api_wechatfile
  12156. ) {
  12157. // console.log($scope);
  12158. var value = $scope.model[$scope.options.key];
  12159. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12160. $scope.model[$scope.options.key] =
  12161. $scope.options.templateOptions.transform(
  12162. $scope.originalModel,
  12163. value
  12164. );
  12165. }
  12166. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12167. $scope.options.templateOptions.felditem($scope);
  12168. }
  12169. // 引用知识库点击
  12170. $scope.openSolution = function () {
  12171. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12172. setTimeout(() => {
  12173. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12174. }, 100);
  12175. };
  12176. },
  12177. ],
  12178. });
  12179. //常用语句选择textarea
  12180. formlyConfigProvider.setType({
  12181. name: "ui-textselect",
  12182. extends: "textarea",
  12183. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12184. defaultOptions: function (options) {
  12185. return {
  12186. templateOptions: {
  12187. transform: function (model, value) {
  12188. return value;
  12189. },
  12190. },
  12191. validation: {
  12192. messages: {
  12193. maxlength: function (viewValue, modelValue, scope) {
  12194. if (viewValue != null) {
  12195. if (viewValue.length > scope.to.maxlength) {
  12196. return (
  12197. scope.to.label +
  12198. " 字数(" +
  12199. viewValue.length +
  12200. ")超限(" +
  12201. scope.to.maxlength +
  12202. ")"
  12203. );
  12204. } else {
  12205. return "";
  12206. }
  12207. }
  12208. },
  12209. },
  12210. },
  12211. };
  12212. },
  12213. controller: [
  12214. "$scope",
  12215. function ($scope) {
  12216. var value = $scope.model[$scope.options.key];
  12217. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12218. $scope.model[$scope.options.key] =
  12219. $scope.options.templateOptions.transform(
  12220. $scope.originalModel,
  12221. value
  12222. );
  12223. }
  12224. },
  12225. ],
  12226. });
  12227. //改动的组件 ckeditor封装后的组件
  12228. formlyConfigProvider.setType({
  12229. name: "ui-text-check",
  12230. extends: "textarea",
  12231. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12232. defaultOptions: function (options) {
  12233. return {
  12234. templateOptions: {
  12235. extraPlugins: "uploadimage",
  12236. uploadimageConfig: {
  12237. backend: "basic",
  12238. settings: {
  12239. uploadUrl:
  12240. options.templateOptions.APIService.upload().getRequestedUrl(),
  12241. headers: "",
  12242. downloadUrl:
  12243. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12244. },
  12245. },
  12246. refresh: function (APIService, contentId, data) {
  12247. return APIService.fetchDataList(contentId, data);
  12248. },
  12249. downloadUri: function (APIService, contentId) {
  12250. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12251. },
  12252. upload: function (APIService, contentId) {
  12253. return APIService.getSolutionDowpath(contentId);
  12254. },
  12255. view: function (attachmentId) {
  12256. // return APIService.attachmentsPreviewUrl(contentId);
  12257. },
  12258. refreshDelay: 0,
  12259. transform: function (model, value) {
  12260. return value;
  12261. },
  12262. },
  12263. validation: {
  12264. messages: {
  12265. maxlength: function (viewValue, modelValue, scope) {
  12266. if (viewValue != null) {
  12267. if (viewValue.length > scope.to.maxlength) {
  12268. return (
  12269. scope.to.label +
  12270. " 字数(" +
  12271. viewValue.length +
  12272. ")超限(" +
  12273. scope.to.maxlength +
  12274. ")"
  12275. );
  12276. } else {
  12277. return "";
  12278. }
  12279. }
  12280. },
  12281. },
  12282. },
  12283. };
  12284. },
  12285. controller: [
  12286. "$scope",
  12287. "$rootScope",
  12288. function ($scope, $rootScope) {
  12289. var value = $scope.model[$scope.options.key];
  12290. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12291. $scope.model[$scope.options.key] =
  12292. $scope.options.templateOptions.transform(
  12293. $scope.originalModel,
  12294. value
  12295. );
  12296. }
  12297. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12298. $rootScope.getSession();
  12299. //var expiry={'expiry':14804244006};
  12300. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12301. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12302. $scope.upload = function (contentId, filename) {
  12303. var filename = filename;
  12304. $scope.options.templateOptions
  12305. .upload($scope.options.templateOptions.ApiService, contentId)
  12306. .then(function (response) {
  12307. var file = new Blob([response], {
  12308. type: "application/octet-stream",
  12309. });
  12310. // var filename = filename;
  12311. var fileURL = URL.createObjectURL(file);
  12312. var a = document.createElement("a");
  12313. a.href = fileURL;
  12314. a.target = "_blank";
  12315. a.download = filename;
  12316. document.body.appendChild(a);
  12317. a.click();
  12318. });
  12319. };
  12320. },
  12321. ],
  12322. });
  12323. //改动的组件 ckeditor封装后的附文本组件
  12324. formlyConfigProvider.setType({
  12325. name: "ui-fuwenben",
  12326. extends: "textarea",
  12327. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12328. defaultOptions: function (options) {
  12329. return {
  12330. templateOptions: {
  12331. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12332. extraPlugins: "uploadimage",
  12333. uploadimageConfig: {
  12334. backend: "basic",
  12335. settings: {
  12336. uploadUrl:
  12337. options.templateOptions.APIService.upload(
  12338. -110
  12339. ).getRequestedUrl(),
  12340. headers: "",
  12341. downloadUrl:
  12342. options.templateOptions.APIService.uploadResponseUri(),
  12343. },
  12344. },
  12345. refresh: function (APIService, contentId, data) {
  12346. return APIService.fetchDataList(-110, data);
  12347. },
  12348. downloadUri: function (APIService, contentId) {
  12349. return APIService.downloadAttachment(-110).getRequestedUrl();
  12350. },
  12351. upload: function (APIService, contentId) {
  12352. return APIService.getSolutionDowpath(-110);
  12353. },
  12354. view: function (attachmentId) {
  12355. // return APIService.attachmentsPreviewUrl(contentId);
  12356. },
  12357. refreshDelay: 0,
  12358. transform: function (model, value) {
  12359. return value;
  12360. },
  12361. },
  12362. validation: {
  12363. messages: {
  12364. maxlength: function (viewValue, modelValue, scope) {
  12365. if (viewValue != null) {
  12366. if (viewValue.length > scope.to.maxlength) {
  12367. return (
  12368. scope.to.label +
  12369. " 字数(" +
  12370. viewValue.length +
  12371. ")超限(" +
  12372. scope.to.maxlength +
  12373. ")"
  12374. );
  12375. } else {
  12376. return "";
  12377. }
  12378. }
  12379. },
  12380. },
  12381. },
  12382. };
  12383. },
  12384. controller: [
  12385. "$scope",
  12386. "$rootScope",
  12387. function ($scope, $rootScope) {
  12388. var value = $scope.model[$scope.options.key];
  12389. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12390. $scope.model[$scope.options.key] =
  12391. $scope.options.templateOptions.transform(
  12392. $scope.originalModel,
  12393. value
  12394. );
  12395. }
  12396. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12397. $rootScope.getSession();
  12398. //var expiry={'expiry':14804244006};
  12399. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12400. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12401. $scope.upload = function (contentId, filename) {
  12402. var filename = filename;
  12403. $scope.options.templateOptions
  12404. .upload($scope.options.templateOptions.ApiService, -110)
  12405. .then(function (response) {
  12406. var file = new Blob([response], {
  12407. type: "application/octet-stream",
  12408. });
  12409. // var filename = filename;
  12410. var fileURL = URL.createObjectURL(file);
  12411. var a = document.createElement("a");
  12412. a.href = fileURL;
  12413. a.target = "_blank";
  12414. a.download = filename;
  12415. document.body.appendChild(a);
  12416. a.click();
  12417. });
  12418. };
  12419. },
  12420. ],
  12421. });
  12422. //ui-grid展示控件
  12423. formlyConfigProvider.setType({
  12424. name: "ui-grid-show",
  12425. extends: "multiCheckbox",
  12426. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12427. defaultOptions: function (options) {
  12428. return {
  12429. templateOptions: {
  12430. linkage: function () { },
  12431. },
  12432. };
  12433. },
  12434. controller: function (
  12435. $scope,
  12436. $rootScope,
  12437. i18nService,
  12438. Restangular,
  12439. api_bpm_data
  12440. ) {
  12441. var loginUser = $rootScope.user;
  12442. $scope.langs = i18nService.getAllLangs();
  12443. $scope.lang = "zh-cn";
  12444. i18nService.setCurrentLang($scope.lang);
  12445. $scope.gridOptions = {};
  12446. $scope.gridOptions.data = "myData";
  12447. $scope.gridOptions.enableColumnResizing = true;
  12448. // $scope.gridOptions.enableFiltering = true;
  12449. $scope.gridOptions.enableGridMenu = false;
  12450. $scope.gridOptions.enableRowSelection = true;
  12451. $scope.gridOptions.showGridFooter = true;
  12452. $scope.gridOptions.showColumnFooter = false;
  12453. $scope.gridOptions.fastWatch = true;
  12454. $scope.gridOptions.useExternalFiltering = true;
  12455. $scope.gridOptions.useExternalPagination = true;
  12456. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  12457. $scope.gridOptions.paginationPageSize = 10;
  12458. $scope.gridOptions.multiSelect = true;
  12459. $scope.gridOptions.rowIdentity = function (row) {
  12460. return row.id;
  12461. };
  12462. $scope.gridOptions.getRowIdentity = function (row) {
  12463. return row.id;
  12464. };
  12465. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12466. $scope.gridOptions.columnDefs = [
  12467. // { name:'id', width:80, enableFiltering:false},
  12468. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12469. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12470. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12471. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12472. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12473. {
  12474. name: "inspection.title",
  12475. displayName: "计划主题",
  12476. width: 120,
  12477. enableFiltering: false,
  12478. },
  12479. {
  12480. name: "stateName",
  12481. displayName: "状态",
  12482. width: 80,
  12483. enableFiltering: false,
  12484. },
  12485. {
  12486. name: "processUser.name",
  12487. displayName: "处理人",
  12488. width: 80,
  12489. enableFiltering: false,
  12490. },
  12491. {
  12492. name: "startDate",
  12493. displayName: "开始时间",
  12494. width: 160,
  12495. enableFiltering: false,
  12496. },
  12497. {
  12498. name: "overdueTime",
  12499. displayName: "逾期时间",
  12500. width: 160,
  12501. enableFiltering: false,
  12502. },
  12503. ];
  12504. var defaultFilterData = {
  12505. idx: 0,
  12506. sum: 10,
  12507. };
  12508. //分页控制
  12509. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12510. gridApi.pagination.on.paginationChanged(
  12511. $scope,
  12512. function (newPage, pageSize) {
  12513. var filtersData = $scope.memoryfilterData;
  12514. filtersData.idx = newPage - 1;
  12515. filtersData.sum = pageSize;
  12516. $scope.refreshData("expand-right", filtersData);
  12517. }
  12518. );
  12519. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12520. data.grid.appScope.selected.items = data.entity;
  12521. });
  12522. };
  12523. //页面获取数据
  12524. $scope.refreshData = function (style, filterData) {
  12525. // $scope.ldloading[style.replace('-', '_')] = true;
  12526. if (angular.isUndefined(filterData)) {
  12527. filterData = defaultFilterData;
  12528. }
  12529. $scope.myData = [];
  12530. angular.extend(filterData, {
  12531. inspectionProcessActual: {
  12532. inspectionid: $scope.model.id,
  12533. },
  12534. });
  12535. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12536. function (data) {
  12537. var myData = Restangular.stripRestangular(data);
  12538. $scope.gridOptions.totalItems = myData.totalNum;
  12539. $scope.myData = myData.list;
  12540. for (var i = 0; i < $scope.myData.length; i++) {
  12541. //添加序号
  12542. $scope.myData[i]["item"] =
  12543. i + 1 + filterData.idx * filterData.sum;
  12544. }
  12545. // $scope.ldloading[style.replace('-', '_')] = false;
  12546. },
  12547. function () {
  12548. // $scope.ldloading[style.replace('-', '_')] = false;
  12549. }
  12550. );
  12551. };
  12552. $scope.refreshData("expand-right", defaultFilterData);
  12553. },
  12554. });
  12555. //文本框自定义选择面板组件
  12556. formlyConfigProvider.setType({
  12557. name: "ui-input-selectmodal",
  12558. extends: "input",
  12559. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  12560. defaultOptions: function (options) {
  12561. return {
  12562. templateOptions: {
  12563. openModal: function (size, options, modal) {
  12564. var modalInstance = modal.open({
  12565. templateUrl: "assets/views/customform/tpl/modal-content.html",
  12566. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  12567. size: size,
  12568. resolve: options.templateOptions.modalParam,
  12569. });
  12570. modalInstance.result.then(
  12571. function (selectedItem) {
  12572. options.value(selectedItem);
  12573. },
  12574. function () {
  12575. //console.log('Modal dismissed at: ' + new Date());
  12576. }
  12577. );
  12578. },
  12579. },
  12580. };
  12581. },
  12582. });
  12583. //日期控件
  12584. var datepicker_attr = [
  12585. "date-disabled",
  12586. "custom-class",
  12587. "show-weeks",
  12588. "starting-day",
  12589. "init-date",
  12590. "min-mode",
  12591. "max-mode",
  12592. "format-day",
  12593. "format-month",
  12594. "format-year",
  12595. "format-day-header",
  12596. "format-day-title",
  12597. "format-month-title",
  12598. "year-range",
  12599. "shortcut-propagation",
  12600. "datepicker-popup",
  12601. "show-button-bar",
  12602. "current-text",
  12603. "clear-text",
  12604. "close-text",
  12605. "close-on-date-selection",
  12606. "datepicker-append-to-body",
  12607. ];
  12608. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  12609. formlyConfigProvider.setType({
  12610. name: "ui-datetime",
  12611. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  12612. extends: "input",
  12613. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12614. defaultOptions: {
  12615. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12616. templateOptions: {
  12617. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12618. },
  12619. },
  12620. controller: [
  12621. "$scope",
  12622. "$filter",
  12623. function ($scope, $filter) {
  12624. $scope.model[$scope.options.key] = $filter("date")(
  12625. new Date(),
  12626. $scope.options.templateOptions.datepickerPopup
  12627. );
  12628. $scope.options.initialValue = $scope.model[$scope.options.key];
  12629. },
  12630. ],
  12631. });
  12632. //日期控件
  12633. formlyConfigProvider.setType({
  12634. name: "ui-datepicker",
  12635. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  12636. extends: "input",
  12637. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12638. defaultOptions: {
  12639. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12640. templateOptions: {
  12641. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12642. },
  12643. },
  12644. controller: [
  12645. "$scope",
  12646. "$filter",
  12647. function ($scope, $filter) {
  12648. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  12649. if ($scope.model[$scope.options.key]) {
  12650. } else {
  12651. $scope.model[$scope.options.key] = $filter("date")(
  12652. new Date(),
  12653. $scope.options.templateOptions.datepickerPopup
  12654. );
  12655. }
  12656. $scope.options.initialValue = $scope.model[$scope.options.key];
  12657. $scope.endOpen = true;
  12658. $scope.datepicker = {};
  12659. $scope.datepicker.opened = false;
  12660. $scope.datepicker.open = function ($event) {
  12661. $scope.datepicker.opened = true;
  12662. };
  12663. },
  12664. ],
  12665. });
  12666. //时分控件
  12667. formlyConfigProvider.setType({
  12668. name: "ui-datehourtime",
  12669. extends: "input",
  12670. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  12671. defaultOptions: function (options) {
  12672. return {
  12673. noFormControl: true,
  12674. // validators:{
  12675. // required:{
  12676. // expression:function(viewValue, modelValue){
  12677. // console.log(options)
  12678. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  12679. // // var value = modelValue.getHours() || viewValue.getHours();
  12680. // return value.length>=1;
  12681. // }
  12682. // }
  12683. // }
  12684. };
  12685. },
  12686. controller: [
  12687. "$scope",
  12688. "$log",
  12689. function ($scope, $log) {
  12690. $scope.hstep = new Date(
  12691. Date.parse($scope.model[$scope.options.key])
  12692. ).getHours();
  12693. $scope.minutes = new Date(
  12694. Date.parse($scope.model[$scope.options.key])
  12695. ).getMinutes();
  12696. $scope.model[$scope.options.key] = new Date(
  12697. Date.parse($scope.model[$scope.options.key])
  12698. );
  12699. },
  12700. ],
  12701. });
  12702. //状态追踪
  12703. formlyConfigProvider.setType({
  12704. name: "ui-followStatus",
  12705. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  12706. controller: [
  12707. "$scope",
  12708. "api_bpm_data",
  12709. "Restangular",
  12710. function ($scope, api_bpm_data, Restangular) {
  12711. setTimeout(function () {
  12712. var pkey = $scope.options.templateOptions.pkey;
  12713. var dataId = $scope.model.id;
  12714. if (dataId) {
  12715. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  12716. if (response) {
  12717. var myData = Restangular.stripRestangular(response);
  12718. var processInstanceId = myData.data.processInstanceId;
  12719. $scope.options.templateOptions
  12720. .getData(
  12721. $scope.model,
  12722. $scope.options.templateOptions.ApiService,
  12723. processInstanceId
  12724. )
  12725. .then(function (result) {
  12726. if (result.status == 200) {
  12727. var newData = Restangular.stripRestangular(result);
  12728. $scope.followData = newData.data;
  12729. }
  12730. });
  12731. }
  12732. });
  12733. }
  12734. }, 10);
  12735. },
  12736. ],
  12737. });
  12738. //处理日志
  12739. formlyConfigProvider.setType({
  12740. name: "ui-handlerLog",
  12741. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  12742. controller: [
  12743. "$scope",
  12744. "api_bpm_data",
  12745. "Restangular",
  12746. function ($scope, api_bpm_data, Restangular) {
  12747. console.log($scope, 'ui-handlerLog')
  12748. },
  12749. ],
  12750. });
  12751. //资产
  12752. formlyConfigProvider.setType({
  12753. name: "ui-zc",
  12754. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  12755. controller: [
  12756. "$scope",
  12757. "api_bpm_data",
  12758. "Restangular",
  12759. function ($scope, api_bpm_data, Restangular) {
  12760. console.log($scope, 'ui-zc');
  12761. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  12762. },
  12763. ],
  12764. });
  12765. //绑定的耗材
  12766. formlyConfigProvider.setType({
  12767. name: "ui-hc",
  12768. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  12769. controller: [
  12770. "$scope",
  12771. "api_cmdb2",
  12772. "Restangular",
  12773. function ($scope, api_cmdb2, Restangular) {
  12774. console.log($scope, 'ui-hc')
  12775. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  12776. $scope.list = [];
  12777. var sjId = $scope.model.incident.id;
  12778. api_cmdb2.getHc(sjId).then(function (response) {
  12779. console.log(response)
  12780. if (response.status == 200) {
  12781. $scope.list = response.data;
  12782. }
  12783. })
  12784. },
  12785. ],
  12786. });
  12787. //历史记录
  12788. formlyConfigProvider.setType({
  12789. name: "ui-history",
  12790. templateUrl: "assets/views/customform/tpl/ui-history.html",
  12791. controller: [
  12792. "$scope",
  12793. "api_bpm_data",
  12794. "Restangular",
  12795. function ($scope, api_bpm_data, Restangular) {
  12796. setTimeout(function () {
  12797. var pkey = $scope.options.templateOptions.pkey;
  12798. var dataId = $scope.model.id;
  12799. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  12800. if (response) {
  12801. var myData = Restangular.stripRestangular(response);
  12802. var processInstanceId = myData.data.processInstanceId;
  12803. $scope.options.templateOptions
  12804. .getData(
  12805. $scope.model,
  12806. $scope.options.templateOptions.ApiService,
  12807. processInstanceId
  12808. )
  12809. .then(function (result) {
  12810. if (result.status == 200) {
  12811. var newData = Restangular.stripRestangular(result);
  12812. var long = newData.data.length - 1;
  12813. $scope.followData = newData.data[long];
  12814. }
  12815. });
  12816. }
  12817. });
  12818. }, 10);
  12819. },
  12820. ],
  12821. });
  12822. // //请求人信息显示
  12823. // formlyConfigProvider.setType({
  12824. // name: "ui-disrequester",
  12825. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  12826. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12827. // defaultOptions: function(options) {
  12828. // return {
  12829. // templateOptions: {}
  12830. // };
  12831. // },
  12832. // controller: ['$scope', function($scope) {
  12833. // $scope.options.templateOptions.that = $scope;
  12834. // }]
  12835. // });
  12836. //退回人信息显示
  12837. formlyConfigProvider.setType({
  12838. name: "ui-returnperson",
  12839. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  12840. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12841. defaultOptions: function (options) {
  12842. return {
  12843. templateOptions: {},
  12844. };
  12845. },
  12846. controller: [
  12847. "$scope",
  12848. function ($scope) {
  12849. $scope.group = "";
  12850. $scope.role = "";
  12851. if (
  12852. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  12853. $scope.model.handlingPersonnelUser.group.length == 1
  12854. ) {
  12855. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  12856. } else {
  12857. for (
  12858. var i = 0;
  12859. i < $scope.model.handlingPersonnelUser.group.length;
  12860. i++
  12861. ) {
  12862. $scope.group +=
  12863. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  12864. }
  12865. }
  12866. if (
  12867. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  12868. $scope.model.handlingPersonnelUser.role.length == 1
  12869. ) {
  12870. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  12871. } else {
  12872. for (
  12873. var i = 0;
  12874. i < $scope.model.handlingPersonnelUser.role.length;
  12875. i++
  12876. ) {
  12877. $scope.role +=
  12878. $scope.model.handlingPersonnelUser.role[i].role + ",";
  12879. }
  12880. }
  12881. $scope.options.templateOptions.that = $scope;
  12882. $scope.options.templateOptions.that = $scope;
  12883. },
  12884. ],
  12885. });
  12886. //退回人信息显示(去掉工作组&角色)
  12887. formlyConfigProvider.setType({
  12888. name: "ui-returnpersonNoGroup",
  12889. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  12890. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12891. defaultOptions: function (options) {
  12892. return {
  12893. templateOptions: {},
  12894. };
  12895. },
  12896. controller: [
  12897. "$scope",
  12898. function ($scope) {
  12899. $scope.group = "";
  12900. $scope.role = "";
  12901. if (
  12902. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  12903. $scope.model.handlingPersonnelUser.group.length == 1
  12904. ) {
  12905. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  12906. } else {
  12907. for (
  12908. var i = 0;
  12909. i < $scope.model.handlingPersonnelUser.group.length;
  12910. i++
  12911. ) {
  12912. $scope.group +=
  12913. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  12914. }
  12915. }
  12916. if (
  12917. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  12918. $scope.model.handlingPersonnelUser.role.length == 1
  12919. ) {
  12920. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  12921. } else {
  12922. for (
  12923. var i = 0;
  12924. i < $scope.model.handlingPersonnelUser.role.length;
  12925. i++
  12926. ) {
  12927. $scope.role +=
  12928. $scope.model.handlingPersonnelUser.role[i].role + ",";
  12929. }
  12930. }
  12931. $scope.options.templateOptions.that = $scope;
  12932. $scope.options.templateOptions.that = $scope;
  12933. },
  12934. ],
  12935. });
  12936. //指派技术人员
  12937. formlyConfigProvider.setType({
  12938. name: "ui-apiontperson",
  12939. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  12940. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12941. defaultOptions: function (options) {
  12942. return {
  12943. templateOptions: {
  12944. transtlara: function (value, $scope) { },
  12945. },
  12946. };
  12947. },
  12948. controller: [
  12949. "$scope",
  12950. "api_user_data",
  12951. "Restangular",
  12952. function ($scope, api_user_data, Restangular) {
  12953. var filterData = {
  12954. idx: 0,
  12955. sum: 1000,
  12956. };
  12957. api_user_data
  12958. .fetchDataList("group", filterData)
  12959. .then(function (response) {
  12960. if (response.status == 200) {
  12961. $scope.select = {};
  12962. $scope.multipleDemo = {};
  12963. $scope.userdata = {};
  12964. var data = response.list;
  12965. var item = [];
  12966. $scope.multipleDemo = data;
  12967. $scope.multipleDemo;
  12968. }
  12969. });
  12970. $scope.options.templateOptions.onChange = function (
  12971. id,
  12972. options,
  12973. groupdata,
  12974. $event,
  12975. model
  12976. ) {
  12977. if (groupdata.option) {
  12978. $scope.model[$scope.options.key] = {};
  12979. var fildate = {
  12980. idx: 0,
  12981. sum: 1000,
  12982. user: {
  12983. roledata: {
  12984. rolecode: model.currentRole,
  12985. },
  12986. selectType: "1",
  12987. groupdata: {
  12988. id: groupdata.option.id,
  12989. },
  12990. },
  12991. };
  12992. api_user_data
  12993. .fetchDataList("user", fildate)
  12994. .then(function (response) {
  12995. if (response.status == 200) {
  12996. $scope.userdata = {};
  12997. $scope.userdata = response.list;
  12998. }
  12999. });
  13000. } else {
  13001. $scope.model[$scope.options.key] = {
  13002. id: groupdata.id.id,
  13003. };
  13004. $scope.options.templateOptions.transtlara(
  13005. $scope.model[$scope.options.key],
  13006. $scope
  13007. );
  13008. }
  13009. };
  13010. // }
  13011. },
  13012. ],
  13013. });
  13014. //请求科室信息(小蓝框) lmm
  13015. formlyConfigProvider.setType({
  13016. name: "ui-deptinformation",
  13017. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13018. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13019. return {
  13020. templateOptions: {
  13021. checkform: function (options) { },
  13022. },
  13023. };
  13024. },
  13025. controller: [
  13026. "$scope",
  13027. "api_statistic",
  13028. function ($scope, api_statistic) {
  13029. // console.log($scope)
  13030. },
  13031. ],
  13032. });
  13033. //请求人信息
  13034. formlyConfigProvider.setType({
  13035. name: "ui-requesterinformation",
  13036. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13037. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13038. return {
  13039. templateOptions: {
  13040. checkform: function (options) {
  13041. if (options.model.requester) {
  13042. options.value(options.model.requester);
  13043. }
  13044. },
  13045. addRequeter: function (size, options, modal, e) {
  13046. if (e) {
  13047. if (e.clientX === 0) {
  13048. return;
  13049. }
  13050. e.preventDefault();
  13051. }
  13052. var modalInstance = modal.open({
  13053. templateUrl:
  13054. "assets/views/customform/tpl/modal-add-callrequester.html",
  13055. controller: function (
  13056. $scope,
  13057. sco,
  13058. $rootScope,
  13059. $modalInstance,
  13060. items,
  13061. SweetAlert,
  13062. title,
  13063. Restangular,
  13064. APIService,
  13065. UserService,
  13066. api_user_data,
  13067. api_statistic,
  13068. api_wechatfile,
  13069. $stateParams
  13070. ) {
  13071. $modalInstance.SweetAlert = SweetAlert;
  13072. $scope.title = "新增报修人";
  13073. $scope.requester = {};
  13074. $scope.searchData = {};
  13075. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13076. var paramsModel = JSON.parse($stateParams.model)
  13077. //来电-添加报修人-回显电话
  13078. if (paramsModel.model.incident.requester.hjzxPhone) {
  13079. $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
  13080. }
  13081. }
  13082. $scope.onChangeadd = function (searchData) {
  13083. $scope.searchKey = searchData.account;
  13084. // $scope.searchDataadd = searchData;
  13085. var requesdata = angular.copy(searchData);
  13086. if (requesdata.mphone) {
  13087. delete requesdata.mphone;
  13088. }
  13089. $scope.requester = requesdata;
  13090. console.log($scope.requester);
  13091. };
  13092. $scope.refreshUseradd = function (searchKey) {
  13093. //请求人搜索
  13094. $scope.requester.account = searchKey;
  13095. $scope.searchData = searchKey;
  13096. serchdataadd(searchKey);
  13097. };
  13098. $scope.getMydata = function (x) {
  13099. $scope.searchField = JSON.parse(x[0]).account;
  13100. $scope.requester = JSON.parse(x[0]);
  13101. console.log($scope.requester);
  13102. };
  13103. $scope.getMydataone = function (x) {
  13104. $scope.searchField = x;
  13105. $scope.requester.account = x;
  13106. };
  13107. serchdataadd();
  13108. api_wechatfile
  13109. .getDictionary({
  13110. type: "list",
  13111. key: "male",
  13112. })
  13113. .then(function (data) {
  13114. if (data.status == 200) {
  13115. requester.gender = data.list;
  13116. }
  13117. });
  13118. function serchdataadd(searchKey) {
  13119. if (searchKey) {
  13120. var filterData = {
  13121. requester: {
  13122. searchKey: searchKey,
  13123. },
  13124. idx: 0,
  13125. sum: 10,
  13126. };
  13127. } else {
  13128. var filterData = {
  13129. idx: 0,
  13130. sum: 10,
  13131. };
  13132. }
  13133. api_user_data
  13134. .fetchDataList("requester", filterData)
  13135. .then(function (response) {
  13136. var myData = response;
  13137. $scope.myData = myData.list;
  13138. });
  13139. }
  13140. api_user_data
  13141. .fetchDataList("area", {
  13142. idx: 0,
  13143. sum: 1000,
  13144. })
  13145. .then(function (response) {
  13146. if (response.status == 200) {
  13147. $scope.areas = response.list;
  13148. }
  13149. });
  13150. api_wechatfile
  13151. .getDictionary(
  13152. {
  13153. key: "requester_type",
  13154. type: "list",
  13155. },
  13156. {
  13157. idx: 0,
  13158. sum: 100,
  13159. }
  13160. )
  13161. .then(function (response) {
  13162. if (response) {
  13163. $scope.networktypes = response;
  13164. }
  13165. });
  13166. $scope.requesterAreaid = "";
  13167. $scope.onChange = function (item) {
  13168. $scope.requesterAreaid = item.id;
  13169. api_user_data
  13170. .fetchDataList("place", {
  13171. place: {
  13172. area: {
  13173. id: item.id,
  13174. },
  13175. },
  13176. idx: 0,
  13177. sum: 1000,
  13178. })
  13179. .then(function (response) {
  13180. if (response.status == 200) {
  13181. $scope.places = response.list;
  13182. delete $scope.requester.placeDTO;
  13183. }
  13184. });
  13185. };
  13186. $scope.refresh = function (searchVal) {
  13187. var faildata = {};
  13188. if ($scope.requesterAreaid) {
  13189. faildata = {
  13190. idx: 0,
  13191. sum: 1000,
  13192. place: {
  13193. areaId: $scope.requesterAreaid,
  13194. place: searchVal,
  13195. selectType: "pinyin_qs",
  13196. },
  13197. };
  13198. } else {
  13199. faildata = {
  13200. idx: 0,
  13201. sum: 1000,
  13202. place: {
  13203. place: searchVal,
  13204. selectType: "pinyin_qs",
  13205. },
  13206. };
  13207. }
  13208. api_user_data
  13209. .fetchDataList("place", faildata)
  13210. .then(function (response) {
  13211. $scope.places = response.list;
  13212. delete $scope.requester.placeDTO;
  13213. });
  13214. };
  13215. $scope.refreshDepts = function (key) {
  13216. var filterData = {
  13217. idx: 0,
  13218. sum: 5,
  13219. dept: {
  13220. name: key,
  13221. },
  13222. };
  13223. UserService.fetchDataList("department", filterData).then(
  13224. function (response) {
  13225. if (response.status == 200) {
  13226. $scope.depts = response.list;
  13227. }
  13228. }
  13229. );
  13230. };
  13231. $scope.ok = function () {
  13232. if (
  13233. angular.isUndefined($scope.requester.account) ||
  13234. $scope.requester.account == null ||
  13235. $scope.requester.account == ""
  13236. ) {
  13237. SweetAlert.swal(
  13238. "报修人员编号未填!",
  13239. "请填写报修人员编号",
  13240. "error"
  13241. );
  13242. } else if (
  13243. angular.isUndefined($scope.requester.name) ||
  13244. $scope.requester.name == null ||
  13245. $scope.requester.name == ""
  13246. ) {
  13247. SweetAlert.swal(
  13248. "报修人姓名未填!",
  13249. "请填写报修人姓名",
  13250. "error"
  13251. );
  13252. } else if (
  13253. angular.isUndefined($scope.requester.requesterType) ||
  13254. $scope.requester.requesterType == null ||
  13255. $scope.requester.requesterTypeDTO == ""
  13256. ) {
  13257. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13258. } else if (
  13259. angular.isUndefined($scope.requester.mphone) ||
  13260. $scope.requester.mphone == null ||
  13261. $scope.requester.mphone == ""
  13262. ) {
  13263. SweetAlert.swal(
  13264. "报修人联系电话未填!",
  13265. "请填写报修人联系电话",
  13266. "error"
  13267. );
  13268. } else {
  13269. $scope.requesterId = $scope.requester.id;
  13270. var data = {
  13271. incident: {
  13272. requester: {
  13273. id: $scope.requesterId,
  13274. },
  13275. },
  13276. idx: 0,
  13277. sum: 3,
  13278. };
  13279. api_statistic
  13280. .tableData(data, "incident")
  13281. .then(function (data) {
  13282. sco.$parent.$parent.$parent.model.incident.tableList =
  13283. data.list;
  13284. });
  13285. $scope.$watch(
  13286. sco.$parent.$parent.$parent.model.incident.tableList,
  13287. function (oldObj, newObj) {
  13288. if (newObj != oldObj) {
  13289. sco.$parent.$parent.$parent.model.incident.tableList =
  13290. newObj;
  13291. }
  13292. }
  13293. ); //lmm
  13294. console.log($scope.requester);
  13295. $modalInstance.close($scope.requester);
  13296. }
  13297. };
  13298. $scope.cancel = function () {
  13299. $modalInstance.dismiss("cancel");
  13300. };
  13301. },
  13302. resolve: {
  13303. items: function () {
  13304. return {
  13305. fetchItems: function (filterData, APIService) {
  13306. filterData = filterData || {};
  13307. if (!filterData.idx) {
  13308. filterData = {
  13309. idx: 0,
  13310. sum: 10,
  13311. };
  13312. }
  13313. return options.templateOptions.fetchItems(
  13314. filterData,
  13315. APIService
  13316. );
  13317. },
  13318. };
  13319. },
  13320. title: function () {
  13321. return options.templateOptions.modalTitle;
  13322. },
  13323. Restangular: function () {
  13324. return options.templateOptions.Restangular;
  13325. },
  13326. APIService: function () {
  13327. return options.templateOptions.ApiService;
  13328. },
  13329. UserService: function () {
  13330. return options.templateOptions.UserService;
  13331. },
  13332. sco: function () {
  13333. return $scope;
  13334. },
  13335. },
  13336. });
  13337. modalInstance.result.then(
  13338. function (selectedItem) {
  13339. console.log(selectedItem);
  13340. if (selectedItem) {
  13341. var data = {
  13342. requester: selectedItem,
  13343. };
  13344. $scope.searchKey = selectedItem.account;
  13345. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13346. // if (selectedItem.place && selectedItem.place.place) {
  13347. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13348. // }
  13349. options.templateOptions.UserService.addData(
  13350. "requester",
  13351. data
  13352. ).then(function (response) {
  13353. if (response.status == 200) {
  13354. if (options.model) {
  13355. options.model.requester = response.data;
  13356. $scope.$parent.$parent.$parent.model.incident.requester =
  13357. response.data;
  13358. $scope.$parent.$parent.$parent.model.requestershow =
  13359. response.data;
  13360. if (options.model.place) {
  13361. options.model.place.id = "";
  13362. }
  13363. if (options.model.area) {
  13364. options.model.area.id = "";
  13365. }
  13366. options.model.contacts = selectedItem.name;
  13367. if (
  13368. selectedItem.mphone &&
  13369. selectedItem.mphone != null &&
  13370. selectedItem.mphone != ""
  13371. ) {
  13372. options.model.contactsInformation =
  13373. selectedItem.mphone;
  13374. } else {
  13375. options.model.contactsInformation =
  13376. selectedItem.telephone;
  13377. }
  13378. if (
  13379. selectedItem.requesterTypeDTO &&
  13380. selectedItem.requesterTypeDTO.id == 2
  13381. ) {
  13382. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13383. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13384. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13385. }
  13386. }
  13387. if (!response.data.id) {
  13388. response.data.id = selectedItem.id;
  13389. }
  13390. options.value(response.data);
  13391. options.value(response.data);
  13392. console.log($scope, "0000000");
  13393. //新增报修人带入区域地点2020年4月23日19:48:15
  13394. $scope.model.selecthouseNumber = selectedItem.place
  13395. ? selectedItem.place
  13396. : {};
  13397. $scope.$root.selecthouseNumber = selectedItem.place
  13398. ? selectedItem.place
  13399. : {};
  13400. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13401. if (selectedItem.place && selectedItem.place.id) {
  13402. options.model.place.id = selectedItem.place.id;
  13403. options.model.place.area.id =
  13404. selectedItem.place.area.id;
  13405. }
  13406. } else {
  13407. if (selectedItem.place && selectedItem.place.id) {
  13408. options.model.place.id = selectedItem.place.id;
  13409. options.model.area.id = selectedItem.place.area.id;
  13410. }
  13411. }
  13412. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13413. // options.model.area.id = selectedItem.place.area.id
  13414. // }
  13415. if (selectedItem.houseNumber) {
  13416. options.model.houseNumber = selectedItem.houseNumber;
  13417. }
  13418. // if (selectedItem.id) {
  13419. options.model.account = selectedItem.account;
  13420. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13421. var baoxiuFields =
  13422. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13423. .fields[1].fields;
  13424. var baoxiurenTo;
  13425. baoxiuFields.forEach((e, i) => {
  13426. if (e.key == "account") {
  13427. baoxiurenTo = e.templateOptions;
  13428. baoxiurenTo.APIService.fetchDataList("requester", {
  13429. idx: 0,
  13430. sum: 20,
  13431. requester: {
  13432. searchKey: selectedItem.account,
  13433. },
  13434. }).then((res) => {
  13435. baoxiurenTo.options = res.list;
  13436. options.model.account = selectedItem.account;
  13437. });
  13438. }
  13439. });
  13440. // }
  13441. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  13442. // 选择重复事件侧滑框
  13443. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  13444. $scope.$parent.$parent.$parent.model[
  13445. "repeatIncidentShow"
  13446. ] = false;
  13447. setTimeout(() => {
  13448. $scope.$parent.$parent.$parent.model[
  13449. "repeatIncidentShow"
  13450. ] = true;
  13451. }, 500);
  13452. // }
  13453. } else {
  13454. modalInstance.SweetAlert.swal({
  13455. title: "系统错误",
  13456. text: "账号重复!",
  13457. type: "error",
  13458. });
  13459. }
  13460. });
  13461. }
  13462. },
  13463. function () { }
  13464. );
  13465. },
  13466. changeRequeter: function (
  13467. size,
  13468. options,
  13469. modal,
  13470. modeldata,
  13471. $rootScope
  13472. ) {
  13473. var modalInstance = modal.open({
  13474. templateUrl:
  13475. "assets/views/customform/tpl/modal-change-requester.html",
  13476. controller: function (
  13477. $scope,
  13478. $modalInstance,
  13479. items,
  13480. SweetAlert,
  13481. title,
  13482. Restangular,
  13483. APIService,
  13484. UserService,
  13485. api_user_data,
  13486. $rootScope
  13487. ) {
  13488. $scope.title = "修改报修人";
  13489. $scope.requester = {
  13490. id: modeldata.requester.id,
  13491. account: modeldata.requester.account,
  13492. name: modeldata.requester.name,
  13493. gender: modeldata.requester.gender,
  13494. email: modeldata.requester.email,
  13495. deptName: modeldata.requester.deptName,
  13496. mphone: modeldata.requester.mphone,
  13497. telephone: modeldata.requester.telephone,
  13498. studentNo: modeldata.requester.studentNo,
  13499. areaDTO: modeldata.requester.areaDTO,
  13500. placeDTO: modeldata.requester.placeDTO,
  13501. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  13502. };
  13503. $scope.onChangeadd = function (searchData) {
  13504. console.log(searchData);
  13505. $scope.searchKey = searchData.account;
  13506. var requesdata = angular.copy(searchData);
  13507. if (requesdata.mphone) {
  13508. delete requesdata.mphone;
  13509. }
  13510. $scope.requester = requesdata;
  13511. };
  13512. $scope.refreshUseradd = function (searchKey) {
  13513. //请求人搜索
  13514. $scope.requester.account = searchKey;
  13515. $scope.searchData = searchKey;
  13516. serchdataadd(searchKey);
  13517. };
  13518. $scope.getMydata = function (x) {
  13519. $scope.searchField = JSON.parse(x[0]).account;
  13520. $scope.requester = JSON.parse(x[0]);
  13521. };
  13522. $scope.getMydataone = function (x) {
  13523. $scope.searchField = x;
  13524. $scope.requester.account = x;
  13525. };
  13526. serchdataadd();
  13527. function serchdataadd(searchKey) {
  13528. if (searchKey) {
  13529. var filterData = {
  13530. requester: {
  13531. searchKey: searchKey,
  13532. },
  13533. idx: 0,
  13534. sum: 10,
  13535. };
  13536. } else {
  13537. var filterData = {
  13538. idx: 0,
  13539. sum: 10,
  13540. };
  13541. }
  13542. api_user_data
  13543. .fetchDataList("requester", filterData)
  13544. .then(function (response) {
  13545. var myData = response;
  13546. $scope.myData = myData.list;
  13547. });
  13548. }
  13549. api_user_data
  13550. .fetchDataList("area", {
  13551. idx: 0,
  13552. sum: 1000,
  13553. })
  13554. .then(function (response) {
  13555. if (response.status == 200) {
  13556. $scope.areas = response.list;
  13557. }
  13558. });
  13559. api_user_data
  13560. .fetchDataList("requesterType", {
  13561. idx: 0,
  13562. sum: 100,
  13563. })
  13564. .then(function (response) {
  13565. if (response.status == 200) {
  13566. $scope.networktypes = response.list;
  13567. }
  13568. });
  13569. if (
  13570. $scope.requester.areaDTO &&
  13571. $scope.requester.areaDTO.id &&
  13572. $scope.requester.areaDTO.id != ""
  13573. ) {
  13574. api_user_data
  13575. .fetchDataList("place", {
  13576. place: {
  13577. areaId: $scope.requester.areaDTO.id,
  13578. },
  13579. idx: 0,
  13580. sum: 1000,
  13581. })
  13582. .then(function (response) {
  13583. if (response.status == 200) {
  13584. $scope.places = response.list;
  13585. }
  13586. });
  13587. }
  13588. $scope.onChange = function (item) {
  13589. $scope.requester.placeDTO = {};
  13590. api_user_data
  13591. .fetchDataList("place", {
  13592. place: {
  13593. areaId: item.id,
  13594. },
  13595. idx: 0,
  13596. sum: 1000,
  13597. })
  13598. .then(function (response) {
  13599. if (response.status == 200) {
  13600. $scope.places = response.list;
  13601. }
  13602. });
  13603. };
  13604. $scope.refreshDepts = function (key) {
  13605. var filterData = {
  13606. idx: 0,
  13607. sum: 5,
  13608. dept: {
  13609. name: key,
  13610. },
  13611. };
  13612. UserService.fetchDataList("department", filterData).then(
  13613. function (response) {
  13614. if (response.status == 200) {
  13615. $scope.depts = response.list;
  13616. }
  13617. }
  13618. );
  13619. };
  13620. $scope.ok = function () {
  13621. if (
  13622. $scope.requester.account == "" ||
  13623. $scope.requester.name == ""
  13624. ) {
  13625. SweetAlert.swal(
  13626. "报修人姓名或人员编号号未填!",
  13627. "请补全报修人信息",
  13628. "error"
  13629. );
  13630. } else {
  13631. $modalInstance.close($scope.requester);
  13632. }
  13633. };
  13634. $scope.cancel = function () {
  13635. $modalInstance.dismiss("cancel");
  13636. };
  13637. },
  13638. resolve: {
  13639. items: function () {
  13640. return {
  13641. fetchItems: function (filterData, APIService) {
  13642. filterData = filterData || {};
  13643. if (!filterData.idx) {
  13644. filterData = {
  13645. idx: 0,
  13646. sum: 10,
  13647. };
  13648. }
  13649. return options.templateOptions.fetchItems(
  13650. filterData,
  13651. APIService
  13652. );
  13653. },
  13654. };
  13655. },
  13656. title: function () {
  13657. return options.templateOptions.modalTitle;
  13658. },
  13659. Restangular: function () {
  13660. return options.templateOptions.Restangular;
  13661. },
  13662. APIService: function () {
  13663. return options.templateOptions.ApiService;
  13664. },
  13665. UserService: function () {
  13666. return options.templateOptions.UserService;
  13667. },
  13668. },
  13669. });
  13670. modalInstance.result.then(
  13671. function (selectedItem) {
  13672. console.log(selectedItem);
  13673. if (selectedItem) {
  13674. if (options.model) {
  13675. if (options.model.place) {
  13676. options.model.place.id = "";
  13677. }
  13678. if (options.model.area) {
  13679. options.model.area.id = "";
  13680. }
  13681. options.model.contacts = selectedItem.name;
  13682. if (
  13683. selectedItem.mphone &&
  13684. selectedItem.mphone != null &&
  13685. selectedItem.mphone != ""
  13686. ) {
  13687. options.model.contactsInformation = selectedItem.mphone;
  13688. } else {
  13689. options.model.contactsInformation =
  13690. selectedItem.telephone;
  13691. }
  13692. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  13693. options.model.place.id = selectedItem.placeDTO.id;
  13694. }
  13695. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  13696. options.model.area.id = selectedItem.areaDTO.id;
  13697. }
  13698. if (
  13699. selectedItem.requesterTypeDTO &&
  13700. selectedItem.requesterTypeDTO.id == 2
  13701. ) {
  13702. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13703. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13704. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13705. }
  13706. }
  13707. var data = {
  13708. requester: selectedItem,
  13709. };
  13710. options.templateOptions.UserService.addData(
  13711. "requester",
  13712. data
  13713. ).then(function (response) {
  13714. if (response.status == 200) {
  13715. $scope.$parent.$parent.$parent.model["requestershow"] =
  13716. selectedItem;
  13717. options.value(response.data);
  13718. } else {
  13719. }
  13720. });
  13721. }
  13722. },
  13723. function () { }
  13724. );
  13725. event.preventDefault();
  13726. },
  13727. },
  13728. };
  13729. },
  13730. controller: [
  13731. "$scope",
  13732. "api_user_data",
  13733. "api_statistic",
  13734. "$stateParams",
  13735. function ($scope, api_user_data, api_statistic, $stateParams) {
  13736. console.log($stateParams)
  13737. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13738. var paramsModel = JSON.parse($stateParams.model)
  13739. //来电-添加报修人
  13740. if (paramsModel.model.incident.requester.hjzxPhone) {
  13741. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  13742. }
  13743. }
  13744. $scope.options.initialValue = $scope.model[$scope.options.key];
  13745. $scope.saveReqPlace = false;
  13746. $scope.model.saveReqPlace = false;
  13747. $scope.selectGradeBox = function () {
  13748. $scope.saveReqPlace = !$scope.saveReqPlace;
  13749. console.log($scope);
  13750. $scope.model.saveReqPlace = $scope.saveReqPlace;
  13751. };
  13752. if (
  13753. $scope.model.requester &&
  13754. $scope.model.requester.requesterTypeDTO &&
  13755. $scope.model.requester.requesterTypeDTO.id == 2
  13756. ) {
  13757. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13758. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13759. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13760. }
  13761. },
  13762. ],
  13763. });
  13764. // 请求人选控件
  13765. formlyConfigProvider.setType({
  13766. name: "ui-requesterselect",
  13767. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  13768. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13769. defaultOptions: function (options, $scope) {
  13770. return {
  13771. templateOptions: {
  13772. // checkform: function(options) {
  13773. // if (options.model.requestershow) {
  13774. // options.value(options.model.requestershow);
  13775. // }
  13776. // },
  13777. validators: {
  13778. required: {
  13779. expression: function (viewValue, modelValue) {
  13780. var value = modelValue || viewValue;
  13781. return value.length >= 1;
  13782. },
  13783. },
  13784. },
  13785. openModal: function (size, options, modal) {
  13786. //查找弹出框
  13787. var modelObject = options.value();
  13788. var searchModal = function (filterSearchData) {
  13789. var modalInstance = modal.open({
  13790. templateUrl:
  13791. "assets/views/customform/tpl/checktable-modal-content.html",
  13792. controller: function (
  13793. $scope,
  13794. scope,
  13795. i18nService,
  13796. $modalInstance,
  13797. items,
  13798. title,
  13799. Restangular,
  13800. APIService,
  13801. language,
  13802. searchDatas,
  13803. api_bpm_data
  13804. ) {
  13805. $scope.langs = i18nService.getAllLangs();
  13806. $scope.lang = "zh-cn";
  13807. i18nService.setCurrentLang($scope.lang);
  13808. $scope.gridOptions = {};
  13809. $scope.gridOptions.data = "myData";
  13810. $scope.gridOptions.enableColumnResizing = true;
  13811. $scope.gridOptions.enableFiltering = true;
  13812. $scope.gridOptions.enableGridMenu = false;
  13813. $scope.gridOptions.enableRowSelection = true;
  13814. $scope.gridOptions.showGridFooter = true;
  13815. $scope.gridOptions.showColumnFooter = false;
  13816. $scope.gridOptions.fastWatch = true;
  13817. $scope.gridOptions.useExternalFiltering = true;
  13818. $scope.gridOptions.useExternalPagination = true;
  13819. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  13820. $scope.gridOptions.paginationPageSize = 10;
  13821. $scope.gridOptions.multiSelect = false;
  13822. $scope.gridOptions.rowIdentity = function (row) {
  13823. return row.id;
  13824. };
  13825. $scope.gridOptions.getRowIdentity = function (row) {
  13826. return row.id;
  13827. };
  13828. $scope.gridOptions.columnDefs = [
  13829. {
  13830. name: "account",
  13831. displayName: "人员编号",
  13832. width: 140,
  13833. },
  13834. {
  13835. name: "name",
  13836. displayName: "姓名",
  13837. width: 100,
  13838. },
  13839. {
  13840. name: "gender.name",
  13841. displayName: "性别",
  13842. width: 80,
  13843. enableFiltering: false,
  13844. },
  13845. {
  13846. name: "mphone",
  13847. displayName: "电话",
  13848. width: 100,
  13849. enableFiltering: false,
  13850. },
  13851. {
  13852. name: "email",
  13853. displayName: "邮件",
  13854. width: 100,
  13855. },
  13856. {
  13857. name: "areaDTO.area",
  13858. displayName: "区域",
  13859. width: 100,
  13860. enableFiltering: false,
  13861. },
  13862. {
  13863. name: "placeDTO.place",
  13864. displayName: "地点",
  13865. enableFiltering: false,
  13866. },
  13867. ];
  13868. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13869. $scope.gridApi = gridApi;
  13870. // var filtersData = $scope.memoryfilterData;
  13871. // filtersData.idx = newPage - 1;
  13872. // filtersData.sum = pageSize;
  13873. gridApi.pagination.on.paginationChanged(
  13874. $scope,
  13875. function (newPage, pageSize) {
  13876. var filtersData = $scope.memoryfilterData;
  13877. filtersData.idx = newPage - 1;
  13878. filtersData.sum = pageSize;
  13879. $scope.loadData(filtersData);
  13880. }
  13881. );
  13882. gridApi.selection.on.rowSelectionChanged(
  13883. $scope,
  13884. function (data) {
  13885. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  13886. $scope.selected.item = data.entity;
  13887. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  13888. }
  13889. );
  13890. gridApi.core.on.filterChanged($scope, function () {
  13891. var grid = this.grid;
  13892. var filtersData = {
  13893. idx: 0,
  13894. sum: 10,
  13895. // 'requester': { 'userType': 1 }
  13896. };
  13897. angular.forEach(grid.columns, function (item) {
  13898. if (item.enableFiltering) {
  13899. if (
  13900. angular.isDefined(item.filters[0].term) &&
  13901. item.filters[0].term != ""
  13902. ) {
  13903. if (angular.isUndefined(filtersData["requester"])) {
  13904. filtersData["requester"] = {};
  13905. }
  13906. filtersData["requester"][item.field] =
  13907. item.filters[0].term;
  13908. }
  13909. }
  13910. });
  13911. $scope.memoryfilterData = filtersData;
  13912. $scope.loadData(filtersData);
  13913. });
  13914. };
  13915. $scope.memoryfilterData = defaultFilterData = {
  13916. idx: 0,
  13917. sum: 10,
  13918. };
  13919. $scope.loadData = function (filterData) {
  13920. if (!filterData.requester) {
  13921. filterData.requester = {};
  13922. }
  13923. if (scope.roleidcode) {
  13924. angular.extend(filterData["requester"], {
  13925. userType: 1,
  13926. });
  13927. }
  13928. items
  13929. .fetchItems(filterData, APIService)
  13930. .then(function (data) {
  13931. var myData = Restangular.stripRestangular(data);
  13932. $scope.gridOptions.totalItems = myData.totalNum;
  13933. $scope.myData = myData.list;
  13934. });
  13935. };
  13936. // $scope.title = title;
  13937. if (searchDatas) {
  13938. $scope.loadData(searchDatas);
  13939. } else {
  13940. $scope.loadData({
  13941. idx: 0,
  13942. sum: 10,
  13943. });
  13944. }
  13945. $scope.selected = {
  13946. item: {},
  13947. };
  13948. $scope.ok = function () {
  13949. $modalInstance.close($scope.selected.item);
  13950. };
  13951. $scope.cancel = function () {
  13952. $modalInstance.dismiss("cancel");
  13953. };
  13954. },
  13955. size: size,
  13956. resolve: {
  13957. items: function () {
  13958. return {
  13959. fetchItems: function (filterData, APIService) {
  13960. filterData = filterData || {};
  13961. if (
  13962. angular.isUndefined(filterData.idx) ||
  13963. filterData.idx == null
  13964. ) {
  13965. filterData = {
  13966. idx: 0,
  13967. sum: 10,
  13968. };
  13969. }
  13970. return options.templateOptions.fetchItems(
  13971. filterData,
  13972. APIService
  13973. );
  13974. },
  13975. };
  13976. },
  13977. title: function () {
  13978. return options.templateOptions.modalTitle;
  13979. },
  13980. Restangular: function () {
  13981. return options.templateOptions.Restangular;
  13982. },
  13983. APIService: function () {
  13984. return options.templateOptions.ApiService;
  13985. },
  13986. language: function () {
  13987. return options.templateOptions.language;
  13988. },
  13989. searchDatas: function () {
  13990. return filterSearchData;
  13991. },
  13992. scope: function () {
  13993. return $scope;
  13994. },
  13995. },
  13996. });
  13997. modalInstance.result.then(
  13998. function (selectedItem) {
  13999. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14000. selectedItem.telephone =
  14001. $scope.model.incident.contactsInformation;
  14002. }
  14003. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14004. selectedItem;
  14005. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14006. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14007. if ($scope.model) {
  14008. if ($scope.model.incident.place) {
  14009. $scope.model.incident.place.id = "";
  14010. }
  14011. if ($scope.model.area) {
  14012. $scope.model.incident.area.id = "";
  14013. }
  14014. $scope.model.incident.contacts = selectedItem.name;
  14015. if (
  14016. selectedItem.mphone &&
  14017. selectedItem.mphone != null &&
  14018. selectedItem.mphone != ""
  14019. ) {
  14020. $scope.model.incident.contactsInformation =
  14021. selectedItem.mphone;
  14022. } else {
  14023. $scope.model.incident.contactsInformation =
  14024. selectedItem.telephone;
  14025. }
  14026. $scope.model.incident.houseNumber = "";
  14027. if (
  14028. selectedItem.requesterTypeDTO &&
  14029. selectedItem.requesterTypeDTO.id == 2
  14030. ) {
  14031. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14032. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14033. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14034. }
  14035. }
  14036. $scope.options.value(selectedItem);
  14037. $scope.searchData = selectedItem.account;
  14038. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14039. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14040. }
  14041. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14042. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14043. }
  14044. if (selectedItem.houseNumber) {
  14045. $scope.model.incident.houseNumber =
  14046. selectedItem.houseNumber;
  14047. }
  14048. if (
  14049. selectedItem.requesterTypeDTO &&
  14050. selectedItem.requesterTypeDTO.id == 2
  14051. ) {
  14052. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14053. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14054. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14055. }
  14056. if (
  14057. options.templateOptions.callback &&
  14058. angular.isFunction(options.templateOptions.callback)
  14059. ) {
  14060. options.templateOptions.callback(selectedItem, options);
  14061. }
  14062. if (!$scope.roleidcode) {
  14063. $scope.charging(selectedItem, modal);
  14064. }
  14065. $scope.recentlyincident(selectedItem);
  14066. },
  14067. function () {
  14068. //console.log('Modal dismissed at: ' + new Date());
  14069. }
  14070. );
  14071. };
  14072. searchModal();
  14073. // }
  14074. },
  14075. },
  14076. };
  14077. },
  14078. controller: [
  14079. "$rootScope",
  14080. "$scope",
  14081. "ngTableParams",
  14082. "$filter",
  14083. "SweetAlert",
  14084. "moment",
  14085. function (
  14086. $rootScope,
  14087. $scope,
  14088. ngTableParams,
  14089. $filter,
  14090. SweetAlert,
  14091. moment
  14092. ) {
  14093. $scope.roleidcode = true;
  14094. // $scope.options.initialValue = undefined;
  14095. if ($rootScope.user && $rootScope.user.role) {
  14096. angular.forEach($rootScope.user.role, function (item) {
  14097. if (item.rolecode == "call center") {
  14098. $scope.roleidcode = false;
  14099. }
  14100. });
  14101. }
  14102. $scope.recently = false;
  14103. $scope.recentlyincident = function (key, model) {
  14104. //关联事件
  14105. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14106. idx: 0,
  14107. sum: 4,
  14108. incident: {
  14109. requester: {
  14110. id: key.id,
  14111. },
  14112. },
  14113. }).then(function (response) {
  14114. if (response.status == 200) {
  14115. $scope.recently = true;
  14116. $scope.recentincident = response.list;
  14117. } else {
  14118. $scope.recently = false;
  14119. }
  14120. });
  14121. $scope.bodyHeight = window.innerHeight - 100;
  14122. $(window).resize(function () {
  14123. $scope.bodyHeight = window.innerHeight - 100;
  14124. });
  14125. // $scope.shows = false;
  14126. $scope.tempData = {};
  14127. $scope.close = function () {
  14128. $scope.changes = !$scope.changes;
  14129. event.preventDefault();
  14130. };
  14131. };
  14132. $scope.charging = function (key, model) {
  14133. //计费弹出框
  14134. //用户信息
  14135. $scope.information = {};
  14136. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14137. userId: key.account,
  14138. }).then(function (response) {
  14139. // if (response.status == 200) {
  14140. if (response && response.data) {
  14141. angular.extend($scope.information, response.data[0]);
  14142. // $scope.information = response.data[0];
  14143. $scope.information.autologicDestroyTime = moment(
  14144. response.data[0].autologicDestroyTime
  14145. ).format("YYYY-MM-DD");
  14146. $scope.information.periodStartTime = moment(
  14147. response.data[0].periodStartTime
  14148. ).format("YYYY-MM-DD");
  14149. $scope.information.nextBillingTime = moment(
  14150. response.data[0].nextBillingTime
  14151. ).format("YYYY-MM-DD");
  14152. } else if (response.err) {
  14153. SweetAlert.swal(
  14154. "系统错误!",
  14155. "用户信息未取到,请刷新重试",
  14156. "error"
  14157. );
  14158. }
  14159. // }
  14160. });
  14161. //上网明细
  14162. $scope.options.templateOptions.ApiSer.fetchDataList(
  14163. "queryOnlineDetail",
  14164. {
  14165. userId: key.account,
  14166. limit: "10",
  14167. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14168. "YYYY-MM-DD HH:mm:ss"
  14169. ),
  14170. toLogoutTime: moment(new Date().getTime()).format(
  14171. "YYYY-MM-DD HH:mm:ss"
  14172. ),
  14173. }
  14174. ).then(function (response) {
  14175. // if (response.status == 200) {
  14176. if (response && response.data) {
  14177. angular.forEach(response.data, function (item, index) {
  14178. if (item.logoutTime) {
  14179. response.data[index].logoutTime = moment(
  14180. item.logoutTime
  14181. ).format("YYYY-MM-DD HH:mm:ss");
  14182. }
  14183. if (item.loginTime) {
  14184. response.data[index].loginTime = moment(
  14185. item.loginTime
  14186. ).format("YYYY-MM-DD HH:mm:ss");
  14187. }
  14188. });
  14189. $scope.logininform = response.data;
  14190. } else if (response.err) {
  14191. SweetAlert.swal(
  14192. "系统错误!",
  14193. "上网明细未取到,请刷新重试",
  14194. "error"
  14195. );
  14196. }
  14197. });
  14198. //黑名单
  14199. // $scope.information.blacklist = "否"
  14200. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14201. userId: key.account,
  14202. }).then(function (response) {
  14203. // if (response.status == 200) {
  14204. // $scope.logininformation = response.data;
  14205. if (response) {
  14206. if (response.data || response.data != null) {
  14207. $scope.information.blacklist = "是";
  14208. } else {
  14209. if (response.err) {
  14210. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14211. } else {
  14212. $scope.information.blacklist = "否";
  14213. }
  14214. }
  14215. }
  14216. // }
  14217. });
  14218. $scope.bodyHeight = window.innerHeight - 100;
  14219. $(window).resize(function () {
  14220. $scope.bodyHeight = window.innerHeight - 100;
  14221. });
  14222. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14223. // $scope.closepages = function(e) {
  14224. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14225. // event.preventDefault();
  14226. // };
  14227. // $scope.shows = false;
  14228. $scope.tempData = {};
  14229. $scope.close = function () {
  14230. $scope.changes = !$scope.changes;
  14231. event.preventDefault();
  14232. };
  14233. };
  14234. $scope.options.templateOptions.ApiService.fetchDataList(
  14235. "requesterType",
  14236. {
  14237. idx: 0,
  14238. sum: 100,
  14239. }
  14240. ).then(function (response) {
  14241. if (response.status == 200) {
  14242. $scope.networktypes = response.list;
  14243. } else {
  14244. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14245. }
  14246. });
  14247. function serchdata(searchKey) {
  14248. if (searchKey) {
  14249. var filterData = {
  14250. requester: {
  14251. searchKey: searchKey,
  14252. // 'userType': 1
  14253. },
  14254. idx: 0,
  14255. sum: 10,
  14256. };
  14257. } else {
  14258. var filterData = {
  14259. idx: 0,
  14260. requester: {},
  14261. sum: 10,
  14262. };
  14263. }
  14264. if (
  14265. $scope.model.requester &&
  14266. $scope.model.requester.requesterTypeDTO
  14267. ) {
  14268. angular.extend(filterData.requester, {
  14269. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14270. });
  14271. if (!$scope.options.model.contactsInformation) {
  14272. $scope.options.model.contactsInformation =
  14273. $scope.model.requester.mphone;
  14274. }
  14275. }
  14276. if ($scope.roleidcode) {
  14277. angular.extend(filterData["requester"], {
  14278. userType: 1,
  14279. });
  14280. }
  14281. $scope.options.templateOptions.ApiService.fetchDataList(
  14282. "requester",
  14283. filterData
  14284. ).then(function (response) {
  14285. var myData = response;
  14286. $scope.myData = myData.list;
  14287. });
  14288. }
  14289. $scope.searchData = {};
  14290. $scope.refreshUser = function (searchKey) {
  14291. //请求人搜索
  14292. if (searchKey && searchKey != "") {
  14293. serchdata(searchKey);
  14294. }
  14295. };
  14296. if (
  14297. $scope.$parent.$parent.$parent.model.incident.callID ||
  14298. $scope.$parent.$parent.$parent.model.requestershow
  14299. ) {
  14300. if (!$scope.roleidcode) {
  14301. $scope.charging(
  14302. $scope.$parent.$parent.$parent.model.incident.requester
  14303. );
  14304. }
  14305. $scope.recentlyincident(
  14306. $scope.$parent.$parent.$parent.model.incident.requester
  14307. );
  14308. }
  14309. $scope.onChange = function (searchData) {
  14310. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14311. searchData.telephone = $scope.model.incident.contactsInformation;
  14312. }
  14313. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14314. searchData;
  14315. if (!$scope.roleidcode) {
  14316. $scope.charging(searchData);
  14317. }
  14318. $scope.recentlyincident(searchData);
  14319. $scope.accountshow = false;
  14320. if ($scope.model.incident) {
  14321. if ($scope.model.incident.place) {
  14322. $scope.model.incident.place.id = "";
  14323. }
  14324. if ($scope.model.incident.area) {
  14325. $scope.model.incident.area.id = "";
  14326. }
  14327. $scope.model.incident.contacts = searchData.name;
  14328. if (
  14329. searchData.mphone &&
  14330. searchData.mphone != null &&
  14331. searchData.mphone != ""
  14332. ) {
  14333. $scope.model.incident.contactsInformation = searchData.mphone;
  14334. } else {
  14335. $scope.model.incident.contactsInformation = searchData.telephone;
  14336. }
  14337. $scope.model.incident.houseNumber = "";
  14338. if (
  14339. searchData.requesterTypeDTO &&
  14340. searchData.requesterTypeDTO.id == 2
  14341. ) {
  14342. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14343. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14344. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14345. }
  14346. }
  14347. $scope.options.value(searchData);
  14348. $scope.searchKey = searchData.account;
  14349. if (searchData.placeDTO && searchData.placeDTO.id) {
  14350. $scope.model.incident.place.id = searchData.placeDTO.id;
  14351. }
  14352. if (searchData.areaDTO && searchData.areaDTO.id) {
  14353. $scope.model.incident.area.id = searchData.areaDTO.id;
  14354. }
  14355. if (searchData.houseNumber) {
  14356. $scope.model.incident.houseNumber = searchData.houseNumber;
  14357. }
  14358. if (
  14359. searchData.requesterTypeDTO &&
  14360. searchData.requesterTypeDTO.id == 2
  14361. ) {
  14362. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14363. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14364. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14365. }
  14366. };
  14367. },
  14368. ],
  14369. });
  14370. //ui-grid-table展示控件
  14371. formlyConfigProvider.setType({
  14372. name: "ui-grid-table",
  14373. // extends: 'multiCheckbox',//去掉冒号
  14374. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  14375. defaultOptions: function (options) {
  14376. return {
  14377. templateOptions: {
  14378. linkage: function () { },
  14379. },
  14380. };
  14381. },
  14382. controller: function (
  14383. $scope,
  14384. $rootScope,
  14385. i18nService,
  14386. Restangular,
  14387. api_bpm_data,
  14388. api_statistic,
  14389. $rootScope
  14390. ) {
  14391. var loginUser = $rootScope.user;
  14392. $scope.langs = i18nService.getAllLangs();
  14393. $scope.lang = "zh-cn";
  14394. i18nService.setCurrentLang($scope.lang);
  14395. $scope.gridOptions = {};
  14396. $scope.gridOptions.data = "myData";
  14397. $scope.gridOptions.enableColumnResizing = true;
  14398. $scope.gridOptions.enableGridMenu = false;
  14399. $scope.gridOptions.enableRowSelection = true;
  14400. $scope.gridOptions.showGridFooter = false;
  14401. $scope.gridOptions.showColumnFooter = false;
  14402. $scope.gridOptions.fastWatch = true;
  14403. $scope.gridOptions.useExternalFiltering = true;
  14404. $scope.gridOptions.useExternalPagination = false;
  14405. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14406. $scope.gridOptions.paginationPageSize = 3;
  14407. $scope.gridOptions.multiSelect = false;
  14408. $scope.gridOptions.rowIdentity = function (row) {
  14409. return row.id;
  14410. };
  14411. $scope.gridOptions.getRowIdentity = function (row) {
  14412. return row.id;
  14413. };
  14414. $scope.gridOptions.columnDefs = [
  14415. {
  14416. name: "item",
  14417. displayName: "序号",
  14418. width: 80,
  14419. enableFiltering: false,
  14420. },
  14421. {
  14422. name: "incidentsign",
  14423. displayName: "单号",
  14424. width: 80,
  14425. enableFiltering: false,
  14426. },
  14427. {
  14428. name: "description",
  14429. displayName: "主题",
  14430. width: 80,
  14431. enableFiltering: false,
  14432. },
  14433. {
  14434. name: "state.name",
  14435. displayName: "状态",
  14436. width: 110,
  14437. enableFiltering: false,
  14438. },
  14439. {
  14440. name: "acceptDate",
  14441. displayName: "创建时间",
  14442. width: 160,
  14443. enableFiltering: false,
  14444. },
  14445. {
  14446. name: "requester.name",
  14447. displayName: "请求人",
  14448. width: 80,
  14449. enableFiltering: false,
  14450. },
  14451. {
  14452. name: "handlingPersonnelUser.name",
  14453. displayName: "处理人",
  14454. width: 160,
  14455. enableFiltering: false,
  14456. },
  14457. {
  14458. name: "place.place",
  14459. displayName: "区域地点",
  14460. width: 160,
  14461. enableFiltering: false,
  14462. },
  14463. ];
  14464. // var defaultFilterData = {
  14465. // "idx": 0,
  14466. // "sum": 3
  14467. // };
  14468. // // //分页控制
  14469. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14470. gridApi.pagination.on.paginationChanged(
  14471. $scope,
  14472. function (newPage, pageSize) {
  14473. var filtersData = $scope.memoryfilterData;
  14474. filtersData.idx = newPage - 1;
  14475. filtersData.sum = pageSize;
  14476. $scope.refreshData("expand-right", filtersData);
  14477. }
  14478. );
  14479. // 表格单选事件
  14480. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  14481. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  14482. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  14483. data.entity;
  14484. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  14485. data.entity.id;
  14486. var str =
  14487. data.grid.appScope.$parent.$parent.$parent.model.incident
  14488. .description || "";
  14489. str = str.split("").reverse().join("");
  14490. var del = addstr.split("").reverse().join("");
  14491. // console.log(del);
  14492. var reg = new RegExp(del);
  14493. str = str.replace(reg, "");
  14494. str = str.split("").reverse().join("");
  14495. if (
  14496. data.grid.appScope.$parent.$parent.$parent.model.incident
  14497. .associationType == "事件补充"
  14498. ) {
  14499. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  14500. null;
  14501. str += data.entity.description;
  14502. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14503. data.entity.description;
  14504. } else if (
  14505. data.grid.appScope.$parent.$parent.$parent.model.incident
  14506. .associationType == "事件已解决"
  14507. ) {
  14508. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  14509. "close";
  14510. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14511. "";
  14512. }
  14513. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  14514. str;
  14515. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  14516. data.entity.id;
  14517. });
  14518. };
  14519. // 刷新表格
  14520. setInterval(function () {
  14521. // console.log($scope.myData);
  14522. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  14523. // console.log($scope.myData);
  14524. if ($scope.myData != null) {
  14525. for (var i = 0; i < $scope.myData.length; i++) {
  14526. //添加序号
  14527. $scope.myData[i]["item"] = i + 1;
  14528. }
  14529. }
  14530. }, 1000);
  14531. },
  14532. });
  14533. //处理人信息
  14534. formlyConfigProvider.setType({
  14535. name: "ui-userinformation",
  14536. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  14537. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14538. defaultOptions: function (options) {
  14539. return {
  14540. templateOptions: {},
  14541. };
  14542. },
  14543. controller: [
  14544. "$scope",
  14545. function ($scope) {
  14546. $scope.group = "";
  14547. $scope.role = "";
  14548. if (
  14549. angular.isDefined($scope.model.handlingPersonnelUser) &&
  14550. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14551. $scope.model.handlingPersonnelUser.group.length == 1
  14552. ) {
  14553. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14554. } else {
  14555. for (
  14556. var i = 0;
  14557. i < $scope.model.handlingPersonnelUser.group.length;
  14558. i++
  14559. ) {
  14560. $scope.group +=
  14561. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14562. }
  14563. }
  14564. if (
  14565. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  14566. $scope.model.handlingPersonnelUser.role.length == 1
  14567. ) {
  14568. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  14569. } else {
  14570. for (
  14571. var i = 0;
  14572. i < $scope.model.handlingPersonnelUser.role.length;
  14573. i++
  14574. ) {
  14575. $scope.role +=
  14576. $scope.model.handlingPersonnelUser.role[i].role + ",";
  14577. }
  14578. }
  14579. $scope.options.templateOptions.that = $scope;
  14580. },
  14581. ],
  14582. });
  14583. //处理界面处理人信息
  14584. formlyConfigProvider.setType({
  14585. name: "ui-handler",
  14586. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  14587. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14588. defaultOptions: function (options) {
  14589. return {
  14590. templateOptions: {},
  14591. };
  14592. },
  14593. controller: [
  14594. "$scope",
  14595. function ($scope) {
  14596. $scope.group = "";
  14597. // $scope.role="";
  14598. if (
  14599. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14600. $scope.model.handlingPersonnelUser.group.length == 1
  14601. ) {
  14602. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14603. } else {
  14604. for (
  14605. var i = 0;
  14606. i < $scope.model.handlingPersonnelUser.group.length;
  14607. i++
  14608. ) {
  14609. $scope.group +=
  14610. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14611. }
  14612. }
  14613. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  14614. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  14615. // }else{
  14616. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  14617. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  14618. // }
  14619. // }
  14620. $scope.options.templateOptions.that = $scope;
  14621. },
  14622. ],
  14623. });
  14624. //微信事件流程
  14625. formlyConfigProvider.setType({
  14626. name: "ui-wxIncidentProcess",
  14627. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  14628. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14629. defaultOptions: function (options) {
  14630. return {
  14631. templateOptions: {},
  14632. };
  14633. },
  14634. controller: [
  14635. "$scope",
  14636. function ($scope) {
  14637. console.log($scope.model);
  14638. $scope.pingjia = false;
  14639. $scope.jiejue = false;
  14640. if ($scope.model.incidentState.value == "3") {
  14641. $scope.pingjia = true;
  14642. } else if ($scope.model.incidentState.value == "4") {
  14643. $scope.jiejue = true;
  14644. }
  14645. },
  14646. ],
  14647. });
  14648. //打电话
  14649. formlyConfigProvider.setType({
  14650. name: "ui-inputcall",
  14651. extends: "input",
  14652. templateUrl: "assets/views/customform/tpl/inputcall.html",
  14653. defaultOptions: function (options) {
  14654. return {
  14655. templateOptions: {
  14656. transform: function (value) { },
  14657. },
  14658. };
  14659. },
  14660. controller: [
  14661. "$scope",
  14662. "$rootScope",
  14663. "api_text",
  14664. "SweetAlert",
  14665. function ($scope, $rootScope, api_text, SweetAlert) {
  14666. $scope.dialout = function (teleno) {
  14667. // var gid = "@0";
  14668. // var telephone = "9" + teleno;
  14669. $rootScope.callout = 2;
  14670. // var agcount = tlwsa.tlaGetagentcount();
  14671. // var agcountFlag = false;
  14672. // console.log(teleno)
  14673. // // 查询当前话机是否签入
  14674. // for (var i = 0; i < agcount; i++) {
  14675. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  14676. // agcountFlag = true;
  14677. // }
  14678. // }
  14679. if (localStorage.getItem('phoneNumber')) {
  14680. var caller = localStorage.getItem('phoneNumber');//呼叫人
  14681. console.log(sessionStorage.getItem('phones'))
  14682. var phones = JSON.parse(sessionStorage.getItem('phones'));
  14683. var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  14684. console.log(isHuajihao)
  14685. if(isHuajihao){
  14686. tlwsa.tlaCallagc(teleno);
  14687. }else{
  14688. tlwsa.tlaCallout(teleno, caller, 0);
  14689. }
  14690. } else {
  14691. SweetAlert.swal({
  14692. title: "呼叫失败",
  14693. text: "请先签入呼叫中心!",
  14694. type: "error",
  14695. confirmButtonColor: "#DD6B55",
  14696. });
  14697. }
  14698. };
  14699. $scope.options.templateOptions.that = $scope;
  14700. },
  14701. ],
  14702. });
  14703. //关闭界面处理人信息
  14704. formlyConfigProvider.setType({
  14705. name: "ui-closehandler",
  14706. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  14707. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14708. defaultOptions: function (options) {
  14709. return {
  14710. templateOptions: {},
  14711. };
  14712. },
  14713. controller: [
  14714. "$scope",
  14715. "$rootScope",
  14716. "api_text",
  14717. function ($scope, $rootScope, api_text) {
  14718. $scope.dialout = function (teleno) {
  14719. var gid = "@0";
  14720. var telephone = "9" + teleno;
  14721. api_text
  14722. .dialout($rootScope.takes, gid, telephone)
  14723. .then(function (data) {
  14724. if (data.errno == 0) {
  14725. $rootScope.status = 6;
  14726. }
  14727. });
  14728. };
  14729. $scope.options.templateOptions.that = $scope;
  14730. },
  14731. ],
  14732. });
  14733. //用户单选控件
  14734. formlyConfigProvider.setType({
  14735. name: "ui-userselect",
  14736. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  14737. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14738. defaultOptions: function (options) {
  14739. return {
  14740. templateOptions: {
  14741. openModal: function (size, options, modal) {
  14742. var modalInstance = modal.open({
  14743. templateUrl:
  14744. "assets/views/customform/tpl/checktable-modal-content.html",
  14745. controller: function (
  14746. $scope,
  14747. i18nService,
  14748. $modalInstance,
  14749. items,
  14750. title,
  14751. Restangular,
  14752. APIService,
  14753. onDataCallback,
  14754. parentScope
  14755. ) {
  14756. $scope.langs = i18nService.getAllLangs();
  14757. $scope.lang = "zh-cn";
  14758. i18nService.setCurrentLang($scope.lang);
  14759. $scope.gridOptions = {};
  14760. $scope.gridOptions.data = "myData";
  14761. $scope.gridOptions.enableColumnResizing = true;
  14762. $scope.gridOptions.enableFiltering = true;
  14763. $scope.gridOptions.enableGridMenu = false;
  14764. $scope.gridOptions.showGridFooter = true;
  14765. $scope.gridOptions.showColumnFooter = false;
  14766. $scope.gridOptions.fastWatch = true;
  14767. $scope.gridOptions.useExternalFiltering = true;
  14768. $scope.gridOptions.useExternalPagination = true;
  14769. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14770. $scope.gridOptions.paginationPageSize = 10;
  14771. $scope.gridOptions.multiSelect = false;
  14772. $scope.gridOptions.rowIdentity = function (row) {
  14773. return row.id;
  14774. };
  14775. $scope.gridOptions.getRowIdentity = function (row) {
  14776. return row.id;
  14777. };
  14778. $scope.gridOptions.rowTemplate =
  14779. '<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>';
  14780. $scope.gridOptions.columnDefs = [
  14781. {
  14782. name: "account",
  14783. displayName: "人员编号",
  14784. width: 120,
  14785. },
  14786. {
  14787. name: "name",
  14788. displayName: "姓名",
  14789. width: 100,
  14790. cellTemplate:
  14791. "<div>" +
  14792. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  14793. "</div>",
  14794. },
  14795. // {
  14796. // name: 'gender.name',
  14797. // displayName: '性别',
  14798. // width: 80,
  14799. // enableFiltering: false
  14800. // },
  14801. {
  14802. name: "phone",
  14803. displayName: "电话",
  14804. width: 230,
  14805. enableFiltering: false,
  14806. },
  14807. {
  14808. name: "email",
  14809. displayName: "邮箱",
  14810. width: 180,
  14811. enableFiltering: false,
  14812. },
  14813. {
  14814. name: "dept.dept",
  14815. displayName: "科室",
  14816. width: 130,
  14817. enableFiltering: false,
  14818. },
  14819. {
  14820. name: "taskCount",
  14821. displayName: "处理中事件数",
  14822. enableFiltering: false,
  14823. },
  14824. ];
  14825. // $scope.selectButtonClick
  14826. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14827. $scope.gridApi = gridApi;
  14828. gridApi.pagination.on.paginationChanged(
  14829. $scope,
  14830. function (newPage, pageSize) {
  14831. var filtersData = $scope.memoryfilterData;
  14832. filtersData.idx = newPage - 1;
  14833. filtersData.sum = pageSize;
  14834. $scope.loadData(filtersData);
  14835. //console.log(pageSize);
  14836. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  14837. }
  14838. );
  14839. gridApi.selection.on.rowSelectionChanged(
  14840. $scope,
  14841. function (data) {
  14842. $scope.selected.items = data.entity;
  14843. //console.log(data);
  14844. }
  14845. );
  14846. gridApi.selection.on.rowSelectionChangedBatch(
  14847. $scope,
  14848. function (data) {
  14849. $scope.selected.items = data.entity;
  14850. //console.log(data);
  14851. }
  14852. );
  14853. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  14854. // // if (row.entity.age > 45) {
  14855. // row.grid.api.selection.selectRow(row.entity); // 选中行
  14856. // // }
  14857. // };
  14858. gridApi.core.on.filterChanged($scope, function () {
  14859. var grid = this.grid;
  14860. var filtersData = {
  14861. idx: 0,
  14862. sum: 10,
  14863. user: {
  14864. roledata: {
  14865. rolecode: "roleset",
  14866. },
  14867. selectType: "1",
  14868. },
  14869. };
  14870. angular.forEach(grid.columns, function (item) {
  14871. if (item.enableFiltering) {
  14872. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  14873. if (
  14874. angular.isDefined(item.filters[0].term) &&
  14875. item.filters[0].term != ""
  14876. ) {
  14877. if (angular.isUndefined(filtersData["user"])) {
  14878. filtersData["user"] = {};
  14879. }
  14880. filtersData["user"][item.field] =
  14881. item.filters[0].term;
  14882. }
  14883. }
  14884. });
  14885. $scope.memoryfilterData = filtersData;
  14886. $scope.loadData(filtersData);
  14887. });
  14888. };
  14889. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  14890. // if (row.entity.age > 45) {
  14891. // row.grid.api.selection.selectRow(row.entity); // 选中行
  14892. // }
  14893. // },
  14894. $scope.onDblClick = function (data, event) {
  14895. // $scope.selected.items = data.entity;
  14896. $scope.selectButtonClick(data, event);
  14897. };
  14898. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  14899. // $scope.selected.items = data.entity;
  14900. // })
  14901. // };
  14902. $scope.memoryfilterData = {
  14903. idx: 0,
  14904. sum: 10,
  14905. user: {
  14906. roledata: {
  14907. rolecode: "roleset",
  14908. },
  14909. selectType: "1",
  14910. },
  14911. };
  14912. $scope.loadData = function (filterData) {
  14913. // console.log("filtersData=111" + JSON.stringify(filterData))
  14914. items
  14915. .fetchItems(filterData, APIService)
  14916. .then(function (data) {
  14917. var myData = Restangular.stripRestangular(data);
  14918. $scope.gridOptions.totalItems = myData.totalNum;
  14919. $scope.myData = myData.list;
  14920. });
  14921. };
  14922. // $scope.title = title;
  14923. $scope.loadData({
  14924. idx: 0,
  14925. sum: 10,
  14926. user: {
  14927. roledata: {
  14928. rolecode: "roleset",
  14929. },
  14930. selectType: "1",
  14931. },
  14932. });
  14933. $scope.selected = {
  14934. items: {},
  14935. };
  14936. $scope.ok = function () {
  14937. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  14938. // onDataCallback($scope.selected.item, parentScope);
  14939. // }
  14940. $modalInstance.close($scope.selected.items);
  14941. };
  14942. $scope.cancel = function () {
  14943. $modalInstance.dismiss("cancel");
  14944. };
  14945. },
  14946. size: size,
  14947. resolve: {
  14948. items: function () {
  14949. return {
  14950. fetchItems: function (filterData, APIService) {
  14951. filterData = filterData || {};
  14952. if (
  14953. angular.isDefined(filterData.idx) &&
  14954. filterData.idx == null
  14955. ) {
  14956. filterData = {
  14957. idx: 0,
  14958. sum: 10,
  14959. user: {
  14960. roledata: {
  14961. rolecode: "roleset",
  14962. },
  14963. selectType: "1",
  14964. },
  14965. };
  14966. }
  14967. return options.templateOptions.fetchItems(
  14968. filterData,
  14969. APIService
  14970. );
  14971. },
  14972. };
  14973. },
  14974. title: function () {
  14975. return options.templateOptions.label;
  14976. },
  14977. Restangular: function () {
  14978. return options.templateOptions.Restangular;
  14979. },
  14980. APIService: function () {
  14981. return options.templateOptions.ApiService;
  14982. },
  14983. onDataCallback: function () {
  14984. return options.templateOptions.callback;
  14985. },
  14986. parentScope: function () {
  14987. return options.templateOptions.that;
  14988. },
  14989. },
  14990. });
  14991. modalInstance.result.then(
  14992. function (selectedItem) {
  14993. // console.log(selectedItem);
  14994. options.value(selectedItem);
  14995. if (
  14996. options.templateOptions.callback &&
  14997. angular.isFunction(options.templateOptions.callback)
  14998. ) {
  14999. options.templateOptions.callback(
  15000. selectedItem,
  15001. options.templateOptions.that
  15002. );
  15003. }
  15004. if (
  15005. options.templateOptions.linkData &&
  15006. angular.isFunction(options.templateOptions.linkData)
  15007. ) {
  15008. options.templateOptions.linkData(
  15009. selectedItem,
  15010. options.templateOptions.that
  15011. );
  15012. }
  15013. },
  15014. function () {
  15015. //console.log('Modal dismissed at: ' + new Date());
  15016. }
  15017. );
  15018. },
  15019. },
  15020. };
  15021. },
  15022. controller: [
  15023. "$scope",
  15024. function ($scope) {
  15025. $scope.options.templateOptions.that = $scope;
  15026. // $scope.options.model[$scope.options.key] = {}
  15027. },
  15028. ],
  15029. });
  15030. //用户单选控件(dd 单选input带搜索)
  15031. formlyConfigProvider.setType({
  15032. name: "ui-userselectSearch",
  15033. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15034. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15035. defaultOptions: function (options) {
  15036. return {
  15037. templateOptions: {
  15038. openModal: function (size, options, modal) {
  15039. var modalInstance = modal.open({
  15040. templateUrl:
  15041. "assets/views/customform/tpl/checktable-modal-content.html",
  15042. controller: function (
  15043. $scope,
  15044. i18nService,
  15045. $modalInstance,
  15046. items,
  15047. title,
  15048. Restangular,
  15049. APIService,
  15050. onDataCallback,
  15051. parentScope
  15052. ) {
  15053. $scope.langs = i18nService.getAllLangs();
  15054. $scope.lang = "zh-cn";
  15055. i18nService.setCurrentLang($scope.lang);
  15056. $scope.gridOptions = {};
  15057. $scope.gridOptions.data = "myData";
  15058. $scope.gridOptions.enableColumnResizing = true;
  15059. $scope.gridOptions.enableFiltering = true;
  15060. $scope.gridOptions.enableGridMenu = false;
  15061. $scope.gridOptions.showGridFooter = true;
  15062. $scope.gridOptions.showColumnFooter = false;
  15063. $scope.gridOptions.fastWatch = true;
  15064. $scope.gridOptions.useExternalFiltering = true;
  15065. $scope.gridOptions.useExternalPagination = true;
  15066. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15067. $scope.gridOptions.paginationPageSize = 10;
  15068. $scope.gridOptions.multiSelect = false;
  15069. $scope.gridOptions.rowIdentity = function (row) {
  15070. return row.id;
  15071. };
  15072. $scope.gridOptions.getRowIdentity = function (row) {
  15073. return row.id;
  15074. };
  15075. $scope.gridOptions.rowTemplate =
  15076. '<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>';
  15077. $scope.gridOptions.columnDefs = [
  15078. {
  15079. name: "account",
  15080. displayName: "人员编号",
  15081. width: 120,
  15082. },
  15083. {
  15084. name: "name",
  15085. displayName: "姓名",
  15086. width: 100,
  15087. cellTemplate:
  15088. "<div>" +
  15089. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15090. "</div>",
  15091. },
  15092. // {
  15093. // name: 'gender.name',
  15094. // displayName: '性别',
  15095. // width: 80,
  15096. // enableFiltering: false
  15097. // },
  15098. {
  15099. name: "phone",
  15100. displayName: "电话",
  15101. width: 230,
  15102. enableFiltering: false,
  15103. },
  15104. {
  15105. name: "email",
  15106. displayName: "邮箱",
  15107. width: 180,
  15108. enableFiltering: false,
  15109. },
  15110. {
  15111. name: "dept.dept",
  15112. displayName: "科室",
  15113. width: 130,
  15114. enableFiltering: false,
  15115. },
  15116. {
  15117. name: "taskCount",
  15118. displayName: "处理中事件数",
  15119. enableFiltering: false,
  15120. },
  15121. ];
  15122. // $scope.selectButtonClick
  15123. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15124. $scope.gridApi = gridApi;
  15125. gridApi.pagination.on.paginationChanged(
  15126. $scope,
  15127. function (newPage, pageSize) {
  15128. var filtersData = $scope.memoryfilterData;
  15129. filtersData.idx = newPage - 1;
  15130. filtersData.sum = pageSize;
  15131. $scope.loadData(filtersData);
  15132. //console.log(pageSize);
  15133. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15134. }
  15135. );
  15136. gridApi.selection.on.rowSelectionChanged(
  15137. $scope,
  15138. function (data) {
  15139. $scope.selected.items = data.entity;
  15140. //console.log(data);
  15141. }
  15142. );
  15143. gridApi.selection.on.rowSelectionChangedBatch(
  15144. $scope,
  15145. function (data) {
  15146. $scope.selected.items = data.entity;
  15147. //console.log(data);
  15148. }
  15149. );
  15150. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15151. // // if (row.entity.age > 45) {
  15152. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15153. // // }
  15154. // };
  15155. gridApi.core.on.filterChanged($scope, function () {
  15156. var grid = this.grid;
  15157. var filtersData = {
  15158. idx: 0,
  15159. sum: 10,
  15160. user: {
  15161. roledata: {
  15162. rolecode: "first-line support",
  15163. },
  15164. selectType: "1",
  15165. },
  15166. };
  15167. angular.forEach(grid.columns, function (item) {
  15168. if (item.enableFiltering) {
  15169. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15170. if (
  15171. angular.isDefined(item.filters[0].term) &&
  15172. item.filters[0].term != ""
  15173. ) {
  15174. if (angular.isUndefined(filtersData["user"])) {
  15175. filtersData["user"] = {};
  15176. }
  15177. filtersData["user"][item.field] =
  15178. item.filters[0].term;
  15179. }
  15180. }
  15181. });
  15182. $scope.memoryfilterData = filtersData;
  15183. $scope.loadData(filtersData);
  15184. });
  15185. };
  15186. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15187. // if (row.entity.age > 45) {
  15188. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15189. // }
  15190. // },
  15191. $scope.onDblClick = function (data, event) {
  15192. // $scope.selected.items = data.entity;
  15193. $scope.selectButtonClick(data, event);
  15194. };
  15195. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15196. // $scope.selected.items = data.entity;
  15197. // })
  15198. // };
  15199. $scope.memoryfilterData = {
  15200. idx: 0,
  15201. sum: 10,
  15202. user: {
  15203. roledata: {
  15204. rolecode: "first-line support",
  15205. },
  15206. selectType: "1",
  15207. },
  15208. };
  15209. $scope.loadData = function (filterData) {
  15210. // console.log("filtersData=111" + JSON.stringify(filterData))
  15211. items
  15212. .fetchItems(filterData, APIService)
  15213. .then(function (data) {
  15214. var myData = Restangular.stripRestangular(data);
  15215. $scope.gridOptions.totalItems = myData.totalNum;
  15216. $scope.myData = myData.list;
  15217. });
  15218. };
  15219. $scope.title = title;
  15220. $scope.loadData({
  15221. idx: 0,
  15222. sum: 10,
  15223. user: {
  15224. roledata: {
  15225. rolecode: "first-line support",
  15226. },
  15227. selectType: "1",
  15228. },
  15229. });
  15230. $scope.selected = {
  15231. items: {},
  15232. };
  15233. $scope.ok = function () {
  15234. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15235. // onDataCallback($scope.selected.item, parentScope);
  15236. // }
  15237. $modalInstance.close($scope.selected.items);
  15238. };
  15239. $scope.cancel = function () {
  15240. $modalInstance.dismiss("cancel");
  15241. };
  15242. },
  15243. size: size,
  15244. resolve: {
  15245. items: function () {
  15246. return {
  15247. fetchItems: function (filterData, APIService) {
  15248. filterData = filterData || {};
  15249. if (
  15250. angular.isDefined(filterData.idx) &&
  15251. filterData.idx == null
  15252. ) {
  15253. filterData = {
  15254. idx: 0,
  15255. sum: 10,
  15256. user: {
  15257. roledata: {
  15258. rolecode: "first-line support",
  15259. },
  15260. selectType: "1",
  15261. },
  15262. };
  15263. }
  15264. return options.templateOptions.fetchItems(
  15265. filterData,
  15266. APIService
  15267. );
  15268. },
  15269. };
  15270. },
  15271. title: function () {
  15272. return options.templateOptions.label;
  15273. },
  15274. Restangular: function () {
  15275. return options.templateOptions.Restangular;
  15276. },
  15277. APIService: function () {
  15278. return options.templateOptions.ApiService;
  15279. },
  15280. onDataCallback: function () {
  15281. return options.templateOptions.callback;
  15282. },
  15283. parentScope: function () {
  15284. return options.templateOptions.that;
  15285. },
  15286. },
  15287. });
  15288. modalInstance.result.then(
  15289. function (selectedItem) {
  15290. // console.log(selectedItem);
  15291. options.value(selectedItem);
  15292. if (
  15293. options.templateOptions.callback &&
  15294. angular.isFunction(options.templateOptions.callback)
  15295. ) {
  15296. options.templateOptions.callback(
  15297. selectedItem,
  15298. options.templateOptions.that
  15299. );
  15300. }
  15301. if (
  15302. options.templateOptions.linkData &&
  15303. angular.isFunction(options.templateOptions.linkData)
  15304. ) {
  15305. options.templateOptions.linkData(
  15306. selectedItem,
  15307. options.templateOptions.that
  15308. );
  15309. }
  15310. },
  15311. function () {
  15312. //console.log('Modal dismissed at: ' + new Date());
  15313. }
  15314. );
  15315. },
  15316. },
  15317. };
  15318. },
  15319. controller: [
  15320. "$scope",
  15321. function ($scope) {
  15322. $scope.options.templateOptions.that = $scope;
  15323. },
  15324. ],
  15325. });
  15326. //用户多选控件
  15327. formlyConfigProvider.setType({
  15328. name: "ui-multiuserselect",
  15329. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  15330. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15331. defaultOptions: function (options) {
  15332. return {
  15333. templateOptions: {
  15334. openModal: function (size, options, modal, model) {
  15335. var modalInstance = modal.open({
  15336. templateUrl:
  15337. "assets/views/customform/tpl/checktable-modal-content.html",
  15338. controller: function (
  15339. $scope,
  15340. $modalInstance,
  15341. i18nService,
  15342. $timeout,
  15343. items,
  15344. title,
  15345. Restangular,
  15346. APIService,
  15347. selectItems
  15348. ) {
  15349. $scope.langs = i18nService.getAllLangs();
  15350. $scope.lang = "zh-cn";
  15351. i18nService.setCurrentLang($scope.lang);
  15352. $scope.gridOptions = {};
  15353. $scope.gridOptions.data = "myData";
  15354. $scope.gridOptions.enableColumnResizing = true;
  15355. $scope.gridOptions.enableFiltering = true;
  15356. $scope.gridOptions.enableGridMenu = true;
  15357. $scope.gridOptions.showGridFooter = true;
  15358. $scope.gridOptions.showColumnFooter = true;
  15359. $scope.gridOptions.fastWatch = true;
  15360. $scope.gridOptions.useExternalFiltering = true;
  15361. $scope.gridOptions.useExternalPagination = true;
  15362. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15363. $scope.gridOptions.paginationPageSize = 10;
  15364. $scope.gridOptions.multiSelect = true;
  15365. $scope.gridOptions.rowIdentity = function (row) {
  15366. return row.id;
  15367. };
  15368. $scope.gridOptions.getRowIdentity = function (row) {
  15369. return row.id;
  15370. };
  15371. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  15372. $scope.gridOptions.columnDefs = [
  15373. // { name:'id', width:80, enableFiltering:false},
  15374. {
  15375. name: "account",
  15376. displayName: "账号",
  15377. width: 140,
  15378. },
  15379. {
  15380. name: "name",
  15381. displayName: "名称",
  15382. width: 100,
  15383. },
  15384. {
  15385. name: "gender.name",
  15386. displayName: "性别",
  15387. width: 140,
  15388. enableFiltering: false,
  15389. },
  15390. {
  15391. name: "phone",
  15392. displayName: "电话",
  15393. width: 100,
  15394. enableFiltering: false,
  15395. },
  15396. {
  15397. name: "email",
  15398. displayName: "邮件",
  15399. width: 100,
  15400. enableFiltering: false,
  15401. },
  15402. {
  15403. name: "dept.dept",
  15404. displayName: "科室",
  15405. width: 100,
  15406. enableFiltering: false,
  15407. },
  15408. {
  15409. name: "group[0].groupName",
  15410. displayName: "职位",
  15411. width: 100,
  15412. enableFiltering: false,
  15413. },
  15414. ];
  15415. $scope.selected = {
  15416. items: selectItems,
  15417. };
  15418. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15419. $scope.gridApi = gridApi;
  15420. gridApi.pagination.on.paginationChanged(
  15421. $scope,
  15422. function (newPage, pageSize) {
  15423. var filtersData = $scope.memoryfilterData;
  15424. filtersData.idx = newPage - 1;
  15425. filtersData.sum = pageSize;
  15426. $scope.loadData(filtersData);
  15427. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15428. }
  15429. );
  15430. gridApi.selection.on.rowSelectionChanged(
  15431. $scope,
  15432. function (scope) {
  15433. var j = 0;
  15434. for (
  15435. var i = 0;
  15436. i <= scope.grid.appScope.selected.items.length;
  15437. i++
  15438. ) {
  15439. if (
  15440. scope.grid.appScope.selected.items[i] == scope.entity
  15441. ) {
  15442. j++;
  15443. break;
  15444. }
  15445. }
  15446. if (j == 1) {
  15447. scope.grid.appScope.selected.items.splice(i, 1);
  15448. } else {
  15449. scope.grid.appScope.selected.items.push(scope.entity);
  15450. for (
  15451. var i = 0;
  15452. i < scope.grid.appScope.selected.items.length;
  15453. i++
  15454. ) {
  15455. for (
  15456. var z = 0;
  15457. z < scope.grid.appScope.selected.items.length;
  15458. z++
  15459. ) {
  15460. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  15461. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  15462. if (
  15463. angular.isDefined(
  15464. scope.grid.appScope.selected.items
  15465. ) &&
  15466. scope.grid.appScope.selected.items[i].id ==
  15467. scope.grid.appScope.selected.items[z].id &&
  15468. i != z
  15469. ) {
  15470. scope.grid.appScope.selected.items.splice(i, 1);
  15471. }
  15472. }
  15473. }
  15474. }
  15475. }
  15476. );
  15477. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  15478. // $scope.grid.appScope.selected.items.push($scope.entity);
  15479. // });
  15480. gridApi.core.on.filterChanged($scope, function () {
  15481. var grid = this.grid;
  15482. var filtersData = {
  15483. idx: 0,
  15484. sum: 10,
  15485. user: {
  15486. roledata: {
  15487. rolecode: options.model.currentRole,
  15488. },
  15489. selectType: "1",
  15490. },
  15491. };
  15492. angular.forEach(grid.columns, function (item) {
  15493. if (item.enableFiltering) {
  15494. //console.log("filtersData="+JSON.stringify(filtersData))
  15495. if (
  15496. angular.isDefined(item.filters[0].term) &&
  15497. item.filters[0].term != ""
  15498. ) {
  15499. if (angular.isUndefined(filtersData["user"])) {
  15500. filtersData["user"] = {};
  15501. }
  15502. filtersData["user"][item.field] =
  15503. item.filters[0].term;
  15504. }
  15505. }
  15506. });
  15507. $scope.memoryfilterData = filtersData;
  15508. $scope.loadData(filtersData);
  15509. });
  15510. };
  15511. if (!options.model) {
  15512. var mouse = {
  15513. model: {
  15514. currentRole: "",
  15515. },
  15516. };
  15517. angular.extend(options, mouse);
  15518. }
  15519. $scope.memoryfilterData = {
  15520. idx: 0,
  15521. sum: 10,
  15522. user: {
  15523. roledata: {
  15524. rolecode: options.model.currentRole,
  15525. },
  15526. selectType: "1",
  15527. },
  15528. };
  15529. $scope.loadData = function (filterData) {
  15530. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  15531. items
  15532. .fetchItems(filterData, APIService)
  15533. .then(function (data) {
  15534. var myData = Restangular.stripRestangular(data);
  15535. $scope.gridOptions.totalItems = myData.totalNum;
  15536. $scope.myData = myData.list;
  15537. //console.log($scope.gridOptions.pagination.getTotalPages());
  15538. // if($scope.selected.items){
  15539. // angular.forEach($scope.selected.items,function(selectItem){
  15540. // $scope.gridApi.selection.selectRow(selectItem);
  15541. // });
  15542. // }
  15543. });
  15544. };
  15545. // $scope.title = title;
  15546. $scope.loadData({
  15547. idx: 0,
  15548. sum: 10,
  15549. user: {
  15550. roledata: {
  15551. rolecode: options.model.currentRole,
  15552. },
  15553. selectType: "1",
  15554. },
  15555. });
  15556. // $timeout(function(){
  15557. // if($scope.selected.items){
  15558. // angular.forEach($scope.selected.items,function(selectItem){
  15559. // $scope.gridApi.selection.selectRow(selectItem);
  15560. // });
  15561. // }
  15562. // },2000)
  15563. $scope.ok = function () {
  15564. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  15565. $modalInstance.close($scope.selected.items);
  15566. };
  15567. $scope.cancel = function () {
  15568. $modalInstance.dismiss("cancel");
  15569. };
  15570. },
  15571. size: size,
  15572. resolve: {
  15573. items: function () {
  15574. return {
  15575. fetchItems: function (filterData, APIService) {
  15576. filterData = filterData || {};
  15577. if (
  15578. angular.isDefined(filterData.idx) &&
  15579. filterData.idx == null
  15580. ) {
  15581. filterData = {
  15582. idx: 0,
  15583. sum: 10,
  15584. user: {
  15585. roledata: {
  15586. rolecode: options.model.incident.currentRole,
  15587. },
  15588. selectType: "1",
  15589. },
  15590. };
  15591. }
  15592. return options.templateOptions.fetchItems(
  15593. filterData,
  15594. APIService
  15595. );
  15596. },
  15597. };
  15598. },
  15599. title: function () {
  15600. return options.templateOptions.modalTitle;
  15601. },
  15602. Restangular: function () {
  15603. return options.templateOptions.Restangular;
  15604. },
  15605. APIService: function () {
  15606. return options.templateOptions.ApiService;
  15607. },
  15608. selectItems: function () {
  15609. return model || [];
  15610. },
  15611. },
  15612. });
  15613. modalInstance.result.then(
  15614. function (selectedItem) {
  15615. options.value(selectedItem);
  15616. options.formControl.$validate();
  15617. },
  15618. function () {
  15619. //console.log('Modal dismissed at: ' + new Date());
  15620. }
  15621. );
  15622. },
  15623. },
  15624. validators: {
  15625. required: {
  15626. expression: function (viewValue, modelValue) {
  15627. var value = modelValue || viewValue;
  15628. return value.length >= 1;
  15629. },
  15630. },
  15631. },
  15632. };
  15633. },
  15634. controller: [
  15635. "$scope",
  15636. function ($scope) {
  15637. $scope.model[$scope.options.key] = [];
  15638. $scope.remove = function (itemId) {
  15639. angular.forEach(
  15640. $scope.model[$scope.options.key],
  15641. function (entry, index) {
  15642. if (entry.id == itemId) {
  15643. $scope.model[$scope.options.key].splice(index, 1);
  15644. // console.log($scope.options.formControl)
  15645. $scope.options.formControl.$validate();
  15646. } else {
  15647. }
  15648. }
  15649. );
  15650. };
  15651. },
  15652. ],
  15653. });
  15654. //用户多选控件-字符串展示
  15655. formlyConfigProvider.setType({
  15656. name: "ui-stringuserselect",
  15657. extends: "input",
  15658. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  15659. defaultOptions: function (options) {
  15660. return {
  15661. templateOptions: {
  15662. translate: "",
  15663. refreshDelay: 0,
  15664. },
  15665. };
  15666. },
  15667. controller: [
  15668. "$scope",
  15669. function ($scope) {
  15670. var keydata = "";
  15671. if (angular.isArray($scope.model)) {
  15672. angular.forEach($scope.model, function (item) {
  15673. keydata = keydata + "," + item.name;
  15674. });
  15675. }
  15676. // $scope.model[$scope.options.key] = [];
  15677. },
  15678. ],
  15679. });
  15680. //重复事件
  15681. formlyConfigProvider.setType({
  15682. name: "ui-incidentmodelselect",
  15683. extends: "input",
  15684. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  15685. defaultOptions: function (options) {
  15686. return {
  15687. templateOptions: {
  15688. openModal: function (size, options, modal) {
  15689. var modalInstance = modal.open({
  15690. templateUrl:
  15691. "assets/views/customform/tpl/checktable-modal-content.html",
  15692. controller: function (
  15693. $scope,
  15694. $rootScope,
  15695. $modalInstance,
  15696. items,
  15697. title,
  15698. Restangular,
  15699. APIService,
  15700. i18nService,
  15701. api_configure_data,
  15702. api_user_data,
  15703. api_bpm_data
  15704. ) {
  15705. $scope.langs = i18nService.getAllLangs();
  15706. $scope.lang = "zh-cn";
  15707. i18nService.setCurrentLang($scope.lang);
  15708. $scope.gridOptions = {};
  15709. $scope.gridOptions.data = "myData";
  15710. $scope.gridOptions.enableColumnResizing = true;
  15711. $scope.gridOptions.enableFiltering = true;
  15712. $scope.gridOptions.enableGridMenu = false;
  15713. $scope.gridOptions.enableRowSelection = true;
  15714. $scope.gridOptions.showGridFooter = true;
  15715. $scope.gridOptions.showColumnFooter = false;
  15716. $scope.gridOptions.fastWatch = true;
  15717. $scope.gridOptions.useExternalFiltering = true;
  15718. $scope.gridOptions.useExternalPagination = true;
  15719. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15720. $scope.gridOptions.paginationPageSize = 10;
  15721. $scope.gridOptions.multiSelect = false;
  15722. var mun = $scope.gridOptions.paginationPageSize;
  15723. $scope.gridOptions.rowIdentity = function (row) {
  15724. return row.id;
  15725. };
  15726. $scope.gridOptions.getRowIdentity = function (row) {
  15727. return row.id;
  15728. };
  15729. $scope.gridOptions.columnDefs = items.columnDefs();
  15730. $scope.transferTime = function (time) {
  15731. return moment(time).format("YYYY-MM-DD HH:mm");
  15732. };
  15733. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15734. $scope.gridApi = gridApi;
  15735. gridApi.pagination.on.paginationChanged(
  15736. $scope,
  15737. function (newPage, pageSize) {
  15738. // console.log(newPage);
  15739. // console.log(pageSize);
  15740. $scope.loadData({
  15741. idx: newPage - 1,
  15742. sum: pageSize,
  15743. });
  15744. }
  15745. );
  15746. gridApi.core.on.filterChanged($scope, function () {
  15747. var grid = this.grid;
  15748. var filtersData = {
  15749. idx: 0,
  15750. sum: 100,
  15751. };
  15752. angular.forEach(grid.columns, function (item) {
  15753. if (item.enableFiltering) {
  15754. if (
  15755. angular.isDefined(item.filters[0].term) &&
  15756. item.filters[0].term != ""
  15757. ) {
  15758. // console.log("filtersData="+JSON.stringify(filtersData))
  15759. if (angular.isUndefined(filtersData["incident"])) {
  15760. filtersData["incident"] = {};
  15761. }
  15762. filtersData["incident"][item.field] =
  15763. item.filters[0].term;
  15764. if (angular.isUndefined(filtersData["problem"])) {
  15765. filtersData["problem"] = {};
  15766. }
  15767. filtersData["problem"][item.field] =
  15768. item.filters[0].term;
  15769. if (angular.isUndefined(filtersData["change"])) {
  15770. filtersData["change"] = {};
  15771. }
  15772. filtersData["change"][item.field] =
  15773. item.filters[0].term;
  15774. if (angular.isUndefined(filtersData["release"])) {
  15775. filtersData["release"] = {};
  15776. }
  15777. filtersData["release"][item.field] =
  15778. item.filters[0].term;
  15779. }
  15780. }
  15781. });
  15782. $scope.loadData(filtersData);
  15783. });
  15784. gridApi.selection.on.rowSelectionChanged(
  15785. $scope,
  15786. function (data) {
  15787. $scope.selected.item = data.entity;
  15788. //console.log(data);
  15789. }
  15790. );
  15791. };
  15792. //资产
  15793. $scope.cmdb = {};
  15794. //资产状态
  15795. $scope.state_data = [
  15796. {
  15797. name: "全部状态",
  15798. value: "",
  15799. },
  15800. {
  15801. name: "在库",
  15802. value: "1",
  15803. },
  15804. {
  15805. name: "在线",
  15806. value: "2",
  15807. },
  15808. {
  15809. name: "借出",
  15810. value: "3",
  15811. },
  15812. {
  15813. name: "报修",
  15814. value: "4",
  15815. },
  15816. {
  15817. name: "报废",
  15818. value: "5",
  15819. },
  15820. {
  15821. name: "备用",
  15822. value: "6",
  15823. },
  15824. ];
  15825. //资产类型
  15826. $scope.wt_zcfl = function () {
  15827. api_configure_data
  15828. .fetchDataList("ciclassify", {
  15829. idx: 0,
  15830. sum: 100,
  15831. })
  15832. .then(function (data) {
  15833. console.log(data);
  15834. // $scope.wt_zclx = data.list;
  15835. console.log(data);
  15836. $scope.wtData = [];
  15837. if (data.status == 200) {
  15838. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  15839. var root = null; //Initially set our loop to null
  15840. var parentNode = null;
  15841. //loop over data
  15842. // $scope.wtData=data.list;
  15843. data = data.list;
  15844. //知识库分类数据三级处理
  15845. for (var i = 0; i < data.length; i++) {
  15846. // console.log(data[i])
  15847. var datum = data[i];
  15848. //each node will have children, so let's give it a "children" poperty
  15849. // console.log(datum);
  15850. datum.children = [];
  15851. if (!datum.parent) {
  15852. $scope.wtData.push(datum);
  15853. // console.log($scope.wtData)
  15854. } else {
  15855. if ($scope.wtData[0]) {
  15856. if ($scope.wtData[0].id == datum.parent.id) {
  15857. $scope.wtData[0].children.push(datum);
  15858. }
  15859. for (
  15860. var j = 0;
  15861. j < $scope.wtData[0].children.length;
  15862. j++
  15863. ) {
  15864. if (
  15865. $scope.wtData[0].children[j].id ==
  15866. datum.parent.id
  15867. ) {
  15868. $scope.wtData[0].children[j].children.push(
  15869. datum
  15870. );
  15871. }
  15872. }
  15873. }
  15874. if ($scope.wtData[1]) {
  15875. if ($scope.wtData[1].id == datum.parent.id) {
  15876. $scope.wtData[1].children.push(datum);
  15877. }
  15878. for (
  15879. var j = 0;
  15880. j < $scope.wtData[1].children.length;
  15881. j++
  15882. ) {
  15883. if (
  15884. $scope.wtData[1].children[j].id ==
  15885. datum.parent.id
  15886. ) {
  15887. $scope.wtData[1].children[j].children.push(
  15888. datum
  15889. );
  15890. }
  15891. }
  15892. }
  15893. if ($scope.wtData[2]) {
  15894. if ($scope.wtData[2].id == datum.parent.id) {
  15895. $scope.wtData[2].children.push(datum);
  15896. }
  15897. for (
  15898. var j = 0;
  15899. j < $scope.wtData[2].children.length;
  15900. j++
  15901. ) {
  15902. if (
  15903. $scope.wtData[2].children[j].id ==
  15904. datum.parent.id
  15905. ) {
  15906. $scope.wtData[2].children[j].children.push(
  15907. datum
  15908. );
  15909. }
  15910. }
  15911. }
  15912. }
  15913. // console.log($scope.wtData)
  15914. idToNodeMap[datum.id] = datum;
  15915. root = datum;
  15916. // treeMap[datum.id] = root;
  15917. }
  15918. }
  15919. });
  15920. };
  15921. $scope.wt_zcfl();
  15922. //事件
  15923. //受理人,处理人
  15924. $scope.searchkeys = {};
  15925. var fieldata = {
  15926. idx: 0,
  15927. sum: 100,
  15928. flag: -1,
  15929. };
  15930. getUser(fieldata, 3);
  15931. function getUser(fieldatas, it) {
  15932. api_user_data
  15933. .fetchDataList("user", fieldatas)
  15934. .then(function (data) {
  15935. if (it == 1) {
  15936. $scope.acceptUser = data.list;
  15937. } else if (it == 2) {
  15938. $scope.handlingPersonnelUser = data.list;
  15939. } else if (it == 3) {
  15940. $scope.acceptUser = data.list;
  15941. $scope.handlingPersonnelUser = data.list;
  15942. }
  15943. });
  15944. }
  15945. //状态
  15946. $scope.othcode = {};
  15947. api_bpm_data
  15948. .fetchDataList("incidentstatus", {
  15949. idx: 0,
  15950. sum: 100,
  15951. })
  15952. .then(function (response) {
  15953. if (response) {
  15954. if ((response.status = 200)) {
  15955. $scope.state = response.list;
  15956. }
  15957. }
  15958. });
  15959. var defaultFilterData = {
  15960. assignee: $rootScope.user.id,
  15961. searchType: "todo",
  15962. idx: 0,
  15963. sum: mun,
  15964. };
  15965. var defaultFilterData1 = {
  15966. // "searchType": "todo",
  15967. idx: 0,
  15968. sum: mun,
  15969. };
  15970. //搜索
  15971. $scope.chiceIncident = function (parameters, item, stateid) {
  15972. console.log(item, stateid);
  15973. console.log($scope);
  15974. if ($scope.title == "关联资产编号") {
  15975. // alert('222222222222');
  15976. var fildata = defaultFilterData1;
  15977. $scope.gridOptions.paginationCurrentPage = 1;
  15978. var transitiondata = angular.copy(item);
  15979. angular.extend(fildata, transitiondata);
  15980. if (fildata.hw_state) {
  15981. fildata.hw_state = fildata.hw_state.name;
  15982. }
  15983. if (fildata.sign) {
  15984. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  15985. fildata.sign = fildata.sign.split(";");
  15986. fildata.sign = fildata.sign.join("");
  15987. fildata.sign = fildata.sign.toLowerCase();
  15988. }
  15989. if (fildata.keys) {
  15990. fildata["searchCriteria"] = "uuid";
  15991. }
  15992. console.log(fildata);
  15993. $scope.loadData(fildata);
  15994. }
  15995. if ($scope.title == "关联事件工单") {
  15996. // alert('3333333333333333')
  15997. if (stateid && stateid.code) {
  15998. item.statusId = stateid.code;
  15999. }
  16000. var fildata = defaultFilterData;
  16001. // $scope.memoryfilterData = fildata;
  16002. if (!fildata.incident) {
  16003. fildata["incident"] = {};
  16004. }
  16005. $scope.gridOptions.paginationCurrentPage = 1;
  16006. var transitiondata = angular.copy(item);
  16007. angular.extend(fildata.incident, transitiondata);
  16008. console.log(fildata);
  16009. // $scope.loadData(fildata);
  16010. api_bpm_data
  16011. .fetchDataList("incident", fildata)
  16012. .then(function (data) {
  16013. console.log(data);
  16014. if (data) {
  16015. $scope.myData = data.list;
  16016. $scope.gridOptions.totalItems = data.totalNum;
  16017. }
  16018. });
  16019. }
  16020. };
  16021. //重置
  16022. $scope.replacement = function (
  16023. parameters,
  16024. searchkeys,
  16025. othcode
  16026. ) {
  16027. // console.log(parameters, searchkeys, othcode);
  16028. delete defaultFilterData.incident;
  16029. console.log(defaultFilterData);
  16030. $scope.parameters = null;
  16031. $scope.searchkeys = {};
  16032. $scope.othcode = {};
  16033. $scope.wt_zcfl();
  16034. };
  16035. $scope.loadData = function (filterData) {
  16036. items
  16037. .fetchItems(filterData, APIService, $rootScope)
  16038. .then(function (data) {
  16039. var myData = Restangular.stripRestangular(data);
  16040. if (myData.data && myData.data.node) {
  16041. $scope.gridOptions.totalItems = myData.total;
  16042. $scope.myData = myData.data.node;
  16043. } else {
  16044. if (myData.resultCount) {
  16045. $scope.gridOptions["totalItems"] = myData.resultCount;
  16046. } else {
  16047. $scope.gridOptions.totalItems = myData.totalNum;
  16048. }
  16049. if (myData.list) {
  16050. $scope.myData = myData.list;
  16051. } else {
  16052. $scope.myData = myData.data;
  16053. }
  16054. }
  16055. });
  16056. };
  16057. $scope.title = title;
  16058. $scope.loadData({
  16059. idx: 0,
  16060. sum: 10,
  16061. });
  16062. $scope.selected = {
  16063. item: {},
  16064. };
  16065. $scope.ok = function () {
  16066. //console.log($scope.selected.item);
  16067. $modalInstance.close($scope.selected.item);
  16068. };
  16069. $scope.cancel = function () {
  16070. $modalInstance.dismiss("cancel");
  16071. };
  16072. },
  16073. size: size,
  16074. resolve: {
  16075. items: function () {
  16076. return {
  16077. fetchItems: function (filterData, APIService, $rootScope) {
  16078. filterData = filterData || {};
  16079. // if(!filterData.idx){
  16080. if (
  16081. angular.isDefined(filterData.idx) &&
  16082. filterData.idx == null
  16083. ) {
  16084. filterData = {
  16085. idx: 0,
  16086. sum: 10,
  16087. };
  16088. }
  16089. return options.templateOptions.fetchItems(
  16090. filterData,
  16091. APIService,
  16092. $rootScope
  16093. );
  16094. },
  16095. columnDefs: function () {
  16096. return options.templateOptions.columnDefs;
  16097. },
  16098. };
  16099. },
  16100. title: function () {
  16101. return options.templateOptions.modalTitle;
  16102. },
  16103. Restangular: function () {
  16104. return options.templateOptions.Restangular;
  16105. },
  16106. APIService: function () {
  16107. return options.templateOptions.ApiService;
  16108. },
  16109. },
  16110. });
  16111. modalInstance.result.then(
  16112. function (selectedItem) {
  16113. var selectitem = {
  16114. title: selectedItem.title,
  16115. description: selectedItem.description,
  16116. };
  16117. if (options.key == "chuku") {
  16118. if (selectedItem.assets) {
  16119. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  16120. selectedItem.assets;
  16121. }
  16122. if (selectedItem.consumables) {
  16123. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  16124. selectedItem.consumables;
  16125. }
  16126. angular.extend(
  16127. $scope.$parent.$parent.$parent.model,
  16128. selectitem
  16129. );
  16130. options.value(selectedItem);
  16131. // options.model.consumables = JSON.parse(consumables);
  16132. } else if (options.templateOptions.pkey == "change") {
  16133. console.log(options);
  16134. angular.extend(options.model);
  16135. options.value(selectedItem);
  16136. } else if (options.key == "cmdbCode") {
  16137. var zc_selectitem = selectedItem.uuid;
  16138. // angular.extend(options.model,zc_selectitem);
  16139. options.model.cmdbCode = zc_selectitem;
  16140. // angular.extend(options.model,zc_selectitem);
  16141. // options.templateOptions.displayName=zc_selectitem;
  16142. options.value(selectedItem);
  16143. console.log(options.model);
  16144. } else {
  16145. angular.extend(options.model, selectitem);
  16146. options.value(selectedItem);
  16147. }
  16148. },
  16149. function () {
  16150. //console.log('Modal dismissed at: ' + new Date());
  16151. }
  16152. );
  16153. },
  16154. },
  16155. };
  16156. },
  16157. });
  16158. //选项选择控件
  16159. formlyConfigProvider.setType({
  16160. name: "ui-modelselect",
  16161. extends: "input",
  16162. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16163. defaultOptions: function (options) {
  16164. return {
  16165. templateOptions: {
  16166. openModal: function (size, options, modal) {
  16167. var modalInstance = modal.open({
  16168. templateUrl:
  16169. "assets/views/customform/tpl/checktable-modal-content.html",
  16170. controller: function (
  16171. $scope,
  16172. $modalInstance,
  16173. items,
  16174. title,
  16175. Restangular,
  16176. APIService,
  16177. i18nService
  16178. ) {
  16179. $scope.langs = i18nService.getAllLangs();
  16180. $scope.lang = "zh-cn";
  16181. i18nService.setCurrentLang($scope.lang);
  16182. $scope.gridOptions = {};
  16183. $scope.gridOptions.data = "myData";
  16184. $scope.gridOptions.enableColumnResizing = true;
  16185. $scope.gridOptions.enableFiltering = true;
  16186. $scope.gridOptions.enableGridMenu = false;
  16187. $scope.gridOptions.enableRowSelection = true;
  16188. $scope.gridOptions.showGridFooter = true;
  16189. $scope.gridOptions.showColumnFooter = true;
  16190. $scope.gridOptions.fastWatch = true;
  16191. $scope.gridOptions.useExternalFiltering = true;
  16192. $scope.gridOptions.useExternalPagination = true;
  16193. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16194. $scope.gridOptions.paginationPageSize = 10;
  16195. $scope.gridOptions.multiSelect = false;
  16196. $scope.gridOptions.rowIdentity = function (row) {
  16197. return row.id;
  16198. };
  16199. $scope.gridOptions.getRowIdentity = function (row) {
  16200. return row.id;
  16201. };
  16202. $scope.gridOptions.columnDefs = items.columnDefs();
  16203. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16204. $scope.gridApi = gridApi;
  16205. gridApi.pagination.on.paginationChanged(
  16206. $scope,
  16207. function (newPage, pageSize) {
  16208. // console.log(newPage);
  16209. // console.log(pageSize);
  16210. $scope.loadData({
  16211. idx: newPage - 1,
  16212. sum: pageSize,
  16213. });
  16214. }
  16215. );
  16216. gridApi.core.on.filterChanged($scope, function () {
  16217. var grid = this.grid;
  16218. var filtersData = {
  16219. idx: 0,
  16220. sum: 10,
  16221. };
  16222. angular.forEach(grid.columns, function (item) {
  16223. if (item.enableFiltering) {
  16224. if (
  16225. angular.isDefined(item.filters[0].term) &&
  16226. item.filters[0].term != ""
  16227. ) {
  16228. // console.log("filtersData="+JSON.stringify(filtersData))
  16229. if (angular.isUndefined(filtersData["incident"])) {
  16230. filtersData["incident"] = {};
  16231. }
  16232. filtersData["incident"][item.field] =
  16233. item.filters[0].term;
  16234. if (angular.isUndefined(filtersData["problem"])) {
  16235. filtersData["problem"] = {};
  16236. }
  16237. filtersData["problem"][item.field] =
  16238. item.filters[0].term;
  16239. if (angular.isUndefined(filtersData["change"])) {
  16240. filtersData["change"] = {};
  16241. }
  16242. filtersData["change"][item.field] =
  16243. item.filters[0].term;
  16244. if (angular.isUndefined(filtersData["release"])) {
  16245. filtersData["release"] = {};
  16246. }
  16247. filtersData["release"][item.field] =
  16248. item.filters[0].term;
  16249. }
  16250. }
  16251. });
  16252. $scope.loadData(filtersData);
  16253. });
  16254. gridApi.selection.on.rowSelectionChanged(
  16255. $scope,
  16256. function (data) {
  16257. $scope.selected.item = data.entity;
  16258. //console.log(data);
  16259. }
  16260. );
  16261. };
  16262. $scope.loadData = function (filterData) {
  16263. items
  16264. .fetchItems(filterData, APIService)
  16265. .then(function (data) {
  16266. var myData = Restangular.stripRestangular(data);
  16267. $scope.gridOptions.totalItems = myData.totalNum;
  16268. $scope.myData = myData.list;
  16269. });
  16270. };
  16271. $scope.title = title;
  16272. $scope.loadData({
  16273. idx: 0,
  16274. sum: 10,
  16275. });
  16276. $scope.selected = {
  16277. item: {},
  16278. };
  16279. $scope.ok = function () {
  16280. if ($scope.selected.item.scheduleOrder) {
  16281. $scope.selected.item.descriptionData =
  16282. "日期:" +
  16283. $scope.selected.item.watchTime +
  16284. ";" +
  16285. "班次:" +
  16286. $scope.selected.item.scheduleOrder.description +
  16287. ";" +
  16288. "值班人:" +
  16289. $scope.selected.item.scheduleOrder.users[0].name;
  16290. }
  16291. //console.log($scope.selected.item);
  16292. $modalInstance.close($scope.selected.item);
  16293. };
  16294. $scope.cancel = function () {
  16295. $modalInstance.dismiss("cancel");
  16296. };
  16297. },
  16298. size: size,
  16299. resolve: {
  16300. items: function () {
  16301. return {
  16302. fetchItems: function (filterData, APIService) {
  16303. filterData = filterData || {};
  16304. // if(!filterData.idx){
  16305. if (
  16306. angular.isDefined(filterData.idx) &&
  16307. filterData.idx == null
  16308. ) {
  16309. filterData = {
  16310. idx: 0,
  16311. sum: 10,
  16312. };
  16313. }
  16314. return options.templateOptions.fetchItems(
  16315. filterData,
  16316. APIService,
  16317. options
  16318. );
  16319. },
  16320. columnDefs: function () {
  16321. return options.templateOptions.columnDefs;
  16322. },
  16323. };
  16324. },
  16325. title: function () {
  16326. return options.templateOptions.modalTitle;
  16327. },
  16328. Restangular: function () {
  16329. return options.templateOptions.Restangular;
  16330. },
  16331. APIService: function () {
  16332. return options.templateOptions.ApiService;
  16333. },
  16334. },
  16335. });
  16336. modalInstance.result.then(
  16337. function (selectedItem) {
  16338. options.value(selectedItem);
  16339. },
  16340. function () {
  16341. //console.log('Modal dismissed at: ' + new Date());
  16342. }
  16343. );
  16344. },
  16345. },
  16346. };
  16347. },
  16348. });
  16349. formlyConfigProvider.setType({
  16350. name: "ui-requestform",
  16351. extends: "input",
  16352. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  16353. controller: [
  16354. "$scope",
  16355. function ($scope) {
  16356. setTimeout(function () {
  16357. var filterData = {
  16358. idx: 0,
  16359. sum: 5,
  16360. incident: {
  16361. requester: {
  16362. id: "",
  16363. },
  16364. },
  16365. };
  16366. $scope.options.templateOptions
  16367. .getWorkernumber(
  16368. $scope.options.templateOptions.ApiService,
  16369. filterData
  16370. )
  16371. .then(function (result) {
  16372. var modelData =
  16373. $scope.options.templateOptions.Restangular.stripRestangular(
  16374. result
  16375. );
  16376. });
  16377. }, 1000);
  16378. },
  16379. ],
  16380. });
  16381. //报修图片展示
  16382. formlyConfigProvider.setType({
  16383. name: "ui-repair-photos",
  16384. // extends: 'label',
  16385. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  16386. controller: [
  16387. "$scope",
  16388. "api_wechatfile",
  16389. "$stateParams",
  16390. function ($scope, api_wechatfile, $stateParams) {
  16391. console.log($scope);
  16392. $scope.fileUrls = [];
  16393. if ($scope.model.wxFile) {
  16394. api_wechatfile
  16395. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  16396. .then(function (res) {
  16397. $scope.fileUrls = res.data;
  16398. });
  16399. }
  16400. console.log($stateParams);
  16401. if (
  16402. $stateParams &&
  16403. $stateParams.model &&
  16404. JSON.parse($stateParams.model) &&
  16405. JSON.parse($stateParams.model).model &&
  16406. JSON.parse($stateParams.model).model.flow
  16407. ) {
  16408. api_wechatfile
  16409. .listAttachment(
  16410. "wechatRequesterIncident",
  16411. JSON.parse($stateParams.model).model.flow
  16412. )
  16413. .then(function (res) {
  16414. $scope.fileUrls = res.data;
  16415. });
  16416. }
  16417. if ($scope.model.flow) {
  16418. api_wechatfile
  16419. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  16420. .then(function (res) {
  16421. $scope.fileUrls = res.data;
  16422. });
  16423. }
  16424. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  16425. // // setTimeout(function () {
  16426. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  16427. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  16428. // // if (modelData.status == 200) {
  16429. // // $scope.model[$scope.options.key] = modelData.data;
  16430. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  16431. // // }
  16432. // // });
  16433. // // }, 1000);
  16434. // }
  16435. $scope.showBigImg = false;
  16436. $scope.showBigImgCli = function (data) {
  16437. $scope.showBigImg = true;
  16438. $scope.bigImgUrl = data;
  16439. };
  16440. $scope.closeBigImg = function () {
  16441. $scope.showBigImg = false;
  16442. };
  16443. },
  16444. ],
  16445. });
  16446. //图片展示
  16447. formlyConfigProvider.setType({
  16448. name: "ui-showImgs",
  16449. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  16450. defaultOptions: function (options) {
  16451. return {
  16452. templateOptions: {
  16453. refresh: function (APIService, processInstanceId, data) {
  16454. return APIService.listAttachments(processInstanceId);
  16455. },
  16456. downloadUri: function (APIService, contentId) {
  16457. return APIService.downloadAttachment(contentId).getRequestedUrl();
  16458. },
  16459. view: function (APIService, contentId) {
  16460. return APIService.attachmentsPreviewUrl(contentId);
  16461. },
  16462. download: function (APIService, contentId, item) {
  16463. var item = {
  16464. url: APIService.download(contentId),
  16465. headers: headers,
  16466. };
  16467. return item;
  16468. },
  16469. refreshDelay: 0,
  16470. },
  16471. };
  16472. },
  16473. controller: [
  16474. "$scope",
  16475. "$timeout",
  16476. "$modal",
  16477. "$rootScope",
  16478. "$http",
  16479. "up_down_file",
  16480. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  16481. var _refreshDelayPromise;
  16482. /**
  16483. * refresh
  16484. */
  16485. $scope._refresh = function (refreshAttr) {
  16486. $scope.attachments = [];
  16487. if (refreshAttr !== undefined) {
  16488. if (_refreshDelayPromise) {
  16489. $timeout.cancel(_refreshDelayPromise);
  16490. }
  16491. _refreshDelayPromise = $timeout(function () {
  16492. // 暂存附件
  16493. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  16494. $scope.options.templateOptions
  16495. .refresh(
  16496. $scope.options.templateOptions.ApiService,
  16497. $scope.options.templateOptions.processInstanceId,
  16498. {
  16499. idx: 0,
  16500. sum: 1000,
  16501. }
  16502. )
  16503. .then(function (response) {
  16504. var myData =
  16505. $scope.options.templateOptions.Restangular.stripRestangular(
  16506. response
  16507. );
  16508. if (myData) {
  16509. for (var i = 0; i < myData.data.length; i++) {
  16510. $scope.attachments.push(myData.data[i]);
  16511. }
  16512. }
  16513. $scope.options.templateOptions
  16514. .refresh(
  16515. $scope.options.templateOptions.ApiService,
  16516. $scope.$parent.$parent.$parent.model.save_fileId,
  16517. {
  16518. idx: 0,
  16519. sum: 1000,
  16520. }
  16521. )
  16522. .then(function (response2) {
  16523. var myData2 =
  16524. $scope.options.templateOptions.Restangular.stripRestangular(
  16525. response2
  16526. );
  16527. if (myData2) {
  16528. for (var i = 0; i < myData2.data.length; i++) {
  16529. $scope.attachments.push(myData2.data[i]);
  16530. }
  16531. }
  16532. console.log($scope.attachments);
  16533. });
  16534. });
  16535. // 正常附件
  16536. } else {
  16537. $scope.options.templateOptions
  16538. .refresh(
  16539. $scope.options.templateOptions.ApiService,
  16540. $scope.options.templateOptions.processInstanceId,
  16541. {
  16542. idx: 0,
  16543. sum: 1000,
  16544. }
  16545. )
  16546. .then(function (response) {
  16547. var myData =
  16548. $scope.options.templateOptions.Restangular.stripRestangular(
  16549. response
  16550. );
  16551. if (myData) {
  16552. $scope.attachments = [];
  16553. $scope.imgs = [];
  16554. myData.data.forEach((e) => {
  16555. if (
  16556. e.suffix == "jpeg" ||
  16557. e.suffix == "jpg" ||
  16558. e.suffix == "svg" ||
  16559. e.suffix == "png" ||
  16560. e.suffix == "bmp" ||
  16561. e.suffix == "gif" ||
  16562. e.suffix == "tif"
  16563. ) {
  16564. $scope.imgs.push(e);
  16565. }
  16566. });
  16567. $scope.imgs = $scope.imgs.splice(0, 3);
  16568. console.log($scope.imgs);
  16569. }
  16570. });
  16571. }
  16572. }, $scope.options.templateOptions.refreshDelay);
  16573. }
  16574. };
  16575. $scope._refresh({});
  16576. // $scope.attachments = $scope.model[$scope.options.key]
  16577. // 预览
  16578. $scope.preview = function (url, idx) {
  16579. var title = $scope.imgs[idx].title;
  16580. $modal.open({
  16581. backdrop: false,
  16582. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16583. controller: function ($scope, scope, $modalInstance) {
  16584. $scope.title = title;
  16585. $scope.imageurl = url;
  16586. $scope.cancel = function () {
  16587. $modalInstance.dismiss("cancel");
  16588. };
  16589. },
  16590. resolve: {
  16591. scope: function () {
  16592. return $scope;
  16593. },
  16594. },
  16595. });
  16596. };
  16597. },
  16598. ],
  16599. });
  16600. //工单/受理人控件
  16601. formlyConfigProvider.setType({
  16602. name: "ui-workernumbersign",
  16603. // extends: 'label',
  16604. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  16605. controller: [
  16606. "$scope",
  16607. function ($scope) {
  16608. // 2020年4月24日13:20:40
  16609. console.log($scope, "docu");
  16610. // 左侧事件工单区域地点填充
  16611. $scope.model.selecthouseNumber = $scope.model.place;
  16612. if (
  16613. angular.isUndefined($scope.model[$scope.options.key]) ||
  16614. $scope.model[$scope.options.key] == null
  16615. ) {
  16616. setTimeout(function () {
  16617. $scope.options.templateOptions
  16618. .getWorkernumber($scope.options.templateOptions.ApiService)
  16619. .then(function (result) {
  16620. var modelData =
  16621. $scope.options.templateOptions.Restangular.stripRestangular(
  16622. result
  16623. );
  16624. if (modelData.status == 200) {
  16625. $scope.model[$scope.options.key] = modelData.data;
  16626. $scope.options.initialValue =
  16627. $scope.model[$scope.options.key];
  16628. }
  16629. });
  16630. }, 1000);
  16631. }
  16632. if (
  16633. $scope.options.templateOptions.user &&
  16634. (angular.isUndefined($scope.model.acceptUser) ||
  16635. $scope.model.acceptUser == null)
  16636. ) {
  16637. if (angular.isFunction($scope.options.templateOptions.transform)) {
  16638. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  16639. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  16640. // }
  16641. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16642. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16643. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  16644. }
  16645. $scope.model.acceptUser = $scope.options.templateOptions.user;
  16646. // $scope.options.initialValue = $scope.model.acceptUser;
  16647. }
  16648. },
  16649. ],
  16650. });
  16651. //工单控件-only number
  16652. formlyConfigProvider.setType({
  16653. name: "ui-workernumber",
  16654. extends: "input",
  16655. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16656. controller: [
  16657. "$scope",
  16658. function ($scope) {
  16659. if (
  16660. angular.isUndefined($scope.model[$scope.options.key]) ||
  16661. $scope.model[$scope.options.key] == null
  16662. ) {
  16663. setTimeout(function () {
  16664. $scope.options.templateOptions
  16665. .getWorkernumber($scope.options.templateOptions.ApiService)
  16666. .then(function (result) {
  16667. var modelData =
  16668. $scope.options.templateOptions.Restangular.stripRestangular(
  16669. result
  16670. );
  16671. if (modelData.status == 200) {
  16672. $scope.model[$scope.options.key] = modelData.data;
  16673. $scope.options.initialValue =
  16674. $scope.model[$scope.options.key];
  16675. }
  16676. });
  16677. }, 1000);
  16678. }
  16679. },
  16680. ],
  16681. });
  16682. //cmdb工单
  16683. formlyConfigProvider.setType({
  16684. name: "ui-cmdbworkernumber",
  16685. extends: "input",
  16686. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16687. controller: [
  16688. "$scope",
  16689. function ($scope) {
  16690. if (
  16691. angular.isUndefined($scope.model[$scope.options.key]) ||
  16692. $scope.model[$scope.options.key] == null
  16693. ) {
  16694. setTimeout(function () {
  16695. $scope.options.templateOptions
  16696. .getWorkernumber(
  16697. $scope.options.templateOptions.ApiService,
  16698. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  16699. .cifilter_classics.id
  16700. )
  16701. .then(function (result) {
  16702. var modelData =
  16703. $scope.options.templateOptions.Restangular.stripRestangular(
  16704. result
  16705. );
  16706. // if(modelData.status==200){
  16707. $scope.model[$scope.options.key] =
  16708. modelData[$scope.options.key];
  16709. $scope.options.initialValue = $scope.model[$scope.options.key];
  16710. // }
  16711. });
  16712. }, 1000);
  16713. }
  16714. },
  16715. ],
  16716. });
  16717. //简易上传图片组件
  16718. formlyConfigProvider.setType({
  16719. name: "ui-uploadImgs",
  16720. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  16721. wrapper: ["bootstrapHasError"],
  16722. controller: [
  16723. "$scope",
  16724. "fileReader",
  16725. "$parse",
  16726. "$modal",
  16727. function ($scope, fileReader, $parse, $modal) {
  16728. $scope.imgshows = [];
  16729. $scope.uploadimgs = [];
  16730. var model = $parse("upload_img");
  16731. var modelSetter = model.assign;
  16732. var uploader = ($scope.uploader =
  16733. $scope.options.templateOptions.fileUploader);
  16734. uploader.filters.push({
  16735. name: "customFilter",
  16736. fn: function (item /*{File|FileLikeObject}*/, options) {
  16737. return this.queue.length < 10;
  16738. },
  16739. });
  16740. // 添加
  16741. $scope.change = function (event) {
  16742. var element = $(".upinp");
  16743. modelSetter($scope, element[0].files[0]);
  16744. //附件预览
  16745. $scope.imgupload = event.files[0];
  16746. getFile($scope.imgupload, $scope);
  16747. //获得预览图地址并且把file对象放入上传合集内
  16748. function getFile(imgupload, $scope) {
  16749. if (!imgupload) {
  16750. return;
  16751. }
  16752. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  16753. $scope.imgshows.push(result);
  16754. var file = document.querySelector("input[type=file]").files[0];
  16755. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  16756. console.log($scope.imgshows, $scope.uploadimgs);
  16757. if ($scope.imgshows.length < 3) {
  16758. $("#upup").show();
  16759. } else {
  16760. $("#upup").hide();
  16761. }
  16762. });
  16763. }
  16764. };
  16765. // 删除
  16766. $scope.uploadimg_del = function (index, imgs) {
  16767. console.log(index, imgs);
  16768. $scope.imgshows.splice(index, 1);
  16769. $scope.uploadimgs.splice(index, 1);
  16770. if ($scope.imgshows.length < 3) {
  16771. $("#upup").show();
  16772. } else {
  16773. $("#upup").hide();
  16774. }
  16775. };
  16776. // 预览
  16777. $scope.preview = function (url, idx) {
  16778. var name = $scope.uploadimgs[idx].name;
  16779. $modal.open({
  16780. backdrop: false,
  16781. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16782. controller: function ($scope, scope, $modalInstance) {
  16783. $scope.title = name;
  16784. $scope.imageurl = url;
  16785. $scope.cancel = function () {
  16786. $modalInstance.dismiss("cancel");
  16787. };
  16788. },
  16789. resolve: {
  16790. scope: function () {
  16791. return $scope;
  16792. },
  16793. },
  16794. });
  16795. };
  16796. if (uploader) {
  16797. uploader.onWhenAddingFileFailed = function (
  16798. item /*{File|FileLikeObject}*/,
  16799. filter,
  16800. options
  16801. ) {
  16802. console.info("onWhenAddingFileFailed", item, filter, options);
  16803. };
  16804. uploader.onAfterAddingFile = function (fileItem) {
  16805. console.info("onAfterAddingFile", fileItem);
  16806. };
  16807. uploader.onAfterAddingAll = function (addedFileItems) {
  16808. console.info("onAfterAddingAll", addedFileItems);
  16809. };
  16810. uploader.onBeforeUploadItem = function (item) {
  16811. console.info("onBeforeUploadItem", item);
  16812. };
  16813. uploader.onProgressItem = function (fileItem, progress) {
  16814. console.info("onProgressItem", fileItem, progress);
  16815. };
  16816. uploader.onProgressAll = function (progress) {
  16817. console.info("onProgressAll", progress);
  16818. };
  16819. uploader.onSuccessItem = function (
  16820. fileItem,
  16821. response,
  16822. status,
  16823. headers
  16824. ) {
  16825. console.info("onSuccessItem", fileItem, response, status, headers);
  16826. };
  16827. uploader.onErrorItem = function (
  16828. fileItem,
  16829. response,
  16830. status,
  16831. headers
  16832. ) {
  16833. console.info("onErrorItem", fileItem, response, status, headers);
  16834. };
  16835. uploader.onCancelItem = function (
  16836. fileItem,
  16837. response,
  16838. status,
  16839. headers
  16840. ) {
  16841. console.info("onCancelItem", fileItem, response, status, headers);
  16842. };
  16843. uploader.onCompleteItem = function (
  16844. fileItem,
  16845. response,
  16846. status,
  16847. headers
  16848. ) {
  16849. console.info("onCompleteItem", fileItem, response, status, headers);
  16850. };
  16851. uploader.onCompleteAll = function () {
  16852. console.info("onCompleteAll");
  16853. };
  16854. }
  16855. // console.log(modelSetter)
  16856. },
  16857. ],
  16858. });
  16859. //jry-上传下载一体
  16860. formlyConfigProvider.setType({
  16861. name: "ui-upDropFile",
  16862. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  16863. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16864. defaultOptions: function (options) {
  16865. return {
  16866. templateOptions: {
  16867. view: function (APIService, contentId) {
  16868. return APIService.downloadAttachment(contentId);
  16869. },
  16870. // ApiService: 'api_wechatfile',
  16871. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  16872. // upUrl: 'common/common/uploadAttachment',
  16873. // listAttachmentUrl: 'common/common/listAttachment',
  16874. // downUrl: 'common/common/downloadAttachment',
  16875. // bindType: 'incident',
  16876. // bindId: 2323
  16877. },
  16878. // validators: {
  16879. // required: {
  16880. // expression: function(viewValue, modelValue) {
  16881. // var value = modelValue || viewValue;
  16882. // return value.length >= 1;
  16883. // }
  16884. // }
  16885. // }
  16886. };
  16887. },
  16888. controller: [
  16889. "$scope",
  16890. "$rootScope",
  16891. "Restangular",
  16892. "up_down_file",
  16893. "$http",
  16894. "api_bpm",
  16895. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  16896. console.log($scope);
  16897. $scope.showFileUp = true;
  16898. if ($scope.model.isKnowledge_detail) {
  16899. $scope.showFileUp = false;
  16900. }
  16901. if (angular.isUndefined($scope.form.dropState)) {
  16902. $scope.form.dropState = false;
  16903. }
  16904. if ($scope.model.incident) {
  16905. if ($scope.model.incident.alarm) {
  16906. console.log($scope);
  16907. if ($scope.model.incident.alarm) {
  16908. if ($scope.model.incident.alarm.alarmExtension) {
  16909. $scope.model.incident.alarm.alarmExtension =
  16910. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  16911. $scope.model.incident.alarm.alarmExtension =
  16912. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  16913. $scope.model.incident.description =
  16914. $scope.model.incident.alarm.alarmExtension;
  16915. console.log($scope.model.incident.description);
  16916. $scope.model.incident.description =
  16917. '"' +
  16918. "告警名称" +
  16919. '":' +
  16920. '"' +
  16921. $scope.model.incident.alarm.alarmSystem +
  16922. '",' +
  16923. '"' +
  16924. "告警状态" +
  16925. '":' +
  16926. '"' +
  16927. $scope.model.incident.alarm.alarmStatus +
  16928. '",' +
  16929. '"' +
  16930. "告警内容" +
  16931. '":' +
  16932. '"' +
  16933. $scope.model.incident.alarm.alarmContent +
  16934. '",' +
  16935. $scope.model.incident.description;
  16936. } else {
  16937. $scope.model.incident.description =
  16938. '"' +
  16939. "告警名称" +
  16940. '":' +
  16941. '"' +
  16942. $scope.model.incident.alarm.alarmSystem +
  16943. '",' +
  16944. '"' +
  16945. "告警状态" +
  16946. '":' +
  16947. '"' +
  16948. $scope.model.incident.alarm.alarmStatus +
  16949. '",' +
  16950. '"' +
  16951. "告警内容" +
  16952. '":' +
  16953. '"' +
  16954. $scope.model.incident.alarm.alarmContent +
  16955. '",';
  16956. }
  16957. $scope.model.incident.description =
  16958. $scope.model.incident.description.replace(/,/g, "\n");
  16959. console.log($scope.model.incident.description);
  16960. }
  16961. }
  16962. api_bpm
  16963. .tellCategory($scope.model.incident.category.id)
  16964. .then(function (wt_data) {
  16965. console.log(wt_data);
  16966. if (wt_data) {
  16967. $rootScope.wt_category = wt_data.data;
  16968. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  16969. $rootScope.wt_child = wt_data.child;
  16970. }
  16971. });
  16972. if ($scope.model.titleName == "接单") {
  16973. $scope.model.receive_code = "handler";
  16974. if (
  16975. $scope.model.incident.groupLeader &&
  16976. !$scope.model.incident.repeat
  16977. ) {
  16978. $scope.model.isHandlerUser = true;
  16979. }
  16980. }
  16981. if ($scope.model.titleName == "事件处理") {
  16982. console.log($scope.model.cmdbCode);
  16983. if ($scope.model.cmdbCode) {
  16984. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  16985. }
  16986. }
  16987. } else {
  16988. $rootScope.wt_category = "";
  16989. }
  16990. //附件上传数据
  16991. if ($scope.options.templateOptions.fileUploader) {
  16992. var uploader = ($scope.uploader =
  16993. $scope.options.templateOptions.fileUploader);
  16994. //$scope.options.templateOptions.uploader();
  16995. console.log(uploader);
  16996. // FILTERS
  16997. uploader.filters.push({
  16998. name: "customFilter",
  16999. fn: function (item /*{File|FileLikeObject}*/, options) {
  17000. return this.queue.length < 10;
  17001. },
  17002. });
  17003. }
  17004. var to = $scope.options.templateOptions;
  17005. // var bindType = $scope.model.bindType;
  17006. if (to.bindType == "incident") {
  17007. var bindId = $scope.model[to.bindType].processInstanceId;
  17008. } else if (to.bindType == "change") {
  17009. var bindId = $scope.model[to.bindType].processInstanceId;
  17010. } else {
  17011. var bindId = $scope.model[to.bindType].id;
  17012. }
  17013. //获取附件列表
  17014. $scope.listAttachmen = function () {
  17015. to.ApiService.listAttachment(
  17016. to.listAttachmentUrl,
  17017. to.bindType,
  17018. bindId
  17019. ).then(function (result) {
  17020. var myData = Restangular.stripRestangular(result);
  17021. // $scope.listAttachmens = myData;
  17022. $scope.attachments = myData.data;
  17023. });
  17024. };
  17025. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  17026. $scope.listAttachmen();
  17027. } else if (to.bindType && $scope.model[to.bindType].id) {
  17028. $scope.listAttachmen();
  17029. }
  17030. //附件上传
  17031. $scope.isUpfload = to.isUpfload;
  17032. $scope.dropfile = function (
  17033. APIService,
  17034. processInstanceId,
  17035. taskId,
  17036. userId
  17037. ) {
  17038. uploader.onBeforeUploadItem = function (item) {
  17039. angular.extend(item.headers, $rootScope.getSession());
  17040. item.url = to.ApiService.saveAttachments(
  17041. to.uploadUrl,
  17042. to.bindType,
  17043. bindId
  17044. ).getRequestedUrl();
  17045. item.formData.push({
  17046. filename: item.file.name,
  17047. });
  17048. };
  17049. uploader.uploadAll();
  17050. };
  17051. //附件下载
  17052. $scope.download = function (token, filename) {
  17053. var downUrl = to.ApiService.downloadAttachment(
  17054. to.downUrl,
  17055. token
  17056. ).getRequestedUrl();
  17057. // window.open(downUrl);
  17058. var a = document.createElement("a");
  17059. a.href = downUrl;
  17060. a.target = "_blank";
  17061. a.download = filename;
  17062. document.body.appendChild(a);
  17063. a.click();
  17064. };
  17065. //附件预览
  17066. $scope.view = function (id, previewUrl) {
  17067. if (previewUrl) {
  17068. window.open(previewUrl);
  17069. }
  17070. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  17071. // if (response.state == 200) {
  17072. // window.open(response.previewUrl);
  17073. // }
  17074. // })
  17075. };
  17076. // CALLBACKS
  17077. if (uploader) {
  17078. uploader.onWhenAddingFileFailed = function (
  17079. item /*{File|FileLikeObject}*/,
  17080. filter,
  17081. options
  17082. ) {
  17083. console.info("onWhenAddingFileFailed", item, filter, options);
  17084. };
  17085. uploader.onAfterAddingFile = function (fileItem) {
  17086. console.info("onAfterAddingFile", fileItem);
  17087. };
  17088. uploader.onAfterAddingAll = function (addedFileItems) {
  17089. console.info("onAfterAddingAll", addedFileItems);
  17090. };
  17091. uploader.onBeforeUploadItem = function (item) {
  17092. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17093. // // $scope.uploader.options.url();
  17094. // $scope.uploader.onBeforeUploadItem = function(item) {
  17095. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17096. // console.info('onBeforeUploadItem', item);
  17097. // };
  17098. // $scope.uploader.uploadAll();
  17099. // }
  17100. console.info("onBeforeUploadItem", item);
  17101. };
  17102. uploader.onProgressItem = function (fileItem, progress) {
  17103. console.info("onProgressItem", fileItem, progress);
  17104. };
  17105. uploader.onProgressAll = function (progress) {
  17106. console.info("onProgressAll", progress);
  17107. };
  17108. uploader.onSuccessItem = function (
  17109. fileItem,
  17110. response,
  17111. status,
  17112. headers
  17113. ) {
  17114. console.info("onSuccessItem", fileItem, response, status, headers);
  17115. if (response.status == 200) {
  17116. $scope.listAttachmen();
  17117. }
  17118. };
  17119. uploader.onErrorItem = function (
  17120. fileItem,
  17121. response,
  17122. status,
  17123. headers
  17124. ) {
  17125. console.info("onErrorItem", fileItem, response, status, headers);
  17126. };
  17127. uploader.onCancelItem = function (
  17128. fileItem,
  17129. response,
  17130. status,
  17131. headers
  17132. ) {
  17133. console.info("onCancelItem", fileItem, response, status, headers);
  17134. };
  17135. uploader.onCompleteItem = function (
  17136. fileItem,
  17137. response,
  17138. status,
  17139. headers
  17140. ) {
  17141. console.info("onCompleteItem", fileItem, response, status, headers);
  17142. };
  17143. uploader.onCompleteAll = function () {
  17144. console.info("onCompleteAll");
  17145. };
  17146. }
  17147. },
  17148. ],
  17149. });
  17150. //简易上传下载附件组件
  17151. formlyConfigProvider.setType({
  17152. name: "ui-upDownFiles",
  17153. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  17154. wrapper: ["bootstrapHasError"],
  17155. defaultOptions: function (options) {
  17156. return {
  17157. templateOptions: {
  17158. refresh: function (APIService, processInstanceId, data) {
  17159. return APIService.listAttachments(processInstanceId);
  17160. },
  17161. downloadUri: function (APIService, contentId) {
  17162. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17163. },
  17164. view: function (APIService, contentId) {
  17165. return APIService.attachmentsPreviewUrl(contentId);
  17166. },
  17167. download: function (APIService, contentId, item) {
  17168. var item = {
  17169. url: APIService.download(contentId),
  17170. headers: headers,
  17171. };
  17172. return item;
  17173. },
  17174. refreshDelay: 0,
  17175. },
  17176. };
  17177. },
  17178. controller: [
  17179. "$scope",
  17180. "$timeout",
  17181. "$modal",
  17182. "$rootScope",
  17183. "$http",
  17184. "up_down_file",
  17185. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17186. if (angular.isUndefined($scope.form.dropState)) {
  17187. $scope.form.dropState = false;
  17188. }
  17189. //附件上传数据
  17190. var uploader = ($scope.uploader =
  17191. $scope.options.templateOptions.fileUploader);
  17192. //$scope.options.templateOptions.uploader();
  17193. // FILTERS
  17194. uploader.filters.push({
  17195. name: "customFilter",
  17196. fn: function (item /*{File|FileLikeObject}*/, options) {
  17197. return this.queue.length < 10;
  17198. },
  17199. });
  17200. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  17201. // uploader.onBeforeUploadItem = function (item) {
  17202. // angular.extend(item.headers, $rootScope.getSession());
  17203. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  17204. // item.formData.push({
  17205. // 'fileName': item.file.name
  17206. // });
  17207. // console.info('onBeforeUploadItem', item);
  17208. // };
  17209. // }
  17210. // CALLBACKS
  17211. uploader.onWhenAddingFileFailed = function (
  17212. item /*{File|FileLikeObject}*/,
  17213. filter,
  17214. options
  17215. ) {
  17216. console.info("onWhenAddingFileFailed", item, filter, options);
  17217. };
  17218. uploader.onAfterAddingFile = function (fileItem) {
  17219. console.info("onAfterAddingFile", fileItem);
  17220. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17221. alert("文件过大");
  17222. fileItem.uploader.queue.pop();
  17223. console.log($scope);
  17224. }
  17225. };
  17226. uploader.onAfterAddingAll = function (addedFileItems) {
  17227. // console.info('onAfterAddingAll', addedFileItems);
  17228. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17229. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17230. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17231. // console.log(123)
  17232. };
  17233. uploader.onBeforeUploadItem = function (item) {
  17234. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17235. // // $scope.uploader.options.url();
  17236. // $scope.uploader.onBeforeUploadItem = function(item) {
  17237. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17238. // console.info('onBeforeUploadItem', item);
  17239. // };
  17240. // $scope.uploader.uploadAll();
  17241. // }
  17242. console.info("onBeforeUploadItem", item);
  17243. };
  17244. uploader.onProgressItem = function (fileItem, progress) {
  17245. console.info("onProgressItem", fileItem, progress);
  17246. };
  17247. uploader.onProgressAll = function (progress) {
  17248. console.info("onProgressAll", progress);
  17249. };
  17250. uploader.onSuccessItem = function (
  17251. fileItem,
  17252. response,
  17253. status,
  17254. headers
  17255. ) {
  17256. console.info("onSuccessItem", fileItem, response, status, headers);
  17257. };
  17258. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17259. console.info("onErrorItem", fileItem, response, status, headers);
  17260. };
  17261. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17262. console.info("onCancelItem", fileItem, response, status, headers);
  17263. };
  17264. uploader.onCompleteItem = function (
  17265. fileItem,
  17266. response,
  17267. status,
  17268. headers
  17269. ) {
  17270. console.info("onCompleteItem", fileItem, response, status, headers);
  17271. };
  17272. uploader.onCompleteAll = function () {
  17273. console.info("onCompleteAll");
  17274. };
  17275. var _refreshDelayPromise;
  17276. // 下载
  17277. $scope.download = function (contentId, filename, token) {
  17278. // console.log(contentId, filename, token)
  17279. //附件下载
  17280. var downUrl = up_down_file
  17281. .downloadAttachment("common/common/downloadAttachment", token)
  17282. .getRequestedUrl();
  17283. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17284. // console.log(downUrl)
  17285. var a = document.createElement("a");
  17286. a.href = downUrl;
  17287. a.target = "_blank";
  17288. a.download = filename;
  17289. document.body.appendChild(a);
  17290. a.click();
  17291. };
  17292. $scope._refresh = function (refreshAttr) {
  17293. $scope.attachments = [];
  17294. if (refreshAttr !== undefined) {
  17295. if (_refreshDelayPromise) {
  17296. $timeout.cancel(_refreshDelayPromise);
  17297. }
  17298. _refreshDelayPromise = $timeout(function () {
  17299. // 暂存附件
  17300. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17301. $scope.options.templateOptions
  17302. .refresh(
  17303. $scope.options.templateOptions.ApiService,
  17304. $scope.options.templateOptions.processInstanceId,
  17305. {
  17306. idx: 0,
  17307. sum: 1000,
  17308. }
  17309. )
  17310. .then(function (response) {
  17311. var myData =
  17312. $scope.options.templateOptions.Restangular.stripRestangular(
  17313. response
  17314. );
  17315. if (myData) {
  17316. for (var i = 0; i < myData.data.length; i++) {
  17317. $scope.attachments.push(myData.data[i]);
  17318. }
  17319. }
  17320. $scope.options.templateOptions
  17321. .refresh(
  17322. $scope.options.templateOptions.ApiService,
  17323. $scope.$parent.$parent.$parent.model.save_fileId,
  17324. {
  17325. idx: 0,
  17326. sum: 1000,
  17327. }
  17328. )
  17329. .then(function (response2) {
  17330. var myData2 =
  17331. $scope.options.templateOptions.Restangular.stripRestangular(
  17332. response2
  17333. );
  17334. if (myData2) {
  17335. for (var i = 0; i < myData2.data.length; i++) {
  17336. $scope.attachments.push(myData2.data[i]);
  17337. }
  17338. // 只展示除图片以外的附件
  17339. var a = [];
  17340. $scope.attachments.forEach((e) => {
  17341. if (
  17342. e.suffix == "jpeg" ||
  17343. e.suffix == "jpg" ||
  17344. e.suffix == "svg" ||
  17345. e.suffix == "png" ||
  17346. e.suffix == "bmp" ||
  17347. e.suffix == "gif" ||
  17348. e.suffix == "tif"
  17349. ) {
  17350. // $scope.imgs.push(e)
  17351. } else {
  17352. a.push(e);
  17353. }
  17354. });
  17355. $scope.attachments = a;
  17356. }
  17357. console.log($scope.attachments);
  17358. });
  17359. });
  17360. // 正常附件
  17361. } else {
  17362. $scope.options.templateOptions
  17363. .refresh(
  17364. $scope.options.templateOptions.ApiService,
  17365. $scope.options.templateOptions.processInstanceId,
  17366. {
  17367. idx: 0,
  17368. sum: 1000,
  17369. }
  17370. )
  17371. .then(function (response) {
  17372. var myData =
  17373. $scope.options.templateOptions.Restangular.stripRestangular(
  17374. response
  17375. );
  17376. if (myData) {
  17377. $scope.attachments = myData.data;
  17378. // 只展示除图片以外的附件
  17379. var a = [];
  17380. $scope.attachments.forEach((e) => {
  17381. if (
  17382. e.suffix == "jpeg" ||
  17383. e.suffix == "jpg" ||
  17384. e.suffix == "svg" ||
  17385. e.suffix == "png" ||
  17386. e.suffix == "bmp" ||
  17387. e.suffix == "gif" ||
  17388. e.suffix == "tif"
  17389. ) {
  17390. // $scope.imgs.push(e)
  17391. } else {
  17392. a.push(e);
  17393. }
  17394. });
  17395. $scope.attachments = a;
  17396. }
  17397. });
  17398. }
  17399. }, $scope.options.templateOptions.refreshDelay);
  17400. }
  17401. };
  17402. $scope._refresh({});
  17403. },
  17404. ],
  17405. });
  17406. //简易上传附件组件
  17407. formlyConfigProvider.setType({
  17408. name: "ui-uploadFiles",
  17409. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  17410. wrapper: ["bootstrapHasError"],
  17411. controller: [
  17412. "$scope",
  17413. function ($scope) {
  17414. if (angular.isUndefined($scope.form.dropState)) {
  17415. $scope.form.dropState = false;
  17416. }
  17417. //附件上传数据
  17418. var uploader = ($scope.uploader =
  17419. $scope.options.templateOptions.fileUploader);
  17420. //$scope.options.templateOptions.uploader();
  17421. // FILTERS
  17422. uploader.filters.push({
  17423. name: "customFilter",
  17424. fn: function (item /*{File|FileLikeObject}*/, options) {
  17425. return this.queue.length < 10;
  17426. },
  17427. });
  17428. $scope.dropfile = function (
  17429. APIService,
  17430. processInstanceId,
  17431. taskId,
  17432. userId
  17433. ) {
  17434. uploader.onBeforeUploadItem = function (item) {
  17435. angular.extend(item.headers, $rootScope.getSession());
  17436. item.url = APIService.saveAttachments(
  17437. processInstanceId,
  17438. taskId,
  17439. userId
  17440. ).getRequestedUrl();
  17441. item.formData.push({
  17442. fileName: item.file.name,
  17443. });
  17444. console.info("onBeforeUploadItem", item);
  17445. };
  17446. };
  17447. // CALLBACKS
  17448. uploader.onWhenAddingFileFailed = function (
  17449. item /*{File|FileLikeObject}*/,
  17450. filter,
  17451. options
  17452. ) {
  17453. console.info("onWhenAddingFileFailed", item, filter, options);
  17454. };
  17455. uploader.onAfterAddingFile = function (fileItem) {
  17456. console.info("onAfterAddingFile", fileItem);
  17457. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17458. alert("文件过大");
  17459. fileItem.uploader.queue.pop();
  17460. console.log($scope);
  17461. }
  17462. };
  17463. uploader.onAfterAddingAll = function (addedFileItems) {
  17464. // console.info('onAfterAddingAll', addedFileItems);
  17465. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17466. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17467. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17468. // console.log(123)
  17469. };
  17470. uploader.onBeforeUploadItem = function (item) {
  17471. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17472. // // $scope.uploader.options.url();
  17473. // $scope.uploader.onBeforeUploadItem = function(item) {
  17474. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17475. // console.info('onBeforeUploadItem', item);
  17476. // };
  17477. // $scope.uploader.uploadAll();
  17478. // }
  17479. console.info("onBeforeUploadItem", item);
  17480. };
  17481. uploader.onProgressItem = function (fileItem, progress) {
  17482. console.info("onProgressItem", fileItem, progress);
  17483. };
  17484. uploader.onProgressAll = function (progress) {
  17485. console.info("onProgressAll", progress);
  17486. };
  17487. uploader.onSuccessItem = function (
  17488. fileItem,
  17489. response,
  17490. status,
  17491. headers
  17492. ) {
  17493. console.info("onSuccessItem", fileItem, response, status, headers);
  17494. };
  17495. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17496. console.info("onErrorItem", fileItem, response, status, headers);
  17497. };
  17498. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17499. console.info("onCancelItem", fileItem, response, status, headers);
  17500. };
  17501. uploader.onCompleteItem = function (
  17502. fileItem,
  17503. response,
  17504. status,
  17505. headers
  17506. ) {
  17507. console.info("onCompleteItem", fileItem, response, status, headers);
  17508. };
  17509. uploader.onCompleteAll = function () {
  17510. console.info("onCompleteAll");
  17511. };
  17512. },
  17513. ],
  17514. });
  17515. //无上传按钮附件上传组件
  17516. formlyConfigProvider.setType({
  17517. name: "ui-dropfilenotup",
  17518. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17519. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17520. controller: [
  17521. "$scope",
  17522. function ($scope) {
  17523. if (angular.isUndefined($scope.form.dropState)) {
  17524. $scope.form.dropState = false;
  17525. }
  17526. //附件上传数据
  17527. var uploader = ($scope.uploader =
  17528. $scope.options.templateOptions.fileUploader);
  17529. //$scope.options.templateOptions.uploader();
  17530. // FILTERS
  17531. uploader.filters.push({
  17532. name: "customFilter",
  17533. fn: function (item /*{File|FileLikeObject}*/, options) {
  17534. return this.queue.length < 10;
  17535. },
  17536. });
  17537. $scope.dropfile = function (
  17538. APIService,
  17539. processInstanceId,
  17540. taskId,
  17541. userId
  17542. ) {
  17543. uploader.onBeforeUploadItem = function (item) {
  17544. angular.extend(item.headers, $rootScope.getSession());
  17545. item.url = APIService.saveAttachments(
  17546. processInstanceId,
  17547. taskId,
  17548. userId
  17549. ).getRequestedUrl();
  17550. item.formData.push({
  17551. fileName: item.file.name,
  17552. });
  17553. console.info("onBeforeUploadItem", item);
  17554. };
  17555. uploader.uploadAll();
  17556. };
  17557. // CALLBACKS
  17558. uploader.onWhenAddingFileFailed = function (
  17559. item /*{File|FileLikeObject}*/,
  17560. filter,
  17561. options
  17562. ) {
  17563. console.info("onWhenAddingFileFailed", item, filter, options);
  17564. };
  17565. uploader.onAfterAddingFile = function (fileItem) {
  17566. console.info("onAfterAddingFile", fileItem);
  17567. };
  17568. uploader.onAfterAddingAll = function (addedFileItems) {
  17569. console.info("onAfterAddingAll", addedFileItems);
  17570. };
  17571. uploader.onBeforeUploadItem = function (item) {
  17572. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17573. // // $scope.uploader.options.url();
  17574. // $scope.uploader.onBeforeUploadItem = function(item) {
  17575. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17576. // console.info('onBeforeUploadItem', item);
  17577. // };
  17578. // $scope.uploader.uploadAll();
  17579. // }
  17580. console.info("onBeforeUploadItem", item);
  17581. };
  17582. uploader.onProgressItem = function (fileItem, progress) {
  17583. console.info("onProgressItem", fileItem, progress);
  17584. };
  17585. uploader.onProgressAll = function (progress) {
  17586. console.info("onProgressAll", progress);
  17587. };
  17588. uploader.onSuccessItem = function (
  17589. fileItem,
  17590. response,
  17591. status,
  17592. headers
  17593. ) {
  17594. console.info("onSuccessItem", fileItem, response, status, headers);
  17595. };
  17596. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17597. console.info("onErrorItem", fileItem, response, status, headers);
  17598. };
  17599. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17600. console.info("onCancelItem", fileItem, response, status, headers);
  17601. };
  17602. uploader.onCompleteItem = function (
  17603. fileItem,
  17604. response,
  17605. status,
  17606. headers
  17607. ) {
  17608. console.info("onCompleteItem", fileItem, response, status, headers);
  17609. };
  17610. uploader.onCompleteAll = function () {
  17611. console.info("onCompleteAll");
  17612. };
  17613. },
  17614. ],
  17615. });
  17616. //无按钮知识库上传
  17617. formlyConfigProvider.setType({
  17618. name: "ui-dropfielkn",
  17619. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17620. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17621. controller: [
  17622. "$scope",
  17623. function ($scope) {
  17624. if (angular.isUndefined($scope.form.dropState)) {
  17625. $scope.form.dropState = false;
  17626. }
  17627. //附件上传数据
  17628. var uploader = ($scope.uploader =
  17629. $scope.options.templateOptions.fileUploader);
  17630. //$scope.options.templateOptions.uploader();
  17631. // FILTERS
  17632. uploader.filters.push({
  17633. name: "customFilter",
  17634. fn: function (item /*{File|FileLikeObject}*/, options) {
  17635. return this.queue.length < 10;
  17636. },
  17637. });
  17638. $scope.dropfile = function (
  17639. APIService,
  17640. processInstanceId,
  17641. taskId,
  17642. userId
  17643. ) {
  17644. uploader.onBeforeUploadItem = function (item) {
  17645. angular.extend(item.headers, $rootScope.getSession());
  17646. item.url = APIService.addFile(
  17647. processInstanceId,
  17648. taskId,
  17649. userId
  17650. ).getRequestedUrl();
  17651. item.formData.push({
  17652. fileName: item.file.name,
  17653. });
  17654. console.info("onBeforeUploadItem", item);
  17655. };
  17656. uploader.uploadAll();
  17657. };
  17658. // CALLBACKS
  17659. uploader.onWhenAddingFileFailed = function (
  17660. item /*{File|FileLikeObject}*/,
  17661. filter,
  17662. options
  17663. ) {
  17664. console.info("onWhenAddingFileFailed", item, filter, options);
  17665. };
  17666. uploader.onAfterAddingFile = function (fileItem) {
  17667. console.info("onAfterAddingFile", fileItem);
  17668. };
  17669. uploader.onAfterAddingAll = function (addedFileItems) {
  17670. console.info("onAfterAddingAll", addedFileItems);
  17671. };
  17672. uploader.onBeforeUploadItem = function (item) {
  17673. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17674. // // $scope.uploader.options.url();
  17675. // $scope.uploader.onBeforeUploadItem = function(item) {
  17676. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17677. // console.info('onBeforeUploadItem', item);
  17678. // };
  17679. // $scope.uploader.uploadAll();
  17680. // }
  17681. console.info("onBeforeUploadItem", item);
  17682. };
  17683. uploader.onProgressItem = function (fileItem, progress) {
  17684. console.info("onProgressItem", fileItem, progress);
  17685. };
  17686. uploader.onProgressAll = function (progress) {
  17687. console.info("onProgressAll", progress);
  17688. };
  17689. uploader.onSuccessItem = function (
  17690. fileItem,
  17691. response,
  17692. status,
  17693. headers
  17694. ) {
  17695. console.info("onSuccessItem", fileItem, response, status, headers);
  17696. };
  17697. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17698. console.info("onErrorItem", fileItem, response, status, headers);
  17699. };
  17700. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17701. console.info("onCancelItem", fileItem, response, status, headers);
  17702. };
  17703. uploader.onCompleteItem = function (
  17704. fileItem,
  17705. response,
  17706. status,
  17707. headers
  17708. ) {
  17709. console.info("onCompleteItem", fileItem, response, status, headers);
  17710. };
  17711. uploader.onCompleteAll = function () {
  17712. console.info("onCompleteAll");
  17713. };
  17714. },
  17715. ],
  17716. });
  17717. //附件上传列表组件
  17718. formlyConfigProvider.setType({
  17719. name: "ui-dropfile",
  17720. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  17721. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17722. controller: [
  17723. "$scope",
  17724. "$rootScope",
  17725. function ($scope, $rootScope) {
  17726. if (angular.isUndefined($scope.form.dropState)) {
  17727. $scope.form.dropState = false;
  17728. }
  17729. //附件上传数据
  17730. var uploader = ($scope.uploader =
  17731. $scope.options.templateOptions.fileUploader);
  17732. //$scope.options.templateOptions.uploader();
  17733. // FILTERS
  17734. uploader.filters.push({
  17735. name: "customFilter",
  17736. fn: function (item /*{File|FileLikeObject}*/, options) {
  17737. return this.queue.length < 10;
  17738. },
  17739. });
  17740. $scope.dropfile = function (
  17741. APIService,
  17742. processInstanceId,
  17743. taskId,
  17744. userId
  17745. ) {
  17746. uploader.onBeforeUploadItem = function (item) {
  17747. angular.extend(item.headers, $rootScope.getSession());
  17748. if (
  17749. $scope.options.templateOptions.upservice &&
  17750. $scope.options.templateOptions.formname
  17751. ) {
  17752. // if ($scope.options.templateOptions.formket) {
  17753. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  17754. // } else {
  17755. item.url = APIService[$scope.options.templateOptions.upservice](
  17756. $scope.model[$scope.options.templateOptions.formname].id,
  17757. taskId,
  17758. userId
  17759. ).getRequestedUrl();
  17760. // }
  17761. } else {
  17762. item.url = APIService.saveAttachments(
  17763. processInstanceId,
  17764. taskId,
  17765. userId
  17766. ).getRequestedUrl();
  17767. }
  17768. item.formData.push({
  17769. filename: item.file.name,
  17770. });
  17771. console.info("onBeforeUploadItem", item);
  17772. };
  17773. uploader.uploadAll();
  17774. };
  17775. // CALLBACKS
  17776. uploader.onWhenAddingFileFailed = function (
  17777. item /*{File|FileLikeObject}*/,
  17778. filter,
  17779. options
  17780. ) {
  17781. console.info("onWhenAddingFileFailed", item, filter, options);
  17782. };
  17783. uploader.onAfterAddingFile = function (fileItem) {
  17784. console.info("onAfterAddingFile", fileItem);
  17785. };
  17786. uploader.onAfterAddingAll = function (addedFileItems) {
  17787. console.info("onAfterAddingAll", addedFileItems);
  17788. };
  17789. uploader.onBeforeUploadItem = function (item) {
  17790. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17791. // // $scope.uploader.options.url();
  17792. // $scope.uploader.onBeforeUploadItem = function(item) {
  17793. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17794. // console.info('onBeforeUploadItem', item);
  17795. // };
  17796. // $scope.uploader.uploadAll();
  17797. // }
  17798. console.info("onBeforeUploadItem", item);
  17799. };
  17800. uploader.onProgressItem = function (fileItem, progress) {
  17801. console.info("onProgressItem", fileItem, progress);
  17802. };
  17803. uploader.onProgressAll = function (progress) {
  17804. console.info("onProgressAll", progress);
  17805. };
  17806. uploader.onSuccessItem = function (
  17807. fileItem,
  17808. response,
  17809. status,
  17810. headers
  17811. ) {
  17812. console.info("onSuccessItem", fileItem, response, status, headers);
  17813. };
  17814. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17815. console.info("onErrorItem", fileItem, response, status, headers);
  17816. };
  17817. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17818. console.info("onCancelItem", fileItem, response, status, headers);
  17819. };
  17820. uploader.onCompleteItem = function (
  17821. fileItem,
  17822. response,
  17823. status,
  17824. headers
  17825. ) {
  17826. console.info("onCompleteItem", fileItem, response, status, headers);
  17827. };
  17828. uploader.onCompleteAll = function () {
  17829. console.info("onCompleteAll");
  17830. };
  17831. },
  17832. ],
  17833. });
  17834. //简易附件展示下载列表组件
  17835. formlyConfigProvider.setType({
  17836. name: "ui-dropFiles",
  17837. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  17838. defaultOptions: function (options) {
  17839. return {
  17840. templateOptions: {
  17841. refresh: function (APIService, processInstanceId, data) {
  17842. return APIService.listAttachments(processInstanceId);
  17843. },
  17844. downloadUri: function (APIService, contentId) {
  17845. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17846. },
  17847. view: function (APIService, contentId) {
  17848. return APIService.attachmentsPreviewUrl(contentId);
  17849. },
  17850. download: function (APIService, contentId, item) {
  17851. var item = {
  17852. url: APIService.download(contentId),
  17853. headers: headers,
  17854. };
  17855. return item;
  17856. },
  17857. refreshDelay: 0,
  17858. },
  17859. };
  17860. },
  17861. controller: [
  17862. "$scope",
  17863. "$timeout",
  17864. "$modal",
  17865. "$rootScope",
  17866. "$http",
  17867. "up_down_file",
  17868. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17869. var _refreshDelayPromise;
  17870. // $scope.downloadUrl = function(contentId){
  17871. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  17872. // };
  17873. $scope.download = function (contentId, filename, token) {
  17874. // console.log(contentId, filename, token)
  17875. //附件下载
  17876. var downUrl = up_down_file
  17877. .downloadAttachment("common/common/downloadAttachment", token)
  17878. .getRequestedUrl();
  17879. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17880. // console.log(downUrl)
  17881. var a = document.createElement("a");
  17882. a.href = downUrl;
  17883. a.target = "_blank";
  17884. a.download = filename;
  17885. document.body.appendChild(a);
  17886. a.click();
  17887. };
  17888. $scope.view = function (contentId, token, filename, type) {
  17889. $scope.options.templateOptions
  17890. .view($scope.options.templateOptions.ApiService, contentId)
  17891. .then(function (response) {
  17892. if (response.state == 200) {
  17893. window.open(response.previewUrl);
  17894. }
  17895. });
  17896. };
  17897. /**
  17898. * refresh
  17899. */
  17900. $scope._refresh = function (refreshAttr) {
  17901. $scope.attachments = [];
  17902. if (refreshAttr !== undefined) {
  17903. if (_refreshDelayPromise) {
  17904. $timeout.cancel(_refreshDelayPromise);
  17905. }
  17906. _refreshDelayPromise = $timeout(function () {
  17907. // 暂存附件
  17908. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17909. $scope.options.templateOptions
  17910. .refresh(
  17911. $scope.options.templateOptions.ApiService,
  17912. $scope.options.templateOptions.processInstanceId,
  17913. {
  17914. idx: 0,
  17915. sum: 1000,
  17916. }
  17917. )
  17918. .then(function (response) {
  17919. var myData =
  17920. $scope.options.templateOptions.Restangular.stripRestangular(
  17921. response
  17922. );
  17923. if (myData) {
  17924. for (var i = 0; i < myData.data.length; i++) {
  17925. $scope.attachments.push(myData.data[i]);
  17926. }
  17927. }
  17928. $scope.options.templateOptions
  17929. .refresh(
  17930. $scope.options.templateOptions.ApiService,
  17931. $scope.$parent.$parent.$parent.model.save_fileId,
  17932. {
  17933. idx: 0,
  17934. sum: 1000,
  17935. }
  17936. )
  17937. .then(function (response2) {
  17938. var myData2 =
  17939. $scope.options.templateOptions.Restangular.stripRestangular(
  17940. response2
  17941. );
  17942. if (myData2) {
  17943. for (var i = 0; i < myData2.data.length; i++) {
  17944. $scope.attachments.push(myData2.data[i]);
  17945. }
  17946. // 只展示除图片以外的附件
  17947. var a = [];
  17948. $scope.attachments.forEach((e) => {
  17949. if (
  17950. e.suffix == "jpeg" ||
  17951. e.suffix == "jpg" ||
  17952. e.suffix == "svg" ||
  17953. e.suffix == "png" ||
  17954. e.suffix == "bmp" ||
  17955. e.suffix == "gif" ||
  17956. e.suffix == "tif"
  17957. ) {
  17958. // $scope.imgs.push(e)
  17959. } else {
  17960. a.push(e);
  17961. }
  17962. });
  17963. $scope.attachments = a;
  17964. }
  17965. console.log($scope.attachments);
  17966. });
  17967. });
  17968. // 正常附件
  17969. } else {
  17970. $scope.options.templateOptions
  17971. .refresh(
  17972. $scope.options.templateOptions.ApiService,
  17973. $scope.options.templateOptions.processInstanceId,
  17974. {
  17975. idx: 0,
  17976. sum: 1000,
  17977. }
  17978. )
  17979. .then(function (response) {
  17980. var myData =
  17981. $scope.options.templateOptions.Restangular.stripRestangular(
  17982. response
  17983. );
  17984. if (myData) {
  17985. $scope.attachments = myData.data;
  17986. // 只展示除图片以外的附件
  17987. var a = [];
  17988. $scope.attachments.forEach((e) => {
  17989. if (
  17990. e.suffix == "jpeg" ||
  17991. e.suffix == "jpg" ||
  17992. e.suffix == "svg" ||
  17993. e.suffix == "png" ||
  17994. e.suffix == "bmp" ||
  17995. e.suffix == "gif" ||
  17996. e.suffix == "tif"
  17997. ) {
  17998. // $scope.imgs.push(e)
  17999. } else {
  18000. a.push(e);
  18001. }
  18002. });
  18003. $scope.attachments = a;
  18004. console.log($scope.attachments);
  18005. }
  18006. });
  18007. }
  18008. }, $scope.options.templateOptions.refreshDelay);
  18009. }
  18010. };
  18011. $scope._refresh({});
  18012. // $scope.attachments = $scope.model[$scope.options.key]
  18013. },
  18014. ],
  18015. });
  18016. //知识库附件上传
  18017. formlyConfigProvider.setType({
  18018. name: "ui-dropfielknow",
  18019. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18020. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18021. controller: [
  18022. "$scope",
  18023. "$rootScope",
  18024. function ($scope, $rootScope) {
  18025. if (angular.isUndefined($scope.form.dropState)) {
  18026. $scope.form.dropState = false;
  18027. }
  18028. //附件上传数据
  18029. var uploader = ($scope.uploader =
  18030. $scope.options.templateOptions.fileUploader);
  18031. //$scope.options.templateOptions.uploader();
  18032. // FILTERS
  18033. uploader.filters.push({
  18034. name: "customFilter",
  18035. fn: function (item /*{File|FileLikeObject}*/, options) {
  18036. return this.queue.length < 10;
  18037. },
  18038. });
  18039. $scope.dropfile = function (
  18040. APIService,
  18041. processInstanceId,
  18042. taskId,
  18043. userId
  18044. ) {
  18045. uploader.onBeforeUploadItem = function (item) {
  18046. angular.extend(item.headers, $rootScope.getSession());
  18047. item.url = APIService.upload(
  18048. processInstanceId,
  18049. taskId,
  18050. userId
  18051. ).getRequestedUrl();
  18052. item.formData.push({
  18053. fileName: item.file.name,
  18054. type: "solution",
  18055. solutionId: $scope.model.knowledge.id,
  18056. });
  18057. console.info("onBeforeUploadItem", item);
  18058. };
  18059. uploader.uploadAll();
  18060. };
  18061. // CALLBACKS
  18062. uploader.onWhenAddingFileFailed = function (
  18063. item /*{File|FileLikeObject}*/,
  18064. filter,
  18065. options
  18066. ) {
  18067. console.info("onWhenAddingFileFailed", item, filter, options);
  18068. };
  18069. uploader.onAfterAddingFile = function (fileItem) {
  18070. console.info("onAfterAddingFile", fileItem);
  18071. };
  18072. uploader.onAfterAddingAll = function (addedFileItems) {
  18073. console.info("onAfterAddingAll", addedFileItems);
  18074. };
  18075. uploader.onBeforeUploadItem = function (item) {
  18076. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18077. // // $scope.uploader.options.url();
  18078. // $scope.uploader.onBeforeUploadItem = function(item) {
  18079. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18080. // console.info('onBeforeUploadItem', item);
  18081. // };
  18082. // $scope.uploader.uploadAll();
  18083. // }
  18084. console.info("onBeforeUploadItem", item);
  18085. };
  18086. uploader.onProgressItem = function (fileItem, progress) {
  18087. console.info("onProgressItem", fileItem, progress);
  18088. };
  18089. uploader.onProgressAll = function (progress) {
  18090. console.info("onProgressAll", progress);
  18091. };
  18092. uploader.onSuccessItem = function (
  18093. fileItem,
  18094. response,
  18095. status,
  18096. headers
  18097. ) {
  18098. console.info("onSuccessItem", fileItem, response, status, headers);
  18099. };
  18100. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18101. console.info("onErrorItem", fileItem, response, status, headers);
  18102. };
  18103. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18104. console.info("onCancelItem", fileItem, response, status, headers);
  18105. };
  18106. uploader.onCompleteItem = function (
  18107. fileItem,
  18108. response,
  18109. status,
  18110. headers
  18111. ) {
  18112. console.info("onCompleteItem", fileItem, response, status, headers);
  18113. };
  18114. uploader.onCompleteAll = function () {
  18115. console.info("onCompleteAll");
  18116. };
  18117. },
  18118. ],
  18119. });
  18120. //知识库附件下载列表
  18121. formlyConfigProvider.setType({
  18122. name: "ui-dropfileknowledge",
  18123. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  18124. defaultOptions: function (options) {
  18125. return {
  18126. templateOptions: {
  18127. refresh: function (APIService, contentId, data) {
  18128. return APIService.fetchDataList(contentId, data);
  18129. },
  18130. downloadUri: function (APIService, contentId) {
  18131. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18132. },
  18133. download: function (APIService, contentId) {
  18134. return APIService.getSolutionDowpath(contentId);
  18135. },
  18136. view: function (attachmentId) {
  18137. // return APIService.attachmentsPreviewUrl(contentId);
  18138. },
  18139. refreshDelay: 0,
  18140. },
  18141. };
  18142. },
  18143. controller: [
  18144. "$scope",
  18145. "$timeout",
  18146. "$modal",
  18147. "$rootScope",
  18148. "api_solution",
  18149. "$http",
  18150. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  18151. var _refreshDelayPromise;
  18152. $scope.attachments = [];
  18153. $scope.downloadUrl = function (contentId) {
  18154. return (
  18155. $scope.options.templateOptions.downloadUri(
  18156. $scope.options.templateOptions.ApiService,
  18157. contentId
  18158. ) || "#"
  18159. );
  18160. };
  18161. $scope.download = function (contentId, filename) {
  18162. $http({
  18163. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  18164. contentId
  18165. ).getRequestedUrl(),
  18166. method: "GET",
  18167. headers: {
  18168. //'Content-type' : 'application/xls',
  18169. Accept: "*/*",
  18170. },
  18171. responseType: "arraybuffer",
  18172. })
  18173. .success(function (data, status, headers, config) {
  18174. var file = new Blob([data], {
  18175. type: "application/octet-stream",
  18176. });
  18177. //trick to download store a file having its URL
  18178. var fileURL = URL.createObjectURL(file);
  18179. var a = document.createElement("a");
  18180. a.href = fileURL;
  18181. a.target = "_blank";
  18182. a.download = filename;
  18183. document.body.appendChild(a);
  18184. a.click();
  18185. })
  18186. .error(function (data, status, headers, config) {
  18187. // console.log(data);
  18188. });
  18189. };
  18190. $scope.view = function (contentId, filename, attachment) {
  18191. var index = filename.indexOf(".");
  18192. var type = filename.substring(index + 1);
  18193. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18194. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  18195. // var modalInstance = $modal.open({
  18196. // backdrop: false,
  18197. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18198. // controller: function($scope, scope, $modalInstance, filename) {
  18199. // $scope.title = filename;
  18200. // $scope.imageurl = scope.imageurl;
  18201. // $scope.cancel = function() {
  18202. // $modalInstance.dismiss('cancel');
  18203. // }
  18204. // },
  18205. // resolve: {
  18206. // scope: function() {
  18207. // return $scope;
  18208. // },
  18209. // filename: function() {
  18210. // return filename;
  18211. // }
  18212. // }
  18213. // });
  18214. // event.preventDefault();
  18215. // } else {
  18216. // for (var i = 0; i < $scope.attachments.length; i++) {
  18217. // if ($scope.attachments[i].id == attachmentId) {
  18218. window.open(attachment.previewUrl);
  18219. // }
  18220. // }
  18221. // }
  18222. };
  18223. $scope._refresh = function (refreshAttr) {
  18224. if (refreshAttr !== undefined) {
  18225. if (_refreshDelayPromise) {
  18226. $timeout.cancel(_refreshDelayPromise);
  18227. }
  18228. _refreshDelayPromise = $timeout(function () {
  18229. $scope.options.templateOptions
  18230. .refresh($scope.options.templateOptions.ApiService, "file", {
  18231. file: {
  18232. solutionId: $scope.model.knowledge.id,
  18233. },
  18234. idx: "0",
  18235. sum: "1000",
  18236. })
  18237. .then(function (response) {
  18238. var myData =
  18239. $scope.options.templateOptions.Restangular.stripRestangular(
  18240. response
  18241. );
  18242. if (myData) {
  18243. $scope.attachments = myData.list;
  18244. // $scope.view = function(attachmentId) {
  18245. // for (var i = 0; i < $scope.attachments.length; i++) {
  18246. // if ($scope.attachments[i].id == attachmentId) {
  18247. // window.open($scope.attachments[i].previewUrl);
  18248. // // var modalInstance = $modal.open({
  18249. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  18250. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  18251. // // }
  18252. // // });
  18253. // }
  18254. // }
  18255. // };
  18256. }
  18257. });
  18258. }, $scope.options.templateOptions.refreshDelay);
  18259. }
  18260. };
  18261. $scope._refresh({});
  18262. // $scope.attachments = $scope.model[$scope.options.key]
  18263. },
  18264. ],
  18265. });
  18266. //附件图片下载
  18267. formlyConfigProvider.setType({
  18268. name: "ui-downimage",
  18269. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  18270. defaultOptions: function (options) {
  18271. return {
  18272. templateOptions: {
  18273. refresh: function (APIService, processInstanceId, data) {
  18274. return APIService.listAttachments(processInstanceId, data);
  18275. },
  18276. downloadUri: function (APIService, contentId) {
  18277. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18278. },
  18279. view: function (APIService, contentId) {
  18280. return APIService.attachmentsPreviewUrl(contentId);
  18281. },
  18282. download: function (APIService, contentId, item) {
  18283. var item = {
  18284. url: APIService.download(contentId),
  18285. headers: headers,
  18286. };
  18287. return item;
  18288. },
  18289. refreshDelay: 0,
  18290. },
  18291. };
  18292. },
  18293. controller: [
  18294. "$scope",
  18295. "$timeout",
  18296. "$rootScope",
  18297. "$http",
  18298. function ($scope, $timeout, $rootScope, $http) {
  18299. var _refreshDelayPromise;
  18300. // $scope.downloadUrl = function(contentId){
  18301. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18302. // };
  18303. $scope.download = function (contentId, filename) {
  18304. // var headers=
  18305. $http({
  18306. url: $scope.options.templateOptions.ApiService.download(
  18307. contentId
  18308. ).getRequestedUrl(),
  18309. method: "GET",
  18310. headers: {
  18311. //'Content-type' : 'application/xls',
  18312. Accept: "*/*",
  18313. },
  18314. responseType: "arraybuffer",
  18315. })
  18316. .success(function (data, status, headers, config) {
  18317. var file = new Blob([data], {
  18318. type: "application/octet-stream",
  18319. });
  18320. //trick to download store a file having its URL
  18321. var fileURL = URL.createObjectURL(file);
  18322. var a = document.createElement("a");
  18323. a.href = fileURL;
  18324. a.target = "_blank";
  18325. a.download = filename;
  18326. document.body.appendChild(a);
  18327. a.click();
  18328. })
  18329. .error(function (data, status, headers, config) {
  18330. // console.log(data);
  18331. });
  18332. };
  18333. $scope.view = function (contentId) {
  18334. $scope.imageurl =
  18335. $scope.options.templateOptions.ApiService.download(
  18336. contentId
  18337. ).getRequestedUrl();
  18338. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  18339. // if (response.state == 200) {
  18340. // window.open(response.previewUrl);
  18341. // }
  18342. // })
  18343. };
  18344. /**
  18345. * refresh
  18346. */
  18347. $scope._refresh = function (refreshAttr) {
  18348. if (refreshAttr !== undefined) {
  18349. if (_refreshDelayPromise) {
  18350. $timeout.cancel(_refreshDelayPromise);
  18351. }
  18352. _refreshDelayPromise = $timeout(function () {
  18353. $scope.options.templateOptions
  18354. .refresh(
  18355. $scope.options.templateOptions.ApiService,
  18356. $scope.options.templateOptions.processInstanceId,
  18357. {
  18358. idx: 0,
  18359. sum: 1000,
  18360. }
  18361. )
  18362. .then(function (response) {
  18363. var myData =
  18364. $scope.options.templateOptions.Restangular.stripRestangular(
  18365. response
  18366. );
  18367. if (myData) {
  18368. $scope.attachments = myData.data;
  18369. }
  18370. });
  18371. }, $scope.options.templateOptions.refreshDelay);
  18372. }
  18373. };
  18374. $scope._refresh({});
  18375. // $scope.attachments = $scope.model[$scope.options.key]
  18376. },
  18377. ],
  18378. });
  18379. //附件下载列表组件
  18380. formlyConfigProvider.setType({
  18381. name: "ui-dropfiletable",
  18382. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  18383. defaultOptions: function (options) {
  18384. return {
  18385. templateOptions: {
  18386. refresh: function (APIService, processInstanceId, data) {
  18387. return APIService.listAttachments(processInstanceId, data);
  18388. },
  18389. downloadUri: function (APIService, contentId) {
  18390. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18391. },
  18392. view: function (APIService, contentId) {
  18393. return APIService.attachmentsPreviewUrl(contentId);
  18394. },
  18395. download: function (APIService, contentId, item) {
  18396. var item = {
  18397. url: APIService.download(contentId),
  18398. headers: headers,
  18399. };
  18400. return item;
  18401. },
  18402. refreshDelay: 0,
  18403. },
  18404. };
  18405. },
  18406. controller: [
  18407. "$scope",
  18408. "$timeout",
  18409. "$modal",
  18410. "$rootScope",
  18411. "$http",
  18412. function ($scope, $timeout, $modal, $rootScope, $http) {
  18413. var _refreshDelayPromise;
  18414. // $scope.downloadUrl = function(contentId){
  18415. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18416. // };
  18417. $scope.download = function (contentId, filename) {
  18418. // var headers=
  18419. $http({
  18420. url: $scope.options.templateOptions.ApiService.download(
  18421. contentId
  18422. ).getRequestedUrl(),
  18423. method: "GET",
  18424. headers: {
  18425. //'Content-type' : 'application/xls',
  18426. Accept: "*/*",
  18427. },
  18428. responseType: "arraybuffer",
  18429. })
  18430. .success(function (data, status, headers, config) {
  18431. var file = new Blob([data], {
  18432. type: "application/octet-stream",
  18433. });
  18434. //trick to download store a file having its URL
  18435. var fileURL = URL.createObjectURL(file);
  18436. var a = document.createElement("a");
  18437. a.href = fileURL;
  18438. a.target = "_blank";
  18439. a.download = filename;
  18440. document.body.appendChild(a);
  18441. a.click();
  18442. })
  18443. .error(function (data, status, headers, config) {
  18444. // console.log(data);
  18445. });
  18446. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  18447. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  18448. // var file = new Blob([response], {
  18449. // type : 'application/octet-stream'
  18450. // });
  18451. // // var filename = filename;
  18452. // //var file = new Blob([response], {type: 'application/pdf'});
  18453. // var fileURL = URL.createObjectURL(file);
  18454. // var a = document.createElement('a');
  18455. // a.href = fileURL;
  18456. // a.target = '_blank';
  18457. // a.download = filename ;
  18458. // document.body.appendChild(a);
  18459. // a.click();
  18460. // })
  18461. };
  18462. $scope.view = function (contentId, token, filename, type) {
  18463. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18464. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  18465. // var modalInstance = $modal.open({
  18466. // backdrop: false,
  18467. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18468. // controller: function($scope, scope, $modalInstance, filename) {
  18469. // $scope.title = filename;
  18470. // $scope.imageurl = scope.imageurl;
  18471. // $scope.cancel = function() {
  18472. // $modalInstance.dismiss('cancel');
  18473. // }
  18474. // },
  18475. // resolve: {
  18476. // scope: function() {
  18477. // return $scope;
  18478. // },
  18479. // filename: function() {
  18480. // return filename;
  18481. // }
  18482. // }
  18483. // });
  18484. // event.preventDefault();
  18485. // } else {
  18486. $scope.options.templateOptions
  18487. .view($scope.options.templateOptions.ApiService, contentId)
  18488. .then(function (response) {
  18489. if (response.state == 200) {
  18490. window.open(response.previewUrl);
  18491. }
  18492. });
  18493. // }
  18494. };
  18495. /**
  18496. * refresh
  18497. */
  18498. $scope._refresh = function (refreshAttr) {
  18499. if (refreshAttr !== undefined) {
  18500. if (_refreshDelayPromise) {
  18501. $timeout.cancel(_refreshDelayPromise);
  18502. }
  18503. _refreshDelayPromise = $timeout(function () {
  18504. $scope.options.templateOptions
  18505. .refresh(
  18506. $scope.options.templateOptions.ApiService,
  18507. $scope.options.templateOptions.processInstanceId,
  18508. {
  18509. idx: 0,
  18510. sum: 1000,
  18511. }
  18512. )
  18513. .then(function (response) {
  18514. var myData =
  18515. $scope.options.templateOptions.Restangular.stripRestangular(
  18516. response
  18517. );
  18518. if (myData) {
  18519. $scope.attachments = myData.data;
  18520. }
  18521. });
  18522. }, $scope.options.templateOptions.refreshDelay);
  18523. }
  18524. };
  18525. $scope._refresh({});
  18526. // $scope.attachments = $scope.model[$scope.options.key]
  18527. },
  18528. ],
  18529. });
  18530. //微信附件下载列表组件
  18531. formlyConfigProvider.setType({
  18532. name: "ui-dropfilewechat",
  18533. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  18534. defaultOptions: function (options) {
  18535. return {
  18536. templateOptions: {
  18537. // refresh: function(APIService, processInstanceId, data) {
  18538. // return APIService.listAttachments(processInstanceId, data);
  18539. // },
  18540. // downloadUri: function(APIService, contentId) {
  18541. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  18542. // },
  18543. view: function (APIService, contentId) {
  18544. // return APIService.attachmentsPreviewUrl(contentId);
  18545. return APIService.attachmentsPreviewUrl(contentId);
  18546. },
  18547. download: function (APIService, contentId, item) {
  18548. var item = {
  18549. url: APIService.download(contentId),
  18550. headers: headers,
  18551. };
  18552. return item;
  18553. },
  18554. // download: function(APIService, contentId, item) {
  18555. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  18556. // return item;
  18557. // },
  18558. refreshDelay: 0,
  18559. },
  18560. };
  18561. },
  18562. controller: [
  18563. "$scope",
  18564. "$timeout",
  18565. "$modal",
  18566. "$stateParams",
  18567. "$rootScope",
  18568. "$http",
  18569. "api_wechatfile",
  18570. function (
  18571. $scope,
  18572. $timeout,
  18573. $modal,
  18574. $stateParams,
  18575. $rootScope,
  18576. $http,
  18577. api_wechatfile
  18578. ) {
  18579. var _refreshDelayPromise;
  18580. // $scope.downloadUrl = function(contentId){
  18581. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18582. // };
  18583. $scope.attachments = {};
  18584. $scope.previewUrl = "";
  18585. $scope.download = function (token, filename) {
  18586. // var headers=
  18587. console.log($scope);
  18588. $http({
  18589. url: $scope.options.templateOptions.ApiService.jry_download(
  18590. token
  18591. ).getRequestedUrl(),
  18592. method: "GET",
  18593. headers: {
  18594. //'Content-type' : 'application/xls',
  18595. Accept: "*/*",
  18596. },
  18597. responseType: "arraybuffer",
  18598. })
  18599. .success(function (data, status, headers, config) {
  18600. var file = new Blob([data], {
  18601. type: "application/octet-stream",
  18602. });
  18603. //trick to download store a file having its URL
  18604. var fileURL = URL.createObjectURL(file);
  18605. var a = document.createElement("a");
  18606. a.href = fileURL;
  18607. a.target = "_blank";
  18608. a.download = filename;
  18609. document.body.appendChild(a);
  18610. a.click();
  18611. })
  18612. .error(function (data, status, headers, config) {
  18613. // console.log(data);
  18614. });
  18615. };
  18616. $scope.view = function (contentId, token, filename, type, previewUrl) {
  18617. // if (type) {
  18618. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  18619. // var modalInstance = $modal.open({
  18620. // backdrop: false,
  18621. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18622. // controller: function($scope, scope, $modalInstance, filename) {
  18623. // $scope.title = filename;
  18624. // $scope.imageurl = scope.imageurl;
  18625. // $scope.cancel = function() {
  18626. // $modalInstance.dismiss('cancel');
  18627. // }
  18628. // },
  18629. // resolve: {
  18630. // scope: function() {
  18631. // return $scope;
  18632. // },
  18633. // filename: function() {
  18634. // return filename;
  18635. // }
  18636. // }
  18637. // });
  18638. // event.preventDefault();
  18639. // } else {
  18640. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  18641. // if (response.state == 200) {
  18642. // window.open(response.previewUrl);
  18643. // }
  18644. // })
  18645. window.open(previewUrl);
  18646. // }
  18647. };
  18648. /**
  18649. * refresh
  18650. */
  18651. $scope._refresh = function (refreshAttr) {
  18652. if (refreshAttr !== undefined) {
  18653. if (_refreshDelayPromise) {
  18654. $timeout.cancel(_refreshDelayPromise);
  18655. }
  18656. _refreshDelayPromise = $timeout(function () {
  18657. // console.log(JSON.parse($stateParams.model))
  18658. var incidentChart = {};
  18659. if ($stateParams.model) {
  18660. incidentChart = JSON.parse($stateParams.model).model;
  18661. }
  18662. $scope.options.templateOptions
  18663. .refresh(
  18664. $scope.options.templateOptions.ApiService,
  18665. $scope.model
  18666. )
  18667. .then(function (response) {
  18668. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  18669. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  18670. var myData =
  18671. $scope.options.templateOptions.Restangular.stripRestangular(
  18672. response
  18673. );
  18674. if (myData) {
  18675. $scope.attachments = myData.data;
  18676. }
  18677. });
  18678. }, $scope.options.templateOptions.refreshDelay);
  18679. }
  18680. };
  18681. $scope._refresh({});
  18682. // $scope.attachments = $scope.model[$scope.options.key]
  18683. },
  18684. ],
  18685. });
  18686. formlyConfigProvider.setType({
  18687. name: "ui-paralleltask",
  18688. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  18689. defaultOptions: function (options) {
  18690. return {
  18691. templateOptions: {
  18692. refresh: function (APIService, processInstanceId, data) {
  18693. //return APIService.listAttachments(processInstanceId, data);
  18694. },
  18695. refreshDelay: 0,
  18696. },
  18697. };
  18698. },
  18699. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  18700. });
  18701. //repeatSection
  18702. //
  18703. formlyConfigProvider.setType({
  18704. name: "ui-repeatSection",
  18705. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  18706. defaultOptions: function (options) {
  18707. return {
  18708. templateOptions: {
  18709. unique: 1,
  18710. initDisplay: false,
  18711. },
  18712. };
  18713. },
  18714. controller: function ($scope) {
  18715. //$scope.options.templateOptions.unique;
  18716. $scope.formOptions = {
  18717. formState: $scope.formState,
  18718. };
  18719. $scope.addNew = addNew;
  18720. $scope.copyFields = copyFields;
  18721. function copyFields(fields) {
  18722. fields = angular.copy(fields);
  18723. addRandomIds(fields);
  18724. return fields;
  18725. }
  18726. function addNew() {
  18727. $scope.model[$scope.options.key] =
  18728. $scope.model[$scope.options.key] || [];
  18729. var repeatsection = $scope.model[$scope.options.key];
  18730. var lastSection = repeatsection[repeatsection.length - 1];
  18731. var newsection = {};
  18732. repeatsection.push(newsection);
  18733. }
  18734. function addRandomIds(fields) {
  18735. $scope.options.templateOptions.unique++;
  18736. angular.forEach(fields, function (field, index) {
  18737. if (field.fieldGroup) {
  18738. addRandomIds(field.fieldGroup);
  18739. return; // fieldGroups don't need an ID
  18740. }
  18741. if (field.templateOptions && field.templateOptions.fields) {
  18742. addRandomIds(field.templateOptions.fields);
  18743. }
  18744. field.id =
  18745. field.id ||
  18746. field.key +
  18747. "_" +
  18748. index +
  18749. "_" +
  18750. $scope.options.templateOptions.unique +
  18751. getRandomInt(0, 9999);
  18752. });
  18753. }
  18754. function getRandomInt(min, max) {
  18755. return Math.floor(Math.random() * (max - min)) + min;
  18756. }
  18757. if ($scope.options.templateOptions.initDisplay) {
  18758. addNew();
  18759. }
  18760. },
  18761. });
  18762. //时间轴任务列表组件
  18763. //cmdb控件
  18764. formlyConfigProvider.setType({
  18765. name: "ui-cmdb",
  18766. extends: "input",
  18767. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  18768. defaultOptions: function (options) {
  18769. return {
  18770. templateOptions: {
  18771. onClick: function (size, options, modal, event, model) {
  18772. var modalInstance = modal.open({
  18773. templateUrl:
  18774. "assets/views/customform/tpl/cmdb-modal-content.html",
  18775. controller: function (
  18776. $scope,
  18777. $modalInstance,
  18778. title,
  18779. Restangular,
  18780. APIService,
  18781. ConfigDataService,
  18782. ConfigFormService,
  18783. SweetAlert,
  18784. Toaster,
  18785. api_wechatfile
  18786. ) {
  18787. var width = ($scope.width = 600);
  18788. var height = ($scope.height = 400);
  18789. var tree;
  18790. var d3 = window.d3;
  18791. $scope.my_tree_handler = function (branch) {
  18792. //var _ref;
  18793. var classify = ($scope.classify =
  18794. branch.prefix.toLowerCase() + branch.sign);
  18795. APIService.query({
  18796. sign: classify,
  18797. }).then(function (data) {
  18798. var myData = Restangular.stripRestangular(data);
  18799. // console.log(myData.data.node);
  18800. if (myData.data && myData.status == 200) {
  18801. var ret = myData.data;
  18802. redrawSvg(myData);
  18803. }
  18804. });
  18805. };
  18806. $scope.my_data = [];
  18807. function convertListToTree(data, treeMap) {
  18808. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  18809. var root = null; //Initially set our loop to null
  18810. var parentNode = null;
  18811. //loop over data
  18812. for (var i = 0; i < data.length; i++) {
  18813. var datum = data[i];
  18814. //each node will have children, so let's give it a "children" poperty
  18815. datum.children = [];
  18816. //add an entry for this node to the map so that any future children can
  18817. //lookup the parent
  18818. idToNodeMap[datum.id] = datum;
  18819. //Does this node have a parent?
  18820. if (
  18821. typeof datum.parent === "undefined" ||
  18822. datum.parent == null
  18823. ) {
  18824. //Doesn't look like it, so this node is the root of the tree
  18825. root = datum;
  18826. treeMap[datum.id] = root;
  18827. } else {
  18828. //This node has a parent, so let's look it up using the id
  18829. parentNode = idToNodeMap[datum.parent.id];
  18830. //We don't need this property, so let's delete it.
  18831. delete datum.parent;
  18832. //Let's add the current node as a child of the parent node.
  18833. parentNode.children.push(datum);
  18834. }
  18835. }
  18836. return root;
  18837. }
  18838. function convertParentToChildList(data) {
  18839. var treeMap = {};
  18840. var list = [];
  18841. convertListToTree(data, treeMap);
  18842. angular.forEach(treeMap, function (item) {
  18843. list.push(item);
  18844. });
  18845. return list;
  18846. }
  18847. $scope.my_tree = tree = {};
  18848. $scope.try_async_load = function () {
  18849. $scope.my_data = [];
  18850. $scope.select_treedata = [];
  18851. $scope.doing_async = true;
  18852. ConfigDataService.fetchDataList("ciclassify", {
  18853. idx: 0,
  18854. sum: 100,
  18855. }).then(function (result) {
  18856. $scope.select_treedata = $scope.my_data =
  18857. convertParentToChildList(result["list"]);
  18858. $scope.doing_async = false;
  18859. });
  18860. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  18861. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  18862. // $scope.doing_async = false;
  18863. // });
  18864. };
  18865. $scope.select_treedata = [];
  18866. $scope.propTypeOptions = [];
  18867. $scope.try_async_load();
  18868. $scope.onFilterCallback = function (item) {
  18869. //console.log(item);
  18870. if (
  18871. angular.isDefined(item.children) &&
  18872. item.children.length >= 1
  18873. ) {
  18874. //not valid
  18875. } else {
  18876. var tempclassify = item.prefix.toLowerCase() + item.sign;
  18877. $scope.cifilter_classic = tempclassify;
  18878. ConfigFormService.renderTabForm(tempclassify).then(
  18879. function (data) {
  18880. var myData = Restangular.stripRestangular(data);
  18881. $scope.propTypeOptions = myData;
  18882. }
  18883. );
  18884. }
  18885. };
  18886. $scope.onPropTypeChange = function (form) {
  18887. $scope.propOptions = form.fields;
  18888. };
  18889. $scope.onPropChange = function (prop) {
  18890. $scope.cifilter_prop = prop;
  18891. };
  18892. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  18893. //if(searchKey!=null&&searchKey.length>1){
  18894. var searchData = {};
  18895. if (angular.isUndefined(propObj)) {
  18896. propObj = $scope.cifilter_prop;
  18897. }
  18898. if (angular.isUndefined(ciclassify)) {
  18899. ciclassify = $scope.cifilter_classic;
  18900. }
  18901. searchData["sign"] = ciclassify;
  18902. if (angular.isDefined(propObj)) {
  18903. searchData[propObj.key] = searchKey;
  18904. }
  18905. APIService.query(searchData).then(function (response) {
  18906. var data = Restangular.stripRestangular(response);
  18907. //此处不清空nodes
  18908. var node = data.data.node;
  18909. var tempNode = [];
  18910. //nodes 或者links 要去重
  18911. for (var i = 0; i < node.length; i++) {
  18912. var tmp = 0;
  18913. for (var j = 0; j < nodes.length; j++) {
  18914. if (node[i].uuid == nodes[j].uuid) {
  18915. tmp++;
  18916. break;
  18917. }
  18918. }
  18919. if (tmp == 0) {
  18920. tempNode.push(node[i]);
  18921. }
  18922. }
  18923. for (var i = 0; i < tempNode.length; i++) {
  18924. //nodes 不清空
  18925. nodes.push(tempNode[i]);
  18926. }
  18927. restart();
  18928. });
  18929. };
  18930. $scope.refresh = function () {
  18931. nodes.length = 0;
  18932. links.length = 0;
  18933. restart();
  18934. };
  18935. $scope.traversal = function () {
  18936. if ($scope.selected_node == null) {
  18937. SweetAlert.swal({
  18938. title: "错误的操作!",
  18939. text: "没有配置项被选中!",
  18940. type: "error",
  18941. });
  18942. } else {
  18943. var uuid = $scope.selected_node.uuid;
  18944. APIService.traversal(uuid).then(function (response) {
  18945. var d = response.data;
  18946. var node = d.node;
  18947. var link = d.edge;
  18948. var tempNode = [];
  18949. var tempLink = [];
  18950. //nodes 或者links 要去重
  18951. for (var i = 0; i < node.length; i++) {
  18952. var tmp = 0;
  18953. for (var j = 0; j < nodes.length; j++) {
  18954. if (node[i].id == nodes[j].id) {
  18955. tmp++;
  18956. break;
  18957. }
  18958. }
  18959. if (tmp == 0) {
  18960. tempNode.push(node[i]);
  18961. }
  18962. }
  18963. for (var i = 0; i < link.length; i++) {
  18964. var tmp = 0;
  18965. for (var j = 0; j < links.length; j++) {
  18966. if (link[i].id == links[j].id) {
  18967. tmp++;
  18968. break;
  18969. }
  18970. }
  18971. if (tmp == 0) {
  18972. tempLink.push(link[i]);
  18973. }
  18974. }
  18975. //数据写入页面
  18976. for (var i = 0; i < tempNode.length; i++) {
  18977. //nodes 不清空
  18978. nodes.push(tempNode[i]);
  18979. }
  18980. for (var i = 0; i < tempLink.length; i++) {
  18981. //link 不清空
  18982. links.push(tempLink[i]);
  18983. }
  18984. //links转换
  18985. for (var i = 0; i < links.length; i++) {
  18986. for (var j = 0; j < nodes.length; j++) {
  18987. if (links[i].source == nodes[j].id) {
  18988. links[i].source = nodes[j];
  18989. }
  18990. if (links[i].target == nodes[j].id) {
  18991. links[i].target = nodes[j];
  18992. }
  18993. }
  18994. }
  18995. restart();
  18996. });
  18997. }
  18998. };
  18999. var svg;
  19000. var force;
  19001. var drag_line, path, circle;
  19002. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  19003. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19004. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19005. var nodes = [],
  19006. links = [];
  19007. var treeNodes = [];
  19008. //读取labels (node)
  19009. var labels = [];
  19010. function redrawSvg(json) {
  19011. nodes.length = 0; //先清空
  19012. links.length = 0;
  19013. var data = json.data;
  19014. for (var i = 0; i < data.node.length; i++) {
  19015. nodes.push(data.node[i]);
  19016. }
  19017. restart();
  19018. }
  19019. //读取status (节点 连线)
  19020. var statuses = [];
  19021. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  19022. // if (result && result.status == 200) {
  19023. // d3.select('#nodeStatus').selectAll('option')
  19024. // .data(statuses).enter()
  19025. // .append('option')
  19026. // .attr('value', function(d) { return d.code; })
  19027. // .html(function(d) { return d.desc; });
  19028. // } else {
  19029. // SweetAlert.swal({
  19030. // title: "提示!",
  19031. // text: "服务器请求异常!",
  19032. // type: "error"
  19033. // });
  19034. // }
  19035. // });
  19036. api_wechatfile
  19037. .getDictionary({
  19038. key: "cmdb_status",
  19039. type: "list",
  19040. })
  19041. .then(function (result) {
  19042. if (result) {
  19043. d3.select("#nodeStatus")
  19044. .selectAll("option")
  19045. .data(statuses)
  19046. .enter()
  19047. .append("option")
  19048. .attr("value", function (d) {
  19049. return d.code;
  19050. })
  19051. .html(function (d) {
  19052. return d.desc;
  19053. });
  19054. } else {
  19055. SweetAlert.swal({
  19056. title: "提示!",
  19057. text: "服务器请求异常!",
  19058. type: "error",
  19059. });
  19060. }
  19061. });
  19062. //查询relationship_type表 name 为表里的type,label为显示值
  19063. var linkType = [];
  19064. function fetchEdgeTypes() {
  19065. ConfigDataService.fetchDataList("ciedgetype", {
  19066. idx: 0,
  19067. sum: 100,
  19068. }).then(function (response) {
  19069. if (response) {
  19070. if (response["list"]) {
  19071. linkType = response["list"];
  19072. // d3.select('#linkName').selectAll('option')
  19073. // .data(linkType).enter()
  19074. // .append('option')
  19075. // .attr('value',function(d){return d.type;})
  19076. // .html(function(d){ return d.label;});
  19077. } else {
  19078. SweetAlert.swal({
  19079. title: "提示!",
  19080. text: "服务器请求异常!",
  19081. type: "error",
  19082. });
  19083. }
  19084. } else {
  19085. SweetAlert.swal({
  19086. title: "提示!",
  19087. text: "服务器请求异常!",
  19088. type: "error",
  19089. });
  19090. }
  19091. });
  19092. }
  19093. // fetchEdgeTypes();
  19094. /*
  19095. // init D3 force layout
  19096. var force = d3.layout.force()
  19097. .nodes(nodes)
  19098. .links(links)
  19099. .size([width, height])
  19100. .gravity(.05)
  19101. .linkDistance(150)
  19102. .linkStrength(2)
  19103. .charge(-500)
  19104. .on('tick', tick);
  19105. // define arrow markers for graph links
  19106. svg.append('svg:defs').append('svg:marker')
  19107. .attr('id', 'end-arrow')
  19108. .attr('viewBox', '0 -5 10 10')
  19109. .attr('refX', 6)
  19110. .attr('markerWidth', 3)
  19111. .attr('markerHeight', 3)
  19112. .attr('orient', 'auto')
  19113. .append('svg:path')
  19114. .attr('d', 'M0,-5L10,0L0,5')
  19115. .attr('fill', '#000');
  19116. svg.append('svg:defs').append('svg:marker')
  19117. .attr('id', 'start-arrow')
  19118. .attr('viewBox', '0 -5 10 10')
  19119. .attr('refX', 4)
  19120. .attr('markerWidth', 3)
  19121. .attr('markerHeight', 3)
  19122. .attr('orient', 'auto')
  19123. .append('svg:path')
  19124. .attr('d', 'M10,-5L0,0L10,5')
  19125. .attr('fill', '#000');
  19126. // line displayed when dragging new nodes
  19127. var drag_line = svg.append('svg:path')
  19128. .attr('class', 'link dragline hidden')
  19129. .attr('d', 'M0,0L0,0');
  19130. // handles to link and node element groups
  19131. //(1)var path = svg.append('svg:g').selectAll('g')
  19132. var path = svg.append('svg:g').selectAll('g'),
  19133. circle = svg.append('svg:g').selectAll('g');
  19134. */
  19135. // mouse event vars
  19136. var selected_node = null,
  19137. selected_link = null,
  19138. mousedown_link = null,
  19139. mousedown_node = null,
  19140. mouseup_node = null;
  19141. function resetMouseVars() {
  19142. mousedown_node = null;
  19143. mouseup_node = null;
  19144. mousedown_link = null;
  19145. }
  19146. // update force layout (called automatically each iteration)
  19147. function tick() {
  19148. // draw directed edges with proper padding from node centers
  19149. path.selectAll("path").attr("d", function (d) {
  19150. var deltaX = d.target.x - d.source.x,
  19151. deltaY = d.target.y - d.source.y,
  19152. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  19153. normX = deltaX / dist,
  19154. normY = deltaY / dist,
  19155. sourcePadding = d.left ? 27 : 22,
  19156. targetPadding = d.right ? 27 : 22,
  19157. sourceX = d.source.x + sourcePadding * normX,
  19158. sourceY = d.source.y + sourcePadding * normY,
  19159. targetX = d.target.x - targetPadding * normX,
  19160. targetY = d.target.y - targetPadding * normY;
  19161. return (
  19162. "M" +
  19163. sourceX +
  19164. "," +
  19165. sourceY +
  19166. "L" +
  19167. targetX +
  19168. "," +
  19169. targetY
  19170. );
  19171. });
  19172. circle.attr("transform", function (d) {
  19173. return "translate(" + d.x + "," + d.y + ")";
  19174. });
  19175. }
  19176. // update graph (called when needed)
  19177. function restart() {
  19178. //绑定link 数据
  19179. path.datum(links);
  19180. // path (link) group
  19181. path = path.data(links, function (d) {
  19182. return d.id;
  19183. });
  19184. var p = path.enter().append("svg:g");
  19185. //update existing links
  19186. path
  19187. .selectAll("path")
  19188. .classed("selected", function (d) {
  19189. return d === selected_link;
  19190. })
  19191. .style("marker-start", function (d) {
  19192. return d.left ? "url(#start-arrow)" : "";
  19193. })
  19194. .style("marker-end", function (d) {
  19195. return d.right ? "url(#end-arrow)" : "";
  19196. });
  19197. // add new links
  19198. p.append("svg:path")
  19199. .attr("class", "link")
  19200. .attr("id", function (d) {
  19201. return "path_" + d.id;
  19202. })
  19203. // .attr('startOffset', '0%')
  19204. .classed("selected", function (d) {
  19205. return d === selected_link;
  19206. })
  19207. .style("marker-start", function (d) {
  19208. return d.left ? "url(#start-arrow)" : "";
  19209. })
  19210. .style("marker-end", function (d) {
  19211. return d.right ? "url(#end-arrow)" : "";
  19212. })
  19213. .on("mousedown", function (d) {
  19214. if (d3.event.ctrlKey) return;
  19215. //去除没有提交的连线
  19216. for (var i = 0; i < links.length; i++) {
  19217. if (links[i].id == -1 && d.id != -1) {
  19218. links.splice(i, 1);
  19219. }
  19220. }
  19221. // select link
  19222. mousedown_link = d;
  19223. if (mousedown_link === selected_link) {
  19224. selected_link = $scope.selected_link = null;
  19225. selected_node = $scope.selected_node = null;
  19226. // d3.select("#linkDetail").attr('style','display:none');
  19227. //hideLinkForm(true);//return ;
  19228. } else {
  19229. selected_link = $scope.selected_link = mousedown_link;
  19230. selected_node = $scope.selected_node = null;
  19231. }
  19232. selected_node = $scope.selected_node = null;
  19233. restart();
  19234. });
  19235. p.append("svg:text")
  19236. .attr("x", 30)
  19237. .attr("y", 20)
  19238. .attr("class", "fontM")
  19239. .append("textPath")
  19240. .attr("xlink:xlink:href", function (d, i) {
  19241. return "#path_" + d.id;
  19242. })
  19243. .html(function (d) {
  19244. for (var i = 0; i < linkType.length; i++) {
  19245. if (linkType[i].type == d.name) {
  19246. return linkType[i].label;
  19247. }
  19248. }
  19249. });
  19250. // remove old links
  19251. path.exit().remove();
  19252. // circle (node) group
  19253. // NB: the function arg is crucial here! nodes are known by id, not by index!
  19254. circle.datum(nodes);
  19255. circle = circle.data(nodes, function (d) {
  19256. return d.id;
  19257. });
  19258. // update existing nodes (reflexive & selected visual states)
  19259. circle
  19260. .selectAll("circle")
  19261. .style("fill", function (d) {
  19262. return d === selected_node
  19263. ? d3.rgb(colors(d.label)).brighter().toString()
  19264. : colors(d.label);
  19265. })
  19266. .style("fill-opacity", 0.75) // add by xi
  19267. .classed("reflexive", function (d) {
  19268. return d.reflexive;
  19269. });
  19270. // add new nodes
  19271. var g = circle.enter().append("svg:g");
  19272. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  19273. //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');
  19274. g.append("svg:circle")
  19275. .attr("r", 24)
  19276. .style("fill", function (d) {
  19277. return d === selected_node
  19278. ? "rgb(153,153,153)"
  19279. : "rgb(255,255,255)";
  19280. })
  19281. .style("stroke", function (d) {
  19282. return d3.rgb(colors(d.label)).darker().toString();
  19283. })
  19284. .style("stroke-width", "2");
  19285. g.append("svg:circle")
  19286. .attr("class", "node")
  19287. .attr("r", 18)
  19288. .style("fill", function (d) {
  19289. return d === selected_node
  19290. ? d3.rgb(colors(d.label)).brighter().toString()
  19291. : colors(d.label);
  19292. })
  19293. .style("stroke", function (d) {
  19294. return d3.rgb(colors(d.label)).darker().toString();
  19295. })
  19296. .style("fill-opacity", 0.25) //add by xj
  19297. .style("stroke-opacity", 0.5) //add by xj
  19298. .classed("reflexive", function (d) {
  19299. return d.reflexive;
  19300. });
  19301. g.on("mouseover", function (d) {
  19302. //if(!mousedown_node || d === mousedown_node) return;
  19303. // enlarge target node
  19304. //d3.select(this).attr('transform', 'scale(1.1)');
  19305. })
  19306. .on("mouseout", function (d) {
  19307. //if(!mousedown_node || d === mousedown_node) return;
  19308. // unenlarge target node
  19309. //d3.select(this).attr('transform', '');
  19310. })
  19311. .on("mousedown", function (d) {
  19312. if (d3.event.ctrlKey) return;
  19313. //hideLinkForm(true);
  19314. //去除没有提交的连线
  19315. for (var i = 0; i < links.length; i++) {
  19316. if (links[i].id == -1) {
  19317. links.splice(i, 1);
  19318. }
  19319. }
  19320. // select node
  19321. mousedown_node = d;
  19322. if (mousedown_node === selected_node) {
  19323. selected_node = $scope.selected_node = null;
  19324. } else {
  19325. selected_node = $scope.selected_node = mousedown_node;
  19326. selected_link = $scope.selected_link = null;
  19327. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  19328. APIService.findRefById(selected_node.id).then(function (
  19329. result
  19330. ) {
  19331. var d = result.data;
  19332. var node = d.node;
  19333. var link = d.edge;
  19334. var tempNode = [];
  19335. var tempLink = [];
  19336. //nodes 或者links 要去重
  19337. for (var i = 0; i < node.length; i++) {
  19338. var tmp = 0;
  19339. for (var j = 0; j < nodes.length; j++) {
  19340. if (node[i].id == nodes[j].id) {
  19341. tmp++;
  19342. break;
  19343. }
  19344. }
  19345. if (tmp == 0) {
  19346. tempNode.push(node[i]);
  19347. }
  19348. }
  19349. for (var i = 0; i < link.length; i++) {
  19350. var tmp = 0;
  19351. for (var j = 0; j < links.length; j++) {
  19352. if (link[i].id == links[j].id) {
  19353. tmp++;
  19354. break;
  19355. }
  19356. }
  19357. if (tmp == 0) {
  19358. tempLink.push(link[i]);
  19359. }
  19360. }
  19361. //数据写入页面
  19362. for (var i = 0; i < tempNode.length; i++) {
  19363. //nodes 不清空
  19364. nodes.push(tempNode[i]);
  19365. }
  19366. for (var i = 0; i < tempLink.length; i++) {
  19367. //link 不清空
  19368. links.push(tempLink[i]);
  19369. }
  19370. //links转换
  19371. for (var i = 0; i < links.length; i++) {
  19372. for (var j = 0; j < nodes.length; j++) {
  19373. if (links[i].source == nodes[j].id) {
  19374. links[i].source = nodes[j];
  19375. }
  19376. if (links[i].target == nodes[j].id) {
  19377. links[i].target = nodes[j];
  19378. }
  19379. }
  19380. }
  19381. restart();
  19382. });
  19383. }
  19384. // reposition drag line
  19385. drag_line
  19386. .style("marker-end", "url(#end-arrow)")
  19387. .classed("hidden", false)
  19388. .attr(
  19389. "d",
  19390. "M" +
  19391. mousedown_node.x +
  19392. "," +
  19393. mousedown_node.y +
  19394. "L" +
  19395. mousedown_node.x +
  19396. "," +
  19397. mousedown_node.y
  19398. );
  19399. restart();
  19400. })
  19401. .on("mouseup", function (d) {
  19402. if (!mousedown_node) return;
  19403. });
  19404. // show node name
  19405. g.append("svg:text")
  19406. .attr("x", 0)
  19407. .attr("y", 34)
  19408. .attr("class", "id")
  19409. .text(function (d) {
  19410. return d.name;
  19411. }); //TODO 改为 d.name
  19412. //设置图片
  19413. g.append("svg:foreignObject")
  19414. .attr("width", 32)
  19415. .attr("height", 32)
  19416. .attr("x", "-16px")
  19417. .attr("y", "-11px")
  19418. .html(function (d) {
  19419. for (var i = 0; i < labels.length; i++) {
  19420. if (d.label == labels[i].sign) {
  19421. return (
  19422. '<i class="icon iconfont">' +
  19423. labels[i].iconname +
  19424. "</i>"
  19425. );
  19426. }
  19427. }
  19428. });
  19429. // remove old nodes
  19430. circle.exit().remove();
  19431. // set the graph in motion
  19432. force.start();
  19433. }
  19434. function mousedown() {
  19435. // prevent I-bar on drag
  19436. //d3.event.preventDefault();
  19437. // because :active only works in WebKit?
  19438. svg.classed("active", true);
  19439. if (mousedown_node) {
  19440. viewNode(mousedown_node);
  19441. }
  19442. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  19443. return;
  19444. restart();
  19445. }
  19446. function mousemove() {
  19447. if (!mousedown_node) return;
  19448. // update drag line
  19449. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  19450. //restart();
  19451. }
  19452. function mouseup() {
  19453. if (mousedown_node) {
  19454. // hide drag line
  19455. drag_line.classed("hidden", true).style("marker-end", "");
  19456. }
  19457. // because :active only works in WebKit?
  19458. svg.classed("active", false);
  19459. // clear mouse event vars
  19460. resetMouseVars();
  19461. }
  19462. function spliceLinksForNode(node) {
  19463. var toSplice = links.filter(function (l) {
  19464. return l.source === node || l.target === node;
  19465. });
  19466. toSplice.map(function (l) {
  19467. links.splice(links.indexOf(l), 1);
  19468. });
  19469. }
  19470. // only respond once per keydown
  19471. var lastKeyDown = -1;
  19472. function keydown() {
  19473. //d3.event.preventDefault();
  19474. if (lastKeyDown !== -1) return;
  19475. lastKeyDown = d3.event.keyCode;
  19476. // ctrl
  19477. if (d3.event.keyCode === 17) {
  19478. circle.call(force.drag);
  19479. svg.classed("ctrl", true);
  19480. }
  19481. if (!selected_node && !selected_link) return;
  19482. switch (d3.event.keyCode) {
  19483. case 8: // backspace
  19484. case 66: // B
  19485. if (selected_link) {
  19486. // set link direction to both left and right
  19487. selected_link.left = true;
  19488. selected_link.right = true;
  19489. }
  19490. restart();
  19491. break;
  19492. case 76: // L
  19493. if (selected_link) {
  19494. // set link direction to left only
  19495. selected_link.left = true;
  19496. selected_link.right = false;
  19497. }
  19498. restart();
  19499. break;
  19500. case 82: // R
  19501. if (selected_node) {
  19502. // toggle node reflexivity
  19503. selected_node.reflexive = !selected_node.reflexive;
  19504. } else if (selected_link) {
  19505. // set link direction to right only
  19506. selected_link.left = false;
  19507. selected_link.right = true;
  19508. }
  19509. restart();
  19510. break;
  19511. }
  19512. }
  19513. function keyup() {
  19514. lastKeyDown = -1;
  19515. // ctrl
  19516. if (d3.event.keyCode === 17) {
  19517. circle
  19518. .on("mousedown.drag", null)
  19519. .on("touchstart.drag", null);
  19520. svg.classed("ctrl", false);
  19521. }
  19522. }
  19523. function viewNode(node) {
  19524. // console.log(svg.attr('left'));
  19525. //var el = angular.element('div.modal-dialog')[0];
  19526. var title =
  19527. $scope.selected_node.name +
  19528. "-[" +
  19529. $scope.selected_node.uuid +
  19530. "]";
  19531. if (!$scope.selected_node.props.state) {
  19532. $scope.selected_node.props.state = "空";
  19533. } else if ($scope.selected_node.props.state) {
  19534. if ($scope.selected_node.props.state == "1") {
  19535. $scope.selected_node.props.state = "未审核";
  19536. } else if ($scope.selected_node.props.state == "2") {
  19537. $scope.selected_node.props.state = "已审核";
  19538. } else if ($scope.selected_node.props.state == "3") {
  19539. $scope.selected_node.props.state = "不匹配";
  19540. } else if ($scope.selected_node.props.state == "4") {
  19541. $scope.selected_node.props.state = "丢失";
  19542. }
  19543. }
  19544. if (!$scope.selected_node.name) {
  19545. $scope.selected_node.name = "空";
  19546. }
  19547. if (!$scope.selected_node.status) {
  19548. $scope.selected_node.statu = "空";
  19549. }
  19550. if (!$scope.selected_node.props.useradmin) {
  19551. $scope.selected_node.props.useradmin = "空";
  19552. }
  19553. Toaster.pop({
  19554. // type: 'info',
  19555. // title: title,
  19556. body:
  19557. "<br/><p>搜索代码:" +
  19558. $scope.selected_node.uuid +
  19559. "</p>" +
  19560. "<p>配置标题:" +
  19561. $scope.selected_node.name +
  19562. "</p>" +
  19563. "<p>状态:" +
  19564. $scope.selected_node.status +
  19565. "</p>" +
  19566. "<p>审核状态:" +
  19567. $scope.selected_node.props.state +
  19568. "</p>" +
  19569. "<p>维护人员:" +
  19570. $scope.selected_node.props.useradmin +
  19571. "</p>",
  19572. bodyOutputType: "trustedHtml",
  19573. timeout: 3000,
  19574. });
  19575. }
  19576. //GT 颜色与数值对照表
  19577. function colors(sign) {
  19578. //num=num>20?num%20:parseInt(num);
  19579. for (var i = 0; i < labels.length; i++) {
  19580. var entity = labels[i];
  19581. if (sign == entity.sign) {
  19582. return entity.color;
  19583. }
  19584. if (i == labels.length - 1 && sign != entity.sign) {
  19585. return "#ffeeee";
  19586. }
  19587. }
  19588. }
  19589. $scope.init = function () {
  19590. svg = d3
  19591. .select("#cmdbSVG")
  19592. .append("svg")
  19593. .attr("width", width)
  19594. .attr("height", height);
  19595. // init D3 force layout
  19596. force = d3.layout
  19597. .force()
  19598. .nodes(nodes)
  19599. .links(links)
  19600. .size([width, height])
  19601. .gravity(0.05)
  19602. .linkDistance(150)
  19603. .linkStrength(2)
  19604. .charge(-500)
  19605. .on("tick", tick);
  19606. // define arrow markers for graph links
  19607. svg
  19608. .append("svg:defs")
  19609. .append("svg:marker")
  19610. .attr("id", "end-arrow")
  19611. .attr("viewBox", "0 -5 10 10")
  19612. .attr("refX", 6)
  19613. .attr("markerWidth", 3)
  19614. .attr("markerHeight", 3)
  19615. .attr("orient", "auto")
  19616. .append("svg:path")
  19617. .attr("d", "M0,-5L10,0L0,5")
  19618. .attr("fill", "#000");
  19619. svg
  19620. .append("svg:defs")
  19621. .append("svg:marker")
  19622. .attr("id", "start-arrow")
  19623. .attr("viewBox", "0 -5 10 10")
  19624. .attr("refX", 4)
  19625. .attr("markerWidth", 3)
  19626. .attr("markerHeight", 3)
  19627. .attr("orient", "auto")
  19628. .append("svg:path")
  19629. .attr("d", "M10,-5L0,0L10,5")
  19630. .attr("fill", "#000");
  19631. // line displayed when dragging new nodes
  19632. drag_line = svg
  19633. .append("svg:path")
  19634. .attr("class", "link dragline hidden")
  19635. .attr("d", "M0,0L0,0");
  19636. // handles to link and node element groups
  19637. //(1)var path = svg.append('svg:g').selectAll('g')
  19638. path = svg.append("svg:g").selectAll("g");
  19639. circle = svg.append("svg:g").selectAll("g");
  19640. svg
  19641. .on("mousedown", mousedown)
  19642. .on("mousemove", mousemove)
  19643. .on("mouseup", mouseup);
  19644. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  19645. };
  19646. var CI = {};
  19647. window.CI = CI;
  19648. $scope.ok = function () {
  19649. $modalInstance.close($scope.selected_node);
  19650. };
  19651. $scope.cancel = function () {
  19652. $modalInstance.dismiss("cancel");
  19653. };
  19654. },
  19655. size: size,
  19656. resolve: {
  19657. title: function () {
  19658. return options.templateOptions.title;
  19659. },
  19660. Restangular: function () {
  19661. return options.templateOptions.Restangular;
  19662. },
  19663. APIService: function () {
  19664. return options.templateOptions.ApiService;
  19665. },
  19666. ConfigDataService: function () {
  19667. return options.templateOptions.ConfigDataService;
  19668. },
  19669. ConfigFormService: function () {
  19670. return options.templateOptions.ConfigFormService;
  19671. },
  19672. SweetAlert: function () {
  19673. return options.templateOptions.Alert;
  19674. },
  19675. Toaster: function () {
  19676. return options.templateOptions.toaster;
  19677. },
  19678. },
  19679. });
  19680. modalInstance.result.then(
  19681. function (selectedItem) {
  19682. options.value(selectedItem.name + "-" + selectedItem.uuid);
  19683. },
  19684. function () {
  19685. //console.log('Modal dismissed at: ' + new Date());
  19686. }
  19687. );
  19688. },
  19689. },
  19690. };
  19691. },
  19692. controller: [
  19693. "$scope",
  19694. function ($scope) {
  19695. // setTimeout(function(){
  19696. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  19697. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  19698. // if(modelData.status==200){
  19699. // $scope.model[$scope.options.key] = modelData.data;
  19700. // $scope.options.initialValue = $scope.model[$scope.options.key];
  19701. // }
  19702. // });
  19703. // },1000);
  19704. },
  19705. ],
  19706. });
  19707. });
  19708. appFormly.run(function (formlyConfig, $parse) {
  19709. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  19710. var removeOnHideTransformer = function (fields, model) {
  19711. return fields.map(function (field) {
  19712. if (
  19713. field.hideExpression &&
  19714. (!field.data || !field.data.dontRemoveOnHidden)
  19715. ) {
  19716. addFieldRemoveOnHideWatcher(field);
  19717. }
  19718. if (field.type == "ui-title") {
  19719. addFieldRemoveOnHideWatcher(field);
  19720. }
  19721. return field;
  19722. });
  19723. };
  19724. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  19725. function addFieldRemoveOnHideWatcher(field) {
  19726. var watcher = getWatcher();
  19727. if (field.watcher) {
  19728. if (!angular.isArray(field.watcher)) {
  19729. field.watcher = [field.watcher];
  19730. }
  19731. field.watcher.push(watcher);
  19732. } else {
  19733. field.watcher = watcher;
  19734. }
  19735. }
  19736. function getWatcher() {
  19737. return {
  19738. expression: function (field) {
  19739. return field.hide;
  19740. },
  19741. listener: function (field, newHide, oldHide, scope) {
  19742. if (field.hide) {
  19743. if (field.templateOptions.pkey) {
  19744. if (field.key == "transferuser") {
  19745. $parse(field.templateOptions.pkey + "." + field.key).assign(
  19746. scope.model,
  19747. undefined
  19748. );
  19749. }
  19750. } else {
  19751. $parse(field.key).assign(scope.model, undefined);
  19752. }
  19753. }
  19754. if (field.type == "ui-title") {
  19755. $parse(field.key).assign(scope.model, undefined);
  19756. }
  19757. },
  19758. };
  19759. }
  19760. });
  19761. appFormly.controller("CustomformCtrl", [
  19762. "$rootScope",
  19763. "$scope",
  19764. "$parse",
  19765. "$injector",
  19766. "$http",
  19767. "$q",
  19768. "$state",
  19769. "$stateParams",
  19770. "$modal",
  19771. "$timeout",
  19772. "$interval",
  19773. "SweetAlert",
  19774. "FileUploader",
  19775. "i18nService",
  19776. "Restangular",
  19777. "UserRestangular",
  19778. "BpmRestangular",
  19779. "WechatRestangular",
  19780. "api_configure_form",
  19781. "api_bpm_domain",
  19782. "api_bpm_domain1",
  19783. "api_bpm_data",
  19784. "api_user_data",
  19785. "api_statistic",
  19786. "up_down_file",
  19787. "fileReader",
  19788. function (
  19789. $rootScope,
  19790. $scope,
  19791. $parse,
  19792. $injector,
  19793. $http,
  19794. $q,
  19795. $state,
  19796. $stateParams,
  19797. $modal,
  19798. $timeout,
  19799. $interval,
  19800. SweetAlert,
  19801. FileUploader,
  19802. i18nService,
  19803. Restangular,
  19804. UserRestangular,
  19805. BpmRestangular,
  19806. WechatRestangular,
  19807. api_configure_form,
  19808. api_bpm_domain,
  19809. api_bpm_domain1,
  19810. api_bpm_data,
  19811. api_user_data,
  19812. api_statistic,
  19813. up_down_file,
  19814. fileReader
  19815. ) {
  19816. //console.log($parse('Restangular')($scope));
  19817. //console.log($injector.get('Restangular'));
  19818. //console.log($stateParams);
  19819. //保存报修主体
  19820. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  19821. $scope.imgUrlList = [];
  19822. $scope.uploadimg_del = function () {
  19823. console.log(123);
  19824. };
  19825. var vm = this;
  19826. vm.options = {};
  19827. vm.exampleTitle = ["expressionProperties", "model property"];
  19828. vm.fields = [];
  19829. vm.model = {};
  19830. $scope.langs = i18nService.getAllLangs();
  19831. $scope.lang = "zh-cn";
  19832. i18nService.setCurrentLang($scope.lang);
  19833. //alert($rootScope.user.id,null,2);
  19834. vm.model["loginUser"] = $rootScope.user;
  19835. var loginUser = $rootScope.user;
  19836. // console.log(vm);
  19837. var that = $injector;
  19838. var parse = $parse;
  19839. var formKey = "";
  19840. var pdKey = "";
  19841. var modelWatch = "";
  19842. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  19843. modelWatch = JSON.parse($stateParams.model);
  19844. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  19845. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  19846. console.log(modelWatch, $rootScope);
  19847. // if(modelWatch.model.incident){
  19848. // if(modelWatch.model.incident.place){
  19849. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  19850. // }else{
  19851. // $rootScope.selecthouseNumber = undefined;
  19852. // }
  19853. // }
  19854. }
  19855. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  19856. pdKey = $state.current.pdKey;
  19857. } else if ($stateParams.pdKey) {
  19858. pdKey = $stateParams.pdKey;
  19859. }
  19860. // console.log("pdKey::" + JSON.stringify($state.current.title));
  19861. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  19862. formKey = $stateParams.formKey;
  19863. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  19864. }
  19865. if (angular.isDefined($stateParams.model)) {
  19866. var formModel = $stateParams.model;
  19867. }
  19868. //用户测试数据,后续从header的auth中获取
  19869. var userId = 2;
  19870. userId = $rootScope.user.id;
  19871. //==============处理表单设计数据 开始====================
  19872. //处理组件加载后台数据选项的方法
  19873. function refreshSelectOptions(searchVal, field) {
  19874. if (
  19875. field.templateOptions.optionsUrl &&
  19876. !field.templateOptions.isnosearch
  19877. ) {
  19878. var process = BpmRestangular.all("");
  19879. if (field.templateOptions.ApiService) {
  19880. process = UserRestangular.all("");
  19881. }
  19882. if (field.templateOptions.Apicommon) {
  19883. process = WechatRestangular.all("");
  19884. }
  19885. var datakey = {
  19886. idx: 0,
  19887. sum: 1000,
  19888. };
  19889. if (field.templateOptions.modelreasondata) {
  19890. datakey = field.templateOptions.modelreasondata;
  19891. }
  19892. process
  19893. .customPOST(datakey, field.templateOptions.optionsUrl)
  19894. .then(function (result) {
  19895. if (!field.templateOptions.options) {
  19896. field.templateOptions.options = [];
  19897. }
  19898. if (field.templateOptions.optionsDataKey) {
  19899. field.templateOptions.options =
  19900. result[field.templateOptions.optionsDataKey];
  19901. } else {
  19902. field.templateOptions.options = result;
  19903. }
  19904. });
  19905. }
  19906. }
  19907. //获取表单后数据处理
  19908. function formfield(field, result) {
  19909. // angular.forEach(fields.fields, function(field) {
  19910. if (field.key == "") {
  19911. delete field.key;
  19912. }
  19913. if (angular.isDefined(field.extjson)) {
  19914. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  19915. angular.extend(field.templateOptions, extObj.templateOptions);
  19916. delete extObj.templateOptions;
  19917. for (var prop in extObj) {
  19918. if (new RegExp("Expression").test(prop)) {
  19919. //var obj = $scope.$eval(extObj[prop]);
  19920. //extObj[prop] = $scope.$eval(extObj[prop]);
  19921. if (extObj[prop] != null) {
  19922. if (new RegExp("function").test(extObj[prop])) {
  19923. var propValue = eval(extObj[prop]);
  19924. extObj[prop] = propValue;
  19925. } else {
  19926. //console.log(extObj[prop]);
  19927. var obj = $scope.$eval(extObj[prop]);
  19928. extObj[prop] = obj;
  19929. //console.log(obj);
  19930. }
  19931. }
  19932. } else if (new RegExp("expressionProperties").test(prop)) {
  19933. for (var p in extObj[prop]) {
  19934. if (new RegExp("function").test(extObj[prop][p])) {
  19935. var propValue = eval(extObj[prop][p]);
  19936. extObj[prop][p] = propValue;
  19937. } else {
  19938. //if(p.indexOf("'")>=0){
  19939. // var obj = $scope.$eval(extObj[prop][p]);
  19940. // extObj[prop][$scope.$eval(p)]=obj;
  19941. //}
  19942. }
  19943. }
  19944. } else if ("watcher" == prop) {
  19945. if (angular.isArray(extObj[prop])) {
  19946. angular.forEach(extObj[prop], function (item, index) {
  19947. for (var p in item) {
  19948. if (new RegExp("function").test(item[p])) {
  19949. var propValue = eval(item[p]);
  19950. extObj[prop][index][p] = propValue;
  19951. }
  19952. }
  19953. });
  19954. } else if (angular.isObject(extObj[prop])) {
  19955. for (var p in extObj[prop]) {
  19956. if (new RegExp("function").test(extObj[prop][p])) {
  19957. var propValue = eval(extObj[prop][p]);
  19958. extObj[prop][p] = propValue;
  19959. }
  19960. }
  19961. }
  19962. }
  19963. }
  19964. angular.extend(field, extObj);
  19965. delete field.extjson;
  19966. }
  19967. if (angular.isDefined(field.templateOptions)) {
  19968. var templateOs = field.templateOptions;
  19969. // console.log(templateOs,'come')
  19970. for (var property in templateOs) {
  19971. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  19972. if (angular.isString(templateOs[property])) {
  19973. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  19974. if (new RegExp("function").test(templateOs[property])) {
  19975. var propValue = eval(templateOs[property]);
  19976. field.templateOptions[property] = propValue;
  19977. } else {
  19978. if (that.has(templateOs[property])) {
  19979. field.templateOptions[property] = that.get(
  19980. templateOs[property]
  19981. );
  19982. } else {
  19983. field.templateOptions[property] = templateOs[property];
  19984. }
  19985. }
  19986. } else if (templateOs[property] == null) {
  19987. //delete field.templateOptions[property];
  19988. } else {
  19989. }
  19990. }
  19991. }
  19992. if (
  19993. angular.isDefined(field.templateOptions) &&
  19994. angular.isDefined(field.templateOptions.extjson)
  19995. ) {
  19996. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  19997. angular.extend(field.templateOptions, extObj);
  19998. delete field.templateOptions.extjson;
  19999. }
  20000. // ...
  20001. if (field.templateOptions) {
  20002. //处理远程获取数据控件方法调用
  20003. if (
  20004. field.templateOptions.optionsUrl &&
  20005. !field.templateOptions.refresh
  20006. ) {
  20007. // if (!field.templateOptions.isnoreash) {
  20008. field.templateOptions.refresh = refreshSelectOptions;
  20009. // }
  20010. }
  20011. //处理嵌套属性数据绑定/
  20012. if (field.templateOptions.pkey) {
  20013. var pmodel,
  20014. i = 0;
  20015. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  20016. if (i == 0) {
  20017. if (result.model[p] == null) {
  20018. result.model[p] = {};
  20019. }
  20020. pmodel = result.model[p];
  20021. i++;
  20022. } else {
  20023. if (pmodel[p] == null) {
  20024. pmodel[p] = {};
  20025. }
  20026. pmodel = pmodel[p];
  20027. }
  20028. });
  20029. if (pmodel != null) {
  20030. field.model = pmodel;
  20031. if (pmodel[field.key] == null) {
  20032. pmodel[field.key] = null;
  20033. }
  20034. }
  20035. } else {
  20036. if (result.model[field.key] == null) {
  20037. result.model[field.key] = null;
  20038. }
  20039. }
  20040. //处理弹出框组件初始化
  20041. if (field.type == "ui-input-selectmodal") {
  20042. field.templateOptions.modal = $modal;
  20043. //field.templateOptions.Restangular = Restangular;
  20044. } else if (field.type == "ui-requesterselect") {
  20045. //field.templateOptions.language = $scope.lang;
  20046. field.templateOptions.modal = $modal;
  20047. field.templateOptions.UserService = api_user_data;
  20048. } else if (field.type == "ui-deptinformation") {
  20049. field.templateOptions.modal = $modal;
  20050. field.templateOptions.UserService = api_user_data;
  20051. } else if (field.type == "ui-requesterinformation") {
  20052. field.templateOptions.modal = $modal;
  20053. field.templateOptions.UserService = api_user_data;
  20054. } else if (field.type == "ui-userselect") {
  20055. field.templateOptions.modal = $modal;
  20056. //field.templateOptions.Restangular = Restangular;
  20057. } else if (field.type == "ui-userselectSearch") {
  20058. field.templateOptions.modal = $modal;
  20059. //field.templateOptions.Restangular = Restangular;
  20060. } else if (field.type == "ui-multiuserselect") {
  20061. field.templateOptions.modal = $modal;
  20062. } else if (field.type == "ui-stringuserselect") {
  20063. field.templateOptions.modal = $modal;
  20064. } else if (field.type == "ui-search") {
  20065. field.templateOptions.modal = $modal;
  20066. } else if (field.type == "ui-modelselect") {
  20067. field.templateOptions.modal = $modal;
  20068. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20069. field.templateOptions.loginUser = $rootScope.user;
  20070. //field.templateOptions.Restangular = Restangular;
  20071. } else if (field.type == "ui-incidentmodelselect") {
  20072. field.templateOptions.modal = $modal;
  20073. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20074. field.templateOptions.loginUser = $rootScope.user;
  20075. //field.templateOptions.Restangular = Restangular;
  20076. } else if (field.type == "ui-dropfile") {
  20077. $scope.fileUploader = field.templateOptions.fileUploader =
  20078. new FileUploader({
  20079. url: "/uploader",
  20080. });
  20081. field.templateOptions.taskId = $stateParams.taskId;
  20082. field.templateOptions.processInstanceId =
  20083. $stateParams.processInstanceId;
  20084. field.templateOptions.userId = $rootScope.user.id;
  20085. } else if (field.type == "ui-dropfielknow") {
  20086. $scope.fileUploader = field.templateOptions.fileUploader =
  20087. new FileUploader({
  20088. url: "/uploader",
  20089. });
  20090. field.templateOptions.taskId = $stateParams.taskId;
  20091. field.templateOptions.processInstanceId =
  20092. $stateParams.processInstanceId;
  20093. field.templateOptions.userId = $rootScope.user.id;
  20094. } else if (field.type == "ui-upDropFile") {
  20095. $scope.fileUploader = field.templateOptions.fileUploader =
  20096. new FileUploader({
  20097. url: "/uploader",
  20098. });
  20099. field.templateOptions.taskId = $stateParams.taskId;
  20100. field.templateOptions.processInstanceId =
  20101. $stateParams.processInstanceId;
  20102. field.templateOptions.userId = $rootScope.user.id;
  20103. } else if (field.type == "ui-dropfilenotup") {
  20104. $scope.fileUploader = field.templateOptions.fileUploader =
  20105. new FileUploader({
  20106. url: "/uploader",
  20107. });
  20108. field.templateOptions.taskId = $stateParams.taskId;
  20109. field.templateOptions.processInstanceId =
  20110. $stateParams.processInstanceId;
  20111. field.templateOptions.userId = $rootScope.user.id;
  20112. //field.ApiService=api_bpm_domain;
  20113. } else if (field.type == "ui-uploadFiles") {
  20114. $scope.fileUploader = field.templateOptions.fileUploader =
  20115. new FileUploader({
  20116. url: "/uploader",
  20117. });
  20118. field.templateOptions.taskId = $stateParams.taskId;
  20119. field.templateOptions.processInstanceId =
  20120. $stateParams.processInstanceId;
  20121. field.templateOptions.userId = $rootScope.user.id;
  20122. //field.ApiService=api_bpm_domain;
  20123. } else if (field.type == "ui-upDownFiles") {
  20124. $scope.fileUploader = field.templateOptions.fileUploader =
  20125. new FileUploader({
  20126. url: "/uploader",
  20127. });
  20128. field.templateOptions.taskId = $stateParams.taskId;
  20129. field.templateOptions.processInstanceId =
  20130. $stateParams.processInstanceId;
  20131. field.templateOptions.userId = $rootScope.user.id;
  20132. //field.ApiService=api_bpm_domain;
  20133. } else if (field.type == "ui-uploadImgs") {
  20134. $scope.fileUploader = field.templateOptions.fileUploader =
  20135. new FileUploader({
  20136. url: "/uploader",
  20137. });
  20138. field.templateOptions.taskId = $stateParams.taskId;
  20139. field.templateOptions.processInstanceId =
  20140. $stateParams.processInstanceId;
  20141. field.templateOptions.userId = $rootScope.user.id;
  20142. //field.ApiService=api_bpm_domain;
  20143. } else if (field.type == "ui-dropfiletable") {
  20144. if (field.templateOptions.processInstanceId) {
  20145. } else {
  20146. field.templateOptions.processInstanceId =
  20147. $stateParams.processInstanceId;
  20148. }
  20149. } else if (field.type == "ui-dropFiles") {
  20150. if (field.templateOptions.processInstanceId) {
  20151. } else {
  20152. field.templateOptions.processInstanceId =
  20153. $stateParams.processInstanceId;
  20154. }
  20155. } else if (field.type == "ui-showImgs") {
  20156. if (field.templateOptions.processInstanceId) {
  20157. } else {
  20158. field.templateOptions.processInstanceId =
  20159. $stateParams.processInstanceId;
  20160. }
  20161. } else if (field.type == "ui-repeatSection") {
  20162. var repeatForm = {
  20163. model: {},
  20164. fields: field.templateOptions.fields,
  20165. };
  20166. repeatForm.model[field.key] = [];
  20167. decodeVMForm(repeatForm);
  20168. } else if (field.type == "ui-currentuser") {
  20169. field.templateOptions.user = vm.model["loginUser"];
  20170. } else if (field.type == "ui-workernumbersign") {
  20171. field.templateOptions.user = vm.model["loginUser"];
  20172. } else if (field.type == "ui-repair-photos") {
  20173. field.templateOptions.user = vm.model["loginUser"];
  20174. }
  20175. }
  20176. }
  20177. //解析自定义表单设计数据
  20178. $scope.oldfromtype = true;
  20179. function decodeVMForm(vmForm) {
  20180. if (vmForm.formType == "1") {
  20181. $scope.oldfromtype = false;
  20182. } else {
  20183. $scope.oldfromtype = true;
  20184. }
  20185. var result = {
  20186. model: {},
  20187. fields: [],
  20188. };
  20189. //设置模型实体数据 begin
  20190. // var mdata = vmForm.model;
  20191. //解析数据实体
  20192. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  20193. angular.extend(result.model, mdata);
  20194. if (modelWatch != null && modelWatch != "") {
  20195. //angular.extend(result.model.incident,modelWatch.incident);
  20196. //result.model.alarmType = modelWatch.alarmType;
  20197. // vmForm.cancelUrl = modelWatch.cancelUrl;
  20198. // console.log(modelWatch.cancelUrl)
  20199. for (var index in modelWatch.model) {
  20200. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  20201. if (result.model[index] != null) {
  20202. angular.extend(result.model[index], modelWatch.model[index]);
  20203. } else {
  20204. result.model[index] = modelWatch.model[index];
  20205. }
  20206. }
  20207. }
  20208. //设置模型实体数据 end
  20209. //解析设计数据生成表单项 begin
  20210. var fields = [];
  20211. //处理修改设计数据中展示设置
  20212. angular.forEach(vmForm.fields, function (fields) {
  20213. if (vmForm.formType == "1") {
  20214. angular.forEach(fields.fields, function (field) {
  20215. formfield(field, result);
  20216. });
  20217. } else {
  20218. formfield(fields, result);
  20219. }
  20220. // console.log(field);
  20221. result.fields.push(fields);
  20222. });
  20223. angular.extend($scope.vm.fields, result.fields);
  20224. angular.extend($scope.vm.model, result.model);
  20225. vm.model["loginUser"] = $rootScope.user;
  20226. //增加识别报修主体seimin
  20227. vm.model.repairType = $scope.repairMain.valueconfig;
  20228. if (vm.model.incident) {
  20229. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  20230. }
  20231. console.log(vm, "repairType"); //lmm
  20232. if (
  20233. modelWatch != null &&
  20234. modelWatch != "" &&
  20235. modelWatch.cancelUrl != null &&
  20236. modelWatch.cancelUrl != ""
  20237. ) {
  20238. vmForm.cancelUrl = modelWatch.cancelUrl;
  20239. }
  20240. $scope.formData = vmForm;
  20241. console.log($scope.formData, 4444444);
  20242. // console.log($scope.formData.url);
  20243. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  20244. if ($scope.formData.url == "start") {
  20245. $scope.Reset = true;
  20246. $scope.close = true;
  20247. $rootScope.isMask = false;
  20248. } else if ($scope.formData.url == "complete") {
  20249. $scope.Reset = false;
  20250. $scope.close = true;
  20251. }
  20252. //解析设计数据生成表单项 end
  20253. return result;
  20254. }
  20255. //======================处理表单设计数据 结束========================
  20256. $scope.ldloading = {};
  20257. function filter(obj) {
  20258. angular.forEach(obj, function (key, value) {
  20259. if (value === "" || value === null) {
  20260. delete obj[key];
  20261. } else if (
  20262. Object.prototype.toString.call(value) === "[object Object]"
  20263. ) {
  20264. filter(value);
  20265. } else if (angular.isArray(value)) {
  20266. angular.forEach(value, function (item) {
  20267. filter(item);
  20268. });
  20269. }
  20270. });
  20271. }
  20272. $scope.closeModel = function () {
  20273. // console.log($stateParams);
  20274. $state.go($scope.formData.cancelUrl, {});
  20275. event.preventDefault();
  20276. };
  20277. // console.log(vm);
  20278. // 暂存
  20279. $scope.save = function (data) {
  20280. console.log(vm);
  20281. if (vm.model.startSave) {
  20282. vm.model["initUser"] = $rootScope.user.id;
  20283. vm.model.start_code = "temporary";
  20284. //处理请求数据0327
  20285. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20286. delete data0327.repairType;
  20287. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20288. if (
  20289. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20290. .selecthouseNumber
  20291. ) {
  20292. data0327.incident.place = {
  20293. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20294. .selecthouseNumber.id,
  20295. };
  20296. }
  20297. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  20298. if (response) {
  20299. var resData = Restangular.stripRestangular(response);
  20300. if (resData) {
  20301. if (
  20302. $scope.fileUploader != null &&
  20303. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  20304. resData.id
  20305. ) {
  20306. $scope.fileUploader.onBeforeUploadItem = function (item) {
  20307. angular.extend(item.headers, $rootScope.getSession());
  20308. item.url = api_bpm_domain
  20309. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  20310. .getRequestedUrl();
  20311. item.formData.push({
  20312. fileName: item.file.name,
  20313. });
  20314. //console.log();
  20315. };
  20316. $scope.fileUploader.uploadAll();
  20317. }
  20318. }
  20319. SweetAlert.swal(
  20320. {
  20321. title: "提交成功!",
  20322. type: "success",
  20323. confirmButtonColor: "#007AFF",
  20324. },
  20325. function () {
  20326. $state.go($scope.formData.cancelUrl);
  20327. }
  20328. );
  20329. } else {
  20330. SweetAlert.swal({
  20331. title: "系统错误",
  20332. text: "系统错误,请稍后重试!",
  20333. type: "error",
  20334. confirmButtonColor: "#DD6B55",
  20335. });
  20336. }
  20337. $scope.ldloading[style.replace("-", "_")] = false;
  20338. });
  20339. event.preventDefault();
  20340. } else if (vm.model.saveAgain) {
  20341. var toData = {
  20342. incident: vm.model.incident,
  20343. };
  20344. api_user_data.updData("incident", toData).then(function (response) {
  20345. if (response) {
  20346. var resData = Restangular.stripRestangular(response);
  20347. SweetAlert.swal(
  20348. {
  20349. title: "提交成功!",
  20350. type: "success",
  20351. confirmButtonColor: "#007AFF",
  20352. },
  20353. function () {
  20354. $state.go($scope.formData.cancelUrl);
  20355. }
  20356. );
  20357. } else {
  20358. SweetAlert.swal({
  20359. title: "系统错误",
  20360. text: "系统错误,请稍后重试!",
  20361. type: "error",
  20362. confirmButtonColor: "#DD6B55",
  20363. });
  20364. }
  20365. $scope.ldloading[style.replace("-", "_")] = false;
  20366. });
  20367. event.preventDefault();
  20368. } else {
  20369. SweetAlert.swal({
  20370. title: "系统错误",
  20371. text: "系统错误,请稍后重试!",
  20372. type: "error",
  20373. confirmButtonColor: "#DD6B55",
  20374. });
  20375. }
  20376. };
  20377. // 巡检生成事件
  20378. $scope.inspectionToIncident = function () {
  20379. var userData = {
  20380. idx: 0,
  20381. sum: 10,
  20382. requester: {
  20383. name: loginUser.name,
  20384. },
  20385. };
  20386. api_user_data.fetchDataList("requester", userData).then(function (res) {
  20387. console.log(res);
  20388. var toUser = {};
  20389. if (res.list.length > 0) {
  20390. toUser = res.list[0];
  20391. } else {
  20392. toUser = loginUser;
  20393. }
  20394. console.log(vm);
  20395. var incidentDescription = "";
  20396. console.log($stateParams.formUiEdit);
  20397. if ($stateParams.formUiEdit == "inspection_confirm") {
  20398. if (vm.model.wnCheckEnable) {
  20399. incidentDescription =
  20400. incidentDescription.concat(" 机房温度检查异常");
  20401. }
  20402. if (vm.model.sdCheckEnable) {
  20403. incidentDescription =
  20404. incidentDescription.concat(" 机房湿度检查异常");
  20405. }
  20406. if (vm.model.xfjCheckEnable) {
  20407. incidentDescription = incidentDescription.concat(" 新风机检查异常");
  20408. }
  20409. if (vm.model.lsCheckEnable) {
  20410. incidentDescription = incidentDescription.concat(" 漏水检查异常");
  20411. }
  20412. if (vm.model.xfCheckEnable) {
  20413. incidentDescription = incidentDescription.concat(" 消防检查异常");
  20414. }
  20415. if (vm.model.upsCheckEnable) {
  20416. incidentDescription =
  20417. incidentDescription.concat(" UPS供电检查异常");
  20418. }
  20419. if (vm.model.dcCheckEnable) {
  20420. incidentDescription =
  20421. incidentDescription.concat(" 电池连接检查异常");
  20422. }
  20423. if (vm.model.plCheckEnable) {
  20424. incidentDescription =
  20425. incidentDescription.concat(" 旁路供电检查异常");
  20426. }
  20427. if (vm.model.wjtdCheckEnable) {
  20428. incidentDescription =
  20429. incidentDescription.concat(" 外机通道检查异常");
  20430. }
  20431. if (vm.model.descriptionTextarea) {
  20432. incidentDescription = incidentDescription.concat(
  20433. " " + "备注:" + vm.model.descriptionTextarea
  20434. );
  20435. }
  20436. }
  20437. // console.log(incidentDescription)
  20438. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  20439. var formdata = {
  20440. model: {
  20441. // 'isInspection': true,
  20442. // 'start_code':'assignment',
  20443. // 'isHandlerUser':false,
  20444. incident: {
  20445. requester: bxr,
  20446. area: bxr.place.area,
  20447. place: bxr.place,
  20448. houseNumber: bxr.houseNumber,
  20449. contacts: bxr.name,
  20450. contactsInformation: bxr.mphone,
  20451. // 'category': data.wxIncidentClassifyDTO.category,
  20452. description: incidentDescription,
  20453. source: {
  20454. id: 1552,
  20455. },
  20456. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  20457. // 'sourceType': data.incident.sourceType,
  20458. // 'fileUrl': data.incident.fileUrl
  20459. },
  20460. // 'requestershow': toUser,//2020年4月27日22:29:15
  20461. // 'flow': data.incident.id
  20462. // 'assignee': loginUser.id//2020年4月27日22:29:25
  20463. },
  20464. };
  20465. // console.log(formdata,toUser,'1111');
  20466. console.log(formdata, "1111");
  20467. // return;
  20468. $state.go("app.incident.chart", {
  20469. model: JSON.stringify(formdata),
  20470. });
  20471. });
  20472. // var formdata = {
  20473. // model:$rootScope.login_requester
  20474. // };
  20475. // console.log(formdata,'00000')
  20476. // return;
  20477. // $state.go("app.incident.chart", {
  20478. // 'model': JSON.stringify(formdata)
  20479. // });
  20480. event.preventDefault();
  20481. };
  20482. // console.log(vm);
  20483. // 创建事件seimin
  20484. vm.submit = function (data, style) {
  20485. console.log(vm, 22222);
  20486. // return;
  20487. if (vm.model.handler_code == undefined) {
  20488. vm.model.handler_code = "resolve";
  20489. }
  20490. if (
  20491. vm.model.change &&
  20492. vm.model.change.requestingPerson &&
  20493. vm.model.change.requestingPerson.menu
  20494. ) {
  20495. delete vm.model.change.requestingPerson.menu;
  20496. }
  20497. // var pdKey = $stateParams.pdKey;
  20498. if (vm.form.$valid) {
  20499. if (data.incident && data.incident.synergetic) {
  20500. console.log(data.incident.synergetic);
  20501. var synergetic = [];
  20502. for (var i = 0; i < data.incident.synergetic.length; i++) {
  20503. synergetic.push({
  20504. id: data.incident.synergetic[i],
  20505. });
  20506. }
  20507. data.incident.synergetic = synergetic;
  20508. vm.model.incident.synergetic = synergetic;
  20509. }
  20510. $scope.ldloading[style.replace("-", "_")] = true;
  20511. var startsub = true;
  20512. if (pdKey == "bpm_incident") {
  20513. angular.forEach(vm.fields, function (item) {
  20514. angular.forEach(item.fields, function (index) {
  20515. if (index.templateOptions.required && !index.hide) {
  20516. if (index.model) {
  20517. if (
  20518. angular.isDefined(index.model[index.key]) &&
  20519. index.model[index.key] != null
  20520. ) {
  20521. if (
  20522. index.model[index.key].id &&
  20523. index.model[index.key].id == ""
  20524. ) {
  20525. startsub = false;
  20526. $scope.ldloading.expand_right = false;
  20527. SweetAlert.swal({
  20528. title: index.templateOptions.label + "未填",
  20529. text: "请填写此项!",
  20530. type: "error",
  20531. confirmButtonColor: "#DD6B55",
  20532. });
  20533. } else {
  20534. }
  20535. } else {
  20536. startsub = false;
  20537. $scope.ldloading.expand_right = false;
  20538. console.log(vm);
  20539. SweetAlert.swal({
  20540. title: index.templateOptions.label + "未填",
  20541. text: "请填写此项!",
  20542. type: "error",
  20543. confirmButtonColor: "#DD6B55",
  20544. });
  20545. }
  20546. } else {
  20547. if (
  20548. data[index.key] &&
  20549. data[index.key] != "" &&
  20550. data[index.key] != null
  20551. ) {
  20552. } else {
  20553. startsub = false;
  20554. $scope.ldloading.expand_right = false;
  20555. SweetAlert.swal({
  20556. title: index.templateOptions.label + "未填",
  20557. text: "请填写此项!",
  20558. type: "error",
  20559. confirmButtonColor: "#DD6B55",
  20560. });
  20561. }
  20562. }
  20563. }
  20564. });
  20565. });
  20566. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  20567. // startsub = false;
  20568. // $scope.ldloading.expand_right = false;
  20569. // SweetAlert.swal({
  20570. // title: '保修人未填',
  20571. // text: "请填写此项!",
  20572. // type: "error",
  20573. // confirmButtonColor: "#DD6B55"
  20574. // });
  20575. // }
  20576. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  20577. // } else {
  20578. // startsub = false;
  20579. // $scope.ldloading.expand_right = false;
  20580. // SweetAlert.swal({
  20581. // title: '事件分类未填',
  20582. // text: "请填写此项!",
  20583. // type: "error",
  20584. // confirmButtonColor: "#DD6B55"
  20585. // });
  20586. // }
  20587. }
  20588. if (startsub) {
  20589. $scope.ldloading[style.replace("-", "_")] = true;
  20590. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  20591. // console.log("vm.options:"+ JSON.stringify(vm.options));
  20592. vm.options.updateInitialValue();
  20593. // console.log("dfjkasdhfkhskjf ")
  20594. var _ = window._;
  20595. vm.model = (function filter(obj) {
  20596. var dateTransKeys = [];
  20597. var filtered = _.pick(obj, function (v, k, obj) {
  20598. if (_.isDate(v)) {
  20599. dateTransKeys.push(k);
  20600. }
  20601. return (
  20602. angular.isDefined(v) &&
  20603. v !== null &&
  20604. (angular.isArray(v) ? v.length > 0 : true) &&
  20605. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  20606. );
  20607. });
  20608. return _.cloneDeep(filtered, function (v, index, object) {
  20609. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  20610. angular.forEach(dateTransKeys, function (item) {
  20611. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  20612. });
  20613. dateTransKey = [];
  20614. return v;
  20615. }
  20616. return !_.isEmpty(filtered) &&
  20617. v !== filtered &&
  20618. _.isPlainObject(v)
  20619. ? filter(v)
  20620. : undefined;
  20621. });
  20622. })(vm.model);
  20623. if (pdKey != "") {
  20624. if ($scope.oprcode == "save") {
  20625. //保存
  20626. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  20627. if (response) {
  20628. var resData = Restangular.stripRestangular(response);
  20629. SweetAlert.swal(
  20630. {
  20631. title: "保存成功!",
  20632. confirmButtonColor: "#007AFF",
  20633. },
  20634. function () {
  20635. $state.go($scope.formData.cancelUri);
  20636. }
  20637. );
  20638. // if(resData.status){
  20639. // resData
  20640. // }
  20641. } else {
  20642. SweetAlert.swal({
  20643. title: "系统错误",
  20644. text: "系统错误,请稍后重试!",
  20645. type: "error",
  20646. confirmButtonColor: "#DD6B55",
  20647. });
  20648. }
  20649. $scope.ldloading[style.replace("-", "_")] = false;
  20650. });
  20651. } else {
  20652. console.log($scope.formData.url, "zzzz");
  20653. switch ($scope.formData.url) {
  20654. case "start":
  20655. vm.model["initUser"] = $rootScope.user.id;
  20656. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  20657. } else {
  20658. vm.model["assignee"] = $rootScope.user.id;
  20659. }
  20660. if (
  20661. vm.model["candidateGroups"] &&
  20662. vm.model.candidateGroups.id
  20663. ) {
  20664. vm.model.candidateGroups = vm.model.candidateGroups.id;
  20665. }
  20666. if (pdKey == "bpm_service_request") {
  20667. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  20668. angular.extend(vm.model.serviceCatalogueProcessActual, {
  20669. category: {
  20670. id: $stateParams.userId,
  20671. },
  20672. });
  20673. }
  20674. if (vm.model.schedule && vm.model.schedule.initUser) {
  20675. delete vm.model.schedule.initUser.menu;
  20676. }
  20677. if (
  20678. vm.model.isHandlerUser == "true" ||
  20679. vm.model.isHandlerUser == true
  20680. ) {
  20681. delete vm.model.candidateGroups;
  20682. }
  20683. if (vm.model.start_code == "close") {
  20684. // 直接处理
  20685. vm.model.incident.handlingPersonnelUser =
  20686. vm.model.incident.acceptUser;
  20687. delete vm.model.incident.handlerUser;
  20688. delete vm.model.candidateGroups;
  20689. } else if (vm.model.start_code == "assignment") {
  20690. // 派单
  20691. delete vm.model.incident.handlingPersonnelUser;
  20692. }
  20693. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  20694. $scope.jry_processInstanceId =
  20695. $stateParams.processInstanceId;
  20696. }
  20697. if ($scope.jry_processInstanceId) {
  20698. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  20699. }
  20700. //事件暂存判断
  20701. if (vm.model.saveAgain) {
  20702. if (
  20703. vm.model.directClose == "1" ||
  20704. vm.model.directClose == true
  20705. ) {
  20706. vm.model.start_code = "assignment";
  20707. vm.model.temporary_code = "assignment";
  20708. } else {
  20709. vm.model.start_code = "close";
  20710. vm.model.temporary_code = "close";
  20711. }
  20712. if (
  20713. vm.model.isHandlerUser == "true" ||
  20714. vm.model.isHandlerUser == true
  20715. ) {
  20716. delete vm.model.candidateGroups;
  20717. }
  20718. }
  20719. //处理请求数据0327
  20720. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20721. delete data0327.repairType;
  20722. // 增加地点的请求参数2020年4月24日10:44:36
  20723. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20724. // if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  20725. // data0327.incident.place = {
  20726. // id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  20727. // }
  20728. // }
  20729. if (data0327.start_code == "close") {
  20730. data0327.incident.directProcess = 1;
  20731. }
  20732. console.log(vm);
  20733. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20734. var paramsModel = JSON.parse($stateParams.model)
  20735. //来电-传话机id
  20736. if (paramsModel.model.incident.sockid) {
  20737. data0327.incident.callID = paramsModel.model.incident.sockid;
  20738. }
  20739. }
  20740. api_bpm_domain
  20741. .start(pdKey, data0327)
  20742. .then(function (response) {
  20743. // console.log("response="+JSON.stringify(response));
  20744. if (response) {
  20745. var resData = Restangular.stripRestangular(response);
  20746. if (resData) {
  20747. if (resData) {
  20748. if (
  20749. $scope.fileUploader != null &&
  20750. $scope.fileUploader.getNotUploadedItems().length >
  20751. 0 &&
  20752. resData.id
  20753. ) {
  20754. $scope.fileUploader.onBeforeUploadItem =
  20755. function (item) {
  20756. angular.extend(
  20757. item.headers,
  20758. $rootScope.getSession()
  20759. );
  20760. item.url = api_bpm_domain
  20761. .uploadAttachment(
  20762. resData.id,
  20763. "00000",
  20764. $rootScope.user.id
  20765. )
  20766. .getRequestedUrl();
  20767. item.formData.push({
  20768. fileName: item.file.name,
  20769. });
  20770. //console.log();
  20771. };
  20772. $scope.fileUploader.uploadAll();
  20773. }
  20774. }
  20775. }
  20776. SweetAlert.swal(
  20777. {
  20778. title: "提交成功!",
  20779. type: "success",
  20780. confirmButtonColor: "#007AFF",
  20781. },
  20782. function () {
  20783. if (
  20784. vm.model.incident &&
  20785. vm.model.incident.callID &&
  20786. vm.model.incident.callID != ""
  20787. ) {
  20788. $rootScope.app.layout.isSidebarClosed = false;
  20789. if ($scope.login && !$rootScope.busy) {
  20790. $rootScope.setidle();
  20791. }
  20792. }
  20793. $state.go($scope.formData.cancelUrl);
  20794. }
  20795. );
  20796. } else {
  20797. SweetAlert.swal({
  20798. title: "系统错误",
  20799. text: "系统错误,请稍后重试!",
  20800. type: "error",
  20801. confirmButtonColor: "#DD6B55",
  20802. });
  20803. }
  20804. $scope.ldloading[style.replace("-", "_")] = false;
  20805. });
  20806. break;
  20807. case "complete":
  20808. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  20809. //console.log("complete taskId::"+$stateParams.taskId);
  20810. if (
  20811. $scope.formData.name == "transferform" &&
  20812. vm.model.ishandlers &&
  20813. !vm.model.incident.handlerUser
  20814. ) {
  20815. SweetAlert.swal({
  20816. title: "处理人未填",
  20817. text: "请填写此项!",
  20818. type: "error",
  20819. confirmButtonColor: "#DD6B55",
  20820. });
  20821. return;
  20822. }
  20823. console.log(vm);
  20824. //处理日志
  20825. // 处理日志不为空并且事件是处理中状态
  20826. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  20827. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  20828. baseHandler();
  20829. })
  20830. } else {
  20831. baseHandler();
  20832. }
  20833. // return;
  20834. function baseHandler() {
  20835. api_bpm_domain
  20836. .complete($stateParams.taskId, userId, vm.model)
  20837. .then(function (response) {
  20838. if (response) {
  20839. var resData = Restangular.stripRestangular(response);
  20840. SweetAlert.swal(
  20841. {
  20842. title: "提交成功!",
  20843. type: "success",
  20844. confirmButtonColor: "#007AFF",
  20845. },
  20846. function () {
  20847. if (
  20848. $scope.fileUploader != null &&
  20849. $scope.fileUploader.getNotUploadedItems().length >
  20850. 0
  20851. ) {
  20852. console.log(vm);
  20853. if (vm.model.incident) {
  20854. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  20855. // angular.extend(item.headers, $rootScope.getSession());
  20856. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  20857. // item.formData.push({
  20858. // 'fileName': item.file.name
  20859. // });
  20860. // };
  20861. // $scope.fileUploader.uploadAll();
  20862. $scope.fileUploader.onBeforeUploadItem =
  20863. function (item) {
  20864. angular.extend(
  20865. item.headers,
  20866. $rootScope.getSession()
  20867. );
  20868. item.url = api_bpm_domain
  20869. .uploadAttachment(
  20870. vm.model.incident.processInstanceId,
  20871. "00000",
  20872. $rootScope.user.id
  20873. )
  20874. .getRequestedUrl();
  20875. item.formData.push({
  20876. fileName: item.file.name,
  20877. });
  20878. //console.log();
  20879. };
  20880. $scope.fileUploader.uploadAll();
  20881. } else if (vm.model.problem) {
  20882. $scope.fileUploader.onBeforeUploadItem =
  20883. function (item) {
  20884. angular.extend(
  20885. item.headers,
  20886. $rootScope.getSession()
  20887. );
  20888. item.url = api_bpm_domain
  20889. .uploadAttachmentJryModel(
  20890. "problem",
  20891. vm.model.problem.id,
  20892. "00000",
  20893. $rootScope.user.id
  20894. )
  20895. .getRequestedUrl();
  20896. item.formData.push({
  20897. fileName: item.file.name,
  20898. });
  20899. };
  20900. $scope.fileUploader.uploadAll();
  20901. } else if (vm.model.change) {
  20902. }else if(vm.model.inspectionProcessActual){
  20903. //巡检图片上传yeye
  20904. $scope.fileUploader.onBeforeUploadItem =
  20905. function (item) {
  20906. angular.extend(
  20907. item.headers,
  20908. $rootScope.getSession()
  20909. );
  20910. item.url = api_bpm_domain1
  20911. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  20912. .getRequestedUrl();
  20913. item.formData.push({
  20914. fileName: item.file.name,
  20915. });
  20916. //console.log();
  20917. };
  20918. $scope.fileUploader.uploadAll();
  20919. }
  20920. }
  20921. $state.go($scope.formData.cancelUrl);
  20922. }
  20923. );
  20924. } else {
  20925. SweetAlert.swal({
  20926. title: "系统错误",
  20927. text: "系统错误,请稍后重试!",
  20928. type: "error",
  20929. confirmButtonColor: "#DD6B55",
  20930. });
  20931. }
  20932. $scope.ldloading[style.replace("-", "_")] = false;
  20933. });
  20934. }
  20935. break;
  20936. case "back":
  20937. $state.go($scope.formData.cancelUrl);
  20938. break;
  20939. default:
  20940. $scope.ldloading[style.replace("-", "_")] = false;
  20941. break;
  20942. }
  20943. }
  20944. // var submitFunc = api_bpm_domain[$scope.formData.url]
  20945. // if(anuglar.isFunction(submitFunc)){
  20946. // submitFunc.apply(null, pdKey)
  20947. // }
  20948. }
  20949. }
  20950. } else {
  20951. // console.log(data)
  20952. // angular.forEach(vm.form.$error.required, function(item){
  20953. // var i=(item.$name).substring(item.$name.length-2)
  20954. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  20955. // for(var i=0;i<vm.fields.length;i++){
  20956. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  20957. SweetAlert.swal({
  20958. title: vm.fields[i].templateOptions.label + "未填",
  20959. text: "请填写此项!",
  20960. type: "error",
  20961. confirmButtonColor: "#DD6B55",
  20962. });
  20963. }
  20964. // }
  20965. // angular.forEach(vm.fields,function(f){
  20966. // if(f.name == item.$name){
  20967. // f.validation.show = true;
  20968. // SweetAlert.swal({
  20969. // title: f.templateOptions.label+'未填',
  20970. // text: "请填写此项!",
  20971. // type: "error",
  20972. // confirmButtonColor: "#DD6B55"
  20973. // });
  20974. // }
  20975. // });
  20976. // })
  20977. }
  20978. };
  20979. $scope.vm = vm;
  20980. console.log($stateParams, pdKey, 88888);
  20981. console.log($scope.vm, "assdfsdf");
  20982. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  20983. var processInstanceId = $stateParams.processInstanceId;
  20984. var itemId = $stateParams.dataId;
  20985. console.log($stateParams);
  20986. if (
  20987. angular.isDefined($stateParams.pdKey) &&
  20988. $stateParams.pdKey == "bpm_inspection"
  20989. ) {
  20990. api_configure_form
  20991. .renderForm(
  20992. $stateParams.formUiEdit,
  20993. userId,
  20994. processInstanceId,
  20995. itemId
  20996. )
  20997. .then(function (responseData) {
  20998. if (responseData) {
  20999. //console.log("responseData>>>");//console.log(responseData);
  21000. var vmForm = Restangular.stripRestangular(responseData);
  21001. if (vmForm) {
  21002. //console.log("vmForm>>>");//console.log(vmForm);
  21003. decodeVMForm(vmForm);
  21004. }
  21005. }
  21006. });
  21007. } else if (
  21008. angular.isDefined($stateParams.pdKey) &&
  21009. $stateParams.pdKey == "bpm_service_request"
  21010. ) {
  21011. api_configure_form
  21012. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  21013. .then(function (responseData) {
  21014. if (responseData) {
  21015. //console.log("responseData>>>");//console.log(responseData);
  21016. var vmForm = Restangular.stripRestangular(responseData);
  21017. if (vmForm) {
  21018. //console.log("vmForm>>>");//console.log(vmForm);
  21019. decodeVMForm(vmForm);
  21020. }
  21021. }
  21022. });
  21023. } else {
  21024. api_bpm_domain
  21025. .taskformkey($stateParams.taskId)
  21026. .then(function (response) {
  21027. if (response) {
  21028. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  21029. api_configure_form
  21030. .renderForm(myData.data, userId, processInstanceId, itemId)
  21031. .then(function (responseData) {
  21032. if (responseData) {
  21033. //console.log("responseData>>>");//console.log(responseData);
  21034. var vmForm = Restangular.stripRestangular(responseData);
  21035. if (vmForm) {
  21036. //console.log("vmForm>>>");//console.log(vmForm);
  21037. decodeVMForm(vmForm);
  21038. console.log(vmForm, 111111);
  21039. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  21040. console.log($scope, "今天"); //2020年4月24日11:40:55
  21041. }
  21042. }
  21043. });
  21044. }
  21045. });
  21046. }
  21047. } else {
  21048. // create process instance
  21049. if (pdKey != "") {
  21050. //for process
  21051. if (pdKey == "bpm_service_request") {
  21052. api_configure_form
  21053. .renderForm($stateParams.formUiStart, userId)
  21054. .then(function (responseData) {
  21055. if (responseData) {
  21056. var vmForm = Restangular.stripRestangular(responseData);
  21057. if (vmForm) {
  21058. decodeVMForm(vmForm);
  21059. }
  21060. }
  21061. });
  21062. } else {
  21063. api_bpm_domain.startformkey(pdKey).then(function (response) {
  21064. if (response) {
  21065. var myData = Restangular.stripRestangular(response);
  21066. //myData.data = "arrangeform";
  21067. api_configure_form
  21068. .renderForm(myData.data, userId)
  21069. .then(function (responseData) {
  21070. if (responseData) {
  21071. var vmForm = Restangular.stripRestangular(responseData);
  21072. if (vmForm) {
  21073. decodeVMForm(vmForm);
  21074. }
  21075. }
  21076. });
  21077. }
  21078. });
  21079. }
  21080. } else {
  21081. //for form
  21082. //TODO
  21083. //测试数据 开始
  21084. var testJson = {
  21085. fields: [
  21086. {
  21087. fields: [
  21088. {
  21089. className: "col-xs-12",
  21090. noFormControl: true,
  21091. key: "formtitle",
  21092. templateOptions: {
  21093. readOnly: false,
  21094. placeholder: "新建事件单",
  21095. hidden: false,
  21096. label: "事件工单",
  21097. required: false,
  21098. },
  21099. type: "ui-title",
  21100. },
  21101. ],
  21102. },
  21103. {
  21104. fields: [
  21105. {
  21106. key: "selectUser",
  21107. type: "ui-deptinformation",
  21108. className: "col-xs-12",
  21109. templateOptions: {
  21110. label: "请求人信息",
  21111. modalTitle: "请求人列表",
  21112. fetchItems: function (filterData, APIService) {
  21113. return APIService.fetchDataList("requester", filterData);
  21114. },
  21115. Restangular: Restangular,
  21116. ApiService: api_user_data,
  21117. // onClick:function(val, options, field, event , model){
  21118. // console.log(options);
  21119. // }
  21120. },
  21121. },
  21122. ],
  21123. },
  21124. {
  21125. fields: [
  21126. {
  21127. key: "first",
  21128. type: "ui-workernumber",
  21129. className: "col-xs-12",
  21130. templateOptions: {
  21131. type: "input",
  21132. label: "事件单号",
  21133. pkey: "name",
  21134. },
  21135. },
  21136. ],
  21137. },
  21138. {
  21139. fields: [
  21140. {
  21141. type: "ui-header",
  21142. key: "title",
  21143. className: "col-xs-12",
  21144. templateOptions: {
  21145. label: "报修人",
  21146. pkey: "change",
  21147. },
  21148. },
  21149. {
  21150. type: "ui-input",
  21151. key: "title",
  21152. className: "col-xs-4",
  21153. templateOptions: {
  21154. label: "报修人",
  21155. pkey: "change",
  21156. },
  21157. },
  21158. {
  21159. type: "ui-input",
  21160. key: "title",
  21161. className: "col-xs-4",
  21162. templateOptions: {
  21163. label: "联系人",
  21164. pkey: "change",
  21165. },
  21166. },
  21167. {
  21168. type: "ui-input",
  21169. key: "title",
  21170. className: "col-xs-4",
  21171. templateOptions: {
  21172. label: "联系电话",
  21173. pkey: "change",
  21174. },
  21175. },
  21176. ],
  21177. },
  21178. {
  21179. fields: [
  21180. {
  21181. type: "ui-header",
  21182. key: "title1",
  21183. className: "col-xs-12",
  21184. templateOptions: {
  21185. label: "报修人",
  21186. pkey: "change",
  21187. },
  21188. },
  21189. {
  21190. type: "ui-input",
  21191. key: "title2",
  21192. className: "col-xs-4",
  21193. templateOptions: {
  21194. label: "报修人",
  21195. pkey: "change",
  21196. },
  21197. },
  21198. {
  21199. type: "ui-input",
  21200. key: "title3",
  21201. className: "col-xs-4",
  21202. templateOptions: {
  21203. label: "联系人",
  21204. pkey: "change",
  21205. },
  21206. },
  21207. {
  21208. type: "ui-input",
  21209. key: "title4",
  21210. className: "col-xs-4",
  21211. templateOptions: {
  21212. label: "联系电话",
  21213. pkey: "change",
  21214. },
  21215. },
  21216. ],
  21217. },
  21218. ],
  21219. model: [
  21220. {
  21221. username: "robin lau",
  21222. password: "123456",
  21223. chkme: false,
  21224. start_code: 0,
  21225. formtitle: "Hey!I am title value!",
  21226. name: {
  21227. first: "robin",
  21228. last: "lau",
  21229. },
  21230. multiselectItem: [],
  21231. //date:"2015-09-15 00:00:00"
  21232. },
  21233. ],
  21234. // }
  21235. };
  21236. setTimeout(function () {
  21237. decodeVMForm(testJson);
  21238. $scope.$apply();
  21239. }, 500);
  21240. //测试数据结束
  21241. }
  21242. }
  21243. //console.log("end decode");
  21244. },
  21245. ]);