customformCtrl.js 959 KB

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