customformCtrl.js 959 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799
  1. var appFormly = angular.module('formlyExample', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlyExample');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. // 图片上传
  10. app.factory('fileReader', ["$q", "$log", function ($q, $log) {
  11. var onLoad = function (reader, deferred, scope) {
  12. return function () {
  13. scope.$apply(function () {
  14. deferred.resolve(reader.result);
  15. });
  16. };
  17. };
  18. var onError = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.reject(reader.result);
  22. });
  23. };
  24. };
  25. var getReader = function (deferred, scope) {
  26. var reader = new FileReader(); //fileReader
  27. reader.onload = onLoad(reader, deferred, scope);
  28. reader.onerror = onError(reader, deferred, scope);
  29. return reader;
  30. };
  31. var readAsDataURL = function (file, scope) {
  32. var deferred = $q.defer();
  33. var reader = getReader(deferred, scope);
  34. reader.readAsDataURL(file);
  35. return deferred.promise;
  36. };
  37. return {
  38. readAsDataUrl: readAsDataURL
  39. };
  40. }])
  41. appFormly.filter('minutesToHours', function() { //分钟转小时
  42. return function(num) {
  43. var hour = parseInt(num / 60);
  44. var minute = num % 60;
  45. return hour + '小时' + minute + '分钟';
  46. }
  47. });
  48. appFormly.config(
  49. function config(formlyConfigProvider) {
  50. //格式转换方法 XXX-XXX转驼峰命名
  51. function camelize(string) {
  52. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  53. return chr ? chr.toUpperCase() : '';
  54. });
  55. // Ensure 1st char is always lowercase
  56. return string.replace(/^([A-Z])/, function (match, chr) {
  57. return chr ? chr.toLowerCase() : '';
  58. });
  59. }
  60. //获取ngModelAttr对象设置
  61. function getNgModelAttr(attrs, bindings) {
  62. var ngModelAttrs = {};
  63. angular.forEach(attrs, function (attr) {
  64. ngModelAttrs[camelize(attr)] = {
  65. attribute: attr
  66. };
  67. });
  68. angular.forEach(bindings, function (binding) {
  69. ngModelAttrs[camelize(binding)] = {
  70. bound: binding
  71. };
  72. });
  73. return ngModelAttrs;
  74. }
  75. formlyConfigProvider.setWrapper({
  76. name: 'bootstrapLabel',
  77. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  78. });
  79. //流程图
  80. formlyConfigProvider.setType({
  81. name: 'ui-process',
  82. templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
  83. defaultOptions: function (options) {
  84. return {
  85. templateOptions: {
  86. refresh: function () { },
  87. refreshDelay: 0
  88. }
  89. };
  90. },
  91. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  92. $scope.processdata = [];
  93. api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function (data) {
  94. console.log(data)
  95. $scope.processdata = data.data;
  96. })
  97. }]
  98. });
  99. //出库单详情
  100. formlyConfigProvider.setType({
  101. name: 'ui-getoutinform',
  102. extends: 'radio',
  103. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
  104. defaultOptions: function (options) {
  105. return {
  106. templateOptions: {
  107. refresh: function () { },
  108. refreshDelay: 0
  109. }
  110. };
  111. },
  112. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  113. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  114. if ($scope.model.type.id = 0) {
  115. $scope.model.type.name = "新资产入库";
  116. } else if ($scope.model.type.id = 1) {
  117. $scope.model.type.name = "新设备领用出库";
  118. } else if ($scope.model.type.id = 2) {
  119. $scope.model.type.name = "资产归还";
  120. } else if ($scope.model.type.id = 4) {
  121. $scope.model.type.name = "设备更换";
  122. }
  123. }
  124. }]
  125. });
  126. //多选框组件
  127. formlyConfigProvider.setType({
  128. name: 'ui-checkboxmore',
  129. extends: 'radio',
  130. templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
  131. defaultOptions: function (options) {
  132. return {
  133. templateOptions: {
  134. refresh: function () { },
  135. refreshDelay: 0
  136. }
  137. };
  138. },
  139. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  140. $scope.options.initialValue = $scope.model[$scope.options.key];
  141. }]
  142. });
  143. //入库单详情
  144. formlyConfigProvider.setType({
  145. name: 'ui-getininform',
  146. extends: 'radio',
  147. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
  148. defaultOptions: function (options) {
  149. return {
  150. templateOptions: {
  151. refresh: function () { },
  152. refreshDelay: 0
  153. }
  154. };
  155. },
  156. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  157. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  158. if ($scope.model.type.id = 0) {
  159. $scope.model.type.name = "新资产入库";
  160. } else if ($scope.model.type.id = 1) {
  161. $scope.model.type.name = "新设备领用出库";
  162. } else if ($scope.model.type.id = 2) {
  163. $scope.model.type.name = "资产归还";
  164. } else if ($scope.model.type.id = 4) {
  165. $scope.model.type.name = "设备更换";
  166. }
  167. }
  168. }]
  169. });
  170. //申请人详情
  171. formlyConfigProvider.setType({
  172. name: 'ui-requsterinfom',
  173. extends: 'radio',
  174. templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
  175. defaultOptions: function (options) {
  176. return {
  177. templateOptions: {
  178. refresh: function () { },
  179. refreshDelay: 0
  180. }
  181. };
  182. }
  183. });
  184. //设备耗材list组件
  185. formlyConfigProvider.setType({
  186. name: 'ui-uplodchange',
  187. templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
  188. defaultOptions: function (options) {
  189. return {
  190. templateOptions: {
  191. refresh: function () { },
  192. refreshDelay: 0,
  193. view: function (APIService, contentId) {
  194. return APIService.downloadAttachment(contentId);
  195. }
  196. }
  197. };
  198. },
  199. controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  200. // var data = { "haodata": [], "shedata": [] };
  201. var haodata = [];
  202. var shedata = [];
  203. if ($scope.model.consumables) {
  204. if (angular.isArray($scope.model.consumables)) {
  205. haodata = $scope.model.consumables;
  206. } else {
  207. haodata = JSON.parse($scope.model.consumables);
  208. }
  209. $scope.model.consumables = haodata;
  210. angular.forEach(haodata, function (item, index) {
  211. haodata[index].item = index + 1;
  212. })
  213. }
  214. if ($scope.model.assets) {
  215. if (angular.isArray($scope.model.assets)) {
  216. shedata = $scope.model.assets;
  217. } else {
  218. shedata = JSON.parse($scope.model.assets);
  219. }
  220. $scope.model.assets = shedata;
  221. angular.forEach(shedata, function (item, index) {
  222. shedata[index].item = index + 1;
  223. })
  224. }
  225. $scope.tableParamshao = new ngTableParams({
  226. page: 1,
  227. count: 5
  228. }, {
  229. total: haodata.length,
  230. getData: function ($defer, params) {
  231. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  232. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  233. }
  234. });
  235. $scope.tableParamsshe = new ngTableParams({
  236. page: 1,
  237. count: 5
  238. }, {
  239. total: shedata.length,
  240. getData: function ($defer, params) {
  241. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  242. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  243. }
  244. });
  245. $scope.editId = -1;
  246. $scope.setEditId = function (pid) {
  247. $scope.editId = pid;
  248. };
  249. if (angular.isUndefined($scope.form.dropState)) {
  250. $scope.form.dropState = false;
  251. }
  252. var to = $scope.options.templateOptions;
  253. var bindId = $scope.model.processInstanceId;
  254. //获取附件列表
  255. $scope.listAttachmen = function () {
  256. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  257. var myData = Restangular.stripRestangular(result);
  258. // $scope.listAttachmens = myData;
  259. $scope.attachments = myData.data;
  260. });
  261. };
  262. $scope.listAttachmen();
  263. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  264. // $scope.listAttachmen();
  265. // } else if (to.bindType && $scope.model[to.bindType].id) {
  266. // $scope.listAttachmen();
  267. // }
  268. //附件下载
  269. $scope.download = function (token, filename) {
  270. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  271. // window.open(downUrl);
  272. var a = document.createElement('a');
  273. a.href = downUrl;
  274. a.target = '_blank';
  275. a.download = filename;
  276. document.body.appendChild(a);
  277. a.click();
  278. };
  279. //附件预览
  280. $scope.view = function (id, previewUrl) {
  281. if (previewUrl) {
  282. window.open(previewUrl);
  283. }
  284. };
  285. }]
  286. });
  287. //多选框组件
  288. formlyConfigProvider.setType({
  289. name: 'ui-nodataimage',
  290. templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
  291. defaultOptions: function (options) {
  292. return {
  293. templateOptions: {
  294. refresh: function () { },
  295. refreshDelay: 0
  296. }
  297. };
  298. }
  299. });
  300. //ui-grid list
  301. formlyConfigProvider.setType({
  302. name: "ui-gridtwolist",
  303. // extends: 'input',
  304. templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
  305. defaultOptions: function (options, $scope) {
  306. return {
  307. templateOptions: {}
  308. };
  309. },
  310. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  311. //gridone
  312. $scope.langs = i18nService.getAllLangs();
  313. $scope.lang = 'zh-cn';
  314. i18nService.setCurrentLang($scope.lang);
  315. $scope.gridOptions = {};
  316. $scope.gridOptions.data = 'myDatagrid';
  317. $scope.gridOptions.enableColumnResizing = true;
  318. $scope.gridOptions.enableFiltering = true;
  319. $scope.gridOptions.enableGridMenu = false;
  320. $scope.gridOptions.enableRowSelection = true;
  321. $scope.gridOptions.showGridFooter = true;
  322. $scope.gridOptions.showColumnFooter = false;
  323. $scope.gridOptions.fastWatch = true;
  324. $scope.gridOptions.useExternalFiltering = false;
  325. $scope.gridOptions.useExternalPagination = true;
  326. $scope.gridOptions.paginationPageSizes = [10];
  327. $scope.gridOptions.paginationPageSize = 10;
  328. $scope.gridOptions.multiSelect = false;
  329. $scope.myDatagrid = [];
  330. $scope.myDatagridall = [];
  331. $scope.selected = {
  332. item: {}
  333. };
  334. $scope.memoryfilterDatagrid = {
  335. idx: 0,
  336. sum: 10
  337. }
  338. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  339. filterData = {
  340. idx: 0,
  341. sum: 10
  342. };
  343. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  344. }
  345. $scope.gridOptions.rowIdentity = function (row) {
  346. return row.id;
  347. };
  348. $scope.gridOptions.getRowIdentity = function (row) {
  349. return row.id;
  350. };
  351. // $scope.gridOptions.columnDefs = items.columnDefs();
  352. $scope.interceptMydata = function (mydate, idx, sum) {
  353. return mydate.slice(idx * sum, (idx + 1) * sum)
  354. }
  355. $scope.gridOptions.onRegisterApi = function (gridApi) {
  356. $scope.gridApi = gridApi;
  357. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  358. $scope.memoryfilterDatagrid.idx = newPage - 1;
  359. $scope.memoryfilterDatagrid.sum = pageSize;
  360. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  361. $scope.loadData({
  362. "idx": newPage - 1,
  363. "sum": pageSize
  364. });
  365. });
  366. gridApi.core.on.filterChanged($scope, function () { });
  367. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  368. $scope.selected.item = data.entity;
  369. //console.log(data);
  370. });
  371. };
  372. $scope.loadData = function (mydate, idx, sum) {
  373. angular.forEach($scope.myDatagrid, function (item, index) {
  374. $scope.myDatagrid[index].item = index;
  375. })
  376. $scope.gridOptions.totalItems = mydate.length;
  377. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  378. }
  379. if ($scope.model.assets) {
  380. $scope.myDatagridall = $scope.model.assets;
  381. $scope.loadData($scope.model.assets, 0, 10)
  382. }
  383. $scope.saveData = function (itemin) {
  384. event.preventDefault();
  385. var modalInstance = $modal.open({
  386. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  387. controller: function ($scope, $modalInstance, SweetAlert) {
  388. // $scope.consumptive = {};
  389. $scope.title = "填写领用设备信息";
  390. // if (items.name) {
  391. // $scope.consumptive.name = items.name.name;
  392. // }
  393. $scope.placechange = angular.copy(itemin);
  394. $scope.ok = function (item) {
  395. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  396. $modalInstance.close(item);
  397. } else {
  398. SweetAlert.swal({
  399. title: "数据填写不完整!",
  400. text: "请检查数据然后提交!",
  401. type: "error"
  402. });
  403. }
  404. };
  405. $scope.cancel = function () {
  406. $modalInstance.dismiss('cancel');
  407. };
  408. },
  409. resolve: {
  410. SweetAlert: function () {
  411. return SweetAlert;
  412. }
  413. }
  414. });
  415. modalInstance.result.then(function (selectedItem) {
  416. angular.forEach($scope.myDatagrid, function (item, index) {
  417. // $scope.myDatagrid[index].props.hw_state = "在线";
  418. if (item.id == selectedItem.id) {
  419. // $scope.myDatagrid[index] = selectedItem;
  420. angular.extend($scope.myDatagrid[index], selectedItem)
  421. }
  422. })
  423. // $scope.myData3.push(selectedItem);
  424. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  425. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  426. }
  427. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  428. })
  429. }
  430. //gridtwo
  431. $scope.langs = i18nService.getAllLangs();
  432. $scope.lang = 'zh-cn';
  433. i18nService.setCurrentLang($scope.lang);
  434. $scope.gridOptions2 = {};
  435. $scope.gridOptions2.data = 'myDatagridold';
  436. $scope.gridOptions2.enableColumnResizing = true;
  437. $scope.gridOptions2.enableFiltering = true;
  438. $scope.gridOptions2.enableGridMenu = false;
  439. $scope.gridOptions2.enableRowSelection = true;
  440. $scope.gridOptions2.showGridFooter = true;
  441. $scope.gridOptions2.showColumnFooter = false;
  442. $scope.gridOptions2.fastWatch = true;
  443. $scope.gridOptions2.useExternalFiltering = false;
  444. $scope.gridOptions.useExternalPagination = true;
  445. $scope.gridOptions2.paginationPageSizes = [10];
  446. $scope.gridOptions2.paginationPageSize = 10;
  447. $scope.gridOptions2.multiSelect = false;
  448. $scope.myDatagridold = [];
  449. $scope.myDatagridoldall = [];
  450. $scope.selected = {
  451. item: {}
  452. };
  453. $scope.memoryfilterDatagridold = {
  454. idx: 0,
  455. sum: 10
  456. }
  457. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  458. filterData = {
  459. idx: 0,
  460. sum: 10
  461. };
  462. $scope.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
  463. }
  464. $scope.gridOptions2.rowIdentity = function (row) {
  465. return row.id;
  466. };
  467. $scope.gridOptions2.getRowIdentity = function (row) {
  468. return row.id;
  469. };
  470. // $scope.gridOptions.columnDefs = items.columnDefs();
  471. $scope.interceptMydata = function (mydate, idx, sum) {
  472. return mydate.slice(idx * sum, (idx + 1) * sum)
  473. }
  474. if ($scope.model.oldAssets) {
  475. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  476. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
  477. }
  478. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  479. $scope.gridApi = gridApi;
  480. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  481. $scope.memoryfilterDatagridold.idx = newPage - 1;
  482. $scope.memoryfilterDatagridold.sum = pageSize;
  483. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
  484. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  485. });
  486. gridApi.core.on.filterChanged($scope, function () { });
  487. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  488. $scope.selected.item = data.entity;
  489. //console.log(data);
  490. });
  491. };
  492. // $scope.loadData = function(mydate, idx, sum) {
  493. // angular.forEach($scope.myDatagridold, function(item, index) {
  494. // $scope.myDatagridold[index].item = index;
  495. // })
  496. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  497. // }
  498. // if ($scope.model.assets) {
  499. // $scope.myDatagridallold = $scope.model.assets;
  500. // $scope.loadData($scope.model.assets, 0, 10)
  501. // }
  502. // $scope.addoldassets = function(itemin) {
  503. // event.preventDefault();
  504. // var modalInstance = $modal.open({
  505. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  506. // controller: function($scope, $modalInstance, SweetAlert) {
  507. // // $scope.consumptive = {};
  508. // $scope.title = "填写领用设备信息";
  509. // // if (items.name) {
  510. // // $scope.consumptive.name = items.name.name;
  511. // // }
  512. // $scope.placechange = itemin;
  513. // $scope.ok = function(item) {
  514. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  515. // $modalInstance.close(item);
  516. // } else {
  517. // SweetAlert.swal({
  518. // title: "数据填写不完整!",
  519. // text: "请检查数据然后提交!",
  520. // type: "error"
  521. // });
  522. // }
  523. // };
  524. // $scope.cancel = function() {
  525. // $modalInstance.dismiss('cancel');
  526. // };
  527. // },
  528. // resolve: {
  529. // SweetAlert: function() {
  530. // return SweetAlert;
  531. // }
  532. // }
  533. // });
  534. $scope.interceptMydata = function (mydate, idx, sum) {
  535. return mydate.slice(idx * sum, (idx + 1) * sum)
  536. }
  537. $scope.addshebei = function () {
  538. event.preventDefault();
  539. var modalInstance = $modal.open({
  540. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  541. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
  542. $scope.langs = i18nService.getAllLangs();
  543. $scope.lang = 'zh-cn';
  544. i18nService.setCurrentLang($scope.lang);
  545. $scope.gridOptions = {};
  546. $scope.gridOptions.data = 'myDatatwo';
  547. $scope.gridOptions.enableColumnResizing = true;
  548. $scope.gridOptions.enableFiltering = false;
  549. $scope.gridOptions.enableGridMenu = false;
  550. $scope.gridOptions.showGridFooter = true;
  551. $scope.gridOptions.showColumnFooter = false;
  552. $scope.gridOptions.fastWatch = true;
  553. $scope.gridOptions.useExternalFiltering = true;
  554. $scope.gridOptions.useExternalPagination = true;
  555. $scope.gridOptions.paginationPageSizes = [10];
  556. $scope.gridOptions.paginationPageSize = 10;
  557. $scope.gridOptions.multiSelect = true;
  558. $scope.gridOptions.rowIdentity = function (row) {
  559. return row.id;
  560. };
  561. $scope.gridOptions.getRowIdentity = function (row) {
  562. return row.id;
  563. };
  564. $scope.gridOptions.columnDefs = [{
  565. name: 'item',
  566. displayName: '序号',
  567. width: 80,
  568. enableFiltering: false
  569. },
  570. {
  571. name: 'uuid',
  572. displayName: '内部编号',
  573. width: 150
  574. },
  575. {
  576. name: 'props.hw_mingcheng',
  577. displayName: '资产名称',
  578. width: 100
  579. },
  580. {
  581. name: 'props.hw_cifilterClassic',
  582. displayName: '资产类型',
  583. width: 120,
  584. enableFiltering: false
  585. },
  586. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  587. {
  588. name: 'props.hw_state',
  589. displayName: '资产状态',
  590. width: 150,
  591. enableFiltering: false
  592. },
  593. {
  594. name: 'props.hwnw_area',
  595. displayName: '资产地点',
  596. width: 130,
  597. enableFiltering: false
  598. },
  599. {
  600. name: 'createtime',
  601. displayName: '申请时间',
  602. enableFiltering: false
  603. }
  604. ];
  605. // $scope.selectButtonClick
  606. var defaultFilterData = {
  607. // "assignee":2,
  608. // "applicationForm": { "hw_state": "在线" },
  609. "hw_state": "在线",
  610. "idx": 0,
  611. "sum": 10
  612. };
  613. $scope.memoryfilterData = {
  614. // "assignee":2,
  615. // "applicationForm": { "hw_state": "在线" },
  616. "hw_state": "在线",
  617. "idx": 0,
  618. "sum": 10
  619. }
  620. $scope.refreshData = function (style, filterData) {
  621. if (angular.isUndefined(filterData)) {
  622. filterData = defaultFilterData;
  623. }
  624. $scope.myDatatwo = [];
  625. // $scope.gridOptions['sum']=filterData.sum;
  626. api_cmdb.query(filterData).then(function (data) {
  627. // $scope.callsPending--;
  628. var myDatatwo = Restangular.stripRestangular(data);
  629. $scope.gridOptions['totalItems'] = data.total;
  630. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  631. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  632. }
  633. $scope.myDatatwo = myDatatwo.data.node;
  634. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  635. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  636. }
  637. }, function () { });
  638. };
  639. $scope.refreshData('expand-right', defaultFilterData);
  640. $scope.gridOptions.onRegisterApi = function (gridApi) {
  641. $scope.gridApi = gridApi;
  642. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  643. var filtersData = $scope.memoryfilterData;
  644. filtersData.idx = newPage - 1;
  645. filtersData.sum = pageSize;
  646. // $scope.loadData(filtersData);
  647. $scope.refreshData('expand-right', filtersData);
  648. //console.log(pageSize);
  649. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  650. });
  651. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  652. // $scope.selected.items.push(data.entity);
  653. //console.log(data);
  654. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  655. if (scope.isSelected) {
  656. scope.grid.appScope.selected.items.push(scope.entity)
  657. } else {
  658. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  659. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  660. scope.grid.appScope.selected.items.splice(i, 1);
  661. break;
  662. }
  663. }
  664. }
  665. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  666. });
  667. // });
  668. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  669. // $scope.selected.items = data.entity;
  670. //console.log(data);
  671. var selectitem = [];
  672. selectitem = angular.copy($scope.selected.items);
  673. for (var j = 0; j < rows.length; j++) {
  674. if (rows[j].isSelected == true) {
  675. selectitem.push(rows[j].entity);
  676. } else {
  677. delete selectitem[j];
  678. // rows.splice(j, 1);
  679. }
  680. }
  681. $scope.selected.items = [];
  682. for (var i = 0; i < selectitem.length; i++) {
  683. if (selectitem[i]) {
  684. $scope.selected.items.push(selectitem[i]);
  685. }
  686. }
  687. });
  688. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  689. // // if (row.entity.age > 45) {
  690. // row.grid.api.selection.selectRow(row.entity); // 选中行
  691. // // }
  692. // };
  693. gridApi.core.on.filterChanged($scope, function () {
  694. var grid = this.grid;
  695. var filtersData = {
  696. idx: 0,
  697. sum: 10,
  698. "user": {
  699. "roledata": {
  700. "rolecode": "roleset"
  701. },
  702. "selectType": "1"
  703. }
  704. };
  705. angular.forEach(grid.columns, function (item) {
  706. if (item.enableFiltering) {
  707. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  708. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  709. if (angular.isUndefined(filtersData['user'])) {
  710. filtersData['user'] = {};
  711. }
  712. filtersData['user'][item.field] = item.filters[0].term;
  713. }
  714. }
  715. });
  716. $scope.memoryfilterData = filtersData;
  717. // $scope.loadData(filtersData);
  718. });
  719. };
  720. $scope.onDblClick = function (data, event) {
  721. // $scope.selected.items = data.entity;
  722. $scope.selectButtonClick(data, event);
  723. };
  724. $scope.title = title;
  725. //树形图
  726. var apple_selected, tree, treedata_avm, treedata_geography;
  727. $scope.my_tree_handler = function (branch) {
  728. //var _ref;
  729. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  730. api_cmdb.query({
  731. 'sign': classify
  732. }).then(function (data) {
  733. var myDatalingbei = Restangular.stripRestangular(data);
  734. // console.log(myData.data.node);
  735. if (myDatalingbei.data && myDatalingbei.status == 200) {
  736. var ret = myDatalingbei.data;
  737. redrawSvg(myDatalingbei);
  738. }
  739. });
  740. };
  741. $scope.my_data = [];
  742. function convertListToTree(data, treeMap) {
  743. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  744. var root = null; //Initially set our loop to null
  745. var parentNode = null;
  746. //loop over data
  747. for (var i = 0; i < data.length; i++) {
  748. var datum = data[i];
  749. //each node will have children, so let's give it a "children" poperty
  750. datum.children = [];
  751. //add an entry for this node to the map so that any future children can
  752. //lookup the parent
  753. idToNodeMap[datum.id] = datum;
  754. //Does this node have a parent?
  755. if (typeof datum.parent === "undefined" || datum.parent == null) {
  756. //Doesn't look like it, so this node is the root of the tree
  757. root = datum;
  758. treeMap[datum.id] = root;
  759. } else {
  760. //This node has a parent, so let's look it up using the id
  761. parentNode = idToNodeMap[datum.parent.id];
  762. //We don't need this property, so let's delete it.
  763. delete datum.parent;
  764. //Let's add the current node as a child of the parent node.
  765. parentNode.children.push(datum);
  766. }
  767. }
  768. return root;
  769. }
  770. function convertParentToChildList(data) {
  771. var treeMap = {};
  772. var list = [];
  773. convertListToTree(data, treeMap);
  774. angular.forEach(treeMap, function (item) {
  775. list.push(item);
  776. });
  777. return list;
  778. }
  779. $scope.my_tree = tree = {};
  780. $scope.try_async_load = function () {
  781. $scope.my_data = [];
  782. $scope.select_treedata = [];
  783. $scope.doing_async = true;
  784. api_configure_data.fetchDataList('ciclassify', {
  785. 'idx': 0,
  786. 'sum': 100
  787. }).then(function (result) {
  788. //console.log(result['list']);
  789. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  790. $scope.doing_async = false;
  791. // tree.expand_all();
  792. //console.log(treelist);
  793. });
  794. };
  795. $scope.select_treedata = [];
  796. $scope.propTypeOptions = [];
  797. $scope.try_async_load();
  798. $scope.onFilterremove = function (item) {
  799. console.log(item)
  800. }
  801. $scope.searchdata = {};
  802. $scope.clear = function () {
  803. $scope.searchdata = {};
  804. $scope.cifilter_classic = {};
  805. $scope.try_async_load();
  806. var fildata = {
  807. idx: 0,
  808. sum: 10,
  809. 'hw_state': '在线'
  810. }
  811. $scope.memoryfilterData = fildata;
  812. $scope.refreshData('expand-right', fildata);
  813. }
  814. $scope.chiceIncident = function (item) {
  815. var fildata = $scope.memoryfilterData;
  816. // fildata.applicationForm = {};
  817. // if (item.alltitle && item.alldata) {
  818. // fildata.applicationForm[item.alltitle.key] = item.alldata
  819. // }
  820. if (item && item.id) {
  821. var classify = item.prefix.toLowerCase() + item.sign;
  822. fildata.sign = classify
  823. }
  824. $scope.gridOptions.paginationCurrentPage = 1;
  825. var transitiondata = angular.copy(item);
  826. $scope.refreshData('expand-right', fildata);
  827. }
  828. $scope.applicadata = [];
  829. $scope.onFilterCallback = function (item) {
  830. var tempclassify = item.prefix.toLowerCase() + item.sign;
  831. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  832. var myData = Restangular.stripRestangular(data);
  833. $scope.applicadata = myData[0].form.fields;
  834. });
  835. // }
  836. }
  837. // $scope.loadData({
  838. // idx: 0,
  839. // sum: 10,
  840. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  841. // });
  842. $scope.selected = {
  843. items: []
  844. };
  845. $scope.ok = function () {
  846. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  847. // onDataCallback($scope.selected.item, parentScope);
  848. // }
  849. $modalInstance.close($scope.selected.items);
  850. };
  851. $scope.cancel = function () {
  852. $modalInstance.dismiss('cancel');
  853. };
  854. },
  855. size: 'lg',
  856. resolve: {
  857. items: function () {
  858. return {
  859. fetchItems: function (filterData, APIService) {
  860. filterData = filterData || {};
  861. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  862. filterData = {
  863. idx: 0,
  864. sum: 10,
  865. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  866. };
  867. }
  868. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  869. }
  870. };
  871. },
  872. title: function () {
  873. return $scope.options.templateOptions.label;
  874. },
  875. Restangular: function () {
  876. return $scope.options.templateOptions.Restangular;
  877. },
  878. APIService: function () {
  879. return $scope.options.templateOptions.ApiService;
  880. },
  881. onDataCallback: function () {
  882. return $scope.options.templateOptions.callback;
  883. },
  884. parentScope: function () {
  885. return $scope.options.templateOptions.that;
  886. }
  887. }
  888. });
  889. modalInstance.result.then(function (selectedItem) {
  890. $scope.myDatagridoldall = selectedItem;
  891. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  892. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  893. }
  894. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  895. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  896. // $scope.model.oldAssets = $scope.myDatagridoldall;
  897. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  898. $scope.options.initialValue = $scope.model.oldAssets;
  899. });
  900. // }
  901. }
  902. $scope.changestate = function (itemin) {
  903. event.preventDefault();
  904. var modalInstance = $modal.open({
  905. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
  906. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  907. $scope.title = '旧设备状态修改';
  908. $scope.stateshe = [{
  909. "id": 2,
  910. "name": "在库"
  911. }, {
  912. "id": 4,
  913. "name": "报修"
  914. }, {
  915. "id": 3,
  916. "name": "报废"
  917. }];
  918. $scope.hw_state = {};
  919. $scope.ok = function (item) {
  920. $modalInstance.close(item.id);
  921. };
  922. $scope.cancel = function () {
  923. $modalInstance.dismiss('cancel');
  924. };
  925. },
  926. size: 'sm',
  927. resolve: {
  928. scope: function () {
  929. return $scope;
  930. }
  931. }
  932. });
  933. modalInstance.result.then(function (selectedItem) {
  934. if (selectedItem) {
  935. angular.forEach($scope.myDatagridallold, function (item, index) {
  936. if (item.id == itemin.id) {
  937. $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
  938. }
  939. })
  940. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  941. $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  942. }
  943. $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
  944. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
  945. // $scope.model.oldAssets = $scope.myDatagridallold;
  946. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
  947. $scope.options.initialValue = $scope.model.oldAssets;
  948. }
  949. })
  950. }
  951. $scope.savedata = function (data) {
  952. event.preventDefault();
  953. var modalInstance = $modal.open({
  954. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
  955. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  956. $scope.title = '设备编辑';
  957. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  958. $scope.ok = function (item) {
  959. $modalInstance.close(item);
  960. };
  961. $scope.cancel = function () {
  962. $modalInstance.dismiss('cancel');
  963. };
  964. },
  965. size: 'sm',
  966. resolve: {
  967. scope: function () {
  968. return $scope;
  969. }
  970. }
  971. });
  972. modalInstance.result.then(function (selectedItem) {
  973. if (selectedItem) {
  974. angular.forEach($scope.myDatagridoldall, function (item, index) {
  975. if (item.id == data.id) {
  976. $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
  977. }
  978. })
  979. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  980. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  981. }
  982. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  983. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  984. // $scope.model.oldAssets = $scope.myDatagridoldall;
  985. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  986. $scope.options.initialValue = $scope.model.oldAssets;
  987. }
  988. })
  989. }
  990. $scope.removeold = function (data) {
  991. event.preventDefault();
  992. var modalInstance = $modal.open({
  993. templateUrl: 'assets/views/delete.html',
  994. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  995. $scope.title = '设备删除';
  996. $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  997. $scope.ok = function () {
  998. $modalInstance.close(data);
  999. };
  1000. $scope.cancel = function () {
  1001. $modalInstance.dismiss('cancel');
  1002. };
  1003. },
  1004. size: 'sm',
  1005. resolve: {
  1006. scope: function () {
  1007. return $scope;
  1008. }
  1009. }
  1010. });
  1011. modalInstance.result.then(function (selectedItem) {
  1012. if (selectedItem) {
  1013. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1014. if (item.id == selectedItem.id) {
  1015. $scope.myDatagridoldall.splice(index, 1);
  1016. }
  1017. })
  1018. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1019. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  1020. }
  1021. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  1022. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  1023. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1024. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  1025. $scope.options.initialValue = $scope.model.oldAssets;
  1026. }
  1027. })
  1028. }
  1029. }]
  1030. });
  1031. //ui-grid list
  1032. formlyConfigProvider.setType({
  1033. name: "ui-gridlist",
  1034. extends: 'input',
  1035. templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
  1036. defaultOptions: function (options, $scope) {
  1037. return {
  1038. templateOptions: {}
  1039. };
  1040. },
  1041. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  1042. //gridone
  1043. $scope.langs = i18nService.getAllLangs();
  1044. $scope.lang = 'zh-cn';
  1045. i18nService.setCurrentLang($scope.lang);
  1046. $scope.gridOptions = {};
  1047. $scope.gridOptions.data = 'myDatagrid';
  1048. $scope.gridOptions.enableColumnResizing = true;
  1049. $scope.gridOptions.enableFiltering = true;
  1050. $scope.gridOptions.enableGridMenu = false;
  1051. $scope.gridOptions.enableRowSelection = true;
  1052. $scope.gridOptions.showGridFooter = true;
  1053. $scope.gridOptions.showColumnFooter = false;
  1054. $scope.gridOptions.fastWatch = true;
  1055. $scope.gridOptions.useExternalFiltering = false;
  1056. // $scope.gridOptions.useExternalPagination = true;
  1057. $scope.gridOptions.paginationPageSizes = [10];
  1058. $scope.gridOptions.paginationPageSize = 10;
  1059. $scope.gridOptions.multiSelect = false;
  1060. $scope.myDatagrid = [];
  1061. $scope.myDatagridall = [];
  1062. $scope.selected = {
  1063. item: {}
  1064. };
  1065. $scope.memoryfilterDatagrid = {
  1066. idx: 0,
  1067. sum: 10
  1068. }
  1069. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1070. filterData = {
  1071. idx: 0,
  1072. sum: 10
  1073. };
  1074. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  1075. }
  1076. $scope.gridOptions.rowIdentity = function (row) {
  1077. return row.id;
  1078. };
  1079. $scope.gridOptions.getRowIdentity = function (row) {
  1080. return row.id;
  1081. };
  1082. // $scope.gridOptions.columnDefs = items.columnDefs();
  1083. $scope.interceptMydata = function (mydate, idx, sum) {
  1084. return mydate.slice(idx * sum, (idx + 1) * sum)
  1085. }
  1086. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1087. $scope.gridApi = gridApi;
  1088. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1089. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1090. $scope.memoryfilterDatagrid.sum = pageSize;
  1091. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  1092. $scope.loadData({
  1093. "idx": newPage - 1,
  1094. "sum": pageSize
  1095. });
  1096. });
  1097. gridApi.core.on.filterChanged($scope, function () { });
  1098. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1099. $scope.selected.item = data.entity;
  1100. //console.log(data);
  1101. });
  1102. };
  1103. $scope.loadData = function (mydate, idx, sum) {
  1104. angular.forEach($scope.myDatagrid, function (item, index) {
  1105. $scope.myDatagrid[index].item = index;
  1106. })
  1107. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  1108. }
  1109. if ($scope.model.assets) {
  1110. $scope.myDatagridall = $scope.model.assets;
  1111. $scope.loadData($scope.model.assets, 0, 10)
  1112. }
  1113. $scope.saveData = function (itemin) {
  1114. event.preventDefault();
  1115. var modalInstance = $modal.open({
  1116. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  1117. controller: function ($scope, $modalInstance, SweetAlert) {
  1118. // $scope.consumptive = {};
  1119. $scope.title = "填写领用设备信息";
  1120. // if (items.name) {
  1121. // $scope.consumptive.name = items.name.name;
  1122. // }
  1123. $scope.placechange = angular.copy(itemin);
  1124. $scope.ok = function (item) {
  1125. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  1126. $modalInstance.close(item);
  1127. } else {
  1128. SweetAlert.swal({
  1129. title: "数据填写不完整!",
  1130. text: "请检查数据然后提交!",
  1131. type: "error"
  1132. });
  1133. }
  1134. };
  1135. $scope.cancel = function () {
  1136. $modalInstance.dismiss('cancel');
  1137. };
  1138. },
  1139. resolve: {
  1140. SweetAlert: function () {
  1141. return SweetAlert;
  1142. }
  1143. }
  1144. });
  1145. modalInstance.result.then(function (selectedItem) {
  1146. angular.forEach($scope.myDatagrid, function (item, index) {
  1147. if (item.id == selectedItem.id) {
  1148. angular.extend($scope.myDatagrid[index], selectedItem)
  1149. }
  1150. })
  1151. // $scope.myData3.push(selectedItem);
  1152. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1153. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  1154. }
  1155. // $scope.model.assets = $scope.myDatagridall;
  1156. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  1157. })
  1158. }
  1159. }]
  1160. });
  1161. //设备耗材list组件
  1162. formlyConfigProvider.setType({
  1163. name: 'ui-shehaolist',
  1164. // extends: 'radio',
  1165. templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
  1166. defaultOptions: function (options) {
  1167. return {
  1168. templateOptions: {
  1169. refresh: function () { },
  1170. refreshDelay: 0
  1171. }
  1172. };
  1173. },
  1174. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1175. // var data = { "haodata": [], "shedata": [] };
  1176. var haodata = [];
  1177. var shedata = [];
  1178. if ($scope.model.consumables) {
  1179. if (angular.isArray($scope.model.consumables)) {
  1180. haodata = $scope.model.consumables;
  1181. } else {
  1182. haodata = JSON.parse($scope.model.consumables);
  1183. }
  1184. $scope.model.consumables = haodata;
  1185. angular.forEach(haodata, function (item, index) {
  1186. haodata[index].item = index + 1;
  1187. })
  1188. }
  1189. if ($scope.model.assets) {
  1190. if (angular.isArray($scope.model.assets)) {
  1191. shedata = $scope.model.assets;
  1192. } else {
  1193. shedata = JSON.parse($scope.model.assets);
  1194. }
  1195. $scope.model.assets = shedata;
  1196. angular.forEach(shedata, function (item, index) {
  1197. shedata[index].item = index + 1;
  1198. })
  1199. }
  1200. $scope.tableParamshao = new ngTableParams({
  1201. page: 1,
  1202. count: 5
  1203. }, {
  1204. total: haodata.length,
  1205. getData: function ($defer, params) {
  1206. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  1207. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1208. }
  1209. });
  1210. $scope.tableParamsshe = new ngTableParams({
  1211. page: 1,
  1212. count: 5
  1213. }, {
  1214. total: shedata.length,
  1215. getData: function ($defer, params) {
  1216. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  1217. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1218. }
  1219. });
  1220. $scope.editId = -1;
  1221. $scope.setEditId = function (pid) {
  1222. $scope.editId = pid;
  1223. };
  1224. if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
  1225. $scope.isAgree = "同意";
  1226. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
  1227. $scope.isAgree = "同意";
  1228. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
  1229. $scope.isAgree = "返回修改";
  1230. }
  1231. }]
  1232. });
  1233. //关联资产出库
  1234. formlyConfigProvider.setType({
  1235. name: "ui-meansmodelselect",
  1236. extends: 'input',
  1237. templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
  1238. defaultOptions: function (options) {
  1239. return {
  1240. templateOptions: {}
  1241. };
  1242. },
  1243. controller: ['$scope', '$modal', function ($scope, $modal) {
  1244. $scope.openModal = function (size, options, modal) {
  1245. var modalInstance = $modal.open({
  1246. templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
  1247. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService, api_wechatfile) {
  1248. $scope.langs = i18nService.getAllLangs();
  1249. $scope.lang = 'zh-cn';
  1250. i18nService.setCurrentLang($scope.lang);
  1251. $scope.gridOptions = {};
  1252. $scope.gridOptions.data = 'myData';
  1253. $scope.gridOptions.enableColumnResizing = true;
  1254. $scope.gridOptions.enableFiltering = false;
  1255. $scope.gridOptions.enableGridMenu = false;
  1256. $scope.gridOptions.showGridFooter = true;
  1257. $scope.gridOptions.showColumnFooter = false;
  1258. $scope.gridOptions.fastWatch = true;
  1259. $scope.gridOptions.useExternalFiltering = true;
  1260. $scope.gridOptions.useExternalPagination = true;
  1261. $scope.gridOptions.paginationPageSizes = [10];
  1262. $scope.gridOptions.paginationPageSize = 10;
  1263. $scope.gridOptions.multiSelect = false;
  1264. $scope.gridOptions.rowIdentity = function (row) {
  1265. return row.id;
  1266. };
  1267. $scope.gridOptions.getRowIdentity = function (row) {
  1268. return row.id;
  1269. };
  1270. // $scope.states = [{
  1271. // id: 0,
  1272. // name: '待批准'
  1273. // },
  1274. // {
  1275. // id: 1,
  1276. // name: '已驳回'
  1277. // },
  1278. // {
  1279. // id: 2,
  1280. // name: '待出库'
  1281. // },
  1282. // {
  1283. // id: 3,
  1284. // name: '信息更新'
  1285. // },
  1286. // {
  1287. // id: 4,
  1288. // name: '信息确认'
  1289. // },
  1290. // {
  1291. // id: 5,
  1292. // name: '已关闭'
  1293. // }
  1294. // ];
  1295. $scope.getStatesDictionary = function () {
  1296. var data = {
  1297. "key": "applicationForm_status",
  1298. "type": "list"
  1299. }
  1300. api_wechatfile.getDictionary(data).then(function (res) {
  1301. $scope.states = res
  1302. })
  1303. };
  1304. $scope.getStatesDictionary();
  1305. $scope.type = [{
  1306. id: 1,
  1307. name: '资产入库'
  1308. },
  1309. {
  1310. id: 2,
  1311. name: '资产归还'
  1312. },
  1313. {
  1314. id: 3,
  1315. name: '资产领用'
  1316. },
  1317. {
  1318. id: 4,
  1319. name: '资产更换'
  1320. }
  1321. ];
  1322. $scope.typedata = function (row) {
  1323. if (row.type == 0) {
  1324. return "资产入库";
  1325. } else if (row.type == 2) {
  1326. return "资产归还";
  1327. } else if (row.type == 1) {
  1328. return "资产领用";
  1329. } else if (row.type == 4) {
  1330. return "资产更换";
  1331. }
  1332. };
  1333. $scope.statedata = function (row) {
  1334. if (row.status == 0) {
  1335. return "待批准";
  1336. } else if (row.status == 1) {
  1337. return "已驳回";
  1338. } else if (row.status == 2) {
  1339. return "待出库";
  1340. } else if (row.status == 3) {
  1341. return "信息更新";
  1342. } else if (row.status == 4) {
  1343. return "信息确认";
  1344. } else if (row.status == 5) {
  1345. return "已关闭";
  1346. }
  1347. };
  1348. $scope.transferTime = function (time) {
  1349. return moment(time).format('YYYY-MM-DD HH:mm');
  1350. }
  1351. $scope.application = [{
  1352. value: "serialNumbe",
  1353. name: '申请单编号'
  1354. },
  1355. // { value: "proposer", name: '申请人' },
  1356. {
  1357. value: "purpose",
  1358. name: '领用用途'
  1359. },
  1360. // { value: "cmdbsign", name: '设备编号' }
  1361. ];
  1362. $scope.parameters = null;
  1363. $scope.open = function ($event) {
  1364. $event.preventDefault();
  1365. $event.stopPropagation();
  1366. $scope.opened = !$scope.opened;
  1367. };
  1368. $scope.endOpen = function ($event) {
  1369. $event.preventDefault();
  1370. $event.stopPropagation();
  1371. $scope.startOpened = false;
  1372. $scope.endOpened = !$scope.endOpened;
  1373. };
  1374. $scope.startOpen = function ($event) {
  1375. $event.preventDefault();
  1376. $event.stopPropagation();
  1377. $scope.endOpened = false;
  1378. $scope.startOpened = !$scope.startOpened;
  1379. };
  1380. $scope.othcode = {};
  1381. $scope.searchkeys = {};
  1382. $scope.parameters = {};
  1383. $scope.memoryfilterData = {
  1384. "assignee": $rootScope.user.id,
  1385. "candidateGroups": $rootScope.user.group[0].id,
  1386. "searchType": "todo",
  1387. idx: 0,
  1388. sum: 10
  1389. }
  1390. $scope.clear = function () {
  1391. $scope.searchkeys = {};
  1392. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1393. // $scope.othcode = {};
  1394. $scope.parameters = {};
  1395. var fildata = {
  1396. "assignee": $rootScope.user.id,
  1397. "candidateGroups": $rootScope.user.group[0].id,
  1398. "searchType": "todo",
  1399. idx: 0,
  1400. sum: 10
  1401. }
  1402. // sessionStorage.removeItem("searchincident");
  1403. $scope.memoryfilterData = fildata;
  1404. $scope.loadData(fildata);
  1405. }
  1406. $scope.chiceIncident = function (parameters, item, stateid) {
  1407. var fildata = {
  1408. "assignee": $rootScope.user.id,
  1409. "candidateGroups": 1,
  1410. "searchType": "todo",
  1411. "idx": 0,
  1412. "sum": 10
  1413. };
  1414. if (item) {
  1415. fildata.applicationForm = {};
  1416. if (item.alltitle && item.alldata) {
  1417. fildata.applicationForm[item.alltitle.value] = item.alldata
  1418. }
  1419. if (item.linkProposer) {
  1420. fildata.applicationForm.linkProposer = item.linkProposer
  1421. }
  1422. if (item.proposer) {
  1423. fildata.applicationForm.proposer = item.proposer
  1424. }
  1425. if (item.status) {
  1426. fildata.applicationForm['status'] = {
  1427. id: item.status.id
  1428. };
  1429. }
  1430. if (item.type) {
  1431. fildata.applicationForm['type'] = {
  1432. id: item.type.id
  1433. };
  1434. }
  1435. }
  1436. $scope.gridOptions.paginationCurrentPage = 1;
  1437. if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
  1438. angular.extend(fildata, {
  1439. 'idx': 0,
  1440. 'sum': $scope.gridOptions.paginationPageSize
  1441. })
  1442. angular.extend(fildata.applicationForm, {
  1443. 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'),
  1444. 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59')
  1445. })
  1446. }
  1447. var transitiondata = angular.copy(item);
  1448. // angular.extend(fildata.applicationForm, transitiondata)
  1449. $scope.loadData(fildata);
  1450. }
  1451. $scope.key = {};
  1452. api_user_data.fetchDataList('user', {
  1453. "idx": 0,
  1454. "sum": 1000,
  1455. "flag": -1
  1456. }).then(function (data) {
  1457. $scope.handlingPersonnelUser = data.list;
  1458. });
  1459. $scope.gridOptions.columnDefs = items.columnDefs();
  1460. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1461. $scope.gridApi = gridApi;
  1462. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1463. // console.log(newPage);
  1464. // console.log(pageSize);
  1465. $scope.loadData({
  1466. "idx": newPage - 1,
  1467. "sum": pageSize
  1468. });
  1469. });
  1470. gridApi.core.on.filterChanged($scope, function () {
  1471. });
  1472. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1473. $scope.selected.item = data.entity;
  1474. //console.log(data);
  1475. });
  1476. };
  1477. $scope.loadData = function (filterData) {
  1478. items.fetchItems(filterData, APIService).then(function (data) {
  1479. var myData = Restangular.stripRestangular(data);
  1480. $scope.gridOptions.totalItems = myData.totalNum;
  1481. $scope.myData = myData.list;
  1482. for (var i = 0; i < $scope.myData.length; i++) {
  1483. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  1484. }
  1485. });
  1486. };
  1487. $scope.title = title;
  1488. $scope.loadData({
  1489. idx: 0,
  1490. sum: 10,
  1491. "assignee": $rootScope.user.id,
  1492. "candidateGroups": $rootScope.user.group[0].id,
  1493. "searchType": "todo",
  1494. });
  1495. $scope.selected = {
  1496. item: {}
  1497. };
  1498. $scope.ok = function () {
  1499. //console.log($scope.selected.item);
  1500. $modalInstance.close($scope.selected.item);
  1501. };
  1502. $scope.cancel = function () {
  1503. $modalInstance.dismiss('cancel');
  1504. };
  1505. },
  1506. size: 'lg',
  1507. resolve: {
  1508. items: function () {
  1509. return {
  1510. fetchItems: function (filterData, APIService) {
  1511. filterData = filterData || {};
  1512. // if(!filterData.idx){
  1513. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  1514. filterData = {
  1515. idx: 0,
  1516. sum: 10
  1517. };
  1518. }
  1519. return options.templateOptions.fetchItems(filterData, APIService, options);
  1520. },
  1521. columnDefs: function () {
  1522. return options.templateOptions.columnDefs;
  1523. }
  1524. };
  1525. },
  1526. title: function () {
  1527. return options.templateOptions.modalTitle;
  1528. },
  1529. Restangular: function () {
  1530. return options.templateOptions.Restangular;
  1531. },
  1532. APIService: function () {
  1533. return options.templateOptions.ApiService;
  1534. }
  1535. }
  1536. });
  1537. modalInstance.result.then(function (selectedItem) {
  1538. var selectitem = {
  1539. title: selectedItem.title,
  1540. description: selectedItem.description
  1541. }
  1542. if (options.key == "chuku") {
  1543. if (selectedItem.assets) {
  1544. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  1545. }
  1546. if (selectedItem.consumables) {
  1547. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  1548. }
  1549. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  1550. options.value(selectedItem);
  1551. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1552. } else {
  1553. angular.extend(options.model, selectitem);
  1554. options.value(selectedItem);
  1555. }
  1556. }, function () {
  1557. //console.log('Modal dismissed at: ' + new Date());
  1558. });
  1559. }
  1560. }]
  1561. });
  1562. //文本框
  1563. formlyConfigProvider.setType({
  1564. name: 'ui-textcmdb',
  1565. extends: '',
  1566. templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
  1567. defaultOptions: function (options) {
  1568. return {
  1569. templateOptions: {
  1570. transform: function (model, value) {
  1571. return value;
  1572. },
  1573. },
  1574. validation: {
  1575. messages: {
  1576. maxlength: function (viewValue, modelValue, scope) {
  1577. if (viewValue != null) {
  1578. if (viewValue.length > scope.to.maxlength) {
  1579. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1580. } else {
  1581. return "";
  1582. }
  1583. }
  1584. },
  1585. }
  1586. }
  1587. }
  1588. },
  1589. controller: ['$scope', function ($scope) {
  1590. var value = $scope.model[$scope.options.key];
  1591. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1592. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1593. }
  1594. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1595. $scope.options.templateOptions.felditem($scope);
  1596. }
  1597. }]
  1598. });
  1599. //设备组件
  1600. formlyConfigProvider.setType({
  1601. name: 'ui-applist',
  1602. extends: 'radio',
  1603. templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
  1604. defaultOptions: function (options) {
  1605. return {
  1606. templateOptions: {
  1607. refresh: function () { },
  1608. refreshDelay: 0
  1609. }
  1610. };
  1611. },
  1612. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1613. var data = [];
  1614. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1615. // data = JSON.parse($scope.model.consumables);
  1616. if (angular.isArray($scope.model.consumables)) {
  1617. data = $scope.model.consumables;
  1618. } else {
  1619. data = JSON.parse($scope.model.consumables);
  1620. }
  1621. $scope.model.consumables = data;
  1622. angular.forEach(data, function (item, index) {
  1623. data[index].item = index + 1;
  1624. })
  1625. }
  1626. if ($scope.model.assets && $scope.options.key == "assets") {
  1627. if (angular.isArray($scope.model.assets)) {
  1628. data = $scope.model.assets;
  1629. } else {
  1630. data = JSON.parse($scope.model.assets);
  1631. }
  1632. // data = JSON.parse($scope.model.assets);
  1633. $scope.model.assets = data;
  1634. angular.forEach(data, function (item, index) {
  1635. data[index].item = index + 1;
  1636. })
  1637. }
  1638. $scope.tableParams = new ngTableParams({
  1639. page: 1,
  1640. count: 5
  1641. }, {
  1642. total: data.length,
  1643. getData: function ($defer, params) {
  1644. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1645. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1646. }
  1647. });
  1648. $scope.editId = -1;
  1649. $scope.setEditId = function (pid) {
  1650. $scope.editId = pid;
  1651. };
  1652. }]
  1653. });
  1654. //list组件
  1655. formlyConfigProvider.setType({
  1656. name: 'ui-gudinglist',
  1657. extends: 'radio',
  1658. templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
  1659. defaultOptions: function (options) {
  1660. return {
  1661. templateOptions: {
  1662. refresh: function () { },
  1663. refreshDelay: 0
  1664. }
  1665. };
  1666. },
  1667. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1668. var data = [];
  1669. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1670. // data = JSON.parse($scope.model.consumables);
  1671. if (angular.isArray($scope.model.consumables)) {
  1672. data = $scope.model.consumables;
  1673. } else {
  1674. data = JSON.parse($scope.model.consumables);
  1675. }
  1676. $scope.model.consumables = data;
  1677. angular.forEach(data, function (item, index) {
  1678. data[index].item = index + 1;
  1679. })
  1680. }
  1681. if ($scope.model.assets && $scope.options.key == "assets") {
  1682. if (angular.isArray($scope.model.assets)) {
  1683. data = $scope.model.assets;
  1684. } else {
  1685. data = JSON.parse($scope.model.assets);
  1686. }
  1687. // data = JSON.parse($scope.model.assets);
  1688. $scope.model.assets = data;
  1689. angular.forEach(data, function (item, index) {
  1690. data[index].item = index + 1;
  1691. })
  1692. }
  1693. $scope.tableParams = new ngTableParams({
  1694. page: 1,
  1695. count: 5
  1696. }, {
  1697. total: data.length,
  1698. getData: function ($defer, params) {
  1699. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1700. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1701. }
  1702. });
  1703. $scope.editId = -1;
  1704. $scope.setEditId = function (pid) {
  1705. $scope.editId = pid;
  1706. };
  1707. }]
  1708. });
  1709. //other list tab组件
  1710. formlyConfigProvider.setType({
  1711. name: 'ui-otherlisttab',
  1712. extends: '',
  1713. templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
  1714. defaultOptions: function (options) {
  1715. return {
  1716. templateOptions: {
  1717. refresh: function () { },
  1718. refreshDelay: 0
  1719. }
  1720. };
  1721. },
  1722. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1723. }]
  1724. });
  1725. //审核查看组件
  1726. formlyConfigProvider.setType({
  1727. name: 'ui-aprovelist',
  1728. extends: '',
  1729. templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
  1730. defaultOptions: function (options) {
  1731. return {
  1732. templateOptions: {
  1733. refresh: function () { },
  1734. refreshDelay: 0
  1735. }
  1736. };
  1737. },
  1738. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1739. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  1740. $scope.isAgree = "同意";
  1741. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  1742. $scope.isAgree = "同意";
  1743. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  1744. $scope.isAgree = "返回修改";
  1745. }
  1746. }]
  1747. });
  1748. //other list组件
  1749. formlyConfigProvider.setType({
  1750. name: 'ui-otherlist',
  1751. extends: '',
  1752. templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
  1753. defaultOptions: function (options) {
  1754. return {
  1755. templateOptions: {
  1756. refresh: function () { },
  1757. refreshDelay: 0
  1758. }
  1759. };
  1760. },
  1761. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  1762. console.log("哈哈");
  1763. console.log($scope);
  1764. $scope.langs = i18nService.getAllLangs();
  1765. $scope.lang = 'zh-cn';
  1766. i18nService.setCurrentLang($scope.lang);
  1767. var vm = this;
  1768. vm.options = {};
  1769. vm.exampleTitle = ['expressionProperties', 'model property'];
  1770. vm.fields = [];
  1771. vm.models = {};
  1772. // vm.models["loginUser"] = $rootScope.user;
  1773. var that = $injector;
  1774. var parse = $parse;
  1775. var formKey = "";
  1776. var pdKey = "";
  1777. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1778. pdKey = $state.current.pdKey;
  1779. //console.log("pdKey::"+$state.current.pdKey);
  1780. }
  1781. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1782. formKey = $stateParams.formKey;
  1783. //console.log("formKey::"+$stateParams.formKey);
  1784. }
  1785. //用户测试数据,后续从header的auth中获取
  1786. var userId = 2;
  1787. userId = $rootScope.user.id;
  1788. //==============处理表单设计数据 开始====================
  1789. //处理组件加载后台数据选项的方法
  1790. function refreshSelectOptions(searchVal, field) {
  1791. if (field.templateOptions.optionsUrl) {
  1792. var process = BpmRestangular.all("");
  1793. if (field.templateOptions.ApiService) {
  1794. process = UserRestangular.all("");
  1795. }
  1796. process.customPOST({
  1797. "idx": 0,
  1798. "sum": 1000
  1799. }, field.templateOptions.optionsUrl).then(function (result) {
  1800. if (!field.templateOptions.options) {
  1801. field.templateOptions.options = [];
  1802. }
  1803. if (field.templateOptions.optionsDataKey) {
  1804. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  1805. } else {
  1806. field.templateOptions.options = result;
  1807. }
  1808. });
  1809. }
  1810. }
  1811. function decodeVMTabForm(model, tabs) {
  1812. var result = {
  1813. model: {},
  1814. tabs: []
  1815. };
  1816. var mdata = angular.fromJson(model);
  1817. angular.extend(result.model, mdata);
  1818. angular.forEach(tabs, function (tab) {
  1819. tab.form.model = vm.models;
  1820. angular.forEach(tab.form.fields, function (field) {
  1821. if (field.key == "") {
  1822. delete field.key;
  1823. }
  1824. field.type = "ui-otherlisttab";
  1825. if (angular.isDefined(field.extjson) && field.extjson != "") {
  1826. var extObj = angular.fromJson(field.extjson);
  1827. angular.extend(field.templateOptions, extObj.templateOptions);
  1828. delete extObj.templateOptions;
  1829. for (var prop in extObj) {
  1830. if (new RegExp("Expression").test(prop)) {
  1831. //var obj = $scope.$eval(extObj[prop]);
  1832. //extObj[prop] = $scope.$eval(extObj[prop]);
  1833. if (extObj[prop] != null) {
  1834. if (new RegExp("function").test(extObj[prop])) {
  1835. var propValue = eval(extObj[prop]);
  1836. extObj[prop] = propValue;
  1837. } else {
  1838. //console.log(extObj[prop]);
  1839. var obj = $scope.$eval(extObj[prop]);
  1840. extObj[prop] = obj;
  1841. //console.log(obj);
  1842. }
  1843. }
  1844. } else if (new RegExp("expressionProperties").test(prop)) {
  1845. for (var p in extObj[prop]) {
  1846. if (new RegExp("function").test(extObj[prop][p])) {
  1847. var propValue = eval(extObj[prop][p]);
  1848. extObj[prop][p] = propValue;
  1849. } else {
  1850. //if(p.indexOf("'")>=0){
  1851. // var obj = $scope.$eval(extObj[prop][p]);
  1852. // extObj[prop][$scope.$eval(p)]=obj;
  1853. //}
  1854. }
  1855. }
  1856. } else if ("watcher" == prop) {
  1857. if (angular.isArray(extObj[prop])) {
  1858. angular.forEach(extObj[prop], function (item, index) {
  1859. for (var p in item) {
  1860. if (new RegExp("function").test(item[p])) {
  1861. var propValue = eval(item[p]);
  1862. extObj[prop][index][p] = propValue;
  1863. }
  1864. }
  1865. });
  1866. } else if (angular.isObject(extObj[prop])) {
  1867. for (var p in extObj[prop]) {
  1868. if (new RegExp("function").test(extObj[prop][p])) {
  1869. var propValue = eval(extObj[prop][p]);
  1870. extObj[prop][p] = propValue;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. }
  1876. angular.extend(field, extObj);
  1877. delete field.extjson;
  1878. }
  1879. if (field.extjson == "") {
  1880. delete field.extjson;
  1881. }
  1882. if (angular.isDefined(field.templateOptions)) {
  1883. var templateOs = field.templateOptions;
  1884. for (var property in templateOs) {
  1885. //console.log(property);
  1886. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  1887. if (new RegExp("function").test(templateOs[property])) {
  1888. var propValue = eval(templateOs[property]);
  1889. field.templateOptions[property] = propValue;
  1890. } else {
  1891. if (that.has(templateOs[property])) {
  1892. field.templateOptions[property] = that.get(templateOs[property]);
  1893. } else {
  1894. field.templateOptions[property] = templateOs[property];
  1895. }
  1896. }
  1897. } else if (templateOs[property] == null) {
  1898. //delete field.templateOptions[property];
  1899. } else { }
  1900. }
  1901. }
  1902. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  1903. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  1904. angular.extend(field.templateOptions, extObj);
  1905. delete field.templateOptions.extjson;
  1906. }
  1907. //...
  1908. if (field.templateOptions) {
  1909. //处理远程获取数据控件方法调用
  1910. if (field.templateOptions.optionsUrl) {
  1911. field.templateOptions.refresh = refreshSelectOptions;
  1912. }
  1913. //处理嵌套属性数据绑定/
  1914. if (field.templateOptions.pkey) {
  1915. var pmodel, i = 0;
  1916. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  1917. if (i == 0) {
  1918. if (result.model[p] == null) {
  1919. result.model[p] = {};
  1920. }
  1921. pmodel = result.model[p];
  1922. i++;
  1923. } else {
  1924. if (pmodel[p] == null) {
  1925. pmodel[p] = {};
  1926. }
  1927. pmodel = pmodel[p];
  1928. }
  1929. });
  1930. if (pmodel != null) {
  1931. field.model = pmodel;
  1932. if (pmodel[field.key] == null) {
  1933. pmodel[field.key] = null;
  1934. }
  1935. }
  1936. } else {
  1937. if (result.model[field.key] == null) {
  1938. result.model[field.key] = null;
  1939. }
  1940. }
  1941. //处理弹出框组件初始化
  1942. if (field.type == "ui-input-selectmodal") {
  1943. field.templateOptions.modal = $modal;
  1944. //field.templateOptions.Restangular = Restangular;
  1945. } else if (field.type == "ui-userselect") {
  1946. field.templateOptions.modal = $modal;
  1947. //field.templateOptions.Restangular = Restangular;
  1948. } else if (field.type == "ui-multiuserselect") {
  1949. field.templateOptions.modal = $modal;
  1950. } else if (field.type == "ui-modelselect") {
  1951. field.templateOptions.modal = $modal;
  1952. //field.templateOptions.Restangular = Restangular;
  1953. } else if (field.type == "ui-cmdbuplode") {
  1954. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  1955. url: '/uploader',
  1956. queueLimit: 1, //文件个数
  1957. autoUpload: true
  1958. });
  1959. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  1960. } else if (field.type == "ui-dropfile") {
  1961. field.templateOptions.fileUploader = new FileUploader({
  1962. url: '/uploader'
  1963. });
  1964. field.templateOptions.taskId = $stateParams.taskId;
  1965. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1966. field.templateOptions.userId = $rootScope.user.id;
  1967. //field.ApiService=api_bpm_domain;
  1968. } else if (field.type == "ui-dropfiletable") {
  1969. if (field.templateOptions.processInstanceId) {
  1970. } else {
  1971. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1972. }
  1973. } else if (field.type == "ui-repeatSection") {
  1974. var repeatForm = {
  1975. model: {
  1976. },
  1977. fields: field.templateOptions.fields
  1978. };
  1979. repeatForm.model[field.key] = [];
  1980. decodeVMTabForm(repeatForm);
  1981. }
  1982. }
  1983. // console.log(field);
  1984. //field
  1985. //result.fields.push(field);
  1986. })
  1987. });
  1988. vm.originalTabs = angular.copy(vm.form);
  1989. }
  1990. //======================处理表单设计数据 结束========================
  1991. $scope.ldloading = {};
  1992. function filter(obj) {
  1993. angular.forEach(obj, function (key, value) {
  1994. if (value === "" || value === null) {
  1995. delete obj[key];
  1996. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1997. filter(value);
  1998. } else if (angular.isArray(value)) {
  1999. angular.forEach(value, function (item) {
  2000. filter(item);
  2001. });
  2002. }
  2003. });
  2004. }
  2005. function invokeOnAllFormOptions(fn) {
  2006. angular.forEach(vm.tabs, function (tab) {
  2007. if (tab.form.options && tab.form.options[fn]) {
  2008. tab.form.options[fn]();
  2009. }
  2010. });
  2011. }
  2012. function encodeCIData(data, ciId) {
  2013. /*
  2014. create/update state:未审核
  2015. create createtime:系统时间
  2016. create/update lastupdatetime : 系统时间
  2017. label:ci分类
  2018. */
  2019. if (ciId) {
  2020. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2021. var extraprop = 'props';
  2022. data[extraprop] = {};
  2023. for (var key in data) {
  2024. console.log(data[key]);
  2025. if (_.indexOf(baseprop, key) >= 0) {
  2026. continue;
  2027. } else {
  2028. data[extraprop][key] = data[key];
  2029. delete data[key];
  2030. }
  2031. }
  2032. if ($rootScope.user) {
  2033. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2034. data[extraprop]['configperson'] = $rootScope.user.name;
  2035. var isCMAdminFlag = false;
  2036. angular.forEach($rootScope.user.role, function (roleItem) {
  2037. if (roleItem.rolecode == "cmdb charge") {
  2038. isCMAdminFlag = true;
  2039. }
  2040. })
  2041. if (!isCMAdminFlag) {
  2042. data[extraprop]['state'] = '1';
  2043. }
  2044. }
  2045. if (data.props.id) {
  2046. } else {
  2047. data.label = ciId;
  2048. }
  2049. return data;
  2050. }
  2051. return undefined;
  2052. }
  2053. function decodeCIModel(data) {
  2054. var extraprop = 'props';
  2055. if (data[extraprop]) {
  2056. for (var key in data[extraprop]) {
  2057. data[key] = data[extraprop][key];
  2058. }
  2059. delete data[extraprop];
  2060. }
  2061. data['iscmadmin'] = false;
  2062. angular.forEach($rootScope.user.role, function (roleItem) {
  2063. if (roleItem.rolecode == "cmdb charge") {
  2064. data['iscmadmin'] = true;
  2065. }
  2066. })
  2067. return data;
  2068. }
  2069. function formValid() {
  2070. angular.forEach(vm.tabs, function (item) {
  2071. //item.
  2072. })
  2073. }
  2074. $scope.vm = vm;
  2075. $scope.refreshcmdbform = function (item) {
  2076. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2077. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2078. var myData = Restangular.stripRestangular(data);
  2079. $scope.propTypeOptions = myData;
  2080. $scope.templateProps = myData;
  2081. $scope.vm.tabs = myData;
  2082. if ($scope.model.assets) {
  2083. vm.models = JSON.parse($scope.model.assets);
  2084. }
  2085. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2086. if (vm.models.vtvmvtm_kaiji) {
  2087. vm.models.vtvmvtm_kaiji = "是";
  2088. } else {
  2089. vm.models.vtvmvtm_kaiji = "否";
  2090. }
  2091. }
  2092. decodeVMTabForm(vm.models, vm.tabs);
  2093. });
  2094. // }
  2095. }
  2096. var cifilterClassic = {};
  2097. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2098. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2099. $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
  2100. // } else {}
  2101. }]
  2102. });
  2103. //固定资产下载
  2104. formlyConfigProvider.setType({
  2105. name: 'ui-dropupload',
  2106. templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
  2107. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2108. defaultOptions: function (options) {
  2109. return {
  2110. templateOptions: {
  2111. view: function (APIService, contentId) {
  2112. return APIService.downloadAttachment(contentId);
  2113. },
  2114. },
  2115. };
  2116. },
  2117. controller: ['$scope', '$rootScope', 'Restangular', function ($scope, $rootScope, Restangular) {
  2118. if (angular.isUndefined($scope.form.dropState)) {
  2119. $scope.form.dropState = false;
  2120. }
  2121. var to = $scope.options.templateOptions;
  2122. var bindId = $scope.model[to.bindType].processInstanceId;
  2123. //获取附件列表
  2124. $scope.listAttachmen = function () {
  2125. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  2126. var myData = Restangular.stripRestangular(result);
  2127. // $scope.listAttachmens = myData;
  2128. $scope.attachments = myData.data;
  2129. });
  2130. };
  2131. $scope.listAttachmen();
  2132. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2133. // $scope.listAttachmen();
  2134. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2135. // $scope.listAttachmen();
  2136. // }
  2137. //附件下载
  2138. $scope.download = function (token, filename) {
  2139. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  2140. var a = document.createElement('a');
  2141. a.href = downUrl;
  2142. a.target = '_blank';
  2143. a.download = filename;
  2144. document.body.appendChild(a);
  2145. a.click();
  2146. };
  2147. //附件预览
  2148. $scope.view = function (id, previewUrl) {
  2149. if (previewUrl) {
  2150. window.open(previewUrl);
  2151. }
  2152. };
  2153. }]
  2154. });
  2155. formlyConfigProvider.setType({
  2156. name: 'ui-form',
  2157. templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
  2158. defaultOptions: function (options) {
  2159. return {
  2160. templateOptions: {
  2161. // link: function() {}
  2162. }
  2163. };
  2164. },
  2165. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  2166. $scope.langs = i18nService.getAllLangs();
  2167. $scope.lang = 'zh-cn';
  2168. i18nService.setCurrentLang($scope.lang);
  2169. var vm = this;
  2170. vm.options = {};
  2171. vm.exampleTitle = ['expressionProperties', 'model property'];
  2172. vm.fields = [];
  2173. vm.models = {};
  2174. // vm.models["loginUser"] = $rootScope.user;
  2175. var that = $injector;
  2176. var parse = $parse;
  2177. var formKey = "";
  2178. var pdKey = "";
  2179. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  2180. pdKey = $state.current.pdKey;
  2181. //console.log("pdKey::"+$state.current.pdKey);
  2182. }
  2183. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2184. formKey = $stateParams.formKey;
  2185. //console.log("formKey::"+$stateParams.formKey);
  2186. }
  2187. //用户测试数据,后续从header的auth中获取
  2188. var userId = 2;
  2189. userId = $rootScope.user.id;
  2190. //==============处理表单设计数据 开始====================
  2191. //处理组件加载后台数据选项的方法
  2192. function refreshSelectOptions(searchVal, field) {
  2193. if (field.templateOptions.optionsUrl) {
  2194. var process = BpmRestangular.all("");
  2195. if (field.templateOptions.ApiService) {
  2196. process = UserRestangular.all("");
  2197. }
  2198. process.customPOST({
  2199. "idx": 0,
  2200. "sum": 1000
  2201. }, field.templateOptions.optionsUrl).then(function (result) {
  2202. if (!field.templateOptions.options) {
  2203. field.templateOptions.options = [];
  2204. }
  2205. if (field.templateOptions.optionsDataKey) {
  2206. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  2207. } else {
  2208. field.templateOptions.options = result;
  2209. }
  2210. });
  2211. }
  2212. }
  2213. function decodeVMTabForm(model, tabs) {
  2214. var result = {
  2215. model: {},
  2216. tabs: []
  2217. };
  2218. var mdata = angular.fromJson(model);
  2219. angular.extend(result.model, mdata);
  2220. angular.forEach(tabs, function (tab) {
  2221. tab.form.model = vm.models;
  2222. angular.forEach(tab.form.fields, function (field) {
  2223. if (field.key == "") {
  2224. delete field.key;
  2225. }
  2226. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2227. var extObj = angular.fromJson(field.extjson);
  2228. angular.extend(field.templateOptions, extObj.templateOptions);
  2229. delete extObj.templateOptions;
  2230. for (var prop in extObj) {
  2231. if (new RegExp("Expression").test(prop)) {
  2232. //var obj = $scope.$eval(extObj[prop]);
  2233. //extObj[prop] = $scope.$eval(extObj[prop]);
  2234. if (extObj[prop] != null) {
  2235. if (new RegExp("function").test(extObj[prop])) {
  2236. var propValue = eval(extObj[prop]);
  2237. extObj[prop] = propValue;
  2238. } else {
  2239. //console.log(extObj[prop]);
  2240. var obj = $scope.$eval(extObj[prop]);
  2241. extObj[prop] = obj;
  2242. //console.log(obj);
  2243. }
  2244. }
  2245. } else if (new RegExp("expressionProperties").test(prop)) {
  2246. for (var p in extObj[prop]) {
  2247. if (new RegExp("function").test(extObj[prop][p])) {
  2248. var propValue = eval(extObj[prop][p]);
  2249. extObj[prop][p] = propValue;
  2250. } else {
  2251. //if(p.indexOf("'")>=0){
  2252. // var obj = $scope.$eval(extObj[prop][p]);
  2253. // extObj[prop][$scope.$eval(p)]=obj;
  2254. //}
  2255. }
  2256. }
  2257. } else if ("watcher" == prop) {
  2258. if (angular.isArray(extObj[prop])) {
  2259. angular.forEach(extObj[prop], function (item, index) {
  2260. for (var p in item) {
  2261. if (new RegExp("function").test(item[p])) {
  2262. var propValue = eval(item[p]);
  2263. extObj[prop][index][p] = propValue;
  2264. }
  2265. }
  2266. });
  2267. } else if (angular.isObject(extObj[prop])) {
  2268. for (var p in extObj[prop]) {
  2269. if (new RegExp("function").test(extObj[prop][p])) {
  2270. var propValue = eval(extObj[prop][p]);
  2271. extObj[prop][p] = propValue;
  2272. }
  2273. }
  2274. }
  2275. }
  2276. }
  2277. angular.extend(field, extObj);
  2278. delete field.extjson;
  2279. }
  2280. if (field.extjson == "") {
  2281. delete field.extjson;
  2282. }
  2283. if (angular.isDefined(field.templateOptions)) {
  2284. var templateOs = field.templateOptions;
  2285. for (var property in templateOs) {
  2286. //console.log(property);
  2287. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2288. if (new RegExp("function").test(templateOs[property])) {
  2289. var propValue = eval(templateOs[property]);
  2290. field.templateOptions[property] = propValue;
  2291. } else {
  2292. if (that.has(templateOs[property])) {
  2293. field.templateOptions[property] = that.get(templateOs[property]);
  2294. } else {
  2295. field.templateOptions[property] = templateOs[property];
  2296. }
  2297. }
  2298. } else if (templateOs[property] == null) {
  2299. //delete field.templateOptions[property];
  2300. } else { }
  2301. }
  2302. }
  2303. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2304. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2305. angular.extend(field.templateOptions, extObj);
  2306. delete field.templateOptions.extjson;
  2307. }
  2308. //...
  2309. if (field.templateOptions) {
  2310. //处理远程获取数据控件方法调用
  2311. if (field.templateOptions.optionsUrl) {
  2312. field.templateOptions.refresh = refreshSelectOptions;
  2313. }
  2314. //处理嵌套属性数据绑定/
  2315. if (field.templateOptions.pkey) {
  2316. var pmodel, i = 0;
  2317. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2318. if (i == 0) {
  2319. if (result.model[p] == null) {
  2320. result.model[p] = {};
  2321. }
  2322. pmodel = result.model[p];
  2323. i++;
  2324. } else {
  2325. if (pmodel[p] == null) {
  2326. pmodel[p] = {};
  2327. }
  2328. pmodel = pmodel[p];
  2329. }
  2330. });
  2331. if (pmodel != null) {
  2332. field.model = pmodel;
  2333. if (pmodel[field.key] == null) {
  2334. pmodel[field.key] = null;
  2335. }
  2336. }
  2337. } else {
  2338. if (result.model[field.key] == null) {
  2339. result.model[field.key] = null;
  2340. }
  2341. }
  2342. //处理弹出框组件初始化
  2343. if (field.type == "ui-input-selectmodal") {
  2344. field.templateOptions.modal = $modal;
  2345. //field.templateOptions.Restangular = Restangular;
  2346. } else if (field.type == "ui-userselect") {
  2347. field.templateOptions.modal = $modal;
  2348. //field.templateOptions.Restangular = Restangular;
  2349. } else if (field.type == "ui-multiuserselect") {
  2350. field.templateOptions.modal = $modal;
  2351. } else if (field.type == "ui-modelselect") {
  2352. field.templateOptions.modal = $modal;
  2353. //field.templateOptions.Restangular = Restangular;
  2354. } else if (field.type == "ui-dropfile") {
  2355. field.templateOptions.fileUploader = new FileUploader({
  2356. url: '/uploader'
  2357. });
  2358. field.templateOptions.taskId = $stateParams.taskId;
  2359. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2360. field.templateOptions.userId = $rootScope.user.id;
  2361. //field.ApiService=api_bpm_domain;
  2362. // }else if (field.type == "ui-uploadFile") {
  2363. // field.templateOptions.fileUploader = new FileUploader({
  2364. // url: '/uploader'
  2365. // });
  2366. // field.templateOptions.taskId = $stateParams.taskId;
  2367. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2368. // field.templateOptions.userId = $rootScope.user.id;
  2369. //field.ApiService=api_bpm_domain;
  2370. } else if (field.type == "ui-dropfiletable") {
  2371. if (field.templateOptions.processInstanceId) {
  2372. } else {
  2373. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2374. }
  2375. } else if (field.type == "ui-dropFiles") {
  2376. if (field.templateOptions.processInstanceId) {
  2377. } else {
  2378. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2379. }
  2380. } else if (field.type == "ui-showImgs") {
  2381. if (field.templateOptions.processInstanceId) {
  2382. } else {
  2383. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2384. }
  2385. } else if (field.type == "ui-repeatSection") {
  2386. var repeatForm = {
  2387. model: {
  2388. },
  2389. fields: field.templateOptions.fields
  2390. };
  2391. repeatForm.model[field.key] = [];
  2392. decodeVMTabForm(repeatForm);
  2393. }
  2394. }
  2395. // console.log(field);
  2396. //field
  2397. //result.fields.push(field);
  2398. })
  2399. });
  2400. vm.originalTabs = angular.copy(vm.form);
  2401. }
  2402. //解析自定义表单设计数据
  2403. function decodeVMForm(vmForm) {
  2404. var result = {
  2405. model: {},
  2406. tabs: []
  2407. };
  2408. //设置模型实体数据 begin
  2409. // var mdata = vmForm.model;
  2410. //解析数据实体
  2411. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2412. angular.extend(result.model, mdata);
  2413. //设置模型实体数据 end
  2414. //解析设计数据生成表单项 begin
  2415. var fields = [];
  2416. //处理修改设计数据中展示设置
  2417. angular.forEach(vmForm.tabs, function (field) {
  2418. if (field.key == "") {
  2419. delete field.key;
  2420. }
  2421. if (angular.isDefined(field.extjson)) {
  2422. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2423. angular.extend(field.templateOptions, extObj.templateOptions);
  2424. delete extObj.templateOptions;
  2425. for (var prop in extObj) {
  2426. if (new RegExp("Expression").test(prop)) {
  2427. //var obj = $scope.$eval(extObj[prop]);
  2428. //extObj[prop] = $scope.$eval(extObj[prop]);
  2429. if (extObj[prop] != null) {
  2430. if (new RegExp("function").test(extObj[prop])) {
  2431. var propValue = eval(extObj[prop]);
  2432. extObj[prop] = propValue;
  2433. } else {
  2434. //console.log(extObj[prop]);
  2435. var obj = $scope.$eval(extObj[prop]);
  2436. extObj[prop] = obj;
  2437. //console.log(obj);
  2438. }
  2439. }
  2440. } else if (new RegExp("expressionProperties").test(prop)) {
  2441. for (var p in extObj[prop]) {
  2442. if (new RegExp("function").test(extObj[prop][p])) {
  2443. var propValue = eval(extObj[prop][p]);
  2444. extObj[prop][p] = propValue;
  2445. } else {
  2446. //if(p.indexOf("'")>=0){
  2447. // var obj = $scope.$eval(extObj[prop][p]);
  2448. // extObj[prop][$scope.$eval(p)]=obj;
  2449. //}
  2450. }
  2451. }
  2452. } else if ("watcher" == prop) {
  2453. if (angular.isArray(extObj[prop])) {
  2454. angular.forEach(extObj[prop], function (item, index) {
  2455. for (var p in item) {
  2456. if (new RegExp("function").test(item[p])) {
  2457. var propValue = eval(item[p]);
  2458. extObj[prop][index][p] = propValue;
  2459. }
  2460. }
  2461. });
  2462. } else if (angular.isObject(extObj[prop])) {
  2463. for (var p in extObj[prop]) {
  2464. if (new RegExp("function").test(extObj[prop][p])) {
  2465. var propValue = eval(extObj[prop][p]);
  2466. extObj[prop][p] = propValue;
  2467. }
  2468. }
  2469. }
  2470. }
  2471. }
  2472. angular.extend(field, extObj);
  2473. delete field.extjson;
  2474. }
  2475. if (angular.isDefined(field.templateOptions)) {
  2476. var templateOs = field.templateOptions;
  2477. for (var property in templateOs) {
  2478. //console.log(property);
  2479. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2480. if (new RegExp("function").test(templateOs[property])) {
  2481. var propValue = eval(templateOs[property]);
  2482. field.templateOptions[property] = propValue;
  2483. } else {
  2484. if (that.has(templateOs[property])) {
  2485. field.templateOptions[property] = that.get(templateOs[property]);
  2486. } else {
  2487. field.templateOptions[property] = templateOs[property];
  2488. }
  2489. }
  2490. } else if (templateOs[property] == null) {
  2491. //delete field.templateOptions[property];
  2492. } else { }
  2493. }
  2494. }
  2495. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2496. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2497. angular.extend(field.templateOptions, extObj);
  2498. delete field.templateOptions.extjson;
  2499. }
  2500. //...
  2501. if (field.templateOptions) {
  2502. //处理远程获取数据控件方法调用
  2503. if (field.templateOptions.optionsUrl) {
  2504. field.templateOptions.refresh = refreshSelectOptions;
  2505. }
  2506. //处理嵌套属性数据绑定/
  2507. if (field.templateOptions.pkey) {
  2508. var pmodel, i = 0;
  2509. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2510. if (i == 0) {
  2511. if (result.model[p] == null) {
  2512. result.model[p] = {};
  2513. }
  2514. pmodel = result.model[p];
  2515. i++;
  2516. } else {
  2517. if (pmodel[p] == null) {
  2518. pmodel[p] = {};
  2519. }
  2520. pmodel = pmodel[p];
  2521. }
  2522. });
  2523. if (pmodel != null) {
  2524. field.model = pmodel;
  2525. if (pmodel[field.key] == null) {
  2526. pmodel[field.key] = null;
  2527. }
  2528. }
  2529. } else {
  2530. if (result.model[field.key] == null) {
  2531. result.model[field.key] = null;
  2532. }
  2533. }
  2534. //处理弹出框组件初始化
  2535. if (field.type == "ui-input-selectmodal") {
  2536. field.templateOptions.modal = $modal;
  2537. //field.templateOptions.Restangular = Restangular;
  2538. } else if (field.type == "ui-userselect") {
  2539. field.templateOptions.modal = $modal;
  2540. //field.templateOptions.Restangular = Restangular;
  2541. } else if (field.type == "ui-multiuserselect") {
  2542. field.templateOptions.modal = $modal;
  2543. } else if (field.type == "ui-modelselect") {
  2544. field.templateOptions.modal = $modal;
  2545. //field.templateOptions.Restangular = Restangular;
  2546. } else if (field.type == "ui-dropfile") {
  2547. field.templateOptions.fileUploader = new FileUploader({
  2548. url: '/uploader'
  2549. });
  2550. field.templateOptions.taskId = $stateParams.taskId;
  2551. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2552. field.templateOptions.userId = $rootScope.user.id;
  2553. //field.ApiService=api_bpm_domain;
  2554. } else if (field.type == "ui-dropfiletable") {
  2555. if (field.templateOptions.processInstanceId) {
  2556. } else {
  2557. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2558. }
  2559. } else if (field.type == "ui-dropFiles") {
  2560. if (field.templateOptions.processInstanceId) {
  2561. } else {
  2562. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2563. }
  2564. } else if (field.type == "ui-showImgs") {
  2565. if (field.templateOptions.processInstanceId) {
  2566. } else {
  2567. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2568. }
  2569. } else if (field.type == "ui-repeatSection") {
  2570. var repeatForm = {
  2571. model: {
  2572. },
  2573. fields: field.templateOptions.fields
  2574. };
  2575. repeatForm.model[field.key] = [];
  2576. decodeVMForm(repeatForm);
  2577. }
  2578. }
  2579. // console.log(field);
  2580. result.fields.push(field);
  2581. });
  2582. angular.extend($scope.vm.fields, result.fields);
  2583. angular.extend($scope.vm.models, result.model);
  2584. $scope.formData = vmForm;
  2585. //console.log($scope.vm);
  2586. //解析设计数据生成表单项 end
  2587. return result;
  2588. }
  2589. //======================处理表单设计数据 结束========================
  2590. $scope.ldloading = {};
  2591. function filter(obj) {
  2592. angular.forEach(obj, function (key, value) {
  2593. if (value === "" || value === null) {
  2594. delete obj[key];
  2595. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  2596. filter(value);
  2597. } else if (angular.isArray(value)) {
  2598. angular.forEach(value, function (item) {
  2599. filter(item);
  2600. });
  2601. }
  2602. });
  2603. }
  2604. function invokeOnAllFormOptions(fn) {
  2605. angular.forEach(vm.tabs, function (tab) {
  2606. if (tab.form.options && tab.form.options[fn]) {
  2607. tab.form.options[fn]();
  2608. }
  2609. });
  2610. }
  2611. function encodeCIData(data, ciId) {
  2612. /*
  2613. create/update state:未审核
  2614. create createtime:系统时间
  2615. create/update lastupdatetime : 系统时间
  2616. label:ci分类
  2617. */
  2618. if (ciId) {
  2619. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2620. var extraprop = 'props';
  2621. data[extraprop] = {};
  2622. for (var key in data) {
  2623. console.log(data[key]);
  2624. if (_.indexOf(baseprop, key) >= 0) {
  2625. continue;
  2626. } else {
  2627. data[extraprop][key] = data[key];
  2628. delete data[key];
  2629. }
  2630. }
  2631. if ($rootScope.user) {
  2632. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2633. data[extraprop]['configperson'] = $rootScope.user.name;
  2634. var isCMAdminFlag = false;
  2635. angular.forEach($rootScope.user.role, function (roleItem) {
  2636. if (roleItem.rolecode == "cmdb charge") {
  2637. isCMAdminFlag = true;
  2638. }
  2639. })
  2640. if (!isCMAdminFlag) {
  2641. data[extraprop]['state'] = '1';
  2642. }
  2643. }
  2644. if (data.props.id) {
  2645. } else {
  2646. data.label = ciId;
  2647. }
  2648. return data;
  2649. }
  2650. return undefined;
  2651. }
  2652. function decodeCIModel(data) {
  2653. var extraprop = 'props';
  2654. if (data[extraprop]) {
  2655. for (var key in data[extraprop]) {
  2656. data[key] = data[extraprop][key];
  2657. }
  2658. delete data[extraprop];
  2659. }
  2660. data['iscmadmin'] = false;
  2661. angular.forEach($rootScope.user.role, function (roleItem) {
  2662. if (roleItem.rolecode == "cmdb charge") {
  2663. data['iscmadmin'] = true;
  2664. }
  2665. })
  2666. return data;
  2667. }
  2668. vm.remove = function (data, style) {
  2669. $scope.ldloading[style.replace('-', '_')] = true;
  2670. var modalInstance = $modal.open({
  2671. templateUrl: 'assets/views/delete.html',
  2672. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  2673. var cidata = {
  2674. label: data.label,
  2675. id: data.id,
  2676. uuid: data.uuid,
  2677. name: data.name,
  2678. props: {}
  2679. };
  2680. if (cidata.id) {
  2681. cidata.props['removeflag'] = true;
  2682. cidata.props['lastupdateperson'] = vm.models.loginUser;
  2683. $scope.ok = function () {
  2684. $modalInstance.close(cidata);
  2685. };
  2686. $scope.cancel = function () {
  2687. $modalInstance.dismiss('cancel');
  2688. };
  2689. }
  2690. },
  2691. size: 'sm',
  2692. resolve: {
  2693. scope: function () {
  2694. return $scope;
  2695. }
  2696. }
  2697. });
  2698. modalInstance.result.then(function (selectedItem) {
  2699. if (selectedItem) {
  2700. // if (selectedItem.length > 0) {
  2701. api_cmdb.put(selectedItem, selectedItem.id).then(function (response) {
  2702. if (response) {
  2703. var resData = Restangular.stripRestangular(response);
  2704. SweetAlert.swal({
  2705. title: "删除成功!",
  2706. confirmButtonColor: "#007AFF"
  2707. }, function () {
  2708. $state.go("app.means.list");
  2709. // $scope.refreshform();
  2710. // reinitTabForm($scope.classify);
  2711. });
  2712. } else {
  2713. SweetAlert.swal({
  2714. title: "系统错误",
  2715. text: "系统错误,请稍后重试!",
  2716. type: "error",
  2717. confirmButtonColor: "#DD6B55"
  2718. });
  2719. }
  2720. $scope.ldloading[style.replace('-', '_')] = false;
  2721. });
  2722. }
  2723. })
  2724. }
  2725. function formValid() {
  2726. angular.forEach(vm.tabs, function (item) {
  2727. //item.
  2728. })
  2729. }
  2730. $scope.closeModel = function () {
  2731. console.log($stateParams);
  2732. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2733. if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
  2734. $state.go('app.means.list', {});
  2735. }
  2736. event.preventDefault();
  2737. }
  2738. }
  2739. // setInterval(function() {
  2740. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  2741. // cifilter_classic = $scope.model.cifilter_classic;
  2742. // $scope.refreshcmdbform(cifilter_classic);
  2743. // } else {}
  2744. // }, 100);
  2745. vm.models = (function filter(obj) {
  2746. var filtered = _.pick(obj, function (v) {
  2747. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2748. });
  2749. return _.cloneDeep(filtered, function (v) {
  2750. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2751. });
  2752. })(vm.models);
  2753. // setInterval(function() {
  2754. // if ($scope.model.type == 0) {
  2755. // $scope.model[$scope.options.key] = vm.models;
  2756. // }
  2757. // }, 100);
  2758. setInterval(function () {
  2759. if (vm.form && vm.form.$$parentForm.$valid) {
  2760. if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
  2761. vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2762. $scope.model[$scope.options.key] = vm.models;
  2763. }
  2764. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2765. // $scope.model[$scope.options.key] = vm.models;
  2766. }
  2767. }, 100);
  2768. vm.submit = function (data, ciId, templateitem, style) {
  2769. // $scope.ldloading[style.replace('-', '_')] = true;
  2770. console.log(vm.form.$$parentForm.$valid);
  2771. if (vm.form.$$parentForm.$valid) {
  2772. invokeOnAllFormOptions('updateInitialValue');
  2773. //alert(JSON.stringify(vm.model), null, 2);
  2774. //vm.options.updateInitialValue();
  2775. //console.log(vm.model);
  2776. var cidata = encodeCIData(vm.models, ciId);
  2777. if (cidata) {
  2778. //var cidata = ;
  2779. if (cidata.props.id) {
  2780. //修改
  2781. api_cmdb.put(cidata, ciId).then(function (response) {
  2782. if (response) {
  2783. var resData = Restangular.stripRestangular(response);
  2784. SweetAlert.swal({
  2785. title: "保存成功!",
  2786. confirmButtonColor: "#007AFF"
  2787. }, function () {
  2788. $scope.ldloading[style.replace('-', '_')] = false;
  2789. // $scope.refreshform();
  2790. $state.go("app.means.list");
  2791. });
  2792. } else {
  2793. SweetAlert.swal({
  2794. title: "系统错误",
  2795. text: "系统错误,请稍后重试!",
  2796. type: "error",
  2797. confirmButtonColor: "#DD6B55"
  2798. });
  2799. }
  2800. $scope.ldloading[style.replace('-', '_')] = false;
  2801. });
  2802. } else {
  2803. //新建
  2804. var type = 2;
  2805. api_sysinfo.getSerialnumber(type, templateitem.id).then(function (data) {
  2806. if (data && data.status == 200) {
  2807. cidata.uuid = data.uuid;
  2808. api_cmdb.create(cidata).then(function (response) {
  2809. if (response) {
  2810. var resData = Restangular.stripRestangular(response);
  2811. SweetAlert.swal({
  2812. title: "保存成功!",
  2813. text: "内部编号:" + cidata.uuid,
  2814. confirmButtonColor: "#007AFF"
  2815. }, function () {
  2816. $state.go("app.means.list");
  2817. });
  2818. // if(resData.status){
  2819. // resData
  2820. // }
  2821. } else {
  2822. SweetAlert.swal({
  2823. title: "系统错误",
  2824. text: "系统错误,请稍后重试!",
  2825. type: "error",
  2826. confirmButtonColor: "#DD6B55"
  2827. });
  2828. }
  2829. $scope.ldloading[style.replace('-', '_')] = false;
  2830. });
  2831. } else {
  2832. SweetAlert.swal({
  2833. title: "系统错误",
  2834. text: "内部编号生成出错!",
  2835. type: "error",
  2836. confirmButtonColor: "#DD6B55"
  2837. });
  2838. }
  2839. })
  2840. }
  2841. } else {
  2842. SweetAlert.swal({
  2843. title: "错误",
  2844. text: "错误,请选择资产分类!",
  2845. type: "error",
  2846. confirmButtonColor: "#DD6B55"
  2847. });
  2848. }
  2849. //alert(JSON.stringify(cidata), null, 2);
  2850. $scope.ldloading[style.replace('-', '_')] = true;
  2851. return;
  2852. var _ = window._;
  2853. vm.models = (function filter(obj) {
  2854. var filtered = _.pick(obj, function (v) {
  2855. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2856. });
  2857. return _.cloneDeep(filtered, function (v) {
  2858. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2859. });
  2860. })(vm.models);
  2861. } else {
  2862. if (vm.form.$$parentForm.$error) {
  2863. SweetAlert.swal({
  2864. title: "校验错误",
  2865. text: "请填写必填项!",
  2866. type: "error",
  2867. confirmButtonColor: "#DD6B55"
  2868. });
  2869. angular.forEach(vm.form.$$parentForm.$error.required, function (item) {
  2870. angular.forEach(vm.tabs, function (tab) {
  2871. angular.forEach(tab.form.fields, function (f) {
  2872. if (f.name == item.$name) {
  2873. f.validation.show = true;
  2874. tab.active = true;
  2875. }
  2876. })
  2877. })
  2878. });
  2879. $scope.ldloading[style.replace('-', '_')] = false;
  2880. }
  2881. }
  2882. };
  2883. $scope.vm = vm;
  2884. $scope.refreshcmdbform = function (item) {
  2885. // if ($stateParams.model) {
  2886. // var modeldata = JSON.parse($stateParams.model)
  2887. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2888. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2889. var myData = Restangular.stripRestangular(data);
  2890. $scope.propTypeOptions = myData;
  2891. $scope.templateProps = myData;
  2892. $scope.vm.tabs = myData;
  2893. if ($scope.model.asset && $scope.model.asset.length != "") {
  2894. vm.models = JSON.parse($scope.model.asset);
  2895. }
  2896. decodeVMTabForm(vm.models, vm.tabs);
  2897. });
  2898. // }
  2899. }
  2900. var cifilterClassic = {};
  2901. setInterval(function () {
  2902. if ($scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2903. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  2904. cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2905. $scope.refreshcmdbform(cifilterClassic);
  2906. } else { }
  2907. }, 100);
  2908. }]
  2909. });
  2910. //请求人信息
  2911. formlyConfigProvider.setType({
  2912. name: 'ui-cmdbinformation',
  2913. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
  2914. wrapper: ['bootstrapHasError'],
  2915. defaultOptions: function (options, $scope) {
  2916. return {
  2917. templateOptions: {
  2918. // checkform: function(options) {
  2919. // if (options.model.requester) {
  2920. // options.value(options.model.requester);
  2921. // }
  2922. // },
  2923. }
  2924. };
  2925. },
  2926. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2927. if ($scope.options.templateOptions.loginUser) {
  2928. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
  2929. } else {
  2930. $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
  2931. }
  2932. $scope.options.initialValue = $scope.model[$scope.options.key];
  2933. }
  2934. }]
  2935. });
  2936. //资产属性
  2937. formlyConfigProvider.setType({
  2938. name: 'ui-cmdbtype',
  2939. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
  2940. wrapper: ['bootstrapHasError'],
  2941. defaultOptions: function (options, $scope) {
  2942. return {
  2943. templateOptions: {
  2944. // checkform: function(options) {
  2945. // if (options.model.requester) {
  2946. // options.value(options.model.requester);
  2947. // }
  2948. // },
  2949. }
  2950. };
  2951. },
  2952. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2953. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2954. $scope.property = {
  2955. 'hw_change': $scope.to.loginUser,
  2956. 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
  2957. 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
  2958. }
  2959. if ($scope.$parent.$parent.$parent.model.assets) {
  2960. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  2961. }
  2962. }]
  2963. });
  2964. //申请单信息
  2965. formlyConfigProvider.setType({
  2966. name: 'ui-cmdbformimform',
  2967. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
  2968. wrapper: ['bootstrapHasError'],
  2969. defaultOptions: function (options, $scope) {
  2970. return {
  2971. templateOptions: {
  2972. // checkform: function(options) {
  2973. // if (options.model.requester) {
  2974. // options.value(options.model.requester);
  2975. // }
  2976. // },
  2977. }
  2978. };
  2979. },
  2980. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2981. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2982. $scope.getininform = {
  2983. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2984. time: $scope.$parent.$parent.$parent.model.applicationForm.time
  2985. };
  2986. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  2987. $scope.getininform.types = "新资产入库";
  2988. } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
  2989. $scope.getininform.types = "资产归还";
  2990. }
  2991. }]
  2992. });
  2993. //出库单信息
  2994. formlyConfigProvider.setType({
  2995. name: 'ui-outinformation',
  2996. templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
  2997. wrapper: ['bootstrapHasError'],
  2998. defaultOptions: function (options, $scope) {
  2999. return {
  3000. templateOptions: {
  3001. // checkform: function(options) {
  3002. // if (options.model.requester) {
  3003. // options.value(options.model.requester);
  3004. // }
  3005. // },
  3006. }
  3007. };
  3008. },
  3009. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  3010. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3011. $scope.getininform = {
  3012. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3013. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3014. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3015. sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3016. describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
  3017. };
  3018. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3019. $scope.getininform.types = "新设备领用出库";
  3020. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3021. $scope.getininform.types = "设备更换";
  3022. }
  3023. $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.value;
  3024. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3025. $scope.getininform.source = "事件";
  3026. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3027. $scope.getininform.source = "变更";
  3028. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3029. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3030. $scope.getininform.source = "其它";
  3031. }
  3032. }]
  3033. });
  3034. //资产附件上传
  3035. formlyConfigProvider.setType({
  3036. name: 'ui-cmdbuplode',
  3037. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
  3038. wrapper: ['bootstrapHasError'],
  3039. defaultOptions: function (options, $scope) {
  3040. return {
  3041. templateOptions: {
  3042. // checkform: function(options) {
  3043. // if (options.model.requester) {
  3044. // options.value(options.model.requester);
  3045. // }
  3046. // },
  3047. }
  3048. };
  3049. },
  3050. controller: ['$scope', '$rootScope', '$http', 'SweetAlert', 'FileUploader', 'api_user_data', 'i18nService', '$modal', 'Restangular', 'api_configure_data', 'api_cmdb', 'api_cmdb_new', 'api_wechatfile', 'api_sysinfo', function ($scope, $rootScope, $http, SweetAlert, FileUploader, api_user_data, i18nService, $modal, Restangular, api_configure_data, api_cmdb, api_cmdb_new, api_wechatfile, api_sysinfo) {
  3051. $scope.state = 1;
  3052. $scope.myData3all = [];
  3053. $scope.myData3 = [];
  3054. $scope.memoryfilterDatahao = {
  3055. "idx": 0,
  3056. "sum": 10,
  3057. }
  3058. $scope.selected = {
  3059. items: []
  3060. };
  3061. $scope.interceptMydata = function (mydate, idx, sum) {
  3062. return mydate.slice(idx * sum, (idx + 1) * sum)
  3063. }
  3064. // $scope.importnext = function() {
  3065. // $scope.state = 2;
  3066. // event.preventDefault();
  3067. // }
  3068. $scope.workspaces = [];
  3069. $scope.options.templateOptions.getpush = function (item) {
  3070. $scope.workspaces = [];
  3071. if (item.gu) {
  3072. $scope.workspaces.push({
  3073. id: 1,
  3074. name: "固定资产",
  3075. active: true,
  3076. contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html'
  3077. })
  3078. }
  3079. if (item.hao) {
  3080. $scope.workspaces.push({
  3081. id: 2,
  3082. name: "耗材资产",
  3083. active: true,
  3084. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  3085. })
  3086. }
  3087. };
  3088. //获取附件列表
  3089. $scope.listAttachmen = function () {
  3090. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  3091. var myData = Restangular.stripRestangular(result);
  3092. // $scope.listAttachmens = myData;
  3093. $scope.attachments = myData.data;
  3094. });
  3095. };
  3096. //附件列表
  3097. if ($scope.options.templateOptions.bindType) {
  3098. if (angular.isUndefined($scope.form.dropState)) {
  3099. $scope.form.dropState = false;
  3100. }
  3101. var to = $scope.options.templateOptions;
  3102. var bindId = $scope.model[to.bindType].processInstanceId;
  3103. $scope.listAttachmen();
  3104. }
  3105. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3106. // $scope.listAttachmen();
  3107. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3108. // $scope.listAttachmen();
  3109. // }
  3110. //附件下载
  3111. $scope.download = function (token, filename) {
  3112. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  3113. // window.open(downUrl);
  3114. var a = document.createElement('a');
  3115. a.href = downUrl;
  3116. a.target = '_blank';
  3117. a.download = filename;
  3118. document.body.appendChild(a);
  3119. a.click();
  3120. };
  3121. //附件预览
  3122. $scope.view = function (id, previewUrl) {
  3123. if (previewUrl) {
  3124. window.open(previewUrl);
  3125. }
  3126. };
  3127. //下载资产模版
  3128. $scope.filenum = 0;
  3129. $scope.openmeans = function () {
  3130. var modalInstance = $modal.open({
  3131. templateUrl: 'assets/views/means/tpl/meansdown.html',
  3132. controller: function ($scope, scope, $modalInstance) {
  3133. $scope.item = {};
  3134. $scope.title = "选择下载模版";
  3135. $scope.lable = "资产模版下载";
  3136. function foreachdata(my_datas) {
  3137. // angular.forEach(my_datas, function(item, index) {
  3138. // if (item.children && item.children.length > 0) {
  3139. // foreachdata(item.children);
  3140. // } else {
  3141. // my_datas[index].checks = true;
  3142. // }
  3143. // })
  3144. for (var i = 0; i < my_datas.length; i++) {
  3145. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3146. foreachdata(my_datas[i].children);
  3147. console.log($scope);
  3148. } else {
  3149. my_datas[i].checks = true;
  3150. }
  3151. }
  3152. }
  3153. function foreachtree(data) {
  3154. angular.forEach(data, function (item) {
  3155. // if (item.checks != true) {
  3156. item.checks = true;
  3157. item.expanded = true;
  3158. if (item.children && item.children.length > 0) {
  3159. foreachtree(item.children)
  3160. } else {
  3161. $scope.getslowtree.push(item)
  3162. }
  3163. // }
  3164. })
  3165. }
  3166. $scope.getslowtree = [];
  3167. $scope.slowtree = function (tree) {
  3168. foreachtree(tree)
  3169. return $scope.getslowtree
  3170. }
  3171. $scope.all = function (c, v) { //全选
  3172. if (c == true) {
  3173. $scope.formdashboard($scope.slowtree(v));
  3174. } else {
  3175. $scope.my_data_after = [];
  3176. angular.forEach($scope.my_data, function (item, index) {
  3177. $scope.my_data[index].checks = false;
  3178. $scope.my_data[index].expanded = false;
  3179. if (item.children && item.children.length > 0) {
  3180. angular.forEach(item.children, function (itemone, indexone) {
  3181. $scope.my_data[index].children[indexone].checks = false;
  3182. $scope.my_data[index].children[indexone].expanded = false;
  3183. if (itemone.children && itemone.children.length > 0) {
  3184. angular.forEach(itemone.children, function (itemtwo, indextwo) {
  3185. $scope.my_data[index].children[indexone].children[indextwo].checks = false;
  3186. })
  3187. } else { }
  3188. })
  3189. } else { }
  3190. })
  3191. $scope.mydatacate = [];
  3192. $scope.getslowtree = [];
  3193. // }
  3194. }
  3195. };
  3196. // $scope.searchone = function(search) {
  3197. // angular.forEach($scope.my_data, function(item) {
  3198. // if (item.indexOf(search) > 0) {
  3199. // }
  3200. // })
  3201. // }
  3202. $scope.checkall = function () {
  3203. angular.forEach($scope.my_data, function (item, index) {
  3204. scope.my_data[index].checks = true;
  3205. })
  3206. }
  3207. $scope.selectitem = [];
  3208. $scope.choiceitem = function (item) {
  3209. // if (item.checkeds) {
  3210. // item.checkeds = false;
  3211. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3212. // // if ($scope.selectitem[i].id == item.id) {
  3213. // // $scope.selectitem.splice(i, 1)
  3214. // // }
  3215. // // }
  3216. // for (var i = 0; i < $scope.my_data_after; i++) {
  3217. // if ($scope.my_data_after[i].id == item.id) {
  3218. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3219. // // $scope.selectitem.splice(i, 1)
  3220. // }
  3221. // }
  3222. // } else {
  3223. // item.checkeds = true;
  3224. // $scope.selectitem.push(item)
  3225. // }
  3226. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3227. if ($scope.my_data_after[i].id == item.id) {
  3228. $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3229. }
  3230. }
  3231. }
  3232. $scope.remove = function (removeitem) {
  3233. var realdat = angular.copy($scope.my_data_after)
  3234. // angular.extend(realdat, $scope.selectitem);
  3235. $scope.my_data_after = [];
  3236. angular.forEach(realdat, function (item) {
  3237. if (!item.checkeds) {
  3238. $scope.my_data_after.push(item)
  3239. }
  3240. })
  3241. $scope.mydatacate = angular.copy($scope.my_data_after);
  3242. }
  3243. $scope.try_async_loads = function (item, search) {
  3244. var fildatas = {
  3245. 'idx': 0,
  3246. 'sum': 1000
  3247. };
  3248. $scope.my_data = [];
  3249. // $scope.try_async_load = true;
  3250. if (item) {
  3251. angular.extend(fildatas, item)
  3252. }
  3253. api_configure_data.fetchDataList('ciclassify', fildatas).then(function (response) {
  3254. if (response.status == 200) {
  3255. var data = response.list;
  3256. var objects = [];
  3257. for (var i = 0; i < data.length; i++) {
  3258. var object = {};
  3259. object.id = data[i].id;
  3260. if (search) {
  3261. delete data[i].parent
  3262. } else {
  3263. if (data[i].parent && data[i].parent.id != 0) {
  3264. object.parent = data[i].parent.id;
  3265. }
  3266. }
  3267. angular.extend(object, data[i]);
  3268. objects.push(object);
  3269. }
  3270. $scope.my_data = convertParentToChildList(objects);
  3271. $scope.tree_data = angular.copy($scope.my_data);
  3272. if ($scope.my_data.length > 0) {
  3273. $scope.try_async_load = false;
  3274. }
  3275. } else {
  3276. SweetAlert.swal({
  3277. title: "系统错误!",
  3278. text: "请刷新重试!",
  3279. type: "error"
  3280. });
  3281. }
  3282. });
  3283. };
  3284. function convertListToTree(data, treeMap) {
  3285. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3286. var root = null; //Initially set our loop to null
  3287. //loop over data
  3288. for (var i = 0; i < data.length; i++) {
  3289. var datum = data[i];
  3290. //each node will have children, so let's give it a "children" poperty
  3291. datum.children = [];
  3292. //add an entry for this node to the map so that any future children can
  3293. //lookup the parent
  3294. idToNodeMap[datum.id] = datum;
  3295. //Does this node have a parent?
  3296. // console.log("datum="+JSON.stringify(datum))
  3297. if (typeof datum.parent === "undefined" || datum.parent === null) {
  3298. //Doesn't look like it, so this node is the root of the tree
  3299. root = datum;
  3300. treeMap[datum.id] = root;
  3301. } else {
  3302. //This node has a parent, so let's look it up using the id
  3303. parentNode = idToNodeMap[datum.parent.id];
  3304. //We don't need this property, so let's delete it.
  3305. // delete datum.parent;
  3306. //Let's add the current node as a child of the parent node.
  3307. parentNode.children.push(datum);
  3308. }
  3309. }
  3310. return root;
  3311. }
  3312. function convertParentToChildList(data) {
  3313. var treeMap = {};
  3314. var list = [];
  3315. convertListToTree(data, treeMap);
  3316. angular.forEach(treeMap, function (item) {
  3317. list.push(item);
  3318. });
  3319. return list;
  3320. }
  3321. function convertParentToChild(datato) {
  3322. var treeMapto = {};
  3323. var listto = [];
  3324. convertListToTree(datato, treeMapto);
  3325. angular.forEach(treeMapto, function (items) {
  3326. listto.push(items);
  3327. });
  3328. return listto;
  3329. }
  3330. $scope.try_async_loads();
  3331. $scope.searchdown = function (key) {
  3332. if (key && key != '') {
  3333. $scope.try_async_loads({
  3334. 'ciclassify': {
  3335. "label": key
  3336. }
  3337. }, 'search')
  3338. } else {
  3339. $scope.try_async_loads()
  3340. }
  3341. // var mydatacatedown = angular.copy($scope.my_data);
  3342. // $scope.my_data = [];
  3343. // var objects = [];
  3344. // angular.forEach(mydatacatedown, function(item) {
  3345. // if (item.label.match(key)) {
  3346. // objects.push(item)
  3347. // } else {
  3348. // // $scope.my_data_after.push(item)
  3349. // }
  3350. // })
  3351. // $scope.my_data = convertParentToChildList(objects);
  3352. // $scope.tree_data = angular.copy($scope.my_data);
  3353. }
  3354. $scope.mydatacate = [];
  3355. $scope.searchup = function (key) {
  3356. // var mydatacate = angular.copy($scope.my_data_after);
  3357. $scope.my_data_after = [];
  3358. angular.forEach($scope.mydatacate, function (item) {
  3359. if (item.label.match(key)) {
  3360. $scope.my_data_after.push(item)
  3361. } else { }
  3362. })
  3363. }
  3364. //角色树
  3365. $scope.my_tree = [];
  3366. $scope.tree_data_after = [];
  3367. $scope.my_data = [];
  3368. $scope.my_data_after = [];
  3369. $scope.formdashboard = function (item) {
  3370. $scope.my_data_after = [];
  3371. angular.forEach(item, function (infox) {
  3372. if (infox.children.length == 0) {
  3373. $scope.my_data_after.push(infox);
  3374. }
  3375. })
  3376. $scope.mydatacate = angular.copy($scope.my_data_after);
  3377. }
  3378. $scope.ok = function (item) {
  3379. $modalInstance.close(item);
  3380. };
  3381. $scope.cancel = function () {
  3382. $modalInstance.dismiss('cancel');
  3383. };
  3384. },
  3385. // size: 'sm',
  3386. resolve: {
  3387. scope: function () {
  3388. return $scope;
  3389. }
  3390. }
  3391. });
  3392. modalInstance.result.then(function (selectedItem) {
  3393. // $rootScope.isMask = true;
  3394. if (selectedItem) {
  3395. var type = 1;
  3396. var fildat = {
  3397. 'configure': selectedItem
  3398. };
  3399. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  3400. // // if (data.errno == 0) {
  3401. // var file = new Blob([data], {
  3402. // // 'Accept': '*/*'
  3403. // type: 'application/octet-stream'
  3404. // // type: 'application/vnd.ms-excel'
  3405. // });
  3406. // //trick to download store a file having its URL
  3407. // var fileURL = URL.createObjectURL(file);
  3408. // var a = document.createElement('a');
  3409. // a.href = fileURL;
  3410. // a.target = '_blank';
  3411. // a.download = "资产导入模版.xlsx";
  3412. // document.body.appendChild(a);
  3413. // a.click();
  3414. // // }
  3415. // })
  3416. $http({
  3417. url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
  3418. method: 'POST',
  3419. data: JSON.stringify(fildat),
  3420. headers: {
  3421. // 'Content-type': 'application/xls',
  3422. 'Accept': '*/*'
  3423. },
  3424. responseType: 'arraybuffer'
  3425. }).success(function (data, status, headers, config) {
  3426. $rootScope.isMask = false;
  3427. var file = new Blob([data], {
  3428. type: 'application/octet-stream'
  3429. // type : 'application/vnd.ms-excel'
  3430. });
  3431. //trick to download store a file having its URL
  3432. var fileURL = URL.createObjectURL(file);
  3433. var a = document.createElement('a');
  3434. a.href = fileURL;
  3435. a.target = '_blank';
  3436. a.download = "资产导入模版.xlsx";
  3437. document.body.appendChild(a);
  3438. a.click();
  3439. }).error(function (data, status, headers, config) {
  3440. // console.log(data);
  3441. $rootScope.isMask = false;
  3442. });
  3443. // break;
  3444. // }
  3445. // }
  3446. // }
  3447. // })
  3448. } else {
  3449. SweetAlert.swal({
  3450. title: "未选择资产分类!",
  3451. text: "请选择资产分类",
  3452. type: "error"
  3453. }, function () {
  3454. $rootScope.isMask = false;
  3455. });
  3456. }
  3457. // }
  3458. });
  3459. }
  3460. $scope.wrongdata = [];
  3461. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3462. var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
  3463. $scope.importopen = function () { //导入触发事件
  3464. if (angular.isUndefined($scope.form.dropState)) {
  3465. $scope.form.dropState = false;
  3466. }
  3467. //附件上传数据
  3468. //$scope.options.templateOptions.uploader();
  3469. // FILTERS
  3470. uploader.filters.push({
  3471. name: 'customFilter',
  3472. fn: function (item /*{File|FileLikeObject}*/, options) {
  3473. return this.queue.length < 2;
  3474. }
  3475. });
  3476. // CALLBACKS
  3477. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  3478. console.info('onWhenAddingFileFailed', item, filter, options);
  3479. };
  3480. uploader.onAfterAddingFile = function (fileItem) {
  3481. console.info('onAfterAddingFile', fileItem);
  3482. };
  3483. uploader.onAfterAddingAll = function (addedFileItems) {
  3484. console.info('onAfterAddingAll', addedFileItems);
  3485. };
  3486. uploader.onBeforeUploadItem = function (item) {
  3487. console.info('onBeforeUploadItem', item);
  3488. };
  3489. uploader.onProgressItem = function (fileItem, progress) {
  3490. console.info('onProgressItem', fileItem, progress);
  3491. };
  3492. uploader.onProgressAll = function (progress) {
  3493. console.info('onProgressAll', progress);
  3494. };
  3495. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3496. // console.info('onSuccessItem', fileItem, response, status, headers);
  3497. // };
  3498. uploader.onErrorItem = function (fileItem, response, status, headers) {
  3499. console.info('onErrorItem', fileItem, response, status, headers);
  3500. };
  3501. uploader.onCancelItem = function (fileItem, response, status, headers) {
  3502. console.info('onCancelItem', fileItem, response, status, headers);
  3503. };
  3504. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  3505. console.info('onCompleteItem', fileItem, response, status, headers);
  3506. };
  3507. uploader.onCompleteAll = function () {
  3508. console.info('onCompleteAll');
  3509. };
  3510. }
  3511. // $scope.importnext = function() {
  3512. // $scope.state = 2;
  3513. // event.preventDefault();
  3514. // }
  3515. $scope.importnext = function () {
  3516. event.preventDefault();
  3517. // $rootScope.isMask = true;
  3518. $rootScope.loading = true;
  3519. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3520. uploader.onBeforeUploadItem = function (item) {
  3521. angular.extend(item.headers, $rootScope.getSession());
  3522. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3523. // if (item.index > 1) {
  3524. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3525. // }
  3526. // item.index = 1;
  3527. item.formData = [{
  3528. 'filename': item.file.name
  3529. }];
  3530. console.info('onBeforeUploadItem', item);
  3531. };
  3532. uploader.uploadAll();
  3533. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3534. if (response.status == 200) {
  3535. $scope.wrongdata = [];
  3536. $rootScope.loading = false;
  3537. if (response.abnormal) {
  3538. $scope.state = 2;
  3539. angular.forEach(response.msg, function (item) {
  3540. $scope.wrongdata.push({
  3541. 'name': item.assetName,
  3542. 'line': item.row,
  3543. 'cmdbname': item.name,
  3544. 'errotip': [{
  3545. 'label': item.msg
  3546. }]
  3547. })
  3548. })
  3549. } else {
  3550. $scope.state = 3;
  3551. }
  3552. } else {
  3553. $rootScope.loading = false;
  3554. $scope.state = 2;
  3555. }
  3556. }
  3557. }
  3558. $scope.clearItems = function () { //重新选择文件时,清空队列,达到覆盖文件的效果
  3559. uploader.clearQueue();
  3560. // uploader.remove();
  3561. // uploader.cancel();
  3562. // uploader.onChange();
  3563. }
  3564. uploader.onAfterAddingFile = function (fileItem) {
  3565. $scope.fileItem = fileItem._file;
  3566. // $scope.$apply();
  3567. // $scope.fileItem = filenum;
  3568. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  3569. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  3570. $scope.filenum++;
  3571. };
  3572. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3573. $scope.uploadStatus = true; //上传成功则把状态改为true
  3574. // alert(response.path);
  3575. };
  3576. $scope.importnext = function () {
  3577. event.preventDefault();
  3578. // uploader.onChange();
  3579. $rootScope.loading = true;
  3580. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3581. uploader.onBeforeUploadItem = function (item) {
  3582. angular.extend(item.headers, $rootScope.getSession());
  3583. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3584. // if (item.index > 1) {
  3585. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3586. // }
  3587. // item.index = 1;
  3588. item.formData = [{
  3589. 'filename': item.file.name
  3590. }];
  3591. console.info('onBeforeUploadItem', item);
  3592. };
  3593. uploader.uploadAll();
  3594. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3595. if (response.status == 200) {
  3596. $scope.wrongdata = [];
  3597. // uploader.queue = [];
  3598. $rootScope.loading = false;
  3599. if (response.abnormal) {
  3600. $scope.state = 2;
  3601. uploader.clearQueue();
  3602. angular.forEach(response.msg, function (item) {
  3603. $scope.wrongdata.push({
  3604. 'name': item.assetName,
  3605. 'line': item.row,
  3606. 'cmdbname': item.name,
  3607. 'errotip': [{
  3608. 'label': item.msg
  3609. }]
  3610. })
  3611. })
  3612. } else {
  3613. $scope.state = 3;
  3614. }
  3615. } else {
  3616. uploader.clearQueue();
  3617. $rootScope.loading = false;
  3618. $scope.state = 2;
  3619. }
  3620. }
  3621. }
  3622. var setAllInactive = function () {
  3623. angular.forEach($scope.workspaces, function (workspace) {
  3624. workspace.active = false;
  3625. });
  3626. };
  3627. //添加
  3628. var addNewWorkspace = function (name, contentUrl) {
  3629. var id = $scope.workspaces.length + 1;
  3630. $scope.workspaces.push({
  3631. id: id,
  3632. name: name,
  3633. active: true,
  3634. contentUrl: 'main/html/content.html'
  3635. });
  3636. };
  3637. //关闭
  3638. $scope.closeopen = function (closedata) {
  3639. event.preventDefault();
  3640. angular.forEach($scope.workspaces, function (item, index) {
  3641. if (closedata.id == item.id) {
  3642. if (closedata.id == 1) {
  3643. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  3644. } else {
  3645. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  3646. }
  3647. $scope.workspaces.splice(index, 1);
  3648. }
  3649. })
  3650. }
  3651. // $scope.workspaces = [
  3652. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  3653. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3654. // ];
  3655. $scope.addWorkspace = function (contentUrl, name) {
  3656. setAllInactive();
  3657. addNewWorkspace(name, contentUrl);
  3658. };
  3659. // $rootScope.addWorkspace = $scope.addWorkspace;
  3660. $scope.close = function (idNumber) {
  3661. var index = 0; //记录当前元素下标
  3662. angular.forEach($scope.workspaces, function (workspace) {
  3663. if (workspace.id === idNumber) {
  3664. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3665. }
  3666. index++;
  3667. });
  3668. };
  3669. //grid2
  3670. $scope.langs = i18nService.getAllLangs();
  3671. $scope.lang = 'zh-cn';
  3672. i18nService.setCurrentLang($scope.lang);
  3673. $scope.gridOptions2 = {};
  3674. $scope.gridOptions2.data = 'myData3';
  3675. $scope.gridOptions2.enableColumnResizing = true;
  3676. $scope.gridOptions2.enableFiltering = false;
  3677. $scope.gridOptions2.enableGridMenu = false;
  3678. $scope.gridOptions2.showGridFooter = true;
  3679. $scope.gridOptions2.showColumnFooter = false;
  3680. $scope.gridOptions2.fastWatch = true;
  3681. $scope.gridOptions2.useExternalFiltering = true;
  3682. $scope.gridOptions2.useExternalPagination = true;
  3683. $scope.gridOptions2.paginationPageSizes = [10];
  3684. $scope.gridOptions2.paginationPageSize = 10;
  3685. $scope.gridOptions2.multiSelect = false;
  3686. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  3687. $scope.gridOptions2.columnDefs = [{
  3688. name: 'item',
  3689. displayName: '序号',
  3690. width: 120
  3691. },
  3692. {
  3693. name: 'name',
  3694. displayName: '耗材名称',
  3695. width: 80,
  3696. enableFiltering: false
  3697. },
  3698. {
  3699. name: 'model',
  3700. displayName: '品牌/型号',
  3701. width: 100,
  3702. enableFiltering: false
  3703. },
  3704. {
  3705. name: 'Specifications',
  3706. displayName: '规格',
  3707. width: 150,
  3708. enableFiltering: false
  3709. },
  3710. {
  3711. name: 'sum',
  3712. displayName: '数量',
  3713. enableFiltering: false
  3714. },
  3715. {
  3716. name: '操作',
  3717. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3718. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  3719. '</div></div>',
  3720. enableFiltering: false
  3721. },
  3722. ];
  3723. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  3724. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  3725. $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
  3726. for (var i = 0; i < $scope.myData3all.length; i++) {
  3727. $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  3728. }
  3729. // $scope.model.consumables = $scope.myDataone;
  3730. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3731. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
  3732. $scope.model.applicationForm.consumables = $scope.myData3all;
  3733. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3734. $scope.options.templateOptions.getpush({
  3735. "hao": true,
  3736. "gu": true
  3737. });
  3738. } else {
  3739. $scope.options.templateOptions.getpush({
  3740. "hao": true
  3741. });
  3742. }
  3743. } else {
  3744. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3745. $scope.options.templateOptions.getpush({
  3746. "gu": true
  3747. });
  3748. }
  3749. }
  3750. }
  3751. $scope.options.templateOptions.workspaces = $scope.workspaces;
  3752. $scope.changecai = function (item) {
  3753. event.preventDefault();
  3754. var modalInstance = $modal.open({
  3755. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  3756. controller: function ($scope, $modalInstance) {
  3757. $scope.title = "修改耗材数量";
  3758. $scope.consumptive = angular.copy(item);
  3759. $scope.ok = function () {
  3760. $modalInstance.close($scope.consumptive);
  3761. };
  3762. $scope.cancel = function () {
  3763. $modalInstance.dismiss('cancel');
  3764. };
  3765. },
  3766. size: 'sm'
  3767. });
  3768. modalInstance.result.then(function (selectedItem) {
  3769. // angular.forEach($scope.myData3, function(items, index) {
  3770. // if (items.id == selectedItem.id) {
  3771. // $scope.myData3[index] = selectedItem;
  3772. // }
  3773. // })
  3774. // // $scope.myData3.push(selectedItem);
  3775. // $scope.model.applicationForm.consumables = $scope.myData3;
  3776. angular.forEach($scope.myData3all, function (items, index) {
  3777. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  3778. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  3779. angular.extend($scope.myData3all[index], selectedItem)
  3780. }
  3781. })
  3782. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3783. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3784. $scope.model.applicationForm.consumables = $scope.myData3all;
  3785. })
  3786. }
  3787. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  3788. $scope.gridApi = gridApi;
  3789. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  3790. // var filtersData = $scope.memoryfilterDatahao;
  3791. // filtersData.idx = newPage - 1;
  3792. // filtersData.sum = pageSize;
  3793. // $scope.loadData(filtersData);
  3794. $scope.memoryfilterDatahao.idx = newPage - 1;
  3795. $scope.memoryfilterDatahao.sum = pageSize;
  3796. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
  3797. });
  3798. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  3799. $scope.selected.items = data.entity;
  3800. //console.log(data);
  3801. });
  3802. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  3803. $scope.selected.items = data.entity;
  3804. //console.log(data);
  3805. });
  3806. gridApi.core.on.filterChanged($scope, function () {
  3807. var grid = this.grid;
  3808. var filtersData = {
  3809. idx: 0,
  3810. sum: 10,
  3811. };
  3812. $scope.memoryfilterDatahao = filtersData;
  3813. // $scope.loadData(filtersData);
  3814. // $scope.memoryfilterDatahao.idx = newPage - 1;
  3815. // $scope.memoryfilterDatahao.sum = pageSize;
  3816. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3817. });
  3818. };
  3819. $scope.haocaiopen = function (items) {
  3820. event.preventDefault();
  3821. var modalInstance = $modal.open({
  3822. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3823. controller: function ($scope, $modalInstance, SweetAlert) {
  3824. $scope.consumptive = {};
  3825. $scope.title = "新增耗材";
  3826. if (items.name) {
  3827. $scope.consumptive.name = items.name.name;
  3828. }
  3829. $scope.clearNoNum = function (obj, attr) {
  3830. //先把非数字的都替换掉,除了数字和.
  3831. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3832. //必须保证第一个为数字而不是.
  3833. obj[attr] = obj[attr].replace(/^\./g, "");
  3834. //保证只有出现一个.而没有多个.
  3835. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3836. //保证.只出现一次,而不能出现两次以上
  3837. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3838. //小于最大值
  3839. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3840. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3841. // obj[attr] = '';
  3842. // }
  3843. }
  3844. $scope.ok = function (item) {
  3845. // if (item.name && item.model && item.Specifications && item.sum) {
  3846. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3847. $modalInstance.close(item);
  3848. } else {
  3849. SweetAlert.swal({
  3850. title: "数据填写不完整!",
  3851. text: "请检查数据然后提交!",
  3852. type: "error"
  3853. });
  3854. }
  3855. };
  3856. $scope.cancel = function () {
  3857. $modalInstance.dismiss('cancel');
  3858. };
  3859. },
  3860. size: 'sm',
  3861. resolve: {
  3862. SweetAlert: function () {
  3863. return SweetAlert;
  3864. }
  3865. }
  3866. });
  3867. modalInstance.result.then(function (selectedItem) {
  3868. api_sysinfo.addData('dictionaryTree', {
  3869. // "type": "list",
  3870. "key": "haocaifenlei",
  3871. "name": selectedItem.name,
  3872. "parent": selectedItem.id,
  3873. "value": selectedItem.name,
  3874. "deleted": false,
  3875. "level": 1
  3876. }).then(function (data) {
  3877. // $scope.haocainame.name = data.list;
  3878. api_sysinfo.addData('dictionaryTree', {
  3879. // "type": "list",
  3880. "key": "pinpai",
  3881. "name": selectedItem.model,
  3882. "parent": data.id,
  3883. "value": selectedItem.model,
  3884. "deleted": false,
  3885. "level": 2
  3886. }).then(function (data) {
  3887. // $scope.haocainame = data.list;
  3888. })
  3889. api_sysinfo.addData({
  3890. // "type": "list",
  3891. "key": "guige",
  3892. "name": selectedItem.Specifications,
  3893. "parent": data.id,
  3894. "value": selectedItem.Specifications,
  3895. "deleted": false,
  3896. "level": 2
  3897. }).then(function (data) {
  3898. // $scope.haocainame = data.list;
  3899. })
  3900. })
  3901. // $scope.myData3.push(selectedItem);
  3902. // for (var i = 0; i < $scope.myData3.length; i++) {
  3903. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3904. // }
  3905. // $scope.model.applicationForm.consumables = $scope.myData3;
  3906. $scope.myData3all.push(selectedItem);
  3907. for (var i = 0; i < $scope.myData3all.length; i++) {
  3908. $scope.myData3all[i]['item'] = i + 1
  3909. }
  3910. // $scope.model.consumables = $scope.myDataone;
  3911. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3912. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3913. $scope.model.applicationForm.consumables = $scope.myData3all;
  3914. })
  3915. }
  3916. $scope.haocaiadd = function () {
  3917. event.preventDefault();
  3918. var modalInstance = $modal.open({
  3919. templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
  3920. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  3921. $scope.haocainame = [];
  3922. $scope.pinpai = [];
  3923. $scope.guige = [];
  3924. $scope.consumptive = {};
  3925. $scope.consumpall = {};
  3926. $scope.title = "添加耗材";
  3927. api_wechatfile.getDictionary({
  3928. "key": "haocaifenlei",
  3929. "type": "tree"
  3930. }).then(function (data) {
  3931. $scope.haocainame = data;
  3932. })
  3933. $scope.clearNoNum = function (obj, attr) {
  3934. //先把非数字的都替换掉,除了数字和.
  3935. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3936. //必须保证第一个为数字而不是.
  3937. obj[attr] = obj[attr].replace(/^\./g, "");
  3938. //保证只有出现一个.而没有多个.
  3939. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3940. //保证.只出现一次,而不能出现两次以上
  3941. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3942. //小于最大值
  3943. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3944. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3945. // obj[attr] = '';
  3946. // }
  3947. }
  3948. $scope.onChange = function (parent) {
  3949. $scope.consumptive.model = {};
  3950. $scope.consumptive.Specifications = {};
  3951. api_wechatfile.getDictionaryForList({
  3952. "key": "pinpai",
  3953. "parent": parent.id
  3954. }).then(function (data) {
  3955. $scope.pinpai = data;
  3956. })
  3957. api_wechatfile.getDictionaryForList({
  3958. "key": "guige",
  3959. "parent": parent.id
  3960. }).then(function (data) {
  3961. $scope.guige = data;
  3962. })
  3963. }
  3964. $scope.addhaocai = function () {
  3965. $modalInstance.dismiss('cancel');
  3966. scope.haocaiopen($scope.consumptive);
  3967. }
  3968. $scope.ok = function (item) {
  3969. var items = {};
  3970. var submittrue = true;
  3971. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3972. items = {
  3973. "modelid": item.model.id,
  3974. "nameid": item.name.id,
  3975. "Specificationsid": item.Specifications.id,
  3976. "name": item.name.name,
  3977. "model": item.model.name,
  3978. "Specifications": item.Specifications.name,
  3979. "sum": item.sum
  3980. }
  3981. angular.forEach(scope.myData3all, function (itemsdata) {
  3982. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  3983. submittrue = false;
  3984. }
  3985. })
  3986. if (submittrue) {
  3987. $modalInstance.close(items);
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "该耗材已有添加",
  3991. text: "请检查数据然后提交!",
  3992. type: "error"
  3993. });
  3994. }
  3995. } else {
  3996. SweetAlert.swal({
  3997. title: "数据填写不完整!",
  3998. text: "请检查数据然后提交!",
  3999. type: "error"
  4000. });
  4001. }
  4002. // var isold = false;
  4003. // if (item.name && item.model && item.Specifications && item.sum) {
  4004. // for (var i = 0; i < scope.myData3all.length; i++) {
  4005. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4006. // isold = true;
  4007. // }
  4008. // }
  4009. // if (isold) {
  4010. // SweetAlert.swal({
  4011. // title: "该耗材已添加!",
  4012. // text: "请不要重复添加耗材!",
  4013. // type: "error"
  4014. // });
  4015. // } else {
  4016. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4017. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4018. // $scope.consumpall.sum = item.sum;
  4019. // delete $scope.consumpall.brandModel;
  4020. // delete $scope.consumpall.specification;
  4021. // $modalInstance.close($scope.consumpall);
  4022. // }
  4023. // } else {
  4024. // SweetAlert.swal({
  4025. // title: "数据填写不完整!",
  4026. // text: "请检查数据然后提交!",
  4027. // type: "error"
  4028. // });
  4029. // }
  4030. };
  4031. $scope.cancel = function () {
  4032. $modalInstance.dismiss('cancel');
  4033. };
  4034. },
  4035. size: 'sm',
  4036. resolve: {
  4037. scope: function () {
  4038. return $scope;
  4039. }
  4040. }
  4041. });
  4042. modalInstance.result.then(function (selectedItem) {
  4043. $scope.myData3all.push(selectedItem);
  4044. for (var i = 0; i < $scope.myData3all.length; i++) {
  4045. $scope.myData3all[i]['item'] = i + 1
  4046. }
  4047. // $scope.model.consumables = $scope.myDataone;
  4048. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  4049. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  4050. $scope.model.applicationForm.consumables = $scope.myData3all;
  4051. })
  4052. }
  4053. $scope.onDblClick = function (data, event) {
  4054. $scope.selectButtonClick(data, event);
  4055. };
  4056. // $scope.memoryfilterDatahao = {
  4057. // "idx": 0,
  4058. // "sum": 10,
  4059. // }
  4060. // $scope.loadData = function(filterData) {};
  4061. // $scope.title = title;
  4062. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4063. $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
  4064. }
  4065. }]
  4066. });
  4067. //归还设备耗材tab
  4068. formlyConfigProvider.setType({
  4069. name: 'ui-cmdbreturntab',
  4070. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
  4071. wrapper: ['bootstrapHasError'],
  4072. defaultOptions: function (options, $scope) {
  4073. return {
  4074. templateOptions: {
  4075. // checkform: function(options) {
  4076. // if (options.model.requester) {
  4077. // options.value(options.model.requester);
  4078. // }
  4079. // },
  4080. }
  4081. };
  4082. },
  4083. controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function ($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
  4084. var setAllInactive = function () {
  4085. angular.forEach($scope.workspaces, function (workspace) {
  4086. workspace.active = false;
  4087. });
  4088. };
  4089. $scope.memoryfilterData = {
  4090. "idx": 0,
  4091. "sum": 10,
  4092. }
  4093. //添加
  4094. var addNewWorkspace = function (name, contentUrl) {
  4095. var id = $scope.workspaces.length + 1;
  4096. $scope.workspaces.push({
  4097. id: id,
  4098. name: name,
  4099. active: true,
  4100. contentUrl: 'main/html/content.html'
  4101. });
  4102. };
  4103. $scope.workspaces = [{
  4104. id: 1,
  4105. name: "归还设备",
  4106. active: true,
  4107. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4108. },
  4109. {
  4110. id: 2,
  4111. name: "归还耗材",
  4112. active: true,
  4113. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4114. }
  4115. ];
  4116. $scope.addWorkspace = function (contentUrl, name) {
  4117. setAllInactive();
  4118. addNewWorkspace(name, contentUrl);
  4119. };
  4120. // $rootScope.addWorkspace = $scope.addWorkspace;
  4121. $scope.close = function (idNumber) {
  4122. var index = 0; //记录当前元素下标
  4123. angular.forEach($scope.workspaces, function (workspace) {
  4124. if (workspace.id === idNumber) {
  4125. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4126. }
  4127. index++;
  4128. });
  4129. };
  4130. $scope.memoryfilterDataguishe = {
  4131. "idx": 0,
  4132. "sum": 10,
  4133. }
  4134. //grid1
  4135. $scope.langs = i18nService.getAllLangs();
  4136. $scope.lang = 'zh-cn';
  4137. i18nService.setCurrentLang($scope.lang);
  4138. $scope.gridOptions1 = {};
  4139. $scope.gridOptions1.data = 'myData1';
  4140. $scope.gridOptions1.enableColumnResizing = true;
  4141. $scope.gridOptions1.enableFiltering = false;
  4142. $scope.gridOptions1.enableGridMenu = false;
  4143. $scope.gridOptions1.showGridFooter = true;
  4144. $scope.gridOptions1.showColumnFooter = false;
  4145. $scope.gridOptions1.fastWatch = true;
  4146. $scope.gridOptions1.useExternalFiltering = true;
  4147. $scope.gridOptions1.useExternalPagination = true;
  4148. $scope.gridOptions1.paginationPageSizes = [10];
  4149. $scope.gridOptions1.paginationPageSize = 10;
  4150. $scope.gridOptions1.multiSelect = false;
  4151. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4152. $scope.gridOptions1.columnDefs = [{
  4153. name: 'item',
  4154. displayName: '序号',
  4155. width: 120
  4156. },
  4157. {
  4158. name: 'props.hw_cifilterClassic',
  4159. displayName: '设备类型',
  4160. width: 150,
  4161. enableFiltering: false
  4162. },
  4163. {
  4164. name: 'props.hw_mingcheng',
  4165. displayName: '设备名称',
  4166. width: 180,
  4167. enableFiltering: false
  4168. },
  4169. {
  4170. name: 'uuid',
  4171. displayName: '设备编号',
  4172. width: 180,
  4173. enableFiltering: false
  4174. },
  4175. {
  4176. name: 'props.hw_state',
  4177. width: 150,
  4178. displayName: '状态',
  4179. enableFiltering: false
  4180. },
  4181. {
  4182. name: '操作',
  4183. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4184. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  4185. '</div></div>',
  4186. enableFiltering: false
  4187. },
  4188. ];
  4189. // $scope.selectButtonClick
  4190. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4191. $scope.gridApi = gridApi;
  4192. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4193. // var filtersData = $scope.memoryfilterData;
  4194. // filtersData.idx = newPage - 1;
  4195. // filtersData.sum = pageSize;
  4196. // $scope.loadData(filtersData);
  4197. $scope.memoryfilterDataguishe.idx = newPage - 1;
  4198. $scope.memoryfilterDataguishe.sum = pageSize;
  4199. $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
  4200. });
  4201. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4202. $scope.selected.items = data.entity;
  4203. //console.log(data);
  4204. });
  4205. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4206. $scope.selected.items = data.entity;
  4207. //console.log(data);
  4208. });
  4209. gridApi.core.on.filterChanged($scope, function () {
  4210. // var grid = this.grid;
  4211. // var filtersData = {
  4212. // idx: 0,
  4213. // sum: 20,
  4214. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4215. // };
  4216. // angular.forEach(grid.columns, function(item) {
  4217. // if (item.enableFiltering) {
  4218. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4219. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4220. // if (angular.isUndefined(filtersData['user'])) {
  4221. // filtersData['user'] = {};
  4222. // }
  4223. // filtersData['user'][item.field] = item.filters[0].term;
  4224. // }
  4225. // }
  4226. // });
  4227. // $scope.memoryfilterData = filtersData;
  4228. // $scope.loadData(filtersData);
  4229. });
  4230. };
  4231. $scope.changegu = function (item) {
  4232. event.preventDefault();
  4233. var modalInstance = $modal.open({
  4234. templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
  4235. controller: function ($scope, $modalInstance) {
  4236. $scope.title = "修改设备状态";
  4237. $scope.hw_state = {};;
  4238. if (item.status) {
  4239. $scope.hw_state.name = item.hw_state;
  4240. }
  4241. // $scope.consumptive = item;
  4242. $scope.stateshe = [{
  4243. "id": 2,
  4244. "name": "在库"
  4245. }, {
  4246. "id": 4,
  4247. "name": "报修"
  4248. }, {
  4249. "id": 3,
  4250. "name": "报废"
  4251. }]
  4252. $scope.ok = function (item) {
  4253. $modalInstance.close($scope.hw_state);
  4254. };
  4255. $scope.cancel = function () {
  4256. $modalInstance.dismiss('cancel');
  4257. };
  4258. },
  4259. size: 'sm'
  4260. });
  4261. modalInstance.result.then(function (selectedItem) {
  4262. angular.forEach($scope.myData1, function (items, index) {
  4263. if (items.id == item.id) {
  4264. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  4265. }
  4266. })
  4267. $scope.model.assets = $scope.myData1;
  4268. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
  4269. })
  4270. }
  4271. $scope.onDblClick = function (data, event) {
  4272. $scope.selectButtonClick(data, event);
  4273. };
  4274. $scope.memoryfilterData = {
  4275. "idx": 0,
  4276. "sum": 10,
  4277. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4278. }
  4279. // $scope.myData = {};
  4280. $scope.loadData = function (filterData) { };
  4281. // $scope.title = title;
  4282. $scope.loadData({
  4283. idx: 0,
  4284. sum: 10,
  4285. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4286. });
  4287. $scope.selected = {
  4288. items: []
  4289. };
  4290. $scope.myData2 = [];
  4291. $scope.consumptive = {};
  4292. $scope.myDataguibeiall = [];
  4293. $scope.haocaiopen = function (items) {
  4294. event.preventDefault();
  4295. var modalInstance = $modal.open({
  4296. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  4297. controller: function ($scope, $modalInstance, SweetAlert, api_wechatfile, api_sysinfo) {
  4298. $scope.consumptive = {};
  4299. $scope.title = "新增耗材";
  4300. if (items.name) {
  4301. $scope.consumptive.name = items.name.name;
  4302. }
  4303. $scope.ok = function (item) {
  4304. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4305. $modalInstance.close(item);
  4306. } else {
  4307. SweetAlert.swal({
  4308. title: "数据填写不完整!",
  4309. text: "请检查数据然后提交!",
  4310. type: "error"
  4311. });
  4312. }
  4313. };
  4314. $scope.cancel = function () {
  4315. $modalInstance.dismiss('cancel');
  4316. };
  4317. },
  4318. size: 'sm'
  4319. });
  4320. modalInstance.result.then(function (selectedItem) {
  4321. api_sysinfo.addData({
  4322. "type": "list",
  4323. "key": "haocaifenlei",
  4324. "name": selectedItem.name,
  4325. "parent": selectedItem.id,
  4326. "value": "1"
  4327. }).then(function (data) {
  4328. // $scope.haocainame.name = data.list;
  4329. api_wechatfile.addDictionary({
  4330. "type": "list",
  4331. "key": "pinpai",
  4332. "name": selectedItem.model,
  4333. "parent": data.id,
  4334. "value": "1"
  4335. }).then(function (data) {
  4336. // $scope.haocainame = data.list;
  4337. })
  4338. api_wechatfile.addDictionary({
  4339. "type": "list",
  4340. "key": "guige",
  4341. "name": selectedItem.Specifications,
  4342. "parent": data.id,
  4343. "value": "1"
  4344. }).then(function (data) {
  4345. // $scope.haocainame = data.list;
  4346. })
  4347. })
  4348. $scope.myData2.push(selectedItem);
  4349. for (var i = 0; i < $scope.myData2.length; i++) {
  4350. $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4351. }
  4352. // $scope.model.applicationForm.consumables = $scope.myData2;
  4353. angular.forEach($scope.myDataguibeiall, function (items, index) {
  4354. if (items.id == selectedItem.id) {
  4355. $scope.myDataguibeiall.splice(index, 1);
  4356. }
  4357. })
  4358. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
  4359. $scope.model.consumables = $scope.myDataguibeiall;
  4360. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4361. $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
  4362. })
  4363. }
  4364. //grid2
  4365. $scope.langs = i18nService.getAllLangs();
  4366. $scope.lang = 'zh-cn';
  4367. i18nService.setCurrentLang($scope.lang);
  4368. $scope.gridOptions2 = {};
  4369. $scope.gridOptions2.data = 'myData2';
  4370. $scope.gridOptions2.enableColumnResizing = true;
  4371. $scope.gridOptions2.enableFiltering = false;
  4372. $scope.gridOptions2.enableGridMenu = false;
  4373. $scope.gridOptions2.showGridFooter = true;
  4374. $scope.gridOptions2.showColumnFooter = false;
  4375. $scope.gridOptions2.fastWatch = true;
  4376. $scope.gridOptions2.useExternalFiltering = true;
  4377. $scope.gridOptions2.useExternalPagination = true;
  4378. $scope.gridOptions2.paginationPageSizes = [10];
  4379. $scope.gridOptions2.paginationPageSize = 10;
  4380. $scope.gridOptions2.multiSelect = false;
  4381. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4382. $scope.modelcons = {};
  4383. $scope.modelass = {};
  4384. $scope.myData2all = [];
  4385. $scope.myData1all = [];
  4386. $scope.memoryfilterDatagui = {
  4387. "idx": 0,
  4388. "sum": 10
  4389. }
  4390. setInterval(function () {
  4391. if ($scope.model.assets) {
  4392. if ($scope.model.assets != $scope.modelass && typeof ($scope.model.assets) == 'string') {
  4393. $scope.modelass = $scope.model.assets;
  4394. if (JSON.stringify($scope.model.assets) == "{}") {
  4395. $scope.model.assets = []
  4396. } else {
  4397. $scope.model.assets = JSON.parse($scope.model.assets);
  4398. }
  4399. // $scope.myData1 = $scope.model.assets;
  4400. // for (var i = 0; i < $scope.myData1.length; i++) {
  4401. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4402. // }
  4403. $scope.myData1all = $scope.model.assets;
  4404. for (var i = 0; i < $scope.myData1all.length; i++) {
  4405. $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4406. }
  4407. $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
  4408. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
  4409. }
  4410. }
  4411. if ($scope.model.consumables) {
  4412. if ($scope.model.consumables != $scope.modelcons && typeof ($scope.model.consumables) == 'string') {
  4413. $scope.modelass = $scope.model.consumables;
  4414. if (JSON.stringify($scope.model.consumables) == "{}") {
  4415. $scope.model.consumables = [];
  4416. } else {
  4417. $scope.model.consumables = JSON.parse($scope.model.consumables);
  4418. }
  4419. // $scope.myData2 = $scope.model.consumables;
  4420. // for (var i = 0; i < $scope.myData2.length; i++) {
  4421. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4422. // }
  4423. $scope.myData2all = $scope.model.consumables;
  4424. for (var i = 0; i < $scope.myData2all.length; i++) {
  4425. $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4426. }
  4427. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4428. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
  4429. // $scope.model.consumables = $scope.myData2all;
  4430. }
  4431. }
  4432. }, 100);
  4433. $scope.gridOptions2.columnDefs = [{
  4434. name: 'item',
  4435. displayName: '序号',
  4436. width: 120
  4437. },
  4438. {
  4439. name: 'name',
  4440. displayName: '耗材名称',
  4441. width: 180,
  4442. enableFiltering: false
  4443. },
  4444. {
  4445. name: 'model',
  4446. displayName: '品牌/型号',
  4447. width: 180,
  4448. enableFiltering: false
  4449. },
  4450. {
  4451. name: 'Specifications',
  4452. displayName: '规格',
  4453. width: 150,
  4454. enableFiltering: false
  4455. },
  4456. {
  4457. name: 'sum',
  4458. width: 150,
  4459. displayName: '数量',
  4460. enableFiltering: false
  4461. },
  4462. {
  4463. name: '操作',
  4464. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4465. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4466. '</div></div>',
  4467. enableFiltering: false
  4468. },
  4469. ];
  4470. // $scope.selectButtonClick
  4471. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4472. $scope.gridApi = gridApi;
  4473. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4474. // var filtersData = $scope.memoryfilterDatagui;
  4475. // filtersData.idx = newPage - 1;
  4476. // filtersData.sum = pageSize;
  4477. $scope.memoryfilterDatagui.idx = newPage - 1;
  4478. $scope.memoryfilterDatagui.sum = pageSize;
  4479. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4480. });
  4481. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4482. $scope.selected.items = data.entity;
  4483. //console.log(data);
  4484. });
  4485. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4486. $scope.selected.items = data.entity;
  4487. //console.log(data);
  4488. });
  4489. gridApi.core.on.filterChanged($scope, function () {
  4490. var grid = this.grid;
  4491. var filtersData = {
  4492. idx: 0,
  4493. sum: 10,
  4494. };
  4495. angular.forEach(grid.columns, function (item) {
  4496. if (item.enableFiltering) {
  4497. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4498. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4499. if (angular.isUndefined(filtersData['user'])) {
  4500. filtersData['user'] = {};
  4501. }
  4502. filtersData['user'][item.field] = item.filters[0].term;
  4503. }
  4504. }
  4505. });
  4506. $scope.memoryfilterData = filtersData;
  4507. $scope.loadData(filtersData);
  4508. });
  4509. };
  4510. $scope.changecai = function (item) {
  4511. event.preventDefault();
  4512. var modalInstance = $modal.open({
  4513. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4514. controller: function ($scope, $modalInstance) {
  4515. $scope.title = "修改耗材数量";
  4516. $scope.consumptive = angular.copy(item);
  4517. // $scope.consumptive = item;
  4518. $scope.maxsum = item.inventoryNum;
  4519. $scope.clearNoNum = function (obj, attr) {
  4520. //先把非数字的都替换掉,除了数字和.
  4521. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4522. //必须保证第一个为数字而不是.
  4523. obj[attr] = obj[attr].replace(/^\./g, "");
  4524. //保证只有出现一个.而没有多个.
  4525. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4526. //保证.只出现一次,而不能出现两次以上
  4527. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4528. //小于最大值
  4529. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4530. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4531. // obj[attr] = '';
  4532. // }
  4533. }
  4534. $scope.ok = function () {
  4535. $modalInstance.close($scope.consumptive);
  4536. };
  4537. $scope.cancel = function () {
  4538. $modalInstance.dismiss('cancel');
  4539. };
  4540. },
  4541. size: 'sm'
  4542. });
  4543. modalInstance.result.then(function (selectedItem) {
  4544. angular.forEach($scope.myData2all, function (items, index) {
  4545. // if (items.id == selectedItem.id) {
  4546. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  4547. angular.extend($scope.myData2all[index], selectedItem)
  4548. }
  4549. })
  4550. // $scope.model.consumables = $scope.myData2;
  4551. // $scope.myData2 = $scope.model.consumables;
  4552. // $scope.myData2all.push(selectedItem);
  4553. // for (var i = 0; i < $scope.myData2all.length; i++) {
  4554. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4555. // }
  4556. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4557. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4558. $scope.model.consumables = $scope.myData2all;
  4559. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4560. })
  4561. }
  4562. $scope.interceptMydata = function (mydate, idx, sum) {
  4563. return mydate.slice(idx * sum, (idx + 1) * sum)
  4564. }
  4565. $scope.haocaiadd = function () {
  4566. event.preventDefault();
  4567. var modalInstance = $modal.open({
  4568. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  4569. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
  4570. $scope.haocainame = [];
  4571. $scope.pinpai = [];
  4572. $scope.guige = [];
  4573. $scope.consumptive = {};
  4574. $scope.consumptiveall = {};
  4575. $scope.title = "添加耗材";
  4576. api_wechatfile.getDictionaryForList({
  4577. "key": "haocaifenlei"
  4578. }).then(function (data) {
  4579. $scope.haocainame = data;
  4580. })
  4581. $scope.clearNoNum = function (obj, attr) {
  4582. //先把非数字的都替换掉,除了数字和.
  4583. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4584. //必须保证第一个为数字而不是.
  4585. obj[attr] = obj[attr].replace(/^\./g, "");
  4586. //保证只有出现一个.而没有多个.
  4587. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4588. //保证.只出现一次,而不能出现两次以上
  4589. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4590. //小于最大值
  4591. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4592. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4593. obj[attr] = '';
  4594. }
  4595. }
  4596. $scope.onChange = function (parent) {
  4597. $scope.consumptive.model = {};
  4598. $scope.consumptive.Specifications = {};
  4599. api_wechatfile.getDictionaryForList({
  4600. "key": "pinpai",
  4601. "parent": parent.id
  4602. }).then(function (data) {
  4603. $scope.pinpai = data;
  4604. })
  4605. api_wechatfile.getDictionaryForList({
  4606. "key": "guige",
  4607. "parent": parent.id
  4608. }).then(function (data) {
  4609. $scope.guige = data;
  4610. })
  4611. }
  4612. // $scope.onChangesum = function(item) {
  4613. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  4614. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  4615. // $scope.consumptiveall = data1;
  4616. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  4617. // // if (data.list && data.list.length != 0) {
  4618. // // var myData = data.list;
  4619. // // $scope.consumptiveall = myData[0];
  4620. // // $scope.maxsum = myData[0].inventoryNum;
  4621. // // } else if (data.list && data.list.length == 0) {
  4622. // // SweetAlert.swal({
  4623. // // title: "库存数据存在问题!",
  4624. // // text: "请检查库存数据!",
  4625. // // type: "error"
  4626. // // });
  4627. // // }
  4628. // // });
  4629. // }
  4630. // }
  4631. $scope.addhaocai = function () {
  4632. $modalInstance.dismiss('cancel');
  4633. scope.haocaiopen($scope.consumptive);
  4634. }
  4635. $scope.ok = function (item) {
  4636. var submittrue = true;
  4637. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4638. var data = {
  4639. "modelid": item.model.id,
  4640. "nameid": item.name.id,
  4641. "Specificationsid": item.Specifications.id,
  4642. "name": item.name.name,
  4643. "model": item.model.name,
  4644. "Specifications": item.Specifications.name,
  4645. "sum": item.sum
  4646. }
  4647. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4648. // $modalInstance.close(data);
  4649. angular.forEach(scope.myData2all, function (itemsdata) {
  4650. // if (item.model.id == itemsdata.id) {
  4651. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  4652. submittrue = false;
  4653. }
  4654. })
  4655. if (submittrue) {
  4656. $modalInstance.close(data);
  4657. } else {
  4658. SweetAlert.swal({
  4659. title: "该耗材已有添加",
  4660. text: "请检查数据然后提交!",
  4661. type: "error"
  4662. });
  4663. }
  4664. } else {
  4665. SweetAlert.swal({
  4666. title: "数据填写不完整!",
  4667. text: "请检查数据然后提交!",
  4668. type: "error"
  4669. });
  4670. }
  4671. };
  4672. $scope.cancel = function () {
  4673. $modalInstance.dismiss('cancel');
  4674. };
  4675. },
  4676. size: 'sm',
  4677. resolve: {
  4678. scope: function () {
  4679. return $scope;
  4680. }
  4681. }
  4682. });
  4683. modalInstance.result.then(function (selectedItem) {
  4684. // $scope.myData2.push(selectedItem);
  4685. // for (var i = 0; i < $scope.myData2.length; i++) {
  4686. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4687. // }
  4688. // $scope.model.consumables = $scope.myData2;
  4689. $scope.myData2all.push(selectedItem);
  4690. for (var i = 0; i < $scope.myData2all.length; i++) {
  4691. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4692. $scope.myData2all[i]['item'] = i + 1
  4693. }
  4694. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4695. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4696. $scope.model.consumables = $scope.myData2all;
  4697. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4698. })
  4699. }
  4700. $scope.onDblClick = function (data, event) {
  4701. $scope.selectButtonClick(data, event);
  4702. };
  4703. $scope.memoryfilterData = {
  4704. "idx": 0,
  4705. "sum": 20,
  4706. "user": {
  4707. "roledata": {
  4708. "rolecode": "roleset"
  4709. },
  4710. "selectType": "1"
  4711. }
  4712. }
  4713. $scope.myData = {};
  4714. $scope.loadData = function (filterData) { };
  4715. // $scope.title = title;
  4716. $scope.loadData({
  4717. idx: 0,
  4718. sum: 20,
  4719. "user": {
  4720. "roledata": {
  4721. "rolecode": "roleset"
  4722. },
  4723. "selectType": "1"
  4724. }
  4725. });
  4726. $scope.selected = {
  4727. items: {}
  4728. };
  4729. }]
  4730. });
  4731. //tab 列表
  4732. formlyConfigProvider.setType({
  4733. name: 'ui-cmdbtab',
  4734. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
  4735. wrapper: ['bootstrapHasError'],
  4736. defaultOptions: function (options, $scope) {
  4737. return {
  4738. templateOptions: {}
  4739. };
  4740. },
  4741. controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  4742. $scope.memoryfilterDatashe = {
  4743. "idx": 0,
  4744. "sum": 10
  4745. }
  4746. $scope.myDataoneall = [];
  4747. var setAllInactive = function () {
  4748. angular.forEach($scope.workspaces, function (workspace) {
  4749. workspace.active = false;
  4750. });
  4751. };
  4752. //添加
  4753. var addNewWorkspace = function (name, contentUrl) {
  4754. var id = $scope.workspaces.length + 1;
  4755. $scope.workspaces.push({
  4756. id: id,
  4757. name: name,
  4758. active: true,
  4759. contentUrl: 'main/html/content.html'
  4760. });
  4761. };
  4762. //关闭
  4763. $scope.remove = function (closedata) {
  4764. event.preventDefault();
  4765. angular.forEach($scope.workspaces, function (item, index) {
  4766. if (closedata.id == item.id) {
  4767. if (closedata.id == 1) {
  4768. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  4769. } else {
  4770. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  4771. }
  4772. $scope.workspaces.splice(index, 1);
  4773. }
  4774. })
  4775. }
  4776. $scope.workspaces = [];
  4777. $scope.options.templateOptions.getpush = function (item) {
  4778. $scope.workspaces = [];
  4779. if (item.gu) {
  4780. $scope.workspaces.push({
  4781. id: 1,
  4782. name: "领用设备",
  4783. active: true,
  4784. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4785. })
  4786. }
  4787. if (item.hao) {
  4788. $scope.workspaces.push({
  4789. id: 2,
  4790. name: "领用耗材",
  4791. active: true,
  4792. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4793. })
  4794. }
  4795. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4796. };
  4797. $scope.addWorkspace = function (contentUrl, name) {
  4798. setAllInactive();
  4799. addNewWorkspace(name, contentUrl);
  4800. };
  4801. // $rootScope.addWorkspace = $scope.addWorkspace;
  4802. // $scope.remove = function(idNumber) {
  4803. // var index = 0; //记录当前元素下标
  4804. // angular.forEach($scope.workspaces, function(workspace) {
  4805. // if (workspace.id === idNumber.id) {
  4806. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4807. // }
  4808. // index++;
  4809. // });
  4810. // };
  4811. // setInterval(function() {
  4812. // if ($scope.model.assets) {
  4813. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4814. // $scope.modelass = $scope.model.assets;
  4815. // if (JSON.stringify($scope.model.assets) == "{}") {
  4816. // $scope.model.assets = []
  4817. // } else {
  4818. // $scope.model.assets = JSON.parse($scope.model.assets);
  4819. // }
  4820. // $scope.myDatalingbeiall = $scope.model.assets;
  4821. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4822. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4823. // }
  4824. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4825. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4826. // }
  4827. // }
  4828. // if ($scope.model.consumables) {
  4829. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4830. // $scope.modelass = $scope.model.consumables;
  4831. // if (JSON.stringify($scope.model.consumables) == "{}") {
  4832. // $scope.model.consumables = [];
  4833. // } else {
  4834. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  4835. // }
  4836. // $scope.myDatalingbeiall = $scope.model.consumables;
  4837. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4838. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4839. // }
  4840. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  4841. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4842. // // $scope.model.consumables = $scope.myData2all;
  4843. // }
  4844. // }
  4845. // }, 100);
  4846. //grid1
  4847. $scope.langs = i18nService.getAllLangs();
  4848. $scope.lang = 'zh-cn';
  4849. i18nService.setCurrentLang($scope.lang);
  4850. $scope.gridOptions1 = {};
  4851. $scope.gridOptions1.data = 'myDatalingbei';
  4852. $scope.gridOptions1.enableColumnResizing = true;
  4853. $scope.gridOptions1.enableFiltering = false;
  4854. $scope.gridOptions1.enableGridMenu = false;
  4855. $scope.gridOptions1.showGridFooter = true;
  4856. $scope.gridOptions1.showColumnFooter = false;
  4857. $scope.gridOptions1.fastWatch = true;
  4858. $scope.gridOptions1.useExternalFiltering = true;
  4859. $scope.gridOptions1.useExternalPagination = true;
  4860. $scope.gridOptions1.paginationPageSizes = [10];
  4861. $scope.gridOptions1.paginationPageSize = 10;
  4862. $scope.gridOptions1.multiSelect = false;
  4863. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4864. $scope.gridOptions1.columnDefs = [{
  4865. name: 'item',
  4866. displayName: '序号',
  4867. width: 120
  4868. },
  4869. {
  4870. name: 'props.hw_cifilterClassic',
  4871. displayName: '设备类型',
  4872. width: 150,
  4873. enableFiltering: false
  4874. },
  4875. {
  4876. name: 'props.hw_mingcheng',
  4877. displayName: '设备名称',
  4878. width: 100,
  4879. enableFiltering: false
  4880. },
  4881. {
  4882. name: 'uuid',
  4883. displayName: '设备编号',
  4884. enableFiltering: false
  4885. }
  4886. ];
  4887. $scope.myDatalingbeiall = [];
  4888. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4889. $scope.gridApi = gridApi;
  4890. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4891. // var filtersData = $scope.memoryfilterData;
  4892. // filtersData.idx = newPage - 1;
  4893. // filtersData.sum = pageSize;
  4894. // $scope.loadData(filtersData);
  4895. $scope.memoryfilterDatashe.idx = newPage - 1;
  4896. $scope.memoryfilterDatashe.sum = pageSize;
  4897. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
  4898. });
  4899. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4900. $scope.selected.items = data.entity;
  4901. //console.log(data);
  4902. });
  4903. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4904. $scope.selected.items = data.entity;
  4905. //console.log(data);
  4906. });
  4907. gridApi.core.on.filterChanged($scope, function () {
  4908. var grid = this.grid;
  4909. var filtersData = {
  4910. idx: 0,
  4911. sum: 20,
  4912. "user": {
  4913. "roledata": {
  4914. "rolecode": "roleset"
  4915. },
  4916. "selectType": "1"
  4917. }
  4918. };
  4919. angular.forEach(grid.columns, function (item) {
  4920. if (item.enableFiltering) {
  4921. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4922. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4923. if (angular.isUndefined(filtersData['user'])) {
  4924. filtersData['user'] = {};
  4925. }
  4926. filtersData['user'][item.field] = item.filters[0].term;
  4927. }
  4928. }
  4929. });
  4930. $scope.memoryfilterDatashe = filtersData;
  4931. // $scope.loadData(filtersData);
  4932. });
  4933. };
  4934. $scope.interceptMydata = function (mydate, idx, sum) {
  4935. return mydate.slice(idx * sum, (idx + 1) * sum)
  4936. }
  4937. $scope.removeshebei = function (item) {
  4938. event.preventDefault();
  4939. var modalInstance = $modal.open({
  4940. templateUrl: 'assets/views/delete.html',
  4941. controller: function ($scope, $modalInstance, scope) {
  4942. $scope.title = '设备移除';
  4943. $scope.connect = '确定要移除此设备?';
  4944. $scope.consumptive = scope.selected.items;
  4945. $scope.ok = function () {
  4946. $modalInstance.close($scope.consumptive);
  4947. };
  4948. $scope.cancel = function () {
  4949. $modalInstance.dismiss('cancel');
  4950. };
  4951. },
  4952. size: 'sm',
  4953. resolve: {
  4954. scope: function () {
  4955. return $scope;
  4956. },
  4957. }
  4958. });
  4959. modalInstance.result.then(function (selectedItem) {
  4960. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  4961. if (items.id == selectedItem.id) {
  4962. $scope.myDatalingbeiall.splice(index, 1);
  4963. }
  4964. })
  4965. // $scope.myData3.push(selectedItem);
  4966. $scope.model.consumables = $scope.myDatalingbeiall;
  4967. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
  4968. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4970. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
  4971. }
  4972. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4973. })
  4974. }
  4975. $scope.addshebei = function () {
  4976. event.preventDefault();
  4977. var modalInstance = $modal.open({
  4978. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  4979. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
  4980. $scope.langs = i18nService.getAllLangs();
  4981. $scope.lang = 'zh-cn';
  4982. i18nService.setCurrentLang($scope.lang);
  4983. $scope.gridOptions = {};
  4984. $scope.gridOptions.data = 'myDatatwo';
  4985. $scope.gridOptions.enableColumnResizing = true;
  4986. $scope.gridOptions.enableFiltering = false;
  4987. $scope.gridOptions.enableGridMenu = false;
  4988. $scope.gridOptions.showGridFooter = true;
  4989. $scope.gridOptions.showColumnFooter = false;
  4990. $scope.gridOptions.fastWatch = true;
  4991. $scope.gridOptions.useExternalFiltering = true;
  4992. $scope.gridOptions.useExternalPagination = true;
  4993. $scope.gridOptions.paginationPageSizes = [10];
  4994. $scope.gridOptions.paginationPageSize = 10;
  4995. $scope.gridOptions.multiSelect = true;
  4996. $scope.gridOptions.rowIdentity = function (row) {
  4997. return row.id;
  4998. };
  4999. $scope.gridOptions.getRowIdentity = function (row) {
  5000. return row.id;
  5001. };
  5002. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5003. $scope.gridOptions.columnDefs = [{
  5004. name: 'item',
  5005. displayName: '序号',
  5006. width: 80,
  5007. enableFiltering: false
  5008. },
  5009. {
  5010. name: 'uuid',
  5011. displayName: '内部编号',
  5012. width: 175
  5013. },
  5014. {
  5015. name: 'props.hw_mingcheng',
  5016. displayName: '资产名称',
  5017. width: 120
  5018. },
  5019. {
  5020. name: 'props.hw_cifilterClassic',
  5021. displayName: '资产类型',
  5022. width: 80,
  5023. enableFiltering: false
  5024. },
  5025. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  5026. {
  5027. name: 'props.hw_state',
  5028. displayName: '资产状态',
  5029. width: 150,
  5030. enableFiltering: false
  5031. },
  5032. {
  5033. name: 'props.hwnw_area',
  5034. displayName: '资产地点',
  5035. width: 130,
  5036. enableFiltering: false
  5037. },
  5038. {
  5039. name: 'createtime',
  5040. displayName: '申请时间',
  5041. enableFiltering: false
  5042. }
  5043. ];
  5044. // $scope.selectButtonClick
  5045. var defaultFilterData = {
  5046. // "assignee":2,
  5047. // "sign":"basehwitndl",
  5048. // "applicationForm": { "hw_state": "在线" },
  5049. "hw_state": "在库",
  5050. "idx": 0,
  5051. "sum": 10
  5052. };
  5053. $scope.memoryfilterData = {
  5054. // "assignee":2,
  5055. // "sign":"basehwitndl",
  5056. // "applicationForm": { "hw_state": "在线" },
  5057. "hw_state": "在库",
  5058. "idx": 0,
  5059. "sum": 10
  5060. }
  5061. $scope.refreshData = function (style, filterData) {
  5062. if (angular.isUndefined(filterData)) {
  5063. filterData = defaultFilterData;
  5064. }
  5065. $scope.myDatatwo = [];
  5066. // $scope.gridOptions['sum']=filterData.sum;
  5067. api_cmdb.query(filterData).then(function (data) {
  5068. // $scope.callsPending--;
  5069. var filterData = $scope.memoryfilterData;
  5070. var myDatatwo = Restangular.stripRestangular(data);
  5071. $scope.gridOptions['totalItems'] = data.total;
  5072. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  5073. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  5074. }
  5075. $scope.myDatatwo = myDatatwo.data.node;
  5076. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  5077. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5078. }
  5079. }, function () { });
  5080. };
  5081. $scope.refreshData('expand-right', defaultFilterData);
  5082. $scope.gridOptions.onRegisterApi = function (gridApi) {
  5083. $scope.gridApi = gridApi;
  5084. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5085. var filtersData = $scope.memoryfilterData;
  5086. filtersData.idx = newPage - 1;
  5087. filtersData.sum = pageSize;
  5088. // $scope.loadData(filtersData);
  5089. $scope.refreshData('expand-right', filtersData);
  5090. //console.log(pageSize);
  5091. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  5092. });
  5093. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  5094. // $scope.selected.items.push(data.entity);
  5095. //console.log(data);
  5096. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  5097. if (scope.isSelected) {
  5098. scope.grid.appScope.selected.items.push(scope.entity)
  5099. } else {
  5100. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  5101. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  5102. scope.grid.appScope.selected.items.splice(i, 1);
  5103. break;
  5104. }
  5105. }
  5106. }
  5107. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  5108. });
  5109. // });
  5110. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  5111. // $scope.selected.items = data.entity;
  5112. //console.log(data);
  5113. var selectitem = [];
  5114. selectitem = angular.copy($scope.selected.items);
  5115. for (var j = 0; j < rows.length; j++) {
  5116. if (rows[j].isSelected == true) {
  5117. selectitem.push(rows[j].entity);
  5118. } else {
  5119. delete selectitem[j];
  5120. // rows.splice(j, 1);
  5121. }
  5122. }
  5123. $scope.selected.items = [];
  5124. for (var i = 0; i < selectitem.length; i++) {
  5125. if (selectitem[i]) {
  5126. $scope.selected.items.push(selectitem[i]);
  5127. }
  5128. }
  5129. });
  5130. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  5131. // // if (row.entity.age > 45) {
  5132. // row.grid.api.selection.selectRow(row.entity); // 选中行
  5133. // // }
  5134. // };
  5135. gridApi.core.on.filterChanged($scope, function () {
  5136. var grid = this.grid;
  5137. var filtersData = {
  5138. idx: 0,
  5139. sum: 10,
  5140. "user": {
  5141. "roledata": {
  5142. "rolecode": "roleset"
  5143. },
  5144. "selectType": "1"
  5145. }
  5146. };
  5147. angular.forEach(grid.columns, function (item) {
  5148. if (item.enableFiltering) {
  5149. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5150. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5151. if (angular.isUndefined(filtersData['user'])) {
  5152. filtersData['user'] = {};
  5153. }
  5154. filtersData['user'][item.field] = item.filters[0].term;
  5155. }
  5156. }
  5157. });
  5158. $scope.memoryfilterData = filtersData;
  5159. // $scope.loadData(filtersData);
  5160. });
  5161. };
  5162. $scope.onDblClick = function (data, event) {
  5163. // $scope.selected.items = data.entity;
  5164. $scope.selectButtonClick(data, event);
  5165. };
  5166. // $scope.loadData = function(filterData) {
  5167. // // console.log("filtersData=111" + JSON.stringify(filterData))
  5168. // items.fetchItems(filterData, APIService).then(function(data) {
  5169. // var myDatatwo = Restangular.stripRestangular(data);
  5170. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  5171. // $scope.myDatatwo = myDatatwo.list;
  5172. // });
  5173. // };
  5174. $scope.title = title;
  5175. //树形图
  5176. var apple_selected, tree, treedata_avm, treedata_geography;
  5177. $scope.my_tree_handler = function (branch) {
  5178. //var _ref;
  5179. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  5180. api_cmdb.query({
  5181. 'sign': classify
  5182. }).then(function (data) {
  5183. var myDatalingbei = Restangular.stripRestangular(data);
  5184. // console.log(myData.data.node);
  5185. if (myDatalingbei.data && myDatalingbei.status == 200) {
  5186. var ret = myDatalingbei.data;
  5187. redrawSvg(myDatalingbei);
  5188. }
  5189. });
  5190. };
  5191. $scope.my_data = [];
  5192. function convertListToTree(data, treeMap) {
  5193. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  5194. var root = null; //Initially set our loop to null
  5195. var parentNode = null;
  5196. //loop over data
  5197. for (var i = 0; i < data.length; i++) {
  5198. var datum = data[i];
  5199. //each node will have children, so let's give it a "children" poperty
  5200. datum.children = [];
  5201. //add an entry for this node to the map so that any future children can
  5202. //lookup the parent
  5203. idToNodeMap[datum.id] = datum;
  5204. //Does this node have a parent?
  5205. if (typeof datum.parent === "undefined" || datum.parent == null) {
  5206. //Doesn't look like it, so this node is the root of the tree
  5207. root = datum;
  5208. treeMap[datum.id] = root;
  5209. } else {
  5210. //This node has a parent, so let's look it up using the id
  5211. parentNode = idToNodeMap[datum.parent.id];
  5212. //We don't need this property, so let's delete it.
  5213. delete datum.parent;
  5214. //Let's add the current node as a child of the parent node.
  5215. parentNode.children.push(datum);
  5216. }
  5217. }
  5218. return root;
  5219. }
  5220. function convertParentToChildList(data) {
  5221. var treeMap = {};
  5222. var list = [];
  5223. convertListToTree(data, treeMap);
  5224. angular.forEach(treeMap, function (item) {
  5225. list.push(item);
  5226. });
  5227. return list;
  5228. }
  5229. $scope.my_tree = tree = {};
  5230. $scope.try_async_load = function () {
  5231. $scope.my_data = [];
  5232. $scope.select_treedata = [];
  5233. $scope.doing_async = true;
  5234. api_configure_data.fetchDataList('ciclassify', {
  5235. 'idx': 0,
  5236. 'sum': 100
  5237. }).then(function (result) {
  5238. //console.log(result['list']);
  5239. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  5240. $scope.doing_async = false;
  5241. // tree.expand_all();
  5242. //console.log(treelist);
  5243. });
  5244. };
  5245. $scope.select_treedata = [];
  5246. $scope.propTypeOptions = [];
  5247. $scope.try_async_load();
  5248. $scope.onFilterremove = function (item) {
  5249. console.log(item)
  5250. }
  5251. $scope.searchdata = {};
  5252. $scope.clear = function () {
  5253. $scope.searchdata = {};
  5254. $scope.cifilter_classic = {};
  5255. $scope.try_async_load();
  5256. var fildata = {
  5257. idx: 0,
  5258. sum: 10,
  5259. 'hw_state': '在库'
  5260. }
  5261. $scope.memoryfilterData = fildata;
  5262. $scope.refreshData('expand-right', fildata);
  5263. }
  5264. $scope.cifilter_classic = {};
  5265. $scope.chiceIncident = function (item) {
  5266. var fildata = defaultFilterData;
  5267. // fildata.applicationForm = {};
  5268. // sign: basehwnwswt
  5269. if (item && item.id) {
  5270. var classify = item.prefix.toLowerCase() + item.sign;
  5271. fildata.sign = classify
  5272. } else {
  5273. delete fildata.sign
  5274. }
  5275. $scope.gridOptions.paginationCurrentPage = 1;
  5276. var transitiondata = angular.copy(item);
  5277. $scope.refreshData('expand-right', fildata);
  5278. }
  5279. $scope.applicadata = [];
  5280. $scope.onFilterCallback = function (item) {
  5281. var tempclassify = item.prefix.toLowerCase() + item.sign;
  5282. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  5283. var myData = Restangular.stripRestangular(data);
  5284. $scope.applicadata = myData[0].form.fields;
  5285. });
  5286. // }
  5287. }
  5288. // $scope.loadData({
  5289. // idx: 0,
  5290. // sum: 10,
  5291. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5292. // });
  5293. $scope.selected = {
  5294. items: []
  5295. };
  5296. $scope.ok = function () {
  5297. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  5298. // onDataCallback($scope.selected.item, parentScope);
  5299. // }
  5300. $modalInstance.close($scope.selected.items);
  5301. };
  5302. $scope.cancel = function () {
  5303. $modalInstance.dismiss('cancel');
  5304. };
  5305. },
  5306. size: 'lg',
  5307. resolve: {
  5308. items: function () {
  5309. return {
  5310. fetchItems: function (filterData, APIService) {
  5311. filterData = filterData || {};
  5312. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  5313. filterData = {
  5314. idx: 0,
  5315. sum: 10,
  5316. "user": {
  5317. "roledata": {
  5318. "rolecode": "roleset"
  5319. },
  5320. "selectType": "1"
  5321. }
  5322. };
  5323. }
  5324. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  5325. }
  5326. };
  5327. },
  5328. title: function () {
  5329. return $scope.options.templateOptions.label;
  5330. },
  5331. Restangular: function () {
  5332. return $scope.options.templateOptions.Restangular;
  5333. },
  5334. APIService: function () {
  5335. return $scope.options.templateOptions.ApiService;
  5336. },
  5337. onDataCallback: function () {
  5338. return $scope.options.templateOptions.callback;
  5339. },
  5340. parentScope: function () {
  5341. return $scope.options.templateOptions.that;
  5342. }
  5343. }
  5344. });
  5345. modalInstance.result.then(function (selectedItem) {
  5346. // console.log(selectedItem);
  5347. // options.value(selectedItem);
  5348. var filterData = $scope.memoryfilterDatashe;
  5349. $scope.myDatalingbeiall = selectedItem;
  5350. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5351. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5352. $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5353. }
  5354. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5355. $scope.model.assets = $scope.myDatalingbeiall;
  5356. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
  5357. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  5358. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  5359. // }
  5360. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  5361. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  5362. // }
  5363. }, function () {
  5364. //console.log('Modal dismissed at: ' + new Date());
  5365. });
  5366. }
  5367. $scope.onDblClick = function (data, event) {
  5368. $scope.selectButtonClick(data, event);
  5369. };
  5370. // $scope.loadData = function(filterData) {};
  5371. // $scope.title = title;
  5372. // $scope.loadData({
  5373. // idx: 0,
  5374. // sum: 20,
  5375. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5376. // });
  5377. $scope.selected = {
  5378. items: []
  5379. };
  5380. //grid2
  5381. $scope.langs = i18nService.getAllLangs();
  5382. $scope.lang = 'zh-cn';
  5383. i18nService.setCurrentLang($scope.lang);
  5384. $scope.gridOptions2 = {};
  5385. $scope.gridOptions2.data = 'myDataone';
  5386. $scope.gridOptions2.enableColumnResizing = true;
  5387. $scope.gridOptions2.enableFiltering = false;
  5388. $scope.gridOptions2.enableGridMenu = false;
  5389. $scope.gridOptions2.showGridFooter = true;
  5390. $scope.gridOptions2.showColumnFooter = false;
  5391. $scope.gridOptions2.fastWatch = true;
  5392. $scope.gridOptions2.useExternalFiltering = true;
  5393. $scope.gridOptions2.useExternalPagination = true;
  5394. $scope.gridOptions2.paginationPageSizes = [10];
  5395. $scope.gridOptions2.paginationPageSize = 10;
  5396. $scope.gridOptions2.multiSelect = false;
  5397. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5398. $scope.gridOptions2.columnDefs = [{
  5399. name: 'item',
  5400. displayName: '序号',
  5401. width: 120
  5402. },
  5403. {
  5404. name: 'name',
  5405. displayName: '耗材名称',
  5406. width: 150,
  5407. enableFiltering: false
  5408. },
  5409. {
  5410. name: 'model',
  5411. displayName: '品牌/型号',
  5412. width: 100,
  5413. enableFiltering: false
  5414. },
  5415. {
  5416. name: 'Specifications',
  5417. displayName: '规格',
  5418. width: 150,
  5419. enableFiltering: false
  5420. },
  5421. {
  5422. name: 'sum',
  5423. displayName: '领用数量',
  5424. enableFiltering: false
  5425. }
  5426. ];
  5427. // $scope.selectButtonClick
  5428. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5429. $scope.gridApi = gridApi;
  5430. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5431. // var filtersData = $scope.memoryfilterData;
  5432. // filtersData.idx = newPage - 1;
  5433. // filtersData.sum = pageSize;
  5434. // $scope.loadData(filtersData);
  5435. $scope.memoryfilterDatahao.idx = newPage - 1;
  5436. $scope.memoryfilterDatahao.sum = pageSize;
  5437. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
  5438. });
  5439. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5440. $scope.selected.items.push(data.entity);
  5441. //console.log(data);
  5442. });
  5443. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  5444. $scope.selected.items.push(data.entity);
  5445. //console.log(data);
  5446. });
  5447. gridApi.core.on.filterChanged($scope, function () {
  5448. var grid = this.grid;
  5449. var filtersData = {
  5450. idx: 0,
  5451. sum: 10,
  5452. "user": {
  5453. "roledata": {
  5454. "rolecode": "roleset"
  5455. },
  5456. "selectType": "1"
  5457. }
  5458. };
  5459. angular.forEach(grid.columns, function (item) {
  5460. if (item.enableFiltering) {
  5461. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5462. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5463. if (angular.isUndefined(filtersData['user'])) {
  5464. filtersData['user'] = {};
  5465. }
  5466. filtersData['user'][item.field] = item.filters[0].term;
  5467. }
  5468. }
  5469. });
  5470. $scope.memoryfilterDatahao = filtersData;
  5471. $scope.loadData(filtersData);
  5472. });
  5473. };
  5474. $scope.removehaocai = function (item) {
  5475. event.preventDefault();
  5476. // var modalInstance = $modal.open({
  5477. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  5478. // controller: function($scope, $modalInstance) {
  5479. // $scope.title = "修改耗材数量";
  5480. // $scope.consumptive = item;
  5481. // $scope.ok = function() {
  5482. // $modalInstance.close($scope.consumptive);
  5483. // };
  5484. // $scope.cancel = function() {
  5485. // $modalInstance.dismiss('cancel');
  5486. // };
  5487. // },
  5488. // size: 'sm'
  5489. // });
  5490. var modalInstance = $modal.open({
  5491. templateUrl: 'assets/views/delete.html',
  5492. controller: function ($scope, $modalInstance, scope) {
  5493. $scope.title = '耗材移除';
  5494. $scope.connect = '确定要移除此设备?';
  5495. $scope.consumptive = scope.selected.items[0];
  5496. $scope.ok = function () {
  5497. $modalInstance.close($scope.consumptive);
  5498. };
  5499. $scope.cancel = function () {
  5500. $modalInstance.dismiss('cancel');
  5501. };
  5502. },
  5503. size: 'sm',
  5504. resolve: {
  5505. scope: function () {
  5506. return $scope;
  5507. },
  5508. }
  5509. });
  5510. modalInstance.result.then(function (selectedItem) {
  5511. // angular.forEach($scope.myData3, function(items, index) {
  5512. // if (items.id == selectedItem.id) {
  5513. // $scope.myData3[index] = selectedItem;
  5514. // }
  5515. // })
  5516. // $scope.model.applicationForm.consumables = $scope.myData3;
  5517. angular.forEach($scope.myDataoneall, function (items, index) {
  5518. if (items.id == selectedItem.id) {
  5519. $scope.myDataoneall.splice(index, 1);
  5520. }
  5521. })
  5522. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5523. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5524. }
  5525. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5526. $scope.model.consumables = $scope.myDataoneall;
  5527. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5528. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5529. $scope.selected = {
  5530. items: []
  5531. };
  5532. })
  5533. }
  5534. $scope.haocaiadd = function () {
  5535. event.preventDefault();
  5536. var modalInstance = $modal.open({
  5537. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  5538. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  5539. $scope.haocainame = [];
  5540. $scope.pinpai = [];
  5541. $scope.guige = [];
  5542. $scope.consumptive = {};
  5543. $scope.consumpall = {};
  5544. $scope.title = "添加耗材";
  5545. api_wechatfile.getDictionaryForList({
  5546. "key": "haocaifenlei"
  5547. }).then(function (data) {
  5548. $scope.haocainame = data;
  5549. })
  5550. $scope.clearNoNum = function (obj, attr) {
  5551. //先把非数字的都替换掉,除了数字和.
  5552. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5553. //必须保证第一个为数字而不是.
  5554. obj[attr] = obj[attr].replace(/^\./g, "");
  5555. //保证只有出现一个.而没有多个.
  5556. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5557. //保证.只出现一次,而不能出现两次以上
  5558. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  5559. //小于最大值
  5560. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5561. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5562. obj[attr] = '';
  5563. }
  5564. }
  5565. $scope.onChange = function (parent) {
  5566. $scope.consumptive.model = {};
  5567. $scope.consumptive.Specifications = {};
  5568. api_wechatfile.getDictionaryForList({
  5569. "key": "pinpai",
  5570. "parent": parent.id
  5571. }).then(function (data) {
  5572. $scope.pinpai = data;
  5573. })
  5574. api_wechatfile.getDictionaryForList({
  5575. "key": "guige",
  5576. "parent": parent.id
  5577. }).then(function (data) {
  5578. $scope.guige = data;
  5579. })
  5580. }
  5581. $scope.onChangesum = function (item) {
  5582. if (item.name && item.model.id && item.Specifications.id) {
  5583. $scope.consumptive.sum = "";
  5584. var data1 = {
  5585. "idx": 0,
  5586. "sum": 10,
  5587. "consumable": {
  5588. "name": item.name.name,
  5589. "brandModel": item.model.name,
  5590. "specification": item.Specifications.name
  5591. }
  5592. }
  5593. api_cmdb3.fetchDataList('consumable', data1).then(function (data) {
  5594. if (data.status == 200 && data.list.length > 0) {
  5595. var myData = data.list;
  5596. $scope.consumpall = myData[0];
  5597. $scope.maxsum = myData[0].inventoryNum;
  5598. } else {
  5599. SweetAlert.swal({
  5600. title: "不存在该耗材",
  5601. text: "请检查库存后重新填写!",
  5602. type: "error"
  5603. });
  5604. }
  5605. });
  5606. }
  5607. }
  5608. $scope.addhaocai = function () {
  5609. $modalInstance.dismiss('cancel');
  5610. scope.haocaiopen($scope.consumptive);
  5611. }
  5612. $scope.ok = function (item) {
  5613. var items = {};
  5614. // if (item.name && item.model && item.Specifications && item.sum) {
  5615. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5616. // $scope.consumpall.model = $scope.consumpall.brandModel;
  5617. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  5618. // $scope.consumpall.sum = item.sum;
  5619. // delete $scope.consumpall.brandModel;
  5620. // delete $scope.consumpall.specification;
  5621. // $modalInstance.close($scope.consumpall);
  5622. // } else {
  5623. // SweetAlert.swal({
  5624. // title: "数据填写不完整!",
  5625. // text: "请检查数据然后提交!",
  5626. // type: "error"
  5627. // });
  5628. // }
  5629. var isold = false;
  5630. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  5631. for (var i = 0; i < scope.myDataoneall.length; i++) {
  5632. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  5633. isold = true;
  5634. }
  5635. }
  5636. if (isold) {
  5637. SweetAlert.swal({
  5638. title: "该耗材已添加!",
  5639. text: "请不要重复添加耗材!",
  5640. type: "error"
  5641. });
  5642. } else {
  5643. $scope.consumpall.model = $scope.consumpall.brandModel;
  5644. $scope.consumpall.Specifications = $scope.consumpall.specification;
  5645. $scope.consumpall.sum = item.sum;
  5646. delete $scope.consumpall.brandModel;
  5647. delete $scope.consumpall.specification;
  5648. $modalInstance.close($scope.consumpall);
  5649. }
  5650. } else {
  5651. SweetAlert.swal({
  5652. title: "数据填写不完整!",
  5653. text: "请检查数据然后提交!",
  5654. type: "error"
  5655. });
  5656. }
  5657. // $modalInstance.close(item);
  5658. };
  5659. $scope.cancel = function () {
  5660. $modalInstance.dismiss('cancel');
  5661. };
  5662. },
  5663. size: 'sm',
  5664. resolve: {
  5665. scope: function () {
  5666. return $scope;
  5667. }
  5668. }
  5669. });
  5670. modalInstance.result.then(function (selectedItem) {
  5671. $scope.myDataoneall.push(selectedItem);
  5672. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5673. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5674. }
  5675. // $scope.model.consumables = $scope.myDataone;
  5676. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5677. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5678. $scope.model.consumables = $scope.myDataoneall;
  5679. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5680. })
  5681. }
  5682. $scope.onDblClick = function (data, event) {
  5683. $scope.selectButtonClick(data, event);
  5684. };
  5685. $scope.memoryfilterDatahao = {
  5686. "idx": 0,
  5687. "sum": 10,
  5688. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5689. }
  5690. $scope.myDataone = [];
  5691. $scope.loadData = function (filterData) { };
  5692. // $scope.title = title;
  5693. $scope.ldloading = {};
  5694. $scope.selected = {
  5695. items: []
  5696. };
  5697. if ($scope.$parent.$parent.$parent.model.gettype) {
  5698. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  5699. if ($scope.model.assets) {
  5700. if (JSON.stringify($scope.model.assets) == "{}") {
  5701. $scope.model.assets = []
  5702. } else {
  5703. $scope.model.assets = JSON.parse($scope.model.assets);
  5704. }
  5705. $scope.myDatalingbeiall = $scope.model.assets;
  5706. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5707. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
  5708. }
  5709. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5710. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5711. }
  5712. if ($scope.model.consumables) {
  5713. if (JSON.stringify($scope.model.consumables) == "{}") {
  5714. $scope.model.consumables = []
  5715. } else {
  5716. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5717. }
  5718. $scope.myDataoneall = $scope.model.consumables;
  5719. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5720. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5721. }
  5722. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5723. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5724. }
  5725. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5726. $scope.options.templateOptions.getpush({
  5727. "hao": true,
  5728. "gu": true
  5729. });
  5730. } else {
  5731. $scope.options.templateOptions.getpush({
  5732. "hao": true
  5733. });
  5734. }
  5735. } else {
  5736. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5737. $scope.options.templateOptions.getpush({
  5738. "gu": true
  5739. });
  5740. }
  5741. }
  5742. }
  5743. }]
  5744. });
  5745. formlyConfigProvider.setType({
  5746. name: 'ui-panel',
  5747. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  5748. });
  5749. formlyConfigProvider.setType({
  5750. name: 'ui-currentuser',
  5751. extends: 'input',
  5752. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  5753. defaultOptions: function (options) {
  5754. return {
  5755. templateOptions: {
  5756. // link: function() {}
  5757. }
  5758. };
  5759. },
  5760. controller: ['$scope', function ($scope) {
  5761. if ($scope.options.templateOptions.user) {
  5762. if (angular.isFunction($scope.options.templateOptions.transform)) {
  5763. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  5764. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  5765. // }
  5766. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5767. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5768. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  5769. }
  5770. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  5771. $scope.options.initialValue = $scope.model[$scope.options.key];
  5772. }
  5773. }]
  5774. });
  5775. //仪表盘
  5776. //待处理变更列表
  5777. formlyConfigProvider.setType({
  5778. name: 'ui-ngpchangetable',
  5779. templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
  5780. defaultOptions: function (options) {
  5781. return {
  5782. templateOptions: {
  5783. // relationAction: function() {
  5784. // options.hideExpression = true
  5785. // }
  5786. }
  5787. };
  5788. },
  5789. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5790. // var filterData = {
  5791. // "assignee": $rootScope.user.id,
  5792. // "searchtype": "all",
  5793. // "idx": "0",
  5794. // "sum": "10"
  5795. // };
  5796. var filterData = {
  5797. "idx": "0",
  5798. "sum": "10",
  5799. "assignee": 2,
  5800. "searchType": "todo"
  5801. }
  5802. $scope.incidentprocess = function (item) {
  5803. $state.go('app.wt_change.add', {
  5804. taskId: item.taskId,
  5805. processInstanceId: item.processInstanceId
  5806. });
  5807. }
  5808. $scope.more = function () {
  5809. $state.go('app.wt_change.list', {})
  5810. }
  5811. api_bpm_domain.fetchtask('bpm_change', filterData).then(function (data) {
  5812. if (data.data) {
  5813. $scope.myData = data.data;
  5814. } else {
  5815. SweetAlert.swal({
  5816. title: "操作异常!",
  5817. text: "系统异常,请稍后重试,或者联系管理员!",
  5818. type: "error"
  5819. });
  5820. }
  5821. })
  5822. $scope.removes = function () {
  5823. var modalInstance = $modal.open({
  5824. templateUrl: 'assets/views/delete.html',
  5825. controller: function ($scope, $modalInstance) {
  5826. $scope.ok = function () {
  5827. $modalInstance.close();
  5828. };
  5829. $scope.cancel = function () {
  5830. $modalInstance.dismiss('cancel');
  5831. };
  5832. },
  5833. size: 'sm'
  5834. });
  5835. modalInstance.result.then(function () {
  5836. console.log($scope.$parent.$parent.$parent.$parent)
  5837. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5838. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5839. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5840. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5841. break;
  5842. }
  5843. }
  5844. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5845. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5846. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5847. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5848. }
  5849. })
  5850. }
  5851. }]
  5852. });
  5853. //待处理问题列表
  5854. formlyConfigProvider.setType({
  5855. name: 'ui-ngproblemtable',
  5856. templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
  5857. defaultOptions: function (options) {
  5858. return {
  5859. templateOptions: {
  5860. // relationAction: function() {
  5861. // options.hideExpression = true
  5862. // }
  5863. }
  5864. };
  5865. },
  5866. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
  5867. var filterData = {
  5868. "assignee": $rootScope.user.id,
  5869. "candidateGroups": $rootScope.user.group[0].id,
  5870. "searchtype": "todo",
  5871. "idx": 0,
  5872. "sum": 10
  5873. };
  5874. $scope.incidentprocess = function (item) {
  5875. $state.go('app.wt_change.add', {
  5876. taskId: item.taskId,
  5877. processInstanceId: item.processInstanceId
  5878. });
  5879. }
  5880. $scope.more = function () {
  5881. $state.go('app.wt_change.list', {})
  5882. }
  5883. api_bpm_data.fetchDataList('changeclassify', filterData).then(function (data) {
  5884. if (data.data) {
  5885. $scope.myData = data.data;
  5886. } else {
  5887. SweetAlert.swal({
  5888. title: "操作异常!",
  5889. text: "系统异常,请稍后重试,或者联系管理员!",
  5890. type: "error"
  5891. });
  5892. }
  5893. })
  5894. $scope.removes = function () {
  5895. var modalInstance = $modal.open({
  5896. templateUrl: 'assets/views/delete.html',
  5897. controller: function ($scope, $modalInstance) {
  5898. $scope.ok = function () {
  5899. $modalInstance.close();
  5900. };
  5901. $scope.cancel = function () {
  5902. $modalInstance.dismiss('cancel');
  5903. };
  5904. },
  5905. size: 'sm'
  5906. });
  5907. modalInstance.result.then(function () {
  5908. console.log($scope.$parent.$parent.$parent.$parent)
  5909. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5910. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5911. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5912. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5913. break;
  5914. }
  5915. }
  5916. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5917. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5918. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5919. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5920. }
  5921. })
  5922. }
  5923. }]
  5924. });
  5925. //待处理事件列表
  5926. formlyConfigProvider.setType({
  5927. name: 'ui-ngtable',
  5928. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  5929. defaultOptions: function (options) {
  5930. return {
  5931. templateOptions: {
  5932. // relationAction: function() {
  5933. // options.hideExpression = true
  5934. // }
  5935. }
  5936. };
  5937. },
  5938. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5939. var filterData = {
  5940. "assignee": $rootScope.user.id,
  5941. "candidateGroups": $rootScope.user.group[0].id,
  5942. "searchtype": "done",
  5943. "idx": 0,
  5944. "sum": 10
  5945. };
  5946. $scope.incidentprocess = function (item) {
  5947. $state.go('app.incident.editor', {
  5948. taskId: item.taskId,
  5949. processInstanceId: item.processInstanceId
  5950. });
  5951. }
  5952. $scope.more = function () {
  5953. $state.go('app.incident.list', {})
  5954. }
  5955. api_bpm_domain.fetchtask('bpm_incident', filterData).then(function (data) {
  5956. if (data.data) {
  5957. $scope.myData = data.data;
  5958. } else {
  5959. SweetAlert.swal({
  5960. title: "操作异常!",
  5961. text: "系统异常,请稍后重试,或者联系管理员!",
  5962. type: "error"
  5963. });
  5964. }
  5965. })
  5966. $scope.removes = function () {
  5967. var modalInstance = $modal.open({
  5968. templateUrl: 'assets/views/delete.html',
  5969. controller: function ($scope, $modalInstance) {
  5970. $scope.ok = function () {
  5971. $modalInstance.close();
  5972. };
  5973. $scope.cancel = function () {
  5974. $modalInstance.dismiss('cancel');
  5975. };
  5976. },
  5977. size: 'sm'
  5978. });
  5979. modalInstance.result.then(function () {
  5980. console.log($scope.$parent.$parent.$parent.$parent)
  5981. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5982. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5983. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5984. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5985. break;
  5986. }
  5987. }
  5988. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5989. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5990. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5991. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5992. }
  5993. })
  5994. }
  5995. }]
  5996. });
  5997. //知识库列表
  5998. formlyConfigProvider.setType({
  5999. name: 'ui-knowledge',
  6000. templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
  6001. defaultOptions: function (options) {
  6002. return {
  6003. templateOptions: {
  6004. // relationAction: function() {
  6005. // options.hideExpression = true
  6006. // }
  6007. }
  6008. };
  6009. },
  6010. controller: ['$scope', '$modal', '$timeout', 'api_solution', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, api_solution, $rootScope, ngTableParams, $filter, $state) {
  6011. var filterData = {
  6012. "key": "null",
  6013. "pageIndex": 0,
  6014. "pageSum": 6,
  6015. "status": 0,
  6016. "userId": $rootScope.user.id
  6017. };
  6018. $scope.model.removereport = false;
  6019. $scope.removes = function () {
  6020. $scope.model.removereport = true;
  6021. }
  6022. $scope.more = function () {
  6023. $state.go('app.knowledge.manager', {});
  6024. }
  6025. api_solution.findSolutionByKeys(filterData).then(function (data) {
  6026. if (data.status == 200) {
  6027. $scope.myData = data.list
  6028. }
  6029. })
  6030. $scope.removes = function () {
  6031. var modalInstance = $modal.open({
  6032. templateUrl: 'assets/views/delete.html',
  6033. controller: function ($scope, $modalInstance) {
  6034. $scope.ok = function () {
  6035. $modalInstance.close();
  6036. };
  6037. $scope.cancel = function () {
  6038. $modalInstance.dismiss('cancel');
  6039. };
  6040. },
  6041. size: 'sm'
  6042. });
  6043. modalInstance.result.then(function () {
  6044. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6045. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6046. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6047. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6048. break;
  6049. }
  6050. }
  6051. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6052. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6053. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6054. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6055. }
  6056. })
  6057. }
  6058. }]
  6059. });
  6060. //公告列表
  6061. formlyConfigProvider.setType({
  6062. name: 'ui-ngnotice',
  6063. templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
  6064. defaultOptions: function (options) {
  6065. return {
  6066. templateOptions: {
  6067. // relationAction: function() {
  6068. // options.hideExpression = true
  6069. // }
  6070. }
  6071. };
  6072. },
  6073. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
  6074. var filterData = {
  6075. "idx": 0,
  6076. "sum": 10
  6077. };
  6078. // $scope.$scope.model.className = "col-xs-12";
  6079. api_user_data.fetchDataList('notice', filterData).then(function (data) {
  6080. if (data) {
  6081. $scope.myData = data.data;
  6082. } else {
  6083. SweetAlert.swal({
  6084. title: "操作异常!",
  6085. text: "系统异常,请稍后重试,或者联系管理员!",
  6086. type: "error"
  6087. });
  6088. }
  6089. })
  6090. $scope.more = function () {
  6091. $state.go('app.system.notice.list', {});
  6092. }
  6093. $scope.removes = function () {
  6094. var modalInstance = $modal.open({
  6095. templateUrl: 'assets/views/delete.html',
  6096. controller: function ($scope, $modalInstance) {
  6097. $scope.ok = function () {
  6098. $modalInstance.close();
  6099. };
  6100. $scope.cancel = function () {
  6101. $modalInstance.dismiss('cancel');
  6102. };
  6103. },
  6104. size: 'sm'
  6105. });
  6106. modalInstance.result.then(function () {
  6107. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6108. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6109. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6110. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6111. break;
  6112. }
  6113. }
  6114. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6115. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6116. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6117. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6118. }
  6119. })
  6120. }
  6121. }]
  6122. });
  6123. //事件统计图
  6124. formlyConfigProvider.setType({
  6125. name: 'ui-incidentreport',
  6126. templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
  6127. defaultOptions: function (options) {
  6128. return {
  6129. templateOptions: {
  6130. // relationAction: function() {
  6131. // options.hideExpression = true
  6132. // }
  6133. }
  6134. };
  6135. },
  6136. controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function ($scope, $modal, moment, api_report, $cookieStore) {
  6137. api_report.getLicenseKey().then(function (response) {
  6138. $cookieStore.put('Auth-Token', response.token);
  6139. $scope.try_async_load();
  6140. });
  6141. $scope.try_async_load = function () {
  6142. $scope.my_data = [];
  6143. api_report.list().then(function (response) {
  6144. var dataList = response;
  6145. getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
  6146. $scope.repoRoot.name = "事件报表"
  6147. convertRepoObject($scope.repoRoot);
  6148. $scope.my_data.push($scope.repoRoot);
  6149. });
  6150. };
  6151. var workspace = {};
  6152. $scope.repoRoot = null;
  6153. function getRepoRoot(repo, path) {
  6154. angular.forEach(repo, function (value, key) {
  6155. if (value.path == path) {
  6156. $scope.repoRoot = value;
  6157. } else {
  6158. if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
  6159. getRepoRoot(value.repoObjects, path);
  6160. } else {
  6161. }
  6162. }
  6163. });
  6164. }
  6165. function convertRepoObject(repo) {
  6166. if (angular.isArray(repo)) {
  6167. angular.forEach(repo, function (value, key) {
  6168. convertRepoObject(value);
  6169. })
  6170. } else {
  6171. if (angular.isDefined(repo.name)) {
  6172. if (repo.name.indexOf(".") >= 0) {
  6173. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  6174. } else {
  6175. repo.label = repo.name;
  6176. }
  6177. //delete repo.name;
  6178. }
  6179. if (angular.isDefined(repo.repoObjects)) {
  6180. repo.children = [];
  6181. repo.children = repo.repoObjects;
  6182. delete repo.repoObjects;
  6183. convertRepoObject(repo.children);
  6184. }
  6185. }
  6186. }
  6187. function parseDateParameter(parameters) {
  6188. var result = undefined;
  6189. if (angular.isArray(parameters)) {
  6190. // angular.forEach(parmeters,function(param){
  6191. // param.
  6192. // })
  6193. } else {
  6194. result = {};
  6195. for (var k in parameters) {
  6196. if (k.indexOf("Date") > 0) {
  6197. if (angular.isString(parameters[k])) {
  6198. result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
  6199. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  6200. }
  6201. }
  6202. }
  6203. }
  6204. return result;
  6205. }
  6206. function ConvertDateParameter(parameters) {
  6207. var result = undefined;
  6208. if (angular.isArray(parameters)) {
  6209. //
  6210. } else {
  6211. result = {};
  6212. for (var k in parameters) {
  6213. if (k.indexOf("Date") > 0) {
  6214. if (angular.isDate(parameters[k])) {
  6215. result[k] = moment(parameters[k]).format("YYYYMMDD");
  6216. } else if (angular.isString(parameters[k])) {
  6217. result[k] = parameters[k];
  6218. }
  6219. }
  6220. }
  6221. }
  6222. return result;
  6223. }
  6224. var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  6225. var queryUUID;
  6226. function genUUID() {
  6227. var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
  6228. function (c) {
  6229. var r = Math.random() * 16 | 0,
  6230. v = c == 'x' ? r : (r & 0x3 | 0x8);
  6231. return v.toString(16);
  6232. }).toUpperCase();
  6233. return uuid;
  6234. }
  6235. queryUUID = genUUID();
  6236. var pathincidenttimekey = [];
  6237. var incidenttime = {
  6238. 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
  6239. 'endtimes': moment(new Date()).format('YYYYMMDD')
  6240. };
  6241. var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
  6242. var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
  6243. var averages = [
  6244. [thisdaymine - 86400000 * 14, 0],
  6245. [thisdaymine - 86400000 * 13, 0],
  6246. [thisdaymine - 86400000 * 12, 0],
  6247. [thisdaymine - 86400000 * 11, 0],
  6248. [thisdaymine - 86400000 * 10, 0],
  6249. [thisdaymine - 86400000 * 9, 0],
  6250. [thisdaymine - 86400000 * 8, 0],
  6251. [thisdaymine - 86400000 * 7, 0],
  6252. [thisdaymine - 86400000 * 6, 0],
  6253. [thisdaymine - 86400000 * 5, 0],
  6254. [thisdaymine - 86400000 * 4, 0],
  6255. [thisdaymine - 86400000 * 3, 0],
  6256. [thisdaymine - 86400000 * 2, 0],
  6257. [thisdaymine - 86400000 * 1, 0],
  6258. [thisdaymine, 0]
  6259. ];
  6260. var getreportdata = function (incidenttime, path) {
  6261. api_report.getMdx(path, queryUUID).then(function (response) {
  6262. var mdxquery = response;
  6263. workspace.query = mdxquery;
  6264. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  6265. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  6266. $scope.parameters = parseDateParameter(workspace.query.parameters);
  6267. weekuser(mdxquery);
  6268. });
  6269. }
  6270. getreportdata(incidenttime, incidentchart);
  6271. var weekuser = function (mdxquery) {
  6272. var key = [];
  6273. api_report.execute(mdxquery).then(function (data) {
  6274. $scope.rheaders = [];
  6275. $scope.rRows = [];
  6276. var reportData = data;
  6277. if (reportData.cellset == null || reportData.cellset.length == 0) {
  6278. $scope.shows = true;
  6279. $scope.empty = "数据为空!"
  6280. } else {
  6281. angular.forEach(reportData.cellset, function (item, i) {
  6282. angular.forEach(averages, function (index, j) {
  6283. // angular.forEach(averages, function(item, index) {
  6284. if (item.length > 1 && i > 0 && item[1].value != '') {
  6285. if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
  6286. index[1] = Number(item[1].value);
  6287. }
  6288. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  6289. }
  6290. // })
  6291. })
  6292. })
  6293. incidentchartfun(averages);
  6294. }
  6295. })
  6296. }
  6297. var incidentchartfun = function (incidentchartkey) {
  6298. // $scope.isMaskincident = false;
  6299. Highcharts.chart('incidentchart', {
  6300. title: {
  6301. text: '事件近15天趋势图'
  6302. },
  6303. xAxis: {
  6304. type: 'datetime',
  6305. labels: {
  6306. align: 'left',
  6307. step: 1
  6308. }
  6309. },
  6310. yAxis: {
  6311. title: {
  6312. text: null
  6313. }
  6314. },
  6315. tooltip: {
  6316. crosshairs: true,
  6317. shared: true,
  6318. valueSuffix: '条'
  6319. },
  6320. legend: {},
  6321. series: [{
  6322. name: '生成事件',
  6323. data: incidentchartkey,
  6324. zIndex: 1,
  6325. marker: {
  6326. fillColor: 'white',
  6327. lineWidth: 2,
  6328. lineColor: Highcharts.getOptions().colors[0]
  6329. }
  6330. }]
  6331. });
  6332. }
  6333. $scope.data = {
  6334. labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
  6335. datasets: [{
  6336. label: '新增事件数量',
  6337. fillColor: 'rgba(220,220,220,0.2)',
  6338. strokeColor: 'rgba(220,220,220,1)',
  6339. pointColor: 'rgba(220,220,220,1)',
  6340. pointStrokeColor: '#fff',
  6341. pointHighlightFill: '#fff',
  6342. pointHighlightStroke: 'rgba(220,220,220,1)',
  6343. data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
  6344. },
  6345. {
  6346. label: '已解决事件数量',
  6347. fillColor: 'rgba(151,187,205,0.2)',
  6348. strokeColor: 'rgba(151,187,205,1)',
  6349. pointColor: 'rgba(151,187,205,1)',
  6350. pointStrokeColor: '#fff',
  6351. pointHighlightFill: '#fff',
  6352. pointHighlightStroke: 'rgba(151,187,205,1)',
  6353. data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
  6354. }
  6355. ]
  6356. };
  6357. $scope.removes = function () {
  6358. var modalInstance = $modal.open({
  6359. templateUrl: 'assets/views/delete.html',
  6360. controller: function ($scope, $modalInstance) {
  6361. $scope.ok = function () {
  6362. $modalInstance.close();
  6363. };
  6364. $scope.cancel = function () {
  6365. $modalInstance.dismiss('cancel');
  6366. };
  6367. },
  6368. size: 'sm'
  6369. });
  6370. modalInstance.result.then(function () {
  6371. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6372. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6373. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6374. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6375. break;
  6376. }
  6377. }
  6378. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6379. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6380. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6381. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6382. }
  6383. })
  6384. }
  6385. var addDatas = 0;
  6386. var resolve = 0;
  6387. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  6388. addDatas = addDatas + $scope.data.datasets[0].data[i];
  6389. }
  6390. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  6391. resolve = resolve + $scope.data.datasets[1].data[i];
  6392. }
  6393. $scope.resolution = (resolve / addDatas * 100).toFixed(2);
  6394. $scope.opt = {
  6395. maintainAspectRatio: false,
  6396. // Sets the chart to be responsive
  6397. responsive: true,
  6398. ///Boolean - Whether grid lines are shown across the chart
  6399. scaleShowGridLines: true,
  6400. //String - Colour of the grid lines
  6401. scaleGridLineColor: 'rgba(0,0,0,.05)',
  6402. //Number - Width of the grid lines
  6403. scaleGridLineWidth: 1,
  6404. //Boolean - Whether the line is curved between points
  6405. bezierCurve: false,
  6406. //Number - Tension of the bezier curve between points
  6407. bezierCurveTension: 0.4,
  6408. //Boolean - Whether to show a dot for each point
  6409. pointDot: true,
  6410. //Number - Radius of each point dot in pixels
  6411. pointDotRadius: 4,
  6412. //Number - Pixel width of point dot stroke
  6413. pointDotStrokeWidth: 1,
  6414. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  6415. pointHitDetectionRadius: 20,
  6416. //Boolean - Whether to show a stroke for datasets
  6417. datasetStroke: true,
  6418. //Number - Pixel width of dataset stroke
  6419. datasetStrokeWidth: 2,
  6420. //Boolean - Whether to fill the dataset with a colour
  6421. datasetFill: true,
  6422. // Function - on animation progress
  6423. onAnimationProgress: function () { },
  6424. // Function - on animation complete
  6425. onAnimationComplete: function () { },
  6426. //String - A legend template
  6427. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  6428. };
  6429. angular.extend($scope.options, $scope.opt)
  6430. $scope.datamonth = {
  6431. labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
  6432. datasets: [{
  6433. label: '新增事件数量',
  6434. fillColor: 'rgba(220,220,220,0.5)',
  6435. strokeColor: 'rgba(220,220,220,0.8)',
  6436. highlightFill: 'rgba(220,220,220,0.75)',
  6437. highlightStroke: 'rgba(220,220,220,1)',
  6438. data: [65, 59, 80, 81, 56, 55]
  6439. },
  6440. {
  6441. label: '已解决事件数量',
  6442. fillColor: 'rgba(151,187,205,0.5)',
  6443. strokeColor: 'rgba(151,187,205,0.8)',
  6444. highlightFill: 'rgba(151,187,205,0.75)',
  6445. highlightStroke: 'rgba(151,187,205,1)',
  6446. data: [28, 48, 40, 19, 86, 27]
  6447. }
  6448. ]
  6449. };
  6450. // Chart.js Options
  6451. $scope.taption = {
  6452. maintainAspectRatio: false,
  6453. // Sets the chart to be responsive
  6454. responsive: true,
  6455. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  6456. scaleBeginAtZero: true,
  6457. //Boolean - Whether grid lines are shown across the chart
  6458. scaleShowGridLines: true,
  6459. //String - Colour of the grid lines
  6460. scaleGridLineColor: "rgba(0,0,0,.05)",
  6461. //Number - Width of the grid lines
  6462. scaleGridLineWidth: 1,
  6463. //Boolean - If there is a stroke on each bar
  6464. barShowStroke: true,
  6465. //Number - Pixel width of the bar stroke
  6466. barStrokeWidth: 2,
  6467. //Number - Spacing between each of the X value sets
  6468. barValueSpacing: 5,
  6469. //Number - Spacing between data sets within X values
  6470. barDatasetSpacing: 1,
  6471. //String - A legend template
  6472. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  6473. };
  6474. }]
  6475. });
  6476. //排版日历
  6477. formlyConfigProvider.setType({
  6478. name: 'ui-dashcalendar',
  6479. templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
  6480. defaultOptions: function (options) {
  6481. return {
  6482. templateOptions: {
  6483. // relationAction: function() {
  6484. // options.hideExpression = true
  6485. // }
  6486. }
  6487. };
  6488. },
  6489. controller: ["$rootScope", "$scope", "$modal", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", "$state", function ($rootScope, $scope, $modal, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data, $state) {
  6490. var loginUser = $rootScope.user;
  6491. calendarConfig.dateFormatter = 'moment';
  6492. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  6493. calendarConfig.i18nStrings.timeLabel = '时间';
  6494. calendarConfig.i18nStrings.weekNumber = '{week}周';
  6495. calendarConfig.allDateFormats = {
  6496. angular: {
  6497. date: {
  6498. hour: 'ha',
  6499. day: 'd MMM',
  6500. month: 'MMMM',
  6501. weekDay: 'EEEE',
  6502. time: 'HH:mm',
  6503. datetime: 'MMM d, h:mm a'
  6504. },
  6505. title: {
  6506. day: 'yyyy MMMM EEEE d',
  6507. week: '{year}年第{week}周',
  6508. month: 'yyyy MMMM',
  6509. year: 'yyyy'
  6510. }
  6511. },
  6512. moment: {
  6513. date: {
  6514. hour: 'ha',
  6515. day: 'MMMDD日',
  6516. month: 'MMMM',
  6517. weekDay: 'dddd',
  6518. time: 'HH:mm',
  6519. datetime: 'MMM D, h:mm a'
  6520. },
  6521. title: {
  6522. day: 'YYYY年MMMMDD日, dddd ',
  6523. week: '{year}年第{week}周',
  6524. month: 'YYYY年MMMM',
  6525. year: 'YYYY'
  6526. }
  6527. }
  6528. };
  6529. moment.locale('zh_cn', {
  6530. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  6531. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  6532. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6533. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6534. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6535. longDateFormat: {
  6536. LT: 'Ah点mm分',
  6537. LTS: 'Ah点m分s秒',
  6538. L: 'YYYY-MM-DD',
  6539. LL: 'YYYY年MMMD日',
  6540. LLL: 'YYYY年MMMD日Ah点mm分',
  6541. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  6542. l: 'YYYY-MM-DD',
  6543. ll: 'YYYY年MMMD日',
  6544. lll: 'YYYY年MMMD日Ah点mm分',
  6545. llll: 'YYYY年MMMD日ddddAh点mm分'
  6546. },
  6547. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6548. meridiemHour: function (hour, meridiem) {
  6549. if (hour === 12) {
  6550. hour = 0;
  6551. }
  6552. if (meridiem === '凌晨' || meridiem === '早上' ||
  6553. meridiem === '上午') {
  6554. return hour;
  6555. } else if (meridiem === '下午' || meridiem === '晚上') {
  6556. return hour + 12;
  6557. } else {
  6558. // '中午'
  6559. return hour >= 11 ? hour : hour + 12;
  6560. }
  6561. },
  6562. meridiem: function (hour, minute, isLower) {
  6563. var hm = hour * 100 + minute;
  6564. if (hm < 600) {
  6565. return '凌晨';
  6566. } else if (hm < 900) {
  6567. return '早上';
  6568. } else if (hm < 1130) {
  6569. return '上午';
  6570. } else if (hm < 1230) {
  6571. return '中午';
  6572. } else if (hm < 1800) {
  6573. return '下午';
  6574. } else {
  6575. return '晚上';
  6576. }
  6577. },
  6578. calendar: {
  6579. sameDay: function () {
  6580. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  6581. },
  6582. nextDay: function () {
  6583. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  6584. },
  6585. lastDay: function () {
  6586. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  6587. },
  6588. nextWeek: function () {
  6589. var startOfWeek, prefix;
  6590. startOfWeek = moment().startOf('week');
  6591. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  6592. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6593. },
  6594. lastWeek: function () {
  6595. var startOfWeek, prefix;
  6596. startOfWeek = moment().startOf('week');
  6597. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  6598. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6599. },
  6600. sameElse: 'LL'
  6601. },
  6602. ordinalParse: /\d{1,2}(日|月|周)/,
  6603. ordinal: function (number, period) {
  6604. switch (period) {
  6605. case 'd':
  6606. case 'D':
  6607. case 'DDD':
  6608. return number + '日';
  6609. case 'M':
  6610. return number + '月';
  6611. case 'w':
  6612. case 'W':
  6613. return number + '周';
  6614. default:
  6615. return number;
  6616. }
  6617. },
  6618. relativeTime: {
  6619. future: '%s内',
  6620. past: '%s前',
  6621. s: '几秒',
  6622. m: '1 分钟',
  6623. mm: '%d 分钟',
  6624. h: '1 小时',
  6625. hh: '%d 小时',
  6626. d: '1 天',
  6627. dd: '%d 天',
  6628. M: '1 个月',
  6629. MM: '%d 个月',
  6630. y: '1 年',
  6631. yy: '%d 年'
  6632. },
  6633. week: {
  6634. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6635. dow: 1, // Monday is the first day of the week.
  6636. doy: 4 // The week that contains Jan 4th is the first week of the year.
  6637. }
  6638. });
  6639. var date = new Date();
  6640. var d = date.getDate();
  6641. var m = date.getMonth();
  6642. var y = date.getFullYear();
  6643. var filterData = {
  6644. "userId": loginUser.id,
  6645. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  6646. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  6647. };
  6648. var load = $scope.load = function (filterData) {
  6649. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function (response) {
  6650. if (response.status == 200) {
  6651. $scope.events = [];
  6652. var myData = response.list;
  6653. angular.forEach(myData, function (item) {
  6654. var eventTemp = {};
  6655. eventTemp.title = item.description;
  6656. eventTemp.type = item.scheduleClass.code;
  6657. eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
  6658. eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
  6659. eventTemp.startTime = item['scheduleOrderDTO'].startTime;
  6660. eventTemp.endTime = item['scheduleOrderDTO'].endTime;
  6661. //eventTemp.ends_at = moment(item.endTime).toDate();
  6662. eventTemp.id = item.id;
  6663. eventTemp.deletable = false;
  6664. eventTemp.user = item.user;
  6665. $scope.events.push(eventTemp);
  6666. })
  6667. }
  6668. });
  6669. }
  6670. // var load = $scope.load = function(filterData){
  6671. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  6672. // console.log("response="+JSON.stringify(response));
  6673. // if(response.status==200){
  6674. // $scope.events = [];
  6675. // console.log(response.list);
  6676. // var myData = response.list;
  6677. // angular.forEach(myData,function(item){
  6678. // var eventTemp = {};
  6679. // eventTemp.title = item.description;
  6680. // eventTemp.type = item.scheduleClass.code;
  6681. // eventTemp.startsAt = moment(item.startTime).toDate();
  6682. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  6683. // eventTemp.startTime = item.startTime;
  6684. // eventTemp.endTime = item.endTime;
  6685. // //eventTemp.ends_at = moment(item.endTime).toDate();
  6686. // eventTemp.id = item.id;
  6687. // eventTemp.deletable = false;
  6688. // eventTemp.users = item.users;
  6689. // $scope.events.push(eventTemp);
  6690. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  6691. // })
  6692. // }
  6693. // });
  6694. // }
  6695. $scope.scheduleClass = {};
  6696. var convertEvent = function (scheduleorder) {
  6697. var eventTemp = {};
  6698. eventTemp.title = scheduleorder.description;
  6699. eventTemp.type = scheduleorder.scheduleClass.code;
  6700. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  6701. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  6702. eventTemp.id = scheduleorder.id;
  6703. eventTemp.user = scheduleorder.user;
  6704. eventTemp.deletable = false;
  6705. return eventTemp;
  6706. }
  6707. // var convertEvent = function(scheduleorder){
  6708. // var eventTemp = {};
  6709. // eventTemp.title = scheduleorder.description;
  6710. // eventTemp.type = scheduleorder.scheduleClass.code;
  6711. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  6712. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  6713. // eventTemp.id = scheduleorder.id;
  6714. // eventTemp.users = scheduleorder.users;
  6715. // eventTemp.deletable = false;
  6716. // return eventTemp;
  6717. // }
  6718. api_bpm_schedule.getScheduleClass().then(function (response) {
  6719. if (response.status == 200) {
  6720. var scheduleClassList = response.list;
  6721. angular.forEach(scheduleClassList, function (item) {
  6722. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  6723. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  6724. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  6725. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  6726. $scope.scheduleClass[item['code']] = item;
  6727. })
  6728. }
  6729. })
  6730. $scope.events = [];
  6731. $scope.calendarView = 'month';
  6732. //$scope.calendarDay = new Date();
  6733. $scope.calendarDate = moment().startOf('month').toDate();
  6734. $scope.timeLabel = "时间";
  6735. $scope.eventLabel = "描述";
  6736. function showModal(action, event) {
  6737. // console.log("action="+JSON.stringify(action))
  6738. var modalInstance = $aside.open({
  6739. templateUrl: 'scheduleEvent.html',
  6740. placement: 'right',
  6741. size: 'sm',
  6742. backdrop: true,
  6743. controller: function ($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  6744. $scope.$modalInstance = $modalInstance;
  6745. $scope.action = action;
  6746. $scope.event = event;
  6747. $scope.scheduleClassic = scheduleClass;
  6748. $scope.$watch('event.type', function (newvalue, oldvalue) {
  6749. // if(oldvalue == newvalue) return;
  6750. // if(scheduleClass[newvalue]){
  6751. var sm = MementFormat(scheduleClass[newvalue].startTime);
  6752. var em = MementFormat(scheduleClass[newvalue].endTime);
  6753. console.log("sm=" + JSON.stringify(sm))
  6754. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  6755. console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  6756. if (sm.hour() > em.hour()) {
  6757. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6758. console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  6759. } else {
  6760. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6761. console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  6762. }
  6763. // }
  6764. });
  6765. // $scope.ok = function (event) {
  6766. // console.log("event="+JSON.stringify(event))
  6767. // event.action = action;
  6768. // $modalInstance.close(event);
  6769. // };
  6770. $scope.cancel = function (event) {
  6771. $modalInstance.dismiss();
  6772. };
  6773. var acUserSelect = $scope.refreshUser = function (key) {
  6774. //for test
  6775. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  6776. // return;
  6777. var data = {
  6778. "idx": "0",
  6779. "sum": "5"
  6780. };
  6781. if (key) {
  6782. data['user'] = {
  6783. 'name': key
  6784. };
  6785. }
  6786. APIService.fetchDataList('user', data).then(function (response) {
  6787. if (response) {
  6788. if (response.status = 200) {
  6789. $scope.users = response.list;
  6790. console.log($scope.users);
  6791. }
  6792. }
  6793. })
  6794. };
  6795. if (angular.isDefined(event.users) && event.users.length > 0) {
  6796. }
  6797. $scope.users = [event.user];
  6798. acUserSelect();
  6799. },
  6800. resolve: {
  6801. scheduleClass: function () {
  6802. return $scope.scheduleClass;
  6803. },
  6804. APIService: function () {
  6805. return api_user_data;
  6806. },
  6807. MementFormat: function () {
  6808. return moment;
  6809. }
  6810. }
  6811. });
  6812. modalInstance.result.then(function (selectedEvent) {
  6813. if (selectedEvent.action == 'Clicked') {
  6814. // var data = {
  6815. // "scheduleorder":{
  6816. // "id":selectedEvent.id,
  6817. // "description":selectedEvent.title,
  6818. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  6819. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  6820. // "users":selectedEvent.users,
  6821. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  6822. // }
  6823. // };
  6824. // api_bpm_schedule.update(data).then(function(response){
  6825. // if(response.status==200){
  6826. // SweetAlert.swal({
  6827. // title: "操作成功!",
  6828. // text: "排班更新成功!",
  6829. // type: "succes"
  6830. // });
  6831. // angular.forEach($scope.events,function(item){
  6832. // if(item.id==selectedEvent.id){
  6833. // item = selectedEvent;
  6834. // }
  6835. // })
  6836. // }else{
  6837. // SweetAlert.swal({
  6838. // title: "操作失败",
  6839. // text: "排班更新失败,请稍后重试!",
  6840. // type: "error"
  6841. // })
  6842. // }
  6843. // })
  6844. } else {
  6845. //
  6846. }
  6847. });
  6848. }
  6849. $scope.moment = function (string) {
  6850. return moment(string);
  6851. }
  6852. $scope.eventClicked = function (event) {
  6853. // console.log("event="+JSON.stringify(event))
  6854. showModal('Clicked', event);
  6855. };
  6856. $scope.eventEdited = function (event) {
  6857. showModal('Edited', event);
  6858. };
  6859. var updateView = function (newvalue, oldvalue) {
  6860. if (oldvalue == newvalue) return;
  6861. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  6862. if ($scope.calendarView == "year") {
  6863. } else if ($scope.calendarView == "month") {
  6864. timeStart = moment(newvalue).startOf('month');
  6865. timeEnd = moment(newvalue).endOf('month');
  6866. } else if ($scope.calendarView == "week") {
  6867. timeStart = moment(newvalue).startOf('week');
  6868. timeEnd = moment(newvalue).endOf('week');
  6869. } else if ($scope.calendarView == "Day") {
  6870. timeStart = moment(newvalue).startOf('day');
  6871. timeEnd = moment(newvalue).endOf('day');
  6872. }
  6873. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  6874. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  6875. filterData["startTime"] = timeStartSpan;
  6876. filterData["endTime"] = timeEndSpan;
  6877. load(filterData);
  6878. }
  6879. $scope.$watch('calendarDate', updateView)
  6880. $scope.next = function () {
  6881. $scope.calendarControl.next();
  6882. }
  6883. $scope.prev = function () {
  6884. $scope.calendarControl.prev();
  6885. }
  6886. $scope.setCalendarToToday = function () {
  6887. $scope.calendarDay = new Date();
  6888. };
  6889. $scope.toggle = function ($event, field, event) {
  6890. $event.preventDefault();
  6891. $event.stopPropagation();
  6892. event[field] = !event[field];
  6893. };
  6894. $scope.load(filterData);
  6895. $scope.more = function () {
  6896. $state.go('app.scheduling.myscheduling', {});
  6897. }
  6898. $scope.removes = function () {
  6899. var modalInstance = $modal.open({
  6900. templateUrl: 'assets/views/delete.html',
  6901. controller: function ($scope, $modalInstance) {
  6902. $scope.ok = function () {
  6903. $modalInstance.close();
  6904. };
  6905. $scope.cancel = function () {
  6906. $modalInstance.dismiss('cancel');
  6907. };
  6908. },
  6909. size: 'sm'
  6910. });
  6911. modalInstance.result.then(function () {
  6912. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6913. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6914. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6915. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6916. break;
  6917. }
  6918. }
  6919. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6920. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6921. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6922. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6923. }
  6924. })
  6925. }
  6926. }]
  6927. });
  6928. //空格组件
  6929. formlyConfigProvider.setType({
  6930. name: 'ui-black',
  6931. /*extends: 'input',*/
  6932. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  6933. });
  6934. //请求人最近事件
  6935. formlyConfigProvider.setType({
  6936. name: 'ui-recentIncident',
  6937. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  6938. controller: ['$scope', '$modal', 'api_solution', function ($scope, $modal, api_solution) {
  6939. var filterData = {
  6940. 'incident': {
  6941. 'requester': {
  6942. 'id': ''
  6943. }
  6944. },
  6945. idx: 0,
  6946. sum: 3
  6947. };
  6948. setInterval(function () {
  6949. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  6950. var requester = $scope.model.requester;
  6951. if (requester != null && angular.isDefined(requester.id)) {
  6952. filterData.incident.requester.id = $scope.model.requester.id;
  6953. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  6954. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  6955. if (modelData.status == 200) {
  6956. $scope.lastrequst = modelData.list;
  6957. }
  6958. });
  6959. requester = null
  6960. } else { }
  6961. } else { }
  6962. }, 1000);
  6963. $scope.detail = function (data) {
  6964. var modalInstance = $modal.open({
  6965. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  6966. controller: function ($scope, $modalInstance) {
  6967. $scope.entity = {};
  6968. $scope.entity = data;
  6969. $scope.cancel = function () {
  6970. $modalInstance.dismiss('cancel');
  6971. };
  6972. },
  6973. size: 'lg',
  6974. });
  6975. }
  6976. }]
  6977. });
  6978. //参数列表
  6979. formlyConfigProvider.setType({
  6980. name: "ui-listinput",
  6981. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  6982. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6983. defaultOptions: function (options) {
  6984. return {
  6985. templateOptions: {}
  6986. };
  6987. },
  6988. controller: ['$scope', function ($scope) {
  6989. }]
  6990. });
  6991. //时间段控件(分)
  6992. formlyConfigProvider.setType({
  6993. name: 'ui-timeslot',
  6994. extends: 'input',
  6995. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6996. controller: ['$scope', function ($scope) { }]
  6997. });
  6998. //优先级级联-逾期时间
  6999. formlyConfigProvider.setType({
  7000. name: 'ui-overtime',
  7001. extends: 'input',
  7002. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  7003. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7004. var filteData = {};
  7005. var datas = {}
  7006. setInterval(function () {
  7007. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7008. filteData = "L" + $scope.model.priority.id;
  7009. datas = $scope.model.priority.id;
  7010. // console.log($scope.options.templateOptions)
  7011. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7012. // var overtime=requester.date;
  7013. if (requester.state == 200) {
  7014. // if($scope.options.key=="date"){
  7015. $scope.model[$scope.options.key] = requester.date
  7016. // }
  7017. }
  7018. })
  7019. }
  7020. }, 1000);
  7021. }]
  7022. });
  7023. formlyConfigProvider.setType({
  7024. name: 'ui-responsetime',
  7025. extends: 'input',
  7026. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  7027. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7028. var filteData = {};
  7029. var datas = {}
  7030. setInterval(function () {
  7031. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7032. filteData = "L" + $scope.model.priority.id;
  7033. datas = $scope.model.priority.id;
  7034. // console.log($scope.options.templateOptions)
  7035. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7036. // var overtime=requester.date;
  7037. if (requester.state == 200) {
  7038. var keyName = {};
  7039. // $scope.model.overdueTime = requester.date;
  7040. if ($scope.options.key == "expectIntroTime") {
  7041. keyName = "resolveTime";
  7042. } else if ($scope.options.key == "expectResponseTime") {
  7043. keyName = "responseTime";
  7044. }
  7045. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  7046. // }
  7047. console.log($scope.$parent.$parent.$parent.model)
  7048. }
  7049. if (requester.date1) {
  7050. $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
  7051. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
  7052. $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
  7053. $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
  7054. }
  7055. })
  7056. }
  7057. }, 1000);
  7058. }]
  7059. });
  7060. //知识库按钮组件
  7061. formlyConfigProvider.setType({
  7062. name: 'ui-discasecade',
  7063. extends: 'input',
  7064. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  7065. defaultOptions: function (options) {
  7066. return {
  7067. templateOptions: {
  7068. relationAction: function (fields, modelscope, item) { }
  7069. },
  7070. validators: {
  7071. required: {
  7072. expression: function (viewValue, modelValue) {
  7073. var value = modelValue || viewValue;
  7074. // return value = "true";
  7075. }
  7076. }
  7077. }
  7078. }
  7079. },
  7080. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
  7081. // $scope.options.initialValue = $scope.model[$scope.options.key];
  7082. $scope.searchField = $scope.options.model[$scope.options.key];
  7083. $scope.searchData = "";
  7084. $scope.onChangeadd = function (searchData) {
  7085. $scope.searchKey = searchData.account;
  7086. // $scope.searchDataadd = searchData;
  7087. var requesdata = angular.copy(searchData)
  7088. $scope.requester = requesdata;
  7089. }
  7090. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7091. $scope.searchData = searchKey;
  7092. reashdata($scope.searchData);
  7093. }
  7094. $scope.getMydata = function (x) {
  7095. $scope.model[$scope.options.key] = JSON.parse(x).title;
  7096. $scope.searchField = $scope.model[$scope.options.key];
  7097. }
  7098. $scope.getMydataone = function (x) {
  7099. $scope.model[$scope.options.key] = x;
  7100. $scope.searchField = $scope.model[$scope.options.key];
  7101. }
  7102. $scope.fildata = {
  7103. "idx": 0,
  7104. "sum": 10
  7105. // 'incident': { 'tilte': item }
  7106. }
  7107. function reashdata(item) {
  7108. if (item && item != "") {
  7109. angular.extend($scope.fildata, {
  7110. 'incident': {
  7111. 'title': item
  7112. }
  7113. })
  7114. } else {
  7115. delete $scope.fildata.incident;
  7116. }
  7117. api_bpm_data.fetchDataList('incident', $scope.fildata).then(function (response) {
  7118. if (response) {
  7119. if (response.status = 200) {
  7120. var myData = response;
  7121. $scope.myData = myData.list;
  7122. }
  7123. }
  7124. })
  7125. }
  7126. function delHtmlTag(str) {
  7127. return str.replace(/<[^>]+>/g, "");
  7128. }
  7129. // reashdata();
  7130. var changedata = {};
  7131. setInterval(function () {
  7132. if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
  7133. $scope.searchData = {};
  7134. changedata = angular.copy($scope.model.category);
  7135. if ($scope.options.key == "title") {
  7136. var filterData = {
  7137. "idx": 0,
  7138. "sum": 1000
  7139. };
  7140. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function (data) {
  7141. var datalist = data.list;
  7142. angular.forEach(datalist, function (item) {
  7143. if (item.id == $scope.model.category.id) {
  7144. $scope.model[$scope.options.key] = item.category;
  7145. $scope.searchField = $scope.options.model[$scope.options.key];
  7146. $scope.titles = item.category;
  7147. titles = $scope.model.category;
  7148. }
  7149. })
  7150. })
  7151. }
  7152. }
  7153. }, 1000);
  7154. $scope.open = function (key, options, fildata, $event, model) {
  7155. if (key && key.length > 1) {
  7156. api_zsk.solutionData({
  7157. "solution": {
  7158. "searchWord": key
  7159. },
  7160. "idx": "0",
  7161. "sum": "1000"
  7162. }, 'solution').then(function (response) {
  7163. if (response && response.list.length > 0) {
  7164. $scope.dlideboxslide = true
  7165. angular.forEach(response, function (item) {
  7166. console.log(response)
  7167. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  7168. // if (response.status == 200) {
  7169. // var quote = { 'totalNum': response.totalNum }
  7170. // item = angular.extend(item, quote)
  7171. // }
  7172. // })
  7173. $scope.searchData = response.list;
  7174. console.log($scope.searchData)
  7175. })
  7176. $scope.changes = false;
  7177. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  7178. // $scope.closepages = function(e) {
  7179. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  7180. // event.preventDefault();
  7181. // };
  7182. $scope.shows = false;
  7183. $scope.tempData = {};
  7184. $scope.showpage = function (item) {
  7185. item.content = delHtmlTag(item.content);
  7186. $scope.shows = true;
  7187. $scope.tempData = item;
  7188. if (item.content != null) {
  7189. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  7190. }
  7191. $scope.knowledgedata = item;
  7192. $scope.pageid = item.id;
  7193. $scope.changes = !$scope.changes;
  7194. api_bpm_domain.listAttachments(item.id)
  7195. // api_solution.fetchDataList('file', {
  7196. // "file": {
  7197. // "solutionId": item.id
  7198. // },
  7199. // "idx": "0",
  7200. // "sum": "1000"
  7201. // })
  7202. .then(function (data) {
  7203. if (data) {
  7204. $scope.attachments = data.list;
  7205. $scope.view = function (attachmentId) {
  7206. for (var i = 0; i < $scope.attachments.length; i++) {
  7207. if ($scope.attachments[i].id == attachmentId) {
  7208. window.open($scope.attachments[i].previewUrl);
  7209. }
  7210. }
  7211. };
  7212. $scope.download = function (contentId, filename) {
  7213. api_solution.getSolutionDowpath(contentId).then(function (response) {
  7214. var file = new Blob([response], {
  7215. type: 'application/octet-stream'
  7216. });
  7217. // var filename = filename;
  7218. var fileURL = URL.createObjectURL(file);
  7219. var a = document.createElement('a');
  7220. a.href = fileURL;
  7221. a.target = '_blank';
  7222. a.download = filename;
  7223. document.body.appendChild(a);
  7224. a.click();
  7225. })
  7226. };
  7227. }
  7228. })
  7229. }
  7230. $scope.related = function (item) {
  7231. if (item.content != null) {
  7232. item.content = item.content.replace("<p>", "").replace("</p>", "")
  7233. }
  7234. // fildata.$parent.$parent.$parent.model.directClose = 0;
  7235. options.model.handleDescription = item.content;
  7236. var data = {
  7237. 'solutionQuote': {
  7238. 'solutionId': item.id,
  7239. 'incidentsign': options.model.incidentsign
  7240. }
  7241. };
  7242. api_zsk.solutionQuote(item.id).then(function (response) {
  7243. if (response.status == 200) {
  7244. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7245. fildata.$parent.$parent.$parent.$parent.model.start_code = 'close';
  7246. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  7247. } else {
  7248. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7249. };
  7250. })
  7251. }
  7252. $scope.close = function () {
  7253. $scope.changes = !$scope.changes;
  7254. event.preventDefault();
  7255. }
  7256. }
  7257. });
  7258. }
  7259. };
  7260. }]
  7261. });
  7262. //侧滑选择重复事件
  7263. formlyConfigProvider.setType({
  7264. name: 'ui-repeatIncidentbtn',
  7265. templateUrl: 'assets/views/customform/tpl/ui-repeatIncidentbtn.html',
  7266. defaultOptions: function (options) {
  7267. return {
  7268. templateOptions: {
  7269. relationAction: function (fields, modelscope, item) { }
  7270. },
  7271. validators: {
  7272. required: {
  7273. expression: function (viewValue, modelValue) {
  7274. // var value = modelValue || viewValue;
  7275. }
  7276. }
  7277. }
  7278. }
  7279. },
  7280. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
  7281. $scope.selection = {
  7282. id: ''
  7283. };
  7284. // 收起重复事件侧滑框
  7285. function reashdata(item) {
  7286. var fildata = {
  7287. idx: 0,
  7288. incident: {
  7289. department: {
  7290. id: $scope.model.incident.department.id,
  7291. },
  7292. },
  7293. sum: 3
  7294. }
  7295. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  7296. console.log(data)
  7297. if (data) {
  7298. $scope.repeatData = data.list;
  7299. }
  7300. })
  7301. }
  7302. reashdata();
  7303. // 确认选中的重复事件
  7304. $scope.repeatIncidentOk = function () {
  7305. if ($scope.selection.id) {
  7306. $scope.model.incident.repeat = $scope.selection;
  7307. $scope.model.isRepeat = true; //隐藏处理信息
  7308. console.log($scope.model);
  7309. }
  7310. angular.element('#repeatIncident').removeClass('active');
  7311. }
  7312. // 取消选中的重复事件
  7313. $scope.repeatIncidentCancle = function () {
  7314. angular.element('#repeatIncident').removeClass('active');
  7315. return;
  7316. }
  7317. }]
  7318. });
  7319. //侧滑选择知识库查询
  7320. formlyConfigProvider.setType({
  7321. name: 'ui-knowledgebtn',
  7322. templateUrl: 'assets/views/customform/tpl/ui-knowledgebtn.html',
  7323. defaultOptions: function (options) {
  7324. return {
  7325. templateOptions: {
  7326. relationAction: function (fields, modelscope, item) { }
  7327. },
  7328. validators: {
  7329. required: {
  7330. expression: function (viewValue, modelValue) {
  7331. // var value = modelValue || viewValue;
  7332. }
  7333. }
  7334. }
  7335. }
  7336. },
  7337. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', 'api_wechatfile', 'up_down_file', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain, api_wechatfile, up_down_file) {
  7338. // 引用知识库点击
  7339. $scope.searchKeyWord = '';
  7340. $scope.openModel = function (key) {
  7341. // alert(1)//重点
  7342. $scope.searchKeyWord = key;
  7343. if (key) {
  7344. api_zsk.solutionData({
  7345. "solution": {
  7346. threeSearch: key,
  7347. status: { id: 72 },//已发布
  7348. selectType: "keySearch"
  7349. },
  7350. "idx": "0",
  7351. "sum": "1000"
  7352. }, 'solution').then(function (response) {
  7353. $scope.searchData = response.list;
  7354. });
  7355. }
  7356. };
  7357. $scope.openModel($scope.model.incident.description)
  7358. // 展开/收起
  7359. $scope.showId = '';
  7360. $scope.ifshow = false;
  7361. $scope.showAll = function (id) {
  7362. $scope.attachments = []
  7363. if ($scope.showId == id) {
  7364. $scope.ifshow = !$scope.ifshow;
  7365. } else {
  7366. $scope.ifshow = true;
  7367. }
  7368. $scope.showId = id;
  7369. // 获取附件
  7370. api_wechatfile.listAttachments('knowledge', $scope.showId).then(function (data) {
  7371. $scope.attachments = data.data;
  7372. $scope.download = function (token, filename) {
  7373. var downUrl = up_down_file.downloadAttachment('common/common/downloadAttachment', token).getRequestedUrl();
  7374. // window.open(downUrl);
  7375. var a = document.createElement('a');
  7376. a.href = downUrl;
  7377. a.target = '_blank';
  7378. a.download = filename;
  7379. document.body.appendChild(a);
  7380. a.click();
  7381. };
  7382. })
  7383. }
  7384. // 引用
  7385. $scope.related = function (item) {
  7386. console.log(item,'引用名')
  7387. if (item.content) {
  7388. item.content = item.content.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/&nbsp;/g, '')
  7389. }
  7390. $scope.model.incident.handleDescription = item.content;
  7391. $scope.model.incident.category = item.category;
  7392. $scope.model.incident.priority.id = item.category.priority.id;
  7393. $scope.model.incident.title = $scope.model.incident.description = item.title;
  7394. item.category.label = item.category.category;
  7395. var categoryId = item.category.id;
  7396. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  7397. function getres(nodes) {
  7398. if (!nodes || nodes.length == 0) {
  7399. return;
  7400. }
  7401. nodes.forEach(e => {
  7402. e.selected = false;
  7403. if (e.id == categoryId) {
  7404. e.selected = true;
  7405. return false;
  7406. }
  7407. getres(e.children)
  7408. })
  7409. }
  7410. var categorys = [];
  7411. $scope.fields.forEach((e, i) => {
  7412. if (e.key == 'category') {
  7413. categorys = e.templateOptions.options;
  7414. if (categorys.length) {
  7415. getres(categorys);
  7416. $scope.fields[i].templateOptions.options = categorys;
  7417. $scope.$root.refreshSelectedItems();
  7418. }
  7419. return false;
  7420. }
  7421. })
  7422. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  7423. $scope.model.candidateGroups = item.category.group
  7424. // 携带关联优先级,事件工单信息的时间
  7425. if ($scope.model && $scope.model.incident && item.category && item.category.priority && item.category.priority.id) {
  7426. api_bpm_domain.expectedTime('L' + (item.category.priority.id - 1559)).then(function (res) {
  7427. $scope.model.incident.expectResponseTime = $scope.$parent.$parent.$parent.model.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  7428. $scope.model.incident.expectIntroTime = $scope.$parent.$parent.$parent.model.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  7429. $scope.model.incident.overdueTime = $scope.$parent.$parent.$parent.model.incident.overdueTime = res.date;
  7430. })
  7431. }
  7432. api_zsk.solutionQuote(item.id).then(function (response) {
  7433. if (response.status == 200) {
  7434. $('#seachknowledge').removeClass('active')
  7435. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7436. $scope.$parent.$parent.$parent.model.start_code = 'close';
  7437. $scope.$parent.$parent.$parent.model.directClose = 0;
  7438. console.log($scope.model)
  7439. } else {
  7440. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7441. };
  7442. })
  7443. }
  7444. }]
  7445. });
  7446. //下拉输入组件
  7447. formlyConfigProvider.setType({
  7448. name: 'ui-selectinput',
  7449. extends: 'input',
  7450. templateUrl: 'assets/views/customform/tpl/selectinput.html',
  7451. defaultOptions: function (options) {
  7452. return {
  7453. templateOptions: {
  7454. refresh: function () { },
  7455. refreshDelay: 0,
  7456. linkage: function (modelName, data) {
  7457. }
  7458. },
  7459. }
  7460. },
  7461. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  7462. $scope.searchData = "";
  7463. $scope.onChangeadd = function (searchData) {
  7464. // $scope.searchKey = searchData.account;
  7465. // var requesdata = angular.copy(searchData)
  7466. // $scope.requester = requesdata;
  7467. }
  7468. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7469. // $scope.searchData = searchKey;
  7470. // reashdata($scope.searchData);
  7471. }
  7472. $scope.getMydata = function (x) {
  7473. $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
  7474. $scope.searchField = $scope.model[$scope.options.key];
  7475. }
  7476. $scope.getMydataone = function (x) {
  7477. $scope.model[$scope.options.key] = x;
  7478. $scope.searchField = $scope.model[$scope.options.key];
  7479. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
  7480. $scope.hidden = false;
  7481. } else {
  7482. $scope.hidden = true;
  7483. }
  7484. }
  7485. function reashdata(item) {
  7486. $scope.myData = $scope.options.templateOptions.mydata;
  7487. }
  7488. reashdata()
  7489. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  7490. $scope.options.templateOptions.fetchItems($scope);
  7491. }
  7492. }]
  7493. });
  7494. //重构组件模板
  7495. //获取当前人
  7496. formlyConfigProvider.setType({
  7497. name: 'ui-users',
  7498. extends: 'input',
  7499. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7500. defaultOptions: function (options) {
  7501. return {
  7502. templateOptions: {
  7503. translate: '',
  7504. refreshDelay: 0
  7505. }
  7506. }
  7507. },
  7508. controller: ['$scope', function ($scope) {
  7509. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  7510. $scope.options.templateOptions.translate = $scope.$root.user.name;
  7511. }]
  7512. });
  7513. //只读控件
  7514. formlyConfigProvider.setType({
  7515. name: 'ui-label',
  7516. extends: 'input',
  7517. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7518. defaultOptions: function (options) {
  7519. return {
  7520. templateOptions: {
  7521. translate: '',
  7522. refreshDelay: 0
  7523. }
  7524. }
  7525. },
  7526. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  7527. // console.log($scope.options.templateOptions)
  7528. // console.log($scope.options,'options1122');
  7529. $scope.isSolutionLabel = false;
  7530. $scope.solutionLabelStr = "";
  7531. // console.log($scope.options.templateOptions.solotinLabel);
  7532. if ($scope.options.templateOptions.solotinLabel) {
  7533. $scope.isSolutionLabel = true;
  7534. if ($scope.model[$scope.options.key]) {
  7535. var solutionArr = $scope.model[$scope.options.key].split("/");
  7536. $scope.solutionLabelStr = solutionArr.join(" ");
  7537. }
  7538. }
  7539. var value = $scope.model[$scope.options.key];
  7540. // ----------------
  7541. // ----------------
  7542. // console.log(value, 'pppp')
  7543. function treeDesc(children, key, label) {
  7544. if (label == "") {
  7545. label = children[key];
  7546. } else {
  7547. label = children[key] + "-" + label;
  7548. }
  7549. if (angular.isDefined(children.parent)) {
  7550. treeDesc(children.parent, key, label);
  7551. } else {
  7552. return label;
  7553. }
  7554. }
  7555. if (angular.isArray(value)) {
  7556. var tempValue = "";
  7557. angular.forEach(value, function (item) {
  7558. if (tempValue != "") {
  7559. tempValue = tempValue + ",";
  7560. }
  7561. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  7562. });
  7563. $scope.options.templateOptions.translate = tempValue;
  7564. } else if (angular.isObject(value)) {
  7565. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  7566. //tree
  7567. // console.log("value.parent="+JSON.stringify(value.parent))
  7568. var nameLabel = value[$scope.options.templateOptions.labelProp];
  7569. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  7570. $scope.options.templateOptions.translate = nameLabel;
  7571. } else {
  7572. $scope.options.templateOptions.translate = value;
  7573. }
  7574. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  7575. // console.log("value=" + value);
  7576. $scope.options.templateOptions.translate = value;
  7577. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  7578. // console.log("value="+value);
  7579. // $scope.options.templateOptions.translate = value;
  7580. } else {
  7581. // var datasdf = JSON.parse(value);
  7582. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  7583. $scope.options.templateOptions.translate = value;
  7584. }
  7585. if (angular.isFunction($scope.options.templateOptions.transform)) {
  7586. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  7587. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
  7588. }
  7589. // console.log($scope.options.templateOptions.translate,99999);
  7590. }]
  7591. });
  7592. //小标题组件
  7593. formlyConfigProvider.setType({
  7594. name: 'ui-header',
  7595. template: '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>'
  7596. });
  7597. //标题组件
  7598. formlyConfigProvider.setType({
  7599. name: 'ui-title',
  7600. template: '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>'
  7601. });
  7602. //标栏是否展示
  7603. formlyConfigProvider.setType({
  7604. name: 'ui-orshow',
  7605. template: '<div class=\"panel\"><div class=\"panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix\"><h3 class=\"pull-left panel-title text-head margin-left-10\" ng-if=\"options.templateOptions.label\">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
  7606. controller: ['$scope', function ($scope) {
  7607. $scope.clickshow = function (key) {
  7608. // $scope.model[$scope.options.key] != key;
  7609. if (key == false) {
  7610. $scope.model[$scope.options.key] = true
  7611. } else {
  7612. $scope.model[$scope.options.key] = false
  7613. }
  7614. }
  7615. }]
  7616. });
  7617. //按钮组
  7618. formlyConfigProvider.setType({
  7619. name: 'ui-button',
  7620. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  7621. defaultOptions: function (options) {
  7622. return {
  7623. noFormControl: true
  7624. }
  7625. }
  7626. });
  7627. //3d组link
  7628. formlyConfigProvider.setType({
  7629. name: 'ui-link',
  7630. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  7631. defaultOptions: function (options) {
  7632. return {
  7633. noFormControl: true
  7634. }
  7635. }
  7636. });
  7637. //隐藏域组件
  7638. formlyConfigProvider.setType({
  7639. name: 'ui-hidden',
  7640. extends: 'input',
  7641. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  7642. defaultOptions: function (options) {
  7643. return {
  7644. // noFormControl: true
  7645. };
  7646. }
  7647. });
  7648. //文本框组件
  7649. formlyConfigProvider.setType({
  7650. name: 'ui-input',
  7651. extends: 'input',
  7652. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7653. defaultOptions: function (options) {
  7654. return {
  7655. templateOptions: {
  7656. transform: function (value) { }
  7657. }
  7658. };
  7659. },
  7660. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7661. // console.log($scope.model[$scope.options.key]);
  7662. // console.log($scope.options)
  7663. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7664. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7665. }
  7666. }]
  7667. });
  7668. //搜索下拉框-故障地点seimin
  7669. formlyConfigProvider.setType({
  7670. name: 'ui-select-search',
  7671. extends: 'input',
  7672. templateUrl: 'assets/views/customform/tpl/ui-select-search.html',
  7673. defaultOptions: function (options) {
  7674. return {
  7675. templateOptions: {
  7676. transform: function (value) { }
  7677. }
  7678. };
  7679. },
  7680. controller: ['$scope','$rootScope', 'api_search_area', function ($scope,$rootScope, api_search_area) {
  7681. // console.log($scope.options, $scope.model)
  7682. // ----------------分割线 start-----------------
  7683. // 故障地点下拉
  7684. $scope.address_arr = [];//故障地点所有数据
  7685. $scope.addressFlag = false;//默认下拉框列表隐藏
  7686. //点击文本框
  7687. $scope.AddressClickHandle = function () {
  7688. $scope.getDepartmentList();
  7689. angular.element('#bx_address_ul').scrollTop(0);
  7690. }
  7691. //修改文字,实时监听
  7692. $scope.ksChangeHandle = _.debounce(function () {
  7693. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === undefined ? '' : $scope.model[$scope.options.key];
  7694. $scope.getDepartmentList();
  7695. angular.element('#bx_address_ul').scrollTop(0);
  7696. }, 500)
  7697. //获取故障地点seimin
  7698. $scope.getDepartmentList = function () {
  7699. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === null ? '' : $scope.model[$scope.options.key];
  7700. api_search_area.getAreaList({ "searchKey": $scope.model[$scope.options.key] })
  7701. .then(res => {
  7702. if (res.state == 200) {
  7703. $scope.address_arr = res.result;
  7704. $scope.addressFlag = true;//显示
  7705. }
  7706. })
  7707. .catch(err => {
  7708. console.log(err);
  7709. })
  7710. }
  7711. // $scope.getDepartmentList();
  7712. // console.log($scope.model[$scope.options.key])
  7713. //下拉框列表选中
  7714. $scope.addressItemClick = function (obj) {
  7715. $scope.addressFlag = false;//隐藏
  7716. $scope.model[$scope.options.key] = obj.place ? obj.area.area + obj.place : obj.area;
  7717. //选择故障地点后带入区域地点2020年4月23日15:20:44
  7718. $scope.model.selecthouseNumber = obj;
  7719. console.log($scope,77777)
  7720. $scope.$root.selecthouseNumber = obj;
  7721. }
  7722. //点击空白处隐藏
  7723. angular.element(document).on('click', function (e) {
  7724. if (e.target !== angular.element('#bx_address').get(0)) {
  7725. $scope.addressFlag = false;//隐藏
  7726. //模拟placeholder
  7727. // if ($('#bx_address').val() == '') {
  7728. // $('#bx_address').val('请选择报修科室');
  7729. // }
  7730. }
  7731. })
  7732. // -----------------分割线 end----------------
  7733. }]
  7734. });
  7735. //知识库关键字组件
  7736. formlyConfigProvider.setType({
  7737. name: 'ui-knowledgeKeywords',
  7738. extends: 'input',
  7739. templateUrl: 'assets/views/customform/tpl/ui-knowledgeKeywords.html',
  7740. defaultOptions: function (options) {
  7741. return {
  7742. templateOptions: {
  7743. transform: function (value) { }
  7744. }
  7745. };
  7746. },
  7747. controller: ['$scope', '$timeout', 'SweetAlert', function ($scope, $timeout, SweetAlert) {
  7748. $scope.valueLength = [{
  7749. "value": ""
  7750. }];
  7751. $scope.valueAll = [];
  7752. if ($scope.model[$scope.options.key]) {
  7753. var valueArr = $scope.model[$scope.options.key].split("/");
  7754. $scope.valueLength = [];
  7755. for (var i = 0; i < valueArr.length; i++) {
  7756. $scope.valueLength.push({
  7757. "value": valueArr[i]
  7758. })
  7759. }
  7760. }
  7761. $scope.addIpt = function () {
  7762. if ($scope.valueLength.length < 5) {
  7763. $scope.valueLength.push({
  7764. "value": ""
  7765. })
  7766. } else {
  7767. SweetAlert.swal({
  7768. title: "添加失败",
  7769. text: "关键字不能超过5个!",
  7770. type: "error",
  7771. confirmButtonColor: "#DD6B55"
  7772. });
  7773. }
  7774. };
  7775. $scope.closeIpt = function (data) {
  7776. $scope.valueLength.splice(data, 1)
  7777. }
  7778. $scope.toOption = function () {
  7779. $scope.valueAll = [];
  7780. for (var i = 0; i < $scope.valueLength.length; i++) {
  7781. if ($scope.valueLength[i].value != "") {
  7782. $scope.valueAll.push($scope.valueLength[i].value)
  7783. }
  7784. }
  7785. $scope.model.label = $scope.valueAll.join("/")
  7786. }
  7787. }]
  7788. });
  7789. //文本框组件
  7790. formlyConfigProvider.setType({
  7791. name: 'ui-num',
  7792. extends: 'input',
  7793. templateUrl: 'assets/views/customform/tpl/ui-num.html',
  7794. defaultOptions: function (options) {
  7795. return {
  7796. templateOptions: {
  7797. transform: function (value) { }
  7798. }
  7799. };
  7800. },
  7801. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7802. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7803. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7804. }
  7805. $scope.clearNoNum = function (obj, attr) {
  7806. //先把非数字的都替换掉,除了数字和.
  7807. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  7808. //必须保证第一个为数字而不是.
  7809. obj[attr] = obj[attr].replace(/^\./g, "");
  7810. //保证只有出现一个.而没有多个.
  7811. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  7812. //保证.只出现一次,而不能出现两次以上
  7813. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  7814. //小于最大值
  7815. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  7816. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  7817. // obj[attr] = '';
  7818. // }
  7819. }
  7820. }]
  7821. });
  7822. // //关联请求人文本框组件
  7823. // formlyConfigProvider.setType({
  7824. // name: 'ui-requestinput',
  7825. // extends: 'input',
  7826. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7827. // defaultOptions: function(options) {
  7828. // return {
  7829. // templateOptions: {
  7830. // transform: function(value) {},
  7831. // linkData: function(options) {}
  7832. // }
  7833. // };
  7834. // }
  7835. // });
  7836. //只读文本
  7837. formlyConfigProvider.setType({
  7838. name: 'ui-disableinput',
  7839. extends: 'input',
  7840. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  7841. defaultOptions: function (options) {
  7842. return {
  7843. templateOptions: {
  7844. transform: function (value) {
  7845. var ret = "";
  7846. if (value) {
  7847. ret = "已删除";
  7848. } else {
  7849. ret = "正常";
  7850. }
  7851. return ret;
  7852. }
  7853. }
  7854. };
  7855. }
  7856. });
  7857. formlyConfigProvider.setType({
  7858. name: 'ui-disinput',
  7859. extends: 'input',
  7860. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  7861. defaultOptions: function (options) {
  7862. return {
  7863. templateOptions: {}
  7864. };
  7865. }
  7866. });
  7867. //数字组件
  7868. formlyConfigProvider.setType({
  7869. name: 'ui-number',
  7870. extends: 'input',
  7871. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  7872. defaultOptions: function (options) {
  7873. return {
  7874. templateOptions: {}
  7875. };
  7876. },
  7877. controller: ['$scope', function ($scope) { }]
  7878. });
  7879. //含有周的日期
  7880. formlyConfigProvider.setType({
  7881. name: 'ui-datepickerweek',
  7882. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  7883. extends: 'input',
  7884. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  7885. defaultOptions: {
  7886. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  7887. templateOptions: {
  7888. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  7889. }
  7890. },
  7891. controller: ['$scope', '$filter', function ($scope, $filter) {
  7892. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  7893. if ($scope.model[$scope.options.key]) {
  7894. } else {
  7895. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  7896. }
  7897. $scope.options.initialValue = $scope.model[$scope.options.key];
  7898. $scope.endOpen = true;
  7899. $scope.datepicker = {};
  7900. $scope.datepicker.opened = false;
  7901. $scope.datepicker.open = function ($event) {
  7902. $scope.datepicker.opened = true;
  7903. };
  7904. }]
  7905. });
  7906. //lmm
  7907. //分配任务列表
  7908. formlyConfigProvider.setType({
  7909. name: 'jry_taskDistributionList',
  7910. templateUrl: 'assets/views/customform/tpl/jry_taskDistributionList.html',
  7911. wrapper: ['bootstrapHasError'],
  7912. defaultOptions: function (options, $scope) {
  7913. return {
  7914. templateOptions: {
  7915. }
  7916. };
  7917. },
  7918. controller: function ($rootScope, $scope, api_user_data, $modal, api_doc_data, i18nService, SweetAlert, api_wechatfile) {
  7919. // 获取状态
  7920. $scope.stateListData = {};
  7921. $scope.getStateData = function () {//lyl
  7922. var data = {
  7923. "key": 'task_sub_state',
  7924. "type": 'list'
  7925. }
  7926. api_wechatfile.getDictionary(data).then(function (res) {
  7927. angular.forEach(res, function (v, i) {
  7928. $scope.stateListData[v.value] = v.id;
  7929. })
  7930. })
  7931. }
  7932. $scope.getStateData();
  7933. var loginUser = $rootScope.user;
  7934. $scope.langs = i18nService.getAllLangs();
  7935. $scope.lang = 'zh-cn';
  7936. i18nService.setCurrentLang($scope.lang);
  7937. $scope.gridOptions = {};
  7938. $scope.gridOptions.data = 'myData';
  7939. $scope.gridOptions.enableColumnResizing = true;
  7940. $scope.gridOptions.enableGridMenu = false;
  7941. $scope.gridOptions.enableRowSelection = true;
  7942. $scope.gridOptions.showGridFooter = true;
  7943. $scope.gridOptions.showColumnFooter = false;
  7944. $scope.gridOptions.fastWatch = true;
  7945. $scope.gridOptions.useExternalFiltering = true;
  7946. $scope.gridOptions.useExternalPagination = true;
  7947. $scope.gridOptions.paginationPageSizes = [10];
  7948. $scope.gridOptions.paginationPageSize = 10;
  7949. $scope.gridOptions.multiSelect = true;
  7950. $scope.gridOptions.rowIdentity = function (row) {
  7951. return row.id;
  7952. };
  7953. $scope.gridOptions.getRowIdentity = function (row) {
  7954. return row.id;
  7955. };
  7956. // console.log($scope.model);//lmmmm
  7957. $scope.gridOptions.columnDefs = [{
  7958. name: 'item',
  7959. displayName: '序号',
  7960. width: "10%",
  7961. cellTemplate: '<div>' +
  7962. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  7963. '</div>'
  7964. },
  7965. {
  7966. name: 'taskDescribe',
  7967. displayName: '任务说明',
  7968. width: "25%",
  7969. enableFiltering: false,
  7970. cellTemplate: '<div>' +
  7971. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  7972. '</div>'
  7973. },
  7974. {
  7975. name: 'assign.name',
  7976. displayName: '指派人',
  7977. width: "5%",
  7978. enableFiltering: false,
  7979. cellTemplate: '<div>' +
  7980. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  7981. '</div>'
  7982. },
  7983. {
  7984. name: 'startTime',
  7985. displayName: '开始时间',
  7986. width: '13%',
  7987. enableFiltering: false,
  7988. cellTemplate: '<div>' +
  7989. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  7990. '</div>'
  7991. },
  7992. {
  7993. name: 'endTime',
  7994. displayName: '结束时间',
  7995. width: '13%',
  7996. enableFiltering: false,
  7997. cellTemplate: '<div>' +
  7998. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  7999. '</div>'
  8000. },
  8001. {
  8002. name: 'priority.name',
  8003. displayName: '优先级',
  8004. width: "5%",
  8005. enableFiltering: false,
  8006. cellTemplate: '<div>' +
  8007. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  8008. '</div>'
  8009. },
  8010. {
  8011. name: 'state.name',
  8012. displayName: '状态',
  8013. width: "5%",
  8014. enableFiltering: false,
  8015. cellTemplate: '<div>' +
  8016. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  8017. '</div>'
  8018. },
  8019. {
  8020. name: '操作',//lmmm
  8021. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  8022. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  8023. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  8024. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  8025. '<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>' +
  8026. '</div></div>',
  8027. enableFiltering: false
  8028. }
  8029. ];
  8030. // 查看
  8031. $scope.see = function (data) {
  8032. $scope.seeData = data;
  8033. var modalInstance = $modal.open({
  8034. backdrop: false,
  8035. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8036. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8037. $scope.personData = {}; //指派人
  8038. $scope.priorityData = {}; //优先级
  8039. $scope.personListData = {}; //指派人下拉数据
  8040. $scope.priorityListData = {}; //优先级下拉数据
  8041. $scope.startTime = ""; //开始时间
  8042. $scope.releaseShow = "no";
  8043. $scope.subShow = "no";
  8044. $scope.onlySee = "ok";
  8045. $scope.endTime = ""; //结束时间
  8046. $scope.taskDescribe = ""; //任务描述
  8047. $scope.taskDescribe = scope.seeData.taskDescribe;
  8048. $scope.personData.data = scope.seeData.assign;
  8049. $scope.priorityData.data = scope.seeData.priority;
  8050. $scope.startTime = scope.seeData.startTime;
  8051. $scope.endTime = scope.seeData.endTime;
  8052. $scope.done = scope.seeData.done;
  8053. $scope.feedback = scope.seeData.feedback;
  8054. $scope.cancel = function () {
  8055. $modalInstance.dismiss('cancel');
  8056. }
  8057. },
  8058. size: 'sm',
  8059. resolve: {
  8060. scope: function () {
  8061. return $scope;
  8062. },
  8063. },
  8064. backdrop: true
  8065. });
  8066. }
  8067. // 编辑
  8068. $scope.edit = function (data) {
  8069. $scope.editData = data;
  8070. var modalInstance = $modal.open({
  8071. backdrop: false,
  8072. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8073. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8074. console.log(scope.editData);
  8075. $scope.personData = {}; //指派人
  8076. $scope.priorityData = {}; //优先级
  8077. $scope.personListData = {}; //指派人下拉数据
  8078. $scope.priorityListData = {}; //优先级下拉数据
  8079. $scope.startTime = ""; //开始时间
  8080. $scope.releaseShow = "no";
  8081. $scope.endTime = ""; //结束时间
  8082. $scope.taskDescribe = ""; //任务描述
  8083. $scope.taskDescribe = scope.editData.taskDescribe;
  8084. $scope.personData.data = scope.editData.assign;
  8085. $scope.priorityData.data = scope.editData.priority;
  8086. $scope.startTime = scope.editData.startTime;
  8087. $scope.endTime = scope.editData.endTime;
  8088. // 指派人下拉框数据
  8089. $scope.getPersonData = function () {
  8090. var data = {
  8091. "idx": 0,
  8092. "sum": 1000
  8093. }
  8094. api_user_data.fetchDataList("user", data).then(function (res) {
  8095. $scope.personListData = res.list;
  8096. })
  8097. }
  8098. $scope.getPersonData();
  8099. //优先级下拉数据
  8100. $scope.getPriorityData = function () {
  8101. var data = {
  8102. "key": "change_rick_level",
  8103. "type": "list"
  8104. }
  8105. api_wechatfile.getDictionary(data).then(function (res) {
  8106. $scope.priorityListData = res
  8107. })
  8108. }
  8109. $scope.getPriorityData();
  8110. // 获取状态-lmm
  8111. $scope.stateListData = {};
  8112. $scope.getStateData = function () {//lyl
  8113. var data = {
  8114. "key": 'task_sub_state',
  8115. "type": 'list'
  8116. }
  8117. api_wechatfile.getDictionary(data).then(function (res) {
  8118. angular.forEach(res, function (v, i) {
  8119. $scope.stateListData[v.value] = v.id;
  8120. })
  8121. })
  8122. }
  8123. $scope.getStateData();
  8124. //时间控件
  8125. $scope.open = function ($event) {
  8126. $event.preventDefault();
  8127. $event.stopPropagation();
  8128. $scope.opened = !$scope.opened;
  8129. };
  8130. $scope.endOpen = function ($event) {
  8131. $event.preventDefault();
  8132. $event.stopPropagation();
  8133. $scope.startOpened = false;
  8134. $scope.endOpened = !$scope.endOpened;
  8135. };
  8136. $scope.startOpen = function ($event) {
  8137. $event.preventDefault();
  8138. $event.stopPropagation();
  8139. $scope.endOpened = false;
  8140. $scope.startOpened = !$scope.startOpened;
  8141. };
  8142. // 确定
  8143. $scope.ok = function (item) {
  8144. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8145. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8146. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8147. $scope.addData = {
  8148. "taskSub": {
  8149. "taskDescribe": $scope.taskDescribe,
  8150. "assign": $scope.personData.data,
  8151. "priority": $scope.priorityData.data,
  8152. "startTime": $scope.startTime,
  8153. "endTime": $scope.endTime,
  8154. "taskMonth": {
  8155. "id": scope.model.taskMonth.id
  8156. },
  8157. "id": scope.editData.id
  8158. }
  8159. }
  8160. $scope.addData.taskSub["state"] = {
  8161. "id": $scope.stateListData[1]
  8162. };
  8163. api_user_data.updData('taskSub', $scope.addData).then(function (res) {
  8164. if (res.status == 200) {
  8165. SweetAlert.swal({
  8166. title: "修改成功!",
  8167. type: "success",
  8168. confirmButtonColor: "#007AFF"
  8169. });
  8170. scope.refreshData(scope.jry_filterdata);
  8171. $modalInstance.dismiss('cancel');
  8172. } else {
  8173. SweetAlert.swal({
  8174. title: "修改失败",
  8175. text: "系统错误,请重试!",
  8176. type: "error"
  8177. });
  8178. $modalInstance.dismiss('cancel');
  8179. }
  8180. })
  8181. } else {
  8182. SweetAlert.swal({
  8183. title: "修改失败",
  8184. text: "必填项不能为空!",
  8185. type: "error"
  8186. });
  8187. }
  8188. };
  8189. $scope.cancel = function () {
  8190. $modalInstance.dismiss('cancel');
  8191. }
  8192. },
  8193. size: 'sm',
  8194. resolve: {
  8195. scope: function () {
  8196. return $scope;
  8197. },
  8198. },
  8199. backdrop: true
  8200. });
  8201. }
  8202. // 发布
  8203. $scope.release = function (data) {
  8204. SweetAlert.swal({
  8205. title: "确认发布?",
  8206. text: "请确定发布操作!",
  8207. type: "warning",
  8208. showCancelButton: true,
  8209. confirmButtonColor: "#DD6B55",
  8210. confirmButtonText: "确定",
  8211. cancelButtonText: "取消",
  8212. closeOnConfirm: false,
  8213. closeOnCancel: false
  8214. }, function (isConfirm) {
  8215. if (isConfirm) {
  8216. data.state.id = $scope.stateListData[2];
  8217. delete data.item;
  8218. api_user_data.updData("taskSub", {
  8219. taskSub: data
  8220. }).then(function (res) {
  8221. if (res.status == 200) {
  8222. SweetAlert.swal({
  8223. title: "发布成功!",
  8224. type: "success",
  8225. confirmButtonColor: "#007AFF"
  8226. });
  8227. $scope.refreshData($scope.jry_filterdata);
  8228. } else {
  8229. SweetAlert.swal({
  8230. title: "删除失败",
  8231. text: "系统错误,请重试!",
  8232. type: "error"
  8233. });
  8234. }
  8235. })
  8236. } else {
  8237. SweetAlert.swal("操作取消", "发布取消", "error");
  8238. }
  8239. });
  8240. }
  8241. // 删除
  8242. $scope.remove = function (data) {
  8243. SweetAlert.swal({
  8244. title: "确认删除?",
  8245. text: "删除的数据不可恢复,请确认继续操作!",
  8246. type: "warning",
  8247. showCancelButton: true,
  8248. confirmButtonColor: "#DD6B55",
  8249. confirmButtonText: "继续删除",
  8250. cancelButtonText: "取消操作",
  8251. closeOnConfirm: false,
  8252. closeOnCancel: false
  8253. }, function (isConfirm) {
  8254. if (isConfirm) {
  8255. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  8256. if (res.status == 200) {
  8257. SweetAlert.swal({
  8258. title: "删除成功!",
  8259. type: "success",
  8260. confirmButtonColor: "#007AFF"
  8261. });
  8262. $scope.refreshData($scope.jry_filterdata);
  8263. } else {
  8264. SweetAlert.swal({
  8265. title: "删除失败",
  8266. text: "系统错误,请重试!",
  8267. type: "error"
  8268. });
  8269. }
  8270. })
  8271. } else {
  8272. SweetAlert.swal("操作取消", "数据安全", "error");
  8273. }
  8274. });
  8275. }
  8276. $scope.refreshData = function (filterData) {
  8277. // $scope.ldloading[style.replace('-', '_')] = true;
  8278. if (angular.isUndefined(filterData)) {
  8279. filterData = defaultFilterData;
  8280. }
  8281. $scope.myData = [];
  8282. $scope.memoryfilterData = filterData;
  8283. api_doc_data.fetchDataList('taskSub', filterData).then(function (data) {
  8284. var myData = data;
  8285. $scope.gridOptions.totalItems = myData.totalNum;
  8286. $scope.removeFileNum = myData.totalNum;
  8287. if (angular.isArray(myData.list)) {
  8288. $scope.myData = myData.list;
  8289. for (var i = 0; i < $scope.myData.length; i++) {
  8290. //添加序号
  8291. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  8292. $scope.myData[i].startTime = moment($scope.myData[i].startTime).format('YYYY-MM-DD HH:mm:ss');
  8293. $scope.myData[i].endTime = moment($scope.myData[i].endTime).format('YYYY-MM-DD HH:mm:ss');
  8294. }
  8295. }
  8296. }, function () {
  8297. // $scope.ldloading[style.replace('-', '_')] = false;
  8298. });
  8299. };
  8300. //分页控制
  8301. $scope.gridOptions.onRegisterApi = function (gridApi) {
  8302. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  8303. $scope.jry_filterdata.idx = newPage - 1;
  8304. $scope.fenye = newPage - 1;
  8305. $scope.jry_filterdata.sum = pageSize;
  8306. $scope.refreshData($scope.jry_filterdata);
  8307. });
  8308. }
  8309. $scope.fenye = 0;
  8310. if ($scope.model.label == "分配任务") {
  8311. $scope.jry_filterdata = {
  8312. "idx": $scope.fenye,
  8313. "sum": 10,
  8314. "taskSub": {
  8315. "taskMonth": {
  8316. "id": $scope.model.taskMonth.id
  8317. },
  8318. "userid": loginUser.id,
  8319. "role": loginUser.role
  8320. }
  8321. };
  8322. } else {
  8323. $scope.jry_filterdata = {
  8324. "idx": $scope.fenye,
  8325. "sum": 10,
  8326. "taskSub": {
  8327. "taskMonth": {
  8328. "id": $scope.model.taskMonth.id
  8329. },
  8330. "userid": loginUser.id,
  8331. "role": loginUser.role,
  8332. "type": 1
  8333. }
  8334. };
  8335. }
  8336. $scope.refreshData($scope.jry_filterdata);
  8337. //新增模态框
  8338. $scope.newDistribution = function () {
  8339. var modalInstance = $modal.open({
  8340. backdrop: false,
  8341. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8342. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8343. $scope.personData = {}; //指派人
  8344. $scope.priorityData = {}; //优先级
  8345. $scope.personListData = {}; //指派人下拉数据
  8346. $scope.priorityListData = {}; //优先级下拉数据
  8347. $scope.startTime = ""; //开始时间
  8348. $scope.endTime = ""; //结束时间
  8349. $scope.taskDescribe = ""; //任务描述
  8350. $scope.motaikuang = "";
  8351. $scope.shijian = "哈哈";
  8352. // 指派人下拉框数据
  8353. $scope.getPersonData = function () {
  8354. var data = {
  8355. "idx": 0,
  8356. "sum": 1000
  8357. }
  8358. api_user_data.fetchDataList("user", data).then(function (res) {
  8359. $scope.personListData = res.list;
  8360. })
  8361. }
  8362. $scope.getPersonData();
  8363. //优先级下拉数据
  8364. $scope.getPriorityData = function () {
  8365. var data = {
  8366. "key": "change_rick_level",
  8367. "type": "list"
  8368. }
  8369. api_wechatfile.getDictionary(data).then(function (res) {
  8370. $scope.priorityListData = res
  8371. })
  8372. }
  8373. // 控制结束时间的最大时间
  8374. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  8375. // 控制结束时间的最小时间
  8376. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  8377. $scope.$watch('startTime', function (n, o) {
  8378. if (n) {
  8379. if (n > scope.model.taskMonth.startTime) {
  8380. $scope.jryEndMinTime = n
  8381. }
  8382. }
  8383. })
  8384. // 控制开始时间的最小时间
  8385. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  8386. // 控制开始时间的最大时间
  8387. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  8388. $scope.$watch('endTime', function (n, o) {
  8389. if (n) {
  8390. if (n < scope.model.taskMonth.endTime) {
  8391. $scope.jryStartMaxTime = n
  8392. }
  8393. }
  8394. })
  8395. $scope.getPriorityData();
  8396. //时间控件
  8397. $scope.open = function ($event) {
  8398. $event.preventDefault();
  8399. $event.stopPropagation();
  8400. $scope.opened = !$scope.opened;
  8401. };
  8402. $scope.endOpen = function ($event) {
  8403. $event.preventDefault();
  8404. $event.stopPropagation();
  8405. $scope.startOpened = false;
  8406. $scope.endOpened = !$scope.endOpened;
  8407. };
  8408. $scope.startOpen = function ($event) {
  8409. $event.preventDefault();
  8410. $event.stopPropagation();
  8411. $scope.endOpened = false;
  8412. $scope.startOpened = !$scope.startOpened;
  8413. };
  8414. $scope.datepickerPopup = 'yyyy-MM-dd HH:mm:ss';
  8415. // 获取状态-lmm
  8416. $scope.stateListData = {};
  8417. $scope.getStateData = function () {//lyl
  8418. var data = {
  8419. "key": 'task_sub_state',
  8420. "type": 'list'
  8421. }
  8422. api_wechatfile.getDictionary(data).then(function (res) {
  8423. angular.forEach(res, function (v, i) {
  8424. $scope.stateListData[v.value] = v.id;
  8425. })
  8426. })
  8427. }
  8428. $scope.getStateData();
  8429. // 草稿保存
  8430. $scope.ok = function (item) {
  8431. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8432. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8433. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8434. $scope.addData = {
  8435. "taskSub": {
  8436. "taskDescribe": $scope.taskDescribe,
  8437. "assign": $scope.personData.data,
  8438. "priority": $scope.priorityData.data,
  8439. "startTime": $scope.startTime,
  8440. "endTime": $scope.endTime,
  8441. "taskMonth": {
  8442. "id": scope.model.taskMonth.id
  8443. }
  8444. }
  8445. }
  8446. $scope.addData.taskSub["state"] = {
  8447. "id": $scope.stateListData[1]
  8448. };
  8449. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8450. if (res.status == 200) {
  8451. SweetAlert.swal({
  8452. title: "保存成功!",
  8453. type: "success",
  8454. confirmButtonColor: "#007AFF"
  8455. });
  8456. scope.refreshData(scope.jry_filterdata);
  8457. $modalInstance.dismiss('cancel');
  8458. } else {
  8459. SweetAlert.swal({
  8460. title: "保存失败",
  8461. text: "系统错误,请重试!",
  8462. type: "error"
  8463. });
  8464. $modalInstance.dismiss('cancel');
  8465. }
  8466. })
  8467. } else {
  8468. SweetAlert.swal({
  8469. title: "保存失败",
  8470. text: "必填项不能为空!",
  8471. type: "error"
  8472. });
  8473. }
  8474. };
  8475. // 发布
  8476. $scope.release = function () {
  8477. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8478. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8479. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8480. $scope.addData = {
  8481. "taskSub": {
  8482. "taskDescribe": $scope.taskDescribe,
  8483. "assign": $scope.personData.data,
  8484. "priority": $scope.priorityData.data,
  8485. "startTime": $scope.startTime,
  8486. "endTime": $scope.endTime,
  8487. "taskMonth": {
  8488. "id": scope.model.taskMonth.id
  8489. }
  8490. }
  8491. }
  8492. $scope.addData.taskSub["state"] = {
  8493. "id": $scope.stateListData[1]
  8494. };
  8495. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8496. if (res.status == 200) {
  8497. SweetAlert.swal({
  8498. title: "保存成功!",
  8499. type: "success",
  8500. confirmButtonColor: "#007AFF"
  8501. });
  8502. scope.refreshData(scope.jry_filterdata);
  8503. $modalInstance.dismiss('cancel');
  8504. } else {
  8505. SweetAlert.swal({
  8506. title: "保存失败",
  8507. text: "系统错误,请重试!",
  8508. type: "error"
  8509. });
  8510. $modalInstance.dismiss('cancel');
  8511. }
  8512. })
  8513. } else {
  8514. SweetAlert.swal({
  8515. title: "保存失败",
  8516. text: "必填项不能为空!",
  8517. type: "error"
  8518. });
  8519. }
  8520. }
  8521. $scope.cancel = function () {
  8522. $modalInstance.dismiss('cancel');
  8523. }
  8524. },
  8525. size: 'sm',
  8526. resolve: {
  8527. scope: function () {
  8528. return $scope;
  8529. },
  8530. },
  8531. backdrop: true
  8532. });
  8533. }
  8534. }
  8535. });
  8536. // 多次反馈文本域组件--jry
  8537. formlyConfigProvider.setType({
  8538. name: 'ui-feedbacktTextarea',
  8539. extends: 'textarea',
  8540. templateUrl: 'assets/views/customform/tpl/ui-feedbacktTextarea.html',
  8541. defaultOptions: function (options) {
  8542. return {
  8543. templateOptions: {
  8544. transform: function (model, value) {
  8545. return value;
  8546. },
  8547. },
  8548. validation: {
  8549. messages: {
  8550. maxlength: function (viewValue, modelValue, scope) {
  8551. if (viewValue != null) {
  8552. if (viewValue.length > scope.to.maxlength) {
  8553. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8554. } else {
  8555. return "";
  8556. }
  8557. }
  8558. },
  8559. }
  8560. }
  8561. }
  8562. },
  8563. controller: ['$scope', 'moment', function ($scope, moment) {
  8564. // console.log($scope);
  8565. var timeKey = $scope.options.templateOptions.time;
  8566. $scope.time = moment($scope.model[timeKey]).format('YYYY-MM-DD HH:mm:ss');
  8567. var value = $scope.model[$scope.options.key];
  8568. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8569. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8570. }
  8571. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  8572. $scope.options.templateOptions.felditem($scope);
  8573. }
  8574. }]
  8575. });
  8576. //任务管理开始时间--jry
  8577. formlyConfigProvider.setType({
  8578. name: 'ui-jryStartdatepicker',
  8579. templateUrl: 'assets/views/customform/tpl/ui-jryStartdatepicker.html',
  8580. extends: 'input',
  8581. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8582. defaultOptions: {
  8583. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8584. templateOptions: {
  8585. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8586. }
  8587. },
  8588. controller: ['$scope', '$filter', function ($scope, $filter) {
  8589. // console.log($scope.model[$scope.options.key],'lmm');
  8590. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8591. if ($scope.model[$scope.options.key]) {
  8592. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8593. }
  8594. // console.log($scope.model[$scope.options.key],'lmm');
  8595. // console.log($scope.model,'lmm',$scope.options.key);
  8596. $scope.options.initialValue = $scope.model[$scope.options.key];
  8597. $scope.endOpen = true;
  8598. $scope.datepicker = {};
  8599. $scope.datepicker.opened = false;
  8600. $scope.datepicker.open = function ($event) {
  8601. $scope.datepicker.opened = true;
  8602. };
  8603. }]
  8604. });
  8605. //任务管理结束时间--jry
  8606. formlyConfigProvider.setType({
  8607. name: 'ui-jryEnddatepicker',
  8608. templateUrl: 'assets/views/customform/tpl/ui-jryEnddatepicker.html',
  8609. extends: 'input',
  8610. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8611. defaultOptions: {
  8612. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8613. templateOptions: {
  8614. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8615. }
  8616. },
  8617. controller: ['$scope', '$filter', function ($scope, $filter) {
  8618. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8619. if ($scope.model[$scope.options.key]) {
  8620. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8621. }
  8622. $scope.options.initialValue = $scope.model[$scope.options.key];
  8623. $scope.endOpen = true;
  8624. $scope.datepicker = {};
  8625. $scope.datepicker.opened = false;
  8626. $scope.datepicker.open = function ($event) {
  8627. $scope.datepicker.opened = true;
  8628. };
  8629. }]
  8630. });
  8631. //下拉多选框灵活组件--jry
  8632. formlyConfigProvider.setType({
  8633. name: 'ui-jry_multiselectplus',
  8634. extends: 'multiCheckbox',
  8635. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8636. defaultOptions: function (options) {
  8637. return {
  8638. templateOptions: {
  8639. refreshData: function (search, options, model, that) {
  8640. // var process = options.templateOptions.ApiService.all("");
  8641. if (search) {
  8642. } else {
  8643. }
  8644. var postData = options.templateOptions.optionsPostData;
  8645. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8646. postData = options.templateOptions.optionsPostData(options, model, that);
  8647. }
  8648. options.templateOptions.ApiService.fetchDataList(options.templateOptions.optionsUrl, options.templateOptions.optionsPostData).then(function (result) {
  8649. // if (!options.templateOptions.options) {
  8650. // options.templateOptions.options = [];
  8651. // }
  8652. if (options.templateOptions.optionsDataKey) {
  8653. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8654. } else {
  8655. options.templateOptions.options = result;
  8656. }
  8657. if (options.templateOptions.optionsChecked) {
  8658. // return options.value = null;
  8659. options.value(options.model[options.key]);
  8660. }
  8661. });
  8662. },
  8663. refreshDelay: 0,
  8664. // },
  8665. validators: {
  8666. required: {
  8667. expression: function (viewValue, modelValue) {
  8668. var value = modelValue || viewValue;
  8669. return value != null;
  8670. // return value.length>=1;
  8671. // if (modelValue && viewValue) {
  8672. // return value != null;
  8673. // } else {
  8674. // var value = modelValue || viewValue;
  8675. // return value.length > 0;
  8676. // }
  8677. }
  8678. }
  8679. }
  8680. }
  8681. };
  8682. },
  8683. controller: ['$scope', function ($scope) {
  8684. console.log($scope.to);
  8685. if (angular.isArray($scope.model[$scope.options.key])) {
  8686. } else {
  8687. $scope.model[$scope.options.key] = [];
  8688. }
  8689. }]
  8690. });
  8691. //下拉框组件
  8692. formlyConfigProvider.setType({
  8693. name: 'ui-select',
  8694. extends: 'select',
  8695. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  8696. defaultOptions: function (options, scope) {
  8697. return {
  8698. templateOptions: {
  8699. // refresh: function() {},
  8700. refreshDelay: 0,
  8701. linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
  8702. console.log(model,'model')
  8703. angular.extend(data, {
  8704. "idx": 0,
  8705. "sum": 1000
  8706. });
  8707. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  8708. var myData = options.templateOptions.Restangular.stripRestangular(response);
  8709. var list = myData.list;
  8710. console.log(myData)
  8711. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  8712. // console.log('balabalabala');
  8713. // console.log(res);
  8714. // })
  8715. if (list.length == 1) {
  8716. if (options.templateOptions.APIport) {
  8717. options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
  8718. if (response.state == "200") {
  8719. // if (model.$parent.model && model.$parent.model.incident) {
  8720. // } else {
  8721. // model.$parent.model = { 'incident': {} };
  8722. // }
  8723. var myDatas = response.serviceLevelAgreement;
  8724. //逾期
  8725. scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
  8726. //解决
  8727. scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
  8728. //响应
  8729. scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
  8730. } else {
  8731. }
  8732. });
  8733. }
  8734. angular.forEach(model.fields, function (item) {
  8735. angular.forEach(model.fields, function (item) {
  8736. if (item.templateOptions.pkey == modelKey + "." + key) {
  8737. item.model.id = "";
  8738. if (key == "place") {
  8739. item.templateOptions.options = list;
  8740. } else if (key == "placeDTO") {
  8741. item.templateOptions.options = list;
  8742. } else if (key == "requester") {
  8743. } else {
  8744. item.value(list[0][key][item.key]);
  8745. }
  8746. }
  8747. })
  8748. })
  8749. } else {
  8750. if (model.fields) {
  8751. angular.forEach(model.fields, function (item) {
  8752. angular.forEach(model.fields, function (item) {
  8753. if (item.templateOptions.pkey == modelKey + "." + key) {
  8754. item.model.id = "";
  8755. if (key == "place") {
  8756. item.templateOptions.isnosearch = true;
  8757. item.templateOptions.options = list;
  8758. }
  8759. if (key == "placeDTO") {
  8760. item.templateOptions.options = list;
  8761. }
  8762. if (key == "requester") {
  8763. }
  8764. }
  8765. })
  8766. })
  8767. } else {
  8768. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8769. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8770. if (item.templateOptions.pkey == modelKey + "." + key) {
  8771. if (key == "place") {
  8772. item.templateOptions.isnosearch = true;
  8773. item.templateOptions.options = list;
  8774. scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
  8775. }
  8776. if (key == "placeDTO") {
  8777. item.templateOptions.options = list;
  8778. }
  8779. if (key == "requester") {
  8780. }
  8781. }
  8782. })
  8783. })
  8784. }
  8785. }
  8786. console.log(key)
  8787. //报修科室
  8788. if (key == 'dept') {
  8789. // 报修科室单选
  8790. scope.$parent.$parent.$parent.model.incident.department = response.list[0];
  8791. scope.$parent.$parent.$parent.model.incident.contactsInformation = response.list[0].phone;
  8792. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  8793. // 选择重复事件侧滑框
  8794. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  8795. setTimeout(() => {
  8796. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  8797. }, 500);
  8798. }
  8799. // 报修人
  8800. if (key == 'requester') {
  8801. // 报修人单选
  8802. scope.$parent.$parent.$parent.model.incident.requester = response.list[
  8803. 0];
  8804. console.log(scope.$parent.$parent.$parent.model)
  8805. scope.$parent.$parent.$parent.model.incident.account = response.list[
  8806. 0].account;
  8807. var selectedItem = response.list[
  8808. 0];
  8809. var data = {
  8810. 'requester': selectedItem
  8811. };
  8812. scope.$parent.$parent.$parent.model[
  8813. 'requestershow'] = selectedItem;
  8814. console.log(selectedItem, '----------------------')
  8815. // if (selectedItem.dept.place.place) {
  8816. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  8817. // }
  8818. scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.houseNumber?selectedItem.houseNumber:'';
  8819. scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place?selectedItem.place.area.id:null;
  8820. scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place?selectedItem.place.id:null;
  8821. console.log(scope,89898998)
  8822. // console.log(scope.formData,'接单页面');
  8823. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  8824. scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8825. scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8826. options.templateOptions.ApiService.addData('requester',
  8827. data).then(function (response) {
  8828. if (response.status == 200) {
  8829. if (scope.$parent.$parent.$parent) {
  8830. if (scope.$parent.$parent.$parent.place) {
  8831. scope.$parent.$parent.$parent.place.id = '';
  8832. }
  8833. if (scope.$parent.$parent.$parent.area) {
  8834. scope.$parent.$parent.$parent.area.id = '';
  8835. }
  8836. scope.$parent.$parent.$parent.model.incident.contacts = selectedItem.name;
  8837. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8838. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.mphone;
  8839. } else {
  8840. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.telephone;
  8841. }
  8842. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8843. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8844. }
  8845. }
  8846. if (!response.data.id) {
  8847. response.data.id = selectedItem.id
  8848. }
  8849. console.log(scope);
  8850. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  8851. // if (selectedItem.place && selectedItem.place.id) {
  8852. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8853. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  8854. // };
  8855. // } else {
  8856. // if (selectedItem.place && selectedItem.place.id) {
  8857. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8858. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  8859. // };
  8860. // }
  8861. // if(scope.$parent.$parent.$parent.model.incident.area){
  8862. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  8863. // }
  8864. if (selectedItem.id) {
  8865. scope.$parent.$parent.$parent.model.incident.account = selectedItem.account;
  8866. }
  8867. // 选择重复事件侧滑框
  8868. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  8869. scope.$parent.$parent.$parent.model[
  8870. 'repeatIncidentShow'] = false;
  8871. setTimeout(() => {
  8872. scope.$parent.$parent.$parent.model[
  8873. 'repeatIncidentShow'] = true;
  8874. },
  8875. 500);
  8876. // }
  8877. }
  8878. })
  8879. }
  8880. });
  8881. },
  8882. validators: {
  8883. required: {
  8884. expression: function (viewValue, modelValue) {
  8885. var value = modelValue || viewValue;
  8886. return value != null;
  8887. // return value.length>=1;
  8888. // if (modelValue && viewValue) {
  8889. // return value != null;
  8890. // } else {
  8891. // var value = modelValue || viewValue;
  8892. // return value.length > 0;
  8893. // }
  8894. }
  8895. }
  8896. }
  8897. },
  8898. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  8899. // $scope.myFilter = function(item) {
  8900. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  8901. // }
  8902. // console.log($scope,'风浪')
  8903. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  8904. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  8905. $scope.options.templateOptions.linkage("place", {
  8906. "place": {
  8907. "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
  8908. // area:{
  8909. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  8910. // }
  8911. }
  8912. }, $scope.$parent.$parent.$parent.model, "incident", "place");
  8913. }
  8914. }
  8915. $scope.myFilter = $scope;
  8916. // console.log($scope.options.templateOptions)
  8917. console.log($scope,77777)
  8918. // 关闭事件页面满意度评价下拉框处理
  8919. if($scope.options.templateOptions.onlyKey=="close_degree"){
  8920. $scope.model.id = $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id
  8921. }
  8922. if($scope.options.templateOptions.initData == 1){
  8923. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8924. }
  8925. if ($scope.options.templateOptions.transform) {
  8926. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8927. }
  8928. if (angular.isFunction($scope.options.templateOptions.translate)) {
  8929. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  8930. }
  8931. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  8932. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  8933. }
  8934. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  8935. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  8936. }
  8937. }]
  8938. };
  8939. }
  8940. });
  8941. //下拉多选框组件
  8942. formlyConfigProvider.setType({
  8943. name: 'ui-multiselect',
  8944. extends: 'select',
  8945. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  8946. defaultOptions: function (options) {
  8947. return {
  8948. templateOptions: {
  8949. refresh: function () { },
  8950. refreshDelay: 1000
  8951. }
  8952. };
  8953. },
  8954. controller: ['$scope', function ($scope) {
  8955. $scope.model[$scope.options.key] = [];
  8956. }]
  8957. });
  8958. //下拉多选框灵活组件
  8959. formlyConfigProvider.setType({
  8960. name: 'ui-multiselectplus',
  8961. extends: 'multiCheckbox',
  8962. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8963. defaultOptions: function (options, $scope) {
  8964. return {
  8965. templateOptions: {
  8966. refreshData: function (search, options, model, that) {
  8967. var process = options.templateOptions.ApiService.all("");
  8968. if (search) {
  8969. } else {
  8970. }
  8971. var postData = options.templateOptions.optionsPostData;
  8972. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8973. postData = options.templateOptions.optionsPostData(options, model, that);
  8974. }
  8975. if (options.templateOptions.modelreasondata) {
  8976. postData = options.templateOptions.modelreasondata
  8977. }
  8978. process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
  8979. // if (!options.templateOptions.options) {
  8980. // options.templateOptions.options = [];
  8981. // }
  8982. // 过滤下拉列表已选择的值
  8983. var modelVal = $scope.model[$scope.options.key];
  8984. for (var i = 0; i < result.list.length; i++) {
  8985. for (var j = 0; j < modelVal.length; j++) {
  8986. if (result.list[i].id == modelVal[j].id) {
  8987. result.list.splice(i, 1)
  8988. }
  8989. }
  8990. }
  8991. if (options.templateOptions.optionsDataKey) {
  8992. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8993. } else {
  8994. options.templateOptions.options = result;
  8995. }
  8996. if (options.templateOptions.optionsChecked) {
  8997. // return options.value = null;
  8998. options.value(options.model[options.key]);
  8999. }
  9000. });
  9001. },
  9002. refreshDelay: 0,
  9003. // },
  9004. // validators: {
  9005. // required: {
  9006. // expression: function(viewValue, modelValue) {
  9007. // var value = modelValue || viewValue;
  9008. // // return value.length>=1;
  9009. // // if (modelValue && viewValue) {
  9010. // // return value != null;
  9011. // // } else {
  9012. // // var value = modelValue || viewValue;
  9013. // // return value.length > 0;
  9014. // // }
  9015. // }
  9016. // }
  9017. }
  9018. };
  9019. },
  9020. controller: ['$scope', function ($scope) {
  9021. if (angular.isArray($scope.model[$scope.options.key])) {
  9022. } else {
  9023. $scope.model[$scope.options.key] = [];
  9024. }
  9025. }]
  9026. });
  9027. //下拉树形多选组件
  9028. formlyConfigProvider.setType({
  9029. name: 'ui-multiselect-tree',
  9030. extends: 'multiCheckbox',
  9031. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9032. defaultOptions: function (options) {
  9033. return {
  9034. templateOptions: {
  9035. linkage: function (modelName, data, model, modelKey, key) {
  9036. angular.extend(data, {
  9037. "idx": 0,
  9038. "sum": 10
  9039. });
  9040. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9041. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9042. var list = myData.list;
  9043. if (list.length == 1) {
  9044. angular.forEach(model.fields, function (item) {
  9045. angular.forEach(model.fields, function (item) {
  9046. if (item.templateOptions.pkey == modelKey + "." + key) {
  9047. item.model.id = "";
  9048. if (key == "place") {
  9049. item.templateOptions.options = list;
  9050. } else {
  9051. item.value(list[0][key][item.key]);
  9052. }
  9053. }
  9054. })
  9055. })
  9056. }
  9057. });
  9058. },
  9059. // my_tree_handler : function(items) {
  9060. // },
  9061. // onFilterCallback : function(items) {
  9062. // },
  9063. // onFilterCallback : function(items) {
  9064. // },
  9065. refresh: function (items) {
  9066. var treedata = [];
  9067. function convertListToTree(data, treeMap) {
  9068. treedata = data;
  9069. for (var i = 0; i < data.length; i++) {
  9070. for (var j = 0; j < data.length; j++) {
  9071. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9072. if (data[i].pid == data[j].id) {
  9073. data[i].parent = data[j];
  9074. }
  9075. }
  9076. }
  9077. }
  9078. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9079. var root = null; //Initially set our loop to null
  9080. //loop over data
  9081. for (var i = 0; i < data.length; i++) {
  9082. var datum = data[i];
  9083. //each node will have children, so let's give it a "children" poperty
  9084. datum.children = [];
  9085. //add an entry for this node to the map so that any future children can
  9086. //lookup the parent
  9087. idToNodeMap[datum.id] = datum;
  9088. //Does this node have a parent?
  9089. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9090. //Doesn't look like it, so this node is the root of the tree
  9091. root = datum;
  9092. treeMap[datum.id] = root;
  9093. } else {
  9094. //This node has a parent, so let's look it up using the id
  9095. parentNode = idToNodeMap[datum.parent.id];
  9096. //We don't need this property, so let's delete it.
  9097. delete datum.parent;
  9098. //Let's add the current node as a child of the parent node.
  9099. parentNode.children.push(datum);
  9100. }
  9101. }
  9102. return root;
  9103. }
  9104. function convertParentToChildList(data) {
  9105. // console.log("data="+JSON.stringify(data))
  9106. var treeMap = {};
  9107. var list = [];
  9108. convertListToTree(data, treeMap);
  9109. angular.forEach(treeMap, function (item) {
  9110. list.push(item);
  9111. });
  9112. return list;
  9113. }
  9114. function selectItem(pmodel, childrens) {
  9115. if (angular.isArray(pmodel)) {
  9116. angular.forEach(pmodel, function (index) {
  9117. if (index && index.id) {
  9118. angular.forEach(childrens, function (item) {
  9119. if (item.id == index.id) {
  9120. item.selected = true;
  9121. }
  9122. if (item && item.children) {
  9123. selectItem(pmodel, item.children);
  9124. }
  9125. });
  9126. }
  9127. })
  9128. } else {
  9129. if (pmodel && pmodel.id) {
  9130. angular.forEach(childrens, function (item) {
  9131. if (item.id == pmodel.id) {
  9132. item.selected = true;
  9133. }
  9134. if (item && item.children) {
  9135. selectItem(pmodel, item.children);
  9136. }
  9137. });
  9138. }
  9139. }
  9140. }
  9141. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9142. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9143. if (result.status == 200) {
  9144. if (!options.templateOptions.options) {
  9145. options.templateOptions.options = [];
  9146. }
  9147. if (options.templateOptions.optionsDataKey) {
  9148. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9149. } else {
  9150. options.templateOptions.options = convertParentToChildList(result);
  9151. }
  9152. //set default value
  9153. var pmodel, i = 0;
  9154. if (options.templateOptions.pkey) {
  9155. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9156. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9157. if (i == 0) {
  9158. if (options.model[p] == null) {
  9159. options.model[p] = {};
  9160. }
  9161. pmodel = options.model[p];
  9162. i++;
  9163. } else {
  9164. if (pmodel[p] == null) {
  9165. pmodel[p] = {};
  9166. }
  9167. pmodel = pmodel[p];
  9168. }
  9169. });
  9170. } else {
  9171. pmodel = options.model;
  9172. }
  9173. }
  9174. if (pmodel) {
  9175. pmodel = pmodel[options.key];
  9176. } else if (options.model) {
  9177. pmodel = options.model[options.key];
  9178. } else {
  9179. pmodel = options.templateOptions.options;
  9180. }
  9181. if (angular.isArray(pmodel)) {
  9182. if (pmodel) {
  9183. // if(options.templateOptions.isMultiSelect==true){
  9184. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  9185. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  9186. // })
  9187. // }else{
  9188. selectItem(pmodel, options.templateOptions.options);
  9189. // }
  9190. }
  9191. } else {
  9192. if (pmodel && pmodel.id) {
  9193. selectItem(pmodel, options.templateOptions.options);
  9194. }
  9195. }
  9196. items.inputModel = options.templateOptions.options;
  9197. }
  9198. });
  9199. }
  9200. },
  9201. validators: {
  9202. required: {
  9203. expression: function (viewValue, modelValue) {
  9204. var value = modelValue || viewValue;
  9205. if (angular.isArray(value)) {
  9206. for (var i = 0; i < value.length; i++) {
  9207. value[i] = {
  9208. id: value[i].id
  9209. }
  9210. }
  9211. return value.length > 0
  9212. } else {
  9213. // console.log(options)
  9214. // return value = "true";
  9215. return value != null;
  9216. }
  9217. }
  9218. }
  9219. }
  9220. }
  9221. },
  9222. controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
  9223. if ($scope.options.templateOptions.isMultiSelect) {
  9224. // console.log($scope);
  9225. } else {
  9226. if ($scope.model[$scope.options.key]) {
  9227. }
  9228. }
  9229. }]
  9230. });
  9231. //多选下拉框组件
  9232. formlyConfigProvider.setType({
  9233. name: 'ui-multi-select-tree',
  9234. extends: 'input',
  9235. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9236. defaultOptions: function (options) {
  9237. return {
  9238. templateOptions: {
  9239. linkage: function (modelName, data, model, modelKey, key) {
  9240. angular.extend(data, {
  9241. "idx": 0,
  9242. "sum": 10
  9243. });
  9244. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9245. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9246. var list = myData.list;
  9247. if (list.length == 1) {
  9248. angular.forEach(model.fields, function (item) {
  9249. angular.forEach(model.fields, function (item) {
  9250. if (item.templateOptions.pkey == modelKey + "." + key) {
  9251. item.model.id = "";
  9252. if (key == "place") {
  9253. item.templateOptions.options = list;
  9254. } else {
  9255. item.value(list[0][key][item.key]);
  9256. }
  9257. }
  9258. })
  9259. })
  9260. }
  9261. });
  9262. },
  9263. getparentdata: function (items) {
  9264. // console.log(items)
  9265. },
  9266. refresh: function (items, search, fn) {
  9267. console.log(items);
  9268. var treedata = [];
  9269. function convertListToTree(data, treeMap) {
  9270. // console.log(data)
  9271. treedata = data;
  9272. for (var i = 0; i < data.length; i++) {
  9273. for (var j = 0; j < data.length; j++) {
  9274. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9275. if (data[i].pid == data[j].id) {
  9276. data[i].parent = data[j];
  9277. }
  9278. }
  9279. // if (data[i].id) {
  9280. // if (data[i].id== data[j].id) {
  9281. // data[i].parent = data[j];
  9282. // }
  9283. // }
  9284. }
  9285. }
  9286. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9287. var root = []; //Initially set our loop to null
  9288. if (search == 'search' && items.filterKeyword) {
  9289. function transform(nodes) {
  9290. var treeConverter = {
  9291. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  9292. attributeName: 'id', //节点唯一标识符
  9293. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  9294. transform: function (node) { //转化递归函数,参数:一个待插入节点
  9295. if (node.parent != null) { //该节点有父节点
  9296. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  9297. if (this.needFind) {
  9298. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  9299. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  9300. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9301. }
  9302. }
  9303. }
  9304. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  9305. // delete node.parent; //删除该节点的parent属性,如果有的话
  9306. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  9307. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  9308. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  9309. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  9310. // delete node.parent; //删除该节点的parent属性,如果有的话
  9311. if (this.result == null) { //根节点不存在
  9312. node.children = []; //给该节点增加children:[]属性
  9313. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9314. } else {
  9315. node.children = [];
  9316. // 顶级去重
  9317. for (var i = 0; i < this.result.children.length; i++) {
  9318. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  9319. return this.result.children[i];
  9320. }
  9321. }
  9322. this.result.children.push(node)
  9323. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9324. }
  9325. }
  9326. },
  9327. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  9328. var _node = {};
  9329. _node.children = [];
  9330. this.result = _node; //重置根节点
  9331. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  9332. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  9333. nodes.forEach(item => { //循环调用转化方法
  9334. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  9335. this.transform(item);
  9336. })
  9337. return this.result; //返回根节点
  9338. }
  9339. }
  9340. var result = treeConverter.getWhole(nodes); //调用
  9341. return result;
  9342. }
  9343. var li = transform(data).children;
  9344. // li=[...new Set(li)]
  9345. console.log(li)
  9346. treeMap = li;
  9347. fn(li);
  9348. return li;
  9349. } else {
  9350. //loop over data
  9351. for (var i = 0; i < data.length; i++) {
  9352. var datum = data[i];
  9353. //each node will have children, so let's give it a "children" poperty
  9354. datum.children = [];
  9355. //add an entry for this node to the map so that any future children can
  9356. //lookup the parent
  9357. idToNodeMap[datum.id] = datum;
  9358. //Does this node have a parent?
  9359. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9360. //Doesn't look like it, so this node is the root of the tree
  9361. root = datum;
  9362. treeMap[datum.id] = root;
  9363. } else {
  9364. //This node has a parent, so let's look it up using the id
  9365. parentNode = idToNodeMap[datum.parent.id];
  9366. //We don't need this property, so let's delete it.
  9367. // delete datum.parent;
  9368. //Let's add the current node as a child of the parent node.
  9369. parentNode.children.push(datum);
  9370. }
  9371. }
  9372. }
  9373. return root;
  9374. }
  9375. function convertParentToChildList(data) {
  9376. var treeMap = {};
  9377. var list = [];
  9378. if (search == 'search' && items.filterKeyword) {
  9379. var lis = convertListToTree(data, treeMap)
  9380. return lis;
  9381. } else {
  9382. if (data[0] && data[0].orders) {
  9383. list = data;
  9384. } else {
  9385. convertListToTree(data, treeMap);
  9386. angular.forEach(treeMap, function (item) {
  9387. // console.log("item="+JSON.stringify(item))
  9388. list.push(item);
  9389. });
  9390. }
  9391. return list;
  9392. }
  9393. }
  9394. function selectItem(pmodel, childrens) {
  9395. if (angular.isArray(pmodel)) {
  9396. angular.forEach(pmodel, function (index) {
  9397. if (index && index.id) {
  9398. angular.forEach(childrens, function (item) {
  9399. if (item.id == index.id) {
  9400. item.selected = true;
  9401. }
  9402. if (item && item.children) {
  9403. selectItem(pmodel, item.children);
  9404. }
  9405. });
  9406. // angular.forEach(treedata,function(parentdata){
  9407. // if(parentdata.id == index.id){
  9408. // if(parentdata.parent&&parentdata.parent.id){
  9409. // parentdata.parent.$
  9410. // }
  9411. // item.selected = true;
  9412. // }
  9413. // if (item && item.children) {
  9414. // selectItem(pmodel ,item.children);
  9415. // }
  9416. // });
  9417. }
  9418. })
  9419. } else {
  9420. if (pmodel && pmodel.id) {
  9421. angular.forEach(childrens, function (item, index) {
  9422. if (item.id == pmodel.id) {
  9423. item.selected = true;
  9424. delete item.children;
  9425. }
  9426. if (item && item.children) {
  9427. selectItem(pmodel, item.children);
  9428. }
  9429. });
  9430. }
  9431. }
  9432. }
  9433. function selectItemchild(pmodel, childrens) {
  9434. if (angular.isArray(pmodel)) {
  9435. angular.forEach(pmodel, function (index) {
  9436. if (index && index.id) {
  9437. angular.forEach(childrens, function (item) {
  9438. if (item.id == index.id) {
  9439. item.selected = true;
  9440. }
  9441. if (item && item.children) {
  9442. selectItem(pmodel, item.children);
  9443. }
  9444. });
  9445. }
  9446. })
  9447. } else {
  9448. if (pmodel && pmodel.id) {
  9449. angular.forEach(childrens, function (item, index) {
  9450. if (item.id == pmodel.id) {
  9451. item.selected = true;
  9452. childrens[index].selected = true;
  9453. }
  9454. if (item && item.children) {
  9455. selectItem(pmodel, item.children);
  9456. }
  9457. });
  9458. }
  9459. }
  9460. }
  9461. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9462. if (search === 'search' && items.filterKeyword) {
  9463. // bala:树形模糊搜索
  9464. options.templateOptions.bala(options.templateOptions.APIService, items.filterKeyword).then(function (result) {
  9465. result.list = [...new Set(result.list)]; //去重
  9466. if (!options.templateOptions.options) {
  9467. options.templateOptions.options = [];
  9468. }
  9469. if (options.templateOptions.optionsDataKey) {
  9470. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9471. } else {
  9472. options.templateOptions.options = convertParentToChildList(result);
  9473. }
  9474. //set default value
  9475. var pmodel, i = 0;
  9476. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9477. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9478. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9479. if (i == 0) {
  9480. if (options.model[p] == null) {
  9481. options.model[p] = {};
  9482. }
  9483. pmodel = options.model[p];
  9484. i++;
  9485. } else {
  9486. if (pmodel[p] == null) {
  9487. pmodel[p] = {};
  9488. }
  9489. pmodel = pmodel[p];
  9490. }
  9491. });
  9492. } else {
  9493. pmodel = options.model;
  9494. }
  9495. }
  9496. var topdata = angular.copy(options.templateOptions.options);
  9497. if (pmodel) {
  9498. pmodel = pmodel[options.key];
  9499. } else if (options.model) {
  9500. pmodel = options.model[options.key];
  9501. }
  9502. if (angular.isArray(pmodel)) {
  9503. if (pmodel) {
  9504. items.inputModel = angular.copy(options.templateOptions.options);
  9505. selectItem(pmodel, options.templateOptions.options);
  9506. }
  9507. } else {
  9508. if (pmodel && pmodel.id) {
  9509. items.inputModel = angular.copy(options.templateOptions.options);
  9510. selectItem(pmodel, options.templateOptions.options);
  9511. } else {
  9512. // items.inputModel = options.templateOptions.options;
  9513. }
  9514. }
  9515. // items.inputModel = options.templateOptions.options;
  9516. items.selectModel = options.templateOptions.options;
  9517. // 可在此展开
  9518. if (!items.inputModel) {
  9519. items.inputModel = items.selectModel;
  9520. } else {
  9521. selectItemchild(pmodel, items.inputModel);
  9522. // for (var i = 0; i < items.inputModel.length; i++) {
  9523. // items.inputModel[i].
  9524. // for (var j = 0; j < items.selectModel.length; j++) {
  9525. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9526. // items.inputModel[i].selected = true;
  9527. // }
  9528. // }
  9529. // }
  9530. }
  9531. return items.inputModel;
  9532. // options.templateOptions.options = angular.copy(topdata);
  9533. // console.log(model);
  9534. // console.log(options);
  9535. });
  9536. } else {
  9537. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9538. if (!options.templateOptions.options) {
  9539. options.templateOptions.options = [];
  9540. }
  9541. if (options.templateOptions.optionsDataKey) {
  9542. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9543. } else {
  9544. options.templateOptions.options = convertParentToChildList(result);
  9545. }
  9546. //set default value
  9547. var pmodel, i = 0;
  9548. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9549. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9550. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9551. if (i == 0) {
  9552. if (options.model[p] == null) {
  9553. options.model[p] = {};
  9554. }
  9555. pmodel = options.model[p];
  9556. i++;
  9557. } else {
  9558. if (pmodel[p] == null) {
  9559. pmodel[p] = {};
  9560. }
  9561. pmodel = pmodel[p];
  9562. }
  9563. });
  9564. } else {
  9565. pmodel = options.model;
  9566. }
  9567. }
  9568. var topdata = angular.copy(options.templateOptions.options);
  9569. if (pmodel) {
  9570. pmodel = pmodel[options.key];
  9571. } else if (options.model) {
  9572. pmodel = options.model[options.key];
  9573. }
  9574. if (angular.isArray(pmodel)) {
  9575. if (pmodel) {
  9576. items.inputModel = angular.copy(options.templateOptions.options);
  9577. selectItem(pmodel, options.templateOptions.options);
  9578. }
  9579. } else {
  9580. if (pmodel && pmodel.id) {
  9581. items.inputModel = angular.copy(options.templateOptions.options);
  9582. selectItem(pmodel, options.templateOptions.options);
  9583. } else {
  9584. // items.inputModel = options.templateOptions.options;
  9585. }
  9586. }
  9587. // items.inputModel = options.templateOptions.options;
  9588. items.selectModel = options.templateOptions.options;
  9589. if (!items.inputModel) {
  9590. items.inputModel = items.selectModel;
  9591. } else {
  9592. selectItemchild(pmodel, items.inputModel);
  9593. // for (var i = 0; i < items.inputModel.length; i++) {
  9594. // for (var j = 0; j < items.selectModel.length; j++) {
  9595. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9596. // items.inputModel[i].selected = true;
  9597. // }
  9598. // }
  9599. // }
  9600. }
  9601. // options.templateOptions.options = angular.copy(topdata);
  9602. // console.log(model);
  9603. // console.log(options);
  9604. });
  9605. }
  9606. }
  9607. },
  9608. validators: {
  9609. required: {
  9610. expression: function (viewValue, modelValue) {
  9611. var value = modelValue || viewValue;
  9612. if (angular.isArray(value)) {
  9613. return value.length > 0
  9614. } else {
  9615. // console.log(options)
  9616. if (options.templateOptions.required && !value) {
  9617. // return value != null;
  9618. } else {
  9619. return value;
  9620. }
  9621. // return value = "true";
  9622. }
  9623. }
  9624. }
  9625. }
  9626. }
  9627. },
  9628. controller: ['$scope', '$rootScope', 'api_configure_form', 'api_bpm_domain', function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  9629. $rootScope.checkClicked = function (item) {
  9630. angular.forEach($scope.to.options, function (itemone) {
  9631. if (!item.parent) {
  9632. if (item.id == itemone.id) {
  9633. // itemone.isExpanded = true;
  9634. } else {
  9635. itemone.isExpanded = false;
  9636. }
  9637. } else {
  9638. if (item.parent.id == itemone.id) {
  9639. angular.forEach(itemone.children, function (itemtwo) {
  9640. if (item.id == itemtwo.id) { } else {
  9641. itemtwo.isExpanded = false;
  9642. }
  9643. })
  9644. }
  9645. }
  9646. })
  9647. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  9648. console.log($scope,'gsm');
  9649. if ($scope.originalModel && $scope.originalModel.incident && item.category && (!item.children || !item.children.length) && item.priority && item.priority.id) {
  9650. api_bpm_domain.expectedTime('L' + (item.priority.id - 1559)).then(function (res) {
  9651. $scope.originalModel.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  9652. $scope.originalModel.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  9653. $scope.originalModel.incident.overdueTime = res.date;
  9654. })
  9655. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9656. // setTimeout(() => {
  9657. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9658. // }, 500);
  9659. // console.log($scope.$parent.$parent.$parent)
  9660. }
  9661. }
  9662. if ($scope.options.templateOptions.isMultiSelect) {
  9663. // console.log($scope);
  9664. } else {
  9665. if ($scope.model[$scope.options.key]) {
  9666. }
  9667. }
  9668. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  9669. // console.log(item)
  9670. // // if(){
  9671. // // }
  9672. // // $scope.model[$scope.options.key]=item.id;
  9673. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  9674. // $scope.propTypeOptions = data;
  9675. // });
  9676. // }
  9677. // $scope.model[$scope.options.key]=[];
  9678. // $scope.fn
  9679. $rootScope.bala1 = function (items, fn) {
  9680. // $scope.fn = fn;
  9681. console.log(items)
  9682. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  9683. $scope.options.templateOptions.refresh(items, 'search', fn)
  9684. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  9685. // // return res.list;
  9686. // console.log(666)
  9687. // fn(res.list)
  9688. // })
  9689. }
  9690. }]
  9691. });
  9692. //勾选组件
  9693. formlyConfigProvider.setType({
  9694. name: 'ui-checkbox',
  9695. extends: 'checkbox',
  9696. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  9697. controller: ['$scope', function ($scope) {
  9698. // 巡检生成事件,默认派单
  9699. if ($scope.model.isInspection) {
  9700. $scope.model[$scope.options.key] = true;
  9701. };
  9702. if ($scope.model[$scope.options.key] == "true") {
  9703. $scope.model[$scope.options.key] = true;
  9704. };
  9705. if ($scope.model[$scope.options.key] == "false") {
  9706. $scope.model[$scope.options.key] = false;
  9707. };
  9708. }]
  9709. });
  9710. //换行组件
  9711. formlyConfigProvider.setType({
  9712. name: 'ui-nextLine',
  9713. /*extends: 'input',*/
  9714. template: '<div></div>',
  9715. });
  9716. //多选框组件
  9717. formlyConfigProvider.setType({
  9718. name: 'ui-checklist',
  9719. extends: 'multiCheckbox',
  9720. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  9721. defaultOptions: function (options) {
  9722. return {
  9723. templateOptions: {
  9724. refresh: function () { },
  9725. refreshDelay: 0
  9726. }
  9727. };
  9728. }
  9729. });
  9730. //单选框组件
  9731. formlyConfigProvider.setType({
  9732. name: 'ui-radio',
  9733. extends: 'radio',
  9734. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  9735. defaultOptions: function (options) {
  9736. return {
  9737. templateOptions: {
  9738. refresh: function () { },
  9739. refreshDelay: 0
  9740. }
  9741. };
  9742. },
  9743. controller: ['$scope', function ($scope) {
  9744. // 巡检生成事件,默认派单
  9745. if ($scope.model.isInspection) {
  9746. $scope.model[$scope.options.key] = true;
  9747. // $scope.model.isHandlerUser=true;
  9748. $scope.model.start_code = "assignment";
  9749. console.log($scope.model);
  9750. };
  9751. //多次暂存配置
  9752. // console.log($scope);
  9753. if ($scope.model.saveAgain) {
  9754. if ($scope.model.directClose == "1" || $scope.model.directClose == true) {
  9755. $scope.model[$scope.options.key] = true;
  9756. // if($scope.model.incident.handlingPersonnelUser){
  9757. // delete $scope.model.incident.handlingPersonnelUser;
  9758. // };
  9759. if ($scope.model.incident.handleDescription) {
  9760. delete $scope.model.incident.handleDescription
  9761. };
  9762. if ($scope.model.incident.closecode) {
  9763. delete $scope.model.incident.closecode
  9764. };
  9765. if ($scope.model.incident.degree) {
  9766. delete $scope.model.incident.degree
  9767. }
  9768. } else {
  9769. $scope.model.incident.handlingPersonnelUser = $scope.model.incident.acceptUser;
  9770. $scope.model[$scope.options.key] = false
  9771. }
  9772. }
  9773. }]
  9774. });
  9775. //文本域组件
  9776. formlyConfigProvider.setWrapper({
  9777. name: 'validation',
  9778. types: ['ui-textarea'],
  9779. template: "<formly-transclude></formly-transclude><div class=\"has-error\" ng-messages=\"fc.$error\" ng-if=\"options.formControl.$touched\"><div class=\"error\" ng-message=\"{{::name}}\" ng-repeat=\"(name, message) in ::options.validation.messages\">{{message(fc.$viewValue, fc.$modelValue, this)}}</div></div>"
  9780. });
  9781. formlyConfigProvider.setType({
  9782. name: 'ui-textarea',
  9783. extends: 'textarea',
  9784. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  9785. defaultOptions: function (options) {
  9786. return {
  9787. templateOptions: {
  9788. transform: function (model, value) {
  9789. return value;
  9790. },
  9791. },
  9792. validation: {
  9793. messages: {
  9794. maxlength: function (viewValue, modelValue, scope) {
  9795. if (viewValue != null) {
  9796. if (viewValue.length > scope.to.maxlength) {
  9797. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9798. } else {
  9799. return "";
  9800. }
  9801. }
  9802. },
  9803. }
  9804. }
  9805. }
  9806. },
  9807. controller: ['$scope', function ($scope) {
  9808. var value = $scope.model[$scope.options.key];
  9809. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9810. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9811. }
  9812. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9813. $scope.options.templateOptions.felditem($scope);
  9814. }
  9815. }]
  9816. });
  9817. // div版的textarea(展示富文本框内容用)
  9818. formlyConfigProvider.setType({
  9819. name: 'ui-divTextarea',
  9820. extends: 'textarea',
  9821. templateUrl: 'assets/views/customform/tpl/ui-divTextarea.html',
  9822. defaultOptions: function (options) {
  9823. return {
  9824. templateOptions: {
  9825. transform: function (model, value) {
  9826. return value;
  9827. },
  9828. },
  9829. validation: {
  9830. messages: {
  9831. // maxlength: function (viewValue, modelValue, scope) {
  9832. // if (viewValue != null) {
  9833. // if (viewValue.length > scope.to.maxlength) {
  9834. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9835. // } else {
  9836. // return "";
  9837. // }
  9838. // }
  9839. // },
  9840. }
  9841. }
  9842. }
  9843. },
  9844. controller: ['$scope', function ($scope) {
  9845. var value = $scope.model[$scope.options.key];
  9846. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9847. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9848. }
  9849. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9850. $scope.options.templateOptions.felditem($scope);
  9851. }
  9852. }]
  9853. });
  9854. // 带有知识库引用的textarea
  9855. formlyConfigProvider.setType({
  9856. name: 'ui-textAreaKnowledge',
  9857. // extends: 'textarea',
  9858. templateUrl: 'assets/views/customform/tpl/ui-textAreaKnowledge.html',
  9859. defaultOptions: function (options) {
  9860. return {
  9861. templateOptions: {
  9862. transform: function (model, value) {
  9863. return value;
  9864. },
  9865. },
  9866. validation: {
  9867. messages: {
  9868. maxlength: function (viewValue, modelValue, scope) {
  9869. if (viewValue != null) {
  9870. if (viewValue.length > scope.to.maxlength) {
  9871. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9872. } else {
  9873. return "";
  9874. }
  9875. }
  9876. },
  9877. }
  9878. }
  9879. }
  9880. },
  9881. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_bpm_domain', 'api_solution', '$aside', 'api_zsk', 'up_down_file', 'api_wechatfile', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_bpm_domain, api_solution, $aside, api_zsk, up_down_file, api_wechatfile) {
  9882. // console.log($scope);
  9883. var value = $scope.model[$scope.options.key];
  9884. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9885. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9886. }
  9887. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9888. $scope.options.templateOptions.felditem($scope);
  9889. }
  9890. // 引用知识库点击
  9891. $scope.openSolution = function () {
  9892. $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9893. setTimeout(() => {
  9894. $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9895. }, 100);
  9896. }
  9897. }]
  9898. });
  9899. //常用语句选择textarea
  9900. formlyConfigProvider.setType({
  9901. name: 'ui-textselect',
  9902. extends: 'textarea',
  9903. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  9904. defaultOptions: function (options) {
  9905. return {
  9906. templateOptions: {
  9907. transform: function (model, value) {
  9908. return value;
  9909. },
  9910. },
  9911. validation: {
  9912. messages: {
  9913. maxlength: function (viewValue, modelValue, scope) {
  9914. if (viewValue != null) {
  9915. if (viewValue.length > scope.to.maxlength) {
  9916. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9917. } else {
  9918. return "";
  9919. }
  9920. }
  9921. },
  9922. }
  9923. }
  9924. }
  9925. },
  9926. controller: ['$scope', function ($scope) {
  9927. var value = $scope.model[$scope.options.key];
  9928. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9929. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9930. }
  9931. }]
  9932. });
  9933. //改动的组件 ckeditor封装后的组件
  9934. formlyConfigProvider.setType({
  9935. name: 'ui-text-check',
  9936. extends: 'textarea',
  9937. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  9938. defaultOptions: function (options) {
  9939. return {
  9940. templateOptions: {
  9941. extraPlugins: 'uploadimage',
  9942. uploadimageConfig: {
  9943. backend: 'basic',
  9944. settings: {
  9945. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  9946. headers: '',
  9947. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  9948. }
  9949. },
  9950. refresh: function (APIService, contentId, data) {
  9951. return APIService.fetchDataList(contentId, data);
  9952. },
  9953. downloadUri: function (APIService, contentId) {
  9954. return APIService.downloadAttachment(contentId).getRequestedUrl();
  9955. },
  9956. upload: function (APIService, contentId) {
  9957. return APIService.getSolutionDowpath(contentId);
  9958. },
  9959. view: function (attachmentId) {
  9960. // return APIService.attachmentsPreviewUrl(contentId);
  9961. },
  9962. refreshDelay: 0,
  9963. transform: function (model, value) {
  9964. return value;
  9965. },
  9966. },
  9967. validation: {
  9968. messages: {
  9969. maxlength: function (viewValue, modelValue, scope) {
  9970. if (viewValue != null) {
  9971. if (viewValue.length > scope.to.maxlength) {
  9972. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9973. } else {
  9974. return "";
  9975. }
  9976. }
  9977. },
  9978. }
  9979. }
  9980. }
  9981. },
  9982. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  9983. var value = $scope.model[$scope.options.key];
  9984. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9985. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9986. }
  9987. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  9988. //var expiry={'expiry':14804244006};
  9989. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  9990. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  9991. $scope.upload = function (contentId, filename) {
  9992. var filename = filename;
  9993. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  9994. var file = new Blob([response], {
  9995. type: 'application/octet-stream'
  9996. });
  9997. // var filename = filename;
  9998. var fileURL = URL.createObjectURL(file);
  9999. var a = document.createElement('a');
  10000. a.href = fileURL;
  10001. a.target = '_blank';
  10002. a.download = filename;
  10003. document.body.appendChild(a);
  10004. a.click();
  10005. })
  10006. };
  10007. }]
  10008. });
  10009. //改动的组件 ckeditor封装后的附文本组件
  10010. formlyConfigProvider.setType({
  10011. name: 'ui-fuwenben',
  10012. extends: 'textarea',
  10013. templateUrl: 'assets/views/customform/tpl/ui-fuwenben.html',
  10014. defaultOptions: function (options) {
  10015. return {
  10016. templateOptions: {
  10017. allowedContent: 'img[!src]',//允许展示源码的标签,否则会被富文本框强制删除
  10018. extraPlugins: 'uploadimage',
  10019. uploadimageConfig: {
  10020. backend: 'basic',
  10021. settings: {
  10022. uploadUrl: options.templateOptions.APIService.upload(-110).getRequestedUrl(),
  10023. headers: '',
  10024. downloadUrl: options.templateOptions.APIService.uploadResponseUri()
  10025. }
  10026. },
  10027. refresh: function (APIService, contentId, data) {
  10028. return APIService.fetchDataList(-110, data);
  10029. },
  10030. downloadUri: function (APIService, contentId) {
  10031. return APIService.downloadAttachment(-110).getRequestedUrl();
  10032. },
  10033. upload: function (APIService, contentId) {
  10034. return APIService.getSolutionDowpath(-110);
  10035. },
  10036. view: function (attachmentId) {
  10037. // return APIService.attachmentsPreviewUrl(contentId);
  10038. },
  10039. refreshDelay: 0,
  10040. transform: function (model, value) {
  10041. return value;
  10042. },
  10043. },
  10044. validation: {
  10045. messages: {
  10046. maxlength: function (viewValue, modelValue, scope) {
  10047. if (viewValue != null) {
  10048. if (viewValue.length > scope.to.maxlength) {
  10049. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  10050. } else {
  10051. return "";
  10052. }
  10053. }
  10054. },
  10055. }
  10056. }
  10057. }
  10058. },
  10059. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10060. var value = $scope.model[$scope.options.key];
  10061. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10062. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10063. }
  10064. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10065. //var expiry={'expiry':14804244006};
  10066. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10067. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10068. $scope.upload = function (contentId, filename) {
  10069. var filename = filename;
  10070. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, -110).then(function (response) {
  10071. var file = new Blob([response], {
  10072. type: 'application/octet-stream'
  10073. });
  10074. // var filename = filename;
  10075. var fileURL = URL.createObjectURL(file);
  10076. var a = document.createElement('a');
  10077. a.href = fileURL;
  10078. a.target = '_blank';
  10079. a.download = filename;
  10080. document.body.appendChild(a);
  10081. a.click();
  10082. })
  10083. };
  10084. }]
  10085. });
  10086. //ui-grid展示控件
  10087. formlyConfigProvider.setType({
  10088. name: 'ui-grid-show',
  10089. extends: 'multiCheckbox',
  10090. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  10091. defaultOptions: function (options) {
  10092. return {
  10093. templateOptions: {
  10094. linkage: function () {
  10095. },
  10096. },
  10097. };
  10098. },
  10099. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  10100. var loginUser = $rootScope.user;
  10101. $scope.langs = i18nService.getAllLangs();
  10102. $scope.lang = 'zh-cn';
  10103. i18nService.setCurrentLang($scope.lang);
  10104. $scope.gridOptions = {};
  10105. $scope.gridOptions.data = 'myData';
  10106. $scope.gridOptions.enableColumnResizing = true;
  10107. // $scope.gridOptions.enableFiltering = true;
  10108. $scope.gridOptions.enableGridMenu = false;
  10109. $scope.gridOptions.enableRowSelection = true;
  10110. $scope.gridOptions.showGridFooter = true;
  10111. $scope.gridOptions.showColumnFooter = false;
  10112. $scope.gridOptions.fastWatch = true;
  10113. $scope.gridOptions.useExternalFiltering = true;
  10114. $scope.gridOptions.useExternalPagination = true;
  10115. $scope.gridOptions.paginationPageSizes = [10];
  10116. $scope.gridOptions.paginationPageSize = 10;
  10117. $scope.gridOptions.multiSelect = true;
  10118. $scope.gridOptions.rowIdentity = function (row) {
  10119. return row.id;
  10120. };
  10121. $scope.gridOptions.getRowIdentity = function (row) {
  10122. return row.id;
  10123. };
  10124. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10125. $scope.gridOptions.columnDefs = [
  10126. // { name:'id', width:80, enableFiltering:false},
  10127. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  10128. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  10129. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  10130. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  10131. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  10132. {
  10133. name: 'inspection.title',
  10134. displayName: '计划主题',
  10135. width: 120,
  10136. enableFiltering: false
  10137. },
  10138. {
  10139. name: 'stateName',
  10140. displayName: '状态',
  10141. width: 80,
  10142. enableFiltering: false
  10143. },
  10144. {
  10145. name: 'processUser.name',
  10146. displayName: '处理人',
  10147. width: 80,
  10148. enableFiltering: false
  10149. },
  10150. {
  10151. name: 'startDate',
  10152. displayName: '开始时间',
  10153. width: 160,
  10154. enableFiltering: false
  10155. },
  10156. {
  10157. name: 'overdueTime',
  10158. displayName: '逾期时间',
  10159. width: 160,
  10160. enableFiltering: false
  10161. },
  10162. ];
  10163. var defaultFilterData = {
  10164. "idx": 0,
  10165. "sum": 10
  10166. };
  10167. //分页控制
  10168. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10169. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10170. var filtersData = $scope.memoryfilterData;
  10171. filtersData.idx = newPage - 1;
  10172. filtersData.sum = pageSize;
  10173. $scope.refreshData('expand-right', filtersData);
  10174. });
  10175. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10176. data.grid.appScope.selected.items = data.entity
  10177. });
  10178. };
  10179. //页面获取数据
  10180. $scope.refreshData = function (style, filterData) {
  10181. // $scope.ldloading[style.replace('-', '_')] = true;
  10182. if (angular.isUndefined(filterData)) {
  10183. filterData = defaultFilterData;
  10184. }
  10185. $scope.myData = [];
  10186. angular.extend(filterData, {
  10187. inspectionProcessActual: {
  10188. "inspectionid": $scope.model.id
  10189. }
  10190. })
  10191. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
  10192. var myData = Restangular.stripRestangular(data);
  10193. $scope.gridOptions.totalItems = myData.totalNum;
  10194. $scope.myData = myData.list;
  10195. for (var i = 0; i < $scope.myData.length; i++) {
  10196. //添加序号
  10197. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  10198. }
  10199. // $scope.ldloading[style.replace('-', '_')] = false;
  10200. }, function () {
  10201. // $scope.ldloading[style.replace('-', '_')] = false;
  10202. });
  10203. };
  10204. $scope.refreshData('expand-right', defaultFilterData);
  10205. }
  10206. });
  10207. //文本框自定义选择面板组件
  10208. formlyConfigProvider.setType({
  10209. name: 'ui-input-selectmodal',
  10210. extends: 'input',
  10211. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  10212. defaultOptions: function (options) {
  10213. return {
  10214. templateOptions: {
  10215. openModal: function (size, options, modal) {
  10216. var modalInstance = modal.open({
  10217. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  10218. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  10219. size: size,
  10220. resolve: options.templateOptions.modalParam
  10221. });
  10222. modalInstance.result.then(function (selectedItem) {
  10223. options.value(selectedItem);
  10224. }, function () {
  10225. //console.log('Modal dismissed at: ' + new Date());
  10226. });
  10227. }
  10228. }
  10229. };
  10230. }
  10231. });
  10232. //日期控件
  10233. var datepicker_attr = [
  10234. 'date-disabled',
  10235. 'custom-class',
  10236. 'show-weeks',
  10237. 'starting-day',
  10238. 'init-date',
  10239. 'min-mode',
  10240. 'max-mode',
  10241. 'format-day',
  10242. 'format-month',
  10243. 'format-year',
  10244. 'format-day-header',
  10245. 'format-day-title',
  10246. 'format-month-title',
  10247. 'year-range',
  10248. 'shortcut-propagation',
  10249. 'datepicker-popup',
  10250. 'show-button-bar',
  10251. 'current-text',
  10252. 'clear-text',
  10253. 'close-text',
  10254. 'close-on-date-selection',
  10255. 'datepicker-append-to-body'
  10256. ];
  10257. var datepicker_bindings = [
  10258. 'datepicker-mode',
  10259. 'min-date',
  10260. 'max-date'
  10261. ];
  10262. formlyConfigProvider.setType({
  10263. name: 'ui-datetime',
  10264. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  10265. extends: 'input',
  10266. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10267. defaultOptions: {
  10268. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10269. templateOptions: {
  10270. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10271. }
  10272. },
  10273. controller: ['$scope', '$filter', function ($scope, $filter) {
  10274. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10275. $scope.options.initialValue = $scope.model[$scope.options.key];
  10276. }]
  10277. });
  10278. //日期控件
  10279. formlyConfigProvider.setType({
  10280. name: 'ui-datepicker',
  10281. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  10282. extends: 'input',
  10283. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10284. defaultOptions: {
  10285. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10286. templateOptions: {
  10287. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10288. }
  10289. },
  10290. controller: ['$scope', '$filter', function ($scope, $filter) {
  10291. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  10292. if ($scope.model[$scope.options.key]) {
  10293. } else {
  10294. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10295. }
  10296. $scope.options.initialValue = $scope.model[$scope.options.key];
  10297. $scope.endOpen = true;
  10298. $scope.datepicker = {};
  10299. $scope.datepicker.opened = false;
  10300. $scope.datepicker.open = function ($event) {
  10301. $scope.datepicker.opened = true;
  10302. };
  10303. }]
  10304. });
  10305. //时分控件
  10306. formlyConfigProvider.setType({
  10307. name: 'ui-datehourtime',
  10308. extends: 'input',
  10309. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  10310. defaultOptions: function (options) {
  10311. return {
  10312. noFormControl: true,
  10313. // validators:{
  10314. // required:{
  10315. // expression:function(viewValue, modelValue){
  10316. // console.log(options)
  10317. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  10318. // // var value = modelValue.getHours() || viewValue.getHours();
  10319. // return value.length>=1;
  10320. // }
  10321. // }
  10322. // }
  10323. }
  10324. },
  10325. controller: ['$scope', '$log', function ($scope, $log) {
  10326. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  10327. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  10328. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  10329. }]
  10330. });
  10331. //状态追踪
  10332. formlyConfigProvider.setType({
  10333. name: 'ui-followStatus',
  10334. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  10335. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10336. setTimeout(function () {
  10337. var pkey = $scope.options.templateOptions.pkey;
  10338. var dataId = $scope.model.id;
  10339. if (dataId) {
  10340. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10341. if (response) {
  10342. var myData = Restangular.stripRestangular(response);
  10343. var processInstanceId = myData.data.processInstanceId;
  10344. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10345. if (result.status == 200) {
  10346. var newData = Restangular.stripRestangular(result);
  10347. $scope.followData = newData.data;
  10348. }
  10349. });
  10350. }
  10351. })
  10352. }
  10353. }, 10);
  10354. }]
  10355. });
  10356. //历史记录
  10357. formlyConfigProvider.setType({
  10358. name: 'ui-history',
  10359. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  10360. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10361. setTimeout(function () {
  10362. var pkey = $scope.options.templateOptions.pkey;
  10363. var dataId = $scope.model.id;
  10364. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10365. if (response) {
  10366. var myData = Restangular.stripRestangular(response);
  10367. var processInstanceId = myData.data.processInstanceId;
  10368. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10369. if (result.status == 200) {
  10370. var newData = Restangular.stripRestangular(result);
  10371. var long = newData.data.length - 1;
  10372. $scope.followData = newData.data[long];
  10373. }
  10374. });
  10375. }
  10376. })
  10377. }, 10);
  10378. }]
  10379. });
  10380. // //请求人信息显示
  10381. // formlyConfigProvider.setType({
  10382. // name: "ui-disrequester",
  10383. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  10384. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10385. // defaultOptions: function(options) {
  10386. // return {
  10387. // templateOptions: {}
  10388. // };
  10389. // },
  10390. // controller: ['$scope', function($scope) {
  10391. // $scope.options.templateOptions.that = $scope;
  10392. // }]
  10393. // });
  10394. //退回人信息显示
  10395. formlyConfigProvider.setType({
  10396. name: "ui-returnperson",
  10397. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  10398. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10399. defaultOptions: function (options) {
  10400. return {
  10401. templateOptions: {}
  10402. };
  10403. },
  10404. controller: ['$scope', function ($scope) {
  10405. $scope.group = "";
  10406. $scope.role = "";
  10407. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10408. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10409. } else {
  10410. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10411. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10412. }
  10413. }
  10414. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10415. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10416. } else {
  10417. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10418. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10419. }
  10420. }
  10421. $scope.options.templateOptions.that = $scope;
  10422. $scope.options.templateOptions.that = $scope;
  10423. }]
  10424. });
  10425. //退回人信息显示(去掉工作组&角色)
  10426. formlyConfigProvider.setType({
  10427. name: "ui-returnpersonNoGroup",
  10428. templateUrl: 'assets/views/customform/tpl/ui-returnpersonNoGroup.html',
  10429. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10430. defaultOptions: function (options) {
  10431. return {
  10432. templateOptions: {}
  10433. };
  10434. },
  10435. controller: ['$scope', function ($scope) {
  10436. $scope.group = "";
  10437. $scope.role = "";
  10438. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10439. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10440. } else {
  10441. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10442. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10443. }
  10444. }
  10445. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10446. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10447. } else {
  10448. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10449. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10450. }
  10451. }
  10452. $scope.options.templateOptions.that = $scope;
  10453. $scope.options.templateOptions.that = $scope;
  10454. }]
  10455. });
  10456. //指派技术人员
  10457. formlyConfigProvider.setType({
  10458. name: "ui-apiontperson",
  10459. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  10460. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10461. defaultOptions: function (options) {
  10462. return {
  10463. templateOptions: {
  10464. transtlara: function (value, $scope) { }
  10465. }
  10466. };
  10467. },
  10468. controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
  10469. var filterData = {
  10470. "idx": 0,
  10471. "sum": 1000
  10472. }
  10473. api_user_data.fetchDataList('group', filterData).then(function (response) {
  10474. if (response.status == 200) {
  10475. $scope.select = {};
  10476. $scope.multipleDemo = {};
  10477. $scope.userdata = {};
  10478. var data = response.list;
  10479. var item = [];
  10480. $scope.multipleDemo = data;
  10481. $scope.multipleDemo;
  10482. }
  10483. })
  10484. $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
  10485. if (groupdata.option) {
  10486. $scope.model[$scope.options.key] = {};
  10487. var fildate = {
  10488. "idx": 0,
  10489. "sum": 1000,
  10490. "user": {
  10491. "roledata": {
  10492. "rolecode": model.currentRole
  10493. },
  10494. "selectType": "1",
  10495. "groupdata": {
  10496. "id": groupdata.option.id
  10497. }
  10498. }
  10499. }
  10500. api_user_data.fetchDataList('user', fildate).then(function (response) {
  10501. if (response.status == 200) {
  10502. $scope.userdata = {};
  10503. $scope.userdata = response.list;
  10504. }
  10505. })
  10506. } else {
  10507. $scope.model[$scope.options.key] = {
  10508. id: groupdata.id.id
  10509. }
  10510. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  10511. }
  10512. }
  10513. // }
  10514. }]
  10515. });
  10516. //请求科室信息(小蓝框) lmm
  10517. formlyConfigProvider.setType({
  10518. name: 'ui-deptinformation',
  10519. templateUrl: 'assets/views/customform/tpl/ui-deptinformation.html',
  10520. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10521. return {
  10522. templateOptions: {
  10523. checkform: function (options) {
  10524. }
  10525. }
  10526. };
  10527. },
  10528. controller: ['$scope', 'api_statistic', function ($scope, api_statistic) {
  10529. // console.log($scope)
  10530. }]
  10531. });
  10532. //请求人信息
  10533. formlyConfigProvider.setType({
  10534. name: 'ui-requesterinformation',
  10535. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  10536. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10537. return {
  10538. templateOptions: {
  10539. checkform: function (options) {
  10540. if (options.model.requester) {
  10541. options.value(options.model.requester);
  10542. }
  10543. },
  10544. addRequeter: function (size, options, modal) {
  10545. event.preventDefault();
  10546. var modalInstance = modal.open({
  10547. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  10548. controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
  10549. $scope.title = "新增报修人";
  10550. $scope.requester = {};
  10551. $scope.searchData = {};
  10552. $scope.onChangeadd = function (searchData) {
  10553. $scope.searchKey = searchData.account;
  10554. // $scope.searchDataadd = searchData;
  10555. var requesdata = angular.copy(searchData)
  10556. if (requesdata.mphone) {
  10557. delete requesdata.mphone;
  10558. }
  10559. $scope.requester = requesdata;
  10560. console.log($scope.requester)
  10561. }
  10562. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10563. $scope.requester.account = searchKey;
  10564. $scope.searchData = searchKey;
  10565. serchdataadd(searchKey);
  10566. }
  10567. $scope.getMydata = function (x) {
  10568. $scope.searchField = JSON.parse(x[0]).account;
  10569. $scope.requester = JSON.parse(x[0]);
  10570. console.log($scope.requester)
  10571. }
  10572. $scope.getMydataone = function (x) {
  10573. $scope.searchField = x;
  10574. $scope.requester.account = x;
  10575. }
  10576. serchdataadd();
  10577. api_wechatfile.getDictionary({
  10578. "type": "list",
  10579. "key": "male"
  10580. }).then(function (data) {
  10581. if (data.status == 200) {
  10582. requester.gender = data.list;
  10583. }
  10584. })
  10585. function serchdataadd(searchKey) {
  10586. if (searchKey) {
  10587. var filterData = {
  10588. 'requester': {
  10589. 'searchKey': searchKey,
  10590. },
  10591. idx: 0,
  10592. sum: 10
  10593. };
  10594. } else {
  10595. var filterData = {
  10596. idx: 0,
  10597. sum: 10
  10598. };
  10599. }
  10600. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10601. var myData = response;
  10602. $scope.myData = myData.list;
  10603. });
  10604. }
  10605. api_user_data.fetchDataList('area', {
  10606. idx: 0,
  10607. sum: 1000
  10608. }).then(function (response) {
  10609. if (response.status == 200) {
  10610. $scope.areas = response.list;
  10611. }
  10612. })
  10613. api_wechatfile.getDictionary({
  10614. key: "requester_type",
  10615. type: "list"
  10616. }, {
  10617. idx: 0,
  10618. sum: 100
  10619. }).then(function (response) {
  10620. if (response) {
  10621. $scope.networktypes = response;
  10622. }
  10623. })
  10624. $scope.requesterAreaid = "";
  10625. $scope.onChange = function (item) {
  10626. $scope.requesterAreaid = item.id;
  10627. api_user_data.fetchDataList('place', {
  10628. place: {
  10629. area: {
  10630. id: item.id
  10631. }
  10632. },
  10633. idx: 0,
  10634. sum: 1000
  10635. }).then(function (response) {
  10636. if (response.status == 200) {
  10637. $scope.places = response.list;
  10638. delete $scope.requester.placeDTO;
  10639. }
  10640. })
  10641. }
  10642. $scope.refresh = function (searchVal) {
  10643. var faildata = {};
  10644. if ($scope.requesterAreaid) {
  10645. faildata = {
  10646. 'idx': 0,
  10647. 'sum': 1000,
  10648. 'place': {
  10649. 'areaId': $scope.requesterAreaid,
  10650. 'place': searchVal,
  10651. 'selectType': 'pinyin_qs'
  10652. }
  10653. }
  10654. } else {
  10655. faildata = {
  10656. 'idx': 0,
  10657. 'sum': 1000,
  10658. 'place': {
  10659. 'place': searchVal,
  10660. 'selectType': 'pinyin_qs'
  10661. }
  10662. }
  10663. }
  10664. api_user_data.fetchDataList('place', faildata).then(function (response) {
  10665. $scope.places = response.list;
  10666. delete $scope.requester.placeDTO;
  10667. })
  10668. }
  10669. $scope.refreshDepts = function (key) {
  10670. var filterData = {
  10671. 'idx': 0,
  10672. 'sum': 5,
  10673. 'dept': {
  10674. 'name': key
  10675. }
  10676. };
  10677. UserService.fetchDataList('department', filterData).then(function (response) {
  10678. if (response.status == 200) {
  10679. $scope.depts = response.list;
  10680. }
  10681. })
  10682. }
  10683. $scope.ok = function () {
  10684. if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  10685. SweetAlert.swal("报修人员编号未填!", "请填写报修人员编号", "error");
  10686. } else if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  10687. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  10688. } else if (angular.isUndefined($scope.requester.requesterType) || $scope.requester.requesterType == null || $scope.requester.requesterTypeDTO == "") {
  10689. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  10690. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  10691. SweetAlert.swal("报修人联系电话未填!", "请填写报修人联系电话", "error");
  10692. } else {
  10693. $scope.requesterId = $scope.requester.id;
  10694. var data = {
  10695. incident: {
  10696. requester: {
  10697. id: $scope.requesterId
  10698. }
  10699. },
  10700. idx: 0,
  10701. sum: 3
  10702. };
  10703. api_statistic.tableData(data, 'incident').then(function (data) {
  10704. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  10705. })
  10706. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  10707. if (newObj != oldObj) {
  10708. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  10709. }
  10710. })//lmm
  10711. console.log($scope.requester)
  10712. $modalInstance.close($scope.requester);
  10713. }
  10714. };
  10715. $scope.cancel = function () {
  10716. $modalInstance.dismiss('cancel');
  10717. };
  10718. },
  10719. resolve: {
  10720. items: function () {
  10721. return {
  10722. fetchItems: function (filterData, APIService) {
  10723. filterData = filterData || {};
  10724. if (!filterData.idx) {
  10725. filterData = {
  10726. idx: 0,
  10727. sum: 10
  10728. };
  10729. }
  10730. return options.templateOptions.fetchItems(filterData, APIService);
  10731. }
  10732. };
  10733. },
  10734. title: function () {
  10735. return options.templateOptions.modalTitle;
  10736. },
  10737. Restangular: function () {
  10738. return options.templateOptions.Restangular;
  10739. },
  10740. APIService: function () {
  10741. return options.templateOptions.ApiService;
  10742. },
  10743. UserService: function () {
  10744. return options.templateOptions.UserService;
  10745. },
  10746. sco: function () {
  10747. return $scope;
  10748. }
  10749. }
  10750. });
  10751. modalInstance.result.then(function (selectedItem) {
  10752. console.log(selectedItem)
  10753. if (selectedItem) {
  10754. var data = {
  10755. 'requester': selectedItem
  10756. };
  10757. $scope.searchKey = selectedItem.account;
  10758. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  10759. // if (selectedItem.place && selectedItem.place.place) {
  10760. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  10761. // }
  10762. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  10763. if (response.status == 200) {
  10764. if (options.model) {
  10765. options.model.requester = response.data
  10766. $scope.$parent.$parent.$parent.model.incident.requester = response.data;
  10767. $scope.$parent.$parent.$parent.model.requestershow = response.data;
  10768. if (options.model.place) {
  10769. options.model.place.id = '';
  10770. }
  10771. if (options.model.area) {
  10772. options.model.area.id = '';
  10773. }
  10774. options.model.contacts = selectedItem.name;
  10775. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  10776. options.model.contactsInformation = selectedItem.mphone;
  10777. } else {
  10778. options.model.contactsInformation = selectedItem.telephone;
  10779. }
  10780. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  10781. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10782. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  10783. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  10784. }
  10785. }
  10786. if (!response.data.id) {
  10787. response.data.id = selectedItem.id
  10788. }
  10789. options.value(response.data);
  10790. options.value(response.data);
  10791. console.log($scope,'0000000');
  10792. //新增报修人带入区域地点2020年4月23日19:48:15
  10793. $scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10794. $scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10795. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  10796. if (selectedItem.place && selectedItem.place.id) {
  10797. options.model.place.id = selectedItem.place.id
  10798. options.model.place.area.id = selectedItem.place.area.id
  10799. };
  10800. } else {
  10801. if (selectedItem.place && selectedItem.place.id) {
  10802. options.model.place.id = selectedItem.place.id
  10803. options.model.area.id = selectedItem.place.area.id
  10804. };
  10805. }
  10806. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  10807. // options.model.area.id = selectedItem.place.area.id
  10808. // }
  10809. if (selectedItem.houseNumber) {
  10810. options.model.houseNumber = selectedItem.houseNumber
  10811. }
  10812. // if (selectedItem.id) {
  10813. options.model.account = selectedItem.account;
  10814. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  10815. var baoxiuFields = $scope.$parent.$parent.$parent.$parent.$parent.vm.fields[1].fields;
  10816. var baoxiurenTo;
  10817. baoxiuFields.forEach((e, i) => {
  10818. if (e.key == 'account') {
  10819. baoxiurenTo = e.templateOptions
  10820. baoxiurenTo.APIService.fetchDataList('requester', {
  10821. "idx": 0,
  10822. "sum": 20,
  10823. requester: {
  10824. searchKey: selectedItem.account
  10825. }
  10826. }).then(res => {
  10827. baoxiurenTo.options = res.list;
  10828. options.model.account = selectedItem.account;
  10829. })
  10830. }
  10831. })
  10832. // }
  10833. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  10834. // 选择重复事件侧滑框
  10835. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  10836. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  10837. setTimeout(() => {
  10838. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  10839. }, 500);
  10840. // }
  10841. }
  10842. })
  10843. }
  10844. }, function () { });
  10845. },
  10846. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  10847. var modalInstance = modal.open({
  10848. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  10849. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  10850. $scope.title = "修改报修人";
  10851. $scope.requester = {
  10852. id: modeldata.requester.id,
  10853. account: modeldata.requester.account,
  10854. name: modeldata.requester.name,
  10855. gender: modeldata.requester.gender,
  10856. email: modeldata.requester.email,
  10857. deptName: modeldata.requester.deptName,
  10858. mphone: modeldata.requester.mphone,
  10859. telephone: modeldata.requester.telephone,
  10860. studentNo: modeldata.requester.studentNo,
  10861. areaDTO: modeldata.requester.areaDTO,
  10862. placeDTO: modeldata.requester.placeDTO,
  10863. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  10864. };
  10865. $scope.onChangeadd = function (searchData) {
  10866. console.log(searchData)
  10867. $scope.searchKey = searchData.account;
  10868. var requesdata = angular.copy(searchData)
  10869. if (requesdata.mphone) {
  10870. delete requesdata.mphone;
  10871. }
  10872. $scope.requester = requesdata;
  10873. }
  10874. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10875. $scope.requester.account = searchKey;
  10876. $scope.searchData = searchKey;
  10877. serchdataadd(searchKey);
  10878. }
  10879. $scope.getMydata = function (x) {
  10880. $scope.searchField = JSON.parse(x[0]).account;
  10881. $scope.requester = JSON.parse(x[0]);
  10882. }
  10883. $scope.getMydataone = function (x) {
  10884. $scope.searchField = x;
  10885. $scope.requester.account = x;
  10886. }
  10887. serchdataadd();
  10888. function serchdataadd(searchKey) {
  10889. if (searchKey) {
  10890. var filterData = {
  10891. 'requester': {
  10892. 'searchKey': searchKey,
  10893. },
  10894. idx: 0,
  10895. sum: 10
  10896. };
  10897. } else {
  10898. var filterData = {
  10899. idx: 0,
  10900. sum: 10
  10901. };
  10902. }
  10903. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10904. var myData = response;
  10905. $scope.myData = myData.list;
  10906. });
  10907. }
  10908. api_user_data.fetchDataList('area', {
  10909. idx: 0,
  10910. sum: 1000
  10911. }).then(function (response) {
  10912. if (response.status == 200) {
  10913. $scope.areas = response.list;
  10914. }
  10915. })
  10916. api_user_data.fetchDataList('requesterType', {
  10917. idx: 0,
  10918. sum: 100
  10919. }).then(function (response) {
  10920. if (response.status == 200) {
  10921. $scope.networktypes = response.list;
  10922. }
  10923. })
  10924. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  10925. api_user_data.fetchDataList('place', {
  10926. place: {
  10927. areaId: $scope.requester.areaDTO.id
  10928. },
  10929. idx: 0,
  10930. sum: 1000
  10931. }).then(function (response) {
  10932. if (response.status == 200) {
  10933. $scope.places = response.list;
  10934. }
  10935. })
  10936. }
  10937. $scope.onChange = function (item) {
  10938. $scope.requester.placeDTO = {};
  10939. api_user_data.fetchDataList('place', {
  10940. place: {
  10941. areaId: item.id
  10942. },
  10943. idx: 0,
  10944. sum: 1000
  10945. }).then(function (response) {
  10946. if (response.status == 200) {
  10947. $scope.places = response.list;
  10948. }
  10949. })
  10950. }
  10951. $scope.refreshDepts = function (key) {
  10952. var filterData = {
  10953. 'idx': 0,
  10954. 'sum': 5,
  10955. 'dept': {
  10956. 'name': key
  10957. }
  10958. };
  10959. UserService.fetchDataList('department', filterData).then(function (response) {
  10960. if (response.status == 200) {
  10961. $scope.depts = response.list;
  10962. }
  10963. })
  10964. }
  10965. $scope.ok = function () {
  10966. if ($scope.requester.account == "" || $scope.requester.name == "") {
  10967. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  10968. } else {
  10969. $modalInstance.close($scope.requester);
  10970. }
  10971. };
  10972. $scope.cancel = function () {
  10973. $modalInstance.dismiss('cancel');
  10974. };
  10975. },
  10976. resolve: {
  10977. items: function () {
  10978. return {
  10979. fetchItems: function (filterData, APIService) {
  10980. filterData = filterData || {};
  10981. if (!filterData.idx) {
  10982. filterData = {
  10983. idx: 0,
  10984. sum: 10
  10985. };
  10986. }
  10987. return options.templateOptions.fetchItems(filterData, APIService);
  10988. }
  10989. };
  10990. },
  10991. title: function () {
  10992. return options.templateOptions.modalTitle;
  10993. },
  10994. Restangular: function () {
  10995. return options.templateOptions.Restangular;
  10996. },
  10997. APIService: function () {
  10998. return options.templateOptions.ApiService;
  10999. },
  11000. UserService: function () {
  11001. return options.templateOptions.UserService;
  11002. }
  11003. }
  11004. });
  11005. modalInstance.result.then(function (selectedItem) {
  11006. console.log(selectedItem)
  11007. if (selectedItem) {
  11008. if (options.model) {
  11009. if (options.model.place) {
  11010. options.model.place.id = '';
  11011. }
  11012. if (options.model.area) {
  11013. options.model.area.id = '';
  11014. }
  11015. options.model.contacts = selectedItem.name;
  11016. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11017. options.model.contactsInformation = selectedItem.mphone;
  11018. } else {
  11019. options.model.contactsInformation = selectedItem.telephone;
  11020. }
  11021. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11022. options.model.place.id = selectedItem.placeDTO.id
  11023. }
  11024. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11025. options.model.area.id = selectedItem.areaDTO.id
  11026. }
  11027. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11028. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11029. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11030. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11031. }
  11032. }
  11033. var data = {
  11034. 'requester': selectedItem
  11035. };
  11036. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  11037. if (response.status == 200) {
  11038. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  11039. options.value(response.data);
  11040. } else { }
  11041. })
  11042. }
  11043. }, function () { });
  11044. event.preventDefault();
  11045. }
  11046. }
  11047. };
  11048. },
  11049. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  11050. $scope.options.initialValue = $scope.model[$scope.options.key];
  11051. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  11052. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11053. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11054. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11055. }
  11056. }]
  11057. });
  11058. // 请求人选控件
  11059. formlyConfigProvider.setType({
  11060. name: "ui-requesterselect",
  11061. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  11062. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11063. defaultOptions: function (options, $scope) {
  11064. return {
  11065. templateOptions: {
  11066. // checkform: function(options) {
  11067. // if (options.model.requestershow) {
  11068. // options.value(options.model.requestershow);
  11069. // }
  11070. // },
  11071. validators: {
  11072. required: {
  11073. expression: function (viewValue, modelValue) {
  11074. var value = modelValue || viewValue;
  11075. return value.length >= 1;
  11076. }
  11077. }
  11078. },
  11079. openModal: function (size, options, modal) { //查找弹出框
  11080. var modelObject = options.value();
  11081. var searchModal = function (filterSearchData) {
  11082. var modalInstance = modal.open({
  11083. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11084. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  11085. $scope.langs = i18nService.getAllLangs();
  11086. $scope.lang = 'zh-cn';
  11087. i18nService.setCurrentLang($scope.lang);
  11088. $scope.gridOptions = {};
  11089. $scope.gridOptions.data = 'myData';
  11090. $scope.gridOptions.enableColumnResizing = true;
  11091. $scope.gridOptions.enableFiltering = true;
  11092. $scope.gridOptions.enableGridMenu = false;
  11093. $scope.gridOptions.enableRowSelection = true;
  11094. $scope.gridOptions.showGridFooter = true;
  11095. $scope.gridOptions.showColumnFooter = false;
  11096. $scope.gridOptions.fastWatch = true;
  11097. $scope.gridOptions.useExternalFiltering = true;
  11098. $scope.gridOptions.useExternalPagination = true;
  11099. $scope.gridOptions.paginationPageSizes = [10];
  11100. $scope.gridOptions.paginationPageSize = 10;
  11101. $scope.gridOptions.multiSelect = false;
  11102. $scope.gridOptions.rowIdentity = function (row) {
  11103. return row.id;
  11104. };
  11105. $scope.gridOptions.getRowIdentity = function (row) {
  11106. return row.id;
  11107. };
  11108. $scope.gridOptions.columnDefs = [{
  11109. name: 'account',
  11110. displayName: '人员编号',
  11111. width: 140
  11112. },
  11113. {
  11114. name: 'name',
  11115. displayName: '姓名',
  11116. width: 100
  11117. },
  11118. {
  11119. name: 'gender.name',
  11120. displayName: '性别',
  11121. width: 80,
  11122. enableFiltering: false
  11123. },
  11124. {
  11125. name: 'mphone',
  11126. displayName: '电话',
  11127. width: 100,
  11128. enableFiltering: false
  11129. },
  11130. {
  11131. name: 'email',
  11132. displayName: '邮件',
  11133. width: 100
  11134. },
  11135. {
  11136. name: 'areaDTO.area',
  11137. displayName: '区域',
  11138. width: 100,
  11139. enableFiltering: false
  11140. },
  11141. {
  11142. name: 'placeDTO.place',
  11143. displayName: '地点',
  11144. enableFiltering: false
  11145. }
  11146. ];
  11147. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11148. $scope.gridApi = gridApi;
  11149. // var filtersData = $scope.memoryfilterData;
  11150. // filtersData.idx = newPage - 1;
  11151. // filtersData.sum = pageSize;
  11152. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11153. var filtersData = $scope.memoryfilterData;
  11154. filtersData.idx = newPage - 1;
  11155. filtersData.sum = pageSize;
  11156. $scope.loadData(filtersData);
  11157. });
  11158. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11159. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  11160. $scope.selected.item = data.entity;
  11161. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  11162. });
  11163. gridApi.core.on.filterChanged($scope, function () {
  11164. var grid = this.grid;
  11165. var filtersData = {
  11166. idx: 0,
  11167. sum: 10
  11168. // 'requester': { 'userType': 1 }
  11169. };
  11170. angular.forEach(grid.columns, function (item) {
  11171. if (item.enableFiltering) {
  11172. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11173. if (angular.isUndefined(filtersData['requester'])) {
  11174. filtersData['requester'] = {};
  11175. }
  11176. filtersData['requester'][item.field] = item.filters[0].term;
  11177. }
  11178. }
  11179. });
  11180. $scope.memoryfilterData = filtersData;
  11181. $scope.loadData(filtersData);
  11182. });
  11183. };
  11184. $scope.memoryfilterData = defaultFilterData = {
  11185. "idx": 0,
  11186. "sum": 10
  11187. };
  11188. $scope.loadData = function (filterData) {
  11189. if (!filterData.requester) {
  11190. filterData.requester = {};
  11191. }
  11192. if (scope.roleidcode) {
  11193. angular.extend(filterData['requester'], {
  11194. 'userType': 1
  11195. });
  11196. }
  11197. items.fetchItems(filterData, APIService).then(function (data) {
  11198. var myData = Restangular.stripRestangular(data);
  11199. $scope.gridOptions.totalItems = myData.totalNum;
  11200. $scope.myData = myData.list;
  11201. });
  11202. };
  11203. // $scope.title = title;
  11204. if (searchDatas) {
  11205. $scope.loadData(searchDatas);
  11206. } else {
  11207. $scope.loadData({
  11208. idx: 0,
  11209. sum: 10,
  11210. });
  11211. }
  11212. $scope.selected = {
  11213. item: {}
  11214. };
  11215. $scope.ok = function () {
  11216. $modalInstance.close($scope.selected.item);
  11217. };
  11218. $scope.cancel = function () {
  11219. $modalInstance.dismiss('cancel');
  11220. };
  11221. },
  11222. size: size,
  11223. resolve: {
  11224. items: function () {
  11225. return {
  11226. fetchItems: function (filterData, APIService) {
  11227. filterData = filterData || {};
  11228. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  11229. filterData = {
  11230. idx: 0,
  11231. sum: 10
  11232. };
  11233. }
  11234. return options.templateOptions.fetchItems(filterData, APIService);
  11235. }
  11236. };
  11237. },
  11238. title: function () {
  11239. return options.templateOptions.modalTitle;
  11240. },
  11241. Restangular: function () {
  11242. return options.templateOptions.Restangular;
  11243. },
  11244. APIService: function () {
  11245. return options.templateOptions.ApiService;
  11246. },
  11247. language: function () {
  11248. return options.templateOptions.language;
  11249. },
  11250. searchDatas: function () {
  11251. return filterSearchData;
  11252. },
  11253. scope: function () {
  11254. return $scope;
  11255. }
  11256. }
  11257. });
  11258. modalInstance.result.then(function (selectedItem) {
  11259. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11260. selectedItem.telephone = $scope.model.incident.contactsInformation;
  11261. }
  11262. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  11263. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  11264. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  11265. if ($scope.model) {
  11266. if ($scope.model.incident.place) {
  11267. $scope.model.incident.place.id = '';
  11268. }
  11269. if ($scope.model.area) {
  11270. $scope.model.incident.area.id = '';
  11271. }
  11272. $scope.model.incident.contacts = selectedItem.name;
  11273. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11274. $scope.model.incident.contactsInformation = selectedItem.mphone;
  11275. } else {
  11276. $scope.model.incident.contactsInformation = selectedItem.telephone;
  11277. }
  11278. $scope.model.incident.houseNumber = '';
  11279. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11280. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11281. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11282. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11283. }
  11284. }
  11285. $scope.options.value(selectedItem);
  11286. $scope.searchData = selectedItem.account;
  11287. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11288. $scope.model.incident.place.id = selectedItem.placeDTO.id
  11289. }
  11290. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11291. $scope.model.incident.area.id = selectedItem.areaDTO.id
  11292. }
  11293. if (selectedItem.houseNumber) {
  11294. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  11295. }
  11296. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11297. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11298. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11299. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11300. }
  11301. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  11302. options.templateOptions.callback(selectedItem, options);
  11303. }
  11304. if (!$scope.roleidcode) {
  11305. $scope.charging(selectedItem, modal)
  11306. }
  11307. $scope.recentlyincident(selectedItem);
  11308. }, function () {
  11309. //console.log('Modal dismissed at: ' + new Date());
  11310. });
  11311. }
  11312. searchModal();
  11313. // }
  11314. }
  11315. }
  11316. };
  11317. },
  11318. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  11319. $scope.roleidcode = true;
  11320. // $scope.options.initialValue = undefined;
  11321. if ($rootScope.user && $rootScope.user.role) {
  11322. angular.forEach($rootScope.user.role, function (item) {
  11323. if (item.rolecode == "call center") {
  11324. $scope.roleidcode = false;
  11325. }
  11326. })
  11327. }
  11328. $scope.recently = false;
  11329. $scope.recentlyincident = function (key, model) { //关联事件
  11330. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  11331. "idx": 0,
  11332. "sum": 4,
  11333. incident: {
  11334. requester: {
  11335. id: key.id
  11336. }
  11337. }
  11338. }).then(function (response) {
  11339. if (response.status == 200) {
  11340. $scope.recently = true;
  11341. $scope.recentincident = response.list;
  11342. } else {
  11343. $scope.recently = false;
  11344. }
  11345. })
  11346. $scope.bodyHeight = window.innerHeight - 100;
  11347. $(window).resize(function () {
  11348. $scope.bodyHeight = window.innerHeight - 100;
  11349. });
  11350. // $scope.shows = false;
  11351. $scope.tempData = {};
  11352. $scope.close = function () {
  11353. $scope.changes = !$scope.changes;
  11354. event.preventDefault();
  11355. }
  11356. }
  11357. $scope.charging = function (key, model) { //计费弹出框
  11358. //用户信息
  11359. $scope.information = {};
  11360. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  11361. "userId": key.account
  11362. }).then(function (response) {
  11363. // if (response.status == 200) {
  11364. if (response && response.data) {
  11365. angular.extend($scope.information, response.data[0]);
  11366. // $scope.information = response.data[0];
  11367. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  11368. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  11369. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  11370. } else if (response.err) {
  11371. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  11372. }
  11373. // }
  11374. })
  11375. //上网明细
  11376. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  11377. "userId": key.account,
  11378. "limit": "10",
  11379. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  11380. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  11381. }).then(function (response) {
  11382. // if (response.status == 200) {
  11383. if (response && response.data) {
  11384. angular.forEach(response.data, function (item, index) {
  11385. if (item.logoutTime) {
  11386. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  11387. }
  11388. if (item.loginTime) {
  11389. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  11390. }
  11391. })
  11392. $scope.logininform = response.data;
  11393. } else if (response.err) {
  11394. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  11395. }
  11396. })
  11397. //黑名单
  11398. // $scope.information.blacklist = "否"
  11399. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  11400. "userId": key.account
  11401. }).then(function (response) {
  11402. // if (response.status == 200) {
  11403. // $scope.logininformation = response.data;
  11404. if (response) {
  11405. if (response.data || response.data != null) {
  11406. $scope.information.blacklist = "是"
  11407. } else {
  11408. if (response.err) {
  11409. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  11410. } else {
  11411. $scope.information.blacklist = "否"
  11412. }
  11413. }
  11414. }
  11415. // }
  11416. })
  11417. $scope.bodyHeight = window.innerHeight - 100;
  11418. $(window).resize(function () {
  11419. $scope.bodyHeight = window.innerHeight - 100;
  11420. });
  11421. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  11422. // $scope.closepages = function(e) {
  11423. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  11424. // event.preventDefault();
  11425. // };
  11426. // $scope.shows = false;
  11427. $scope.tempData = {};
  11428. $scope.close = function () {
  11429. $scope.changes = !$scope.changes;
  11430. event.preventDefault();
  11431. }
  11432. }
  11433. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  11434. idx: 0,
  11435. sum: 100
  11436. }).then(function (response) {
  11437. if (response.status == 200) {
  11438. $scope.networktypes = response.list;
  11439. } else {
  11440. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  11441. }
  11442. })
  11443. function serchdata(searchKey) {
  11444. if (searchKey) {
  11445. var filterData = {
  11446. 'requester': {
  11447. 'searchKey': searchKey
  11448. // 'userType': 1
  11449. },
  11450. idx: 0,
  11451. sum: 10
  11452. };
  11453. } else {
  11454. var filterData = {
  11455. 'idx': 0,
  11456. 'requester': {},
  11457. 'sum': 10
  11458. };
  11459. }
  11460. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  11461. angular.extend(filterData.requester, {
  11462. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  11463. });
  11464. if (!$scope.options.model.contactsInformation) {
  11465. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  11466. }
  11467. }
  11468. if ($scope.roleidcode) {
  11469. angular.extend(filterData['requester'], {
  11470. 'userType': 1
  11471. });
  11472. }
  11473. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  11474. var myData = response;
  11475. $scope.myData = myData.list;
  11476. });
  11477. }
  11478. $scope.searchData = {};
  11479. $scope.refreshUser = function (searchKey) { //请求人搜索
  11480. if (searchKey && searchKey != "") {
  11481. serchdata(searchKey);
  11482. }
  11483. }
  11484. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  11485. if (!$scope.roleidcode) {
  11486. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  11487. }
  11488. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  11489. }
  11490. $scope.onChange = function (searchData) {
  11491. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11492. searchData.telephone = $scope.model.incident.contactsInformation;;
  11493. }
  11494. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  11495. if (!$scope.roleidcode) {
  11496. $scope.charging(searchData);
  11497. }
  11498. $scope.recentlyincident(searchData);
  11499. $scope.accountshow = false;
  11500. if ($scope.model.incident) {
  11501. if ($scope.model.incident.place) {
  11502. $scope.model.incident.place.id = '';
  11503. }
  11504. if ($scope.model.incident.area) {
  11505. $scope.model.incident.area.id = '';
  11506. }
  11507. $scope.model.incident.contacts = searchData.name;
  11508. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  11509. $scope.model.incident.contactsInformation = searchData.mphone;
  11510. } else {
  11511. $scope.model.incident.contactsInformation = searchData.telephone;
  11512. }
  11513. $scope.model.incident.houseNumber = '';
  11514. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11515. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11516. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11517. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11518. }
  11519. }
  11520. $scope.options.value(searchData);
  11521. $scope.searchKey = searchData.account;
  11522. if (searchData.placeDTO && searchData.placeDTO.id) {
  11523. $scope.model.incident.place.id = searchData.placeDTO.id
  11524. }
  11525. if (searchData.areaDTO && searchData.areaDTO.id) {
  11526. $scope.model.incident.area.id = searchData.areaDTO.id
  11527. }
  11528. if (searchData.houseNumber) {
  11529. $scope.model.incident.houseNumber = searchData.houseNumber;
  11530. }
  11531. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11532. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11533. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11534. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11535. }
  11536. }
  11537. }]
  11538. });
  11539. //ui-grid-table展示控件
  11540. formlyConfigProvider.setType({
  11541. name: 'ui-grid-table',
  11542. // extends: 'multiCheckbox',//去掉冒号
  11543. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  11544. defaultOptions: function (options) {
  11545. return {
  11546. templateOptions: {
  11547. linkage: function () { },
  11548. },
  11549. };
  11550. },
  11551. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  11552. var loginUser = $rootScope.user;
  11553. $scope.langs = i18nService.getAllLangs();
  11554. $scope.lang = 'zh-cn';
  11555. i18nService.setCurrentLang($scope.lang);
  11556. $scope.gridOptions = {};
  11557. $scope.gridOptions.data = 'myData';
  11558. $scope.gridOptions.enableColumnResizing = true;
  11559. $scope.gridOptions.enableGridMenu = false;
  11560. $scope.gridOptions.enableRowSelection = true;
  11561. $scope.gridOptions.showGridFooter = false;
  11562. $scope.gridOptions.showColumnFooter = false;
  11563. $scope.gridOptions.fastWatch = true;
  11564. $scope.gridOptions.useExternalFiltering = true;
  11565. $scope.gridOptions.useExternalPagination = false;
  11566. $scope.gridOptions.paginationPageSizes = [10];
  11567. $scope.gridOptions.paginationPageSize = 3;
  11568. $scope.gridOptions.multiSelect = false;
  11569. $scope.gridOptions.rowIdentity = function (row) {
  11570. return row.id;
  11571. };
  11572. $scope.gridOptions.getRowIdentity = function (row) {
  11573. return row.id;
  11574. };
  11575. $scope.gridOptions.columnDefs = [{
  11576. name: 'item',
  11577. displayName: '序号',
  11578. width: 80,
  11579. enableFiltering: false
  11580. },
  11581. {
  11582. name: 'incidentsign',
  11583. displayName: '单号',
  11584. width: 80,
  11585. enableFiltering: false
  11586. },
  11587. {
  11588. name: 'description',
  11589. displayName: '主题',
  11590. width: 80,
  11591. enableFiltering: false
  11592. },
  11593. {
  11594. name: 'state.name',
  11595. displayName: '状态',
  11596. width: 110,
  11597. enableFiltering: false
  11598. },
  11599. {
  11600. name: 'acceptDate',
  11601. displayName: '创建时间',
  11602. width: 160,
  11603. enableFiltering: false
  11604. },
  11605. {
  11606. name: 'requester.name',
  11607. displayName: '请求人',
  11608. width: 80,
  11609. enableFiltering: false
  11610. },
  11611. {
  11612. name: 'handlingPersonnelUser.name',
  11613. displayName: '处理人',
  11614. width: 160,
  11615. enableFiltering: false
  11616. },
  11617. {
  11618. name: 'place.place',
  11619. displayName: '区域地点',
  11620. width: 160,
  11621. enableFiltering: false
  11622. },
  11623. ];
  11624. // var defaultFilterData = {
  11625. // "idx": 0,
  11626. // "sum": 3
  11627. // };
  11628. // // //分页控制
  11629. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11630. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11631. var filtersData = $scope.memoryfilterData;
  11632. filtersData.idx = newPage - 1;
  11633. filtersData.sum = pageSize;
  11634. $scope.refreshData('expand-right', filtersData);
  11635. });
  11636. // 表格单选事件
  11637. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11638. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  11639. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  11640. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  11641. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  11642. str = str.split("").reverse().join("");
  11643. var del = addstr.split("").reverse().join("");
  11644. // console.log(del);
  11645. var reg = new RegExp(del);
  11646. str = str.replace(reg, '');
  11647. str = str.split("").reverse().join("")
  11648. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  11649. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  11650. str += data.entity.description;
  11651. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  11652. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  11653. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  11654. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  11655. }
  11656. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  11657. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  11658. });
  11659. };
  11660. // 刷新表格
  11661. setInterval(function () {
  11662. // console.log($scope.myData);
  11663. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  11664. // console.log($scope.myData);
  11665. if ($scope.myData != null) {
  11666. for (var i = 0; i < $scope.myData.length; i++) {
  11667. //添加序号
  11668. $scope.myData[i]['item'] = i + 1;
  11669. }
  11670. }
  11671. }, 1000)
  11672. }
  11673. });
  11674. //处理人信息
  11675. formlyConfigProvider.setType({
  11676. name: "ui-userinformation",
  11677. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  11678. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11679. defaultOptions: function (options) {
  11680. return {
  11681. templateOptions: {}
  11682. };
  11683. },
  11684. controller: ['$scope', function ($scope) {
  11685. $scope.group = "";
  11686. $scope.role = "";
  11687. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11688. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11689. } else {
  11690. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11691. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11692. }
  11693. }
  11694. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  11695. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  11696. } else {
  11697. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  11698. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  11699. }
  11700. }
  11701. $scope.options.templateOptions.that = $scope;
  11702. }]
  11703. });
  11704. //处理界面处理人信息
  11705. formlyConfigProvider.setType({
  11706. name: "ui-handler",
  11707. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  11708. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11709. defaultOptions: function (options) {
  11710. return {
  11711. templateOptions: {}
  11712. };
  11713. },
  11714. controller: ['$scope', function ($scope) {
  11715. $scope.group = "";
  11716. // $scope.role="";
  11717. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11718. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11719. } else {
  11720. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11721. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11722. }
  11723. }
  11724. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  11725. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  11726. // }else{
  11727. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  11728. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  11729. // }
  11730. // }
  11731. $scope.options.templateOptions.that = $scope;
  11732. }]
  11733. });
  11734. //微信事件流程
  11735. formlyConfigProvider.setType({
  11736. name: "ui-wxIncidentProcess",
  11737. templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
  11738. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11739. defaultOptions: function (options) {
  11740. return {
  11741. templateOptions: {}
  11742. };
  11743. },
  11744. controller: ['$scope', function ($scope) {
  11745. console.log($scope.model);
  11746. $scope.pingjia = false;
  11747. $scope.jiejue = false;
  11748. if ($scope.model.incidentState.value == "3") {
  11749. $scope.pingjia = true
  11750. } else if ($scope.model.incidentState.value == "4") {
  11751. $scope.jiejue = true;
  11752. }
  11753. }]
  11754. });
  11755. //打电话
  11756. formlyConfigProvider.setType({
  11757. name: "ui-inputcall",
  11758. extends: 'input',
  11759. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  11760. defaultOptions: function (options) {
  11761. return {
  11762. templateOptions: {
  11763. transform: function (value) { }
  11764. }
  11765. };
  11766. },
  11767. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  11768. $scope.dialout = function (teleno) {
  11769. var gid = "@0"
  11770. var telephone = '9' + teleno
  11771. $rootScope.callout = 2;
  11772. if ($rootScope.takes) {
  11773. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11774. if (data.errno == 0) {
  11775. $rootScope.status = 6;
  11776. }
  11777. })
  11778. } else {
  11779. SweetAlert.swal({
  11780. title: "呼叫失败",
  11781. text: "请先签入呼叫中心!",
  11782. type: "error",
  11783. confirmButtonColor: "#DD6B55"
  11784. });
  11785. }
  11786. }
  11787. $scope.options.templateOptions.that = $scope;
  11788. }]
  11789. });
  11790. //关闭界面处理人信息
  11791. formlyConfigProvider.setType({
  11792. name: "ui-closehandler",
  11793. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  11794. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11795. defaultOptions: function (options) {
  11796. return {
  11797. templateOptions: {}
  11798. };
  11799. },
  11800. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  11801. $scope.dialout = function (teleno) {
  11802. var gid = "@0"
  11803. var telephone = '9' + teleno
  11804. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11805. if (data.errno == 0) {
  11806. $rootScope.status = 6;
  11807. }
  11808. })
  11809. }
  11810. $scope.options.templateOptions.that = $scope;
  11811. }]
  11812. });
  11813. //用户单选控件
  11814. formlyConfigProvider.setType({
  11815. name: "ui-userselect",
  11816. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  11817. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11818. defaultOptions: function (options) {
  11819. return {
  11820. templateOptions: {
  11821. openModal: function (size, options, modal) {
  11822. var modalInstance = modal.open({
  11823. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11824. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  11825. $scope.langs = i18nService.getAllLangs();
  11826. $scope.lang = 'zh-cn';
  11827. i18nService.setCurrentLang($scope.lang);
  11828. $scope.gridOptions = {};
  11829. $scope.gridOptions.data = 'myData';
  11830. $scope.gridOptions.enableColumnResizing = true;
  11831. $scope.gridOptions.enableFiltering = true;
  11832. $scope.gridOptions.enableGridMenu = false;
  11833. $scope.gridOptions.showGridFooter = true;
  11834. $scope.gridOptions.showColumnFooter = false;
  11835. $scope.gridOptions.fastWatch = true;
  11836. $scope.gridOptions.useExternalFiltering = true;
  11837. $scope.gridOptions.useExternalPagination = true;
  11838. $scope.gridOptions.paginationPageSizes = [10];
  11839. $scope.gridOptions.paginationPageSize = 10;
  11840. $scope.gridOptions.multiSelect = false;
  11841. $scope.gridOptions.rowIdentity = function (row) {
  11842. return row.id;
  11843. };
  11844. $scope.gridOptions.getRowIdentity = function (row) {
  11845. return row.id;
  11846. };
  11847. $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>";
  11848. $scope.gridOptions.columnDefs = [{
  11849. name: 'account',
  11850. displayName: '人员编号',
  11851. width: 120
  11852. },
  11853. {
  11854. name: 'name',
  11855. displayName: '姓名',
  11856. width: 100,
  11857. cellTemplate: '<div>' +
  11858. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  11859. '</div>'
  11860. },
  11861. // {
  11862. // name: 'gender.name',
  11863. // displayName: '性别',
  11864. // width: 80,
  11865. // enableFiltering: false
  11866. // },
  11867. {
  11868. name: 'phone',
  11869. displayName: '电话',
  11870. width: 230,
  11871. enableFiltering: false
  11872. },
  11873. {
  11874. name: 'email',
  11875. displayName: '邮箱',
  11876. width: 180,
  11877. enableFiltering: false
  11878. },
  11879. {
  11880. name: 'dept.dept',
  11881. displayName: '科室',
  11882. width: 130,
  11883. enableFiltering: false
  11884. },
  11885. {
  11886. name: 'taskCount',
  11887. displayName: '处理中事件数',
  11888. enableFiltering: false
  11889. }
  11890. ];
  11891. // $scope.selectButtonClick
  11892. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11893. $scope.gridApi = gridApi;
  11894. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11895. var filtersData = $scope.memoryfilterData;
  11896. filtersData.idx = newPage - 1;
  11897. filtersData.sum = pageSize;
  11898. $scope.loadData(filtersData);
  11899. //console.log(pageSize);
  11900. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  11901. });
  11902. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11903. $scope.selected.items = data.entity;
  11904. //console.log(data);
  11905. });
  11906. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  11907. $scope.selected.items = data.entity;
  11908. //console.log(data);
  11909. });
  11910. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  11911. // // if (row.entity.age > 45) {
  11912. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11913. // // }
  11914. // };
  11915. gridApi.core.on.filterChanged($scope, function () {
  11916. var grid = this.grid;
  11917. var filtersData = {
  11918. idx: 0,
  11919. sum: 10,
  11920. "user": {
  11921. "roledata": {
  11922. "rolecode": "roleset"
  11923. },
  11924. "selectType": "1"
  11925. }
  11926. };
  11927. angular.forEach(grid.columns, function (item) {
  11928. if (item.enableFiltering) {
  11929. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  11930. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11931. if (angular.isUndefined(filtersData['user'])) {
  11932. filtersData['user'] = {};
  11933. }
  11934. filtersData['user'][item.field] = item.filters[0].term;
  11935. }
  11936. }
  11937. });
  11938. $scope.memoryfilterData = filtersData;
  11939. $scope.loadData(filtersData);
  11940. });
  11941. };
  11942. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  11943. // if (row.entity.age > 45) {
  11944. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11945. // }
  11946. // },
  11947. $scope.onDblClick = function (data, event) {
  11948. // $scope.selected.items = data.entity;
  11949. $scope.selectButtonClick(data, event);
  11950. };
  11951. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  11952. // $scope.selected.items = data.entity;
  11953. // })
  11954. // };
  11955. $scope.memoryfilterData = {
  11956. "idx": 0,
  11957. "sum": 10,
  11958. "user": {
  11959. "roledata": {
  11960. "rolecode": "roleset"
  11961. },
  11962. "selectType": "1"
  11963. }
  11964. }
  11965. $scope.loadData = function (filterData) {
  11966. // console.log("filtersData=111" + JSON.stringify(filterData))
  11967. items.fetchItems(filterData, APIService).then(function (data) {
  11968. var myData = Restangular.stripRestangular(data);
  11969. $scope.gridOptions.totalItems = myData.totalNum;
  11970. $scope.myData = myData.list;
  11971. });
  11972. };
  11973. // $scope.title = title;
  11974. $scope.loadData({
  11975. idx: 0,
  11976. sum: 10,
  11977. "user": {
  11978. "roledata": {
  11979. "rolecode": "roleset"
  11980. },
  11981. "selectType": "1"
  11982. }
  11983. });
  11984. $scope.selected = {
  11985. items: {}
  11986. };
  11987. $scope.ok = function () {
  11988. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  11989. // onDataCallback($scope.selected.item, parentScope);
  11990. // }
  11991. $modalInstance.close($scope.selected.items);
  11992. };
  11993. $scope.cancel = function () {
  11994. $modalInstance.dismiss('cancel');
  11995. };
  11996. },
  11997. size: size,
  11998. resolve: {
  11999. items: function () {
  12000. return {
  12001. fetchItems: function (filterData, APIService) {
  12002. filterData = filterData || {};
  12003. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12004. filterData = {
  12005. idx: 0,
  12006. sum: 10,
  12007. "user": {
  12008. "roledata": {
  12009. "rolecode": "roleset"
  12010. },
  12011. "selectType": "1"
  12012. }
  12013. };
  12014. }
  12015. return options.templateOptions.fetchItems(filterData, APIService);
  12016. }
  12017. };
  12018. },
  12019. title: function () {
  12020. return options.templateOptions.label;
  12021. },
  12022. Restangular: function () {
  12023. return options.templateOptions.Restangular;
  12024. },
  12025. APIService: function () {
  12026. return options.templateOptions.ApiService;
  12027. },
  12028. onDataCallback: function () {
  12029. return options.templateOptions.callback;
  12030. },
  12031. parentScope: function () {
  12032. return options.templateOptions.that;
  12033. }
  12034. }
  12035. });
  12036. modalInstance.result.then(function (selectedItem) {
  12037. // console.log(selectedItem);
  12038. options.value(selectedItem);
  12039. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12040. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12041. }
  12042. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12043. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12044. }
  12045. }, function () {
  12046. //console.log('Modal dismissed at: ' + new Date());
  12047. });
  12048. }
  12049. }
  12050. };
  12051. },
  12052. controller: ['$scope', function ($scope) {
  12053. $scope.options.templateOptions.that = $scope;
  12054. // $scope.options.model[$scope.options.key] = {}
  12055. }]
  12056. });
  12057. //用户单选控件(dd 单选input带搜索)
  12058. formlyConfigProvider.setType({
  12059. name: "ui-userselectSearch",
  12060. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  12061. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12062. defaultOptions: function (options) {
  12063. return {
  12064. templateOptions: {
  12065. openModal: function (size, options, modal) {
  12066. var modalInstance = modal.open({
  12067. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12068. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  12069. $scope.langs = i18nService.getAllLangs();
  12070. $scope.lang = 'zh-cn';
  12071. i18nService.setCurrentLang($scope.lang);
  12072. $scope.gridOptions = {};
  12073. $scope.gridOptions.data = 'myData';
  12074. $scope.gridOptions.enableColumnResizing = true;
  12075. $scope.gridOptions.enableFiltering = true;
  12076. $scope.gridOptions.enableGridMenu = false;
  12077. $scope.gridOptions.showGridFooter = true;
  12078. $scope.gridOptions.showColumnFooter = false;
  12079. $scope.gridOptions.fastWatch = true;
  12080. $scope.gridOptions.useExternalFiltering = true;
  12081. $scope.gridOptions.useExternalPagination = true;
  12082. $scope.gridOptions.paginationPageSizes = [10];
  12083. $scope.gridOptions.paginationPageSize = 10;
  12084. $scope.gridOptions.multiSelect = false;
  12085. $scope.gridOptions.rowIdentity = function (row) {
  12086. return row.id;
  12087. };
  12088. $scope.gridOptions.getRowIdentity = function (row) {
  12089. return row.id;
  12090. };
  12091. $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>";
  12092. $scope.gridOptions.columnDefs = [{
  12093. name: 'account',
  12094. displayName: '人员编号',
  12095. width: 120
  12096. },
  12097. {
  12098. name: 'name',
  12099. displayName: '姓名',
  12100. width: 100,
  12101. cellTemplate: '<div>' +
  12102. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  12103. '</div>'
  12104. },
  12105. // {
  12106. // name: 'gender.name',
  12107. // displayName: '性别',
  12108. // width: 80,
  12109. // enableFiltering: false
  12110. // },
  12111. {
  12112. name: 'phone',
  12113. displayName: '电话',
  12114. width: 230,
  12115. enableFiltering: false
  12116. },
  12117. {
  12118. name: 'email',
  12119. displayName: '邮箱',
  12120. width: 180,
  12121. enableFiltering: false
  12122. },
  12123. {
  12124. name: 'dept.dept',
  12125. displayName: '科室',
  12126. width: 130,
  12127. enableFiltering: false
  12128. },
  12129. {
  12130. name: 'taskCount',
  12131. displayName: '处理中事件数',
  12132. enableFiltering: false
  12133. }
  12134. ];
  12135. // $scope.selectButtonClick
  12136. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12137. $scope.gridApi = gridApi;
  12138. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12139. var filtersData = $scope.memoryfilterData;
  12140. filtersData.idx = newPage - 1;
  12141. filtersData.sum = pageSize;
  12142. $scope.loadData(filtersData);
  12143. //console.log(pageSize);
  12144. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12145. });
  12146. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12147. $scope.selected.items = data.entity;
  12148. //console.log(data);
  12149. });
  12150. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  12151. $scope.selected.items = data.entity;
  12152. //console.log(data);
  12153. });
  12154. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  12155. // // if (row.entity.age > 45) {
  12156. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12157. // // }
  12158. // };
  12159. gridApi.core.on.filterChanged($scope, function () {
  12160. var grid = this.grid;
  12161. var filtersData = {
  12162. idx: 0,
  12163. sum: 10,
  12164. user: {
  12165. roledata: {
  12166. rolecode: "first-line support"
  12167. },
  12168. selectType: "1"
  12169. }
  12170. };
  12171. angular.forEach(grid.columns, function (item) {
  12172. if (item.enableFiltering) {
  12173. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  12174. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12175. if (angular.isUndefined(filtersData['user'])) {
  12176. filtersData['user'] = {};
  12177. }
  12178. filtersData['user'][item.field] = item.filters[0].term;
  12179. }
  12180. }
  12181. });
  12182. $scope.memoryfilterData = filtersData;
  12183. $scope.loadData(filtersData);
  12184. });
  12185. };
  12186. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  12187. // if (row.entity.age > 45) {
  12188. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12189. // }
  12190. // },
  12191. $scope.onDblClick = function (data, event) {
  12192. // $scope.selected.items = data.entity;
  12193. $scope.selectButtonClick(data, event);
  12194. };
  12195. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  12196. // $scope.selected.items = data.entity;
  12197. // })
  12198. // };
  12199. $scope.memoryfilterData = {
  12200. idx: 0,
  12201. sum: 10,
  12202. user: {
  12203. roledata: {
  12204. rolecode: "first-line support"
  12205. },
  12206. selectType: "1"
  12207. }
  12208. }
  12209. $scope.loadData = function (filterData) {
  12210. // console.log("filtersData=111" + JSON.stringify(filterData))
  12211. items.fetchItems(filterData, APIService).then(function (data) {
  12212. var myData = Restangular.stripRestangular(data);
  12213. $scope.gridOptions.totalItems = myData.totalNum;
  12214. $scope.myData = myData.list;
  12215. });
  12216. };
  12217. $scope.title = title;
  12218. $scope.loadData({
  12219. idx: 0,
  12220. sum: 10,
  12221. user: {
  12222. roledata: {
  12223. rolecode: "first-line support"
  12224. },
  12225. selectType: "1"
  12226. }
  12227. });
  12228. $scope.selected = {
  12229. items: {}
  12230. };
  12231. $scope.ok = function () {
  12232. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12233. // onDataCallback($scope.selected.item, parentScope);
  12234. // }
  12235. $modalInstance.close($scope.selected.items);
  12236. };
  12237. $scope.cancel = function () {
  12238. $modalInstance.dismiss('cancel');
  12239. };
  12240. },
  12241. size: size,
  12242. resolve: {
  12243. items: function () {
  12244. return {
  12245. fetchItems: function (filterData, APIService) {
  12246. filterData = filterData || {};
  12247. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12248. filterData = {
  12249. idx: 0,
  12250. sum: 10,
  12251. user: {
  12252. roledata: {
  12253. rolecode: "first-line support"
  12254. },
  12255. selectType: "1"
  12256. }
  12257. };
  12258. }
  12259. return options.templateOptions.fetchItems(filterData, APIService);
  12260. }
  12261. };
  12262. },
  12263. title: function () {
  12264. return options.templateOptions.label;
  12265. },
  12266. Restangular: function () {
  12267. return options.templateOptions.Restangular;
  12268. },
  12269. APIService: function () {
  12270. return options.templateOptions.ApiService;
  12271. },
  12272. onDataCallback: function () {
  12273. return options.templateOptions.callback;
  12274. },
  12275. parentScope: function () {
  12276. return options.templateOptions.that;
  12277. }
  12278. }
  12279. });
  12280. modalInstance.result.then(function (selectedItem) {
  12281. // console.log(selectedItem);
  12282. options.value(selectedItem);
  12283. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12284. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12285. }
  12286. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12287. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12288. }
  12289. }, function () {
  12290. //console.log('Modal dismissed at: ' + new Date());
  12291. });
  12292. }
  12293. }
  12294. };
  12295. },
  12296. controller: ['$scope', function ($scope) {
  12297. $scope.options.templateOptions.that = $scope;
  12298. }]
  12299. });
  12300. //用户多选控件
  12301. formlyConfigProvider.setType({
  12302. name: "ui-multiuserselect",
  12303. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  12304. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12305. defaultOptions: function (options) {
  12306. return {
  12307. templateOptions: {
  12308. openModal: function (size, options, modal, model) {
  12309. var modalInstance = modal.open({
  12310. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12311. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  12312. $scope.langs = i18nService.getAllLangs();
  12313. $scope.lang = 'zh-cn';
  12314. i18nService.setCurrentLang($scope.lang);
  12315. $scope.gridOptions = {};
  12316. $scope.gridOptions.data = 'myData';
  12317. $scope.gridOptions.enableColumnResizing = true;
  12318. $scope.gridOptions.enableFiltering = true;
  12319. $scope.gridOptions.enableGridMenu = true;
  12320. $scope.gridOptions.showGridFooter = true;
  12321. $scope.gridOptions.showColumnFooter = true;
  12322. $scope.gridOptions.fastWatch = true;
  12323. $scope.gridOptions.useExternalFiltering = true;
  12324. $scope.gridOptions.useExternalPagination = true;
  12325. $scope.gridOptions.paginationPageSizes = [10];
  12326. $scope.gridOptions.paginationPageSize = 10;
  12327. $scope.gridOptions.multiSelect = true;
  12328. $scope.gridOptions.rowIdentity = function (row) {
  12329. return row.id;
  12330. };
  12331. $scope.gridOptions.getRowIdentity = function (row) {
  12332. return row.id;
  12333. };
  12334. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12335. $scope.gridOptions.columnDefs = [
  12336. // { name:'id', width:80, enableFiltering:false},
  12337. {
  12338. name: 'account',
  12339. displayName: '账号',
  12340. width: 140
  12341. },
  12342. {
  12343. name: 'name',
  12344. displayName: '名称',
  12345. width: 100
  12346. },
  12347. {
  12348. name: 'gender.name',
  12349. displayName: '性别',
  12350. width: 140,
  12351. enableFiltering: false
  12352. },
  12353. {
  12354. name: 'phone',
  12355. displayName: '电话',
  12356. width: 100,
  12357. enableFiltering: false
  12358. },
  12359. {
  12360. name: 'email',
  12361. displayName: '邮件',
  12362. width: 100,
  12363. enableFiltering: false
  12364. },
  12365. {
  12366. name: 'dept.dept',
  12367. displayName: '科室',
  12368. width: 100,
  12369. enableFiltering: false
  12370. },
  12371. {
  12372. name: 'group[0].groupName',
  12373. displayName: '职位',
  12374. width: 100,
  12375. enableFiltering: false
  12376. }
  12377. ];
  12378. $scope.selected = {
  12379. items: selectItems
  12380. };
  12381. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12382. $scope.gridApi = gridApi;
  12383. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12384. var filtersData = $scope.memoryfilterData;
  12385. filtersData.idx = newPage - 1;
  12386. filtersData.sum = pageSize;
  12387. $scope.loadData(filtersData);
  12388. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12389. });
  12390. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  12391. var j = 0;
  12392. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  12393. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  12394. j++;
  12395. break;
  12396. }
  12397. }
  12398. if (j == 1) {
  12399. scope.grid.appScope.selected.items.splice(i, 1);
  12400. } else {
  12401. scope.grid.appScope.selected.items.push(scope.entity)
  12402. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  12403. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  12404. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  12405. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  12406. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  12407. scope.grid.appScope.selected.items.splice(i, 1);
  12408. }
  12409. }
  12410. }
  12411. }
  12412. });
  12413. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  12414. // $scope.grid.appScope.selected.items.push($scope.entity);
  12415. // });
  12416. gridApi.core.on.filterChanged($scope, function () {
  12417. var grid = this.grid;
  12418. var filtersData = {
  12419. idx: 0,
  12420. sum: 10,
  12421. "user": {
  12422. "roledata": {
  12423. "rolecode": options.model.currentRole
  12424. },
  12425. "selectType": "1"
  12426. }
  12427. };
  12428. angular.forEach(grid.columns, function (item) {
  12429. if (item.enableFiltering) {
  12430. //console.log("filtersData="+JSON.stringify(filtersData))
  12431. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12432. if (angular.isUndefined(filtersData['user'])) {
  12433. filtersData['user'] = {};
  12434. }
  12435. filtersData['user'][item.field] = item.filters[0].term;
  12436. }
  12437. }
  12438. });
  12439. $scope.memoryfilterData = filtersData;
  12440. $scope.loadData(filtersData);
  12441. });
  12442. };
  12443. if (!options.model) {
  12444. var mouse = {
  12445. "model": {
  12446. "currentRole": ""
  12447. }
  12448. };
  12449. angular.extend(options, mouse);
  12450. }
  12451. $scope.memoryfilterData = {
  12452. "idx": 0,
  12453. "sum": 10,
  12454. "user": {
  12455. "roledata": {
  12456. "rolecode": options.model.currentRole
  12457. },
  12458. "selectType": "1"
  12459. }
  12460. }
  12461. $scope.loadData = function (filterData) {
  12462. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  12463. items.fetchItems(filterData, APIService).then(function (data) {
  12464. var myData = Restangular.stripRestangular(data);
  12465. $scope.gridOptions.totalItems = myData.totalNum;
  12466. $scope.myData = myData.list;
  12467. //console.log($scope.gridOptions.pagination.getTotalPages());
  12468. // if($scope.selected.items){
  12469. // angular.forEach($scope.selected.items,function(selectItem){
  12470. // $scope.gridApi.selection.selectRow(selectItem);
  12471. // });
  12472. // }
  12473. });
  12474. };
  12475. // $scope.title = title;
  12476. $scope.loadData({
  12477. idx: 0,
  12478. sum: 10,
  12479. "user": {
  12480. "roledata": {
  12481. "rolecode": options.model.currentRole
  12482. },
  12483. "selectType": "1"
  12484. }
  12485. });
  12486. // $timeout(function(){
  12487. // if($scope.selected.items){
  12488. // angular.forEach($scope.selected.items,function(selectItem){
  12489. // $scope.gridApi.selection.selectRow(selectItem);
  12490. // });
  12491. // }
  12492. // },2000)
  12493. $scope.ok = function () {
  12494. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  12495. $modalInstance.close($scope.selected.items);
  12496. };
  12497. $scope.cancel = function () {
  12498. $modalInstance.dismiss('cancel');
  12499. };
  12500. },
  12501. size: size,
  12502. resolve: {
  12503. items: function () {
  12504. return {
  12505. fetchItems: function (filterData, APIService) {
  12506. filterData = filterData || {};
  12507. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12508. filterData = {
  12509. idx: 0,
  12510. sum: 10,
  12511. "user": {
  12512. "roledata": {
  12513. "rolecode": options.model.incident.currentRole
  12514. },
  12515. "selectType": "1"
  12516. }
  12517. };
  12518. }
  12519. return options.templateOptions.fetchItems(filterData, APIService);
  12520. }
  12521. };
  12522. },
  12523. title: function () {
  12524. return options.templateOptions.modalTitle;
  12525. },
  12526. Restangular: function () {
  12527. return options.templateOptions.Restangular;
  12528. },
  12529. APIService: function () {
  12530. return options.templateOptions.ApiService;
  12531. },
  12532. selectItems: function () {
  12533. return model || [];
  12534. }
  12535. }
  12536. });
  12537. modalInstance.result.then(function (selectedItem) {
  12538. options.value(selectedItem);
  12539. options.formControl.$validate();
  12540. }, function () {
  12541. //console.log('Modal dismissed at: ' + new Date());
  12542. });
  12543. }
  12544. },
  12545. validators: {
  12546. required: {
  12547. expression: function (viewValue, modelValue) {
  12548. var value = modelValue || viewValue;
  12549. return value.length >= 1;
  12550. }
  12551. }
  12552. }
  12553. };
  12554. },
  12555. controller: ['$scope', function ($scope) {
  12556. $scope.model[$scope.options.key] = [];
  12557. $scope.remove = function (itemId) {
  12558. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  12559. if (entry.id == itemId) {
  12560. $scope.model[$scope.options.key].splice(index, 1);
  12561. // console.log($scope.options.formControl)
  12562. $scope.options.formControl.$validate();
  12563. } else {
  12564. }
  12565. });
  12566. }
  12567. }]
  12568. });
  12569. //用户多选控件-字符串展示
  12570. formlyConfigProvider.setType({
  12571. name: 'ui-stringuserselect',
  12572. extends: 'input',
  12573. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  12574. defaultOptions: function (options) {
  12575. return {
  12576. templateOptions: {
  12577. translate: '',
  12578. refreshDelay: 0
  12579. }
  12580. }
  12581. },
  12582. controller: ['$scope', function ($scope) {
  12583. var keydata = "";
  12584. if (angular.isArray($scope.model)) {
  12585. angular.forEach($scope.model, function (item) {
  12586. keydata = keydata + "," + item.name;
  12587. })
  12588. }
  12589. // $scope.model[$scope.options.key] = [];
  12590. }]
  12591. });
  12592. //重复事件
  12593. formlyConfigProvider.setType({
  12594. name: "ui-incidentmodelselect",
  12595. extends: 'input',
  12596. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12597. defaultOptions: function (options) {
  12598. return {
  12599. templateOptions: {
  12600. openModal: function (size, options, modal) {
  12601. var modalInstance = modal.open({
  12602. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12603. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  12604. $scope.langs = i18nService.getAllLangs();
  12605. $scope.lang = 'zh-cn';
  12606. i18nService.setCurrentLang($scope.lang);
  12607. $scope.gridOptions = {};
  12608. $scope.gridOptions.data = 'myData';
  12609. $scope.gridOptions.enableColumnResizing = true;
  12610. $scope.gridOptions.enableFiltering = true;
  12611. $scope.gridOptions.enableGridMenu = false;
  12612. $scope.gridOptions.enableRowSelection = true;
  12613. $scope.gridOptions.showGridFooter = true;
  12614. $scope.gridOptions.showColumnFooter = false;
  12615. $scope.gridOptions.fastWatch = true;
  12616. $scope.gridOptions.useExternalFiltering = true;
  12617. $scope.gridOptions.useExternalPagination = true;
  12618. $scope.gridOptions.paginationPageSizes = [10];
  12619. $scope.gridOptions.paginationPageSize = 10;
  12620. $scope.gridOptions.multiSelect = false;
  12621. var mun = $scope.gridOptions.paginationPageSize;
  12622. $scope.gridOptions.rowIdentity = function (row) {
  12623. return row.id;
  12624. };
  12625. $scope.gridOptions.getRowIdentity = function (row) {
  12626. return row.id;
  12627. };
  12628. $scope.gridOptions.columnDefs = items.columnDefs();
  12629. $scope.transferTime = function (time) {
  12630. return moment(time).format('YYYY-MM-DD HH:mm');
  12631. }
  12632. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12633. $scope.gridApi = gridApi;
  12634. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12635. // console.log(newPage);
  12636. // console.log(pageSize);
  12637. $scope.loadData({
  12638. "idx": newPage - 1,
  12639. "sum": pageSize
  12640. });
  12641. });
  12642. gridApi.core.on.filterChanged($scope, function () {
  12643. var grid = this.grid;
  12644. var filtersData = {
  12645. idx: 0,
  12646. sum: 100
  12647. };
  12648. angular.forEach(grid.columns, function (item) {
  12649. if (item.enableFiltering) {
  12650. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12651. // console.log("filtersData="+JSON.stringify(filtersData))
  12652. if (angular.isUndefined(filtersData['incident'])) {
  12653. filtersData['incident'] = {};
  12654. }
  12655. filtersData['incident'][item.field] = item.filters[0].term;
  12656. if (angular.isUndefined(filtersData['problem'])) {
  12657. filtersData['problem'] = {};
  12658. }
  12659. filtersData['problem'][item.field] = item.filters[0].term;
  12660. if (angular.isUndefined(filtersData['change'])) {
  12661. filtersData['change'] = {};
  12662. }
  12663. filtersData['change'][item.field] = item.filters[0].term;
  12664. if (angular.isUndefined(filtersData['release'])) {
  12665. filtersData['release'] = {};
  12666. }
  12667. filtersData['release'][item.field] = item.filters[0].term;
  12668. }
  12669. }
  12670. });
  12671. $scope.loadData(filtersData);
  12672. });
  12673. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12674. $scope.selected.item = data.entity;
  12675. //console.log(data);
  12676. });
  12677. };
  12678. //资产
  12679. $scope.cmdb = {}
  12680. //资产状态
  12681. $scope.state_data = [{
  12682. "name": "全部状态",
  12683. "value": ""
  12684. },
  12685. {
  12686. "name": "在库",
  12687. "value": "1"
  12688. },
  12689. {
  12690. "name": "在线",
  12691. "value": "2"
  12692. },
  12693. {
  12694. "name": "借出",
  12695. "value": "3"
  12696. },
  12697. {
  12698. "name": "报修",
  12699. "value": "4"
  12700. },
  12701. {
  12702. "name": "报废",
  12703. "value": "5"
  12704. },
  12705. {
  12706. "name": "备用",
  12707. "value": "6"
  12708. },
  12709. ]
  12710. //资产类型
  12711. $scope.wt_zcfl = function () {
  12712. api_configure_data.fetchDataList('ciclassify', {
  12713. idx: 0,
  12714. sum: 100
  12715. }).then(function (data) {
  12716. console.log(data);
  12717. // $scope.wt_zclx = data.list;
  12718. console.log(data);
  12719. $scope.wtData = []
  12720. if (data.status == 200) {
  12721. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12722. var root = null; //Initially set our loop to null
  12723. var parentNode = null;
  12724. //loop over data
  12725. // $scope.wtData=data.list;
  12726. data = data.list;
  12727. //知识库分类数据三级处理
  12728. for (var i = 0; i < data.length; i++) {
  12729. // console.log(data[i])
  12730. var datum = data[i];
  12731. //each node will have children, so let's give it a "children" poperty
  12732. // console.log(datum);
  12733. datum.children = [];
  12734. if (!datum.parent) {
  12735. $scope.wtData.push(datum);
  12736. // console.log($scope.wtData)
  12737. } else {
  12738. if ($scope.wtData[0]) {
  12739. if ($scope.wtData[0].id == datum.parent.id) {
  12740. $scope.wtData[0].children.push(datum);
  12741. }
  12742. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  12743. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  12744. $scope.wtData[0].children[j].children.push(datum);
  12745. }
  12746. };
  12747. }
  12748. if ($scope.wtData[1]) {
  12749. if ($scope.wtData[1].id == datum.parent.id) {
  12750. $scope.wtData[1].children.push(datum);
  12751. }
  12752. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  12753. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  12754. $scope.wtData[1].children[j].children.push(datum);
  12755. }
  12756. };
  12757. }
  12758. if ($scope.wtData[2]) {
  12759. if ($scope.wtData[2].id == datum.parent.id) {
  12760. $scope.wtData[2].children.push(datum);
  12761. }
  12762. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  12763. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  12764. $scope.wtData[2].children[j].children.push(datum);
  12765. }
  12766. };
  12767. }
  12768. }
  12769. // console.log($scope.wtData)
  12770. idToNodeMap[datum.id] = datum;
  12771. root = datum;
  12772. // treeMap[datum.id] = root;
  12773. }
  12774. }
  12775. });
  12776. }
  12777. $scope.wt_zcfl();
  12778. //事件
  12779. //受理人,处理人
  12780. $scope.searchkeys = {};
  12781. var fieldata = {
  12782. "idx": 0,
  12783. "sum": 100,
  12784. "flag": -1
  12785. };
  12786. getUser(fieldata, 3);
  12787. function getUser(fieldatas, it) {
  12788. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  12789. if (it == 1) {
  12790. $scope.acceptUser = data.list;
  12791. } else if (it == 2) {
  12792. $scope.handlingPersonnelUser = data.list;
  12793. } else if (it == 3) {
  12794. $scope.acceptUser = data.list;
  12795. $scope.handlingPersonnelUser = data.list;
  12796. }
  12797. });
  12798. }
  12799. //状态
  12800. $scope.othcode = {};
  12801. api_bpm_data.fetchDataList('incidentstatus', {
  12802. "idx": 0,
  12803. "sum": 100
  12804. }).then(function (response) {
  12805. if (response) {
  12806. if (response.status = 200) {
  12807. $scope.state = response.list;
  12808. }
  12809. }
  12810. })
  12811. var defaultFilterData = {
  12812. "assignee": $rootScope.user.id,
  12813. "searchType": "todo",
  12814. "idx": 0,
  12815. "sum": mun
  12816. };
  12817. var defaultFilterData1 = {
  12818. // "searchType": "todo",
  12819. "idx": 0,
  12820. "sum": mun
  12821. };
  12822. //搜索
  12823. $scope.chiceIncident = function (parameters, item, stateid) {
  12824. console.log(item, stateid);
  12825. console.log($scope);
  12826. if ($scope.title == '关联资产编号') {
  12827. // alert('222222222222');
  12828. var fildata = defaultFilterData1;
  12829. $scope.gridOptions.paginationCurrentPage = 1;
  12830. var transitiondata = angular.copy(item);
  12831. angular.extend(fildata, transitiondata);
  12832. if (fildata.hw_state) {
  12833. fildata.hw_state = fildata.hw_state.name;
  12834. }
  12835. if (fildata.sign) {
  12836. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  12837. fildata.sign = fildata.sign.split(';');
  12838. fildata.sign = fildata.sign.join('');
  12839. fildata.sign = fildata.sign.toLowerCase()
  12840. }
  12841. if (fildata.keys) {
  12842. fildata['searchCriteria'] = 'uuid';
  12843. }
  12844. console.log(fildata);
  12845. $scope.loadData(fildata);
  12846. }
  12847. if ($scope.title == '关联事件工单') {
  12848. // alert('3333333333333333')
  12849. if (stateid && stateid.code) {
  12850. item.statusId = stateid.code;
  12851. }
  12852. var fildata = defaultFilterData;
  12853. // $scope.memoryfilterData = fildata;
  12854. if (!fildata.incident) {
  12855. fildata['incident'] = {};
  12856. }
  12857. $scope.gridOptions.paginationCurrentPage = 1;
  12858. var transitiondata = angular.copy(item);
  12859. angular.extend(fildata.incident, transitiondata);
  12860. console.log(fildata)
  12861. // $scope.loadData(fildata);
  12862. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  12863. console.log(data)
  12864. if (data) {
  12865. $scope.myData = data.list;
  12866. $scope.gridOptions.totalItems = data.totalNum;
  12867. }
  12868. })
  12869. }
  12870. }
  12871. //重置
  12872. $scope.replacement = function (parameters, searchkeys, othcode) {
  12873. // console.log(parameters, searchkeys, othcode);
  12874. delete (defaultFilterData.incident);
  12875. console.log(defaultFilterData)
  12876. $scope.parameters = null;
  12877. $scope.searchkeys = {};
  12878. $scope.othcode = {};
  12879. $scope.wt_zcfl();
  12880. }
  12881. $scope.loadData = function (filterData) {
  12882. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  12883. var myData = Restangular.stripRestangular(data);
  12884. if (myData.data && myData.data.node) {
  12885. $scope.gridOptions.totalItems = myData.total;
  12886. $scope.myData = myData.data.node;
  12887. } else {
  12888. if (myData.resultCount) {
  12889. $scope.gridOptions['totalItems'] = myData.resultCount;
  12890. } else {
  12891. $scope.gridOptions.totalItems = myData.totalNum;
  12892. }
  12893. if (myData.list) {
  12894. $scope.myData = myData.list;
  12895. } else {
  12896. $scope.myData = myData.data;
  12897. }
  12898. }
  12899. });
  12900. };
  12901. $scope.title = title;
  12902. $scope.loadData({
  12903. idx: 0,
  12904. sum: 10
  12905. });
  12906. $scope.selected = {
  12907. item: {}
  12908. };
  12909. $scope.ok = function () {
  12910. //console.log($scope.selected.item);
  12911. $modalInstance.close($scope.selected.item);
  12912. };
  12913. $scope.cancel = function () {
  12914. $modalInstance.dismiss('cancel');
  12915. };
  12916. },
  12917. size: size,
  12918. resolve: {
  12919. items: function () {
  12920. return {
  12921. fetchItems: function (filterData, APIService, $rootScope) {
  12922. filterData = filterData || {};
  12923. // if(!filterData.idx){
  12924. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12925. filterData = {
  12926. idx: 0,
  12927. sum: 10
  12928. };
  12929. }
  12930. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  12931. },
  12932. columnDefs: function () {
  12933. return options.templateOptions.columnDefs;
  12934. }
  12935. };
  12936. },
  12937. title: function () {
  12938. return options.templateOptions.modalTitle;
  12939. },
  12940. Restangular: function () {
  12941. return options.templateOptions.Restangular;
  12942. },
  12943. APIService: function () {
  12944. return options.templateOptions.ApiService;
  12945. }
  12946. }
  12947. });
  12948. modalInstance.result.then(function (selectedItem) {
  12949. var selectitem = {
  12950. title: selectedItem.title,
  12951. description: selectedItem.description
  12952. }
  12953. if (options.key == "chuku") {
  12954. if (selectedItem.assets) {
  12955. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  12956. }
  12957. if (selectedItem.consumables) {
  12958. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  12959. }
  12960. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  12961. options.value(selectedItem);
  12962. // options.model.consumables = JSON.parse(consumables);
  12963. } else if (options.templateOptions.pkey == "change") {
  12964. console.log(options)
  12965. angular.extend(options.model);
  12966. options.value(selectedItem);
  12967. } else if (options.key == "cmdbCode") {
  12968. var zc_selectitem = selectedItem.uuid;
  12969. // angular.extend(options.model,zc_selectitem);
  12970. options.model.cmdbCode = zc_selectitem;
  12971. // angular.extend(options.model,zc_selectitem);
  12972. // options.templateOptions.displayName=zc_selectitem;
  12973. options.value(selectedItem);
  12974. console.log(options.model)
  12975. } else {
  12976. angular.extend(options.model, selectitem);
  12977. options.value(selectedItem);
  12978. }
  12979. }, function () {
  12980. //console.log('Modal dismissed at: ' + new Date());
  12981. });
  12982. }
  12983. }
  12984. };
  12985. }
  12986. });
  12987. //选项选择控件
  12988. formlyConfigProvider.setType({
  12989. name: "ui-modelselect",
  12990. extends: 'input',
  12991. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12992. defaultOptions: function (options) {
  12993. return {
  12994. templateOptions: {
  12995. openModal: function (size, options, modal) {
  12996. var modalInstance = modal.open({
  12997. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12998. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  12999. $scope.langs = i18nService.getAllLangs();
  13000. $scope.lang = 'zh-cn';
  13001. i18nService.setCurrentLang($scope.lang);
  13002. $scope.gridOptions = {};
  13003. $scope.gridOptions.data = 'myData';
  13004. $scope.gridOptions.enableColumnResizing = true;
  13005. $scope.gridOptions.enableFiltering = true;
  13006. $scope.gridOptions.enableGridMenu = false;
  13007. $scope.gridOptions.enableRowSelection = true;
  13008. $scope.gridOptions.showGridFooter = true;
  13009. $scope.gridOptions.showColumnFooter = true;
  13010. $scope.gridOptions.fastWatch = true;
  13011. $scope.gridOptions.useExternalFiltering = true;
  13012. $scope.gridOptions.useExternalPagination = true;
  13013. $scope.gridOptions.paginationPageSizes = [10];
  13014. $scope.gridOptions.paginationPageSize = 10;
  13015. $scope.gridOptions.multiSelect = false;
  13016. $scope.gridOptions.rowIdentity = function (row) {
  13017. return row.id;
  13018. };
  13019. $scope.gridOptions.getRowIdentity = function (row) {
  13020. return row.id;
  13021. };
  13022. $scope.gridOptions.columnDefs = items.columnDefs();
  13023. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13024. $scope.gridApi = gridApi;
  13025. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  13026. // console.log(newPage);
  13027. // console.log(pageSize);
  13028. $scope.loadData({
  13029. "idx": newPage - 1,
  13030. "sum": pageSize
  13031. });
  13032. });
  13033. gridApi.core.on.filterChanged($scope, function () {
  13034. var grid = this.grid;
  13035. var filtersData = {
  13036. idx: 0,
  13037. sum: 10
  13038. };
  13039. angular.forEach(grid.columns, function (item) {
  13040. if (item.enableFiltering) {
  13041. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  13042. // console.log("filtersData="+JSON.stringify(filtersData))
  13043. if (angular.isUndefined(filtersData['incident'])) {
  13044. filtersData['incident'] = {};
  13045. }
  13046. filtersData['incident'][item.field] = item.filters[0].term;
  13047. if (angular.isUndefined(filtersData['problem'])) {
  13048. filtersData['problem'] = {};
  13049. }
  13050. filtersData['problem'][item.field] = item.filters[0].term;
  13051. if (angular.isUndefined(filtersData['change'])) {
  13052. filtersData['change'] = {};
  13053. }
  13054. filtersData['change'][item.field] = item.filters[0].term;
  13055. if (angular.isUndefined(filtersData['release'])) {
  13056. filtersData['release'] = {};
  13057. }
  13058. filtersData['release'][item.field] = item.filters[0].term;
  13059. }
  13060. }
  13061. });
  13062. $scope.loadData(filtersData);
  13063. });
  13064. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13065. $scope.selected.item = data.entity;
  13066. //console.log(data);
  13067. });
  13068. };
  13069. $scope.loadData = function (filterData) {
  13070. items.fetchItems(filterData, APIService).then(function (data) {
  13071. var myData = Restangular.stripRestangular(data);
  13072. $scope.gridOptions.totalItems = myData.totalNum;
  13073. $scope.myData = myData.list;
  13074. });
  13075. };
  13076. $scope.title = title;
  13077. $scope.loadData({
  13078. idx: 0,
  13079. sum: 10
  13080. });
  13081. $scope.selected = {
  13082. item: {}
  13083. };
  13084. $scope.ok = function () {
  13085. if ($scope.selected.item.scheduleOrder) {
  13086. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  13087. }
  13088. //console.log($scope.selected.item);
  13089. $modalInstance.close($scope.selected.item);
  13090. };
  13091. $scope.cancel = function () {
  13092. $modalInstance.dismiss('cancel');
  13093. };
  13094. },
  13095. size: size,
  13096. resolve: {
  13097. items: function () {
  13098. return {
  13099. fetchItems: function (filterData, APIService) {
  13100. filterData = filterData || {};
  13101. // if(!filterData.idx){
  13102. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  13103. filterData = {
  13104. idx: 0,
  13105. sum: 10
  13106. };
  13107. }
  13108. return options.templateOptions.fetchItems(filterData, APIService, options);
  13109. },
  13110. columnDefs: function () {
  13111. return options.templateOptions.columnDefs;
  13112. }
  13113. };
  13114. },
  13115. title: function () {
  13116. return options.templateOptions.modalTitle;
  13117. },
  13118. Restangular: function () {
  13119. return options.templateOptions.Restangular;
  13120. },
  13121. APIService: function () {
  13122. return options.templateOptions.ApiService;
  13123. }
  13124. }
  13125. });
  13126. modalInstance.result.then(function (selectedItem) {
  13127. options.value(selectedItem);
  13128. }, function () {
  13129. //console.log('Modal dismissed at: ' + new Date());
  13130. });
  13131. }
  13132. }
  13133. };
  13134. }
  13135. });
  13136. formlyConfigProvider.setType({
  13137. name: 'ui-requestform',
  13138. extends: 'input',
  13139. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  13140. controller: ['$scope', function ($scope) {
  13141. setTimeout(function () {
  13142. var filterData = {
  13143. "idx": 0,
  13144. "sum": 5,
  13145. "incident": {
  13146. "requester": {
  13147. "id": ""
  13148. }
  13149. }
  13150. }
  13151. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  13152. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13153. });
  13154. }, 1000);
  13155. }]
  13156. });
  13157. //报修图片展示
  13158. formlyConfigProvider.setType({
  13159. name: 'ui-repair-photos',
  13160. // extends: 'label',
  13161. templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
  13162. controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
  13163. console.log($scope);
  13164. $scope.fileUrls = [];
  13165. if ($scope.model.wxFile) {
  13166. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
  13167. $scope.fileUrls = res.data
  13168. })
  13169. }
  13170. console.log($stateParams);
  13171. if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
  13172. api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
  13173. $scope.fileUrls = res.data
  13174. })
  13175. }
  13176. if ($scope.model.flow) {
  13177. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
  13178. $scope.fileUrls = res.data
  13179. })
  13180. }
  13181. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13182. // // setTimeout(function () {
  13183. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13184. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13185. // // if (modelData.status == 200) {
  13186. // // $scope.model[$scope.options.key] = modelData.data;
  13187. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  13188. // // }
  13189. // // });
  13190. // // }, 1000);
  13191. // }
  13192. $scope.showBigImg = false;
  13193. $scope.showBigImgCli = function (data) {
  13194. $scope.showBigImg = true;
  13195. $scope.bigImgUrl = data
  13196. }
  13197. $scope.closeBigImg = function () {
  13198. $scope.showBigImg = false
  13199. }
  13200. }]
  13201. });
  13202. //图片展示
  13203. formlyConfigProvider.setType({
  13204. name: 'ui-showImgs',
  13205. templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
  13206. defaultOptions: function (options) {
  13207. return {
  13208. templateOptions: {
  13209. refresh: function (APIService, processInstanceId, data) {
  13210. return APIService.listAttachments(processInstanceId);
  13211. },
  13212. downloadUri: function (APIService, contentId) {
  13213. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13214. },
  13215. view: function (APIService, contentId) {
  13216. return APIService.attachmentsPreviewUrl(contentId);
  13217. },
  13218. download: function (APIService, contentId, item) {
  13219. var item = {
  13220. 'url': APIService.download(contentId),
  13221. 'headers': headers
  13222. };
  13223. return item;
  13224. },
  13225. refreshDelay: 0
  13226. }
  13227. };
  13228. },
  13229. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13230. var _refreshDelayPromise;
  13231. /**
  13232. * refresh
  13233. */
  13234. $scope._refresh = function (refreshAttr) {
  13235. $scope.attachments = [];
  13236. if (refreshAttr !== undefined) {
  13237. if (_refreshDelayPromise) {
  13238. $timeout.cancel(_refreshDelayPromise);
  13239. }
  13240. _refreshDelayPromise = $timeout(function () {
  13241. // 暂存附件
  13242. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13243. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13244. $scope.options.templateOptions.processInstanceId, {
  13245. 'idx': 0,
  13246. 'sum': 1000
  13247. }).then(function (response) {
  13248. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13249. if (myData) {
  13250. for (var i = 0; i < myData.data.length; i++) {
  13251. $scope.attachments.push(myData.data[i]);
  13252. }
  13253. };
  13254. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13255. $scope.$parent.$parent.$parent.model.save_fileId, {
  13256. 'idx': 0,
  13257. 'sum': 1000
  13258. }).then(function (response2) {
  13259. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13260. if (myData2) {
  13261. for (var i = 0; i < myData2.data.length; i++) {
  13262. $scope.attachments.push(myData2.data[i]);
  13263. }
  13264. };
  13265. console.log($scope.attachments)
  13266. });
  13267. });
  13268. // 正常附件
  13269. } else {
  13270. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13271. $scope.options.templateOptions.processInstanceId, {
  13272. 'idx': 0,
  13273. 'sum': 1000
  13274. }).then(function (response) {
  13275. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13276. if (myData) {
  13277. $scope.attachments = [];
  13278. $scope.imgs = []
  13279. myData.data.forEach(e => {
  13280. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13281. $scope.imgs.push(e)
  13282. }
  13283. })
  13284. $scope.imgs = $scope.imgs.splice(0, 3);
  13285. console.log($scope.imgs)
  13286. }
  13287. });
  13288. }
  13289. }, $scope.options.templateOptions.refreshDelay);
  13290. }
  13291. }
  13292. $scope._refresh({});
  13293. // $scope.attachments = $scope.model[$scope.options.key]
  13294. // 预览
  13295. $scope.preview = function (url, idx) {
  13296. var title = $scope.imgs[idx].title
  13297. $modal.open({
  13298. backdrop: false,
  13299. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13300. controller: function ($scope, scope, $modalInstance) {
  13301. $scope.title = title;
  13302. $scope.imageurl = url;
  13303. $scope.cancel = function () {
  13304. $modalInstance.dismiss('cancel');
  13305. }
  13306. },
  13307. resolve: {
  13308. scope: function () {
  13309. return $scope;
  13310. }
  13311. }
  13312. });
  13313. }
  13314. }]
  13315. });
  13316. //工单/受理人控件
  13317. formlyConfigProvider.setType({
  13318. name: 'ui-workernumbersign',
  13319. // extends: 'label',
  13320. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  13321. controller: ['$scope', function ($scope) {
  13322. // 2020年4月24日13:20:40
  13323. console.log($scope,'docu');
  13324. // 左侧事件工单区域地点填充
  13325. $scope.model.selecthouseNumber = $scope.model.place;
  13326. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13327. setTimeout(function () {
  13328. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13329. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13330. if (modelData.status == 200) {
  13331. $scope.model[$scope.options.key] = modelData.data;
  13332. $scope.options.initialValue = $scope.model[$scope.options.key];
  13333. }
  13334. });
  13335. }, 1000);
  13336. }
  13337. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  13338. if (angular.isFunction($scope.options.templateOptions.transform)) {
  13339. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  13340. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  13341. // }
  13342. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13343. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13344. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  13345. }
  13346. $scope.model.acceptUser = $scope.options.templateOptions.user;
  13347. // $scope.options.initialValue = $scope.model.acceptUser;
  13348. }
  13349. }]
  13350. });
  13351. //工单控件-only number
  13352. formlyConfigProvider.setType({
  13353. name: 'ui-workernumber',
  13354. extends: 'input',
  13355. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13356. controller: ['$scope', function ($scope) {
  13357. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13358. setTimeout(function () {
  13359. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13360. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13361. if (modelData.status == 200) {
  13362. $scope.model[$scope.options.key] = modelData.data;
  13363. $scope.options.initialValue = $scope.model[$scope.options.key];
  13364. }
  13365. });
  13366. }, 1000);
  13367. }
  13368. }]
  13369. });
  13370. //cmdb工单
  13371. formlyConfigProvider.setType({
  13372. name: 'ui-cmdbworkernumber',
  13373. extends: 'input',
  13374. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13375. controller: ['$scope', function ($scope) {
  13376. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13377. setTimeout(function () {
  13378. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  13379. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13380. // if(modelData.status==200){
  13381. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  13382. $scope.options.initialValue = $scope.model[$scope.options.key];
  13383. // }
  13384. });
  13385. }, 1000);
  13386. }
  13387. }]
  13388. });
  13389. //简易上传图片组件
  13390. formlyConfigProvider.setType({
  13391. name: 'ui-uploadImgs',
  13392. templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
  13393. wrapper: ['bootstrapHasError'],
  13394. controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
  13395. $scope.imgshows = [];
  13396. $scope.uploadimgs = [];
  13397. var model = $parse('upload_img');
  13398. var modelSetter = model.assign;
  13399. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13400. uploader.filters.push({
  13401. name: 'customFilter',
  13402. fn: function (item /*{File|FileLikeObject}*/, options) {
  13403. return this.queue.length < 10;
  13404. }
  13405. });
  13406. // 添加
  13407. $scope.change = function (event) {
  13408. var element = $('.upinp')
  13409. modelSetter($scope, element[0].files[0]);
  13410. //附件预览
  13411. $scope.imgupload = event.files[0];
  13412. getFile($scope.imgupload, $scope);
  13413. //获得预览图地址并且把file对象放入上传合集内
  13414. function getFile(imgupload, $scope) {
  13415. if (!imgupload) {
  13416. return;
  13417. }
  13418. fileReader.readAsDataUrl(imgupload, $scope)
  13419. .then(function (result) {
  13420. $scope.imgshows.push(result)
  13421. var file = document.querySelector('input[type=file]').files[0];
  13422. $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
  13423. console.log($scope.imgshows, $scope.uploadimgs)
  13424. if ($scope.imgshows.length < 3) {
  13425. $('#upup').show()
  13426. } else {
  13427. $('#upup').hide()
  13428. }
  13429. });
  13430. };
  13431. }
  13432. // 删除
  13433. $scope.uploadimg_del = function (index, imgs) {
  13434. console.log(index, imgs)
  13435. $scope.imgshows.splice(index, 1);
  13436. $scope.uploadimgs.splice(index, 1);
  13437. if ($scope.imgshows.length < 3) {
  13438. $('#upup').show()
  13439. } else {
  13440. $('#upup').hide()
  13441. }
  13442. }
  13443. // 预览
  13444. $scope.preview = function (url, idx) {
  13445. var name = $scope.uploadimgs[idx].name
  13446. $modal.open({
  13447. backdrop: false,
  13448. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13449. controller: function ($scope, scope, $modalInstance) {
  13450. $scope.title = name;
  13451. $scope.imageurl = url;
  13452. $scope.cancel = function () {
  13453. $modalInstance.dismiss('cancel');
  13454. }
  13455. },
  13456. resolve: {
  13457. scope: function () {
  13458. return $scope;
  13459. }
  13460. }
  13461. });
  13462. }
  13463. if (uploader) {
  13464. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13465. console.info('onWhenAddingFileFailed', item, filter, options);
  13466. };
  13467. uploader.onAfterAddingFile = function (fileItem) {
  13468. console.info('onAfterAddingFile', fileItem);
  13469. };
  13470. uploader.onAfterAddingAll = function (addedFileItems) {
  13471. console.info('onAfterAddingAll', addedFileItems);
  13472. };
  13473. uploader.onBeforeUploadItem = function (item) {
  13474. console.info('onBeforeUploadItem', item);
  13475. };
  13476. uploader.onProgressItem = function (fileItem, progress) {
  13477. console.info('onProgressItem', fileItem, progress);
  13478. };
  13479. uploader.onProgressAll = function (progress) {
  13480. console.info('onProgressAll', progress);
  13481. };
  13482. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13483. console.info('onSuccessItem', fileItem, response, status, headers);
  13484. };
  13485. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13486. console.info('onErrorItem', fileItem, response, status, headers);
  13487. };
  13488. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13489. console.info('onCancelItem', fileItem, response, status, headers);
  13490. };
  13491. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13492. console.info('onCompleteItem', fileItem, response, status, headers);
  13493. };
  13494. uploader.onCompleteAll = function () {
  13495. console.info('onCompleteAll');
  13496. };
  13497. }
  13498. // console.log(modelSetter)
  13499. }]
  13500. });
  13501. //jry-上传下载一体
  13502. formlyConfigProvider.setType({
  13503. name: 'ui-upDropFile',
  13504. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  13505. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13506. defaultOptions: function (options) {
  13507. return {
  13508. templateOptions: {
  13509. view: function (APIService, contentId) {
  13510. return APIService.downloadAttachment(contentId);
  13511. },
  13512. // ApiService: 'api_wechatfile',
  13513. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  13514. // upUrl: 'common/common/uploadAttachment',
  13515. // listAttachmentUrl: 'common/common/listAttachment',
  13516. // downUrl: 'common/common/downloadAttachment',
  13517. // bindType: 'incident',
  13518. // bindId: 2323
  13519. },
  13520. // validators: {
  13521. // required: {
  13522. // expression: function(viewValue, modelValue) {
  13523. // var value = modelValue || viewValue;
  13524. // return value.length >= 1;
  13525. // }
  13526. // }
  13527. // }
  13528. };
  13529. },
  13530. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  13531. console.log($scope);
  13532. $scope.showFileUp = true;
  13533. if ($scope.model.isKnowledge_detail) {
  13534. $scope.showFileUp = false;
  13535. }
  13536. if (angular.isUndefined($scope.form.dropState)) {
  13537. $scope.form.dropState = false;
  13538. }
  13539. if ($scope.model.incident) {
  13540. if ($scope.model.incident.alarm) {
  13541. console.log($scope)
  13542. if ($scope.model.incident.alarm) {
  13543. if ($scope.model.incident.alarm.alarmExtension) {
  13544. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  13545. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  13546. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  13547. console.log($scope.model.incident.description)
  13548. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  13549. } else {
  13550. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  13551. }
  13552. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  13553. console.log($scope.model.incident.description)
  13554. };
  13555. }
  13556. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  13557. console.log(wt_data);
  13558. if (wt_data) {
  13559. $rootScope.wt_category = wt_data.data;
  13560. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  13561. $rootScope.wt_child = wt_data.child
  13562. }
  13563. })
  13564. if ($scope.model.titleName == '接单') {
  13565. $scope.model.receive_code = 'handler'
  13566. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  13567. $scope.model.isHandlerUser = true;
  13568. }
  13569. }
  13570. if ($scope.model.titleName == '事件处理') {
  13571. console.log($scope.model.cmdbCode)
  13572. if ($scope.model.cmdbCode) {
  13573. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  13574. }
  13575. }
  13576. } else {
  13577. $rootScope.wt_category = '';
  13578. }
  13579. //附件上传数据
  13580. if ($scope.options.templateOptions.fileUploader) {
  13581. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13582. //$scope.options.templateOptions.uploader();
  13583. console.log(uploader)
  13584. // FILTERS
  13585. uploader.filters.push({
  13586. name: 'customFilter',
  13587. fn: function (item /*{File|FileLikeObject}*/, options) {
  13588. return this.queue.length < 10;
  13589. }
  13590. });
  13591. }
  13592. var to = $scope.options.templateOptions;
  13593. // var bindType = $scope.model.bindType;
  13594. if (to.bindType == 'incident') {
  13595. var bindId = $scope.model[to.bindType].processInstanceId;
  13596. } else if (to.bindType == 'change') {
  13597. var bindId = $scope.model[to.bindType].processInstanceId;
  13598. } else {
  13599. var bindId = $scope.model[to.bindType].id;
  13600. }
  13601. //获取附件列表
  13602. $scope.listAttachmen = function () {
  13603. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  13604. var myData = Restangular.stripRestangular(result);
  13605. // $scope.listAttachmens = myData;
  13606. $scope.attachments = myData.data;
  13607. });
  13608. };
  13609. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  13610. $scope.listAttachmen();
  13611. } else if (to.bindType && $scope.model[to.bindType].id) {
  13612. $scope.listAttachmen();
  13613. }
  13614. //附件上传
  13615. $scope.isUpfload = to.isUpfload;
  13616. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13617. uploader.onBeforeUploadItem = function (item) {
  13618. angular.extend(item.headers, $rootScope.getSession());
  13619. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  13620. item.formData.push({
  13621. 'filename': item.file.name
  13622. });
  13623. };
  13624. uploader.uploadAll();
  13625. }
  13626. //附件下载
  13627. $scope.download = function (token, filename) {
  13628. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  13629. // window.open(downUrl);
  13630. var a = document.createElement('a');
  13631. a.href = downUrl;
  13632. a.target = '_blank';
  13633. a.download = filename;
  13634. document.body.appendChild(a);
  13635. a.click();
  13636. };
  13637. //附件预览
  13638. $scope.view = function (id, previewUrl) {
  13639. if (previewUrl) {
  13640. window.open(previewUrl);
  13641. }
  13642. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  13643. // if (response.state == 200) {
  13644. // window.open(response.previewUrl);
  13645. // }
  13646. // })
  13647. };
  13648. // CALLBACKS
  13649. if (uploader) {
  13650. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13651. console.info('onWhenAddingFileFailed', item, filter, options);
  13652. };
  13653. uploader.onAfterAddingFile = function (fileItem) {
  13654. console.info('onAfterAddingFile', fileItem);
  13655. };
  13656. uploader.onAfterAddingAll = function (addedFileItems) {
  13657. console.info('onAfterAddingAll', addedFileItems);
  13658. };
  13659. uploader.onBeforeUploadItem = function (item) {
  13660. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13661. // // $scope.uploader.options.url();
  13662. // $scope.uploader.onBeforeUploadItem = function(item) {
  13663. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13664. // console.info('onBeforeUploadItem', item);
  13665. // };
  13666. // $scope.uploader.uploadAll();
  13667. // }
  13668. console.info('onBeforeUploadItem', item);
  13669. };
  13670. uploader.onProgressItem = function (fileItem, progress) {
  13671. console.info('onProgressItem', fileItem, progress);
  13672. };
  13673. uploader.onProgressAll = function (progress) {
  13674. console.info('onProgressAll', progress);
  13675. };
  13676. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13677. console.info('onSuccessItem', fileItem, response, status, headers);
  13678. if (response.status == 200) {
  13679. $scope.listAttachmen();
  13680. }
  13681. };
  13682. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13683. console.info('onErrorItem', fileItem, response, status, headers);
  13684. };
  13685. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13686. console.info('onCancelItem', fileItem, response, status, headers);
  13687. };
  13688. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13689. console.info('onCompleteItem', fileItem, response, status, headers);
  13690. };
  13691. uploader.onCompleteAll = function () {
  13692. console.info('onCompleteAll');
  13693. };
  13694. }
  13695. }]
  13696. });
  13697. //简易上传下载附件组件
  13698. formlyConfigProvider.setType({
  13699. name: 'ui-upDownFiles',
  13700. templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
  13701. wrapper: ['bootstrapHasError'],
  13702. defaultOptions: function (options) {
  13703. return {
  13704. templateOptions: {
  13705. refresh: function (APIService, processInstanceId, data) {
  13706. return APIService.listAttachments(processInstanceId);
  13707. },
  13708. downloadUri: function (APIService, contentId) {
  13709. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13710. },
  13711. view: function (APIService, contentId) {
  13712. return APIService.attachmentsPreviewUrl(contentId);
  13713. },
  13714. download: function (APIService, contentId, item) {
  13715. var item = {
  13716. 'url': APIService.download(contentId),
  13717. 'headers': headers
  13718. };
  13719. return item;
  13720. },
  13721. refreshDelay: 0
  13722. }
  13723. };
  13724. },
  13725. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13726. if (angular.isUndefined($scope.form.dropState)) {
  13727. $scope.form.dropState = false;
  13728. }
  13729. //附件上传数据
  13730. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13731. //$scope.options.templateOptions.uploader();
  13732. // FILTERS
  13733. uploader.filters.push({
  13734. name: 'customFilter',
  13735. fn: function (item /*{File|FileLikeObject}*/, options) {
  13736. return this.queue.length < 10;
  13737. }
  13738. });
  13739. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13740. // uploader.onBeforeUploadItem = function (item) {
  13741. // angular.extend(item.headers, $rootScope.getSession());
  13742. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13743. // item.formData.push({
  13744. // 'fileName': item.file.name
  13745. // });
  13746. // console.info('onBeforeUploadItem', item);
  13747. // };
  13748. // }
  13749. // CALLBACKS
  13750. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13751. console.info('onWhenAddingFileFailed', item, filter, options);
  13752. };
  13753. uploader.onAfterAddingFile = function (fileItem) {
  13754. console.info('onAfterAddingFile', fileItem);
  13755. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13756. alert('文件过大');
  13757. fileItem.uploader.queue.pop()
  13758. console.log($scope);
  13759. }
  13760. };
  13761. uploader.onAfterAddingAll = function (addedFileItems) {
  13762. // console.info('onAfterAddingAll', addedFileItems);
  13763. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13764. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13765. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13766. // console.log(123)
  13767. };
  13768. uploader.onBeforeUploadItem = function (item) {
  13769. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13770. // // $scope.uploader.options.url();
  13771. // $scope.uploader.onBeforeUploadItem = function(item) {
  13772. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13773. // console.info('onBeforeUploadItem', item);
  13774. // };
  13775. // $scope.uploader.uploadAll();
  13776. // }
  13777. console.info('onBeforeUploadItem', item);
  13778. };
  13779. uploader.onProgressItem = function (fileItem, progress) {
  13780. console.info('onProgressItem', fileItem, progress);
  13781. };
  13782. uploader.onProgressAll = function (progress) {
  13783. console.info('onProgressAll', progress);
  13784. };
  13785. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13786. console.info('onSuccessItem', fileItem, response, status, headers);
  13787. };
  13788. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13789. console.info('onErrorItem', fileItem, response, status, headers);
  13790. };
  13791. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13792. console.info('onCancelItem', fileItem, response, status, headers);
  13793. };
  13794. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13795. console.info('onCompleteItem', fileItem, response, status, headers);
  13796. };
  13797. uploader.onCompleteAll = function () {
  13798. console.info('onCompleteAll');
  13799. };
  13800. var _refreshDelayPromise;
  13801. // 下载
  13802. $scope.download = function (contentId, filename, token) {
  13803. // console.log(contentId, filename, token)
  13804. //附件下载
  13805. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  13806. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  13807. // console.log(downUrl)
  13808. var a = document.createElement('a');
  13809. a.href = downUrl;
  13810. a.target = '_blank';
  13811. a.download = filename;
  13812. document.body.appendChild(a);
  13813. a.click();
  13814. };
  13815. $scope._refresh = function (refreshAttr) {
  13816. $scope.attachments = [];
  13817. if (refreshAttr !== undefined) {
  13818. if (_refreshDelayPromise) {
  13819. $timeout.cancel(_refreshDelayPromise);
  13820. }
  13821. _refreshDelayPromise = $timeout(function () {
  13822. // 暂存附件
  13823. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13824. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13825. $scope.options.templateOptions.processInstanceId, {
  13826. 'idx': 0,
  13827. 'sum': 1000
  13828. }).then(function (response) {
  13829. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13830. if (myData) {
  13831. for (var i = 0; i < myData.data.length; i++) {
  13832. $scope.attachments.push(myData.data[i]);
  13833. }
  13834. };
  13835. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13836. $scope.$parent.$parent.$parent.model.save_fileId, {
  13837. 'idx': 0,
  13838. 'sum': 1000
  13839. }).then(function (response2) {
  13840. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13841. if (myData2) {
  13842. for (var i = 0; i < myData2.data.length; i++) {
  13843. $scope.attachments.push(myData2.data[i]);
  13844. }
  13845. // 只展示除图片以外的附件
  13846. var a = [];
  13847. $scope.attachments.forEach(e => {
  13848. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13849. // $scope.imgs.push(e)
  13850. } else {
  13851. a.push(e)
  13852. }
  13853. })
  13854. $scope.attachments = a;
  13855. };
  13856. console.log($scope.attachments)
  13857. });
  13858. });
  13859. // 正常附件
  13860. } else {
  13861. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13862. $scope.options.templateOptions.processInstanceId, {
  13863. 'idx': 0,
  13864. 'sum': 1000
  13865. }).then(function (response) {
  13866. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13867. if (myData) {
  13868. $scope.attachments = myData.data;
  13869. // 只展示除图片以外的附件
  13870. var a = [];
  13871. $scope.attachments.forEach(e => {
  13872. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13873. // $scope.imgs.push(e)
  13874. } else {
  13875. a.push(e)
  13876. }
  13877. })
  13878. $scope.attachments = a;
  13879. }
  13880. });
  13881. }
  13882. }, $scope.options.templateOptions.refreshDelay);
  13883. }
  13884. }
  13885. $scope._refresh({});
  13886. }]
  13887. });
  13888. //简易上传附件组件
  13889. formlyConfigProvider.setType({
  13890. name: 'ui-uploadFiles',
  13891. templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
  13892. wrapper: ['bootstrapHasError'],
  13893. controller: ['$scope', function ($scope) {
  13894. if (angular.isUndefined($scope.form.dropState)) {
  13895. $scope.form.dropState = false;
  13896. }
  13897. //附件上传数据
  13898. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13899. //$scope.options.templateOptions.uploader();
  13900. // FILTERS
  13901. uploader.filters.push({
  13902. name: 'customFilter',
  13903. fn: function (item /*{File|FileLikeObject}*/, options) {
  13904. return this.queue.length < 10;
  13905. }
  13906. });
  13907. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13908. uploader.onBeforeUploadItem = function (item) {
  13909. angular.extend(item.headers, $rootScope.getSession());
  13910. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13911. item.formData.push({
  13912. 'fileName': item.file.name
  13913. });
  13914. console.info('onBeforeUploadItem', item);
  13915. };
  13916. }
  13917. // CALLBACKS
  13918. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13919. console.info('onWhenAddingFileFailed', item, filter, options);
  13920. };
  13921. uploader.onAfterAddingFile = function (fileItem) {
  13922. console.info('onAfterAddingFile', fileItem);
  13923. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13924. alert('文件过大');
  13925. fileItem.uploader.queue.pop()
  13926. console.log($scope);
  13927. }
  13928. };
  13929. uploader.onAfterAddingAll = function (addedFileItems) {
  13930. // console.info('onAfterAddingAll', addedFileItems);
  13931. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13932. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13933. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13934. // console.log(123)
  13935. };
  13936. uploader.onBeforeUploadItem = function (item) {
  13937. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13938. // // $scope.uploader.options.url();
  13939. // $scope.uploader.onBeforeUploadItem = function(item) {
  13940. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13941. // console.info('onBeforeUploadItem', item);
  13942. // };
  13943. // $scope.uploader.uploadAll();
  13944. // }
  13945. console.info('onBeforeUploadItem', item);
  13946. };
  13947. uploader.onProgressItem = function (fileItem, progress) {
  13948. console.info('onProgressItem', fileItem, progress);
  13949. };
  13950. uploader.onProgressAll = function (progress) {
  13951. console.info('onProgressAll', progress);
  13952. };
  13953. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13954. console.info('onSuccessItem', fileItem, response, status, headers);
  13955. };
  13956. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13957. console.info('onErrorItem', fileItem, response, status, headers);
  13958. };
  13959. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13960. console.info('onCancelItem', fileItem, response, status, headers);
  13961. };
  13962. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13963. console.info('onCompleteItem', fileItem, response, status, headers);
  13964. };
  13965. uploader.onCompleteAll = function () {
  13966. console.info('onCompleteAll');
  13967. };
  13968. }]
  13969. });
  13970. //无上传按钮附件上传组件
  13971. formlyConfigProvider.setType({
  13972. name: 'ui-dropfilenotup',
  13973. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  13974. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13975. controller: ['$scope', function ($scope) {
  13976. if (angular.isUndefined($scope.form.dropState)) {
  13977. $scope.form.dropState = false;
  13978. }
  13979. //附件上传数据
  13980. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13981. //$scope.options.templateOptions.uploader();
  13982. // FILTERS
  13983. uploader.filters.push({
  13984. name: 'customFilter',
  13985. fn: function (item /*{File|FileLikeObject}*/, options) {
  13986. return this.queue.length < 10;
  13987. }
  13988. });
  13989. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13990. uploader.onBeforeUploadItem = function (item) {
  13991. angular.extend(item.headers, $rootScope.getSession());
  13992. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13993. item.formData.push({
  13994. 'fileName': item.file.name
  13995. });
  13996. console.info('onBeforeUploadItem', item);
  13997. };
  13998. uploader.uploadAll();
  13999. }
  14000. // CALLBACKS
  14001. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14002. console.info('onWhenAddingFileFailed', item, filter, options);
  14003. };
  14004. uploader.onAfterAddingFile = function (fileItem) {
  14005. console.info('onAfterAddingFile', fileItem);
  14006. };
  14007. uploader.onAfterAddingAll = function (addedFileItems) {
  14008. console.info('onAfterAddingAll', addedFileItems);
  14009. };
  14010. uploader.onBeforeUploadItem = function (item) {
  14011. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14012. // // $scope.uploader.options.url();
  14013. // $scope.uploader.onBeforeUploadItem = function(item) {
  14014. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14015. // console.info('onBeforeUploadItem', item);
  14016. // };
  14017. // $scope.uploader.uploadAll();
  14018. // }
  14019. console.info('onBeforeUploadItem', item);
  14020. };
  14021. uploader.onProgressItem = function (fileItem, progress) {
  14022. console.info('onProgressItem', fileItem, progress);
  14023. };
  14024. uploader.onProgressAll = function (progress) {
  14025. console.info('onProgressAll', progress);
  14026. };
  14027. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14028. console.info('onSuccessItem', fileItem, response, status, headers);
  14029. };
  14030. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14031. console.info('onErrorItem', fileItem, response, status, headers);
  14032. };
  14033. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14034. console.info('onCancelItem', fileItem, response, status, headers);
  14035. };
  14036. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14037. console.info('onCompleteItem', fileItem, response, status, headers);
  14038. };
  14039. uploader.onCompleteAll = function () {
  14040. console.info('onCompleteAll');
  14041. };
  14042. }]
  14043. });
  14044. //无按钮知识库上传
  14045. formlyConfigProvider.setType({
  14046. name: 'ui-dropfielkn',
  14047. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14048. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14049. controller: ['$scope', function ($scope) {
  14050. if (angular.isUndefined($scope.form.dropState)) {
  14051. $scope.form.dropState = false;
  14052. }
  14053. //附件上传数据
  14054. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14055. //$scope.options.templateOptions.uploader();
  14056. // FILTERS
  14057. uploader.filters.push({
  14058. name: 'customFilter',
  14059. fn: function (item /*{File|FileLikeObject}*/, options) {
  14060. return this.queue.length < 10;
  14061. }
  14062. });
  14063. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14064. uploader.onBeforeUploadItem = function (item) {
  14065. angular.extend(item.headers, $rootScope.getSession());
  14066. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  14067. item.formData.push({
  14068. 'fileName': item.file.name
  14069. });
  14070. console.info('onBeforeUploadItem', item);
  14071. };
  14072. uploader.uploadAll();
  14073. }
  14074. // CALLBACKS
  14075. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14076. console.info('onWhenAddingFileFailed', item, filter, options);
  14077. };
  14078. uploader.onAfterAddingFile = function (fileItem) {
  14079. console.info('onAfterAddingFile', fileItem);
  14080. };
  14081. uploader.onAfterAddingAll = function (addedFileItems) {
  14082. console.info('onAfterAddingAll', addedFileItems);
  14083. };
  14084. uploader.onBeforeUploadItem = function (item) {
  14085. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14086. // // $scope.uploader.options.url();
  14087. // $scope.uploader.onBeforeUploadItem = function(item) {
  14088. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14089. // console.info('onBeforeUploadItem', item);
  14090. // };
  14091. // $scope.uploader.uploadAll();
  14092. // }
  14093. console.info('onBeforeUploadItem', item);
  14094. };
  14095. uploader.onProgressItem = function (fileItem, progress) {
  14096. console.info('onProgressItem', fileItem, progress);
  14097. };
  14098. uploader.onProgressAll = function (progress) {
  14099. console.info('onProgressAll', progress);
  14100. };
  14101. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14102. console.info('onSuccessItem', fileItem, response, status, headers);
  14103. };
  14104. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14105. console.info('onErrorItem', fileItem, response, status, headers);
  14106. };
  14107. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14108. console.info('onCancelItem', fileItem, response, status, headers);
  14109. };
  14110. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14111. console.info('onCompleteItem', fileItem, response, status, headers);
  14112. };
  14113. uploader.onCompleteAll = function () {
  14114. console.info('onCompleteAll');
  14115. };
  14116. }]
  14117. });
  14118. //附件上传列表组件
  14119. formlyConfigProvider.setType({
  14120. name: 'ui-dropfile',
  14121. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14122. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14123. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14124. if (angular.isUndefined($scope.form.dropState)) {
  14125. $scope.form.dropState = false;
  14126. }
  14127. //附件上传数据
  14128. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14129. //$scope.options.templateOptions.uploader();
  14130. // FILTERS
  14131. uploader.filters.push({
  14132. name: 'customFilter',
  14133. fn: function (item /*{File|FileLikeObject}*/, options) {
  14134. return this.queue.length < 10;
  14135. }
  14136. });
  14137. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14138. uploader.onBeforeUploadItem = function (item) {
  14139. angular.extend(item.headers, $rootScope.getSession());
  14140. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  14141. // if ($scope.options.templateOptions.formket) {
  14142. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  14143. // } else {
  14144. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  14145. // }
  14146. } else {
  14147. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14148. }
  14149. item.formData.push({
  14150. 'filename': item.file.name
  14151. });
  14152. console.info('onBeforeUploadItem', item);
  14153. };
  14154. uploader.uploadAll();
  14155. }
  14156. // CALLBACKS
  14157. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14158. console.info('onWhenAddingFileFailed', item, filter, options);
  14159. };
  14160. uploader.onAfterAddingFile = function (fileItem) {
  14161. console.info('onAfterAddingFile', fileItem);
  14162. };
  14163. uploader.onAfterAddingAll = function (addedFileItems) {
  14164. console.info('onAfterAddingAll', addedFileItems);
  14165. };
  14166. uploader.onBeforeUploadItem = function (item) {
  14167. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14168. // // $scope.uploader.options.url();
  14169. // $scope.uploader.onBeforeUploadItem = function(item) {
  14170. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14171. // console.info('onBeforeUploadItem', item);
  14172. // };
  14173. // $scope.uploader.uploadAll();
  14174. // }
  14175. console.info('onBeforeUploadItem', item);
  14176. };
  14177. uploader.onProgressItem = function (fileItem, progress) {
  14178. console.info('onProgressItem', fileItem, progress);
  14179. };
  14180. uploader.onProgressAll = function (progress) {
  14181. console.info('onProgressAll', progress);
  14182. };
  14183. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14184. console.info('onSuccessItem', fileItem, response, status, headers);
  14185. };
  14186. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14187. console.info('onErrorItem', fileItem, response, status, headers);
  14188. };
  14189. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14190. console.info('onCancelItem', fileItem, response, status, headers);
  14191. };
  14192. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14193. console.info('onCompleteItem', fileItem, response, status, headers);
  14194. };
  14195. uploader.onCompleteAll = function () {
  14196. console.info('onCompleteAll');
  14197. };
  14198. }]
  14199. });
  14200. //简易附件展示下载列表组件
  14201. formlyConfigProvider.setType({
  14202. name: 'ui-dropFiles',
  14203. templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
  14204. defaultOptions: function (options) {
  14205. return {
  14206. templateOptions: {
  14207. refresh: function (APIService, processInstanceId, data) {
  14208. return APIService.listAttachments(processInstanceId);
  14209. },
  14210. downloadUri: function (APIService, contentId) {
  14211. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14212. },
  14213. view: function (APIService, contentId) {
  14214. return APIService.attachmentsPreviewUrl(contentId);
  14215. },
  14216. download: function (APIService, contentId, item) {
  14217. var item = {
  14218. 'url': APIService.download(contentId),
  14219. 'headers': headers
  14220. };
  14221. return item;
  14222. },
  14223. refreshDelay: 0
  14224. }
  14225. };
  14226. },
  14227. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  14228. var _refreshDelayPromise;
  14229. // $scope.downloadUrl = function(contentId){
  14230. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14231. // };
  14232. $scope.download = function (contentId, filename, token) {
  14233. // console.log(contentId, filename, token)
  14234. //附件下载
  14235. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  14236. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  14237. // console.log(downUrl)
  14238. var a = document.createElement('a');
  14239. a.href = downUrl;
  14240. a.target = '_blank';
  14241. a.download = filename;
  14242. document.body.appendChild(a);
  14243. a.click();
  14244. };
  14245. $scope.view = function (contentId, token, filename, type) {
  14246. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14247. if (response.state == 200) {
  14248. window.open(response.previewUrl);
  14249. }
  14250. })
  14251. };
  14252. /**
  14253. * refresh
  14254. */
  14255. $scope._refresh = function (refreshAttr) {
  14256. $scope.attachments = [];
  14257. if (refreshAttr !== undefined) {
  14258. if (_refreshDelayPromise) {
  14259. $timeout.cancel(_refreshDelayPromise);
  14260. }
  14261. _refreshDelayPromise = $timeout(function () {
  14262. // 暂存附件
  14263. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  14264. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14265. $scope.options.templateOptions.processInstanceId, {
  14266. 'idx': 0,
  14267. 'sum': 1000
  14268. }).then(function (response) {
  14269. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14270. if (myData) {
  14271. for (var i = 0; i < myData.data.length; i++) {
  14272. $scope.attachments.push(myData.data[i]);
  14273. }
  14274. };
  14275. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14276. $scope.$parent.$parent.$parent.model.save_fileId, {
  14277. 'idx': 0,
  14278. 'sum': 1000
  14279. }).then(function (response2) {
  14280. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  14281. if (myData2) {
  14282. for (var i = 0; i < myData2.data.length; i++) {
  14283. $scope.attachments.push(myData2.data[i]);
  14284. }
  14285. // 只展示除图片以外的附件
  14286. var a = [];
  14287. $scope.attachments.forEach(e => {
  14288. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14289. // $scope.imgs.push(e)
  14290. } else {
  14291. a.push(e)
  14292. }
  14293. })
  14294. $scope.attachments = a;
  14295. };
  14296. console.log($scope.attachments)
  14297. });
  14298. });
  14299. // 正常附件
  14300. } else {
  14301. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14302. $scope.options.templateOptions.processInstanceId, {
  14303. 'idx': 0,
  14304. 'sum': 1000
  14305. }).then(function (response) {
  14306. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14307. if (myData) {
  14308. $scope.attachments = myData.data;
  14309. // 只展示除图片以外的附件
  14310. var a = [];
  14311. $scope.attachments.forEach(e => {
  14312. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14313. // $scope.imgs.push(e)
  14314. } else {
  14315. a.push(e)
  14316. }
  14317. })
  14318. $scope.attachments = a;
  14319. console.log($scope.attachments)
  14320. }
  14321. });
  14322. }
  14323. }, $scope.options.templateOptions.refreshDelay);
  14324. }
  14325. }
  14326. $scope._refresh({});
  14327. // $scope.attachments = $scope.model[$scope.options.key]
  14328. }]
  14329. });
  14330. //知识库附件上传
  14331. formlyConfigProvider.setType({
  14332. name: 'ui-dropfielknow',
  14333. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14334. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14335. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14336. if (angular.isUndefined($scope.form.dropState)) {
  14337. $scope.form.dropState = false;
  14338. }
  14339. //附件上传数据
  14340. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14341. //$scope.options.templateOptions.uploader();
  14342. // FILTERS
  14343. uploader.filters.push({
  14344. name: 'customFilter',
  14345. fn: function (item /*{File|FileLikeObject}*/, options) {
  14346. return this.queue.length < 10;
  14347. }
  14348. });
  14349. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14350. uploader.onBeforeUploadItem = function (item) {
  14351. angular.extend(item.headers, $rootScope.getSession());
  14352. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  14353. item.formData.push({
  14354. 'fileName': item.file.name,
  14355. 'type': 'solution',
  14356. 'solutionId': $scope.model.knowledge.id
  14357. });
  14358. console.info('onBeforeUploadItem', item);
  14359. };
  14360. uploader.uploadAll();
  14361. }
  14362. // CALLBACKS
  14363. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14364. console.info('onWhenAddingFileFailed', item, filter, options);
  14365. };
  14366. uploader.onAfterAddingFile = function (fileItem) {
  14367. console.info('onAfterAddingFile', fileItem);
  14368. };
  14369. uploader.onAfterAddingAll = function (addedFileItems) {
  14370. console.info('onAfterAddingAll', addedFileItems);
  14371. };
  14372. uploader.onBeforeUploadItem = function (item) {
  14373. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14374. // // $scope.uploader.options.url();
  14375. // $scope.uploader.onBeforeUploadItem = function(item) {
  14376. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14377. // console.info('onBeforeUploadItem', item);
  14378. // };
  14379. // $scope.uploader.uploadAll();
  14380. // }
  14381. console.info('onBeforeUploadItem', item);
  14382. };
  14383. uploader.onProgressItem = function (fileItem, progress) {
  14384. console.info('onProgressItem', fileItem, progress);
  14385. };
  14386. uploader.onProgressAll = function (progress) {
  14387. console.info('onProgressAll', progress);
  14388. };
  14389. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14390. console.info('onSuccessItem', fileItem, response, status, headers);
  14391. };
  14392. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14393. console.info('onErrorItem', fileItem, response, status, headers);
  14394. };
  14395. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14396. console.info('onCancelItem', fileItem, response, status, headers);
  14397. };
  14398. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14399. console.info('onCompleteItem', fileItem, response, status, headers);
  14400. };
  14401. uploader.onCompleteAll = function () {
  14402. console.info('onCompleteAll');
  14403. };
  14404. }]
  14405. });
  14406. //知识库附件下载列表
  14407. formlyConfigProvider.setType({
  14408. name: 'ui-dropfileknowledge',
  14409. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  14410. defaultOptions: function (options) {
  14411. return {
  14412. templateOptions: {
  14413. refresh: function (APIService, contentId, data) {
  14414. return APIService.fetchDataList(contentId, data);
  14415. },
  14416. downloadUri: function (APIService, contentId) {
  14417. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14418. },
  14419. download: function (APIService, contentId) {
  14420. return APIService.getSolutionDowpath(contentId);
  14421. },
  14422. view: function (attachmentId) {
  14423. // return APIService.attachmentsPreviewUrl(contentId);
  14424. },
  14425. refreshDelay: 0
  14426. }
  14427. };
  14428. },
  14429. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  14430. var _refreshDelayPromise;
  14431. $scope.attachments = [];
  14432. $scope.downloadUrl = function (contentId) {
  14433. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  14434. };
  14435. $scope.download = function (contentId, filename) {
  14436. $http({
  14437. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  14438. method: 'GET',
  14439. headers: {
  14440. //'Content-type' : 'application/xls',
  14441. 'Accept': '*/*'
  14442. },
  14443. responseType: 'arraybuffer'
  14444. }).success(function (data, status, headers, config) {
  14445. var file = new Blob([data], {
  14446. type: 'application/octet-stream'
  14447. });
  14448. //trick to download store a file having its URL
  14449. var fileURL = URL.createObjectURL(file);
  14450. var a = document.createElement('a');
  14451. a.href = fileURL;
  14452. a.target = '_blank';
  14453. a.download = filename;
  14454. document.body.appendChild(a);
  14455. a.click();
  14456. }).error(function (data, status, headers, config) {
  14457. // console.log(data);
  14458. });
  14459. }
  14460. $scope.view = function (contentId, filename, attachment) {
  14461. var index = filename.indexOf(".");
  14462. var type = filename.substring(index + 1);
  14463. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14464. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  14465. // var modalInstance = $modal.open({
  14466. // backdrop: false,
  14467. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14468. // controller: function($scope, scope, $modalInstance, filename) {
  14469. // $scope.title = filename;
  14470. // $scope.imageurl = scope.imageurl;
  14471. // $scope.cancel = function() {
  14472. // $modalInstance.dismiss('cancel');
  14473. // }
  14474. // },
  14475. // resolve: {
  14476. // scope: function() {
  14477. // return $scope;
  14478. // },
  14479. // filename: function() {
  14480. // return filename;
  14481. // }
  14482. // }
  14483. // });
  14484. // event.preventDefault();
  14485. // } else {
  14486. // for (var i = 0; i < $scope.attachments.length; i++) {
  14487. // if ($scope.attachments[i].id == attachmentId) {
  14488. window.open(attachment.previewUrl);
  14489. // }
  14490. // }
  14491. // }
  14492. };
  14493. $scope._refresh = function (refreshAttr) {
  14494. if (refreshAttr !== undefined) {
  14495. if (_refreshDelayPromise) {
  14496. $timeout.cancel(_refreshDelayPromise);
  14497. }
  14498. _refreshDelayPromise = $timeout(function () {
  14499. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14500. 'file', {
  14501. "file": {
  14502. "solutionId": $scope.model.knowledge.id
  14503. },
  14504. "idx": "0",
  14505. "sum": "1000"
  14506. }).then(function (response) {
  14507. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14508. if (myData) {
  14509. $scope.attachments = myData.list;
  14510. // $scope.view = function(attachmentId) {
  14511. // for (var i = 0; i < $scope.attachments.length; i++) {
  14512. // if ($scope.attachments[i].id == attachmentId) {
  14513. // window.open($scope.attachments[i].previewUrl);
  14514. // // var modalInstance = $modal.open({
  14515. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  14516. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  14517. // // }
  14518. // // });
  14519. // }
  14520. // }
  14521. // };
  14522. }
  14523. });
  14524. }, $scope.options.templateOptions.refreshDelay);
  14525. }
  14526. }
  14527. $scope._refresh({});
  14528. // $scope.attachments = $scope.model[$scope.options.key]
  14529. }]
  14530. });
  14531. //附件图片下载
  14532. formlyConfigProvider.setType({
  14533. name: 'ui-downimage',
  14534. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  14535. defaultOptions: function (options) {
  14536. return {
  14537. templateOptions: {
  14538. refresh: function (APIService, processInstanceId, data) {
  14539. return APIService.listAttachments(processInstanceId, data);
  14540. },
  14541. downloadUri: function (APIService, contentId) {
  14542. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14543. },
  14544. view: function (APIService, contentId) {
  14545. return APIService.attachmentsPreviewUrl(contentId);
  14546. },
  14547. download: function (APIService, contentId, item) {
  14548. var item = {
  14549. 'url': APIService.download(contentId),
  14550. 'headers': headers
  14551. };
  14552. return item;
  14553. },
  14554. refreshDelay: 0
  14555. }
  14556. };
  14557. },
  14558. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  14559. var _refreshDelayPromise;
  14560. // $scope.downloadUrl = function(contentId){
  14561. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14562. // };
  14563. $scope.download = function (contentId, filename) {
  14564. // var headers=
  14565. $http({
  14566. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14567. method: 'GET',
  14568. headers: {
  14569. //'Content-type' : 'application/xls',
  14570. 'Accept': '*/*'
  14571. },
  14572. responseType: 'arraybuffer'
  14573. }).success(function (data, status, headers, config) {
  14574. var file = new Blob([data], {
  14575. type: 'application/octet-stream'
  14576. });
  14577. //trick to download store a file having its URL
  14578. var fileURL = URL.createObjectURL(file);
  14579. var a = document.createElement('a');
  14580. a.href = fileURL;
  14581. a.target = '_blank';
  14582. a.download = filename;
  14583. document.body.appendChild(a);
  14584. a.click();
  14585. }).error(function (data, status, headers, config) {
  14586. // console.log(data);
  14587. });
  14588. };
  14589. $scope.view = function (contentId) {
  14590. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14591. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  14592. // if (response.state == 200) {
  14593. // window.open(response.previewUrl);
  14594. // }
  14595. // })
  14596. };
  14597. /**
  14598. * refresh
  14599. */
  14600. $scope._refresh = function (refreshAttr) {
  14601. if (refreshAttr !== undefined) {
  14602. if (_refreshDelayPromise) {
  14603. $timeout.cancel(_refreshDelayPromise);
  14604. }
  14605. _refreshDelayPromise = $timeout(function () {
  14606. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14607. $scope.options.templateOptions.processInstanceId, {
  14608. 'idx': 0,
  14609. 'sum': 1000
  14610. }).then(function (response) {
  14611. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14612. if (myData) {
  14613. $scope.attachments = myData.data;
  14614. }
  14615. });
  14616. }, $scope.options.templateOptions.refreshDelay);
  14617. }
  14618. }
  14619. $scope._refresh({});
  14620. // $scope.attachments = $scope.model[$scope.options.key]
  14621. }]
  14622. });
  14623. //附件下载列表组件
  14624. formlyConfigProvider.setType({
  14625. name: 'ui-dropfiletable',
  14626. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  14627. defaultOptions: function (options) {
  14628. return {
  14629. templateOptions: {
  14630. refresh: function (APIService, processInstanceId, data) {
  14631. return APIService.listAttachments(processInstanceId, data);
  14632. },
  14633. downloadUri: function (APIService, contentId) {
  14634. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14635. },
  14636. view: function (APIService, contentId) {
  14637. return APIService.attachmentsPreviewUrl(contentId);
  14638. },
  14639. download: function (APIService, contentId, item) {
  14640. var item = {
  14641. 'url': APIService.download(contentId),
  14642. 'headers': headers
  14643. };
  14644. return item;
  14645. },
  14646. refreshDelay: 0
  14647. }
  14648. };
  14649. },
  14650. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  14651. var _refreshDelayPromise;
  14652. // $scope.downloadUrl = function(contentId){
  14653. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14654. // };
  14655. $scope.download = function (contentId, filename) {
  14656. // var headers=
  14657. $http({
  14658. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14659. method: 'GET',
  14660. headers: {
  14661. //'Content-type' : 'application/xls',
  14662. 'Accept': '*/*'
  14663. },
  14664. responseType: 'arraybuffer'
  14665. }).success(function (data, status, headers, config) {
  14666. var file = new Blob([data], {
  14667. type: 'application/octet-stream'
  14668. });
  14669. //trick to download store a file having its URL
  14670. var fileURL = URL.createObjectURL(file);
  14671. var a = document.createElement('a');
  14672. a.href = fileURL;
  14673. a.target = '_blank';
  14674. a.download = filename;
  14675. document.body.appendChild(a);
  14676. a.click();
  14677. }).error(function (data, status, headers, config) {
  14678. // console.log(data);
  14679. });
  14680. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  14681. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  14682. // var file = new Blob([response], {
  14683. // type : 'application/octet-stream'
  14684. // });
  14685. // // var filename = filename;
  14686. // //var file = new Blob([response], {type: 'application/pdf'});
  14687. // var fileURL = URL.createObjectURL(file);
  14688. // var a = document.createElement('a');
  14689. // a.href = fileURL;
  14690. // a.target = '_blank';
  14691. // a.download = filename ;
  14692. // document.body.appendChild(a);
  14693. // a.click();
  14694. // })
  14695. };
  14696. $scope.view = function (contentId, token, filename, type) {
  14697. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14698. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14699. // var modalInstance = $modal.open({
  14700. // backdrop: false,
  14701. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14702. // controller: function($scope, scope, $modalInstance, filename) {
  14703. // $scope.title = filename;
  14704. // $scope.imageurl = scope.imageurl;
  14705. // $scope.cancel = function() {
  14706. // $modalInstance.dismiss('cancel');
  14707. // }
  14708. // },
  14709. // resolve: {
  14710. // scope: function() {
  14711. // return $scope;
  14712. // },
  14713. // filename: function() {
  14714. // return filename;
  14715. // }
  14716. // }
  14717. // });
  14718. // event.preventDefault();
  14719. // } else {
  14720. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14721. if (response.state == 200) {
  14722. window.open(response.previewUrl);
  14723. }
  14724. })
  14725. // }
  14726. };
  14727. /**
  14728. * refresh
  14729. */
  14730. $scope._refresh = function (refreshAttr) {
  14731. if (refreshAttr !== undefined) {
  14732. if (_refreshDelayPromise) {
  14733. $timeout.cancel(_refreshDelayPromise);
  14734. }
  14735. _refreshDelayPromise = $timeout(function () {
  14736. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14737. $scope.options.templateOptions.processInstanceId, {
  14738. 'idx': 0,
  14739. 'sum': 1000
  14740. }).then(function (response) {
  14741. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14742. if (myData) {
  14743. $scope.attachments = myData.data;
  14744. }
  14745. });
  14746. }, $scope.options.templateOptions.refreshDelay);
  14747. }
  14748. }
  14749. $scope._refresh({});
  14750. // $scope.attachments = $scope.model[$scope.options.key]
  14751. }]
  14752. });
  14753. //微信附件下载列表组件
  14754. formlyConfigProvider.setType({
  14755. name: 'ui-dropfilewechat',
  14756. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  14757. defaultOptions: function (options) {
  14758. return {
  14759. templateOptions: {
  14760. // refresh: function(APIService, processInstanceId, data) {
  14761. // return APIService.listAttachments(processInstanceId, data);
  14762. // },
  14763. // downloadUri: function(APIService, contentId) {
  14764. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  14765. // },
  14766. view: function (APIService, contentId) {
  14767. // return APIService.attachmentsPreviewUrl(contentId);
  14768. return APIService.attachmentsPreviewUrl(contentId);
  14769. },
  14770. download: function (APIService, contentId, item) {
  14771. var item = {
  14772. 'url': APIService.download(contentId),
  14773. 'headers': headers
  14774. };
  14775. return item;
  14776. },
  14777. // download: function(APIService, contentId, item) {
  14778. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  14779. // return item;
  14780. // },
  14781. refreshDelay: 0
  14782. }
  14783. };
  14784. },
  14785. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  14786. var _refreshDelayPromise;
  14787. // $scope.downloadUrl = function(contentId){
  14788. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14789. // };
  14790. $scope.attachments = {};
  14791. $scope.previewUrl = '';
  14792. $scope.download = function (token, filename) {
  14793. // var headers=
  14794. console.log($scope);
  14795. $http({
  14796. url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
  14797. method: 'GET',
  14798. headers: {
  14799. //'Content-type' : 'application/xls',
  14800. 'Accept': '*/*'
  14801. },
  14802. responseType: 'arraybuffer'
  14803. }).success(function (data, status, headers, config) {
  14804. var file = new Blob([data], {
  14805. type: 'application/octet-stream'
  14806. });
  14807. //trick to download store a file having its URL
  14808. var fileURL = URL.createObjectURL(file);
  14809. var a = document.createElement('a');
  14810. a.href = fileURL;
  14811. a.target = '_blank';
  14812. a.download = filename;
  14813. document.body.appendChild(a);
  14814. a.click();
  14815. }).error(function (data, status, headers, config) {
  14816. // console.log(data);
  14817. });
  14818. };
  14819. $scope.view = function (contentId, token, filename, type, previewUrl) {
  14820. // if (type) {
  14821. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  14822. // var modalInstance = $modal.open({
  14823. // backdrop: false,
  14824. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14825. // controller: function($scope, scope, $modalInstance, filename) {
  14826. // $scope.title = filename;
  14827. // $scope.imageurl = scope.imageurl;
  14828. // $scope.cancel = function() {
  14829. // $modalInstance.dismiss('cancel');
  14830. // }
  14831. // },
  14832. // resolve: {
  14833. // scope: function() {
  14834. // return $scope;
  14835. // },
  14836. // filename: function() {
  14837. // return filename;
  14838. // }
  14839. // }
  14840. // });
  14841. // event.preventDefault();
  14842. // } else {
  14843. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  14844. // if (response.state == 200) {
  14845. // window.open(response.previewUrl);
  14846. // }
  14847. // })
  14848. window.open(previewUrl);
  14849. // }
  14850. };
  14851. /**
  14852. * refresh
  14853. */
  14854. $scope._refresh = function (refreshAttr) {
  14855. if (refreshAttr !== undefined) {
  14856. if (_refreshDelayPromise) {
  14857. $timeout.cancel(_refreshDelayPromise);
  14858. }
  14859. _refreshDelayPromise = $timeout(function () {
  14860. // console.log(JSON.parse($stateParams.model))
  14861. var incidentChart = {};
  14862. if ($stateParams.model) {
  14863. incidentChart = JSON.parse($stateParams.model).model;
  14864. }
  14865. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14866. $scope.model).then(function (response) {
  14867. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14868. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  14869. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14870. if (myData) {
  14871. $scope.attachments = myData.data;
  14872. }
  14873. });
  14874. }, $scope.options.templateOptions.refreshDelay);
  14875. }
  14876. }
  14877. $scope._refresh({});
  14878. // $scope.attachments = $scope.model[$scope.options.key]
  14879. }]
  14880. });
  14881. formlyConfigProvider.setType({
  14882. name: 'ui-paralleltask',
  14883. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  14884. defaultOptions: function (options) {
  14885. return {
  14886. templateOptions: {
  14887. refresh: function (APIService, processInstanceId, data) {
  14888. //return APIService.listAttachments(processInstanceId, data);
  14889. },
  14890. refreshDelay: 0
  14891. }
  14892. };
  14893. },
  14894. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  14895. });
  14896. //repeatSection
  14897. //
  14898. formlyConfigProvider.setType({
  14899. name: 'ui-repeatSection',
  14900. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  14901. defaultOptions: function (options) {
  14902. return {
  14903. templateOptions: {
  14904. unique: 1,
  14905. initDisplay: false
  14906. }
  14907. };
  14908. },
  14909. controller: function ($scope) {
  14910. //$scope.options.templateOptions.unique;
  14911. $scope.formOptions = {
  14912. formState: $scope.formState
  14913. };
  14914. $scope.addNew = addNew;
  14915. $scope.copyFields = copyFields;
  14916. function copyFields(fields) {
  14917. fields = angular.copy(fields);
  14918. addRandomIds(fields);
  14919. return fields;
  14920. }
  14921. function addNew() {
  14922. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  14923. var repeatsection = $scope.model[$scope.options.key];
  14924. var lastSection = repeatsection[repeatsection.length - 1];
  14925. var newsection = {};
  14926. repeatsection.push(newsection);
  14927. }
  14928. function addRandomIds(fields) {
  14929. $scope.options.templateOptions.unique++;
  14930. angular.forEach(fields, function (field, index) {
  14931. if (field.fieldGroup) {
  14932. addRandomIds(field.fieldGroup);
  14933. return; // fieldGroups don't need an ID
  14934. }
  14935. if (field.templateOptions && field.templateOptions.fields) {
  14936. addRandomIds(field.templateOptions.fields);
  14937. }
  14938. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  14939. });
  14940. }
  14941. function getRandomInt(min, max) {
  14942. return Math.floor(Math.random() * (max - min)) + min;
  14943. }
  14944. if ($scope.options.templateOptions.initDisplay) {
  14945. addNew();
  14946. }
  14947. }
  14948. });
  14949. //时间轴任务列表组件
  14950. //cmdb控件
  14951. formlyConfigProvider.setType({
  14952. name: 'ui-cmdb',
  14953. extends: 'input',
  14954. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  14955. defaultOptions: function (options) {
  14956. return {
  14957. templateOptions: {
  14958. onClick: function (size, options, modal, event, model) {
  14959. var modalInstance = modal.open({
  14960. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  14961. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  14962. var width = $scope.width = 600;
  14963. var height = $scope.height = 400;
  14964. var tree;
  14965. var d3 = window.d3;
  14966. $scope.my_tree_handler = function (branch) {
  14967. //var _ref;
  14968. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  14969. APIService.query({
  14970. 'sign': classify
  14971. }).then(function (data) {
  14972. var myData = Restangular.stripRestangular(data);
  14973. // console.log(myData.data.node);
  14974. if (myData.data && myData.status == 200) {
  14975. var ret = myData.data;
  14976. redrawSvg(myData);
  14977. }
  14978. });
  14979. };
  14980. $scope.my_data = [];
  14981. function convertListToTree(data, treeMap) {
  14982. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  14983. var root = null; //Initially set our loop to null
  14984. var parentNode = null;
  14985. //loop over data
  14986. for (var i = 0; i < data.length; i++) {
  14987. var datum = data[i];
  14988. //each node will have children, so let's give it a "children" poperty
  14989. datum.children = [];
  14990. //add an entry for this node to the map so that any future children can
  14991. //lookup the parent
  14992. idToNodeMap[datum.id] = datum;
  14993. //Does this node have a parent?
  14994. if (typeof datum.parent === "undefined" || datum.parent == null) {
  14995. //Doesn't look like it, so this node is the root of the tree
  14996. root = datum;
  14997. treeMap[datum.id] = root;
  14998. } else {
  14999. //This node has a parent, so let's look it up using the id
  15000. parentNode = idToNodeMap[datum.parent.id];
  15001. //We don't need this property, so let's delete it.
  15002. delete datum.parent;
  15003. //Let's add the current node as a child of the parent node.
  15004. parentNode.children.push(datum);
  15005. }
  15006. }
  15007. return root;
  15008. }
  15009. function convertParentToChildList(data) {
  15010. var treeMap = {};
  15011. var list = [];
  15012. convertListToTree(data, treeMap);
  15013. angular.forEach(treeMap, function (item) {
  15014. list.push(item);
  15015. });
  15016. return list;
  15017. }
  15018. $scope.my_tree = tree = {};
  15019. $scope.try_async_load = function () {
  15020. $scope.my_data = [];
  15021. $scope.select_treedata = [];
  15022. $scope.doing_async = true;
  15023. ConfigDataService.fetchDataList('ciclassify', {
  15024. 'idx': 0,
  15025. 'sum': 100
  15026. }).then(function (result) {
  15027. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15028. $scope.doing_async = false;
  15029. });
  15030. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  15031. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15032. // $scope.doing_async = false;
  15033. // });
  15034. };
  15035. $scope.select_treedata = [];
  15036. $scope.propTypeOptions = [];
  15037. $scope.try_async_load();
  15038. $scope.onFilterCallback = function (item) {
  15039. //console.log(item);
  15040. if (angular.isDefined(item.children) && item.children.length >= 1) {
  15041. //not valid
  15042. } else {
  15043. var tempclassify = item.prefix.toLowerCase() + item.sign;
  15044. $scope.cifilter_classic = tempclassify;
  15045. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  15046. var myData = Restangular.stripRestangular(data);
  15047. $scope.propTypeOptions = myData;
  15048. });
  15049. }
  15050. }
  15051. $scope.onPropTypeChange = function (form) {
  15052. $scope.propOptions = form.fields;
  15053. }
  15054. $scope.onPropChange = function (prop) {
  15055. $scope.cifilter_prop = prop;
  15056. }
  15057. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  15058. //if(searchKey!=null&&searchKey.length>1){
  15059. var searchData = {};
  15060. if (angular.isUndefined(propObj)) {
  15061. propObj = $scope.cifilter_prop;
  15062. }
  15063. if (angular.isUndefined(ciclassify)) {
  15064. ciclassify = $scope.cifilter_classic;
  15065. }
  15066. searchData['sign'] = ciclassify;
  15067. if (angular.isDefined(propObj)) {
  15068. searchData[propObj.key] = searchKey;
  15069. }
  15070. APIService.query(searchData).then(function (response) {
  15071. var data = Restangular.stripRestangular(response);
  15072. //此处不清空nodes
  15073. var node = data.data.node;
  15074. var tempNode = [];
  15075. //nodes 或者links 要去重
  15076. for (var i = 0; i < node.length; i++) {
  15077. var tmp = 0;
  15078. for (var j = 0; j < nodes.length; j++) {
  15079. if (node[i].uuid == nodes[j].uuid) {
  15080. tmp++;
  15081. break;
  15082. }
  15083. }
  15084. if (tmp == 0) {
  15085. tempNode.push(node[i]);
  15086. }
  15087. }
  15088. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15089. nodes.push(tempNode[i]);
  15090. }
  15091. restart();
  15092. })
  15093. }
  15094. $scope.refresh = function () {
  15095. nodes.length = 0;
  15096. links.length = 0;
  15097. restart();
  15098. }
  15099. $scope.traversal = function () {
  15100. if ($scope.selected_node == null) {
  15101. SweetAlert.swal({
  15102. title: "错误的操作!",
  15103. text: "没有配置项被选中!",
  15104. type: "error"
  15105. });
  15106. } else {
  15107. var uuid = $scope.selected_node.uuid;
  15108. APIService.traversal(uuid).then(function (response) {
  15109. var d = response.data;
  15110. var node = d.node;
  15111. var link = d.edge;
  15112. var tempNode = [];
  15113. var tempLink = [];
  15114. //nodes 或者links 要去重
  15115. for (var i = 0; i < node.length; i++) {
  15116. var tmp = 0;
  15117. for (var j = 0; j < nodes.length; j++) {
  15118. if (node[i].id == nodes[j].id) {
  15119. tmp++;
  15120. break;
  15121. }
  15122. }
  15123. if (tmp == 0) {
  15124. tempNode.push(node[i]);
  15125. }
  15126. }
  15127. for (var i = 0; i < link.length; i++) {
  15128. var tmp = 0;
  15129. for (var j = 0; j < links.length; j++) {
  15130. if (link[i].id == links[j].id) {
  15131. tmp++;
  15132. break;
  15133. }
  15134. }
  15135. if (tmp == 0) {
  15136. tempLink.push(link[i]);
  15137. }
  15138. }
  15139. //数据写入页面
  15140. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15141. nodes.push(tempNode[i]);
  15142. }
  15143. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15144. links.push(tempLink[i]);
  15145. }
  15146. //links转换
  15147. for (var i = 0; i < links.length; i++) {
  15148. for (var j = 0; j < nodes.length; j++) {
  15149. if (links[i].source == nodes[j].id) {
  15150. links[i].source = nodes[j];
  15151. }
  15152. if (links[i].target == nodes[j].id) {
  15153. links[i].target = nodes[j];
  15154. }
  15155. }
  15156. }
  15157. restart();
  15158. })
  15159. }
  15160. }
  15161. var svg;
  15162. var force;
  15163. var drag_line, path, circle;
  15164. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  15165. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15166. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15167. var nodes = [],
  15168. links = [];
  15169. var treeNodes = [];
  15170. //读取labels (node)
  15171. var labels = [];
  15172. function redrawSvg(json) {
  15173. nodes.length = 0; //先清空
  15174. links.length = 0;
  15175. var data = json.data;
  15176. for (var i = 0; i < data.node.length; i++) {
  15177. nodes.push(data.node[i]);
  15178. }
  15179. restart();
  15180. }
  15181. //读取status (节点 连线)
  15182. var statuses = [];
  15183. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  15184. // if (result && result.status == 200) {
  15185. // d3.select('#nodeStatus').selectAll('option')
  15186. // .data(statuses).enter()
  15187. // .append('option')
  15188. // .attr('value', function(d) { return d.code; })
  15189. // .html(function(d) { return d.desc; });
  15190. // } else {
  15191. // SweetAlert.swal({
  15192. // title: "提示!",
  15193. // text: "服务器请求异常!",
  15194. // type: "error"
  15195. // });
  15196. // }
  15197. // });
  15198. api_wechatfile.getDictionary({
  15199. 'key': 'cmdb_status',
  15200. 'type': 'list'
  15201. }).then(function (result) {
  15202. if (result) {
  15203. d3.select('#nodeStatus').selectAll('option')
  15204. .data(statuses).enter()
  15205. .append('option')
  15206. .attr('value', function (d) {
  15207. return d.code;
  15208. })
  15209. .html(function (d) {
  15210. return d.desc;
  15211. });
  15212. } else {
  15213. SweetAlert.swal({
  15214. title: "提示!",
  15215. text: "服务器请求异常!",
  15216. type: "error"
  15217. });
  15218. }
  15219. });
  15220. //查询relationship_type表 name 为表里的type,label为显示值
  15221. var linkType = [];
  15222. function fetchEdgeTypes() {
  15223. ConfigDataService.fetchDataList('ciedgetype', {
  15224. 'idx': 0,
  15225. 'sum': 100
  15226. }).then(function (response) {
  15227. if (response) {
  15228. if (response['list']) {
  15229. linkType = response['list'];
  15230. // d3.select('#linkName').selectAll('option')
  15231. // .data(linkType).enter()
  15232. // .append('option')
  15233. // .attr('value',function(d){return d.type;})
  15234. // .html(function(d){ return d.label;});
  15235. } else {
  15236. SweetAlert.swal({
  15237. title: "提示!",
  15238. text: "服务器请求异常!",
  15239. type: "error"
  15240. });
  15241. }
  15242. } else {
  15243. SweetAlert.swal({
  15244. title: "提示!",
  15245. text: "服务器请求异常!",
  15246. type: "error"
  15247. });
  15248. }
  15249. })
  15250. }
  15251. // fetchEdgeTypes();
  15252. /*
  15253. // init D3 force layout
  15254. var force = d3.layout.force()
  15255. .nodes(nodes)
  15256. .links(links)
  15257. .size([width, height])
  15258. .gravity(.05)
  15259. .linkDistance(150)
  15260. .linkStrength(2)
  15261. .charge(-500)
  15262. .on('tick', tick);
  15263. // define arrow markers for graph links
  15264. svg.append('svg:defs').append('svg:marker')
  15265. .attr('id', 'end-arrow')
  15266. .attr('viewBox', '0 -5 10 10')
  15267. .attr('refX', 6)
  15268. .attr('markerWidth', 3)
  15269. .attr('markerHeight', 3)
  15270. .attr('orient', 'auto')
  15271. .append('svg:path')
  15272. .attr('d', 'M0,-5L10,0L0,5')
  15273. .attr('fill', '#000');
  15274. svg.append('svg:defs').append('svg:marker')
  15275. .attr('id', 'start-arrow')
  15276. .attr('viewBox', '0 -5 10 10')
  15277. .attr('refX', 4)
  15278. .attr('markerWidth', 3)
  15279. .attr('markerHeight', 3)
  15280. .attr('orient', 'auto')
  15281. .append('svg:path')
  15282. .attr('d', 'M10,-5L0,0L10,5')
  15283. .attr('fill', '#000');
  15284. // line displayed when dragging new nodes
  15285. var drag_line = svg.append('svg:path')
  15286. .attr('class', 'link dragline hidden')
  15287. .attr('d', 'M0,0L0,0');
  15288. // handles to link and node element groups
  15289. //(1)var path = svg.append('svg:g').selectAll('g')
  15290. var path = svg.append('svg:g').selectAll('g'),
  15291. circle = svg.append('svg:g').selectAll('g');
  15292. */
  15293. // mouse event vars
  15294. var selected_node = null,
  15295. selected_link = null,
  15296. mousedown_link = null,
  15297. mousedown_node = null,
  15298. mouseup_node = null;
  15299. function resetMouseVars() {
  15300. mousedown_node = null;
  15301. mouseup_node = null;
  15302. mousedown_link = null;
  15303. }
  15304. // update force layout (called automatically each iteration)
  15305. function tick() {
  15306. // draw directed edges with proper padding from node centers
  15307. path.selectAll('path').attr('d', function (d) {
  15308. var deltaX = d.target.x - d.source.x,
  15309. deltaY = d.target.y - d.source.y,
  15310. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  15311. normX = deltaX / dist,
  15312. normY = deltaY / dist,
  15313. sourcePadding = d.left ? 27 : 22,
  15314. targetPadding = d.right ? 27 : 22,
  15315. sourceX = d.source.x + (sourcePadding * normX),
  15316. sourceY = d.source.y + (sourcePadding * normY),
  15317. targetX = d.target.x - (targetPadding * normX),
  15318. targetY = d.target.y - (targetPadding * normY);
  15319. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  15320. });
  15321. circle.attr('transform', function (d) {
  15322. return 'translate(' + d.x + ',' + d.y + ')';
  15323. });
  15324. }
  15325. // update graph (called when needed)
  15326. function restart() {
  15327. //绑定link 数据
  15328. path.datum(links);
  15329. // path (link) group
  15330. path = path.data(links, function (d) {
  15331. return d.id;
  15332. });
  15333. var p = path.enter().append('svg:g');
  15334. //update existing links
  15335. path.selectAll('path').classed('selected', function (d) {
  15336. return d === selected_link;
  15337. })
  15338. .style('marker-start', function (d) {
  15339. return d.left ? 'url(#start-arrow)' : '';
  15340. })
  15341. .style('marker-end', function (d) {
  15342. return d.right ? 'url(#end-arrow)' : '';
  15343. });
  15344. // add new links
  15345. p.append('svg:path')
  15346. .attr('class', 'link')
  15347. .attr('id', function (d) {
  15348. return "path_" + d.id;
  15349. })
  15350. // .attr('startOffset', '0%')
  15351. .classed('selected', function (d) {
  15352. return d === selected_link;
  15353. })
  15354. .style('marker-start', function (d) {
  15355. return d.left ? 'url(#start-arrow)' : '';
  15356. })
  15357. .style('marker-end', function (d) {
  15358. return d.right ? 'url(#end-arrow)' : '';
  15359. })
  15360. .on('mousedown', function (d) {
  15361. if (d3.event.ctrlKey) return;
  15362. //去除没有提交的连线
  15363. for (var i = 0; i < links.length; i++) {
  15364. if (links[i].id == -1 && d.id != -1) {
  15365. links.splice(i, 1);
  15366. }
  15367. }
  15368. // select link
  15369. mousedown_link = d;
  15370. if (mousedown_link === selected_link) {
  15371. selected_link = $scope.selected_link = null;
  15372. selected_node = $scope.selected_node = null;
  15373. // d3.select("#linkDetail").attr('style','display:none');
  15374. //hideLinkForm(true);//return ;
  15375. } else {
  15376. selected_link = $scope.selected_link = mousedown_link;
  15377. selected_node = $scope.selected_node = null;
  15378. }
  15379. selected_node = $scope.selected_node = null;
  15380. restart();
  15381. });
  15382. p.append('svg:text')
  15383. .attr('x', 30)
  15384. .attr('y', 20)
  15385. .attr('class', 'fontM')
  15386. .append('textPath')
  15387. .attr('xlink:xlink:href', function (d, i) {
  15388. return "#path_" + d.id;
  15389. })
  15390. .html(function (d) {
  15391. for (var i = 0; i < linkType.length; i++) {
  15392. if (linkType[i].type == d.name) {
  15393. return linkType[i].label;
  15394. }
  15395. }
  15396. });
  15397. // remove old links
  15398. path.exit().remove();
  15399. // circle (node) group
  15400. // NB: the function arg is crucial here! nodes are known by id, not by index!
  15401. circle.datum(nodes);
  15402. circle = circle.data(nodes, function (d) {
  15403. return d.id;
  15404. });
  15405. // update existing nodes (reflexive & selected visual states)
  15406. circle.selectAll('circle')
  15407. .style('fill', function (d) {
  15408. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15409. })
  15410. .style('fill-opacity', 0.75) // add by xi
  15411. .classed('reflexive', function (d) {
  15412. return d.reflexive;
  15413. });
  15414. // add new nodes
  15415. var g = circle.enter().append('svg:g');
  15416. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  15417. //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');
  15418. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  15419. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  15420. }).style('stroke', function (d) {
  15421. return d3.rgb(colors(d.label)).darker().toString();
  15422. }).style('stroke-width', '2');
  15423. g.append('svg:circle')
  15424. .attr('class', 'node')
  15425. .attr('r', 18)
  15426. .style('fill', function (d) {
  15427. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15428. })
  15429. .style('stroke', function (d) {
  15430. return d3.rgb(colors(d.label)).darker().toString();
  15431. })
  15432. .style('fill-opacity', 0.25) //add by xj
  15433. .style('stroke-opacity', 0.5) //add by xj
  15434. .classed('reflexive', function (d) {
  15435. return d.reflexive;
  15436. });
  15437. g.on('mouseover', function (d) {
  15438. //if(!mousedown_node || d === mousedown_node) return;
  15439. // enlarge target node
  15440. //d3.select(this).attr('transform', 'scale(1.1)');
  15441. })
  15442. .on('mouseout', function (d) {
  15443. //if(!mousedown_node || d === mousedown_node) return;
  15444. // unenlarge target node
  15445. //d3.select(this).attr('transform', '');
  15446. })
  15447. .on('mousedown', function (d) {
  15448. if (d3.event.ctrlKey) return;
  15449. //hideLinkForm(true);
  15450. //去除没有提交的连线
  15451. for (var i = 0; i < links.length; i++) {
  15452. if (links[i].id == -1) {
  15453. links.splice(i, 1);
  15454. }
  15455. }
  15456. // select node
  15457. mousedown_node = d;
  15458. if (mousedown_node === selected_node) {
  15459. selected_node = $scope.selected_node = null;
  15460. } else {
  15461. selected_node = $scope.selected_node = mousedown_node;
  15462. selected_link = $scope.selected_link = null;
  15463. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  15464. APIService.findRefById(selected_node.id).then(function (result) {
  15465. var d = result.data;
  15466. var node = d.node;
  15467. var link = d.edge;
  15468. var tempNode = [];
  15469. var tempLink = [];
  15470. //nodes 或者links 要去重
  15471. for (var i = 0; i < node.length; i++) {
  15472. var tmp = 0;
  15473. for (var j = 0; j < nodes.length; j++) {
  15474. if (node[i].id == nodes[j].id) {
  15475. tmp++;
  15476. break;
  15477. }
  15478. }
  15479. if (tmp == 0) {
  15480. tempNode.push(node[i]);
  15481. }
  15482. }
  15483. for (var i = 0; i < link.length; i++) {
  15484. var tmp = 0;
  15485. for (var j = 0; j < links.length; j++) {
  15486. if (link[i].id == links[j].id) {
  15487. tmp++;
  15488. break;
  15489. }
  15490. }
  15491. if (tmp == 0) {
  15492. tempLink.push(link[i]);
  15493. }
  15494. }
  15495. //数据写入页面
  15496. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15497. nodes.push(tempNode[i]);
  15498. }
  15499. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15500. links.push(tempLink[i]);
  15501. }
  15502. //links转换
  15503. for (var i = 0; i < links.length; i++) {
  15504. for (var j = 0; j < nodes.length; j++) {
  15505. if (links[i].source == nodes[j].id) {
  15506. links[i].source = nodes[j];
  15507. }
  15508. if (links[i].target == nodes[j].id) {
  15509. links[i].target = nodes[j];
  15510. }
  15511. }
  15512. }
  15513. restart();
  15514. });
  15515. }
  15516. // reposition drag line
  15517. drag_line
  15518. .style('marker-end', 'url(#end-arrow)')
  15519. .classed('hidden', false)
  15520. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  15521. restart();
  15522. })
  15523. .on('mouseup', function (d) {
  15524. if (!mousedown_node) return;
  15525. });
  15526. // show node name
  15527. g.append('svg:text')
  15528. .attr('x', 0)
  15529. .attr('y', 34)
  15530. .attr('class', 'id')
  15531. .text(function (d) {
  15532. return d.name;
  15533. }); //TODO 改为 d.name
  15534. //设置图片
  15535. g.append('svg:foreignObject')
  15536. .attr("width", 32)
  15537. .attr("height", 32)
  15538. .attr('x', "-16px")
  15539. .attr('y', "-11px")
  15540. .html(function (d) {
  15541. for (var i = 0; i < labels.length; i++) {
  15542. if (d.label == labels[i].sign) {
  15543. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  15544. }
  15545. }
  15546. });
  15547. // remove old nodes
  15548. circle.exit().remove();
  15549. // set the graph in motion
  15550. force.start();
  15551. }
  15552. function mousedown() {
  15553. // prevent I-bar on drag
  15554. //d3.event.preventDefault();
  15555. // because :active only works in WebKit?
  15556. svg.classed('active', true);
  15557. if (mousedown_node) {
  15558. viewNode(mousedown_node);
  15559. }
  15560. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  15561. restart();
  15562. }
  15563. function mousemove() {
  15564. if (!mousedown_node) return;
  15565. // update drag line
  15566. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  15567. //restart();
  15568. }
  15569. function mouseup() {
  15570. if (mousedown_node) {
  15571. // hide drag line
  15572. drag_line
  15573. .classed('hidden', true)
  15574. .style('marker-end', '');
  15575. }
  15576. // because :active only works in WebKit?
  15577. svg.classed('active', false);
  15578. // clear mouse event vars
  15579. resetMouseVars();
  15580. }
  15581. function spliceLinksForNode(node) {
  15582. var toSplice = links.filter(function (l) {
  15583. return (l.source === node || l.target === node);
  15584. });
  15585. toSplice.map(function (l) {
  15586. links.splice(links.indexOf(l), 1);
  15587. });
  15588. }
  15589. // only respond once per keydown
  15590. var lastKeyDown = -1;
  15591. function keydown() {
  15592. //d3.event.preventDefault();
  15593. if (lastKeyDown !== -1) return;
  15594. lastKeyDown = d3.event.keyCode;
  15595. // ctrl
  15596. if (d3.event.keyCode === 17) {
  15597. circle.call(force.drag);
  15598. svg.classed('ctrl', true);
  15599. }
  15600. if (!selected_node && !selected_link) return;
  15601. switch (d3.event.keyCode) {
  15602. case 8: // backspace
  15603. case 66: // B
  15604. if (selected_link) {
  15605. // set link direction to both left and right
  15606. selected_link.left = true;
  15607. selected_link.right = true;
  15608. }
  15609. restart();
  15610. break;
  15611. case 76: // L
  15612. if (selected_link) {
  15613. // set link direction to left only
  15614. selected_link.left = true;
  15615. selected_link.right = false;
  15616. }
  15617. restart();
  15618. break;
  15619. case 82: // R
  15620. if (selected_node) {
  15621. // toggle node reflexivity
  15622. selected_node.reflexive = !selected_node.reflexive;
  15623. } else if (selected_link) {
  15624. // set link direction to right only
  15625. selected_link.left = false;
  15626. selected_link.right = true;
  15627. }
  15628. restart();
  15629. break;
  15630. }
  15631. }
  15632. function keyup() {
  15633. lastKeyDown = -1;
  15634. // ctrl
  15635. if (d3.event.keyCode === 17) {
  15636. circle
  15637. .on('mousedown.drag', null)
  15638. .on('touchstart.drag', null);
  15639. svg.classed('ctrl', false);
  15640. }
  15641. }
  15642. function viewNode(node) {
  15643. // console.log(svg.attr('left'));
  15644. //var el = angular.element('div.modal-dialog')[0];
  15645. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  15646. if (!$scope.selected_node.props.state) {
  15647. $scope.selected_node.props.state = "空"
  15648. } else if ($scope.selected_node.props.state) {
  15649. if ($scope.selected_node.props.state == "1") {
  15650. $scope.selected_node.props.state = "未审核"
  15651. } else if ($scope.selected_node.props.state == "2") {
  15652. $scope.selected_node.props.state = "已审核"
  15653. } else if ($scope.selected_node.props.state == "3") {
  15654. $scope.selected_node.props.state = "不匹配"
  15655. } else if ($scope.selected_node.props.state == "4") {
  15656. $scope.selected_node.props.state = "丢失"
  15657. }
  15658. };
  15659. if (!$scope.selected_node.name) {
  15660. $scope.selected_node.name = "空"
  15661. }
  15662. if (!$scope.selected_node.status) {
  15663. $scope.selected_node.statu = "空"
  15664. }
  15665. if (!$scope.selected_node.props.useradmin) {
  15666. $scope.selected_node.props.useradmin = "空"
  15667. }
  15668. Toaster.pop({
  15669. // type: 'info',
  15670. // title: title,
  15671. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  15672. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  15673. '<p>状态:' + $scope.selected_node.status + '</p>' +
  15674. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  15675. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  15676. bodyOutputType: 'trustedHtml',
  15677. timeout: 3000
  15678. })
  15679. }
  15680. //GT 颜色与数值对照表
  15681. function colors(sign) {
  15682. //num=num>20?num%20:parseInt(num);
  15683. for (var i = 0; i < labels.length; i++) {
  15684. var entity = labels[i];
  15685. if (sign == entity.sign) {
  15686. return entity.color;
  15687. }
  15688. if (i == labels.length - 1 && sign != entity.sign) {
  15689. return '#ffeeee';
  15690. }
  15691. }
  15692. }
  15693. $scope.init = function () {
  15694. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15695. // init D3 force layout
  15696. force = d3.layout.force()
  15697. .nodes(nodes)
  15698. .links(links)
  15699. .size([width, height])
  15700. .gravity(.05)
  15701. .linkDistance(150)
  15702. .linkStrength(2)
  15703. .charge(-500)
  15704. .on('tick', tick);
  15705. // define arrow markers for graph links
  15706. svg.append('svg:defs').append('svg:marker')
  15707. .attr('id', 'end-arrow')
  15708. .attr('viewBox', '0 -5 10 10')
  15709. .attr('refX', 6)
  15710. .attr('markerWidth', 3)
  15711. .attr('markerHeight', 3)
  15712. .attr('orient', 'auto')
  15713. .append('svg:path')
  15714. .attr('d', 'M0,-5L10,0L0,5')
  15715. .attr('fill', '#000');
  15716. svg.append('svg:defs').append('svg:marker')
  15717. .attr('id', 'start-arrow')
  15718. .attr('viewBox', '0 -5 10 10')
  15719. .attr('refX', 4)
  15720. .attr('markerWidth', 3)
  15721. .attr('markerHeight', 3)
  15722. .attr('orient', 'auto')
  15723. .append('svg:path')
  15724. .attr('d', 'M10,-5L0,0L10,5')
  15725. .attr('fill', '#000');
  15726. // line displayed when dragging new nodes
  15727. drag_line = svg.append('svg:path')
  15728. .attr('class', 'link dragline hidden')
  15729. .attr('d', 'M0,0L0,0');
  15730. // handles to link and node element groups
  15731. //(1)var path = svg.append('svg:g').selectAll('g')
  15732. path = svg.append('svg:g').selectAll('g');
  15733. circle = svg.append('svg:g').selectAll('g');
  15734. svg.on('mousedown', mousedown)
  15735. .on('mousemove', mousemove)
  15736. .on('mouseup', mouseup);
  15737. d3.select(window)
  15738. .on('keydown', keydown)
  15739. .on('keyup', keyup);
  15740. }
  15741. var CI = {};
  15742. window.CI = CI;
  15743. $scope.ok = function () {
  15744. $modalInstance.close($scope.selected_node);
  15745. };
  15746. $scope.cancel = function () {
  15747. $modalInstance.dismiss('cancel');
  15748. };
  15749. },
  15750. size: size,
  15751. resolve: {
  15752. title: function () {
  15753. return options.templateOptions.title;
  15754. },
  15755. Restangular: function () {
  15756. return options.templateOptions.Restangular;
  15757. },
  15758. APIService: function () {
  15759. return options.templateOptions.ApiService;
  15760. },
  15761. ConfigDataService: function () {
  15762. return options.templateOptions.ConfigDataService;
  15763. },
  15764. ConfigFormService: function () {
  15765. return options.templateOptions.ConfigFormService;
  15766. },
  15767. SweetAlert: function () {
  15768. return options.templateOptions.Alert;
  15769. },
  15770. Toaster: function () {
  15771. return options.templateOptions.toaster;
  15772. }
  15773. }
  15774. });
  15775. modalInstance.result.then(function (selectedItem) {
  15776. options.value(selectedItem.name + '-' + selectedItem.uuid);
  15777. }, function () {
  15778. //console.log('Modal dismissed at: ' + new Date());
  15779. });
  15780. }
  15781. }
  15782. }
  15783. },
  15784. controller: ['$scope', function ($scope) {
  15785. // setTimeout(function(){
  15786. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  15787. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  15788. // if(modelData.status==200){
  15789. // $scope.model[$scope.options.key] = modelData.data;
  15790. // $scope.options.initialValue = $scope.model[$scope.options.key];
  15791. // }
  15792. // });
  15793. // },1000);
  15794. }]
  15795. });
  15796. });
  15797. appFormly.run(function (formlyConfig, $parse) {
  15798. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  15799. var removeOnHideTransformer = function (fields, model) {
  15800. return fields.map(function (field) {
  15801. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  15802. addFieldRemoveOnHideWatcher(field);
  15803. }
  15804. if (field.type == "ui-title") {
  15805. addFieldRemoveOnHideWatcher(field);
  15806. }
  15807. return field;
  15808. });
  15809. };
  15810. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  15811. function addFieldRemoveOnHideWatcher(field) {
  15812. var watcher = getWatcher();
  15813. if (field.watcher) {
  15814. if (!angular.isArray(field.watcher)) {
  15815. field.watcher = [field.watcher];
  15816. }
  15817. field.watcher.push(watcher);
  15818. } else {
  15819. field.watcher = watcher;
  15820. }
  15821. }
  15822. function getWatcher() {
  15823. return {
  15824. expression: function (field) {
  15825. return field.hide;
  15826. },
  15827. listener: function (field, newHide, oldHide, scope) {
  15828. if (field.hide) {
  15829. if (field.templateOptions.pkey) {
  15830. if (field.key == 'transferuser') {
  15831. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  15832. }
  15833. } else {
  15834. $parse(field.key).assign(scope.model, undefined);
  15835. }
  15836. }
  15837. if (field.type == "ui-title") {
  15838. $parse(field.key).assign(scope.model, undefined);
  15839. }
  15840. }
  15841. };
  15842. }
  15843. });
  15844. appFormly.controller('CustomformCtrl', ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'SweetAlert', 'FileUploader', 'i18nService', 'Restangular', 'UserRestangular', 'BpmRestangular', 'WechatRestangular', 'api_configure_form', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_statistic', 'up_down_file', 'fileReader',
  15845. function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, SweetAlert, FileUploader, i18nService, Restangular, UserRestangular, BpmRestangular, WechatRestangular, api_configure_form, api_bpm_domain, api_bpm_data, api_user_data, api_statistic, up_down_file, fileReader) {
  15846. //console.log($parse('Restangular')($scope));
  15847. //console.log($injector.get('Restangular'));
  15848. //console.log($stateParams);
  15849. //保存报修主体
  15850. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15851. $scope.imgUrlList = [];
  15852. $scope.uploadimg_del = function () {
  15853. console.log(123)
  15854. };
  15855. var vm = this;
  15856. vm.options = {};
  15857. vm.exampleTitle = ['expressionProperties', 'model property'];
  15858. vm.fields = [];
  15859. vm.model = {};
  15860. $scope.langs = i18nService.getAllLangs();
  15861. $scope.lang = 'zh-cn';
  15862. i18nService.setCurrentLang($scope.lang);
  15863. //alert($rootScope.user.id,null,2);
  15864. vm.model["loginUser"] = $rootScope.user;
  15865. var loginUser = $rootScope.user;
  15866. // console.log(vm);
  15867. var that = $injector;
  15868. var parse = $parse;
  15869. var formKey = "";
  15870. var pdKey = "";
  15871. var modelWatch = "";
  15872. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  15873. modelWatch = JSON.parse($stateParams.model);
  15874. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  15875. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  15876. console.log(modelWatch,$rootScope)
  15877. // if(modelWatch.model.incident){
  15878. // if(modelWatch.model.incident.place){
  15879. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  15880. // }else{
  15881. // $rootScope.selecthouseNumber = undefined;
  15882. // }
  15883. // }
  15884. }
  15885. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  15886. pdKey = $state.current.pdKey;
  15887. } else if ($stateParams.pdKey) {
  15888. pdKey = $stateParams.pdKey;
  15889. }
  15890. // console.log("pdKey::" + JSON.stringify($state.current.title));
  15891. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  15892. formKey = $stateParams.formKey;
  15893. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  15894. }
  15895. if (angular.isDefined($stateParams.model)) {
  15896. var formModel = $stateParams.model;
  15897. }
  15898. //用户测试数据,后续从header的auth中获取
  15899. var userId = 2;
  15900. userId = $rootScope.user.id;
  15901. //==============处理表单设计数据 开始====================
  15902. //处理组件加载后台数据选项的方法
  15903. function refreshSelectOptions(searchVal, field) {
  15904. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  15905. var process = BpmRestangular.all("");
  15906. if (field.templateOptions.ApiService) {
  15907. process = UserRestangular.all("");
  15908. }
  15909. if (field.templateOptions.Apicommon) {
  15910. process = WechatRestangular.all("");
  15911. }
  15912. var datakey = {
  15913. "idx": 0,
  15914. "sum": 1000
  15915. };
  15916. if (field.templateOptions.modelreasondata) {
  15917. datakey = field.templateOptions.modelreasondata
  15918. }
  15919. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  15920. if (!field.templateOptions.options) {
  15921. field.templateOptions.options = [];
  15922. }
  15923. if (field.templateOptions.optionsDataKey) {
  15924. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  15925. } else {
  15926. field.templateOptions.options = result;
  15927. }
  15928. });
  15929. }
  15930. }
  15931. //获取表单后数据处理
  15932. function formfield(field, result) {
  15933. // angular.forEach(fields.fields, function(field) {
  15934. if (field.key == "") {
  15935. delete field.key;
  15936. }
  15937. if (angular.isDefined(field.extjson)) {
  15938. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  15939. angular.extend(field.templateOptions, extObj.templateOptions);
  15940. delete extObj.templateOptions;
  15941. for (var prop in extObj) {
  15942. if (new RegExp("Expression").test(prop)) {
  15943. //var obj = $scope.$eval(extObj[prop]);
  15944. //extObj[prop] = $scope.$eval(extObj[prop]);
  15945. if (extObj[prop] != null) {
  15946. if (new RegExp("function").test(extObj[prop])) {
  15947. var propValue = eval(extObj[prop]);
  15948. extObj[prop] = propValue;
  15949. } else {
  15950. //console.log(extObj[prop]);
  15951. var obj = $scope.$eval(extObj[prop]);
  15952. extObj[prop] = obj;
  15953. //console.log(obj);
  15954. }
  15955. }
  15956. } else if (new RegExp("expressionProperties").test(prop)) {
  15957. for (var p in extObj[prop]) {
  15958. if (new RegExp("function").test(extObj[prop][p])) {
  15959. var propValue = eval(extObj[prop][p]);
  15960. extObj[prop][p] = propValue;
  15961. } else {
  15962. //if(p.indexOf("'")>=0){
  15963. // var obj = $scope.$eval(extObj[prop][p]);
  15964. // extObj[prop][$scope.$eval(p)]=obj;
  15965. //}
  15966. }
  15967. }
  15968. } else if ("watcher" == prop) {
  15969. if (angular.isArray(extObj[prop])) {
  15970. angular.forEach(extObj[prop], function (item, index) {
  15971. for (var p in item) {
  15972. if (new RegExp("function").test(item[p])) {
  15973. var propValue = eval(item[p]);
  15974. extObj[prop][index][p] = propValue;
  15975. }
  15976. }
  15977. });
  15978. } else if (angular.isObject(extObj[prop])) {
  15979. for (var p in extObj[prop]) {
  15980. if (new RegExp("function").test(extObj[prop][p])) {
  15981. var propValue = eval(extObj[prop][p]);
  15982. extObj[prop][p] = propValue;
  15983. }
  15984. }
  15985. }
  15986. }
  15987. }
  15988. angular.extend(field, extObj);
  15989. delete field.extjson;
  15990. }
  15991. if (angular.isDefined(field.templateOptions)) {
  15992. var templateOs = field.templateOptions;
  15993. // console.log(templateOs,'come')
  15994. for (var property in templateOs) {
  15995. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  15996. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  15997. if (new RegExp("function").test(templateOs[property])) {
  15998. var propValue = eval(templateOs[property]);
  15999. field.templateOptions[property] = propValue;
  16000. } else {
  16001. if (that.has(templateOs[property])) {
  16002. field.templateOptions[property] = that.get(templateOs[property]);
  16003. } else {
  16004. field.templateOptions[property] = templateOs[property];
  16005. }
  16006. }
  16007. } else if (templateOs[property] == null) {
  16008. //delete field.templateOptions[property];
  16009. } else { }
  16010. }
  16011. }
  16012. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  16013. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  16014. angular.extend(field.templateOptions, extObj);
  16015. delete field.templateOptions.extjson;
  16016. }
  16017. // ...
  16018. if (field.templateOptions) {
  16019. //处理远程获取数据控件方法调用
  16020. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  16021. // if (!field.templateOptions.isnoreash) {
  16022. field.templateOptions.refresh = refreshSelectOptions;
  16023. // }
  16024. }
  16025. //处理嵌套属性数据绑定/
  16026. if (field.templateOptions.pkey) {
  16027. var pmodel, i = 0;
  16028. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  16029. if (i == 0) {
  16030. if (result.model[p] == null) {
  16031. result.model[p] = {};
  16032. }
  16033. pmodel = result.model[p];
  16034. i++;
  16035. } else {
  16036. if (pmodel[p] == null) {
  16037. pmodel[p] = {};
  16038. }
  16039. pmodel = pmodel[p];
  16040. }
  16041. });
  16042. if (pmodel != null) {
  16043. field.model = pmodel;
  16044. if (pmodel[field.key] == null) {
  16045. pmodel[field.key] = null;
  16046. }
  16047. }
  16048. } else {
  16049. if (result.model[field.key] == null) {
  16050. result.model[field.key] = null;
  16051. }
  16052. }
  16053. //处理弹出框组件初始化
  16054. if (field.type == "ui-input-selectmodal") {
  16055. field.templateOptions.modal = $modal;
  16056. //field.templateOptions.Restangular = Restangular;
  16057. } else if (field.type == "ui-requesterselect") {
  16058. //field.templateOptions.language = $scope.lang;
  16059. field.templateOptions.modal = $modal;
  16060. field.templateOptions.UserService = api_user_data;
  16061. } else if (field.type == "ui-deptinformation") {
  16062. field.templateOptions.modal = $modal;
  16063. field.templateOptions.UserService = api_user_data;
  16064. } else if (field.type == "ui-requesterinformation") {
  16065. field.templateOptions.modal = $modal;
  16066. field.templateOptions.UserService = api_user_data;
  16067. } else if (field.type == "ui-userselect") {
  16068. field.templateOptions.modal = $modal;
  16069. //field.templateOptions.Restangular = Restangular;
  16070. } else if (field.type == "ui-userselectSearch") {
  16071. field.templateOptions.modal = $modal;
  16072. //field.templateOptions.Restangular = Restangular;
  16073. } else if (field.type == "ui-multiuserselect") {
  16074. field.templateOptions.modal = $modal;
  16075. } else if (field.type == "ui-stringuserselect") {
  16076. field.templateOptions.modal = $modal;
  16077. } else if (field.type == "ui-search") {
  16078. field.templateOptions.modal = $modal;
  16079. } else if (field.type == "ui-modelselect") {
  16080. field.templateOptions.modal = $modal;
  16081. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16082. field.templateOptions.loginUser = $rootScope.user;
  16083. //field.templateOptions.Restangular = Restangular;
  16084. } else if (field.type == "ui-incidentmodelselect") {
  16085. field.templateOptions.modal = $modal;
  16086. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16087. field.templateOptions.loginUser = $rootScope.user;
  16088. //field.templateOptions.Restangular = Restangular;
  16089. } else if (field.type == "ui-dropfile") {
  16090. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16091. url: '/uploader'
  16092. });
  16093. field.templateOptions.taskId = $stateParams.taskId;
  16094. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16095. field.templateOptions.userId = $rootScope.user.id;
  16096. } else if (field.type == "ui-dropfielknow") {
  16097. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16098. url: '/uploader'
  16099. });
  16100. field.templateOptions.taskId = $stateParams.taskId;
  16101. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16102. field.templateOptions.userId = $rootScope.user.id;
  16103. } else if (field.type == "ui-upDropFile") {
  16104. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16105. url: '/uploader'
  16106. });
  16107. field.templateOptions.taskId = $stateParams.taskId;
  16108. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16109. field.templateOptions.userId = $rootScope.user.id;
  16110. } else if (field.type == "ui-dropfilenotup") {
  16111. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16112. url: '/uploader'
  16113. });
  16114. field.templateOptions.taskId = $stateParams.taskId;
  16115. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16116. field.templateOptions.userId = $rootScope.user.id;
  16117. //field.ApiService=api_bpm_domain;
  16118. } else if (field.type == "ui-uploadFiles") {
  16119. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16120. url: '/uploader'
  16121. });
  16122. field.templateOptions.taskId = $stateParams.taskId;
  16123. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16124. field.templateOptions.userId = $rootScope.user.id;
  16125. //field.ApiService=api_bpm_domain;
  16126. } else if (field.type == "ui-upDownFiles") {
  16127. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16128. url: '/uploader'
  16129. });
  16130. field.templateOptions.taskId = $stateParams.taskId;
  16131. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16132. field.templateOptions.userId = $rootScope.user.id;
  16133. //field.ApiService=api_bpm_domain;
  16134. } else if (field.type == "ui-uploadImgs") {
  16135. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16136. url: '/uploader'
  16137. });
  16138. field.templateOptions.taskId = $stateParams.taskId;
  16139. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16140. field.templateOptions.userId = $rootScope.user.id;
  16141. //field.ApiService=api_bpm_domain;
  16142. } else if (field.type == "ui-dropfiletable") {
  16143. if (field.templateOptions.processInstanceId) {
  16144. } else {
  16145. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16146. }
  16147. } else if (field.type == "ui-dropFiles") {
  16148. if (field.templateOptions.processInstanceId) {
  16149. } else {
  16150. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16151. }
  16152. } else if (field.type == "ui-showImgs") {
  16153. if (field.templateOptions.processInstanceId) {
  16154. } else {
  16155. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16156. }
  16157. } else if (field.type == "ui-repeatSection") {
  16158. var repeatForm = {
  16159. model: {
  16160. },
  16161. fields: field.templateOptions.fields
  16162. };
  16163. repeatForm.model[field.key] = [];
  16164. decodeVMForm(repeatForm);
  16165. } else if (field.type == "ui-currentuser") {
  16166. field.templateOptions.user = vm.model["loginUser"];
  16167. } else if (field.type == "ui-workernumbersign") {
  16168. field.templateOptions.user = vm.model["loginUser"];
  16169. } else if (field.type == "ui-repair-photos") {
  16170. field.templateOptions.user = vm.model["loginUser"];
  16171. }
  16172. }
  16173. }
  16174. //解析自定义表单设计数据
  16175. $scope.oldfromtype = true;
  16176. function decodeVMForm(vmForm) {
  16177. if (vmForm.formType == "1") {
  16178. $scope.oldfromtype = false;
  16179. } else {
  16180. $scope.oldfromtype = true;
  16181. }
  16182. var result = {
  16183. model: {},
  16184. fields: []
  16185. };
  16186. //设置模型实体数据 begin
  16187. // var mdata = vmForm.model;
  16188. //解析数据实体
  16189. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  16190. angular.extend(result.model, mdata);
  16191. if (modelWatch != null && modelWatch != '') {
  16192. //angular.extend(result.model.incident,modelWatch.incident);
  16193. //result.model.alarmType = modelWatch.alarmType;
  16194. // vmForm.cancelUrl = modelWatch.cancelUrl;
  16195. // console.log(modelWatch.cancelUrl)
  16196. for (var index in modelWatch.model) {
  16197. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  16198. if (result.model[index] != null) {
  16199. angular.extend(result.model[index], modelWatch.model[index]);
  16200. } else {
  16201. result.model[index] = modelWatch.model[index];
  16202. }
  16203. }
  16204. }
  16205. //设置模型实体数据 end
  16206. //解析设计数据生成表单项 begin
  16207. var fields = [];
  16208. //处理修改设计数据中展示设置
  16209. angular.forEach(vmForm.fields, function (fields) {
  16210. if (vmForm.formType == "1") {
  16211. angular.forEach(fields.fields, function (field) {
  16212. formfield(field, result);
  16213. });
  16214. } else {
  16215. formfield(fields, result);
  16216. }
  16217. // console.log(field);
  16218. result.fields.push(fields);
  16219. });
  16220. angular.extend($scope.vm.fields, result.fields);
  16221. angular.extend($scope.vm.model, result.model);
  16222. vm.model["loginUser"] = $rootScope.user;
  16223. //增加识别报修主体seimin
  16224. vm.model.repairType = $scope.repairMain.valueconfig;
  16225. if(vm.model.incident){
  16226. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  16227. }
  16228. console.log(vm, 'repairType')//lmm
  16229. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  16230. vmForm.cancelUrl = modelWatch.cancelUrl;
  16231. }
  16232. $scope.formData = vmForm;
  16233. console.log($scope.formData,4444444)
  16234. // console.log($scope.formData.url);
  16235. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  16236. if ($scope.formData.url == "start") {
  16237. $scope.Reset = true;
  16238. $scope.close = true;
  16239. $rootScope.isMask = false;
  16240. } else if ($scope.formData.url == "complete") {
  16241. $scope.Reset = false;
  16242. $scope.close = true;
  16243. }
  16244. //解析设计数据生成表单项 end
  16245. return result;
  16246. }
  16247. //======================处理表单设计数据 结束========================
  16248. $scope.ldloading = {};
  16249. function filter(obj) {
  16250. angular.forEach(obj, function (key, value) {
  16251. if (value === "" || value === null) {
  16252. delete obj[key];
  16253. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  16254. filter(value);
  16255. } else if (angular.isArray(value)) {
  16256. angular.forEach(value, function (item) {
  16257. filter(item);
  16258. });
  16259. }
  16260. });
  16261. }
  16262. $scope.closeModel = function () {
  16263. // console.log($stateParams);
  16264. $state.go($scope.formData.cancelUrl, {});
  16265. event.preventDefault();
  16266. };
  16267. // console.log(vm);
  16268. // 暂存
  16269. $scope.save = function (data) {
  16270. console.log(vm)
  16271. if (vm.model.startSave) {
  16272. vm.model["initUser"] = $rootScope.user.id;
  16273. vm.model.start_code = "temporary";
  16274. //处理请求数据0327
  16275. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16276. delete data0327.repairType;
  16277. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16278. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16279. data0327.incident.place = {
  16280. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16281. }
  16282. }
  16283. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16284. if (response) {
  16285. var resData = Restangular.stripRestangular(response);
  16286. if (resData) {
  16287. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16288. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16289. angular.extend(item.headers, $rootScope.getSession());
  16290. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16291. item.formData.push({
  16292. 'fileName': item.file.name
  16293. });
  16294. //console.log();
  16295. };
  16296. $scope.fileUploader.uploadAll();
  16297. }
  16298. }
  16299. SweetAlert.swal({
  16300. title: "提交成功!",
  16301. type: "success",
  16302. confirmButtonColor: "#007AFF"
  16303. }, function () {
  16304. $state.go($scope.formData.cancelUrl);
  16305. });
  16306. } else {
  16307. SweetAlert.swal({
  16308. title: "系统错误",
  16309. text: "系统错误,请稍后重试!",
  16310. type: "error",
  16311. confirmButtonColor: "#DD6B55"
  16312. });
  16313. }
  16314. $scope.ldloading[style.replace('-', '_')] = false;
  16315. });
  16316. event.preventDefault();
  16317. } else if (vm.model.saveAgain) {
  16318. var toData = {
  16319. "incident": vm.model.incident
  16320. };
  16321. api_user_data.updData("incident", toData).then(function (response) {
  16322. if (response) {
  16323. var resData = Restangular.stripRestangular(response);
  16324. SweetAlert.swal({
  16325. title: "提交成功!",
  16326. type: "success",
  16327. confirmButtonColor: "#007AFF"
  16328. }, function () {
  16329. $state.go($scope.formData.cancelUrl);
  16330. });
  16331. } else {
  16332. SweetAlert.swal({
  16333. title: "系统错误",
  16334. text: "系统错误,请稍后重试!",
  16335. type: "error",
  16336. confirmButtonColor: "#DD6B55"
  16337. });
  16338. }
  16339. $scope.ldloading[style.replace('-', '_')] = false;
  16340. });
  16341. event.preventDefault();
  16342. } else {
  16343. SweetAlert.swal({
  16344. title: "系统错误",
  16345. text: "系统错误,请稍后重试!",
  16346. type: "error",
  16347. confirmButtonColor: "#DD6B55"
  16348. });
  16349. }
  16350. }
  16351. // 巡检生成事件
  16352. $scope.inspectionToIncident = function () {
  16353. var userData = {
  16354. "idx": 0,
  16355. "sum": 10,
  16356. "requester": {
  16357. "name": loginUser.name
  16358. }
  16359. }
  16360. api_user_data.fetchDataList("requester", userData).then(function (res) {
  16361. console.log(res);
  16362. var toUser = {};
  16363. if (res.list.length > 0) {
  16364. toUser = res.list[0]
  16365. } else {
  16366. toUser = loginUser
  16367. }
  16368. console.log(vm);
  16369. var incidentDescription = "";
  16370. console.log($stateParams.formUiEdit);
  16371. if ($stateParams.formUiEdit == "inspection_confirm") {
  16372. if (vm.model.wnCheckEnable) {
  16373. incidentDescription = incidentDescription.concat(" 机房温度检查异常")
  16374. }
  16375. if (vm.model.sdCheckEnable) {
  16376. incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
  16377. }
  16378. if (vm.model.xfjCheckEnable) {
  16379. incidentDescription = incidentDescription.concat(" 新风机检查异常")
  16380. }
  16381. if (vm.model.lsCheckEnable) {
  16382. incidentDescription = incidentDescription.concat(" 漏水检查异常")
  16383. }
  16384. if (vm.model.xfCheckEnable) {
  16385. incidentDescription = incidentDescription.concat(" 消防检查异常")
  16386. }
  16387. if (vm.model.upsCheckEnable) {
  16388. incidentDescription = incidentDescription.concat(" UPS供电检查异常")
  16389. }
  16390. if (vm.model.dcCheckEnable) {
  16391. incidentDescription = incidentDescription.concat(" 电池连接检查异常")
  16392. }
  16393. if (vm.model.plCheckEnable) {
  16394. incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
  16395. }
  16396. if (vm.model.wjtdCheckEnable) {
  16397. incidentDescription = incidentDescription.concat(" 外机通道检查异常")
  16398. }
  16399. if (vm.model.descriptionTextarea) {
  16400. incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
  16401. }
  16402. }
  16403. // console.log(incidentDescription)
  16404. var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
  16405. var formdata = {
  16406. 'model': {
  16407. // 'isInspection': true,
  16408. // 'start_code':'assignment',
  16409. // 'isHandlerUser':false,
  16410. 'incident': {
  16411. 'requester':bxr ,
  16412. // 'area': data.incident.place.area,
  16413. // 'place': data.incident.place,
  16414. // 'houseNumber': data.incident.address,
  16415. 'contacts': bxr.name,
  16416. 'contactsInformation': bxr.mphone,
  16417. // 'category': data.wxIncidentClassifyDTO.category,
  16418. 'description': incidentDescription,
  16419. 'source': {
  16420. 'id': 1552
  16421. },
  16422. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  16423. // 'sourceType': data.incident.sourceType,
  16424. // 'fileUrl': data.incident.fileUrl
  16425. },
  16426. // 'requestershow': toUser,//2020年4月27日22:29:15
  16427. // 'flow': data.incident.id
  16428. // 'assignee': loginUser.id//2020年4月27日22:29:25
  16429. }
  16430. }
  16431. // console.log(formdata,toUser,'1111');
  16432. console.log(formdata,'1111');
  16433. // return;
  16434. $state.go("app.incident.chart", {
  16435. 'model': JSON.stringify(formdata)
  16436. });
  16437. })
  16438. // var formdata = {
  16439. // model:$rootScope.login_requester
  16440. // };
  16441. // console.log(formdata,'00000')
  16442. // return;
  16443. // $state.go("app.incident.chart", {
  16444. // 'model': JSON.stringify(formdata)
  16445. // });
  16446. event.preventDefault();
  16447. };
  16448. // console.log(vm);
  16449. // 创建事件seimin
  16450. vm.submit = function (data, style) {
  16451. console.log(vm,22222);
  16452. if (vm.model.handler_code == undefined) {
  16453. vm.model.handler_code = "resolve";
  16454. }
  16455. if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
  16456. delete vm.model.change.requestingPerson.menu;
  16457. }
  16458. // var pdKey = $stateParams.pdKey;
  16459. if (vm.form.$valid) {
  16460. if (data.incident && data.incident.synergetic) {
  16461. console.log(data.incident.synergetic);
  16462. var synergetic = [];
  16463. for (var i = 0; i < data.incident.synergetic.length; i++) {
  16464. synergetic.push({
  16465. id: data.incident.synergetic[i]
  16466. });
  16467. }
  16468. data.incident.synergetic = synergetic;
  16469. vm.model.incident.synergetic = synergetic;
  16470. }
  16471. $scope.ldloading[style.replace('-', '_')] = true;
  16472. var startsub = true;
  16473. if (pdKey == 'bpm_incident') {
  16474. angular.forEach(vm.fields, function (item) {
  16475. angular.forEach(item.fields, function (index) {
  16476. if (index.templateOptions.required && !index.hide) {
  16477. if (index.model) {
  16478. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  16479. if (index.model[index.key].id && index.model[index.key].id == '') {
  16480. startsub = false;
  16481. $scope.ldloading.expand_right = false;
  16482. SweetAlert.swal({
  16483. title: index.templateOptions.label + '未填',
  16484. text: "请填写此项!",
  16485. type: "error",
  16486. confirmButtonColor: "#DD6B55"
  16487. });
  16488. } else { }
  16489. } else {
  16490. startsub = false;
  16491. $scope.ldloading.expand_right = false;
  16492. SweetAlert.swal({
  16493. title: index.templateOptions.label + '未填',
  16494. text: "请填写此项!",
  16495. type: "error",
  16496. confirmButtonColor: "#DD6B55"
  16497. });
  16498. }
  16499. } else {
  16500. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  16501. } else {
  16502. startsub = false;
  16503. $scope.ldloading.expand_right = false;
  16504. SweetAlert.swal({
  16505. title: index.templateOptions.label + '未填',
  16506. text: "请填写此项!",
  16507. type: "error",
  16508. confirmButtonColor: "#DD6B55"
  16509. });
  16510. }
  16511. }
  16512. }
  16513. })
  16514. })
  16515. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  16516. // startsub = false;
  16517. // $scope.ldloading.expand_right = false;
  16518. // SweetAlert.swal({
  16519. // title: '保修人未填',
  16520. // text: "请填写此项!",
  16521. // type: "error",
  16522. // confirmButtonColor: "#DD6B55"
  16523. // });
  16524. // }
  16525. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  16526. // } else {
  16527. // startsub = false;
  16528. // $scope.ldloading.expand_right = false;
  16529. // SweetAlert.swal({
  16530. // title: '事件分类未填',
  16531. // text: "请填写此项!",
  16532. // type: "error",
  16533. // confirmButtonColor: "#DD6B55"
  16534. // });
  16535. // }
  16536. }
  16537. if (startsub) {
  16538. $scope.ldloading[style.replace('-', '_')] = true;
  16539. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  16540. // console.log("vm.options:"+ JSON.stringify(vm.options));
  16541. vm.options.updateInitialValue();
  16542. // console.log("dfjkasdhfkhskjf ")
  16543. var _ = window._;
  16544. vm.model = (function filter(obj) {
  16545. var dateTransKeys = [];
  16546. var filtered = _.pick(obj, function (v, k, obj) {
  16547. if (_.isDate(v)) {
  16548. dateTransKeys.push(k);
  16549. }
  16550. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  16551. });
  16552. return _.cloneDeep(filtered, function (v, index, object) {
  16553. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  16554. angular.forEach(dateTransKeys, function (item) {
  16555. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  16556. })
  16557. dateTransKey = [];
  16558. return v;
  16559. }
  16560. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  16561. });
  16562. })(vm.model);
  16563. if (pdKey != "") {
  16564. if ($scope.oprcode == "save") { //保存
  16565. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  16566. if (response) {
  16567. var resData = Restangular.stripRestangular(response);
  16568. SweetAlert.swal({
  16569. title: "保存成功!",
  16570. confirmButtonColor: "#007AFF"
  16571. }, function () {
  16572. $state.go($scope.formData.cancelUri);
  16573. });
  16574. // if(resData.status){
  16575. // resData
  16576. // }
  16577. } else {
  16578. SweetAlert.swal({
  16579. title: "系统错误",
  16580. text: "系统错误,请稍后重试!",
  16581. type: "error",
  16582. confirmButtonColor: "#DD6B55"
  16583. });
  16584. }
  16585. $scope.ldloading[style.replace('-', '_')] = false;
  16586. });
  16587. } else {
  16588. console.log($scope.formData.url,'zzzz')
  16589. switch ($scope.formData.url) {
  16590. case "start":
  16591. vm.model["initUser"] = $rootScope.user.id;
  16592. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  16593. } else {
  16594. vm.model["assignee"] = $rootScope.user.id;
  16595. }
  16596. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  16597. vm.model.candidateGroups = vm.model.candidateGroups.id;
  16598. }
  16599. if (pdKey == 'bpm_service_request') {
  16600. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  16601. angular.extend(vm.model.serviceCatalogueProcessActual, {
  16602. 'category': {
  16603. 'id': $stateParams.userId
  16604. }
  16605. });
  16606. }
  16607. if (vm.model.schedule && vm.model.schedule.initUser) {
  16608. delete vm.model.schedule.initUser.menu
  16609. }
  16610. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16611. delete vm.model.candidateGroups
  16612. }
  16613. if (vm.model.start_code == 'close') {
  16614. // 直接处理
  16615. vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
  16616. delete vm.model.incident.handlerUser
  16617. delete vm.model.candidateGroups;
  16618. } else if (vm.model.start_code == 'assignment') {
  16619. // 派单
  16620. delete vm.model.incident.handlingPersonnelUser
  16621. }
  16622. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  16623. $scope.jry_processInstanceId = $stateParams.processInstanceId;
  16624. }
  16625. if ($scope.jry_processInstanceId) {
  16626. vm.model["save_fileId"] = $scope.jry_processInstanceId
  16627. }
  16628. //事件暂存判断
  16629. if (vm.model.saveAgain) {
  16630. if (vm.model.directClose == "1" || vm.model.directClose == true) {
  16631. vm.model.start_code = "assignment";
  16632. vm.model.temporary_code = "assignment";
  16633. } else {
  16634. vm.model.start_code = "close";
  16635. vm.model.temporary_code = "close"
  16636. };
  16637. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16638. delete vm.model.candidateGroups
  16639. }
  16640. }
  16641. //处理请求数据0327
  16642. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16643. delete data0327.repairType;
  16644. // 增加地点的请求参数2020年4月24日10:44:36
  16645. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16646. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16647. data0327.incident.place = {
  16648. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16649. }
  16650. }
  16651. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16652. // console.log("response="+JSON.stringify(response));
  16653. if (response) {
  16654. var resData = Restangular.stripRestangular(response);
  16655. if (resData) {
  16656. if (resData) {
  16657. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16658. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16659. angular.extend(item.headers, $rootScope.getSession());
  16660. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16661. item.formData.push({
  16662. 'fileName': item.file.name
  16663. });
  16664. //console.log();
  16665. };
  16666. $scope.fileUploader.uploadAll();
  16667. }
  16668. }
  16669. }
  16670. SweetAlert.swal({
  16671. title: "提交成功!",
  16672. type: "success",
  16673. confirmButtonColor: "#007AFF"
  16674. }, function () {
  16675. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  16676. $rootScope.app.layout.isSidebarClosed = false;
  16677. if ($scope.login && !$rootScope.busy) {
  16678. $rootScope.setidle();
  16679. }
  16680. }
  16681. $state.go($scope.formData.cancelUrl);
  16682. });
  16683. } else {
  16684. SweetAlert.swal({
  16685. title: "系统错误",
  16686. text: "系统错误,请稍后重试!",
  16687. type: "error",
  16688. confirmButtonColor: "#DD6B55"
  16689. });
  16690. }
  16691. $scope.ldloading[style.replace('-', '_')] = false;
  16692. });
  16693. break;
  16694. case "complete":
  16695. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  16696. //console.log("complete taskId::"+$stateParams.taskId);
  16697. if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
  16698. SweetAlert.swal({
  16699. title: "处理人未填",
  16700. text: "请填写此项!",
  16701. type: "error",
  16702. confirmButtonColor: "#DD6B55"
  16703. });
  16704. return;
  16705. }
  16706. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  16707. if (response) {
  16708. var resData = Restangular.stripRestangular(response);
  16709. SweetAlert.swal({
  16710. title: "提交成功!",
  16711. type: "success",
  16712. confirmButtonColor: "#007AFF"
  16713. }, function () {
  16714. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
  16715. console.log(vm);
  16716. if (vm.model.incident) {
  16717. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  16718. // angular.extend(item.headers, $rootScope.getSession());
  16719. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16720. // item.formData.push({
  16721. // 'fileName': item.file.name
  16722. // });
  16723. // };
  16724. // $scope.fileUploader.uploadAll();
  16725. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16726. angular.extend(item.headers, $rootScope.getSession());
  16727. item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
  16728. item.formData.push({
  16729. 'fileName': item.file.name
  16730. });
  16731. //console.log();
  16732. };
  16733. $scope.fileUploader.uploadAll();
  16734. } else if (vm.model.problem) {
  16735. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16736. angular.extend(item.headers, $rootScope.getSession());
  16737. item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16738. item.formData.push({
  16739. 'fileName': item.file.name
  16740. });
  16741. };
  16742. $scope.fileUploader.uploadAll();
  16743. } else if (vm.model.change) {
  16744. }
  16745. }
  16746. $state.go($scope.formData.cancelUrl);
  16747. });
  16748. } else {
  16749. SweetAlert.swal({
  16750. title: "系统错误",
  16751. text: "系统错误,请稍后重试!",
  16752. type: "error",
  16753. confirmButtonColor: "#DD6B55"
  16754. });
  16755. }
  16756. $scope.ldloading[style.replace('-', '_')] = false;
  16757. });
  16758. break;
  16759. case "back":
  16760. $state.go($scope.formData.cancelUrl);
  16761. break;
  16762. default:
  16763. $scope.ldloading[style.replace('-', '_')] = false;
  16764. break;
  16765. }
  16766. }
  16767. // var submitFunc = api_bpm_domain[$scope.formData.url]
  16768. // if(anuglar.isFunction(submitFunc)){
  16769. // submitFunc.apply(null, pdKey)
  16770. // }
  16771. }
  16772. }
  16773. } else {
  16774. // console.log(data)
  16775. // angular.forEach(vm.form.$error.required, function(item){
  16776. // var i=(item.$name).substring(item.$name.length-2)
  16777. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  16778. // for(var i=0;i<vm.fields.length;i++){
  16779. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  16780. SweetAlert.swal({
  16781. title: vm.fields[i].templateOptions.label + '未填',
  16782. text: "请填写此项!",
  16783. type: "error",
  16784. confirmButtonColor: "#DD6B55"
  16785. });
  16786. }
  16787. // }
  16788. // angular.forEach(vm.fields,function(f){
  16789. // if(f.name == item.$name){
  16790. // f.validation.show = true;
  16791. // SweetAlert.swal({
  16792. // title: f.templateOptions.label+'未填',
  16793. // text: "请填写此项!",
  16794. // type: "error",
  16795. // confirmButtonColor: "#DD6B55"
  16796. // });
  16797. // }
  16798. // });
  16799. // })
  16800. }
  16801. };
  16802. $scope.vm = vm;
  16803. console.log($stateParams,pdKey,88888)
  16804. console.log($scope.vm,'assdfsdf')
  16805. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  16806. var processInstanceId = $stateParams.processInstanceId;
  16807. var itemId = $stateParams.dataId;
  16808. console.log($stateParams)
  16809. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  16810. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
  16811. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16812. var vmForm = Restangular.stripRestangular(responseData);
  16813. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16814. decodeVMForm(vmForm);
  16815. }
  16816. }
  16817. });
  16818. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  16819. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  16820. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16821. var vmForm = Restangular.stripRestangular(responseData);
  16822. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16823. decodeVMForm(vmForm);
  16824. }
  16825. }
  16826. });
  16827. } else {
  16828. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  16829. if (response) {
  16830. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  16831. api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
  16832. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16833. var vmForm = Restangular.stripRestangular(responseData);
  16834. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16835. decodeVMForm(vmForm);
  16836. console.log(vmForm,111111);
  16837. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  16838. console.log($scope,'今天')//2020年4月24日11:40:55
  16839. }
  16840. }
  16841. });
  16842. }
  16843. })
  16844. }
  16845. } else {
  16846. // create process instance
  16847. if (pdKey != "") { //for process
  16848. if (pdKey == 'bpm_service_request') {
  16849. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  16850. if (responseData) {
  16851. var vmForm = Restangular.stripRestangular(responseData);
  16852. if (vmForm) {
  16853. decodeVMForm(vmForm);
  16854. }
  16855. }
  16856. });
  16857. } else {
  16858. api_bpm_domain.startformkey(pdKey).then(function (response) {
  16859. if (response) {
  16860. var myData = Restangular.stripRestangular(response);
  16861. //myData.data = "arrangeform";
  16862. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  16863. if (responseData) {
  16864. var vmForm = Restangular.stripRestangular(responseData);
  16865. if (vmForm) {
  16866. decodeVMForm(vmForm);
  16867. }
  16868. }
  16869. });
  16870. }
  16871. });
  16872. }
  16873. } else { //for form
  16874. //TODO
  16875. //测试数据 开始
  16876. var testJson = {
  16877. fields: [{
  16878. fields: [{
  16879. className: "col-xs-12",
  16880. noFormControl: true,
  16881. key: "formtitle",
  16882. templateOptions: {
  16883. readOnly: false,
  16884. placeholder: "新建事件单",
  16885. hidden: false,
  16886. label: "事件工单",
  16887. required: false
  16888. },
  16889. type: "ui-title"
  16890. }]
  16891. }, {
  16892. fields: [{
  16893. key: 'selectUser',
  16894. type: 'ui-deptinformation',
  16895. className: 'col-xs-12',
  16896. templateOptions: {
  16897. label: '请求人信息',
  16898. modalTitle: '请求人列表',
  16899. fetchItems: function (filterData, APIService) {
  16900. return APIService.fetchDataList('requester', filterData);
  16901. },
  16902. Restangular: Restangular,
  16903. ApiService: api_user_data
  16904. // onClick:function(val, options, field, event , model){
  16905. // console.log(options);
  16906. // }
  16907. }
  16908. }]
  16909. }, {
  16910. fields: [{
  16911. key: 'first',
  16912. type: 'ui-workernumber',
  16913. className: 'col-xs-12',
  16914. templateOptions: {
  16915. type: 'input',
  16916. label: '事件单号',
  16917. pkey: 'name'
  16918. }
  16919. }]
  16920. }, {
  16921. fields: [{
  16922. type: 'ui-header',
  16923. key: 'title',
  16924. className: 'col-xs-12',
  16925. templateOptions: {
  16926. label: '报修人',
  16927. pkey: 'change'
  16928. }
  16929. }, {
  16930. type: 'ui-input',
  16931. key: 'title',
  16932. className: 'col-xs-4',
  16933. templateOptions: {
  16934. label: '报修人',
  16935. pkey: 'change'
  16936. }
  16937. }, {
  16938. type: 'ui-input',
  16939. key: 'title',
  16940. className: 'col-xs-4',
  16941. templateOptions: {
  16942. label: '联系人',
  16943. pkey: 'change'
  16944. }
  16945. }, {
  16946. type: 'ui-input',
  16947. key: 'title',
  16948. className: 'col-xs-4',
  16949. templateOptions: {
  16950. label: '联系电话',
  16951. pkey: 'change'
  16952. }
  16953. }]
  16954. }, {
  16955. fields: [{
  16956. type: 'ui-header',
  16957. key: 'title1',
  16958. className: 'col-xs-12',
  16959. templateOptions: {
  16960. label: '报修人',
  16961. pkey: 'change'
  16962. }
  16963. }, {
  16964. type: 'ui-input',
  16965. key: 'title2',
  16966. className: 'col-xs-4',
  16967. templateOptions: {
  16968. label: '报修人',
  16969. pkey: 'change'
  16970. }
  16971. }, {
  16972. type: 'ui-input',
  16973. key: 'title3',
  16974. className: 'col-xs-4',
  16975. templateOptions: {
  16976. label: '联系人',
  16977. pkey: 'change'
  16978. }
  16979. }, {
  16980. type: 'ui-input',
  16981. key: 'title4',
  16982. className: 'col-xs-4',
  16983. templateOptions: {
  16984. label: '联系电话',
  16985. pkey: 'change'
  16986. }
  16987. }]
  16988. }],
  16989. model: [{
  16990. username: "robin lau",
  16991. password: "123456",
  16992. chkme: false,
  16993. start_code: 0,
  16994. formtitle: "Hey!I am title value!",
  16995. name: {
  16996. first: "robin",
  16997. last: "lau"
  16998. },
  16999. multiselectItem: []
  17000. //date:"2015-09-15 00:00:00"
  17001. }]
  17002. // }
  17003. };
  17004. setTimeout(function () {
  17005. decodeVMForm(testJson);
  17006. $scope.$apply();
  17007. }, 500);
  17008. //测试数据结束
  17009. }
  17010. }
  17011. //console.log("end decode");
  17012. }
  17013. ]);