customformCtrl.js 960 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826
  1. var appFormly = angular.module('formlyExample', [
  2. 'formly', 'formlyBootstrap', 'ui.bootstrap',
  3. 'ngSanitize', 'ui.select', 'ui.grid'
  4. ]);
  5. app.requires.push('formlyExample');
  6. // var appFormly = angular.module('formlyExample', [
  7. // 'formly', 'formlyBootstrap','ui.bootstrap',
  8. // 'ngSanitize','ui.select','ui.grid'],
  9. // 图片上传
  10. app.factory('fileReader', ["$q", "$log", function ($q, $log) {
  11. var onLoad = function (reader, deferred, scope) {
  12. return function () {
  13. scope.$apply(function () {
  14. deferred.resolve(reader.result);
  15. });
  16. };
  17. };
  18. var onError = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.reject(reader.result);
  22. });
  23. };
  24. };
  25. var getReader = function (deferred, scope) {
  26. var reader = new FileReader(); //fileReader
  27. reader.onload = onLoad(reader, deferred, scope);
  28. reader.onerror = onError(reader, deferred, scope);
  29. return reader;
  30. };
  31. var readAsDataURL = function (file, scope) {
  32. var deferred = $q.defer();
  33. var reader = getReader(deferred, scope);
  34. reader.readAsDataURL(file);
  35. return deferred.promise;
  36. };
  37. return {
  38. readAsDataUrl: readAsDataURL
  39. };
  40. }])
  41. appFormly.filter('minutesToHours', function() { //分钟转小时
  42. return function(num) {
  43. var hour = parseInt(num / 60);
  44. var minute = num % 60;
  45. return hour + '小时' + minute + '分钟';
  46. }
  47. });
  48. appFormly.config(
  49. function config(formlyConfigProvider) {
  50. //格式转换方法 XXX-XXX转驼峰命名
  51. function camelize(string) {
  52. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  53. return chr ? chr.toUpperCase() : '';
  54. });
  55. // Ensure 1st char is always lowercase
  56. return string.replace(/^([A-Z])/, function (match, chr) {
  57. return chr ? chr.toLowerCase() : '';
  58. });
  59. }
  60. //获取ngModelAttr对象设置
  61. function getNgModelAttr(attrs, bindings) {
  62. var ngModelAttrs = {};
  63. angular.forEach(attrs, function (attr) {
  64. ngModelAttrs[camelize(attr)] = {
  65. attribute: attr
  66. };
  67. });
  68. angular.forEach(bindings, function (binding) {
  69. ngModelAttrs[camelize(binding)] = {
  70. bound: binding
  71. };
  72. });
  73. return ngModelAttrs;
  74. }
  75. formlyConfigProvider.setWrapper({
  76. name: 'bootstrapLabel',
  77. templateUrl: 'assets/views/customform/tpl/normal-label.html'
  78. });
  79. //流程图
  80. formlyConfigProvider.setType({
  81. name: 'ui-process',
  82. templateUrl: 'assets/views/customform/tpl/cmdb/ui-process.html',
  83. defaultOptions: function (options) {
  84. return {
  85. templateOptions: {
  86. refresh: function () { },
  87. refreshDelay: 0
  88. }
  89. };
  90. },
  91. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  92. $scope.processdata = [];
  93. api_bpm_domain.flowTracing($scope.model.applicationForm.processInstanceId).then(function (data) {
  94. console.log(data)
  95. $scope.processdata = data.data;
  96. })
  97. }]
  98. });
  99. //出库单详情
  100. formlyConfigProvider.setType({
  101. name: 'ui-getoutinform',
  102. extends: 'radio',
  103. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getoutinform.html',
  104. defaultOptions: function (options) {
  105. return {
  106. templateOptions: {
  107. refresh: function () { },
  108. refreshDelay: 0
  109. }
  110. };
  111. },
  112. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  113. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  114. if ($scope.model.type.id = 0) {
  115. $scope.model.type.name = "新资产入库";
  116. } else if ($scope.model.type.id = 1) {
  117. $scope.model.type.name = "新设备领用出库";
  118. } else if ($scope.model.type.id = 2) {
  119. $scope.model.type.name = "资产归还";
  120. } else if ($scope.model.type.id = 4) {
  121. $scope.model.type.name = "设备更换";
  122. }
  123. }
  124. }]
  125. });
  126. //多选框组件
  127. formlyConfigProvider.setType({
  128. name: 'ui-checkboxmore',
  129. extends: 'radio',
  130. templateUrl: 'assets/views/customform/tpl/cmdb/ui-checkboxmore.html',
  131. defaultOptions: function (options) {
  132. return {
  133. templateOptions: {
  134. refresh: function () { },
  135. refreshDelay: 0
  136. }
  137. };
  138. },
  139. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  140. $scope.options.initialValue = $scope.model[$scope.options.key];
  141. }]
  142. });
  143. //入库单详情
  144. formlyConfigProvider.setType({
  145. name: 'ui-getininform',
  146. extends: 'radio',
  147. templateUrl: 'assets/views/customform/tpl/cmdb/ui-getininform.html',
  148. defaultOptions: function (options) {
  149. return {
  150. templateOptions: {
  151. refresh: function () { },
  152. refreshDelay: 0
  153. }
  154. };
  155. },
  156. controller: ['$scope', "$modal", "SweetAlert", "api_bpm_domain", function ($scope, $modal, SweetAlert, api_bpm_domain) {
  157. if (angular.isDefined($scope.model.type.id) && !$scope.model.type.name) {
  158. if ($scope.model.type.id = 0) {
  159. $scope.model.type.name = "新资产入库";
  160. } else if ($scope.model.type.id = 1) {
  161. $scope.model.type.name = "新设备领用出库";
  162. } else if ($scope.model.type.id = 2) {
  163. $scope.model.type.name = "资产归还";
  164. } else if ($scope.model.type.id = 4) {
  165. $scope.model.type.name = "设备更换";
  166. }
  167. }
  168. }]
  169. });
  170. //申请人详情
  171. formlyConfigProvider.setType({
  172. name: 'ui-requsterinfom',
  173. extends: 'radio',
  174. templateUrl: 'assets/views/customform/tpl/cmdb/requsterinfom.html',
  175. defaultOptions: function (options) {
  176. return {
  177. templateOptions: {
  178. refresh: function () { },
  179. refreshDelay: 0
  180. }
  181. };
  182. }
  183. });
  184. //设备耗材list组件
  185. formlyConfigProvider.setType({
  186. name: 'ui-uplodchange',
  187. templateUrl: 'assets/views/customform/tpl/cmdb/uplodchange.html',
  188. defaultOptions: function (options) {
  189. return {
  190. templateOptions: {
  191. refresh: function () { },
  192. refreshDelay: 0,
  193. view: function (APIService, contentId) {
  194. return APIService.downloadAttachment(contentId);
  195. }
  196. }
  197. };
  198. },
  199. controller: ['$scope', "$filter", "ngTableParams", '$rootScope', 'Restangular', function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  200. // var data = { "haodata": [], "shedata": [] };
  201. var haodata = [];
  202. var shedata = [];
  203. if ($scope.model.consumables) {
  204. if (angular.isArray($scope.model.consumables)) {
  205. haodata = $scope.model.consumables;
  206. } else {
  207. haodata = JSON.parse($scope.model.consumables);
  208. }
  209. $scope.model.consumables = haodata;
  210. angular.forEach(haodata, function (item, index) {
  211. haodata[index].item = index + 1;
  212. })
  213. }
  214. if ($scope.model.assets) {
  215. if (angular.isArray($scope.model.assets)) {
  216. shedata = $scope.model.assets;
  217. } else {
  218. shedata = JSON.parse($scope.model.assets);
  219. }
  220. $scope.model.assets = shedata;
  221. angular.forEach(shedata, function (item, index) {
  222. shedata[index].item = index + 1;
  223. })
  224. }
  225. $scope.tableParamshao = new ngTableParams({
  226. page: 1,
  227. count: 5
  228. }, {
  229. total: haodata.length,
  230. getData: function ($defer, params) {
  231. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  232. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  233. }
  234. });
  235. $scope.tableParamsshe = new ngTableParams({
  236. page: 1,
  237. count: 5
  238. }, {
  239. total: shedata.length,
  240. getData: function ($defer, params) {
  241. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  242. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  243. }
  244. });
  245. $scope.editId = -1;
  246. $scope.setEditId = function (pid) {
  247. $scope.editId = pid;
  248. };
  249. if (angular.isUndefined($scope.form.dropState)) {
  250. $scope.form.dropState = false;
  251. }
  252. var to = $scope.options.templateOptions;
  253. var bindId = $scope.model.processInstanceId;
  254. //获取附件列表
  255. $scope.listAttachmen = function () {
  256. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  257. var myData = Restangular.stripRestangular(result);
  258. // $scope.listAttachmens = myData;
  259. $scope.attachments = myData.data;
  260. });
  261. };
  262. $scope.listAttachmen();
  263. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  264. // $scope.listAttachmen();
  265. // } else if (to.bindType && $scope.model[to.bindType].id) {
  266. // $scope.listAttachmen();
  267. // }
  268. //附件下载
  269. $scope.download = function (token, filename) {
  270. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  271. // window.open(downUrl);
  272. var a = document.createElement('a');
  273. a.href = downUrl;
  274. a.target = '_blank';
  275. a.download = filename;
  276. document.body.appendChild(a);
  277. a.click();
  278. };
  279. //附件预览
  280. $scope.view = function (id, previewUrl) {
  281. if (previewUrl) {
  282. window.open(previewUrl);
  283. }
  284. };
  285. }]
  286. });
  287. //多选框组件
  288. formlyConfigProvider.setType({
  289. name: 'ui-nodataimage',
  290. templateUrl: 'assets/views/customform/tpl/cmdb/ui-nodataimage.html',
  291. defaultOptions: function (options) {
  292. return {
  293. templateOptions: {
  294. refresh: function () { },
  295. refreshDelay: 0
  296. }
  297. };
  298. }
  299. });
  300. //ui-grid list
  301. formlyConfigProvider.setType({
  302. name: "ui-gridtwolist",
  303. // extends: 'input',
  304. templateUrl: 'assets/views/customform/tpl/cmdb/gridtwolist.html',
  305. defaultOptions: function (options, $scope) {
  306. return {
  307. templateOptions: {}
  308. };
  309. },
  310. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  311. //gridone
  312. $scope.langs = i18nService.getAllLangs();
  313. $scope.lang = 'zh-cn';
  314. i18nService.setCurrentLang($scope.lang);
  315. $scope.gridOptions = {};
  316. $scope.gridOptions.data = 'myDatagrid';
  317. $scope.gridOptions.enableColumnResizing = true;
  318. $scope.gridOptions.enableFiltering = true;
  319. $scope.gridOptions.enableGridMenu = false;
  320. $scope.gridOptions.enableRowSelection = true;
  321. $scope.gridOptions.showGridFooter = true;
  322. $scope.gridOptions.showColumnFooter = false;
  323. $scope.gridOptions.fastWatch = true;
  324. $scope.gridOptions.useExternalFiltering = false;
  325. $scope.gridOptions.useExternalPagination = true;
  326. $scope.gridOptions.paginationPageSizes = [10];
  327. $scope.gridOptions.paginationPageSize = 10;
  328. $scope.gridOptions.multiSelect = false;
  329. $scope.myDatagrid = [];
  330. $scope.myDatagridall = [];
  331. $scope.selected = {
  332. item: {}
  333. };
  334. $scope.memoryfilterDatagrid = {
  335. idx: 0,
  336. sum: 10
  337. }
  338. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  339. filterData = {
  340. idx: 0,
  341. sum: 10
  342. };
  343. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  344. }
  345. $scope.gridOptions.rowIdentity = function (row) {
  346. return row.id;
  347. };
  348. $scope.gridOptions.getRowIdentity = function (row) {
  349. return row.id;
  350. };
  351. // $scope.gridOptions.columnDefs = items.columnDefs();
  352. $scope.interceptMydata = function (mydate, idx, sum) {
  353. return mydate.slice(idx * sum, (idx + 1) * sum)
  354. }
  355. $scope.gridOptions.onRegisterApi = function (gridApi) {
  356. $scope.gridApi = gridApi;
  357. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  358. $scope.memoryfilterDatagrid.idx = newPage - 1;
  359. $scope.memoryfilterDatagrid.sum = pageSize;
  360. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  361. $scope.loadData({
  362. "idx": newPage - 1,
  363. "sum": pageSize
  364. });
  365. });
  366. gridApi.core.on.filterChanged($scope, function () { });
  367. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  368. $scope.selected.item = data.entity;
  369. //console.log(data);
  370. });
  371. };
  372. $scope.loadData = function (mydate, idx, sum) {
  373. angular.forEach($scope.myDatagrid, function (item, index) {
  374. $scope.myDatagrid[index].item = index;
  375. })
  376. $scope.gridOptions.totalItems = mydate.length;
  377. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  378. }
  379. if ($scope.model.assets) {
  380. $scope.myDatagridall = $scope.model.assets;
  381. $scope.loadData($scope.model.assets, 0, 10)
  382. }
  383. $scope.saveData = function (itemin) {
  384. event.preventDefault();
  385. var modalInstance = $modal.open({
  386. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  387. controller: function ($scope, $modalInstance, SweetAlert) {
  388. // $scope.consumptive = {};
  389. $scope.title = "填写领用设备信息";
  390. // if (items.name) {
  391. // $scope.consumptive.name = items.name.name;
  392. // }
  393. $scope.placechange = angular.copy(itemin);
  394. $scope.ok = function (item) {
  395. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  396. $modalInstance.close(item);
  397. } else {
  398. SweetAlert.swal({
  399. title: "数据填写不完整!",
  400. text: "请检查数据然后提交!",
  401. type: "error"
  402. });
  403. }
  404. };
  405. $scope.cancel = function () {
  406. $modalInstance.dismiss('cancel');
  407. };
  408. },
  409. resolve: {
  410. SweetAlert: function () {
  411. return SweetAlert;
  412. }
  413. }
  414. });
  415. modalInstance.result.then(function (selectedItem) {
  416. angular.forEach($scope.myDatagrid, function (item, index) {
  417. // $scope.myDatagrid[index].props.hw_state = "在线";
  418. if (item.id == selectedItem.id) {
  419. // $scope.myDatagrid[index] = selectedItem;
  420. angular.extend($scope.myDatagrid[index], selectedItem)
  421. }
  422. })
  423. // $scope.myData3.push(selectedItem);
  424. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  425. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  426. }
  427. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  428. })
  429. }
  430. //gridtwo
  431. $scope.langs = i18nService.getAllLangs();
  432. $scope.lang = 'zh-cn';
  433. i18nService.setCurrentLang($scope.lang);
  434. $scope.gridOptions2 = {};
  435. $scope.gridOptions2.data = 'myDatagridold';
  436. $scope.gridOptions2.enableColumnResizing = true;
  437. $scope.gridOptions2.enableFiltering = true;
  438. $scope.gridOptions2.enableGridMenu = false;
  439. $scope.gridOptions2.enableRowSelection = true;
  440. $scope.gridOptions2.showGridFooter = true;
  441. $scope.gridOptions2.showColumnFooter = false;
  442. $scope.gridOptions2.fastWatch = true;
  443. $scope.gridOptions2.useExternalFiltering = false;
  444. $scope.gridOptions.useExternalPagination = true;
  445. $scope.gridOptions2.paginationPageSizes = [10];
  446. $scope.gridOptions2.paginationPageSize = 10;
  447. $scope.gridOptions2.multiSelect = false;
  448. $scope.myDatagridold = [];
  449. $scope.myDatagridoldall = [];
  450. $scope.selected = {
  451. item: {}
  452. };
  453. $scope.memoryfilterDatagridold = {
  454. idx: 0,
  455. sum: 10
  456. }
  457. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  458. filterData = {
  459. idx: 0,
  460. sum: 10
  461. };
  462. $scope.gridOptions2.columnDefs = $scope.options.templateOptions.columnDefstwo;
  463. }
  464. $scope.gridOptions2.rowIdentity = function (row) {
  465. return row.id;
  466. };
  467. $scope.gridOptions2.getRowIdentity = function (row) {
  468. return row.id;
  469. };
  470. // $scope.gridOptions.columnDefs = items.columnDefs();
  471. $scope.interceptMydata = function (mydate, idx, sum) {
  472. return mydate.slice(idx * sum, (idx + 1) * sum)
  473. }
  474. if ($scope.model.oldAssets) {
  475. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  476. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10);
  477. }
  478. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  479. $scope.gridApi = gridApi;
  480. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  481. $scope.memoryfilterDatagridold.idx = newPage - 1;
  482. $scope.memoryfilterDatagridold.sum = pageSize;
  483. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, 10)
  484. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  485. });
  486. gridApi.core.on.filterChanged($scope, function () { });
  487. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  488. $scope.selected.item = data.entity;
  489. //console.log(data);
  490. });
  491. };
  492. // $scope.loadData = function(mydate, idx, sum) {
  493. // angular.forEach($scope.myDatagridold, function(item, index) {
  494. // $scope.myDatagridold[index].item = index;
  495. // })
  496. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  497. // }
  498. // if ($scope.model.assets) {
  499. // $scope.myDatagridallold = $scope.model.assets;
  500. // $scope.loadData($scope.model.assets, 0, 10)
  501. // }
  502. // $scope.addoldassets = function(itemin) {
  503. // event.preventDefault();
  504. // var modalInstance = $modal.open({
  505. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  506. // controller: function($scope, $modalInstance, SweetAlert) {
  507. // // $scope.consumptive = {};
  508. // $scope.title = "填写领用设备信息";
  509. // // if (items.name) {
  510. // // $scope.consumptive.name = items.name.name;
  511. // // }
  512. // $scope.placechange = itemin;
  513. // $scope.ok = function(item) {
  514. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  515. // $modalInstance.close(item);
  516. // } else {
  517. // SweetAlert.swal({
  518. // title: "数据填写不完整!",
  519. // text: "请检查数据然后提交!",
  520. // type: "error"
  521. // });
  522. // }
  523. // };
  524. // $scope.cancel = function() {
  525. // $modalInstance.dismiss('cancel');
  526. // };
  527. // },
  528. // resolve: {
  529. // SweetAlert: function() {
  530. // return SweetAlert;
  531. // }
  532. // }
  533. // });
  534. $scope.interceptMydata = function (mydate, idx, sum) {
  535. return mydate.slice(idx * sum, (idx + 1) * sum)
  536. }
  537. $scope.addshebei = function () {
  538. event.preventDefault();
  539. var modalInstance = $modal.open({
  540. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  541. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form, api_cmdb) {
  542. $scope.langs = i18nService.getAllLangs();
  543. $scope.lang = 'zh-cn';
  544. i18nService.setCurrentLang($scope.lang);
  545. $scope.gridOptions = {};
  546. $scope.gridOptions.data = 'myDatatwo';
  547. $scope.gridOptions.enableColumnResizing = true;
  548. $scope.gridOptions.enableFiltering = false;
  549. $scope.gridOptions.enableGridMenu = false;
  550. $scope.gridOptions.showGridFooter = true;
  551. $scope.gridOptions.showColumnFooter = false;
  552. $scope.gridOptions.fastWatch = true;
  553. $scope.gridOptions.useExternalFiltering = true;
  554. $scope.gridOptions.useExternalPagination = true;
  555. $scope.gridOptions.paginationPageSizes = [10];
  556. $scope.gridOptions.paginationPageSize = 10;
  557. $scope.gridOptions.multiSelect = true;
  558. $scope.gridOptions.rowIdentity = function (row) {
  559. return row.id;
  560. };
  561. $scope.gridOptions.getRowIdentity = function (row) {
  562. return row.id;
  563. };
  564. $scope.gridOptions.columnDefs = [{
  565. name: 'item',
  566. displayName: '序号',
  567. width: 80,
  568. enableFiltering: false
  569. },
  570. {
  571. name: 'uuid',
  572. displayName: '内部编号',
  573. width: 150
  574. },
  575. {
  576. name: 'props.hw_mingcheng',
  577. displayName: '资产名称',
  578. width: 100
  579. },
  580. {
  581. name: 'props.hw_cifilterClassic',
  582. displayName: '资产类型',
  583. width: 120,
  584. enableFiltering: false
  585. },
  586. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  587. {
  588. name: 'props.hw_state',
  589. displayName: '资产状态',
  590. width: 150,
  591. enableFiltering: false
  592. },
  593. {
  594. name: 'props.hwnw_area',
  595. displayName: '资产地点',
  596. width: 130,
  597. enableFiltering: false
  598. },
  599. {
  600. name: 'createtime',
  601. displayName: '申请时间',
  602. enableFiltering: false
  603. }
  604. ];
  605. // $scope.selectButtonClick
  606. var defaultFilterData = {
  607. // "assignee":2,
  608. // "applicationForm": { "hw_state": "在线" },
  609. "hw_state": "在线",
  610. "idx": 0,
  611. "sum": 10
  612. };
  613. $scope.memoryfilterData = {
  614. // "assignee":2,
  615. // "applicationForm": { "hw_state": "在线" },
  616. "hw_state": "在线",
  617. "idx": 0,
  618. "sum": 10
  619. }
  620. $scope.refreshData = function (style, filterData) {
  621. if (angular.isUndefined(filterData)) {
  622. filterData = defaultFilterData;
  623. }
  624. $scope.myDatatwo = [];
  625. // $scope.gridOptions['sum']=filterData.sum;
  626. api_cmdb.query(filterData).then(function (data) {
  627. // $scope.callsPending--;
  628. var myDatatwo = Restangular.stripRestangular(data);
  629. $scope.gridOptions['totalItems'] = data.total;
  630. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  631. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  632. }
  633. $scope.myDatatwo = myDatatwo.data.node;
  634. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  635. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  636. }
  637. }, function () { });
  638. };
  639. $scope.refreshData('expand-right', defaultFilterData);
  640. $scope.gridOptions.onRegisterApi = function (gridApi) {
  641. $scope.gridApi = gridApi;
  642. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  643. var filtersData = $scope.memoryfilterData;
  644. filtersData.idx = newPage - 1;
  645. filtersData.sum = pageSize;
  646. // $scope.loadData(filtersData);
  647. $scope.refreshData('expand-right', filtersData);
  648. //console.log(pageSize);
  649. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  650. });
  651. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  652. // $scope.selected.items.push(data.entity);
  653. //console.log(data);
  654. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  655. if (scope.isSelected) {
  656. scope.grid.appScope.selected.items.push(scope.entity)
  657. } else {
  658. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  659. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  660. scope.grid.appScope.selected.items.splice(i, 1);
  661. break;
  662. }
  663. }
  664. }
  665. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  666. });
  667. // });
  668. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  669. // $scope.selected.items = data.entity;
  670. //console.log(data);
  671. var selectitem = [];
  672. selectitem = angular.copy($scope.selected.items);
  673. for (var j = 0; j < rows.length; j++) {
  674. if (rows[j].isSelected == true) {
  675. selectitem.push(rows[j].entity);
  676. } else {
  677. delete selectitem[j];
  678. // rows.splice(j, 1);
  679. }
  680. }
  681. $scope.selected.items = [];
  682. for (var i = 0; i < selectitem.length; i++) {
  683. if (selectitem[i]) {
  684. $scope.selected.items.push(selectitem[i]);
  685. }
  686. }
  687. });
  688. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  689. // // if (row.entity.age > 45) {
  690. // row.grid.api.selection.selectRow(row.entity); // 选中行
  691. // // }
  692. // };
  693. gridApi.core.on.filterChanged($scope, function () {
  694. var grid = this.grid;
  695. var filtersData = {
  696. idx: 0,
  697. sum: 10,
  698. "user": {
  699. "roledata": {
  700. "rolecode": "roleset"
  701. },
  702. "selectType": "1"
  703. }
  704. };
  705. angular.forEach(grid.columns, function (item) {
  706. if (item.enableFiltering) {
  707. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  708. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  709. if (angular.isUndefined(filtersData['user'])) {
  710. filtersData['user'] = {};
  711. }
  712. filtersData['user'][item.field] = item.filters[0].term;
  713. }
  714. }
  715. });
  716. $scope.memoryfilterData = filtersData;
  717. // $scope.loadData(filtersData);
  718. });
  719. };
  720. $scope.onDblClick = function (data, event) {
  721. // $scope.selected.items = data.entity;
  722. $scope.selectButtonClick(data, event);
  723. };
  724. $scope.title = title;
  725. //树形图
  726. var apple_selected, tree, treedata_avm, treedata_geography;
  727. $scope.my_tree_handler = function (branch) {
  728. //var _ref;
  729. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  730. api_cmdb.query({
  731. 'sign': classify
  732. }).then(function (data) {
  733. var myDatalingbei = Restangular.stripRestangular(data);
  734. // console.log(myData.data.node);
  735. if (myDatalingbei.data && myDatalingbei.status == 200) {
  736. var ret = myDatalingbei.data;
  737. redrawSvg(myDatalingbei);
  738. }
  739. });
  740. };
  741. $scope.my_data = [];
  742. function convertListToTree(data, treeMap) {
  743. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  744. var root = null; //Initially set our loop to null
  745. var parentNode = null;
  746. //loop over data
  747. for (var i = 0; i < data.length; i++) {
  748. var datum = data[i];
  749. //each node will have children, so let's give it a "children" poperty
  750. datum.children = [];
  751. //add an entry for this node to the map so that any future children can
  752. //lookup the parent
  753. idToNodeMap[datum.id] = datum;
  754. //Does this node have a parent?
  755. if (typeof datum.parent === "undefined" || datum.parent == null) {
  756. //Doesn't look like it, so this node is the root of the tree
  757. root = datum;
  758. treeMap[datum.id] = root;
  759. } else {
  760. //This node has a parent, so let's look it up using the id
  761. parentNode = idToNodeMap[datum.parent.id];
  762. //We don't need this property, so let's delete it.
  763. delete datum.parent;
  764. //Let's add the current node as a child of the parent node.
  765. parentNode.children.push(datum);
  766. }
  767. }
  768. return root;
  769. }
  770. function convertParentToChildList(data) {
  771. var treeMap = {};
  772. var list = [];
  773. convertListToTree(data, treeMap);
  774. angular.forEach(treeMap, function (item) {
  775. list.push(item);
  776. });
  777. return list;
  778. }
  779. $scope.my_tree = tree = {};
  780. $scope.try_async_load = function () {
  781. $scope.my_data = [];
  782. $scope.select_treedata = [];
  783. $scope.doing_async = true;
  784. api_configure_data.fetchDataList('ciclassify', {
  785. 'idx': 0,
  786. 'sum': 100
  787. }).then(function (result) {
  788. //console.log(result['list']);
  789. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  790. $scope.doing_async = false;
  791. // tree.expand_all();
  792. //console.log(treelist);
  793. });
  794. };
  795. $scope.select_treedata = [];
  796. $scope.propTypeOptions = [];
  797. $scope.try_async_load();
  798. $scope.onFilterremove = function (item) {
  799. console.log(item)
  800. }
  801. $scope.searchdata = {};
  802. $scope.clear = function () {
  803. $scope.searchdata = {};
  804. $scope.cifilter_classic = {};
  805. $scope.try_async_load();
  806. var fildata = {
  807. idx: 0,
  808. sum: 10,
  809. 'hw_state': '在线'
  810. }
  811. $scope.memoryfilterData = fildata;
  812. $scope.refreshData('expand-right', fildata);
  813. }
  814. $scope.chiceIncident = function (item) {
  815. var fildata = $scope.memoryfilterData;
  816. // fildata.applicationForm = {};
  817. // if (item.alltitle && item.alldata) {
  818. // fildata.applicationForm[item.alltitle.key] = item.alldata
  819. // }
  820. if (item && item.id) {
  821. var classify = item.prefix.toLowerCase() + item.sign;
  822. fildata.sign = classify
  823. }
  824. $scope.gridOptions.paginationCurrentPage = 1;
  825. var transitiondata = angular.copy(item);
  826. $scope.refreshData('expand-right', fildata);
  827. }
  828. $scope.applicadata = [];
  829. $scope.onFilterCallback = function (item) {
  830. var tempclassify = item.prefix.toLowerCase() + item.sign;
  831. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  832. var myData = Restangular.stripRestangular(data);
  833. $scope.applicadata = myData[0].form.fields;
  834. });
  835. // }
  836. }
  837. // $scope.loadData({
  838. // idx: 0,
  839. // sum: 10,
  840. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  841. // });
  842. $scope.selected = {
  843. items: []
  844. };
  845. $scope.ok = function () {
  846. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  847. // onDataCallback($scope.selected.item, parentScope);
  848. // }
  849. $modalInstance.close($scope.selected.items);
  850. };
  851. $scope.cancel = function () {
  852. $modalInstance.dismiss('cancel');
  853. };
  854. },
  855. size: 'lg',
  856. resolve: {
  857. items: function () {
  858. return {
  859. fetchItems: function (filterData, APIService) {
  860. filterData = filterData || {};
  861. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  862. filterData = {
  863. idx: 0,
  864. sum: 10,
  865. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  866. };
  867. }
  868. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  869. }
  870. };
  871. },
  872. title: function () {
  873. return $scope.options.templateOptions.label;
  874. },
  875. Restangular: function () {
  876. return $scope.options.templateOptions.Restangular;
  877. },
  878. APIService: function () {
  879. return $scope.options.templateOptions.ApiService;
  880. },
  881. onDataCallback: function () {
  882. return $scope.options.templateOptions.callback;
  883. },
  884. parentScope: function () {
  885. return $scope.options.templateOptions.that;
  886. }
  887. }
  888. });
  889. modalInstance.result.then(function (selectedItem) {
  890. $scope.myDatagridoldall = selectedItem;
  891. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  892. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  893. }
  894. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  895. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  896. // $scope.model.oldAssets = $scope.myDatagridoldall;
  897. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  898. $scope.options.initialValue = $scope.model.oldAssets;
  899. });
  900. // }
  901. }
  902. $scope.changestate = function (itemin) {
  903. event.preventDefault();
  904. var modalInstance = $modal.open({
  905. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldstate.html',
  906. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  907. $scope.title = '旧设备状态修改';
  908. $scope.stateshe = [{
  909. "id": 2,
  910. "name": "在库"
  911. }, {
  912. "id": 4,
  913. "name": "报修"
  914. }, {
  915. "id": 3,
  916. "name": "报废"
  917. }];
  918. $scope.hw_state = {};
  919. $scope.ok = function (item) {
  920. $modalInstance.close(item.id);
  921. };
  922. $scope.cancel = function () {
  923. $modalInstance.dismiss('cancel');
  924. };
  925. },
  926. size: 'sm',
  927. resolve: {
  928. scope: function () {
  929. return $scope;
  930. }
  931. }
  932. });
  933. modalInstance.result.then(function (selectedItem) {
  934. if (selectedItem) {
  935. angular.forEach($scope.myDatagridallold, function (item, index) {
  936. if (item.id == itemin.id) {
  937. $scope.myDatagridallold[index].props.hw_state = selectedItem.name;
  938. }
  939. })
  940. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  941. $scope.myDatagridallold[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  942. }
  943. $scope.gridOptions2['totalItems'] = $scope.myDatagridallold.length;
  944. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridallold, $scope.memoryfilterDatagridold.idx, $scope.memoryfilterDatagridold.sum)
  945. // $scope.model.oldAssets = $scope.myDatagridallold;
  946. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridallold;
  947. $scope.options.initialValue = $scope.model.oldAssets;
  948. }
  949. })
  950. }
  951. $scope.savedata = function (data) {
  952. event.preventDefault();
  953. var modalInstance = $modal.open({
  954. templateUrl: 'assets/views/customform/tpl/cmdb/changeoldshe.html',
  955. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  956. $scope.title = '设备编辑';
  957. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  958. $scope.ok = function (item) {
  959. $modalInstance.close(item);
  960. };
  961. $scope.cancel = function () {
  962. $modalInstance.dismiss('cancel');
  963. };
  964. },
  965. size: 'sm',
  966. resolve: {
  967. scope: function () {
  968. return $scope;
  969. }
  970. }
  971. });
  972. modalInstance.result.then(function (selectedItem) {
  973. if (selectedItem) {
  974. angular.forEach($scope.myDatagridoldall, function (item, index) {
  975. if (item.id == data.id) {
  976. $scope.myDatagridoldall[index].olddecription = selectedItem.olddecription;
  977. }
  978. })
  979. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  980. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  981. }
  982. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  983. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  984. // $scope.model.oldAssets = $scope.myDatagridoldall;
  985. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  986. $scope.options.initialValue = $scope.model.oldAssets;
  987. }
  988. })
  989. }
  990. $scope.removeold = function (data) {
  991. event.preventDefault();
  992. var modalInstance = $modal.open({
  993. templateUrl: 'assets/views/delete.html',
  994. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  995. $scope.title = '设备删除';
  996. $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  997. $scope.ok = function () {
  998. $modalInstance.close(data);
  999. };
  1000. $scope.cancel = function () {
  1001. $modalInstance.dismiss('cancel');
  1002. };
  1003. },
  1004. size: 'sm',
  1005. resolve: {
  1006. scope: function () {
  1007. return $scope;
  1008. }
  1009. }
  1010. });
  1011. modalInstance.result.then(function (selectedItem) {
  1012. if (selectedItem) {
  1013. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1014. if (item.id == selectedItem.id) {
  1015. $scope.myDatagridoldall.splice(index, 1);
  1016. }
  1017. })
  1018. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1019. $scope.myDatagridoldall[i]['item'] = i + 1 + $scope.memoryfilterDatagridold.idx * $scope.memoryfilterDatagridold.sum
  1020. }
  1021. $scope.gridOptions2['totalItems'] = $scope.myDatagridoldall.length;
  1022. $scope.myDatagridold = $scope.interceptMydata($scope.myDatagridoldall, 0, 10)
  1023. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1024. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets = $scope.myDatagridoldall;
  1025. $scope.options.initialValue = $scope.model.oldAssets;
  1026. }
  1027. })
  1028. }
  1029. }]
  1030. });
  1031. //ui-grid list
  1032. formlyConfigProvider.setType({
  1033. name: "ui-gridlist",
  1034. extends: 'input',
  1035. templateUrl: 'assets/views/customform/tpl/cmdb/gridlist.html',
  1036. defaultOptions: function (options, $scope) {
  1037. return {
  1038. templateOptions: {}
  1039. };
  1040. },
  1041. controller: ['$scope', "$modal", "i18nService", "SweetAlert", function ($scope, $modal, i18nService, SweetAlert) {
  1042. //gridone
  1043. $scope.langs = i18nService.getAllLangs();
  1044. $scope.lang = 'zh-cn';
  1045. i18nService.setCurrentLang($scope.lang);
  1046. $scope.gridOptions = {};
  1047. $scope.gridOptions.data = 'myDatagrid';
  1048. $scope.gridOptions.enableColumnResizing = true;
  1049. $scope.gridOptions.enableFiltering = true;
  1050. $scope.gridOptions.enableGridMenu = false;
  1051. $scope.gridOptions.enableRowSelection = true;
  1052. $scope.gridOptions.showGridFooter = true;
  1053. $scope.gridOptions.showColumnFooter = false;
  1054. $scope.gridOptions.fastWatch = true;
  1055. $scope.gridOptions.useExternalFiltering = false;
  1056. // $scope.gridOptions.useExternalPagination = true;
  1057. $scope.gridOptions.paginationPageSizes = [10];
  1058. $scope.gridOptions.paginationPageSize = 10;
  1059. $scope.gridOptions.multiSelect = false;
  1060. $scope.myDatagrid = [];
  1061. $scope.myDatagridall = [];
  1062. $scope.selected = {
  1063. item: {}
  1064. };
  1065. $scope.memoryfilterDatagrid = {
  1066. idx: 0,
  1067. sum: 10
  1068. }
  1069. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1070. filterData = {
  1071. idx: 0,
  1072. sum: 10
  1073. };
  1074. $scope.gridOptions.columnDefs = $scope.options.templateOptions.columnDefs;
  1075. }
  1076. $scope.gridOptions.rowIdentity = function (row) {
  1077. return row.id;
  1078. };
  1079. $scope.gridOptions.getRowIdentity = function (row) {
  1080. return row.id;
  1081. };
  1082. // $scope.gridOptions.columnDefs = items.columnDefs();
  1083. $scope.interceptMydata = function (mydate, idx, sum) {
  1084. return mydate.slice(idx * sum, (idx + 1) * sum)
  1085. }
  1086. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1087. $scope.gridApi = gridApi;
  1088. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1089. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1090. $scope.memoryfilterDatagrid.sum = pageSize;
  1091. $scope.myDatagrid = $scope.interceptMydata($scope.myDatagridall, $scope.memoryfilterDatagrid.idx, 10)
  1092. $scope.loadData({
  1093. "idx": newPage - 1,
  1094. "sum": pageSize
  1095. });
  1096. });
  1097. gridApi.core.on.filterChanged($scope, function () { });
  1098. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1099. $scope.selected.item = data.entity;
  1100. //console.log(data);
  1101. });
  1102. };
  1103. $scope.loadData = function (mydate, idx, sum) {
  1104. angular.forEach($scope.myDatagrid, function (item, index) {
  1105. $scope.myDatagrid[index].item = index;
  1106. })
  1107. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum)
  1108. }
  1109. if ($scope.model.assets) {
  1110. $scope.myDatagridall = $scope.model.assets;
  1111. $scope.loadData($scope.model.assets, 0, 10)
  1112. }
  1113. $scope.saveData = function (itemin) {
  1114. event.preventDefault();
  1115. var modalInstance = $modal.open({
  1116. templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  1117. controller: function ($scope, $modalInstance, SweetAlert) {
  1118. // $scope.consumptive = {};
  1119. $scope.title = "填写领用设备信息";
  1120. // if (items.name) {
  1121. // $scope.consumptive.name = items.name.name;
  1122. // }
  1123. $scope.placechange = angular.copy(itemin);
  1124. $scope.ok = function (item) {
  1125. if (item.props && item.props.hwnw_area && item.props.hwnw_place && item.props.hwnw_room && item.props.hwnwswt_jiguihao && item.props.hwnwswt_Ushu && item.props.snnum) {
  1126. $modalInstance.close(item);
  1127. } else {
  1128. SweetAlert.swal({
  1129. title: "数据填写不完整!",
  1130. text: "请检查数据然后提交!",
  1131. type: "error"
  1132. });
  1133. }
  1134. };
  1135. $scope.cancel = function () {
  1136. $modalInstance.dismiss('cancel');
  1137. };
  1138. },
  1139. resolve: {
  1140. SweetAlert: function () {
  1141. return SweetAlert;
  1142. }
  1143. }
  1144. });
  1145. modalInstance.result.then(function (selectedItem) {
  1146. angular.forEach($scope.myDatagrid, function (item, index) {
  1147. if (item.id == selectedItem.id) {
  1148. angular.extend($scope.myDatagrid[index], selectedItem)
  1149. }
  1150. })
  1151. // $scope.myData3.push(selectedItem);
  1152. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1153. $scope.myDatagrid[i]['item'] = i + 1 + $scope.memoryfilterDatagrid.idx * 10
  1154. }
  1155. // $scope.model.assets = $scope.myDatagridall;
  1156. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatagridall;
  1157. })
  1158. }
  1159. }]
  1160. });
  1161. //设备耗材list组件
  1162. formlyConfigProvider.setType({
  1163. name: 'ui-shehaolist',
  1164. // extends: 'radio',
  1165. templateUrl: 'assets/views/customform/tpl/cmdb/shehaolist.html',
  1166. defaultOptions: function (options) {
  1167. return {
  1168. templateOptions: {
  1169. refresh: function () { },
  1170. refreshDelay: 0
  1171. }
  1172. };
  1173. },
  1174. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1175. // var data = { "haodata": [], "shedata": [] };
  1176. var haodata = [];
  1177. var shedata = [];
  1178. if ($scope.model.consumables) {
  1179. if (angular.isArray($scope.model.consumables)) {
  1180. haodata = $scope.model.consumables;
  1181. } else {
  1182. haodata = JSON.parse($scope.model.consumables);
  1183. }
  1184. $scope.model.consumables = haodata;
  1185. angular.forEach(haodata, function (item, index) {
  1186. haodata[index].item = index + 1;
  1187. })
  1188. }
  1189. if ($scope.model.assets) {
  1190. if (angular.isArray($scope.model.assets)) {
  1191. shedata = $scope.model.assets;
  1192. } else {
  1193. shedata = JSON.parse($scope.model.assets);
  1194. }
  1195. $scope.model.assets = shedata;
  1196. angular.forEach(shedata, function (item, index) {
  1197. shedata[index].item = index + 1;
  1198. })
  1199. }
  1200. $scope.tableParamshao = new ngTableParams({
  1201. page: 1,
  1202. count: 5
  1203. }, {
  1204. total: haodata.length,
  1205. getData: function ($defer, params) {
  1206. var orderedData = params.sorting() ? $filter('orderBy')(haodata, params.orderBy()) : haodata;
  1207. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1208. }
  1209. });
  1210. $scope.tableParamsshe = new ngTableParams({
  1211. page: 1,
  1212. count: 5
  1213. }, {
  1214. total: shedata.length,
  1215. getData: function ($defer, params) {
  1216. var orderedData = params.sorting() ? $filter('orderBy')(shedata, params.orderBy()) : shedata;
  1217. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1218. }
  1219. });
  1220. $scope.editId = -1;
  1221. $scope.setEditId = function (pid) {
  1222. $scope.editId = pid;
  1223. };
  1224. if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "2") {
  1225. $scope.isAgree = "同意";
  1226. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "1") {
  1227. $scope.isAgree = "同意";
  1228. } else if ($scope.$parent.$parent.$parent.model.isAgree && $scope.$parent.$parent.$parent.model.isAgree == "3") {
  1229. $scope.isAgree = "返回修改";
  1230. }
  1231. }]
  1232. });
  1233. //关联资产出库
  1234. formlyConfigProvider.setType({
  1235. name: "ui-meansmodelselect",
  1236. extends: 'input',
  1237. templateUrl: 'assets/views/customform/tpl/cmdb/inputguanlina.html',
  1238. defaultOptions: function (options) {
  1239. return {
  1240. templateOptions: {}
  1241. };
  1242. },
  1243. controller: ['$scope', '$modal', function ($scope, $modal) {
  1244. $scope.openModal = function (size, options, modal) {
  1245. var modalInstance = $modal.open({
  1246. templateUrl: 'assets/views/customform/tpl/cmdb/guanlian.html',
  1247. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, api_user_data, i18nService, api_wechatfile) {
  1248. $scope.langs = i18nService.getAllLangs();
  1249. $scope.lang = 'zh-cn';
  1250. i18nService.setCurrentLang($scope.lang);
  1251. $scope.gridOptions = {};
  1252. $scope.gridOptions.data = 'myData';
  1253. $scope.gridOptions.enableColumnResizing = true;
  1254. $scope.gridOptions.enableFiltering = false;
  1255. $scope.gridOptions.enableGridMenu = false;
  1256. $scope.gridOptions.showGridFooter = true;
  1257. $scope.gridOptions.showColumnFooter = false;
  1258. $scope.gridOptions.fastWatch = true;
  1259. $scope.gridOptions.useExternalFiltering = true;
  1260. $scope.gridOptions.useExternalPagination = true;
  1261. $scope.gridOptions.paginationPageSizes = [10];
  1262. $scope.gridOptions.paginationPageSize = 10;
  1263. $scope.gridOptions.multiSelect = false;
  1264. $scope.gridOptions.rowIdentity = function (row) {
  1265. return row.id;
  1266. };
  1267. $scope.gridOptions.getRowIdentity = function (row) {
  1268. return row.id;
  1269. };
  1270. // $scope.states = [{
  1271. // id: 0,
  1272. // name: '待批准'
  1273. // },
  1274. // {
  1275. // id: 1,
  1276. // name: '已驳回'
  1277. // },
  1278. // {
  1279. // id: 2,
  1280. // name: '待出库'
  1281. // },
  1282. // {
  1283. // id: 3,
  1284. // name: '信息更新'
  1285. // },
  1286. // {
  1287. // id: 4,
  1288. // name: '信息确认'
  1289. // },
  1290. // {
  1291. // id: 5,
  1292. // name: '已关闭'
  1293. // }
  1294. // ];
  1295. $scope.getStatesDictionary = function () {
  1296. var data = {
  1297. "key": "applicationForm_status",
  1298. "type": "list"
  1299. }
  1300. api_wechatfile.getDictionary(data).then(function (res) {
  1301. $scope.states = res
  1302. })
  1303. };
  1304. $scope.getStatesDictionary();
  1305. $scope.type = [{
  1306. id: 1,
  1307. name: '资产入库'
  1308. },
  1309. {
  1310. id: 2,
  1311. name: '资产归还'
  1312. },
  1313. {
  1314. id: 3,
  1315. name: '资产领用'
  1316. },
  1317. {
  1318. id: 4,
  1319. name: '资产更换'
  1320. }
  1321. ];
  1322. $scope.typedata = function (row) {
  1323. if (row.type == 0) {
  1324. return "资产入库";
  1325. } else if (row.type == 2) {
  1326. return "资产归还";
  1327. } else if (row.type == 1) {
  1328. return "资产领用";
  1329. } else if (row.type == 4) {
  1330. return "资产更换";
  1331. }
  1332. };
  1333. $scope.statedata = function (row) {
  1334. if (row.status == 0) {
  1335. return "待批准";
  1336. } else if (row.status == 1) {
  1337. return "已驳回";
  1338. } else if (row.status == 2) {
  1339. return "待出库";
  1340. } else if (row.status == 3) {
  1341. return "信息更新";
  1342. } else if (row.status == 4) {
  1343. return "信息确认";
  1344. } else if (row.status == 5) {
  1345. return "已关闭";
  1346. }
  1347. };
  1348. $scope.transferTime = function (time) {
  1349. return moment(time).format('YYYY-MM-DD HH:mm');
  1350. }
  1351. $scope.application = [{
  1352. value: "serialNumbe",
  1353. name: '申请单编号'
  1354. },
  1355. // { value: "proposer", name: '申请人' },
  1356. {
  1357. value: "purpose",
  1358. name: '领用用途'
  1359. },
  1360. // { value: "cmdbsign", name: '设备编号' }
  1361. ];
  1362. $scope.parameters = null;
  1363. $scope.open = function ($event) {
  1364. $event.preventDefault();
  1365. $event.stopPropagation();
  1366. $scope.opened = !$scope.opened;
  1367. };
  1368. $scope.endOpen = function ($event) {
  1369. $event.preventDefault();
  1370. $event.stopPropagation();
  1371. $scope.startOpened = false;
  1372. $scope.endOpened = !$scope.endOpened;
  1373. };
  1374. $scope.startOpen = function ($event) {
  1375. $event.preventDefault();
  1376. $event.stopPropagation();
  1377. $scope.endOpened = false;
  1378. $scope.startOpened = !$scope.startOpened;
  1379. };
  1380. $scope.othcode = {};
  1381. $scope.searchkeys = {};
  1382. $scope.parameters = {};
  1383. $scope.memoryfilterData = {
  1384. "assignee": $rootScope.user.id,
  1385. "candidateGroups": $rootScope.user.group[0].id,
  1386. "searchType": "todo",
  1387. idx: 0,
  1388. sum: 10
  1389. }
  1390. $scope.clear = function () {
  1391. $scope.searchkeys = {};
  1392. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1393. // $scope.othcode = {};
  1394. $scope.parameters = {};
  1395. var fildata = {
  1396. "assignee": $rootScope.user.id,
  1397. "candidateGroups": $rootScope.user.group[0].id,
  1398. "searchType": "todo",
  1399. idx: 0,
  1400. sum: 10
  1401. }
  1402. // sessionStorage.removeItem("searchincident");
  1403. $scope.memoryfilterData = fildata;
  1404. $scope.loadData(fildata);
  1405. }
  1406. $scope.chiceIncident = function (parameters, item, stateid) {
  1407. var fildata = {
  1408. "assignee": $rootScope.user.id,
  1409. "candidateGroups": 1,
  1410. "searchType": "todo",
  1411. "idx": 0,
  1412. "sum": 10
  1413. };
  1414. if (item) {
  1415. fildata.applicationForm = {};
  1416. if (item.alltitle && item.alldata) {
  1417. fildata.applicationForm[item.alltitle.value] = item.alldata
  1418. }
  1419. if (item.linkProposer) {
  1420. fildata.applicationForm.linkProposer = item.linkProposer
  1421. }
  1422. if (item.proposer) {
  1423. fildata.applicationForm.proposer = item.proposer
  1424. }
  1425. if (item.status) {
  1426. fildata.applicationForm['status'] = {
  1427. id: item.status.id
  1428. };
  1429. }
  1430. if (item.type) {
  1431. fildata.applicationForm['type'] = {
  1432. id: item.type.id
  1433. };
  1434. }
  1435. }
  1436. $scope.gridOptions.paginationCurrentPage = 1;
  1437. if (parameters && parameters.paramDateFrom && parameters.paramDateTo) {
  1438. angular.extend(fildata, {
  1439. 'idx': 0,
  1440. 'sum': $scope.gridOptions.paginationPageSize
  1441. })
  1442. angular.extend(fildata.applicationForm, {
  1443. 'startDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'),
  1444. 'endDate': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59')
  1445. })
  1446. }
  1447. var transitiondata = angular.copy(item);
  1448. // angular.extend(fildata.applicationForm, transitiondata)
  1449. $scope.loadData(fildata);
  1450. }
  1451. $scope.key = {};
  1452. api_user_data.fetchDataList('user', {
  1453. "idx": 0,
  1454. "sum": 1000,
  1455. "flag": -1
  1456. }).then(function (data) {
  1457. $scope.handlingPersonnelUser = data.list;
  1458. });
  1459. $scope.gridOptions.columnDefs = items.columnDefs();
  1460. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1461. $scope.gridApi = gridApi;
  1462. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1463. // console.log(newPage);
  1464. // console.log(pageSize);
  1465. $scope.loadData({
  1466. "idx": newPage - 1,
  1467. "sum": pageSize
  1468. });
  1469. });
  1470. gridApi.core.on.filterChanged($scope, function () {
  1471. });
  1472. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1473. $scope.selected.item = data.entity;
  1474. //console.log(data);
  1475. });
  1476. };
  1477. $scope.loadData = function (filterData) {
  1478. items.fetchItems(filterData, APIService).then(function (data) {
  1479. var myData = Restangular.stripRestangular(data);
  1480. $scope.gridOptions.totalItems = myData.totalNum;
  1481. $scope.myData = myData.list;
  1482. for (var i = 0; i < $scope.myData.length; i++) {
  1483. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  1484. }
  1485. });
  1486. };
  1487. $scope.title = title;
  1488. $scope.loadData({
  1489. idx: 0,
  1490. sum: 10,
  1491. "assignee": $rootScope.user.id,
  1492. "candidateGroups": $rootScope.user.group[0].id,
  1493. "searchType": "todo",
  1494. });
  1495. $scope.selected = {
  1496. item: {}
  1497. };
  1498. $scope.ok = function () {
  1499. //console.log($scope.selected.item);
  1500. $modalInstance.close($scope.selected.item);
  1501. };
  1502. $scope.cancel = function () {
  1503. $modalInstance.dismiss('cancel');
  1504. };
  1505. },
  1506. size: 'lg',
  1507. resolve: {
  1508. items: function () {
  1509. return {
  1510. fetchItems: function (filterData, APIService) {
  1511. filterData = filterData || {};
  1512. // if(!filterData.idx){
  1513. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  1514. filterData = {
  1515. idx: 0,
  1516. sum: 10
  1517. };
  1518. }
  1519. return options.templateOptions.fetchItems(filterData, APIService, options);
  1520. },
  1521. columnDefs: function () {
  1522. return options.templateOptions.columnDefs;
  1523. }
  1524. };
  1525. },
  1526. title: function () {
  1527. return options.templateOptions.modalTitle;
  1528. },
  1529. Restangular: function () {
  1530. return options.templateOptions.Restangular;
  1531. },
  1532. APIService: function () {
  1533. return options.templateOptions.ApiService;
  1534. }
  1535. }
  1536. });
  1537. modalInstance.result.then(function (selectedItem) {
  1538. var selectitem = {
  1539. title: selectedItem.title,
  1540. description: selectedItem.description
  1541. }
  1542. if (options.key == "chuku") {
  1543. if (selectedItem.assets) {
  1544. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  1545. }
  1546. if (selectedItem.consumables) {
  1547. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  1548. }
  1549. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  1550. options.value(selectedItem);
  1551. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1552. } else {
  1553. angular.extend(options.model, selectitem);
  1554. options.value(selectedItem);
  1555. }
  1556. }, function () {
  1557. //console.log('Modal dismissed at: ' + new Date());
  1558. });
  1559. }
  1560. }]
  1561. });
  1562. //文本框
  1563. formlyConfigProvider.setType({
  1564. name: 'ui-textcmdb',
  1565. extends: '',
  1566. templateUrl: 'assets/views/customform/tpl/cmdb/ui-textcmdb.html',
  1567. defaultOptions: function (options) {
  1568. return {
  1569. templateOptions: {
  1570. transform: function (model, value) {
  1571. return value;
  1572. },
  1573. },
  1574. validation: {
  1575. messages: {
  1576. maxlength: function (viewValue, modelValue, scope) {
  1577. if (viewValue != null) {
  1578. if (viewValue.length > scope.to.maxlength) {
  1579. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  1580. } else {
  1581. return "";
  1582. }
  1583. }
  1584. },
  1585. }
  1586. }
  1587. }
  1588. },
  1589. controller: ['$scope', function ($scope) {
  1590. var value = $scope.model[$scope.options.key];
  1591. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1592. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  1593. }
  1594. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1595. $scope.options.templateOptions.felditem($scope);
  1596. }
  1597. }]
  1598. });
  1599. //设备组件
  1600. formlyConfigProvider.setType({
  1601. name: 'ui-applist',
  1602. extends: 'radio',
  1603. templateUrl: 'assets/views/customform/tpl/cmdb/applist.html',
  1604. defaultOptions: function (options) {
  1605. return {
  1606. templateOptions: {
  1607. refresh: function () { },
  1608. refreshDelay: 0
  1609. }
  1610. };
  1611. },
  1612. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1613. var data = [];
  1614. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1615. // data = JSON.parse($scope.model.consumables);
  1616. if (angular.isArray($scope.model.consumables)) {
  1617. data = $scope.model.consumables;
  1618. } else {
  1619. data = JSON.parse($scope.model.consumables);
  1620. }
  1621. $scope.model.consumables = data;
  1622. angular.forEach(data, function (item, index) {
  1623. data[index].item = index + 1;
  1624. })
  1625. }
  1626. if ($scope.model.assets && $scope.options.key == "assets") {
  1627. if (angular.isArray($scope.model.assets)) {
  1628. data = $scope.model.assets;
  1629. } else {
  1630. data = JSON.parse($scope.model.assets);
  1631. }
  1632. // data = JSON.parse($scope.model.assets);
  1633. $scope.model.assets = data;
  1634. angular.forEach(data, function (item, index) {
  1635. data[index].item = index + 1;
  1636. })
  1637. }
  1638. $scope.tableParams = new ngTableParams({
  1639. page: 1,
  1640. count: 5
  1641. }, {
  1642. total: data.length,
  1643. getData: function ($defer, params) {
  1644. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1645. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1646. }
  1647. });
  1648. $scope.editId = -1;
  1649. $scope.setEditId = function (pid) {
  1650. $scope.editId = pid;
  1651. };
  1652. }]
  1653. });
  1654. //list组件
  1655. formlyConfigProvider.setType({
  1656. name: 'ui-gudinglist',
  1657. extends: 'radio',
  1658. templateUrl: 'assets/views/customform/tpl/cmdb/gudinglist.html',
  1659. defaultOptions: function (options) {
  1660. return {
  1661. templateOptions: {
  1662. refresh: function () { },
  1663. refreshDelay: 0
  1664. }
  1665. };
  1666. },
  1667. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1668. var data = [];
  1669. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1670. // data = JSON.parse($scope.model.consumables);
  1671. if (angular.isArray($scope.model.consumables)) {
  1672. data = $scope.model.consumables;
  1673. } else {
  1674. data = JSON.parse($scope.model.consumables);
  1675. }
  1676. $scope.model.consumables = data;
  1677. angular.forEach(data, function (item, index) {
  1678. data[index].item = index + 1;
  1679. })
  1680. }
  1681. if ($scope.model.assets && $scope.options.key == "assets") {
  1682. if (angular.isArray($scope.model.assets)) {
  1683. data = $scope.model.assets;
  1684. } else {
  1685. data = JSON.parse($scope.model.assets);
  1686. }
  1687. // data = JSON.parse($scope.model.assets);
  1688. $scope.model.assets = data;
  1689. angular.forEach(data, function (item, index) {
  1690. data[index].item = index + 1;
  1691. })
  1692. }
  1693. $scope.tableParams = new ngTableParams({
  1694. page: 1,
  1695. count: 5
  1696. }, {
  1697. total: data.length,
  1698. getData: function ($defer, params) {
  1699. var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
  1700. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1701. }
  1702. });
  1703. $scope.editId = -1;
  1704. $scope.setEditId = function (pid) {
  1705. $scope.editId = pid;
  1706. };
  1707. }]
  1708. });
  1709. //other list tab组件
  1710. formlyConfigProvider.setType({
  1711. name: 'ui-otherlisttab',
  1712. extends: '',
  1713. templateUrl: 'assets/views/customform/tpl/cmdb/otherlisttab.html',
  1714. defaultOptions: function (options) {
  1715. return {
  1716. templateOptions: {
  1717. refresh: function () { },
  1718. refreshDelay: 0
  1719. }
  1720. };
  1721. },
  1722. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1723. }]
  1724. });
  1725. //审核查看组件
  1726. formlyConfigProvider.setType({
  1727. name: 'ui-aprovelist',
  1728. extends: '',
  1729. templateUrl: 'assets/views/customform/tpl/cmdb/aprovelist.html',
  1730. defaultOptions: function (options) {
  1731. return {
  1732. templateOptions: {
  1733. refresh: function () { },
  1734. refreshDelay: 0
  1735. }
  1736. };
  1737. },
  1738. controller: ['$scope', "$filter", "ngTableParams", function ($scope, $filter, ngTableParams) {
  1739. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  1740. $scope.isAgree = "同意";
  1741. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  1742. $scope.isAgree = "同意";
  1743. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  1744. $scope.isAgree = "返回修改";
  1745. }
  1746. }]
  1747. });
  1748. //other list组件
  1749. formlyConfigProvider.setType({
  1750. name: 'ui-otherlist',
  1751. extends: '',
  1752. templateUrl: 'assets/views/customform/tpl/cmdb/otherlist.html',
  1753. defaultOptions: function (options) {
  1754. return {
  1755. templateOptions: {
  1756. refresh: function () { },
  1757. refreshDelay: 0
  1758. }
  1759. };
  1760. },
  1761. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  1762. console.log("哈哈");
  1763. console.log($scope);
  1764. $scope.langs = i18nService.getAllLangs();
  1765. $scope.lang = 'zh-cn';
  1766. i18nService.setCurrentLang($scope.lang);
  1767. var vm = this;
  1768. vm.options = {};
  1769. vm.exampleTitle = ['expressionProperties', 'model property'];
  1770. vm.fields = [];
  1771. vm.models = {};
  1772. // vm.models["loginUser"] = $rootScope.user;
  1773. var that = $injector;
  1774. var parse = $parse;
  1775. var formKey = "";
  1776. var pdKey = "";
  1777. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  1778. pdKey = $state.current.pdKey;
  1779. //console.log("pdKey::"+$state.current.pdKey);
  1780. }
  1781. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  1782. formKey = $stateParams.formKey;
  1783. //console.log("formKey::"+$stateParams.formKey);
  1784. }
  1785. //用户测试数据,后续从header的auth中获取
  1786. var userId = 2;
  1787. userId = $rootScope.user.id;
  1788. //==============处理表单设计数据 开始====================
  1789. //处理组件加载后台数据选项的方法
  1790. function refreshSelectOptions(searchVal, field) {
  1791. if (field.templateOptions.optionsUrl) {
  1792. var process = BpmRestangular.all("");
  1793. if (field.templateOptions.ApiService) {
  1794. process = UserRestangular.all("");
  1795. }
  1796. process.customPOST({
  1797. "idx": 0,
  1798. "sum": 1000
  1799. }, field.templateOptions.optionsUrl).then(function (result) {
  1800. if (!field.templateOptions.options) {
  1801. field.templateOptions.options = [];
  1802. }
  1803. if (field.templateOptions.optionsDataKey) {
  1804. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  1805. } else {
  1806. field.templateOptions.options = result;
  1807. }
  1808. });
  1809. }
  1810. }
  1811. function decodeVMTabForm(model, tabs) {
  1812. var result = {
  1813. model: {},
  1814. tabs: []
  1815. };
  1816. var mdata = angular.fromJson(model);
  1817. angular.extend(result.model, mdata);
  1818. angular.forEach(tabs, function (tab) {
  1819. tab.form.model = vm.models;
  1820. angular.forEach(tab.form.fields, function (field) {
  1821. if (field.key == "") {
  1822. delete field.key;
  1823. }
  1824. field.type = "ui-otherlisttab";
  1825. if (angular.isDefined(field.extjson) && field.extjson != "") {
  1826. var extObj = angular.fromJson(field.extjson);
  1827. angular.extend(field.templateOptions, extObj.templateOptions);
  1828. delete extObj.templateOptions;
  1829. for (var prop in extObj) {
  1830. if (new RegExp("Expression").test(prop)) {
  1831. //var obj = $scope.$eval(extObj[prop]);
  1832. //extObj[prop] = $scope.$eval(extObj[prop]);
  1833. if (extObj[prop] != null) {
  1834. if (new RegExp("function").test(extObj[prop])) {
  1835. var propValue = eval(extObj[prop]);
  1836. extObj[prop] = propValue;
  1837. } else {
  1838. //console.log(extObj[prop]);
  1839. var obj = $scope.$eval(extObj[prop]);
  1840. extObj[prop] = obj;
  1841. //console.log(obj);
  1842. }
  1843. }
  1844. } else if (new RegExp("expressionProperties").test(prop)) {
  1845. for (var p in extObj[prop]) {
  1846. if (new RegExp("function").test(extObj[prop][p])) {
  1847. var propValue = eval(extObj[prop][p]);
  1848. extObj[prop][p] = propValue;
  1849. } else {
  1850. //if(p.indexOf("'")>=0){
  1851. // var obj = $scope.$eval(extObj[prop][p]);
  1852. // extObj[prop][$scope.$eval(p)]=obj;
  1853. //}
  1854. }
  1855. }
  1856. } else if ("watcher" == prop) {
  1857. if (angular.isArray(extObj[prop])) {
  1858. angular.forEach(extObj[prop], function (item, index) {
  1859. for (var p in item) {
  1860. if (new RegExp("function").test(item[p])) {
  1861. var propValue = eval(item[p]);
  1862. extObj[prop][index][p] = propValue;
  1863. }
  1864. }
  1865. });
  1866. } else if (angular.isObject(extObj[prop])) {
  1867. for (var p in extObj[prop]) {
  1868. if (new RegExp("function").test(extObj[prop][p])) {
  1869. var propValue = eval(extObj[prop][p]);
  1870. extObj[prop][p] = propValue;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. }
  1876. angular.extend(field, extObj);
  1877. delete field.extjson;
  1878. }
  1879. if (field.extjson == "") {
  1880. delete field.extjson;
  1881. }
  1882. if (angular.isDefined(field.templateOptions)) {
  1883. var templateOs = field.templateOptions;
  1884. for (var property in templateOs) {
  1885. //console.log(property);
  1886. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  1887. if (new RegExp("function").test(templateOs[property])) {
  1888. var propValue = eval(templateOs[property]);
  1889. field.templateOptions[property] = propValue;
  1890. } else {
  1891. if (that.has(templateOs[property])) {
  1892. field.templateOptions[property] = that.get(templateOs[property]);
  1893. } else {
  1894. field.templateOptions[property] = templateOs[property];
  1895. }
  1896. }
  1897. } else if (templateOs[property] == null) {
  1898. //delete field.templateOptions[property];
  1899. } else { }
  1900. }
  1901. }
  1902. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  1903. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  1904. angular.extend(field.templateOptions, extObj);
  1905. delete field.templateOptions.extjson;
  1906. }
  1907. //...
  1908. if (field.templateOptions) {
  1909. //处理远程获取数据控件方法调用
  1910. if (field.templateOptions.optionsUrl) {
  1911. field.templateOptions.refresh = refreshSelectOptions;
  1912. }
  1913. //处理嵌套属性数据绑定/
  1914. if (field.templateOptions.pkey) {
  1915. var pmodel, i = 0;
  1916. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  1917. if (i == 0) {
  1918. if (result.model[p] == null) {
  1919. result.model[p] = {};
  1920. }
  1921. pmodel = result.model[p];
  1922. i++;
  1923. } else {
  1924. if (pmodel[p] == null) {
  1925. pmodel[p] = {};
  1926. }
  1927. pmodel = pmodel[p];
  1928. }
  1929. });
  1930. if (pmodel != null) {
  1931. field.model = pmodel;
  1932. if (pmodel[field.key] == null) {
  1933. pmodel[field.key] = null;
  1934. }
  1935. }
  1936. } else {
  1937. if (result.model[field.key] == null) {
  1938. result.model[field.key] = null;
  1939. }
  1940. }
  1941. //处理弹出框组件初始化
  1942. if (field.type == "ui-input-selectmodal") {
  1943. field.templateOptions.modal = $modal;
  1944. //field.templateOptions.Restangular = Restangular;
  1945. } else if (field.type == "ui-userselect") {
  1946. field.templateOptions.modal = $modal;
  1947. //field.templateOptions.Restangular = Restangular;
  1948. } else if (field.type == "ui-multiuserselect") {
  1949. field.templateOptions.modal = $modal;
  1950. } else if (field.type == "ui-modelselect") {
  1951. field.templateOptions.modal = $modal;
  1952. //field.templateOptions.Restangular = Restangular;
  1953. } else if (field.type == "ui-cmdbuplode") {
  1954. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  1955. url: '/uploader',
  1956. queueLimit: 1, //文件个数
  1957. autoUpload: true
  1958. });
  1959. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  1960. } else if (field.type == "ui-dropfile") {
  1961. field.templateOptions.fileUploader = new FileUploader({
  1962. url: '/uploader'
  1963. });
  1964. field.templateOptions.taskId = $stateParams.taskId;
  1965. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1966. field.templateOptions.userId = $rootScope.user.id;
  1967. //field.ApiService=api_bpm_domain;
  1968. } else if (field.type == "ui-dropfiletable") {
  1969. if (field.templateOptions.processInstanceId) {
  1970. } else {
  1971. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  1972. }
  1973. } else if (field.type == "ui-repeatSection") {
  1974. var repeatForm = {
  1975. model: {
  1976. },
  1977. fields: field.templateOptions.fields
  1978. };
  1979. repeatForm.model[field.key] = [];
  1980. decodeVMTabForm(repeatForm);
  1981. }
  1982. }
  1983. // console.log(field);
  1984. //field
  1985. //result.fields.push(field);
  1986. })
  1987. });
  1988. vm.originalTabs = angular.copy(vm.form);
  1989. }
  1990. //======================处理表单设计数据 结束========================
  1991. $scope.ldloading = {};
  1992. function filter(obj) {
  1993. angular.forEach(obj, function (key, value) {
  1994. if (value === "" || value === null) {
  1995. delete obj[key];
  1996. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1997. filter(value);
  1998. } else if (angular.isArray(value)) {
  1999. angular.forEach(value, function (item) {
  2000. filter(item);
  2001. });
  2002. }
  2003. });
  2004. }
  2005. function invokeOnAllFormOptions(fn) {
  2006. angular.forEach(vm.tabs, function (tab) {
  2007. if (tab.form.options && tab.form.options[fn]) {
  2008. tab.form.options[fn]();
  2009. }
  2010. });
  2011. }
  2012. function encodeCIData(data, ciId) {
  2013. /*
  2014. create/update state:未审核
  2015. create createtime:系统时间
  2016. create/update lastupdatetime : 系统时间
  2017. label:ci分类
  2018. */
  2019. if (ciId) {
  2020. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2021. var extraprop = 'props';
  2022. data[extraprop] = {};
  2023. for (var key in data) {
  2024. console.log(data[key]);
  2025. if (_.indexOf(baseprop, key) >= 0) {
  2026. continue;
  2027. } else {
  2028. data[extraprop][key] = data[key];
  2029. delete data[key];
  2030. }
  2031. }
  2032. if ($rootScope.user) {
  2033. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2034. data[extraprop]['configperson'] = $rootScope.user.name;
  2035. var isCMAdminFlag = false;
  2036. angular.forEach($rootScope.user.role, function (roleItem) {
  2037. if (roleItem.rolecode == "cmdb charge") {
  2038. isCMAdminFlag = true;
  2039. }
  2040. })
  2041. if (!isCMAdminFlag) {
  2042. data[extraprop]['state'] = '1';
  2043. }
  2044. }
  2045. if (data.props.id) {
  2046. } else {
  2047. data.label = ciId;
  2048. }
  2049. return data;
  2050. }
  2051. return undefined;
  2052. }
  2053. function decodeCIModel(data) {
  2054. var extraprop = 'props';
  2055. if (data[extraprop]) {
  2056. for (var key in data[extraprop]) {
  2057. data[key] = data[extraprop][key];
  2058. }
  2059. delete data[extraprop];
  2060. }
  2061. data['iscmadmin'] = false;
  2062. angular.forEach($rootScope.user.role, function (roleItem) {
  2063. if (roleItem.rolecode == "cmdb charge") {
  2064. data['iscmadmin'] = true;
  2065. }
  2066. })
  2067. return data;
  2068. }
  2069. function formValid() {
  2070. angular.forEach(vm.tabs, function (item) {
  2071. //item.
  2072. })
  2073. }
  2074. $scope.vm = vm;
  2075. $scope.refreshcmdbform = function (item) {
  2076. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2077. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2078. var myData = Restangular.stripRestangular(data);
  2079. $scope.propTypeOptions = myData;
  2080. $scope.templateProps = myData;
  2081. $scope.vm.tabs = myData;
  2082. if ($scope.model.assets) {
  2083. vm.models = JSON.parse($scope.model.assets);
  2084. }
  2085. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2086. if (vm.models.vtvmvtm_kaiji) {
  2087. vm.models.vtvmvtm_kaiji = "是";
  2088. } else {
  2089. vm.models.vtvmvtm_kaiji = "否";
  2090. }
  2091. }
  2092. decodeVMTabForm(vm.models, vm.tabs);
  2093. });
  2094. // }
  2095. }
  2096. var cifilterClassic = {};
  2097. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2098. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2099. $scope.refreshcmdbform($scope.$parent.$parent.$parent.model.cifilterClassic);
  2100. // } else {}
  2101. }]
  2102. });
  2103. //固定资产下载
  2104. formlyConfigProvider.setType({
  2105. name: 'ui-dropupload',
  2106. templateUrl: 'assets/views/customform/tpl/cmdb/upload.html',
  2107. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  2108. defaultOptions: function (options) {
  2109. return {
  2110. templateOptions: {
  2111. view: function (APIService, contentId) {
  2112. return APIService.downloadAttachment(contentId);
  2113. },
  2114. },
  2115. };
  2116. },
  2117. controller: ['$scope', '$rootScope', 'Restangular', function ($scope, $rootScope, Restangular) {
  2118. if (angular.isUndefined($scope.form.dropState)) {
  2119. $scope.form.dropState = false;
  2120. }
  2121. var to = $scope.options.templateOptions;
  2122. var bindId = $scope.model[to.bindType].processInstanceId;
  2123. //获取附件列表
  2124. $scope.listAttachmen = function () {
  2125. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  2126. var myData = Restangular.stripRestangular(result);
  2127. // $scope.listAttachmens = myData;
  2128. $scope.attachments = myData.data;
  2129. });
  2130. };
  2131. $scope.listAttachmen();
  2132. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2133. // $scope.listAttachmen();
  2134. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2135. // $scope.listAttachmen();
  2136. // }
  2137. //附件下载
  2138. $scope.download = function (token, filename) {
  2139. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  2140. var a = document.createElement('a');
  2141. a.href = downUrl;
  2142. a.target = '_blank';
  2143. a.download = filename;
  2144. document.body.appendChild(a);
  2145. a.click();
  2146. };
  2147. //附件预览
  2148. $scope.view = function (id, previewUrl) {
  2149. if (previewUrl) {
  2150. window.open(previewUrl);
  2151. }
  2152. };
  2153. }]
  2154. });
  2155. formlyConfigProvider.setType({
  2156. name: 'ui-form',
  2157. templateUrl: 'assets/views/customform/tpl/ui-cmdbform.html',
  2158. defaultOptions: function (options) {
  2159. return {
  2160. templateOptions: {
  2161. // link: function() {}
  2162. }
  2163. };
  2164. },
  2165. controller: ['$rootScope', '$scope', '$parse', '$injector', '$http', '$q', '$state', '$stateParams', '$modal', '$timeout', '$interval', 'i18nService', 'SweetAlert', 'FileUploader', 'Restangular', 'UserRestangular', 'BpmRestangular', 'api_configure_form', 'api_configure_data', 'api_bpm_domain', 'api_bpm_data', 'api_user_data', 'api_cmdb', 'api_sysinfo', function ($rootScope, $scope, $parse, $injector, $http, $q, $state, $stateParams, $modal, $timeout, $interval, i18nService, SweetAlert, FileUploader, Restangular, UserRestangular, BpmRestangular, api_configure_form, api_configure_data, api_bpm_domain, api_bpm_data, api_user_data, api_cmdb, api_sysinfo) {
  2166. $scope.langs = i18nService.getAllLangs();
  2167. $scope.lang = 'zh-cn';
  2168. i18nService.setCurrentLang($scope.lang);
  2169. var vm = this;
  2170. vm.options = {};
  2171. vm.exampleTitle = ['expressionProperties', 'model property'];
  2172. vm.fields = [];
  2173. vm.models = {};
  2174. // vm.models["loginUser"] = $rootScope.user;
  2175. var that = $injector;
  2176. var parse = $parse;
  2177. var formKey = "";
  2178. var pdKey = "";
  2179. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  2180. pdKey = $state.current.pdKey;
  2181. //console.log("pdKey::"+$state.current.pdKey);
  2182. }
  2183. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2184. formKey = $stateParams.formKey;
  2185. //console.log("formKey::"+$stateParams.formKey);
  2186. }
  2187. //用户测试数据,后续从header的auth中获取
  2188. var userId = 2;
  2189. userId = $rootScope.user.id;
  2190. //==============处理表单设计数据 开始====================
  2191. //处理组件加载后台数据选项的方法
  2192. function refreshSelectOptions(searchVal, field) {
  2193. if (field.templateOptions.optionsUrl) {
  2194. var process = BpmRestangular.all("");
  2195. if (field.templateOptions.ApiService) {
  2196. process = UserRestangular.all("");
  2197. }
  2198. process.customPOST({
  2199. "idx": 0,
  2200. "sum": 1000
  2201. }, field.templateOptions.optionsUrl).then(function (result) {
  2202. if (!field.templateOptions.options) {
  2203. field.templateOptions.options = [];
  2204. }
  2205. if (field.templateOptions.optionsDataKey) {
  2206. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  2207. } else {
  2208. field.templateOptions.options = result;
  2209. }
  2210. });
  2211. }
  2212. }
  2213. function decodeVMTabForm(model, tabs) {
  2214. var result = {
  2215. model: {},
  2216. tabs: []
  2217. };
  2218. var mdata = angular.fromJson(model);
  2219. angular.extend(result.model, mdata);
  2220. angular.forEach(tabs, function (tab) {
  2221. tab.form.model = vm.models;
  2222. angular.forEach(tab.form.fields, function (field) {
  2223. if (field.key == "") {
  2224. delete field.key;
  2225. }
  2226. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2227. var extObj = angular.fromJson(field.extjson);
  2228. angular.extend(field.templateOptions, extObj.templateOptions);
  2229. delete extObj.templateOptions;
  2230. for (var prop in extObj) {
  2231. if (new RegExp("Expression").test(prop)) {
  2232. //var obj = $scope.$eval(extObj[prop]);
  2233. //extObj[prop] = $scope.$eval(extObj[prop]);
  2234. if (extObj[prop] != null) {
  2235. if (new RegExp("function").test(extObj[prop])) {
  2236. var propValue = eval(extObj[prop]);
  2237. extObj[prop] = propValue;
  2238. } else {
  2239. //console.log(extObj[prop]);
  2240. var obj = $scope.$eval(extObj[prop]);
  2241. extObj[prop] = obj;
  2242. //console.log(obj);
  2243. }
  2244. }
  2245. } else if (new RegExp("expressionProperties").test(prop)) {
  2246. for (var p in extObj[prop]) {
  2247. if (new RegExp("function").test(extObj[prop][p])) {
  2248. var propValue = eval(extObj[prop][p]);
  2249. extObj[prop][p] = propValue;
  2250. } else {
  2251. //if(p.indexOf("'")>=0){
  2252. // var obj = $scope.$eval(extObj[prop][p]);
  2253. // extObj[prop][$scope.$eval(p)]=obj;
  2254. //}
  2255. }
  2256. }
  2257. } else if ("watcher" == prop) {
  2258. if (angular.isArray(extObj[prop])) {
  2259. angular.forEach(extObj[prop], function (item, index) {
  2260. for (var p in item) {
  2261. if (new RegExp("function").test(item[p])) {
  2262. var propValue = eval(item[p]);
  2263. extObj[prop][index][p] = propValue;
  2264. }
  2265. }
  2266. });
  2267. } else if (angular.isObject(extObj[prop])) {
  2268. for (var p in extObj[prop]) {
  2269. if (new RegExp("function").test(extObj[prop][p])) {
  2270. var propValue = eval(extObj[prop][p]);
  2271. extObj[prop][p] = propValue;
  2272. }
  2273. }
  2274. }
  2275. }
  2276. }
  2277. angular.extend(field, extObj);
  2278. delete field.extjson;
  2279. }
  2280. if (field.extjson == "") {
  2281. delete field.extjson;
  2282. }
  2283. if (angular.isDefined(field.templateOptions)) {
  2284. var templateOs = field.templateOptions;
  2285. for (var property in templateOs) {
  2286. //console.log(property);
  2287. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2288. if (new RegExp("function").test(templateOs[property])) {
  2289. var propValue = eval(templateOs[property]);
  2290. field.templateOptions[property] = propValue;
  2291. } else {
  2292. if (that.has(templateOs[property])) {
  2293. field.templateOptions[property] = that.get(templateOs[property]);
  2294. } else {
  2295. field.templateOptions[property] = templateOs[property];
  2296. }
  2297. }
  2298. } else if (templateOs[property] == null) {
  2299. //delete field.templateOptions[property];
  2300. } else { }
  2301. }
  2302. }
  2303. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2304. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2305. angular.extend(field.templateOptions, extObj);
  2306. delete field.templateOptions.extjson;
  2307. }
  2308. //...
  2309. if (field.templateOptions) {
  2310. //处理远程获取数据控件方法调用
  2311. if (field.templateOptions.optionsUrl) {
  2312. field.templateOptions.refresh = refreshSelectOptions;
  2313. }
  2314. //处理嵌套属性数据绑定/
  2315. if (field.templateOptions.pkey) {
  2316. var pmodel, i = 0;
  2317. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2318. if (i == 0) {
  2319. if (result.model[p] == null) {
  2320. result.model[p] = {};
  2321. }
  2322. pmodel = result.model[p];
  2323. i++;
  2324. } else {
  2325. if (pmodel[p] == null) {
  2326. pmodel[p] = {};
  2327. }
  2328. pmodel = pmodel[p];
  2329. }
  2330. });
  2331. if (pmodel != null) {
  2332. field.model = pmodel;
  2333. if (pmodel[field.key] == null) {
  2334. pmodel[field.key] = null;
  2335. }
  2336. }
  2337. } else {
  2338. if (result.model[field.key] == null) {
  2339. result.model[field.key] = null;
  2340. }
  2341. }
  2342. //处理弹出框组件初始化
  2343. if (field.type == "ui-input-selectmodal") {
  2344. field.templateOptions.modal = $modal;
  2345. //field.templateOptions.Restangular = Restangular;
  2346. } else if (field.type == "ui-userselect") {
  2347. field.templateOptions.modal = $modal;
  2348. //field.templateOptions.Restangular = Restangular;
  2349. } else if (field.type == "ui-multiuserselect") {
  2350. field.templateOptions.modal = $modal;
  2351. } else if (field.type == "ui-modelselect") {
  2352. field.templateOptions.modal = $modal;
  2353. //field.templateOptions.Restangular = Restangular;
  2354. } else if (field.type == "ui-dropfile") {
  2355. field.templateOptions.fileUploader = new FileUploader({
  2356. url: '/uploader'
  2357. });
  2358. field.templateOptions.taskId = $stateParams.taskId;
  2359. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2360. field.templateOptions.userId = $rootScope.user.id;
  2361. //field.ApiService=api_bpm_domain;
  2362. // }else if (field.type == "ui-uploadFile") {
  2363. // field.templateOptions.fileUploader = new FileUploader({
  2364. // url: '/uploader'
  2365. // });
  2366. // field.templateOptions.taskId = $stateParams.taskId;
  2367. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2368. // field.templateOptions.userId = $rootScope.user.id;
  2369. //field.ApiService=api_bpm_domain;
  2370. } else if (field.type == "ui-dropfiletable") {
  2371. if (field.templateOptions.processInstanceId) {
  2372. } else {
  2373. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2374. }
  2375. } else if (field.type == "ui-dropFiles") {
  2376. if (field.templateOptions.processInstanceId) {
  2377. } else {
  2378. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2379. }
  2380. } else if (field.type == "ui-showImgs") {
  2381. if (field.templateOptions.processInstanceId) {
  2382. } else {
  2383. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2384. }
  2385. } else if (field.type == "ui-repeatSection") {
  2386. var repeatForm = {
  2387. model: {
  2388. },
  2389. fields: field.templateOptions.fields
  2390. };
  2391. repeatForm.model[field.key] = [];
  2392. decodeVMTabForm(repeatForm);
  2393. }
  2394. }
  2395. // console.log(field);
  2396. //field
  2397. //result.fields.push(field);
  2398. })
  2399. });
  2400. vm.originalTabs = angular.copy(vm.form);
  2401. }
  2402. //解析自定义表单设计数据
  2403. function decodeVMForm(vmForm) {
  2404. var result = {
  2405. model: {},
  2406. tabs: []
  2407. };
  2408. //设置模型实体数据 begin
  2409. // var mdata = vmForm.model;
  2410. //解析数据实体
  2411. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2412. angular.extend(result.model, mdata);
  2413. //设置模型实体数据 end
  2414. //解析设计数据生成表单项 begin
  2415. var fields = [];
  2416. //处理修改设计数据中展示设置
  2417. angular.forEach(vmForm.tabs, function (field) {
  2418. if (field.key == "") {
  2419. delete field.key;
  2420. }
  2421. if (angular.isDefined(field.extjson)) {
  2422. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2423. angular.extend(field.templateOptions, extObj.templateOptions);
  2424. delete extObj.templateOptions;
  2425. for (var prop in extObj) {
  2426. if (new RegExp("Expression").test(prop)) {
  2427. //var obj = $scope.$eval(extObj[prop]);
  2428. //extObj[prop] = $scope.$eval(extObj[prop]);
  2429. if (extObj[prop] != null) {
  2430. if (new RegExp("function").test(extObj[prop])) {
  2431. var propValue = eval(extObj[prop]);
  2432. extObj[prop] = propValue;
  2433. } else {
  2434. //console.log(extObj[prop]);
  2435. var obj = $scope.$eval(extObj[prop]);
  2436. extObj[prop] = obj;
  2437. //console.log(obj);
  2438. }
  2439. }
  2440. } else if (new RegExp("expressionProperties").test(prop)) {
  2441. for (var p in extObj[prop]) {
  2442. if (new RegExp("function").test(extObj[prop][p])) {
  2443. var propValue = eval(extObj[prop][p]);
  2444. extObj[prop][p] = propValue;
  2445. } else {
  2446. //if(p.indexOf("'")>=0){
  2447. // var obj = $scope.$eval(extObj[prop][p]);
  2448. // extObj[prop][$scope.$eval(p)]=obj;
  2449. //}
  2450. }
  2451. }
  2452. } else if ("watcher" == prop) {
  2453. if (angular.isArray(extObj[prop])) {
  2454. angular.forEach(extObj[prop], function (item, index) {
  2455. for (var p in item) {
  2456. if (new RegExp("function").test(item[p])) {
  2457. var propValue = eval(item[p]);
  2458. extObj[prop][index][p] = propValue;
  2459. }
  2460. }
  2461. });
  2462. } else if (angular.isObject(extObj[prop])) {
  2463. for (var p in extObj[prop]) {
  2464. if (new RegExp("function").test(extObj[prop][p])) {
  2465. var propValue = eval(extObj[prop][p]);
  2466. extObj[prop][p] = propValue;
  2467. }
  2468. }
  2469. }
  2470. }
  2471. }
  2472. angular.extend(field, extObj);
  2473. delete field.extjson;
  2474. }
  2475. if (angular.isDefined(field.templateOptions)) {
  2476. var templateOs = field.templateOptions;
  2477. for (var property in templateOs) {
  2478. //console.log(property);
  2479. if (angular.isString(templateOs[property]) && !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))) {
  2480. if (new RegExp("function").test(templateOs[property])) {
  2481. var propValue = eval(templateOs[property]);
  2482. field.templateOptions[property] = propValue;
  2483. } else {
  2484. if (that.has(templateOs[property])) {
  2485. field.templateOptions[property] = that.get(templateOs[property]);
  2486. } else {
  2487. field.templateOptions[property] = templateOs[property];
  2488. }
  2489. }
  2490. } else if (templateOs[property] == null) {
  2491. //delete field.templateOptions[property];
  2492. } else { }
  2493. }
  2494. }
  2495. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  2496. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2497. angular.extend(field.templateOptions, extObj);
  2498. delete field.templateOptions.extjson;
  2499. }
  2500. //...
  2501. if (field.templateOptions) {
  2502. //处理远程获取数据控件方法调用
  2503. if (field.templateOptions.optionsUrl) {
  2504. field.templateOptions.refresh = refreshSelectOptions;
  2505. }
  2506. //处理嵌套属性数据绑定/
  2507. if (field.templateOptions.pkey) {
  2508. var pmodel, i = 0;
  2509. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  2510. if (i == 0) {
  2511. if (result.model[p] == null) {
  2512. result.model[p] = {};
  2513. }
  2514. pmodel = result.model[p];
  2515. i++;
  2516. } else {
  2517. if (pmodel[p] == null) {
  2518. pmodel[p] = {};
  2519. }
  2520. pmodel = pmodel[p];
  2521. }
  2522. });
  2523. if (pmodel != null) {
  2524. field.model = pmodel;
  2525. if (pmodel[field.key] == null) {
  2526. pmodel[field.key] = null;
  2527. }
  2528. }
  2529. } else {
  2530. if (result.model[field.key] == null) {
  2531. result.model[field.key] = null;
  2532. }
  2533. }
  2534. //处理弹出框组件初始化
  2535. if (field.type == "ui-input-selectmodal") {
  2536. field.templateOptions.modal = $modal;
  2537. //field.templateOptions.Restangular = Restangular;
  2538. } else if (field.type == "ui-userselect") {
  2539. field.templateOptions.modal = $modal;
  2540. //field.templateOptions.Restangular = Restangular;
  2541. } else if (field.type == "ui-multiuserselect") {
  2542. field.templateOptions.modal = $modal;
  2543. } else if (field.type == "ui-modelselect") {
  2544. field.templateOptions.modal = $modal;
  2545. //field.templateOptions.Restangular = Restangular;
  2546. } else if (field.type == "ui-dropfile") {
  2547. field.templateOptions.fileUploader = new FileUploader({
  2548. url: '/uploader'
  2549. });
  2550. field.templateOptions.taskId = $stateParams.taskId;
  2551. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2552. field.templateOptions.userId = $rootScope.user.id;
  2553. //field.ApiService=api_bpm_domain;
  2554. } else if (field.type == "ui-dropfiletable") {
  2555. if (field.templateOptions.processInstanceId) {
  2556. } else {
  2557. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2558. }
  2559. } else if (field.type == "ui-dropFiles") {
  2560. if (field.templateOptions.processInstanceId) {
  2561. } else {
  2562. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2563. }
  2564. } else if (field.type == "ui-showImgs") {
  2565. if (field.templateOptions.processInstanceId) {
  2566. } else {
  2567. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2568. }
  2569. } else if (field.type == "ui-repeatSection") {
  2570. var repeatForm = {
  2571. model: {
  2572. },
  2573. fields: field.templateOptions.fields
  2574. };
  2575. repeatForm.model[field.key] = [];
  2576. decodeVMForm(repeatForm);
  2577. }
  2578. }
  2579. // console.log(field);
  2580. result.fields.push(field);
  2581. });
  2582. angular.extend($scope.vm.fields, result.fields);
  2583. angular.extend($scope.vm.models, result.model);
  2584. $scope.formData = vmForm;
  2585. //console.log($scope.vm);
  2586. //解析设计数据生成表单项 end
  2587. return result;
  2588. }
  2589. //======================处理表单设计数据 结束========================
  2590. $scope.ldloading = {};
  2591. function filter(obj) {
  2592. angular.forEach(obj, function (key, value) {
  2593. if (value === "" || value === null) {
  2594. delete obj[key];
  2595. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  2596. filter(value);
  2597. } else if (angular.isArray(value)) {
  2598. angular.forEach(value, function (item) {
  2599. filter(item);
  2600. });
  2601. }
  2602. });
  2603. }
  2604. function invokeOnAllFormOptions(fn) {
  2605. angular.forEach(vm.tabs, function (tab) {
  2606. if (tab.form.options && tab.form.options[fn]) {
  2607. tab.form.options[fn]();
  2608. }
  2609. });
  2610. }
  2611. function encodeCIData(data, ciId) {
  2612. /*
  2613. create/update state:未审核
  2614. create createtime:系统时间
  2615. create/update lastupdatetime : 系统时间
  2616. label:ci分类
  2617. */
  2618. if (ciId) {
  2619. var baseprop = ['uuid', 'name', 'type', 'label', 'status', 'createtime', 'lastupdatetime', 'props']; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2620. var extraprop = 'props';
  2621. data[extraprop] = {};
  2622. for (var key in data) {
  2623. console.log(data[key]);
  2624. if (_.indexOf(baseprop, key) >= 0) {
  2625. continue;
  2626. } else {
  2627. data[extraprop][key] = data[key];
  2628. delete data[key];
  2629. }
  2630. }
  2631. if ($rootScope.user) {
  2632. data[extraprop]['lastupdateperson'] = $rootScope.user.name;
  2633. data[extraprop]['configperson'] = $rootScope.user.name;
  2634. var isCMAdminFlag = false;
  2635. angular.forEach($rootScope.user.role, function (roleItem) {
  2636. if (roleItem.rolecode == "cmdb charge") {
  2637. isCMAdminFlag = true;
  2638. }
  2639. })
  2640. if (!isCMAdminFlag) {
  2641. data[extraprop]['state'] = '1';
  2642. }
  2643. }
  2644. if (data.props.id) {
  2645. } else {
  2646. data.label = ciId;
  2647. }
  2648. return data;
  2649. }
  2650. return undefined;
  2651. }
  2652. function decodeCIModel(data) {
  2653. var extraprop = 'props';
  2654. if (data[extraprop]) {
  2655. for (var key in data[extraprop]) {
  2656. data[key] = data[extraprop][key];
  2657. }
  2658. delete data[extraprop];
  2659. }
  2660. data['iscmadmin'] = false;
  2661. angular.forEach($rootScope.user.role, function (roleItem) {
  2662. if (roleItem.rolecode == "cmdb charge") {
  2663. data['iscmadmin'] = true;
  2664. }
  2665. })
  2666. return data;
  2667. }
  2668. vm.remove = function (data, style) {
  2669. $scope.ldloading[style.replace('-', '_')] = true;
  2670. var modalInstance = $modal.open({
  2671. templateUrl: 'assets/views/delete.html',
  2672. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  2673. var cidata = {
  2674. label: data.label,
  2675. id: data.id,
  2676. uuid: data.uuid,
  2677. name: data.name,
  2678. props: {}
  2679. };
  2680. if (cidata.id) {
  2681. cidata.props['removeflag'] = true;
  2682. cidata.props['lastupdateperson'] = vm.models.loginUser;
  2683. $scope.ok = function () {
  2684. $modalInstance.close(cidata);
  2685. };
  2686. $scope.cancel = function () {
  2687. $modalInstance.dismiss('cancel');
  2688. };
  2689. }
  2690. },
  2691. size: 'sm',
  2692. resolve: {
  2693. scope: function () {
  2694. return $scope;
  2695. }
  2696. }
  2697. });
  2698. modalInstance.result.then(function (selectedItem) {
  2699. if (selectedItem) {
  2700. // if (selectedItem.length > 0) {
  2701. api_cmdb.put(selectedItem, selectedItem.id).then(function (response) {
  2702. if (response) {
  2703. var resData = Restangular.stripRestangular(response);
  2704. SweetAlert.swal({
  2705. title: "删除成功!",
  2706. confirmButtonColor: "#007AFF"
  2707. }, function () {
  2708. $state.go("app.means.list");
  2709. // $scope.refreshform();
  2710. // reinitTabForm($scope.classify);
  2711. });
  2712. } else {
  2713. SweetAlert.swal({
  2714. title: "系统错误",
  2715. text: "系统错误,请稍后重试!",
  2716. type: "error",
  2717. confirmButtonColor: "#DD6B55"
  2718. });
  2719. }
  2720. $scope.ldloading[style.replace('-', '_')] = false;
  2721. });
  2722. }
  2723. })
  2724. }
  2725. function formValid() {
  2726. angular.forEach(vm.tabs, function (item) {
  2727. //item.
  2728. })
  2729. }
  2730. $scope.closeModel = function () {
  2731. console.log($stateParams);
  2732. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  2733. if ($stateParams.formKey == "means_editor" || $stateParams.formKey == "means_edit") {
  2734. $state.go('app.means.list', {});
  2735. }
  2736. event.preventDefault();
  2737. }
  2738. }
  2739. // setInterval(function() {
  2740. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  2741. // cifilter_classic = $scope.model.cifilter_classic;
  2742. // $scope.refreshcmdbform(cifilter_classic);
  2743. // } else {}
  2744. // }, 100);
  2745. vm.models = (function filter(obj) {
  2746. var filtered = _.pick(obj, function (v) {
  2747. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2748. });
  2749. return _.cloneDeep(filtered, function (v) {
  2750. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2751. });
  2752. })(vm.models);
  2753. // setInterval(function() {
  2754. // if ($scope.model.type == 0) {
  2755. // $scope.model[$scope.options.key] = vm.models;
  2756. // }
  2757. // }, 100);
  2758. setInterval(function () {
  2759. if (vm.form && vm.form.$$parentForm.$valid) {
  2760. if ($scope.$parent && $scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model) {
  2761. vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2762. $scope.model[$scope.options.key] = vm.models;
  2763. }
  2764. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  2765. // $scope.model[$scope.options.key] = vm.models;
  2766. }
  2767. }, 100);
  2768. vm.submit = function (data, ciId, templateitem, style) {
  2769. // $scope.ldloading[style.replace('-', '_')] = true;
  2770. console.log(vm.form.$$parentForm.$valid);
  2771. if (vm.form.$$parentForm.$valid) {
  2772. invokeOnAllFormOptions('updateInitialValue');
  2773. //alert(JSON.stringify(vm.model), null, 2);
  2774. //vm.options.updateInitialValue();
  2775. //console.log(vm.model);
  2776. var cidata = encodeCIData(vm.models, ciId);
  2777. if (cidata) {
  2778. //var cidata = ;
  2779. if (cidata.props.id) {
  2780. //修改
  2781. api_cmdb.put(cidata, ciId).then(function (response) {
  2782. if (response) {
  2783. var resData = Restangular.stripRestangular(response);
  2784. SweetAlert.swal({
  2785. title: "保存成功!",
  2786. confirmButtonColor: "#007AFF"
  2787. }, function () {
  2788. $scope.ldloading[style.replace('-', '_')] = false;
  2789. // $scope.refreshform();
  2790. $state.go("app.means.list");
  2791. });
  2792. } else {
  2793. SweetAlert.swal({
  2794. title: "系统错误",
  2795. text: "系统错误,请稍后重试!",
  2796. type: "error",
  2797. confirmButtonColor: "#DD6B55"
  2798. });
  2799. }
  2800. $scope.ldloading[style.replace('-', '_')] = false;
  2801. });
  2802. } else {
  2803. //新建
  2804. var type = 2;
  2805. api_sysinfo.getSerialnumber(type, templateitem.id).then(function (data) {
  2806. if (data && data.status == 200) {
  2807. cidata.uuid = data.uuid;
  2808. api_cmdb.create(cidata).then(function (response) {
  2809. if (response) {
  2810. var resData = Restangular.stripRestangular(response);
  2811. SweetAlert.swal({
  2812. title: "保存成功!",
  2813. text: "内部编号:" + cidata.uuid,
  2814. confirmButtonColor: "#007AFF"
  2815. }, function () {
  2816. $state.go("app.means.list");
  2817. });
  2818. // if(resData.status){
  2819. // resData
  2820. // }
  2821. } else {
  2822. SweetAlert.swal({
  2823. title: "系统错误",
  2824. text: "系统错误,请稍后重试!",
  2825. type: "error",
  2826. confirmButtonColor: "#DD6B55"
  2827. });
  2828. }
  2829. $scope.ldloading[style.replace('-', '_')] = false;
  2830. });
  2831. } else {
  2832. SweetAlert.swal({
  2833. title: "系统错误",
  2834. text: "内部编号生成出错!",
  2835. type: "error",
  2836. confirmButtonColor: "#DD6B55"
  2837. });
  2838. }
  2839. })
  2840. }
  2841. } else {
  2842. SweetAlert.swal({
  2843. title: "错误",
  2844. text: "错误,请选择资产分类!",
  2845. type: "error",
  2846. confirmButtonColor: "#DD6B55"
  2847. });
  2848. }
  2849. //alert(JSON.stringify(cidata), null, 2);
  2850. $scope.ldloading[style.replace('-', '_')] = true;
  2851. return;
  2852. var _ = window._;
  2853. vm.models = (function filter(obj) {
  2854. var filtered = _.pick(obj, function (v) {
  2855. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  2856. });
  2857. return _.cloneDeep(filtered, function (v) {
  2858. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  2859. });
  2860. })(vm.models);
  2861. } else {
  2862. if (vm.form.$$parentForm.$error) {
  2863. SweetAlert.swal({
  2864. title: "校验错误",
  2865. text: "请填写必填项!",
  2866. type: "error",
  2867. confirmButtonColor: "#DD6B55"
  2868. });
  2869. angular.forEach(vm.form.$$parentForm.$error.required, function (item) {
  2870. angular.forEach(vm.tabs, function (tab) {
  2871. angular.forEach(tab.form.fields, function (f) {
  2872. if (f.name == item.$name) {
  2873. f.validation.show = true;
  2874. tab.active = true;
  2875. }
  2876. })
  2877. })
  2878. });
  2879. $scope.ldloading[style.replace('-', '_')] = false;
  2880. }
  2881. }
  2882. };
  2883. $scope.vm = vm;
  2884. $scope.refreshcmdbform = function (item) {
  2885. // if ($stateParams.model) {
  2886. // var modeldata = JSON.parse($stateParams.model)
  2887. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2888. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2889. var myData = Restangular.stripRestangular(data);
  2890. $scope.propTypeOptions = myData;
  2891. $scope.templateProps = myData;
  2892. $scope.vm.tabs = myData;
  2893. if ($scope.model.asset && $scope.model.asset.length != "") {
  2894. vm.models = JSON.parse($scope.model.asset);
  2895. }
  2896. decodeVMTabForm(vm.models, vm.tabs);
  2897. });
  2898. // }
  2899. }
  2900. var cifilterClassic = {};
  2901. setInterval(function () {
  2902. if ($scope.$parent.$parent && $scope.$parent.$parent.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2903. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  2904. cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2905. $scope.refreshcmdbform(cifilterClassic);
  2906. } else { }
  2907. }, 100);
  2908. }]
  2909. });
  2910. //请求人信息
  2911. formlyConfigProvider.setType({
  2912. name: 'ui-cmdbinformation',
  2913. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbinformation.html',
  2914. wrapper: ['bootstrapHasError'],
  2915. defaultOptions: function (options, $scope) {
  2916. return {
  2917. templateOptions: {
  2918. // checkform: function(options) {
  2919. // if (options.model.requester) {
  2920. // options.value(options.model.requester);
  2921. // }
  2922. // },
  2923. }
  2924. };
  2925. },
  2926. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2927. if ($scope.options.templateOptions.loginUser) {
  2928. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key].id) {
  2929. } else {
  2930. $scope.model[$scope.options.key] = $scope.options.templateOptions.loginUser;
  2931. }
  2932. $scope.options.initialValue = $scope.model[$scope.options.key];
  2933. }
  2934. }]
  2935. });
  2936. //资产属性
  2937. formlyConfigProvider.setType({
  2938. name: 'ui-cmdbtype',
  2939. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtype.html',
  2940. wrapper: ['bootstrapHasError'],
  2941. defaultOptions: function (options, $scope) {
  2942. return {
  2943. templateOptions: {
  2944. // checkform: function(options) {
  2945. // if (options.model.requester) {
  2946. // options.value(options.model.requester);
  2947. // }
  2948. // },
  2949. }
  2950. };
  2951. },
  2952. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2953. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2954. $scope.property = {
  2955. 'hw_change': $scope.to.loginUser,
  2956. 'hw_updata': moment(new Date()).format('YYYY-MM-DD hh:mm:ss'),
  2957. 'hw_createtime': moment(new Date()).format('YYYY-MM-DD hh:mm:ss')
  2958. }
  2959. if ($scope.$parent.$parent.$parent.model.assets) {
  2960. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  2961. }
  2962. }]
  2963. });
  2964. //申请单信息
  2965. formlyConfigProvider.setType({
  2966. name: 'ui-cmdbformimform',
  2967. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbformimform.html',
  2968. wrapper: ['bootstrapHasError'],
  2969. defaultOptions: function (options, $scope) {
  2970. return {
  2971. templateOptions: {
  2972. // checkform: function(options) {
  2973. // if (options.model.requester) {
  2974. // options.value(options.model.requester);
  2975. // }
  2976. // },
  2977. }
  2978. };
  2979. },
  2980. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  2981. // $scope.options.initialValue = $scope.model[$scope.options.key];
  2982. $scope.getininform = {
  2983. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  2984. time: $scope.$parent.$parent.$parent.model.applicationForm.time
  2985. };
  2986. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  2987. $scope.getininform.types = "新资产入库";
  2988. } else if ($scope.$parent.$parent.$parent.model.applicationForm.type == 2) {
  2989. $scope.getininform.types = "资产归还";
  2990. }
  2991. }]
  2992. });
  2993. //出库单信息
  2994. formlyConfigProvider.setType({
  2995. name: 'ui-outinformation',
  2996. templateUrl: 'assets/views/customform/tpl/cmdb/outinformation.html',
  2997. wrapper: ['bootstrapHasError'],
  2998. defaultOptions: function (options, $scope) {
  2999. return {
  3000. templateOptions: {
  3001. // checkform: function(options) {
  3002. // if (options.model.requester) {
  3003. // options.value(options.model.requester);
  3004. // }
  3005. // },
  3006. }
  3007. };
  3008. },
  3009. controller: ['$scope', 'api_user_data', function ($scope, api_user_data) {
  3010. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3011. $scope.getininform = {
  3012. serialNumbe: $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3013. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3014. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3015. sourceId: $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3016. describe: $scope.$parent.$parent.$parent.model.applicationForm.describe
  3017. };
  3018. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3019. $scope.getininform.types = "新设备领用出库";
  3020. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3021. $scope.getininform.types = "设备更换";
  3022. }
  3023. $scope.getininform.source_id = $scope.$parent.$parent.$parent.model.source.value;
  3024. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3025. $scope.getininform.source = "事件";
  3026. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3027. $scope.getininform.source = "变更";
  3028. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3029. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3030. $scope.getininform.source = "其它";
  3031. }
  3032. }]
  3033. });
  3034. //资产附件上传
  3035. formlyConfigProvider.setType({
  3036. name: 'ui-cmdbuplode',
  3037. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbuplode.html',
  3038. wrapper: ['bootstrapHasError'],
  3039. defaultOptions: function (options, $scope) {
  3040. return {
  3041. templateOptions: {
  3042. // checkform: function(options) {
  3043. // if (options.model.requester) {
  3044. // options.value(options.model.requester);
  3045. // }
  3046. // },
  3047. }
  3048. };
  3049. },
  3050. controller: ['$scope', '$rootScope', '$http', 'SweetAlert', 'FileUploader', 'api_user_data', 'i18nService', '$modal', 'Restangular', 'api_configure_data', 'api_cmdb', 'api_cmdb_new', 'api_wechatfile', 'api_sysinfo', function ($scope, $rootScope, $http, SweetAlert, FileUploader, api_user_data, i18nService, $modal, Restangular, api_configure_data, api_cmdb, api_cmdb_new, api_wechatfile, api_sysinfo) {
  3051. $scope.state = 1;
  3052. $scope.myData3all = [];
  3053. $scope.myData3 = [];
  3054. $scope.memoryfilterDatahao = {
  3055. "idx": 0,
  3056. "sum": 10,
  3057. }
  3058. $scope.selected = {
  3059. items: []
  3060. };
  3061. $scope.interceptMydata = function (mydate, idx, sum) {
  3062. return mydate.slice(idx * sum, (idx + 1) * sum)
  3063. }
  3064. // $scope.importnext = function() {
  3065. // $scope.state = 2;
  3066. // event.preventDefault();
  3067. // }
  3068. $scope.workspaces = [];
  3069. $scope.options.templateOptions.getpush = function (item) {
  3070. $scope.workspaces = [];
  3071. if (item.gu) {
  3072. $scope.workspaces.push({
  3073. id: 1,
  3074. name: "固定资产",
  3075. active: true,
  3076. contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html'
  3077. })
  3078. }
  3079. if (item.hao) {
  3080. $scope.workspaces.push({
  3081. id: 2,
  3082. name: "耗材资产",
  3083. active: true,
  3084. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  3085. })
  3086. }
  3087. };
  3088. //获取附件列表
  3089. $scope.listAttachmen = function () {
  3090. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  3091. var myData = Restangular.stripRestangular(result);
  3092. // $scope.listAttachmens = myData;
  3093. $scope.attachments = myData.data;
  3094. });
  3095. };
  3096. //附件列表
  3097. if ($scope.options.templateOptions.bindType) {
  3098. if (angular.isUndefined($scope.form.dropState)) {
  3099. $scope.form.dropState = false;
  3100. }
  3101. var to = $scope.options.templateOptions;
  3102. var bindId = $scope.model[to.bindType].processInstanceId;
  3103. $scope.listAttachmen();
  3104. }
  3105. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3106. // $scope.listAttachmen();
  3107. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3108. // $scope.listAttachmen();
  3109. // }
  3110. //附件下载
  3111. $scope.download = function (token, filename) {
  3112. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  3113. // window.open(downUrl);
  3114. var a = document.createElement('a');
  3115. a.href = downUrl;
  3116. a.target = '_blank';
  3117. a.download = filename;
  3118. document.body.appendChild(a);
  3119. a.click();
  3120. };
  3121. //附件预览
  3122. $scope.view = function (id, previewUrl) {
  3123. if (previewUrl) {
  3124. window.open(previewUrl);
  3125. }
  3126. };
  3127. //下载资产模版
  3128. $scope.filenum = 0;
  3129. $scope.openmeans = function () {
  3130. var modalInstance = $modal.open({
  3131. templateUrl: 'assets/views/means/tpl/meansdown.html',
  3132. controller: function ($scope, scope, $modalInstance) {
  3133. $scope.item = {};
  3134. $scope.title = "选择下载模版";
  3135. $scope.lable = "资产模版下载";
  3136. function foreachdata(my_datas) {
  3137. // angular.forEach(my_datas, function(item, index) {
  3138. // if (item.children && item.children.length > 0) {
  3139. // foreachdata(item.children);
  3140. // } else {
  3141. // my_datas[index].checks = true;
  3142. // }
  3143. // })
  3144. for (var i = 0; i < my_datas.length; i++) {
  3145. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3146. foreachdata(my_datas[i].children);
  3147. console.log($scope);
  3148. } else {
  3149. my_datas[i].checks = true;
  3150. }
  3151. }
  3152. }
  3153. function foreachtree(data) {
  3154. angular.forEach(data, function (item) {
  3155. // if (item.checks != true) {
  3156. item.checks = true;
  3157. item.expanded = true;
  3158. if (item.children && item.children.length > 0) {
  3159. foreachtree(item.children)
  3160. } else {
  3161. $scope.getslowtree.push(item)
  3162. }
  3163. // }
  3164. })
  3165. }
  3166. $scope.getslowtree = [];
  3167. $scope.slowtree = function (tree) {
  3168. foreachtree(tree)
  3169. return $scope.getslowtree
  3170. }
  3171. $scope.all = function (c, v) { //全选
  3172. if (c == true) {
  3173. $scope.formdashboard($scope.slowtree(v));
  3174. } else {
  3175. $scope.my_data_after = [];
  3176. angular.forEach($scope.my_data, function (item, index) {
  3177. $scope.my_data[index].checks = false;
  3178. $scope.my_data[index].expanded = false;
  3179. if (item.children && item.children.length > 0) {
  3180. angular.forEach(item.children, function (itemone, indexone) {
  3181. $scope.my_data[index].children[indexone].checks = false;
  3182. $scope.my_data[index].children[indexone].expanded = false;
  3183. if (itemone.children && itemone.children.length > 0) {
  3184. angular.forEach(itemone.children, function (itemtwo, indextwo) {
  3185. $scope.my_data[index].children[indexone].children[indextwo].checks = false;
  3186. })
  3187. } else { }
  3188. })
  3189. } else { }
  3190. })
  3191. $scope.mydatacate = [];
  3192. $scope.getslowtree = [];
  3193. // }
  3194. }
  3195. };
  3196. // $scope.searchone = function(search) {
  3197. // angular.forEach($scope.my_data, function(item) {
  3198. // if (item.indexOf(search) > 0) {
  3199. // }
  3200. // })
  3201. // }
  3202. $scope.checkall = function () {
  3203. angular.forEach($scope.my_data, function (item, index) {
  3204. scope.my_data[index].checks = true;
  3205. })
  3206. }
  3207. $scope.selectitem = [];
  3208. $scope.choiceitem = function (item) {
  3209. // if (item.checkeds) {
  3210. // item.checkeds = false;
  3211. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3212. // // if ($scope.selectitem[i].id == item.id) {
  3213. // // $scope.selectitem.splice(i, 1)
  3214. // // }
  3215. // // }
  3216. // for (var i = 0; i < $scope.my_data_after; i++) {
  3217. // if ($scope.my_data_after[i].id == item.id) {
  3218. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3219. // // $scope.selectitem.splice(i, 1)
  3220. // }
  3221. // }
  3222. // } else {
  3223. // item.checkeds = true;
  3224. // $scope.selectitem.push(item)
  3225. // }
  3226. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3227. if ($scope.my_data_after[i].id == item.id) {
  3228. $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3229. }
  3230. }
  3231. }
  3232. $scope.remove = function (removeitem) {
  3233. var realdat = angular.copy($scope.my_data_after)
  3234. // angular.extend(realdat, $scope.selectitem);
  3235. $scope.my_data_after = [];
  3236. angular.forEach(realdat, function (item) {
  3237. if (!item.checkeds) {
  3238. $scope.my_data_after.push(item)
  3239. }
  3240. })
  3241. $scope.mydatacate = angular.copy($scope.my_data_after);
  3242. }
  3243. $scope.try_async_loads = function (item, search) {
  3244. var fildatas = {
  3245. 'idx': 0,
  3246. 'sum': 1000
  3247. };
  3248. $scope.my_data = [];
  3249. // $scope.try_async_load = true;
  3250. if (item) {
  3251. angular.extend(fildatas, item)
  3252. }
  3253. api_configure_data.fetchDataList('ciclassify', fildatas).then(function (response) {
  3254. if (response.status == 200) {
  3255. var data = response.list;
  3256. var objects = [];
  3257. for (var i = 0; i < data.length; i++) {
  3258. var object = {};
  3259. object.id = data[i].id;
  3260. if (search) {
  3261. delete data[i].parent
  3262. } else {
  3263. if (data[i].parent && data[i].parent.id != 0) {
  3264. object.parent = data[i].parent.id;
  3265. }
  3266. }
  3267. angular.extend(object, data[i]);
  3268. objects.push(object);
  3269. }
  3270. $scope.my_data = convertParentToChildList(objects);
  3271. $scope.tree_data = angular.copy($scope.my_data);
  3272. if ($scope.my_data.length > 0) {
  3273. $scope.try_async_load = false;
  3274. }
  3275. } else {
  3276. SweetAlert.swal({
  3277. title: "系统错误!",
  3278. text: "请刷新重试!",
  3279. type: "error"
  3280. });
  3281. }
  3282. });
  3283. };
  3284. function convertListToTree(data, treeMap) {
  3285. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3286. var root = null; //Initially set our loop to null
  3287. //loop over data
  3288. for (var i = 0; i < data.length; i++) {
  3289. var datum = data[i];
  3290. //each node will have children, so let's give it a "children" poperty
  3291. datum.children = [];
  3292. //add an entry for this node to the map so that any future children can
  3293. //lookup the parent
  3294. idToNodeMap[datum.id] = datum;
  3295. //Does this node have a parent?
  3296. // console.log("datum="+JSON.stringify(datum))
  3297. if (typeof datum.parent === "undefined" || datum.parent === null) {
  3298. //Doesn't look like it, so this node is the root of the tree
  3299. root = datum;
  3300. treeMap[datum.id] = root;
  3301. } else {
  3302. //This node has a parent, so let's look it up using the id
  3303. parentNode = idToNodeMap[datum.parent.id];
  3304. //We don't need this property, so let's delete it.
  3305. // delete datum.parent;
  3306. //Let's add the current node as a child of the parent node.
  3307. parentNode.children.push(datum);
  3308. }
  3309. }
  3310. return root;
  3311. }
  3312. function convertParentToChildList(data) {
  3313. var treeMap = {};
  3314. var list = [];
  3315. convertListToTree(data, treeMap);
  3316. angular.forEach(treeMap, function (item) {
  3317. list.push(item);
  3318. });
  3319. return list;
  3320. }
  3321. function convertParentToChild(datato) {
  3322. var treeMapto = {};
  3323. var listto = [];
  3324. convertListToTree(datato, treeMapto);
  3325. angular.forEach(treeMapto, function (items) {
  3326. listto.push(items);
  3327. });
  3328. return listto;
  3329. }
  3330. $scope.try_async_loads();
  3331. $scope.searchdown = function (key) {
  3332. if (key && key != '') {
  3333. $scope.try_async_loads({
  3334. 'ciclassify': {
  3335. "label": key
  3336. }
  3337. }, 'search')
  3338. } else {
  3339. $scope.try_async_loads()
  3340. }
  3341. // var mydatacatedown = angular.copy($scope.my_data);
  3342. // $scope.my_data = [];
  3343. // var objects = [];
  3344. // angular.forEach(mydatacatedown, function(item) {
  3345. // if (item.label.match(key)) {
  3346. // objects.push(item)
  3347. // } else {
  3348. // // $scope.my_data_after.push(item)
  3349. // }
  3350. // })
  3351. // $scope.my_data = convertParentToChildList(objects);
  3352. // $scope.tree_data = angular.copy($scope.my_data);
  3353. }
  3354. $scope.mydatacate = [];
  3355. $scope.searchup = function (key) {
  3356. // var mydatacate = angular.copy($scope.my_data_after);
  3357. $scope.my_data_after = [];
  3358. angular.forEach($scope.mydatacate, function (item) {
  3359. if (item.label.match(key)) {
  3360. $scope.my_data_after.push(item)
  3361. } else { }
  3362. })
  3363. }
  3364. //角色树
  3365. $scope.my_tree = [];
  3366. $scope.tree_data_after = [];
  3367. $scope.my_data = [];
  3368. $scope.my_data_after = [];
  3369. $scope.formdashboard = function (item) {
  3370. $scope.my_data_after = [];
  3371. angular.forEach(item, function (infox) {
  3372. if (infox.children.length == 0) {
  3373. $scope.my_data_after.push(infox);
  3374. }
  3375. })
  3376. $scope.mydatacate = angular.copy($scope.my_data_after);
  3377. }
  3378. $scope.ok = function (item) {
  3379. $modalInstance.close(item);
  3380. };
  3381. $scope.cancel = function () {
  3382. $modalInstance.dismiss('cancel');
  3383. };
  3384. },
  3385. // size: 'sm',
  3386. resolve: {
  3387. scope: function () {
  3388. return $scope;
  3389. }
  3390. }
  3391. });
  3392. modalInstance.result.then(function (selectedItem) {
  3393. // $rootScope.isMask = true;
  3394. if (selectedItem) {
  3395. var type = 1;
  3396. var fildat = {
  3397. 'configure': selectedItem
  3398. };
  3399. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  3400. // // if (data.errno == 0) {
  3401. // var file = new Blob([data], {
  3402. // // 'Accept': '*/*'
  3403. // type: 'application/octet-stream'
  3404. // // type: 'application/vnd.ms-excel'
  3405. // });
  3406. // //trick to download store a file having its URL
  3407. // var fileURL = URL.createObjectURL(file);
  3408. // var a = document.createElement('a');
  3409. // a.href = fileURL;
  3410. // a.target = '_blank';
  3411. // a.download = "资产导入模版.xlsx";
  3412. // document.body.appendChild(a);
  3413. // a.click();
  3414. // // }
  3415. // })
  3416. $http({
  3417. url: api_configure_data.downModels('export/cmdb', fildat).getRequestedUrl(),
  3418. method: 'POST',
  3419. data: JSON.stringify(fildat),
  3420. headers: {
  3421. // 'Content-type': 'application/xls',
  3422. 'Accept': '*/*'
  3423. },
  3424. responseType: 'arraybuffer'
  3425. }).success(function (data, status, headers, config) {
  3426. $rootScope.isMask = false;
  3427. var file = new Blob([data], {
  3428. type: 'application/octet-stream'
  3429. // type : 'application/vnd.ms-excel'
  3430. });
  3431. //trick to download store a file having its URL
  3432. var fileURL = URL.createObjectURL(file);
  3433. var a = document.createElement('a');
  3434. a.href = fileURL;
  3435. a.target = '_blank';
  3436. a.download = "资产导入模版.xlsx";
  3437. document.body.appendChild(a);
  3438. a.click();
  3439. }).error(function (data, status, headers, config) {
  3440. // console.log(data);
  3441. $rootScope.isMask = false;
  3442. });
  3443. // break;
  3444. // }
  3445. // }
  3446. // }
  3447. // })
  3448. } else {
  3449. SweetAlert.swal({
  3450. title: "未选择资产分类!",
  3451. text: "请选择资产分类",
  3452. type: "error"
  3453. }, function () {
  3454. $rootScope.isMask = false;
  3455. });
  3456. }
  3457. // }
  3458. });
  3459. }
  3460. $scope.wrongdata = [];
  3461. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  3462. var uploadermeans = $scope.uploadermeans = $scope.options.templateOptions.fileUploadermeans;
  3463. $scope.importopen = function () { //导入触发事件
  3464. if (angular.isUndefined($scope.form.dropState)) {
  3465. $scope.form.dropState = false;
  3466. }
  3467. //附件上传数据
  3468. //$scope.options.templateOptions.uploader();
  3469. // FILTERS
  3470. uploader.filters.push({
  3471. name: 'customFilter',
  3472. fn: function (item /*{File|FileLikeObject}*/, options) {
  3473. return this.queue.length < 2;
  3474. }
  3475. });
  3476. // CALLBACKS
  3477. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  3478. console.info('onWhenAddingFileFailed', item, filter, options);
  3479. };
  3480. uploader.onAfterAddingFile = function (fileItem) {
  3481. console.info('onAfterAddingFile', fileItem);
  3482. };
  3483. uploader.onAfterAddingAll = function (addedFileItems) {
  3484. console.info('onAfterAddingAll', addedFileItems);
  3485. };
  3486. uploader.onBeforeUploadItem = function (item) {
  3487. console.info('onBeforeUploadItem', item);
  3488. };
  3489. uploader.onProgressItem = function (fileItem, progress) {
  3490. console.info('onProgressItem', fileItem, progress);
  3491. };
  3492. uploader.onProgressAll = function (progress) {
  3493. console.info('onProgressAll', progress);
  3494. };
  3495. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  3496. // console.info('onSuccessItem', fileItem, response, status, headers);
  3497. // };
  3498. uploader.onErrorItem = function (fileItem, response, status, headers) {
  3499. console.info('onErrorItem', fileItem, response, status, headers);
  3500. };
  3501. uploader.onCancelItem = function (fileItem, response, status, headers) {
  3502. console.info('onCancelItem', fileItem, response, status, headers);
  3503. };
  3504. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  3505. console.info('onCompleteItem', fileItem, response, status, headers);
  3506. };
  3507. uploader.onCompleteAll = function () {
  3508. console.info('onCompleteAll');
  3509. };
  3510. }
  3511. // $scope.importnext = function() {
  3512. // $scope.state = 2;
  3513. // event.preventDefault();
  3514. // }
  3515. $scope.importnext = function () {
  3516. event.preventDefault();
  3517. // $rootScope.isMask = true;
  3518. $rootScope.loading = true;
  3519. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3520. uploader.onBeforeUploadItem = function (item) {
  3521. angular.extend(item.headers, $rootScope.getSession());
  3522. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3523. // if (item.index > 1) {
  3524. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3525. // }
  3526. // item.index = 1;
  3527. item.formData = [{
  3528. 'filename': item.file.name
  3529. }];
  3530. console.info('onBeforeUploadItem', item);
  3531. };
  3532. uploader.uploadAll();
  3533. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3534. if (response.status == 200) {
  3535. $scope.wrongdata = [];
  3536. $rootScope.loading = false;
  3537. if (response.abnormal) {
  3538. $scope.state = 2;
  3539. angular.forEach(response.msg, function (item) {
  3540. $scope.wrongdata.push({
  3541. 'name': item.assetName,
  3542. 'line': item.row,
  3543. 'cmdbname': item.name,
  3544. 'errotip': [{
  3545. 'label': item.msg
  3546. }]
  3547. })
  3548. })
  3549. } else {
  3550. $scope.state = 3;
  3551. }
  3552. } else {
  3553. $rootScope.loading = false;
  3554. $scope.state = 2;
  3555. }
  3556. }
  3557. }
  3558. $scope.clearItems = function () { //重新选择文件时,清空队列,达到覆盖文件的效果
  3559. uploader.clearQueue();
  3560. // uploader.remove();
  3561. // uploader.cancel();
  3562. // uploader.onChange();
  3563. }
  3564. uploader.onAfterAddingFile = function (fileItem) {
  3565. $scope.fileItem = fileItem._file;
  3566. // $scope.$apply();
  3567. // $scope.fileItem = filenum;
  3568. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  3569. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  3570. $scope.filenum++;
  3571. };
  3572. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3573. $scope.uploadStatus = true; //上传成功则把状态改为true
  3574. // alert(response.path);
  3575. };
  3576. $scope.importnext = function () {
  3577. event.preventDefault();
  3578. // uploader.onChange();
  3579. $rootScope.loading = true;
  3580. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  3581. uploader.onBeforeUploadItem = function (item) {
  3582. angular.extend(item.headers, $rootScope.getSession());
  3583. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  3584. // if (item.index > 1) {
  3585. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  3586. // }
  3587. // item.index = 1;
  3588. item.formData = [{
  3589. 'filename': item.file.name
  3590. }];
  3591. console.info('onBeforeUploadItem', item);
  3592. };
  3593. uploader.uploadAll();
  3594. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  3595. if (response.status == 200) {
  3596. $scope.wrongdata = [];
  3597. // uploader.queue = [];
  3598. $rootScope.loading = false;
  3599. if (response.abnormal) {
  3600. $scope.state = 2;
  3601. uploader.clearQueue();
  3602. angular.forEach(response.msg, function (item) {
  3603. $scope.wrongdata.push({
  3604. 'name': item.assetName,
  3605. 'line': item.row,
  3606. 'cmdbname': item.name,
  3607. 'errotip': [{
  3608. 'label': item.msg
  3609. }]
  3610. })
  3611. })
  3612. } else {
  3613. $scope.state = 3;
  3614. }
  3615. } else {
  3616. uploader.clearQueue();
  3617. $rootScope.loading = false;
  3618. $scope.state = 2;
  3619. }
  3620. }
  3621. }
  3622. var setAllInactive = function () {
  3623. angular.forEach($scope.workspaces, function (workspace) {
  3624. workspace.active = false;
  3625. });
  3626. };
  3627. //添加
  3628. var addNewWorkspace = function (name, contentUrl) {
  3629. var id = $scope.workspaces.length + 1;
  3630. $scope.workspaces.push({
  3631. id: id,
  3632. name: name,
  3633. active: true,
  3634. contentUrl: 'main/html/content.html'
  3635. });
  3636. };
  3637. //关闭
  3638. $scope.closeopen = function (closedata) {
  3639. event.preventDefault();
  3640. angular.forEach($scope.workspaces, function (item, index) {
  3641. if (closedata.id == item.id) {
  3642. if (closedata.id == 1) {
  3643. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  3644. } else {
  3645. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  3646. }
  3647. $scope.workspaces.splice(index, 1);
  3648. }
  3649. })
  3650. }
  3651. // $scope.workspaces = [
  3652. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  3653. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  3654. // ];
  3655. $scope.addWorkspace = function (contentUrl, name) {
  3656. setAllInactive();
  3657. addNewWorkspace(name, contentUrl);
  3658. };
  3659. // $rootScope.addWorkspace = $scope.addWorkspace;
  3660. $scope.close = function (idNumber) {
  3661. var index = 0; //记录当前元素下标
  3662. angular.forEach($scope.workspaces, function (workspace) {
  3663. if (workspace.id === idNumber) {
  3664. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  3665. }
  3666. index++;
  3667. });
  3668. };
  3669. //grid2
  3670. $scope.langs = i18nService.getAllLangs();
  3671. $scope.lang = 'zh-cn';
  3672. i18nService.setCurrentLang($scope.lang);
  3673. $scope.gridOptions2 = {};
  3674. $scope.gridOptions2.data = 'myData3';
  3675. $scope.gridOptions2.enableColumnResizing = true;
  3676. $scope.gridOptions2.enableFiltering = false;
  3677. $scope.gridOptions2.enableGridMenu = false;
  3678. $scope.gridOptions2.showGridFooter = true;
  3679. $scope.gridOptions2.showColumnFooter = false;
  3680. $scope.gridOptions2.fastWatch = true;
  3681. $scope.gridOptions2.useExternalFiltering = true;
  3682. $scope.gridOptions2.useExternalPagination = true;
  3683. $scope.gridOptions2.paginationPageSizes = [10];
  3684. $scope.gridOptions2.paginationPageSize = 10;
  3685. $scope.gridOptions2.multiSelect = false;
  3686. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  3687. $scope.gridOptions2.columnDefs = [{
  3688. name: 'item',
  3689. displayName: '序号',
  3690. width: 120
  3691. },
  3692. {
  3693. name: 'name',
  3694. displayName: '耗材名称',
  3695. width: 80,
  3696. enableFiltering: false
  3697. },
  3698. {
  3699. name: 'model',
  3700. displayName: '品牌/型号',
  3701. width: 100,
  3702. enableFiltering: false
  3703. },
  3704. {
  3705. name: 'Specifications',
  3706. displayName: '规格',
  3707. width: 150,
  3708. enableFiltering: false
  3709. },
  3710. {
  3711. name: 'sum',
  3712. displayName: '数量',
  3713. enableFiltering: false
  3714. },
  3715. {
  3716. name: '操作',
  3717. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3718. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  3719. '</div></div>',
  3720. enableFiltering: false
  3721. },
  3722. ];
  3723. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  3724. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  3725. $scope.myData3all = JSON.parse($scope.$parent.$parent.$parent.model.applicationForm.consumables);
  3726. for (var i = 0; i < $scope.myData3all.length; i++) {
  3727. $scope.myData3all[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  3728. }
  3729. // $scope.model.consumables = $scope.myDataone;
  3730. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3731. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10)
  3732. $scope.model.applicationForm.consumables = $scope.myData3all;
  3733. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3734. $scope.options.templateOptions.getpush({
  3735. "hao": true,
  3736. "gu": true
  3737. });
  3738. } else {
  3739. $scope.options.templateOptions.getpush({
  3740. "hao": true
  3741. });
  3742. }
  3743. } else {
  3744. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  3745. $scope.options.templateOptions.getpush({
  3746. "gu": true
  3747. });
  3748. }
  3749. }
  3750. }
  3751. $scope.options.templateOptions.workspaces = $scope.workspaces;
  3752. $scope.changecai = function (item) {
  3753. event.preventDefault();
  3754. var modalInstance = $modal.open({
  3755. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  3756. controller: function ($scope, $modalInstance) {
  3757. $scope.title = "修改耗材数量";
  3758. $scope.consumptive = angular.copy(item);
  3759. $scope.ok = function () {
  3760. $modalInstance.close($scope.consumptive);
  3761. };
  3762. $scope.cancel = function () {
  3763. $modalInstance.dismiss('cancel');
  3764. };
  3765. },
  3766. size: 'sm'
  3767. });
  3768. modalInstance.result.then(function (selectedItem) {
  3769. // angular.forEach($scope.myData3, function(items, index) {
  3770. // if (items.id == selectedItem.id) {
  3771. // $scope.myData3[index] = selectedItem;
  3772. // }
  3773. // })
  3774. // // $scope.myData3.push(selectedItem);
  3775. // $scope.model.applicationForm.consumables = $scope.myData3;
  3776. angular.forEach($scope.myData3all, function (items, index) {
  3777. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  3778. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  3779. angular.extend($scope.myData3all[index], selectedItem)
  3780. }
  3781. })
  3782. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3783. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3784. $scope.model.applicationForm.consumables = $scope.myData3all;
  3785. })
  3786. }
  3787. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  3788. $scope.gridApi = gridApi;
  3789. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  3790. // var filtersData = $scope.memoryfilterDatahao;
  3791. // filtersData.idx = newPage - 1;
  3792. // filtersData.sum = pageSize;
  3793. // $scope.loadData(filtersData);
  3794. $scope.memoryfilterDatahao.idx = newPage - 1;
  3795. $scope.memoryfilterDatahao.sum = pageSize;
  3796. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10);
  3797. });
  3798. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  3799. $scope.selected.items = data.entity;
  3800. //console.log(data);
  3801. });
  3802. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  3803. $scope.selected.items = data.entity;
  3804. //console.log(data);
  3805. });
  3806. gridApi.core.on.filterChanged($scope, function () {
  3807. var grid = this.grid;
  3808. var filtersData = {
  3809. idx: 0,
  3810. sum: 10,
  3811. };
  3812. $scope.memoryfilterDatahao = filtersData;
  3813. // $scope.loadData(filtersData);
  3814. // $scope.memoryfilterDatahao.idx = newPage - 1;
  3815. // $scope.memoryfilterDatahao.sum = pageSize;
  3816. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3817. });
  3818. };
  3819. $scope.haocaiopen = function (items) {
  3820. event.preventDefault();
  3821. var modalInstance = $modal.open({
  3822. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  3823. controller: function ($scope, $modalInstance, SweetAlert) {
  3824. $scope.consumptive = {};
  3825. $scope.title = "新增耗材";
  3826. if (items.name) {
  3827. $scope.consumptive.name = items.name.name;
  3828. }
  3829. $scope.clearNoNum = function (obj, attr) {
  3830. //先把非数字的都替换掉,除了数字和.
  3831. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3832. //必须保证第一个为数字而不是.
  3833. obj[attr] = obj[attr].replace(/^\./g, "");
  3834. //保证只有出现一个.而没有多个.
  3835. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3836. //保证.只出现一次,而不能出现两次以上
  3837. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3838. //小于最大值
  3839. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3840. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3841. // obj[attr] = '';
  3842. // }
  3843. }
  3844. $scope.ok = function (item) {
  3845. // if (item.name && item.model && item.Specifications && item.sum) {
  3846. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3847. $modalInstance.close(item);
  3848. } else {
  3849. SweetAlert.swal({
  3850. title: "数据填写不完整!",
  3851. text: "请检查数据然后提交!",
  3852. type: "error"
  3853. });
  3854. }
  3855. };
  3856. $scope.cancel = function () {
  3857. $modalInstance.dismiss('cancel');
  3858. };
  3859. },
  3860. size: 'sm',
  3861. resolve: {
  3862. SweetAlert: function () {
  3863. return SweetAlert;
  3864. }
  3865. }
  3866. });
  3867. modalInstance.result.then(function (selectedItem) {
  3868. api_sysinfo.addData('dictionaryTree', {
  3869. // "type": "list",
  3870. "key": "haocaifenlei",
  3871. "name": selectedItem.name,
  3872. "parent": selectedItem.id,
  3873. "value": selectedItem.name,
  3874. "deleted": false,
  3875. "level": 1
  3876. }).then(function (data) {
  3877. // $scope.haocainame.name = data.list;
  3878. api_sysinfo.addData('dictionaryTree', {
  3879. // "type": "list",
  3880. "key": "pinpai",
  3881. "name": selectedItem.model,
  3882. "parent": data.id,
  3883. "value": selectedItem.model,
  3884. "deleted": false,
  3885. "level": 2
  3886. }).then(function (data) {
  3887. // $scope.haocainame = data.list;
  3888. })
  3889. api_sysinfo.addData({
  3890. // "type": "list",
  3891. "key": "guige",
  3892. "name": selectedItem.Specifications,
  3893. "parent": data.id,
  3894. "value": selectedItem.Specifications,
  3895. "deleted": false,
  3896. "level": 2
  3897. }).then(function (data) {
  3898. // $scope.haocainame = data.list;
  3899. })
  3900. })
  3901. // $scope.myData3.push(selectedItem);
  3902. // for (var i = 0; i < $scope.myData3.length; i++) {
  3903. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  3904. // }
  3905. // $scope.model.applicationForm.consumables = $scope.myData3;
  3906. $scope.myData3all.push(selectedItem);
  3907. for (var i = 0; i < $scope.myData3all.length; i++) {
  3908. $scope.myData3all[i]['item'] = i + 1
  3909. }
  3910. // $scope.model.consumables = $scope.myDataone;
  3911. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  3912. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  3913. $scope.model.applicationForm.consumables = $scope.myData3all;
  3914. })
  3915. }
  3916. $scope.haocaiadd = function () {
  3917. event.preventDefault();
  3918. var modalInstance = $modal.open({
  3919. templateUrl: 'assets/views/customform/tpl/cmdb/addchangehaocai.html',
  3920. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  3921. $scope.haocainame = [];
  3922. $scope.pinpai = [];
  3923. $scope.guige = [];
  3924. $scope.consumptive = {};
  3925. $scope.consumpall = {};
  3926. $scope.title = "添加耗材";
  3927. api_wechatfile.getDictionary({
  3928. "key": "haocaifenlei",
  3929. "type": "tree"
  3930. }).then(function (data) {
  3931. $scope.haocainame = data;
  3932. })
  3933. $scope.clearNoNum = function (obj, attr) {
  3934. //先把非数字的都替换掉,除了数字和.
  3935. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  3936. //必须保证第一个为数字而不是.
  3937. obj[attr] = obj[attr].replace(/^\./g, "");
  3938. //保证只有出现一个.而没有多个.
  3939. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  3940. //保证.只出现一次,而不能出现两次以上
  3941. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  3942. //小于最大值
  3943. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  3944. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  3945. // obj[attr] = '';
  3946. // }
  3947. }
  3948. $scope.onChange = function (parent) {
  3949. $scope.consumptive.model = {};
  3950. $scope.consumptive.Specifications = {};
  3951. api_wechatfile.getDictionaryForList({
  3952. "key": "pinpai",
  3953. "parent": parent.id
  3954. }).then(function (data) {
  3955. $scope.pinpai = data;
  3956. })
  3957. api_wechatfile.getDictionaryForList({
  3958. "key": "guige",
  3959. "parent": parent.id
  3960. }).then(function (data) {
  3961. $scope.guige = data;
  3962. })
  3963. }
  3964. $scope.addhaocai = function () {
  3965. $modalInstance.dismiss('cancel');
  3966. scope.haocaiopen($scope.consumptive);
  3967. }
  3968. $scope.ok = function (item) {
  3969. var items = {};
  3970. var submittrue = true;
  3971. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  3972. items = {
  3973. "modelid": item.model.id,
  3974. "nameid": item.name.id,
  3975. "Specificationsid": item.Specifications.id,
  3976. "name": item.name.name,
  3977. "model": item.model.name,
  3978. "Specifications": item.Specifications.name,
  3979. "sum": item.sum
  3980. }
  3981. angular.forEach(scope.myData3all, function (itemsdata) {
  3982. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  3983. submittrue = false;
  3984. }
  3985. })
  3986. if (submittrue) {
  3987. $modalInstance.close(items);
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "该耗材已有添加",
  3991. text: "请检查数据然后提交!",
  3992. type: "error"
  3993. });
  3994. }
  3995. } else {
  3996. SweetAlert.swal({
  3997. title: "数据填写不完整!",
  3998. text: "请检查数据然后提交!",
  3999. type: "error"
  4000. });
  4001. }
  4002. // var isold = false;
  4003. // if (item.name && item.model && item.Specifications && item.sum) {
  4004. // for (var i = 0; i < scope.myData3all.length; i++) {
  4005. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4006. // isold = true;
  4007. // }
  4008. // }
  4009. // if (isold) {
  4010. // SweetAlert.swal({
  4011. // title: "该耗材已添加!",
  4012. // text: "请不要重复添加耗材!",
  4013. // type: "error"
  4014. // });
  4015. // } else {
  4016. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4017. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4018. // $scope.consumpall.sum = item.sum;
  4019. // delete $scope.consumpall.brandModel;
  4020. // delete $scope.consumpall.specification;
  4021. // $modalInstance.close($scope.consumpall);
  4022. // }
  4023. // } else {
  4024. // SweetAlert.swal({
  4025. // title: "数据填写不完整!",
  4026. // text: "请检查数据然后提交!",
  4027. // type: "error"
  4028. // });
  4029. // }
  4030. };
  4031. $scope.cancel = function () {
  4032. $modalInstance.dismiss('cancel');
  4033. };
  4034. },
  4035. size: 'sm',
  4036. resolve: {
  4037. scope: function () {
  4038. return $scope;
  4039. }
  4040. }
  4041. });
  4042. modalInstance.result.then(function (selectedItem) {
  4043. $scope.myData3all.push(selectedItem);
  4044. for (var i = 0; i < $scope.myData3all.length; i++) {
  4045. $scope.myData3all[i]['item'] = i + 1
  4046. }
  4047. // $scope.model.consumables = $scope.myDataone;
  4048. $scope.gridOptions2['totalItems'] = $scope.myData3all.length;
  4049. $scope.myData3 = $scope.interceptMydata($scope.myData3all, $scope.memoryfilterDatahao.idx, 10)
  4050. $scope.model.applicationForm.consumables = $scope.myData3all;
  4051. })
  4052. }
  4053. $scope.onDblClick = function (data, event) {
  4054. $scope.selectButtonClick(data, event);
  4055. };
  4056. // $scope.memoryfilterDatahao = {
  4057. // "idx": 0,
  4058. // "sum": 10,
  4059. // }
  4060. // $scope.loadData = function(filterData) {};
  4061. // $scope.title = title;
  4062. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4063. $scope.options.templateOptions.transform($scope.options, $rootScope, $scope);
  4064. }
  4065. }]
  4066. });
  4067. //归还设备耗材tab
  4068. formlyConfigProvider.setType({
  4069. name: 'ui-cmdbreturntab',
  4070. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html',
  4071. wrapper: ['bootstrapHasError'],
  4072. defaultOptions: function (options, $scope) {
  4073. return {
  4074. templateOptions: {
  4075. // checkform: function(options) {
  4076. // if (options.model.requester) {
  4077. // options.value(options.model.requester);
  4078. // }
  4079. // },
  4080. }
  4081. };
  4082. },
  4083. controller: ['$scope', '$modal', 'api_user_data', 'i18nService', 'api_wechatfile', 'api_cmdb3', function ($scope, $modal, api_user_data, i18nService, api_wechatfile, api_cmdb3) {
  4084. var setAllInactive = function () {
  4085. angular.forEach($scope.workspaces, function (workspace) {
  4086. workspace.active = false;
  4087. });
  4088. };
  4089. $scope.memoryfilterData = {
  4090. "idx": 0,
  4091. "sum": 10,
  4092. }
  4093. //添加
  4094. var addNewWorkspace = function (name, contentUrl) {
  4095. var id = $scope.workspaces.length + 1;
  4096. $scope.workspaces.push({
  4097. id: id,
  4098. name: name,
  4099. active: true,
  4100. contentUrl: 'main/html/content.html'
  4101. });
  4102. };
  4103. $scope.workspaces = [{
  4104. id: 1,
  4105. name: "归还设备",
  4106. active: true,
  4107. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4108. },
  4109. {
  4110. id: 2,
  4111. name: "归还耗材",
  4112. active: true,
  4113. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4114. }
  4115. ];
  4116. $scope.addWorkspace = function (contentUrl, name) {
  4117. setAllInactive();
  4118. addNewWorkspace(name, contentUrl);
  4119. };
  4120. // $rootScope.addWorkspace = $scope.addWorkspace;
  4121. $scope.close = function (idNumber) {
  4122. var index = 0; //记录当前元素下标
  4123. angular.forEach($scope.workspaces, function (workspace) {
  4124. if (workspace.id === idNumber) {
  4125. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4126. }
  4127. index++;
  4128. });
  4129. };
  4130. $scope.memoryfilterDataguishe = {
  4131. "idx": 0,
  4132. "sum": 10,
  4133. }
  4134. //grid1
  4135. $scope.langs = i18nService.getAllLangs();
  4136. $scope.lang = 'zh-cn';
  4137. i18nService.setCurrentLang($scope.lang);
  4138. $scope.gridOptions1 = {};
  4139. $scope.gridOptions1.data = 'myData1';
  4140. $scope.gridOptions1.enableColumnResizing = true;
  4141. $scope.gridOptions1.enableFiltering = false;
  4142. $scope.gridOptions1.enableGridMenu = false;
  4143. $scope.gridOptions1.showGridFooter = true;
  4144. $scope.gridOptions1.showColumnFooter = false;
  4145. $scope.gridOptions1.fastWatch = true;
  4146. $scope.gridOptions1.useExternalFiltering = true;
  4147. $scope.gridOptions1.useExternalPagination = true;
  4148. $scope.gridOptions1.paginationPageSizes = [10];
  4149. $scope.gridOptions1.paginationPageSize = 10;
  4150. $scope.gridOptions1.multiSelect = false;
  4151. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4152. $scope.gridOptions1.columnDefs = [{
  4153. name: 'item',
  4154. displayName: '序号',
  4155. width: 120
  4156. },
  4157. {
  4158. name: 'props.hw_cifilterClassic',
  4159. displayName: '设备类型',
  4160. width: 150,
  4161. enableFiltering: false
  4162. },
  4163. {
  4164. name: 'props.hw_mingcheng',
  4165. displayName: '设备名称',
  4166. width: 180,
  4167. enableFiltering: false
  4168. },
  4169. {
  4170. name: 'uuid',
  4171. displayName: '设备编号',
  4172. width: 180,
  4173. enableFiltering: false
  4174. },
  4175. {
  4176. name: 'props.hw_state',
  4177. width: 150,
  4178. displayName: '状态',
  4179. enableFiltering: false
  4180. },
  4181. {
  4182. name: '操作',
  4183. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4184. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  4185. '</div></div>',
  4186. enableFiltering: false
  4187. },
  4188. ];
  4189. // $scope.selectButtonClick
  4190. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4191. $scope.gridApi = gridApi;
  4192. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4193. // var filtersData = $scope.memoryfilterData;
  4194. // filtersData.idx = newPage - 1;
  4195. // filtersData.sum = pageSize;
  4196. // $scope.loadData(filtersData);
  4197. $scope.memoryfilterDataguishe.idx = newPage - 1;
  4198. $scope.memoryfilterDataguishe.sum = pageSize;
  4199. $scope.myData1 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDataguishe.idx, 10)
  4200. });
  4201. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4202. $scope.selected.items = data.entity;
  4203. //console.log(data);
  4204. });
  4205. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4206. $scope.selected.items = data.entity;
  4207. //console.log(data);
  4208. });
  4209. gridApi.core.on.filterChanged($scope, function () {
  4210. // var grid = this.grid;
  4211. // var filtersData = {
  4212. // idx: 0,
  4213. // sum: 20,
  4214. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4215. // };
  4216. // angular.forEach(grid.columns, function(item) {
  4217. // if (item.enableFiltering) {
  4218. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4219. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4220. // if (angular.isUndefined(filtersData['user'])) {
  4221. // filtersData['user'] = {};
  4222. // }
  4223. // filtersData['user'][item.field] = item.filters[0].term;
  4224. // }
  4225. // }
  4226. // });
  4227. // $scope.memoryfilterData = filtersData;
  4228. // $scope.loadData(filtersData);
  4229. });
  4230. };
  4231. $scope.changegu = function (item) {
  4232. event.preventDefault();
  4233. var modalInstance = $modal.open({
  4234. templateUrl: 'assets/views/customform/tpl/cmdb/changestate.html',
  4235. controller: function ($scope, $modalInstance) {
  4236. $scope.title = "修改设备状态";
  4237. $scope.hw_state = {};;
  4238. if (item.status) {
  4239. $scope.hw_state.name = item.hw_state;
  4240. }
  4241. // $scope.consumptive = item;
  4242. $scope.stateshe = [{
  4243. "id": 2,
  4244. "name": "在库"
  4245. }, {
  4246. "id": 4,
  4247. "name": "报修"
  4248. }, {
  4249. "id": 3,
  4250. "name": "报废"
  4251. }]
  4252. $scope.ok = function (item) {
  4253. $modalInstance.close($scope.hw_state);
  4254. };
  4255. $scope.cancel = function () {
  4256. $modalInstance.dismiss('cancel');
  4257. };
  4258. },
  4259. size: 'sm'
  4260. });
  4261. modalInstance.result.then(function (selectedItem) {
  4262. angular.forEach($scope.myData1, function (items, index) {
  4263. if (items.id == item.id) {
  4264. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  4265. }
  4266. })
  4267. $scope.model.assets = $scope.myData1;
  4268. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.model.assets;
  4269. })
  4270. }
  4271. $scope.onDblClick = function (data, event) {
  4272. $scope.selectButtonClick(data, event);
  4273. };
  4274. $scope.memoryfilterData = {
  4275. "idx": 0,
  4276. "sum": 10,
  4277. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4278. }
  4279. // $scope.myData = {};
  4280. $scope.loadData = function (filterData) { };
  4281. // $scope.title = title;
  4282. $scope.loadData({
  4283. idx: 0,
  4284. sum: 10,
  4285. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  4286. });
  4287. $scope.selected = {
  4288. items: []
  4289. };
  4290. $scope.myData2 = [];
  4291. $scope.consumptive = {};
  4292. $scope.myDataguibeiall = [];
  4293. $scope.haocaiopen = function (items) {
  4294. event.preventDefault();
  4295. var modalInstance = $modal.open({
  4296. templateUrl: 'assets/views/customform/tpl/cmdb/addhaocai.html',
  4297. controller: function ($scope, $modalInstance, SweetAlert, api_wechatfile, api_sysinfo) {
  4298. $scope.consumptive = {};
  4299. $scope.title = "新增耗材";
  4300. if (items.name) {
  4301. $scope.consumptive.name = items.name.name;
  4302. }
  4303. $scope.ok = function (item) {
  4304. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4305. $modalInstance.close(item);
  4306. } else {
  4307. SweetAlert.swal({
  4308. title: "数据填写不完整!",
  4309. text: "请检查数据然后提交!",
  4310. type: "error"
  4311. });
  4312. }
  4313. };
  4314. $scope.cancel = function () {
  4315. $modalInstance.dismiss('cancel');
  4316. };
  4317. },
  4318. size: 'sm'
  4319. });
  4320. modalInstance.result.then(function (selectedItem) {
  4321. api_sysinfo.addData({
  4322. "type": "list",
  4323. "key": "haocaifenlei",
  4324. "name": selectedItem.name,
  4325. "parent": selectedItem.id,
  4326. "value": "1"
  4327. }).then(function (data) {
  4328. // $scope.haocainame.name = data.list;
  4329. api_wechatfile.addDictionary({
  4330. "type": "list",
  4331. "key": "pinpai",
  4332. "name": selectedItem.model,
  4333. "parent": data.id,
  4334. "value": "1"
  4335. }).then(function (data) {
  4336. // $scope.haocainame = data.list;
  4337. })
  4338. api_wechatfile.addDictionary({
  4339. "type": "list",
  4340. "key": "guige",
  4341. "name": selectedItem.Specifications,
  4342. "parent": data.id,
  4343. "value": "1"
  4344. }).then(function (data) {
  4345. // $scope.haocainame = data.list;
  4346. })
  4347. })
  4348. $scope.myData2.push(selectedItem);
  4349. for (var i = 0; i < $scope.myData2.length; i++) {
  4350. $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4351. }
  4352. // $scope.model.applicationForm.consumables = $scope.myData2;
  4353. angular.forEach($scope.myDataguibeiall, function (items, index) {
  4354. if (items.id == selectedItem.id) {
  4355. $scope.myDataguibeiall.splice(index, 1);
  4356. }
  4357. })
  4358. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10)
  4359. $scope.model.consumables = $scope.myDataguibeiall;
  4360. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4361. $scope.gridOptions1['totalItems'] = $scope.myDataguibeiall.length;
  4362. })
  4363. }
  4364. //grid2
  4365. $scope.langs = i18nService.getAllLangs();
  4366. $scope.lang = 'zh-cn';
  4367. i18nService.setCurrentLang($scope.lang);
  4368. $scope.gridOptions2 = {};
  4369. $scope.gridOptions2.data = 'myData2';
  4370. $scope.gridOptions2.enableColumnResizing = true;
  4371. $scope.gridOptions2.enableFiltering = false;
  4372. $scope.gridOptions2.enableGridMenu = false;
  4373. $scope.gridOptions2.showGridFooter = true;
  4374. $scope.gridOptions2.showColumnFooter = false;
  4375. $scope.gridOptions2.fastWatch = true;
  4376. $scope.gridOptions2.useExternalFiltering = true;
  4377. $scope.gridOptions2.useExternalPagination = true;
  4378. $scope.gridOptions2.paginationPageSizes = [10];
  4379. $scope.gridOptions2.paginationPageSize = 10;
  4380. $scope.gridOptions2.multiSelect = false;
  4381. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4382. $scope.modelcons = {};
  4383. $scope.modelass = {};
  4384. $scope.myData2all = [];
  4385. $scope.myData1all = [];
  4386. $scope.memoryfilterDatagui = {
  4387. "idx": 0,
  4388. "sum": 10
  4389. }
  4390. setInterval(function () {
  4391. if ($scope.model.assets) {
  4392. if ($scope.model.assets != $scope.modelass && typeof ($scope.model.assets) == 'string') {
  4393. $scope.modelass = $scope.model.assets;
  4394. if (JSON.stringify($scope.model.assets) == "{}") {
  4395. $scope.model.assets = []
  4396. } else {
  4397. $scope.model.assets = JSON.parse($scope.model.assets);
  4398. }
  4399. // $scope.myData1 = $scope.model.assets;
  4400. // for (var i = 0; i < $scope.myData1.length; i++) {
  4401. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4402. // }
  4403. $scope.myData1all = $scope.model.assets;
  4404. for (var i = 0; i < $scope.myData1all.length; i++) {
  4405. $scope.myData1all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4406. }
  4407. $scope.gridOptions1['totalItems'] = $scope.myData1all.length;
  4408. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10)
  4409. }
  4410. }
  4411. if ($scope.model.consumables) {
  4412. if ($scope.model.consumables != $scope.modelcons && typeof ($scope.model.consumables) == 'string') {
  4413. $scope.modelass = $scope.model.consumables;
  4414. if (JSON.stringify($scope.model.consumables) == "{}") {
  4415. $scope.model.consumables = [];
  4416. } else {
  4417. $scope.model.consumables = JSON.parse($scope.model.consumables);
  4418. }
  4419. // $scope.myData2 = $scope.model.consumables;
  4420. // for (var i = 0; i < $scope.myData2.length; i++) {
  4421. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4422. // }
  4423. $scope.myData2all = $scope.model.consumables;
  4424. for (var i = 0; i < $scope.myData2all.length; i++) {
  4425. $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4426. }
  4427. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4428. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10)
  4429. // $scope.model.consumables = $scope.myData2all;
  4430. }
  4431. }
  4432. }, 100);
  4433. $scope.gridOptions2.columnDefs = [{
  4434. name: 'item',
  4435. displayName: '序号',
  4436. width: 120
  4437. },
  4438. {
  4439. name: 'name',
  4440. displayName: '耗材名称',
  4441. width: 180,
  4442. enableFiltering: false
  4443. },
  4444. {
  4445. name: 'model',
  4446. displayName: '品牌/型号',
  4447. width: 180,
  4448. enableFiltering: false
  4449. },
  4450. {
  4451. name: 'Specifications',
  4452. displayName: '规格',
  4453. width: 150,
  4454. enableFiltering: false
  4455. },
  4456. {
  4457. name: 'sum',
  4458. width: 150,
  4459. displayName: '数量',
  4460. enableFiltering: false
  4461. },
  4462. {
  4463. name: '操作',
  4464. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  4465. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4466. '</div></div>',
  4467. enableFiltering: false
  4468. },
  4469. ];
  4470. // $scope.selectButtonClick
  4471. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4472. $scope.gridApi = gridApi;
  4473. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4474. // var filtersData = $scope.memoryfilterDatagui;
  4475. // filtersData.idx = newPage - 1;
  4476. // filtersData.sum = pageSize;
  4477. $scope.memoryfilterDatagui.idx = newPage - 1;
  4478. $scope.memoryfilterDatagui.sum = pageSize;
  4479. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4480. });
  4481. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4482. $scope.selected.items = data.entity;
  4483. //console.log(data);
  4484. });
  4485. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4486. $scope.selected.items = data.entity;
  4487. //console.log(data);
  4488. });
  4489. gridApi.core.on.filterChanged($scope, function () {
  4490. var grid = this.grid;
  4491. var filtersData = {
  4492. idx: 0,
  4493. sum: 10,
  4494. };
  4495. angular.forEach(grid.columns, function (item) {
  4496. if (item.enableFiltering) {
  4497. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4498. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4499. if (angular.isUndefined(filtersData['user'])) {
  4500. filtersData['user'] = {};
  4501. }
  4502. filtersData['user'][item.field] = item.filters[0].term;
  4503. }
  4504. }
  4505. });
  4506. $scope.memoryfilterData = filtersData;
  4507. $scope.loadData(filtersData);
  4508. });
  4509. };
  4510. $scope.changecai = function (item) {
  4511. event.preventDefault();
  4512. var modalInstance = $modal.open({
  4513. templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  4514. controller: function ($scope, $modalInstance) {
  4515. $scope.title = "修改耗材数量";
  4516. $scope.consumptive = angular.copy(item);
  4517. // $scope.consumptive = item;
  4518. $scope.maxsum = item.inventoryNum;
  4519. $scope.clearNoNum = function (obj, attr) {
  4520. //先把非数字的都替换掉,除了数字和.
  4521. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4522. //必须保证第一个为数字而不是.
  4523. obj[attr] = obj[attr].replace(/^\./g, "");
  4524. //保证只有出现一个.而没有多个.
  4525. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4526. //保证.只出现一次,而不能出现两次以上
  4527. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4528. //小于最大值
  4529. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4530. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4531. // obj[attr] = '';
  4532. // }
  4533. }
  4534. $scope.ok = function () {
  4535. $modalInstance.close($scope.consumptive);
  4536. };
  4537. $scope.cancel = function () {
  4538. $modalInstance.dismiss('cancel');
  4539. };
  4540. },
  4541. size: 'sm'
  4542. });
  4543. modalInstance.result.then(function (selectedItem) {
  4544. angular.forEach($scope.myData2all, function (items, index) {
  4545. // if (items.id == selectedItem.id) {
  4546. if (items.modelid == selectedItem.modelid && items.nameid == selectedItem.nameid && items.Specificationsid == selectedItem.Specificationsid) {
  4547. angular.extend($scope.myData2all[index], selectedItem)
  4548. }
  4549. })
  4550. // $scope.model.consumables = $scope.myData2;
  4551. // $scope.myData2 = $scope.model.consumables;
  4552. // $scope.myData2all.push(selectedItem);
  4553. // for (var i = 0; i < $scope.myData2all.length; i++) {
  4554. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4555. // }
  4556. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4557. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4558. $scope.model.consumables = $scope.myData2all;
  4559. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4560. })
  4561. }
  4562. $scope.interceptMydata = function (mydate, idx, sum) {
  4563. return mydate.slice(idx * sum, (idx + 1) * sum)
  4564. }
  4565. $scope.haocaiadd = function () {
  4566. event.preventDefault();
  4567. var modalInstance = $modal.open({
  4568. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  4569. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert) {
  4570. $scope.haocainame = [];
  4571. $scope.pinpai = [];
  4572. $scope.guige = [];
  4573. $scope.consumptive = {};
  4574. $scope.consumptiveall = {};
  4575. $scope.title = "添加耗材";
  4576. api_wechatfile.getDictionaryForList({
  4577. "key": "haocaifenlei"
  4578. }).then(function (data) {
  4579. $scope.haocainame = data;
  4580. })
  4581. $scope.clearNoNum = function (obj, attr) {
  4582. //先把非数字的都替换掉,除了数字和.
  4583. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4584. //必须保证第一个为数字而不是.
  4585. obj[attr] = obj[attr].replace(/^\./g, "");
  4586. //保证只有出现一个.而没有多个.
  4587. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4588. //保证.只出现一次,而不能出现两次以上
  4589. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  4590. //小于最大值
  4591. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4592. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4593. obj[attr] = '';
  4594. }
  4595. }
  4596. $scope.onChange = function (parent) {
  4597. $scope.consumptive.model = {};
  4598. $scope.consumptive.Specifications = {};
  4599. api_wechatfile.getDictionaryForList({
  4600. "key": "pinpai",
  4601. "parent": parent.id
  4602. }).then(function (data) {
  4603. $scope.pinpai = data;
  4604. })
  4605. api_wechatfile.getDictionaryForList({
  4606. "key": "guige",
  4607. "parent": parent.id
  4608. }).then(function (data) {
  4609. $scope.guige = data;
  4610. })
  4611. }
  4612. // $scope.onChangesum = function(item) {
  4613. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  4614. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  4615. // $scope.consumptiveall = data1;
  4616. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  4617. // // if (data.list && data.list.length != 0) {
  4618. // // var myData = data.list;
  4619. // // $scope.consumptiveall = myData[0];
  4620. // // $scope.maxsum = myData[0].inventoryNum;
  4621. // // } else if (data.list && data.list.length == 0) {
  4622. // // SweetAlert.swal({
  4623. // // title: "库存数据存在问题!",
  4624. // // text: "请检查库存数据!",
  4625. // // type: "error"
  4626. // // });
  4627. // // }
  4628. // // });
  4629. // }
  4630. // }
  4631. $scope.addhaocai = function () {
  4632. $modalInstance.dismiss('cancel');
  4633. scope.haocaiopen($scope.consumptive);
  4634. }
  4635. $scope.ok = function (item) {
  4636. var submittrue = true;
  4637. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  4638. var data = {
  4639. "modelid": item.model.id,
  4640. "nameid": item.name.id,
  4641. "Specificationsid": item.Specifications.id,
  4642. "name": item.name.name,
  4643. "model": item.model.name,
  4644. "Specifications": item.Specifications.name,
  4645. "sum": item.sum
  4646. }
  4647. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  4648. // $modalInstance.close(data);
  4649. angular.forEach(scope.myData2all, function (itemsdata) {
  4650. // if (item.model.id == itemsdata.id) {
  4651. if (item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid) {
  4652. submittrue = false;
  4653. }
  4654. })
  4655. if (submittrue) {
  4656. $modalInstance.close(data);
  4657. } else {
  4658. SweetAlert.swal({
  4659. title: "该耗材已有添加",
  4660. text: "请检查数据然后提交!",
  4661. type: "error"
  4662. });
  4663. }
  4664. } else {
  4665. SweetAlert.swal({
  4666. title: "数据填写不完整!",
  4667. text: "请检查数据然后提交!",
  4668. type: "error"
  4669. });
  4670. }
  4671. };
  4672. $scope.cancel = function () {
  4673. $modalInstance.dismiss('cancel');
  4674. };
  4675. },
  4676. size: 'sm',
  4677. resolve: {
  4678. scope: function () {
  4679. return $scope;
  4680. }
  4681. }
  4682. });
  4683. modalInstance.result.then(function (selectedItem) {
  4684. // $scope.myData2.push(selectedItem);
  4685. // for (var i = 0; i < $scope.myData2.length; i++) {
  4686. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4687. // }
  4688. // $scope.model.consumables = $scope.myData2;
  4689. $scope.myData2all.push(selectedItem);
  4690. for (var i = 0; i < $scope.myData2all.length; i++) {
  4691. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4692. $scope.myData2all[i]['item'] = i + 1
  4693. }
  4694. $scope.gridOptions2['totalItems'] = $scope.myData2all.length;
  4695. $scope.myData2 = $scope.interceptMydata($scope.myData2all, $scope.memoryfilterDatagui.idx, 10)
  4696. $scope.model.consumables = $scope.myData2all;
  4697. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.model.consumables;
  4698. })
  4699. }
  4700. $scope.onDblClick = function (data, event) {
  4701. $scope.selectButtonClick(data, event);
  4702. };
  4703. $scope.memoryfilterData = {
  4704. "idx": 0,
  4705. "sum": 20,
  4706. "user": {
  4707. "roledata": {
  4708. "rolecode": "roleset"
  4709. },
  4710. "selectType": "1"
  4711. }
  4712. }
  4713. $scope.myData = {};
  4714. $scope.loadData = function (filterData) { };
  4715. // $scope.title = title;
  4716. $scope.loadData({
  4717. idx: 0,
  4718. sum: 20,
  4719. "user": {
  4720. "roledata": {
  4721. "rolecode": "roleset"
  4722. },
  4723. "selectType": "1"
  4724. }
  4725. });
  4726. $scope.selected = {
  4727. items: {}
  4728. };
  4729. }]
  4730. });
  4731. //tab 列表
  4732. formlyConfigProvider.setType({
  4733. name: 'ui-cmdbtab',
  4734. templateUrl: 'assets/views/customform/tpl/cmdb/ui-cmdbtab.html',
  4735. wrapper: ['bootstrapHasError'],
  4736. defaultOptions: function (options, $scope) {
  4737. return {
  4738. templateOptions: {}
  4739. };
  4740. },
  4741. controller: ['$scope', 'api_user_data', 'i18nService', '$modal', 'api_cmdb', function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  4742. $scope.memoryfilterDatashe = {
  4743. "idx": 0,
  4744. "sum": 10
  4745. }
  4746. $scope.myDataoneall = [];
  4747. var setAllInactive = function () {
  4748. angular.forEach($scope.workspaces, function (workspace) {
  4749. workspace.active = false;
  4750. });
  4751. };
  4752. //添加
  4753. var addNewWorkspace = function (name, contentUrl) {
  4754. var id = $scope.workspaces.length + 1;
  4755. $scope.workspaces.push({
  4756. id: id,
  4757. name: name,
  4758. active: true,
  4759. contentUrl: 'main/html/content.html'
  4760. });
  4761. };
  4762. //关闭
  4763. $scope.remove = function (closedata) {
  4764. event.preventDefault();
  4765. angular.forEach($scope.workspaces, function (item, index) {
  4766. if (closedata.id == item.id) {
  4767. if (closedata.id == 1) {
  4768. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  4769. } else {
  4770. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  4771. }
  4772. $scope.workspaces.splice(index, 1);
  4773. }
  4774. })
  4775. }
  4776. $scope.workspaces = [];
  4777. $scope.options.templateOptions.getpush = function (item) {
  4778. $scope.workspaces = [];
  4779. if (item.gu) {
  4780. $scope.workspaces.push({
  4781. id: 1,
  4782. name: "领用设备",
  4783. active: true,
  4784. contentUrl: 'assets/views/customform/tpl/cmdb/shebei.html'
  4785. })
  4786. }
  4787. if (item.hao) {
  4788. $scope.workspaces.push({
  4789. id: 2,
  4790. name: "领用耗材",
  4791. active: true,
  4792. contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html'
  4793. })
  4794. }
  4795. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4796. };
  4797. $scope.addWorkspace = function (contentUrl, name) {
  4798. setAllInactive();
  4799. addNewWorkspace(name, contentUrl);
  4800. };
  4801. // $rootScope.addWorkspace = $scope.addWorkspace;
  4802. // $scope.remove = function(idNumber) {
  4803. // var index = 0; //记录当前元素下标
  4804. // angular.forEach($scope.workspaces, function(workspace) {
  4805. // if (workspace.id === idNumber.id) {
  4806. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4807. // }
  4808. // index++;
  4809. // });
  4810. // };
  4811. // setInterval(function() {
  4812. // if ($scope.model.assets) {
  4813. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  4814. // $scope.modelass = $scope.model.assets;
  4815. // if (JSON.stringify($scope.model.assets) == "{}") {
  4816. // $scope.model.assets = []
  4817. // } else {
  4818. // $scope.model.assets = JSON.parse($scope.model.assets);
  4819. // }
  4820. // $scope.myDatalingbeiall = $scope.model.assets;
  4821. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4822. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4823. // }
  4824. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4825. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4826. // }
  4827. // }
  4828. // if ($scope.model.consumables) {
  4829. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  4830. // $scope.modelass = $scope.model.consumables;
  4831. // if (JSON.stringify($scope.model.consumables) == "{}") {
  4832. // $scope.model.consumables = [];
  4833. // } else {
  4834. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  4835. // }
  4836. // $scope.myDatalingbeiall = $scope.model.consumables;
  4837. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4838. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  4839. // }
  4840. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  4841. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4842. // // $scope.model.consumables = $scope.myData2all;
  4843. // }
  4844. // }
  4845. // }, 100);
  4846. //grid1
  4847. $scope.langs = i18nService.getAllLangs();
  4848. $scope.lang = 'zh-cn';
  4849. i18nService.setCurrentLang($scope.lang);
  4850. $scope.gridOptions1 = {};
  4851. $scope.gridOptions1.data = 'myDatalingbei';
  4852. $scope.gridOptions1.enableColumnResizing = true;
  4853. $scope.gridOptions1.enableFiltering = false;
  4854. $scope.gridOptions1.enableGridMenu = false;
  4855. $scope.gridOptions1.showGridFooter = true;
  4856. $scope.gridOptions1.showColumnFooter = false;
  4857. $scope.gridOptions1.fastWatch = true;
  4858. $scope.gridOptions1.useExternalFiltering = true;
  4859. $scope.gridOptions1.useExternalPagination = true;
  4860. $scope.gridOptions1.paginationPageSizes = [10];
  4861. $scope.gridOptions1.paginationPageSize = 10;
  4862. $scope.gridOptions1.multiSelect = false;
  4863. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4864. $scope.gridOptions1.columnDefs = [{
  4865. name: 'item',
  4866. displayName: '序号',
  4867. width: 120
  4868. },
  4869. {
  4870. name: 'props.hw_cifilterClassic',
  4871. displayName: '设备类型',
  4872. width: 150,
  4873. enableFiltering: false
  4874. },
  4875. {
  4876. name: 'props.hw_mingcheng',
  4877. displayName: '设备名称',
  4878. width: 100,
  4879. enableFiltering: false
  4880. },
  4881. {
  4882. name: 'uuid',
  4883. displayName: '设备编号',
  4884. enableFiltering: false
  4885. }
  4886. ];
  4887. $scope.myDatalingbeiall = [];
  4888. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  4889. $scope.gridApi = gridApi;
  4890. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  4891. // var filtersData = $scope.memoryfilterData;
  4892. // filtersData.idx = newPage - 1;
  4893. // filtersData.sum = pageSize;
  4894. // $scope.loadData(filtersData);
  4895. $scope.memoryfilterDatashe.idx = newPage - 1;
  4896. $scope.memoryfilterDatashe.sum = pageSize;
  4897. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, $scope.memoryfilterDatashe.idx, 10)
  4898. });
  4899. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4900. $scope.selected.items = data.entity;
  4901. //console.log(data);
  4902. });
  4903. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  4904. $scope.selected.items = data.entity;
  4905. //console.log(data);
  4906. });
  4907. gridApi.core.on.filterChanged($scope, function () {
  4908. var grid = this.grid;
  4909. var filtersData = {
  4910. idx: 0,
  4911. sum: 20,
  4912. "user": {
  4913. "roledata": {
  4914. "rolecode": "roleset"
  4915. },
  4916. "selectType": "1"
  4917. }
  4918. };
  4919. angular.forEach(grid.columns, function (item) {
  4920. if (item.enableFiltering) {
  4921. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  4922. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  4923. if (angular.isUndefined(filtersData['user'])) {
  4924. filtersData['user'] = {};
  4925. }
  4926. filtersData['user'][item.field] = item.filters[0].term;
  4927. }
  4928. }
  4929. });
  4930. $scope.memoryfilterDatashe = filtersData;
  4931. // $scope.loadData(filtersData);
  4932. });
  4933. };
  4934. $scope.interceptMydata = function (mydate, idx, sum) {
  4935. return mydate.slice(idx * sum, (idx + 1) * sum)
  4936. }
  4937. $scope.removeshebei = function (item) {
  4938. event.preventDefault();
  4939. var modalInstance = $modal.open({
  4940. templateUrl: 'assets/views/delete.html',
  4941. controller: function ($scope, $modalInstance, scope) {
  4942. $scope.title = '设备移除';
  4943. $scope.connect = '确定要移除此设备?';
  4944. $scope.consumptive = scope.selected.items;
  4945. $scope.ok = function () {
  4946. $modalInstance.close($scope.consumptive);
  4947. };
  4948. $scope.cancel = function () {
  4949. $modalInstance.dismiss('cancel');
  4950. };
  4951. },
  4952. size: 'sm',
  4953. resolve: {
  4954. scope: function () {
  4955. return $scope;
  4956. },
  4957. }
  4958. });
  4959. modalInstance.result.then(function (selectedItem) {
  4960. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  4961. if (items.id == selectedItem.id) {
  4962. $scope.myDatalingbeiall.splice(index, 1);
  4963. }
  4964. })
  4965. // $scope.myData3.push(selectedItem);
  4966. $scope.model.consumables = $scope.myDatalingbeiall;
  4967. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDatalingbeiall;
  4968. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  4969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  4970. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum
  4971. }
  4972. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  4973. })
  4974. }
  4975. $scope.addshebei = function () {
  4976. event.preventDefault();
  4977. var modalInstance = $modal.open({
  4978. templateUrl: 'assets/views/customform/tpl/cmdb/add_shebei.html',
  4979. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope, api_configure_data, api_configure_form) {
  4980. $scope.langs = i18nService.getAllLangs();
  4981. $scope.lang = 'zh-cn';
  4982. i18nService.setCurrentLang($scope.lang);
  4983. $scope.gridOptions = {};
  4984. $scope.gridOptions.data = 'myDatatwo';
  4985. $scope.gridOptions.enableColumnResizing = true;
  4986. $scope.gridOptions.enableFiltering = false;
  4987. $scope.gridOptions.enableGridMenu = false;
  4988. $scope.gridOptions.showGridFooter = true;
  4989. $scope.gridOptions.showColumnFooter = false;
  4990. $scope.gridOptions.fastWatch = true;
  4991. $scope.gridOptions.useExternalFiltering = true;
  4992. $scope.gridOptions.useExternalPagination = true;
  4993. $scope.gridOptions.paginationPageSizes = [10];
  4994. $scope.gridOptions.paginationPageSize = 10;
  4995. $scope.gridOptions.multiSelect = true;
  4996. $scope.gridOptions.rowIdentity = function (row) {
  4997. return row.id;
  4998. };
  4999. $scope.gridOptions.getRowIdentity = function (row) {
  5000. return row.id;
  5001. };
  5002. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5003. $scope.gridOptions.columnDefs = [{
  5004. name: 'item',
  5005. displayName: '序号',
  5006. width: 80,
  5007. enableFiltering: false
  5008. },
  5009. {
  5010. name: 'uuid',
  5011. displayName: '内部编号',
  5012. width: 175
  5013. },
  5014. {
  5015. name: 'props.hw_mingcheng',
  5016. displayName: '资产名称',
  5017. width: 120
  5018. },
  5019. {
  5020. name: 'props.hw_cifilterClassic',
  5021. displayName: '资产类型',
  5022. width: 80,
  5023. enableFiltering: false
  5024. },
  5025. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  5026. {
  5027. name: 'props.hw_state',
  5028. displayName: '资产状态',
  5029. width: 150,
  5030. enableFiltering: false
  5031. },
  5032. {
  5033. name: 'props.hwnw_area',
  5034. displayName: '资产地点',
  5035. width: 130,
  5036. enableFiltering: false
  5037. },
  5038. {
  5039. name: 'createtime',
  5040. displayName: '申请时间',
  5041. enableFiltering: false
  5042. }
  5043. ];
  5044. // $scope.selectButtonClick
  5045. var defaultFilterData = {
  5046. // "assignee":2,
  5047. // "sign":"basehwitndl",
  5048. // "applicationForm": { "hw_state": "在线" },
  5049. "hw_state": "在库",
  5050. "idx": 0,
  5051. "sum": 10
  5052. };
  5053. $scope.memoryfilterData = {
  5054. // "assignee":2,
  5055. // "sign":"basehwitndl",
  5056. // "applicationForm": { "hw_state": "在线" },
  5057. "hw_state": "在库",
  5058. "idx": 0,
  5059. "sum": 10
  5060. }
  5061. $scope.refreshData = function (style, filterData) {
  5062. if (angular.isUndefined(filterData)) {
  5063. filterData = defaultFilterData;
  5064. }
  5065. $scope.myDatatwo = [];
  5066. // $scope.gridOptions['sum']=filterData.sum;
  5067. api_cmdb.query(filterData).then(function (data) {
  5068. // $scope.callsPending--;
  5069. var filterData = $scope.memoryfilterData;
  5070. var myDatatwo = Restangular.stripRestangular(data);
  5071. $scope.gridOptions['totalItems'] = data.total;
  5072. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  5073. myDatatwo.data.node[i].createtime = moment(myDatatwo.data.node[i].createtime).format('YYYY-MM-DD');
  5074. }
  5075. $scope.myDatatwo = myDatatwo.data.node;
  5076. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  5077. $scope.myDatatwo[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5078. }
  5079. }, function () { });
  5080. };
  5081. $scope.refreshData('expand-right', defaultFilterData);
  5082. $scope.gridOptions.onRegisterApi = function (gridApi) {
  5083. $scope.gridApi = gridApi;
  5084. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5085. var filtersData = $scope.memoryfilterData;
  5086. filtersData.idx = newPage - 1;
  5087. filtersData.sum = pageSize;
  5088. // $scope.loadData(filtersData);
  5089. $scope.refreshData('expand-right', filtersData);
  5090. //console.log(pageSize);
  5091. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  5092. });
  5093. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  5094. // $scope.selected.items.push(data.entity);
  5095. //console.log(data);
  5096. gridApi.selection.on.rowSelectionChanged($scope, function (scope, ect) {
  5097. if (scope.isSelected) {
  5098. scope.grid.appScope.selected.items.push(scope.entity)
  5099. } else {
  5100. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  5101. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  5102. scope.grid.appScope.selected.items.splice(i, 1);
  5103. break;
  5104. }
  5105. }
  5106. }
  5107. $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  5108. });
  5109. // });
  5110. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
  5111. // $scope.selected.items = data.entity;
  5112. //console.log(data);
  5113. var selectitem = [];
  5114. selectitem = angular.copy($scope.selected.items);
  5115. for (var j = 0; j < rows.length; j++) {
  5116. if (rows[j].isSelected == true) {
  5117. selectitem.push(rows[j].entity);
  5118. } else {
  5119. delete selectitem[j];
  5120. // rows.splice(j, 1);
  5121. }
  5122. }
  5123. $scope.selected.items = [];
  5124. for (var i = 0; i < selectitem.length; i++) {
  5125. if (selectitem[i]) {
  5126. $scope.selected.items.push(selectitem[i]);
  5127. }
  5128. }
  5129. });
  5130. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  5131. // // if (row.entity.age > 45) {
  5132. // row.grid.api.selection.selectRow(row.entity); // 选中行
  5133. // // }
  5134. // };
  5135. gridApi.core.on.filterChanged($scope, function () {
  5136. var grid = this.grid;
  5137. var filtersData = {
  5138. idx: 0,
  5139. sum: 10,
  5140. "user": {
  5141. "roledata": {
  5142. "rolecode": "roleset"
  5143. },
  5144. "selectType": "1"
  5145. }
  5146. };
  5147. angular.forEach(grid.columns, function (item) {
  5148. if (item.enableFiltering) {
  5149. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5150. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5151. if (angular.isUndefined(filtersData['user'])) {
  5152. filtersData['user'] = {};
  5153. }
  5154. filtersData['user'][item.field] = item.filters[0].term;
  5155. }
  5156. }
  5157. });
  5158. $scope.memoryfilterData = filtersData;
  5159. // $scope.loadData(filtersData);
  5160. });
  5161. };
  5162. $scope.onDblClick = function (data, event) {
  5163. // $scope.selected.items = data.entity;
  5164. $scope.selectButtonClick(data, event);
  5165. };
  5166. // $scope.loadData = function(filterData) {
  5167. // // console.log("filtersData=111" + JSON.stringify(filterData))
  5168. // items.fetchItems(filterData, APIService).then(function(data) {
  5169. // var myDatatwo = Restangular.stripRestangular(data);
  5170. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  5171. // $scope.myDatatwo = myDatatwo.list;
  5172. // });
  5173. // };
  5174. $scope.title = title;
  5175. //树形图
  5176. var apple_selected, tree, treedata_avm, treedata_geography;
  5177. $scope.my_tree_handler = function (branch) {
  5178. //var _ref;
  5179. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  5180. api_cmdb.query({
  5181. 'sign': classify
  5182. }).then(function (data) {
  5183. var myDatalingbei = Restangular.stripRestangular(data);
  5184. // console.log(myData.data.node);
  5185. if (myDatalingbei.data && myDatalingbei.status == 200) {
  5186. var ret = myDatalingbei.data;
  5187. redrawSvg(myDatalingbei);
  5188. }
  5189. });
  5190. };
  5191. $scope.my_data = [];
  5192. function convertListToTree(data, treeMap) {
  5193. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  5194. var root = null; //Initially set our loop to null
  5195. var parentNode = null;
  5196. //loop over data
  5197. for (var i = 0; i < data.length; i++) {
  5198. var datum = data[i];
  5199. //each node will have children, so let's give it a "children" poperty
  5200. datum.children = [];
  5201. //add an entry for this node to the map so that any future children can
  5202. //lookup the parent
  5203. idToNodeMap[datum.id] = datum;
  5204. //Does this node have a parent?
  5205. if (typeof datum.parent === "undefined" || datum.parent == null) {
  5206. //Doesn't look like it, so this node is the root of the tree
  5207. root = datum;
  5208. treeMap[datum.id] = root;
  5209. } else {
  5210. //This node has a parent, so let's look it up using the id
  5211. parentNode = idToNodeMap[datum.parent.id];
  5212. //We don't need this property, so let's delete it.
  5213. delete datum.parent;
  5214. //Let's add the current node as a child of the parent node.
  5215. parentNode.children.push(datum);
  5216. }
  5217. }
  5218. return root;
  5219. }
  5220. function convertParentToChildList(data) {
  5221. var treeMap = {};
  5222. var list = [];
  5223. convertListToTree(data, treeMap);
  5224. angular.forEach(treeMap, function (item) {
  5225. list.push(item);
  5226. });
  5227. return list;
  5228. }
  5229. $scope.my_tree = tree = {};
  5230. $scope.try_async_load = function () {
  5231. $scope.my_data = [];
  5232. $scope.select_treedata = [];
  5233. $scope.doing_async = true;
  5234. api_configure_data.fetchDataList('ciclassify', {
  5235. 'idx': 0,
  5236. 'sum': 100
  5237. }).then(function (result) {
  5238. //console.log(result['list']);
  5239. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  5240. $scope.doing_async = false;
  5241. // tree.expand_all();
  5242. //console.log(treelist);
  5243. });
  5244. };
  5245. $scope.select_treedata = [];
  5246. $scope.propTypeOptions = [];
  5247. $scope.try_async_load();
  5248. $scope.onFilterremove = function (item) {
  5249. console.log(item)
  5250. }
  5251. $scope.searchdata = {};
  5252. $scope.clear = function () {
  5253. $scope.searchdata = {};
  5254. $scope.cifilter_classic = {};
  5255. $scope.try_async_load();
  5256. var fildata = {
  5257. idx: 0,
  5258. sum: 10,
  5259. 'hw_state': '在库'
  5260. }
  5261. $scope.memoryfilterData = fildata;
  5262. $scope.refreshData('expand-right', fildata);
  5263. }
  5264. $scope.cifilter_classic = {};
  5265. $scope.chiceIncident = function (item) {
  5266. var fildata = defaultFilterData;
  5267. // fildata.applicationForm = {};
  5268. // sign: basehwnwswt
  5269. if (item && item.id) {
  5270. var classify = item.prefix.toLowerCase() + item.sign;
  5271. fildata.sign = classify
  5272. } else {
  5273. delete fildata.sign
  5274. }
  5275. $scope.gridOptions.paginationCurrentPage = 1;
  5276. var transitiondata = angular.copy(item);
  5277. $scope.refreshData('expand-right', fildata);
  5278. }
  5279. $scope.applicadata = [];
  5280. $scope.onFilterCallback = function (item) {
  5281. var tempclassify = item.prefix.toLowerCase() + item.sign;
  5282. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  5283. var myData = Restangular.stripRestangular(data);
  5284. $scope.applicadata = myData[0].form.fields;
  5285. });
  5286. // }
  5287. }
  5288. // $scope.loadData({
  5289. // idx: 0,
  5290. // sum: 10,
  5291. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5292. // });
  5293. $scope.selected = {
  5294. items: []
  5295. };
  5296. $scope.ok = function () {
  5297. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  5298. // onDataCallback($scope.selected.item, parentScope);
  5299. // }
  5300. $modalInstance.close($scope.selected.items);
  5301. };
  5302. $scope.cancel = function () {
  5303. $modalInstance.dismiss('cancel');
  5304. };
  5305. },
  5306. size: 'lg',
  5307. resolve: {
  5308. items: function () {
  5309. return {
  5310. fetchItems: function (filterData, APIService) {
  5311. filterData = filterData || {};
  5312. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  5313. filterData = {
  5314. idx: 0,
  5315. sum: 10,
  5316. "user": {
  5317. "roledata": {
  5318. "rolecode": "roleset"
  5319. },
  5320. "selectType": "1"
  5321. }
  5322. };
  5323. }
  5324. return $scope.options.templateOptions.fetchItems(filterData, APIService);
  5325. }
  5326. };
  5327. },
  5328. title: function () {
  5329. return $scope.options.templateOptions.label;
  5330. },
  5331. Restangular: function () {
  5332. return $scope.options.templateOptions.Restangular;
  5333. },
  5334. APIService: function () {
  5335. return $scope.options.templateOptions.ApiService;
  5336. },
  5337. onDataCallback: function () {
  5338. return $scope.options.templateOptions.callback;
  5339. },
  5340. parentScope: function () {
  5341. return $scope.options.templateOptions.that;
  5342. }
  5343. }
  5344. });
  5345. modalInstance.result.then(function (selectedItem) {
  5346. // console.log(selectedItem);
  5347. // options.value(selectedItem);
  5348. var filterData = $scope.memoryfilterDatashe;
  5349. $scope.myDatalingbeiall = selectedItem;
  5350. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5351. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5352. $scope.myDatalingbeiall[i]['item'] = i + 1 + filterData.idx * filterData.sum
  5353. }
  5354. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5355. $scope.model.assets = $scope.myDatalingbeiall;
  5356. $scope.$parent.$parent.$parent.model.applicationForm.assets = $scope.myDatalingbeiall;
  5357. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  5358. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  5359. // }
  5360. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  5361. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  5362. // }
  5363. }, function () {
  5364. //console.log('Modal dismissed at: ' + new Date());
  5365. });
  5366. }
  5367. $scope.onDblClick = function (data, event) {
  5368. $scope.selectButtonClick(data, event);
  5369. };
  5370. // $scope.loadData = function(filterData) {};
  5371. // $scope.title = title;
  5372. // $scope.loadData({
  5373. // idx: 0,
  5374. // sum: 20,
  5375. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5376. // });
  5377. $scope.selected = {
  5378. items: []
  5379. };
  5380. //grid2
  5381. $scope.langs = i18nService.getAllLangs();
  5382. $scope.lang = 'zh-cn';
  5383. i18nService.setCurrentLang($scope.lang);
  5384. $scope.gridOptions2 = {};
  5385. $scope.gridOptions2.data = 'myDataone';
  5386. $scope.gridOptions2.enableColumnResizing = true;
  5387. $scope.gridOptions2.enableFiltering = false;
  5388. $scope.gridOptions2.enableGridMenu = false;
  5389. $scope.gridOptions2.showGridFooter = true;
  5390. $scope.gridOptions2.showColumnFooter = false;
  5391. $scope.gridOptions2.fastWatch = true;
  5392. $scope.gridOptions2.useExternalFiltering = true;
  5393. $scope.gridOptions2.useExternalPagination = true;
  5394. $scope.gridOptions2.paginationPageSizes = [10];
  5395. $scope.gridOptions2.paginationPageSize = 10;
  5396. $scope.gridOptions2.multiSelect = false;
  5397. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5398. $scope.gridOptions2.columnDefs = [{
  5399. name: 'item',
  5400. displayName: '序号',
  5401. width: 120
  5402. },
  5403. {
  5404. name: 'name',
  5405. displayName: '耗材名称',
  5406. width: 150,
  5407. enableFiltering: false
  5408. },
  5409. {
  5410. name: 'model',
  5411. displayName: '品牌/型号',
  5412. width: 100,
  5413. enableFiltering: false
  5414. },
  5415. {
  5416. name: 'Specifications',
  5417. displayName: '规格',
  5418. width: 150,
  5419. enableFiltering: false
  5420. },
  5421. {
  5422. name: 'sum',
  5423. displayName: '领用数量',
  5424. enableFiltering: false
  5425. }
  5426. ];
  5427. // $scope.selectButtonClick
  5428. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5429. $scope.gridApi = gridApi;
  5430. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  5431. // var filtersData = $scope.memoryfilterData;
  5432. // filtersData.idx = newPage - 1;
  5433. // filtersData.sum = pageSize;
  5434. // $scope.loadData(filtersData);
  5435. $scope.memoryfilterDatahao.idx = newPage - 1;
  5436. $scope.memoryfilterDatahao.sum = pageSize;
  5437. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, $scope.memoryfilterDatahao.idx, 10)
  5438. });
  5439. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5440. $scope.selected.items.push(data.entity);
  5441. //console.log(data);
  5442. });
  5443. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  5444. $scope.selected.items.push(data.entity);
  5445. //console.log(data);
  5446. });
  5447. gridApi.core.on.filterChanged($scope, function () {
  5448. var grid = this.grid;
  5449. var filtersData = {
  5450. idx: 0,
  5451. sum: 10,
  5452. "user": {
  5453. "roledata": {
  5454. "rolecode": "roleset"
  5455. },
  5456. "selectType": "1"
  5457. }
  5458. };
  5459. angular.forEach(grid.columns, function (item) {
  5460. if (item.enableFiltering) {
  5461. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5462. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5463. if (angular.isUndefined(filtersData['user'])) {
  5464. filtersData['user'] = {};
  5465. }
  5466. filtersData['user'][item.field] = item.filters[0].term;
  5467. }
  5468. }
  5469. });
  5470. $scope.memoryfilterDatahao = filtersData;
  5471. $scope.loadData(filtersData);
  5472. });
  5473. };
  5474. $scope.removehaocai = function (item) {
  5475. event.preventDefault();
  5476. // var modalInstance = $modal.open({
  5477. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  5478. // controller: function($scope, $modalInstance) {
  5479. // $scope.title = "修改耗材数量";
  5480. // $scope.consumptive = item;
  5481. // $scope.ok = function() {
  5482. // $modalInstance.close($scope.consumptive);
  5483. // };
  5484. // $scope.cancel = function() {
  5485. // $modalInstance.dismiss('cancel');
  5486. // };
  5487. // },
  5488. // size: 'sm'
  5489. // });
  5490. var modalInstance = $modal.open({
  5491. templateUrl: 'assets/views/delete.html',
  5492. controller: function ($scope, $modalInstance, scope) {
  5493. $scope.title = '耗材移除';
  5494. $scope.connect = '确定要移除此设备?';
  5495. $scope.consumptive = scope.selected.items[0];
  5496. $scope.ok = function () {
  5497. $modalInstance.close($scope.consumptive);
  5498. };
  5499. $scope.cancel = function () {
  5500. $modalInstance.dismiss('cancel');
  5501. };
  5502. },
  5503. size: 'sm',
  5504. resolve: {
  5505. scope: function () {
  5506. return $scope;
  5507. },
  5508. }
  5509. });
  5510. modalInstance.result.then(function (selectedItem) {
  5511. // angular.forEach($scope.myData3, function(items, index) {
  5512. // if (items.id == selectedItem.id) {
  5513. // $scope.myData3[index] = selectedItem;
  5514. // }
  5515. // })
  5516. // $scope.model.applicationForm.consumables = $scope.myData3;
  5517. angular.forEach($scope.myDataoneall, function (items, index) {
  5518. if (items.id == selectedItem.id) {
  5519. $scope.myDataoneall.splice(index, 1);
  5520. }
  5521. })
  5522. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5523. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5524. }
  5525. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5526. $scope.model.consumables = $scope.myDataoneall;
  5527. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5528. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5529. $scope.selected = {
  5530. items: []
  5531. };
  5532. })
  5533. }
  5534. $scope.haocaiadd = function () {
  5535. event.preventDefault();
  5536. var modalInstance = $modal.open({
  5537. templateUrl: 'assets/views/customform/tpl/cmdb/add_haocai.html',
  5538. controller: function ($scope, scope, $modalInstance, api_wechatfile, SweetAlert, api_cmdb3) {
  5539. $scope.haocainame = [];
  5540. $scope.pinpai = [];
  5541. $scope.guige = [];
  5542. $scope.consumptive = {};
  5543. $scope.consumpall = {};
  5544. $scope.title = "添加耗材";
  5545. api_wechatfile.getDictionaryForList({
  5546. "key": "haocaifenlei"
  5547. }).then(function (data) {
  5548. $scope.haocainame = data;
  5549. })
  5550. $scope.clearNoNum = function (obj, attr) {
  5551. //先把非数字的都替换掉,除了数字和.
  5552. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5553. //必须保证第一个为数字而不是.
  5554. obj[attr] = obj[attr].replace(/^\./g, "");
  5555. //保证只有出现一个.而没有多个.
  5556. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5557. //保证.只出现一次,而不能出现两次以上
  5558. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  5559. //小于最大值
  5560. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5561. alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5562. obj[attr] = '';
  5563. }
  5564. }
  5565. $scope.onChange = function (parent) {
  5566. $scope.consumptive.model = {};
  5567. $scope.consumptive.Specifications = {};
  5568. api_wechatfile.getDictionaryForList({
  5569. "key": "pinpai",
  5570. "parent": parent.id
  5571. }).then(function (data) {
  5572. $scope.pinpai = data;
  5573. })
  5574. api_wechatfile.getDictionaryForList({
  5575. "key": "guige",
  5576. "parent": parent.id
  5577. }).then(function (data) {
  5578. $scope.guige = data;
  5579. })
  5580. }
  5581. $scope.onChangesum = function (item) {
  5582. if (item.name && item.model.id && item.Specifications.id) {
  5583. $scope.consumptive.sum = "";
  5584. var data1 = {
  5585. "idx": 0,
  5586. "sum": 10,
  5587. "consumable": {
  5588. "name": item.name.name,
  5589. "brandModel": item.model.name,
  5590. "specification": item.Specifications.name
  5591. }
  5592. }
  5593. api_cmdb3.fetchDataList('consumable', data1).then(function (data) {
  5594. if (data.status == 200 && data.list.length > 0) {
  5595. var myData = data.list;
  5596. $scope.consumpall = myData[0];
  5597. $scope.maxsum = myData[0].inventoryNum;
  5598. } else {
  5599. SweetAlert.swal({
  5600. title: "不存在该耗材",
  5601. text: "请检查库存后重新填写!",
  5602. type: "error"
  5603. });
  5604. }
  5605. });
  5606. }
  5607. }
  5608. $scope.addhaocai = function () {
  5609. $modalInstance.dismiss('cancel');
  5610. scope.haocaiopen($scope.consumptive);
  5611. }
  5612. $scope.ok = function (item) {
  5613. var items = {};
  5614. // if (item.name && item.model && item.Specifications && item.sum) {
  5615. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5616. // $scope.consumpall.model = $scope.consumpall.brandModel;
  5617. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  5618. // $scope.consumpall.sum = item.sum;
  5619. // delete $scope.consumpall.brandModel;
  5620. // delete $scope.consumpall.specification;
  5621. // $modalInstance.close($scope.consumpall);
  5622. // } else {
  5623. // SweetAlert.swal({
  5624. // title: "数据填写不完整!",
  5625. // text: "请检查数据然后提交!",
  5626. // type: "error"
  5627. // });
  5628. // }
  5629. var isold = false;
  5630. if (item.name && (item.model && JSON.stringify(item.model) != "{}") && (item.Specifications && JSON.stringify(item.Specifications) != "{}") && item.sum) {
  5631. for (var i = 0; i < scope.myDataoneall.length; i++) {
  5632. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  5633. isold = true;
  5634. }
  5635. }
  5636. if (isold) {
  5637. SweetAlert.swal({
  5638. title: "该耗材已添加!",
  5639. text: "请不要重复添加耗材!",
  5640. type: "error"
  5641. });
  5642. } else {
  5643. $scope.consumpall.model = $scope.consumpall.brandModel;
  5644. $scope.consumpall.Specifications = $scope.consumpall.specification;
  5645. $scope.consumpall.sum = item.sum;
  5646. delete $scope.consumpall.brandModel;
  5647. delete $scope.consumpall.specification;
  5648. $modalInstance.close($scope.consumpall);
  5649. }
  5650. } else {
  5651. SweetAlert.swal({
  5652. title: "数据填写不完整!",
  5653. text: "请检查数据然后提交!",
  5654. type: "error"
  5655. });
  5656. }
  5657. // $modalInstance.close(item);
  5658. };
  5659. $scope.cancel = function () {
  5660. $modalInstance.dismiss('cancel');
  5661. };
  5662. },
  5663. size: 'sm',
  5664. resolve: {
  5665. scope: function () {
  5666. return $scope;
  5667. }
  5668. }
  5669. });
  5670. modalInstance.result.then(function (selectedItem) {
  5671. $scope.myDataoneall.push(selectedItem);
  5672. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5673. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5674. }
  5675. // $scope.model.consumables = $scope.myDataone;
  5676. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5677. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5678. $scope.model.consumables = $scope.myDataoneall;
  5679. $scope.$parent.$parent.$parent.model.applicationForm.consumables = $scope.myDataoneall;
  5680. })
  5681. }
  5682. $scope.onDblClick = function (data, event) {
  5683. $scope.selectButtonClick(data, event);
  5684. };
  5685. $scope.memoryfilterDatahao = {
  5686. "idx": 0,
  5687. "sum": 10,
  5688. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5689. }
  5690. $scope.myDataone = [];
  5691. $scope.loadData = function (filterData) { };
  5692. // $scope.title = title;
  5693. $scope.ldloading = {};
  5694. $scope.selected = {
  5695. items: []
  5696. };
  5697. if ($scope.$parent.$parent.$parent.model.gettype) {
  5698. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  5699. if ($scope.model.assets) {
  5700. if (JSON.stringify($scope.model.assets) == "{}") {
  5701. $scope.model.assets = []
  5702. } else {
  5703. $scope.model.assets = JSON.parse($scope.model.assets);
  5704. }
  5705. $scope.myDatalingbeiall = $scope.model.assets;
  5706. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5707. $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatashe.idx * 10
  5708. }
  5709. $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5710. $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5711. }
  5712. if ($scope.model.consumables) {
  5713. if (JSON.stringify($scope.model.consumables) == "{}") {
  5714. $scope.model.consumables = []
  5715. } else {
  5716. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5717. }
  5718. $scope.myDataoneall = $scope.model.consumables;
  5719. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  5720. $scope.myDataoneall[i]['item'] = i + 1 + $scope.memoryfilterDatahao.idx * 10
  5721. }
  5722. $scope.gridOptions2['totalItems'] = $scope.myDataoneall.length;
  5723. $scope.myDataone = $scope.interceptMydata($scope.myDataoneall, 0, 10)
  5724. }
  5725. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5726. $scope.options.templateOptions.getpush({
  5727. "hao": true,
  5728. "gu": true
  5729. });
  5730. } else {
  5731. $scope.options.templateOptions.getpush({
  5732. "hao": true
  5733. });
  5734. }
  5735. } else {
  5736. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  5737. $scope.options.templateOptions.getpush({
  5738. "gu": true
  5739. });
  5740. }
  5741. }
  5742. }
  5743. }]
  5744. });
  5745. formlyConfigProvider.setType({
  5746. name: 'ui-panel',
  5747. templateUrl: 'assets/views/customform/tpl/ui-panel.html'
  5748. });
  5749. formlyConfigProvider.setType({
  5750. name: 'ui-currentuser',
  5751. extends: 'input',
  5752. templateUrl: 'assets/views/customform/tpl/ui-username.html',
  5753. defaultOptions: function (options) {
  5754. return {
  5755. templateOptions: {
  5756. // link: function() {}
  5757. }
  5758. };
  5759. },
  5760. controller: ['$scope', function ($scope) {
  5761. if ($scope.options.templateOptions.user) {
  5762. if (angular.isFunction($scope.options.templateOptions.transform)) {
  5763. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  5764. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  5765. // }
  5766. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5767. $scope.$parent.$parent.$parent.model['directClose'] = false;
  5768. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  5769. }
  5770. $scope.model[$scope.options.key] = $scope.options.templateOptions.user;
  5771. $scope.options.initialValue = $scope.model[$scope.options.key];
  5772. }
  5773. }]
  5774. });
  5775. //仪表盘
  5776. //待处理变更列表
  5777. formlyConfigProvider.setType({
  5778. name: 'ui-ngpchangetable',
  5779. templateUrl: 'assets/views/customform/tpl/ui-ngpchangetable.html',
  5780. defaultOptions: function (options) {
  5781. return {
  5782. templateOptions: {
  5783. // relationAction: function() {
  5784. // options.hideExpression = true
  5785. // }
  5786. }
  5787. };
  5788. },
  5789. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5790. // var filterData = {
  5791. // "assignee": $rootScope.user.id,
  5792. // "searchtype": "all",
  5793. // "idx": "0",
  5794. // "sum": "10"
  5795. // };
  5796. var filterData = {
  5797. "idx": "0",
  5798. "sum": "10",
  5799. "assignee": 2,
  5800. "searchType": "todo"
  5801. }
  5802. $scope.incidentprocess = function (item) {
  5803. $state.go('app.wt_change.add', {
  5804. taskId: item.taskId,
  5805. processInstanceId: item.processInstanceId
  5806. });
  5807. }
  5808. $scope.more = function () {
  5809. $state.go('app.wt_change.list', {})
  5810. }
  5811. api_bpm_domain.fetchtask('bpm_change', filterData).then(function (data) {
  5812. if (data.data) {
  5813. $scope.myData = data.data;
  5814. } else {
  5815. SweetAlert.swal({
  5816. title: "操作异常!",
  5817. text: "系统异常,请稍后重试,或者联系管理员!",
  5818. type: "error"
  5819. });
  5820. }
  5821. })
  5822. $scope.removes = function () {
  5823. var modalInstance = $modal.open({
  5824. templateUrl: 'assets/views/delete.html',
  5825. controller: function ($scope, $modalInstance) {
  5826. $scope.ok = function () {
  5827. $modalInstance.close();
  5828. };
  5829. $scope.cancel = function () {
  5830. $modalInstance.dismiss('cancel');
  5831. };
  5832. },
  5833. size: 'sm'
  5834. });
  5835. modalInstance.result.then(function () {
  5836. console.log($scope.$parent.$parent.$parent.$parent)
  5837. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5838. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5839. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5840. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5841. break;
  5842. }
  5843. }
  5844. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5845. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5846. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5847. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5848. }
  5849. })
  5850. }
  5851. }]
  5852. });
  5853. //待处理问题列表
  5854. formlyConfigProvider.setType({
  5855. name: 'ui-ngproblemtable',
  5856. templateUrl: 'assets/views/customform/tpl/ui-ngproblemtable.html',
  5857. defaultOptions: function (options) {
  5858. return {
  5859. templateOptions: {
  5860. // relationAction: function() {
  5861. // options.hideExpression = true
  5862. // }
  5863. }
  5864. };
  5865. },
  5866. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_data, $rootScope, ngTableParams, $filter, $state) {
  5867. var filterData = {
  5868. "assignee": $rootScope.user.id,
  5869. "candidateGroups": $rootScope.user.group[0].id,
  5870. "searchtype": "todo",
  5871. "idx": 0,
  5872. "sum": 10
  5873. };
  5874. $scope.incidentprocess = function (item) {
  5875. $state.go('app.wt_change.add', {
  5876. taskId: item.taskId,
  5877. processInstanceId: item.processInstanceId
  5878. });
  5879. }
  5880. $scope.more = function () {
  5881. $state.go('app.wt_change.list', {})
  5882. }
  5883. api_bpm_data.fetchDataList('changeclassify', filterData).then(function (data) {
  5884. if (data.data) {
  5885. $scope.myData = data.data;
  5886. } else {
  5887. SweetAlert.swal({
  5888. title: "操作异常!",
  5889. text: "系统异常,请稍后重试,或者联系管理员!",
  5890. type: "error"
  5891. });
  5892. }
  5893. })
  5894. $scope.removes = function () {
  5895. var modalInstance = $modal.open({
  5896. templateUrl: 'assets/views/delete.html',
  5897. controller: function ($scope, $modalInstance) {
  5898. $scope.ok = function () {
  5899. $modalInstance.close();
  5900. };
  5901. $scope.cancel = function () {
  5902. $modalInstance.dismiss('cancel');
  5903. };
  5904. },
  5905. size: 'sm'
  5906. });
  5907. modalInstance.result.then(function () {
  5908. console.log($scope.$parent.$parent.$parent.$parent)
  5909. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5910. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5911. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5912. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5913. break;
  5914. }
  5915. }
  5916. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5917. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5918. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5919. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5920. }
  5921. })
  5922. }
  5923. }]
  5924. });
  5925. //待处理事件列表
  5926. formlyConfigProvider.setType({
  5927. name: 'ui-ngtable',
  5928. templateUrl: 'assets/views/customform/tpl/ui-ngtable.html',
  5929. defaultOptions: function (options) {
  5930. return {
  5931. templateOptions: {
  5932. // relationAction: function() {
  5933. // options.hideExpression = true
  5934. // }
  5935. }
  5936. };
  5937. },
  5938. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_bpm_domain', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_bpm_domain, $rootScope, ngTableParams, $filter, $state) {
  5939. var filterData = {
  5940. "assignee": $rootScope.user.id,
  5941. "candidateGroups": $rootScope.user.group[0].id,
  5942. "searchtype": "done",
  5943. "idx": 0,
  5944. "sum": 10
  5945. };
  5946. $scope.incidentprocess = function (item) {
  5947. $state.go('app.incident.editor', {
  5948. taskId: item.taskId,
  5949. processInstanceId: item.processInstanceId
  5950. });
  5951. }
  5952. $scope.more = function () {
  5953. $state.go('app.incident.list', {})
  5954. }
  5955. api_bpm_domain.fetchtask('bpm_incident', filterData).then(function (data) {
  5956. if (data.data) {
  5957. $scope.myData = data.data;
  5958. } else {
  5959. SweetAlert.swal({
  5960. title: "操作异常!",
  5961. text: "系统异常,请稍后重试,或者联系管理员!",
  5962. type: "error"
  5963. });
  5964. }
  5965. })
  5966. $scope.removes = function () {
  5967. var modalInstance = $modal.open({
  5968. templateUrl: 'assets/views/delete.html',
  5969. controller: function ($scope, $modalInstance) {
  5970. $scope.ok = function () {
  5971. $modalInstance.close();
  5972. };
  5973. $scope.cancel = function () {
  5974. $modalInstance.dismiss('cancel');
  5975. };
  5976. },
  5977. size: 'sm'
  5978. });
  5979. modalInstance.result.then(function () {
  5980. console.log($scope.$parent.$parent.$parent.$parent)
  5981. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  5982. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  5983. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  5984. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  5985. break;
  5986. }
  5987. }
  5988. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  5989. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  5990. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  5991. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  5992. }
  5993. })
  5994. }
  5995. }]
  5996. });
  5997. //知识库列表
  5998. formlyConfigProvider.setType({
  5999. name: 'ui-knowledge',
  6000. templateUrl: 'assets/views/customform/tpl/ui-knowledgelist.html',
  6001. defaultOptions: function (options) {
  6002. return {
  6003. templateOptions: {
  6004. // relationAction: function() {
  6005. // options.hideExpression = true
  6006. // }
  6007. }
  6008. };
  6009. },
  6010. controller: ['$scope', '$modal', '$timeout', 'api_solution', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, api_solution, $rootScope, ngTableParams, $filter, $state) {
  6011. var filterData = {
  6012. "key": "null",
  6013. "pageIndex": 0,
  6014. "pageSum": 6,
  6015. "status": 0,
  6016. "userId": $rootScope.user.id
  6017. };
  6018. $scope.model.removereport = false;
  6019. $scope.removes = function () {
  6020. $scope.model.removereport = true;
  6021. }
  6022. $scope.more = function () {
  6023. $state.go('app.knowledge.manager', {});
  6024. }
  6025. api_solution.findSolutionByKeys(filterData).then(function (data) {
  6026. if (data.status == 200) {
  6027. $scope.myData = data.list
  6028. }
  6029. })
  6030. $scope.removes = function () {
  6031. var modalInstance = $modal.open({
  6032. templateUrl: 'assets/views/delete.html',
  6033. controller: function ($scope, $modalInstance) {
  6034. $scope.ok = function () {
  6035. $modalInstance.close();
  6036. };
  6037. $scope.cancel = function () {
  6038. $modalInstance.dismiss('cancel');
  6039. };
  6040. },
  6041. size: 'sm'
  6042. });
  6043. modalInstance.result.then(function () {
  6044. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6045. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6046. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6047. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6048. break;
  6049. }
  6050. }
  6051. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6052. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6053. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6054. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6055. }
  6056. })
  6057. }
  6058. }]
  6059. });
  6060. //公告列表
  6061. formlyConfigProvider.setType({
  6062. name: 'ui-ngnotice',
  6063. templateUrl: 'assets/views/customform/tpl/ui-ngnotice.html',
  6064. defaultOptions: function (options) {
  6065. return {
  6066. templateOptions: {
  6067. // relationAction: function() {
  6068. // options.hideExpression = true
  6069. // }
  6070. }
  6071. };
  6072. },
  6073. controller: ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', '$rootScope', 'ngTableParams', '$filter', '$state', function ($scope, $modal, $timeout, SweetAlert, api_user_data, $rootScope, ngTableParams, $filter, $state) {
  6074. var filterData = {
  6075. "idx": 0,
  6076. "sum": 10
  6077. };
  6078. // $scope.$scope.model.className = "col-xs-12";
  6079. api_user_data.fetchDataList('notice', filterData).then(function (data) {
  6080. if (data) {
  6081. $scope.myData = data.data;
  6082. } else {
  6083. SweetAlert.swal({
  6084. title: "操作异常!",
  6085. text: "系统异常,请稍后重试,或者联系管理员!",
  6086. type: "error"
  6087. });
  6088. }
  6089. })
  6090. $scope.more = function () {
  6091. $state.go('app.system.notice.list', {});
  6092. }
  6093. $scope.removes = function () {
  6094. var modalInstance = $modal.open({
  6095. templateUrl: 'assets/views/delete.html',
  6096. controller: function ($scope, $modalInstance) {
  6097. $scope.ok = function () {
  6098. $modalInstance.close();
  6099. };
  6100. $scope.cancel = function () {
  6101. $modalInstance.dismiss('cancel');
  6102. };
  6103. },
  6104. size: 'sm'
  6105. });
  6106. modalInstance.result.then(function () {
  6107. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6108. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6109. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6110. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6111. break;
  6112. }
  6113. }
  6114. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6115. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6116. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6117. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6118. }
  6119. })
  6120. }
  6121. }]
  6122. });
  6123. //事件统计图
  6124. formlyConfigProvider.setType({
  6125. name: 'ui-incidentreport',
  6126. templateUrl: 'assets/views/customform/tpl/ui-incidentreport.html',
  6127. defaultOptions: function (options) {
  6128. return {
  6129. templateOptions: {
  6130. // relationAction: function() {
  6131. // options.hideExpression = true
  6132. // }
  6133. }
  6134. };
  6135. },
  6136. controller: ['$scope', '$modal', 'moment', 'api_report', '$cookieStore', function ($scope, $modal, moment, api_report, $cookieStore) {
  6137. api_report.getLicenseKey().then(function (response) {
  6138. $cookieStore.put('Auth-Token', response.token);
  6139. $scope.try_async_load();
  6140. });
  6141. $scope.try_async_load = function () {
  6142. $scope.my_data = [];
  6143. api_report.list().then(function (response) {
  6144. var dataList = response;
  6145. getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
  6146. $scope.repoRoot.name = "事件报表"
  6147. convertRepoObject($scope.repoRoot);
  6148. $scope.my_data.push($scope.repoRoot);
  6149. });
  6150. };
  6151. var workspace = {};
  6152. $scope.repoRoot = null;
  6153. function getRepoRoot(repo, path) {
  6154. angular.forEach(repo, function (value, key) {
  6155. if (value.path == path) {
  6156. $scope.repoRoot = value;
  6157. } else {
  6158. if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
  6159. getRepoRoot(value.repoObjects, path);
  6160. } else {
  6161. }
  6162. }
  6163. });
  6164. }
  6165. function convertRepoObject(repo) {
  6166. if (angular.isArray(repo)) {
  6167. angular.forEach(repo, function (value, key) {
  6168. convertRepoObject(value);
  6169. })
  6170. } else {
  6171. if (angular.isDefined(repo.name)) {
  6172. if (repo.name.indexOf(".") >= 0) {
  6173. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  6174. } else {
  6175. repo.label = repo.name;
  6176. }
  6177. //delete repo.name;
  6178. }
  6179. if (angular.isDefined(repo.repoObjects)) {
  6180. repo.children = [];
  6181. repo.children = repo.repoObjects;
  6182. delete repo.repoObjects;
  6183. convertRepoObject(repo.children);
  6184. }
  6185. }
  6186. }
  6187. function parseDateParameter(parameters) {
  6188. var result = undefined;
  6189. if (angular.isArray(parameters)) {
  6190. // angular.forEach(parmeters,function(param){
  6191. // param.
  6192. // })
  6193. } else {
  6194. result = {};
  6195. for (var k in parameters) {
  6196. if (k.indexOf("Date") > 0) {
  6197. if (angular.isString(parameters[k])) {
  6198. result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
  6199. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  6200. }
  6201. }
  6202. }
  6203. }
  6204. return result;
  6205. }
  6206. function ConvertDateParameter(parameters) {
  6207. var result = undefined;
  6208. if (angular.isArray(parameters)) {
  6209. //
  6210. } else {
  6211. result = {};
  6212. for (var k in parameters) {
  6213. if (k.indexOf("Date") > 0) {
  6214. if (angular.isDate(parameters[k])) {
  6215. result[k] = moment(parameters[k]).format("YYYYMMDD");
  6216. } else if (angular.isString(parameters[k])) {
  6217. result[k] = parameters[k];
  6218. }
  6219. }
  6220. }
  6221. }
  6222. return result;
  6223. }
  6224. var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  6225. var queryUUID;
  6226. function genUUID() {
  6227. var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
  6228. function (c) {
  6229. var r = Math.random() * 16 | 0,
  6230. v = c == 'x' ? r : (r & 0x3 | 0x8);
  6231. return v.toString(16);
  6232. }).toUpperCase();
  6233. return uuid;
  6234. }
  6235. queryUUID = genUUID();
  6236. var pathincidenttimekey = [];
  6237. var incidenttime = {
  6238. 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
  6239. 'endtimes': moment(new Date()).format('YYYYMMDD')
  6240. };
  6241. var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
  6242. var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
  6243. var averages = [
  6244. [thisdaymine - 86400000 * 14, 0],
  6245. [thisdaymine - 86400000 * 13, 0],
  6246. [thisdaymine - 86400000 * 12, 0],
  6247. [thisdaymine - 86400000 * 11, 0],
  6248. [thisdaymine - 86400000 * 10, 0],
  6249. [thisdaymine - 86400000 * 9, 0],
  6250. [thisdaymine - 86400000 * 8, 0],
  6251. [thisdaymine - 86400000 * 7, 0],
  6252. [thisdaymine - 86400000 * 6, 0],
  6253. [thisdaymine - 86400000 * 5, 0],
  6254. [thisdaymine - 86400000 * 4, 0],
  6255. [thisdaymine - 86400000 * 3, 0],
  6256. [thisdaymine - 86400000 * 2, 0],
  6257. [thisdaymine - 86400000 * 1, 0],
  6258. [thisdaymine, 0]
  6259. ];
  6260. var getreportdata = function (incidenttime, path) {
  6261. api_report.getMdx(path, queryUUID).then(function (response) {
  6262. var mdxquery = response;
  6263. workspace.query = mdxquery;
  6264. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  6265. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  6266. $scope.parameters = parseDateParameter(workspace.query.parameters);
  6267. weekuser(mdxquery);
  6268. });
  6269. }
  6270. getreportdata(incidenttime, incidentchart);
  6271. var weekuser = function (mdxquery) {
  6272. var key = [];
  6273. api_report.execute(mdxquery).then(function (data) {
  6274. $scope.rheaders = [];
  6275. $scope.rRows = [];
  6276. var reportData = data;
  6277. if (reportData.cellset == null || reportData.cellset.length == 0) {
  6278. $scope.shows = true;
  6279. $scope.empty = "数据为空!"
  6280. } else {
  6281. angular.forEach(reportData.cellset, function (item, i) {
  6282. angular.forEach(averages, function (index, j) {
  6283. // angular.forEach(averages, function(item, index) {
  6284. if (item.length > 1 && i > 0 && item[1].value != '') {
  6285. if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
  6286. index[1] = Number(item[1].value);
  6287. }
  6288. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  6289. }
  6290. // })
  6291. })
  6292. })
  6293. incidentchartfun(averages);
  6294. }
  6295. })
  6296. }
  6297. var incidentchartfun = function (incidentchartkey) {
  6298. // $scope.isMaskincident = false;
  6299. Highcharts.chart('incidentchart', {
  6300. title: {
  6301. text: '事件近15天趋势图'
  6302. },
  6303. xAxis: {
  6304. type: 'datetime',
  6305. labels: {
  6306. align: 'left',
  6307. step: 1
  6308. }
  6309. },
  6310. yAxis: {
  6311. title: {
  6312. text: null
  6313. }
  6314. },
  6315. tooltip: {
  6316. crosshairs: true,
  6317. shared: true,
  6318. valueSuffix: '条'
  6319. },
  6320. legend: {},
  6321. series: [{
  6322. name: '生成事件',
  6323. data: incidentchartkey,
  6324. zIndex: 1,
  6325. marker: {
  6326. fillColor: 'white',
  6327. lineWidth: 2,
  6328. lineColor: Highcharts.getOptions().colors[0]
  6329. }
  6330. }]
  6331. });
  6332. }
  6333. $scope.data = {
  6334. labels: ['1号', '2号', '3号', '4号', '5号', '6号', '7号', '8号', '9号', '10号', '11号', '12号', '13号', '14号', '15号'],
  6335. datasets: [{
  6336. label: '新增事件数量',
  6337. fillColor: 'rgba(220,220,220,0.2)',
  6338. strokeColor: 'rgba(220,220,220,1)',
  6339. pointColor: 'rgba(220,220,220,1)',
  6340. pointStrokeColor: '#fff',
  6341. pointHighlightFill: '#fff',
  6342. pointHighlightStroke: 'rgba(220,220,220,1)',
  6343. data: [65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34]
  6344. },
  6345. {
  6346. label: '已解决事件数量',
  6347. fillColor: 'rgba(151,187,205,0.2)',
  6348. strokeColor: 'rgba(151,187,205,1)',
  6349. pointColor: 'rgba(151,187,205,1)',
  6350. pointStrokeColor: '#fff',
  6351. pointHighlightFill: '#fff',
  6352. pointHighlightStroke: 'rgba(151,187,205,1)',
  6353. data: [48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20]
  6354. }
  6355. ]
  6356. };
  6357. $scope.removes = function () {
  6358. var modalInstance = $modal.open({
  6359. templateUrl: 'assets/views/delete.html',
  6360. controller: function ($scope, $modalInstance) {
  6361. $scope.ok = function () {
  6362. $modalInstance.close();
  6363. };
  6364. $scope.cancel = function () {
  6365. $modalInstance.dismiss('cancel');
  6366. };
  6367. },
  6368. size: 'sm'
  6369. });
  6370. modalInstance.result.then(function () {
  6371. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6372. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6373. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6374. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6375. break;
  6376. }
  6377. }
  6378. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6379. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6380. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6381. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6382. }
  6383. })
  6384. }
  6385. var addDatas = 0;
  6386. var resolve = 0;
  6387. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  6388. addDatas = addDatas + $scope.data.datasets[0].data[i];
  6389. }
  6390. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  6391. resolve = resolve + $scope.data.datasets[1].data[i];
  6392. }
  6393. $scope.resolution = (resolve / addDatas * 100).toFixed(2);
  6394. $scope.opt = {
  6395. maintainAspectRatio: false,
  6396. // Sets the chart to be responsive
  6397. responsive: true,
  6398. ///Boolean - Whether grid lines are shown across the chart
  6399. scaleShowGridLines: true,
  6400. //String - Colour of the grid lines
  6401. scaleGridLineColor: 'rgba(0,0,0,.05)',
  6402. //Number - Width of the grid lines
  6403. scaleGridLineWidth: 1,
  6404. //Boolean - Whether the line is curved between points
  6405. bezierCurve: false,
  6406. //Number - Tension of the bezier curve between points
  6407. bezierCurveTension: 0.4,
  6408. //Boolean - Whether to show a dot for each point
  6409. pointDot: true,
  6410. //Number - Radius of each point dot in pixels
  6411. pointDotRadius: 4,
  6412. //Number - Pixel width of point dot stroke
  6413. pointDotStrokeWidth: 1,
  6414. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  6415. pointHitDetectionRadius: 20,
  6416. //Boolean - Whether to show a stroke for datasets
  6417. datasetStroke: true,
  6418. //Number - Pixel width of dataset stroke
  6419. datasetStrokeWidth: 2,
  6420. //Boolean - Whether to fill the dataset with a colour
  6421. datasetFill: true,
  6422. // Function - on animation progress
  6423. onAnimationProgress: function () { },
  6424. // Function - on animation complete
  6425. onAnimationComplete: function () { },
  6426. //String - A legend template
  6427. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  6428. };
  6429. angular.extend($scope.options, $scope.opt)
  6430. $scope.datamonth = {
  6431. labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
  6432. datasets: [{
  6433. label: '新增事件数量',
  6434. fillColor: 'rgba(220,220,220,0.5)',
  6435. strokeColor: 'rgba(220,220,220,0.8)',
  6436. highlightFill: 'rgba(220,220,220,0.75)',
  6437. highlightStroke: 'rgba(220,220,220,1)',
  6438. data: [65, 59, 80, 81, 56, 55]
  6439. },
  6440. {
  6441. label: '已解决事件数量',
  6442. fillColor: 'rgba(151,187,205,0.5)',
  6443. strokeColor: 'rgba(151,187,205,0.8)',
  6444. highlightFill: 'rgba(151,187,205,0.75)',
  6445. highlightStroke: 'rgba(151,187,205,1)',
  6446. data: [28, 48, 40, 19, 86, 27]
  6447. }
  6448. ]
  6449. };
  6450. // Chart.js Options
  6451. $scope.taption = {
  6452. maintainAspectRatio: false,
  6453. // Sets the chart to be responsive
  6454. responsive: true,
  6455. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  6456. scaleBeginAtZero: true,
  6457. //Boolean - Whether grid lines are shown across the chart
  6458. scaleShowGridLines: true,
  6459. //String - Colour of the grid lines
  6460. scaleGridLineColor: "rgba(0,0,0,.05)",
  6461. //Number - Width of the grid lines
  6462. scaleGridLineWidth: 1,
  6463. //Boolean - If there is a stroke on each bar
  6464. barShowStroke: true,
  6465. //Number - Pixel width of the bar stroke
  6466. barStrokeWidth: 2,
  6467. //Number - Spacing between each of the X value sets
  6468. barValueSpacing: 5,
  6469. //Number - Spacing between data sets within X values
  6470. barDatasetSpacing: 1,
  6471. //String - A legend template
  6472. legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'
  6473. };
  6474. }]
  6475. });
  6476. //排版日历
  6477. formlyConfigProvider.setType({
  6478. name: 'ui-dashcalendar',
  6479. templateUrl: 'assets/views/customform/tpl/ui-dashcalendar.html',
  6480. defaultOptions: function (options) {
  6481. return {
  6482. templateOptions: {
  6483. // relationAction: function() {
  6484. // options.hideExpression = true
  6485. // }
  6486. }
  6487. };
  6488. },
  6489. controller: ["$rootScope", "$scope", "$modal", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", "$state", function ($rootScope, $scope, $modal, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data, $state) {
  6490. var loginUser = $rootScope.user;
  6491. calendarConfig.dateFormatter = 'moment';
  6492. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  6493. calendarConfig.i18nStrings.timeLabel = '时间';
  6494. calendarConfig.i18nStrings.weekNumber = '{week}周';
  6495. calendarConfig.allDateFormats = {
  6496. angular: {
  6497. date: {
  6498. hour: 'ha',
  6499. day: 'd MMM',
  6500. month: 'MMMM',
  6501. weekDay: 'EEEE',
  6502. time: 'HH:mm',
  6503. datetime: 'MMM d, h:mm a'
  6504. },
  6505. title: {
  6506. day: 'yyyy MMMM EEEE d',
  6507. week: '{year}年第{week}周',
  6508. month: 'yyyy MMMM',
  6509. year: 'yyyy'
  6510. }
  6511. },
  6512. moment: {
  6513. date: {
  6514. hour: 'ha',
  6515. day: 'MMMDD日',
  6516. month: 'MMMM',
  6517. weekDay: 'dddd',
  6518. time: 'HH:mm',
  6519. datetime: 'MMM D, h:mm a'
  6520. },
  6521. title: {
  6522. day: 'YYYY年MMMMDD日, dddd ',
  6523. week: '{year}年第{week}周',
  6524. month: 'YYYY年MMMM',
  6525. year: 'YYYY'
  6526. }
  6527. }
  6528. };
  6529. moment.locale('zh_cn', {
  6530. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  6531. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  6532. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6533. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6534. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6535. longDateFormat: {
  6536. LT: 'Ah点mm分',
  6537. LTS: 'Ah点m分s秒',
  6538. L: 'YYYY-MM-DD',
  6539. LL: 'YYYY年MMMD日',
  6540. LLL: 'YYYY年MMMD日Ah点mm分',
  6541. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  6542. l: 'YYYY-MM-DD',
  6543. ll: 'YYYY年MMMD日',
  6544. lll: 'YYYY年MMMD日Ah点mm分',
  6545. llll: 'YYYY年MMMD日ddddAh点mm分'
  6546. },
  6547. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6548. meridiemHour: function (hour, meridiem) {
  6549. if (hour === 12) {
  6550. hour = 0;
  6551. }
  6552. if (meridiem === '凌晨' || meridiem === '早上' ||
  6553. meridiem === '上午') {
  6554. return hour;
  6555. } else if (meridiem === '下午' || meridiem === '晚上') {
  6556. return hour + 12;
  6557. } else {
  6558. // '中午'
  6559. return hour >= 11 ? hour : hour + 12;
  6560. }
  6561. },
  6562. meridiem: function (hour, minute, isLower) {
  6563. var hm = hour * 100 + minute;
  6564. if (hm < 600) {
  6565. return '凌晨';
  6566. } else if (hm < 900) {
  6567. return '早上';
  6568. } else if (hm < 1130) {
  6569. return '上午';
  6570. } else if (hm < 1230) {
  6571. return '中午';
  6572. } else if (hm < 1800) {
  6573. return '下午';
  6574. } else {
  6575. return '晚上';
  6576. }
  6577. },
  6578. calendar: {
  6579. sameDay: function () {
  6580. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  6581. },
  6582. nextDay: function () {
  6583. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  6584. },
  6585. lastDay: function () {
  6586. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  6587. },
  6588. nextWeek: function () {
  6589. var startOfWeek, prefix;
  6590. startOfWeek = moment().startOf('week');
  6591. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  6592. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6593. },
  6594. lastWeek: function () {
  6595. var startOfWeek, prefix;
  6596. startOfWeek = moment().startOf('week');
  6597. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  6598. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  6599. },
  6600. sameElse: 'LL'
  6601. },
  6602. ordinalParse: /\d{1,2}(日|月|周)/,
  6603. ordinal: function (number, period) {
  6604. switch (period) {
  6605. case 'd':
  6606. case 'D':
  6607. case 'DDD':
  6608. return number + '日';
  6609. case 'M':
  6610. return number + '月';
  6611. case 'w':
  6612. case 'W':
  6613. return number + '周';
  6614. default:
  6615. return number;
  6616. }
  6617. },
  6618. relativeTime: {
  6619. future: '%s内',
  6620. past: '%s前',
  6621. s: '几秒',
  6622. m: '1 分钟',
  6623. mm: '%d 分钟',
  6624. h: '1 小时',
  6625. hh: '%d 小时',
  6626. d: '1 天',
  6627. dd: '%d 天',
  6628. M: '1 个月',
  6629. MM: '%d 个月',
  6630. y: '1 年',
  6631. yy: '%d 年'
  6632. },
  6633. week: {
  6634. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6635. dow: 1, // Monday is the first day of the week.
  6636. doy: 4 // The week that contains Jan 4th is the first week of the year.
  6637. }
  6638. });
  6639. var date = new Date();
  6640. var d = date.getDate();
  6641. var m = date.getMonth();
  6642. var y = date.getFullYear();
  6643. var filterData = {
  6644. "userId": loginUser.id,
  6645. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  6646. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  6647. };
  6648. var load = $scope.load = function (filterData) {
  6649. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function (response) {
  6650. if (response.status == 200) {
  6651. $scope.events = [];
  6652. var myData = response.list;
  6653. angular.forEach(myData, function (item) {
  6654. var eventTemp = {};
  6655. eventTemp.title = item.description;
  6656. eventTemp.type = item.scheduleClass.code;
  6657. eventTemp.startsAt = moment(item['scheduleOrderDTO'].startTime).toDate();
  6658. eventTemp.endsAtTime = moment(item['scheduleOrderDTO'].endTime).toDate();
  6659. eventTemp.startTime = item['scheduleOrderDTO'].startTime;
  6660. eventTemp.endTime = item['scheduleOrderDTO'].endTime;
  6661. //eventTemp.ends_at = moment(item.endTime).toDate();
  6662. eventTemp.id = item.id;
  6663. eventTemp.deletable = false;
  6664. eventTemp.user = item.user;
  6665. $scope.events.push(eventTemp);
  6666. })
  6667. }
  6668. });
  6669. }
  6670. // var load = $scope.load = function(filterData){
  6671. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  6672. // console.log("response="+JSON.stringify(response));
  6673. // if(response.status==200){
  6674. // $scope.events = [];
  6675. // console.log(response.list);
  6676. // var myData = response.list;
  6677. // angular.forEach(myData,function(item){
  6678. // var eventTemp = {};
  6679. // eventTemp.title = item.description;
  6680. // eventTemp.type = item.scheduleClass.code;
  6681. // eventTemp.startsAt = moment(item.startTime).toDate();
  6682. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  6683. // eventTemp.startTime = item.startTime;
  6684. // eventTemp.endTime = item.endTime;
  6685. // //eventTemp.ends_at = moment(item.endTime).toDate();
  6686. // eventTemp.id = item.id;
  6687. // eventTemp.deletable = false;
  6688. // eventTemp.users = item.users;
  6689. // $scope.events.push(eventTemp);
  6690. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  6691. // })
  6692. // }
  6693. // });
  6694. // }
  6695. $scope.scheduleClass = {};
  6696. var convertEvent = function (scheduleorder) {
  6697. var eventTemp = {};
  6698. eventTemp.title = scheduleorder.description;
  6699. eventTemp.type = scheduleorder.scheduleClass.code;
  6700. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  6701. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  6702. eventTemp.id = scheduleorder.id;
  6703. eventTemp.user = scheduleorder.user;
  6704. eventTemp.deletable = false;
  6705. return eventTemp;
  6706. }
  6707. // var convertEvent = function(scheduleorder){
  6708. // var eventTemp = {};
  6709. // eventTemp.title = scheduleorder.description;
  6710. // eventTemp.type = scheduleorder.scheduleClass.code;
  6711. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  6712. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  6713. // eventTemp.id = scheduleorder.id;
  6714. // eventTemp.users = scheduleorder.users;
  6715. // eventTemp.deletable = false;
  6716. // return eventTemp;
  6717. // }
  6718. api_bpm_schedule.getScheduleClass().then(function (response) {
  6719. if (response.status == 200) {
  6720. var scheduleClassList = response.list;
  6721. angular.forEach(scheduleClassList, function (item) {
  6722. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  6723. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  6724. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  6725. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  6726. $scope.scheduleClass[item['code']] = item;
  6727. })
  6728. }
  6729. })
  6730. $scope.events = [];
  6731. $scope.calendarView = 'month';
  6732. //$scope.calendarDay = new Date();
  6733. $scope.calendarDate = moment().startOf('month').toDate();
  6734. $scope.timeLabel = "时间";
  6735. $scope.eventLabel = "描述";
  6736. function showModal(action, event) {
  6737. // console.log("action="+JSON.stringify(action))
  6738. var modalInstance = $aside.open({
  6739. templateUrl: 'scheduleEvent.html',
  6740. placement: 'right',
  6741. size: 'sm',
  6742. backdrop: true,
  6743. controller: function ($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  6744. $scope.$modalInstance = $modalInstance;
  6745. $scope.action = action;
  6746. $scope.event = event;
  6747. $scope.scheduleClassic = scheduleClass;
  6748. $scope.$watch('event.type', function (newvalue, oldvalue) {
  6749. // if(oldvalue == newvalue) return;
  6750. // if(scheduleClass[newvalue]){
  6751. var sm = MementFormat(scheduleClass[newvalue].startTime);
  6752. var em = MementFormat(scheduleClass[newvalue].endTime);
  6753. console.log("sm=" + JSON.stringify(sm))
  6754. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  6755. console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  6756. if (sm.hour() > em.hour()) {
  6757. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6758. console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  6759. } else {
  6760. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  6761. console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  6762. }
  6763. // }
  6764. });
  6765. // $scope.ok = function (event) {
  6766. // console.log("event="+JSON.stringify(event))
  6767. // event.action = action;
  6768. // $modalInstance.close(event);
  6769. // };
  6770. $scope.cancel = function (event) {
  6771. $modalInstance.dismiss();
  6772. };
  6773. var acUserSelect = $scope.refreshUser = function (key) {
  6774. //for test
  6775. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  6776. // return;
  6777. var data = {
  6778. "idx": "0",
  6779. "sum": "5"
  6780. };
  6781. if (key) {
  6782. data['user'] = {
  6783. 'name': key
  6784. };
  6785. }
  6786. APIService.fetchDataList('user', data).then(function (response) {
  6787. if (response) {
  6788. if (response.status = 200) {
  6789. $scope.users = response.list;
  6790. console.log($scope.users);
  6791. }
  6792. }
  6793. })
  6794. };
  6795. if (angular.isDefined(event.users) && event.users.length > 0) {
  6796. }
  6797. $scope.users = [event.user];
  6798. acUserSelect();
  6799. },
  6800. resolve: {
  6801. scheduleClass: function () {
  6802. return $scope.scheduleClass;
  6803. },
  6804. APIService: function () {
  6805. return api_user_data;
  6806. },
  6807. MementFormat: function () {
  6808. return moment;
  6809. }
  6810. }
  6811. });
  6812. modalInstance.result.then(function (selectedEvent) {
  6813. if (selectedEvent.action == 'Clicked') {
  6814. // var data = {
  6815. // "scheduleorder":{
  6816. // "id":selectedEvent.id,
  6817. // "description":selectedEvent.title,
  6818. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  6819. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  6820. // "users":selectedEvent.users,
  6821. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  6822. // }
  6823. // };
  6824. // api_bpm_schedule.update(data).then(function(response){
  6825. // if(response.status==200){
  6826. // SweetAlert.swal({
  6827. // title: "操作成功!",
  6828. // text: "排班更新成功!",
  6829. // type: "succes"
  6830. // });
  6831. // angular.forEach($scope.events,function(item){
  6832. // if(item.id==selectedEvent.id){
  6833. // item = selectedEvent;
  6834. // }
  6835. // })
  6836. // }else{
  6837. // SweetAlert.swal({
  6838. // title: "操作失败",
  6839. // text: "排班更新失败,请稍后重试!",
  6840. // type: "error"
  6841. // })
  6842. // }
  6843. // })
  6844. } else {
  6845. //
  6846. }
  6847. });
  6848. }
  6849. $scope.moment = function (string) {
  6850. return moment(string);
  6851. }
  6852. $scope.eventClicked = function (event) {
  6853. // console.log("event="+JSON.stringify(event))
  6854. showModal('Clicked', event);
  6855. };
  6856. $scope.eventEdited = function (event) {
  6857. showModal('Edited', event);
  6858. };
  6859. var updateView = function (newvalue, oldvalue) {
  6860. if (oldvalue == newvalue) return;
  6861. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  6862. if ($scope.calendarView == "year") {
  6863. } else if ($scope.calendarView == "month") {
  6864. timeStart = moment(newvalue).startOf('month');
  6865. timeEnd = moment(newvalue).endOf('month');
  6866. } else if ($scope.calendarView == "week") {
  6867. timeStart = moment(newvalue).startOf('week');
  6868. timeEnd = moment(newvalue).endOf('week');
  6869. } else if ($scope.calendarView == "Day") {
  6870. timeStart = moment(newvalue).startOf('day');
  6871. timeEnd = moment(newvalue).endOf('day');
  6872. }
  6873. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  6874. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  6875. filterData["startTime"] = timeStartSpan;
  6876. filterData["endTime"] = timeEndSpan;
  6877. load(filterData);
  6878. }
  6879. $scope.$watch('calendarDate', updateView)
  6880. $scope.next = function () {
  6881. $scope.calendarControl.next();
  6882. }
  6883. $scope.prev = function () {
  6884. $scope.calendarControl.prev();
  6885. }
  6886. $scope.setCalendarToToday = function () {
  6887. $scope.calendarDay = new Date();
  6888. };
  6889. $scope.toggle = function ($event, field, event) {
  6890. $event.preventDefault();
  6891. $event.stopPropagation();
  6892. event[field] = !event[field];
  6893. };
  6894. $scope.load(filterData);
  6895. $scope.more = function () {
  6896. $state.go('app.scheduling.myscheduling', {});
  6897. }
  6898. $scope.removes = function () {
  6899. var modalInstance = $modal.open({
  6900. templateUrl: 'assets/views/delete.html',
  6901. controller: function ($scope, $modalInstance) {
  6902. $scope.ok = function () {
  6903. $modalInstance.close();
  6904. };
  6905. $scope.cancel = function () {
  6906. $modalInstance.dismiss('cancel');
  6907. };
  6908. },
  6909. size: 'sm'
  6910. });
  6911. modalInstance.result.then(function () {
  6912. for (var i = 0; i < $scope.$parent.$parent.$parent.$parent.resonseform.fields.length; i++) {
  6913. if ($scope.fields.type == $scope.$parent.$parent.$parent.$parent.resonseform.fields[i].type) {
  6914. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  6915. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(i, 1)
  6916. break;
  6917. }
  6918. }
  6919. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  6920. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  6921. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  6922. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields
  6923. }
  6924. })
  6925. }
  6926. }]
  6927. });
  6928. //空格组件
  6929. formlyConfigProvider.setType({
  6930. name: 'ui-black',
  6931. /*extends: 'input',*/
  6932. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  6933. });
  6934. //请求人最近事件
  6935. formlyConfigProvider.setType({
  6936. name: 'ui-recentIncident',
  6937. templateUrl: 'assets/views/customform/tpl/ui-recentincident.html',
  6938. controller: ['$scope', '$modal', 'api_solution', function ($scope, $modal, api_solution) {
  6939. var filterData = {
  6940. 'incident': {
  6941. 'requester': {
  6942. 'id': ''
  6943. }
  6944. },
  6945. idx: 0,
  6946. sum: 3
  6947. };
  6948. setInterval(function () {
  6949. if (filterData.incident.requester.id == "" || filterData.incident.requester.id != $scope.model.requester.id) {
  6950. var requester = $scope.model.requester;
  6951. if (requester != null && angular.isDefined(requester.id)) {
  6952. filterData.incident.requester.id = $scope.model.requester.id;
  6953. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  6954. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  6955. if (modelData.status == 200) {
  6956. $scope.lastrequst = modelData.list;
  6957. }
  6958. });
  6959. requester = null
  6960. } else { }
  6961. } else { }
  6962. }, 1000);
  6963. $scope.detail = function (data) {
  6964. var modalInstance = $modal.open({
  6965. templateUrl: 'assets/views/incident/tpl/detailincident.html',
  6966. controller: function ($scope, $modalInstance) {
  6967. $scope.entity = {};
  6968. $scope.entity = data;
  6969. $scope.cancel = function () {
  6970. $modalInstance.dismiss('cancel');
  6971. };
  6972. },
  6973. size: 'lg',
  6974. });
  6975. }
  6976. }]
  6977. });
  6978. //参数列表
  6979. formlyConfigProvider.setType({
  6980. name: "ui-listinput",
  6981. templateUrl: 'assets/views/customform/tpl/ui-listinput.html',
  6982. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  6983. defaultOptions: function (options) {
  6984. return {
  6985. templateOptions: {}
  6986. };
  6987. },
  6988. controller: ['$scope', function ($scope) {
  6989. }]
  6990. });
  6991. //时间段控件(分)
  6992. formlyConfigProvider.setType({
  6993. name: 'ui-timeslot',
  6994. extends: 'input',
  6995. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  6996. controller: ['$scope', function ($scope) { }]
  6997. });
  6998. //优先级级联-逾期时间
  6999. formlyConfigProvider.setType({
  7000. name: 'ui-overtime',
  7001. extends: 'input',
  7002. templateUrl: 'assets/views/customform/tpl/ui-overtime.html',
  7003. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7004. var filteData = {};
  7005. var datas = {}
  7006. setInterval(function () {
  7007. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7008. filteData = "L" + $scope.model.priority.id;
  7009. datas = $scope.model.priority.id;
  7010. // console.log($scope.options.templateOptions)
  7011. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7012. // var overtime=requester.date;
  7013. if (requester.state == 200) {
  7014. // if($scope.options.key=="date"){
  7015. $scope.model[$scope.options.key] = requester.date
  7016. // }
  7017. }
  7018. })
  7019. }
  7020. }, 1000);
  7021. }]
  7022. });
  7023. formlyConfigProvider.setType({
  7024. name: 'ui-responsetime',
  7025. extends: 'input',
  7026. templateUrl: 'assets/views/customform/tpl/ui-responsetime.html',
  7027. controller: ['$scope', 'api_bpm_domain', function ($scope, api_bpm_domain) {
  7028. var filteData = {};
  7029. var datas = {}
  7030. setInterval(function () {
  7031. if ($scope.model.priority && $scope.model.priority.id != null && filteData && datas != $scope.model.priority.id) {
  7032. filteData = "L" + $scope.model.priority.id;
  7033. datas = $scope.model.priority.id;
  7034. // console.log($scope.options.templateOptions)
  7035. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  7036. // var overtime=requester.date;
  7037. if (requester.state == 200) {
  7038. var keyName = {};
  7039. // $scope.model.overdueTime = requester.date;
  7040. if ($scope.options.key == "expectIntroTime") {
  7041. keyName = "resolveTime";
  7042. } else if ($scope.options.key == "expectResponseTime") {
  7043. keyName = "responseTime";
  7044. }
  7045. $scope.model[$scope.options.key] = requester.serviceLevelAgreement[keyName];
  7046. // }
  7047. console.log($scope.$parent.$parent.$parent.model)
  7048. }
  7049. if (requester.date1) {
  7050. $scope.$parent.$parent.$parent.model.incident.overdueTime = requester.date;
  7051. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate = requester.date1;
  7052. $scope.$parent.$parent.$parent.model.incident.expectIntroTime = requester.serviceLevelAgreement.resolveTime;
  7053. $scope.$parent.$parent.$parent.model.incident.expectResponseTime = requester.serviceLevelAgreement.responseTime;
  7054. }
  7055. })
  7056. }
  7057. }, 1000);
  7058. }]
  7059. });
  7060. //知识库按钮组件
  7061. formlyConfigProvider.setType({
  7062. name: 'ui-discasecade',
  7063. extends: 'input',
  7064. templateUrl: 'assets/views/customform/tpl/ui-discasecade.html',
  7065. defaultOptions: function (options) {
  7066. return {
  7067. templateOptions: {
  7068. relationAction: function (fields, modelscope, item) { }
  7069. },
  7070. validators: {
  7071. required: {
  7072. expression: function (viewValue, modelValue) {
  7073. var value = modelValue || viewValue;
  7074. // return value = "true";
  7075. }
  7076. }
  7077. }
  7078. }
  7079. },
  7080. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
  7081. // $scope.options.initialValue = $scope.model[$scope.options.key];
  7082. $scope.searchField = $scope.options.model[$scope.options.key];
  7083. $scope.searchData = "";
  7084. $scope.onChangeadd = function (searchData) {
  7085. $scope.searchKey = searchData.account;
  7086. // $scope.searchDataadd = searchData;
  7087. var requesdata = angular.copy(searchData)
  7088. $scope.requester = requesdata;
  7089. }
  7090. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7091. $scope.searchData = searchKey;
  7092. reashdata($scope.searchData);
  7093. }
  7094. $scope.getMydata = function (x) {
  7095. $scope.model[$scope.options.key] = JSON.parse(x).title;
  7096. $scope.searchField = $scope.model[$scope.options.key];
  7097. }
  7098. $scope.getMydataone = function (x) {
  7099. $scope.model[$scope.options.key] = x;
  7100. $scope.searchField = $scope.model[$scope.options.key];
  7101. }
  7102. $scope.fildata = {
  7103. "idx": 0,
  7104. "sum": 10
  7105. // 'incident': { 'tilte': item }
  7106. }
  7107. function reashdata(item) {
  7108. if (item && item != "") {
  7109. angular.extend($scope.fildata, {
  7110. 'incident': {
  7111. 'title': item
  7112. }
  7113. })
  7114. } else {
  7115. delete $scope.fildata.incident;
  7116. }
  7117. api_bpm_data.fetchDataList('incident', $scope.fildata).then(function (response) {
  7118. if (response) {
  7119. if (response.status = 200) {
  7120. var myData = response;
  7121. $scope.myData = myData.list;
  7122. }
  7123. }
  7124. })
  7125. }
  7126. function delHtmlTag(str) {
  7127. return str.replace(/<[^>]+>/g, "");
  7128. }
  7129. // reashdata();
  7130. var changedata = {};
  7131. setInterval(function () {
  7132. if ($scope.model.category != null && $scope.model.category.id != changedata.id && $scope.model.titles != $scope.model.category) {
  7133. $scope.searchData = {};
  7134. changedata = angular.copy($scope.model.category);
  7135. if ($scope.options.key == "title") {
  7136. var filterData = {
  7137. "idx": 0,
  7138. "sum": 1000
  7139. };
  7140. api_bpm_data.fetchDataList('incidentcategory', filterData).then(function (data) {
  7141. var datalist = data.list;
  7142. angular.forEach(datalist, function (item) {
  7143. if (item.id == $scope.model.category.id) {
  7144. $scope.model[$scope.options.key] = item.category;
  7145. $scope.searchField = $scope.options.model[$scope.options.key];
  7146. $scope.titles = item.category;
  7147. titles = $scope.model.category;
  7148. }
  7149. })
  7150. })
  7151. }
  7152. }
  7153. }, 1000);
  7154. $scope.open = function (key, options, fildata, $event, model) {
  7155. if (key && key.length > 1) {
  7156. api_zsk.solutionData({
  7157. "solution": {
  7158. "searchWord": key
  7159. },
  7160. "idx": "0",
  7161. "sum": "1000"
  7162. }, 'solution').then(function (response) {
  7163. if (response && response.list.length > 0) {
  7164. $scope.dlideboxslide = true
  7165. angular.forEach(response, function (item) {
  7166. console.log(response)
  7167. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  7168. // if (response.status == 200) {
  7169. // var quote = { 'totalNum': response.totalNum }
  7170. // item = angular.extend(item, quote)
  7171. // }
  7172. // })
  7173. $scope.searchData = response.list;
  7174. console.log($scope.searchData)
  7175. })
  7176. $scope.changes = false;
  7177. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  7178. // $scope.closepages = function(e) {
  7179. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  7180. // event.preventDefault();
  7181. // };
  7182. $scope.shows = false;
  7183. $scope.tempData = {};
  7184. $scope.showpage = function (item) {
  7185. item.content = delHtmlTag(item.content);
  7186. $scope.shows = true;
  7187. $scope.tempData = item;
  7188. if (item.content != null) {
  7189. $scope.tempData.content = $scope.tempData.content.replace("<p>", "").replace("</p>", "")
  7190. }
  7191. $scope.knowledgedata = item;
  7192. $scope.pageid = item.id;
  7193. $scope.changes = !$scope.changes;
  7194. api_bpm_domain.listAttachments(item.id)
  7195. // api_solution.fetchDataList('file', {
  7196. // "file": {
  7197. // "solutionId": item.id
  7198. // },
  7199. // "idx": "0",
  7200. // "sum": "1000"
  7201. // })
  7202. .then(function (data) {
  7203. if (data) {
  7204. $scope.attachments = data.list;
  7205. $scope.view = function (attachmentId) {
  7206. for (var i = 0; i < $scope.attachments.length; i++) {
  7207. if ($scope.attachments[i].id == attachmentId) {
  7208. window.open($scope.attachments[i].previewUrl);
  7209. }
  7210. }
  7211. };
  7212. $scope.download = function (contentId, filename) {
  7213. api_solution.getSolutionDowpath(contentId).then(function (response) {
  7214. var file = new Blob([response], {
  7215. type: 'application/octet-stream'
  7216. });
  7217. // var filename = filename;
  7218. var fileURL = URL.createObjectURL(file);
  7219. var a = document.createElement('a');
  7220. a.href = fileURL;
  7221. a.target = '_blank';
  7222. a.download = filename;
  7223. document.body.appendChild(a);
  7224. a.click();
  7225. })
  7226. };
  7227. }
  7228. })
  7229. }
  7230. $scope.related = function (item) {
  7231. if (item.content != null) {
  7232. item.content = item.content.replace("<p>", "").replace("</p>", "")
  7233. }
  7234. // fildata.$parent.$parent.$parent.model.directClose = 0;
  7235. options.model.handleDescription = item.content;
  7236. var data = {
  7237. 'solutionQuote': {
  7238. 'solutionId': item.id,
  7239. 'incidentsign': options.model.incidentsign
  7240. }
  7241. };
  7242. api_zsk.solutionQuote(item.id).then(function (response) {
  7243. if (response.status == 200) {
  7244. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7245. fildata.$parent.$parent.$parent.$parent.model.start_code = 'close';
  7246. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  7247. } else {
  7248. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7249. };
  7250. })
  7251. }
  7252. $scope.close = function () {
  7253. $scope.changes = !$scope.changes;
  7254. event.preventDefault();
  7255. }
  7256. }
  7257. });
  7258. }
  7259. };
  7260. }]
  7261. });
  7262. //侧滑选择重复事件
  7263. formlyConfigProvider.setType({
  7264. name: 'ui-repeatIncidentbtn',
  7265. templateUrl: 'assets/views/customform/tpl/ui-repeatIncidentbtn.html',
  7266. defaultOptions: function (options) {
  7267. return {
  7268. templateOptions: {
  7269. relationAction: function (fields, modelscope, item) { }
  7270. },
  7271. validators: {
  7272. required: {
  7273. expression: function (viewValue, modelValue) {
  7274. // var value = modelValue || viewValue;
  7275. }
  7276. }
  7277. }
  7278. }
  7279. },
  7280. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain) {
  7281. console.log($scope)
  7282. $scope.selection = {
  7283. id: ''
  7284. };
  7285. //认证计费数据获取
  7286. $scope.sumInfo = {};
  7287. function getSumInfo() {
  7288. api_bpm_data.sumInfo($scope.model.incident.account).then(function (data) {
  7289. console.log(data)
  7290. if (data) {
  7291. $scope.sumInfo = data.data||{};
  7292. }
  7293. })
  7294. }
  7295. getSumInfo();
  7296. // 收起重复事件侧滑框
  7297. function reashdata(item) {
  7298. var fildata = {
  7299. idx: 0,
  7300. incident: {
  7301. department: {
  7302. id: $scope.model.incident.department.id,
  7303. },
  7304. },
  7305. sum: 3
  7306. }
  7307. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  7308. console.log(data)
  7309. if (data) {
  7310. $scope.repeatData = data.list;
  7311. }
  7312. })
  7313. }
  7314. reashdata();
  7315. // 确认选中的重复事件
  7316. $scope.repeatIncidentOk = function () {
  7317. if ($scope.selection.id) {
  7318. $scope.model.incident.repeat = $scope.selection;
  7319. $scope.model.isRepeat = true; //隐藏处理信息
  7320. console.log($scope.model);
  7321. }
  7322. angular.element('#repeatIncident').removeClass('active');
  7323. }
  7324. // 取消选中的重复事件
  7325. $scope.repeatIncidentCancle = function () {
  7326. angular.element('#repeatIncident').removeClass('active');
  7327. return;
  7328. }
  7329. }]
  7330. });
  7331. //侧滑选择知识库查询
  7332. formlyConfigProvider.setType({
  7333. name: 'ui-knowledgebtn',
  7334. templateUrl: 'assets/views/customform/tpl/ui-knowledgebtn.html',
  7335. defaultOptions: function (options) {
  7336. return {
  7337. templateOptions: {
  7338. relationAction: function (fields, modelscope, item) { }
  7339. },
  7340. validators: {
  7341. required: {
  7342. expression: function (viewValue, modelValue) {
  7343. // var value = modelValue || viewValue;
  7344. }
  7345. }
  7346. }
  7347. }
  7348. },
  7349. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', 'api_zsk', 'api_bpm_domain', 'api_wechatfile', 'up_down_file', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside, api_zsk, api_bpm_domain, api_wechatfile, up_down_file) {
  7350. $scope.keypressModel = function(e,key){
  7351. if(e.keyCode === 13){
  7352. $scope.openModel(key);
  7353. }
  7354. }
  7355. // 引用知识库点击
  7356. $scope.searchKeyWord = '';
  7357. $scope.openModel = function (key) {
  7358. // alert(1)//重点
  7359. $scope.searchKeyWord = key;
  7360. if (key) {
  7361. api_zsk.solutionData({
  7362. "solution": {
  7363. threeSearch: key,
  7364. status: { id: 72 },//已发布
  7365. selectType: "keySearch"
  7366. },
  7367. "idx": "0",
  7368. "sum": "1000"
  7369. }, 'solution').then(function (response) {
  7370. $scope.searchData = response.list;
  7371. });
  7372. }
  7373. };
  7374. $scope.openModel($scope.model.incident.description)
  7375. // 展开/收起
  7376. $scope.showId = '';
  7377. $scope.ifshow = false;
  7378. $scope.showAll = function (id) {
  7379. $scope.attachments = []
  7380. if ($scope.showId == id) {
  7381. $scope.ifshow = !$scope.ifshow;
  7382. } else {
  7383. $scope.ifshow = true;
  7384. }
  7385. $scope.showId = id;
  7386. // 获取附件
  7387. api_wechatfile.listAttachments('knowledge', $scope.showId).then(function (data) {
  7388. $scope.attachments = data.data;
  7389. $scope.download = function (token, filename) {
  7390. var downUrl = up_down_file.downloadAttachment('common/common/downloadAttachment', token).getRequestedUrl();
  7391. // window.open(downUrl);
  7392. var a = document.createElement('a');
  7393. a.href = downUrl;
  7394. a.target = '_blank';
  7395. a.download = filename;
  7396. document.body.appendChild(a);
  7397. a.click();
  7398. };
  7399. })
  7400. }
  7401. // 引用
  7402. $scope.related = function (item) {
  7403. console.log(item,'引用名')
  7404. if (item.content) {
  7405. item.content = item.content.replace(/<p>/g, "").replace(/<\/p>/g, "").replace(/&nbsp;/g, '')
  7406. }
  7407. $scope.model.incident.handleDescription = item.content;
  7408. $scope.model.incident.title = $scope.model.incident.description = item.title;
  7409. $scope.model.incident.category = item.category;
  7410. if(item.category){
  7411. $scope.model.incident.priority.id = item.category.priority.id;
  7412. item.category.label = item.category.category;
  7413. }
  7414. var categoryId = item.category?item.category.id:'';
  7415. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  7416. function getres(nodes) {
  7417. if (!nodes || nodes.length == 0) {
  7418. return;
  7419. }
  7420. nodes.forEach(e => {
  7421. e.selected = false;
  7422. if (e.id == categoryId) {
  7423. e.selected = true;
  7424. return false;
  7425. }
  7426. getres(e.children)
  7427. })
  7428. }
  7429. var categorys = [];
  7430. $scope.fields.forEach((e, i) => {
  7431. if (e.key == 'category') {
  7432. categorys = e.templateOptions.options;
  7433. if (categorys.length) {
  7434. getres(categorys);
  7435. $scope.fields[i].templateOptions.options = categorys;
  7436. $scope.$root.refreshSelectedItems();
  7437. }
  7438. return false;
  7439. }
  7440. })
  7441. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  7442. $scope.model.candidateGroups = item.category?item.category.group:{};
  7443. // 携带关联优先级,事件工单信息的时间
  7444. if ($scope.model && $scope.model.incident && item.category && item.category.priority && item.category.priority.id) {
  7445. api_bpm_domain.expectedTime('L' + (item.category.priority.id - 1559)).then(function (res) {
  7446. $scope.model.incident.expectResponseTime = $scope.$parent.$parent.$parent.model.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  7447. $scope.model.incident.expectIntroTime = $scope.$parent.$parent.$parent.model.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  7448. $scope.model.incident.overdueTime = $scope.$parent.$parent.$parent.model.incident.overdueTime = res.date;
  7449. })
  7450. }
  7451. api_zsk.solutionQuote(item.id).then(function (response) {
  7452. if (response.status == 200) {
  7453. $('#seachknowledge').removeClass('active')
  7454. SweetAlert.swal("引用成功", "知识库已引用", "success");
  7455. $scope.$parent.$parent.$parent.model.start_code = 'close';
  7456. $scope.$parent.$parent.$parent.model.directClose = 0;
  7457. console.log($scope.model)
  7458. } else {
  7459. SweetAlert.swal("引用失败", "知识库未引用", "error");
  7460. };
  7461. })
  7462. }
  7463. }]
  7464. });
  7465. //下拉输入组件
  7466. formlyConfigProvider.setType({
  7467. name: 'ui-selectinput',
  7468. extends: 'input',
  7469. templateUrl: 'assets/views/customform/tpl/selectinput.html',
  7470. defaultOptions: function (options) {
  7471. return {
  7472. templateOptions: {
  7473. refresh: function () { },
  7474. refreshDelay: 0,
  7475. linkage: function (modelName, data) {
  7476. }
  7477. },
  7478. }
  7479. },
  7480. controller: ['$scope', '$rootScope', '$modal', 'SweetAlert', 'api_bpm_data', 'api_solution', '$aside', function ($scope, $rootScope, $modal, SweetAlert, api_bpm_data, api_solution, $aside) {
  7481. $scope.searchData = "";
  7482. $scope.onChangeadd = function (searchData) {
  7483. // $scope.searchKey = searchData.account;
  7484. // var requesdata = angular.copy(searchData)
  7485. // $scope.requester = requesdata;
  7486. }
  7487. $scope.refreshUseradd = function (searchKey) { //主题搜索
  7488. // $scope.searchData = searchKey;
  7489. // reashdata($scope.searchData);
  7490. }
  7491. $scope.getMydata = function (x) {
  7492. $scope.model[$scope.options.key] = JSON.parse(x)[$scope.options.templateOptions.labelProp];
  7493. $scope.searchField = $scope.model[$scope.options.key];
  7494. }
  7495. $scope.getMydataone = function (x) {
  7496. $scope.model[$scope.options.key] = x;
  7497. $scope.searchField = $scope.model[$scope.options.key];
  7498. if ($scope.model[$scope.options.key] && $scope.model[$scope.options.key] != "") {
  7499. $scope.hidden = false;
  7500. } else {
  7501. $scope.hidden = true;
  7502. }
  7503. }
  7504. function reashdata(item) {
  7505. $scope.myData = $scope.options.templateOptions.mydata;
  7506. }
  7507. reashdata()
  7508. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  7509. $scope.options.templateOptions.fetchItems($scope);
  7510. }
  7511. }]
  7512. });
  7513. //重构组件模板
  7514. //获取当前人
  7515. formlyConfigProvider.setType({
  7516. name: 'ui-users',
  7517. extends: 'input',
  7518. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7519. defaultOptions: function (options) {
  7520. return {
  7521. templateOptions: {
  7522. translate: '',
  7523. refreshDelay: 0
  7524. }
  7525. }
  7526. },
  7527. controller: ['$scope', function ($scope) {
  7528. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  7529. $scope.options.templateOptions.translate = $scope.$root.user.name;
  7530. }]
  7531. });
  7532. //只读控件
  7533. formlyConfigProvider.setType({
  7534. name: 'ui-label',
  7535. extends: 'input',
  7536. templateUrl: 'assets/views/customform/tpl/ui-label.html',
  7537. defaultOptions: function (options) {
  7538. return {
  7539. templateOptions: {
  7540. translate: '',
  7541. refreshDelay: 0
  7542. }
  7543. }
  7544. },
  7545. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  7546. // console.log($scope.options.templateOptions)
  7547. // console.log($scope.options,'options1122');
  7548. $scope.isSolutionLabel = false;
  7549. $scope.solutionLabelStr = "";
  7550. // console.log($scope.options.templateOptions.solotinLabel);
  7551. if ($scope.options.templateOptions.solotinLabel) {
  7552. $scope.isSolutionLabel = true;
  7553. if ($scope.model[$scope.options.key]) {
  7554. var solutionArr = $scope.model[$scope.options.key].split("/");
  7555. $scope.solutionLabelStr = solutionArr.join(" ");
  7556. }
  7557. }
  7558. var value = $scope.model[$scope.options.key];
  7559. // ----------------
  7560. // ----------------
  7561. // console.log(value, 'pppp')
  7562. function treeDesc(children, key, label) {
  7563. if (label == "") {
  7564. label = children[key];
  7565. } else {
  7566. label = children[key] + "-" + label;
  7567. }
  7568. if (angular.isDefined(children.parent)) {
  7569. treeDesc(children.parent, key, label);
  7570. } else {
  7571. return label;
  7572. }
  7573. }
  7574. if (angular.isArray(value)) {
  7575. var tempValue = "";
  7576. angular.forEach(value, function (item) {
  7577. if (tempValue != "") {
  7578. tempValue = tempValue + ",";
  7579. }
  7580. tempValue = tempValue + item[$scope.options.templateOptions.labelProp] || item;
  7581. });
  7582. $scope.options.templateOptions.translate = tempValue;
  7583. } else if (angular.isObject(value)) {
  7584. if (angular.isDefined(value.children) || angular.isDefined(value.parent)) {
  7585. //tree
  7586. // console.log("value.parent="+JSON.stringify(value.parent))
  7587. var nameLabel = value[$scope.options.templateOptions.labelProp];
  7588. nameLabel = treeDesc(value.parent, $scope.options.templateOptions.labelProp, nameLabel);
  7589. $scope.options.templateOptions.translate = nameLabel;
  7590. } else {
  7591. $scope.options.templateOptions.translate = value;
  7592. }
  7593. } else if (angular.isString(value) && value.indexOf('yyyy-MM-ddTHH:mm:sssZ') > 0) {
  7594. // console.log("value=" + value);
  7595. $scope.options.templateOptions.translate = value;
  7596. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  7597. // console.log("value="+value);
  7598. // $scope.options.templateOptions.translate = value;
  7599. } else {
  7600. // var datasdf = JSON.parse(value);
  7601. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  7602. $scope.options.templateOptions.translate = value;
  7603. }
  7604. if (angular.isFunction($scope.options.templateOptions.transform)) {
  7605. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  7606. $scope.options.templateOptions.translate = $scope.options.templateOptions.transform($scope.originalModel, value, $rootScope, $scope);
  7607. }
  7608. // console.log($scope.options.templateOptions.translate,99999);
  7609. }]
  7610. });
  7611. //小标题组件
  7612. formlyConfigProvider.setType({
  7613. name: 'ui-header',
  7614. 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>'
  7615. });
  7616. //标题组件
  7617. formlyConfigProvider.setType({
  7618. name: 'ui-title',
  7619. 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>'
  7620. });
  7621. //标栏是否展示
  7622. formlyConfigProvider.setType({
  7623. name: 'ui-orshow',
  7624. 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>',
  7625. controller: ['$scope', function ($scope) {
  7626. $scope.clickshow = function (key) {
  7627. // $scope.model[$scope.options.key] != key;
  7628. if (key == false) {
  7629. $scope.model[$scope.options.key] = true
  7630. } else {
  7631. $scope.model[$scope.options.key] = false
  7632. }
  7633. }
  7634. }]
  7635. });
  7636. //按钮组
  7637. formlyConfigProvider.setType({
  7638. name: 'ui-button',
  7639. templateUrl: 'assets/views/customform/tpl/ui-button.html',
  7640. defaultOptions: function (options) {
  7641. return {
  7642. noFormControl: true
  7643. }
  7644. }
  7645. });
  7646. //3d组link
  7647. formlyConfigProvider.setType({
  7648. name: 'ui-link',
  7649. templateUrl: 'assets/views/customform/tpl/ui-link.html',
  7650. defaultOptions: function (options) {
  7651. return {
  7652. noFormControl: true
  7653. }
  7654. }
  7655. });
  7656. //隐藏域组件
  7657. formlyConfigProvider.setType({
  7658. name: 'ui-hidden',
  7659. extends: 'input',
  7660. template: '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  7661. defaultOptions: function (options) {
  7662. return {
  7663. // noFormControl: true
  7664. };
  7665. }
  7666. });
  7667. //文本框组件
  7668. formlyConfigProvider.setType({
  7669. name: 'ui-input',
  7670. extends: 'input',
  7671. templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7672. defaultOptions: function (options) {
  7673. return {
  7674. templateOptions: {
  7675. transform: function (value) { }
  7676. }
  7677. };
  7678. },
  7679. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7680. // console.log($scope.model[$scope.options.key]);
  7681. // console.log($scope.options)
  7682. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7683. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7684. }
  7685. }]
  7686. });
  7687. //搜索下拉框-故障地点seimin
  7688. formlyConfigProvider.setType({
  7689. name: 'ui-select-search',
  7690. extends: 'input',
  7691. templateUrl: 'assets/views/customform/tpl/ui-select-search.html',
  7692. defaultOptions: function (options) {
  7693. return {
  7694. templateOptions: {
  7695. transform: function (value) { }
  7696. }
  7697. };
  7698. },
  7699. controller: ['$scope','$rootScope', 'api_search_area', function ($scope,$rootScope, api_search_area) {
  7700. // console.log($scope.options, $scope.model)
  7701. // ----------------分割线 start-----------------
  7702. // 故障地点下拉
  7703. $scope.address_arr = [];//故障地点所有数据
  7704. $scope.addressFlag = false;//默认下拉框列表隐藏
  7705. //点击文本框
  7706. $scope.AddressClickHandle = function () {
  7707. $scope.getDepartmentList();
  7708. angular.element('#bx_address_ul').scrollTop(0);
  7709. }
  7710. //修改文字,实时监听
  7711. $scope.ksChangeHandle = _.debounce(function () {
  7712. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === undefined ? '' : $scope.model[$scope.options.key];
  7713. $scope.getDepartmentList();
  7714. angular.element('#bx_address_ul').scrollTop(0);
  7715. }, 500)
  7716. //获取故障地点seimin
  7717. $scope.getDepartmentList = function () {
  7718. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] === null ? '' : $scope.model[$scope.options.key];
  7719. api_search_area.getAreaList({ "searchKey": $scope.model[$scope.options.key] })
  7720. .then(res => {
  7721. if (res.state == 200) {
  7722. $scope.address_arr = res.result;
  7723. $scope.addressFlag = true;//显示
  7724. }
  7725. })
  7726. .catch(err => {
  7727. console.log(err);
  7728. })
  7729. }
  7730. // $scope.getDepartmentList();
  7731. // console.log($scope.model[$scope.options.key])
  7732. //下拉框列表选中
  7733. $scope.addressItemClick = function (obj) {
  7734. $scope.addressFlag = false;//隐藏
  7735. $scope.model[$scope.options.key] = obj.place ? obj.area.area + obj.place : obj.area;
  7736. //选择故障地点后带入区域地点2020年4月23日15:20:44
  7737. $scope.model.selecthouseNumber = obj;
  7738. console.log($scope,77777)
  7739. $scope.$root.selecthouseNumber = obj;
  7740. }
  7741. //点击空白处隐藏
  7742. angular.element(document).on('click', function (e) {
  7743. if (e.target !== angular.element('#bx_address').get(0)) {
  7744. $scope.addressFlag = false;//隐藏
  7745. //模拟placeholder
  7746. // if ($('#bx_address').val() == '') {
  7747. // $('#bx_address').val('请选择报修科室');
  7748. // }
  7749. }
  7750. })
  7751. // -----------------分割线 end----------------
  7752. }]
  7753. });
  7754. //知识库关键字组件
  7755. formlyConfigProvider.setType({
  7756. name: 'ui-knowledgeKeywords',
  7757. extends: 'input',
  7758. templateUrl: 'assets/views/customform/tpl/ui-knowledgeKeywords.html',
  7759. defaultOptions: function (options) {
  7760. return {
  7761. templateOptions: {
  7762. transform: function (value) { }
  7763. }
  7764. };
  7765. },
  7766. controller: ['$scope', '$timeout', 'SweetAlert', function ($scope, $timeout, SweetAlert) {
  7767. $scope.valueLength = [{
  7768. "value": ""
  7769. }];
  7770. $scope.valueAll = [];
  7771. if ($scope.model[$scope.options.key]) {
  7772. var valueArr = $scope.model[$scope.options.key].split("/");
  7773. $scope.valueLength = [];
  7774. for (var i = 0; i < valueArr.length; i++) {
  7775. $scope.valueLength.push({
  7776. "value": valueArr[i]
  7777. })
  7778. }
  7779. }
  7780. $scope.addIpt = function () {
  7781. if ($scope.valueLength.length < 5) {
  7782. $scope.valueLength.push({
  7783. "value": ""
  7784. })
  7785. } else {
  7786. SweetAlert.swal({
  7787. title: "添加失败",
  7788. text: "关键字不能超过5个!",
  7789. type: "error",
  7790. confirmButtonColor: "#DD6B55"
  7791. });
  7792. }
  7793. };
  7794. $scope.closeIpt = function (data) {
  7795. $scope.valueLength.splice(data, 1)
  7796. }
  7797. $scope.toOption = function () {
  7798. $scope.valueAll = [];
  7799. for (var i = 0; i < $scope.valueLength.length; i++) {
  7800. if ($scope.valueLength[i].value != "") {
  7801. $scope.valueAll.push($scope.valueLength[i].value)
  7802. }
  7803. }
  7804. $scope.model.label = $scope.valueAll.join("/")
  7805. }
  7806. }]
  7807. });
  7808. //文本框组件
  7809. formlyConfigProvider.setType({
  7810. name: 'ui-num',
  7811. extends: 'input',
  7812. templateUrl: 'assets/views/customform/tpl/ui-num.html',
  7813. defaultOptions: function (options) {
  7814. return {
  7815. templateOptions: {
  7816. transform: function (value) { }
  7817. }
  7818. };
  7819. },
  7820. controller: ['$scope', '$timeout', function ($scope, $timeout) {
  7821. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  7822. $scope.model[$scope.options.key] = $scope.options.templateOptions.linkData($scope.model);
  7823. }
  7824. $scope.clearNoNum = function (obj, attr) {
  7825. //先把非数字的都替换掉,除了数字和.
  7826. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  7827. //必须保证第一个为数字而不是.
  7828. obj[attr] = obj[attr].replace(/^\./g, "");
  7829. //保证只有出现一个.而没有多个.
  7830. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  7831. //保证.只出现一次,而不能出现两次以上
  7832. obj[attr] = obj[attr].replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  7833. //小于最大值
  7834. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  7835. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  7836. // obj[attr] = '';
  7837. // }
  7838. }
  7839. }]
  7840. });
  7841. // //关联请求人文本框组件
  7842. // formlyConfigProvider.setType({
  7843. // name: 'ui-requestinput',
  7844. // extends: 'input',
  7845. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  7846. // defaultOptions: function(options) {
  7847. // return {
  7848. // templateOptions: {
  7849. // transform: function(value) {},
  7850. // linkData: function(options) {}
  7851. // }
  7852. // };
  7853. // }
  7854. // });
  7855. //只读文本
  7856. formlyConfigProvider.setType({
  7857. name: 'ui-disableinput',
  7858. extends: 'input',
  7859. templateUrl: 'assets/views/customform/tpl/ui-disableinput.html',
  7860. defaultOptions: function (options) {
  7861. return {
  7862. templateOptions: {
  7863. transform: function (value) {
  7864. var ret = "";
  7865. if (value) {
  7866. ret = "已删除";
  7867. } else {
  7868. ret = "正常";
  7869. }
  7870. return ret;
  7871. }
  7872. }
  7873. };
  7874. }
  7875. });
  7876. formlyConfigProvider.setType({
  7877. name: 'ui-disinput',
  7878. extends: 'input',
  7879. templateUrl: 'assets/views/customform/tpl/ui-disinput.html',
  7880. defaultOptions: function (options) {
  7881. return {
  7882. templateOptions: {}
  7883. };
  7884. }
  7885. });
  7886. //数字组件
  7887. formlyConfigProvider.setType({
  7888. name: 'ui-number',
  7889. extends: 'input',
  7890. templateUrl: 'assets/views/customform/tpl/ui-number.html',
  7891. defaultOptions: function (options) {
  7892. return {
  7893. templateOptions: {}
  7894. };
  7895. },
  7896. controller: ['$scope', function ($scope) { }]
  7897. });
  7898. //含有周的日期
  7899. formlyConfigProvider.setType({
  7900. name: 'ui-datepickerweek',
  7901. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  7902. extends: 'input',
  7903. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  7904. defaultOptions: {
  7905. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  7906. templateOptions: {
  7907. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  7908. }
  7909. },
  7910. controller: ['$scope', '$filter', function ($scope, $filter) {
  7911. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  7912. if ($scope.model[$scope.options.key]) {
  7913. } else {
  7914. $scope.model[$scope.options.key] = $filter('date')(new Date(new Date().getTime()), $scope.options.templateOptions.datepickerPopup);
  7915. }
  7916. $scope.options.initialValue = $scope.model[$scope.options.key];
  7917. $scope.endOpen = true;
  7918. $scope.datepicker = {};
  7919. $scope.datepicker.opened = false;
  7920. $scope.datepicker.open = function ($event) {
  7921. $scope.datepicker.opened = true;
  7922. };
  7923. }]
  7924. });
  7925. //lmm
  7926. //分配任务列表
  7927. formlyConfigProvider.setType({
  7928. name: 'jry_taskDistributionList',
  7929. templateUrl: 'assets/views/customform/tpl/jry_taskDistributionList.html',
  7930. wrapper: ['bootstrapHasError'],
  7931. defaultOptions: function (options, $scope) {
  7932. return {
  7933. templateOptions: {
  7934. }
  7935. };
  7936. },
  7937. controller: function ($rootScope, $scope, api_user_data, $modal, api_doc_data, i18nService, SweetAlert, api_wechatfile) {
  7938. // 获取状态
  7939. $scope.stateListData = {};
  7940. $scope.getStateData = function () {//lyl
  7941. var data = {
  7942. "key": 'task_sub_state',
  7943. "type": 'list'
  7944. }
  7945. api_wechatfile.getDictionary(data).then(function (res) {
  7946. angular.forEach(res, function (v, i) {
  7947. $scope.stateListData[v.value] = v.id;
  7948. })
  7949. })
  7950. }
  7951. $scope.getStateData();
  7952. var loginUser = $rootScope.user;
  7953. $scope.langs = i18nService.getAllLangs();
  7954. $scope.lang = 'zh-cn';
  7955. i18nService.setCurrentLang($scope.lang);
  7956. $scope.gridOptions = {};
  7957. $scope.gridOptions.data = 'myData';
  7958. $scope.gridOptions.enableColumnResizing = true;
  7959. $scope.gridOptions.enableGridMenu = false;
  7960. $scope.gridOptions.enableRowSelection = true;
  7961. $scope.gridOptions.showGridFooter = true;
  7962. $scope.gridOptions.showColumnFooter = false;
  7963. $scope.gridOptions.fastWatch = true;
  7964. $scope.gridOptions.useExternalFiltering = true;
  7965. $scope.gridOptions.useExternalPagination = true;
  7966. $scope.gridOptions.paginationPageSizes = [10];
  7967. $scope.gridOptions.paginationPageSize = 10;
  7968. $scope.gridOptions.multiSelect = true;
  7969. $scope.gridOptions.rowIdentity = function (row) {
  7970. return row.id;
  7971. };
  7972. $scope.gridOptions.getRowIdentity = function (row) {
  7973. return row.id;
  7974. };
  7975. // console.log($scope.model);//lmmmm
  7976. $scope.gridOptions.columnDefs = [{
  7977. name: 'item',
  7978. displayName: '序号',
  7979. width: "10%",
  7980. cellTemplate: '<div>' +
  7981. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  7982. '</div>'
  7983. },
  7984. {
  7985. name: 'taskDescribe',
  7986. displayName: '任务说明',
  7987. width: "25%",
  7988. enableFiltering: false,
  7989. cellTemplate: '<div>' +
  7990. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  7991. '</div>'
  7992. },
  7993. {
  7994. name: 'assign.name',
  7995. displayName: '指派人',
  7996. width: "5%",
  7997. enableFiltering: false,
  7998. cellTemplate: '<div>' +
  7999. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  8000. '</div>'
  8001. },
  8002. {
  8003. name: 'startTime',
  8004. displayName: '开始时间',
  8005. width: '13%',
  8006. enableFiltering: false,
  8007. cellTemplate: '<div>' +
  8008. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  8009. '</div>'
  8010. },
  8011. {
  8012. name: 'endTime',
  8013. displayName: '结束时间',
  8014. width: '13%',
  8015. enableFiltering: false,
  8016. cellTemplate: '<div>' +
  8017. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  8018. '</div>'
  8019. },
  8020. {
  8021. name: 'priority.name',
  8022. displayName: '优先级',
  8023. width: "5%",
  8024. enableFiltering: false,
  8025. cellTemplate: '<div>' +
  8026. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  8027. '</div>'
  8028. },
  8029. {
  8030. name: 'state.name',
  8031. displayName: '状态',
  8032. width: "5%",
  8033. enableFiltering: false,
  8034. cellTemplate: '<div>' +
  8035. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  8036. '</div>'
  8037. },
  8038. {
  8039. name: '操作',//lmmm
  8040. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  8041. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  8042. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  8043. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  8044. '<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>' +
  8045. '</div></div>',
  8046. enableFiltering: false
  8047. }
  8048. ];
  8049. // 查看
  8050. $scope.see = function (data) {
  8051. $scope.seeData = data;
  8052. var modalInstance = $modal.open({
  8053. backdrop: false,
  8054. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8055. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8056. $scope.personData = {}; //指派人
  8057. $scope.priorityData = {}; //优先级
  8058. $scope.personListData = {}; //指派人下拉数据
  8059. $scope.priorityListData = {}; //优先级下拉数据
  8060. $scope.startTime = ""; //开始时间
  8061. $scope.releaseShow = "no";
  8062. $scope.subShow = "no";
  8063. $scope.onlySee = "ok";
  8064. $scope.endTime = ""; //结束时间
  8065. $scope.taskDescribe = ""; //任务描述
  8066. $scope.taskDescribe = scope.seeData.taskDescribe;
  8067. $scope.personData.data = scope.seeData.assign;
  8068. $scope.priorityData.data = scope.seeData.priority;
  8069. $scope.startTime = scope.seeData.startTime;
  8070. $scope.endTime = scope.seeData.endTime;
  8071. $scope.done = scope.seeData.done;
  8072. $scope.feedback = scope.seeData.feedback;
  8073. $scope.cancel = function () {
  8074. $modalInstance.dismiss('cancel');
  8075. }
  8076. },
  8077. size: 'sm',
  8078. resolve: {
  8079. scope: function () {
  8080. return $scope;
  8081. },
  8082. },
  8083. backdrop: true
  8084. });
  8085. }
  8086. // 编辑
  8087. $scope.edit = function (data) {
  8088. $scope.editData = data;
  8089. var modalInstance = $modal.open({
  8090. backdrop: false,
  8091. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8092. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8093. console.log(scope.editData);
  8094. $scope.personData = {}; //指派人
  8095. $scope.priorityData = {}; //优先级
  8096. $scope.personListData = {}; //指派人下拉数据
  8097. $scope.priorityListData = {}; //优先级下拉数据
  8098. $scope.startTime = ""; //开始时间
  8099. $scope.releaseShow = "no";
  8100. $scope.endTime = ""; //结束时间
  8101. $scope.taskDescribe = ""; //任务描述
  8102. $scope.taskDescribe = scope.editData.taskDescribe;
  8103. $scope.personData.data = scope.editData.assign;
  8104. $scope.priorityData.data = scope.editData.priority;
  8105. $scope.startTime = scope.editData.startTime;
  8106. $scope.endTime = scope.editData.endTime;
  8107. // 指派人下拉框数据
  8108. $scope.getPersonData = function () {
  8109. var data = {
  8110. "idx": 0,
  8111. "sum": 1000
  8112. }
  8113. api_user_data.fetchDataList("user", data).then(function (res) {
  8114. $scope.personListData = res.list;
  8115. })
  8116. }
  8117. $scope.getPersonData();
  8118. //优先级下拉数据
  8119. $scope.getPriorityData = function () {
  8120. var data = {
  8121. "key": "change_rick_level",
  8122. "type": "list"
  8123. }
  8124. api_wechatfile.getDictionary(data).then(function (res) {
  8125. $scope.priorityListData = res
  8126. })
  8127. }
  8128. $scope.getPriorityData();
  8129. // 获取状态-lmm
  8130. $scope.stateListData = {};
  8131. $scope.getStateData = function () {//lyl
  8132. var data = {
  8133. "key": 'task_sub_state',
  8134. "type": 'list'
  8135. }
  8136. api_wechatfile.getDictionary(data).then(function (res) {
  8137. angular.forEach(res, function (v, i) {
  8138. $scope.stateListData[v.value] = v.id;
  8139. })
  8140. })
  8141. }
  8142. $scope.getStateData();
  8143. //时间控件
  8144. $scope.open = function ($event) {
  8145. $event.preventDefault();
  8146. $event.stopPropagation();
  8147. $scope.opened = !$scope.opened;
  8148. };
  8149. $scope.endOpen = function ($event) {
  8150. $event.preventDefault();
  8151. $event.stopPropagation();
  8152. $scope.startOpened = false;
  8153. $scope.endOpened = !$scope.endOpened;
  8154. };
  8155. $scope.startOpen = function ($event) {
  8156. $event.preventDefault();
  8157. $event.stopPropagation();
  8158. $scope.endOpened = false;
  8159. $scope.startOpened = !$scope.startOpened;
  8160. };
  8161. // 确定
  8162. $scope.ok = function (item) {
  8163. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8164. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8165. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8166. $scope.addData = {
  8167. "taskSub": {
  8168. "taskDescribe": $scope.taskDescribe,
  8169. "assign": $scope.personData.data,
  8170. "priority": $scope.priorityData.data,
  8171. "startTime": $scope.startTime,
  8172. "endTime": $scope.endTime,
  8173. "taskMonth": {
  8174. "id": scope.model.taskMonth.id
  8175. },
  8176. "id": scope.editData.id
  8177. }
  8178. }
  8179. $scope.addData.taskSub["state"] = {
  8180. "id": $scope.stateListData[1]
  8181. };
  8182. api_user_data.updData('taskSub', $scope.addData).then(function (res) {
  8183. if (res.status == 200) {
  8184. SweetAlert.swal({
  8185. title: "修改成功!",
  8186. type: "success",
  8187. confirmButtonColor: "#007AFF"
  8188. });
  8189. scope.refreshData(scope.jry_filterdata);
  8190. $modalInstance.dismiss('cancel');
  8191. } else {
  8192. SweetAlert.swal({
  8193. title: "修改失败",
  8194. text: "系统错误,请重试!",
  8195. type: "error"
  8196. });
  8197. $modalInstance.dismiss('cancel');
  8198. }
  8199. })
  8200. } else {
  8201. SweetAlert.swal({
  8202. title: "修改失败",
  8203. text: "必填项不能为空!",
  8204. type: "error"
  8205. });
  8206. }
  8207. };
  8208. $scope.cancel = function () {
  8209. $modalInstance.dismiss('cancel');
  8210. }
  8211. },
  8212. size: 'sm',
  8213. resolve: {
  8214. scope: function () {
  8215. return $scope;
  8216. },
  8217. },
  8218. backdrop: true
  8219. });
  8220. }
  8221. // 发布
  8222. $scope.release = function (data) {
  8223. SweetAlert.swal({
  8224. title: "确认发布?",
  8225. text: "请确定发布操作!",
  8226. type: "warning",
  8227. showCancelButton: true,
  8228. confirmButtonColor: "#DD6B55",
  8229. confirmButtonText: "确定",
  8230. cancelButtonText: "取消",
  8231. closeOnConfirm: false,
  8232. closeOnCancel: false
  8233. }, function (isConfirm) {
  8234. if (isConfirm) {
  8235. data.state.id = $scope.stateListData[2];
  8236. delete data.item;
  8237. api_user_data.updData("taskSub", {
  8238. taskSub: data
  8239. }).then(function (res) {
  8240. if (res.status == 200) {
  8241. SweetAlert.swal({
  8242. title: "发布成功!",
  8243. type: "success",
  8244. confirmButtonColor: "#007AFF"
  8245. });
  8246. $scope.refreshData($scope.jry_filterdata);
  8247. } else {
  8248. SweetAlert.swal({
  8249. title: "删除失败",
  8250. text: "系统错误,请重试!",
  8251. type: "error"
  8252. });
  8253. }
  8254. })
  8255. } else {
  8256. SweetAlert.swal("操作取消", "发布取消", "error");
  8257. }
  8258. });
  8259. }
  8260. // 删除
  8261. $scope.remove = function (data) {
  8262. SweetAlert.swal({
  8263. title: "确认删除?",
  8264. text: "删除的数据不可恢复,请确认继续操作!",
  8265. type: "warning",
  8266. showCancelButton: true,
  8267. confirmButtonColor: "#DD6B55",
  8268. confirmButtonText: "继续删除",
  8269. cancelButtonText: "取消操作",
  8270. closeOnConfirm: false,
  8271. closeOnCancel: false
  8272. }, function (isConfirm) {
  8273. if (isConfirm) {
  8274. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  8275. if (res.status == 200) {
  8276. SweetAlert.swal({
  8277. title: "删除成功!",
  8278. type: "success",
  8279. confirmButtonColor: "#007AFF"
  8280. });
  8281. $scope.refreshData($scope.jry_filterdata);
  8282. } else {
  8283. SweetAlert.swal({
  8284. title: "删除失败",
  8285. text: "系统错误,请重试!",
  8286. type: "error"
  8287. });
  8288. }
  8289. })
  8290. } else {
  8291. SweetAlert.swal("操作取消", "数据安全", "error");
  8292. }
  8293. });
  8294. }
  8295. $scope.refreshData = function (filterData) {
  8296. // $scope.ldloading[style.replace('-', '_')] = true;
  8297. if (angular.isUndefined(filterData)) {
  8298. filterData = defaultFilterData;
  8299. }
  8300. $scope.myData = [];
  8301. $scope.memoryfilterData = filterData;
  8302. api_doc_data.fetchDataList('taskSub', filterData).then(function (data) {
  8303. var myData = data;
  8304. $scope.gridOptions.totalItems = myData.totalNum;
  8305. $scope.removeFileNum = myData.totalNum;
  8306. if (angular.isArray(myData.list)) {
  8307. $scope.myData = myData.list;
  8308. for (var i = 0; i < $scope.myData.length; i++) {
  8309. //添加序号
  8310. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  8311. $scope.myData[i].startTime = moment($scope.myData[i].startTime).format('YYYY-MM-DD HH:mm:ss');
  8312. $scope.myData[i].endTime = moment($scope.myData[i].endTime).format('YYYY-MM-DD HH:mm:ss');
  8313. }
  8314. }
  8315. }, function () {
  8316. // $scope.ldloading[style.replace('-', '_')] = false;
  8317. });
  8318. };
  8319. //分页控制
  8320. $scope.gridOptions.onRegisterApi = function (gridApi) {
  8321. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  8322. $scope.jry_filterdata.idx = newPage - 1;
  8323. $scope.fenye = newPage - 1;
  8324. $scope.jry_filterdata.sum = pageSize;
  8325. $scope.refreshData($scope.jry_filterdata);
  8326. });
  8327. }
  8328. $scope.fenye = 0;
  8329. if ($scope.model.label == "分配任务") {
  8330. $scope.jry_filterdata = {
  8331. "idx": $scope.fenye,
  8332. "sum": 10,
  8333. "taskSub": {
  8334. "taskMonth": {
  8335. "id": $scope.model.taskMonth.id
  8336. },
  8337. "userid": loginUser.id,
  8338. "role": loginUser.role
  8339. }
  8340. };
  8341. } else {
  8342. $scope.jry_filterdata = {
  8343. "idx": $scope.fenye,
  8344. "sum": 10,
  8345. "taskSub": {
  8346. "taskMonth": {
  8347. "id": $scope.model.taskMonth.id
  8348. },
  8349. "userid": loginUser.id,
  8350. "role": loginUser.role,
  8351. "type": 1
  8352. }
  8353. };
  8354. }
  8355. $scope.refreshData($scope.jry_filterdata);
  8356. //新增模态框
  8357. $scope.newDistribution = function () {
  8358. var modalInstance = $modal.open({
  8359. backdrop: false,
  8360. templateUrl: 'assets/views/customform/tpl/newTaskDistribution.html',
  8361. controller: function ($scope, scope, $modalInstance, api_doc_data, SweetAlert, api_user_data, api_wechatfile) {
  8362. $scope.personData = {}; //指派人
  8363. $scope.priorityData = {}; //优先级
  8364. $scope.personListData = {}; //指派人下拉数据
  8365. $scope.priorityListData = {}; //优先级下拉数据
  8366. $scope.startTime = ""; //开始时间
  8367. $scope.endTime = ""; //结束时间
  8368. $scope.taskDescribe = ""; //任务描述
  8369. $scope.motaikuang = "";
  8370. $scope.shijian = "哈哈";
  8371. // 指派人下拉框数据
  8372. $scope.getPersonData = function () {
  8373. var data = {
  8374. "idx": 0,
  8375. "sum": 1000
  8376. }
  8377. api_user_data.fetchDataList("user", data).then(function (res) {
  8378. $scope.personListData = res.list;
  8379. })
  8380. }
  8381. $scope.getPersonData();
  8382. //优先级下拉数据
  8383. $scope.getPriorityData = function () {
  8384. var data = {
  8385. "key": "change_rick_level",
  8386. "type": "list"
  8387. }
  8388. api_wechatfile.getDictionary(data).then(function (res) {
  8389. $scope.priorityListData = res
  8390. })
  8391. }
  8392. // 控制结束时间的最大时间
  8393. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  8394. // 控制结束时间的最小时间
  8395. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  8396. $scope.$watch('startTime', function (n, o) {
  8397. if (n) {
  8398. if (n > scope.model.taskMonth.startTime) {
  8399. $scope.jryEndMinTime = n
  8400. }
  8401. }
  8402. })
  8403. // 控制开始时间的最小时间
  8404. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  8405. // 控制开始时间的最大时间
  8406. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  8407. $scope.$watch('endTime', function (n, o) {
  8408. if (n) {
  8409. if (n < scope.model.taskMonth.endTime) {
  8410. $scope.jryStartMaxTime = n
  8411. }
  8412. }
  8413. })
  8414. $scope.getPriorityData();
  8415. //时间控件
  8416. $scope.open = function ($event) {
  8417. $event.preventDefault();
  8418. $event.stopPropagation();
  8419. $scope.opened = !$scope.opened;
  8420. };
  8421. $scope.endOpen = function ($event) {
  8422. $event.preventDefault();
  8423. $event.stopPropagation();
  8424. $scope.startOpened = false;
  8425. $scope.endOpened = !$scope.endOpened;
  8426. };
  8427. $scope.startOpen = function ($event) {
  8428. $event.preventDefault();
  8429. $event.stopPropagation();
  8430. $scope.endOpened = false;
  8431. $scope.startOpened = !$scope.startOpened;
  8432. };
  8433. $scope.datepickerPopup = 'yyyy-MM-dd HH:mm:ss';
  8434. // 获取状态-lmm
  8435. $scope.stateListData = {};
  8436. $scope.getStateData = function () {//lyl
  8437. var data = {
  8438. "key": 'task_sub_state',
  8439. "type": 'list'
  8440. }
  8441. api_wechatfile.getDictionary(data).then(function (res) {
  8442. angular.forEach(res, function (v, i) {
  8443. $scope.stateListData[v.value] = v.id;
  8444. })
  8445. })
  8446. }
  8447. $scope.getStateData();
  8448. // 草稿保存
  8449. $scope.ok = function (item) {
  8450. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8451. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8452. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8453. $scope.addData = {
  8454. "taskSub": {
  8455. "taskDescribe": $scope.taskDescribe,
  8456. "assign": $scope.personData.data,
  8457. "priority": $scope.priorityData.data,
  8458. "startTime": $scope.startTime,
  8459. "endTime": $scope.endTime,
  8460. "taskMonth": {
  8461. "id": scope.model.taskMonth.id
  8462. }
  8463. }
  8464. }
  8465. $scope.addData.taskSub["state"] = {
  8466. "id": $scope.stateListData[1]
  8467. };
  8468. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8469. if (res.status == 200) {
  8470. SweetAlert.swal({
  8471. title: "保存成功!",
  8472. type: "success",
  8473. confirmButtonColor: "#007AFF"
  8474. });
  8475. scope.refreshData(scope.jry_filterdata);
  8476. $modalInstance.dismiss('cancel');
  8477. } else {
  8478. SweetAlert.swal({
  8479. title: "保存失败",
  8480. text: "系统错误,请重试!",
  8481. type: "error"
  8482. });
  8483. $modalInstance.dismiss('cancel');
  8484. }
  8485. })
  8486. } else {
  8487. SweetAlert.swal({
  8488. title: "保存失败",
  8489. text: "必填项不能为空!",
  8490. type: "error"
  8491. });
  8492. }
  8493. };
  8494. // 发布
  8495. $scope.release = function () {
  8496. if ($scope.taskDescribe && $scope.personData.data && $scope.priorityData.data && $scope.startTime && $scope.endTime) {
  8497. $scope.startTime = moment(new Date($scope.startTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8498. $scope.endTime = moment(new Date($scope.endTime).getTime()).format('YYYY-MM-DD HH:mm:ss');
  8499. $scope.addData = {
  8500. "taskSub": {
  8501. "taskDescribe": $scope.taskDescribe,
  8502. "assign": $scope.personData.data,
  8503. "priority": $scope.priorityData.data,
  8504. "startTime": $scope.startTime,
  8505. "endTime": $scope.endTime,
  8506. "taskMonth": {
  8507. "id": scope.model.taskMonth.id
  8508. }
  8509. }
  8510. }
  8511. $scope.addData.taskSub["state"] = {
  8512. "id": $scope.stateListData[1]
  8513. };
  8514. api_user_data.addData('taskSub', $scope.addData).then(function (res) {
  8515. if (res.status == 200) {
  8516. SweetAlert.swal({
  8517. title: "保存成功!",
  8518. type: "success",
  8519. confirmButtonColor: "#007AFF"
  8520. });
  8521. scope.refreshData(scope.jry_filterdata);
  8522. $modalInstance.dismiss('cancel');
  8523. } else {
  8524. SweetAlert.swal({
  8525. title: "保存失败",
  8526. text: "系统错误,请重试!",
  8527. type: "error"
  8528. });
  8529. $modalInstance.dismiss('cancel');
  8530. }
  8531. })
  8532. } else {
  8533. SweetAlert.swal({
  8534. title: "保存失败",
  8535. text: "必填项不能为空!",
  8536. type: "error"
  8537. });
  8538. }
  8539. }
  8540. $scope.cancel = function () {
  8541. $modalInstance.dismiss('cancel');
  8542. }
  8543. },
  8544. size: 'sm',
  8545. resolve: {
  8546. scope: function () {
  8547. return $scope;
  8548. },
  8549. },
  8550. backdrop: true
  8551. });
  8552. }
  8553. }
  8554. });
  8555. // 多次反馈文本域组件--jry
  8556. formlyConfigProvider.setType({
  8557. name: 'ui-feedbacktTextarea',
  8558. extends: 'textarea',
  8559. templateUrl: 'assets/views/customform/tpl/ui-feedbacktTextarea.html',
  8560. defaultOptions: function (options) {
  8561. return {
  8562. templateOptions: {
  8563. transform: function (model, value) {
  8564. return value;
  8565. },
  8566. },
  8567. validation: {
  8568. messages: {
  8569. maxlength: function (viewValue, modelValue, scope) {
  8570. if (viewValue != null) {
  8571. if (viewValue.length > scope.to.maxlength) {
  8572. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  8573. } else {
  8574. return "";
  8575. }
  8576. }
  8577. },
  8578. }
  8579. }
  8580. }
  8581. },
  8582. controller: ['$scope', 'moment', function ($scope, moment) {
  8583. // console.log($scope);
  8584. var timeKey = $scope.options.templateOptions.time;
  8585. $scope.time = moment($scope.model[timeKey]).format('YYYY-MM-DD HH:mm:ss');
  8586. var value = $scope.model[$scope.options.key];
  8587. if (angular.isFunction($scope.options.templateOptions.transform)) {
  8588. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  8589. }
  8590. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  8591. $scope.options.templateOptions.felditem($scope);
  8592. }
  8593. }]
  8594. });
  8595. //任务管理开始时间--jry
  8596. formlyConfigProvider.setType({
  8597. name: 'ui-jryStartdatepicker',
  8598. templateUrl: 'assets/views/customform/tpl/ui-jryStartdatepicker.html',
  8599. extends: 'input',
  8600. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8601. defaultOptions: {
  8602. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8603. templateOptions: {
  8604. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8605. }
  8606. },
  8607. controller: ['$scope', '$filter', function ($scope, $filter) {
  8608. // console.log($scope.model[$scope.options.key],'lmm');
  8609. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8610. if ($scope.model[$scope.options.key]) {
  8611. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8612. }
  8613. // console.log($scope.model[$scope.options.key],'lmm');
  8614. // console.log($scope.model,'lmm',$scope.options.key);
  8615. $scope.options.initialValue = $scope.model[$scope.options.key];
  8616. $scope.endOpen = true;
  8617. $scope.datepicker = {};
  8618. $scope.datepicker.opened = false;
  8619. $scope.datepicker.open = function ($event) {
  8620. $scope.datepicker.opened = true;
  8621. };
  8622. }]
  8623. });
  8624. //任务管理结束时间--jry
  8625. formlyConfigProvider.setType({
  8626. name: 'ui-jryEnddatepicker',
  8627. templateUrl: 'assets/views/customform/tpl/ui-jryEnddatepicker.html',
  8628. extends: 'input',
  8629. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  8630. defaultOptions: {
  8631. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  8632. templateOptions: {
  8633. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  8634. }
  8635. },
  8636. controller: ['$scope', '$filter', function ($scope, $filter) {
  8637. $scope.mindata = new Date($scope.options.templateOptions.transform($scope.model).getTime() + 5 * 60 * 1000);
  8638. if ($scope.model[$scope.options.key]) {
  8639. $scope.model[$scope.options.key] = $filter('date')($scope.model[$scope.options.key], $scope.options.templateOptions.datepickerPopup);
  8640. }
  8641. $scope.options.initialValue = $scope.model[$scope.options.key];
  8642. $scope.endOpen = true;
  8643. $scope.datepicker = {};
  8644. $scope.datepicker.opened = false;
  8645. $scope.datepicker.open = function ($event) {
  8646. $scope.datepicker.opened = true;
  8647. };
  8648. }]
  8649. });
  8650. //下拉多选框灵活组件--jry
  8651. formlyConfigProvider.setType({
  8652. name: 'ui-jry_multiselectplus',
  8653. extends: 'multiCheckbox',
  8654. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8655. defaultOptions: function (options) {
  8656. return {
  8657. templateOptions: {
  8658. refreshData: function (search, options, model, that) {
  8659. // var process = options.templateOptions.ApiService.all("");
  8660. if (search) {
  8661. } else {
  8662. }
  8663. var postData = options.templateOptions.optionsPostData;
  8664. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  8665. postData = options.templateOptions.optionsPostData(options, model, that);
  8666. }
  8667. options.templateOptions.ApiService.fetchDataList(options.templateOptions.optionsUrl, options.templateOptions.optionsPostData).then(function (result) {
  8668. // if (!options.templateOptions.options) {
  8669. // options.templateOptions.options = [];
  8670. // }
  8671. if (options.templateOptions.optionsDataKey) {
  8672. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  8673. } else {
  8674. options.templateOptions.options = result;
  8675. }
  8676. if (options.templateOptions.optionsChecked) {
  8677. // return options.value = null;
  8678. options.value(options.model[options.key]);
  8679. }
  8680. });
  8681. },
  8682. refreshDelay: 0,
  8683. // },
  8684. validators: {
  8685. required: {
  8686. expression: function (viewValue, modelValue) {
  8687. var value = modelValue || viewValue;
  8688. return value != null;
  8689. // return value.length>=1;
  8690. // if (modelValue && viewValue) {
  8691. // return value != null;
  8692. // } else {
  8693. // var value = modelValue || viewValue;
  8694. // return value.length > 0;
  8695. // }
  8696. }
  8697. }
  8698. }
  8699. }
  8700. };
  8701. },
  8702. controller: ['$scope', function ($scope) {
  8703. console.log($scope.to);
  8704. if (angular.isArray($scope.model[$scope.options.key])) {
  8705. } else {
  8706. $scope.model[$scope.options.key] = [];
  8707. }
  8708. }]
  8709. });
  8710. //下拉框组件
  8711. formlyConfigProvider.setType({
  8712. name: 'ui-select',
  8713. extends: 'select',
  8714. templateUrl: 'assets/views/customform/tpl/ui-select.html',
  8715. defaultOptions: function (options, scope) {
  8716. return {
  8717. templateOptions: {
  8718. // refresh: function() {},
  8719. refreshDelay: 0,
  8720. linkage: function (modelName, data, model, modelKey, key, timekey) { //POST
  8721. console.log(model,'model')
  8722. angular.extend(data, {
  8723. "idx": 0,
  8724. "sum": 1000
  8725. });
  8726. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  8727. var myData = options.templateOptions.Restangular.stripRestangular(response);
  8728. var list = myData.list;
  8729. console.log(myData)
  8730. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  8731. // console.log('balabalabala');
  8732. // console.log(res);
  8733. // })
  8734. if (list.length == 1) {
  8735. if (options.templateOptions.APIport) {
  8736. options.templateOptions.APIport.expectedTime("L" + list[0][key].id).then(function (response) {
  8737. if (response.state == "200") {
  8738. // if (model.$parent.model && model.$parent.model.incident) {
  8739. // } else {
  8740. // model.$parent.model = { 'incident': {} };
  8741. // }
  8742. var myDatas = response.serviceLevelAgreement;
  8743. //逾期
  8744. scope.$parent.$parent.$parent.model.incident.overdueTime = response.date
  8745. //解决
  8746. scope.$parent.$parent.$parent.model.incident.expectIntroTime = myDatas.resolveTime;
  8747. //响应
  8748. scope.$parent.$parent.$parent.model.incident.expectResponseTime = myDatas.responseTime;
  8749. } else {
  8750. }
  8751. });
  8752. }
  8753. angular.forEach(model.fields, function (item) {
  8754. angular.forEach(model.fields, function (item) {
  8755. if (item.templateOptions.pkey == modelKey + "." + key) {
  8756. item.model.id = "";
  8757. if (key == "place") {
  8758. item.templateOptions.options = list;
  8759. } else if (key == "placeDTO") {
  8760. item.templateOptions.options = list;
  8761. } else if (key == "requester") {
  8762. } else {
  8763. item.value(list[0][key][item.key]);
  8764. }
  8765. }
  8766. })
  8767. })
  8768. } else {
  8769. if (model.fields) {
  8770. angular.forEach(model.fields, function (item) {
  8771. angular.forEach(model.fields, function (item) {
  8772. if (item.templateOptions.pkey == modelKey + "." + key) {
  8773. item.model.id = "";
  8774. if (key == "place") {
  8775. item.templateOptions.isnosearch = true;
  8776. item.templateOptions.options = list;
  8777. }
  8778. if (key == "placeDTO") {
  8779. item.templateOptions.options = list;
  8780. }
  8781. if (key == "requester") {
  8782. }
  8783. }
  8784. })
  8785. })
  8786. } else {
  8787. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8788. angular.forEach(scope.$parent.$parent.$parent.fields, function (item) {
  8789. if (item.templateOptions.pkey == modelKey + "." + key) {
  8790. if (key == "place") {
  8791. item.templateOptions.isnosearch = true;
  8792. item.templateOptions.options = list;
  8793. scope.$parent.$parent.$parent.model.incident.place = model.incident.place;
  8794. }
  8795. if (key == "placeDTO") {
  8796. item.templateOptions.options = list;
  8797. }
  8798. if (key == "requester") {
  8799. }
  8800. }
  8801. })
  8802. })
  8803. }
  8804. }
  8805. console.log(key)
  8806. //报修科室
  8807. if (key == 'dept') {
  8808. // 报修科室单选
  8809. scope.$parent.$parent.$parent.model.incident.department = response.list[0];
  8810. scope.$parent.$parent.$parent.model.incident.contactsInformation = response.list[0].phone;
  8811. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  8812. // 选择重复事件侧滑框
  8813. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  8814. setTimeout(() => {
  8815. scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  8816. }, 500);
  8817. }
  8818. // 报修人
  8819. if (key == 'requester') {
  8820. // 报修人单选
  8821. scope.$parent.$parent.$parent.model.incident.requester = response.list[
  8822. 0];
  8823. console.log(scope.$parent.$parent.$parent.model)
  8824. scope.$parent.$parent.$parent.model.incident.account = response.list[
  8825. 0].account;
  8826. var selectedItem = response.list[
  8827. 0];
  8828. var data = {
  8829. 'requester': selectedItem
  8830. };
  8831. scope.$parent.$parent.$parent.model[
  8832. 'requestershow'] = selectedItem;
  8833. console.log(selectedItem, '----------------------')
  8834. // if (selectedItem.dept.place.place) {
  8835. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  8836. // }
  8837. scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.houseNumber?selectedItem.houseNumber:'';
  8838. scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place?selectedItem.place.area.id:null;
  8839. scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place?selectedItem.place.id:null;
  8840. console.log(scope,89898998)
  8841. // console.log(scope.formData,'接单页面');
  8842. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  8843. scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8844. scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  8845. options.templateOptions.ApiService.addData('requester',
  8846. data).then(function (response) {
  8847. if (response.status == 200) {
  8848. if (scope.$parent.$parent.$parent) {
  8849. if (scope.$parent.$parent.$parent.place) {
  8850. scope.$parent.$parent.$parent.place.id = '';
  8851. }
  8852. if (scope.$parent.$parent.$parent.area) {
  8853. scope.$parent.$parent.$parent.area.id = '';
  8854. }
  8855. scope.$parent.$parent.$parent.model.incident.contacts = selectedItem.name;
  8856. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  8857. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.mphone;
  8858. } else {
  8859. scope.$parent.$parent.$parent.model.incident.contactsInformation = selectedItem.telephone;
  8860. }
  8861. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  8862. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  8863. }
  8864. }
  8865. if (!response.data.id) {
  8866. response.data.id = selectedItem.id
  8867. }
  8868. console.log(scope);
  8869. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  8870. // if (selectedItem.place && selectedItem.place.id) {
  8871. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8872. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  8873. // };
  8874. // } else {
  8875. // if (selectedItem.place && selectedItem.place.id) {
  8876. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  8877. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  8878. // };
  8879. // }
  8880. // if(scope.$parent.$parent.$parent.model.incident.area){
  8881. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  8882. // }
  8883. if (selectedItem.id) {
  8884. scope.$parent.$parent.$parent.model.incident.account = selectedItem.account;
  8885. }
  8886. // 选择重复事件侧滑框
  8887. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  8888. scope.$parent.$parent.$parent.model[
  8889. 'repeatIncidentShow'] = false;
  8890. setTimeout(() => {
  8891. scope.$parent.$parent.$parent.model[
  8892. 'repeatIncidentShow'] = true;
  8893. },
  8894. 500);
  8895. // }
  8896. }
  8897. })
  8898. }
  8899. });
  8900. },
  8901. validators: {
  8902. required: {
  8903. expression: function (viewValue, modelValue) {
  8904. var value = modelValue || viewValue;
  8905. return value != null;
  8906. // return value.length>=1;
  8907. // if (modelValue && viewValue) {
  8908. // return value != null;
  8909. // } else {
  8910. // var value = modelValue || viewValue;
  8911. // return value.length > 0;
  8912. // }
  8913. }
  8914. }
  8915. }
  8916. },
  8917. controller: ['$scope', '$rootScope', 'api_bpm_domain', function ($scope, $rootScope, api_bpm_domain) {
  8918. // $scope.myFilter = function(item) {
  8919. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  8920. // }
  8921. // console.log($scope,'风浪')
  8922. if ($scope.options.templateOptions.pkey && $scope.options.templateOptions.pkey == "incident.place") {
  8923. if ($scope.$parent && $scope.$parent.$parent.$parent.model && $scope.$parent.$parent.$parent.model.incident.area && $scope.$parent.$parent.$parent.model.incident.area.id) {
  8924. $scope.options.templateOptions.linkage("place", {
  8925. "place": {
  8926. "areaId": $scope.$parent.$parent.$parent.model.incident.area.id
  8927. // area:{
  8928. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  8929. // }
  8930. }
  8931. }, $scope.$parent.$parent.$parent.model, "incident", "place");
  8932. }
  8933. }
  8934. $scope.myFilter = $scope;
  8935. // console.log($scope.options.templateOptions)
  8936. console.log($scope,77777)
  8937. //处理人根据事件分类自动带入
  8938. if($scope.options.templateOptions.pkey == "incident.handlerUser"){
  8939. if($scope.$parent.$parent.$parent.model.incident.handlerUser){
  8940. if($scope.$parent.$parent.$parent.model.incident.handlerUser.id){
  8941. $scope.options.model.id = $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  8942. }
  8943. }
  8944. }
  8945. // 关闭事件页面满意度评价下拉框处理
  8946. if($scope.options.templateOptions.onlyKey=="close_degree"){
  8947. $scope.model.id = $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id
  8948. }
  8949. if($scope.options.templateOptions.initData == 1){
  8950. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8951. }
  8952. if ($scope.options.templateOptions.transform) {
  8953. $scope.options.templateOptions.onChange($scope.model.id, $scope.options, $scope);
  8954. }
  8955. if (angular.isFunction($scope.options.templateOptions.translate)) {
  8956. $scope.model[$scope.options.key] = $scope.options.templateOptions.translate($scope.options, $rootScope, $scope);
  8957. }
  8958. if (angular.isFunction($scope.options.templateOptions.translatefunc)) {
  8959. $scope.model[$scope.options.key] = $scope.options.templateOptions.translatefunc($scope.options, $rootScope, $scope);
  8960. }
  8961. if (angular.isFunction($scope.options.templateOptions.onlyfunction)) {
  8962. $scope.options.templateOptions.onlyfunction($scope.options, $rootScope, $scope);
  8963. }
  8964. }]
  8965. };
  8966. }
  8967. });
  8968. //下拉多选框组件
  8969. formlyConfigProvider.setType({
  8970. name: 'ui-multiselect',
  8971. extends: 'select',
  8972. templateUrl: 'assets/views/customform/tpl/ui-multiselect.html',
  8973. defaultOptions: function (options) {
  8974. return {
  8975. templateOptions: {
  8976. refresh: function () { },
  8977. refreshDelay: 1000
  8978. }
  8979. };
  8980. },
  8981. controller: ['$scope', function ($scope) {
  8982. $scope.model[$scope.options.key] = [];
  8983. }]
  8984. });
  8985. //下拉多选框灵活组件
  8986. formlyConfigProvider.setType({
  8987. name: 'ui-multiselectplus',
  8988. extends: 'multiCheckbox',
  8989. templateUrl: 'assets/views/customform/tpl/ui-multiselectplus.html',
  8990. defaultOptions: function (options, $scope) {
  8991. return {
  8992. templateOptions: {
  8993. refreshData: function (search, options, model, that) {
  8994. var process = options.templateOptions.ApiService.all("");
  8995. if (search) {
  8996. } else {
  8997. }
  8998. var postData = options.templateOptions.optionsPostData;
  8999. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  9000. postData = options.templateOptions.optionsPostData(options, model, that);
  9001. }
  9002. if (options.templateOptions.modelreasondata) {
  9003. postData = options.templateOptions.modelreasondata
  9004. }
  9005. process.customPOST(postData, options.templateOptions.optionsUrl).then(function (result) {
  9006. // if (!options.templateOptions.options) {
  9007. // options.templateOptions.options = [];
  9008. // }
  9009. // 过滤下拉列表已选择的值
  9010. var modelVal = $scope.model[$scope.options.key];
  9011. for (var i = 0; i < result.list.length; i++) {
  9012. for (var j = 0; j < modelVal.length; j++) {
  9013. if (result.list[i].id == modelVal[j].id) {
  9014. result.list.splice(i, 1)
  9015. }
  9016. }
  9017. }
  9018. if (options.templateOptions.optionsDataKey) {
  9019. options.templateOptions.options = result[options.templateOptions.optionsDataKey];
  9020. } else {
  9021. options.templateOptions.options = result;
  9022. }
  9023. if (options.templateOptions.optionsChecked) {
  9024. // return options.value = null;
  9025. options.value(options.model[options.key]);
  9026. }
  9027. });
  9028. },
  9029. refreshDelay: 0,
  9030. // },
  9031. // validators: {
  9032. // required: {
  9033. // expression: function(viewValue, modelValue) {
  9034. // var value = modelValue || viewValue;
  9035. // // return value.length>=1;
  9036. // // if (modelValue && viewValue) {
  9037. // // return value != null;
  9038. // // } else {
  9039. // // var value = modelValue || viewValue;
  9040. // // return value.length > 0;
  9041. // // }
  9042. // }
  9043. // }
  9044. }
  9045. };
  9046. },
  9047. controller: ['$scope', function ($scope) {
  9048. if (angular.isArray($scope.model[$scope.options.key])) {
  9049. } else {
  9050. $scope.model[$scope.options.key] = [];
  9051. }
  9052. }]
  9053. });
  9054. //下拉树形多选组件
  9055. formlyConfigProvider.setType({
  9056. name: 'ui-multiselect-tree',
  9057. extends: 'multiCheckbox',
  9058. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9059. defaultOptions: function (options) {
  9060. return {
  9061. templateOptions: {
  9062. linkage: function (modelName, data, model, modelKey, key) {
  9063. angular.extend(data, {
  9064. "idx": 0,
  9065. "sum": 10
  9066. });
  9067. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9068. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9069. var list = myData.list;
  9070. if (list.length == 1) {
  9071. angular.forEach(model.fields, function (item) {
  9072. angular.forEach(model.fields, function (item) {
  9073. if (item.templateOptions.pkey == modelKey + "." + key) {
  9074. item.model.id = "";
  9075. if (key == "place") {
  9076. item.templateOptions.options = list;
  9077. } else {
  9078. item.value(list[0][key][item.key]);
  9079. }
  9080. }
  9081. })
  9082. })
  9083. }
  9084. });
  9085. },
  9086. // my_tree_handler : function(items) {
  9087. // },
  9088. // onFilterCallback : function(items) {
  9089. // },
  9090. // onFilterCallback : function(items) {
  9091. // },
  9092. refresh: function (items) {
  9093. var treedata = [];
  9094. function convertListToTree(data, treeMap) {
  9095. treedata = data;
  9096. for (var i = 0; i < data.length; i++) {
  9097. for (var j = 0; j < data.length; j++) {
  9098. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9099. if (data[i].pid == data[j].id) {
  9100. data[i].parent = data[j];
  9101. }
  9102. }
  9103. }
  9104. }
  9105. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9106. var root = null; //Initially set our loop to null
  9107. //loop over data
  9108. for (var i = 0; i < data.length; i++) {
  9109. var datum = data[i];
  9110. //each node will have children, so let's give it a "children" poperty
  9111. datum.children = [];
  9112. //add an entry for this node to the map so that any future children can
  9113. //lookup the parent
  9114. idToNodeMap[datum.id] = datum;
  9115. //Does this node have a parent?
  9116. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9117. //Doesn't look like it, so this node is the root of the tree
  9118. root = datum;
  9119. treeMap[datum.id] = root;
  9120. } else {
  9121. //This node has a parent, so let's look it up using the id
  9122. parentNode = idToNodeMap[datum.parent.id];
  9123. //We don't need this property, so let's delete it.
  9124. delete datum.parent;
  9125. //Let's add the current node as a child of the parent node.
  9126. parentNode.children.push(datum);
  9127. }
  9128. }
  9129. return root;
  9130. }
  9131. function convertParentToChildList(data) {
  9132. // console.log("data="+JSON.stringify(data))
  9133. var treeMap = {};
  9134. var list = [];
  9135. convertListToTree(data, treeMap);
  9136. angular.forEach(treeMap, function (item) {
  9137. list.push(item);
  9138. });
  9139. return list;
  9140. }
  9141. function selectItem(pmodel, childrens) {
  9142. if (angular.isArray(pmodel)) {
  9143. angular.forEach(pmodel, function (index) {
  9144. if (index && index.id) {
  9145. angular.forEach(childrens, function (item) {
  9146. if (item.id == index.id) {
  9147. item.selected = true;
  9148. }
  9149. if (item && item.children) {
  9150. selectItem(pmodel, item.children);
  9151. }
  9152. });
  9153. }
  9154. })
  9155. } else {
  9156. if (pmodel && pmodel.id) {
  9157. angular.forEach(childrens, function (item) {
  9158. if (item.id == pmodel.id) {
  9159. item.selected = true;
  9160. }
  9161. if (item && item.children) {
  9162. selectItem(pmodel, item.children);
  9163. }
  9164. });
  9165. }
  9166. }
  9167. }
  9168. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9169. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9170. if (result.status == 200) {
  9171. if (!options.templateOptions.options) {
  9172. options.templateOptions.options = [];
  9173. }
  9174. if (options.templateOptions.optionsDataKey) {
  9175. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9176. } else {
  9177. options.templateOptions.options = convertParentToChildList(result);
  9178. }
  9179. //set default value
  9180. var pmodel, i = 0;
  9181. if (options.templateOptions.pkey) {
  9182. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9183. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9184. if (i == 0) {
  9185. if (options.model[p] == null) {
  9186. options.model[p] = {};
  9187. }
  9188. pmodel = options.model[p];
  9189. i++;
  9190. } else {
  9191. if (pmodel[p] == null) {
  9192. pmodel[p] = {};
  9193. }
  9194. pmodel = pmodel[p];
  9195. }
  9196. });
  9197. } else {
  9198. pmodel = options.model;
  9199. }
  9200. }
  9201. if (pmodel) {
  9202. pmodel = pmodel[options.key];
  9203. } else if (options.model) {
  9204. pmodel = options.model[options.key];
  9205. } else {
  9206. pmodel = options.templateOptions.options;
  9207. }
  9208. if (angular.isArray(pmodel)) {
  9209. if (pmodel) {
  9210. // if(options.templateOptions.isMultiSelect==true){
  9211. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  9212. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  9213. // })
  9214. // }else{
  9215. selectItem(pmodel, options.templateOptions.options);
  9216. // }
  9217. }
  9218. } else {
  9219. if (pmodel && pmodel.id) {
  9220. selectItem(pmodel, options.templateOptions.options);
  9221. }
  9222. }
  9223. items.inputModel = options.templateOptions.options;
  9224. }
  9225. });
  9226. }
  9227. },
  9228. validators: {
  9229. required: {
  9230. expression: function (viewValue, modelValue) {
  9231. var value = modelValue || viewValue;
  9232. if (angular.isArray(value)) {
  9233. for (var i = 0; i < value.length; i++) {
  9234. value[i] = {
  9235. id: value[i].id
  9236. }
  9237. }
  9238. return value.length > 0
  9239. } else {
  9240. // console.log(options)
  9241. // return value = "true";
  9242. return value != null;
  9243. }
  9244. }
  9245. }
  9246. }
  9247. }
  9248. },
  9249. controller: ['$scope', 'api_configure_form', function ($scope, api_configure_form) {
  9250. if ($scope.options.templateOptions.isMultiSelect) {
  9251. // console.log($scope);
  9252. } else {
  9253. if ($scope.model[$scope.options.key]) {
  9254. }
  9255. }
  9256. }]
  9257. });
  9258. //多选下拉框组件
  9259. formlyConfigProvider.setType({
  9260. name: 'ui-multi-select-tree',
  9261. extends: 'input',
  9262. templateUrl: 'assets/views/customform/tpl/ui-multi-select-tree.html',
  9263. defaultOptions: function (options) {
  9264. return {
  9265. templateOptions: {
  9266. linkage: function (modelName, data, model, modelKey, key) {
  9267. angular.extend(data, {
  9268. "idx": 0,
  9269. "sum": 10
  9270. });
  9271. options.templateOptions.APIService.fetchDataList(modelName, data).then(function (response) {
  9272. var myData = options.templateOptions.Restangular.stripRestangular(response);
  9273. var list = myData.list;
  9274. if (list.length == 1) {
  9275. angular.forEach(model.fields, function (item) {
  9276. angular.forEach(model.fields, function (item) {
  9277. if (item.templateOptions.pkey == modelKey + "." + key) {
  9278. item.model.id = "";
  9279. if (key == "place") {
  9280. item.templateOptions.options = list;
  9281. } else {
  9282. item.value(list[0][key][item.key]);
  9283. }
  9284. }
  9285. })
  9286. })
  9287. }
  9288. });
  9289. },
  9290. getparentdata: function (items) {
  9291. // console.log(items)
  9292. },
  9293. refresh: function (items, search, fn) {
  9294. console.log(items);
  9295. var treedata = [];
  9296. function convertListToTree(data, treeMap) {
  9297. // console.log(data)
  9298. treedata = data;
  9299. for (var i = 0; i < data.length; i++) {
  9300. for (var j = 0; j < data.length; j++) {
  9301. if (data[i].pid && data[i].id && data[i].pid != 0) {
  9302. if (data[i].pid == data[j].id) {
  9303. data[i].parent = data[j];
  9304. }
  9305. }
  9306. // if (data[i].id) {
  9307. // if (data[i].id== data[j].id) {
  9308. // data[i].parent = data[j];
  9309. // }
  9310. // }
  9311. }
  9312. }
  9313. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  9314. var root = []; //Initially set our loop to null
  9315. if (search == 'search' && items.filterKeyword) {
  9316. function transform(nodes) {
  9317. var treeConverter = {
  9318. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  9319. attributeName: 'id', //节点唯一标识符
  9320. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  9321. transform: function (node) { //转化递归函数,参数:一个待插入节点
  9322. if (node.parent != null) { //该节点有父节点
  9323. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  9324. if (this.needFind) {
  9325. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  9326. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  9327. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9328. }
  9329. }
  9330. }
  9331. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  9332. // delete node.parent; //删除该节点的parent属性,如果有的话
  9333. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  9334. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  9335. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  9336. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  9337. // delete node.parent; //删除该节点的parent属性,如果有的话
  9338. if (this.result == null) { //根节点不存在
  9339. node.children = []; //给该节点增加children:[]属性
  9340. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9341. } else {
  9342. node.children = [];
  9343. // 顶级去重
  9344. for (var i = 0; i < this.result.children.length; i++) {
  9345. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  9346. return this.result.children[i];
  9347. }
  9348. }
  9349. this.result.children.push(node)
  9350. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  9351. }
  9352. }
  9353. },
  9354. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  9355. var _node = {};
  9356. _node.children = [];
  9357. this.result = _node; //重置根节点
  9358. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  9359. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  9360. nodes.forEach(item => { //循环调用转化方法
  9361. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  9362. this.transform(item);
  9363. })
  9364. return this.result; //返回根节点
  9365. }
  9366. }
  9367. var result = treeConverter.getWhole(nodes); //调用
  9368. return result;
  9369. }
  9370. var li = transform(data).children;
  9371. // li=[...new Set(li)]
  9372. console.log(li)
  9373. treeMap = li;
  9374. fn(li);
  9375. return li;
  9376. } else {
  9377. //loop over data
  9378. for (var i = 0; i < data.length; i++) {
  9379. var datum = data[i];
  9380. //each node will have children, so let's give it a "children" poperty
  9381. datum.children = [];
  9382. //add an entry for this node to the map so that any future children can
  9383. //lookup the parent
  9384. idToNodeMap[datum.id] = datum;
  9385. //Does this node have a parent?
  9386. if (typeof datum.parent === "undefined" || datum.parent === null) {
  9387. //Doesn't look like it, so this node is the root of the tree
  9388. root = datum;
  9389. treeMap[datum.id] = root;
  9390. } else {
  9391. //This node has a parent, so let's look it up using the id
  9392. parentNode = idToNodeMap[datum.parent.id];
  9393. //We don't need this property, so let's delete it.
  9394. // delete datum.parent;
  9395. //Let's add the current node as a child of the parent node.
  9396. parentNode.children.push(datum);
  9397. }
  9398. }
  9399. }
  9400. return root;
  9401. }
  9402. function convertParentToChildList(data) {
  9403. var treeMap = {};
  9404. var list = [];
  9405. if (search == 'search' && items.filterKeyword) {
  9406. var lis = convertListToTree(data, treeMap)
  9407. return lis;
  9408. } else {
  9409. if (data[0] && data[0].orders) {
  9410. list = data;
  9411. } else {
  9412. convertListToTree(data, treeMap);
  9413. angular.forEach(treeMap, function (item) {
  9414. // console.log("item="+JSON.stringify(item))
  9415. list.push(item);
  9416. });
  9417. }
  9418. return list;
  9419. }
  9420. }
  9421. function selectItem(pmodel, childrens) {
  9422. if (angular.isArray(pmodel)) {
  9423. angular.forEach(pmodel, function (index) {
  9424. if (index && index.id) {
  9425. angular.forEach(childrens, function (item) {
  9426. if (item.id == index.id) {
  9427. item.selected = true;
  9428. }
  9429. if (item && item.children) {
  9430. selectItem(pmodel, item.children);
  9431. }
  9432. });
  9433. // angular.forEach(treedata,function(parentdata){
  9434. // if(parentdata.id == index.id){
  9435. // if(parentdata.parent&&parentdata.parent.id){
  9436. // parentdata.parent.$
  9437. // }
  9438. // item.selected = true;
  9439. // }
  9440. // if (item && item.children) {
  9441. // selectItem(pmodel ,item.children);
  9442. // }
  9443. // });
  9444. }
  9445. })
  9446. } else {
  9447. if (pmodel && pmodel.id) {
  9448. angular.forEach(childrens, function (item, index) {
  9449. if (item.id == pmodel.id) {
  9450. item.selected = true;
  9451. delete item.children;
  9452. }
  9453. if (item && item.children) {
  9454. selectItem(pmodel, item.children);
  9455. }
  9456. });
  9457. }
  9458. }
  9459. }
  9460. function selectItemchild(pmodel, childrens) {
  9461. if (angular.isArray(pmodel)) {
  9462. angular.forEach(pmodel, function (index) {
  9463. if (index && index.id) {
  9464. angular.forEach(childrens, function (item) {
  9465. if (item.id == index.id) {
  9466. item.selected = true;
  9467. }
  9468. if (item && item.children) {
  9469. selectItem(pmodel, item.children);
  9470. }
  9471. });
  9472. }
  9473. })
  9474. } else {
  9475. if (pmodel && pmodel.id) {
  9476. angular.forEach(childrens, function (item, index) {
  9477. if (item.id == pmodel.id) {
  9478. item.selected = true;
  9479. childrens[index].selected = true;
  9480. }
  9481. if (item && item.children) {
  9482. selectItem(pmodel, item.children);
  9483. }
  9484. });
  9485. }
  9486. }
  9487. }
  9488. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  9489. if (search === 'search' && items.filterKeyword) {
  9490. // bala:树形模糊搜索
  9491. options.templateOptions.bala(options.templateOptions.APIService, items.filterKeyword).then(function (result) {
  9492. result.list = [...new Set(result.list)]; //去重
  9493. if (!options.templateOptions.options) {
  9494. options.templateOptions.options = [];
  9495. }
  9496. if (options.templateOptions.optionsDataKey) {
  9497. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9498. } else {
  9499. options.templateOptions.options = convertParentToChildList(result);
  9500. }
  9501. //set default value
  9502. var pmodel, i = 0;
  9503. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9504. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9505. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9506. if (i == 0) {
  9507. if (options.model[p] == null) {
  9508. options.model[p] = {};
  9509. }
  9510. pmodel = options.model[p];
  9511. i++;
  9512. } else {
  9513. if (pmodel[p] == null) {
  9514. pmodel[p] = {};
  9515. }
  9516. pmodel = pmodel[p];
  9517. }
  9518. });
  9519. } else {
  9520. pmodel = options.model;
  9521. }
  9522. }
  9523. var topdata = angular.copy(options.templateOptions.options);
  9524. if (pmodel) {
  9525. pmodel = pmodel[options.key];
  9526. } else if (options.model) {
  9527. pmodel = options.model[options.key];
  9528. }
  9529. if (angular.isArray(pmodel)) {
  9530. if (pmodel) {
  9531. items.inputModel = angular.copy(options.templateOptions.options);
  9532. selectItem(pmodel, options.templateOptions.options);
  9533. }
  9534. } else {
  9535. if (pmodel && pmodel.id) {
  9536. items.inputModel = angular.copy(options.templateOptions.options);
  9537. selectItem(pmodel, options.templateOptions.options);
  9538. } else {
  9539. // items.inputModel = options.templateOptions.options;
  9540. }
  9541. }
  9542. // items.inputModel = options.templateOptions.options;
  9543. items.selectModel = options.templateOptions.options;
  9544. // 可在此展开
  9545. if (!items.inputModel) {
  9546. items.inputModel = items.selectModel;
  9547. } else {
  9548. selectItemchild(pmodel, items.inputModel);
  9549. // for (var i = 0; i < items.inputModel.length; i++) {
  9550. // items.inputModel[i].
  9551. // for (var j = 0; j < items.selectModel.length; j++) {
  9552. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9553. // items.inputModel[i].selected = true;
  9554. // }
  9555. // }
  9556. // }
  9557. }
  9558. return items.inputModel;
  9559. // options.templateOptions.options = angular.copy(topdata);
  9560. // console.log(model);
  9561. // console.log(options);
  9562. });
  9563. } else {
  9564. options.templateOptions.refreshData(options.templateOptions.APIService).then(function (result) {
  9565. if (!options.templateOptions.options) {
  9566. options.templateOptions.options = [];
  9567. }
  9568. if (options.templateOptions.optionsDataKey) {
  9569. options.templateOptions.options = convertParentToChildList(result[options.templateOptions.optionsDataKey]);
  9570. } else {
  9571. options.templateOptions.options = convertParentToChildList(result);
  9572. }
  9573. //set default value
  9574. var pmodel, i = 0;
  9575. if (options.templateOptions.pkey || options.templateOptions.pkey != "") {
  9576. if (options.templateOptions.pkey.indexOf(".") > 0) {
  9577. angular.forEach(options.templateOptions.pkey.split("."), function (p) {
  9578. if (i == 0) {
  9579. if (options.model[p] == null) {
  9580. options.model[p] = {};
  9581. }
  9582. pmodel = options.model[p];
  9583. i++;
  9584. } else {
  9585. if (pmodel[p] == null) {
  9586. pmodel[p] = {};
  9587. }
  9588. pmodel = pmodel[p];
  9589. }
  9590. });
  9591. } else {
  9592. pmodel = options.model;
  9593. }
  9594. }
  9595. var topdata = angular.copy(options.templateOptions.options);
  9596. if (pmodel) {
  9597. pmodel = pmodel[options.key];
  9598. } else if (options.model) {
  9599. pmodel = options.model[options.key];
  9600. }
  9601. if (angular.isArray(pmodel)) {
  9602. if (pmodel) {
  9603. items.inputModel = angular.copy(options.templateOptions.options);
  9604. selectItem(pmodel, options.templateOptions.options);
  9605. }
  9606. } else {
  9607. if (pmodel && pmodel.id) {
  9608. items.inputModel = angular.copy(options.templateOptions.options);
  9609. selectItem(pmodel, options.templateOptions.options);
  9610. } else {
  9611. // items.inputModel = options.templateOptions.options;
  9612. }
  9613. }
  9614. // items.inputModel = options.templateOptions.options;
  9615. items.selectModel = options.templateOptions.options;
  9616. if (!items.inputModel) {
  9617. items.inputModel = items.selectModel;
  9618. } else {
  9619. selectItemchild(pmodel, items.inputModel);
  9620. // for (var i = 0; i < items.inputModel.length; i++) {
  9621. // for (var j = 0; j < items.selectModel.length; j++) {
  9622. // if (items.selectModel[j].id == items.inputModel[i].id) {
  9623. // items.inputModel[i].selected = true;
  9624. // }
  9625. // }
  9626. // }
  9627. }
  9628. // options.templateOptions.options = angular.copy(topdata);
  9629. // console.log(model);
  9630. // console.log(options);
  9631. });
  9632. }
  9633. }
  9634. },
  9635. validators: {
  9636. required: {
  9637. expression: function (viewValue, modelValue) {
  9638. var value = modelValue || viewValue;
  9639. if (angular.isArray(value)) {
  9640. return value.length > 0
  9641. } else {
  9642. // console.log(options)
  9643. if (options.templateOptions.required && !value) {
  9644. // return value != null;
  9645. } else {
  9646. return value;
  9647. }
  9648. // return value = "true";
  9649. }
  9650. }
  9651. }
  9652. }
  9653. }
  9654. },
  9655. controller: ['$scope', '$rootScope', 'api_configure_form', 'api_bpm_domain', function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  9656. $rootScope.checkClicked = function (item) {
  9657. angular.forEach($scope.to.options, function (itemone) {
  9658. if (!item.parent) {
  9659. if (item.id == itemone.id) {
  9660. // itemone.isExpanded = true;
  9661. } else {
  9662. itemone.isExpanded = false;
  9663. }
  9664. } else {
  9665. if (item.parent.id == itemone.id) {
  9666. angular.forEach(itemone.children, function (itemtwo) {
  9667. if (item.id == itemtwo.id) { } else {
  9668. itemtwo.isExpanded = false;
  9669. }
  9670. })
  9671. }
  9672. }
  9673. })
  9674. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  9675. console.log($scope,'gsm');
  9676. if ($scope.originalModel && $scope.originalModel.incident && item.category && (!item.children || !item.children.length) && item.priority && item.priority.id) {
  9677. api_bpm_domain.expectedTime('L' + (item.priority.id - 1559)).then(function (res) {
  9678. $scope.originalModel.incident.expectResponseTime = res.serviceLevelAgreement.responseTime;
  9679. $scope.originalModel.incident.expectIntroTime = res.serviceLevelAgreement.resolveTime;
  9680. $scope.originalModel.incident.overdueTime = res.date;
  9681. })
  9682. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9683. // setTimeout(() => {
  9684. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9685. // }, 500);
  9686. // console.log($scope.$parent.$parent.$parent)
  9687. }
  9688. }
  9689. if ($scope.options.templateOptions.isMultiSelect) {
  9690. // console.log($scope);
  9691. } else {
  9692. if ($scope.model[$scope.options.key]) {
  9693. }
  9694. }
  9695. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  9696. // console.log(item)
  9697. // // if(){
  9698. // // }
  9699. // // $scope.model[$scope.options.key]=item.id;
  9700. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  9701. // $scope.propTypeOptions = data;
  9702. // });
  9703. // }
  9704. // $scope.model[$scope.options.key]=[];
  9705. // $scope.fn
  9706. $rootScope.bala1 = function (items, fn) {
  9707. // $scope.fn = fn;
  9708. console.log(items)
  9709. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  9710. $scope.options.templateOptions.refresh(items, 'search', fn)
  9711. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  9712. // // return res.list;
  9713. // console.log(666)
  9714. // fn(res.list)
  9715. // })
  9716. }
  9717. }]
  9718. });
  9719. //勾选组件
  9720. formlyConfigProvider.setType({
  9721. name: 'ui-checkbox',
  9722. extends: 'checkbox',
  9723. templateUrl: 'assets/views/customform/tpl/ui-checkbox.html',
  9724. controller: ['$scope', function ($scope) {
  9725. // 巡检生成事件,默认派单
  9726. if ($scope.model.isInspection) {
  9727. $scope.model[$scope.options.key] = true;
  9728. };
  9729. if ($scope.model[$scope.options.key] == "true") {
  9730. $scope.model[$scope.options.key] = true;
  9731. };
  9732. if ($scope.model[$scope.options.key] == "false") {
  9733. $scope.model[$scope.options.key] = false;
  9734. };
  9735. }]
  9736. });
  9737. //换行组件
  9738. formlyConfigProvider.setType({
  9739. name: 'ui-nextLine',
  9740. /*extends: 'input',*/
  9741. template: '<div></div>',
  9742. });
  9743. //多选框组件
  9744. formlyConfigProvider.setType({
  9745. name: 'ui-checklist',
  9746. extends: 'multiCheckbox',
  9747. templateUrl: 'assets/views/customform/tpl/ui-checklist.html',
  9748. defaultOptions: function (options) {
  9749. return {
  9750. templateOptions: {
  9751. refresh: function () { },
  9752. refreshDelay: 0
  9753. }
  9754. };
  9755. }
  9756. });
  9757. //单选框组件
  9758. formlyConfigProvider.setType({
  9759. name: 'ui-radio',
  9760. extends: 'radio',
  9761. templateUrl: 'assets/views/customform/tpl/ui-radio.html',
  9762. defaultOptions: function (options) {
  9763. return {
  9764. templateOptions: {
  9765. refresh: function () { },
  9766. refreshDelay: 0
  9767. }
  9768. };
  9769. },
  9770. controller: ['$scope', function ($scope) {
  9771. // 巡检生成事件,默认派单
  9772. if ($scope.model.isInspection) {
  9773. $scope.model[$scope.options.key] = true;
  9774. // $scope.model.isHandlerUser=true;
  9775. $scope.model.start_code = "assignment";
  9776. console.log($scope.model);
  9777. };
  9778. //多次暂存配置
  9779. // console.log($scope);
  9780. if ($scope.model.saveAgain) {
  9781. if ($scope.model.directClose == "1" || $scope.model.directClose == true) {
  9782. $scope.model[$scope.options.key] = true;
  9783. // if($scope.model.incident.handlingPersonnelUser){
  9784. // delete $scope.model.incident.handlingPersonnelUser;
  9785. // };
  9786. if ($scope.model.incident.handleDescription) {
  9787. delete $scope.model.incident.handleDescription
  9788. };
  9789. if ($scope.model.incident.closecode) {
  9790. delete $scope.model.incident.closecode
  9791. };
  9792. if ($scope.model.incident.degree) {
  9793. delete $scope.model.incident.degree
  9794. }
  9795. } else {
  9796. $scope.model.incident.handlingPersonnelUser = $scope.model.incident.acceptUser;
  9797. $scope.model[$scope.options.key] = false
  9798. }
  9799. }
  9800. }]
  9801. });
  9802. //文本域组件
  9803. formlyConfigProvider.setWrapper({
  9804. name: 'validation',
  9805. types: ['ui-textarea'],
  9806. 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>"
  9807. });
  9808. formlyConfigProvider.setType({
  9809. name: 'ui-textarea',
  9810. extends: 'textarea',
  9811. templateUrl: 'assets/views/customform/tpl/ui-textarea.html',
  9812. defaultOptions: function (options) {
  9813. return {
  9814. templateOptions: {
  9815. transform: function (model, value) {
  9816. return value;
  9817. },
  9818. },
  9819. validation: {
  9820. messages: {
  9821. maxlength: function (viewValue, modelValue, scope) {
  9822. if (viewValue != null) {
  9823. if (viewValue.length > scope.to.maxlength) {
  9824. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9825. } else {
  9826. return "";
  9827. }
  9828. }
  9829. },
  9830. }
  9831. }
  9832. }
  9833. },
  9834. controller: ['$scope', function ($scope) {
  9835. var value = $scope.model[$scope.options.key];
  9836. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9837. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9838. }
  9839. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9840. $scope.options.templateOptions.felditem($scope);
  9841. }
  9842. }]
  9843. });
  9844. // div版的textarea(展示富文本框内容用)
  9845. formlyConfigProvider.setType({
  9846. name: 'ui-divTextarea',
  9847. extends: 'textarea',
  9848. templateUrl: 'assets/views/customform/tpl/ui-divTextarea.html',
  9849. defaultOptions: function (options) {
  9850. return {
  9851. templateOptions: {
  9852. transform: function (model, value) {
  9853. return value;
  9854. },
  9855. },
  9856. validation: {
  9857. messages: {
  9858. // maxlength: function (viewValue, modelValue, scope) {
  9859. // if (viewValue != null) {
  9860. // if (viewValue.length > scope.to.maxlength) {
  9861. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9862. // } else {
  9863. // return "";
  9864. // }
  9865. // }
  9866. // },
  9867. }
  9868. }
  9869. }
  9870. },
  9871. controller: ['$scope', function ($scope) {
  9872. var value = $scope.model[$scope.options.key];
  9873. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9874. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9875. }
  9876. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9877. $scope.options.templateOptions.felditem($scope);
  9878. }
  9879. }]
  9880. });
  9881. // 带有知识库引用的textarea
  9882. formlyConfigProvider.setType({
  9883. name: 'ui-textAreaKnowledge',
  9884. // extends: 'textarea',
  9885. templateUrl: 'assets/views/customform/tpl/ui-textAreaKnowledge.html',
  9886. defaultOptions: function (options) {
  9887. return {
  9888. templateOptions: {
  9889. transform: function (model, value) {
  9890. return value;
  9891. },
  9892. },
  9893. validation: {
  9894. messages: {
  9895. maxlength: function (viewValue, modelValue, scope) {
  9896. if (viewValue != null) {
  9897. if (viewValue.length > scope.to.maxlength) {
  9898. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9899. } else {
  9900. return "";
  9901. }
  9902. }
  9903. },
  9904. }
  9905. }
  9906. }
  9907. },
  9908. 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) {
  9909. // console.log($scope);
  9910. var value = $scope.model[$scope.options.key];
  9911. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9912. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9913. }
  9914. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  9915. $scope.options.templateOptions.felditem($scope);
  9916. }
  9917. // 引用知识库点击
  9918. $scope.openSolution = function () {
  9919. $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  9920. setTimeout(() => {
  9921. $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  9922. }, 100);
  9923. }
  9924. }]
  9925. });
  9926. //常用语句选择textarea
  9927. formlyConfigProvider.setType({
  9928. name: 'ui-textselect',
  9929. extends: 'textarea',
  9930. templateUrl: 'assets/views/customform/tpl/ui-textselect.html',
  9931. defaultOptions: function (options) {
  9932. return {
  9933. templateOptions: {
  9934. transform: function (model, value) {
  9935. return value;
  9936. },
  9937. },
  9938. validation: {
  9939. messages: {
  9940. maxlength: function (viewValue, modelValue, scope) {
  9941. if (viewValue != null) {
  9942. if (viewValue.length > scope.to.maxlength) {
  9943. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  9944. } else {
  9945. return "";
  9946. }
  9947. }
  9948. },
  9949. }
  9950. }
  9951. }
  9952. },
  9953. controller: ['$scope', function ($scope) {
  9954. var value = $scope.model[$scope.options.key];
  9955. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9956. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  9957. }
  9958. }]
  9959. });
  9960. //改动的组件 ckeditor封装后的组件
  9961. formlyConfigProvider.setType({
  9962. name: 'ui-text-check',
  9963. extends: 'textarea',
  9964. templateUrl: 'assets/views/customform/tpl/ui-text-check.html',
  9965. defaultOptions: function (options) {
  9966. return {
  9967. templateOptions: {
  9968. extraPlugins: 'uploadimage',
  9969. uploadimageConfig: {
  9970. backend: 'basic',
  9971. settings: {
  9972. uploadUrl: options.templateOptions.APIService.upload().getRequestedUrl(),
  9973. headers: '',
  9974. downloadUrl: options.templateOptions.APIService.uploadResponseUri().getRequestedUrl()
  9975. }
  9976. },
  9977. refresh: function (APIService, contentId, data) {
  9978. return APIService.fetchDataList(contentId, data);
  9979. },
  9980. downloadUri: function (APIService, contentId) {
  9981. return APIService.downloadAttachment(contentId).getRequestedUrl();
  9982. },
  9983. upload: function (APIService, contentId) {
  9984. return APIService.getSolutionDowpath(contentId);
  9985. },
  9986. view: function (attachmentId) {
  9987. // return APIService.attachmentsPreviewUrl(contentId);
  9988. },
  9989. refreshDelay: 0,
  9990. transform: function (model, value) {
  9991. return value;
  9992. },
  9993. },
  9994. validation: {
  9995. messages: {
  9996. maxlength: function (viewValue, modelValue, scope) {
  9997. if (viewValue != null) {
  9998. if (viewValue.length > scope.to.maxlength) {
  9999. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  10000. } else {
  10001. return "";
  10002. }
  10003. }
  10004. },
  10005. }
  10006. }
  10007. }
  10008. },
  10009. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10010. var value = $scope.model[$scope.options.key];
  10011. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10012. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10013. }
  10014. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10015. //var expiry={'expiry':14804244006};
  10016. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10017. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10018. $scope.upload = function (contentId, filename) {
  10019. var filename = filename;
  10020. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  10021. var file = new Blob([response], {
  10022. type: 'application/octet-stream'
  10023. });
  10024. // var filename = filename;
  10025. var fileURL = URL.createObjectURL(file);
  10026. var a = document.createElement('a');
  10027. a.href = fileURL;
  10028. a.target = '_blank';
  10029. a.download = filename;
  10030. document.body.appendChild(a);
  10031. a.click();
  10032. })
  10033. };
  10034. }]
  10035. });
  10036. //改动的组件 ckeditor封装后的附文本组件
  10037. formlyConfigProvider.setType({
  10038. name: 'ui-fuwenben',
  10039. extends: 'textarea',
  10040. templateUrl: 'assets/views/customform/tpl/ui-fuwenben.html',
  10041. defaultOptions: function (options) {
  10042. return {
  10043. templateOptions: {
  10044. allowedContent: 'img[!src]',//允许展示源码的标签,否则会被富文本框强制删除
  10045. extraPlugins: 'uploadimage',
  10046. uploadimageConfig: {
  10047. backend: 'basic',
  10048. settings: {
  10049. uploadUrl: options.templateOptions.APIService.upload(-110).getRequestedUrl(),
  10050. headers: '',
  10051. downloadUrl: options.templateOptions.APIService.uploadResponseUri()
  10052. }
  10053. },
  10054. refresh: function (APIService, contentId, data) {
  10055. return APIService.fetchDataList(-110, data);
  10056. },
  10057. downloadUri: function (APIService, contentId) {
  10058. return APIService.downloadAttachment(-110).getRequestedUrl();
  10059. },
  10060. upload: function (APIService, contentId) {
  10061. return APIService.getSolutionDowpath(-110);
  10062. },
  10063. view: function (attachmentId) {
  10064. // return APIService.attachmentsPreviewUrl(contentId);
  10065. },
  10066. refreshDelay: 0,
  10067. transform: function (model, value) {
  10068. return value;
  10069. },
  10070. },
  10071. validation: {
  10072. messages: {
  10073. maxlength: function (viewValue, modelValue, scope) {
  10074. if (viewValue != null) {
  10075. if (viewValue.length > scope.to.maxlength) {
  10076. return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  10077. } else {
  10078. return "";
  10079. }
  10080. }
  10081. },
  10082. }
  10083. }
  10084. }
  10085. },
  10086. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  10087. var value = $scope.model[$scope.options.key];
  10088. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10089. $scope.model[$scope.options.key] = $scope.options.templateOptions.transform($scope.originalModel, value);
  10090. }
  10091. $scope.options.templateOptions.uploadimageConfig.settings.headers = $rootScope.getSession();
  10092. //var expiry={'expiry':14804244006};
  10093. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  10094. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  10095. $scope.upload = function (contentId, filename) {
  10096. var filename = filename;
  10097. $scope.options.templateOptions.upload($scope.options.templateOptions.ApiService, -110).then(function (response) {
  10098. var file = new Blob([response], {
  10099. type: 'application/octet-stream'
  10100. });
  10101. // var filename = filename;
  10102. var fileURL = URL.createObjectURL(file);
  10103. var a = document.createElement('a');
  10104. a.href = fileURL;
  10105. a.target = '_blank';
  10106. a.download = filename;
  10107. document.body.appendChild(a);
  10108. a.click();
  10109. })
  10110. };
  10111. }]
  10112. });
  10113. //ui-grid展示控件
  10114. formlyConfigProvider.setType({
  10115. name: 'ui-grid-show',
  10116. extends: 'multiCheckbox',
  10117. templateUrl: 'assets/views/customform/tpl/ui-grid-show.html',
  10118. defaultOptions: function (options) {
  10119. return {
  10120. templateOptions: {
  10121. linkage: function () {
  10122. },
  10123. },
  10124. };
  10125. },
  10126. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data) {
  10127. var loginUser = $rootScope.user;
  10128. $scope.langs = i18nService.getAllLangs();
  10129. $scope.lang = 'zh-cn';
  10130. i18nService.setCurrentLang($scope.lang);
  10131. $scope.gridOptions = {};
  10132. $scope.gridOptions.data = 'myData';
  10133. $scope.gridOptions.enableColumnResizing = true;
  10134. // $scope.gridOptions.enableFiltering = true;
  10135. $scope.gridOptions.enableGridMenu = false;
  10136. $scope.gridOptions.enableRowSelection = true;
  10137. $scope.gridOptions.showGridFooter = true;
  10138. $scope.gridOptions.showColumnFooter = false;
  10139. $scope.gridOptions.fastWatch = true;
  10140. $scope.gridOptions.useExternalFiltering = true;
  10141. $scope.gridOptions.useExternalPagination = true;
  10142. $scope.gridOptions.paginationPageSizes = [10];
  10143. $scope.gridOptions.paginationPageSize = 10;
  10144. $scope.gridOptions.multiSelect = true;
  10145. $scope.gridOptions.rowIdentity = function (row) {
  10146. return row.id;
  10147. };
  10148. $scope.gridOptions.getRowIdentity = function (row) {
  10149. return row.id;
  10150. };
  10151. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  10152. $scope.gridOptions.columnDefs = [
  10153. // { name:'id', width:80, enableFiltering:false},
  10154. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  10155. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  10156. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  10157. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  10158. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  10159. {
  10160. name: 'inspection.title',
  10161. displayName: '计划主题',
  10162. width: 120,
  10163. enableFiltering: false
  10164. },
  10165. {
  10166. name: 'stateName',
  10167. displayName: '状态',
  10168. width: 80,
  10169. enableFiltering: false
  10170. },
  10171. {
  10172. name: 'processUser.name',
  10173. displayName: '处理人',
  10174. width: 80,
  10175. enableFiltering: false
  10176. },
  10177. {
  10178. name: 'startDate',
  10179. displayName: '开始时间',
  10180. width: 160,
  10181. enableFiltering: false
  10182. },
  10183. {
  10184. name: 'overdueTime',
  10185. displayName: '逾期时间',
  10186. width: 160,
  10187. enableFiltering: false
  10188. },
  10189. ];
  10190. var defaultFilterData = {
  10191. "idx": 0,
  10192. "sum": 10
  10193. };
  10194. //分页控制
  10195. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10196. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  10197. var filtersData = $scope.memoryfilterData;
  10198. filtersData.idx = newPage - 1;
  10199. filtersData.sum = pageSize;
  10200. $scope.refreshData('expand-right', filtersData);
  10201. });
  10202. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  10203. data.grid.appScope.selected.items = data.entity
  10204. });
  10205. };
  10206. //页面获取数据
  10207. $scope.refreshData = function (style, filterData) {
  10208. // $scope.ldloading[style.replace('-', '_')] = true;
  10209. if (angular.isUndefined(filterData)) {
  10210. filterData = defaultFilterData;
  10211. }
  10212. $scope.myData = [];
  10213. angular.extend(filterData, {
  10214. inspectionProcessActual: {
  10215. "inspectionid": $scope.model.id
  10216. }
  10217. })
  10218. api_bpm_data.fetchDataList('inspectionProcessActual', filterData).then(function (data) {
  10219. var myData = Restangular.stripRestangular(data);
  10220. $scope.gridOptions.totalItems = myData.totalNum;
  10221. $scope.myData = myData.list;
  10222. for (var i = 0; i < $scope.myData.length; i++) {
  10223. //添加序号
  10224. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  10225. }
  10226. // $scope.ldloading[style.replace('-', '_')] = false;
  10227. }, function () {
  10228. // $scope.ldloading[style.replace('-', '_')] = false;
  10229. });
  10230. };
  10231. $scope.refreshData('expand-right', defaultFilterData);
  10232. }
  10233. });
  10234. //文本框自定义选择面板组件
  10235. formlyConfigProvider.setType({
  10236. name: 'ui-input-selectmodal',
  10237. extends: 'input',
  10238. templateUrl: 'assets/views/customform/tpl/ui-input-selectmodal.html',
  10239. defaultOptions: function (options) {
  10240. return {
  10241. templateOptions: {
  10242. openModal: function (size, options, modal) {
  10243. var modalInstance = modal.open({
  10244. templateUrl: 'assets/views/customform/tpl/modal-content.html',
  10245. controller: 'ModalInstanceCtrl', //'CustomformCtrl',//
  10246. size: size,
  10247. resolve: options.templateOptions.modalParam
  10248. });
  10249. modalInstance.result.then(function (selectedItem) {
  10250. options.value(selectedItem);
  10251. }, function () {
  10252. //console.log('Modal dismissed at: ' + new Date());
  10253. });
  10254. }
  10255. }
  10256. };
  10257. }
  10258. });
  10259. //日期控件
  10260. var datepicker_attr = [
  10261. 'date-disabled',
  10262. 'custom-class',
  10263. 'show-weeks',
  10264. 'starting-day',
  10265. 'init-date',
  10266. 'min-mode',
  10267. 'max-mode',
  10268. 'format-day',
  10269. 'format-month',
  10270. 'format-year',
  10271. 'format-day-header',
  10272. 'format-day-title',
  10273. 'format-month-title',
  10274. 'year-range',
  10275. 'shortcut-propagation',
  10276. 'datepicker-popup',
  10277. 'show-button-bar',
  10278. 'current-text',
  10279. 'clear-text',
  10280. 'close-text',
  10281. 'close-on-date-selection',
  10282. 'datepicker-append-to-body'
  10283. ];
  10284. var datepicker_bindings = [
  10285. 'datepicker-mode',
  10286. 'min-date',
  10287. 'max-date'
  10288. ];
  10289. formlyConfigProvider.setType({
  10290. name: 'ui-datetime',
  10291. templateUrl: 'assets/views/customform/tpl/ui-datetime.html',
  10292. extends: 'input',
  10293. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10294. defaultOptions: {
  10295. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10296. templateOptions: {
  10297. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10298. }
  10299. },
  10300. controller: ['$scope', '$filter', function ($scope, $filter) {
  10301. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10302. $scope.options.initialValue = $scope.model[$scope.options.key];
  10303. }]
  10304. });
  10305. //日期控件
  10306. formlyConfigProvider.setType({
  10307. name: 'ui-datepicker',
  10308. templateUrl: 'assets/views/customform/tpl/ui-datepicker.html',
  10309. extends: 'input',
  10310. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10311. defaultOptions: {
  10312. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10313. templateOptions: {
  10314. datepickerPopup: 'yyyy-MM-dd HH:mm:ss'
  10315. }
  10316. },
  10317. controller: ['$scope', '$filter', function ($scope, $filter) {
  10318. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  10319. if ($scope.model[$scope.options.key]) {
  10320. } else {
  10321. $scope.model[$scope.options.key] = $filter('date')(new Date(), $scope.options.templateOptions.datepickerPopup);
  10322. }
  10323. $scope.options.initialValue = $scope.model[$scope.options.key];
  10324. $scope.endOpen = true;
  10325. $scope.datepicker = {};
  10326. $scope.datepicker.opened = false;
  10327. $scope.datepicker.open = function ($event) {
  10328. $scope.datepicker.opened = true;
  10329. };
  10330. }]
  10331. });
  10332. //时分控件
  10333. formlyConfigProvider.setType({
  10334. name: 'ui-datehourtime',
  10335. extends: 'input',
  10336. templateUrl: 'assets/views/customform/tpl/ui-datehourtime.html',
  10337. defaultOptions: function (options) {
  10338. return {
  10339. noFormControl: true,
  10340. // validators:{
  10341. // required:{
  10342. // expression:function(viewValue, modelValue){
  10343. // console.log(options)
  10344. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  10345. // // var value = modelValue.getHours() || viewValue.getHours();
  10346. // return value.length>=1;
  10347. // }
  10348. // }
  10349. // }
  10350. }
  10351. },
  10352. controller: ['$scope', '$log', function ($scope, $log) {
  10353. $scope.hstep = (new Date(Date.parse($scope.model[$scope.options.key]))).getHours();
  10354. $scope.minutes = (new Date(Date.parse($scope.model[$scope.options.key]))).getMinutes();
  10355. $scope.model[$scope.options.key] = new Date(Date.parse($scope.model[$scope.options.key]))
  10356. }]
  10357. });
  10358. //状态追踪
  10359. formlyConfigProvider.setType({
  10360. name: 'ui-followStatus',
  10361. templateUrl: 'assets/views/customform/tpl/ui-followStatus.html',
  10362. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10363. setTimeout(function () {
  10364. var pkey = $scope.options.templateOptions.pkey;
  10365. var dataId = $scope.model.id;
  10366. if (dataId) {
  10367. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10368. if (response) {
  10369. var myData = Restangular.stripRestangular(response);
  10370. var processInstanceId = myData.data.processInstanceId;
  10371. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10372. if (result.status == 200) {
  10373. var newData = Restangular.stripRestangular(result);
  10374. $scope.followData = newData.data;
  10375. }
  10376. });
  10377. }
  10378. })
  10379. }
  10380. }, 10);
  10381. }]
  10382. });
  10383. //历史记录
  10384. formlyConfigProvider.setType({
  10385. name: 'ui-history',
  10386. templateUrl: 'assets/views/customform/tpl/ui-history.html',
  10387. controller: ['$scope', 'api_bpm_data', 'Restangular', function ($scope, api_bpm_data, Restangular) {
  10388. setTimeout(function () {
  10389. var pkey = $scope.options.templateOptions.pkey;
  10390. var dataId = $scope.model.id;
  10391. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  10392. if (response) {
  10393. var myData = Restangular.stripRestangular(response);
  10394. var processInstanceId = myData.data.processInstanceId;
  10395. $scope.options.templateOptions.getData($scope.model, $scope.options.templateOptions.ApiService, processInstanceId).then(function (result) {
  10396. if (result.status == 200) {
  10397. var newData = Restangular.stripRestangular(result);
  10398. var long = newData.data.length - 1;
  10399. $scope.followData = newData.data[long];
  10400. }
  10401. });
  10402. }
  10403. })
  10404. }, 10);
  10405. }]
  10406. });
  10407. // //请求人信息显示
  10408. // formlyConfigProvider.setType({
  10409. // name: "ui-disrequester",
  10410. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  10411. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10412. // defaultOptions: function(options) {
  10413. // return {
  10414. // templateOptions: {}
  10415. // };
  10416. // },
  10417. // controller: ['$scope', function($scope) {
  10418. // $scope.options.templateOptions.that = $scope;
  10419. // }]
  10420. // });
  10421. //退回人信息显示
  10422. formlyConfigProvider.setType({
  10423. name: "ui-returnperson",
  10424. templateUrl: 'assets/views/customform/tpl/ui-returnperson.html',
  10425. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10426. defaultOptions: function (options) {
  10427. return {
  10428. templateOptions: {}
  10429. };
  10430. },
  10431. controller: ['$scope', function ($scope) {
  10432. $scope.group = "";
  10433. $scope.role = "";
  10434. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10435. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10436. } else {
  10437. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10438. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10439. }
  10440. }
  10441. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10442. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10443. } else {
  10444. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10445. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10446. }
  10447. }
  10448. $scope.options.templateOptions.that = $scope;
  10449. $scope.options.templateOptions.that = $scope;
  10450. }]
  10451. });
  10452. //退回人信息显示(去掉工作组&角色)
  10453. formlyConfigProvider.setType({
  10454. name: "ui-returnpersonNoGroup",
  10455. templateUrl: 'assets/views/customform/tpl/ui-returnpersonNoGroup.html',
  10456. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10457. defaultOptions: function (options) {
  10458. return {
  10459. templateOptions: {}
  10460. };
  10461. },
  10462. controller: ['$scope', function ($scope) {
  10463. $scope.group = "";
  10464. $scope.role = "";
  10465. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  10466. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  10467. } else {
  10468. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  10469. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  10470. }
  10471. }
  10472. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  10473. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  10474. } else {
  10475. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  10476. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  10477. }
  10478. }
  10479. $scope.options.templateOptions.that = $scope;
  10480. $scope.options.templateOptions.that = $scope;
  10481. }]
  10482. });
  10483. //指派技术人员
  10484. formlyConfigProvider.setType({
  10485. name: "ui-apiontperson",
  10486. templateUrl: 'assets/views/customform/tpl/ui-apiontperson.html',
  10487. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  10488. defaultOptions: function (options) {
  10489. return {
  10490. templateOptions: {
  10491. transtlara: function (value, $scope) { }
  10492. }
  10493. };
  10494. },
  10495. controller: ['$scope', 'api_user_data', 'Restangular', function ($scope, api_user_data, Restangular) {
  10496. var filterData = {
  10497. "idx": 0,
  10498. "sum": 1000
  10499. }
  10500. api_user_data.fetchDataList('group', filterData).then(function (response) {
  10501. if (response.status == 200) {
  10502. $scope.select = {};
  10503. $scope.multipleDemo = {};
  10504. $scope.userdata = {};
  10505. var data = response.list;
  10506. var item = [];
  10507. $scope.multipleDemo = data;
  10508. $scope.multipleDemo;
  10509. }
  10510. })
  10511. $scope.options.templateOptions.onChange = function (id, options, groupdata, $event, model) {
  10512. if (groupdata.option) {
  10513. $scope.model[$scope.options.key] = {};
  10514. var fildate = {
  10515. "idx": 0,
  10516. "sum": 1000,
  10517. "user": {
  10518. "roledata": {
  10519. "rolecode": model.currentRole
  10520. },
  10521. "selectType": "1",
  10522. "groupdata": {
  10523. "id": groupdata.option.id
  10524. }
  10525. }
  10526. }
  10527. api_user_data.fetchDataList('user', fildate).then(function (response) {
  10528. if (response.status == 200) {
  10529. $scope.userdata = {};
  10530. $scope.userdata = response.list;
  10531. }
  10532. })
  10533. } else {
  10534. $scope.model[$scope.options.key] = {
  10535. id: groupdata.id.id
  10536. }
  10537. $scope.options.templateOptions.transtlara($scope.model[$scope.options.key], $scope);
  10538. }
  10539. }
  10540. // }
  10541. }]
  10542. });
  10543. //请求科室信息(小蓝框) lmm
  10544. formlyConfigProvider.setType({
  10545. name: 'ui-deptinformation',
  10546. templateUrl: 'assets/views/customform/tpl/ui-deptinformation.html',
  10547. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10548. return {
  10549. templateOptions: {
  10550. checkform: function (options) {
  10551. }
  10552. }
  10553. };
  10554. },
  10555. controller: ['$scope', 'api_statistic', function ($scope, api_statistic) {
  10556. // console.log($scope)
  10557. }]
  10558. });
  10559. //请求人信息
  10560. formlyConfigProvider.setType({
  10561. name: 'ui-requesterinformation',
  10562. templateUrl: 'assets/views/customform/tpl/ui-requesterinformation.html',
  10563. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  10564. return {
  10565. templateOptions: {
  10566. checkform: function (options) {
  10567. if (options.model.requester) {
  10568. options.value(options.model.requester);
  10569. }
  10570. },
  10571. addRequeter: function (size, options, modal, e) {
  10572. if(e.clientX === 0){
  10573. return;
  10574. }
  10575. e.preventDefault();
  10576. var modalInstance = modal.open({
  10577. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  10578. controller: function ($scope, sco, $rootScope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, api_statistic, api_wechatfile) {
  10579. $scope.title = "新增报修人";
  10580. $scope.requester = {};
  10581. $scope.searchData = {};
  10582. $scope.onChangeadd = function (searchData) {
  10583. $scope.searchKey = searchData.account;
  10584. // $scope.searchDataadd = searchData;
  10585. var requesdata = angular.copy(searchData)
  10586. if (requesdata.mphone) {
  10587. delete requesdata.mphone;
  10588. }
  10589. $scope.requester = requesdata;
  10590. console.log($scope.requester)
  10591. }
  10592. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10593. $scope.requester.account = searchKey;
  10594. $scope.searchData = searchKey;
  10595. serchdataadd(searchKey);
  10596. }
  10597. $scope.getMydata = function (x) {
  10598. $scope.searchField = JSON.parse(x[0]).account;
  10599. $scope.requester = JSON.parse(x[0]);
  10600. console.log($scope.requester)
  10601. }
  10602. $scope.getMydataone = function (x) {
  10603. $scope.searchField = x;
  10604. $scope.requester.account = x;
  10605. }
  10606. serchdataadd();
  10607. api_wechatfile.getDictionary({
  10608. "type": "list",
  10609. "key": "male"
  10610. }).then(function (data) {
  10611. if (data.status == 200) {
  10612. requester.gender = data.list;
  10613. }
  10614. })
  10615. function serchdataadd(searchKey) {
  10616. if (searchKey) {
  10617. var filterData = {
  10618. 'requester': {
  10619. 'searchKey': searchKey,
  10620. },
  10621. idx: 0,
  10622. sum: 10
  10623. };
  10624. } else {
  10625. var filterData = {
  10626. idx: 0,
  10627. sum: 10
  10628. };
  10629. }
  10630. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10631. var myData = response;
  10632. $scope.myData = myData.list;
  10633. });
  10634. }
  10635. api_user_data.fetchDataList('area', {
  10636. idx: 0,
  10637. sum: 1000
  10638. }).then(function (response) {
  10639. if (response.status == 200) {
  10640. $scope.areas = response.list;
  10641. }
  10642. })
  10643. api_wechatfile.getDictionary({
  10644. key: "requester_type",
  10645. type: "list"
  10646. }, {
  10647. idx: 0,
  10648. sum: 100
  10649. }).then(function (response) {
  10650. if (response) {
  10651. $scope.networktypes = response;
  10652. }
  10653. })
  10654. $scope.requesterAreaid = "";
  10655. $scope.onChange = function (item) {
  10656. $scope.requesterAreaid = item.id;
  10657. api_user_data.fetchDataList('place', {
  10658. place: {
  10659. area: {
  10660. id: item.id
  10661. }
  10662. },
  10663. idx: 0,
  10664. sum: 1000
  10665. }).then(function (response) {
  10666. if (response.status == 200) {
  10667. $scope.places = response.list;
  10668. delete $scope.requester.placeDTO;
  10669. }
  10670. })
  10671. }
  10672. $scope.refresh = function (searchVal) {
  10673. var faildata = {};
  10674. if ($scope.requesterAreaid) {
  10675. faildata = {
  10676. 'idx': 0,
  10677. 'sum': 1000,
  10678. 'place': {
  10679. 'areaId': $scope.requesterAreaid,
  10680. 'place': searchVal,
  10681. 'selectType': 'pinyin_qs'
  10682. }
  10683. }
  10684. } else {
  10685. faildata = {
  10686. 'idx': 0,
  10687. 'sum': 1000,
  10688. 'place': {
  10689. 'place': searchVal,
  10690. 'selectType': 'pinyin_qs'
  10691. }
  10692. }
  10693. }
  10694. api_user_data.fetchDataList('place', faildata).then(function (response) {
  10695. $scope.places = response.list;
  10696. delete $scope.requester.placeDTO;
  10697. })
  10698. }
  10699. $scope.refreshDepts = function (key) {
  10700. var filterData = {
  10701. 'idx': 0,
  10702. 'sum': 5,
  10703. 'dept': {
  10704. 'name': key
  10705. }
  10706. };
  10707. UserService.fetchDataList('department', filterData).then(function (response) {
  10708. if (response.status == 200) {
  10709. $scope.depts = response.list;
  10710. }
  10711. })
  10712. }
  10713. $scope.ok = function () {
  10714. if (angular.isUndefined($scope.requester.account) || $scope.requester.account == null || $scope.requester.account == "") {
  10715. SweetAlert.swal("报修人员编号未填!", "请填写报修人员编号", "error");
  10716. } else if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  10717. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  10718. } else if (angular.isUndefined($scope.requester.requesterType) || $scope.requester.requesterType == null || $scope.requester.requesterTypeDTO == "") {
  10719. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  10720. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  10721. SweetAlert.swal("报修人联系电话未填!", "请填写报修人联系电话", "error");
  10722. } else {
  10723. $scope.requesterId = $scope.requester.id;
  10724. var data = {
  10725. incident: {
  10726. requester: {
  10727. id: $scope.requesterId
  10728. }
  10729. },
  10730. idx: 0,
  10731. sum: 3
  10732. };
  10733. api_statistic.tableData(data, 'incident').then(function (data) {
  10734. sco.$parent.$parent.$parent.model.incident.tableList = data.list;
  10735. })
  10736. $scope.$watch(sco.$parent.$parent.$parent.model.incident.tableList, function (oldObj, newObj) {
  10737. if (newObj != oldObj) {
  10738. sco.$parent.$parent.$parent.model.incident.tableList = newObj;
  10739. }
  10740. })//lmm
  10741. console.log($scope.requester)
  10742. $modalInstance.close($scope.requester);
  10743. }
  10744. };
  10745. $scope.cancel = function () {
  10746. $modalInstance.dismiss('cancel');
  10747. };
  10748. },
  10749. resolve: {
  10750. items: function () {
  10751. return {
  10752. fetchItems: function (filterData, APIService) {
  10753. filterData = filterData || {};
  10754. if (!filterData.idx) {
  10755. filterData = {
  10756. idx: 0,
  10757. sum: 10
  10758. };
  10759. }
  10760. return options.templateOptions.fetchItems(filterData, APIService);
  10761. }
  10762. };
  10763. },
  10764. title: function () {
  10765. return options.templateOptions.modalTitle;
  10766. },
  10767. Restangular: function () {
  10768. return options.templateOptions.Restangular;
  10769. },
  10770. APIService: function () {
  10771. return options.templateOptions.ApiService;
  10772. },
  10773. UserService: function () {
  10774. return options.templateOptions.UserService;
  10775. },
  10776. sco: function () {
  10777. return $scope;
  10778. }
  10779. }
  10780. });
  10781. modalInstance.result.then(function (selectedItem) {
  10782. console.log(selectedItem)
  10783. if (selectedItem) {
  10784. var data = {
  10785. 'requester': selectedItem
  10786. };
  10787. $scope.searchKey = selectedItem.account;
  10788. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  10789. // if (selectedItem.place && selectedItem.place.place) {
  10790. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  10791. // }
  10792. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  10793. if (response.status == 200) {
  10794. if (options.model) {
  10795. options.model.requester = response.data
  10796. $scope.$parent.$parent.$parent.model.incident.requester = response.data;
  10797. $scope.$parent.$parent.$parent.model.requestershow = response.data;
  10798. if (options.model.place) {
  10799. options.model.place.id = '';
  10800. }
  10801. if (options.model.area) {
  10802. options.model.area.id = '';
  10803. }
  10804. options.model.contacts = selectedItem.name;
  10805. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  10806. options.model.contactsInformation = selectedItem.mphone;
  10807. } else {
  10808. options.model.contactsInformation = selectedItem.telephone;
  10809. }
  10810. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  10811. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10812. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  10813. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  10814. }
  10815. }
  10816. if (!response.data.id) {
  10817. response.data.id = selectedItem.id
  10818. }
  10819. options.value(response.data);
  10820. options.value(response.data);
  10821. console.log($scope,'0000000');
  10822. //新增报修人带入区域地点2020年4月23日19:48:15
  10823. $scope.model.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10824. $scope.$root.selecthouseNumber = selectedItem.place?selectedItem.place:{};
  10825. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  10826. if (selectedItem.place && selectedItem.place.id) {
  10827. options.model.place.id = selectedItem.place.id
  10828. options.model.place.area.id = selectedItem.place.area.id
  10829. };
  10830. } else {
  10831. if (selectedItem.place && selectedItem.place.id) {
  10832. options.model.place.id = selectedItem.place.id
  10833. options.model.area.id = selectedItem.place.area.id
  10834. };
  10835. }
  10836. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  10837. // options.model.area.id = selectedItem.place.area.id
  10838. // }
  10839. if (selectedItem.houseNumber) {
  10840. options.model.houseNumber = selectedItem.houseNumber
  10841. }
  10842. // if (selectedItem.id) {
  10843. options.model.account = selectedItem.account;
  10844. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  10845. var baoxiuFields = $scope.$parent.$parent.$parent.$parent.$parent.vm.fields[1].fields;
  10846. var baoxiurenTo;
  10847. baoxiuFields.forEach((e, i) => {
  10848. if (e.key == 'account') {
  10849. baoxiurenTo = e.templateOptions
  10850. baoxiurenTo.APIService.fetchDataList('requester', {
  10851. "idx": 0,
  10852. "sum": 20,
  10853. requester: {
  10854. searchKey: selectedItem.account
  10855. }
  10856. }).then(res => {
  10857. baoxiurenTo.options = res.list;
  10858. options.model.account = selectedItem.account;
  10859. })
  10860. }
  10861. })
  10862. // }
  10863. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  10864. // 选择重复事件侧滑框
  10865. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  10866. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = false;
  10867. setTimeout(() => {
  10868. $scope.$parent.$parent.$parent.model['repeatIncidentShow'] = true;
  10869. }, 500);
  10870. // }
  10871. }
  10872. })
  10873. }
  10874. }, function () { });
  10875. },
  10876. changeRequeter: function (size, options, modal, modeldata, $rootScope) {
  10877. var modalInstance = modal.open({
  10878. templateUrl: 'assets/views/customform/tpl/modal-change-requester.html',
  10879. controller: function ($scope, $modalInstance, items, SweetAlert, title, Restangular, APIService, UserService, api_user_data, $rootScope) {
  10880. $scope.title = "修改报修人";
  10881. $scope.requester = {
  10882. id: modeldata.requester.id,
  10883. account: modeldata.requester.account,
  10884. name: modeldata.requester.name,
  10885. gender: modeldata.requester.gender,
  10886. email: modeldata.requester.email,
  10887. deptName: modeldata.requester.deptName,
  10888. mphone: modeldata.requester.mphone,
  10889. telephone: modeldata.requester.telephone,
  10890. studentNo: modeldata.requester.studentNo,
  10891. areaDTO: modeldata.requester.areaDTO,
  10892. placeDTO: modeldata.requester.placeDTO,
  10893. requesterTypeDTO: modeldata.requester.requesterTypeDTO
  10894. };
  10895. $scope.onChangeadd = function (searchData) {
  10896. console.log(searchData)
  10897. $scope.searchKey = searchData.account;
  10898. var requesdata = angular.copy(searchData)
  10899. if (requesdata.mphone) {
  10900. delete requesdata.mphone;
  10901. }
  10902. $scope.requester = requesdata;
  10903. }
  10904. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  10905. $scope.requester.account = searchKey;
  10906. $scope.searchData = searchKey;
  10907. serchdataadd(searchKey);
  10908. }
  10909. $scope.getMydata = function (x) {
  10910. $scope.searchField = JSON.parse(x[0]).account;
  10911. $scope.requester = JSON.parse(x[0]);
  10912. }
  10913. $scope.getMydataone = function (x) {
  10914. $scope.searchField = x;
  10915. $scope.requester.account = x;
  10916. }
  10917. serchdataadd();
  10918. function serchdataadd(searchKey) {
  10919. if (searchKey) {
  10920. var filterData = {
  10921. 'requester': {
  10922. 'searchKey': searchKey,
  10923. },
  10924. idx: 0,
  10925. sum: 10
  10926. };
  10927. } else {
  10928. var filterData = {
  10929. idx: 0,
  10930. sum: 10
  10931. };
  10932. }
  10933. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  10934. var myData = response;
  10935. $scope.myData = myData.list;
  10936. });
  10937. }
  10938. api_user_data.fetchDataList('area', {
  10939. idx: 0,
  10940. sum: 1000
  10941. }).then(function (response) {
  10942. if (response.status == 200) {
  10943. $scope.areas = response.list;
  10944. }
  10945. })
  10946. api_user_data.fetchDataList('requesterType', {
  10947. idx: 0,
  10948. sum: 100
  10949. }).then(function (response) {
  10950. if (response.status == 200) {
  10951. $scope.networktypes = response.list;
  10952. }
  10953. })
  10954. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  10955. api_user_data.fetchDataList('place', {
  10956. place: {
  10957. areaId: $scope.requester.areaDTO.id
  10958. },
  10959. idx: 0,
  10960. sum: 1000
  10961. }).then(function (response) {
  10962. if (response.status == 200) {
  10963. $scope.places = response.list;
  10964. }
  10965. })
  10966. }
  10967. $scope.onChange = function (item) {
  10968. $scope.requester.placeDTO = {};
  10969. api_user_data.fetchDataList('place', {
  10970. place: {
  10971. areaId: item.id
  10972. },
  10973. idx: 0,
  10974. sum: 1000
  10975. }).then(function (response) {
  10976. if (response.status == 200) {
  10977. $scope.places = response.list;
  10978. }
  10979. })
  10980. }
  10981. $scope.refreshDepts = function (key) {
  10982. var filterData = {
  10983. 'idx': 0,
  10984. 'sum': 5,
  10985. 'dept': {
  10986. 'name': key
  10987. }
  10988. };
  10989. UserService.fetchDataList('department', filterData).then(function (response) {
  10990. if (response.status == 200) {
  10991. $scope.depts = response.list;
  10992. }
  10993. })
  10994. }
  10995. $scope.ok = function () {
  10996. if ($scope.requester.account == "" || $scope.requester.name == "") {
  10997. SweetAlert.swal("报修人姓名或人员编号号未填!", "请补全报修人信息", "error");
  10998. } else {
  10999. $modalInstance.close($scope.requester);
  11000. }
  11001. };
  11002. $scope.cancel = function () {
  11003. $modalInstance.dismiss('cancel');
  11004. };
  11005. },
  11006. resolve: {
  11007. items: function () {
  11008. return {
  11009. fetchItems: function (filterData, APIService) {
  11010. filterData = filterData || {};
  11011. if (!filterData.idx) {
  11012. filterData = {
  11013. idx: 0,
  11014. sum: 10
  11015. };
  11016. }
  11017. return options.templateOptions.fetchItems(filterData, APIService);
  11018. }
  11019. };
  11020. },
  11021. title: function () {
  11022. return options.templateOptions.modalTitle;
  11023. },
  11024. Restangular: function () {
  11025. return options.templateOptions.Restangular;
  11026. },
  11027. APIService: function () {
  11028. return options.templateOptions.ApiService;
  11029. },
  11030. UserService: function () {
  11031. return options.templateOptions.UserService;
  11032. }
  11033. }
  11034. });
  11035. modalInstance.result.then(function (selectedItem) {
  11036. console.log(selectedItem)
  11037. if (selectedItem) {
  11038. if (options.model) {
  11039. if (options.model.place) {
  11040. options.model.place.id = '';
  11041. }
  11042. if (options.model.area) {
  11043. options.model.area.id = '';
  11044. }
  11045. options.model.contacts = selectedItem.name;
  11046. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11047. options.model.contactsInformation = selectedItem.mphone;
  11048. } else {
  11049. options.model.contactsInformation = selectedItem.telephone;
  11050. }
  11051. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11052. options.model.place.id = selectedItem.placeDTO.id
  11053. }
  11054. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11055. options.model.area.id = selectedItem.areaDTO.id
  11056. }
  11057. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11058. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11059. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11060. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11061. }
  11062. }
  11063. var data = {
  11064. 'requester': selectedItem
  11065. };
  11066. options.templateOptions.UserService.addData('requester', data).then(function (response) {
  11067. if (response.status == 200) {
  11068. $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  11069. options.value(response.data);
  11070. } else { }
  11071. })
  11072. }
  11073. }, function () { });
  11074. event.preventDefault();
  11075. }
  11076. }
  11077. };
  11078. },
  11079. controller: ['$scope', 'api_user_data', 'api_statistic', function ($scope, api_user_data, api_statistic) {
  11080. $scope.options.initialValue = $scope.model[$scope.options.key];
  11081. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  11082. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11083. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11084. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11085. }
  11086. }]
  11087. });
  11088. // 请求人选控件
  11089. formlyConfigProvider.setType({
  11090. name: "ui-requesterselect",
  11091. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  11092. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11093. defaultOptions: function (options, $scope) {
  11094. return {
  11095. templateOptions: {
  11096. // checkform: function(options) {
  11097. // if (options.model.requestershow) {
  11098. // options.value(options.model.requestershow);
  11099. // }
  11100. // },
  11101. validators: {
  11102. required: {
  11103. expression: function (viewValue, modelValue) {
  11104. var value = modelValue || viewValue;
  11105. return value.length >= 1;
  11106. }
  11107. }
  11108. },
  11109. openModal: function (size, options, modal) { //查找弹出框
  11110. var modelObject = options.value();
  11111. var searchModal = function (filterSearchData) {
  11112. var modalInstance = modal.open({
  11113. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11114. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  11115. $scope.langs = i18nService.getAllLangs();
  11116. $scope.lang = 'zh-cn';
  11117. i18nService.setCurrentLang($scope.lang);
  11118. $scope.gridOptions = {};
  11119. $scope.gridOptions.data = 'myData';
  11120. $scope.gridOptions.enableColumnResizing = true;
  11121. $scope.gridOptions.enableFiltering = true;
  11122. $scope.gridOptions.enableGridMenu = false;
  11123. $scope.gridOptions.enableRowSelection = true;
  11124. $scope.gridOptions.showGridFooter = true;
  11125. $scope.gridOptions.showColumnFooter = false;
  11126. $scope.gridOptions.fastWatch = true;
  11127. $scope.gridOptions.useExternalFiltering = true;
  11128. $scope.gridOptions.useExternalPagination = true;
  11129. $scope.gridOptions.paginationPageSizes = [10];
  11130. $scope.gridOptions.paginationPageSize = 10;
  11131. $scope.gridOptions.multiSelect = false;
  11132. $scope.gridOptions.rowIdentity = function (row) {
  11133. return row.id;
  11134. };
  11135. $scope.gridOptions.getRowIdentity = function (row) {
  11136. return row.id;
  11137. };
  11138. $scope.gridOptions.columnDefs = [{
  11139. name: 'account',
  11140. displayName: '人员编号',
  11141. width: 140
  11142. },
  11143. {
  11144. name: 'name',
  11145. displayName: '姓名',
  11146. width: 100
  11147. },
  11148. {
  11149. name: 'gender.name',
  11150. displayName: '性别',
  11151. width: 80,
  11152. enableFiltering: false
  11153. },
  11154. {
  11155. name: 'mphone',
  11156. displayName: '电话',
  11157. width: 100,
  11158. enableFiltering: false
  11159. },
  11160. {
  11161. name: 'email',
  11162. displayName: '邮件',
  11163. width: 100
  11164. },
  11165. {
  11166. name: 'areaDTO.area',
  11167. displayName: '区域',
  11168. width: 100,
  11169. enableFiltering: false
  11170. },
  11171. {
  11172. name: 'placeDTO.place',
  11173. displayName: '地点',
  11174. enableFiltering: false
  11175. }
  11176. ];
  11177. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11178. $scope.gridApi = gridApi;
  11179. // var filtersData = $scope.memoryfilterData;
  11180. // filtersData.idx = newPage - 1;
  11181. // filtersData.sum = pageSize;
  11182. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11183. var filtersData = $scope.memoryfilterData;
  11184. filtersData.idx = newPage - 1;
  11185. filtersData.sum = pageSize;
  11186. $scope.loadData(filtersData);
  11187. });
  11188. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11189. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  11190. $scope.selected.item = data.entity;
  11191. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  11192. });
  11193. gridApi.core.on.filterChanged($scope, function () {
  11194. var grid = this.grid;
  11195. var filtersData = {
  11196. idx: 0,
  11197. sum: 10
  11198. // 'requester': { 'userType': 1 }
  11199. };
  11200. angular.forEach(grid.columns, function (item) {
  11201. if (item.enableFiltering) {
  11202. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11203. if (angular.isUndefined(filtersData['requester'])) {
  11204. filtersData['requester'] = {};
  11205. }
  11206. filtersData['requester'][item.field] = item.filters[0].term;
  11207. }
  11208. }
  11209. });
  11210. $scope.memoryfilterData = filtersData;
  11211. $scope.loadData(filtersData);
  11212. });
  11213. };
  11214. $scope.memoryfilterData = defaultFilterData = {
  11215. "idx": 0,
  11216. "sum": 10
  11217. };
  11218. $scope.loadData = function (filterData) {
  11219. if (!filterData.requester) {
  11220. filterData.requester = {};
  11221. }
  11222. if (scope.roleidcode) {
  11223. angular.extend(filterData['requester'], {
  11224. 'userType': 1
  11225. });
  11226. }
  11227. items.fetchItems(filterData, APIService).then(function (data) {
  11228. var myData = Restangular.stripRestangular(data);
  11229. $scope.gridOptions.totalItems = myData.totalNum;
  11230. $scope.myData = myData.list;
  11231. });
  11232. };
  11233. // $scope.title = title;
  11234. if (searchDatas) {
  11235. $scope.loadData(searchDatas);
  11236. } else {
  11237. $scope.loadData({
  11238. idx: 0,
  11239. sum: 10,
  11240. });
  11241. }
  11242. $scope.selected = {
  11243. item: {}
  11244. };
  11245. $scope.ok = function () {
  11246. $modalInstance.close($scope.selected.item);
  11247. };
  11248. $scope.cancel = function () {
  11249. $modalInstance.dismiss('cancel');
  11250. };
  11251. },
  11252. size: size,
  11253. resolve: {
  11254. items: function () {
  11255. return {
  11256. fetchItems: function (filterData, APIService) {
  11257. filterData = filterData || {};
  11258. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  11259. filterData = {
  11260. idx: 0,
  11261. sum: 10
  11262. };
  11263. }
  11264. return options.templateOptions.fetchItems(filterData, APIService);
  11265. }
  11266. };
  11267. },
  11268. title: function () {
  11269. return options.templateOptions.modalTitle;
  11270. },
  11271. Restangular: function () {
  11272. return options.templateOptions.Restangular;
  11273. },
  11274. APIService: function () {
  11275. return options.templateOptions.ApiService;
  11276. },
  11277. language: function () {
  11278. return options.templateOptions.language;
  11279. },
  11280. searchDatas: function () {
  11281. return filterSearchData;
  11282. },
  11283. scope: function () {
  11284. return $scope;
  11285. }
  11286. }
  11287. });
  11288. modalInstance.result.then(function (selectedItem) {
  11289. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11290. selectedItem.telephone = $scope.model.incident.contactsInformation;
  11291. }
  11292. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  11293. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  11294. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  11295. if ($scope.model) {
  11296. if ($scope.model.incident.place) {
  11297. $scope.model.incident.place.id = '';
  11298. }
  11299. if ($scope.model.area) {
  11300. $scope.model.incident.area.id = '';
  11301. }
  11302. $scope.model.incident.contacts = selectedItem.name;
  11303. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11304. $scope.model.incident.contactsInformation = selectedItem.mphone;
  11305. } else {
  11306. $scope.model.incident.contactsInformation = selectedItem.telephone;
  11307. }
  11308. $scope.model.incident.houseNumber = '';
  11309. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11310. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11311. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11312. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11313. }
  11314. }
  11315. $scope.options.value(selectedItem);
  11316. $scope.searchData = selectedItem.account;
  11317. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11318. $scope.model.incident.place.id = selectedItem.placeDTO.id
  11319. }
  11320. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11321. $scope.model.incident.area.id = selectedItem.areaDTO.id
  11322. }
  11323. if (selectedItem.houseNumber) {
  11324. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  11325. }
  11326. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11327. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11328. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11329. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11330. }
  11331. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  11332. options.templateOptions.callback(selectedItem, options);
  11333. }
  11334. if (!$scope.roleidcode) {
  11335. $scope.charging(selectedItem, modal)
  11336. }
  11337. $scope.recentlyincident(selectedItem);
  11338. }, function () {
  11339. //console.log('Modal dismissed at: ' + new Date());
  11340. });
  11341. }
  11342. searchModal();
  11343. // }
  11344. }
  11345. }
  11346. };
  11347. },
  11348. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  11349. $scope.roleidcode = true;
  11350. // $scope.options.initialValue = undefined;
  11351. if ($rootScope.user && $rootScope.user.role) {
  11352. angular.forEach($rootScope.user.role, function (item) {
  11353. if (item.rolecode == "call center") {
  11354. $scope.roleidcode = false;
  11355. }
  11356. })
  11357. }
  11358. $scope.recently = false;
  11359. $scope.recentlyincident = function (key, model) { //关联事件
  11360. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  11361. "idx": 0,
  11362. "sum": 4,
  11363. incident: {
  11364. requester: {
  11365. id: key.id
  11366. }
  11367. }
  11368. }).then(function (response) {
  11369. if (response.status == 200) {
  11370. $scope.recently = true;
  11371. $scope.recentincident = response.list;
  11372. } else {
  11373. $scope.recently = false;
  11374. }
  11375. })
  11376. $scope.bodyHeight = window.innerHeight - 100;
  11377. $(window).resize(function () {
  11378. $scope.bodyHeight = window.innerHeight - 100;
  11379. });
  11380. // $scope.shows = false;
  11381. $scope.tempData = {};
  11382. $scope.close = function () {
  11383. $scope.changes = !$scope.changes;
  11384. event.preventDefault();
  11385. }
  11386. }
  11387. $scope.charging = function (key, model) { //计费弹出框
  11388. //用户信息
  11389. $scope.information = {};
  11390. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  11391. "userId": key.account
  11392. }).then(function (response) {
  11393. // if (response.status == 200) {
  11394. if (response && response.data) {
  11395. angular.extend($scope.information, response.data[0]);
  11396. // $scope.information = response.data[0];
  11397. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  11398. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  11399. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  11400. } else if (response.err) {
  11401. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  11402. }
  11403. // }
  11404. })
  11405. //上网明细
  11406. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  11407. "userId": key.account,
  11408. "limit": "10",
  11409. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  11410. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  11411. }).then(function (response) {
  11412. // if (response.status == 200) {
  11413. if (response && response.data) {
  11414. angular.forEach(response.data, function (item, index) {
  11415. if (item.logoutTime) {
  11416. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  11417. }
  11418. if (item.loginTime) {
  11419. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  11420. }
  11421. })
  11422. $scope.logininform = response.data;
  11423. } else if (response.err) {
  11424. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  11425. }
  11426. })
  11427. //黑名单
  11428. // $scope.information.blacklist = "否"
  11429. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  11430. "userId": key.account
  11431. }).then(function (response) {
  11432. // if (response.status == 200) {
  11433. // $scope.logininformation = response.data;
  11434. if (response) {
  11435. if (response.data || response.data != null) {
  11436. $scope.information.blacklist = "是"
  11437. } else {
  11438. if (response.err) {
  11439. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  11440. } else {
  11441. $scope.information.blacklist = "否"
  11442. }
  11443. }
  11444. }
  11445. // }
  11446. })
  11447. $scope.bodyHeight = window.innerHeight - 100;
  11448. $(window).resize(function () {
  11449. $scope.bodyHeight = window.innerHeight - 100;
  11450. });
  11451. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  11452. // $scope.closepages = function(e) {
  11453. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  11454. // event.preventDefault();
  11455. // };
  11456. // $scope.shows = false;
  11457. $scope.tempData = {};
  11458. $scope.close = function () {
  11459. $scope.changes = !$scope.changes;
  11460. event.preventDefault();
  11461. }
  11462. }
  11463. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  11464. idx: 0,
  11465. sum: 100
  11466. }).then(function (response) {
  11467. if (response.status == 200) {
  11468. $scope.networktypes = response.list;
  11469. } else {
  11470. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  11471. }
  11472. })
  11473. function serchdata(searchKey) {
  11474. if (searchKey) {
  11475. var filterData = {
  11476. 'requester': {
  11477. 'searchKey': searchKey
  11478. // 'userType': 1
  11479. },
  11480. idx: 0,
  11481. sum: 10
  11482. };
  11483. } else {
  11484. var filterData = {
  11485. 'idx': 0,
  11486. 'requester': {},
  11487. 'sum': 10
  11488. };
  11489. }
  11490. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  11491. angular.extend(filterData.requester, {
  11492. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  11493. });
  11494. if (!$scope.options.model.contactsInformation) {
  11495. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  11496. }
  11497. }
  11498. if ($scope.roleidcode) {
  11499. angular.extend(filterData['requester'], {
  11500. 'userType': 1
  11501. });
  11502. }
  11503. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  11504. var myData = response;
  11505. $scope.myData = myData.list;
  11506. });
  11507. }
  11508. $scope.searchData = {};
  11509. $scope.refreshUser = function (searchKey) { //请求人搜索
  11510. if (searchKey && searchKey != "") {
  11511. serchdata(searchKey);
  11512. }
  11513. }
  11514. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  11515. if (!$scope.roleidcode) {
  11516. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  11517. }
  11518. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  11519. }
  11520. $scope.onChange = function (searchData) {
  11521. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11522. searchData.telephone = $scope.model.incident.contactsInformation;;
  11523. }
  11524. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  11525. if (!$scope.roleidcode) {
  11526. $scope.charging(searchData);
  11527. }
  11528. $scope.recentlyincident(searchData);
  11529. $scope.accountshow = false;
  11530. if ($scope.model.incident) {
  11531. if ($scope.model.incident.place) {
  11532. $scope.model.incident.place.id = '';
  11533. }
  11534. if ($scope.model.incident.area) {
  11535. $scope.model.incident.area.id = '';
  11536. }
  11537. $scope.model.incident.contacts = searchData.name;
  11538. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  11539. $scope.model.incident.contactsInformation = searchData.mphone;
  11540. } else {
  11541. $scope.model.incident.contactsInformation = searchData.telephone;
  11542. }
  11543. $scope.model.incident.houseNumber = '';
  11544. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11545. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11546. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11547. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11548. }
  11549. }
  11550. $scope.options.value(searchData);
  11551. $scope.searchKey = searchData.account;
  11552. if (searchData.placeDTO && searchData.placeDTO.id) {
  11553. $scope.model.incident.place.id = searchData.placeDTO.id
  11554. }
  11555. if (searchData.areaDTO && searchData.areaDTO.id) {
  11556. $scope.model.incident.area.id = searchData.areaDTO.id
  11557. }
  11558. if (searchData.houseNumber) {
  11559. $scope.model.incident.houseNumber = searchData.houseNumber;
  11560. }
  11561. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11562. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11563. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11564. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11565. }
  11566. }
  11567. }]
  11568. });
  11569. //ui-grid-table展示控件
  11570. formlyConfigProvider.setType({
  11571. name: 'ui-grid-table',
  11572. // extends: 'multiCheckbox',//去掉冒号
  11573. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  11574. defaultOptions: function (options) {
  11575. return {
  11576. templateOptions: {
  11577. linkage: function () { },
  11578. },
  11579. };
  11580. },
  11581. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  11582. var loginUser = $rootScope.user;
  11583. $scope.langs = i18nService.getAllLangs();
  11584. $scope.lang = 'zh-cn';
  11585. i18nService.setCurrentLang($scope.lang);
  11586. $scope.gridOptions = {};
  11587. $scope.gridOptions.data = 'myData';
  11588. $scope.gridOptions.enableColumnResizing = true;
  11589. $scope.gridOptions.enableGridMenu = false;
  11590. $scope.gridOptions.enableRowSelection = true;
  11591. $scope.gridOptions.showGridFooter = false;
  11592. $scope.gridOptions.showColumnFooter = false;
  11593. $scope.gridOptions.fastWatch = true;
  11594. $scope.gridOptions.useExternalFiltering = true;
  11595. $scope.gridOptions.useExternalPagination = false;
  11596. $scope.gridOptions.paginationPageSizes = [10];
  11597. $scope.gridOptions.paginationPageSize = 3;
  11598. $scope.gridOptions.multiSelect = false;
  11599. $scope.gridOptions.rowIdentity = function (row) {
  11600. return row.id;
  11601. };
  11602. $scope.gridOptions.getRowIdentity = function (row) {
  11603. return row.id;
  11604. };
  11605. $scope.gridOptions.columnDefs = [{
  11606. name: 'item',
  11607. displayName: '序号',
  11608. width: 80,
  11609. enableFiltering: false
  11610. },
  11611. {
  11612. name: 'incidentsign',
  11613. displayName: '单号',
  11614. width: 80,
  11615. enableFiltering: false
  11616. },
  11617. {
  11618. name: 'description',
  11619. displayName: '主题',
  11620. width: 80,
  11621. enableFiltering: false
  11622. },
  11623. {
  11624. name: 'state.name',
  11625. displayName: '状态',
  11626. width: 110,
  11627. enableFiltering: false
  11628. },
  11629. {
  11630. name: 'acceptDate',
  11631. displayName: '创建时间',
  11632. width: 160,
  11633. enableFiltering: false
  11634. },
  11635. {
  11636. name: 'requester.name',
  11637. displayName: '请求人',
  11638. width: 80,
  11639. enableFiltering: false
  11640. },
  11641. {
  11642. name: 'handlingPersonnelUser.name',
  11643. displayName: '处理人',
  11644. width: 160,
  11645. enableFiltering: false
  11646. },
  11647. {
  11648. name: 'place.place',
  11649. displayName: '区域地点',
  11650. width: 160,
  11651. enableFiltering: false
  11652. },
  11653. ];
  11654. // var defaultFilterData = {
  11655. // "idx": 0,
  11656. // "sum": 3
  11657. // };
  11658. // // //分页控制
  11659. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11660. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11661. var filtersData = $scope.memoryfilterData;
  11662. filtersData.idx = newPage - 1;
  11663. filtersData.sum = pageSize;
  11664. $scope.refreshData('expand-right', filtersData);
  11665. });
  11666. // 表格单选事件
  11667. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11668. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  11669. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  11670. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  11671. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  11672. str = str.split("").reverse().join("");
  11673. var del = addstr.split("").reverse().join("");
  11674. // console.log(del);
  11675. var reg = new RegExp(del);
  11676. str = str.replace(reg, '');
  11677. str = str.split("").reverse().join("")
  11678. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  11679. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  11680. str += data.entity.description;
  11681. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  11682. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  11683. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  11684. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  11685. }
  11686. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  11687. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  11688. });
  11689. };
  11690. // 刷新表格
  11691. setInterval(function () {
  11692. // console.log($scope.myData);
  11693. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  11694. // console.log($scope.myData);
  11695. if ($scope.myData != null) {
  11696. for (var i = 0; i < $scope.myData.length; i++) {
  11697. //添加序号
  11698. $scope.myData[i]['item'] = i + 1;
  11699. }
  11700. }
  11701. }, 1000)
  11702. }
  11703. });
  11704. //处理人信息
  11705. formlyConfigProvider.setType({
  11706. name: "ui-userinformation",
  11707. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  11708. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11709. defaultOptions: function (options) {
  11710. return {
  11711. templateOptions: {}
  11712. };
  11713. },
  11714. controller: ['$scope', function ($scope) {
  11715. $scope.group = "";
  11716. $scope.role = "";
  11717. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11718. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11719. } else {
  11720. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11721. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11722. }
  11723. }
  11724. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  11725. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  11726. } else {
  11727. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  11728. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  11729. }
  11730. }
  11731. $scope.options.templateOptions.that = $scope;
  11732. }]
  11733. });
  11734. //处理界面处理人信息
  11735. formlyConfigProvider.setType({
  11736. name: "ui-handler",
  11737. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  11738. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11739. defaultOptions: function (options) {
  11740. return {
  11741. templateOptions: {}
  11742. };
  11743. },
  11744. controller: ['$scope', function ($scope) {
  11745. $scope.group = "";
  11746. // $scope.role="";
  11747. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11748. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11749. } else {
  11750. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11751. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11752. }
  11753. }
  11754. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  11755. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  11756. // }else{
  11757. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  11758. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  11759. // }
  11760. // }
  11761. $scope.options.templateOptions.that = $scope;
  11762. }]
  11763. });
  11764. //微信事件流程
  11765. formlyConfigProvider.setType({
  11766. name: "ui-wxIncidentProcess",
  11767. templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
  11768. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11769. defaultOptions: function (options) {
  11770. return {
  11771. templateOptions: {}
  11772. };
  11773. },
  11774. controller: ['$scope', function ($scope) {
  11775. console.log($scope.model);
  11776. $scope.pingjia = false;
  11777. $scope.jiejue = false;
  11778. if ($scope.model.incidentState.value == "3") {
  11779. $scope.pingjia = true
  11780. } else if ($scope.model.incidentState.value == "4") {
  11781. $scope.jiejue = true;
  11782. }
  11783. }]
  11784. });
  11785. //打电话
  11786. formlyConfigProvider.setType({
  11787. name: "ui-inputcall",
  11788. extends: 'input',
  11789. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  11790. defaultOptions: function (options) {
  11791. return {
  11792. templateOptions: {
  11793. transform: function (value) { }
  11794. }
  11795. };
  11796. },
  11797. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  11798. $scope.dialout = function (teleno) {
  11799. var gid = "@0"
  11800. var telephone = '9' + teleno
  11801. $rootScope.callout = 2;
  11802. if ($rootScope.takes) {
  11803. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11804. if (data.errno == 0) {
  11805. $rootScope.status = 6;
  11806. }
  11807. })
  11808. } else {
  11809. SweetAlert.swal({
  11810. title: "呼叫失败",
  11811. text: "请先签入呼叫中心!",
  11812. type: "error",
  11813. confirmButtonColor: "#DD6B55"
  11814. });
  11815. }
  11816. }
  11817. $scope.options.templateOptions.that = $scope;
  11818. }]
  11819. });
  11820. //关闭界面处理人信息
  11821. formlyConfigProvider.setType({
  11822. name: "ui-closehandler",
  11823. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  11824. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11825. defaultOptions: function (options) {
  11826. return {
  11827. templateOptions: {}
  11828. };
  11829. },
  11830. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  11831. $scope.dialout = function (teleno) {
  11832. var gid = "@0"
  11833. var telephone = '9' + teleno
  11834. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11835. if (data.errno == 0) {
  11836. $rootScope.status = 6;
  11837. }
  11838. })
  11839. }
  11840. $scope.options.templateOptions.that = $scope;
  11841. }]
  11842. });
  11843. //用户单选控件
  11844. formlyConfigProvider.setType({
  11845. name: "ui-userselect",
  11846. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  11847. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11848. defaultOptions: function (options) {
  11849. return {
  11850. templateOptions: {
  11851. openModal: function (size, options, modal) {
  11852. var modalInstance = modal.open({
  11853. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11854. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  11855. $scope.langs = i18nService.getAllLangs();
  11856. $scope.lang = 'zh-cn';
  11857. i18nService.setCurrentLang($scope.lang);
  11858. $scope.gridOptions = {};
  11859. $scope.gridOptions.data = 'myData';
  11860. $scope.gridOptions.enableColumnResizing = true;
  11861. $scope.gridOptions.enableFiltering = true;
  11862. $scope.gridOptions.enableGridMenu = false;
  11863. $scope.gridOptions.showGridFooter = true;
  11864. $scope.gridOptions.showColumnFooter = false;
  11865. $scope.gridOptions.fastWatch = true;
  11866. $scope.gridOptions.useExternalFiltering = true;
  11867. $scope.gridOptions.useExternalPagination = true;
  11868. $scope.gridOptions.paginationPageSizes = [10];
  11869. $scope.gridOptions.paginationPageSize = 10;
  11870. $scope.gridOptions.multiSelect = false;
  11871. $scope.gridOptions.rowIdentity = function (row) {
  11872. return row.id;
  11873. };
  11874. $scope.gridOptions.getRowIdentity = function (row) {
  11875. return row.id;
  11876. };
  11877. $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>";
  11878. $scope.gridOptions.columnDefs = [{
  11879. name: 'account',
  11880. displayName: '人员编号',
  11881. width: 120
  11882. },
  11883. {
  11884. name: 'name',
  11885. displayName: '姓名',
  11886. width: 100,
  11887. cellTemplate: '<div>' +
  11888. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  11889. '</div>'
  11890. },
  11891. // {
  11892. // name: 'gender.name',
  11893. // displayName: '性别',
  11894. // width: 80,
  11895. // enableFiltering: false
  11896. // },
  11897. {
  11898. name: 'phone',
  11899. displayName: '电话',
  11900. width: 230,
  11901. enableFiltering: false
  11902. },
  11903. {
  11904. name: 'email',
  11905. displayName: '邮箱',
  11906. width: 180,
  11907. enableFiltering: false
  11908. },
  11909. {
  11910. name: 'dept.dept',
  11911. displayName: '科室',
  11912. width: 130,
  11913. enableFiltering: false
  11914. },
  11915. {
  11916. name: 'taskCount',
  11917. displayName: '处理中事件数',
  11918. enableFiltering: false
  11919. }
  11920. ];
  11921. // $scope.selectButtonClick
  11922. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11923. $scope.gridApi = gridApi;
  11924. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11925. var filtersData = $scope.memoryfilterData;
  11926. filtersData.idx = newPage - 1;
  11927. filtersData.sum = pageSize;
  11928. $scope.loadData(filtersData);
  11929. //console.log(pageSize);
  11930. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  11931. });
  11932. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11933. $scope.selected.items = data.entity;
  11934. //console.log(data);
  11935. });
  11936. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  11937. $scope.selected.items = data.entity;
  11938. //console.log(data);
  11939. });
  11940. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  11941. // // if (row.entity.age > 45) {
  11942. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11943. // // }
  11944. // };
  11945. gridApi.core.on.filterChanged($scope, function () {
  11946. var grid = this.grid;
  11947. var filtersData = {
  11948. idx: 0,
  11949. sum: 10,
  11950. "user": {
  11951. "roledata": {
  11952. "rolecode": "roleset"
  11953. },
  11954. "selectType": "1"
  11955. }
  11956. };
  11957. angular.forEach(grid.columns, function (item) {
  11958. if (item.enableFiltering) {
  11959. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  11960. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11961. if (angular.isUndefined(filtersData['user'])) {
  11962. filtersData['user'] = {};
  11963. }
  11964. filtersData['user'][item.field] = item.filters[0].term;
  11965. }
  11966. }
  11967. });
  11968. $scope.memoryfilterData = filtersData;
  11969. $scope.loadData(filtersData);
  11970. });
  11971. };
  11972. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  11973. // if (row.entity.age > 45) {
  11974. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11975. // }
  11976. // },
  11977. $scope.onDblClick = function (data, event) {
  11978. // $scope.selected.items = data.entity;
  11979. $scope.selectButtonClick(data, event);
  11980. };
  11981. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  11982. // $scope.selected.items = data.entity;
  11983. // })
  11984. // };
  11985. $scope.memoryfilterData = {
  11986. "idx": 0,
  11987. "sum": 10,
  11988. "user": {
  11989. "roledata": {
  11990. "rolecode": "roleset"
  11991. },
  11992. "selectType": "1"
  11993. }
  11994. }
  11995. $scope.loadData = function (filterData) {
  11996. // console.log("filtersData=111" + JSON.stringify(filterData))
  11997. items.fetchItems(filterData, APIService).then(function (data) {
  11998. var myData = Restangular.stripRestangular(data);
  11999. $scope.gridOptions.totalItems = myData.totalNum;
  12000. $scope.myData = myData.list;
  12001. });
  12002. };
  12003. // $scope.title = title;
  12004. $scope.loadData({
  12005. idx: 0,
  12006. sum: 10,
  12007. "user": {
  12008. "roledata": {
  12009. "rolecode": "roleset"
  12010. },
  12011. "selectType": "1"
  12012. }
  12013. });
  12014. $scope.selected = {
  12015. items: {}
  12016. };
  12017. $scope.ok = function () {
  12018. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12019. // onDataCallback($scope.selected.item, parentScope);
  12020. // }
  12021. $modalInstance.close($scope.selected.items);
  12022. };
  12023. $scope.cancel = function () {
  12024. $modalInstance.dismiss('cancel');
  12025. };
  12026. },
  12027. size: size,
  12028. resolve: {
  12029. items: function () {
  12030. return {
  12031. fetchItems: function (filterData, APIService) {
  12032. filterData = filterData || {};
  12033. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12034. filterData = {
  12035. idx: 0,
  12036. sum: 10,
  12037. "user": {
  12038. "roledata": {
  12039. "rolecode": "roleset"
  12040. },
  12041. "selectType": "1"
  12042. }
  12043. };
  12044. }
  12045. return options.templateOptions.fetchItems(filterData, APIService);
  12046. }
  12047. };
  12048. },
  12049. title: function () {
  12050. return options.templateOptions.label;
  12051. },
  12052. Restangular: function () {
  12053. return options.templateOptions.Restangular;
  12054. },
  12055. APIService: function () {
  12056. return options.templateOptions.ApiService;
  12057. },
  12058. onDataCallback: function () {
  12059. return options.templateOptions.callback;
  12060. },
  12061. parentScope: function () {
  12062. return options.templateOptions.that;
  12063. }
  12064. }
  12065. });
  12066. modalInstance.result.then(function (selectedItem) {
  12067. // console.log(selectedItem);
  12068. options.value(selectedItem);
  12069. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12070. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12071. }
  12072. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12073. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12074. }
  12075. }, function () {
  12076. //console.log('Modal dismissed at: ' + new Date());
  12077. });
  12078. }
  12079. }
  12080. };
  12081. },
  12082. controller: ['$scope', function ($scope) {
  12083. $scope.options.templateOptions.that = $scope;
  12084. // $scope.options.model[$scope.options.key] = {}
  12085. }]
  12086. });
  12087. //用户单选控件(dd 单选input带搜索)
  12088. formlyConfigProvider.setType({
  12089. name: "ui-userselectSearch",
  12090. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  12091. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12092. defaultOptions: function (options) {
  12093. return {
  12094. templateOptions: {
  12095. openModal: function (size, options, modal) {
  12096. var modalInstance = modal.open({
  12097. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12098. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  12099. $scope.langs = i18nService.getAllLangs();
  12100. $scope.lang = 'zh-cn';
  12101. i18nService.setCurrentLang($scope.lang);
  12102. $scope.gridOptions = {};
  12103. $scope.gridOptions.data = 'myData';
  12104. $scope.gridOptions.enableColumnResizing = true;
  12105. $scope.gridOptions.enableFiltering = true;
  12106. $scope.gridOptions.enableGridMenu = false;
  12107. $scope.gridOptions.showGridFooter = true;
  12108. $scope.gridOptions.showColumnFooter = false;
  12109. $scope.gridOptions.fastWatch = true;
  12110. $scope.gridOptions.useExternalFiltering = true;
  12111. $scope.gridOptions.useExternalPagination = true;
  12112. $scope.gridOptions.paginationPageSizes = [10];
  12113. $scope.gridOptions.paginationPageSize = 10;
  12114. $scope.gridOptions.multiSelect = false;
  12115. $scope.gridOptions.rowIdentity = function (row) {
  12116. return row.id;
  12117. };
  12118. $scope.gridOptions.getRowIdentity = function (row) {
  12119. return row.id;
  12120. };
  12121. $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>";
  12122. $scope.gridOptions.columnDefs = [{
  12123. name: 'account',
  12124. displayName: '人员编号',
  12125. width: 120
  12126. },
  12127. {
  12128. name: 'name',
  12129. displayName: '姓名',
  12130. width: 100,
  12131. cellTemplate: '<div>' +
  12132. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  12133. '</div>'
  12134. },
  12135. // {
  12136. // name: 'gender.name',
  12137. // displayName: '性别',
  12138. // width: 80,
  12139. // enableFiltering: false
  12140. // },
  12141. {
  12142. name: 'phone',
  12143. displayName: '电话',
  12144. width: 230,
  12145. enableFiltering: false
  12146. },
  12147. {
  12148. name: 'email',
  12149. displayName: '邮箱',
  12150. width: 180,
  12151. enableFiltering: false
  12152. },
  12153. {
  12154. name: 'dept.dept',
  12155. displayName: '科室',
  12156. width: 130,
  12157. enableFiltering: false
  12158. },
  12159. {
  12160. name: 'taskCount',
  12161. displayName: '处理中事件数',
  12162. enableFiltering: false
  12163. }
  12164. ];
  12165. // $scope.selectButtonClick
  12166. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12167. $scope.gridApi = gridApi;
  12168. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12169. var filtersData = $scope.memoryfilterData;
  12170. filtersData.idx = newPage - 1;
  12171. filtersData.sum = pageSize;
  12172. $scope.loadData(filtersData);
  12173. //console.log(pageSize);
  12174. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12175. });
  12176. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12177. $scope.selected.items = data.entity;
  12178. //console.log(data);
  12179. });
  12180. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  12181. $scope.selected.items = data.entity;
  12182. //console.log(data);
  12183. });
  12184. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  12185. // // if (row.entity.age > 45) {
  12186. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12187. // // }
  12188. // };
  12189. gridApi.core.on.filterChanged($scope, function () {
  12190. var grid = this.grid;
  12191. var filtersData = {
  12192. idx: 0,
  12193. sum: 10,
  12194. user: {
  12195. roledata: {
  12196. rolecode: "first-line support"
  12197. },
  12198. selectType: "1"
  12199. }
  12200. };
  12201. angular.forEach(grid.columns, function (item) {
  12202. if (item.enableFiltering) {
  12203. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  12204. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12205. if (angular.isUndefined(filtersData['user'])) {
  12206. filtersData['user'] = {};
  12207. }
  12208. filtersData['user'][item.field] = item.filters[0].term;
  12209. }
  12210. }
  12211. });
  12212. $scope.memoryfilterData = filtersData;
  12213. $scope.loadData(filtersData);
  12214. });
  12215. };
  12216. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  12217. // if (row.entity.age > 45) {
  12218. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12219. // }
  12220. // },
  12221. $scope.onDblClick = function (data, event) {
  12222. // $scope.selected.items = data.entity;
  12223. $scope.selectButtonClick(data, event);
  12224. };
  12225. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  12226. // $scope.selected.items = data.entity;
  12227. // })
  12228. // };
  12229. $scope.memoryfilterData = {
  12230. idx: 0,
  12231. sum: 10,
  12232. user: {
  12233. roledata: {
  12234. rolecode: "first-line support"
  12235. },
  12236. selectType: "1"
  12237. }
  12238. }
  12239. $scope.loadData = function (filterData) {
  12240. // console.log("filtersData=111" + JSON.stringify(filterData))
  12241. items.fetchItems(filterData, APIService).then(function (data) {
  12242. var myData = Restangular.stripRestangular(data);
  12243. $scope.gridOptions.totalItems = myData.totalNum;
  12244. $scope.myData = myData.list;
  12245. });
  12246. };
  12247. $scope.title = title;
  12248. $scope.loadData({
  12249. idx: 0,
  12250. sum: 10,
  12251. user: {
  12252. roledata: {
  12253. rolecode: "first-line support"
  12254. },
  12255. selectType: "1"
  12256. }
  12257. });
  12258. $scope.selected = {
  12259. items: {}
  12260. };
  12261. $scope.ok = function () {
  12262. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12263. // onDataCallback($scope.selected.item, parentScope);
  12264. // }
  12265. $modalInstance.close($scope.selected.items);
  12266. };
  12267. $scope.cancel = function () {
  12268. $modalInstance.dismiss('cancel');
  12269. };
  12270. },
  12271. size: size,
  12272. resolve: {
  12273. items: function () {
  12274. return {
  12275. fetchItems: function (filterData, APIService) {
  12276. filterData = filterData || {};
  12277. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12278. filterData = {
  12279. idx: 0,
  12280. sum: 10,
  12281. user: {
  12282. roledata: {
  12283. rolecode: "first-line support"
  12284. },
  12285. selectType: "1"
  12286. }
  12287. };
  12288. }
  12289. return options.templateOptions.fetchItems(filterData, APIService);
  12290. }
  12291. };
  12292. },
  12293. title: function () {
  12294. return options.templateOptions.label;
  12295. },
  12296. Restangular: function () {
  12297. return options.templateOptions.Restangular;
  12298. },
  12299. APIService: function () {
  12300. return options.templateOptions.ApiService;
  12301. },
  12302. onDataCallback: function () {
  12303. return options.templateOptions.callback;
  12304. },
  12305. parentScope: function () {
  12306. return options.templateOptions.that;
  12307. }
  12308. }
  12309. });
  12310. modalInstance.result.then(function (selectedItem) {
  12311. // console.log(selectedItem);
  12312. options.value(selectedItem);
  12313. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12314. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12315. }
  12316. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12317. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12318. }
  12319. }, function () {
  12320. //console.log('Modal dismissed at: ' + new Date());
  12321. });
  12322. }
  12323. }
  12324. };
  12325. },
  12326. controller: ['$scope', function ($scope) {
  12327. $scope.options.templateOptions.that = $scope;
  12328. }]
  12329. });
  12330. //用户多选控件
  12331. formlyConfigProvider.setType({
  12332. name: "ui-multiuserselect",
  12333. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  12334. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12335. defaultOptions: function (options) {
  12336. return {
  12337. templateOptions: {
  12338. openModal: function (size, options, modal, model) {
  12339. var modalInstance = modal.open({
  12340. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12341. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  12342. $scope.langs = i18nService.getAllLangs();
  12343. $scope.lang = 'zh-cn';
  12344. i18nService.setCurrentLang($scope.lang);
  12345. $scope.gridOptions = {};
  12346. $scope.gridOptions.data = 'myData';
  12347. $scope.gridOptions.enableColumnResizing = true;
  12348. $scope.gridOptions.enableFiltering = true;
  12349. $scope.gridOptions.enableGridMenu = true;
  12350. $scope.gridOptions.showGridFooter = true;
  12351. $scope.gridOptions.showColumnFooter = true;
  12352. $scope.gridOptions.fastWatch = true;
  12353. $scope.gridOptions.useExternalFiltering = true;
  12354. $scope.gridOptions.useExternalPagination = true;
  12355. $scope.gridOptions.paginationPageSizes = [10];
  12356. $scope.gridOptions.paginationPageSize = 10;
  12357. $scope.gridOptions.multiSelect = true;
  12358. $scope.gridOptions.rowIdentity = function (row) {
  12359. return row.id;
  12360. };
  12361. $scope.gridOptions.getRowIdentity = function (row) {
  12362. return row.id;
  12363. };
  12364. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12365. $scope.gridOptions.columnDefs = [
  12366. // { name:'id', width:80, enableFiltering:false},
  12367. {
  12368. name: 'account',
  12369. displayName: '账号',
  12370. width: 140
  12371. },
  12372. {
  12373. name: 'name',
  12374. displayName: '名称',
  12375. width: 100
  12376. },
  12377. {
  12378. name: 'gender.name',
  12379. displayName: '性别',
  12380. width: 140,
  12381. enableFiltering: false
  12382. },
  12383. {
  12384. name: 'phone',
  12385. displayName: '电话',
  12386. width: 100,
  12387. enableFiltering: false
  12388. },
  12389. {
  12390. name: 'email',
  12391. displayName: '邮件',
  12392. width: 100,
  12393. enableFiltering: false
  12394. },
  12395. {
  12396. name: 'dept.dept',
  12397. displayName: '科室',
  12398. width: 100,
  12399. enableFiltering: false
  12400. },
  12401. {
  12402. name: 'group[0].groupName',
  12403. displayName: '职位',
  12404. width: 100,
  12405. enableFiltering: false
  12406. }
  12407. ];
  12408. $scope.selected = {
  12409. items: selectItems
  12410. };
  12411. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12412. $scope.gridApi = gridApi;
  12413. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12414. var filtersData = $scope.memoryfilterData;
  12415. filtersData.idx = newPage - 1;
  12416. filtersData.sum = pageSize;
  12417. $scope.loadData(filtersData);
  12418. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12419. });
  12420. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  12421. var j = 0;
  12422. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  12423. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  12424. j++;
  12425. break;
  12426. }
  12427. }
  12428. if (j == 1) {
  12429. scope.grid.appScope.selected.items.splice(i, 1);
  12430. } else {
  12431. scope.grid.appScope.selected.items.push(scope.entity)
  12432. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  12433. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  12434. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  12435. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  12436. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  12437. scope.grid.appScope.selected.items.splice(i, 1);
  12438. }
  12439. }
  12440. }
  12441. }
  12442. });
  12443. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  12444. // $scope.grid.appScope.selected.items.push($scope.entity);
  12445. // });
  12446. gridApi.core.on.filterChanged($scope, function () {
  12447. var grid = this.grid;
  12448. var filtersData = {
  12449. idx: 0,
  12450. sum: 10,
  12451. "user": {
  12452. "roledata": {
  12453. "rolecode": options.model.currentRole
  12454. },
  12455. "selectType": "1"
  12456. }
  12457. };
  12458. angular.forEach(grid.columns, function (item) {
  12459. if (item.enableFiltering) {
  12460. //console.log("filtersData="+JSON.stringify(filtersData))
  12461. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12462. if (angular.isUndefined(filtersData['user'])) {
  12463. filtersData['user'] = {};
  12464. }
  12465. filtersData['user'][item.field] = item.filters[0].term;
  12466. }
  12467. }
  12468. });
  12469. $scope.memoryfilterData = filtersData;
  12470. $scope.loadData(filtersData);
  12471. });
  12472. };
  12473. if (!options.model) {
  12474. var mouse = {
  12475. "model": {
  12476. "currentRole": ""
  12477. }
  12478. };
  12479. angular.extend(options, mouse);
  12480. }
  12481. $scope.memoryfilterData = {
  12482. "idx": 0,
  12483. "sum": 10,
  12484. "user": {
  12485. "roledata": {
  12486. "rolecode": options.model.currentRole
  12487. },
  12488. "selectType": "1"
  12489. }
  12490. }
  12491. $scope.loadData = function (filterData) {
  12492. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  12493. items.fetchItems(filterData, APIService).then(function (data) {
  12494. var myData = Restangular.stripRestangular(data);
  12495. $scope.gridOptions.totalItems = myData.totalNum;
  12496. $scope.myData = myData.list;
  12497. //console.log($scope.gridOptions.pagination.getTotalPages());
  12498. // if($scope.selected.items){
  12499. // angular.forEach($scope.selected.items,function(selectItem){
  12500. // $scope.gridApi.selection.selectRow(selectItem);
  12501. // });
  12502. // }
  12503. });
  12504. };
  12505. // $scope.title = title;
  12506. $scope.loadData({
  12507. idx: 0,
  12508. sum: 10,
  12509. "user": {
  12510. "roledata": {
  12511. "rolecode": options.model.currentRole
  12512. },
  12513. "selectType": "1"
  12514. }
  12515. });
  12516. // $timeout(function(){
  12517. // if($scope.selected.items){
  12518. // angular.forEach($scope.selected.items,function(selectItem){
  12519. // $scope.gridApi.selection.selectRow(selectItem);
  12520. // });
  12521. // }
  12522. // },2000)
  12523. $scope.ok = function () {
  12524. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  12525. $modalInstance.close($scope.selected.items);
  12526. };
  12527. $scope.cancel = function () {
  12528. $modalInstance.dismiss('cancel');
  12529. };
  12530. },
  12531. size: size,
  12532. resolve: {
  12533. items: function () {
  12534. return {
  12535. fetchItems: function (filterData, APIService) {
  12536. filterData = filterData || {};
  12537. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12538. filterData = {
  12539. idx: 0,
  12540. sum: 10,
  12541. "user": {
  12542. "roledata": {
  12543. "rolecode": options.model.incident.currentRole
  12544. },
  12545. "selectType": "1"
  12546. }
  12547. };
  12548. }
  12549. return options.templateOptions.fetchItems(filterData, APIService);
  12550. }
  12551. };
  12552. },
  12553. title: function () {
  12554. return options.templateOptions.modalTitle;
  12555. },
  12556. Restangular: function () {
  12557. return options.templateOptions.Restangular;
  12558. },
  12559. APIService: function () {
  12560. return options.templateOptions.ApiService;
  12561. },
  12562. selectItems: function () {
  12563. return model || [];
  12564. }
  12565. }
  12566. });
  12567. modalInstance.result.then(function (selectedItem) {
  12568. options.value(selectedItem);
  12569. options.formControl.$validate();
  12570. }, function () {
  12571. //console.log('Modal dismissed at: ' + new Date());
  12572. });
  12573. }
  12574. },
  12575. validators: {
  12576. required: {
  12577. expression: function (viewValue, modelValue) {
  12578. var value = modelValue || viewValue;
  12579. return value.length >= 1;
  12580. }
  12581. }
  12582. }
  12583. };
  12584. },
  12585. controller: ['$scope', function ($scope) {
  12586. $scope.model[$scope.options.key] = [];
  12587. $scope.remove = function (itemId) {
  12588. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  12589. if (entry.id == itemId) {
  12590. $scope.model[$scope.options.key].splice(index, 1);
  12591. // console.log($scope.options.formControl)
  12592. $scope.options.formControl.$validate();
  12593. } else {
  12594. }
  12595. });
  12596. }
  12597. }]
  12598. });
  12599. //用户多选控件-字符串展示
  12600. formlyConfigProvider.setType({
  12601. name: 'ui-stringuserselect',
  12602. extends: 'input',
  12603. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  12604. defaultOptions: function (options) {
  12605. return {
  12606. templateOptions: {
  12607. translate: '',
  12608. refreshDelay: 0
  12609. }
  12610. }
  12611. },
  12612. controller: ['$scope', function ($scope) {
  12613. var keydata = "";
  12614. if (angular.isArray($scope.model)) {
  12615. angular.forEach($scope.model, function (item) {
  12616. keydata = keydata + "," + item.name;
  12617. })
  12618. }
  12619. // $scope.model[$scope.options.key] = [];
  12620. }]
  12621. });
  12622. //重复事件
  12623. formlyConfigProvider.setType({
  12624. name: "ui-incidentmodelselect",
  12625. extends: 'input',
  12626. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12627. defaultOptions: function (options) {
  12628. return {
  12629. templateOptions: {
  12630. openModal: function (size, options, modal) {
  12631. var modalInstance = modal.open({
  12632. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12633. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  12634. $scope.langs = i18nService.getAllLangs();
  12635. $scope.lang = 'zh-cn';
  12636. i18nService.setCurrentLang($scope.lang);
  12637. $scope.gridOptions = {};
  12638. $scope.gridOptions.data = 'myData';
  12639. $scope.gridOptions.enableColumnResizing = true;
  12640. $scope.gridOptions.enableFiltering = true;
  12641. $scope.gridOptions.enableGridMenu = false;
  12642. $scope.gridOptions.enableRowSelection = true;
  12643. $scope.gridOptions.showGridFooter = true;
  12644. $scope.gridOptions.showColumnFooter = false;
  12645. $scope.gridOptions.fastWatch = true;
  12646. $scope.gridOptions.useExternalFiltering = true;
  12647. $scope.gridOptions.useExternalPagination = true;
  12648. $scope.gridOptions.paginationPageSizes = [10];
  12649. $scope.gridOptions.paginationPageSize = 10;
  12650. $scope.gridOptions.multiSelect = false;
  12651. var mun = $scope.gridOptions.paginationPageSize;
  12652. $scope.gridOptions.rowIdentity = function (row) {
  12653. return row.id;
  12654. };
  12655. $scope.gridOptions.getRowIdentity = function (row) {
  12656. return row.id;
  12657. };
  12658. $scope.gridOptions.columnDefs = items.columnDefs();
  12659. $scope.transferTime = function (time) {
  12660. return moment(time).format('YYYY-MM-DD HH:mm');
  12661. }
  12662. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12663. $scope.gridApi = gridApi;
  12664. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12665. // console.log(newPage);
  12666. // console.log(pageSize);
  12667. $scope.loadData({
  12668. "idx": newPage - 1,
  12669. "sum": pageSize
  12670. });
  12671. });
  12672. gridApi.core.on.filterChanged($scope, function () {
  12673. var grid = this.grid;
  12674. var filtersData = {
  12675. idx: 0,
  12676. sum: 100
  12677. };
  12678. angular.forEach(grid.columns, function (item) {
  12679. if (item.enableFiltering) {
  12680. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12681. // console.log("filtersData="+JSON.stringify(filtersData))
  12682. if (angular.isUndefined(filtersData['incident'])) {
  12683. filtersData['incident'] = {};
  12684. }
  12685. filtersData['incident'][item.field] = item.filters[0].term;
  12686. if (angular.isUndefined(filtersData['problem'])) {
  12687. filtersData['problem'] = {};
  12688. }
  12689. filtersData['problem'][item.field] = item.filters[0].term;
  12690. if (angular.isUndefined(filtersData['change'])) {
  12691. filtersData['change'] = {};
  12692. }
  12693. filtersData['change'][item.field] = item.filters[0].term;
  12694. if (angular.isUndefined(filtersData['release'])) {
  12695. filtersData['release'] = {};
  12696. }
  12697. filtersData['release'][item.field] = item.filters[0].term;
  12698. }
  12699. }
  12700. });
  12701. $scope.loadData(filtersData);
  12702. });
  12703. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12704. $scope.selected.item = data.entity;
  12705. //console.log(data);
  12706. });
  12707. };
  12708. //资产
  12709. $scope.cmdb = {}
  12710. //资产状态
  12711. $scope.state_data = [{
  12712. "name": "全部状态",
  12713. "value": ""
  12714. },
  12715. {
  12716. "name": "在库",
  12717. "value": "1"
  12718. },
  12719. {
  12720. "name": "在线",
  12721. "value": "2"
  12722. },
  12723. {
  12724. "name": "借出",
  12725. "value": "3"
  12726. },
  12727. {
  12728. "name": "报修",
  12729. "value": "4"
  12730. },
  12731. {
  12732. "name": "报废",
  12733. "value": "5"
  12734. },
  12735. {
  12736. "name": "备用",
  12737. "value": "6"
  12738. },
  12739. ]
  12740. //资产类型
  12741. $scope.wt_zcfl = function () {
  12742. api_configure_data.fetchDataList('ciclassify', {
  12743. idx: 0,
  12744. sum: 100
  12745. }).then(function (data) {
  12746. console.log(data);
  12747. // $scope.wt_zclx = data.list;
  12748. console.log(data);
  12749. $scope.wtData = []
  12750. if (data.status == 200) {
  12751. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12752. var root = null; //Initially set our loop to null
  12753. var parentNode = null;
  12754. //loop over data
  12755. // $scope.wtData=data.list;
  12756. data = data.list;
  12757. //知识库分类数据三级处理
  12758. for (var i = 0; i < data.length; i++) {
  12759. // console.log(data[i])
  12760. var datum = data[i];
  12761. //each node will have children, so let's give it a "children" poperty
  12762. // console.log(datum);
  12763. datum.children = [];
  12764. if (!datum.parent) {
  12765. $scope.wtData.push(datum);
  12766. // console.log($scope.wtData)
  12767. } else {
  12768. if ($scope.wtData[0]) {
  12769. if ($scope.wtData[0].id == datum.parent.id) {
  12770. $scope.wtData[0].children.push(datum);
  12771. }
  12772. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  12773. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  12774. $scope.wtData[0].children[j].children.push(datum);
  12775. }
  12776. };
  12777. }
  12778. if ($scope.wtData[1]) {
  12779. if ($scope.wtData[1].id == datum.parent.id) {
  12780. $scope.wtData[1].children.push(datum);
  12781. }
  12782. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  12783. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  12784. $scope.wtData[1].children[j].children.push(datum);
  12785. }
  12786. };
  12787. }
  12788. if ($scope.wtData[2]) {
  12789. if ($scope.wtData[2].id == datum.parent.id) {
  12790. $scope.wtData[2].children.push(datum);
  12791. }
  12792. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  12793. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  12794. $scope.wtData[2].children[j].children.push(datum);
  12795. }
  12796. };
  12797. }
  12798. }
  12799. // console.log($scope.wtData)
  12800. idToNodeMap[datum.id] = datum;
  12801. root = datum;
  12802. // treeMap[datum.id] = root;
  12803. }
  12804. }
  12805. });
  12806. }
  12807. $scope.wt_zcfl();
  12808. //事件
  12809. //受理人,处理人
  12810. $scope.searchkeys = {};
  12811. var fieldata = {
  12812. "idx": 0,
  12813. "sum": 100,
  12814. "flag": -1
  12815. };
  12816. getUser(fieldata, 3);
  12817. function getUser(fieldatas, it) {
  12818. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  12819. if (it == 1) {
  12820. $scope.acceptUser = data.list;
  12821. } else if (it == 2) {
  12822. $scope.handlingPersonnelUser = data.list;
  12823. } else if (it == 3) {
  12824. $scope.acceptUser = data.list;
  12825. $scope.handlingPersonnelUser = data.list;
  12826. }
  12827. });
  12828. }
  12829. //状态
  12830. $scope.othcode = {};
  12831. api_bpm_data.fetchDataList('incidentstatus', {
  12832. "idx": 0,
  12833. "sum": 100
  12834. }).then(function (response) {
  12835. if (response) {
  12836. if (response.status = 200) {
  12837. $scope.state = response.list;
  12838. }
  12839. }
  12840. })
  12841. var defaultFilterData = {
  12842. "assignee": $rootScope.user.id,
  12843. "searchType": "todo",
  12844. "idx": 0,
  12845. "sum": mun
  12846. };
  12847. var defaultFilterData1 = {
  12848. // "searchType": "todo",
  12849. "idx": 0,
  12850. "sum": mun
  12851. };
  12852. //搜索
  12853. $scope.chiceIncident = function (parameters, item, stateid) {
  12854. console.log(item, stateid);
  12855. console.log($scope);
  12856. if ($scope.title == '关联资产编号') {
  12857. // alert('222222222222');
  12858. var fildata = defaultFilterData1;
  12859. $scope.gridOptions.paginationCurrentPage = 1;
  12860. var transitiondata = angular.copy(item);
  12861. angular.extend(fildata, transitiondata);
  12862. if (fildata.hw_state) {
  12863. fildata.hw_state = fildata.hw_state.name;
  12864. }
  12865. if (fildata.sign) {
  12866. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  12867. fildata.sign = fildata.sign.split(';');
  12868. fildata.sign = fildata.sign.join('');
  12869. fildata.sign = fildata.sign.toLowerCase()
  12870. }
  12871. if (fildata.keys) {
  12872. fildata['searchCriteria'] = 'uuid';
  12873. }
  12874. console.log(fildata);
  12875. $scope.loadData(fildata);
  12876. }
  12877. if ($scope.title == '关联事件工单') {
  12878. // alert('3333333333333333')
  12879. if (stateid && stateid.code) {
  12880. item.statusId = stateid.code;
  12881. }
  12882. var fildata = defaultFilterData;
  12883. // $scope.memoryfilterData = fildata;
  12884. if (!fildata.incident) {
  12885. fildata['incident'] = {};
  12886. }
  12887. $scope.gridOptions.paginationCurrentPage = 1;
  12888. var transitiondata = angular.copy(item);
  12889. angular.extend(fildata.incident, transitiondata);
  12890. console.log(fildata)
  12891. // $scope.loadData(fildata);
  12892. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  12893. console.log(data)
  12894. if (data) {
  12895. $scope.myData = data.list;
  12896. $scope.gridOptions.totalItems = data.totalNum;
  12897. }
  12898. })
  12899. }
  12900. }
  12901. //重置
  12902. $scope.replacement = function (parameters, searchkeys, othcode) {
  12903. // console.log(parameters, searchkeys, othcode);
  12904. delete (defaultFilterData.incident);
  12905. console.log(defaultFilterData)
  12906. $scope.parameters = null;
  12907. $scope.searchkeys = {};
  12908. $scope.othcode = {};
  12909. $scope.wt_zcfl();
  12910. }
  12911. $scope.loadData = function (filterData) {
  12912. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  12913. var myData = Restangular.stripRestangular(data);
  12914. if (myData.data && myData.data.node) {
  12915. $scope.gridOptions.totalItems = myData.total;
  12916. $scope.myData = myData.data.node;
  12917. } else {
  12918. if (myData.resultCount) {
  12919. $scope.gridOptions['totalItems'] = myData.resultCount;
  12920. } else {
  12921. $scope.gridOptions.totalItems = myData.totalNum;
  12922. }
  12923. if (myData.list) {
  12924. $scope.myData = myData.list;
  12925. } else {
  12926. $scope.myData = myData.data;
  12927. }
  12928. }
  12929. });
  12930. };
  12931. $scope.title = title;
  12932. $scope.loadData({
  12933. idx: 0,
  12934. sum: 10
  12935. });
  12936. $scope.selected = {
  12937. item: {}
  12938. };
  12939. $scope.ok = function () {
  12940. //console.log($scope.selected.item);
  12941. $modalInstance.close($scope.selected.item);
  12942. };
  12943. $scope.cancel = function () {
  12944. $modalInstance.dismiss('cancel');
  12945. };
  12946. },
  12947. size: size,
  12948. resolve: {
  12949. items: function () {
  12950. return {
  12951. fetchItems: function (filterData, APIService, $rootScope) {
  12952. filterData = filterData || {};
  12953. // if(!filterData.idx){
  12954. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12955. filterData = {
  12956. idx: 0,
  12957. sum: 10
  12958. };
  12959. }
  12960. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  12961. },
  12962. columnDefs: function () {
  12963. return options.templateOptions.columnDefs;
  12964. }
  12965. };
  12966. },
  12967. title: function () {
  12968. return options.templateOptions.modalTitle;
  12969. },
  12970. Restangular: function () {
  12971. return options.templateOptions.Restangular;
  12972. },
  12973. APIService: function () {
  12974. return options.templateOptions.ApiService;
  12975. }
  12976. }
  12977. });
  12978. modalInstance.result.then(function (selectedItem) {
  12979. var selectitem = {
  12980. title: selectedItem.title,
  12981. description: selectedItem.description
  12982. }
  12983. if (options.key == "chuku") {
  12984. if (selectedItem.assets) {
  12985. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  12986. }
  12987. if (selectedItem.consumables) {
  12988. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  12989. }
  12990. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  12991. options.value(selectedItem);
  12992. // options.model.consumables = JSON.parse(consumables);
  12993. } else if (options.templateOptions.pkey == "change") {
  12994. console.log(options)
  12995. angular.extend(options.model);
  12996. options.value(selectedItem);
  12997. } else if (options.key == "cmdbCode") {
  12998. var zc_selectitem = selectedItem.uuid;
  12999. // angular.extend(options.model,zc_selectitem);
  13000. options.model.cmdbCode = zc_selectitem;
  13001. // angular.extend(options.model,zc_selectitem);
  13002. // options.templateOptions.displayName=zc_selectitem;
  13003. options.value(selectedItem);
  13004. console.log(options.model)
  13005. } else {
  13006. angular.extend(options.model, selectitem);
  13007. options.value(selectedItem);
  13008. }
  13009. }, function () {
  13010. //console.log('Modal dismissed at: ' + new Date());
  13011. });
  13012. }
  13013. }
  13014. };
  13015. }
  13016. });
  13017. //选项选择控件
  13018. formlyConfigProvider.setType({
  13019. name: "ui-modelselect",
  13020. extends: 'input',
  13021. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  13022. defaultOptions: function (options) {
  13023. return {
  13024. templateOptions: {
  13025. openModal: function (size, options, modal) {
  13026. var modalInstance = modal.open({
  13027. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  13028. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  13029. $scope.langs = i18nService.getAllLangs();
  13030. $scope.lang = 'zh-cn';
  13031. i18nService.setCurrentLang($scope.lang);
  13032. $scope.gridOptions = {};
  13033. $scope.gridOptions.data = 'myData';
  13034. $scope.gridOptions.enableColumnResizing = true;
  13035. $scope.gridOptions.enableFiltering = true;
  13036. $scope.gridOptions.enableGridMenu = false;
  13037. $scope.gridOptions.enableRowSelection = true;
  13038. $scope.gridOptions.showGridFooter = true;
  13039. $scope.gridOptions.showColumnFooter = true;
  13040. $scope.gridOptions.fastWatch = true;
  13041. $scope.gridOptions.useExternalFiltering = true;
  13042. $scope.gridOptions.useExternalPagination = true;
  13043. $scope.gridOptions.paginationPageSizes = [10];
  13044. $scope.gridOptions.paginationPageSize = 10;
  13045. $scope.gridOptions.multiSelect = false;
  13046. $scope.gridOptions.rowIdentity = function (row) {
  13047. return row.id;
  13048. };
  13049. $scope.gridOptions.getRowIdentity = function (row) {
  13050. return row.id;
  13051. };
  13052. $scope.gridOptions.columnDefs = items.columnDefs();
  13053. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13054. $scope.gridApi = gridApi;
  13055. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  13056. // console.log(newPage);
  13057. // console.log(pageSize);
  13058. $scope.loadData({
  13059. "idx": newPage - 1,
  13060. "sum": pageSize
  13061. });
  13062. });
  13063. gridApi.core.on.filterChanged($scope, function () {
  13064. var grid = this.grid;
  13065. var filtersData = {
  13066. idx: 0,
  13067. sum: 10
  13068. };
  13069. angular.forEach(grid.columns, function (item) {
  13070. if (item.enableFiltering) {
  13071. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  13072. // console.log("filtersData="+JSON.stringify(filtersData))
  13073. if (angular.isUndefined(filtersData['incident'])) {
  13074. filtersData['incident'] = {};
  13075. }
  13076. filtersData['incident'][item.field] = item.filters[0].term;
  13077. if (angular.isUndefined(filtersData['problem'])) {
  13078. filtersData['problem'] = {};
  13079. }
  13080. filtersData['problem'][item.field] = item.filters[0].term;
  13081. if (angular.isUndefined(filtersData['change'])) {
  13082. filtersData['change'] = {};
  13083. }
  13084. filtersData['change'][item.field] = item.filters[0].term;
  13085. if (angular.isUndefined(filtersData['release'])) {
  13086. filtersData['release'] = {};
  13087. }
  13088. filtersData['release'][item.field] = item.filters[0].term;
  13089. }
  13090. }
  13091. });
  13092. $scope.loadData(filtersData);
  13093. });
  13094. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13095. $scope.selected.item = data.entity;
  13096. //console.log(data);
  13097. });
  13098. };
  13099. $scope.loadData = function (filterData) {
  13100. items.fetchItems(filterData, APIService).then(function (data) {
  13101. var myData = Restangular.stripRestangular(data);
  13102. $scope.gridOptions.totalItems = myData.totalNum;
  13103. $scope.myData = myData.list;
  13104. });
  13105. };
  13106. $scope.title = title;
  13107. $scope.loadData({
  13108. idx: 0,
  13109. sum: 10
  13110. });
  13111. $scope.selected = {
  13112. item: {}
  13113. };
  13114. $scope.ok = function () {
  13115. if ($scope.selected.item.scheduleOrder) {
  13116. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  13117. }
  13118. //console.log($scope.selected.item);
  13119. $modalInstance.close($scope.selected.item);
  13120. };
  13121. $scope.cancel = function () {
  13122. $modalInstance.dismiss('cancel');
  13123. };
  13124. },
  13125. size: size,
  13126. resolve: {
  13127. items: function () {
  13128. return {
  13129. fetchItems: function (filterData, APIService) {
  13130. filterData = filterData || {};
  13131. // if(!filterData.idx){
  13132. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  13133. filterData = {
  13134. idx: 0,
  13135. sum: 10
  13136. };
  13137. }
  13138. return options.templateOptions.fetchItems(filterData, APIService, options);
  13139. },
  13140. columnDefs: function () {
  13141. return options.templateOptions.columnDefs;
  13142. }
  13143. };
  13144. },
  13145. title: function () {
  13146. return options.templateOptions.modalTitle;
  13147. },
  13148. Restangular: function () {
  13149. return options.templateOptions.Restangular;
  13150. },
  13151. APIService: function () {
  13152. return options.templateOptions.ApiService;
  13153. }
  13154. }
  13155. });
  13156. modalInstance.result.then(function (selectedItem) {
  13157. options.value(selectedItem);
  13158. }, function () {
  13159. //console.log('Modal dismissed at: ' + new Date());
  13160. });
  13161. }
  13162. }
  13163. };
  13164. }
  13165. });
  13166. formlyConfigProvider.setType({
  13167. name: 'ui-requestform',
  13168. extends: 'input',
  13169. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  13170. controller: ['$scope', function ($scope) {
  13171. setTimeout(function () {
  13172. var filterData = {
  13173. "idx": 0,
  13174. "sum": 5,
  13175. "incident": {
  13176. "requester": {
  13177. "id": ""
  13178. }
  13179. }
  13180. }
  13181. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  13182. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13183. });
  13184. }, 1000);
  13185. }]
  13186. });
  13187. //报修图片展示
  13188. formlyConfigProvider.setType({
  13189. name: 'ui-repair-photos',
  13190. // extends: 'label',
  13191. templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
  13192. controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
  13193. console.log($scope);
  13194. $scope.fileUrls = [];
  13195. if ($scope.model.wxFile) {
  13196. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
  13197. $scope.fileUrls = res.data
  13198. })
  13199. }
  13200. console.log($stateParams);
  13201. if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
  13202. api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
  13203. $scope.fileUrls = res.data
  13204. })
  13205. }
  13206. if ($scope.model.flow) {
  13207. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
  13208. $scope.fileUrls = res.data
  13209. })
  13210. }
  13211. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13212. // // setTimeout(function () {
  13213. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13214. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13215. // // if (modelData.status == 200) {
  13216. // // $scope.model[$scope.options.key] = modelData.data;
  13217. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  13218. // // }
  13219. // // });
  13220. // // }, 1000);
  13221. // }
  13222. $scope.showBigImg = false;
  13223. $scope.showBigImgCli = function (data) {
  13224. $scope.showBigImg = true;
  13225. $scope.bigImgUrl = data
  13226. }
  13227. $scope.closeBigImg = function () {
  13228. $scope.showBigImg = false
  13229. }
  13230. }]
  13231. });
  13232. //图片展示
  13233. formlyConfigProvider.setType({
  13234. name: 'ui-showImgs',
  13235. templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
  13236. defaultOptions: function (options) {
  13237. return {
  13238. templateOptions: {
  13239. refresh: function (APIService, processInstanceId, data) {
  13240. return APIService.listAttachments(processInstanceId);
  13241. },
  13242. downloadUri: function (APIService, contentId) {
  13243. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13244. },
  13245. view: function (APIService, contentId) {
  13246. return APIService.attachmentsPreviewUrl(contentId);
  13247. },
  13248. download: function (APIService, contentId, item) {
  13249. var item = {
  13250. 'url': APIService.download(contentId),
  13251. 'headers': headers
  13252. };
  13253. return item;
  13254. },
  13255. refreshDelay: 0
  13256. }
  13257. };
  13258. },
  13259. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13260. var _refreshDelayPromise;
  13261. /**
  13262. * refresh
  13263. */
  13264. $scope._refresh = function (refreshAttr) {
  13265. $scope.attachments = [];
  13266. if (refreshAttr !== undefined) {
  13267. if (_refreshDelayPromise) {
  13268. $timeout.cancel(_refreshDelayPromise);
  13269. }
  13270. _refreshDelayPromise = $timeout(function () {
  13271. // 暂存附件
  13272. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13273. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13274. $scope.options.templateOptions.processInstanceId, {
  13275. 'idx': 0,
  13276. 'sum': 1000
  13277. }).then(function (response) {
  13278. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13279. if (myData) {
  13280. for (var i = 0; i < myData.data.length; i++) {
  13281. $scope.attachments.push(myData.data[i]);
  13282. }
  13283. };
  13284. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13285. $scope.$parent.$parent.$parent.model.save_fileId, {
  13286. 'idx': 0,
  13287. 'sum': 1000
  13288. }).then(function (response2) {
  13289. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13290. if (myData2) {
  13291. for (var i = 0; i < myData2.data.length; i++) {
  13292. $scope.attachments.push(myData2.data[i]);
  13293. }
  13294. };
  13295. console.log($scope.attachments)
  13296. });
  13297. });
  13298. // 正常附件
  13299. } else {
  13300. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13301. $scope.options.templateOptions.processInstanceId, {
  13302. 'idx': 0,
  13303. 'sum': 1000
  13304. }).then(function (response) {
  13305. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13306. if (myData) {
  13307. $scope.attachments = [];
  13308. $scope.imgs = []
  13309. myData.data.forEach(e => {
  13310. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13311. $scope.imgs.push(e)
  13312. }
  13313. })
  13314. $scope.imgs = $scope.imgs.splice(0, 3);
  13315. console.log($scope.imgs)
  13316. }
  13317. });
  13318. }
  13319. }, $scope.options.templateOptions.refreshDelay);
  13320. }
  13321. }
  13322. $scope._refresh({});
  13323. // $scope.attachments = $scope.model[$scope.options.key]
  13324. // 预览
  13325. $scope.preview = function (url, idx) {
  13326. var title = $scope.imgs[idx].title
  13327. $modal.open({
  13328. backdrop: false,
  13329. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13330. controller: function ($scope, scope, $modalInstance) {
  13331. $scope.title = title;
  13332. $scope.imageurl = url;
  13333. $scope.cancel = function () {
  13334. $modalInstance.dismiss('cancel');
  13335. }
  13336. },
  13337. resolve: {
  13338. scope: function () {
  13339. return $scope;
  13340. }
  13341. }
  13342. });
  13343. }
  13344. }]
  13345. });
  13346. //工单/受理人控件
  13347. formlyConfigProvider.setType({
  13348. name: 'ui-workernumbersign',
  13349. // extends: 'label',
  13350. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  13351. controller: ['$scope', function ($scope) {
  13352. // 2020年4月24日13:20:40
  13353. console.log($scope,'docu');
  13354. // 左侧事件工单区域地点填充
  13355. $scope.model.selecthouseNumber = $scope.model.place;
  13356. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13357. setTimeout(function () {
  13358. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13359. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13360. if (modelData.status == 200) {
  13361. $scope.model[$scope.options.key] = modelData.data;
  13362. $scope.options.initialValue = $scope.model[$scope.options.key];
  13363. }
  13364. });
  13365. }, 1000);
  13366. }
  13367. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  13368. if (angular.isFunction($scope.options.templateOptions.transform)) {
  13369. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  13370. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  13371. // }
  13372. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13373. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13374. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  13375. }
  13376. $scope.model.acceptUser = $scope.options.templateOptions.user;
  13377. // $scope.options.initialValue = $scope.model.acceptUser;
  13378. }
  13379. }]
  13380. });
  13381. //工单控件-only number
  13382. formlyConfigProvider.setType({
  13383. name: 'ui-workernumber',
  13384. extends: 'input',
  13385. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13386. controller: ['$scope', function ($scope) {
  13387. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13388. setTimeout(function () {
  13389. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13390. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13391. if (modelData.status == 200) {
  13392. $scope.model[$scope.options.key] = modelData.data;
  13393. $scope.options.initialValue = $scope.model[$scope.options.key];
  13394. }
  13395. });
  13396. }, 1000);
  13397. }
  13398. }]
  13399. });
  13400. //cmdb工单
  13401. formlyConfigProvider.setType({
  13402. name: 'ui-cmdbworkernumber',
  13403. extends: 'input',
  13404. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13405. controller: ['$scope', function ($scope) {
  13406. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13407. setTimeout(function () {
  13408. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  13409. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13410. // if(modelData.status==200){
  13411. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  13412. $scope.options.initialValue = $scope.model[$scope.options.key];
  13413. // }
  13414. });
  13415. }, 1000);
  13416. }
  13417. }]
  13418. });
  13419. //简易上传图片组件
  13420. formlyConfigProvider.setType({
  13421. name: 'ui-uploadImgs',
  13422. templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
  13423. wrapper: ['bootstrapHasError'],
  13424. controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
  13425. $scope.imgshows = [];
  13426. $scope.uploadimgs = [];
  13427. var model = $parse('upload_img');
  13428. var modelSetter = model.assign;
  13429. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13430. uploader.filters.push({
  13431. name: 'customFilter',
  13432. fn: function (item /*{File|FileLikeObject}*/, options) {
  13433. return this.queue.length < 10;
  13434. }
  13435. });
  13436. // 添加
  13437. $scope.change = function (event) {
  13438. var element = $('.upinp')
  13439. modelSetter($scope, element[0].files[0]);
  13440. //附件预览
  13441. $scope.imgupload = event.files[0];
  13442. getFile($scope.imgupload, $scope);
  13443. //获得预览图地址并且把file对象放入上传合集内
  13444. function getFile(imgupload, $scope) {
  13445. if (!imgupload) {
  13446. return;
  13447. }
  13448. fileReader.readAsDataUrl(imgupload, $scope)
  13449. .then(function (result) {
  13450. $scope.imgshows.push(result)
  13451. var file = document.querySelector('input[type=file]').files[0];
  13452. $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
  13453. console.log($scope.imgshows, $scope.uploadimgs)
  13454. if ($scope.imgshows.length < 3) {
  13455. $('#upup').show()
  13456. } else {
  13457. $('#upup').hide()
  13458. }
  13459. });
  13460. };
  13461. }
  13462. // 删除
  13463. $scope.uploadimg_del = function (index, imgs) {
  13464. console.log(index, imgs)
  13465. $scope.imgshows.splice(index, 1);
  13466. $scope.uploadimgs.splice(index, 1);
  13467. if ($scope.imgshows.length < 3) {
  13468. $('#upup').show()
  13469. } else {
  13470. $('#upup').hide()
  13471. }
  13472. }
  13473. // 预览
  13474. $scope.preview = function (url, idx) {
  13475. var name = $scope.uploadimgs[idx].name
  13476. $modal.open({
  13477. backdrop: false,
  13478. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13479. controller: function ($scope, scope, $modalInstance) {
  13480. $scope.title = name;
  13481. $scope.imageurl = url;
  13482. $scope.cancel = function () {
  13483. $modalInstance.dismiss('cancel');
  13484. }
  13485. },
  13486. resolve: {
  13487. scope: function () {
  13488. return $scope;
  13489. }
  13490. }
  13491. });
  13492. }
  13493. if (uploader) {
  13494. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13495. console.info('onWhenAddingFileFailed', item, filter, options);
  13496. };
  13497. uploader.onAfterAddingFile = function (fileItem) {
  13498. console.info('onAfterAddingFile', fileItem);
  13499. };
  13500. uploader.onAfterAddingAll = function (addedFileItems) {
  13501. console.info('onAfterAddingAll', addedFileItems);
  13502. };
  13503. uploader.onBeforeUploadItem = function (item) {
  13504. console.info('onBeforeUploadItem', item);
  13505. };
  13506. uploader.onProgressItem = function (fileItem, progress) {
  13507. console.info('onProgressItem', fileItem, progress);
  13508. };
  13509. uploader.onProgressAll = function (progress) {
  13510. console.info('onProgressAll', progress);
  13511. };
  13512. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13513. console.info('onSuccessItem', fileItem, response, status, headers);
  13514. };
  13515. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13516. console.info('onErrorItem', fileItem, response, status, headers);
  13517. };
  13518. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13519. console.info('onCancelItem', fileItem, response, status, headers);
  13520. };
  13521. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13522. console.info('onCompleteItem', fileItem, response, status, headers);
  13523. };
  13524. uploader.onCompleteAll = function () {
  13525. console.info('onCompleteAll');
  13526. };
  13527. }
  13528. // console.log(modelSetter)
  13529. }]
  13530. });
  13531. //jry-上传下载一体
  13532. formlyConfigProvider.setType({
  13533. name: 'ui-upDropFile',
  13534. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  13535. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13536. defaultOptions: function (options) {
  13537. return {
  13538. templateOptions: {
  13539. view: function (APIService, contentId) {
  13540. return APIService.downloadAttachment(contentId);
  13541. },
  13542. // ApiService: 'api_wechatfile',
  13543. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  13544. // upUrl: 'common/common/uploadAttachment',
  13545. // listAttachmentUrl: 'common/common/listAttachment',
  13546. // downUrl: 'common/common/downloadAttachment',
  13547. // bindType: 'incident',
  13548. // bindId: 2323
  13549. },
  13550. // validators: {
  13551. // required: {
  13552. // expression: function(viewValue, modelValue) {
  13553. // var value = modelValue || viewValue;
  13554. // return value.length >= 1;
  13555. // }
  13556. // }
  13557. // }
  13558. };
  13559. },
  13560. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  13561. console.log($scope);
  13562. $scope.showFileUp = true;
  13563. if ($scope.model.isKnowledge_detail) {
  13564. $scope.showFileUp = false;
  13565. }
  13566. if (angular.isUndefined($scope.form.dropState)) {
  13567. $scope.form.dropState = false;
  13568. }
  13569. if ($scope.model.incident) {
  13570. if ($scope.model.incident.alarm) {
  13571. console.log($scope)
  13572. if ($scope.model.incident.alarm) {
  13573. if ($scope.model.incident.alarm.alarmExtension) {
  13574. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  13575. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  13576. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  13577. console.log($scope.model.incident.description)
  13578. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  13579. } else {
  13580. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  13581. }
  13582. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  13583. console.log($scope.model.incident.description)
  13584. };
  13585. }
  13586. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  13587. console.log(wt_data);
  13588. if (wt_data) {
  13589. $rootScope.wt_category = wt_data.data;
  13590. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  13591. $rootScope.wt_child = wt_data.child
  13592. }
  13593. })
  13594. if ($scope.model.titleName == '接单') {
  13595. $scope.model.receive_code = 'handler'
  13596. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  13597. $scope.model.isHandlerUser = true;
  13598. }
  13599. }
  13600. if ($scope.model.titleName == '事件处理') {
  13601. console.log($scope.model.cmdbCode)
  13602. if ($scope.model.cmdbCode) {
  13603. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  13604. }
  13605. }
  13606. } else {
  13607. $rootScope.wt_category = '';
  13608. }
  13609. //附件上传数据
  13610. if ($scope.options.templateOptions.fileUploader) {
  13611. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13612. //$scope.options.templateOptions.uploader();
  13613. console.log(uploader)
  13614. // FILTERS
  13615. uploader.filters.push({
  13616. name: 'customFilter',
  13617. fn: function (item /*{File|FileLikeObject}*/, options) {
  13618. return this.queue.length < 10;
  13619. }
  13620. });
  13621. }
  13622. var to = $scope.options.templateOptions;
  13623. // var bindType = $scope.model.bindType;
  13624. if (to.bindType == 'incident') {
  13625. var bindId = $scope.model[to.bindType].processInstanceId;
  13626. } else if (to.bindType == 'change') {
  13627. var bindId = $scope.model[to.bindType].processInstanceId;
  13628. } else {
  13629. var bindId = $scope.model[to.bindType].id;
  13630. }
  13631. //获取附件列表
  13632. $scope.listAttachmen = function () {
  13633. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  13634. var myData = Restangular.stripRestangular(result);
  13635. // $scope.listAttachmens = myData;
  13636. $scope.attachments = myData.data;
  13637. });
  13638. };
  13639. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  13640. $scope.listAttachmen();
  13641. } else if (to.bindType && $scope.model[to.bindType].id) {
  13642. $scope.listAttachmen();
  13643. }
  13644. //附件上传
  13645. $scope.isUpfload = to.isUpfload;
  13646. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13647. uploader.onBeforeUploadItem = function (item) {
  13648. angular.extend(item.headers, $rootScope.getSession());
  13649. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  13650. item.formData.push({
  13651. 'filename': item.file.name
  13652. });
  13653. };
  13654. uploader.uploadAll();
  13655. }
  13656. //附件下载
  13657. $scope.download = function (token, filename) {
  13658. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  13659. // window.open(downUrl);
  13660. var a = document.createElement('a');
  13661. a.href = downUrl;
  13662. a.target = '_blank';
  13663. a.download = filename;
  13664. document.body.appendChild(a);
  13665. a.click();
  13666. };
  13667. //附件预览
  13668. $scope.view = function (id, previewUrl) {
  13669. if (previewUrl) {
  13670. window.open(previewUrl);
  13671. }
  13672. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  13673. // if (response.state == 200) {
  13674. // window.open(response.previewUrl);
  13675. // }
  13676. // })
  13677. };
  13678. // CALLBACKS
  13679. if (uploader) {
  13680. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13681. console.info('onWhenAddingFileFailed', item, filter, options);
  13682. };
  13683. uploader.onAfterAddingFile = function (fileItem) {
  13684. console.info('onAfterAddingFile', fileItem);
  13685. };
  13686. uploader.onAfterAddingAll = function (addedFileItems) {
  13687. console.info('onAfterAddingAll', addedFileItems);
  13688. };
  13689. uploader.onBeforeUploadItem = function (item) {
  13690. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13691. // // $scope.uploader.options.url();
  13692. // $scope.uploader.onBeforeUploadItem = function(item) {
  13693. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13694. // console.info('onBeforeUploadItem', item);
  13695. // };
  13696. // $scope.uploader.uploadAll();
  13697. // }
  13698. console.info('onBeforeUploadItem', item);
  13699. };
  13700. uploader.onProgressItem = function (fileItem, progress) {
  13701. console.info('onProgressItem', fileItem, progress);
  13702. };
  13703. uploader.onProgressAll = function (progress) {
  13704. console.info('onProgressAll', progress);
  13705. };
  13706. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13707. console.info('onSuccessItem', fileItem, response, status, headers);
  13708. if (response.status == 200) {
  13709. $scope.listAttachmen();
  13710. }
  13711. };
  13712. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13713. console.info('onErrorItem', fileItem, response, status, headers);
  13714. };
  13715. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13716. console.info('onCancelItem', fileItem, response, status, headers);
  13717. };
  13718. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13719. console.info('onCompleteItem', fileItem, response, status, headers);
  13720. };
  13721. uploader.onCompleteAll = function () {
  13722. console.info('onCompleteAll');
  13723. };
  13724. }
  13725. }]
  13726. });
  13727. //简易上传下载附件组件
  13728. formlyConfigProvider.setType({
  13729. name: 'ui-upDownFiles',
  13730. templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
  13731. wrapper: ['bootstrapHasError'],
  13732. defaultOptions: function (options) {
  13733. return {
  13734. templateOptions: {
  13735. refresh: function (APIService, processInstanceId, data) {
  13736. return APIService.listAttachments(processInstanceId);
  13737. },
  13738. downloadUri: function (APIService, contentId) {
  13739. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13740. },
  13741. view: function (APIService, contentId) {
  13742. return APIService.attachmentsPreviewUrl(contentId);
  13743. },
  13744. download: function (APIService, contentId, item) {
  13745. var item = {
  13746. 'url': APIService.download(contentId),
  13747. 'headers': headers
  13748. };
  13749. return item;
  13750. },
  13751. refreshDelay: 0
  13752. }
  13753. };
  13754. },
  13755. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13756. if (angular.isUndefined($scope.form.dropState)) {
  13757. $scope.form.dropState = false;
  13758. }
  13759. //附件上传数据
  13760. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13761. //$scope.options.templateOptions.uploader();
  13762. // FILTERS
  13763. uploader.filters.push({
  13764. name: 'customFilter',
  13765. fn: function (item /*{File|FileLikeObject}*/, options) {
  13766. return this.queue.length < 10;
  13767. }
  13768. });
  13769. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13770. // uploader.onBeforeUploadItem = function (item) {
  13771. // angular.extend(item.headers, $rootScope.getSession());
  13772. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13773. // item.formData.push({
  13774. // 'fileName': item.file.name
  13775. // });
  13776. // console.info('onBeforeUploadItem', item);
  13777. // };
  13778. // }
  13779. // CALLBACKS
  13780. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13781. console.info('onWhenAddingFileFailed', item, filter, options);
  13782. };
  13783. uploader.onAfterAddingFile = function (fileItem) {
  13784. console.info('onAfterAddingFile', fileItem);
  13785. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13786. alert('文件过大');
  13787. fileItem.uploader.queue.pop()
  13788. console.log($scope);
  13789. }
  13790. };
  13791. uploader.onAfterAddingAll = function (addedFileItems) {
  13792. // console.info('onAfterAddingAll', addedFileItems);
  13793. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13794. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13795. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13796. // console.log(123)
  13797. };
  13798. uploader.onBeforeUploadItem = function (item) {
  13799. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13800. // // $scope.uploader.options.url();
  13801. // $scope.uploader.onBeforeUploadItem = function(item) {
  13802. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13803. // console.info('onBeforeUploadItem', item);
  13804. // };
  13805. // $scope.uploader.uploadAll();
  13806. // }
  13807. console.info('onBeforeUploadItem', item);
  13808. };
  13809. uploader.onProgressItem = function (fileItem, progress) {
  13810. console.info('onProgressItem', fileItem, progress);
  13811. };
  13812. uploader.onProgressAll = function (progress) {
  13813. console.info('onProgressAll', progress);
  13814. };
  13815. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13816. console.info('onSuccessItem', fileItem, response, status, headers);
  13817. };
  13818. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13819. console.info('onErrorItem', fileItem, response, status, headers);
  13820. };
  13821. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13822. console.info('onCancelItem', fileItem, response, status, headers);
  13823. };
  13824. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13825. console.info('onCompleteItem', fileItem, response, status, headers);
  13826. };
  13827. uploader.onCompleteAll = function () {
  13828. console.info('onCompleteAll');
  13829. };
  13830. var _refreshDelayPromise;
  13831. // 下载
  13832. $scope.download = function (contentId, filename, token) {
  13833. // console.log(contentId, filename, token)
  13834. //附件下载
  13835. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  13836. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  13837. // console.log(downUrl)
  13838. var a = document.createElement('a');
  13839. a.href = downUrl;
  13840. a.target = '_blank';
  13841. a.download = filename;
  13842. document.body.appendChild(a);
  13843. a.click();
  13844. };
  13845. $scope._refresh = function (refreshAttr) {
  13846. $scope.attachments = [];
  13847. if (refreshAttr !== undefined) {
  13848. if (_refreshDelayPromise) {
  13849. $timeout.cancel(_refreshDelayPromise);
  13850. }
  13851. _refreshDelayPromise = $timeout(function () {
  13852. // 暂存附件
  13853. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13854. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13855. $scope.options.templateOptions.processInstanceId, {
  13856. 'idx': 0,
  13857. 'sum': 1000
  13858. }).then(function (response) {
  13859. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13860. if (myData) {
  13861. for (var i = 0; i < myData.data.length; i++) {
  13862. $scope.attachments.push(myData.data[i]);
  13863. }
  13864. };
  13865. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13866. $scope.$parent.$parent.$parent.model.save_fileId, {
  13867. 'idx': 0,
  13868. 'sum': 1000
  13869. }).then(function (response2) {
  13870. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13871. if (myData2) {
  13872. for (var i = 0; i < myData2.data.length; i++) {
  13873. $scope.attachments.push(myData2.data[i]);
  13874. }
  13875. // 只展示除图片以外的附件
  13876. var a = [];
  13877. $scope.attachments.forEach(e => {
  13878. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13879. // $scope.imgs.push(e)
  13880. } else {
  13881. a.push(e)
  13882. }
  13883. })
  13884. $scope.attachments = a;
  13885. };
  13886. console.log($scope.attachments)
  13887. });
  13888. });
  13889. // 正常附件
  13890. } else {
  13891. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13892. $scope.options.templateOptions.processInstanceId, {
  13893. 'idx': 0,
  13894. 'sum': 1000
  13895. }).then(function (response) {
  13896. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13897. if (myData) {
  13898. $scope.attachments = myData.data;
  13899. // 只展示除图片以外的附件
  13900. var a = [];
  13901. $scope.attachments.forEach(e => {
  13902. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13903. // $scope.imgs.push(e)
  13904. } else {
  13905. a.push(e)
  13906. }
  13907. })
  13908. $scope.attachments = a;
  13909. }
  13910. });
  13911. }
  13912. }, $scope.options.templateOptions.refreshDelay);
  13913. }
  13914. }
  13915. $scope._refresh({});
  13916. }]
  13917. });
  13918. //简易上传附件组件
  13919. formlyConfigProvider.setType({
  13920. name: 'ui-uploadFiles',
  13921. templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
  13922. wrapper: ['bootstrapHasError'],
  13923. controller: ['$scope', function ($scope) {
  13924. if (angular.isUndefined($scope.form.dropState)) {
  13925. $scope.form.dropState = false;
  13926. }
  13927. //附件上传数据
  13928. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13929. //$scope.options.templateOptions.uploader();
  13930. // FILTERS
  13931. uploader.filters.push({
  13932. name: 'customFilter',
  13933. fn: function (item /*{File|FileLikeObject}*/, options) {
  13934. return this.queue.length < 10;
  13935. }
  13936. });
  13937. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13938. uploader.onBeforeUploadItem = function (item) {
  13939. angular.extend(item.headers, $rootScope.getSession());
  13940. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13941. item.formData.push({
  13942. 'fileName': item.file.name
  13943. });
  13944. console.info('onBeforeUploadItem', item);
  13945. };
  13946. }
  13947. // CALLBACKS
  13948. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13949. console.info('onWhenAddingFileFailed', item, filter, options);
  13950. };
  13951. uploader.onAfterAddingFile = function (fileItem) {
  13952. console.info('onAfterAddingFile', fileItem);
  13953. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13954. alert('文件过大');
  13955. fileItem.uploader.queue.pop()
  13956. console.log($scope);
  13957. }
  13958. };
  13959. uploader.onAfterAddingAll = function (addedFileItems) {
  13960. // console.info('onAfterAddingAll', addedFileItems);
  13961. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13962. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13963. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13964. // console.log(123)
  13965. };
  13966. uploader.onBeforeUploadItem = function (item) {
  13967. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13968. // // $scope.uploader.options.url();
  13969. // $scope.uploader.onBeforeUploadItem = function(item) {
  13970. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13971. // console.info('onBeforeUploadItem', item);
  13972. // };
  13973. // $scope.uploader.uploadAll();
  13974. // }
  13975. console.info('onBeforeUploadItem', item);
  13976. };
  13977. uploader.onProgressItem = function (fileItem, progress) {
  13978. console.info('onProgressItem', fileItem, progress);
  13979. };
  13980. uploader.onProgressAll = function (progress) {
  13981. console.info('onProgressAll', progress);
  13982. };
  13983. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13984. console.info('onSuccessItem', fileItem, response, status, headers);
  13985. };
  13986. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13987. console.info('onErrorItem', fileItem, response, status, headers);
  13988. };
  13989. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13990. console.info('onCancelItem', fileItem, response, status, headers);
  13991. };
  13992. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13993. console.info('onCompleteItem', fileItem, response, status, headers);
  13994. };
  13995. uploader.onCompleteAll = function () {
  13996. console.info('onCompleteAll');
  13997. };
  13998. }]
  13999. });
  14000. //无上传按钮附件上传组件
  14001. formlyConfigProvider.setType({
  14002. name: 'ui-dropfilenotup',
  14003. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14004. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14005. controller: ['$scope', function ($scope) {
  14006. if (angular.isUndefined($scope.form.dropState)) {
  14007. $scope.form.dropState = false;
  14008. }
  14009. //附件上传数据
  14010. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14011. //$scope.options.templateOptions.uploader();
  14012. // FILTERS
  14013. uploader.filters.push({
  14014. name: 'customFilter',
  14015. fn: function (item /*{File|FileLikeObject}*/, options) {
  14016. return this.queue.length < 10;
  14017. }
  14018. });
  14019. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14020. uploader.onBeforeUploadItem = function (item) {
  14021. angular.extend(item.headers, $rootScope.getSession());
  14022. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14023. item.formData.push({
  14024. 'fileName': item.file.name
  14025. });
  14026. console.info('onBeforeUploadItem', item);
  14027. };
  14028. uploader.uploadAll();
  14029. }
  14030. // CALLBACKS
  14031. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14032. console.info('onWhenAddingFileFailed', item, filter, options);
  14033. };
  14034. uploader.onAfterAddingFile = function (fileItem) {
  14035. console.info('onAfterAddingFile', fileItem);
  14036. };
  14037. uploader.onAfterAddingAll = function (addedFileItems) {
  14038. console.info('onAfterAddingAll', addedFileItems);
  14039. };
  14040. uploader.onBeforeUploadItem = function (item) {
  14041. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14042. // // $scope.uploader.options.url();
  14043. // $scope.uploader.onBeforeUploadItem = function(item) {
  14044. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14045. // console.info('onBeforeUploadItem', item);
  14046. // };
  14047. // $scope.uploader.uploadAll();
  14048. // }
  14049. console.info('onBeforeUploadItem', item);
  14050. };
  14051. uploader.onProgressItem = function (fileItem, progress) {
  14052. console.info('onProgressItem', fileItem, progress);
  14053. };
  14054. uploader.onProgressAll = function (progress) {
  14055. console.info('onProgressAll', progress);
  14056. };
  14057. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14058. console.info('onSuccessItem', fileItem, response, status, headers);
  14059. };
  14060. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14061. console.info('onErrorItem', fileItem, response, status, headers);
  14062. };
  14063. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14064. console.info('onCancelItem', fileItem, response, status, headers);
  14065. };
  14066. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14067. console.info('onCompleteItem', fileItem, response, status, headers);
  14068. };
  14069. uploader.onCompleteAll = function () {
  14070. console.info('onCompleteAll');
  14071. };
  14072. }]
  14073. });
  14074. //无按钮知识库上传
  14075. formlyConfigProvider.setType({
  14076. name: 'ui-dropfielkn',
  14077. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14078. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14079. controller: ['$scope', function ($scope) {
  14080. if (angular.isUndefined($scope.form.dropState)) {
  14081. $scope.form.dropState = false;
  14082. }
  14083. //附件上传数据
  14084. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14085. //$scope.options.templateOptions.uploader();
  14086. // FILTERS
  14087. uploader.filters.push({
  14088. name: 'customFilter',
  14089. fn: function (item /*{File|FileLikeObject}*/, options) {
  14090. return this.queue.length < 10;
  14091. }
  14092. });
  14093. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14094. uploader.onBeforeUploadItem = function (item) {
  14095. angular.extend(item.headers, $rootScope.getSession());
  14096. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  14097. item.formData.push({
  14098. 'fileName': item.file.name
  14099. });
  14100. console.info('onBeforeUploadItem', item);
  14101. };
  14102. uploader.uploadAll();
  14103. }
  14104. // CALLBACKS
  14105. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14106. console.info('onWhenAddingFileFailed', item, filter, options);
  14107. };
  14108. uploader.onAfterAddingFile = function (fileItem) {
  14109. console.info('onAfterAddingFile', fileItem);
  14110. };
  14111. uploader.onAfterAddingAll = function (addedFileItems) {
  14112. console.info('onAfterAddingAll', addedFileItems);
  14113. };
  14114. uploader.onBeforeUploadItem = function (item) {
  14115. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14116. // // $scope.uploader.options.url();
  14117. // $scope.uploader.onBeforeUploadItem = function(item) {
  14118. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14119. // console.info('onBeforeUploadItem', item);
  14120. // };
  14121. // $scope.uploader.uploadAll();
  14122. // }
  14123. console.info('onBeforeUploadItem', item);
  14124. };
  14125. uploader.onProgressItem = function (fileItem, progress) {
  14126. console.info('onProgressItem', fileItem, progress);
  14127. };
  14128. uploader.onProgressAll = function (progress) {
  14129. console.info('onProgressAll', progress);
  14130. };
  14131. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14132. console.info('onSuccessItem', fileItem, response, status, headers);
  14133. };
  14134. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14135. console.info('onErrorItem', fileItem, response, status, headers);
  14136. };
  14137. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14138. console.info('onCancelItem', fileItem, response, status, headers);
  14139. };
  14140. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14141. console.info('onCompleteItem', fileItem, response, status, headers);
  14142. };
  14143. uploader.onCompleteAll = function () {
  14144. console.info('onCompleteAll');
  14145. };
  14146. }]
  14147. });
  14148. //附件上传列表组件
  14149. formlyConfigProvider.setType({
  14150. name: 'ui-dropfile',
  14151. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14152. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14153. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14154. if (angular.isUndefined($scope.form.dropState)) {
  14155. $scope.form.dropState = false;
  14156. }
  14157. //附件上传数据
  14158. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14159. //$scope.options.templateOptions.uploader();
  14160. // FILTERS
  14161. uploader.filters.push({
  14162. name: 'customFilter',
  14163. fn: function (item /*{File|FileLikeObject}*/, options) {
  14164. return this.queue.length < 10;
  14165. }
  14166. });
  14167. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14168. uploader.onBeforeUploadItem = function (item) {
  14169. angular.extend(item.headers, $rootScope.getSession());
  14170. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  14171. // if ($scope.options.templateOptions.formket) {
  14172. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  14173. // } else {
  14174. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  14175. // }
  14176. } else {
  14177. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14178. }
  14179. item.formData.push({
  14180. 'filename': item.file.name
  14181. });
  14182. console.info('onBeforeUploadItem', item);
  14183. };
  14184. uploader.uploadAll();
  14185. }
  14186. // CALLBACKS
  14187. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14188. console.info('onWhenAddingFileFailed', item, filter, options);
  14189. };
  14190. uploader.onAfterAddingFile = function (fileItem) {
  14191. console.info('onAfterAddingFile', fileItem);
  14192. };
  14193. uploader.onAfterAddingAll = function (addedFileItems) {
  14194. console.info('onAfterAddingAll', addedFileItems);
  14195. };
  14196. uploader.onBeforeUploadItem = function (item) {
  14197. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14198. // // $scope.uploader.options.url();
  14199. // $scope.uploader.onBeforeUploadItem = function(item) {
  14200. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14201. // console.info('onBeforeUploadItem', item);
  14202. // };
  14203. // $scope.uploader.uploadAll();
  14204. // }
  14205. console.info('onBeforeUploadItem', item);
  14206. };
  14207. uploader.onProgressItem = function (fileItem, progress) {
  14208. console.info('onProgressItem', fileItem, progress);
  14209. };
  14210. uploader.onProgressAll = function (progress) {
  14211. console.info('onProgressAll', progress);
  14212. };
  14213. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14214. console.info('onSuccessItem', fileItem, response, status, headers);
  14215. };
  14216. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14217. console.info('onErrorItem', fileItem, response, status, headers);
  14218. };
  14219. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14220. console.info('onCancelItem', fileItem, response, status, headers);
  14221. };
  14222. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14223. console.info('onCompleteItem', fileItem, response, status, headers);
  14224. };
  14225. uploader.onCompleteAll = function () {
  14226. console.info('onCompleteAll');
  14227. };
  14228. }]
  14229. });
  14230. //简易附件展示下载列表组件
  14231. formlyConfigProvider.setType({
  14232. name: 'ui-dropFiles',
  14233. templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
  14234. defaultOptions: function (options) {
  14235. return {
  14236. templateOptions: {
  14237. refresh: function (APIService, processInstanceId, data) {
  14238. return APIService.listAttachments(processInstanceId);
  14239. },
  14240. downloadUri: function (APIService, contentId) {
  14241. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14242. },
  14243. view: function (APIService, contentId) {
  14244. return APIService.attachmentsPreviewUrl(contentId);
  14245. },
  14246. download: function (APIService, contentId, item) {
  14247. var item = {
  14248. 'url': APIService.download(contentId),
  14249. 'headers': headers
  14250. };
  14251. return item;
  14252. },
  14253. refreshDelay: 0
  14254. }
  14255. };
  14256. },
  14257. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  14258. var _refreshDelayPromise;
  14259. // $scope.downloadUrl = function(contentId){
  14260. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14261. // };
  14262. $scope.download = function (contentId, filename, token) {
  14263. // console.log(contentId, filename, token)
  14264. //附件下载
  14265. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  14266. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  14267. // console.log(downUrl)
  14268. var a = document.createElement('a');
  14269. a.href = downUrl;
  14270. a.target = '_blank';
  14271. a.download = filename;
  14272. document.body.appendChild(a);
  14273. a.click();
  14274. };
  14275. $scope.view = function (contentId, token, filename, type) {
  14276. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14277. if (response.state == 200) {
  14278. window.open(response.previewUrl);
  14279. }
  14280. })
  14281. };
  14282. /**
  14283. * refresh
  14284. */
  14285. $scope._refresh = function (refreshAttr) {
  14286. $scope.attachments = [];
  14287. if (refreshAttr !== undefined) {
  14288. if (_refreshDelayPromise) {
  14289. $timeout.cancel(_refreshDelayPromise);
  14290. }
  14291. _refreshDelayPromise = $timeout(function () {
  14292. // 暂存附件
  14293. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  14294. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14295. $scope.options.templateOptions.processInstanceId, {
  14296. 'idx': 0,
  14297. 'sum': 1000
  14298. }).then(function (response) {
  14299. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14300. if (myData) {
  14301. for (var i = 0; i < myData.data.length; i++) {
  14302. $scope.attachments.push(myData.data[i]);
  14303. }
  14304. };
  14305. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14306. $scope.$parent.$parent.$parent.model.save_fileId, {
  14307. 'idx': 0,
  14308. 'sum': 1000
  14309. }).then(function (response2) {
  14310. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  14311. if (myData2) {
  14312. for (var i = 0; i < myData2.data.length; i++) {
  14313. $scope.attachments.push(myData2.data[i]);
  14314. }
  14315. // 只展示除图片以外的附件
  14316. var a = [];
  14317. $scope.attachments.forEach(e => {
  14318. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14319. // $scope.imgs.push(e)
  14320. } else {
  14321. a.push(e)
  14322. }
  14323. })
  14324. $scope.attachments = a;
  14325. };
  14326. console.log($scope.attachments)
  14327. });
  14328. });
  14329. // 正常附件
  14330. } else {
  14331. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14332. $scope.options.templateOptions.processInstanceId, {
  14333. 'idx': 0,
  14334. 'sum': 1000
  14335. }).then(function (response) {
  14336. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14337. if (myData) {
  14338. $scope.attachments = myData.data;
  14339. // 只展示除图片以外的附件
  14340. var a = [];
  14341. $scope.attachments.forEach(e => {
  14342. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14343. // $scope.imgs.push(e)
  14344. } else {
  14345. a.push(e)
  14346. }
  14347. })
  14348. $scope.attachments = a;
  14349. console.log($scope.attachments)
  14350. }
  14351. });
  14352. }
  14353. }, $scope.options.templateOptions.refreshDelay);
  14354. }
  14355. }
  14356. $scope._refresh({});
  14357. // $scope.attachments = $scope.model[$scope.options.key]
  14358. }]
  14359. });
  14360. //知识库附件上传
  14361. formlyConfigProvider.setType({
  14362. name: 'ui-dropfielknow',
  14363. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14364. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14365. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14366. if (angular.isUndefined($scope.form.dropState)) {
  14367. $scope.form.dropState = false;
  14368. }
  14369. //附件上传数据
  14370. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14371. //$scope.options.templateOptions.uploader();
  14372. // FILTERS
  14373. uploader.filters.push({
  14374. name: 'customFilter',
  14375. fn: function (item /*{File|FileLikeObject}*/, options) {
  14376. return this.queue.length < 10;
  14377. }
  14378. });
  14379. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14380. uploader.onBeforeUploadItem = function (item) {
  14381. angular.extend(item.headers, $rootScope.getSession());
  14382. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  14383. item.formData.push({
  14384. 'fileName': item.file.name,
  14385. 'type': 'solution',
  14386. 'solutionId': $scope.model.knowledge.id
  14387. });
  14388. console.info('onBeforeUploadItem', item);
  14389. };
  14390. uploader.uploadAll();
  14391. }
  14392. // CALLBACKS
  14393. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14394. console.info('onWhenAddingFileFailed', item, filter, options);
  14395. };
  14396. uploader.onAfterAddingFile = function (fileItem) {
  14397. console.info('onAfterAddingFile', fileItem);
  14398. };
  14399. uploader.onAfterAddingAll = function (addedFileItems) {
  14400. console.info('onAfterAddingAll', addedFileItems);
  14401. };
  14402. uploader.onBeforeUploadItem = function (item) {
  14403. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14404. // // $scope.uploader.options.url();
  14405. // $scope.uploader.onBeforeUploadItem = function(item) {
  14406. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14407. // console.info('onBeforeUploadItem', item);
  14408. // };
  14409. // $scope.uploader.uploadAll();
  14410. // }
  14411. console.info('onBeforeUploadItem', item);
  14412. };
  14413. uploader.onProgressItem = function (fileItem, progress) {
  14414. console.info('onProgressItem', fileItem, progress);
  14415. };
  14416. uploader.onProgressAll = function (progress) {
  14417. console.info('onProgressAll', progress);
  14418. };
  14419. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14420. console.info('onSuccessItem', fileItem, response, status, headers);
  14421. };
  14422. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14423. console.info('onErrorItem', fileItem, response, status, headers);
  14424. };
  14425. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14426. console.info('onCancelItem', fileItem, response, status, headers);
  14427. };
  14428. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14429. console.info('onCompleteItem', fileItem, response, status, headers);
  14430. };
  14431. uploader.onCompleteAll = function () {
  14432. console.info('onCompleteAll');
  14433. };
  14434. }]
  14435. });
  14436. //知识库附件下载列表
  14437. formlyConfigProvider.setType({
  14438. name: 'ui-dropfileknowledge',
  14439. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  14440. defaultOptions: function (options) {
  14441. return {
  14442. templateOptions: {
  14443. refresh: function (APIService, contentId, data) {
  14444. return APIService.fetchDataList(contentId, data);
  14445. },
  14446. downloadUri: function (APIService, contentId) {
  14447. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14448. },
  14449. download: function (APIService, contentId) {
  14450. return APIService.getSolutionDowpath(contentId);
  14451. },
  14452. view: function (attachmentId) {
  14453. // return APIService.attachmentsPreviewUrl(contentId);
  14454. },
  14455. refreshDelay: 0
  14456. }
  14457. };
  14458. },
  14459. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  14460. var _refreshDelayPromise;
  14461. $scope.attachments = [];
  14462. $scope.downloadUrl = function (contentId) {
  14463. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  14464. };
  14465. $scope.download = function (contentId, filename) {
  14466. $http({
  14467. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  14468. method: 'GET',
  14469. headers: {
  14470. //'Content-type' : 'application/xls',
  14471. 'Accept': '*/*'
  14472. },
  14473. responseType: 'arraybuffer'
  14474. }).success(function (data, status, headers, config) {
  14475. var file = new Blob([data], {
  14476. type: 'application/octet-stream'
  14477. });
  14478. //trick to download store a file having its URL
  14479. var fileURL = URL.createObjectURL(file);
  14480. var a = document.createElement('a');
  14481. a.href = fileURL;
  14482. a.target = '_blank';
  14483. a.download = filename;
  14484. document.body.appendChild(a);
  14485. a.click();
  14486. }).error(function (data, status, headers, config) {
  14487. // console.log(data);
  14488. });
  14489. }
  14490. $scope.view = function (contentId, filename, attachment) {
  14491. var index = filename.indexOf(".");
  14492. var type = filename.substring(index + 1);
  14493. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14494. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  14495. // var modalInstance = $modal.open({
  14496. // backdrop: false,
  14497. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14498. // controller: function($scope, scope, $modalInstance, filename) {
  14499. // $scope.title = filename;
  14500. // $scope.imageurl = scope.imageurl;
  14501. // $scope.cancel = function() {
  14502. // $modalInstance.dismiss('cancel');
  14503. // }
  14504. // },
  14505. // resolve: {
  14506. // scope: function() {
  14507. // return $scope;
  14508. // },
  14509. // filename: function() {
  14510. // return filename;
  14511. // }
  14512. // }
  14513. // });
  14514. // event.preventDefault();
  14515. // } else {
  14516. // for (var i = 0; i < $scope.attachments.length; i++) {
  14517. // if ($scope.attachments[i].id == attachmentId) {
  14518. window.open(attachment.previewUrl);
  14519. // }
  14520. // }
  14521. // }
  14522. };
  14523. $scope._refresh = function (refreshAttr) {
  14524. if (refreshAttr !== undefined) {
  14525. if (_refreshDelayPromise) {
  14526. $timeout.cancel(_refreshDelayPromise);
  14527. }
  14528. _refreshDelayPromise = $timeout(function () {
  14529. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14530. 'file', {
  14531. "file": {
  14532. "solutionId": $scope.model.knowledge.id
  14533. },
  14534. "idx": "0",
  14535. "sum": "1000"
  14536. }).then(function (response) {
  14537. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14538. if (myData) {
  14539. $scope.attachments = myData.list;
  14540. // $scope.view = function(attachmentId) {
  14541. // for (var i = 0; i < $scope.attachments.length; i++) {
  14542. // if ($scope.attachments[i].id == attachmentId) {
  14543. // window.open($scope.attachments[i].previewUrl);
  14544. // // var modalInstance = $modal.open({
  14545. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  14546. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  14547. // // }
  14548. // // });
  14549. // }
  14550. // }
  14551. // };
  14552. }
  14553. });
  14554. }, $scope.options.templateOptions.refreshDelay);
  14555. }
  14556. }
  14557. $scope._refresh({});
  14558. // $scope.attachments = $scope.model[$scope.options.key]
  14559. }]
  14560. });
  14561. //附件图片下载
  14562. formlyConfigProvider.setType({
  14563. name: 'ui-downimage',
  14564. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  14565. defaultOptions: function (options) {
  14566. return {
  14567. templateOptions: {
  14568. refresh: function (APIService, processInstanceId, data) {
  14569. return APIService.listAttachments(processInstanceId, data);
  14570. },
  14571. downloadUri: function (APIService, contentId) {
  14572. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14573. },
  14574. view: function (APIService, contentId) {
  14575. return APIService.attachmentsPreviewUrl(contentId);
  14576. },
  14577. download: function (APIService, contentId, item) {
  14578. var item = {
  14579. 'url': APIService.download(contentId),
  14580. 'headers': headers
  14581. };
  14582. return item;
  14583. },
  14584. refreshDelay: 0
  14585. }
  14586. };
  14587. },
  14588. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  14589. var _refreshDelayPromise;
  14590. // $scope.downloadUrl = function(contentId){
  14591. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14592. // };
  14593. $scope.download = function (contentId, filename) {
  14594. // var headers=
  14595. $http({
  14596. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14597. method: 'GET',
  14598. headers: {
  14599. //'Content-type' : 'application/xls',
  14600. 'Accept': '*/*'
  14601. },
  14602. responseType: 'arraybuffer'
  14603. }).success(function (data, status, headers, config) {
  14604. var file = new Blob([data], {
  14605. type: 'application/octet-stream'
  14606. });
  14607. //trick to download store a file having its URL
  14608. var fileURL = URL.createObjectURL(file);
  14609. var a = document.createElement('a');
  14610. a.href = fileURL;
  14611. a.target = '_blank';
  14612. a.download = filename;
  14613. document.body.appendChild(a);
  14614. a.click();
  14615. }).error(function (data, status, headers, config) {
  14616. // console.log(data);
  14617. });
  14618. };
  14619. $scope.view = function (contentId) {
  14620. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14621. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  14622. // if (response.state == 200) {
  14623. // window.open(response.previewUrl);
  14624. // }
  14625. // })
  14626. };
  14627. /**
  14628. * refresh
  14629. */
  14630. $scope._refresh = function (refreshAttr) {
  14631. if (refreshAttr !== undefined) {
  14632. if (_refreshDelayPromise) {
  14633. $timeout.cancel(_refreshDelayPromise);
  14634. }
  14635. _refreshDelayPromise = $timeout(function () {
  14636. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14637. $scope.options.templateOptions.processInstanceId, {
  14638. 'idx': 0,
  14639. 'sum': 1000
  14640. }).then(function (response) {
  14641. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14642. if (myData) {
  14643. $scope.attachments = myData.data;
  14644. }
  14645. });
  14646. }, $scope.options.templateOptions.refreshDelay);
  14647. }
  14648. }
  14649. $scope._refresh({});
  14650. // $scope.attachments = $scope.model[$scope.options.key]
  14651. }]
  14652. });
  14653. //附件下载列表组件
  14654. formlyConfigProvider.setType({
  14655. name: 'ui-dropfiletable',
  14656. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  14657. defaultOptions: function (options) {
  14658. return {
  14659. templateOptions: {
  14660. refresh: function (APIService, processInstanceId, data) {
  14661. return APIService.listAttachments(processInstanceId, data);
  14662. },
  14663. downloadUri: function (APIService, contentId) {
  14664. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14665. },
  14666. view: function (APIService, contentId) {
  14667. return APIService.attachmentsPreviewUrl(contentId);
  14668. },
  14669. download: function (APIService, contentId, item) {
  14670. var item = {
  14671. 'url': APIService.download(contentId),
  14672. 'headers': headers
  14673. };
  14674. return item;
  14675. },
  14676. refreshDelay: 0
  14677. }
  14678. };
  14679. },
  14680. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  14681. var _refreshDelayPromise;
  14682. // $scope.downloadUrl = function(contentId){
  14683. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14684. // };
  14685. $scope.download = function (contentId, filename) {
  14686. // var headers=
  14687. $http({
  14688. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14689. method: 'GET',
  14690. headers: {
  14691. //'Content-type' : 'application/xls',
  14692. 'Accept': '*/*'
  14693. },
  14694. responseType: 'arraybuffer'
  14695. }).success(function (data, status, headers, config) {
  14696. var file = new Blob([data], {
  14697. type: 'application/octet-stream'
  14698. });
  14699. //trick to download store a file having its URL
  14700. var fileURL = URL.createObjectURL(file);
  14701. var a = document.createElement('a');
  14702. a.href = fileURL;
  14703. a.target = '_blank';
  14704. a.download = filename;
  14705. document.body.appendChild(a);
  14706. a.click();
  14707. }).error(function (data, status, headers, config) {
  14708. // console.log(data);
  14709. });
  14710. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  14711. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  14712. // var file = new Blob([response], {
  14713. // type : 'application/octet-stream'
  14714. // });
  14715. // // var filename = filename;
  14716. // //var file = new Blob([response], {type: 'application/pdf'});
  14717. // var fileURL = URL.createObjectURL(file);
  14718. // var a = document.createElement('a');
  14719. // a.href = fileURL;
  14720. // a.target = '_blank';
  14721. // a.download = filename ;
  14722. // document.body.appendChild(a);
  14723. // a.click();
  14724. // })
  14725. };
  14726. $scope.view = function (contentId, token, filename, type) {
  14727. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14728. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14729. // var modalInstance = $modal.open({
  14730. // backdrop: false,
  14731. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14732. // controller: function($scope, scope, $modalInstance, filename) {
  14733. // $scope.title = filename;
  14734. // $scope.imageurl = scope.imageurl;
  14735. // $scope.cancel = function() {
  14736. // $modalInstance.dismiss('cancel');
  14737. // }
  14738. // },
  14739. // resolve: {
  14740. // scope: function() {
  14741. // return $scope;
  14742. // },
  14743. // filename: function() {
  14744. // return filename;
  14745. // }
  14746. // }
  14747. // });
  14748. // event.preventDefault();
  14749. // } else {
  14750. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14751. if (response.state == 200) {
  14752. window.open(response.previewUrl);
  14753. }
  14754. })
  14755. // }
  14756. };
  14757. /**
  14758. * refresh
  14759. */
  14760. $scope._refresh = function (refreshAttr) {
  14761. if (refreshAttr !== undefined) {
  14762. if (_refreshDelayPromise) {
  14763. $timeout.cancel(_refreshDelayPromise);
  14764. }
  14765. _refreshDelayPromise = $timeout(function () {
  14766. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14767. $scope.options.templateOptions.processInstanceId, {
  14768. 'idx': 0,
  14769. 'sum': 1000
  14770. }).then(function (response) {
  14771. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14772. if (myData) {
  14773. $scope.attachments = myData.data;
  14774. }
  14775. });
  14776. }, $scope.options.templateOptions.refreshDelay);
  14777. }
  14778. }
  14779. $scope._refresh({});
  14780. // $scope.attachments = $scope.model[$scope.options.key]
  14781. }]
  14782. });
  14783. //微信附件下载列表组件
  14784. formlyConfigProvider.setType({
  14785. name: 'ui-dropfilewechat',
  14786. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  14787. defaultOptions: function (options) {
  14788. return {
  14789. templateOptions: {
  14790. // refresh: function(APIService, processInstanceId, data) {
  14791. // return APIService.listAttachments(processInstanceId, data);
  14792. // },
  14793. // downloadUri: function(APIService, contentId) {
  14794. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  14795. // },
  14796. view: function (APIService, contentId) {
  14797. // return APIService.attachmentsPreviewUrl(contentId);
  14798. return APIService.attachmentsPreviewUrl(contentId);
  14799. },
  14800. download: function (APIService, contentId, item) {
  14801. var item = {
  14802. 'url': APIService.download(contentId),
  14803. 'headers': headers
  14804. };
  14805. return item;
  14806. },
  14807. // download: function(APIService, contentId, item) {
  14808. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  14809. // return item;
  14810. // },
  14811. refreshDelay: 0
  14812. }
  14813. };
  14814. },
  14815. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  14816. var _refreshDelayPromise;
  14817. // $scope.downloadUrl = function(contentId){
  14818. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14819. // };
  14820. $scope.attachments = {};
  14821. $scope.previewUrl = '';
  14822. $scope.download = function (token, filename) {
  14823. // var headers=
  14824. console.log($scope);
  14825. $http({
  14826. url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
  14827. method: 'GET',
  14828. headers: {
  14829. //'Content-type' : 'application/xls',
  14830. 'Accept': '*/*'
  14831. },
  14832. responseType: 'arraybuffer'
  14833. }).success(function (data, status, headers, config) {
  14834. var file = new Blob([data], {
  14835. type: 'application/octet-stream'
  14836. });
  14837. //trick to download store a file having its URL
  14838. var fileURL = URL.createObjectURL(file);
  14839. var a = document.createElement('a');
  14840. a.href = fileURL;
  14841. a.target = '_blank';
  14842. a.download = filename;
  14843. document.body.appendChild(a);
  14844. a.click();
  14845. }).error(function (data, status, headers, config) {
  14846. // console.log(data);
  14847. });
  14848. };
  14849. $scope.view = function (contentId, token, filename, type, previewUrl) {
  14850. // if (type) {
  14851. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  14852. // var modalInstance = $modal.open({
  14853. // backdrop: false,
  14854. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14855. // controller: function($scope, scope, $modalInstance, filename) {
  14856. // $scope.title = filename;
  14857. // $scope.imageurl = scope.imageurl;
  14858. // $scope.cancel = function() {
  14859. // $modalInstance.dismiss('cancel');
  14860. // }
  14861. // },
  14862. // resolve: {
  14863. // scope: function() {
  14864. // return $scope;
  14865. // },
  14866. // filename: function() {
  14867. // return filename;
  14868. // }
  14869. // }
  14870. // });
  14871. // event.preventDefault();
  14872. // } else {
  14873. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  14874. // if (response.state == 200) {
  14875. // window.open(response.previewUrl);
  14876. // }
  14877. // })
  14878. window.open(previewUrl);
  14879. // }
  14880. };
  14881. /**
  14882. * refresh
  14883. */
  14884. $scope._refresh = function (refreshAttr) {
  14885. if (refreshAttr !== undefined) {
  14886. if (_refreshDelayPromise) {
  14887. $timeout.cancel(_refreshDelayPromise);
  14888. }
  14889. _refreshDelayPromise = $timeout(function () {
  14890. // console.log(JSON.parse($stateParams.model))
  14891. var incidentChart = {};
  14892. if ($stateParams.model) {
  14893. incidentChart = JSON.parse($stateParams.model).model;
  14894. }
  14895. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14896. $scope.model).then(function (response) {
  14897. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14898. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  14899. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14900. if (myData) {
  14901. $scope.attachments = myData.data;
  14902. }
  14903. });
  14904. }, $scope.options.templateOptions.refreshDelay);
  14905. }
  14906. }
  14907. $scope._refresh({});
  14908. // $scope.attachments = $scope.model[$scope.options.key]
  14909. }]
  14910. });
  14911. formlyConfigProvider.setType({
  14912. name: 'ui-paralleltask',
  14913. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  14914. defaultOptions: function (options) {
  14915. return {
  14916. templateOptions: {
  14917. refresh: function (APIService, processInstanceId, data) {
  14918. //return APIService.listAttachments(processInstanceId, data);
  14919. },
  14920. refreshDelay: 0
  14921. }
  14922. };
  14923. },
  14924. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  14925. });
  14926. //repeatSection
  14927. //
  14928. formlyConfigProvider.setType({
  14929. name: 'ui-repeatSection',
  14930. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  14931. defaultOptions: function (options) {
  14932. return {
  14933. templateOptions: {
  14934. unique: 1,
  14935. initDisplay: false
  14936. }
  14937. };
  14938. },
  14939. controller: function ($scope) {
  14940. //$scope.options.templateOptions.unique;
  14941. $scope.formOptions = {
  14942. formState: $scope.formState
  14943. };
  14944. $scope.addNew = addNew;
  14945. $scope.copyFields = copyFields;
  14946. function copyFields(fields) {
  14947. fields = angular.copy(fields);
  14948. addRandomIds(fields);
  14949. return fields;
  14950. }
  14951. function addNew() {
  14952. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  14953. var repeatsection = $scope.model[$scope.options.key];
  14954. var lastSection = repeatsection[repeatsection.length - 1];
  14955. var newsection = {};
  14956. repeatsection.push(newsection);
  14957. }
  14958. function addRandomIds(fields) {
  14959. $scope.options.templateOptions.unique++;
  14960. angular.forEach(fields, function (field, index) {
  14961. if (field.fieldGroup) {
  14962. addRandomIds(field.fieldGroup);
  14963. return; // fieldGroups don't need an ID
  14964. }
  14965. if (field.templateOptions && field.templateOptions.fields) {
  14966. addRandomIds(field.templateOptions.fields);
  14967. }
  14968. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  14969. });
  14970. }
  14971. function getRandomInt(min, max) {
  14972. return Math.floor(Math.random() * (max - min)) + min;
  14973. }
  14974. if ($scope.options.templateOptions.initDisplay) {
  14975. addNew();
  14976. }
  14977. }
  14978. });
  14979. //时间轴任务列表组件
  14980. //cmdb控件
  14981. formlyConfigProvider.setType({
  14982. name: 'ui-cmdb',
  14983. extends: 'input',
  14984. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  14985. defaultOptions: function (options) {
  14986. return {
  14987. templateOptions: {
  14988. onClick: function (size, options, modal, event, model) {
  14989. var modalInstance = modal.open({
  14990. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  14991. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  14992. var width = $scope.width = 600;
  14993. var height = $scope.height = 400;
  14994. var tree;
  14995. var d3 = window.d3;
  14996. $scope.my_tree_handler = function (branch) {
  14997. //var _ref;
  14998. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  14999. APIService.query({
  15000. 'sign': classify
  15001. }).then(function (data) {
  15002. var myData = Restangular.stripRestangular(data);
  15003. // console.log(myData.data.node);
  15004. if (myData.data && myData.status == 200) {
  15005. var ret = myData.data;
  15006. redrawSvg(myData);
  15007. }
  15008. });
  15009. };
  15010. $scope.my_data = [];
  15011. function convertListToTree(data, treeMap) {
  15012. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  15013. var root = null; //Initially set our loop to null
  15014. var parentNode = null;
  15015. //loop over data
  15016. for (var i = 0; i < data.length; i++) {
  15017. var datum = data[i];
  15018. //each node will have children, so let's give it a "children" poperty
  15019. datum.children = [];
  15020. //add an entry for this node to the map so that any future children can
  15021. //lookup the parent
  15022. idToNodeMap[datum.id] = datum;
  15023. //Does this node have a parent?
  15024. if (typeof datum.parent === "undefined" || datum.parent == null) {
  15025. //Doesn't look like it, so this node is the root of the tree
  15026. root = datum;
  15027. treeMap[datum.id] = root;
  15028. } else {
  15029. //This node has a parent, so let's look it up using the id
  15030. parentNode = idToNodeMap[datum.parent.id];
  15031. //We don't need this property, so let's delete it.
  15032. delete datum.parent;
  15033. //Let's add the current node as a child of the parent node.
  15034. parentNode.children.push(datum);
  15035. }
  15036. }
  15037. return root;
  15038. }
  15039. function convertParentToChildList(data) {
  15040. var treeMap = {};
  15041. var list = [];
  15042. convertListToTree(data, treeMap);
  15043. angular.forEach(treeMap, function (item) {
  15044. list.push(item);
  15045. });
  15046. return list;
  15047. }
  15048. $scope.my_tree = tree = {};
  15049. $scope.try_async_load = function () {
  15050. $scope.my_data = [];
  15051. $scope.select_treedata = [];
  15052. $scope.doing_async = true;
  15053. ConfigDataService.fetchDataList('ciclassify', {
  15054. 'idx': 0,
  15055. 'sum': 100
  15056. }).then(function (result) {
  15057. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15058. $scope.doing_async = false;
  15059. });
  15060. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  15061. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15062. // $scope.doing_async = false;
  15063. // });
  15064. };
  15065. $scope.select_treedata = [];
  15066. $scope.propTypeOptions = [];
  15067. $scope.try_async_load();
  15068. $scope.onFilterCallback = function (item) {
  15069. //console.log(item);
  15070. if (angular.isDefined(item.children) && item.children.length >= 1) {
  15071. //not valid
  15072. } else {
  15073. var tempclassify = item.prefix.toLowerCase() + item.sign;
  15074. $scope.cifilter_classic = tempclassify;
  15075. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  15076. var myData = Restangular.stripRestangular(data);
  15077. $scope.propTypeOptions = myData;
  15078. });
  15079. }
  15080. }
  15081. $scope.onPropTypeChange = function (form) {
  15082. $scope.propOptions = form.fields;
  15083. }
  15084. $scope.onPropChange = function (prop) {
  15085. $scope.cifilter_prop = prop;
  15086. }
  15087. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  15088. //if(searchKey!=null&&searchKey.length>1){
  15089. var searchData = {};
  15090. if (angular.isUndefined(propObj)) {
  15091. propObj = $scope.cifilter_prop;
  15092. }
  15093. if (angular.isUndefined(ciclassify)) {
  15094. ciclassify = $scope.cifilter_classic;
  15095. }
  15096. searchData['sign'] = ciclassify;
  15097. if (angular.isDefined(propObj)) {
  15098. searchData[propObj.key] = searchKey;
  15099. }
  15100. APIService.query(searchData).then(function (response) {
  15101. var data = Restangular.stripRestangular(response);
  15102. //此处不清空nodes
  15103. var node = data.data.node;
  15104. var tempNode = [];
  15105. //nodes 或者links 要去重
  15106. for (var i = 0; i < node.length; i++) {
  15107. var tmp = 0;
  15108. for (var j = 0; j < nodes.length; j++) {
  15109. if (node[i].uuid == nodes[j].uuid) {
  15110. tmp++;
  15111. break;
  15112. }
  15113. }
  15114. if (tmp == 0) {
  15115. tempNode.push(node[i]);
  15116. }
  15117. }
  15118. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15119. nodes.push(tempNode[i]);
  15120. }
  15121. restart();
  15122. })
  15123. }
  15124. $scope.refresh = function () {
  15125. nodes.length = 0;
  15126. links.length = 0;
  15127. restart();
  15128. }
  15129. $scope.traversal = function () {
  15130. if ($scope.selected_node == null) {
  15131. SweetAlert.swal({
  15132. title: "错误的操作!",
  15133. text: "没有配置项被选中!",
  15134. type: "error"
  15135. });
  15136. } else {
  15137. var uuid = $scope.selected_node.uuid;
  15138. APIService.traversal(uuid).then(function (response) {
  15139. var d = response.data;
  15140. var node = d.node;
  15141. var link = d.edge;
  15142. var tempNode = [];
  15143. var tempLink = [];
  15144. //nodes 或者links 要去重
  15145. for (var i = 0; i < node.length; i++) {
  15146. var tmp = 0;
  15147. for (var j = 0; j < nodes.length; j++) {
  15148. if (node[i].id == nodes[j].id) {
  15149. tmp++;
  15150. break;
  15151. }
  15152. }
  15153. if (tmp == 0) {
  15154. tempNode.push(node[i]);
  15155. }
  15156. }
  15157. for (var i = 0; i < link.length; i++) {
  15158. var tmp = 0;
  15159. for (var j = 0; j < links.length; j++) {
  15160. if (link[i].id == links[j].id) {
  15161. tmp++;
  15162. break;
  15163. }
  15164. }
  15165. if (tmp == 0) {
  15166. tempLink.push(link[i]);
  15167. }
  15168. }
  15169. //数据写入页面
  15170. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15171. nodes.push(tempNode[i]);
  15172. }
  15173. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15174. links.push(tempLink[i]);
  15175. }
  15176. //links转换
  15177. for (var i = 0; i < links.length; i++) {
  15178. for (var j = 0; j < nodes.length; j++) {
  15179. if (links[i].source == nodes[j].id) {
  15180. links[i].source = nodes[j];
  15181. }
  15182. if (links[i].target == nodes[j].id) {
  15183. links[i].target = nodes[j];
  15184. }
  15185. }
  15186. }
  15187. restart();
  15188. })
  15189. }
  15190. }
  15191. var svg;
  15192. var force;
  15193. var drag_line, path, circle;
  15194. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  15195. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15196. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15197. var nodes = [],
  15198. links = [];
  15199. var treeNodes = [];
  15200. //读取labels (node)
  15201. var labels = [];
  15202. function redrawSvg(json) {
  15203. nodes.length = 0; //先清空
  15204. links.length = 0;
  15205. var data = json.data;
  15206. for (var i = 0; i < data.node.length; i++) {
  15207. nodes.push(data.node[i]);
  15208. }
  15209. restart();
  15210. }
  15211. //读取status (节点 连线)
  15212. var statuses = [];
  15213. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  15214. // if (result && result.status == 200) {
  15215. // d3.select('#nodeStatus').selectAll('option')
  15216. // .data(statuses).enter()
  15217. // .append('option')
  15218. // .attr('value', function(d) { return d.code; })
  15219. // .html(function(d) { return d.desc; });
  15220. // } else {
  15221. // SweetAlert.swal({
  15222. // title: "提示!",
  15223. // text: "服务器请求异常!",
  15224. // type: "error"
  15225. // });
  15226. // }
  15227. // });
  15228. api_wechatfile.getDictionary({
  15229. 'key': 'cmdb_status',
  15230. 'type': 'list'
  15231. }).then(function (result) {
  15232. if (result) {
  15233. d3.select('#nodeStatus').selectAll('option')
  15234. .data(statuses).enter()
  15235. .append('option')
  15236. .attr('value', function (d) {
  15237. return d.code;
  15238. })
  15239. .html(function (d) {
  15240. return d.desc;
  15241. });
  15242. } else {
  15243. SweetAlert.swal({
  15244. title: "提示!",
  15245. text: "服务器请求异常!",
  15246. type: "error"
  15247. });
  15248. }
  15249. });
  15250. //查询relationship_type表 name 为表里的type,label为显示值
  15251. var linkType = [];
  15252. function fetchEdgeTypes() {
  15253. ConfigDataService.fetchDataList('ciedgetype', {
  15254. 'idx': 0,
  15255. 'sum': 100
  15256. }).then(function (response) {
  15257. if (response) {
  15258. if (response['list']) {
  15259. linkType = response['list'];
  15260. // d3.select('#linkName').selectAll('option')
  15261. // .data(linkType).enter()
  15262. // .append('option')
  15263. // .attr('value',function(d){return d.type;})
  15264. // .html(function(d){ return d.label;});
  15265. } else {
  15266. SweetAlert.swal({
  15267. title: "提示!",
  15268. text: "服务器请求异常!",
  15269. type: "error"
  15270. });
  15271. }
  15272. } else {
  15273. SweetAlert.swal({
  15274. title: "提示!",
  15275. text: "服务器请求异常!",
  15276. type: "error"
  15277. });
  15278. }
  15279. })
  15280. }
  15281. // fetchEdgeTypes();
  15282. /*
  15283. // init D3 force layout
  15284. var force = d3.layout.force()
  15285. .nodes(nodes)
  15286. .links(links)
  15287. .size([width, height])
  15288. .gravity(.05)
  15289. .linkDistance(150)
  15290. .linkStrength(2)
  15291. .charge(-500)
  15292. .on('tick', tick);
  15293. // define arrow markers for graph links
  15294. svg.append('svg:defs').append('svg:marker')
  15295. .attr('id', 'end-arrow')
  15296. .attr('viewBox', '0 -5 10 10')
  15297. .attr('refX', 6)
  15298. .attr('markerWidth', 3)
  15299. .attr('markerHeight', 3)
  15300. .attr('orient', 'auto')
  15301. .append('svg:path')
  15302. .attr('d', 'M0,-5L10,0L0,5')
  15303. .attr('fill', '#000');
  15304. svg.append('svg:defs').append('svg:marker')
  15305. .attr('id', 'start-arrow')
  15306. .attr('viewBox', '0 -5 10 10')
  15307. .attr('refX', 4)
  15308. .attr('markerWidth', 3)
  15309. .attr('markerHeight', 3)
  15310. .attr('orient', 'auto')
  15311. .append('svg:path')
  15312. .attr('d', 'M10,-5L0,0L10,5')
  15313. .attr('fill', '#000');
  15314. // line displayed when dragging new nodes
  15315. var drag_line = svg.append('svg:path')
  15316. .attr('class', 'link dragline hidden')
  15317. .attr('d', 'M0,0L0,0');
  15318. // handles to link and node element groups
  15319. //(1)var path = svg.append('svg:g').selectAll('g')
  15320. var path = svg.append('svg:g').selectAll('g'),
  15321. circle = svg.append('svg:g').selectAll('g');
  15322. */
  15323. // mouse event vars
  15324. var selected_node = null,
  15325. selected_link = null,
  15326. mousedown_link = null,
  15327. mousedown_node = null,
  15328. mouseup_node = null;
  15329. function resetMouseVars() {
  15330. mousedown_node = null;
  15331. mouseup_node = null;
  15332. mousedown_link = null;
  15333. }
  15334. // update force layout (called automatically each iteration)
  15335. function tick() {
  15336. // draw directed edges with proper padding from node centers
  15337. path.selectAll('path').attr('d', function (d) {
  15338. var deltaX = d.target.x - d.source.x,
  15339. deltaY = d.target.y - d.source.y,
  15340. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  15341. normX = deltaX / dist,
  15342. normY = deltaY / dist,
  15343. sourcePadding = d.left ? 27 : 22,
  15344. targetPadding = d.right ? 27 : 22,
  15345. sourceX = d.source.x + (sourcePadding * normX),
  15346. sourceY = d.source.y + (sourcePadding * normY),
  15347. targetX = d.target.x - (targetPadding * normX),
  15348. targetY = d.target.y - (targetPadding * normY);
  15349. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  15350. });
  15351. circle.attr('transform', function (d) {
  15352. return 'translate(' + d.x + ',' + d.y + ')';
  15353. });
  15354. }
  15355. // update graph (called when needed)
  15356. function restart() {
  15357. //绑定link 数据
  15358. path.datum(links);
  15359. // path (link) group
  15360. path = path.data(links, function (d) {
  15361. return d.id;
  15362. });
  15363. var p = path.enter().append('svg:g');
  15364. //update existing links
  15365. path.selectAll('path').classed('selected', function (d) {
  15366. return d === selected_link;
  15367. })
  15368. .style('marker-start', function (d) {
  15369. return d.left ? 'url(#start-arrow)' : '';
  15370. })
  15371. .style('marker-end', function (d) {
  15372. return d.right ? 'url(#end-arrow)' : '';
  15373. });
  15374. // add new links
  15375. p.append('svg:path')
  15376. .attr('class', 'link')
  15377. .attr('id', function (d) {
  15378. return "path_" + d.id;
  15379. })
  15380. // .attr('startOffset', '0%')
  15381. .classed('selected', function (d) {
  15382. return d === selected_link;
  15383. })
  15384. .style('marker-start', function (d) {
  15385. return d.left ? 'url(#start-arrow)' : '';
  15386. })
  15387. .style('marker-end', function (d) {
  15388. return d.right ? 'url(#end-arrow)' : '';
  15389. })
  15390. .on('mousedown', function (d) {
  15391. if (d3.event.ctrlKey) return;
  15392. //去除没有提交的连线
  15393. for (var i = 0; i < links.length; i++) {
  15394. if (links[i].id == -1 && d.id != -1) {
  15395. links.splice(i, 1);
  15396. }
  15397. }
  15398. // select link
  15399. mousedown_link = d;
  15400. if (mousedown_link === selected_link) {
  15401. selected_link = $scope.selected_link = null;
  15402. selected_node = $scope.selected_node = null;
  15403. // d3.select("#linkDetail").attr('style','display:none');
  15404. //hideLinkForm(true);//return ;
  15405. } else {
  15406. selected_link = $scope.selected_link = mousedown_link;
  15407. selected_node = $scope.selected_node = null;
  15408. }
  15409. selected_node = $scope.selected_node = null;
  15410. restart();
  15411. });
  15412. p.append('svg:text')
  15413. .attr('x', 30)
  15414. .attr('y', 20)
  15415. .attr('class', 'fontM')
  15416. .append('textPath')
  15417. .attr('xlink:xlink:href', function (d, i) {
  15418. return "#path_" + d.id;
  15419. })
  15420. .html(function (d) {
  15421. for (var i = 0; i < linkType.length; i++) {
  15422. if (linkType[i].type == d.name) {
  15423. return linkType[i].label;
  15424. }
  15425. }
  15426. });
  15427. // remove old links
  15428. path.exit().remove();
  15429. // circle (node) group
  15430. // NB: the function arg is crucial here! nodes are known by id, not by index!
  15431. circle.datum(nodes);
  15432. circle = circle.data(nodes, function (d) {
  15433. return d.id;
  15434. });
  15435. // update existing nodes (reflexive & selected visual states)
  15436. circle.selectAll('circle')
  15437. .style('fill', function (d) {
  15438. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15439. })
  15440. .style('fill-opacity', 0.75) // add by xi
  15441. .classed('reflexive', function (d) {
  15442. return d.reflexive;
  15443. });
  15444. // add new nodes
  15445. var g = circle.enter().append('svg:g');
  15446. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  15447. //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');
  15448. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  15449. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  15450. }).style('stroke', function (d) {
  15451. return d3.rgb(colors(d.label)).darker().toString();
  15452. }).style('stroke-width', '2');
  15453. g.append('svg:circle')
  15454. .attr('class', 'node')
  15455. .attr('r', 18)
  15456. .style('fill', function (d) {
  15457. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15458. })
  15459. .style('stroke', function (d) {
  15460. return d3.rgb(colors(d.label)).darker().toString();
  15461. })
  15462. .style('fill-opacity', 0.25) //add by xj
  15463. .style('stroke-opacity', 0.5) //add by xj
  15464. .classed('reflexive', function (d) {
  15465. return d.reflexive;
  15466. });
  15467. g.on('mouseover', function (d) {
  15468. //if(!mousedown_node || d === mousedown_node) return;
  15469. // enlarge target node
  15470. //d3.select(this).attr('transform', 'scale(1.1)');
  15471. })
  15472. .on('mouseout', function (d) {
  15473. //if(!mousedown_node || d === mousedown_node) return;
  15474. // unenlarge target node
  15475. //d3.select(this).attr('transform', '');
  15476. })
  15477. .on('mousedown', function (d) {
  15478. if (d3.event.ctrlKey) return;
  15479. //hideLinkForm(true);
  15480. //去除没有提交的连线
  15481. for (var i = 0; i < links.length; i++) {
  15482. if (links[i].id == -1) {
  15483. links.splice(i, 1);
  15484. }
  15485. }
  15486. // select node
  15487. mousedown_node = d;
  15488. if (mousedown_node === selected_node) {
  15489. selected_node = $scope.selected_node = null;
  15490. } else {
  15491. selected_node = $scope.selected_node = mousedown_node;
  15492. selected_link = $scope.selected_link = null;
  15493. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  15494. APIService.findRefById(selected_node.id).then(function (result) {
  15495. var d = result.data;
  15496. var node = d.node;
  15497. var link = d.edge;
  15498. var tempNode = [];
  15499. var tempLink = [];
  15500. //nodes 或者links 要去重
  15501. for (var i = 0; i < node.length; i++) {
  15502. var tmp = 0;
  15503. for (var j = 0; j < nodes.length; j++) {
  15504. if (node[i].id == nodes[j].id) {
  15505. tmp++;
  15506. break;
  15507. }
  15508. }
  15509. if (tmp == 0) {
  15510. tempNode.push(node[i]);
  15511. }
  15512. }
  15513. for (var i = 0; i < link.length; i++) {
  15514. var tmp = 0;
  15515. for (var j = 0; j < links.length; j++) {
  15516. if (link[i].id == links[j].id) {
  15517. tmp++;
  15518. break;
  15519. }
  15520. }
  15521. if (tmp == 0) {
  15522. tempLink.push(link[i]);
  15523. }
  15524. }
  15525. //数据写入页面
  15526. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15527. nodes.push(tempNode[i]);
  15528. }
  15529. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15530. links.push(tempLink[i]);
  15531. }
  15532. //links转换
  15533. for (var i = 0; i < links.length; i++) {
  15534. for (var j = 0; j < nodes.length; j++) {
  15535. if (links[i].source == nodes[j].id) {
  15536. links[i].source = nodes[j];
  15537. }
  15538. if (links[i].target == nodes[j].id) {
  15539. links[i].target = nodes[j];
  15540. }
  15541. }
  15542. }
  15543. restart();
  15544. });
  15545. }
  15546. // reposition drag line
  15547. drag_line
  15548. .style('marker-end', 'url(#end-arrow)')
  15549. .classed('hidden', false)
  15550. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  15551. restart();
  15552. })
  15553. .on('mouseup', function (d) {
  15554. if (!mousedown_node) return;
  15555. });
  15556. // show node name
  15557. g.append('svg:text')
  15558. .attr('x', 0)
  15559. .attr('y', 34)
  15560. .attr('class', 'id')
  15561. .text(function (d) {
  15562. return d.name;
  15563. }); //TODO 改为 d.name
  15564. //设置图片
  15565. g.append('svg:foreignObject')
  15566. .attr("width", 32)
  15567. .attr("height", 32)
  15568. .attr('x', "-16px")
  15569. .attr('y', "-11px")
  15570. .html(function (d) {
  15571. for (var i = 0; i < labels.length; i++) {
  15572. if (d.label == labels[i].sign) {
  15573. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  15574. }
  15575. }
  15576. });
  15577. // remove old nodes
  15578. circle.exit().remove();
  15579. // set the graph in motion
  15580. force.start();
  15581. }
  15582. function mousedown() {
  15583. // prevent I-bar on drag
  15584. //d3.event.preventDefault();
  15585. // because :active only works in WebKit?
  15586. svg.classed('active', true);
  15587. if (mousedown_node) {
  15588. viewNode(mousedown_node);
  15589. }
  15590. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  15591. restart();
  15592. }
  15593. function mousemove() {
  15594. if (!mousedown_node) return;
  15595. // update drag line
  15596. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  15597. //restart();
  15598. }
  15599. function mouseup() {
  15600. if (mousedown_node) {
  15601. // hide drag line
  15602. drag_line
  15603. .classed('hidden', true)
  15604. .style('marker-end', '');
  15605. }
  15606. // because :active only works in WebKit?
  15607. svg.classed('active', false);
  15608. // clear mouse event vars
  15609. resetMouseVars();
  15610. }
  15611. function spliceLinksForNode(node) {
  15612. var toSplice = links.filter(function (l) {
  15613. return (l.source === node || l.target === node);
  15614. });
  15615. toSplice.map(function (l) {
  15616. links.splice(links.indexOf(l), 1);
  15617. });
  15618. }
  15619. // only respond once per keydown
  15620. var lastKeyDown = -1;
  15621. function keydown() {
  15622. //d3.event.preventDefault();
  15623. if (lastKeyDown !== -1) return;
  15624. lastKeyDown = d3.event.keyCode;
  15625. // ctrl
  15626. if (d3.event.keyCode === 17) {
  15627. circle.call(force.drag);
  15628. svg.classed('ctrl', true);
  15629. }
  15630. if (!selected_node && !selected_link) return;
  15631. switch (d3.event.keyCode) {
  15632. case 8: // backspace
  15633. case 66: // B
  15634. if (selected_link) {
  15635. // set link direction to both left and right
  15636. selected_link.left = true;
  15637. selected_link.right = true;
  15638. }
  15639. restart();
  15640. break;
  15641. case 76: // L
  15642. if (selected_link) {
  15643. // set link direction to left only
  15644. selected_link.left = true;
  15645. selected_link.right = false;
  15646. }
  15647. restart();
  15648. break;
  15649. case 82: // R
  15650. if (selected_node) {
  15651. // toggle node reflexivity
  15652. selected_node.reflexive = !selected_node.reflexive;
  15653. } else if (selected_link) {
  15654. // set link direction to right only
  15655. selected_link.left = false;
  15656. selected_link.right = true;
  15657. }
  15658. restart();
  15659. break;
  15660. }
  15661. }
  15662. function keyup() {
  15663. lastKeyDown = -1;
  15664. // ctrl
  15665. if (d3.event.keyCode === 17) {
  15666. circle
  15667. .on('mousedown.drag', null)
  15668. .on('touchstart.drag', null);
  15669. svg.classed('ctrl', false);
  15670. }
  15671. }
  15672. function viewNode(node) {
  15673. // console.log(svg.attr('left'));
  15674. //var el = angular.element('div.modal-dialog')[0];
  15675. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  15676. if (!$scope.selected_node.props.state) {
  15677. $scope.selected_node.props.state = "空"
  15678. } else if ($scope.selected_node.props.state) {
  15679. if ($scope.selected_node.props.state == "1") {
  15680. $scope.selected_node.props.state = "未审核"
  15681. } else if ($scope.selected_node.props.state == "2") {
  15682. $scope.selected_node.props.state = "已审核"
  15683. } else if ($scope.selected_node.props.state == "3") {
  15684. $scope.selected_node.props.state = "不匹配"
  15685. } else if ($scope.selected_node.props.state == "4") {
  15686. $scope.selected_node.props.state = "丢失"
  15687. }
  15688. };
  15689. if (!$scope.selected_node.name) {
  15690. $scope.selected_node.name = "空"
  15691. }
  15692. if (!$scope.selected_node.status) {
  15693. $scope.selected_node.statu = "空"
  15694. }
  15695. if (!$scope.selected_node.props.useradmin) {
  15696. $scope.selected_node.props.useradmin = "空"
  15697. }
  15698. Toaster.pop({
  15699. // type: 'info',
  15700. // title: title,
  15701. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  15702. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  15703. '<p>状态:' + $scope.selected_node.status + '</p>' +
  15704. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  15705. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  15706. bodyOutputType: 'trustedHtml',
  15707. timeout: 3000
  15708. })
  15709. }
  15710. //GT 颜色与数值对照表
  15711. function colors(sign) {
  15712. //num=num>20?num%20:parseInt(num);
  15713. for (var i = 0; i < labels.length; i++) {
  15714. var entity = labels[i];
  15715. if (sign == entity.sign) {
  15716. return entity.color;
  15717. }
  15718. if (i == labels.length - 1 && sign != entity.sign) {
  15719. return '#ffeeee';
  15720. }
  15721. }
  15722. }
  15723. $scope.init = function () {
  15724. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15725. // init D3 force layout
  15726. force = d3.layout.force()
  15727. .nodes(nodes)
  15728. .links(links)
  15729. .size([width, height])
  15730. .gravity(.05)
  15731. .linkDistance(150)
  15732. .linkStrength(2)
  15733. .charge(-500)
  15734. .on('tick', tick);
  15735. // define arrow markers for graph links
  15736. svg.append('svg:defs').append('svg:marker')
  15737. .attr('id', 'end-arrow')
  15738. .attr('viewBox', '0 -5 10 10')
  15739. .attr('refX', 6)
  15740. .attr('markerWidth', 3)
  15741. .attr('markerHeight', 3)
  15742. .attr('orient', 'auto')
  15743. .append('svg:path')
  15744. .attr('d', 'M0,-5L10,0L0,5')
  15745. .attr('fill', '#000');
  15746. svg.append('svg:defs').append('svg:marker')
  15747. .attr('id', 'start-arrow')
  15748. .attr('viewBox', '0 -5 10 10')
  15749. .attr('refX', 4)
  15750. .attr('markerWidth', 3)
  15751. .attr('markerHeight', 3)
  15752. .attr('orient', 'auto')
  15753. .append('svg:path')
  15754. .attr('d', 'M10,-5L0,0L10,5')
  15755. .attr('fill', '#000');
  15756. // line displayed when dragging new nodes
  15757. drag_line = svg.append('svg:path')
  15758. .attr('class', 'link dragline hidden')
  15759. .attr('d', 'M0,0L0,0');
  15760. // handles to link and node element groups
  15761. //(1)var path = svg.append('svg:g').selectAll('g')
  15762. path = svg.append('svg:g').selectAll('g');
  15763. circle = svg.append('svg:g').selectAll('g');
  15764. svg.on('mousedown', mousedown)
  15765. .on('mousemove', mousemove)
  15766. .on('mouseup', mouseup);
  15767. d3.select(window)
  15768. .on('keydown', keydown)
  15769. .on('keyup', keyup);
  15770. }
  15771. var CI = {};
  15772. window.CI = CI;
  15773. $scope.ok = function () {
  15774. $modalInstance.close($scope.selected_node);
  15775. };
  15776. $scope.cancel = function () {
  15777. $modalInstance.dismiss('cancel');
  15778. };
  15779. },
  15780. size: size,
  15781. resolve: {
  15782. title: function () {
  15783. return options.templateOptions.title;
  15784. },
  15785. Restangular: function () {
  15786. return options.templateOptions.Restangular;
  15787. },
  15788. APIService: function () {
  15789. return options.templateOptions.ApiService;
  15790. },
  15791. ConfigDataService: function () {
  15792. return options.templateOptions.ConfigDataService;
  15793. },
  15794. ConfigFormService: function () {
  15795. return options.templateOptions.ConfigFormService;
  15796. },
  15797. SweetAlert: function () {
  15798. return options.templateOptions.Alert;
  15799. },
  15800. Toaster: function () {
  15801. return options.templateOptions.toaster;
  15802. }
  15803. }
  15804. });
  15805. modalInstance.result.then(function (selectedItem) {
  15806. options.value(selectedItem.name + '-' + selectedItem.uuid);
  15807. }, function () {
  15808. //console.log('Modal dismissed at: ' + new Date());
  15809. });
  15810. }
  15811. }
  15812. }
  15813. },
  15814. controller: ['$scope', function ($scope) {
  15815. // setTimeout(function(){
  15816. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  15817. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  15818. // if(modelData.status==200){
  15819. // $scope.model[$scope.options.key] = modelData.data;
  15820. // $scope.options.initialValue = $scope.model[$scope.options.key];
  15821. // }
  15822. // });
  15823. // },1000);
  15824. }]
  15825. });
  15826. });
  15827. appFormly.run(function (formlyConfig, $parse) {
  15828. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  15829. var removeOnHideTransformer = function (fields, model) {
  15830. return fields.map(function (field) {
  15831. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  15832. addFieldRemoveOnHideWatcher(field);
  15833. }
  15834. if (field.type == "ui-title") {
  15835. addFieldRemoveOnHideWatcher(field);
  15836. }
  15837. return field;
  15838. });
  15839. };
  15840. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  15841. function addFieldRemoveOnHideWatcher(field) {
  15842. var watcher = getWatcher();
  15843. if (field.watcher) {
  15844. if (!angular.isArray(field.watcher)) {
  15845. field.watcher = [field.watcher];
  15846. }
  15847. field.watcher.push(watcher);
  15848. } else {
  15849. field.watcher = watcher;
  15850. }
  15851. }
  15852. function getWatcher() {
  15853. return {
  15854. expression: function (field) {
  15855. return field.hide;
  15856. },
  15857. listener: function (field, newHide, oldHide, scope) {
  15858. if (field.hide) {
  15859. if (field.templateOptions.pkey) {
  15860. if (field.key == 'transferuser') {
  15861. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  15862. }
  15863. } else {
  15864. $parse(field.key).assign(scope.model, undefined);
  15865. }
  15866. }
  15867. if (field.type == "ui-title") {
  15868. $parse(field.key).assign(scope.model, undefined);
  15869. }
  15870. }
  15871. };
  15872. }
  15873. });
  15874. 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',
  15875. 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) {
  15876. //console.log($parse('Restangular')($scope));
  15877. //console.log($injector.get('Restangular'));
  15878. //console.log($stateParams);
  15879. //保存报修主体
  15880. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15881. $scope.imgUrlList = [];
  15882. $scope.uploadimg_del = function () {
  15883. console.log(123)
  15884. };
  15885. var vm = this;
  15886. vm.options = {};
  15887. vm.exampleTitle = ['expressionProperties', 'model property'];
  15888. vm.fields = [];
  15889. vm.model = {};
  15890. $scope.langs = i18nService.getAllLangs();
  15891. $scope.lang = 'zh-cn';
  15892. i18nService.setCurrentLang($scope.lang);
  15893. //alert($rootScope.user.id,null,2);
  15894. vm.model["loginUser"] = $rootScope.user;
  15895. var loginUser = $rootScope.user;
  15896. // console.log(vm);
  15897. var that = $injector;
  15898. var parse = $parse;
  15899. var formKey = "";
  15900. var pdKey = "";
  15901. var modelWatch = "";
  15902. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  15903. modelWatch = JSON.parse($stateParams.model);
  15904. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  15905. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  15906. console.log(modelWatch,$rootScope)
  15907. // if(modelWatch.model.incident){
  15908. // if(modelWatch.model.incident.place){
  15909. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  15910. // }else{
  15911. // $rootScope.selecthouseNumber = undefined;
  15912. // }
  15913. // }
  15914. }
  15915. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  15916. pdKey = $state.current.pdKey;
  15917. } else if ($stateParams.pdKey) {
  15918. pdKey = $stateParams.pdKey;
  15919. }
  15920. // console.log("pdKey::" + JSON.stringify($state.current.title));
  15921. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  15922. formKey = $stateParams.formKey;
  15923. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  15924. }
  15925. if (angular.isDefined($stateParams.model)) {
  15926. var formModel = $stateParams.model;
  15927. }
  15928. //用户测试数据,后续从header的auth中获取
  15929. var userId = 2;
  15930. userId = $rootScope.user.id;
  15931. //==============处理表单设计数据 开始====================
  15932. //处理组件加载后台数据选项的方法
  15933. function refreshSelectOptions(searchVal, field) {
  15934. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  15935. var process = BpmRestangular.all("");
  15936. if (field.templateOptions.ApiService) {
  15937. process = UserRestangular.all("");
  15938. }
  15939. if (field.templateOptions.Apicommon) {
  15940. process = WechatRestangular.all("");
  15941. }
  15942. var datakey = {
  15943. "idx": 0,
  15944. "sum": 1000
  15945. };
  15946. if (field.templateOptions.modelreasondata) {
  15947. datakey = field.templateOptions.modelreasondata
  15948. }
  15949. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  15950. if (!field.templateOptions.options) {
  15951. field.templateOptions.options = [];
  15952. }
  15953. if (field.templateOptions.optionsDataKey) {
  15954. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  15955. } else {
  15956. field.templateOptions.options = result;
  15957. }
  15958. });
  15959. }
  15960. }
  15961. //获取表单后数据处理
  15962. function formfield(field, result) {
  15963. // angular.forEach(fields.fields, function(field) {
  15964. if (field.key == "") {
  15965. delete field.key;
  15966. }
  15967. if (angular.isDefined(field.extjson)) {
  15968. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  15969. angular.extend(field.templateOptions, extObj.templateOptions);
  15970. delete extObj.templateOptions;
  15971. for (var prop in extObj) {
  15972. if (new RegExp("Expression").test(prop)) {
  15973. //var obj = $scope.$eval(extObj[prop]);
  15974. //extObj[prop] = $scope.$eval(extObj[prop]);
  15975. if (extObj[prop] != null) {
  15976. if (new RegExp("function").test(extObj[prop])) {
  15977. var propValue = eval(extObj[prop]);
  15978. extObj[prop] = propValue;
  15979. } else {
  15980. //console.log(extObj[prop]);
  15981. var obj = $scope.$eval(extObj[prop]);
  15982. extObj[prop] = obj;
  15983. //console.log(obj);
  15984. }
  15985. }
  15986. } else if (new RegExp("expressionProperties").test(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. } else {
  15992. //if(p.indexOf("'")>=0){
  15993. // var obj = $scope.$eval(extObj[prop][p]);
  15994. // extObj[prop][$scope.$eval(p)]=obj;
  15995. //}
  15996. }
  15997. }
  15998. } else if ("watcher" == prop) {
  15999. if (angular.isArray(extObj[prop])) {
  16000. angular.forEach(extObj[prop], function (item, index) {
  16001. for (var p in item) {
  16002. if (new RegExp("function").test(item[p])) {
  16003. var propValue = eval(item[p]);
  16004. extObj[prop][index][p] = propValue;
  16005. }
  16006. }
  16007. });
  16008. } else if (angular.isObject(extObj[prop])) {
  16009. for (var p in extObj[prop]) {
  16010. if (new RegExp("function").test(extObj[prop][p])) {
  16011. var propValue = eval(extObj[prop][p]);
  16012. extObj[prop][p] = propValue;
  16013. }
  16014. }
  16015. }
  16016. }
  16017. }
  16018. angular.extend(field, extObj);
  16019. delete field.extjson;
  16020. }
  16021. if (angular.isDefined(field.templateOptions)) {
  16022. var templateOs = field.templateOptions;
  16023. // console.log(templateOs,'come')
  16024. for (var property in templateOs) {
  16025. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  16026. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  16027. if (new RegExp("function").test(templateOs[property])) {
  16028. var propValue = eval(templateOs[property]);
  16029. field.templateOptions[property] = propValue;
  16030. } else {
  16031. if (that.has(templateOs[property])) {
  16032. field.templateOptions[property] = that.get(templateOs[property]);
  16033. } else {
  16034. field.templateOptions[property] = templateOs[property];
  16035. }
  16036. }
  16037. } else if (templateOs[property] == null) {
  16038. //delete field.templateOptions[property];
  16039. } else { }
  16040. }
  16041. }
  16042. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  16043. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  16044. angular.extend(field.templateOptions, extObj);
  16045. delete field.templateOptions.extjson;
  16046. }
  16047. // ...
  16048. if (field.templateOptions) {
  16049. //处理远程获取数据控件方法调用
  16050. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  16051. // if (!field.templateOptions.isnoreash) {
  16052. field.templateOptions.refresh = refreshSelectOptions;
  16053. // }
  16054. }
  16055. //处理嵌套属性数据绑定/
  16056. if (field.templateOptions.pkey) {
  16057. var pmodel, i = 0;
  16058. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  16059. if (i == 0) {
  16060. if (result.model[p] == null) {
  16061. result.model[p] = {};
  16062. }
  16063. pmodel = result.model[p];
  16064. i++;
  16065. } else {
  16066. if (pmodel[p] == null) {
  16067. pmodel[p] = {};
  16068. }
  16069. pmodel = pmodel[p];
  16070. }
  16071. });
  16072. if (pmodel != null) {
  16073. field.model = pmodel;
  16074. if (pmodel[field.key] == null) {
  16075. pmodel[field.key] = null;
  16076. }
  16077. }
  16078. } else {
  16079. if (result.model[field.key] == null) {
  16080. result.model[field.key] = null;
  16081. }
  16082. }
  16083. //处理弹出框组件初始化
  16084. if (field.type == "ui-input-selectmodal") {
  16085. field.templateOptions.modal = $modal;
  16086. //field.templateOptions.Restangular = Restangular;
  16087. } else if (field.type == "ui-requesterselect") {
  16088. //field.templateOptions.language = $scope.lang;
  16089. field.templateOptions.modal = $modal;
  16090. field.templateOptions.UserService = api_user_data;
  16091. } else if (field.type == "ui-deptinformation") {
  16092. field.templateOptions.modal = $modal;
  16093. field.templateOptions.UserService = api_user_data;
  16094. } else if (field.type == "ui-requesterinformation") {
  16095. field.templateOptions.modal = $modal;
  16096. field.templateOptions.UserService = api_user_data;
  16097. } else if (field.type == "ui-userselect") {
  16098. field.templateOptions.modal = $modal;
  16099. //field.templateOptions.Restangular = Restangular;
  16100. } else if (field.type == "ui-userselectSearch") {
  16101. field.templateOptions.modal = $modal;
  16102. //field.templateOptions.Restangular = Restangular;
  16103. } else if (field.type == "ui-multiuserselect") {
  16104. field.templateOptions.modal = $modal;
  16105. } else if (field.type == "ui-stringuserselect") {
  16106. field.templateOptions.modal = $modal;
  16107. } else if (field.type == "ui-search") {
  16108. field.templateOptions.modal = $modal;
  16109. } else if (field.type == "ui-modelselect") {
  16110. field.templateOptions.modal = $modal;
  16111. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16112. field.templateOptions.loginUser = $rootScope.user;
  16113. //field.templateOptions.Restangular = Restangular;
  16114. } else if (field.type == "ui-incidentmodelselect") {
  16115. field.templateOptions.modal = $modal;
  16116. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16117. field.templateOptions.loginUser = $rootScope.user;
  16118. //field.templateOptions.Restangular = Restangular;
  16119. } else if (field.type == "ui-dropfile") {
  16120. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16121. url: '/uploader'
  16122. });
  16123. field.templateOptions.taskId = $stateParams.taskId;
  16124. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16125. field.templateOptions.userId = $rootScope.user.id;
  16126. } else if (field.type == "ui-dropfielknow") {
  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. } else if (field.type == "ui-upDropFile") {
  16134. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16135. url: '/uploader'
  16136. });
  16137. field.templateOptions.taskId = $stateParams.taskId;
  16138. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16139. field.templateOptions.userId = $rootScope.user.id;
  16140. } else if (field.type == "ui-dropfilenotup") {
  16141. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16142. url: '/uploader'
  16143. });
  16144. field.templateOptions.taskId = $stateParams.taskId;
  16145. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16146. field.templateOptions.userId = $rootScope.user.id;
  16147. //field.ApiService=api_bpm_domain;
  16148. } else if (field.type == "ui-uploadFiles") {
  16149. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16150. url: '/uploader'
  16151. });
  16152. field.templateOptions.taskId = $stateParams.taskId;
  16153. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16154. field.templateOptions.userId = $rootScope.user.id;
  16155. //field.ApiService=api_bpm_domain;
  16156. } else if (field.type == "ui-upDownFiles") {
  16157. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16158. url: '/uploader'
  16159. });
  16160. field.templateOptions.taskId = $stateParams.taskId;
  16161. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16162. field.templateOptions.userId = $rootScope.user.id;
  16163. //field.ApiService=api_bpm_domain;
  16164. } else if (field.type == "ui-uploadImgs") {
  16165. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16166. url: '/uploader'
  16167. });
  16168. field.templateOptions.taskId = $stateParams.taskId;
  16169. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16170. field.templateOptions.userId = $rootScope.user.id;
  16171. //field.ApiService=api_bpm_domain;
  16172. } else if (field.type == "ui-dropfiletable") {
  16173. if (field.templateOptions.processInstanceId) {
  16174. } else {
  16175. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16176. }
  16177. } else if (field.type == "ui-dropFiles") {
  16178. if (field.templateOptions.processInstanceId) {
  16179. } else {
  16180. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16181. }
  16182. } else if (field.type == "ui-showImgs") {
  16183. if (field.templateOptions.processInstanceId) {
  16184. } else {
  16185. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16186. }
  16187. } else if (field.type == "ui-repeatSection") {
  16188. var repeatForm = {
  16189. model: {
  16190. },
  16191. fields: field.templateOptions.fields
  16192. };
  16193. repeatForm.model[field.key] = [];
  16194. decodeVMForm(repeatForm);
  16195. } else if (field.type == "ui-currentuser") {
  16196. field.templateOptions.user = vm.model["loginUser"];
  16197. } else if (field.type == "ui-workernumbersign") {
  16198. field.templateOptions.user = vm.model["loginUser"];
  16199. } else if (field.type == "ui-repair-photos") {
  16200. field.templateOptions.user = vm.model["loginUser"];
  16201. }
  16202. }
  16203. }
  16204. //解析自定义表单设计数据
  16205. $scope.oldfromtype = true;
  16206. function decodeVMForm(vmForm) {
  16207. if (vmForm.formType == "1") {
  16208. $scope.oldfromtype = false;
  16209. } else {
  16210. $scope.oldfromtype = true;
  16211. }
  16212. var result = {
  16213. model: {},
  16214. fields: []
  16215. };
  16216. //设置模型实体数据 begin
  16217. // var mdata = vmForm.model;
  16218. //解析数据实体
  16219. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  16220. angular.extend(result.model, mdata);
  16221. if (modelWatch != null && modelWatch != '') {
  16222. //angular.extend(result.model.incident,modelWatch.incident);
  16223. //result.model.alarmType = modelWatch.alarmType;
  16224. // vmForm.cancelUrl = modelWatch.cancelUrl;
  16225. // console.log(modelWatch.cancelUrl)
  16226. for (var index in modelWatch.model) {
  16227. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  16228. if (result.model[index] != null) {
  16229. angular.extend(result.model[index], modelWatch.model[index]);
  16230. } else {
  16231. result.model[index] = modelWatch.model[index];
  16232. }
  16233. }
  16234. }
  16235. //设置模型实体数据 end
  16236. //解析设计数据生成表单项 begin
  16237. var fields = [];
  16238. //处理修改设计数据中展示设置
  16239. angular.forEach(vmForm.fields, function (fields) {
  16240. if (vmForm.formType == "1") {
  16241. angular.forEach(fields.fields, function (field) {
  16242. formfield(field, result);
  16243. });
  16244. } else {
  16245. formfield(fields, result);
  16246. }
  16247. // console.log(field);
  16248. result.fields.push(fields);
  16249. });
  16250. angular.extend($scope.vm.fields, result.fields);
  16251. angular.extend($scope.vm.model, result.model);
  16252. vm.model["loginUser"] = $rootScope.user;
  16253. //增加识别报修主体seimin
  16254. vm.model.repairType = $scope.repairMain.valueconfig;
  16255. if(vm.model.incident){
  16256. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  16257. }
  16258. console.log(vm, 'repairType')//lmm
  16259. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  16260. vmForm.cancelUrl = modelWatch.cancelUrl;
  16261. }
  16262. $scope.formData = vmForm;
  16263. console.log($scope.formData,4444444)
  16264. // console.log($scope.formData.url);
  16265. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  16266. if ($scope.formData.url == "start") {
  16267. $scope.Reset = true;
  16268. $scope.close = true;
  16269. $rootScope.isMask = false;
  16270. } else if ($scope.formData.url == "complete") {
  16271. $scope.Reset = false;
  16272. $scope.close = true;
  16273. }
  16274. //解析设计数据生成表单项 end
  16275. return result;
  16276. }
  16277. //======================处理表单设计数据 结束========================
  16278. $scope.ldloading = {};
  16279. function filter(obj) {
  16280. angular.forEach(obj, function (key, value) {
  16281. if (value === "" || value === null) {
  16282. delete obj[key];
  16283. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  16284. filter(value);
  16285. } else if (angular.isArray(value)) {
  16286. angular.forEach(value, function (item) {
  16287. filter(item);
  16288. });
  16289. }
  16290. });
  16291. }
  16292. $scope.closeModel = function () {
  16293. // console.log($stateParams);
  16294. $state.go($scope.formData.cancelUrl, {});
  16295. event.preventDefault();
  16296. };
  16297. // console.log(vm);
  16298. // 暂存
  16299. $scope.save = function (data) {
  16300. console.log(vm)
  16301. if (vm.model.startSave) {
  16302. vm.model["initUser"] = $rootScope.user.id;
  16303. vm.model.start_code = "temporary";
  16304. //处理请求数据0327
  16305. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16306. delete data0327.repairType;
  16307. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16308. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16309. data0327.incident.place = {
  16310. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16311. }
  16312. }
  16313. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16314. if (response) {
  16315. var resData = Restangular.stripRestangular(response);
  16316. if (resData) {
  16317. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16318. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16319. angular.extend(item.headers, $rootScope.getSession());
  16320. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16321. item.formData.push({
  16322. 'fileName': item.file.name
  16323. });
  16324. //console.log();
  16325. };
  16326. $scope.fileUploader.uploadAll();
  16327. }
  16328. }
  16329. SweetAlert.swal({
  16330. title: "提交成功!",
  16331. type: "success",
  16332. confirmButtonColor: "#007AFF"
  16333. }, function () {
  16334. $state.go($scope.formData.cancelUrl);
  16335. });
  16336. } else {
  16337. SweetAlert.swal({
  16338. title: "系统错误",
  16339. text: "系统错误,请稍后重试!",
  16340. type: "error",
  16341. confirmButtonColor: "#DD6B55"
  16342. });
  16343. }
  16344. $scope.ldloading[style.replace('-', '_')] = false;
  16345. });
  16346. event.preventDefault();
  16347. } else if (vm.model.saveAgain) {
  16348. var toData = {
  16349. "incident": vm.model.incident
  16350. };
  16351. api_user_data.updData("incident", toData).then(function (response) {
  16352. if (response) {
  16353. var resData = Restangular.stripRestangular(response);
  16354. SweetAlert.swal({
  16355. title: "提交成功!",
  16356. type: "success",
  16357. confirmButtonColor: "#007AFF"
  16358. }, function () {
  16359. $state.go($scope.formData.cancelUrl);
  16360. });
  16361. } else {
  16362. SweetAlert.swal({
  16363. title: "系统错误",
  16364. text: "系统错误,请稍后重试!",
  16365. type: "error",
  16366. confirmButtonColor: "#DD6B55"
  16367. });
  16368. }
  16369. $scope.ldloading[style.replace('-', '_')] = false;
  16370. });
  16371. event.preventDefault();
  16372. } else {
  16373. SweetAlert.swal({
  16374. title: "系统错误",
  16375. text: "系统错误,请稍后重试!",
  16376. type: "error",
  16377. confirmButtonColor: "#DD6B55"
  16378. });
  16379. }
  16380. }
  16381. // 巡检生成事件
  16382. $scope.inspectionToIncident = function () {
  16383. var userData = {
  16384. "idx": 0,
  16385. "sum": 10,
  16386. "requester": {
  16387. "name": loginUser.name
  16388. }
  16389. }
  16390. api_user_data.fetchDataList("requester", userData).then(function (res) {
  16391. console.log(res);
  16392. var toUser = {};
  16393. if (res.list.length > 0) {
  16394. toUser = res.list[0]
  16395. } else {
  16396. toUser = loginUser
  16397. }
  16398. console.log(vm);
  16399. var incidentDescription = "";
  16400. console.log($stateParams.formUiEdit);
  16401. if ($stateParams.formUiEdit == "inspection_confirm") {
  16402. if (vm.model.wnCheckEnable) {
  16403. incidentDescription = incidentDescription.concat(" 机房温度检查异常")
  16404. }
  16405. if (vm.model.sdCheckEnable) {
  16406. incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
  16407. }
  16408. if (vm.model.xfjCheckEnable) {
  16409. incidentDescription = incidentDescription.concat(" 新风机检查异常")
  16410. }
  16411. if (vm.model.lsCheckEnable) {
  16412. incidentDescription = incidentDescription.concat(" 漏水检查异常")
  16413. }
  16414. if (vm.model.xfCheckEnable) {
  16415. incidentDescription = incidentDescription.concat(" 消防检查异常")
  16416. }
  16417. if (vm.model.upsCheckEnable) {
  16418. incidentDescription = incidentDescription.concat(" UPS供电检查异常")
  16419. }
  16420. if (vm.model.dcCheckEnable) {
  16421. incidentDescription = incidentDescription.concat(" 电池连接检查异常")
  16422. }
  16423. if (vm.model.plCheckEnable) {
  16424. incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
  16425. }
  16426. if (vm.model.wjtdCheckEnable) {
  16427. incidentDescription = incidentDescription.concat(" 外机通道检查异常")
  16428. }
  16429. if (vm.model.descriptionTextarea) {
  16430. incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
  16431. }
  16432. }
  16433. // console.log(incidentDescription)
  16434. var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
  16435. var formdata = {
  16436. 'model': {
  16437. // 'isInspection': true,
  16438. // 'start_code':'assignment',
  16439. // 'isHandlerUser':false,
  16440. 'incident': {
  16441. 'requester':bxr ,
  16442. 'area': bxr.place.area,
  16443. 'place': bxr.place,
  16444. 'houseNumber': bxr.houseNumber,
  16445. 'contacts': bxr.name,
  16446. 'contactsInformation': bxr.mphone,
  16447. // 'category': data.wxIncidentClassifyDTO.category,
  16448. 'description': incidentDescription,
  16449. 'source': {
  16450. 'id': 1552
  16451. },
  16452. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  16453. // 'sourceType': data.incident.sourceType,
  16454. // 'fileUrl': data.incident.fileUrl
  16455. },
  16456. // 'requestershow': toUser,//2020年4月27日22:29:15
  16457. // 'flow': data.incident.id
  16458. // 'assignee': loginUser.id//2020年4月27日22:29:25
  16459. }
  16460. }
  16461. // console.log(formdata,toUser,'1111');
  16462. console.log(formdata,'1111');
  16463. // return;
  16464. $state.go("app.incident.chart", {
  16465. 'model': JSON.stringify(formdata)
  16466. });
  16467. })
  16468. // var formdata = {
  16469. // model:$rootScope.login_requester
  16470. // };
  16471. // console.log(formdata,'00000')
  16472. // return;
  16473. // $state.go("app.incident.chart", {
  16474. // 'model': JSON.stringify(formdata)
  16475. // });
  16476. event.preventDefault();
  16477. };
  16478. // console.log(vm);
  16479. // 创建事件seimin
  16480. vm.submit = function (data, style) {
  16481. console.log(vm,22222);
  16482. if (vm.model.handler_code == undefined) {
  16483. vm.model.handler_code = "resolve";
  16484. }
  16485. if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
  16486. delete vm.model.change.requestingPerson.menu;
  16487. }
  16488. // var pdKey = $stateParams.pdKey;
  16489. if (vm.form.$valid) {
  16490. if (data.incident && data.incident.synergetic) {
  16491. console.log(data.incident.synergetic);
  16492. var synergetic = [];
  16493. for (var i = 0; i < data.incident.synergetic.length; i++) {
  16494. synergetic.push({
  16495. id: data.incident.synergetic[i]
  16496. });
  16497. }
  16498. data.incident.synergetic = synergetic;
  16499. vm.model.incident.synergetic = synergetic;
  16500. }
  16501. $scope.ldloading[style.replace('-', '_')] = true;
  16502. var startsub = true;
  16503. if (pdKey == 'bpm_incident') {
  16504. angular.forEach(vm.fields, function (item) {
  16505. angular.forEach(item.fields, function (index) {
  16506. if (index.templateOptions.required && !index.hide) {
  16507. if (index.model) {
  16508. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  16509. if (index.model[index.key].id && index.model[index.key].id == '') {
  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. } else { }
  16519. } else {
  16520. startsub = false;
  16521. $scope.ldloading.expand_right = false;
  16522. SweetAlert.swal({
  16523. title: index.templateOptions.label + '未填',
  16524. text: "请填写此项!",
  16525. type: "error",
  16526. confirmButtonColor: "#DD6B55"
  16527. });
  16528. }
  16529. } else {
  16530. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  16531. } else {
  16532. startsub = false;
  16533. $scope.ldloading.expand_right = false;
  16534. SweetAlert.swal({
  16535. title: index.templateOptions.label + '未填',
  16536. text: "请填写此项!",
  16537. type: "error",
  16538. confirmButtonColor: "#DD6B55"
  16539. });
  16540. }
  16541. }
  16542. }
  16543. })
  16544. })
  16545. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  16546. // startsub = false;
  16547. // $scope.ldloading.expand_right = false;
  16548. // SweetAlert.swal({
  16549. // title: '保修人未填',
  16550. // text: "请填写此项!",
  16551. // type: "error",
  16552. // confirmButtonColor: "#DD6B55"
  16553. // });
  16554. // }
  16555. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  16556. // } else {
  16557. // startsub = false;
  16558. // $scope.ldloading.expand_right = false;
  16559. // SweetAlert.swal({
  16560. // title: '事件分类未填',
  16561. // text: "请填写此项!",
  16562. // type: "error",
  16563. // confirmButtonColor: "#DD6B55"
  16564. // });
  16565. // }
  16566. }
  16567. if (startsub) {
  16568. $scope.ldloading[style.replace('-', '_')] = true;
  16569. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  16570. // console.log("vm.options:"+ JSON.stringify(vm.options));
  16571. vm.options.updateInitialValue();
  16572. // console.log("dfjkasdhfkhskjf ")
  16573. var _ = window._;
  16574. vm.model = (function filter(obj) {
  16575. var dateTransKeys = [];
  16576. var filtered = _.pick(obj, function (v, k, obj) {
  16577. if (_.isDate(v)) {
  16578. dateTransKeys.push(k);
  16579. }
  16580. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  16581. });
  16582. return _.cloneDeep(filtered, function (v, index, object) {
  16583. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  16584. angular.forEach(dateTransKeys, function (item) {
  16585. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  16586. })
  16587. dateTransKey = [];
  16588. return v;
  16589. }
  16590. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  16591. });
  16592. })(vm.model);
  16593. if (pdKey != "") {
  16594. if ($scope.oprcode == "save") { //保存
  16595. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  16596. if (response) {
  16597. var resData = Restangular.stripRestangular(response);
  16598. SweetAlert.swal({
  16599. title: "保存成功!",
  16600. confirmButtonColor: "#007AFF"
  16601. }, function () {
  16602. $state.go($scope.formData.cancelUri);
  16603. });
  16604. // if(resData.status){
  16605. // resData
  16606. // }
  16607. } else {
  16608. SweetAlert.swal({
  16609. title: "系统错误",
  16610. text: "系统错误,请稍后重试!",
  16611. type: "error",
  16612. confirmButtonColor: "#DD6B55"
  16613. });
  16614. }
  16615. $scope.ldloading[style.replace('-', '_')] = false;
  16616. });
  16617. } else {
  16618. console.log($scope.formData.url,'zzzz')
  16619. switch ($scope.formData.url) {
  16620. case "start":
  16621. vm.model["initUser"] = $rootScope.user.id;
  16622. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  16623. } else {
  16624. vm.model["assignee"] = $rootScope.user.id;
  16625. }
  16626. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  16627. vm.model.candidateGroups = vm.model.candidateGroups.id;
  16628. }
  16629. if (pdKey == 'bpm_service_request') {
  16630. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  16631. angular.extend(vm.model.serviceCatalogueProcessActual, {
  16632. 'category': {
  16633. 'id': $stateParams.userId
  16634. }
  16635. });
  16636. }
  16637. if (vm.model.schedule && vm.model.schedule.initUser) {
  16638. delete vm.model.schedule.initUser.menu
  16639. }
  16640. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16641. delete vm.model.candidateGroups
  16642. }
  16643. if (vm.model.start_code == 'close') {
  16644. // 直接处理
  16645. vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
  16646. delete vm.model.incident.handlerUser
  16647. delete vm.model.candidateGroups;
  16648. } else if (vm.model.start_code == 'assignment') {
  16649. // 派单
  16650. delete vm.model.incident.handlingPersonnelUser
  16651. }
  16652. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  16653. $scope.jry_processInstanceId = $stateParams.processInstanceId;
  16654. }
  16655. if ($scope.jry_processInstanceId) {
  16656. vm.model["save_fileId"] = $scope.jry_processInstanceId
  16657. }
  16658. //事件暂存判断
  16659. if (vm.model.saveAgain) {
  16660. if (vm.model.directClose == "1" || vm.model.directClose == true) {
  16661. vm.model.start_code = "assignment";
  16662. vm.model.temporary_code = "assignment";
  16663. } else {
  16664. vm.model.start_code = "close";
  16665. vm.model.temporary_code = "close"
  16666. };
  16667. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16668. delete vm.model.candidateGroups
  16669. }
  16670. }
  16671. //处理请求数据0327
  16672. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16673. delete data0327.repairType;
  16674. // 增加地点的请求参数2020年4月24日10:44:36
  16675. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16676. // if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16677. // data0327.incident.place = {
  16678. // id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16679. // }
  16680. // }
  16681. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16682. // console.log("response="+JSON.stringify(response));
  16683. if (response) {
  16684. var resData = Restangular.stripRestangular(response);
  16685. if (resData) {
  16686. if (resData) {
  16687. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16688. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16689. angular.extend(item.headers, $rootScope.getSession());
  16690. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16691. item.formData.push({
  16692. 'fileName': item.file.name
  16693. });
  16694. //console.log();
  16695. };
  16696. $scope.fileUploader.uploadAll();
  16697. }
  16698. }
  16699. }
  16700. SweetAlert.swal({
  16701. title: "提交成功!",
  16702. type: "success",
  16703. confirmButtonColor: "#007AFF"
  16704. }, function () {
  16705. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  16706. $rootScope.app.layout.isSidebarClosed = false;
  16707. if ($scope.login && !$rootScope.busy) {
  16708. $rootScope.setidle();
  16709. }
  16710. }
  16711. $state.go($scope.formData.cancelUrl);
  16712. });
  16713. } else {
  16714. SweetAlert.swal({
  16715. title: "系统错误",
  16716. text: "系统错误,请稍后重试!",
  16717. type: "error",
  16718. confirmButtonColor: "#DD6B55"
  16719. });
  16720. }
  16721. $scope.ldloading[style.replace('-', '_')] = false;
  16722. });
  16723. break;
  16724. case "complete":
  16725. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  16726. //console.log("complete taskId::"+$stateParams.taskId);
  16727. if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
  16728. SweetAlert.swal({
  16729. title: "处理人未填",
  16730. text: "请填写此项!",
  16731. type: "error",
  16732. confirmButtonColor: "#DD6B55"
  16733. });
  16734. return;
  16735. }
  16736. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  16737. if (response) {
  16738. var resData = Restangular.stripRestangular(response);
  16739. SweetAlert.swal({
  16740. title: "提交成功!",
  16741. type: "success",
  16742. confirmButtonColor: "#007AFF"
  16743. }, function () {
  16744. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
  16745. console.log(vm);
  16746. if (vm.model.incident) {
  16747. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  16748. // angular.extend(item.headers, $rootScope.getSession());
  16749. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16750. // item.formData.push({
  16751. // 'fileName': item.file.name
  16752. // });
  16753. // };
  16754. // $scope.fileUploader.uploadAll();
  16755. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16756. angular.extend(item.headers, $rootScope.getSession());
  16757. item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
  16758. item.formData.push({
  16759. 'fileName': item.file.name
  16760. });
  16761. //console.log();
  16762. };
  16763. $scope.fileUploader.uploadAll();
  16764. } else if (vm.model.problem) {
  16765. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16766. angular.extend(item.headers, $rootScope.getSession());
  16767. item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16768. item.formData.push({
  16769. 'fileName': item.file.name
  16770. });
  16771. };
  16772. $scope.fileUploader.uploadAll();
  16773. } else if (vm.model.change) {
  16774. }
  16775. }
  16776. $state.go($scope.formData.cancelUrl);
  16777. });
  16778. } else {
  16779. SweetAlert.swal({
  16780. title: "系统错误",
  16781. text: "系统错误,请稍后重试!",
  16782. type: "error",
  16783. confirmButtonColor: "#DD6B55"
  16784. });
  16785. }
  16786. $scope.ldloading[style.replace('-', '_')] = false;
  16787. });
  16788. break;
  16789. case "back":
  16790. $state.go($scope.formData.cancelUrl);
  16791. break;
  16792. default:
  16793. $scope.ldloading[style.replace('-', '_')] = false;
  16794. break;
  16795. }
  16796. }
  16797. // var submitFunc = api_bpm_domain[$scope.formData.url]
  16798. // if(anuglar.isFunction(submitFunc)){
  16799. // submitFunc.apply(null, pdKey)
  16800. // }
  16801. }
  16802. }
  16803. } else {
  16804. // console.log(data)
  16805. // angular.forEach(vm.form.$error.required, function(item){
  16806. // var i=(item.$name).substring(item.$name.length-2)
  16807. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  16808. // for(var i=0;i<vm.fields.length;i++){
  16809. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  16810. SweetAlert.swal({
  16811. title: vm.fields[i].templateOptions.label + '未填',
  16812. text: "请填写此项!",
  16813. type: "error",
  16814. confirmButtonColor: "#DD6B55"
  16815. });
  16816. }
  16817. // }
  16818. // angular.forEach(vm.fields,function(f){
  16819. // if(f.name == item.$name){
  16820. // f.validation.show = true;
  16821. // SweetAlert.swal({
  16822. // title: f.templateOptions.label+'未填',
  16823. // text: "请填写此项!",
  16824. // type: "error",
  16825. // confirmButtonColor: "#DD6B55"
  16826. // });
  16827. // }
  16828. // });
  16829. // })
  16830. }
  16831. };
  16832. $scope.vm = vm;
  16833. console.log($stateParams,pdKey,88888)
  16834. console.log($scope.vm,'assdfsdf')
  16835. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  16836. var processInstanceId = $stateParams.processInstanceId;
  16837. var itemId = $stateParams.dataId;
  16838. console.log($stateParams)
  16839. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  16840. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
  16841. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16842. var vmForm = Restangular.stripRestangular(responseData);
  16843. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16844. decodeVMForm(vmForm);
  16845. }
  16846. }
  16847. });
  16848. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  16849. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  16850. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16851. var vmForm = Restangular.stripRestangular(responseData);
  16852. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16853. decodeVMForm(vmForm);
  16854. }
  16855. }
  16856. });
  16857. } else {
  16858. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  16859. if (response) {
  16860. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  16861. api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
  16862. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16863. var vmForm = Restangular.stripRestangular(responseData);
  16864. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16865. decodeVMForm(vmForm);
  16866. console.log(vmForm,111111);
  16867. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  16868. console.log($scope,'今天')//2020年4月24日11:40:55
  16869. }
  16870. }
  16871. });
  16872. }
  16873. })
  16874. }
  16875. } else {
  16876. // create process instance
  16877. if (pdKey != "") { //for process
  16878. if (pdKey == 'bpm_service_request') {
  16879. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  16880. if (responseData) {
  16881. var vmForm = Restangular.stripRestangular(responseData);
  16882. if (vmForm) {
  16883. decodeVMForm(vmForm);
  16884. }
  16885. }
  16886. });
  16887. } else {
  16888. api_bpm_domain.startformkey(pdKey).then(function (response) {
  16889. if (response) {
  16890. var myData = Restangular.stripRestangular(response);
  16891. //myData.data = "arrangeform";
  16892. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  16893. if (responseData) {
  16894. var vmForm = Restangular.stripRestangular(responseData);
  16895. if (vmForm) {
  16896. decodeVMForm(vmForm);
  16897. }
  16898. }
  16899. });
  16900. }
  16901. });
  16902. }
  16903. } else { //for form
  16904. //TODO
  16905. //测试数据 开始
  16906. var testJson = {
  16907. fields: [{
  16908. fields: [{
  16909. className: "col-xs-12",
  16910. noFormControl: true,
  16911. key: "formtitle",
  16912. templateOptions: {
  16913. readOnly: false,
  16914. placeholder: "新建事件单",
  16915. hidden: false,
  16916. label: "事件工单",
  16917. required: false
  16918. },
  16919. type: "ui-title"
  16920. }]
  16921. }, {
  16922. fields: [{
  16923. key: 'selectUser',
  16924. type: 'ui-deptinformation',
  16925. className: 'col-xs-12',
  16926. templateOptions: {
  16927. label: '请求人信息',
  16928. modalTitle: '请求人列表',
  16929. fetchItems: function (filterData, APIService) {
  16930. return APIService.fetchDataList('requester', filterData);
  16931. },
  16932. Restangular: Restangular,
  16933. ApiService: api_user_data
  16934. // onClick:function(val, options, field, event , model){
  16935. // console.log(options);
  16936. // }
  16937. }
  16938. }]
  16939. }, {
  16940. fields: [{
  16941. key: 'first',
  16942. type: 'ui-workernumber',
  16943. className: 'col-xs-12',
  16944. templateOptions: {
  16945. type: 'input',
  16946. label: '事件单号',
  16947. pkey: 'name'
  16948. }
  16949. }]
  16950. }, {
  16951. fields: [{
  16952. type: 'ui-header',
  16953. key: 'title',
  16954. className: 'col-xs-12',
  16955. templateOptions: {
  16956. label: '报修人',
  16957. pkey: 'change'
  16958. }
  16959. }, {
  16960. type: 'ui-input',
  16961. key: 'title',
  16962. className: 'col-xs-4',
  16963. templateOptions: {
  16964. label: '报修人',
  16965. pkey: 'change'
  16966. }
  16967. }, {
  16968. type: 'ui-input',
  16969. key: 'title',
  16970. className: 'col-xs-4',
  16971. templateOptions: {
  16972. label: '联系人',
  16973. pkey: 'change'
  16974. }
  16975. }, {
  16976. type: 'ui-input',
  16977. key: 'title',
  16978. className: 'col-xs-4',
  16979. templateOptions: {
  16980. label: '联系电话',
  16981. pkey: 'change'
  16982. }
  16983. }]
  16984. }, {
  16985. fields: [{
  16986. type: 'ui-header',
  16987. key: 'title1',
  16988. className: 'col-xs-12',
  16989. templateOptions: {
  16990. label: '报修人',
  16991. pkey: 'change'
  16992. }
  16993. }, {
  16994. type: 'ui-input',
  16995. key: 'title2',
  16996. className: 'col-xs-4',
  16997. templateOptions: {
  16998. label: '报修人',
  16999. pkey: 'change'
  17000. }
  17001. }, {
  17002. type: 'ui-input',
  17003. key: 'title3',
  17004. className: 'col-xs-4',
  17005. templateOptions: {
  17006. label: '联系人',
  17007. pkey: 'change'
  17008. }
  17009. }, {
  17010. type: 'ui-input',
  17011. key: 'title4',
  17012. className: 'col-xs-4',
  17013. templateOptions: {
  17014. label: '联系电话',
  17015. pkey: 'change'
  17016. }
  17017. }]
  17018. }],
  17019. model: [{
  17020. username: "robin lau",
  17021. password: "123456",
  17022. chkme: false,
  17023. start_code: 0,
  17024. formtitle: "Hey!I am title value!",
  17025. name: {
  17026. first: "robin",
  17027. last: "lau"
  17028. },
  17029. multiselectItem: []
  17030. //date:"2015-09-15 00:00:00"
  17031. }]
  17032. // }
  17033. };
  17034. setTimeout(function () {
  17035. decodeVMForm(testJson);
  17036. $scope.$apply();
  17037. }, 500);
  17038. //测试数据结束
  17039. }
  17040. }
  17041. //console.log("end decode");
  17042. }
  17043. ]);