customformCtrl.js 960 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836
  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. $scope.saveReqPlace = false;
  11082. $scope.model.saveReqPlace = false;
  11083. $scope.selectGradeBox = function(){
  11084. $scope.saveReqPlace = !$scope.saveReqPlace;
  11085. console.log($scope);
  11086. $scope.model.saveReqPlace = $scope.saveReqPlace;
  11087. }
  11088. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO && $scope.model.requester.requesterTypeDTO.id == 2) {
  11089. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11090. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11091. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11092. }
  11093. }]
  11094. });
  11095. // 请求人选控件
  11096. formlyConfigProvider.setType({
  11097. name: "ui-requesterselect",
  11098. templateUrl: 'assets/views/customform/tpl/ui-requester.html',
  11099. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11100. defaultOptions: function (options, $scope) {
  11101. return {
  11102. templateOptions: {
  11103. // checkform: function(options) {
  11104. // if (options.model.requestershow) {
  11105. // options.value(options.model.requestershow);
  11106. // }
  11107. // },
  11108. validators: {
  11109. required: {
  11110. expression: function (viewValue, modelValue) {
  11111. var value = modelValue || viewValue;
  11112. return value.length >= 1;
  11113. }
  11114. }
  11115. },
  11116. openModal: function (size, options, modal) { //查找弹出框
  11117. var modelObject = options.value();
  11118. var searchModal = function (filterSearchData) {
  11119. var modalInstance = modal.open({
  11120. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11121. controller: function ($scope, scope, i18nService, $modalInstance, items, title, Restangular, APIService, language, searchDatas, api_bpm_data) {
  11122. $scope.langs = i18nService.getAllLangs();
  11123. $scope.lang = 'zh-cn';
  11124. i18nService.setCurrentLang($scope.lang);
  11125. $scope.gridOptions = {};
  11126. $scope.gridOptions.data = 'myData';
  11127. $scope.gridOptions.enableColumnResizing = true;
  11128. $scope.gridOptions.enableFiltering = true;
  11129. $scope.gridOptions.enableGridMenu = false;
  11130. $scope.gridOptions.enableRowSelection = true;
  11131. $scope.gridOptions.showGridFooter = true;
  11132. $scope.gridOptions.showColumnFooter = false;
  11133. $scope.gridOptions.fastWatch = true;
  11134. $scope.gridOptions.useExternalFiltering = true;
  11135. $scope.gridOptions.useExternalPagination = true;
  11136. $scope.gridOptions.paginationPageSizes = [10];
  11137. $scope.gridOptions.paginationPageSize = 10;
  11138. $scope.gridOptions.multiSelect = false;
  11139. $scope.gridOptions.rowIdentity = function (row) {
  11140. return row.id;
  11141. };
  11142. $scope.gridOptions.getRowIdentity = function (row) {
  11143. return row.id;
  11144. };
  11145. $scope.gridOptions.columnDefs = [{
  11146. name: 'account',
  11147. displayName: '人员编号',
  11148. width: 140
  11149. },
  11150. {
  11151. name: 'name',
  11152. displayName: '姓名',
  11153. width: 100
  11154. },
  11155. {
  11156. name: 'gender.name',
  11157. displayName: '性别',
  11158. width: 80,
  11159. enableFiltering: false
  11160. },
  11161. {
  11162. name: 'mphone',
  11163. displayName: '电话',
  11164. width: 100,
  11165. enableFiltering: false
  11166. },
  11167. {
  11168. name: 'email',
  11169. displayName: '邮件',
  11170. width: 100
  11171. },
  11172. {
  11173. name: 'areaDTO.area',
  11174. displayName: '区域',
  11175. width: 100,
  11176. enableFiltering: false
  11177. },
  11178. {
  11179. name: 'placeDTO.place',
  11180. displayName: '地点',
  11181. enableFiltering: false
  11182. }
  11183. ];
  11184. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11185. $scope.gridApi = gridApi;
  11186. // var filtersData = $scope.memoryfilterData;
  11187. // filtersData.idx = newPage - 1;
  11188. // filtersData.sum = pageSize;
  11189. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11190. var filtersData = $scope.memoryfilterData;
  11191. filtersData.idx = newPage - 1;
  11192. filtersData.sum = pageSize;
  11193. $scope.loadData(filtersData);
  11194. });
  11195. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11196. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  11197. $scope.selected.item = data.entity;
  11198. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  11199. });
  11200. gridApi.core.on.filterChanged($scope, function () {
  11201. var grid = this.grid;
  11202. var filtersData = {
  11203. idx: 0,
  11204. sum: 10
  11205. // 'requester': { 'userType': 1 }
  11206. };
  11207. angular.forEach(grid.columns, function (item) {
  11208. if (item.enableFiltering) {
  11209. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11210. if (angular.isUndefined(filtersData['requester'])) {
  11211. filtersData['requester'] = {};
  11212. }
  11213. filtersData['requester'][item.field] = item.filters[0].term;
  11214. }
  11215. }
  11216. });
  11217. $scope.memoryfilterData = filtersData;
  11218. $scope.loadData(filtersData);
  11219. });
  11220. };
  11221. $scope.memoryfilterData = defaultFilterData = {
  11222. "idx": 0,
  11223. "sum": 10
  11224. };
  11225. $scope.loadData = function (filterData) {
  11226. if (!filterData.requester) {
  11227. filterData.requester = {};
  11228. }
  11229. if (scope.roleidcode) {
  11230. angular.extend(filterData['requester'], {
  11231. 'userType': 1
  11232. });
  11233. }
  11234. items.fetchItems(filterData, APIService).then(function (data) {
  11235. var myData = Restangular.stripRestangular(data);
  11236. $scope.gridOptions.totalItems = myData.totalNum;
  11237. $scope.myData = myData.list;
  11238. });
  11239. };
  11240. // $scope.title = title;
  11241. if (searchDatas) {
  11242. $scope.loadData(searchDatas);
  11243. } else {
  11244. $scope.loadData({
  11245. idx: 0,
  11246. sum: 10,
  11247. });
  11248. }
  11249. $scope.selected = {
  11250. item: {}
  11251. };
  11252. $scope.ok = function () {
  11253. $modalInstance.close($scope.selected.item);
  11254. };
  11255. $scope.cancel = function () {
  11256. $modalInstance.dismiss('cancel');
  11257. };
  11258. },
  11259. size: size,
  11260. resolve: {
  11261. items: function () {
  11262. return {
  11263. fetchItems: function (filterData, APIService) {
  11264. filterData = filterData || {};
  11265. if (angular.isUndefined(filterData.idx) || filterData.idx == null) {
  11266. filterData = {
  11267. idx: 0,
  11268. sum: 10
  11269. };
  11270. }
  11271. return options.templateOptions.fetchItems(filterData, APIService);
  11272. }
  11273. };
  11274. },
  11275. title: function () {
  11276. return options.templateOptions.modalTitle;
  11277. },
  11278. Restangular: function () {
  11279. return options.templateOptions.Restangular;
  11280. },
  11281. APIService: function () {
  11282. return options.templateOptions.ApiService;
  11283. },
  11284. language: function () {
  11285. return options.templateOptions.language;
  11286. },
  11287. searchDatas: function () {
  11288. return filterSearchData;
  11289. },
  11290. scope: function () {
  11291. return $scope;
  11292. }
  11293. }
  11294. });
  11295. modalInstance.result.then(function (selectedItem) {
  11296. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11297. selectedItem.telephone = $scope.model.incident.contactsInformation;
  11298. }
  11299. $scope.$parent.$parent.$parent.model.incident['requester'] = selectedItem;
  11300. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  11301. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  11302. if ($scope.model) {
  11303. if ($scope.model.incident.place) {
  11304. $scope.model.incident.place.id = '';
  11305. }
  11306. if ($scope.model.area) {
  11307. $scope.model.incident.area.id = '';
  11308. }
  11309. $scope.model.incident.contacts = selectedItem.name;
  11310. if (selectedItem.mphone && selectedItem.mphone != null && selectedItem.mphone != "") {
  11311. $scope.model.incident.contactsInformation = selectedItem.mphone;
  11312. } else {
  11313. $scope.model.incident.contactsInformation = selectedItem.telephone;
  11314. }
  11315. $scope.model.incident.houseNumber = '';
  11316. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11317. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11318. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11319. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11320. }
  11321. }
  11322. $scope.options.value(selectedItem);
  11323. $scope.searchData = selectedItem.account;
  11324. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  11325. $scope.model.incident.place.id = selectedItem.placeDTO.id
  11326. }
  11327. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  11328. $scope.model.incident.area.id = selectedItem.areaDTO.id
  11329. }
  11330. if (selectedItem.houseNumber) {
  11331. $scope.model.incident.houseNumber = selectedItem.houseNumber;
  11332. }
  11333. if (selectedItem.requesterTypeDTO && selectedItem.requesterTypeDTO.id == 2) {
  11334. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11335. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11336. $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  11337. }
  11338. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  11339. options.templateOptions.callback(selectedItem, options);
  11340. }
  11341. if (!$scope.roleidcode) {
  11342. $scope.charging(selectedItem, modal)
  11343. }
  11344. $scope.recentlyincident(selectedItem);
  11345. }, function () {
  11346. //console.log('Modal dismissed at: ' + new Date());
  11347. });
  11348. }
  11349. searchModal();
  11350. // }
  11351. }
  11352. }
  11353. };
  11354. },
  11355. controller: ['$rootScope', '$scope', 'ngTableParams', '$filter', "SweetAlert", 'moment', function ($rootScope, $scope, ngTableParams, $filter, SweetAlert, moment) {
  11356. $scope.roleidcode = true;
  11357. // $scope.options.initialValue = undefined;
  11358. if ($rootScope.user && $rootScope.user.role) {
  11359. angular.forEach($rootScope.user.role, function (item) {
  11360. if (item.rolecode == "call center") {
  11361. $scope.roleidcode = false;
  11362. }
  11363. })
  11364. }
  11365. $scope.recently = false;
  11366. $scope.recentlyincident = function (key, model) { //关联事件
  11367. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  11368. "idx": 0,
  11369. "sum": 4,
  11370. incident: {
  11371. requester: {
  11372. id: key.id
  11373. }
  11374. }
  11375. }).then(function (response) {
  11376. if (response.status == 200) {
  11377. $scope.recently = true;
  11378. $scope.recentincident = response.list;
  11379. } else {
  11380. $scope.recently = false;
  11381. }
  11382. })
  11383. $scope.bodyHeight = window.innerHeight - 100;
  11384. $(window).resize(function () {
  11385. $scope.bodyHeight = window.innerHeight - 100;
  11386. });
  11387. // $scope.shows = false;
  11388. $scope.tempData = {};
  11389. $scope.close = function () {
  11390. $scope.changes = !$scope.changes;
  11391. event.preventDefault();
  11392. }
  11393. }
  11394. $scope.charging = function (key, model) { //计费弹出框
  11395. //用户信息
  11396. $scope.information = {};
  11397. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  11398. "userId": key.account
  11399. }).then(function (response) {
  11400. // if (response.status == 200) {
  11401. if (response && response.data) {
  11402. angular.extend($scope.information, response.data[0]);
  11403. // $scope.information = response.data[0];
  11404. $scope.information.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  11405. $scope.information.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  11406. $scope.information.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  11407. } else if (response.err) {
  11408. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  11409. }
  11410. // }
  11411. })
  11412. //上网明细
  11413. $scope.options.templateOptions.ApiSer.fetchDataList("queryOnlineDetail", {
  11414. "userId": key.account,
  11415. "limit": "10",
  11416. "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'),
  11417. "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')
  11418. }).then(function (response) {
  11419. // if (response.status == 200) {
  11420. if (response && response.data) {
  11421. angular.forEach(response.data, function (item, index) {
  11422. if (item.logoutTime) {
  11423. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  11424. }
  11425. if (item.loginTime) {
  11426. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  11427. }
  11428. })
  11429. $scope.logininform = response.data;
  11430. } else if (response.err) {
  11431. SweetAlert.swal("系统错误!", "上网明细未取到,请刷新重试", "error");
  11432. }
  11433. })
  11434. //黑名单
  11435. // $scope.information.blacklist = "否"
  11436. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  11437. "userId": key.account
  11438. }).then(function (response) {
  11439. // if (response.status == 200) {
  11440. // $scope.logininformation = response.data;
  11441. if (response) {
  11442. if (response.data || response.data != null) {
  11443. $scope.information.blacklist = "是"
  11444. } else {
  11445. if (response.err) {
  11446. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  11447. } else {
  11448. $scope.information.blacklist = "否"
  11449. }
  11450. }
  11451. }
  11452. // }
  11453. })
  11454. $scope.bodyHeight = window.innerHeight - 100;
  11455. $(window).resize(function () {
  11456. $scope.bodyHeight = window.innerHeight - 100;
  11457. });
  11458. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  11459. // $scope.closepages = function(e) {
  11460. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  11461. // event.preventDefault();
  11462. // };
  11463. // $scope.shows = false;
  11464. $scope.tempData = {};
  11465. $scope.close = function () {
  11466. $scope.changes = !$scope.changes;
  11467. event.preventDefault();
  11468. }
  11469. }
  11470. $scope.options.templateOptions.ApiService.fetchDataList('requesterType', {
  11471. idx: 0,
  11472. sum: 100
  11473. }).then(function (response) {
  11474. if (response.status == 200) {
  11475. $scope.networktypes = response.list;
  11476. } else {
  11477. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  11478. }
  11479. })
  11480. function serchdata(searchKey) {
  11481. if (searchKey) {
  11482. var filterData = {
  11483. 'requester': {
  11484. 'searchKey': searchKey
  11485. // 'userType': 1
  11486. },
  11487. idx: 0,
  11488. sum: 10
  11489. };
  11490. } else {
  11491. var filterData = {
  11492. 'idx': 0,
  11493. 'requester': {},
  11494. 'sum': 10
  11495. };
  11496. }
  11497. if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  11498. angular.extend(filterData.requester, {
  11499. 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO
  11500. });
  11501. if (!$scope.options.model.contactsInformation) {
  11502. $scope.options.model.contactsInformation = $scope.model.requester.mphone;
  11503. }
  11504. }
  11505. if ($scope.roleidcode) {
  11506. angular.extend(filterData['requester'], {
  11507. 'userType': 1
  11508. });
  11509. }
  11510. $scope.options.templateOptions.ApiService.fetchDataList('requester', filterData).then(function (response) {
  11511. var myData = response;
  11512. $scope.myData = myData.list;
  11513. });
  11514. }
  11515. $scope.searchData = {};
  11516. $scope.refreshUser = function (searchKey) { //请求人搜索
  11517. if (searchKey && searchKey != "") {
  11518. serchdata(searchKey);
  11519. }
  11520. }
  11521. if ($scope.$parent.$parent.$parent.model.incident.callID || $scope.$parent.$parent.$parent.model.requestershow) {
  11522. if (!$scope.roleidcode) {
  11523. $scope.charging($scope.$parent.$parent.$parent.model.incident.requester);
  11524. }
  11525. $scope.recentlyincident($scope.$parent.$parent.$parent.model.incident.requester);
  11526. }
  11527. $scope.onChange = function (searchData) {
  11528. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  11529. searchData.telephone = $scope.model.incident.contactsInformation;;
  11530. }
  11531. $scope.$parent.$parent.$parent.model.incident['requester'] = searchData;
  11532. if (!$scope.roleidcode) {
  11533. $scope.charging(searchData);
  11534. }
  11535. $scope.recentlyincident(searchData);
  11536. $scope.accountshow = false;
  11537. if ($scope.model.incident) {
  11538. if ($scope.model.incident.place) {
  11539. $scope.model.incident.place.id = '';
  11540. }
  11541. if ($scope.model.incident.area) {
  11542. $scope.model.incident.area.id = '';
  11543. }
  11544. $scope.model.incident.contacts = searchData.name;
  11545. if (searchData.mphone && searchData.mphone != null && searchData.mphone != "") {
  11546. $scope.model.incident.contactsInformation = searchData.mphone;
  11547. } else {
  11548. $scope.model.incident.contactsInformation = searchData.telephone;
  11549. }
  11550. $scope.model.incident.houseNumber = '';
  11551. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11552. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11553. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11554. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11555. }
  11556. }
  11557. $scope.options.value(searchData);
  11558. $scope.searchKey = searchData.account;
  11559. if (searchData.placeDTO && searchData.placeDTO.id) {
  11560. $scope.model.incident.place.id = searchData.placeDTO.id
  11561. }
  11562. if (searchData.areaDTO && searchData.areaDTO.id) {
  11563. $scope.model.incident.area.id = searchData.areaDTO.id
  11564. }
  11565. if (searchData.houseNumber) {
  11566. $scope.model.incident.houseNumber = searchData.houseNumber;
  11567. }
  11568. if (searchData.requesterTypeDTO && searchData.requesterTypeDTO.id == 2) {
  11569. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  11570. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  11571. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  11572. }
  11573. }
  11574. }]
  11575. });
  11576. //ui-grid-table展示控件
  11577. formlyConfigProvider.setType({
  11578. name: 'ui-grid-table',
  11579. // extends: 'multiCheckbox',//去掉冒号
  11580. templateUrl: 'assets/views/customform/tpl/ui-grid-show-nofooter.html',
  11581. defaultOptions: function (options) {
  11582. return {
  11583. templateOptions: {
  11584. linkage: function () { },
  11585. },
  11586. };
  11587. },
  11588. controller: function ($scope, $rootScope, i18nService, Restangular, api_bpm_data, api_statistic, $rootScope) {
  11589. var loginUser = $rootScope.user;
  11590. $scope.langs = i18nService.getAllLangs();
  11591. $scope.lang = 'zh-cn';
  11592. i18nService.setCurrentLang($scope.lang);
  11593. $scope.gridOptions = {};
  11594. $scope.gridOptions.data = 'myData';
  11595. $scope.gridOptions.enableColumnResizing = true;
  11596. $scope.gridOptions.enableGridMenu = false;
  11597. $scope.gridOptions.enableRowSelection = true;
  11598. $scope.gridOptions.showGridFooter = false;
  11599. $scope.gridOptions.showColumnFooter = false;
  11600. $scope.gridOptions.fastWatch = true;
  11601. $scope.gridOptions.useExternalFiltering = true;
  11602. $scope.gridOptions.useExternalPagination = false;
  11603. $scope.gridOptions.paginationPageSizes = [10];
  11604. $scope.gridOptions.paginationPageSize = 3;
  11605. $scope.gridOptions.multiSelect = false;
  11606. $scope.gridOptions.rowIdentity = function (row) {
  11607. return row.id;
  11608. };
  11609. $scope.gridOptions.getRowIdentity = function (row) {
  11610. return row.id;
  11611. };
  11612. $scope.gridOptions.columnDefs = [{
  11613. name: 'item',
  11614. displayName: '序号',
  11615. width: 80,
  11616. enableFiltering: false
  11617. },
  11618. {
  11619. name: 'incidentsign',
  11620. displayName: '单号',
  11621. width: 80,
  11622. enableFiltering: false
  11623. },
  11624. {
  11625. name: 'description',
  11626. displayName: '主题',
  11627. width: 80,
  11628. enableFiltering: false
  11629. },
  11630. {
  11631. name: 'state.name',
  11632. displayName: '状态',
  11633. width: 110,
  11634. enableFiltering: false
  11635. },
  11636. {
  11637. name: 'acceptDate',
  11638. displayName: '创建时间',
  11639. width: 160,
  11640. enableFiltering: false
  11641. },
  11642. {
  11643. name: 'requester.name',
  11644. displayName: '请求人',
  11645. width: 80,
  11646. enableFiltering: false
  11647. },
  11648. {
  11649. name: 'handlingPersonnelUser.name',
  11650. displayName: '处理人',
  11651. width: 160,
  11652. enableFiltering: false
  11653. },
  11654. {
  11655. name: 'place.place',
  11656. displayName: '区域地点',
  11657. width: 160,
  11658. enableFiltering: false
  11659. },
  11660. ];
  11661. // var defaultFilterData = {
  11662. // "idx": 0,
  11663. // "sum": 3
  11664. // };
  11665. // // //分页控制
  11666. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11667. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11668. var filtersData = $scope.memoryfilterData;
  11669. filtersData.idx = newPage - 1;
  11670. filtersData.sum = pageSize;
  11671. $scope.refreshData('expand-right', filtersData);
  11672. });
  11673. // 表格单选事件
  11674. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11675. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  11676. data.grid.appScope.$parent.$parent.$parent.model.incident.table = data.entity;
  11677. data.grid.appScope.$parent.$parent.$parent.model.associationType = data.entity.id;
  11678. var str = data.grid.appScope.$parent.$parent.$parent.model.incident.description || '';
  11679. str = str.split("").reverse().join("");
  11680. var del = addstr.split("").reverse().join("");
  11681. // console.log(del);
  11682. var reg = new RegExp(del);
  11683. str = str.replace(reg, '');
  11684. str = str.split("").reverse().join("")
  11685. if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件补充') {
  11686. data.grid.appScope.$parent.$parent.$parent.model.relationType = null;
  11687. str += data.entity.description;
  11688. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = data.entity.description;
  11689. } else if (data.grid.appScope.$parent.$parent.$parent.model.incident.associationType == '事件已解决') {
  11690. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType = 'close';
  11691. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr = '';
  11692. }
  11693. data.grid.appScope.$parent.$parent.$parent.model.incident.description = str;
  11694. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId = data.entity.id;
  11695. });
  11696. };
  11697. // 刷新表格
  11698. setInterval(function () {
  11699. // console.log($scope.myData);
  11700. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  11701. // console.log($scope.myData);
  11702. if ($scope.myData != null) {
  11703. for (var i = 0; i < $scope.myData.length; i++) {
  11704. //添加序号
  11705. $scope.myData[i]['item'] = i + 1;
  11706. }
  11707. }
  11708. }, 1000)
  11709. }
  11710. });
  11711. //处理人信息
  11712. formlyConfigProvider.setType({
  11713. name: "ui-userinformation",
  11714. templateUrl: 'assets/views/customform/tpl/ui-userinformation.html',
  11715. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11716. defaultOptions: function (options) {
  11717. return {
  11718. templateOptions: {}
  11719. };
  11720. },
  11721. controller: ['$scope', function ($scope) {
  11722. $scope.group = "";
  11723. $scope.role = "";
  11724. if (angular.isDefined($scope.model.handlingPersonnelUser) && angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11725. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11726. } else {
  11727. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11728. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11729. }
  11730. }
  11731. if (angular.isDefined($scope.model.handlingPersonnelUser.role) && $scope.model.handlingPersonnelUser.role.length == 1) {
  11732. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  11733. } else {
  11734. for (var i = 0; i < $scope.model.handlingPersonnelUser.role.length; i++) {
  11735. $scope.role += $scope.model.handlingPersonnelUser.role[i].role + ",";
  11736. }
  11737. }
  11738. $scope.options.templateOptions.that = $scope;
  11739. }]
  11740. });
  11741. //处理界面处理人信息
  11742. formlyConfigProvider.setType({
  11743. name: "ui-handler",
  11744. templateUrl: 'assets/views/customform/tpl/ui-handler.html',
  11745. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11746. defaultOptions: function (options) {
  11747. return {
  11748. templateOptions: {}
  11749. };
  11750. },
  11751. controller: ['$scope', function ($scope) {
  11752. $scope.group = "";
  11753. // $scope.role="";
  11754. if (angular.isDefined($scope.model.handlingPersonnelUser.group) && $scope.model.handlingPersonnelUser.group.length == 1) {
  11755. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  11756. } else {
  11757. for (var i = 0; i < $scope.model.handlingPersonnelUser.group.length; i++) {
  11758. $scope.group += $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  11759. }
  11760. }
  11761. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  11762. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  11763. // }else{
  11764. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  11765. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  11766. // }
  11767. // }
  11768. $scope.options.templateOptions.that = $scope;
  11769. }]
  11770. });
  11771. //微信事件流程
  11772. formlyConfigProvider.setType({
  11773. name: "ui-wxIncidentProcess",
  11774. templateUrl: 'assets/views/customform/tpl/wxIncidentProcess.html',
  11775. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11776. defaultOptions: function (options) {
  11777. return {
  11778. templateOptions: {}
  11779. };
  11780. },
  11781. controller: ['$scope', function ($scope) {
  11782. console.log($scope.model);
  11783. $scope.pingjia = false;
  11784. $scope.jiejue = false;
  11785. if ($scope.model.incidentState.value == "3") {
  11786. $scope.pingjia = true
  11787. } else if ($scope.model.incidentState.value == "4") {
  11788. $scope.jiejue = true;
  11789. }
  11790. }]
  11791. });
  11792. //打电话
  11793. formlyConfigProvider.setType({
  11794. name: "ui-inputcall",
  11795. extends: 'input',
  11796. templateUrl: 'assets/views/customform/tpl/inputcall.html',
  11797. defaultOptions: function (options) {
  11798. return {
  11799. templateOptions: {
  11800. transform: function (value) { }
  11801. }
  11802. };
  11803. },
  11804. controller: ['$scope', '$rootScope', 'api_text', 'SweetAlert', function ($scope, $rootScope, api_text, SweetAlert) {
  11805. $scope.dialout = function (teleno) {
  11806. var gid = "@0"
  11807. var telephone = '9' + teleno
  11808. $rootScope.callout = 2;
  11809. if ($rootScope.takes) {
  11810. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11811. if (data.errno == 0) {
  11812. $rootScope.status = 6;
  11813. }
  11814. })
  11815. } else {
  11816. SweetAlert.swal({
  11817. title: "呼叫失败",
  11818. text: "请先签入呼叫中心!",
  11819. type: "error",
  11820. confirmButtonColor: "#DD6B55"
  11821. });
  11822. }
  11823. }
  11824. $scope.options.templateOptions.that = $scope;
  11825. }]
  11826. });
  11827. //关闭界面处理人信息
  11828. formlyConfigProvider.setType({
  11829. name: "ui-closehandler",
  11830. templateUrl: 'assets/views/customform/tpl/ui-closehandler.html',
  11831. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11832. defaultOptions: function (options) {
  11833. return {
  11834. templateOptions: {}
  11835. };
  11836. },
  11837. controller: ['$scope', '$rootScope', 'api_text', function ($scope, $rootScope, api_text) {
  11838. $scope.dialout = function (teleno) {
  11839. var gid = "@0"
  11840. var telephone = '9' + teleno
  11841. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  11842. if (data.errno == 0) {
  11843. $rootScope.status = 6;
  11844. }
  11845. })
  11846. }
  11847. $scope.options.templateOptions.that = $scope;
  11848. }]
  11849. });
  11850. //用户单选控件
  11851. formlyConfigProvider.setType({
  11852. name: "ui-userselect",
  11853. templateUrl: 'assets/views/customform/tpl/ui-userselect.html',
  11854. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  11855. defaultOptions: function (options) {
  11856. return {
  11857. templateOptions: {
  11858. openModal: function (size, options, modal) {
  11859. var modalInstance = modal.open({
  11860. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  11861. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  11862. $scope.langs = i18nService.getAllLangs();
  11863. $scope.lang = 'zh-cn';
  11864. i18nService.setCurrentLang($scope.lang);
  11865. $scope.gridOptions = {};
  11866. $scope.gridOptions.data = 'myData';
  11867. $scope.gridOptions.enableColumnResizing = true;
  11868. $scope.gridOptions.enableFiltering = true;
  11869. $scope.gridOptions.enableGridMenu = false;
  11870. $scope.gridOptions.showGridFooter = true;
  11871. $scope.gridOptions.showColumnFooter = false;
  11872. $scope.gridOptions.fastWatch = true;
  11873. $scope.gridOptions.useExternalFiltering = true;
  11874. $scope.gridOptions.useExternalPagination = true;
  11875. $scope.gridOptions.paginationPageSizes = [10];
  11876. $scope.gridOptions.paginationPageSize = 10;
  11877. $scope.gridOptions.multiSelect = false;
  11878. $scope.gridOptions.rowIdentity = function (row) {
  11879. return row.id;
  11880. };
  11881. $scope.gridOptions.getRowIdentity = function (row) {
  11882. return row.id;
  11883. };
  11884. $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>";
  11885. $scope.gridOptions.columnDefs = [{
  11886. name: 'account',
  11887. displayName: '人员编号',
  11888. width: 120
  11889. },
  11890. {
  11891. name: 'name',
  11892. displayName: '姓名',
  11893. width: 100,
  11894. cellTemplate: '<div>' +
  11895. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  11896. '</div>'
  11897. },
  11898. // {
  11899. // name: 'gender.name',
  11900. // displayName: '性别',
  11901. // width: 80,
  11902. // enableFiltering: false
  11903. // },
  11904. {
  11905. name: 'phone',
  11906. displayName: '电话',
  11907. width: 230,
  11908. enableFiltering: false
  11909. },
  11910. {
  11911. name: 'email',
  11912. displayName: '邮箱',
  11913. width: 180,
  11914. enableFiltering: false
  11915. },
  11916. {
  11917. name: 'dept.dept',
  11918. displayName: '科室',
  11919. width: 130,
  11920. enableFiltering: false
  11921. },
  11922. {
  11923. name: 'taskCount',
  11924. displayName: '处理中事件数',
  11925. enableFiltering: false
  11926. }
  11927. ];
  11928. // $scope.selectButtonClick
  11929. $scope.gridOptions.onRegisterApi = function (gridApi) {
  11930. $scope.gridApi = gridApi;
  11931. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  11932. var filtersData = $scope.memoryfilterData;
  11933. filtersData.idx = newPage - 1;
  11934. filtersData.sum = pageSize;
  11935. $scope.loadData(filtersData);
  11936. //console.log(pageSize);
  11937. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  11938. });
  11939. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  11940. $scope.selected.items = data.entity;
  11941. //console.log(data);
  11942. });
  11943. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  11944. $scope.selected.items = data.entity;
  11945. //console.log(data);
  11946. });
  11947. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  11948. // // if (row.entity.age > 45) {
  11949. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11950. // // }
  11951. // };
  11952. gridApi.core.on.filterChanged($scope, function () {
  11953. var grid = this.grid;
  11954. var filtersData = {
  11955. idx: 0,
  11956. sum: 10,
  11957. "user": {
  11958. "roledata": {
  11959. "rolecode": "roleset"
  11960. },
  11961. "selectType": "1"
  11962. }
  11963. };
  11964. angular.forEach(grid.columns, function (item) {
  11965. if (item.enableFiltering) {
  11966. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  11967. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  11968. if (angular.isUndefined(filtersData['user'])) {
  11969. filtersData['user'] = {};
  11970. }
  11971. filtersData['user'][item.field] = item.filters[0].term;
  11972. }
  11973. }
  11974. });
  11975. $scope.memoryfilterData = filtersData;
  11976. $scope.loadData(filtersData);
  11977. });
  11978. };
  11979. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  11980. // if (row.entity.age > 45) {
  11981. // row.grid.api.selection.selectRow(row.entity); // 选中行
  11982. // }
  11983. // },
  11984. $scope.onDblClick = function (data, event) {
  11985. // $scope.selected.items = data.entity;
  11986. $scope.selectButtonClick(data, event);
  11987. };
  11988. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  11989. // $scope.selected.items = data.entity;
  11990. // })
  11991. // };
  11992. $scope.memoryfilterData = {
  11993. "idx": 0,
  11994. "sum": 10,
  11995. "user": {
  11996. "roledata": {
  11997. "rolecode": "roleset"
  11998. },
  11999. "selectType": "1"
  12000. }
  12001. }
  12002. $scope.loadData = function (filterData) {
  12003. // console.log("filtersData=111" + JSON.stringify(filterData))
  12004. items.fetchItems(filterData, APIService).then(function (data) {
  12005. var myData = Restangular.stripRestangular(data);
  12006. $scope.gridOptions.totalItems = myData.totalNum;
  12007. $scope.myData = myData.list;
  12008. });
  12009. };
  12010. // $scope.title = title;
  12011. $scope.loadData({
  12012. idx: 0,
  12013. sum: 10,
  12014. "user": {
  12015. "roledata": {
  12016. "rolecode": "roleset"
  12017. },
  12018. "selectType": "1"
  12019. }
  12020. });
  12021. $scope.selected = {
  12022. items: {}
  12023. };
  12024. $scope.ok = function () {
  12025. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12026. // onDataCallback($scope.selected.item, parentScope);
  12027. // }
  12028. $modalInstance.close($scope.selected.items);
  12029. };
  12030. $scope.cancel = function () {
  12031. $modalInstance.dismiss('cancel');
  12032. };
  12033. },
  12034. size: size,
  12035. resolve: {
  12036. items: function () {
  12037. return {
  12038. fetchItems: function (filterData, APIService) {
  12039. filterData = filterData || {};
  12040. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12041. filterData = {
  12042. idx: 0,
  12043. sum: 10,
  12044. "user": {
  12045. "roledata": {
  12046. "rolecode": "roleset"
  12047. },
  12048. "selectType": "1"
  12049. }
  12050. };
  12051. }
  12052. return options.templateOptions.fetchItems(filterData, APIService);
  12053. }
  12054. };
  12055. },
  12056. title: function () {
  12057. return options.templateOptions.label;
  12058. },
  12059. Restangular: function () {
  12060. return options.templateOptions.Restangular;
  12061. },
  12062. APIService: function () {
  12063. return options.templateOptions.ApiService;
  12064. },
  12065. onDataCallback: function () {
  12066. return options.templateOptions.callback;
  12067. },
  12068. parentScope: function () {
  12069. return options.templateOptions.that;
  12070. }
  12071. }
  12072. });
  12073. modalInstance.result.then(function (selectedItem) {
  12074. // console.log(selectedItem);
  12075. options.value(selectedItem);
  12076. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12077. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12078. }
  12079. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12080. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12081. }
  12082. }, function () {
  12083. //console.log('Modal dismissed at: ' + new Date());
  12084. });
  12085. }
  12086. }
  12087. };
  12088. },
  12089. controller: ['$scope', function ($scope) {
  12090. $scope.options.templateOptions.that = $scope;
  12091. // $scope.options.model[$scope.options.key] = {}
  12092. }]
  12093. });
  12094. //用户单选控件(dd 单选input带搜索)
  12095. formlyConfigProvider.setType({
  12096. name: "ui-userselectSearch",
  12097. templateUrl: 'assets/views/customform/tpl/ui-userselectSearch.html',
  12098. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12099. defaultOptions: function (options) {
  12100. return {
  12101. templateOptions: {
  12102. openModal: function (size, options, modal) {
  12103. var modalInstance = modal.open({
  12104. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12105. controller: function ($scope, i18nService, $modalInstance, items, title, Restangular, APIService, onDataCallback, parentScope) {
  12106. $scope.langs = i18nService.getAllLangs();
  12107. $scope.lang = 'zh-cn';
  12108. i18nService.setCurrentLang($scope.lang);
  12109. $scope.gridOptions = {};
  12110. $scope.gridOptions.data = 'myData';
  12111. $scope.gridOptions.enableColumnResizing = true;
  12112. $scope.gridOptions.enableFiltering = true;
  12113. $scope.gridOptions.enableGridMenu = false;
  12114. $scope.gridOptions.showGridFooter = true;
  12115. $scope.gridOptions.showColumnFooter = false;
  12116. $scope.gridOptions.fastWatch = true;
  12117. $scope.gridOptions.useExternalFiltering = true;
  12118. $scope.gridOptions.useExternalPagination = true;
  12119. $scope.gridOptions.paginationPageSizes = [10];
  12120. $scope.gridOptions.paginationPageSize = 10;
  12121. $scope.gridOptions.multiSelect = false;
  12122. $scope.gridOptions.rowIdentity = function (row) {
  12123. return row.id;
  12124. };
  12125. $scope.gridOptions.getRowIdentity = function (row) {
  12126. return row.id;
  12127. };
  12128. $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>";
  12129. $scope.gridOptions.columnDefs = [{
  12130. name: 'account',
  12131. displayName: '人员编号',
  12132. width: 120
  12133. },
  12134. {
  12135. name: 'name',
  12136. displayName: '姓名',
  12137. width: 100,
  12138. cellTemplate: '<div>' +
  12139. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  12140. '</div>'
  12141. },
  12142. // {
  12143. // name: 'gender.name',
  12144. // displayName: '性别',
  12145. // width: 80,
  12146. // enableFiltering: false
  12147. // },
  12148. {
  12149. name: 'phone',
  12150. displayName: '电话',
  12151. width: 230,
  12152. enableFiltering: false
  12153. },
  12154. {
  12155. name: 'email',
  12156. displayName: '邮箱',
  12157. width: 180,
  12158. enableFiltering: false
  12159. },
  12160. {
  12161. name: 'dept.dept',
  12162. displayName: '科室',
  12163. width: 130,
  12164. enableFiltering: false
  12165. },
  12166. {
  12167. name: 'taskCount',
  12168. displayName: '处理中事件数',
  12169. enableFiltering: false
  12170. }
  12171. ];
  12172. // $scope.selectButtonClick
  12173. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12174. $scope.gridApi = gridApi;
  12175. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12176. var filtersData = $scope.memoryfilterData;
  12177. filtersData.idx = newPage - 1;
  12178. filtersData.sum = pageSize;
  12179. $scope.loadData(filtersData);
  12180. //console.log(pageSize);
  12181. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12182. });
  12183. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12184. $scope.selected.items = data.entity;
  12185. //console.log(data);
  12186. });
  12187. gridApi.selection.on.rowSelectionChangedBatch($scope, function (data) {
  12188. $scope.selected.items = data.entity;
  12189. //console.log(data);
  12190. });
  12191. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  12192. // // if (row.entity.age > 45) {
  12193. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12194. // // }
  12195. // };
  12196. gridApi.core.on.filterChanged($scope, function () {
  12197. var grid = this.grid;
  12198. var filtersData = {
  12199. idx: 0,
  12200. sum: 10,
  12201. user: {
  12202. roledata: {
  12203. rolecode: "first-line support"
  12204. },
  12205. selectType: "1"
  12206. }
  12207. };
  12208. angular.forEach(grid.columns, function (item) {
  12209. if (item.enableFiltering) {
  12210. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  12211. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12212. if (angular.isUndefined(filtersData['user'])) {
  12213. filtersData['user'] = {};
  12214. }
  12215. filtersData['user'][item.field] = item.filters[0].term;
  12216. }
  12217. }
  12218. });
  12219. $scope.memoryfilterData = filtersData;
  12220. $scope.loadData(filtersData);
  12221. });
  12222. };
  12223. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  12224. // if (row.entity.age > 45) {
  12225. // row.grid.api.selection.selectRow(row.entity); // 选中行
  12226. // }
  12227. // },
  12228. $scope.onDblClick = function (data, event) {
  12229. // $scope.selected.items = data.entity;
  12230. $scope.selectButtonClick(data, event);
  12231. };
  12232. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  12233. // $scope.selected.items = data.entity;
  12234. // })
  12235. // };
  12236. $scope.memoryfilterData = {
  12237. idx: 0,
  12238. sum: 10,
  12239. user: {
  12240. roledata: {
  12241. rolecode: "first-line support"
  12242. },
  12243. selectType: "1"
  12244. }
  12245. }
  12246. $scope.loadData = function (filterData) {
  12247. // console.log("filtersData=111" + JSON.stringify(filterData))
  12248. items.fetchItems(filterData, APIService).then(function (data) {
  12249. var myData = Restangular.stripRestangular(data);
  12250. $scope.gridOptions.totalItems = myData.totalNum;
  12251. $scope.myData = myData.list;
  12252. });
  12253. };
  12254. $scope.title = title;
  12255. $scope.loadData({
  12256. idx: 0,
  12257. sum: 10,
  12258. user: {
  12259. roledata: {
  12260. rolecode: "first-line support"
  12261. },
  12262. selectType: "1"
  12263. }
  12264. });
  12265. $scope.selected = {
  12266. items: {}
  12267. };
  12268. $scope.ok = function () {
  12269. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  12270. // onDataCallback($scope.selected.item, parentScope);
  12271. // }
  12272. $modalInstance.close($scope.selected.items);
  12273. };
  12274. $scope.cancel = function () {
  12275. $modalInstance.dismiss('cancel');
  12276. };
  12277. },
  12278. size: size,
  12279. resolve: {
  12280. items: function () {
  12281. return {
  12282. fetchItems: function (filterData, APIService) {
  12283. filterData = filterData || {};
  12284. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12285. filterData = {
  12286. idx: 0,
  12287. sum: 10,
  12288. user: {
  12289. roledata: {
  12290. rolecode: "first-line support"
  12291. },
  12292. selectType: "1"
  12293. }
  12294. };
  12295. }
  12296. return options.templateOptions.fetchItems(filterData, APIService);
  12297. }
  12298. };
  12299. },
  12300. title: function () {
  12301. return options.templateOptions.label;
  12302. },
  12303. Restangular: function () {
  12304. return options.templateOptions.Restangular;
  12305. },
  12306. APIService: function () {
  12307. return options.templateOptions.ApiService;
  12308. },
  12309. onDataCallback: function () {
  12310. return options.templateOptions.callback;
  12311. },
  12312. parentScope: function () {
  12313. return options.templateOptions.that;
  12314. }
  12315. }
  12316. });
  12317. modalInstance.result.then(function (selectedItem) {
  12318. // console.log(selectedItem);
  12319. options.value(selectedItem);
  12320. if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  12321. options.templateOptions.callback(selectedItem, options.templateOptions.that);
  12322. }
  12323. if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  12324. options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  12325. }
  12326. }, function () {
  12327. //console.log('Modal dismissed at: ' + new Date());
  12328. });
  12329. }
  12330. }
  12331. };
  12332. },
  12333. controller: ['$scope', function ($scope) {
  12334. $scope.options.templateOptions.that = $scope;
  12335. }]
  12336. });
  12337. //用户多选控件
  12338. formlyConfigProvider.setType({
  12339. name: "ui-multiuserselect",
  12340. templateUrl: 'assets/views/customform/tpl/ui-multiuserselect.html',
  12341. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12342. defaultOptions: function (options) {
  12343. return {
  12344. templateOptions: {
  12345. openModal: function (size, options, modal, model) {
  12346. var modalInstance = modal.open({
  12347. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12348. controller: function ($scope, $modalInstance, i18nService, $timeout, items, title, Restangular, APIService, selectItems) {
  12349. $scope.langs = i18nService.getAllLangs();
  12350. $scope.lang = 'zh-cn';
  12351. i18nService.setCurrentLang($scope.lang);
  12352. $scope.gridOptions = {};
  12353. $scope.gridOptions.data = 'myData';
  12354. $scope.gridOptions.enableColumnResizing = true;
  12355. $scope.gridOptions.enableFiltering = true;
  12356. $scope.gridOptions.enableGridMenu = true;
  12357. $scope.gridOptions.showGridFooter = true;
  12358. $scope.gridOptions.showColumnFooter = true;
  12359. $scope.gridOptions.fastWatch = true;
  12360. $scope.gridOptions.useExternalFiltering = true;
  12361. $scope.gridOptions.useExternalPagination = true;
  12362. $scope.gridOptions.paginationPageSizes = [10];
  12363. $scope.gridOptions.paginationPageSize = 10;
  12364. $scope.gridOptions.multiSelect = true;
  12365. $scope.gridOptions.rowIdentity = function (row) {
  12366. return row.id;
  12367. };
  12368. $scope.gridOptions.getRowIdentity = function (row) {
  12369. return row.id;
  12370. };
  12371. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12372. $scope.gridOptions.columnDefs = [
  12373. // { name:'id', width:80, enableFiltering:false},
  12374. {
  12375. name: 'account',
  12376. displayName: '账号',
  12377. width: 140
  12378. },
  12379. {
  12380. name: 'name',
  12381. displayName: '名称',
  12382. width: 100
  12383. },
  12384. {
  12385. name: 'gender.name',
  12386. displayName: '性别',
  12387. width: 140,
  12388. enableFiltering: false
  12389. },
  12390. {
  12391. name: 'phone',
  12392. displayName: '电话',
  12393. width: 100,
  12394. enableFiltering: false
  12395. },
  12396. {
  12397. name: 'email',
  12398. displayName: '邮件',
  12399. width: 100,
  12400. enableFiltering: false
  12401. },
  12402. {
  12403. name: 'dept.dept',
  12404. displayName: '科室',
  12405. width: 100,
  12406. enableFiltering: false
  12407. },
  12408. {
  12409. name: 'group[0].groupName',
  12410. displayName: '职位',
  12411. width: 100,
  12412. enableFiltering: false
  12413. }
  12414. ];
  12415. $scope.selected = {
  12416. items: selectItems
  12417. };
  12418. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12419. $scope.gridApi = gridApi;
  12420. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12421. var filtersData = $scope.memoryfilterData;
  12422. filtersData.idx = newPage - 1;
  12423. filtersData.sum = pageSize;
  12424. $scope.loadData(filtersData);
  12425. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  12426. });
  12427. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  12428. var j = 0;
  12429. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  12430. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  12431. j++;
  12432. break;
  12433. }
  12434. }
  12435. if (j == 1) {
  12436. scope.grid.appScope.selected.items.splice(i, 1);
  12437. } else {
  12438. scope.grid.appScope.selected.items.push(scope.entity)
  12439. for (var i = 0; i < scope.grid.appScope.selected.items.length; i++) {
  12440. for (var z = 0; z < scope.grid.appScope.selected.items.length; z++) {
  12441. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  12442. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  12443. if (angular.isDefined(scope.grid.appScope.selected.items) && scope.grid.appScope.selected.items[i].id == scope.grid.appScope.selected.items[z].id && i != z) {
  12444. scope.grid.appScope.selected.items.splice(i, 1);
  12445. }
  12446. }
  12447. }
  12448. }
  12449. });
  12450. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  12451. // $scope.grid.appScope.selected.items.push($scope.entity);
  12452. // });
  12453. gridApi.core.on.filterChanged($scope, function () {
  12454. var grid = this.grid;
  12455. var filtersData = {
  12456. idx: 0,
  12457. sum: 10,
  12458. "user": {
  12459. "roledata": {
  12460. "rolecode": options.model.currentRole
  12461. },
  12462. "selectType": "1"
  12463. }
  12464. };
  12465. angular.forEach(grid.columns, function (item) {
  12466. if (item.enableFiltering) {
  12467. //console.log("filtersData="+JSON.stringify(filtersData))
  12468. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12469. if (angular.isUndefined(filtersData['user'])) {
  12470. filtersData['user'] = {};
  12471. }
  12472. filtersData['user'][item.field] = item.filters[0].term;
  12473. }
  12474. }
  12475. });
  12476. $scope.memoryfilterData = filtersData;
  12477. $scope.loadData(filtersData);
  12478. });
  12479. };
  12480. if (!options.model) {
  12481. var mouse = {
  12482. "model": {
  12483. "currentRole": ""
  12484. }
  12485. };
  12486. angular.extend(options, mouse);
  12487. }
  12488. $scope.memoryfilterData = {
  12489. "idx": 0,
  12490. "sum": 10,
  12491. "user": {
  12492. "roledata": {
  12493. "rolecode": options.model.currentRole
  12494. },
  12495. "selectType": "1"
  12496. }
  12497. }
  12498. $scope.loadData = function (filterData) {
  12499. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  12500. items.fetchItems(filterData, APIService).then(function (data) {
  12501. var myData = Restangular.stripRestangular(data);
  12502. $scope.gridOptions.totalItems = myData.totalNum;
  12503. $scope.myData = myData.list;
  12504. //console.log($scope.gridOptions.pagination.getTotalPages());
  12505. // if($scope.selected.items){
  12506. // angular.forEach($scope.selected.items,function(selectItem){
  12507. // $scope.gridApi.selection.selectRow(selectItem);
  12508. // });
  12509. // }
  12510. });
  12511. };
  12512. // $scope.title = title;
  12513. $scope.loadData({
  12514. idx: 0,
  12515. sum: 10,
  12516. "user": {
  12517. "roledata": {
  12518. "rolecode": options.model.currentRole
  12519. },
  12520. "selectType": "1"
  12521. }
  12522. });
  12523. // $timeout(function(){
  12524. // if($scope.selected.items){
  12525. // angular.forEach($scope.selected.items,function(selectItem){
  12526. // $scope.gridApi.selection.selectRow(selectItem);
  12527. // });
  12528. // }
  12529. // },2000)
  12530. $scope.ok = function () {
  12531. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  12532. $modalInstance.close($scope.selected.items);
  12533. };
  12534. $scope.cancel = function () {
  12535. $modalInstance.dismiss('cancel');
  12536. };
  12537. },
  12538. size: size,
  12539. resolve: {
  12540. items: function () {
  12541. return {
  12542. fetchItems: function (filterData, APIService) {
  12543. filterData = filterData || {};
  12544. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12545. filterData = {
  12546. idx: 0,
  12547. sum: 10,
  12548. "user": {
  12549. "roledata": {
  12550. "rolecode": options.model.incident.currentRole
  12551. },
  12552. "selectType": "1"
  12553. }
  12554. };
  12555. }
  12556. return options.templateOptions.fetchItems(filterData, APIService);
  12557. }
  12558. };
  12559. },
  12560. title: function () {
  12561. return options.templateOptions.modalTitle;
  12562. },
  12563. Restangular: function () {
  12564. return options.templateOptions.Restangular;
  12565. },
  12566. APIService: function () {
  12567. return options.templateOptions.ApiService;
  12568. },
  12569. selectItems: function () {
  12570. return model || [];
  12571. }
  12572. }
  12573. });
  12574. modalInstance.result.then(function (selectedItem) {
  12575. options.value(selectedItem);
  12576. options.formControl.$validate();
  12577. }, function () {
  12578. //console.log('Modal dismissed at: ' + new Date());
  12579. });
  12580. }
  12581. },
  12582. validators: {
  12583. required: {
  12584. expression: function (viewValue, modelValue) {
  12585. var value = modelValue || viewValue;
  12586. return value.length >= 1;
  12587. }
  12588. }
  12589. }
  12590. };
  12591. },
  12592. controller: ['$scope', function ($scope) {
  12593. $scope.model[$scope.options.key] = [];
  12594. $scope.remove = function (itemId) {
  12595. angular.forEach($scope.model[$scope.options.key], function (entry, index) {
  12596. if (entry.id == itemId) {
  12597. $scope.model[$scope.options.key].splice(index, 1);
  12598. // console.log($scope.options.formControl)
  12599. $scope.options.formControl.$validate();
  12600. } else {
  12601. }
  12602. });
  12603. }
  12604. }]
  12605. });
  12606. //用户多选控件-字符串展示
  12607. formlyConfigProvider.setType({
  12608. name: 'ui-stringuserselect',
  12609. extends: 'input',
  12610. templateUrl: 'assets/views/customform/tpl/ui-stringuserselect.html',
  12611. defaultOptions: function (options) {
  12612. return {
  12613. templateOptions: {
  12614. translate: '',
  12615. refreshDelay: 0
  12616. }
  12617. }
  12618. },
  12619. controller: ['$scope', function ($scope) {
  12620. var keydata = "";
  12621. if (angular.isArray($scope.model)) {
  12622. angular.forEach($scope.model, function (item) {
  12623. keydata = keydata + "," + item.name;
  12624. })
  12625. }
  12626. // $scope.model[$scope.options.key] = [];
  12627. }]
  12628. });
  12629. //重复事件
  12630. formlyConfigProvider.setType({
  12631. name: "ui-incidentmodelselect",
  12632. extends: 'input',
  12633. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  12634. defaultOptions: function (options) {
  12635. return {
  12636. templateOptions: {
  12637. openModal: function (size, options, modal) {
  12638. var modalInstance = modal.open({
  12639. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  12640. controller: function ($scope, $rootScope, $modalInstance, items, title, Restangular, APIService, i18nService, api_configure_data, api_user_data, api_bpm_data) {
  12641. $scope.langs = i18nService.getAllLangs();
  12642. $scope.lang = 'zh-cn';
  12643. i18nService.setCurrentLang($scope.lang);
  12644. $scope.gridOptions = {};
  12645. $scope.gridOptions.data = 'myData';
  12646. $scope.gridOptions.enableColumnResizing = true;
  12647. $scope.gridOptions.enableFiltering = true;
  12648. $scope.gridOptions.enableGridMenu = false;
  12649. $scope.gridOptions.enableRowSelection = true;
  12650. $scope.gridOptions.showGridFooter = true;
  12651. $scope.gridOptions.showColumnFooter = false;
  12652. $scope.gridOptions.fastWatch = true;
  12653. $scope.gridOptions.useExternalFiltering = true;
  12654. $scope.gridOptions.useExternalPagination = true;
  12655. $scope.gridOptions.paginationPageSizes = [10];
  12656. $scope.gridOptions.paginationPageSize = 10;
  12657. $scope.gridOptions.multiSelect = false;
  12658. var mun = $scope.gridOptions.paginationPageSize;
  12659. $scope.gridOptions.rowIdentity = function (row) {
  12660. return row.id;
  12661. };
  12662. $scope.gridOptions.getRowIdentity = function (row) {
  12663. return row.id;
  12664. };
  12665. $scope.gridOptions.columnDefs = items.columnDefs();
  12666. $scope.transferTime = function (time) {
  12667. return moment(time).format('YYYY-MM-DD HH:mm');
  12668. }
  12669. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12670. $scope.gridApi = gridApi;
  12671. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  12672. // console.log(newPage);
  12673. // console.log(pageSize);
  12674. $scope.loadData({
  12675. "idx": newPage - 1,
  12676. "sum": pageSize
  12677. });
  12678. });
  12679. gridApi.core.on.filterChanged($scope, function () {
  12680. var grid = this.grid;
  12681. var filtersData = {
  12682. idx: 0,
  12683. sum: 100
  12684. };
  12685. angular.forEach(grid.columns, function (item) {
  12686. if (item.enableFiltering) {
  12687. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  12688. // console.log("filtersData="+JSON.stringify(filtersData))
  12689. if (angular.isUndefined(filtersData['incident'])) {
  12690. filtersData['incident'] = {};
  12691. }
  12692. filtersData['incident'][item.field] = item.filters[0].term;
  12693. if (angular.isUndefined(filtersData['problem'])) {
  12694. filtersData['problem'] = {};
  12695. }
  12696. filtersData['problem'][item.field] = item.filters[0].term;
  12697. if (angular.isUndefined(filtersData['change'])) {
  12698. filtersData['change'] = {};
  12699. }
  12700. filtersData['change'][item.field] = item.filters[0].term;
  12701. if (angular.isUndefined(filtersData['release'])) {
  12702. filtersData['release'] = {};
  12703. }
  12704. filtersData['release'][item.field] = item.filters[0].term;
  12705. }
  12706. }
  12707. });
  12708. $scope.loadData(filtersData);
  12709. });
  12710. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12711. $scope.selected.item = data.entity;
  12712. //console.log(data);
  12713. });
  12714. };
  12715. //资产
  12716. $scope.cmdb = {}
  12717. //资产状态
  12718. $scope.state_data = [{
  12719. "name": "全部状态",
  12720. "value": ""
  12721. },
  12722. {
  12723. "name": "在库",
  12724. "value": "1"
  12725. },
  12726. {
  12727. "name": "在线",
  12728. "value": "2"
  12729. },
  12730. {
  12731. "name": "借出",
  12732. "value": "3"
  12733. },
  12734. {
  12735. "name": "报修",
  12736. "value": "4"
  12737. },
  12738. {
  12739. "name": "报废",
  12740. "value": "5"
  12741. },
  12742. {
  12743. "name": "备用",
  12744. "value": "6"
  12745. },
  12746. ]
  12747. //资产类型
  12748. $scope.wt_zcfl = function () {
  12749. api_configure_data.fetchDataList('ciclassify', {
  12750. idx: 0,
  12751. sum: 100
  12752. }).then(function (data) {
  12753. console.log(data);
  12754. // $scope.wt_zclx = data.list;
  12755. console.log(data);
  12756. $scope.wtData = []
  12757. if (data.status == 200) {
  12758. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  12759. var root = null; //Initially set our loop to null
  12760. var parentNode = null;
  12761. //loop over data
  12762. // $scope.wtData=data.list;
  12763. data = data.list;
  12764. //知识库分类数据三级处理
  12765. for (var i = 0; i < data.length; i++) {
  12766. // console.log(data[i])
  12767. var datum = data[i];
  12768. //each node will have children, so let's give it a "children" poperty
  12769. // console.log(datum);
  12770. datum.children = [];
  12771. if (!datum.parent) {
  12772. $scope.wtData.push(datum);
  12773. // console.log($scope.wtData)
  12774. } else {
  12775. if ($scope.wtData[0]) {
  12776. if ($scope.wtData[0].id == datum.parent.id) {
  12777. $scope.wtData[0].children.push(datum);
  12778. }
  12779. for (var j = 0; j < $scope.wtData[0].children.length; j++) {
  12780. if ($scope.wtData[0].children[j].id == datum.parent.id) {
  12781. $scope.wtData[0].children[j].children.push(datum);
  12782. }
  12783. };
  12784. }
  12785. if ($scope.wtData[1]) {
  12786. if ($scope.wtData[1].id == datum.parent.id) {
  12787. $scope.wtData[1].children.push(datum);
  12788. }
  12789. for (var j = 0; j < $scope.wtData[1].children.length; j++) {
  12790. if ($scope.wtData[1].children[j].id == datum.parent.id) {
  12791. $scope.wtData[1].children[j].children.push(datum);
  12792. }
  12793. };
  12794. }
  12795. if ($scope.wtData[2]) {
  12796. if ($scope.wtData[2].id == datum.parent.id) {
  12797. $scope.wtData[2].children.push(datum);
  12798. }
  12799. for (var j = 0; j < $scope.wtData[2].children.length; j++) {
  12800. if ($scope.wtData[2].children[j].id == datum.parent.id) {
  12801. $scope.wtData[2].children[j].children.push(datum);
  12802. }
  12803. };
  12804. }
  12805. }
  12806. // console.log($scope.wtData)
  12807. idToNodeMap[datum.id] = datum;
  12808. root = datum;
  12809. // treeMap[datum.id] = root;
  12810. }
  12811. }
  12812. });
  12813. }
  12814. $scope.wt_zcfl();
  12815. //事件
  12816. //受理人,处理人
  12817. $scope.searchkeys = {};
  12818. var fieldata = {
  12819. "idx": 0,
  12820. "sum": 100,
  12821. "flag": -1
  12822. };
  12823. getUser(fieldata, 3);
  12824. function getUser(fieldatas, it) {
  12825. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  12826. if (it == 1) {
  12827. $scope.acceptUser = data.list;
  12828. } else if (it == 2) {
  12829. $scope.handlingPersonnelUser = data.list;
  12830. } else if (it == 3) {
  12831. $scope.acceptUser = data.list;
  12832. $scope.handlingPersonnelUser = data.list;
  12833. }
  12834. });
  12835. }
  12836. //状态
  12837. $scope.othcode = {};
  12838. api_bpm_data.fetchDataList('incidentstatus', {
  12839. "idx": 0,
  12840. "sum": 100
  12841. }).then(function (response) {
  12842. if (response) {
  12843. if (response.status = 200) {
  12844. $scope.state = response.list;
  12845. }
  12846. }
  12847. })
  12848. var defaultFilterData = {
  12849. "assignee": $rootScope.user.id,
  12850. "searchType": "todo",
  12851. "idx": 0,
  12852. "sum": mun
  12853. };
  12854. var defaultFilterData1 = {
  12855. // "searchType": "todo",
  12856. "idx": 0,
  12857. "sum": mun
  12858. };
  12859. //搜索
  12860. $scope.chiceIncident = function (parameters, item, stateid) {
  12861. console.log(item, stateid);
  12862. console.log($scope);
  12863. if ($scope.title == '关联资产编号') {
  12864. // alert('222222222222');
  12865. var fildata = defaultFilterData1;
  12866. $scope.gridOptions.paginationCurrentPage = 1;
  12867. var transitiondata = angular.copy(item);
  12868. angular.extend(fildata, transitiondata);
  12869. if (fildata.hw_state) {
  12870. fildata.hw_state = fildata.hw_state.name;
  12871. }
  12872. if (fildata.sign) {
  12873. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  12874. fildata.sign = fildata.sign.split(';');
  12875. fildata.sign = fildata.sign.join('');
  12876. fildata.sign = fildata.sign.toLowerCase()
  12877. }
  12878. if (fildata.keys) {
  12879. fildata['searchCriteria'] = 'uuid';
  12880. }
  12881. console.log(fildata);
  12882. $scope.loadData(fildata);
  12883. }
  12884. if ($scope.title == '关联事件工单') {
  12885. // alert('3333333333333333')
  12886. if (stateid && stateid.code) {
  12887. item.statusId = stateid.code;
  12888. }
  12889. var fildata = defaultFilterData;
  12890. // $scope.memoryfilterData = fildata;
  12891. if (!fildata.incident) {
  12892. fildata['incident'] = {};
  12893. }
  12894. $scope.gridOptions.paginationCurrentPage = 1;
  12895. var transitiondata = angular.copy(item);
  12896. angular.extend(fildata.incident, transitiondata);
  12897. console.log(fildata)
  12898. // $scope.loadData(fildata);
  12899. api_bpm_data.fetchDataList('incident', fildata).then(function (data) {
  12900. console.log(data)
  12901. if (data) {
  12902. $scope.myData = data.list;
  12903. $scope.gridOptions.totalItems = data.totalNum;
  12904. }
  12905. })
  12906. }
  12907. }
  12908. //重置
  12909. $scope.replacement = function (parameters, searchkeys, othcode) {
  12910. // console.log(parameters, searchkeys, othcode);
  12911. delete (defaultFilterData.incident);
  12912. console.log(defaultFilterData)
  12913. $scope.parameters = null;
  12914. $scope.searchkeys = {};
  12915. $scope.othcode = {};
  12916. $scope.wt_zcfl();
  12917. }
  12918. $scope.loadData = function (filterData) {
  12919. items.fetchItems(filterData, APIService, $rootScope).then(function (data) {
  12920. var myData = Restangular.stripRestangular(data);
  12921. if (myData.data && myData.data.node) {
  12922. $scope.gridOptions.totalItems = myData.total;
  12923. $scope.myData = myData.data.node;
  12924. } else {
  12925. if (myData.resultCount) {
  12926. $scope.gridOptions['totalItems'] = myData.resultCount;
  12927. } else {
  12928. $scope.gridOptions.totalItems = myData.totalNum;
  12929. }
  12930. if (myData.list) {
  12931. $scope.myData = myData.list;
  12932. } else {
  12933. $scope.myData = myData.data;
  12934. }
  12935. }
  12936. });
  12937. };
  12938. $scope.title = title;
  12939. $scope.loadData({
  12940. idx: 0,
  12941. sum: 10
  12942. });
  12943. $scope.selected = {
  12944. item: {}
  12945. };
  12946. $scope.ok = function () {
  12947. //console.log($scope.selected.item);
  12948. $modalInstance.close($scope.selected.item);
  12949. };
  12950. $scope.cancel = function () {
  12951. $modalInstance.dismiss('cancel');
  12952. };
  12953. },
  12954. size: size,
  12955. resolve: {
  12956. items: function () {
  12957. return {
  12958. fetchItems: function (filterData, APIService, $rootScope) {
  12959. filterData = filterData || {};
  12960. // if(!filterData.idx){
  12961. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  12962. filterData = {
  12963. idx: 0,
  12964. sum: 10
  12965. };
  12966. }
  12967. return options.templateOptions.fetchItems(filterData, APIService, $rootScope);
  12968. },
  12969. columnDefs: function () {
  12970. return options.templateOptions.columnDefs;
  12971. }
  12972. };
  12973. },
  12974. title: function () {
  12975. return options.templateOptions.modalTitle;
  12976. },
  12977. Restangular: function () {
  12978. return options.templateOptions.Restangular;
  12979. },
  12980. APIService: function () {
  12981. return options.templateOptions.ApiService;
  12982. }
  12983. }
  12984. });
  12985. modalInstance.result.then(function (selectedItem) {
  12986. var selectitem = {
  12987. title: selectedItem.title,
  12988. description: selectedItem.description
  12989. }
  12990. if (options.key == "chuku") {
  12991. if (selectedItem.assets) {
  12992. $scope.$parent.$parent.$parent.model.applicationForm.assets = selectedItem.assets;
  12993. }
  12994. if (selectedItem.consumables) {
  12995. $scope.$parent.$parent.$parent.model.applicationForm.consumables = selectedItem.consumables;
  12996. }
  12997. angular.extend($scope.$parent.$parent.$parent.model, selectitem);
  12998. options.value(selectedItem);
  12999. // options.model.consumables = JSON.parse(consumables);
  13000. } else if (options.templateOptions.pkey == "change") {
  13001. console.log(options)
  13002. angular.extend(options.model);
  13003. options.value(selectedItem);
  13004. } else if (options.key == "cmdbCode") {
  13005. var zc_selectitem = selectedItem.uuid;
  13006. // angular.extend(options.model,zc_selectitem);
  13007. options.model.cmdbCode = zc_selectitem;
  13008. // angular.extend(options.model,zc_selectitem);
  13009. // options.templateOptions.displayName=zc_selectitem;
  13010. options.value(selectedItem);
  13011. console.log(options.model)
  13012. } else {
  13013. angular.extend(options.model, selectitem);
  13014. options.value(selectedItem);
  13015. }
  13016. }, function () {
  13017. //console.log('Modal dismissed at: ' + new Date());
  13018. });
  13019. }
  13020. }
  13021. };
  13022. }
  13023. });
  13024. //选项选择控件
  13025. formlyConfigProvider.setType({
  13026. name: "ui-modelselect",
  13027. extends: 'input',
  13028. templateUrl: 'assets/views/customform/tpl/ui-modelselect.html',
  13029. defaultOptions: function (options) {
  13030. return {
  13031. templateOptions: {
  13032. openModal: function (size, options, modal) {
  13033. var modalInstance = modal.open({
  13034. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  13035. controller: function ($scope, $modalInstance, items, title, Restangular, APIService, i18nService) {
  13036. $scope.langs = i18nService.getAllLangs();
  13037. $scope.lang = 'zh-cn';
  13038. i18nService.setCurrentLang($scope.lang);
  13039. $scope.gridOptions = {};
  13040. $scope.gridOptions.data = 'myData';
  13041. $scope.gridOptions.enableColumnResizing = true;
  13042. $scope.gridOptions.enableFiltering = true;
  13043. $scope.gridOptions.enableGridMenu = false;
  13044. $scope.gridOptions.enableRowSelection = true;
  13045. $scope.gridOptions.showGridFooter = true;
  13046. $scope.gridOptions.showColumnFooter = true;
  13047. $scope.gridOptions.fastWatch = true;
  13048. $scope.gridOptions.useExternalFiltering = true;
  13049. $scope.gridOptions.useExternalPagination = true;
  13050. $scope.gridOptions.paginationPageSizes = [10];
  13051. $scope.gridOptions.paginationPageSize = 10;
  13052. $scope.gridOptions.multiSelect = false;
  13053. $scope.gridOptions.rowIdentity = function (row) {
  13054. return row.id;
  13055. };
  13056. $scope.gridOptions.getRowIdentity = function (row) {
  13057. return row.id;
  13058. };
  13059. $scope.gridOptions.columnDefs = items.columnDefs();
  13060. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13061. $scope.gridApi = gridApi;
  13062. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  13063. // console.log(newPage);
  13064. // console.log(pageSize);
  13065. $scope.loadData({
  13066. "idx": newPage - 1,
  13067. "sum": pageSize
  13068. });
  13069. });
  13070. gridApi.core.on.filterChanged($scope, function () {
  13071. var grid = this.grid;
  13072. var filtersData = {
  13073. idx: 0,
  13074. sum: 10
  13075. };
  13076. angular.forEach(grid.columns, function (item) {
  13077. if (item.enableFiltering) {
  13078. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  13079. // console.log("filtersData="+JSON.stringify(filtersData))
  13080. if (angular.isUndefined(filtersData['incident'])) {
  13081. filtersData['incident'] = {};
  13082. }
  13083. filtersData['incident'][item.field] = item.filters[0].term;
  13084. if (angular.isUndefined(filtersData['problem'])) {
  13085. filtersData['problem'] = {};
  13086. }
  13087. filtersData['problem'][item.field] = item.filters[0].term;
  13088. if (angular.isUndefined(filtersData['change'])) {
  13089. filtersData['change'] = {};
  13090. }
  13091. filtersData['change'][item.field] = item.filters[0].term;
  13092. if (angular.isUndefined(filtersData['release'])) {
  13093. filtersData['release'] = {};
  13094. }
  13095. filtersData['release'][item.field] = item.filters[0].term;
  13096. }
  13097. }
  13098. });
  13099. $scope.loadData(filtersData);
  13100. });
  13101. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  13102. $scope.selected.item = data.entity;
  13103. //console.log(data);
  13104. });
  13105. };
  13106. $scope.loadData = function (filterData) {
  13107. items.fetchItems(filterData, APIService).then(function (data) {
  13108. var myData = Restangular.stripRestangular(data);
  13109. $scope.gridOptions.totalItems = myData.totalNum;
  13110. $scope.myData = myData.list;
  13111. });
  13112. };
  13113. $scope.title = title;
  13114. $scope.loadData({
  13115. idx: 0,
  13116. sum: 10
  13117. });
  13118. $scope.selected = {
  13119. item: {}
  13120. };
  13121. $scope.ok = function () {
  13122. if ($scope.selected.item.scheduleOrder) {
  13123. $scope.selected.item.descriptionData = "日期:" + $scope.selected.item.watchTime + ";" + "班次:" + $scope.selected.item.scheduleOrder.description + ";" + "值班人:" + $scope.selected.item.scheduleOrder.users[0].name
  13124. }
  13125. //console.log($scope.selected.item);
  13126. $modalInstance.close($scope.selected.item);
  13127. };
  13128. $scope.cancel = function () {
  13129. $modalInstance.dismiss('cancel');
  13130. };
  13131. },
  13132. size: size,
  13133. resolve: {
  13134. items: function () {
  13135. return {
  13136. fetchItems: function (filterData, APIService) {
  13137. filterData = filterData || {};
  13138. // if(!filterData.idx){
  13139. if (angular.isDefined(filterData.idx) && filterData.idx == null) {
  13140. filterData = {
  13141. idx: 0,
  13142. sum: 10
  13143. };
  13144. }
  13145. return options.templateOptions.fetchItems(filterData, APIService, options);
  13146. },
  13147. columnDefs: function () {
  13148. return options.templateOptions.columnDefs;
  13149. }
  13150. };
  13151. },
  13152. title: function () {
  13153. return options.templateOptions.modalTitle;
  13154. },
  13155. Restangular: function () {
  13156. return options.templateOptions.Restangular;
  13157. },
  13158. APIService: function () {
  13159. return options.templateOptions.ApiService;
  13160. }
  13161. }
  13162. });
  13163. modalInstance.result.then(function (selectedItem) {
  13164. options.value(selectedItem);
  13165. }, function () {
  13166. //console.log('Modal dismissed at: ' + new Date());
  13167. });
  13168. }
  13169. }
  13170. };
  13171. }
  13172. });
  13173. formlyConfigProvider.setType({
  13174. name: 'ui-requestform',
  13175. extends: 'input',
  13176. templateUrl: 'assets/views/customform/tpl/ui-requestform.html',
  13177. controller: ['$scope', function ($scope) {
  13178. setTimeout(function () {
  13179. var filterData = {
  13180. "idx": 0,
  13181. "sum": 5,
  13182. "incident": {
  13183. "requester": {
  13184. "id": ""
  13185. }
  13186. }
  13187. }
  13188. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, filterData).then(function (result) {
  13189. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13190. });
  13191. }, 1000);
  13192. }]
  13193. });
  13194. //报修图片展示
  13195. formlyConfigProvider.setType({
  13196. name: 'ui-repair-photos',
  13197. // extends: 'label',
  13198. templateUrl: 'assets/views/customform/tpl/ui-repair-photos.html',
  13199. controller: ['$scope', 'api_wechatfile', '$stateParams', function ($scope, api_wechatfile, $stateParams) {
  13200. console.log($scope);
  13201. $scope.fileUrls = [];
  13202. if ($scope.model.wxFile) {
  13203. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.incident.id).then(function (res) {
  13204. $scope.fileUrls = res.data
  13205. })
  13206. }
  13207. console.log($stateParams);
  13208. if ($stateParams && $stateParams.model && JSON.parse($stateParams.model) && JSON.parse($stateParams.model).model && JSON.parse($stateParams.model).model.flow) {
  13209. api_wechatfile.listAttachment('wechatRequesterIncident', JSON.parse($stateParams.model).model.flow).then(function (res) {
  13210. $scope.fileUrls = res.data
  13211. })
  13212. }
  13213. if ($scope.model.flow) {
  13214. api_wechatfile.listAttachment('wechatRequesterIncident', $scope.model.flow).then(function (res) {
  13215. $scope.fileUrls = res.data
  13216. })
  13217. }
  13218. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13219. // // setTimeout(function () {
  13220. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13221. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13222. // // if (modelData.status == 200) {
  13223. // // $scope.model[$scope.options.key] = modelData.data;
  13224. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  13225. // // }
  13226. // // });
  13227. // // }, 1000);
  13228. // }
  13229. $scope.showBigImg = false;
  13230. $scope.showBigImgCli = function (data) {
  13231. $scope.showBigImg = true;
  13232. $scope.bigImgUrl = data
  13233. }
  13234. $scope.closeBigImg = function () {
  13235. $scope.showBigImg = false
  13236. }
  13237. }]
  13238. });
  13239. //图片展示
  13240. formlyConfigProvider.setType({
  13241. name: 'ui-showImgs',
  13242. templateUrl: 'assets/views/customform/tpl/ui-showImgs.html',
  13243. defaultOptions: function (options) {
  13244. return {
  13245. templateOptions: {
  13246. refresh: function (APIService, processInstanceId, data) {
  13247. return APIService.listAttachments(processInstanceId);
  13248. },
  13249. downloadUri: function (APIService, contentId) {
  13250. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13251. },
  13252. view: function (APIService, contentId) {
  13253. return APIService.attachmentsPreviewUrl(contentId);
  13254. },
  13255. download: function (APIService, contentId, item) {
  13256. var item = {
  13257. 'url': APIService.download(contentId),
  13258. 'headers': headers
  13259. };
  13260. return item;
  13261. },
  13262. refreshDelay: 0
  13263. }
  13264. };
  13265. },
  13266. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13267. var _refreshDelayPromise;
  13268. /**
  13269. * refresh
  13270. */
  13271. $scope._refresh = function (refreshAttr) {
  13272. $scope.attachments = [];
  13273. if (refreshAttr !== undefined) {
  13274. if (_refreshDelayPromise) {
  13275. $timeout.cancel(_refreshDelayPromise);
  13276. }
  13277. _refreshDelayPromise = $timeout(function () {
  13278. // 暂存附件
  13279. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13280. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13281. $scope.options.templateOptions.processInstanceId, {
  13282. 'idx': 0,
  13283. 'sum': 1000
  13284. }).then(function (response) {
  13285. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13286. if (myData) {
  13287. for (var i = 0; i < myData.data.length; i++) {
  13288. $scope.attachments.push(myData.data[i]);
  13289. }
  13290. };
  13291. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13292. $scope.$parent.$parent.$parent.model.save_fileId, {
  13293. 'idx': 0,
  13294. 'sum': 1000
  13295. }).then(function (response2) {
  13296. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13297. if (myData2) {
  13298. for (var i = 0; i < myData2.data.length; i++) {
  13299. $scope.attachments.push(myData2.data[i]);
  13300. }
  13301. };
  13302. console.log($scope.attachments)
  13303. });
  13304. });
  13305. // 正常附件
  13306. } else {
  13307. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13308. $scope.options.templateOptions.processInstanceId, {
  13309. 'idx': 0,
  13310. 'sum': 1000
  13311. }).then(function (response) {
  13312. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13313. if (myData) {
  13314. $scope.attachments = [];
  13315. $scope.imgs = []
  13316. myData.data.forEach(e => {
  13317. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13318. $scope.imgs.push(e)
  13319. }
  13320. })
  13321. $scope.imgs = $scope.imgs.splice(0, 3);
  13322. console.log($scope.imgs)
  13323. }
  13324. });
  13325. }
  13326. }, $scope.options.templateOptions.refreshDelay);
  13327. }
  13328. }
  13329. $scope._refresh({});
  13330. // $scope.attachments = $scope.model[$scope.options.key]
  13331. // 预览
  13332. $scope.preview = function (url, idx) {
  13333. var title = $scope.imgs[idx].title
  13334. $modal.open({
  13335. backdrop: false,
  13336. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13337. controller: function ($scope, scope, $modalInstance) {
  13338. $scope.title = title;
  13339. $scope.imageurl = url;
  13340. $scope.cancel = function () {
  13341. $modalInstance.dismiss('cancel');
  13342. }
  13343. },
  13344. resolve: {
  13345. scope: function () {
  13346. return $scope;
  13347. }
  13348. }
  13349. });
  13350. }
  13351. }]
  13352. });
  13353. //工单/受理人控件
  13354. formlyConfigProvider.setType({
  13355. name: 'ui-workernumbersign',
  13356. // extends: 'label',
  13357. templateUrl: 'assets/views/customform/tpl/ui-workernumbersign.html',
  13358. controller: ['$scope', function ($scope) {
  13359. // 2020年4月24日13:20:40
  13360. console.log($scope,'docu');
  13361. // 左侧事件工单区域地点填充
  13362. $scope.model.selecthouseNumber = $scope.model.place;
  13363. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13364. setTimeout(function () {
  13365. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13366. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13367. if (modelData.status == 200) {
  13368. $scope.model[$scope.options.key] = modelData.data;
  13369. $scope.options.initialValue = $scope.model[$scope.options.key];
  13370. }
  13371. });
  13372. }, 1000);
  13373. }
  13374. if ($scope.options.templateOptions.user && (angular.isUndefined($scope.model.acceptUser) || $scope.model.acceptUser == null)) {
  13375. if (angular.isFunction($scope.options.templateOptions.transform)) {
  13376. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  13377. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  13378. // }
  13379. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13380. $scope.$parent.$parent.$parent.model['directClose'] = false;
  13381. $scope.$parent.$parent.$parent.model['isHandlerUser'] = false;
  13382. }
  13383. $scope.model.acceptUser = $scope.options.templateOptions.user;
  13384. // $scope.options.initialValue = $scope.model.acceptUser;
  13385. }
  13386. }]
  13387. });
  13388. //工单控件-only number
  13389. formlyConfigProvider.setType({
  13390. name: 'ui-workernumber',
  13391. extends: 'input',
  13392. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13393. controller: ['$scope', function ($scope) {
  13394. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13395. setTimeout(function () {
  13396. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  13397. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13398. if (modelData.status == 200) {
  13399. $scope.model[$scope.options.key] = modelData.data;
  13400. $scope.options.initialValue = $scope.model[$scope.options.key];
  13401. }
  13402. });
  13403. }, 1000);
  13404. }
  13405. }]
  13406. });
  13407. //cmdb工单
  13408. formlyConfigProvider.setType({
  13409. name: 'ui-cmdbworkernumber',
  13410. extends: 'input',
  13411. templateUrl: 'assets/views/customform/tpl/ui-workernumber.html',
  13412. controller: ['$scope', function ($scope) {
  13413. if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  13414. setTimeout(function () {
  13415. $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService, $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.cifilter_classics.id).then(function (result) {
  13416. var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  13417. // if(modelData.status==200){
  13418. $scope.model[$scope.options.key] = modelData[$scope.options.key];
  13419. $scope.options.initialValue = $scope.model[$scope.options.key];
  13420. // }
  13421. });
  13422. }, 1000);
  13423. }
  13424. }]
  13425. });
  13426. //简易上传图片组件
  13427. formlyConfigProvider.setType({
  13428. name: 'ui-uploadImgs',
  13429. templateUrl: 'assets/views/customform/tpl/ui-uploadImgs.html',
  13430. wrapper: ['bootstrapHasError'],
  13431. controller: ['$scope', 'fileReader', '$parse', '$modal', function ($scope, fileReader, $parse, $modal) {
  13432. $scope.imgshows = [];
  13433. $scope.uploadimgs = [];
  13434. var model = $parse('upload_img');
  13435. var modelSetter = model.assign;
  13436. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13437. uploader.filters.push({
  13438. name: 'customFilter',
  13439. fn: function (item /*{File|FileLikeObject}*/, options) {
  13440. return this.queue.length < 10;
  13441. }
  13442. });
  13443. // 添加
  13444. $scope.change = function (event) {
  13445. var element = $('.upinp')
  13446. modelSetter($scope, element[0].files[0]);
  13447. //附件预览
  13448. $scope.imgupload = event.files[0];
  13449. getFile($scope.imgupload, $scope);
  13450. //获得预览图地址并且把file对象放入上传合集内
  13451. function getFile(imgupload, $scope) {
  13452. if (!imgupload) {
  13453. return;
  13454. }
  13455. fileReader.readAsDataUrl(imgupload, $scope)
  13456. .then(function (result) {
  13457. $scope.imgshows.push(result)
  13458. var file = document.querySelector('input[type=file]').files[0];
  13459. $scope.uploadimgs.push(file) //这里是放着传给后台的数据file,下面controller的时候会有
  13460. console.log($scope.imgshows, $scope.uploadimgs)
  13461. if ($scope.imgshows.length < 3) {
  13462. $('#upup').show()
  13463. } else {
  13464. $('#upup').hide()
  13465. }
  13466. });
  13467. };
  13468. }
  13469. // 删除
  13470. $scope.uploadimg_del = function (index, imgs) {
  13471. console.log(index, imgs)
  13472. $scope.imgshows.splice(index, 1);
  13473. $scope.uploadimgs.splice(index, 1);
  13474. if ($scope.imgshows.length < 3) {
  13475. $('#upup').show()
  13476. } else {
  13477. $('#upup').hide()
  13478. }
  13479. }
  13480. // 预览
  13481. $scope.preview = function (url, idx) {
  13482. var name = $scope.uploadimgs[idx].name
  13483. $modal.open({
  13484. backdrop: false,
  13485. templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  13486. controller: function ($scope, scope, $modalInstance) {
  13487. $scope.title = name;
  13488. $scope.imageurl = url;
  13489. $scope.cancel = function () {
  13490. $modalInstance.dismiss('cancel');
  13491. }
  13492. },
  13493. resolve: {
  13494. scope: function () {
  13495. return $scope;
  13496. }
  13497. }
  13498. });
  13499. }
  13500. if (uploader) {
  13501. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13502. console.info('onWhenAddingFileFailed', item, filter, options);
  13503. };
  13504. uploader.onAfterAddingFile = function (fileItem) {
  13505. console.info('onAfterAddingFile', fileItem);
  13506. };
  13507. uploader.onAfterAddingAll = function (addedFileItems) {
  13508. console.info('onAfterAddingAll', addedFileItems);
  13509. };
  13510. uploader.onBeforeUploadItem = function (item) {
  13511. console.info('onBeforeUploadItem', item);
  13512. };
  13513. uploader.onProgressItem = function (fileItem, progress) {
  13514. console.info('onProgressItem', fileItem, progress);
  13515. };
  13516. uploader.onProgressAll = function (progress) {
  13517. console.info('onProgressAll', progress);
  13518. };
  13519. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13520. console.info('onSuccessItem', fileItem, response, status, headers);
  13521. };
  13522. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13523. console.info('onErrorItem', fileItem, response, status, headers);
  13524. };
  13525. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13526. console.info('onCancelItem', fileItem, response, status, headers);
  13527. };
  13528. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13529. console.info('onCompleteItem', fileItem, response, status, headers);
  13530. };
  13531. uploader.onCompleteAll = function () {
  13532. console.info('onCompleteAll');
  13533. };
  13534. }
  13535. // console.log(modelSetter)
  13536. }]
  13537. });
  13538. //jry-上传下载一体
  13539. formlyConfigProvider.setType({
  13540. name: 'ui-upDropFile',
  13541. templateUrl: 'assets/views/customform/tpl/ui-upDropFile.html',
  13542. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13543. defaultOptions: function (options) {
  13544. return {
  13545. templateOptions: {
  13546. view: function (APIService, contentId) {
  13547. return APIService.downloadAttachment(contentId);
  13548. },
  13549. // ApiService: 'api_wechatfile',
  13550. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  13551. // upUrl: 'common/common/uploadAttachment',
  13552. // listAttachmentUrl: 'common/common/listAttachment',
  13553. // downUrl: 'common/common/downloadAttachment',
  13554. // bindType: 'incident',
  13555. // bindId: 2323
  13556. },
  13557. // validators: {
  13558. // required: {
  13559. // expression: function(viewValue, modelValue) {
  13560. // var value = modelValue || viewValue;
  13561. // return value.length >= 1;
  13562. // }
  13563. // }
  13564. // }
  13565. };
  13566. },
  13567. controller: ['$scope', '$rootScope', 'Restangular', 'up_down_file', "$http", "api_bpm", function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  13568. console.log($scope);
  13569. $scope.showFileUp = true;
  13570. if ($scope.model.isKnowledge_detail) {
  13571. $scope.showFileUp = false;
  13572. }
  13573. if (angular.isUndefined($scope.form.dropState)) {
  13574. $scope.form.dropState = false;
  13575. }
  13576. if ($scope.model.incident) {
  13577. if ($scope.model.incident.alarm) {
  13578. console.log($scope)
  13579. if ($scope.model.incident.alarm) {
  13580. if ($scope.model.incident.alarm.alarmExtension) {
  13581. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('{', "");
  13582. $scope.model.incident.alarm.alarmExtension = $scope.model.incident.alarm.alarmExtension.replace('}', "");
  13583. $scope.model.incident.description = $scope.model.incident.alarm.alarmExtension;
  13584. console.log($scope.model.incident.description)
  13585. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",' + $scope.model.incident.description
  13586. } else {
  13587. $scope.model.incident.description = '"' + '告警名称' + '":' + '"' + $scope.model.incident.alarm.alarmSystem + '",' + '"' + '告警状态' + '":' + '"' + $scope.model.incident.alarm.alarmStatus + '",' + '"' + '告警内容' + '":' + '"' + $scope.model.incident.alarm.alarmContent + '",'
  13588. }
  13589. $scope.model.incident.description = $scope.model.incident.description.replace(/,/g, '\n');
  13590. console.log($scope.model.incident.description)
  13591. };
  13592. }
  13593. api_bpm.tellCategory($scope.model.incident.category.id).then(function (wt_data) {
  13594. console.log(wt_data);
  13595. if (wt_data) {
  13596. $rootScope.wt_category = wt_data.data;
  13597. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  13598. $rootScope.wt_child = wt_data.child
  13599. }
  13600. })
  13601. if ($scope.model.titleName == '接单') {
  13602. $scope.model.receive_code = 'handler'
  13603. if ($scope.model.incident.groupLeader && !$scope.model.incident.repeat) {
  13604. $scope.model.isHandlerUser = true;
  13605. }
  13606. }
  13607. if ($scope.model.titleName == '事件处理') {
  13608. console.log($scope.model.cmdbCode)
  13609. if ($scope.model.cmdbCode) {
  13610. $scope.model.incident.cmdbCode = $scope.model.cmdbCode
  13611. }
  13612. }
  13613. } else {
  13614. $rootScope.wt_category = '';
  13615. }
  13616. //附件上传数据
  13617. if ($scope.options.templateOptions.fileUploader) {
  13618. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13619. //$scope.options.templateOptions.uploader();
  13620. console.log(uploader)
  13621. // FILTERS
  13622. uploader.filters.push({
  13623. name: 'customFilter',
  13624. fn: function (item /*{File|FileLikeObject}*/, options) {
  13625. return this.queue.length < 10;
  13626. }
  13627. });
  13628. }
  13629. var to = $scope.options.templateOptions;
  13630. // var bindType = $scope.model.bindType;
  13631. if (to.bindType == 'incident') {
  13632. var bindId = $scope.model[to.bindType].processInstanceId;
  13633. } else if (to.bindType == 'change') {
  13634. var bindId = $scope.model[to.bindType].processInstanceId;
  13635. } else {
  13636. var bindId = $scope.model[to.bindType].id;
  13637. }
  13638. //获取附件列表
  13639. $scope.listAttachmen = function () {
  13640. to.ApiService.listAttachment(to.listAttachmentUrl, to.bindType, bindId).then(function (result) {
  13641. var myData = Restangular.stripRestangular(result);
  13642. // $scope.listAttachmens = myData;
  13643. $scope.attachments = myData.data;
  13644. });
  13645. };
  13646. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  13647. $scope.listAttachmen();
  13648. } else if (to.bindType && $scope.model[to.bindType].id) {
  13649. $scope.listAttachmen();
  13650. }
  13651. //附件上传
  13652. $scope.isUpfload = to.isUpfload;
  13653. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13654. uploader.onBeforeUploadItem = function (item) {
  13655. angular.extend(item.headers, $rootScope.getSession());
  13656. item.url = to.ApiService.saveAttachments(to.uploadUrl, to.bindType, bindId).getRequestedUrl();
  13657. item.formData.push({
  13658. 'filename': item.file.name
  13659. });
  13660. };
  13661. uploader.uploadAll();
  13662. }
  13663. //附件下载
  13664. $scope.download = function (token, filename) {
  13665. var downUrl = to.ApiService.downloadAttachment(to.downUrl, token).getRequestedUrl();
  13666. // window.open(downUrl);
  13667. var a = document.createElement('a');
  13668. a.href = downUrl;
  13669. a.target = '_blank';
  13670. a.download = filename;
  13671. document.body.appendChild(a);
  13672. a.click();
  13673. };
  13674. //附件预览
  13675. $scope.view = function (id, previewUrl) {
  13676. if (previewUrl) {
  13677. window.open(previewUrl);
  13678. }
  13679. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  13680. // if (response.state == 200) {
  13681. // window.open(response.previewUrl);
  13682. // }
  13683. // })
  13684. };
  13685. // CALLBACKS
  13686. if (uploader) {
  13687. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13688. console.info('onWhenAddingFileFailed', item, filter, options);
  13689. };
  13690. uploader.onAfterAddingFile = function (fileItem) {
  13691. console.info('onAfterAddingFile', fileItem);
  13692. };
  13693. uploader.onAfterAddingAll = function (addedFileItems) {
  13694. console.info('onAfterAddingAll', addedFileItems);
  13695. };
  13696. uploader.onBeforeUploadItem = function (item) {
  13697. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13698. // // $scope.uploader.options.url();
  13699. // $scope.uploader.onBeforeUploadItem = function(item) {
  13700. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13701. // console.info('onBeforeUploadItem', item);
  13702. // };
  13703. // $scope.uploader.uploadAll();
  13704. // }
  13705. console.info('onBeforeUploadItem', item);
  13706. };
  13707. uploader.onProgressItem = function (fileItem, progress) {
  13708. console.info('onProgressItem', fileItem, progress);
  13709. };
  13710. uploader.onProgressAll = function (progress) {
  13711. console.info('onProgressAll', progress);
  13712. };
  13713. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13714. console.info('onSuccessItem', fileItem, response, status, headers);
  13715. if (response.status == 200) {
  13716. $scope.listAttachmen();
  13717. }
  13718. };
  13719. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13720. console.info('onErrorItem', fileItem, response, status, headers);
  13721. };
  13722. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13723. console.info('onCancelItem', fileItem, response, status, headers);
  13724. };
  13725. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13726. console.info('onCompleteItem', fileItem, response, status, headers);
  13727. };
  13728. uploader.onCompleteAll = function () {
  13729. console.info('onCompleteAll');
  13730. };
  13731. }
  13732. }]
  13733. });
  13734. //简易上传下载附件组件
  13735. formlyConfigProvider.setType({
  13736. name: 'ui-upDownFiles',
  13737. templateUrl: 'assets/views/customform/tpl/ui-upDownFiles.html',
  13738. wrapper: ['bootstrapHasError'],
  13739. defaultOptions: function (options) {
  13740. return {
  13741. templateOptions: {
  13742. refresh: function (APIService, processInstanceId, data) {
  13743. return APIService.listAttachments(processInstanceId);
  13744. },
  13745. downloadUri: function (APIService, contentId) {
  13746. return APIService.downloadAttachment(contentId).getRequestedUrl();
  13747. },
  13748. view: function (APIService, contentId) {
  13749. return APIService.attachmentsPreviewUrl(contentId);
  13750. },
  13751. download: function (APIService, contentId, item) {
  13752. var item = {
  13753. 'url': APIService.download(contentId),
  13754. 'headers': headers
  13755. };
  13756. return item;
  13757. },
  13758. refreshDelay: 0
  13759. }
  13760. };
  13761. },
  13762. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  13763. if (angular.isUndefined($scope.form.dropState)) {
  13764. $scope.form.dropState = false;
  13765. }
  13766. //附件上传数据
  13767. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13768. //$scope.options.templateOptions.uploader();
  13769. // FILTERS
  13770. uploader.filters.push({
  13771. name: 'customFilter',
  13772. fn: function (item /*{File|FileLikeObject}*/, options) {
  13773. return this.queue.length < 10;
  13774. }
  13775. });
  13776. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13777. // uploader.onBeforeUploadItem = function (item) {
  13778. // angular.extend(item.headers, $rootScope.getSession());
  13779. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13780. // item.formData.push({
  13781. // 'fileName': item.file.name
  13782. // });
  13783. // console.info('onBeforeUploadItem', item);
  13784. // };
  13785. // }
  13786. // CALLBACKS
  13787. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13788. console.info('onWhenAddingFileFailed', item, filter, options);
  13789. };
  13790. uploader.onAfterAddingFile = function (fileItem) {
  13791. console.info('onAfterAddingFile', fileItem);
  13792. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13793. alert('文件过大');
  13794. fileItem.uploader.queue.pop()
  13795. console.log($scope);
  13796. }
  13797. };
  13798. uploader.onAfterAddingAll = function (addedFileItems) {
  13799. // console.info('onAfterAddingAll', addedFileItems);
  13800. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13801. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13802. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13803. // console.log(123)
  13804. };
  13805. uploader.onBeforeUploadItem = function (item) {
  13806. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13807. // // $scope.uploader.options.url();
  13808. // $scope.uploader.onBeforeUploadItem = function(item) {
  13809. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13810. // console.info('onBeforeUploadItem', item);
  13811. // };
  13812. // $scope.uploader.uploadAll();
  13813. // }
  13814. console.info('onBeforeUploadItem', item);
  13815. };
  13816. uploader.onProgressItem = function (fileItem, progress) {
  13817. console.info('onProgressItem', fileItem, progress);
  13818. };
  13819. uploader.onProgressAll = function (progress) {
  13820. console.info('onProgressAll', progress);
  13821. };
  13822. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13823. console.info('onSuccessItem', fileItem, response, status, headers);
  13824. };
  13825. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13826. console.info('onErrorItem', fileItem, response, status, headers);
  13827. };
  13828. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13829. console.info('onCancelItem', fileItem, response, status, headers);
  13830. };
  13831. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  13832. console.info('onCompleteItem', fileItem, response, status, headers);
  13833. };
  13834. uploader.onCompleteAll = function () {
  13835. console.info('onCompleteAll');
  13836. };
  13837. var _refreshDelayPromise;
  13838. // 下载
  13839. $scope.download = function (contentId, filename, token) {
  13840. // console.log(contentId, filename, token)
  13841. //附件下载
  13842. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  13843. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  13844. // console.log(downUrl)
  13845. var a = document.createElement('a');
  13846. a.href = downUrl;
  13847. a.target = '_blank';
  13848. a.download = filename;
  13849. document.body.appendChild(a);
  13850. a.click();
  13851. };
  13852. $scope._refresh = function (refreshAttr) {
  13853. $scope.attachments = [];
  13854. if (refreshAttr !== undefined) {
  13855. if (_refreshDelayPromise) {
  13856. $timeout.cancel(_refreshDelayPromise);
  13857. }
  13858. _refreshDelayPromise = $timeout(function () {
  13859. // 暂存附件
  13860. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  13861. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13862. $scope.options.templateOptions.processInstanceId, {
  13863. 'idx': 0,
  13864. 'sum': 1000
  13865. }).then(function (response) {
  13866. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13867. if (myData) {
  13868. for (var i = 0; i < myData.data.length; i++) {
  13869. $scope.attachments.push(myData.data[i]);
  13870. }
  13871. };
  13872. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13873. $scope.$parent.$parent.$parent.model.save_fileId, {
  13874. 'idx': 0,
  13875. 'sum': 1000
  13876. }).then(function (response2) {
  13877. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  13878. if (myData2) {
  13879. for (var i = 0; i < myData2.data.length; i++) {
  13880. $scope.attachments.push(myData2.data[i]);
  13881. }
  13882. // 只展示除图片以外的附件
  13883. var a = [];
  13884. $scope.attachments.forEach(e => {
  13885. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13886. // $scope.imgs.push(e)
  13887. } else {
  13888. a.push(e)
  13889. }
  13890. })
  13891. $scope.attachments = a;
  13892. };
  13893. console.log($scope.attachments)
  13894. });
  13895. });
  13896. // 正常附件
  13897. } else {
  13898. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  13899. $scope.options.templateOptions.processInstanceId, {
  13900. 'idx': 0,
  13901. 'sum': 1000
  13902. }).then(function (response) {
  13903. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  13904. if (myData) {
  13905. $scope.attachments = myData.data;
  13906. // 只展示除图片以外的附件
  13907. var a = [];
  13908. $scope.attachments.forEach(e => {
  13909. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  13910. // $scope.imgs.push(e)
  13911. } else {
  13912. a.push(e)
  13913. }
  13914. })
  13915. $scope.attachments = a;
  13916. }
  13917. });
  13918. }
  13919. }, $scope.options.templateOptions.refreshDelay);
  13920. }
  13921. }
  13922. $scope._refresh({});
  13923. }]
  13924. });
  13925. //简易上传附件组件
  13926. formlyConfigProvider.setType({
  13927. name: 'ui-uploadFiles',
  13928. templateUrl: 'assets/views/customform/tpl/ui-uploadFiles.html',
  13929. wrapper: ['bootstrapHasError'],
  13930. controller: ['$scope', function ($scope) {
  13931. if (angular.isUndefined($scope.form.dropState)) {
  13932. $scope.form.dropState = false;
  13933. }
  13934. //附件上传数据
  13935. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  13936. //$scope.options.templateOptions.uploader();
  13937. // FILTERS
  13938. uploader.filters.push({
  13939. name: 'customFilter',
  13940. fn: function (item /*{File|FileLikeObject}*/, options) {
  13941. return this.queue.length < 10;
  13942. }
  13943. });
  13944. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  13945. uploader.onBeforeUploadItem = function (item) {
  13946. angular.extend(item.headers, $rootScope.getSession());
  13947. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  13948. item.formData.push({
  13949. 'fileName': item.file.name
  13950. });
  13951. console.info('onBeforeUploadItem', item);
  13952. };
  13953. }
  13954. // CALLBACKS
  13955. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  13956. console.info('onWhenAddingFileFailed', item, filter, options);
  13957. };
  13958. uploader.onAfterAddingFile = function (fileItem) {
  13959. console.info('onAfterAddingFile', fileItem);
  13960. if (fileItem.file.size >= 1024 * 1024 * 10) {
  13961. alert('文件过大');
  13962. fileItem.uploader.queue.pop()
  13963. console.log($scope);
  13964. }
  13965. };
  13966. uploader.onAfterAddingAll = function (addedFileItems) {
  13967. // console.info('onAfterAddingAll', addedFileItems);
  13968. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13969. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  13970. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  13971. // console.log(123)
  13972. };
  13973. uploader.onBeforeUploadItem = function (item) {
  13974. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  13975. // // $scope.uploader.options.url();
  13976. // $scope.uploader.onBeforeUploadItem = function(item) {
  13977. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  13978. // console.info('onBeforeUploadItem', item);
  13979. // };
  13980. // $scope.uploader.uploadAll();
  13981. // }
  13982. console.info('onBeforeUploadItem', item);
  13983. };
  13984. uploader.onProgressItem = function (fileItem, progress) {
  13985. console.info('onProgressItem', fileItem, progress);
  13986. };
  13987. uploader.onProgressAll = function (progress) {
  13988. console.info('onProgressAll', progress);
  13989. };
  13990. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  13991. console.info('onSuccessItem', fileItem, response, status, headers);
  13992. };
  13993. uploader.onErrorItem = function (fileItem, response, status, headers) {
  13994. console.info('onErrorItem', fileItem, response, status, headers);
  13995. };
  13996. uploader.onCancelItem = function (fileItem, response, status, headers) {
  13997. console.info('onCancelItem', fileItem, response, status, headers);
  13998. };
  13999. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14000. console.info('onCompleteItem', fileItem, response, status, headers);
  14001. };
  14002. uploader.onCompleteAll = function () {
  14003. console.info('onCompleteAll');
  14004. };
  14005. }]
  14006. });
  14007. //无上传按钮附件上传组件
  14008. formlyConfigProvider.setType({
  14009. name: 'ui-dropfilenotup',
  14010. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14011. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14012. controller: ['$scope', function ($scope) {
  14013. if (angular.isUndefined($scope.form.dropState)) {
  14014. $scope.form.dropState = false;
  14015. }
  14016. //附件上传数据
  14017. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14018. //$scope.options.templateOptions.uploader();
  14019. // FILTERS
  14020. uploader.filters.push({
  14021. name: 'customFilter',
  14022. fn: function (item /*{File|FileLikeObject}*/, options) {
  14023. return this.queue.length < 10;
  14024. }
  14025. });
  14026. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14027. uploader.onBeforeUploadItem = function (item) {
  14028. angular.extend(item.headers, $rootScope.getSession());
  14029. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14030. item.formData.push({
  14031. 'fileName': item.file.name
  14032. });
  14033. console.info('onBeforeUploadItem', item);
  14034. };
  14035. uploader.uploadAll();
  14036. }
  14037. // CALLBACKS
  14038. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14039. console.info('onWhenAddingFileFailed', item, filter, options);
  14040. };
  14041. uploader.onAfterAddingFile = function (fileItem) {
  14042. console.info('onAfterAddingFile', fileItem);
  14043. };
  14044. uploader.onAfterAddingAll = function (addedFileItems) {
  14045. console.info('onAfterAddingAll', addedFileItems);
  14046. };
  14047. uploader.onBeforeUploadItem = function (item) {
  14048. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14049. // // $scope.uploader.options.url();
  14050. // $scope.uploader.onBeforeUploadItem = function(item) {
  14051. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14052. // console.info('onBeforeUploadItem', item);
  14053. // };
  14054. // $scope.uploader.uploadAll();
  14055. // }
  14056. console.info('onBeforeUploadItem', item);
  14057. };
  14058. uploader.onProgressItem = function (fileItem, progress) {
  14059. console.info('onProgressItem', fileItem, progress);
  14060. };
  14061. uploader.onProgressAll = function (progress) {
  14062. console.info('onProgressAll', progress);
  14063. };
  14064. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14065. console.info('onSuccessItem', fileItem, response, status, headers);
  14066. };
  14067. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14068. console.info('onErrorItem', fileItem, response, status, headers);
  14069. };
  14070. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14071. console.info('onCancelItem', fileItem, response, status, headers);
  14072. };
  14073. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14074. console.info('onCompleteItem', fileItem, response, status, headers);
  14075. };
  14076. uploader.onCompleteAll = function () {
  14077. console.info('onCompleteAll');
  14078. };
  14079. }]
  14080. });
  14081. //无按钮知识库上传
  14082. formlyConfigProvider.setType({
  14083. name: 'ui-dropfielkn',
  14084. templateUrl: 'assets/views/customform/tpl/ui-dropfilenotup.html',
  14085. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14086. controller: ['$scope', function ($scope) {
  14087. if (angular.isUndefined($scope.form.dropState)) {
  14088. $scope.form.dropState = false;
  14089. }
  14090. //附件上传数据
  14091. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14092. //$scope.options.templateOptions.uploader();
  14093. // FILTERS
  14094. uploader.filters.push({
  14095. name: 'customFilter',
  14096. fn: function (item /*{File|FileLikeObject}*/, options) {
  14097. return this.queue.length < 10;
  14098. }
  14099. });
  14100. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14101. uploader.onBeforeUploadItem = function (item) {
  14102. angular.extend(item.headers, $rootScope.getSession());
  14103. item.url = APIService.addFile(processInstanceId, taskId, userId).getRequestedUrl();
  14104. item.formData.push({
  14105. 'fileName': item.file.name
  14106. });
  14107. console.info('onBeforeUploadItem', item);
  14108. };
  14109. uploader.uploadAll();
  14110. }
  14111. // CALLBACKS
  14112. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14113. console.info('onWhenAddingFileFailed', item, filter, options);
  14114. };
  14115. uploader.onAfterAddingFile = function (fileItem) {
  14116. console.info('onAfterAddingFile', fileItem);
  14117. };
  14118. uploader.onAfterAddingAll = function (addedFileItems) {
  14119. console.info('onAfterAddingAll', addedFileItems);
  14120. };
  14121. uploader.onBeforeUploadItem = function (item) {
  14122. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14123. // // $scope.uploader.options.url();
  14124. // $scope.uploader.onBeforeUploadItem = function(item) {
  14125. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14126. // console.info('onBeforeUploadItem', item);
  14127. // };
  14128. // $scope.uploader.uploadAll();
  14129. // }
  14130. console.info('onBeforeUploadItem', item);
  14131. };
  14132. uploader.onProgressItem = function (fileItem, progress) {
  14133. console.info('onProgressItem', fileItem, progress);
  14134. };
  14135. uploader.onProgressAll = function (progress) {
  14136. console.info('onProgressAll', progress);
  14137. };
  14138. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14139. console.info('onSuccessItem', fileItem, response, status, headers);
  14140. };
  14141. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14142. console.info('onErrorItem', fileItem, response, status, headers);
  14143. };
  14144. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14145. console.info('onCancelItem', fileItem, response, status, headers);
  14146. };
  14147. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14148. console.info('onCompleteItem', fileItem, response, status, headers);
  14149. };
  14150. uploader.onCompleteAll = function () {
  14151. console.info('onCompleteAll');
  14152. };
  14153. }]
  14154. });
  14155. //附件上传列表组件
  14156. formlyConfigProvider.setType({
  14157. name: 'ui-dropfile',
  14158. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14159. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14160. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14161. if (angular.isUndefined($scope.form.dropState)) {
  14162. $scope.form.dropState = false;
  14163. }
  14164. //附件上传数据
  14165. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14166. //$scope.options.templateOptions.uploader();
  14167. // FILTERS
  14168. uploader.filters.push({
  14169. name: 'customFilter',
  14170. fn: function (item /*{File|FileLikeObject}*/, options) {
  14171. return this.queue.length < 10;
  14172. }
  14173. });
  14174. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14175. uploader.onBeforeUploadItem = function (item) {
  14176. angular.extend(item.headers, $rootScope.getSession());
  14177. if ($scope.options.templateOptions.upservice && $scope.options.templateOptions.formname) {
  14178. // if ($scope.options.templateOptions.formket) {
  14179. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  14180. // } else {
  14181. item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname].id, taskId, userId).getRequestedUrl();
  14182. // }
  14183. } else {
  14184. item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  14185. }
  14186. item.formData.push({
  14187. 'filename': item.file.name
  14188. });
  14189. console.info('onBeforeUploadItem', item);
  14190. };
  14191. uploader.uploadAll();
  14192. }
  14193. // CALLBACKS
  14194. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14195. console.info('onWhenAddingFileFailed', item, filter, options);
  14196. };
  14197. uploader.onAfterAddingFile = function (fileItem) {
  14198. console.info('onAfterAddingFile', fileItem);
  14199. };
  14200. uploader.onAfterAddingAll = function (addedFileItems) {
  14201. console.info('onAfterAddingAll', addedFileItems);
  14202. };
  14203. uploader.onBeforeUploadItem = function (item) {
  14204. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14205. // // $scope.uploader.options.url();
  14206. // $scope.uploader.onBeforeUploadItem = function(item) {
  14207. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14208. // console.info('onBeforeUploadItem', item);
  14209. // };
  14210. // $scope.uploader.uploadAll();
  14211. // }
  14212. console.info('onBeforeUploadItem', item);
  14213. };
  14214. uploader.onProgressItem = function (fileItem, progress) {
  14215. console.info('onProgressItem', fileItem, progress);
  14216. };
  14217. uploader.onProgressAll = function (progress) {
  14218. console.info('onProgressAll', progress);
  14219. };
  14220. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14221. console.info('onSuccessItem', fileItem, response, status, headers);
  14222. };
  14223. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14224. console.info('onErrorItem', fileItem, response, status, headers);
  14225. };
  14226. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14227. console.info('onCancelItem', fileItem, response, status, headers);
  14228. };
  14229. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14230. console.info('onCompleteItem', fileItem, response, status, headers);
  14231. };
  14232. uploader.onCompleteAll = function () {
  14233. console.info('onCompleteAll');
  14234. };
  14235. }]
  14236. });
  14237. //简易附件展示下载列表组件
  14238. formlyConfigProvider.setType({
  14239. name: 'ui-dropFiles',
  14240. templateUrl: 'assets/views/customform/tpl/ui-dropFiles.html',
  14241. defaultOptions: function (options) {
  14242. return {
  14243. templateOptions: {
  14244. refresh: function (APIService, processInstanceId, data) {
  14245. return APIService.listAttachments(processInstanceId);
  14246. },
  14247. downloadUri: function (APIService, contentId) {
  14248. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14249. },
  14250. view: function (APIService, contentId) {
  14251. return APIService.attachmentsPreviewUrl(contentId);
  14252. },
  14253. download: function (APIService, contentId, item) {
  14254. var item = {
  14255. 'url': APIService.download(contentId),
  14256. 'headers': headers
  14257. };
  14258. return item;
  14259. },
  14260. refreshDelay: 0
  14261. }
  14262. };
  14263. },
  14264. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', 'up_down_file', function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  14265. var _refreshDelayPromise;
  14266. // $scope.downloadUrl = function(contentId){
  14267. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14268. // };
  14269. $scope.download = function (contentId, filename, token) {
  14270. // console.log(contentId, filename, token)
  14271. //附件下载
  14272. var downUrl = up_down_file.downloadAttachment("common/common/downloadAttachment", token).getRequestedUrl();
  14273. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  14274. // console.log(downUrl)
  14275. var a = document.createElement('a');
  14276. a.href = downUrl;
  14277. a.target = '_blank';
  14278. a.download = filename;
  14279. document.body.appendChild(a);
  14280. a.click();
  14281. };
  14282. $scope.view = function (contentId, token, filename, type) {
  14283. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14284. if (response.state == 200) {
  14285. window.open(response.previewUrl);
  14286. }
  14287. })
  14288. };
  14289. /**
  14290. * refresh
  14291. */
  14292. $scope._refresh = function (refreshAttr) {
  14293. $scope.attachments = [];
  14294. if (refreshAttr !== undefined) {
  14295. if (_refreshDelayPromise) {
  14296. $timeout.cancel(_refreshDelayPromise);
  14297. }
  14298. _refreshDelayPromise = $timeout(function () {
  14299. // 暂存附件
  14300. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  14301. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14302. $scope.options.templateOptions.processInstanceId, {
  14303. 'idx': 0,
  14304. 'sum': 1000
  14305. }).then(function (response) {
  14306. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14307. if (myData) {
  14308. for (var i = 0; i < myData.data.length; i++) {
  14309. $scope.attachments.push(myData.data[i]);
  14310. }
  14311. };
  14312. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14313. $scope.$parent.$parent.$parent.model.save_fileId, {
  14314. 'idx': 0,
  14315. 'sum': 1000
  14316. }).then(function (response2) {
  14317. var myData2 = $scope.options.templateOptions.Restangular.stripRestangular(response2);
  14318. if (myData2) {
  14319. for (var i = 0; i < myData2.data.length; i++) {
  14320. $scope.attachments.push(myData2.data[i]);
  14321. }
  14322. // 只展示除图片以外的附件
  14323. var a = [];
  14324. $scope.attachments.forEach(e => {
  14325. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14326. // $scope.imgs.push(e)
  14327. } else {
  14328. a.push(e)
  14329. }
  14330. })
  14331. $scope.attachments = a;
  14332. };
  14333. console.log($scope.attachments)
  14334. });
  14335. });
  14336. // 正常附件
  14337. } else {
  14338. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14339. $scope.options.templateOptions.processInstanceId, {
  14340. 'idx': 0,
  14341. 'sum': 1000
  14342. }).then(function (response) {
  14343. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14344. if (myData) {
  14345. $scope.attachments = myData.data;
  14346. // 只展示除图片以外的附件
  14347. var a = [];
  14348. $scope.attachments.forEach(e => {
  14349. if (e.suffix == 'jpeg' || e.suffix == 'jpg' || e.suffix == 'svg' || e.suffix == 'png' || e.suffix == 'bmp' || e.suffix == 'gif' || e.suffix == 'tif') {
  14350. // $scope.imgs.push(e)
  14351. } else {
  14352. a.push(e)
  14353. }
  14354. })
  14355. $scope.attachments = a;
  14356. console.log($scope.attachments)
  14357. }
  14358. });
  14359. }
  14360. }, $scope.options.templateOptions.refreshDelay);
  14361. }
  14362. }
  14363. $scope._refresh({});
  14364. // $scope.attachments = $scope.model[$scope.options.key]
  14365. }]
  14366. });
  14367. //知识库附件上传
  14368. formlyConfigProvider.setType({
  14369. name: 'ui-dropfielknow',
  14370. templateUrl: 'assets/views/customform/tpl/ui-dropfile.html',
  14371. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  14372. controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
  14373. if (angular.isUndefined($scope.form.dropState)) {
  14374. $scope.form.dropState = false;
  14375. }
  14376. //附件上传数据
  14377. var uploader = $scope.uploader = $scope.options.templateOptions.fileUploader;
  14378. //$scope.options.templateOptions.uploader();
  14379. // FILTERS
  14380. uploader.filters.push({
  14381. name: 'customFilter',
  14382. fn: function (item /*{File|FileLikeObject}*/, options) {
  14383. return this.queue.length < 10;
  14384. }
  14385. });
  14386. $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  14387. uploader.onBeforeUploadItem = function (item) {
  14388. angular.extend(item.headers, $rootScope.getSession());
  14389. item.url = APIService.upload(processInstanceId, taskId, userId).getRequestedUrl();
  14390. item.formData.push({
  14391. 'fileName': item.file.name,
  14392. 'type': 'solution',
  14393. 'solutionId': $scope.model.knowledge.id
  14394. });
  14395. console.info('onBeforeUploadItem', item);
  14396. };
  14397. uploader.uploadAll();
  14398. }
  14399. // CALLBACKS
  14400. uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
  14401. console.info('onWhenAddingFileFailed', item, filter, options);
  14402. };
  14403. uploader.onAfterAddingFile = function (fileItem) {
  14404. console.info('onAfterAddingFile', fileItem);
  14405. };
  14406. uploader.onAfterAddingAll = function (addedFileItems) {
  14407. console.info('onAfterAddingAll', addedFileItems);
  14408. };
  14409. uploader.onBeforeUploadItem = function (item) {
  14410. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  14411. // // $scope.uploader.options.url();
  14412. // $scope.uploader.onBeforeUploadItem = function(item) {
  14413. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  14414. // console.info('onBeforeUploadItem', item);
  14415. // };
  14416. // $scope.uploader.uploadAll();
  14417. // }
  14418. console.info('onBeforeUploadItem', item);
  14419. };
  14420. uploader.onProgressItem = function (fileItem, progress) {
  14421. console.info('onProgressItem', fileItem, progress);
  14422. };
  14423. uploader.onProgressAll = function (progress) {
  14424. console.info('onProgressAll', progress);
  14425. };
  14426. uploader.onSuccessItem = function (fileItem, response, status, headers) {
  14427. console.info('onSuccessItem', fileItem, response, status, headers);
  14428. };
  14429. uploader.onErrorItem = function (fileItem, response, status, headers) {
  14430. console.info('onErrorItem', fileItem, response, status, headers);
  14431. };
  14432. uploader.onCancelItem = function (fileItem, response, status, headers) {
  14433. console.info('onCancelItem', fileItem, response, status, headers);
  14434. };
  14435. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  14436. console.info('onCompleteItem', fileItem, response, status, headers);
  14437. };
  14438. uploader.onCompleteAll = function () {
  14439. console.info('onCompleteAll');
  14440. };
  14441. }]
  14442. });
  14443. //知识库附件下载列表
  14444. formlyConfigProvider.setType({
  14445. name: 'ui-dropfileknowledge',
  14446. templateUrl: 'assets/views/customform/tpl/ui-dropfileknowledge.html',
  14447. defaultOptions: function (options) {
  14448. return {
  14449. templateOptions: {
  14450. refresh: function (APIService, contentId, data) {
  14451. return APIService.fetchDataList(contentId, data);
  14452. },
  14453. downloadUri: function (APIService, contentId) {
  14454. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14455. },
  14456. download: function (APIService, contentId) {
  14457. return APIService.getSolutionDowpath(contentId);
  14458. },
  14459. view: function (attachmentId) {
  14460. // return APIService.attachmentsPreviewUrl(contentId);
  14461. },
  14462. refreshDelay: 0
  14463. }
  14464. };
  14465. },
  14466. controller: ['$scope', '$timeout', '$modal', '$rootScope', 'api_solution', '$http', function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  14467. var _refreshDelayPromise;
  14468. $scope.attachments = [];
  14469. $scope.downloadUrl = function (contentId) {
  14470. return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService, contentId) || '#';
  14471. };
  14472. $scope.download = function (contentId, filename) {
  14473. $http({
  14474. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl(),
  14475. method: 'GET',
  14476. headers: {
  14477. //'Content-type' : 'application/xls',
  14478. 'Accept': '*/*'
  14479. },
  14480. responseType: 'arraybuffer'
  14481. }).success(function (data, status, headers, config) {
  14482. var file = new Blob([data], {
  14483. type: 'application/octet-stream'
  14484. });
  14485. //trick to download store a file having its URL
  14486. var fileURL = URL.createObjectURL(file);
  14487. var a = document.createElement('a');
  14488. a.href = fileURL;
  14489. a.target = '_blank';
  14490. a.download = filename;
  14491. document.body.appendChild(a);
  14492. a.click();
  14493. }).error(function (data, status, headers, config) {
  14494. // console.log(data);
  14495. });
  14496. }
  14497. $scope.view = function (contentId, filename, attachment) {
  14498. var index = filename.indexOf(".");
  14499. var type = filename.substring(index + 1);
  14500. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14501. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  14502. // var modalInstance = $modal.open({
  14503. // backdrop: false,
  14504. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14505. // controller: function($scope, scope, $modalInstance, filename) {
  14506. // $scope.title = filename;
  14507. // $scope.imageurl = scope.imageurl;
  14508. // $scope.cancel = function() {
  14509. // $modalInstance.dismiss('cancel');
  14510. // }
  14511. // },
  14512. // resolve: {
  14513. // scope: function() {
  14514. // return $scope;
  14515. // },
  14516. // filename: function() {
  14517. // return filename;
  14518. // }
  14519. // }
  14520. // });
  14521. // event.preventDefault();
  14522. // } else {
  14523. // for (var i = 0; i < $scope.attachments.length; i++) {
  14524. // if ($scope.attachments[i].id == attachmentId) {
  14525. window.open(attachment.previewUrl);
  14526. // }
  14527. // }
  14528. // }
  14529. };
  14530. $scope._refresh = function (refreshAttr) {
  14531. if (refreshAttr !== undefined) {
  14532. if (_refreshDelayPromise) {
  14533. $timeout.cancel(_refreshDelayPromise);
  14534. }
  14535. _refreshDelayPromise = $timeout(function () {
  14536. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14537. 'file', {
  14538. "file": {
  14539. "solutionId": $scope.model.knowledge.id
  14540. },
  14541. "idx": "0",
  14542. "sum": "1000"
  14543. }).then(function (response) {
  14544. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14545. if (myData) {
  14546. $scope.attachments = myData.list;
  14547. // $scope.view = function(attachmentId) {
  14548. // for (var i = 0; i < $scope.attachments.length; i++) {
  14549. // if ($scope.attachments[i].id == attachmentId) {
  14550. // window.open($scope.attachments[i].previewUrl);
  14551. // // var modalInstance = $modal.open({
  14552. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  14553. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  14554. // // }
  14555. // // });
  14556. // }
  14557. // }
  14558. // };
  14559. }
  14560. });
  14561. }, $scope.options.templateOptions.refreshDelay);
  14562. }
  14563. }
  14564. $scope._refresh({});
  14565. // $scope.attachments = $scope.model[$scope.options.key]
  14566. }]
  14567. });
  14568. //附件图片下载
  14569. formlyConfigProvider.setType({
  14570. name: 'ui-downimage',
  14571. templateUrl: 'assets/views/customform/tpl/ui-downimage.html',
  14572. defaultOptions: function (options) {
  14573. return {
  14574. templateOptions: {
  14575. refresh: function (APIService, processInstanceId, data) {
  14576. return APIService.listAttachments(processInstanceId, data);
  14577. },
  14578. downloadUri: function (APIService, contentId) {
  14579. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14580. },
  14581. view: function (APIService, contentId) {
  14582. return APIService.attachmentsPreviewUrl(contentId);
  14583. },
  14584. download: function (APIService, contentId, item) {
  14585. var item = {
  14586. 'url': APIService.download(contentId),
  14587. 'headers': headers
  14588. };
  14589. return item;
  14590. },
  14591. refreshDelay: 0
  14592. }
  14593. };
  14594. },
  14595. controller: ['$scope', '$timeout', '$rootScope', '$http', function ($scope, $timeout, $rootScope, $http) {
  14596. var _refreshDelayPromise;
  14597. // $scope.downloadUrl = function(contentId){
  14598. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14599. // };
  14600. $scope.download = function (contentId, filename) {
  14601. // var headers=
  14602. $http({
  14603. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14604. method: 'GET',
  14605. headers: {
  14606. //'Content-type' : 'application/xls',
  14607. 'Accept': '*/*'
  14608. },
  14609. responseType: 'arraybuffer'
  14610. }).success(function (data, status, headers, config) {
  14611. var file = new Blob([data], {
  14612. type: 'application/octet-stream'
  14613. });
  14614. //trick to download store a file having its URL
  14615. var fileURL = URL.createObjectURL(file);
  14616. var a = document.createElement('a');
  14617. a.href = fileURL;
  14618. a.target = '_blank';
  14619. a.download = filename;
  14620. document.body.appendChild(a);
  14621. a.click();
  14622. }).error(function (data, status, headers, config) {
  14623. // console.log(data);
  14624. });
  14625. };
  14626. $scope.view = function (contentId) {
  14627. $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14628. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  14629. // if (response.state == 200) {
  14630. // window.open(response.previewUrl);
  14631. // }
  14632. // })
  14633. };
  14634. /**
  14635. * refresh
  14636. */
  14637. $scope._refresh = function (refreshAttr) {
  14638. if (refreshAttr !== undefined) {
  14639. if (_refreshDelayPromise) {
  14640. $timeout.cancel(_refreshDelayPromise);
  14641. }
  14642. _refreshDelayPromise = $timeout(function () {
  14643. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14644. $scope.options.templateOptions.processInstanceId, {
  14645. 'idx': 0,
  14646. 'sum': 1000
  14647. }).then(function (response) {
  14648. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14649. if (myData) {
  14650. $scope.attachments = myData.data;
  14651. }
  14652. });
  14653. }, $scope.options.templateOptions.refreshDelay);
  14654. }
  14655. }
  14656. $scope._refresh({});
  14657. // $scope.attachments = $scope.model[$scope.options.key]
  14658. }]
  14659. });
  14660. //附件下载列表组件
  14661. formlyConfigProvider.setType({
  14662. name: 'ui-dropfiletable',
  14663. templateUrl: 'assets/views/customform/tpl/ui-dropfiletable.html',
  14664. defaultOptions: function (options) {
  14665. return {
  14666. templateOptions: {
  14667. refresh: function (APIService, processInstanceId, data) {
  14668. return APIService.listAttachments(processInstanceId, data);
  14669. },
  14670. downloadUri: function (APIService, contentId) {
  14671. return APIService.downloadAttachment(contentId).getRequestedUrl();
  14672. },
  14673. view: function (APIService, contentId) {
  14674. return APIService.attachmentsPreviewUrl(contentId);
  14675. },
  14676. download: function (APIService, contentId, item) {
  14677. var item = {
  14678. 'url': APIService.download(contentId),
  14679. 'headers': headers
  14680. };
  14681. return item;
  14682. },
  14683. refreshDelay: 0
  14684. }
  14685. };
  14686. },
  14687. controller: ['$scope', '$timeout', '$modal', '$rootScope', '$http', function ($scope, $timeout, $modal, $rootScope, $http) {
  14688. var _refreshDelayPromise;
  14689. // $scope.downloadUrl = function(contentId){
  14690. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14691. // };
  14692. $scope.download = function (contentId, filename) {
  14693. // var headers=
  14694. $http({
  14695. url: $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl(),
  14696. method: 'GET',
  14697. headers: {
  14698. //'Content-type' : 'application/xls',
  14699. 'Accept': '*/*'
  14700. },
  14701. responseType: 'arraybuffer'
  14702. }).success(function (data, status, headers, config) {
  14703. var file = new Blob([data], {
  14704. type: 'application/octet-stream'
  14705. });
  14706. //trick to download store a file having its URL
  14707. var fileURL = URL.createObjectURL(file);
  14708. var a = document.createElement('a');
  14709. a.href = fileURL;
  14710. a.target = '_blank';
  14711. a.download = filename;
  14712. document.body.appendChild(a);
  14713. a.click();
  14714. }).error(function (data, status, headers, config) {
  14715. // console.log(data);
  14716. });
  14717. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  14718. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  14719. // var file = new Blob([response], {
  14720. // type : 'application/octet-stream'
  14721. // });
  14722. // // var filename = filename;
  14723. // //var file = new Blob([response], {type: 'application/pdf'});
  14724. // var fileURL = URL.createObjectURL(file);
  14725. // var a = document.createElement('a');
  14726. // a.href = fileURL;
  14727. // a.target = '_blank';
  14728. // a.download = filename ;
  14729. // document.body.appendChild(a);
  14730. // a.click();
  14731. // })
  14732. };
  14733. $scope.view = function (contentId, token, filename, type) {
  14734. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  14735. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  14736. // var modalInstance = $modal.open({
  14737. // backdrop: false,
  14738. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14739. // controller: function($scope, scope, $modalInstance, filename) {
  14740. // $scope.title = filename;
  14741. // $scope.imageurl = scope.imageurl;
  14742. // $scope.cancel = function() {
  14743. // $modalInstance.dismiss('cancel');
  14744. // }
  14745. // },
  14746. // resolve: {
  14747. // scope: function() {
  14748. // return $scope;
  14749. // },
  14750. // filename: function() {
  14751. // return filename;
  14752. // }
  14753. // }
  14754. // });
  14755. // event.preventDefault();
  14756. // } else {
  14757. $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function (response) {
  14758. if (response.state == 200) {
  14759. window.open(response.previewUrl);
  14760. }
  14761. })
  14762. // }
  14763. };
  14764. /**
  14765. * refresh
  14766. */
  14767. $scope._refresh = function (refreshAttr) {
  14768. if (refreshAttr !== undefined) {
  14769. if (_refreshDelayPromise) {
  14770. $timeout.cancel(_refreshDelayPromise);
  14771. }
  14772. _refreshDelayPromise = $timeout(function () {
  14773. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14774. $scope.options.templateOptions.processInstanceId, {
  14775. 'idx': 0,
  14776. 'sum': 1000
  14777. }).then(function (response) {
  14778. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14779. if (myData) {
  14780. $scope.attachments = myData.data;
  14781. }
  14782. });
  14783. }, $scope.options.templateOptions.refreshDelay);
  14784. }
  14785. }
  14786. $scope._refresh({});
  14787. // $scope.attachments = $scope.model[$scope.options.key]
  14788. }]
  14789. });
  14790. //微信附件下载列表组件
  14791. formlyConfigProvider.setType({
  14792. name: 'ui-dropfilewechat',
  14793. templateUrl: 'assets/views/customform/tpl/ui-dropfilewechat.html',
  14794. defaultOptions: function (options) {
  14795. return {
  14796. templateOptions: {
  14797. // refresh: function(APIService, processInstanceId, data) {
  14798. // return APIService.listAttachments(processInstanceId, data);
  14799. // },
  14800. // downloadUri: function(APIService, contentId) {
  14801. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  14802. // },
  14803. view: function (APIService, contentId) {
  14804. // return APIService.attachmentsPreviewUrl(contentId);
  14805. return APIService.attachmentsPreviewUrl(contentId);
  14806. },
  14807. download: function (APIService, contentId, item) {
  14808. var item = {
  14809. 'url': APIService.download(contentId),
  14810. 'headers': headers
  14811. };
  14812. return item;
  14813. },
  14814. // download: function(APIService, contentId, item) {
  14815. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  14816. // return item;
  14817. // },
  14818. refreshDelay: 0
  14819. }
  14820. };
  14821. },
  14822. controller: ['$scope', '$timeout', '$modal', '$stateParams', '$rootScope', '$http', 'api_wechatfile', function ($scope, $timeout, $modal, $stateParams, $rootScope, $http, api_wechatfile) {
  14823. var _refreshDelayPromise;
  14824. // $scope.downloadUrl = function(contentId){
  14825. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  14826. // };
  14827. $scope.attachments = {};
  14828. $scope.previewUrl = '';
  14829. $scope.download = function (token, filename) {
  14830. // var headers=
  14831. console.log($scope);
  14832. $http({
  14833. url: $scope.options.templateOptions.ApiService.jry_download(token).getRequestedUrl(),
  14834. method: 'GET',
  14835. headers: {
  14836. //'Content-type' : 'application/xls',
  14837. 'Accept': '*/*'
  14838. },
  14839. responseType: 'arraybuffer'
  14840. }).success(function (data, status, headers, config) {
  14841. var file = new Blob([data], {
  14842. type: 'application/octet-stream'
  14843. });
  14844. //trick to download store a file having its URL
  14845. var fileURL = URL.createObjectURL(file);
  14846. var a = document.createElement('a');
  14847. a.href = fileURL;
  14848. a.target = '_blank';
  14849. a.download = filename;
  14850. document.body.appendChild(a);
  14851. a.click();
  14852. }).error(function (data, status, headers, config) {
  14853. // console.log(data);
  14854. });
  14855. };
  14856. $scope.view = function (contentId, token, filename, type, previewUrl) {
  14857. // if (type) {
  14858. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  14859. // var modalInstance = $modal.open({
  14860. // backdrop: false,
  14861. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  14862. // controller: function($scope, scope, $modalInstance, filename) {
  14863. // $scope.title = filename;
  14864. // $scope.imageurl = scope.imageurl;
  14865. // $scope.cancel = function() {
  14866. // $modalInstance.dismiss('cancel');
  14867. // }
  14868. // },
  14869. // resolve: {
  14870. // scope: function() {
  14871. // return $scope;
  14872. // },
  14873. // filename: function() {
  14874. // return filename;
  14875. // }
  14876. // }
  14877. // });
  14878. // event.preventDefault();
  14879. // } else {
  14880. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  14881. // if (response.state == 200) {
  14882. // window.open(response.previewUrl);
  14883. // }
  14884. // })
  14885. window.open(previewUrl);
  14886. // }
  14887. };
  14888. /**
  14889. * refresh
  14890. */
  14891. $scope._refresh = function (refreshAttr) {
  14892. if (refreshAttr !== undefined) {
  14893. if (_refreshDelayPromise) {
  14894. $timeout.cancel(_refreshDelayPromise);
  14895. }
  14896. _refreshDelayPromise = $timeout(function () {
  14897. // console.log(JSON.parse($stateParams.model))
  14898. var incidentChart = {};
  14899. if ($stateParams.model) {
  14900. incidentChart = JSON.parse($stateParams.model).model;
  14901. }
  14902. $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14903. $scope.model).then(function (response) {
  14904. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  14905. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  14906. var myData = $scope.options.templateOptions.Restangular.stripRestangular(response);
  14907. if (myData) {
  14908. $scope.attachments = myData.data;
  14909. }
  14910. });
  14911. }, $scope.options.templateOptions.refreshDelay);
  14912. }
  14913. }
  14914. $scope._refresh({});
  14915. // $scope.attachments = $scope.model[$scope.options.key]
  14916. }]
  14917. });
  14918. formlyConfigProvider.setType({
  14919. name: 'ui-paralleltask',
  14920. templateUrl: 'assets/views/customform/tpl/ui-paralleltask.html',
  14921. defaultOptions: function (options) {
  14922. return {
  14923. templateOptions: {
  14924. refresh: function (APIService, processInstanceId, data) {
  14925. //return APIService.listAttachments(processInstanceId, data);
  14926. },
  14927. refreshDelay: 0
  14928. }
  14929. };
  14930. },
  14931. controller: ['$scope', '$timeout', function ($scope, $timeout) { }]
  14932. });
  14933. //repeatSection
  14934. //
  14935. formlyConfigProvider.setType({
  14936. name: 'ui-repeatSection',
  14937. templateUrl: 'assets/views/customform/tpl/ui-repeatSection.html',
  14938. defaultOptions: function (options) {
  14939. return {
  14940. templateOptions: {
  14941. unique: 1,
  14942. initDisplay: false
  14943. }
  14944. };
  14945. },
  14946. controller: function ($scope) {
  14947. //$scope.options.templateOptions.unique;
  14948. $scope.formOptions = {
  14949. formState: $scope.formState
  14950. };
  14951. $scope.addNew = addNew;
  14952. $scope.copyFields = copyFields;
  14953. function copyFields(fields) {
  14954. fields = angular.copy(fields);
  14955. addRandomIds(fields);
  14956. return fields;
  14957. }
  14958. function addNew() {
  14959. $scope.model[$scope.options.key] = $scope.model[$scope.options.key] || [];
  14960. var repeatsection = $scope.model[$scope.options.key];
  14961. var lastSection = repeatsection[repeatsection.length - 1];
  14962. var newsection = {};
  14963. repeatsection.push(newsection);
  14964. }
  14965. function addRandomIds(fields) {
  14966. $scope.options.templateOptions.unique++;
  14967. angular.forEach(fields, function (field, index) {
  14968. if (field.fieldGroup) {
  14969. addRandomIds(field.fieldGroup);
  14970. return; // fieldGroups don't need an ID
  14971. }
  14972. if (field.templateOptions && field.templateOptions.fields) {
  14973. addRandomIds(field.templateOptions.fields);
  14974. }
  14975. field.id = field.id || (field.key + '_' + index + '_' + $scope.options.templateOptions.unique + getRandomInt(0, 9999));
  14976. });
  14977. }
  14978. function getRandomInt(min, max) {
  14979. return Math.floor(Math.random() * (max - min)) + min;
  14980. }
  14981. if ($scope.options.templateOptions.initDisplay) {
  14982. addNew();
  14983. }
  14984. }
  14985. });
  14986. //时间轴任务列表组件
  14987. //cmdb控件
  14988. formlyConfigProvider.setType({
  14989. name: 'ui-cmdb',
  14990. extends: 'input',
  14991. templateUrl: 'assets/views/customform/tpl/ui-cmdb.html',
  14992. defaultOptions: function (options) {
  14993. return {
  14994. templateOptions: {
  14995. onClick: function (size, options, modal, event, model) {
  14996. var modalInstance = modal.open({
  14997. templateUrl: 'assets/views/customform/tpl/cmdb-modal-content.html',
  14998. controller: function ($scope, $modalInstance, title, Restangular, APIService, ConfigDataService, ConfigFormService, SweetAlert, Toaster, api_wechatfile) {
  14999. var width = $scope.width = 600;
  15000. var height = $scope.height = 400;
  15001. var tree;
  15002. var d3 = window.d3;
  15003. $scope.my_tree_handler = function (branch) {
  15004. //var _ref;
  15005. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  15006. APIService.query({
  15007. 'sign': classify
  15008. }).then(function (data) {
  15009. var myData = Restangular.stripRestangular(data);
  15010. // console.log(myData.data.node);
  15011. if (myData.data && myData.status == 200) {
  15012. var ret = myData.data;
  15013. redrawSvg(myData);
  15014. }
  15015. });
  15016. };
  15017. $scope.my_data = [];
  15018. function convertListToTree(data, treeMap) {
  15019. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  15020. var root = null; //Initially set our loop to null
  15021. var parentNode = null;
  15022. //loop over data
  15023. for (var i = 0; i < data.length; i++) {
  15024. var datum = data[i];
  15025. //each node will have children, so let's give it a "children" poperty
  15026. datum.children = [];
  15027. //add an entry for this node to the map so that any future children can
  15028. //lookup the parent
  15029. idToNodeMap[datum.id] = datum;
  15030. //Does this node have a parent?
  15031. if (typeof datum.parent === "undefined" || datum.parent == null) {
  15032. //Doesn't look like it, so this node is the root of the tree
  15033. root = datum;
  15034. treeMap[datum.id] = root;
  15035. } else {
  15036. //This node has a parent, so let's look it up using the id
  15037. parentNode = idToNodeMap[datum.parent.id];
  15038. //We don't need this property, so let's delete it.
  15039. delete datum.parent;
  15040. //Let's add the current node as a child of the parent node.
  15041. parentNode.children.push(datum);
  15042. }
  15043. }
  15044. return root;
  15045. }
  15046. function convertParentToChildList(data) {
  15047. var treeMap = {};
  15048. var list = [];
  15049. convertListToTree(data, treeMap);
  15050. angular.forEach(treeMap, function (item) {
  15051. list.push(item);
  15052. });
  15053. return list;
  15054. }
  15055. $scope.my_tree = tree = {};
  15056. $scope.try_async_load = function () {
  15057. $scope.my_data = [];
  15058. $scope.select_treedata = [];
  15059. $scope.doing_async = true;
  15060. ConfigDataService.fetchDataList('ciclassify', {
  15061. 'idx': 0,
  15062. 'sum': 100
  15063. }).then(function (result) {
  15064. $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15065. $scope.doing_async = false;
  15066. });
  15067. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  15068. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  15069. // $scope.doing_async = false;
  15070. // });
  15071. };
  15072. $scope.select_treedata = [];
  15073. $scope.propTypeOptions = [];
  15074. $scope.try_async_load();
  15075. $scope.onFilterCallback = function (item) {
  15076. //console.log(item);
  15077. if (angular.isDefined(item.children) && item.children.length >= 1) {
  15078. //not valid
  15079. } else {
  15080. var tempclassify = item.prefix.toLowerCase() + item.sign;
  15081. $scope.cifilter_classic = tempclassify;
  15082. ConfigFormService.renderTabForm(tempclassify).then(function (data) {
  15083. var myData = Restangular.stripRestangular(data);
  15084. $scope.propTypeOptions = myData;
  15085. });
  15086. }
  15087. }
  15088. $scope.onPropTypeChange = function (form) {
  15089. $scope.propOptions = form.fields;
  15090. }
  15091. $scope.onPropChange = function (prop) {
  15092. $scope.cifilter_prop = prop;
  15093. }
  15094. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  15095. //if(searchKey!=null&&searchKey.length>1){
  15096. var searchData = {};
  15097. if (angular.isUndefined(propObj)) {
  15098. propObj = $scope.cifilter_prop;
  15099. }
  15100. if (angular.isUndefined(ciclassify)) {
  15101. ciclassify = $scope.cifilter_classic;
  15102. }
  15103. searchData['sign'] = ciclassify;
  15104. if (angular.isDefined(propObj)) {
  15105. searchData[propObj.key] = searchKey;
  15106. }
  15107. APIService.query(searchData).then(function (response) {
  15108. var data = Restangular.stripRestangular(response);
  15109. //此处不清空nodes
  15110. var node = data.data.node;
  15111. var tempNode = [];
  15112. //nodes 或者links 要去重
  15113. for (var i = 0; i < node.length; i++) {
  15114. var tmp = 0;
  15115. for (var j = 0; j < nodes.length; j++) {
  15116. if (node[i].uuid == nodes[j].uuid) {
  15117. tmp++;
  15118. break;
  15119. }
  15120. }
  15121. if (tmp == 0) {
  15122. tempNode.push(node[i]);
  15123. }
  15124. }
  15125. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15126. nodes.push(tempNode[i]);
  15127. }
  15128. restart();
  15129. })
  15130. }
  15131. $scope.refresh = function () {
  15132. nodes.length = 0;
  15133. links.length = 0;
  15134. restart();
  15135. }
  15136. $scope.traversal = function () {
  15137. if ($scope.selected_node == null) {
  15138. SweetAlert.swal({
  15139. title: "错误的操作!",
  15140. text: "没有配置项被选中!",
  15141. type: "error"
  15142. });
  15143. } else {
  15144. var uuid = $scope.selected_node.uuid;
  15145. APIService.traversal(uuid).then(function (response) {
  15146. var d = response.data;
  15147. var node = d.node;
  15148. var link = d.edge;
  15149. var tempNode = [];
  15150. var tempLink = [];
  15151. //nodes 或者links 要去重
  15152. for (var i = 0; i < node.length; i++) {
  15153. var tmp = 0;
  15154. for (var j = 0; j < nodes.length; j++) {
  15155. if (node[i].id == nodes[j].id) {
  15156. tmp++;
  15157. break;
  15158. }
  15159. }
  15160. if (tmp == 0) {
  15161. tempNode.push(node[i]);
  15162. }
  15163. }
  15164. for (var i = 0; i < link.length; i++) {
  15165. var tmp = 0;
  15166. for (var j = 0; j < links.length; j++) {
  15167. if (link[i].id == links[j].id) {
  15168. tmp++;
  15169. break;
  15170. }
  15171. }
  15172. if (tmp == 0) {
  15173. tempLink.push(link[i]);
  15174. }
  15175. }
  15176. //数据写入页面
  15177. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15178. nodes.push(tempNode[i]);
  15179. }
  15180. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15181. links.push(tempLink[i]);
  15182. }
  15183. //links转换
  15184. for (var i = 0; i < links.length; i++) {
  15185. for (var j = 0; j < nodes.length; j++) {
  15186. if (links[i].source == nodes[j].id) {
  15187. links[i].source = nodes[j];
  15188. }
  15189. if (links[i].target == nodes[j].id) {
  15190. links[i].target = nodes[j];
  15191. }
  15192. }
  15193. }
  15194. restart();
  15195. })
  15196. }
  15197. }
  15198. var svg;
  15199. var force;
  15200. var drag_line, path, circle;
  15201. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  15202. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15203. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15204. var nodes = [],
  15205. links = [];
  15206. var treeNodes = [];
  15207. //读取labels (node)
  15208. var labels = [];
  15209. function redrawSvg(json) {
  15210. nodes.length = 0; //先清空
  15211. links.length = 0;
  15212. var data = json.data;
  15213. for (var i = 0; i < data.node.length; i++) {
  15214. nodes.push(data.node[i]);
  15215. }
  15216. restart();
  15217. }
  15218. //读取status (节点 连线)
  15219. var statuses = [];
  15220. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  15221. // if (result && result.status == 200) {
  15222. // d3.select('#nodeStatus').selectAll('option')
  15223. // .data(statuses).enter()
  15224. // .append('option')
  15225. // .attr('value', function(d) { return d.code; })
  15226. // .html(function(d) { return d.desc; });
  15227. // } else {
  15228. // SweetAlert.swal({
  15229. // title: "提示!",
  15230. // text: "服务器请求异常!",
  15231. // type: "error"
  15232. // });
  15233. // }
  15234. // });
  15235. api_wechatfile.getDictionary({
  15236. 'key': 'cmdb_status',
  15237. 'type': 'list'
  15238. }).then(function (result) {
  15239. if (result) {
  15240. d3.select('#nodeStatus').selectAll('option')
  15241. .data(statuses).enter()
  15242. .append('option')
  15243. .attr('value', function (d) {
  15244. return d.code;
  15245. })
  15246. .html(function (d) {
  15247. return d.desc;
  15248. });
  15249. } else {
  15250. SweetAlert.swal({
  15251. title: "提示!",
  15252. text: "服务器请求异常!",
  15253. type: "error"
  15254. });
  15255. }
  15256. });
  15257. //查询relationship_type表 name 为表里的type,label为显示值
  15258. var linkType = [];
  15259. function fetchEdgeTypes() {
  15260. ConfigDataService.fetchDataList('ciedgetype', {
  15261. 'idx': 0,
  15262. 'sum': 100
  15263. }).then(function (response) {
  15264. if (response) {
  15265. if (response['list']) {
  15266. linkType = response['list'];
  15267. // d3.select('#linkName').selectAll('option')
  15268. // .data(linkType).enter()
  15269. // .append('option')
  15270. // .attr('value',function(d){return d.type;})
  15271. // .html(function(d){ return d.label;});
  15272. } else {
  15273. SweetAlert.swal({
  15274. title: "提示!",
  15275. text: "服务器请求异常!",
  15276. type: "error"
  15277. });
  15278. }
  15279. } else {
  15280. SweetAlert.swal({
  15281. title: "提示!",
  15282. text: "服务器请求异常!",
  15283. type: "error"
  15284. });
  15285. }
  15286. })
  15287. }
  15288. // fetchEdgeTypes();
  15289. /*
  15290. // init D3 force layout
  15291. var force = d3.layout.force()
  15292. .nodes(nodes)
  15293. .links(links)
  15294. .size([width, height])
  15295. .gravity(.05)
  15296. .linkDistance(150)
  15297. .linkStrength(2)
  15298. .charge(-500)
  15299. .on('tick', tick);
  15300. // define arrow markers for graph links
  15301. svg.append('svg:defs').append('svg:marker')
  15302. .attr('id', 'end-arrow')
  15303. .attr('viewBox', '0 -5 10 10')
  15304. .attr('refX', 6)
  15305. .attr('markerWidth', 3)
  15306. .attr('markerHeight', 3)
  15307. .attr('orient', 'auto')
  15308. .append('svg:path')
  15309. .attr('d', 'M0,-5L10,0L0,5')
  15310. .attr('fill', '#000');
  15311. svg.append('svg:defs').append('svg:marker')
  15312. .attr('id', 'start-arrow')
  15313. .attr('viewBox', '0 -5 10 10')
  15314. .attr('refX', 4)
  15315. .attr('markerWidth', 3)
  15316. .attr('markerHeight', 3)
  15317. .attr('orient', 'auto')
  15318. .append('svg:path')
  15319. .attr('d', 'M10,-5L0,0L10,5')
  15320. .attr('fill', '#000');
  15321. // line displayed when dragging new nodes
  15322. var drag_line = svg.append('svg:path')
  15323. .attr('class', 'link dragline hidden')
  15324. .attr('d', 'M0,0L0,0');
  15325. // handles to link and node element groups
  15326. //(1)var path = svg.append('svg:g').selectAll('g')
  15327. var path = svg.append('svg:g').selectAll('g'),
  15328. circle = svg.append('svg:g').selectAll('g');
  15329. */
  15330. // mouse event vars
  15331. var selected_node = null,
  15332. selected_link = null,
  15333. mousedown_link = null,
  15334. mousedown_node = null,
  15335. mouseup_node = null;
  15336. function resetMouseVars() {
  15337. mousedown_node = null;
  15338. mouseup_node = null;
  15339. mousedown_link = null;
  15340. }
  15341. // update force layout (called automatically each iteration)
  15342. function tick() {
  15343. // draw directed edges with proper padding from node centers
  15344. path.selectAll('path').attr('d', function (d) {
  15345. var deltaX = d.target.x - d.source.x,
  15346. deltaY = d.target.y - d.source.y,
  15347. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  15348. normX = deltaX / dist,
  15349. normY = deltaY / dist,
  15350. sourcePadding = d.left ? 27 : 22,
  15351. targetPadding = d.right ? 27 : 22,
  15352. sourceX = d.source.x + (sourcePadding * normX),
  15353. sourceY = d.source.y + (sourcePadding * normY),
  15354. targetX = d.target.x - (targetPadding * normX),
  15355. targetY = d.target.y - (targetPadding * normY);
  15356. return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
  15357. });
  15358. circle.attr('transform', function (d) {
  15359. return 'translate(' + d.x + ',' + d.y + ')';
  15360. });
  15361. }
  15362. // update graph (called when needed)
  15363. function restart() {
  15364. //绑定link 数据
  15365. path.datum(links);
  15366. // path (link) group
  15367. path = path.data(links, function (d) {
  15368. return d.id;
  15369. });
  15370. var p = path.enter().append('svg:g');
  15371. //update existing links
  15372. path.selectAll('path').classed('selected', function (d) {
  15373. return d === selected_link;
  15374. })
  15375. .style('marker-start', function (d) {
  15376. return d.left ? 'url(#start-arrow)' : '';
  15377. })
  15378. .style('marker-end', function (d) {
  15379. return d.right ? 'url(#end-arrow)' : '';
  15380. });
  15381. // add new links
  15382. p.append('svg:path')
  15383. .attr('class', 'link')
  15384. .attr('id', function (d) {
  15385. return "path_" + d.id;
  15386. })
  15387. // .attr('startOffset', '0%')
  15388. .classed('selected', function (d) {
  15389. return d === selected_link;
  15390. })
  15391. .style('marker-start', function (d) {
  15392. return d.left ? 'url(#start-arrow)' : '';
  15393. })
  15394. .style('marker-end', function (d) {
  15395. return d.right ? 'url(#end-arrow)' : '';
  15396. })
  15397. .on('mousedown', function (d) {
  15398. if (d3.event.ctrlKey) return;
  15399. //去除没有提交的连线
  15400. for (var i = 0; i < links.length; i++) {
  15401. if (links[i].id == -1 && d.id != -1) {
  15402. links.splice(i, 1);
  15403. }
  15404. }
  15405. // select link
  15406. mousedown_link = d;
  15407. if (mousedown_link === selected_link) {
  15408. selected_link = $scope.selected_link = null;
  15409. selected_node = $scope.selected_node = null;
  15410. // d3.select("#linkDetail").attr('style','display:none');
  15411. //hideLinkForm(true);//return ;
  15412. } else {
  15413. selected_link = $scope.selected_link = mousedown_link;
  15414. selected_node = $scope.selected_node = null;
  15415. }
  15416. selected_node = $scope.selected_node = null;
  15417. restart();
  15418. });
  15419. p.append('svg:text')
  15420. .attr('x', 30)
  15421. .attr('y', 20)
  15422. .attr('class', 'fontM')
  15423. .append('textPath')
  15424. .attr('xlink:xlink:href', function (d, i) {
  15425. return "#path_" + d.id;
  15426. })
  15427. .html(function (d) {
  15428. for (var i = 0; i < linkType.length; i++) {
  15429. if (linkType[i].type == d.name) {
  15430. return linkType[i].label;
  15431. }
  15432. }
  15433. });
  15434. // remove old links
  15435. path.exit().remove();
  15436. // circle (node) group
  15437. // NB: the function arg is crucial here! nodes are known by id, not by index!
  15438. circle.datum(nodes);
  15439. circle = circle.data(nodes, function (d) {
  15440. return d.id;
  15441. });
  15442. // update existing nodes (reflexive & selected visual states)
  15443. circle.selectAll('circle')
  15444. .style('fill', function (d) {
  15445. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15446. })
  15447. .style('fill-opacity', 0.75) // add by xi
  15448. .classed('reflexive', function (d) {
  15449. return d.reflexive;
  15450. });
  15451. // add new nodes
  15452. var g = circle.enter().append('svg:g');
  15453. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  15454. //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');
  15455. g.append('svg:circle').attr('r', 24).style('fill', function (d) {
  15456. return (d === selected_node) ? 'rgb(153,153,153)' : 'rgb(255,255,255)';
  15457. }).style('stroke', function (d) {
  15458. return d3.rgb(colors(d.label)).darker().toString();
  15459. }).style('stroke-width', '2');
  15460. g.append('svg:circle')
  15461. .attr('class', 'node')
  15462. .attr('r', 18)
  15463. .style('fill', function (d) {
  15464. return (d === selected_node) ? d3.rgb(colors(d.label)).brighter().toString() : colors(d.label);
  15465. })
  15466. .style('stroke', function (d) {
  15467. return d3.rgb(colors(d.label)).darker().toString();
  15468. })
  15469. .style('fill-opacity', 0.25) //add by xj
  15470. .style('stroke-opacity', 0.5) //add by xj
  15471. .classed('reflexive', function (d) {
  15472. return d.reflexive;
  15473. });
  15474. g.on('mouseover', function (d) {
  15475. //if(!mousedown_node || d === mousedown_node) return;
  15476. // enlarge target node
  15477. //d3.select(this).attr('transform', 'scale(1.1)');
  15478. })
  15479. .on('mouseout', function (d) {
  15480. //if(!mousedown_node || d === mousedown_node) return;
  15481. // unenlarge target node
  15482. //d3.select(this).attr('transform', '');
  15483. })
  15484. .on('mousedown', function (d) {
  15485. if (d3.event.ctrlKey) return;
  15486. //hideLinkForm(true);
  15487. //去除没有提交的连线
  15488. for (var i = 0; i < links.length; i++) {
  15489. if (links[i].id == -1) {
  15490. links.splice(i, 1);
  15491. }
  15492. }
  15493. // select node
  15494. mousedown_node = d;
  15495. if (mousedown_node === selected_node) {
  15496. selected_node = $scope.selected_node = null;
  15497. } else {
  15498. selected_node = $scope.selected_node = mousedown_node;
  15499. selected_link = $scope.selected_link = null;
  15500. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  15501. APIService.findRefById(selected_node.id).then(function (result) {
  15502. var d = result.data;
  15503. var node = d.node;
  15504. var link = d.edge;
  15505. var tempNode = [];
  15506. var tempLink = [];
  15507. //nodes 或者links 要去重
  15508. for (var i = 0; i < node.length; i++) {
  15509. var tmp = 0;
  15510. for (var j = 0; j < nodes.length; j++) {
  15511. if (node[i].id == nodes[j].id) {
  15512. tmp++;
  15513. break;
  15514. }
  15515. }
  15516. if (tmp == 0) {
  15517. tempNode.push(node[i]);
  15518. }
  15519. }
  15520. for (var i = 0; i < link.length; i++) {
  15521. var tmp = 0;
  15522. for (var j = 0; j < links.length; j++) {
  15523. if (link[i].id == links[j].id) {
  15524. tmp++;
  15525. break;
  15526. }
  15527. }
  15528. if (tmp == 0) {
  15529. tempLink.push(link[i]);
  15530. }
  15531. }
  15532. //数据写入页面
  15533. for (var i = 0; i < tempNode.length; i++) { //nodes 不清空
  15534. nodes.push(tempNode[i]);
  15535. }
  15536. for (var i = 0; i < tempLink.length; i++) { //link 不清空
  15537. links.push(tempLink[i]);
  15538. }
  15539. //links转换
  15540. for (var i = 0; i < links.length; i++) {
  15541. for (var j = 0; j < nodes.length; j++) {
  15542. if (links[i].source == nodes[j].id) {
  15543. links[i].source = nodes[j];
  15544. }
  15545. if (links[i].target == nodes[j].id) {
  15546. links[i].target = nodes[j];
  15547. }
  15548. }
  15549. }
  15550. restart();
  15551. });
  15552. }
  15553. // reposition drag line
  15554. drag_line
  15555. .style('marker-end', 'url(#end-arrow)')
  15556. .classed('hidden', false)
  15557. .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y);
  15558. restart();
  15559. })
  15560. .on('mouseup', function (d) {
  15561. if (!mousedown_node) return;
  15562. });
  15563. // show node name
  15564. g.append('svg:text')
  15565. .attr('x', 0)
  15566. .attr('y', 34)
  15567. .attr('class', 'id')
  15568. .text(function (d) {
  15569. return d.name;
  15570. }); //TODO 改为 d.name
  15571. //设置图片
  15572. g.append('svg:foreignObject')
  15573. .attr("width", 32)
  15574. .attr("height", 32)
  15575. .attr('x', "-16px")
  15576. .attr('y', "-11px")
  15577. .html(function (d) {
  15578. for (var i = 0; i < labels.length; i++) {
  15579. if (d.label == labels[i].sign) {
  15580. return '<i class="icon iconfont">' + labels[i].iconname + '</i>';
  15581. }
  15582. }
  15583. });
  15584. // remove old nodes
  15585. circle.exit().remove();
  15586. // set the graph in motion
  15587. force.start();
  15588. }
  15589. function mousedown() {
  15590. // prevent I-bar on drag
  15591. //d3.event.preventDefault();
  15592. // because :active only works in WebKit?
  15593. svg.classed('active', true);
  15594. if (mousedown_node) {
  15595. viewNode(mousedown_node);
  15596. }
  15597. if (d3.event.ctrlKey || mousedown_node || mousedown_link) return;
  15598. restart();
  15599. }
  15600. function mousemove() {
  15601. if (!mousedown_node) return;
  15602. // update drag line
  15603. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  15604. //restart();
  15605. }
  15606. function mouseup() {
  15607. if (mousedown_node) {
  15608. // hide drag line
  15609. drag_line
  15610. .classed('hidden', true)
  15611. .style('marker-end', '');
  15612. }
  15613. // because :active only works in WebKit?
  15614. svg.classed('active', false);
  15615. // clear mouse event vars
  15616. resetMouseVars();
  15617. }
  15618. function spliceLinksForNode(node) {
  15619. var toSplice = links.filter(function (l) {
  15620. return (l.source === node || l.target === node);
  15621. });
  15622. toSplice.map(function (l) {
  15623. links.splice(links.indexOf(l), 1);
  15624. });
  15625. }
  15626. // only respond once per keydown
  15627. var lastKeyDown = -1;
  15628. function keydown() {
  15629. //d3.event.preventDefault();
  15630. if (lastKeyDown !== -1) return;
  15631. lastKeyDown = d3.event.keyCode;
  15632. // ctrl
  15633. if (d3.event.keyCode === 17) {
  15634. circle.call(force.drag);
  15635. svg.classed('ctrl', true);
  15636. }
  15637. if (!selected_node && !selected_link) return;
  15638. switch (d3.event.keyCode) {
  15639. case 8: // backspace
  15640. case 66: // B
  15641. if (selected_link) {
  15642. // set link direction to both left and right
  15643. selected_link.left = true;
  15644. selected_link.right = true;
  15645. }
  15646. restart();
  15647. break;
  15648. case 76: // L
  15649. if (selected_link) {
  15650. // set link direction to left only
  15651. selected_link.left = true;
  15652. selected_link.right = false;
  15653. }
  15654. restart();
  15655. break;
  15656. case 82: // R
  15657. if (selected_node) {
  15658. // toggle node reflexivity
  15659. selected_node.reflexive = !selected_node.reflexive;
  15660. } else if (selected_link) {
  15661. // set link direction to right only
  15662. selected_link.left = false;
  15663. selected_link.right = true;
  15664. }
  15665. restart();
  15666. break;
  15667. }
  15668. }
  15669. function keyup() {
  15670. lastKeyDown = -1;
  15671. // ctrl
  15672. if (d3.event.keyCode === 17) {
  15673. circle
  15674. .on('mousedown.drag', null)
  15675. .on('touchstart.drag', null);
  15676. svg.classed('ctrl', false);
  15677. }
  15678. }
  15679. function viewNode(node) {
  15680. // console.log(svg.attr('left'));
  15681. //var el = angular.element('div.modal-dialog')[0];
  15682. var title = $scope.selected_node.name + "-[" + $scope.selected_node.uuid + "]";
  15683. if (!$scope.selected_node.props.state) {
  15684. $scope.selected_node.props.state = "空"
  15685. } else if ($scope.selected_node.props.state) {
  15686. if ($scope.selected_node.props.state == "1") {
  15687. $scope.selected_node.props.state = "未审核"
  15688. } else if ($scope.selected_node.props.state == "2") {
  15689. $scope.selected_node.props.state = "已审核"
  15690. } else if ($scope.selected_node.props.state == "3") {
  15691. $scope.selected_node.props.state = "不匹配"
  15692. } else if ($scope.selected_node.props.state == "4") {
  15693. $scope.selected_node.props.state = "丢失"
  15694. }
  15695. };
  15696. if (!$scope.selected_node.name) {
  15697. $scope.selected_node.name = "空"
  15698. }
  15699. if (!$scope.selected_node.status) {
  15700. $scope.selected_node.statu = "空"
  15701. }
  15702. if (!$scope.selected_node.props.useradmin) {
  15703. $scope.selected_node.props.useradmin = "空"
  15704. }
  15705. Toaster.pop({
  15706. // type: 'info',
  15707. // title: title,
  15708. body: '<br/><p>搜索代码:' + $scope.selected_node.uuid + '</p>' +
  15709. '<p>配置标题:' + $scope.selected_node.name + '</p>' +
  15710. '<p>状态:' + $scope.selected_node.status + '</p>' +
  15711. '<p>审核状态:' + $scope.selected_node.props.state + '</p>' +
  15712. '<p>维护人员:' + $scope.selected_node.props.useradmin + '</p>',
  15713. bodyOutputType: 'trustedHtml',
  15714. timeout: 3000
  15715. })
  15716. }
  15717. //GT 颜色与数值对照表
  15718. function colors(sign) {
  15719. //num=num>20?num%20:parseInt(num);
  15720. for (var i = 0; i < labels.length; i++) {
  15721. var entity = labels[i];
  15722. if (sign == entity.sign) {
  15723. return entity.color;
  15724. }
  15725. if (i == labels.length - 1 && sign != entity.sign) {
  15726. return '#ffeeee';
  15727. }
  15728. }
  15729. }
  15730. $scope.init = function () {
  15731. svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  15732. // init D3 force layout
  15733. force = d3.layout.force()
  15734. .nodes(nodes)
  15735. .links(links)
  15736. .size([width, height])
  15737. .gravity(.05)
  15738. .linkDistance(150)
  15739. .linkStrength(2)
  15740. .charge(-500)
  15741. .on('tick', tick);
  15742. // define arrow markers for graph links
  15743. svg.append('svg:defs').append('svg:marker')
  15744. .attr('id', 'end-arrow')
  15745. .attr('viewBox', '0 -5 10 10')
  15746. .attr('refX', 6)
  15747. .attr('markerWidth', 3)
  15748. .attr('markerHeight', 3)
  15749. .attr('orient', 'auto')
  15750. .append('svg:path')
  15751. .attr('d', 'M0,-5L10,0L0,5')
  15752. .attr('fill', '#000');
  15753. svg.append('svg:defs').append('svg:marker')
  15754. .attr('id', 'start-arrow')
  15755. .attr('viewBox', '0 -5 10 10')
  15756. .attr('refX', 4)
  15757. .attr('markerWidth', 3)
  15758. .attr('markerHeight', 3)
  15759. .attr('orient', 'auto')
  15760. .append('svg:path')
  15761. .attr('d', 'M10,-5L0,0L10,5')
  15762. .attr('fill', '#000');
  15763. // line displayed when dragging new nodes
  15764. drag_line = svg.append('svg:path')
  15765. .attr('class', 'link dragline hidden')
  15766. .attr('d', 'M0,0L0,0');
  15767. // handles to link and node element groups
  15768. //(1)var path = svg.append('svg:g').selectAll('g')
  15769. path = svg.append('svg:g').selectAll('g');
  15770. circle = svg.append('svg:g').selectAll('g');
  15771. svg.on('mousedown', mousedown)
  15772. .on('mousemove', mousemove)
  15773. .on('mouseup', mouseup);
  15774. d3.select(window)
  15775. .on('keydown', keydown)
  15776. .on('keyup', keyup);
  15777. }
  15778. var CI = {};
  15779. window.CI = CI;
  15780. $scope.ok = function () {
  15781. $modalInstance.close($scope.selected_node);
  15782. };
  15783. $scope.cancel = function () {
  15784. $modalInstance.dismiss('cancel');
  15785. };
  15786. },
  15787. size: size,
  15788. resolve: {
  15789. title: function () {
  15790. return options.templateOptions.title;
  15791. },
  15792. Restangular: function () {
  15793. return options.templateOptions.Restangular;
  15794. },
  15795. APIService: function () {
  15796. return options.templateOptions.ApiService;
  15797. },
  15798. ConfigDataService: function () {
  15799. return options.templateOptions.ConfigDataService;
  15800. },
  15801. ConfigFormService: function () {
  15802. return options.templateOptions.ConfigFormService;
  15803. },
  15804. SweetAlert: function () {
  15805. return options.templateOptions.Alert;
  15806. },
  15807. Toaster: function () {
  15808. return options.templateOptions.toaster;
  15809. }
  15810. }
  15811. });
  15812. modalInstance.result.then(function (selectedItem) {
  15813. options.value(selectedItem.name + '-' + selectedItem.uuid);
  15814. }, function () {
  15815. //console.log('Modal dismissed at: ' + new Date());
  15816. });
  15817. }
  15818. }
  15819. }
  15820. },
  15821. controller: ['$scope', function ($scope) {
  15822. // setTimeout(function(){
  15823. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  15824. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  15825. // if(modelData.status==200){
  15826. // $scope.model[$scope.options.key] = modelData.data;
  15827. // $scope.options.initialValue = $scope.model[$scope.options.key];
  15828. // }
  15829. // });
  15830. // },1000);
  15831. }]
  15832. });
  15833. });
  15834. appFormly.run(function (formlyConfig, $parse) {
  15835. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  15836. var removeOnHideTransformer = function (fields, model) {
  15837. return fields.map(function (field) {
  15838. if (field.hideExpression && (!field.data || !field.data.dontRemoveOnHidden)) {
  15839. addFieldRemoveOnHideWatcher(field);
  15840. }
  15841. if (field.type == "ui-title") {
  15842. addFieldRemoveOnHideWatcher(field);
  15843. }
  15844. return field;
  15845. });
  15846. };
  15847. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  15848. function addFieldRemoveOnHideWatcher(field) {
  15849. var watcher = getWatcher();
  15850. if (field.watcher) {
  15851. if (!angular.isArray(field.watcher)) {
  15852. field.watcher = [field.watcher];
  15853. }
  15854. field.watcher.push(watcher);
  15855. } else {
  15856. field.watcher = watcher;
  15857. }
  15858. }
  15859. function getWatcher() {
  15860. return {
  15861. expression: function (field) {
  15862. return field.hide;
  15863. },
  15864. listener: function (field, newHide, oldHide, scope) {
  15865. if (field.hide) {
  15866. if (field.templateOptions.pkey) {
  15867. if (field.key == 'transferuser') {
  15868. $parse(field.templateOptions.pkey + "." + field.key).assign(scope.model, undefined);
  15869. }
  15870. } else {
  15871. $parse(field.key).assign(scope.model, undefined);
  15872. }
  15873. }
  15874. if (field.type == "ui-title") {
  15875. $parse(field.key).assign(scope.model, undefined);
  15876. }
  15877. }
  15878. };
  15879. }
  15880. });
  15881. 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',
  15882. 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) {
  15883. //console.log($parse('Restangular')($scope));
  15884. //console.log($injector.get('Restangular'));
  15885. //console.log($stateParams);
  15886. //保存报修主体
  15887. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15888. $scope.imgUrlList = [];
  15889. $scope.uploadimg_del = function () {
  15890. console.log(123)
  15891. };
  15892. var vm = this;
  15893. vm.options = {};
  15894. vm.exampleTitle = ['expressionProperties', 'model property'];
  15895. vm.fields = [];
  15896. vm.model = {};
  15897. $scope.langs = i18nService.getAllLangs();
  15898. $scope.lang = 'zh-cn';
  15899. i18nService.setCurrentLang($scope.lang);
  15900. //alert($rootScope.user.id,null,2);
  15901. vm.model["loginUser"] = $rootScope.user;
  15902. var loginUser = $rootScope.user;
  15903. // console.log(vm);
  15904. var that = $injector;
  15905. var parse = $parse;
  15906. var formKey = "";
  15907. var pdKey = "";
  15908. var modelWatch = "";
  15909. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  15910. modelWatch = JSON.parse($stateParams.model);
  15911. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  15912. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  15913. console.log(modelWatch,$rootScope)
  15914. // if(modelWatch.model.incident){
  15915. // if(modelWatch.model.incident.place){
  15916. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  15917. // }else{
  15918. // $rootScope.selecthouseNumber = undefined;
  15919. // }
  15920. // }
  15921. }
  15922. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  15923. pdKey = $state.current.pdKey;
  15924. } else if ($stateParams.pdKey) {
  15925. pdKey = $stateParams.pdKey;
  15926. }
  15927. // console.log("pdKey::" + JSON.stringify($state.current.title));
  15928. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  15929. formKey = $stateParams.formKey;
  15930. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  15931. }
  15932. if (angular.isDefined($stateParams.model)) {
  15933. var formModel = $stateParams.model;
  15934. }
  15935. //用户测试数据,后续从header的auth中获取
  15936. var userId = 2;
  15937. userId = $rootScope.user.id;
  15938. //==============处理表单设计数据 开始====================
  15939. //处理组件加载后台数据选项的方法
  15940. function refreshSelectOptions(searchVal, field) {
  15941. if (field.templateOptions.optionsUrl && !field.templateOptions.isnosearch) {
  15942. var process = BpmRestangular.all("");
  15943. if (field.templateOptions.ApiService) {
  15944. process = UserRestangular.all("");
  15945. }
  15946. if (field.templateOptions.Apicommon) {
  15947. process = WechatRestangular.all("");
  15948. }
  15949. var datakey = {
  15950. "idx": 0,
  15951. "sum": 1000
  15952. };
  15953. if (field.templateOptions.modelreasondata) {
  15954. datakey = field.templateOptions.modelreasondata
  15955. }
  15956. process.customPOST(datakey, field.templateOptions.optionsUrl).then(function (result) {
  15957. if (!field.templateOptions.options) {
  15958. field.templateOptions.options = [];
  15959. }
  15960. if (field.templateOptions.optionsDataKey) {
  15961. field.templateOptions.options = result[field.templateOptions.optionsDataKey];
  15962. } else {
  15963. field.templateOptions.options = result;
  15964. }
  15965. });
  15966. }
  15967. }
  15968. //获取表单后数据处理
  15969. function formfield(field, result) {
  15970. // angular.forEach(fields.fields, function(field) {
  15971. if (field.key == "") {
  15972. delete field.key;
  15973. }
  15974. if (angular.isDefined(field.extjson)) {
  15975. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  15976. angular.extend(field.templateOptions, extObj.templateOptions);
  15977. delete extObj.templateOptions;
  15978. for (var prop in extObj) {
  15979. if (new RegExp("Expression").test(prop)) {
  15980. //var obj = $scope.$eval(extObj[prop]);
  15981. //extObj[prop] = $scope.$eval(extObj[prop]);
  15982. if (extObj[prop] != null) {
  15983. if (new RegExp("function").test(extObj[prop])) {
  15984. var propValue = eval(extObj[prop]);
  15985. extObj[prop] = propValue;
  15986. } else {
  15987. //console.log(extObj[prop]);
  15988. var obj = $scope.$eval(extObj[prop]);
  15989. extObj[prop] = obj;
  15990. //console.log(obj);
  15991. }
  15992. }
  15993. } else if (new RegExp("expressionProperties").test(prop)) {
  15994. for (var p in extObj[prop]) {
  15995. if (new RegExp("function").test(extObj[prop][p])) {
  15996. var propValue = eval(extObj[prop][p]);
  15997. extObj[prop][p] = propValue;
  15998. } else {
  15999. //if(p.indexOf("'")>=0){
  16000. // var obj = $scope.$eval(extObj[prop][p]);
  16001. // extObj[prop][$scope.$eval(p)]=obj;
  16002. //}
  16003. }
  16004. }
  16005. } else if ("watcher" == prop) {
  16006. if (angular.isArray(extObj[prop])) {
  16007. angular.forEach(extObj[prop], function (item, index) {
  16008. for (var p in item) {
  16009. if (new RegExp("function").test(item[p])) {
  16010. var propValue = eval(item[p]);
  16011. extObj[prop][index][p] = propValue;
  16012. }
  16013. }
  16014. });
  16015. } else if (angular.isObject(extObj[prop])) {
  16016. for (var p in extObj[prop]) {
  16017. if (new RegExp("function").test(extObj[prop][p])) {
  16018. var propValue = eval(extObj[prop][p]);
  16019. extObj[prop][p] = propValue;
  16020. }
  16021. }
  16022. }
  16023. }
  16024. }
  16025. angular.extend(field, extObj);
  16026. delete field.extjson;
  16027. }
  16028. if (angular.isDefined(field.templateOptions)) {
  16029. var templateOs = field.templateOptions;
  16030. // console.log(templateOs,'come')
  16031. for (var property in templateOs) {
  16032. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  16033. if (angular.isString(templateOs[property])) { //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  16034. if (new RegExp("function").test(templateOs[property])) {
  16035. var propValue = eval(templateOs[property]);
  16036. field.templateOptions[property] = propValue;
  16037. } else {
  16038. if (that.has(templateOs[property])) {
  16039. field.templateOptions[property] = that.get(templateOs[property]);
  16040. } else {
  16041. field.templateOptions[property] = templateOs[property];
  16042. }
  16043. }
  16044. } else if (templateOs[property] == null) {
  16045. //delete field.templateOptions[property];
  16046. } else { }
  16047. }
  16048. }
  16049. if (angular.isDefined(field.templateOptions) && angular.isDefined(field.templateOptions.extjson)) {
  16050. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  16051. angular.extend(field.templateOptions, extObj);
  16052. delete field.templateOptions.extjson;
  16053. }
  16054. // ...
  16055. if (field.templateOptions) {
  16056. //处理远程获取数据控件方法调用
  16057. if (field.templateOptions.optionsUrl && !field.templateOptions.refresh) {
  16058. // if (!field.templateOptions.isnoreash) {
  16059. field.templateOptions.refresh = refreshSelectOptions;
  16060. // }
  16061. }
  16062. //处理嵌套属性数据绑定/
  16063. if (field.templateOptions.pkey) {
  16064. var pmodel, i = 0;
  16065. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  16066. if (i == 0) {
  16067. if (result.model[p] == null) {
  16068. result.model[p] = {};
  16069. }
  16070. pmodel = result.model[p];
  16071. i++;
  16072. } else {
  16073. if (pmodel[p] == null) {
  16074. pmodel[p] = {};
  16075. }
  16076. pmodel = pmodel[p];
  16077. }
  16078. });
  16079. if (pmodel != null) {
  16080. field.model = pmodel;
  16081. if (pmodel[field.key] == null) {
  16082. pmodel[field.key] = null;
  16083. }
  16084. }
  16085. } else {
  16086. if (result.model[field.key] == null) {
  16087. result.model[field.key] = null;
  16088. }
  16089. }
  16090. //处理弹出框组件初始化
  16091. if (field.type == "ui-input-selectmodal") {
  16092. field.templateOptions.modal = $modal;
  16093. //field.templateOptions.Restangular = Restangular;
  16094. } else if (field.type == "ui-requesterselect") {
  16095. //field.templateOptions.language = $scope.lang;
  16096. field.templateOptions.modal = $modal;
  16097. field.templateOptions.UserService = api_user_data;
  16098. } else if (field.type == "ui-deptinformation") {
  16099. field.templateOptions.modal = $modal;
  16100. field.templateOptions.UserService = api_user_data;
  16101. } else if (field.type == "ui-requesterinformation") {
  16102. field.templateOptions.modal = $modal;
  16103. field.templateOptions.UserService = api_user_data;
  16104. } else if (field.type == "ui-userselect") {
  16105. field.templateOptions.modal = $modal;
  16106. //field.templateOptions.Restangular = Restangular;
  16107. } else if (field.type == "ui-userselectSearch") {
  16108. field.templateOptions.modal = $modal;
  16109. //field.templateOptions.Restangular = Restangular;
  16110. } else if (field.type == "ui-multiuserselect") {
  16111. field.templateOptions.modal = $modal;
  16112. } else if (field.type == "ui-stringuserselect") {
  16113. field.templateOptions.modal = $modal;
  16114. } else if (field.type == "ui-search") {
  16115. field.templateOptions.modal = $modal;
  16116. } else if (field.type == "ui-modelselect") {
  16117. field.templateOptions.modal = $modal;
  16118. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16119. field.templateOptions.loginUser = $rootScope.user;
  16120. //field.templateOptions.Restangular = Restangular;
  16121. } else if (field.type == "ui-incidentmodelselect") {
  16122. field.templateOptions.modal = $modal;
  16123. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  16124. field.templateOptions.loginUser = $rootScope.user;
  16125. //field.templateOptions.Restangular = Restangular;
  16126. } else if (field.type == "ui-dropfile") {
  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-dropfielknow") {
  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-upDropFile") {
  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. } else if (field.type == "ui-dropfilenotup") {
  16148. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16149. url: '/uploader'
  16150. });
  16151. field.templateOptions.taskId = $stateParams.taskId;
  16152. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16153. field.templateOptions.userId = $rootScope.user.id;
  16154. //field.ApiService=api_bpm_domain;
  16155. } else if (field.type == "ui-uploadFiles") {
  16156. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16157. url: '/uploader'
  16158. });
  16159. field.templateOptions.taskId = $stateParams.taskId;
  16160. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16161. field.templateOptions.userId = $rootScope.user.id;
  16162. //field.ApiService=api_bpm_domain;
  16163. } else if (field.type == "ui-upDownFiles") {
  16164. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16165. url: '/uploader'
  16166. });
  16167. field.templateOptions.taskId = $stateParams.taskId;
  16168. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16169. field.templateOptions.userId = $rootScope.user.id;
  16170. //field.ApiService=api_bpm_domain;
  16171. } else if (field.type == "ui-uploadImgs") {
  16172. $scope.fileUploader = field.templateOptions.fileUploader = new FileUploader({
  16173. url: '/uploader'
  16174. });
  16175. field.templateOptions.taskId = $stateParams.taskId;
  16176. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16177. field.templateOptions.userId = $rootScope.user.id;
  16178. //field.ApiService=api_bpm_domain;
  16179. } else if (field.type == "ui-dropfiletable") {
  16180. if (field.templateOptions.processInstanceId) {
  16181. } else {
  16182. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16183. }
  16184. } else if (field.type == "ui-dropFiles") {
  16185. if (field.templateOptions.processInstanceId) {
  16186. } else {
  16187. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16188. }
  16189. } else if (field.type == "ui-showImgs") {
  16190. if (field.templateOptions.processInstanceId) {
  16191. } else {
  16192. field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  16193. }
  16194. } else if (field.type == "ui-repeatSection") {
  16195. var repeatForm = {
  16196. model: {
  16197. },
  16198. fields: field.templateOptions.fields
  16199. };
  16200. repeatForm.model[field.key] = [];
  16201. decodeVMForm(repeatForm);
  16202. } else if (field.type == "ui-currentuser") {
  16203. field.templateOptions.user = vm.model["loginUser"];
  16204. } else if (field.type == "ui-workernumbersign") {
  16205. field.templateOptions.user = vm.model["loginUser"];
  16206. } else if (field.type == "ui-repair-photos") {
  16207. field.templateOptions.user = vm.model["loginUser"];
  16208. }
  16209. }
  16210. }
  16211. //解析自定义表单设计数据
  16212. $scope.oldfromtype = true;
  16213. function decodeVMForm(vmForm) {
  16214. if (vmForm.formType == "1") {
  16215. $scope.oldfromtype = false;
  16216. } else {
  16217. $scope.oldfromtype = true;
  16218. }
  16219. var result = {
  16220. model: {},
  16221. fields: []
  16222. };
  16223. //设置模型实体数据 begin
  16224. // var mdata = vmForm.model;
  16225. //解析数据实体
  16226. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  16227. angular.extend(result.model, mdata);
  16228. if (modelWatch != null && modelWatch != '') {
  16229. //angular.extend(result.model.incident,modelWatch.incident);
  16230. //result.model.alarmType = modelWatch.alarmType;
  16231. // vmForm.cancelUrl = modelWatch.cancelUrl;
  16232. // console.log(modelWatch.cancelUrl)
  16233. for (var index in modelWatch.model) {
  16234. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  16235. if (result.model[index] != null) {
  16236. angular.extend(result.model[index], modelWatch.model[index]);
  16237. } else {
  16238. result.model[index] = modelWatch.model[index];
  16239. }
  16240. }
  16241. }
  16242. //设置模型实体数据 end
  16243. //解析设计数据生成表单项 begin
  16244. var fields = [];
  16245. //处理修改设计数据中展示设置
  16246. angular.forEach(vmForm.fields, function (fields) {
  16247. if (vmForm.formType == "1") {
  16248. angular.forEach(fields.fields, function (field) {
  16249. formfield(field, result);
  16250. });
  16251. } else {
  16252. formfield(fields, result);
  16253. }
  16254. // console.log(field);
  16255. result.fields.push(fields);
  16256. });
  16257. angular.extend($scope.vm.fields, result.fields);
  16258. angular.extend($scope.vm.model, result.model);
  16259. vm.model["loginUser"] = $rootScope.user;
  16260. //增加识别报修主体seimin
  16261. vm.model.repairType = $scope.repairMain.valueconfig;
  16262. if(vm.model.incident){
  16263. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  16264. }
  16265. console.log(vm, 'repairType')//lmm
  16266. if (modelWatch != null && modelWatch != '' && modelWatch.cancelUrl != null && modelWatch.cancelUrl != '') {
  16267. vmForm.cancelUrl = modelWatch.cancelUrl;
  16268. }
  16269. $scope.formData = vmForm;
  16270. console.log($scope.formData,4444444)
  16271. // console.log($scope.formData.url);
  16272. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  16273. if ($scope.formData.url == "start") {
  16274. $scope.Reset = true;
  16275. $scope.close = true;
  16276. $rootScope.isMask = false;
  16277. } else if ($scope.formData.url == "complete") {
  16278. $scope.Reset = false;
  16279. $scope.close = true;
  16280. }
  16281. //解析设计数据生成表单项 end
  16282. return result;
  16283. }
  16284. //======================处理表单设计数据 结束========================
  16285. $scope.ldloading = {};
  16286. function filter(obj) {
  16287. angular.forEach(obj, function (key, value) {
  16288. if (value === "" || value === null) {
  16289. delete obj[key];
  16290. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  16291. filter(value);
  16292. } else if (angular.isArray(value)) {
  16293. angular.forEach(value, function (item) {
  16294. filter(item);
  16295. });
  16296. }
  16297. });
  16298. }
  16299. $scope.closeModel = function () {
  16300. // console.log($stateParams);
  16301. $state.go($scope.formData.cancelUrl, {});
  16302. event.preventDefault();
  16303. };
  16304. // console.log(vm);
  16305. // 暂存
  16306. $scope.save = function (data) {
  16307. console.log(vm)
  16308. if (vm.model.startSave) {
  16309. vm.model["initUser"] = $rootScope.user.id;
  16310. vm.model.start_code = "temporary";
  16311. //处理请求数据0327
  16312. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16313. delete data0327.repairType;
  16314. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16315. if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16316. data0327.incident.place = {
  16317. id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16318. }
  16319. }
  16320. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16321. if (response) {
  16322. var resData = Restangular.stripRestangular(response);
  16323. if (resData) {
  16324. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16325. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16326. angular.extend(item.headers, $rootScope.getSession());
  16327. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16328. item.formData.push({
  16329. 'fileName': item.file.name
  16330. });
  16331. //console.log();
  16332. };
  16333. $scope.fileUploader.uploadAll();
  16334. }
  16335. }
  16336. SweetAlert.swal({
  16337. title: "提交成功!",
  16338. type: "success",
  16339. confirmButtonColor: "#007AFF"
  16340. }, function () {
  16341. $state.go($scope.formData.cancelUrl);
  16342. });
  16343. } else {
  16344. SweetAlert.swal({
  16345. title: "系统错误",
  16346. text: "系统错误,请稍后重试!",
  16347. type: "error",
  16348. confirmButtonColor: "#DD6B55"
  16349. });
  16350. }
  16351. $scope.ldloading[style.replace('-', '_')] = false;
  16352. });
  16353. event.preventDefault();
  16354. } else if (vm.model.saveAgain) {
  16355. var toData = {
  16356. "incident": vm.model.incident
  16357. };
  16358. api_user_data.updData("incident", toData).then(function (response) {
  16359. if (response) {
  16360. var resData = Restangular.stripRestangular(response);
  16361. SweetAlert.swal({
  16362. title: "提交成功!",
  16363. type: "success",
  16364. confirmButtonColor: "#007AFF"
  16365. }, function () {
  16366. $state.go($scope.formData.cancelUrl);
  16367. });
  16368. } else {
  16369. SweetAlert.swal({
  16370. title: "系统错误",
  16371. text: "系统错误,请稍后重试!",
  16372. type: "error",
  16373. confirmButtonColor: "#DD6B55"
  16374. });
  16375. }
  16376. $scope.ldloading[style.replace('-', '_')] = false;
  16377. });
  16378. event.preventDefault();
  16379. } else {
  16380. SweetAlert.swal({
  16381. title: "系统错误",
  16382. text: "系统错误,请稍后重试!",
  16383. type: "error",
  16384. confirmButtonColor: "#DD6B55"
  16385. });
  16386. }
  16387. }
  16388. // 巡检生成事件
  16389. $scope.inspectionToIncident = function () {
  16390. var userData = {
  16391. "idx": 0,
  16392. "sum": 10,
  16393. "requester": {
  16394. "name": loginUser.name
  16395. }
  16396. }
  16397. api_user_data.fetchDataList("requester", userData).then(function (res) {
  16398. console.log(res);
  16399. var toUser = {};
  16400. if (res.list.length > 0) {
  16401. toUser = res.list[0]
  16402. } else {
  16403. toUser = loginUser
  16404. }
  16405. console.log(vm);
  16406. var incidentDescription = "";
  16407. console.log($stateParams.formUiEdit);
  16408. if ($stateParams.formUiEdit == "inspection_confirm") {
  16409. if (vm.model.wnCheckEnable) {
  16410. incidentDescription = incidentDescription.concat(" 机房温度检查异常")
  16411. }
  16412. if (vm.model.sdCheckEnable) {
  16413. incidentDescription = incidentDescription.concat(" 机房湿度检查异常")
  16414. }
  16415. if (vm.model.xfjCheckEnable) {
  16416. incidentDescription = incidentDescription.concat(" 新风机检查异常")
  16417. }
  16418. if (vm.model.lsCheckEnable) {
  16419. incidentDescription = incidentDescription.concat(" 漏水检查异常")
  16420. }
  16421. if (vm.model.xfCheckEnable) {
  16422. incidentDescription = incidentDescription.concat(" 消防检查异常")
  16423. }
  16424. if (vm.model.upsCheckEnable) {
  16425. incidentDescription = incidentDescription.concat(" UPS供电检查异常")
  16426. }
  16427. if (vm.model.dcCheckEnable) {
  16428. incidentDescription = incidentDescription.concat(" 电池连接检查异常")
  16429. }
  16430. if (vm.model.plCheckEnable) {
  16431. incidentDescription = incidentDescription.concat(" 旁路供电检查异常")
  16432. }
  16433. if (vm.model.wjtdCheckEnable) {
  16434. incidentDescription = incidentDescription.concat(" 外机通道检查异常")
  16435. }
  16436. if (vm.model.descriptionTextarea) {
  16437. incidentDescription = incidentDescription.concat(" " + "备注:" + vm.model.descriptionTextarea)
  16438. }
  16439. }
  16440. // console.log(incidentDescription)
  16441. var bxr = JSON.parse(localStorage.getItem("login_requester"));//bababa
  16442. var formdata = {
  16443. 'model': {
  16444. // 'isInspection': true,
  16445. // 'start_code':'assignment',
  16446. // 'isHandlerUser':false,
  16447. 'incident': {
  16448. 'requester':bxr ,
  16449. 'area': bxr.place.area,
  16450. 'place': bxr.place,
  16451. 'houseNumber': bxr.houseNumber,
  16452. 'contacts': bxr.name,
  16453. 'contactsInformation': bxr.mphone,
  16454. // 'category': data.wxIncidentClassifyDTO.category,
  16455. 'description': incidentDescription,
  16456. 'source': {
  16457. 'id': 1552
  16458. },
  16459. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  16460. // 'sourceType': data.incident.sourceType,
  16461. // 'fileUrl': data.incident.fileUrl
  16462. },
  16463. // 'requestershow': toUser,//2020年4月27日22:29:15
  16464. // 'flow': data.incident.id
  16465. // 'assignee': loginUser.id//2020年4月27日22:29:25
  16466. }
  16467. }
  16468. // console.log(formdata,toUser,'1111');
  16469. console.log(formdata,'1111');
  16470. // return;
  16471. $state.go("app.incident.chart", {
  16472. 'model': JSON.stringify(formdata)
  16473. });
  16474. })
  16475. // var formdata = {
  16476. // model:$rootScope.login_requester
  16477. // };
  16478. // console.log(formdata,'00000')
  16479. // return;
  16480. // $state.go("app.incident.chart", {
  16481. // 'model': JSON.stringify(formdata)
  16482. // });
  16483. event.preventDefault();
  16484. };
  16485. // console.log(vm);
  16486. // 创建事件seimin
  16487. vm.submit = function (data, style) {
  16488. console.log(vm,22222);
  16489. // return;
  16490. if (vm.model.handler_code == undefined) {
  16491. vm.model.handler_code = "resolve";
  16492. }
  16493. if (vm.model.change && vm.model.change.requestingPerson && vm.model.change.requestingPerson.menu) {
  16494. delete vm.model.change.requestingPerson.menu;
  16495. }
  16496. // var pdKey = $stateParams.pdKey;
  16497. if (vm.form.$valid) {
  16498. if (data.incident && data.incident.synergetic) {
  16499. console.log(data.incident.synergetic);
  16500. var synergetic = [];
  16501. for (var i = 0; i < data.incident.synergetic.length; i++) {
  16502. synergetic.push({
  16503. id: data.incident.synergetic[i]
  16504. });
  16505. }
  16506. data.incident.synergetic = synergetic;
  16507. vm.model.incident.synergetic = synergetic;
  16508. }
  16509. $scope.ldloading[style.replace('-', '_')] = true;
  16510. var startsub = true;
  16511. if (pdKey == 'bpm_incident') {
  16512. angular.forEach(vm.fields, function (item) {
  16513. angular.forEach(item.fields, function (index) {
  16514. if (index.templateOptions.required && !index.hide) {
  16515. if (index.model) {
  16516. if (angular.isDefined(index.model[index.key]) && index.model[index.key] != null) {
  16517. if (index.model[index.key].id && index.model[index.key].id == '') {
  16518. startsub = false;
  16519. $scope.ldloading.expand_right = false;
  16520. SweetAlert.swal({
  16521. title: index.templateOptions.label + '未填',
  16522. text: "请填写此项!",
  16523. type: "error",
  16524. confirmButtonColor: "#DD6B55"
  16525. });
  16526. } else { }
  16527. } else {
  16528. startsub = false;
  16529. $scope.ldloading.expand_right = false;
  16530. console.log(vm)
  16531. SweetAlert.swal({
  16532. title: index.templateOptions.label + '未填2',
  16533. text: "请填写此项!",
  16534. type: "error",
  16535. confirmButtonColor: "#DD6B55"
  16536. });
  16537. }
  16538. } else {
  16539. if (data[index.key] && data[index.key] != '' && data[index.key] != null) {
  16540. } else {
  16541. startsub = false;
  16542. $scope.ldloading.expand_right = false;
  16543. SweetAlert.swal({
  16544. title: index.templateOptions.label + '未填',
  16545. text: "请填写此项!",
  16546. type: "error",
  16547. confirmButtonColor: "#DD6B55"
  16548. });
  16549. }
  16550. }
  16551. }
  16552. })
  16553. })
  16554. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  16555. // startsub = false;
  16556. // $scope.ldloading.expand_right = false;
  16557. // SweetAlert.swal({
  16558. // title: '保修人未填',
  16559. // text: "请填写此项!",
  16560. // type: "error",
  16561. // confirmButtonColor: "#DD6B55"
  16562. // });
  16563. // }
  16564. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  16565. // } else {
  16566. // startsub = false;
  16567. // $scope.ldloading.expand_right = false;
  16568. // SweetAlert.swal({
  16569. // title: '事件分类未填',
  16570. // text: "请填写此项!",
  16571. // type: "error",
  16572. // confirmButtonColor: "#DD6B55"
  16573. // });
  16574. // }
  16575. }
  16576. if (startsub) {
  16577. $scope.ldloading[style.replace('-', '_')] = true;
  16578. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  16579. // console.log("vm.options:"+ JSON.stringify(vm.options));
  16580. vm.options.updateInitialValue();
  16581. // console.log("dfjkasdhfkhskjf ")
  16582. var _ = window._;
  16583. vm.model = (function filter(obj) {
  16584. var dateTransKeys = [];
  16585. var filtered = _.pick(obj, function (v, k, obj) {
  16586. if (_.isDate(v)) {
  16587. dateTransKeys.push(k);
  16588. }
  16589. return angular.isDefined(v) && v !== null && (angular.isArray(v) ? v.length > 0 : true) && (_.isPlainObject(v) ? (!_.isEmpty(v)) : true);
  16590. });
  16591. return _.cloneDeep(filtered, function (v, index, object) {
  16592. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  16593. angular.forEach(dateTransKeys, function (item) {
  16594. v[item] = moment(v[item]).format('YYYY-MM-DD HH:mm:ss');
  16595. })
  16596. dateTransKey = [];
  16597. return v;
  16598. }
  16599. return !(_.isEmpty(filtered)) && v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  16600. });
  16601. })(vm.model);
  16602. if (pdKey != "") {
  16603. if ($scope.oprcode == "save") { //保存
  16604. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  16605. if (response) {
  16606. var resData = Restangular.stripRestangular(response);
  16607. SweetAlert.swal({
  16608. title: "保存成功!",
  16609. confirmButtonColor: "#007AFF"
  16610. }, function () {
  16611. $state.go($scope.formData.cancelUri);
  16612. });
  16613. // if(resData.status){
  16614. // resData
  16615. // }
  16616. } else {
  16617. SweetAlert.swal({
  16618. title: "系统错误",
  16619. text: "系统错误,请稍后重试!",
  16620. type: "error",
  16621. confirmButtonColor: "#DD6B55"
  16622. });
  16623. }
  16624. $scope.ldloading[style.replace('-', '_')] = false;
  16625. });
  16626. } else {
  16627. console.log($scope.formData.url,'zzzz')
  16628. switch ($scope.formData.url) {
  16629. case "start":
  16630. vm.model["initUser"] = $rootScope.user.id;
  16631. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  16632. } else {
  16633. vm.model["assignee"] = $rootScope.user.id;
  16634. }
  16635. if (vm.model["candidateGroups"] && vm.model.candidateGroups.id) {
  16636. vm.model.candidateGroups = vm.model.candidateGroups.id;
  16637. }
  16638. if (pdKey == 'bpm_service_request') {
  16639. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  16640. angular.extend(vm.model.serviceCatalogueProcessActual, {
  16641. 'category': {
  16642. 'id': $stateParams.userId
  16643. }
  16644. });
  16645. }
  16646. if (vm.model.schedule && vm.model.schedule.initUser) {
  16647. delete vm.model.schedule.initUser.menu
  16648. }
  16649. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16650. delete vm.model.candidateGroups
  16651. }
  16652. if (vm.model.start_code == 'close') {
  16653. // 直接处理
  16654. vm.model.incident.handlingPersonnelUser = vm.model.incident.acceptUser;
  16655. delete vm.model.incident.handlerUser
  16656. delete vm.model.candidateGroups;
  16657. } else if (vm.model.start_code == 'assignment') {
  16658. // 派单
  16659. delete vm.model.incident.handlingPersonnelUser
  16660. }
  16661. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  16662. $scope.jry_processInstanceId = $stateParams.processInstanceId;
  16663. }
  16664. if ($scope.jry_processInstanceId) {
  16665. vm.model["save_fileId"] = $scope.jry_processInstanceId
  16666. }
  16667. //事件暂存判断
  16668. if (vm.model.saveAgain) {
  16669. if (vm.model.directClose == "1" || vm.model.directClose == true) {
  16670. vm.model.start_code = "assignment";
  16671. vm.model.temporary_code = "assignment";
  16672. } else {
  16673. vm.model.start_code = "close";
  16674. vm.model.temporary_code = "close"
  16675. };
  16676. if (vm.model.isHandlerUser == "true" || vm.model.isHandlerUser == true) {
  16677. delete vm.model.candidateGroups
  16678. }
  16679. }
  16680. //处理请求数据0327
  16681. var data0327 = JSON.parse(JSON.stringify(vm.model));
  16682. delete data0327.repairType;
  16683. // 增加地点的请求参数2020年4月24日10:44:36
  16684. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  16685. // if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  16686. // data0327.incident.place = {
  16687. // id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  16688. // }
  16689. // }
  16690. console.log(vm);
  16691. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  16692. // console.log("response="+JSON.stringify(response));
  16693. if (response) {
  16694. var resData = Restangular.stripRestangular(response);
  16695. if (resData) {
  16696. if (resData) {
  16697. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0 && resData.id) {
  16698. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16699. angular.extend(item.headers, $rootScope.getSession());
  16700. item.url = api_bpm_domain.uploadAttachment(resData.id, '00000', $rootScope.user.id).getRequestedUrl();
  16701. item.formData.push({
  16702. 'fileName': item.file.name
  16703. });
  16704. //console.log();
  16705. };
  16706. $scope.fileUploader.uploadAll();
  16707. }
  16708. }
  16709. }
  16710. SweetAlert.swal({
  16711. title: "提交成功!",
  16712. type: "success",
  16713. confirmButtonColor: "#007AFF"
  16714. }, function () {
  16715. if (vm.model.incident && vm.model.incident.callID && vm.model.incident.callID != "") {
  16716. $rootScope.app.layout.isSidebarClosed = false;
  16717. if ($scope.login && !$rootScope.busy) {
  16718. $rootScope.setidle();
  16719. }
  16720. }
  16721. $state.go($scope.formData.cancelUrl);
  16722. });
  16723. } else {
  16724. SweetAlert.swal({
  16725. title: "系统错误",
  16726. text: "系统错误,请稍后重试!",
  16727. type: "error",
  16728. confirmButtonColor: "#DD6B55"
  16729. });
  16730. }
  16731. $scope.ldloading[style.replace('-', '_')] = false;
  16732. });
  16733. break;
  16734. case "complete":
  16735. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  16736. //console.log("complete taskId::"+$stateParams.taskId);
  16737. if ($scope.formData.name == "transferform" && vm.model.ishandlers && !vm.model.incident.handlerUser) {
  16738. SweetAlert.swal({
  16739. title: "处理人未填",
  16740. text: "请填写此项!",
  16741. type: "error",
  16742. confirmButtonColor: "#DD6B55"
  16743. });
  16744. return;
  16745. }
  16746. api_bpm_domain.complete($stateParams.taskId, userId, vm.model).then(function (response) {
  16747. if (response) {
  16748. var resData = Restangular.stripRestangular(response);
  16749. SweetAlert.swal({
  16750. title: "提交成功!",
  16751. type: "success",
  16752. confirmButtonColor: "#007AFF"
  16753. }, function () {
  16754. if ($scope.fileUploader != null && $scope.fileUploader.getNotUploadedItems().length > 0) {
  16755. console.log(vm);
  16756. if (vm.model.incident) {
  16757. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  16758. // angular.extend(item.headers, $rootScope.getSession());
  16759. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16760. // item.formData.push({
  16761. // 'fileName': item.file.name
  16762. // });
  16763. // };
  16764. // $scope.fileUploader.uploadAll();
  16765. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16766. angular.extend(item.headers, $rootScope.getSession());
  16767. item.url = api_bpm_domain.uploadAttachment(vm.model.incident.processInstanceId, '00000', $rootScope.user.id).getRequestedUrl();
  16768. item.formData.push({
  16769. 'fileName': item.file.name
  16770. });
  16771. //console.log();
  16772. };
  16773. $scope.fileUploader.uploadAll();
  16774. } else if (vm.model.problem) {
  16775. $scope.fileUploader.onBeforeUploadItem = function (item) {
  16776. angular.extend(item.headers, $rootScope.getSession());
  16777. item.url = api_bpm_domain.uploadAttachmentJryModel("problem", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  16778. item.formData.push({
  16779. 'fileName': item.file.name
  16780. });
  16781. };
  16782. $scope.fileUploader.uploadAll();
  16783. } else if (vm.model.change) {
  16784. }
  16785. }
  16786. $state.go($scope.formData.cancelUrl);
  16787. });
  16788. } else {
  16789. SweetAlert.swal({
  16790. title: "系统错误",
  16791. text: "系统错误,请稍后重试!",
  16792. type: "error",
  16793. confirmButtonColor: "#DD6B55"
  16794. });
  16795. }
  16796. $scope.ldloading[style.replace('-', '_')] = false;
  16797. });
  16798. break;
  16799. case "back":
  16800. $state.go($scope.formData.cancelUrl);
  16801. break;
  16802. default:
  16803. $scope.ldloading[style.replace('-', '_')] = false;
  16804. break;
  16805. }
  16806. }
  16807. // var submitFunc = api_bpm_domain[$scope.formData.url]
  16808. // if(anuglar.isFunction(submitFunc)){
  16809. // submitFunc.apply(null, pdKey)
  16810. // }
  16811. }
  16812. }
  16813. } else {
  16814. // console.log(data)
  16815. // angular.forEach(vm.form.$error.required, function(item){
  16816. // var i=(item.$name).substring(item.$name.length-2)
  16817. var i = Number((vm.form.$error.required[0].$name).split("_")[4]);
  16818. // for(var i=0;i<vm.fields.length;i++){
  16819. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  16820. SweetAlert.swal({
  16821. title: vm.fields[i].templateOptions.label + '未填',
  16822. text: "请填写此项!",
  16823. type: "error",
  16824. confirmButtonColor: "#DD6B55"
  16825. });
  16826. }
  16827. // }
  16828. // angular.forEach(vm.fields,function(f){
  16829. // if(f.name == item.$name){
  16830. // f.validation.show = true;
  16831. // SweetAlert.swal({
  16832. // title: f.templateOptions.label+'未填',
  16833. // text: "请填写此项!",
  16834. // type: "error",
  16835. // confirmButtonColor: "#DD6B55"
  16836. // });
  16837. // }
  16838. // });
  16839. // })
  16840. }
  16841. };
  16842. $scope.vm = vm;
  16843. console.log($stateParams,pdKey,88888)
  16844. console.log($scope.vm,'assdfsdf')
  16845. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  16846. var processInstanceId = $stateParams.processInstanceId;
  16847. var itemId = $stateParams.dataId;
  16848. console.log($stateParams)
  16849. if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_inspection") {
  16850. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId, itemId).then(function (responseData) {
  16851. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16852. var vmForm = Restangular.stripRestangular(responseData);
  16853. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16854. decodeVMForm(vmForm);
  16855. }
  16856. }
  16857. });
  16858. } else if (angular.isDefined($stateParams.pdKey) && $stateParams.pdKey == "bpm_service_request") {
  16859. api_configure_form.renderForm($stateParams.formUiEdit, userId, processInstanceId).then(function (responseData) {
  16860. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16861. var vmForm = Restangular.stripRestangular(responseData);
  16862. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16863. decodeVMForm(vmForm);
  16864. }
  16865. }
  16866. });
  16867. } else {
  16868. api_bpm_domain.taskformkey($stateParams.taskId).then(function (response) {
  16869. if (response) {
  16870. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  16871. api_configure_form.renderForm(myData.data, userId, processInstanceId, itemId).then(function (responseData) {
  16872. if (responseData) { //console.log("responseData>>>");//console.log(responseData);
  16873. var vmForm = Restangular.stripRestangular(responseData);
  16874. if (vmForm) { //console.log("vmForm>>>");//console.log(vmForm);
  16875. decodeVMForm(vmForm);
  16876. console.log(vmForm,111111);
  16877. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  16878. console.log($scope,'今天')//2020年4月24日11:40:55
  16879. }
  16880. }
  16881. });
  16882. }
  16883. })
  16884. }
  16885. } else {
  16886. // create process instance
  16887. if (pdKey != "") { //for process
  16888. if (pdKey == 'bpm_service_request') {
  16889. api_configure_form.renderForm($stateParams.formUiStart, userId).then(function (responseData) {
  16890. if (responseData) {
  16891. var vmForm = Restangular.stripRestangular(responseData);
  16892. if (vmForm) {
  16893. decodeVMForm(vmForm);
  16894. }
  16895. }
  16896. });
  16897. } else {
  16898. api_bpm_domain.startformkey(pdKey).then(function (response) {
  16899. if (response) {
  16900. var myData = Restangular.stripRestangular(response);
  16901. //myData.data = "arrangeform";
  16902. api_configure_form.renderForm(myData.data, userId).then(function (responseData) {
  16903. if (responseData) {
  16904. var vmForm = Restangular.stripRestangular(responseData);
  16905. if (vmForm) {
  16906. decodeVMForm(vmForm);
  16907. }
  16908. }
  16909. });
  16910. }
  16911. });
  16912. }
  16913. } else { //for form
  16914. //TODO
  16915. //测试数据 开始
  16916. var testJson = {
  16917. fields: [{
  16918. fields: [{
  16919. className: "col-xs-12",
  16920. noFormControl: true,
  16921. key: "formtitle",
  16922. templateOptions: {
  16923. readOnly: false,
  16924. placeholder: "新建事件单",
  16925. hidden: false,
  16926. label: "事件工单",
  16927. required: false
  16928. },
  16929. type: "ui-title"
  16930. }]
  16931. }, {
  16932. fields: [{
  16933. key: 'selectUser',
  16934. type: 'ui-deptinformation',
  16935. className: 'col-xs-12',
  16936. templateOptions: {
  16937. label: '请求人信息',
  16938. modalTitle: '请求人列表',
  16939. fetchItems: function (filterData, APIService) {
  16940. return APIService.fetchDataList('requester', filterData);
  16941. },
  16942. Restangular: Restangular,
  16943. ApiService: api_user_data
  16944. // onClick:function(val, options, field, event , model){
  16945. // console.log(options);
  16946. // }
  16947. }
  16948. }]
  16949. }, {
  16950. fields: [{
  16951. key: 'first',
  16952. type: 'ui-workernumber',
  16953. className: 'col-xs-12',
  16954. templateOptions: {
  16955. type: 'input',
  16956. label: '事件单号',
  16957. pkey: 'name'
  16958. }
  16959. }]
  16960. }, {
  16961. fields: [{
  16962. type: 'ui-header',
  16963. key: 'title',
  16964. className: 'col-xs-12',
  16965. templateOptions: {
  16966. label: '报修人',
  16967. pkey: 'change'
  16968. }
  16969. }, {
  16970. type: 'ui-input',
  16971. key: 'title',
  16972. className: 'col-xs-4',
  16973. templateOptions: {
  16974. label: '报修人',
  16975. pkey: 'change'
  16976. }
  16977. }, {
  16978. type: 'ui-input',
  16979. key: 'title',
  16980. className: 'col-xs-4',
  16981. templateOptions: {
  16982. label: '联系人',
  16983. pkey: 'change'
  16984. }
  16985. }, {
  16986. type: 'ui-input',
  16987. key: 'title',
  16988. className: 'col-xs-4',
  16989. templateOptions: {
  16990. label: '联系电话',
  16991. pkey: 'change'
  16992. }
  16993. }]
  16994. }, {
  16995. fields: [{
  16996. type: 'ui-header',
  16997. key: 'title1',
  16998. className: 'col-xs-12',
  16999. templateOptions: {
  17000. label: '报修人',
  17001. pkey: 'change'
  17002. }
  17003. }, {
  17004. type: 'ui-input',
  17005. key: 'title2',
  17006. className: 'col-xs-4',
  17007. templateOptions: {
  17008. label: '报修人',
  17009. pkey: 'change'
  17010. }
  17011. }, {
  17012. type: 'ui-input',
  17013. key: 'title3',
  17014. className: 'col-xs-4',
  17015. templateOptions: {
  17016. label: '联系人',
  17017. pkey: 'change'
  17018. }
  17019. }, {
  17020. type: 'ui-input',
  17021. key: 'title4',
  17022. className: 'col-xs-4',
  17023. templateOptions: {
  17024. label: '联系电话',
  17025. pkey: 'change'
  17026. }
  17027. }]
  17028. }],
  17029. model: [{
  17030. username: "robin lau",
  17031. password: "123456",
  17032. chkme: false,
  17033. start_code: 0,
  17034. formtitle: "Hey!I am title value!",
  17035. name: {
  17036. first: "robin",
  17037. last: "lau"
  17038. },
  17039. multiselectItem: []
  17040. //date:"2015-09-15 00:00:00"
  17041. }]
  17042. // }
  17043. };
  17044. setTimeout(function () {
  17045. decodeVMForm(testJson);
  17046. $scope.$apply();
  17047. }, 500);
  17048. //测试数据结束
  17049. }
  17050. }
  17051. //console.log("end decode");
  17052. }
  17053. ]);