customformCtrl.js 962 KB

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