customformCtrl.js 827 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. overwriteOk: true,
  85. name: "bootstrapLabel",
  86. templateUrl: "assets/views/customform/tpl/normal-label.html",
  87. });
  88. //流程图
  89. formlyConfigProvider.setType({
  90. name: "ui-process",
  91. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () { },
  96. refreshDelay: 0,
  97. },
  98. };
  99. },
  100. controller: [
  101. "$scope",
  102. "$modal",
  103. "SweetAlert",
  104. "api_bpm_domain",
  105. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. $scope.processdata = [];
  107. api_bpm_domain
  108. .flowTracing($scope.model.applicationForm.processInstanceId)
  109. .then(function (data) {
  110. console.log(data);
  111. $scope.processdata = data.data;
  112. });
  113. },
  114. ],
  115. });
  116. //出库单详情
  117. formlyConfigProvider.setType({
  118. name: "ui-getoutinform",
  119. extends: "radio",
  120. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  121. defaultOptions: function (options) {
  122. return {
  123. templateOptions: {
  124. refresh: function () { },
  125. refreshDelay: 0,
  126. },
  127. };
  128. },
  129. controller: [
  130. "$scope",
  131. "$modal",
  132. "SweetAlert",
  133. "api_bpm_domain",
  134. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  135. if (
  136. angular.isDefined($scope.model.type.id) &&
  137. !$scope.model.type.name
  138. ) {
  139. if (($scope.model.type.id = 0)) {
  140. $scope.model.type.name = "新资产入库";
  141. } else if (($scope.model.type.id = 1)) {
  142. $scope.model.type.name = "新设备领用出库";
  143. } else if (($scope.model.type.id = 2)) {
  144. $scope.model.type.name = "资产归还";
  145. } else if (($scope.model.type.id = 4)) {
  146. $scope.model.type.name = "设备更换";
  147. }
  148. }
  149. },
  150. ],
  151. });
  152. //多选框组件
  153. formlyConfigProvider.setType({
  154. name: "ui-checkboxmore",
  155. extends: "radio",
  156. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  157. defaultOptions: function (options) {
  158. return {
  159. templateOptions: {
  160. refresh: function () { },
  161. refreshDelay: 0,
  162. },
  163. };
  164. },
  165. controller: [
  166. "$scope",
  167. "$modal",
  168. "SweetAlert",
  169. "api_bpm_domain",
  170. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  171. $scope.options.initialValue = $scope.model[$scope.options.key];
  172. },
  173. ],
  174. });
  175. //入库单详情
  176. formlyConfigProvider.setType({
  177. name: "ui-getininform",
  178. extends: "radio",
  179. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  180. defaultOptions: function (options) {
  181. return {
  182. templateOptions: {
  183. refresh: function () { },
  184. refreshDelay: 0,
  185. },
  186. };
  187. },
  188. controller: [
  189. "$scope",
  190. "$modal",
  191. "SweetAlert",
  192. "api_bpm_domain",
  193. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  194. if (
  195. angular.isDefined($scope.model.type.id) &&
  196. !$scope.model.type.name
  197. ) {
  198. if (($scope.model.type.id = 0)) {
  199. $scope.model.type.name = "新资产入库";
  200. } else if (($scope.model.type.id = 1)) {
  201. $scope.model.type.name = "新设备领用出库";
  202. } else if (($scope.model.type.id = 2)) {
  203. $scope.model.type.name = "资产归还";
  204. } else if (($scope.model.type.id = 4)) {
  205. $scope.model.type.name = "设备更换";
  206. }
  207. }
  208. },
  209. ],
  210. });
  211. //申请人详情
  212. formlyConfigProvider.setType({
  213. name: "ui-requsterinfom",
  214. extends: "radio",
  215. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  216. defaultOptions: function (options) {
  217. return {
  218. templateOptions: {
  219. refresh: function () { },
  220. refreshDelay: 0,
  221. },
  222. };
  223. },
  224. });
  225. //设备耗材list组件
  226. formlyConfigProvider.setType({
  227. name: "ui-uplodchange",
  228. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  229. defaultOptions: function (options) {
  230. return {
  231. templateOptions: {
  232. refresh: function () { },
  233. refreshDelay: 0,
  234. view: function (APIService, contentId) {
  235. return APIService.downloadAttachment(contentId);
  236. },
  237. },
  238. };
  239. },
  240. controller: [
  241. "$scope",
  242. "$filter",
  243. "ngTableParams",
  244. "$rootScope",
  245. "Restangular",
  246. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  247. // var data = { "haodata": [], "shedata": [] };
  248. var haodata = [];
  249. var shedata = [];
  250. if ($scope.model.consumables) {
  251. if (angular.isArray($scope.model.consumables)) {
  252. haodata = $scope.model.consumables;
  253. } else {
  254. haodata = JSON.parse($scope.model.consumables);
  255. }
  256. $scope.model.consumables = haodata;
  257. angular.forEach(haodata, function (item, index) {
  258. haodata[index].item = index + 1;
  259. });
  260. }
  261. if ($scope.model.assets) {
  262. if (angular.isArray($scope.model.assets)) {
  263. shedata = $scope.model.assets;
  264. } else {
  265. shedata = JSON.parse($scope.model.assets);
  266. }
  267. $scope.model.assets = shedata;
  268. angular.forEach(shedata, function (item, index) {
  269. shedata[index].item = index + 1;
  270. });
  271. }
  272. $scope.tableParamshao = new ngTableParams(
  273. {
  274. page: 1,
  275. count: 5,
  276. },
  277. {
  278. total: haodata.length,
  279. getData: function ($defer, params) {
  280. var orderedData = params.sorting()
  281. ? $filter("orderBy")(haodata, params.orderBy())
  282. : haodata;
  283. $defer.resolve(
  284. orderedData.slice(
  285. (params.page() - 1) * params.count(),
  286. params.page() * params.count()
  287. )
  288. );
  289. },
  290. }
  291. );
  292. $scope.tableParamsshe = new ngTableParams(
  293. {
  294. page: 1,
  295. count: 5,
  296. },
  297. {
  298. total: shedata.length,
  299. getData: function ($defer, params) {
  300. var orderedData = params.sorting()
  301. ? $filter("orderBy")(shedata, params.orderBy())
  302. : shedata;
  303. $defer.resolve(
  304. orderedData.slice(
  305. (params.page() - 1) * params.count(),
  306. params.page() * params.count()
  307. )
  308. );
  309. },
  310. }
  311. );
  312. $scope.editId = -1;
  313. $scope.setEditId = function (pid) {
  314. $scope.editId = pid;
  315. };
  316. if (angular.isUndefined($scope.form.dropState)) {
  317. $scope.form.dropState = false;
  318. }
  319. var to = $scope.options.templateOptions;
  320. var bindId = $scope.model.processInstanceId;
  321. //获取附件列表
  322. $scope.listAttachmen = function () {
  323. to.ApiService.listAttachment(
  324. to.listAttachmentUrl,
  325. to.bindType,
  326. bindId
  327. ).then(function (result) {
  328. var myData = Restangular.stripRestangular(result);
  329. // $scope.listAttachmens = myData;
  330. $scope.attachments = myData.data;
  331. });
  332. };
  333. $scope.listAttachmen();
  334. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  335. // $scope.listAttachmen();
  336. // } else if (to.bindType && $scope.model[to.bindType].id) {
  337. // $scope.listAttachmen();
  338. // }
  339. //附件下载
  340. $scope.download = function (token, filename) {
  341. var downUrl = to.ApiService.downloadAttachment(
  342. to.downUrl,
  343. token
  344. ).getRequestedUrl();
  345. // window.open(downUrl);
  346. var a = document.createElement("a");
  347. a.href = downUrl;
  348. a.target = "_blank";
  349. a.download = filename;
  350. document.body.appendChild(a);
  351. a.click();
  352. };
  353. //附件预览
  354. $scope.view = function (id, previewUrl) {
  355. if (previewUrl) {
  356. window.open(previewUrl);
  357. }
  358. };
  359. },
  360. ],
  361. });
  362. //多选框组件
  363. formlyConfigProvider.setType({
  364. name: "ui-nodataimage",
  365. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  366. defaultOptions: function (options) {
  367. return {
  368. templateOptions: {
  369. refresh: function () { },
  370. refreshDelay: 0,
  371. },
  372. };
  373. },
  374. });
  375. //ui-grid list
  376. formlyConfigProvider.setType({
  377. name: "ui-gridtwolist",
  378. // extends: 'input',
  379. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  380. defaultOptions: function (options, $scope) {
  381. return {
  382. templateOptions: {},
  383. };
  384. },
  385. controller: [
  386. "$scope",
  387. "$modal",
  388. "i18nService",
  389. "SweetAlert",
  390. function ($scope, $modal, i18nService, SweetAlert) {
  391. //gridone
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = "zh-cn";
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions = {};
  396. $scope.gridOptions.data = "myDatagrid";
  397. $scope.gridOptions.enableColumnResizing = true;
  398. $scope.gridOptions.enableFiltering = true;
  399. $scope.gridOptions.enableGridMenu = false;
  400. $scope.gridOptions.enableRowSelection = true;
  401. $scope.gridOptions.showGridFooter = true;
  402. $scope.gridOptions.showColumnFooter = false;
  403. $scope.gridOptions.fastWatch = true;
  404. $scope.gridOptions.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  407. $scope.gridOptions.paginationPageSize = 10;
  408. $scope.gridOptions.multiSelect = false;
  409. $scope.myDatagrid = [];
  410. $scope.myDatagridall = [];
  411. $scope.selected = {
  412. item: {},
  413. };
  414. $scope.memoryfilterDatagrid = {
  415. idx: 0,
  416. sum: 10,
  417. };
  418. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  419. filterData = {
  420. idx: 0,
  421. sum: 10,
  422. };
  423. $scope.gridOptions.columnDefs =
  424. $scope.options.templateOptions.columnDefs;
  425. }
  426. $scope.gridOptions.rowIdentity = function (row) {
  427. return row.id;
  428. };
  429. $scope.gridOptions.getRowIdentity = function (row) {
  430. return row.id;
  431. };
  432. // $scope.gridOptions.columnDefs = items.columnDefs();
  433. $scope.interceptMydata = function (mydate, idx, sum) {
  434. return mydate.slice(idx * sum, (idx + 1) * sum);
  435. };
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged(
  439. $scope,
  440. function (newPage, pageSize) {
  441. $scope.memoryfilterDatagrid.idx = newPage - 1;
  442. $scope.memoryfilterDatagrid.sum = pageSize;
  443. $scope.myDatagrid = $scope.interceptMydata(
  444. $scope.myDatagridall,
  445. $scope.memoryfilterDatagrid.idx,
  446. 10
  447. );
  448. $scope.loadData({
  449. idx: newPage - 1,
  450. sum: pageSize,
  451. });
  452. }
  453. );
  454. gridApi.core.on.filterChanged($scope, function () { });
  455. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  456. $scope.selected.item = data.entity;
  457. //console.log(data);
  458. });
  459. };
  460. $scope.loadData = function (mydate, idx, sum) {
  461. angular.forEach($scope.myDatagrid, function (item, index) {
  462. $scope.myDatagrid[index].item = index;
  463. });
  464. $scope.gridOptions.totalItems = mydate.length;
  465. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  466. };
  467. if ($scope.model.assets) {
  468. $scope.myDatagridall = $scope.model.assets;
  469. $scope.loadData($scope.model.assets, 0, 10);
  470. }
  471. $scope.saveData = function (itemin) {
  472. event.preventDefault();
  473. var modalInstance = $modal.open({
  474. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  475. controller: function ($scope, $modalInstance, SweetAlert) {
  476. // $scope.consumptive = {};
  477. $scope.title = "填写领用设备信息";
  478. // if (items.name) {
  479. // $scope.consumptive.name = items.name.name;
  480. // }
  481. $scope.placechange = angular.copy(itemin);
  482. $scope.ok = function (item) {
  483. if (
  484. item.props &&
  485. item.props.hwnw_area &&
  486. item.props.hwnw_place &&
  487. item.props.hwnw_room &&
  488. item.props.hwnwswt_jiguihao &&
  489. item.props.hwnwswt_Ushu &&
  490. item.props.snnum
  491. ) {
  492. $modalInstance.close(item);
  493. } else {
  494. SweetAlert.swal({
  495. title: "数据填写不完整!",
  496. text: "请检查数据然后提交!",
  497. type: "error",
  498. });
  499. }
  500. };
  501. $scope.cancel = function () {
  502. $modalInstance.dismiss("cancel");
  503. };
  504. },
  505. resolve: {
  506. SweetAlert: function () {
  507. return SweetAlert;
  508. },
  509. },
  510. });
  511. modalInstance.result.then(function (selectedItem) {
  512. angular.forEach($scope.myDatagrid, function (item, index) {
  513. // $scope.myDatagrid[index].props.hw_state = "在线";
  514. if (item.id == selectedItem.id) {
  515. // $scope.myDatagrid[index] = selectedItem;
  516. angular.extend($scope.myDatagrid[index], selectedItem);
  517. }
  518. });
  519. // $scope.myData3.push(selectedItem);
  520. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  521. $scope.myDatagrid[i]["item"] =
  522. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  523. }
  524. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  525. $scope.myDatagridall;
  526. });
  527. };
  528. //gridtwo
  529. $scope.langs = i18nService.getAllLangs();
  530. $scope.lang = "zh-cn";
  531. i18nService.setCurrentLang($scope.lang);
  532. $scope.gridOptions2 = {};
  533. $scope.gridOptions2.data = "myDatagridold";
  534. $scope.gridOptions2.enableColumnResizing = true;
  535. $scope.gridOptions2.enableFiltering = true;
  536. $scope.gridOptions2.enableGridMenu = false;
  537. $scope.gridOptions2.enableRowSelection = true;
  538. $scope.gridOptions2.showGridFooter = true;
  539. $scope.gridOptions2.showColumnFooter = false;
  540. $scope.gridOptions2.fastWatch = true;
  541. $scope.gridOptions2.useExternalFiltering = false;
  542. $scope.gridOptions.useExternalPagination = true;
  543. $scope.gridOptions2.paginationPageSizes = [10];
  544. $scope.gridOptions2.paginationPageSize = 10;
  545. $scope.gridOptions2.multiSelect = false;
  546. $scope.myDatagridold = [];
  547. $scope.myDatagridoldall = [];
  548. $scope.selected = {
  549. item: {},
  550. };
  551. $scope.memoryfilterDatagridold = {
  552. idx: 0,
  553. sum: 10,
  554. };
  555. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  556. filterData = {
  557. idx: 0,
  558. sum: 10,
  559. };
  560. $scope.gridOptions2.columnDefs =
  561. $scope.options.templateOptions.columnDefstwo;
  562. }
  563. $scope.gridOptions2.rowIdentity = function (row) {
  564. return row.id;
  565. };
  566. $scope.gridOptions2.getRowIdentity = function (row) {
  567. return row.id;
  568. };
  569. // $scope.gridOptions.columnDefs = items.columnDefs();
  570. $scope.interceptMydata = function (mydate, idx, sum) {
  571. return mydate.slice(idx * sum, (idx + 1) * sum);
  572. };
  573. if ($scope.model.oldAssets) {
  574. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  575. $scope.myDatagridold = $scope.interceptMydata(
  576. $scope.myDatagridallold,
  577. $scope.memoryfilterDatagridold.idx,
  578. 10
  579. );
  580. }
  581. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  582. $scope.gridApi = gridApi;
  583. gridApi.pagination.on.paginationChanged(
  584. $scope,
  585. function (newPage, pageSize) {
  586. $scope.memoryfilterDatagridold.idx = newPage - 1;
  587. $scope.memoryfilterDatagridold.sum = pageSize;
  588. $scope.myDatagridold = $scope.interceptMydata(
  589. $scope.myDatagridallold,
  590. $scope.memoryfilterDatagridold.idx,
  591. 10
  592. );
  593. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  594. }
  595. );
  596. gridApi.core.on.filterChanged($scope, function () { });
  597. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  598. $scope.selected.item = data.entity;
  599. //console.log(data);
  600. });
  601. };
  602. // $scope.loadData = function(mydate, idx, sum) {
  603. // angular.forEach($scope.myDatagridold, function(item, index) {
  604. // $scope.myDatagridold[index].item = index;
  605. // })
  606. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  607. // }
  608. // if ($scope.model.assets) {
  609. // $scope.myDatagridallold = $scope.model.assets;
  610. // $scope.loadData($scope.model.assets, 0, 10)
  611. // }
  612. // $scope.addoldassets = function(itemin) {
  613. // event.preventDefault();
  614. // var modalInstance = $modal.open({
  615. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  616. // controller: function($scope, $modalInstance, SweetAlert) {
  617. // // $scope.consumptive = {};
  618. // $scope.title = "填写领用设备信息";
  619. // // if (items.name) {
  620. // // $scope.consumptive.name = items.name.name;
  621. // // }
  622. // $scope.placechange = itemin;
  623. // $scope.ok = function(item) {
  624. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  625. // $modalInstance.close(item);
  626. // } else {
  627. // SweetAlert.swal({
  628. // title: "数据填写不完整!",
  629. // text: "请检查数据然后提交!",
  630. // type: "error"
  631. // });
  632. // }
  633. // };
  634. // $scope.cancel = function() {
  635. // $modalInstance.dismiss('cancel');
  636. // };
  637. // },
  638. // resolve: {
  639. // SweetAlert: function() {
  640. // return SweetAlert;
  641. // }
  642. // }
  643. // });
  644. $scope.interceptMydata = function (mydate, idx, sum) {
  645. return mydate.slice(idx * sum, (idx + 1) * sum);
  646. };
  647. $scope.addshebei = function () {
  648. event.preventDefault();
  649. var modalInstance = $modal.open({
  650. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  651. controller: function (
  652. $scope,
  653. i18nService,
  654. $modalInstance,
  655. items,
  656. title,
  657. Restangular,
  658. APIService,
  659. onDataCallback,
  660. parentScope,
  661. api_configure_data,
  662. api_configure_form,
  663. api_cmdb
  664. ) {
  665. $scope.langs = i18nService.getAllLangs();
  666. $scope.lang = "zh-cn";
  667. i18nService.setCurrentLang($scope.lang);
  668. $scope.gridOptions = {};
  669. $scope.gridOptions.data = "myDatatwo";
  670. $scope.gridOptions.enableColumnResizing = true;
  671. $scope.gridOptions.enableFiltering = false;
  672. $scope.gridOptions.enableGridMenu = false;
  673. $scope.gridOptions.showGridFooter = true;
  674. $scope.gridOptions.showColumnFooter = false;
  675. $scope.gridOptions.fastWatch = true;
  676. $scope.gridOptions.useExternalFiltering = true;
  677. $scope.gridOptions.useExternalPagination = true;
  678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  679. $scope.gridOptions.paginationPageSize = 10;
  680. $scope.gridOptions.multiSelect = true;
  681. $scope.gridOptions.rowIdentity = function (row) {
  682. return row.id;
  683. };
  684. $scope.gridOptions.getRowIdentity = function (row) {
  685. return row.id;
  686. };
  687. $scope.gridOptions.columnDefs = [
  688. {
  689. name: "item",
  690. displayName: "序号",
  691. width: 80,
  692. enableFiltering: false,
  693. },
  694. {
  695. name: "uuid",
  696. displayName: "内部编号",
  697. width: 150,
  698. },
  699. {
  700. name: "props.hw_mingcheng",
  701. displayName: "资产名称",
  702. width: 100,
  703. },
  704. {
  705. name: "props.hw_cifilterClassic",
  706. displayName: "资产类型",
  707. width: 120,
  708. enableFiltering: false,
  709. },
  710. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  711. {
  712. name: "props.hw_state",
  713. displayName: "资产状态",
  714. width: 150,
  715. enableFiltering: false,
  716. },
  717. {
  718. name: "props.hwnw_area",
  719. displayName: "资产地点",
  720. width: 130,
  721. enableFiltering: false,
  722. },
  723. {
  724. name: "createtime",
  725. displayName: "申请时间",
  726. enableFiltering: false,
  727. },
  728. ];
  729. // $scope.selectButtonClick
  730. var defaultFilterData = {
  731. // "assignee":2,
  732. // "applicationForm": { "hw_state": "在线" },
  733. hw_state: "在线",
  734. idx: 0,
  735. sum: 10,
  736. };
  737. $scope.memoryfilterData = {
  738. // "assignee":2,
  739. // "applicationForm": { "hw_state": "在线" },
  740. hw_state: "在线",
  741. idx: 0,
  742. sum: 10,
  743. };
  744. $scope.refreshData = function (style, filterData) {
  745. if (angular.isUndefined(filterData)) {
  746. filterData = defaultFilterData;
  747. }
  748. $scope.myDatatwo = [];
  749. // $scope.gridOptions['sum']=filterData.sum;
  750. api_cmdb.query(filterData).then(
  751. function (data) {
  752. // $scope.callsPending--;
  753. var myDatatwo = Restangular.stripRestangular(data);
  754. $scope.gridOptions["totalItems"] = data.total;
  755. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  756. myDatatwo.data.node[i].createtime = moment(
  757. myDatatwo.data.node[i].createtime
  758. ).format("YYYY-MM-DD");
  759. }
  760. $scope.myDatatwo = myDatatwo.data.node;
  761. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  762. $scope.myDatatwo[i]["item"] =
  763. i + 1 + filterData.idx * filterData.sum;
  764. }
  765. },
  766. function () { }
  767. );
  768. };
  769. $scope.refreshData("expand-right", defaultFilterData);
  770. $scope.gridOptions.onRegisterApi = function (gridApi) {
  771. $scope.gridApi = gridApi;
  772. gridApi.pagination.on.paginationChanged(
  773. $scope,
  774. function (newPage, pageSize) {
  775. var filtersData = $scope.memoryfilterData;
  776. filtersData.idx = newPage - 1;
  777. filtersData.sum = pageSize;
  778. // $scope.loadData(filtersData);
  779. $scope.refreshData("expand-right", filtersData);
  780. //console.log(pageSize);
  781. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  782. }
  783. );
  784. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  785. // $scope.selected.items.push(data.entity);
  786. //console.log(data);
  787. gridApi.selection.on.rowSelectionChanged(
  788. $scope,
  789. function (scope, ect) {
  790. if (scope.isSelected) {
  791. scope.grid.appScope.selected.items.push(scope.entity);
  792. } else {
  793. for (
  794. var i = 0;
  795. i <= scope.grid.appScope.selected.items.length;
  796. i++
  797. ) {
  798. if (
  799. scope.grid.appScope.selected.items[i].id ==
  800. scope.entity.id
  801. ) {
  802. scope.grid.appScope.selected.items.splice(i, 1);
  803. break;
  804. }
  805. }
  806. }
  807. $scope.mySelectedRows =
  808. $scope.gridApi.selection.getSelectedRows();
  809. }
  810. );
  811. // });
  812. gridApi.selection.on.rowSelectionChangedBatch(
  813. $scope,
  814. function (rows) {
  815. // $scope.selected.items = data.entity;
  816. //console.log(data);
  817. var selectitem = [];
  818. selectitem = angular.copy($scope.selected.items);
  819. for (var j = 0; j < rows.length; j++) {
  820. if (rows[j].isSelected == true) {
  821. selectitem.push(rows[j].entity);
  822. } else {
  823. delete selectitem[j];
  824. // rows.splice(j, 1);
  825. }
  826. }
  827. $scope.selected.items = [];
  828. for (var i = 0; i < selectitem.length; i++) {
  829. if (selectitem[i]) {
  830. $scope.selected.items.push(selectitem[i]);
  831. }
  832. }
  833. }
  834. );
  835. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  836. // // if (row.entity.age > 45) {
  837. // row.grid.api.selection.selectRow(row.entity); // 选中行
  838. // // }
  839. // };
  840. gridApi.core.on.filterChanged($scope, function () {
  841. var grid = this.grid;
  842. var filtersData = {
  843. idx: 0,
  844. sum: 10,
  845. user: {
  846. roledata: {
  847. rolecode: "roleset",
  848. },
  849. selectType: "1",
  850. },
  851. };
  852. angular.forEach(grid.columns, function (item) {
  853. if (item.enableFiltering) {
  854. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  855. if (
  856. angular.isDefined(item.filters[0].term) &&
  857. item.filters[0].term != ""
  858. ) {
  859. if (angular.isUndefined(filtersData["user"])) {
  860. filtersData["user"] = {};
  861. }
  862. filtersData["user"][item.field] = item.filters[0].term;
  863. }
  864. }
  865. });
  866. $scope.memoryfilterData = filtersData;
  867. // $scope.loadData(filtersData);
  868. });
  869. };
  870. $scope.onDblClick = function (data, event) {
  871. // $scope.selected.items = data.entity;
  872. $scope.selectButtonClick(data, event);
  873. };
  874. $scope.title = title;
  875. //树形图
  876. var apple_selected, tree, treedata_avm, treedata_geography;
  877. $scope.my_tree_handler = function (branch) {
  878. //var _ref;
  879. var classify = ($scope.classify =
  880. branch.prefix.toLowerCase() + branch.sign);
  881. api_cmdb
  882. .query({
  883. sign: classify,
  884. })
  885. .then(function (data) {
  886. var myDatalingbei = Restangular.stripRestangular(data);
  887. // console.log(myData.data.node);
  888. if (myDatalingbei.data && myDatalingbei.status == 200) {
  889. var ret = myDatalingbei.data;
  890. redrawSvg(myDatalingbei);
  891. }
  892. });
  893. };
  894. $scope.my_data = [];
  895. function convertListToTree(data, treeMap) {
  896. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  897. var root = null; //Initially set our loop to null
  898. var parentNode = null;
  899. //loop over data
  900. for (var i = 0; i < data.length; i++) {
  901. var datum = data[i];
  902. //each node will have children, so let's give it a "children" poperty
  903. datum.children = [];
  904. //add an entry for this node to the map so that any future children can
  905. //lookup the parent
  906. idToNodeMap[datum.id] = datum;
  907. //Does this node have a parent?
  908. if (
  909. typeof datum.parent === "undefined" ||
  910. datum.parent == null
  911. ) {
  912. //Doesn't look like it, so this node is the root of the tree
  913. root = datum;
  914. treeMap[datum.id] = root;
  915. } else {
  916. //This node has a parent, so let's look it up using the id
  917. parentNode = idToNodeMap[datum.parent.id];
  918. //We don't need this property, so let's delete it.
  919. delete datum.parent;
  920. //Let's add the current node as a child of the parent node.
  921. parentNode.children.push(datum);
  922. }
  923. }
  924. return root;
  925. }
  926. function convertParentToChildList(data) {
  927. var treeMap = {};
  928. var list = [];
  929. convertListToTree(data, treeMap);
  930. angular.forEach(treeMap, function (item) {
  931. list.push(item);
  932. });
  933. return list;
  934. }
  935. $scope.my_tree = tree = {};
  936. $scope.try_async_load = function () {
  937. $scope.my_data = [];
  938. $scope.select_treedata = [];
  939. $scope.doing_async = true;
  940. api_configure_data
  941. .fetchDataList("ciclassify", {
  942. idx: 0,
  943. sum: 100,
  944. })
  945. .then(function (result) {
  946. //console.log(result['list']);
  947. $scope.select_treedata = $scope.my_data =
  948. convertParentToChildList(result["list"]);
  949. $scope.doing_async = false;
  950. // tree.expand_all();
  951. //console.log(treelist);
  952. });
  953. };
  954. $scope.select_treedata = [];
  955. $scope.propTypeOptions = [];
  956. $scope.try_async_load();
  957. $scope.onFilterremove = function (item) {
  958. console.log(item);
  959. };
  960. $scope.searchdata = {};
  961. $scope.clear = function () {
  962. $scope.searchdata = {};
  963. $scope.cifilter_classic = {};
  964. $scope.try_async_load();
  965. var fildata = {
  966. idx: 0,
  967. sum: 10,
  968. hw_state: "在线",
  969. };
  970. $scope.memoryfilterData = fildata;
  971. $scope.refreshData("expand-right", fildata);
  972. };
  973. $scope.chiceIncident = function (item) {
  974. var fildata = $scope.memoryfilterData;
  975. // fildata.applicationForm = {};
  976. // if (item.alltitle && item.alldata) {
  977. // fildata.applicationForm[item.alltitle.key] = item.alldata
  978. // }
  979. if (item && item.id) {
  980. var classify = item.prefix.toLowerCase() + item.sign;
  981. fildata.sign = classify;
  982. }
  983. $scope.gridOptions.paginationCurrentPage = 1;
  984. var transitiondata = angular.copy(item);
  985. $scope.refreshData("expand-right", fildata);
  986. };
  987. $scope.applicadata = [];
  988. $scope.onFilterCallback = function (item) {
  989. var tempclassify = item.prefix.toLowerCase() + item.sign;
  990. api_configure_form
  991. .renderTabForm(tempclassify)
  992. .then(function (data) {
  993. var myData = Restangular.stripRestangular(data);
  994. $scope.applicadata = myData[0].form.fields;
  995. });
  996. // }
  997. };
  998. // $scope.loadData({
  999. // idx: 0,
  1000. // sum: 10,
  1001. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1002. // });
  1003. $scope.selected = {
  1004. items: [],
  1005. };
  1006. $scope.ok = function () {
  1007. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1008. // onDataCallback($scope.selected.item, parentScope);
  1009. // }
  1010. $modalInstance.close($scope.selected.items);
  1011. };
  1012. $scope.cancel = function () {
  1013. $modalInstance.dismiss("cancel");
  1014. };
  1015. },
  1016. size: "lg",
  1017. resolve: {
  1018. items: function () {
  1019. return {
  1020. fetchItems: function (filterData, APIService) {
  1021. filterData = filterData || {};
  1022. if (
  1023. angular.isDefined(filterData.idx) &&
  1024. filterData.idx == null
  1025. ) {
  1026. filterData = {
  1027. idx: 0,
  1028. sum: 10,
  1029. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1030. };
  1031. }
  1032. return $scope.options.templateOptions.fetchItems(
  1033. filterData,
  1034. APIService
  1035. );
  1036. },
  1037. };
  1038. },
  1039. title: function () {
  1040. return $scope.options.templateOptions.label;
  1041. },
  1042. Restangular: function () {
  1043. return $scope.options.templateOptions.Restangular;
  1044. },
  1045. APIService: function () {
  1046. return $scope.options.templateOptions.ApiService;
  1047. },
  1048. onDataCallback: function () {
  1049. return $scope.options.templateOptions.callback;
  1050. },
  1051. parentScope: function () {
  1052. return $scope.options.templateOptions.that;
  1053. },
  1054. },
  1055. });
  1056. modalInstance.result.then(function (selectedItem) {
  1057. $scope.myDatagridoldall = selectedItem;
  1058. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1059. $scope.myDatagridoldall[i]["item"] =
  1060. i +
  1061. 1 +
  1062. $scope.memoryfilterDatagridold.idx *
  1063. $scope.memoryfilterDatagridold.sum;
  1064. }
  1065. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1066. $scope.myDatagridold = $scope.interceptMydata(
  1067. $scope.myDatagridoldall,
  1068. 0,
  1069. 10
  1070. );
  1071. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1072. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1073. $scope.myDatagridoldall;
  1074. $scope.options.initialValue = $scope.model.oldAssets;
  1075. });
  1076. // }
  1077. };
  1078. $scope.changestate = function (itemin) {
  1079. event.preventDefault();
  1080. var modalInstance = $modal.open({
  1081. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1082. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1083. $scope.title = "旧设备状态修改";
  1084. $scope.stateshe = [
  1085. {
  1086. id: 2,
  1087. name: "在库",
  1088. },
  1089. {
  1090. id: 4,
  1091. name: "报修",
  1092. },
  1093. {
  1094. id: 3,
  1095. name: "报废",
  1096. },
  1097. ];
  1098. $scope.hw_state = {};
  1099. $scope.ok = function (item) {
  1100. $modalInstance.close(item.id);
  1101. };
  1102. $scope.cancel = function () {
  1103. $modalInstance.dismiss("cancel");
  1104. };
  1105. },
  1106. size: "sm",
  1107. resolve: {
  1108. scope: function () {
  1109. return $scope;
  1110. },
  1111. },
  1112. });
  1113. modalInstance.result.then(function (selectedItem) {
  1114. if (selectedItem) {
  1115. angular.forEach($scope.myDatagridallold, function (item, index) {
  1116. if (item.id == itemin.id) {
  1117. $scope.myDatagridallold[index].props.hw_state =
  1118. selectedItem.name;
  1119. }
  1120. });
  1121. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1122. $scope.myDatagridallold[i]["item"] =
  1123. i +
  1124. 1 +
  1125. $scope.memoryfilterDatagridold.idx *
  1126. $scope.memoryfilterDatagridold.sum;
  1127. }
  1128. $scope.gridOptions2["totalItems"] =
  1129. $scope.myDatagridallold.length;
  1130. $scope.myDatagridold = $scope.interceptMydata(
  1131. $scope.myDatagridallold,
  1132. $scope.memoryfilterDatagridold.idx,
  1133. $scope.memoryfilterDatagridold.sum
  1134. );
  1135. // $scope.model.oldAssets = $scope.myDatagridallold;
  1136. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1137. $scope.myDatagridallold;
  1138. $scope.options.initialValue = $scope.model.oldAssets;
  1139. }
  1140. });
  1141. };
  1142. $scope.savedata = function (data) {
  1143. event.preventDefault();
  1144. var modalInstance = $modal.open({
  1145. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1146. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1147. $scope.title = "设备编辑";
  1148. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1149. $scope.ok = function (item) {
  1150. $modalInstance.close(item);
  1151. };
  1152. $scope.cancel = function () {
  1153. $modalInstance.dismiss("cancel");
  1154. };
  1155. },
  1156. size: "sm",
  1157. resolve: {
  1158. scope: function () {
  1159. return $scope;
  1160. },
  1161. },
  1162. });
  1163. modalInstance.result.then(function (selectedItem) {
  1164. if (selectedItem) {
  1165. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1166. if (item.id == data.id) {
  1167. $scope.myDatagridoldall[index].olddecription =
  1168. selectedItem.olddecription;
  1169. }
  1170. });
  1171. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1172. $scope.myDatagridoldall[i]["item"] =
  1173. i +
  1174. 1 +
  1175. $scope.memoryfilterDatagridold.idx *
  1176. $scope.memoryfilterDatagridold.sum;
  1177. }
  1178. $scope.gridOptions2["totalItems"] =
  1179. $scope.myDatagridoldall.length;
  1180. $scope.myDatagridold = $scope.interceptMydata(
  1181. $scope.myDatagridoldall,
  1182. 0,
  1183. 10
  1184. );
  1185. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1186. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1187. $scope.myDatagridoldall;
  1188. $scope.options.initialValue = $scope.model.oldAssets;
  1189. }
  1190. });
  1191. };
  1192. $scope.removeold = function (data) {
  1193. event.preventDefault();
  1194. var modalInstance = $modal.open({
  1195. templateUrl: "assets/views/delete.html",
  1196. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1197. $scope.title = "设备删除";
  1198. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1199. $scope.ok = function () {
  1200. $modalInstance.close(data);
  1201. };
  1202. $scope.cancel = function () {
  1203. $modalInstance.dismiss("cancel");
  1204. };
  1205. },
  1206. size: "sm",
  1207. resolve: {
  1208. scope: function () {
  1209. return $scope;
  1210. },
  1211. },
  1212. });
  1213. modalInstance.result.then(function (selectedItem) {
  1214. if (selectedItem) {
  1215. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1216. if (item.id == selectedItem.id) {
  1217. $scope.myDatagridoldall.splice(index, 1);
  1218. }
  1219. });
  1220. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1221. $scope.myDatagridoldall[i]["item"] =
  1222. i +
  1223. 1 +
  1224. $scope.memoryfilterDatagridold.idx *
  1225. $scope.memoryfilterDatagridold.sum;
  1226. }
  1227. $scope.gridOptions2["totalItems"] =
  1228. $scope.myDatagridoldall.length;
  1229. $scope.myDatagridold = $scope.interceptMydata(
  1230. $scope.myDatagridoldall,
  1231. 0,
  1232. 10
  1233. );
  1234. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1235. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1236. $scope.myDatagridoldall;
  1237. $scope.options.initialValue = $scope.model.oldAssets;
  1238. }
  1239. });
  1240. };
  1241. },
  1242. ],
  1243. });
  1244. //ui-grid list
  1245. formlyConfigProvider.setType({
  1246. name: "ui-gridlist",
  1247. extends: "input",
  1248. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1249. defaultOptions: function (options, $scope) {
  1250. return {
  1251. templateOptions: {},
  1252. };
  1253. },
  1254. controller: [
  1255. "$scope",
  1256. "$modal",
  1257. "i18nService",
  1258. "SweetAlert",
  1259. function ($scope, $modal, i18nService, SweetAlert) {
  1260. //gridone
  1261. $scope.langs = i18nService.getAllLangs();
  1262. $scope.lang = "zh-cn";
  1263. i18nService.setCurrentLang($scope.lang);
  1264. $scope.gridOptions = {};
  1265. $scope.gridOptions.data = "myDatagrid";
  1266. $scope.gridOptions.enableColumnResizing = true;
  1267. $scope.gridOptions.enableFiltering = true;
  1268. $scope.gridOptions.enableGridMenu = false;
  1269. $scope.gridOptions.enableRowSelection = true;
  1270. $scope.gridOptions.showGridFooter = true;
  1271. $scope.gridOptions.showColumnFooter = false;
  1272. $scope.gridOptions.fastWatch = true;
  1273. $scope.gridOptions.useExternalFiltering = false;
  1274. // $scope.gridOptions.useExternalPagination = true;
  1275. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1276. $scope.gridOptions.paginationPageSize = 10;
  1277. $scope.gridOptions.multiSelect = false;
  1278. $scope.myDatagrid = [];
  1279. $scope.myDatagridall = [];
  1280. $scope.selected = {
  1281. item: {},
  1282. };
  1283. $scope.memoryfilterDatagrid = {
  1284. idx: 0,
  1285. sum: 10,
  1286. };
  1287. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1288. filterData = {
  1289. idx: 0,
  1290. sum: 10,
  1291. };
  1292. $scope.gridOptions.columnDefs =
  1293. $scope.options.templateOptions.columnDefs;
  1294. }
  1295. $scope.gridOptions.rowIdentity = function (row) {
  1296. return row.id;
  1297. };
  1298. $scope.gridOptions.getRowIdentity = function (row) {
  1299. return row.id;
  1300. };
  1301. // $scope.gridOptions.columnDefs = items.columnDefs();
  1302. $scope.interceptMydata = function (mydate, idx, sum) {
  1303. return mydate.slice(idx * sum, (idx + 1) * sum);
  1304. };
  1305. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1306. $scope.gridApi = gridApi;
  1307. gridApi.pagination.on.paginationChanged(
  1308. $scope,
  1309. function (newPage, pageSize) {
  1310. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1311. $scope.memoryfilterDatagrid.sum = pageSize;
  1312. $scope.myDatagrid = $scope.interceptMydata(
  1313. $scope.myDatagridall,
  1314. $scope.memoryfilterDatagrid.idx,
  1315. 10
  1316. );
  1317. $scope.loadData({
  1318. idx: newPage - 1,
  1319. sum: pageSize,
  1320. });
  1321. }
  1322. );
  1323. gridApi.core.on.filterChanged($scope, function () { });
  1324. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1325. $scope.selected.item = data.entity;
  1326. //console.log(data);
  1327. });
  1328. };
  1329. $scope.loadData = function (mydate, idx, sum) {
  1330. angular.forEach($scope.myDatagrid, function (item, index) {
  1331. $scope.myDatagrid[index].item = index;
  1332. });
  1333. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1334. };
  1335. if ($scope.model.assets) {
  1336. $scope.myDatagridall = $scope.model.assets;
  1337. $scope.loadData($scope.model.assets, 0, 10);
  1338. }
  1339. $scope.saveData = function (itemin) {
  1340. event.preventDefault();
  1341. var modalInstance = $modal.open({
  1342. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1343. controller: function ($scope, $modalInstance, SweetAlert) {
  1344. // $scope.consumptive = {};
  1345. $scope.title = "填写领用设备信息";
  1346. // if (items.name) {
  1347. // $scope.consumptive.name = items.name.name;
  1348. // }
  1349. $scope.placechange = angular.copy(itemin);
  1350. $scope.ok = function (item) {
  1351. if (
  1352. item.props &&
  1353. item.props.hwnw_area &&
  1354. item.props.hwnw_place &&
  1355. item.props.hwnw_room &&
  1356. item.props.hwnwswt_jiguihao &&
  1357. item.props.hwnwswt_Ushu &&
  1358. item.props.snnum
  1359. ) {
  1360. $modalInstance.close(item);
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "数据填写不完整!",
  1364. text: "请检查数据然后提交!",
  1365. type: "error",
  1366. });
  1367. }
  1368. };
  1369. $scope.cancel = function () {
  1370. $modalInstance.dismiss("cancel");
  1371. };
  1372. },
  1373. resolve: {
  1374. SweetAlert: function () {
  1375. return SweetAlert;
  1376. },
  1377. },
  1378. });
  1379. modalInstance.result.then(function (selectedItem) {
  1380. angular.forEach($scope.myDatagrid, function (item, index) {
  1381. if (item.id == selectedItem.id) {
  1382. angular.extend($scope.myDatagrid[index], selectedItem);
  1383. }
  1384. });
  1385. // $scope.myData3.push(selectedItem);
  1386. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1387. $scope.myDatagrid[i]["item"] =
  1388. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1389. }
  1390. // $scope.model.assets = $scope.myDatagridall;
  1391. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1392. $scope.myDatagridall;
  1393. });
  1394. };
  1395. },
  1396. ],
  1397. });
  1398. //设备耗材list组件
  1399. formlyConfigProvider.setType({
  1400. name: "ui-shehaolist",
  1401. // extends: 'radio',
  1402. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1403. defaultOptions: function (options) {
  1404. return {
  1405. templateOptions: {
  1406. refresh: function () { },
  1407. refreshDelay: 0,
  1408. },
  1409. };
  1410. },
  1411. controller: [
  1412. "$scope",
  1413. "$filter",
  1414. "ngTableParams",
  1415. function ($scope, $filter, ngTableParams) {
  1416. // var data = { "haodata": [], "shedata": [] };
  1417. var haodata = [];
  1418. var shedata = [];
  1419. if ($scope.model.consumables) {
  1420. if (angular.isArray($scope.model.consumables)) {
  1421. haodata = $scope.model.consumables;
  1422. } else {
  1423. haodata = JSON.parse($scope.model.consumables);
  1424. }
  1425. $scope.model.consumables = haodata;
  1426. angular.forEach(haodata, function (item, index) {
  1427. haodata[index].item = index + 1;
  1428. });
  1429. }
  1430. if ($scope.model.assets) {
  1431. if (angular.isArray($scope.model.assets)) {
  1432. shedata = $scope.model.assets;
  1433. } else {
  1434. shedata = JSON.parse($scope.model.assets);
  1435. }
  1436. $scope.model.assets = shedata;
  1437. angular.forEach(shedata, function (item, index) {
  1438. shedata[index].item = index + 1;
  1439. });
  1440. }
  1441. $scope.tableParamshao = new ngTableParams(
  1442. {
  1443. page: 1,
  1444. count: 5,
  1445. },
  1446. {
  1447. total: haodata.length,
  1448. getData: function ($defer, params) {
  1449. var orderedData = params.sorting()
  1450. ? $filter("orderBy")(haodata, params.orderBy())
  1451. : haodata;
  1452. $defer.resolve(
  1453. orderedData.slice(
  1454. (params.page() - 1) * params.count(),
  1455. params.page() * params.count()
  1456. )
  1457. );
  1458. },
  1459. }
  1460. );
  1461. $scope.tableParamsshe = new ngTableParams(
  1462. {
  1463. page: 1,
  1464. count: 5,
  1465. },
  1466. {
  1467. total: shedata.length,
  1468. getData: function ($defer, params) {
  1469. var orderedData = params.sorting()
  1470. ? $filter("orderBy")(shedata, params.orderBy())
  1471. : shedata;
  1472. $defer.resolve(
  1473. orderedData.slice(
  1474. (params.page() - 1) * params.count(),
  1475. params.page() * params.count()
  1476. )
  1477. );
  1478. },
  1479. }
  1480. );
  1481. $scope.editId = -1;
  1482. $scope.setEditId = function (pid) {
  1483. $scope.editId = pid;
  1484. };
  1485. if (
  1486. $scope.$parent.$parent.$parent.model.isAgree &&
  1487. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1488. ) {
  1489. $scope.isAgree = "同意";
  1490. } else if (
  1491. $scope.$parent.$parent.$parent.model.isAgree &&
  1492. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1493. ) {
  1494. $scope.isAgree = "同意";
  1495. } else if (
  1496. $scope.$parent.$parent.$parent.model.isAgree &&
  1497. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1498. ) {
  1499. $scope.isAgree = "返回修改";
  1500. }
  1501. },
  1502. ],
  1503. });
  1504. //关联资产出库
  1505. formlyConfigProvider.setType({
  1506. name: "ui-meansmodelselect",
  1507. extends: "input",
  1508. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1509. defaultOptions: function (options) {
  1510. return {
  1511. templateOptions: {},
  1512. };
  1513. },
  1514. controller: [
  1515. "$scope",
  1516. "$modal",
  1517. function ($scope, $modal) {
  1518. $scope.openModal = function (size, options, modal) {
  1519. var modalInstance = $modal.open({
  1520. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1521. controller: function (
  1522. $scope,
  1523. $rootScope,
  1524. $modalInstance,
  1525. items,
  1526. title,
  1527. Restangular,
  1528. APIService,
  1529. api_user_data,
  1530. i18nService,
  1531. api_wechatfile
  1532. ) {
  1533. $scope.langs = i18nService.getAllLangs();
  1534. $scope.lang = "zh-cn";
  1535. i18nService.setCurrentLang($scope.lang);
  1536. $scope.gridOptions = {};
  1537. $scope.gridOptions.data = "myData";
  1538. $scope.gridOptions.enableColumnResizing = true;
  1539. $scope.gridOptions.enableFiltering = false;
  1540. $scope.gridOptions.enableGridMenu = false;
  1541. $scope.gridOptions.showGridFooter = true;
  1542. $scope.gridOptions.showColumnFooter = false;
  1543. $scope.gridOptions.fastWatch = true;
  1544. $scope.gridOptions.useExternalFiltering = true;
  1545. $scope.gridOptions.useExternalPagination = true;
  1546. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1547. $scope.gridOptions.paginationPageSize = 10;
  1548. $scope.gridOptions.multiSelect = false;
  1549. $scope.gridOptions.rowIdentity = function (row) {
  1550. return row.id;
  1551. };
  1552. $scope.gridOptions.getRowIdentity = function (row) {
  1553. return row.id;
  1554. };
  1555. // $scope.states = [{
  1556. // id: 0,
  1557. // name: '待批准'
  1558. // },
  1559. // {
  1560. // id: 1,
  1561. // name: '已驳回'
  1562. // },
  1563. // {
  1564. // id: 2,
  1565. // name: '待出库'
  1566. // },
  1567. // {
  1568. // id: 3,
  1569. // name: '信息更新'
  1570. // },
  1571. // {
  1572. // id: 4,
  1573. // name: '信息确认'
  1574. // },
  1575. // {
  1576. // id: 5,
  1577. // name: '已关闭'
  1578. // }
  1579. // ];
  1580. $scope.getStatesDictionary = function () {
  1581. var data = {
  1582. key: "applicationForm_status",
  1583. type: "list",
  1584. };
  1585. api_wechatfile.getDictionary(data).then(function (res) {
  1586. $scope.states = res;
  1587. });
  1588. };
  1589. $scope.getStatesDictionary();
  1590. $scope.type = [
  1591. {
  1592. id: 1,
  1593. name: "资产入库",
  1594. },
  1595. {
  1596. id: 2,
  1597. name: "资产归还",
  1598. },
  1599. {
  1600. id: 3,
  1601. name: "资产领用",
  1602. },
  1603. {
  1604. id: 4,
  1605. name: "资产更换",
  1606. },
  1607. ];
  1608. $scope.typedata = function (row) {
  1609. if (row.type == 0) {
  1610. return "资产入库";
  1611. } else if (row.type == 2) {
  1612. return "资产归还";
  1613. } else if (row.type == 1) {
  1614. return "资产领用";
  1615. } else if (row.type == 4) {
  1616. return "资产更换";
  1617. }
  1618. };
  1619. $scope.statedata = function (row) {
  1620. if (row.status == 0) {
  1621. return "待批准";
  1622. } else if (row.status == 1) {
  1623. return "已驳回";
  1624. } else if (row.status == 2) {
  1625. return "待出库";
  1626. } else if (row.status == 3) {
  1627. return "信息更新";
  1628. } else if (row.status == 4) {
  1629. return "信息确认";
  1630. } else if (row.status == 5) {
  1631. return "已关闭";
  1632. }
  1633. };
  1634. $scope.transferTime = function (time) {
  1635. return moment(time).format("YYYY-MM-DD HH:mm");
  1636. };
  1637. $scope.application = [
  1638. {
  1639. value: "serialNumbe",
  1640. name: "申请单编号",
  1641. },
  1642. // { value: "proposer", name: '申请人' },
  1643. {
  1644. value: "purpose",
  1645. name: "领用用途",
  1646. },
  1647. // { value: "cmdbsign", name: '设备编号' }
  1648. ];
  1649. $scope.parameters = null;
  1650. $scope.open = function ($event) {
  1651. $event.preventDefault();
  1652. $event.stopPropagation();
  1653. $scope.opened = !$scope.opened;
  1654. };
  1655. $scope.endOpen = function ($event) {
  1656. $event.preventDefault();
  1657. $event.stopPropagation();
  1658. $scope.startOpened = false;
  1659. $scope.endOpened = !$scope.endOpened;
  1660. };
  1661. $scope.startOpen = function ($event) {
  1662. $event.preventDefault();
  1663. $event.stopPropagation();
  1664. $scope.endOpened = false;
  1665. $scope.startOpened = !$scope.startOpened;
  1666. };
  1667. $scope.othcode = {};
  1668. $scope.searchkeys = {};
  1669. $scope.parameters = {};
  1670. $scope.memoryfilterData = {
  1671. assignee: $rootScope.user.id,
  1672. candidateGroups: $rootScope.user.group[0].id,
  1673. searchType: "todo",
  1674. idx: 0,
  1675. sum: 10,
  1676. };
  1677. $scope.clear = function () {
  1678. $scope.searchkeys = {};
  1679. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1680. // $scope.othcode = {};
  1681. $scope.parameters = {};
  1682. var fildata = {
  1683. assignee: $rootScope.user.id,
  1684. candidateGroups: $rootScope.user.group[0].id,
  1685. searchType: "todo",
  1686. idx: 0,
  1687. sum: 10,
  1688. };
  1689. // sessionStorage.removeItem("searchincident");
  1690. $scope.memoryfilterData = fildata;
  1691. $scope.loadData(fildata);
  1692. };
  1693. $scope.chiceIncident = function (parameters, item, stateid) {
  1694. var fildata = {
  1695. assignee: $rootScope.user.id,
  1696. candidateGroups: 1,
  1697. searchType: "todo",
  1698. idx: 0,
  1699. sum: 10,
  1700. };
  1701. if (item) {
  1702. fildata.applicationForm = {};
  1703. if (item.alltitle && item.alldata) {
  1704. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1705. }
  1706. if (item.linkProposer) {
  1707. fildata.applicationForm.linkProposer = item.linkProposer;
  1708. }
  1709. if (item.proposer) {
  1710. fildata.applicationForm.proposer = item.proposer;
  1711. }
  1712. if (item.status) {
  1713. fildata.applicationForm["status"] = {
  1714. id: item.status.id,
  1715. };
  1716. }
  1717. if (item.type) {
  1718. fildata.applicationForm["type"] = {
  1719. id: item.type.id,
  1720. };
  1721. }
  1722. }
  1723. $scope.gridOptions.paginationCurrentPage = 1;
  1724. if (
  1725. parameters &&
  1726. parameters.paramDateFrom &&
  1727. parameters.paramDateTo
  1728. ) {
  1729. angular.extend(fildata, {
  1730. idx: 0,
  1731. sum: $scope.gridOptions.paginationPageSize,
  1732. });
  1733. angular.extend(fildata.applicationForm, {
  1734. startDate: moment(parameters.paramDateFrom).format(
  1735. "YYYY-MM-DD HH:mm:ss"
  1736. ),
  1737. endDate: moment(parameters.paramDateTo).format(
  1738. "YYYY-MM-DD 23:59:59"
  1739. ),
  1740. });
  1741. }
  1742. var transitiondata = angular.copy(item);
  1743. // angular.extend(fildata.applicationForm, transitiondata)
  1744. $scope.loadData(fildata);
  1745. };
  1746. $scope.key = {};
  1747. api_user_data
  1748. .fetchDataList("user", {
  1749. idx: 0,
  1750. sum: 1000,
  1751. flag: -1,
  1752. })
  1753. .then(function (data) {
  1754. $scope.handlingPersonnelUser = data.list;
  1755. });
  1756. $scope.gridOptions.columnDefs = items.columnDefs();
  1757. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1758. $scope.gridApi = gridApi;
  1759. gridApi.pagination.on.paginationChanged(
  1760. $scope,
  1761. function (newPage, pageSize) {
  1762. // console.log(newPage);
  1763. // console.log(pageSize);
  1764. $scope.loadData({
  1765. idx: newPage - 1,
  1766. sum: pageSize,
  1767. });
  1768. }
  1769. );
  1770. gridApi.core.on.filterChanged($scope, function () { });
  1771. gridApi.selection.on.rowSelectionChanged(
  1772. $scope,
  1773. function (data) {
  1774. $scope.selected.item = data.entity;
  1775. //console.log(data);
  1776. }
  1777. );
  1778. };
  1779. $scope.loadData = function (filterData) {
  1780. items.fetchItems(filterData, APIService).then(function (data) {
  1781. var myData = Restangular.stripRestangular(data);
  1782. $scope.gridOptions.totalItems = myData.totalNum;
  1783. $scope.myData = myData.list;
  1784. for (var i = 0; i < $scope.myData.length; i++) {
  1785. $scope.myData[i]["item"] =
  1786. i + 1 + filterData.idx * filterData.sum;
  1787. }
  1788. });
  1789. };
  1790. $scope.title = title;
  1791. $scope.loadData({
  1792. idx: 0,
  1793. sum: 10,
  1794. assignee: $rootScope.user.id,
  1795. candidateGroups: $rootScope.user.group[0].id,
  1796. searchType: "todo",
  1797. });
  1798. $scope.selected = {
  1799. item: {},
  1800. };
  1801. $scope.ok = function () {
  1802. //console.log($scope.selected.item);
  1803. $modalInstance.close($scope.selected.item);
  1804. };
  1805. $scope.cancel = function () {
  1806. $modalInstance.dismiss("cancel");
  1807. };
  1808. },
  1809. size: "lg",
  1810. resolve: {
  1811. items: function () {
  1812. return {
  1813. fetchItems: function (filterData, APIService) {
  1814. filterData = filterData || {};
  1815. // if(!filterData.idx){
  1816. if (
  1817. angular.isDefined(filterData.idx) &&
  1818. filterData.idx == null
  1819. ) {
  1820. filterData = {
  1821. idx: 0,
  1822. sum: 10,
  1823. };
  1824. }
  1825. return options.templateOptions.fetchItems(
  1826. filterData,
  1827. APIService,
  1828. options
  1829. );
  1830. },
  1831. columnDefs: function () {
  1832. return options.templateOptions.columnDefs;
  1833. },
  1834. };
  1835. },
  1836. title: function () {
  1837. return options.templateOptions.modalTitle;
  1838. },
  1839. Restangular: function () {
  1840. return options.templateOptions.Restangular;
  1841. },
  1842. APIService: function () {
  1843. return options.templateOptions.ApiService;
  1844. },
  1845. },
  1846. });
  1847. modalInstance.result.then(
  1848. function (selectedItem) {
  1849. var selectitem = {
  1850. title: selectedItem.title,
  1851. description: selectedItem.description,
  1852. };
  1853. if (options.key == "chuku") {
  1854. if (selectedItem.assets) {
  1855. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1856. selectedItem.assets;
  1857. }
  1858. if (selectedItem.consumables) {
  1859. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1860. selectedItem.consumables;
  1861. }
  1862. angular.extend(
  1863. $scope.$parent.$parent.$parent.model,
  1864. selectitem
  1865. );
  1866. options.value(selectedItem);
  1867. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1868. } else {
  1869. angular.extend(options.model, selectitem);
  1870. options.value(selectedItem);
  1871. }
  1872. },
  1873. function () {
  1874. //console.log('Modal dismissed at: ' + new Date());
  1875. }
  1876. );
  1877. };
  1878. },
  1879. ],
  1880. });
  1881. //文本框
  1882. formlyConfigProvider.setType({
  1883. name: "ui-textcmdb",
  1884. extends: "",
  1885. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1886. defaultOptions: function (options) {
  1887. return {
  1888. templateOptions: {
  1889. transform: function (model, value) {
  1890. return value;
  1891. },
  1892. },
  1893. validation: {
  1894. messages: {
  1895. maxlength: function (viewValue, modelValue, scope) {
  1896. if (viewValue != null) {
  1897. if (viewValue.length > scope.to.maxlength) {
  1898. return (
  1899. scope.to.label +
  1900. " 字数(" +
  1901. viewValue.length +
  1902. ")超限(" +
  1903. scope.to.maxlength +
  1904. ")"
  1905. );
  1906. } else {
  1907. return "";
  1908. }
  1909. }
  1910. },
  1911. },
  1912. },
  1913. };
  1914. },
  1915. controller: [
  1916. "$scope",
  1917. function ($scope) {
  1918. var value = $scope.model[$scope.options.key];
  1919. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1920. $scope.model[$scope.options.key] =
  1921. $scope.options.templateOptions.transform(
  1922. $scope.originalModel,
  1923. value
  1924. );
  1925. }
  1926. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1927. $scope.options.templateOptions.felditem($scope);
  1928. }
  1929. },
  1930. ],
  1931. });
  1932. //设备组件
  1933. formlyConfigProvider.setType({
  1934. name: "ui-applist",
  1935. extends: "radio",
  1936. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1937. defaultOptions: function (options) {
  1938. return {
  1939. templateOptions: {
  1940. refresh: function () { },
  1941. refreshDelay: 0,
  1942. },
  1943. };
  1944. },
  1945. controller: [
  1946. "$scope",
  1947. "$filter",
  1948. "ngTableParams",
  1949. function ($scope, $filter, ngTableParams) {
  1950. var data = [];
  1951. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1952. // data = JSON.parse($scope.model.consumables);
  1953. if (angular.isArray($scope.model.consumables)) {
  1954. data = $scope.model.consumables;
  1955. } else {
  1956. data = JSON.parse($scope.model.consumables);
  1957. }
  1958. $scope.model.consumables = data;
  1959. angular.forEach(data, function (item, index) {
  1960. data[index].item = index + 1;
  1961. });
  1962. }
  1963. if ($scope.model.assets && $scope.options.key == "assets") {
  1964. if (angular.isArray($scope.model.assets)) {
  1965. data = $scope.model.assets;
  1966. } else {
  1967. data = JSON.parse($scope.model.assets);
  1968. }
  1969. // data = JSON.parse($scope.model.assets);
  1970. $scope.model.assets = data;
  1971. angular.forEach(data, function (item, index) {
  1972. data[index].item = index + 1;
  1973. });
  1974. }
  1975. $scope.tableParams = new ngTableParams(
  1976. {
  1977. page: 1,
  1978. count: 5,
  1979. },
  1980. {
  1981. total: data.length,
  1982. getData: function ($defer, params) {
  1983. var orderedData = params.sorting()
  1984. ? $filter("orderBy")(data, params.orderBy())
  1985. : data;
  1986. $defer.resolve(
  1987. orderedData.slice(
  1988. (params.page() - 1) * params.count(),
  1989. params.page() * params.count()
  1990. )
  1991. );
  1992. },
  1993. }
  1994. );
  1995. $scope.editId = -1;
  1996. $scope.setEditId = function (pid) {
  1997. $scope.editId = pid;
  1998. };
  1999. },
  2000. ],
  2001. });
  2002. //list组件
  2003. formlyConfigProvider.setType({
  2004. name: "ui-gudinglist",
  2005. extends: "radio",
  2006. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2007. defaultOptions: function (options) {
  2008. return {
  2009. templateOptions: {
  2010. refresh: function () { },
  2011. refreshDelay: 0,
  2012. },
  2013. };
  2014. },
  2015. controller: [
  2016. "$scope",
  2017. "$filter",
  2018. "ngTableParams",
  2019. function ($scope, $filter, ngTableParams) {
  2020. var data = [];
  2021. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2022. // data = JSON.parse($scope.model.consumables);
  2023. if (angular.isArray($scope.model.consumables)) {
  2024. data = $scope.model.consumables;
  2025. } else {
  2026. data = JSON.parse($scope.model.consumables);
  2027. }
  2028. $scope.model.consumables = data;
  2029. angular.forEach(data, function (item, index) {
  2030. data[index].item = index + 1;
  2031. });
  2032. }
  2033. if ($scope.model.assets && $scope.options.key == "assets") {
  2034. if (angular.isArray($scope.model.assets)) {
  2035. data = $scope.model.assets;
  2036. } else {
  2037. data = JSON.parse($scope.model.assets);
  2038. }
  2039. // data = JSON.parse($scope.model.assets);
  2040. $scope.model.assets = data;
  2041. angular.forEach(data, function (item, index) {
  2042. data[index].item = index + 1;
  2043. });
  2044. }
  2045. $scope.tableParams = new ngTableParams(
  2046. {
  2047. page: 1,
  2048. count: 5,
  2049. },
  2050. {
  2051. total: data.length,
  2052. getData: function ($defer, params) {
  2053. var orderedData = params.sorting()
  2054. ? $filter("orderBy")(data, params.orderBy())
  2055. : data;
  2056. $defer.resolve(
  2057. orderedData.slice(
  2058. (params.page() - 1) * params.count(),
  2059. params.page() * params.count()
  2060. )
  2061. );
  2062. },
  2063. }
  2064. );
  2065. $scope.editId = -1;
  2066. $scope.setEditId = function (pid) {
  2067. $scope.editId = pid;
  2068. };
  2069. },
  2070. ],
  2071. });
  2072. //other list tab组件
  2073. formlyConfigProvider.setType({
  2074. name: "ui-otherlisttab",
  2075. extends: "",
  2076. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2077. defaultOptions: function (options) {
  2078. return {
  2079. templateOptions: {
  2080. refresh: function () { },
  2081. refreshDelay: 0,
  2082. },
  2083. };
  2084. },
  2085. controller: [
  2086. "$scope",
  2087. "$filter",
  2088. "ngTableParams",
  2089. function ($scope, $filter, ngTableParams) { },
  2090. ],
  2091. });
  2092. //审核查看组件
  2093. formlyConfigProvider.setType({
  2094. name: "ui-aprovelist",
  2095. extends: "",
  2096. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2097. defaultOptions: function (options) {
  2098. return {
  2099. templateOptions: {
  2100. refresh: function () { },
  2101. refreshDelay: 0,
  2102. },
  2103. };
  2104. },
  2105. controller: [
  2106. "$scope",
  2107. "$filter",
  2108. "ngTableParams",
  2109. function ($scope, $filter, ngTableParams) {
  2110. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2111. $scope.isAgree = "同意";
  2112. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2113. $scope.isAgree = "同意";
  2114. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2115. $scope.isAgree = "返回修改";
  2116. }
  2117. },
  2118. ],
  2119. });
  2120. //other list组件
  2121. formlyConfigProvider.setType({
  2122. name: "ui-otherlist",
  2123. extends: "",
  2124. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2125. defaultOptions: function (options) {
  2126. return {
  2127. templateOptions: {
  2128. refresh: function () { },
  2129. refreshDelay: 0,
  2130. },
  2131. };
  2132. },
  2133. controller: [
  2134. "$rootScope",
  2135. "$scope",
  2136. "$parse",
  2137. "$injector",
  2138. "$http",
  2139. "$q",
  2140. "$state",
  2141. "$stateParams",
  2142. "$modal",
  2143. "$timeout",
  2144. "$interval",
  2145. "i18nService",
  2146. "SweetAlert",
  2147. "FileUploader",
  2148. "Restangular",
  2149. "UserRestangular",
  2150. "BpmRestangular",
  2151. "api_configure_form",
  2152. "api_configure_data",
  2153. "api_bpm_domain",
  2154. "api_bpm_data",
  2155. "api_user_data",
  2156. "api_cmdb",
  2157. "api_sysinfo",
  2158. function (
  2159. $rootScope,
  2160. $scope,
  2161. $parse,
  2162. $injector,
  2163. $http,
  2164. $q,
  2165. $state,
  2166. $stateParams,
  2167. $modal,
  2168. $timeout,
  2169. $interval,
  2170. i18nService,
  2171. SweetAlert,
  2172. FileUploader,
  2173. Restangular,
  2174. UserRestangular,
  2175. BpmRestangular,
  2176. api_configure_form,
  2177. api_configure_data,
  2178. api_bpm_domain,
  2179. api_bpm_data,
  2180. api_user_data,
  2181. api_cmdb,
  2182. api_sysinfo
  2183. ) {
  2184. console.log("哈哈");
  2185. console.log($scope);
  2186. $scope.langs = i18nService.getAllLangs();
  2187. $scope.lang = "zh-cn";
  2188. i18nService.setCurrentLang($scope.lang);
  2189. var vm = this;
  2190. vm.options = {};
  2191. vm.exampleTitle = ["expressionProperties", "model property"];
  2192. vm.fields = [];
  2193. vm.models = {};
  2194. // vm.models["loginUser"] = $rootScope.user;
  2195. var that = $injector;
  2196. var parse = $parse;
  2197. var formKey = "";
  2198. var pdKey = "";
  2199. if (
  2200. angular.isDefined($state.current.pdKey) &&
  2201. $state.current.pdKey != ""
  2202. ) {
  2203. pdKey = $state.current.pdKey;
  2204. //console.log("pdKey::"+$state.current.pdKey);
  2205. }
  2206. if (
  2207. angular.isDefined($stateParams.formKey) &&
  2208. $stateParams.formKey != ""
  2209. ) {
  2210. formKey = $stateParams.formKey;
  2211. //console.log("formKey::"+$stateParams.formKey);
  2212. }
  2213. //用户测试数据,后续从header的auth中获取
  2214. var userId = 2;
  2215. userId = $rootScope.user.id;
  2216. //==============处理表单设计数据 开始====================
  2217. //处理组件加载后台数据选项的方法
  2218. function refreshSelectOptions(searchVal, field) {
  2219. if (field.templateOptions.optionsUrl) {
  2220. var process = BpmRestangular.all("");
  2221. if (field.templateOptions.ApiService) {
  2222. process = UserRestangular.all("");
  2223. }
  2224. process
  2225. .customPOST(
  2226. {
  2227. idx: 0,
  2228. sum: 1000,
  2229. },
  2230. field.templateOptions.optionsUrl
  2231. )
  2232. .then(function (result) {
  2233. if (!field.templateOptions.options) {
  2234. field.templateOptions.options = [];
  2235. }
  2236. if (field.templateOptions.optionsDataKey) {
  2237. field.templateOptions.options =
  2238. result[field.templateOptions.optionsDataKey];
  2239. } else {
  2240. field.templateOptions.options = result;
  2241. }
  2242. });
  2243. }
  2244. }
  2245. function decodeVMTabForm(model, tabs) {
  2246. var result = {
  2247. model: {},
  2248. tabs: [],
  2249. };
  2250. var mdata = angular.fromJson(model);
  2251. angular.extend(result.model, mdata);
  2252. angular.forEach(tabs, function (tab) {
  2253. tab.form.model = vm.models;
  2254. angular.forEach(tab.form.fields, function (field) {
  2255. if (field.key == "") {
  2256. delete field.key;
  2257. }
  2258. field.type = "ui-otherlisttab";
  2259. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2260. var extObj = angular.fromJson(field.extjson);
  2261. angular.extend(field.templateOptions, extObj.templateOptions);
  2262. delete extObj.templateOptions;
  2263. for (var prop in extObj) {
  2264. if (new RegExp("Expression").test(prop)) {
  2265. //var obj = $scope.$eval(extObj[prop]);
  2266. //extObj[prop] = $scope.$eval(extObj[prop]);
  2267. if (extObj[prop] != null) {
  2268. if (new RegExp("function").test(extObj[prop])) {
  2269. var propValue = eval(extObj[prop]);
  2270. extObj[prop] = propValue;
  2271. } else {
  2272. //console.log(extObj[prop]);
  2273. var obj = $scope.$eval(extObj[prop]);
  2274. extObj[prop] = obj;
  2275. //console.log(obj);
  2276. }
  2277. }
  2278. } else if (new RegExp("expressionProperties").test(prop)) {
  2279. for (var p in extObj[prop]) {
  2280. if (new RegExp("function").test(extObj[prop][p])) {
  2281. var propValue = eval(extObj[prop][p]);
  2282. extObj[prop][p] = propValue;
  2283. } else {
  2284. //if(p.indexOf("'")>=0){
  2285. // var obj = $scope.$eval(extObj[prop][p]);
  2286. // extObj[prop][$scope.$eval(p)]=obj;
  2287. //}
  2288. }
  2289. }
  2290. } else if ("watcher" == prop) {
  2291. if (angular.isArray(extObj[prop])) {
  2292. angular.forEach(extObj[prop], function (item, index) {
  2293. for (var p in item) {
  2294. if (new RegExp("function").test(item[p])) {
  2295. var propValue = eval(item[p]);
  2296. extObj[prop][index][p] = propValue;
  2297. }
  2298. }
  2299. });
  2300. } else if (angular.isObject(extObj[prop])) {
  2301. for (var p in extObj[prop]) {
  2302. if (new RegExp("function").test(extObj[prop][p])) {
  2303. var propValue = eval(extObj[prop][p]);
  2304. extObj[prop][p] = propValue;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. }
  2310. angular.extend(field, extObj);
  2311. delete field.extjson;
  2312. }
  2313. if (field.extjson == "") {
  2314. delete field.extjson;
  2315. }
  2316. if (angular.isDefined(field.templateOptions)) {
  2317. var templateOs = field.templateOptions;
  2318. for (var property in templateOs) {
  2319. //console.log(property);
  2320. if (
  2321. angular.isString(templateOs[property]) &&
  2322. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2323. ) {
  2324. if (new RegExp("function").test(templateOs[property])) {
  2325. var propValue = eval(templateOs[property]);
  2326. field.templateOptions[property] = propValue;
  2327. } else {
  2328. if (that.has(templateOs[property])) {
  2329. field.templateOptions[property] = that.get(
  2330. templateOs[property]
  2331. );
  2332. } else {
  2333. field.templateOptions[property] = templateOs[property];
  2334. }
  2335. }
  2336. } else if (templateOs[property] == null) {
  2337. //delete field.templateOptions[property];
  2338. } else {
  2339. }
  2340. }
  2341. }
  2342. if (
  2343. angular.isDefined(field.templateOptions) &&
  2344. angular.isDefined(field.templateOptions.extjson)
  2345. ) {
  2346. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2347. angular.extend(field.templateOptions, extObj);
  2348. delete field.templateOptions.extjson;
  2349. }
  2350. //...
  2351. if (field.templateOptions) {
  2352. //处理远程获取数据控件方法调用
  2353. if (field.templateOptions.optionsUrl) {
  2354. field.templateOptions.refresh = refreshSelectOptions;
  2355. }
  2356. //处理嵌套属性数据绑定/
  2357. if (field.templateOptions.pkey) {
  2358. var pmodel,
  2359. i = 0;
  2360. angular.forEach(
  2361. field.templateOptions.pkey.split("."),
  2362. function (p) {
  2363. if (i == 0) {
  2364. if (result.model[p] == null) {
  2365. result.model[p] = {};
  2366. }
  2367. pmodel = result.model[p];
  2368. i++;
  2369. } else {
  2370. if (pmodel[p] == null) {
  2371. pmodel[p] = {};
  2372. }
  2373. pmodel = pmodel[p];
  2374. }
  2375. }
  2376. );
  2377. if (pmodel != null) {
  2378. field.model = pmodel;
  2379. if (pmodel[field.key] == null) {
  2380. pmodel[field.key] = null;
  2381. }
  2382. }
  2383. } else {
  2384. if (result.model[field.key] == null) {
  2385. result.model[field.key] = null;
  2386. }
  2387. }
  2388. //处理弹出框组件初始化
  2389. if (field.type == "ui-input-selectmodal") {
  2390. field.templateOptions.modal = $modal;
  2391. //field.templateOptions.Restangular = Restangular;
  2392. } else if (field.type == "ui-userselect") {
  2393. field.templateOptions.modal = $modal;
  2394. //field.templateOptions.Restangular = Restangular;
  2395. } else if (field.type == "ui-multiuserselect") {
  2396. field.templateOptions.modal = $modal;
  2397. } else if (field.type == "ui-modelselect") {
  2398. field.templateOptions.modal = $modal;
  2399. //field.templateOptions.Restangular = Restangular;
  2400. } else if (field.type == "ui-cmdbuplode") {
  2401. $scope.fileUploader = field.templateOptions.fileUploader =
  2402. new FileUploader({
  2403. url: "/uploader",
  2404. queueLimit: 1, //文件个数
  2405. autoUpload: true,
  2406. });
  2407. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2408. } else if (field.type == "ui-dropfile") {
  2409. field.templateOptions.fileUploader = new FileUploader({
  2410. url: "/uploader",
  2411. });
  2412. field.templateOptions.taskId = $stateParams.taskId;
  2413. field.templateOptions.processInstanceId =
  2414. $stateParams.processInstanceId;
  2415. field.templateOptions.userId = $rootScope.user.id;
  2416. //field.ApiService=api_bpm_domain;
  2417. } else if (field.type == "ui-dropfiletable") {
  2418. if (field.templateOptions.processInstanceId) {
  2419. } else {
  2420. field.templateOptions.processInstanceId =
  2421. $stateParams.processInstanceId;
  2422. }
  2423. } else if (field.type == "ui-repeatSection") {
  2424. var repeatForm = {
  2425. model: {},
  2426. fields: field.templateOptions.fields,
  2427. };
  2428. repeatForm.model[field.key] = [];
  2429. decodeVMTabForm(repeatForm);
  2430. }
  2431. }
  2432. // console.log(field);
  2433. //field
  2434. //result.fields.push(field);
  2435. });
  2436. });
  2437. vm.originalTabs = angular.copy(vm.form);
  2438. }
  2439. //======================处理表单设计数据 结束========================
  2440. $scope.ldloading = {};
  2441. function filter(obj) {
  2442. angular.forEach(obj, function (key, value) {
  2443. if (value === "" || value === null) {
  2444. delete obj[key];
  2445. } else if (
  2446. Object.prototype.toString.call(value) === "[object Object]"
  2447. ) {
  2448. filter(value);
  2449. } else if (angular.isArray(value)) {
  2450. angular.forEach(value, function (item) {
  2451. filter(item);
  2452. });
  2453. }
  2454. });
  2455. }
  2456. function invokeOnAllFormOptions(fn) {
  2457. angular.forEach(vm.tabs, function (tab) {
  2458. if (tab.form.options && tab.form.options[fn]) {
  2459. tab.form.options[fn]();
  2460. }
  2461. });
  2462. }
  2463. function encodeCIData(data, ciId) {
  2464. /*
  2465. create/update state:未审核
  2466. create createtime:系统时间
  2467. create/update lastupdatetime : 系统时间
  2468. label:ci分类
  2469. */
  2470. if (ciId) {
  2471. var baseprop = [
  2472. "uuid",
  2473. "name",
  2474. "type",
  2475. "label",
  2476. "status",
  2477. "createtime",
  2478. "lastupdatetime",
  2479. "props",
  2480. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2481. var extraprop = "props";
  2482. data[extraprop] = {};
  2483. for (var key in data) {
  2484. console.log(data[key]);
  2485. if (_.indexOf(baseprop, key) >= 0) {
  2486. continue;
  2487. } else {
  2488. data[extraprop][key] = data[key];
  2489. delete data[key];
  2490. }
  2491. }
  2492. if ($rootScope.user) {
  2493. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2494. data[extraprop]["configperson"] = $rootScope.user.name;
  2495. var isCMAdminFlag = false;
  2496. angular.forEach($rootScope.user.role, function (roleItem) {
  2497. if (roleItem.rolecode == "cmdb charge") {
  2498. isCMAdminFlag = true;
  2499. }
  2500. });
  2501. if (!isCMAdminFlag) {
  2502. data[extraprop]["state"] = "1";
  2503. }
  2504. }
  2505. if (data.props.id) {
  2506. } else {
  2507. data.label = ciId;
  2508. }
  2509. return data;
  2510. }
  2511. return undefined;
  2512. }
  2513. function decodeCIModel(data) {
  2514. var extraprop = "props";
  2515. if (data[extraprop]) {
  2516. for (var key in data[extraprop]) {
  2517. data[key] = data[extraprop][key];
  2518. }
  2519. delete data[extraprop];
  2520. }
  2521. data["iscmadmin"] = false;
  2522. angular.forEach($rootScope.user.role, function (roleItem) {
  2523. if (roleItem.rolecode == "cmdb charge") {
  2524. data["iscmadmin"] = true;
  2525. }
  2526. });
  2527. return data;
  2528. }
  2529. function formValid() {
  2530. angular.forEach(vm.tabs, function (item) {
  2531. //item.
  2532. });
  2533. }
  2534. $scope.vm = vm;
  2535. $scope.refreshcmdbform = function (item) {
  2536. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2537. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2538. var myData = Restangular.stripRestangular(data);
  2539. $scope.propTypeOptions = myData;
  2540. $scope.templateProps = myData;
  2541. $scope.vm.tabs = myData;
  2542. if ($scope.model.assets) {
  2543. vm.models = JSON.parse($scope.model.assets);
  2544. }
  2545. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2546. if (vm.models.vtvmvtm_kaiji) {
  2547. vm.models.vtvmvtm_kaiji = "是";
  2548. } else {
  2549. vm.models.vtvmvtm_kaiji = "否";
  2550. }
  2551. }
  2552. decodeVMTabForm(vm.models, vm.tabs);
  2553. });
  2554. // }
  2555. };
  2556. var cifilterClassic = {};
  2557. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2558. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2559. $scope.refreshcmdbform(
  2560. $scope.$parent.$parent.$parent.model.cifilterClassic
  2561. );
  2562. // } else {}
  2563. },
  2564. ],
  2565. });
  2566. //固定资产下载
  2567. formlyConfigProvider.setType({
  2568. name: "ui-dropupload",
  2569. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2570. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2571. defaultOptions: function (options) {
  2572. return {
  2573. templateOptions: {
  2574. view: function (APIService, contentId) {
  2575. return APIService.downloadAttachment(contentId);
  2576. },
  2577. },
  2578. };
  2579. },
  2580. controller: [
  2581. "$scope",
  2582. "$rootScope",
  2583. "Restangular",
  2584. function ($scope, $rootScope, Restangular) {
  2585. if (angular.isUndefined($scope.form.dropState)) {
  2586. $scope.form.dropState = false;
  2587. }
  2588. var to = $scope.options.templateOptions;
  2589. var bindId = $scope.model[to.bindType].processInstanceId;
  2590. //获取附件列表
  2591. $scope.listAttachmen = function () {
  2592. to.ApiService.listAttachment(
  2593. to.listAttachmentUrl,
  2594. to.bindType,
  2595. bindId
  2596. ).then(function (result) {
  2597. var myData = Restangular.stripRestangular(result);
  2598. // $scope.listAttachmens = myData;
  2599. $scope.attachments = myData.data;
  2600. });
  2601. };
  2602. $scope.listAttachmen();
  2603. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2604. // $scope.listAttachmen();
  2605. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2606. // $scope.listAttachmen();
  2607. // }
  2608. //附件下载
  2609. $scope.download = function (token, filename) {
  2610. var downUrl = to.ApiService.downloadAttachment(
  2611. to.downUrl,
  2612. token
  2613. ).getRequestedUrl();
  2614. var a = document.createElement("a");
  2615. a.href = downUrl;
  2616. a.target = "_blank";
  2617. a.download = filename;
  2618. document.body.appendChild(a);
  2619. a.click();
  2620. };
  2621. //附件预览
  2622. $scope.view = function (id, previewUrl) {
  2623. if (previewUrl) {
  2624. window.open(previewUrl);
  2625. }
  2626. };
  2627. },
  2628. ],
  2629. });
  2630. formlyConfigProvider.setType({
  2631. name: "ui-form",
  2632. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2633. defaultOptions: function (options) {
  2634. return {
  2635. templateOptions: {
  2636. // link: function() {}
  2637. },
  2638. };
  2639. },
  2640. controller: [
  2641. "$rootScope",
  2642. "$scope",
  2643. "$parse",
  2644. "$injector",
  2645. "$http",
  2646. "$q",
  2647. "$state",
  2648. "$stateParams",
  2649. "$modal",
  2650. "$timeout",
  2651. "$interval",
  2652. "i18nService",
  2653. "SweetAlert",
  2654. "FileUploader",
  2655. "Restangular",
  2656. "UserRestangular",
  2657. "BpmRestangular",
  2658. "api_configure_form",
  2659. "api_configure_data",
  2660. "api_bpm_domain",
  2661. "api_bpm_data",
  2662. "api_user_data",
  2663. "api_cmdb",
  2664. "api_sysinfo",
  2665. function (
  2666. $rootScope,
  2667. $scope,
  2668. $parse,
  2669. $injector,
  2670. $http,
  2671. $q,
  2672. $state,
  2673. $stateParams,
  2674. $modal,
  2675. $timeout,
  2676. $interval,
  2677. i18nService,
  2678. SweetAlert,
  2679. FileUploader,
  2680. Restangular,
  2681. UserRestangular,
  2682. BpmRestangular,
  2683. api_configure_form,
  2684. api_configure_data,
  2685. api_bpm_domain,
  2686. api_bpm_data,
  2687. api_user_data,
  2688. api_cmdb,
  2689. api_sysinfo
  2690. ) {
  2691. $scope.langs = i18nService.getAllLangs();
  2692. $scope.lang = "zh-cn";
  2693. i18nService.setCurrentLang($scope.lang);
  2694. var vm = this;
  2695. vm.options = {};
  2696. vm.exampleTitle = ["expressionProperties", "model property"];
  2697. vm.fields = [];
  2698. vm.models = {};
  2699. // vm.models["loginUser"] = $rootScope.user;
  2700. var that = $injector;
  2701. var parse = $parse;
  2702. var formKey = "";
  2703. var pdKey = "";
  2704. if (
  2705. angular.isDefined($state.current.pdKey) &&
  2706. $state.current.pdKey != ""
  2707. ) {
  2708. pdKey = $state.current.pdKey;
  2709. //console.log("pdKey::"+$state.current.pdKey);
  2710. }
  2711. if (
  2712. angular.isDefined($stateParams.formKey) &&
  2713. $stateParams.formKey != ""
  2714. ) {
  2715. formKey = $stateParams.formKey;
  2716. //console.log("formKey::"+$stateParams.formKey);
  2717. }
  2718. //用户测试数据,后续从header的auth中获取
  2719. var userId = 2;
  2720. userId = $rootScope.user.id;
  2721. //==============处理表单设计数据 开始====================
  2722. //处理组件加载后台数据选项的方法
  2723. function refreshSelectOptions(searchVal, field) {
  2724. if (field.templateOptions.optionsUrl) {
  2725. var process = BpmRestangular.all("");
  2726. if (field.templateOptions.ApiService) {
  2727. process = UserRestangular.all("");
  2728. }
  2729. process
  2730. .customPOST(
  2731. {
  2732. idx: 0,
  2733. sum: 1000,
  2734. },
  2735. field.templateOptions.optionsUrl
  2736. )
  2737. .then(function (result) {
  2738. if (!field.templateOptions.options) {
  2739. field.templateOptions.options = [];
  2740. }
  2741. if (field.templateOptions.optionsDataKey) {
  2742. field.templateOptions.options =
  2743. result[field.templateOptions.optionsDataKey];
  2744. } else {
  2745. field.templateOptions.options = result;
  2746. }
  2747. });
  2748. }
  2749. }
  2750. function decodeVMTabForm(model, tabs) {
  2751. var result = {
  2752. model: {},
  2753. tabs: [],
  2754. };
  2755. var mdata = angular.fromJson(model);
  2756. angular.extend(result.model, mdata);
  2757. angular.forEach(tabs, function (tab) {
  2758. tab.form.model = vm.models;
  2759. angular.forEach(tab.form.fields, function (field) {
  2760. if (field.key == "") {
  2761. delete field.key;
  2762. }
  2763. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2764. var extObj = angular.fromJson(field.extjson);
  2765. angular.extend(field.templateOptions, extObj.templateOptions);
  2766. delete extObj.templateOptions;
  2767. for (var prop in extObj) {
  2768. if (new RegExp("Expression").test(prop)) {
  2769. //var obj = $scope.$eval(extObj[prop]);
  2770. //extObj[prop] = $scope.$eval(extObj[prop]);
  2771. if (extObj[prop] != null) {
  2772. if (new RegExp("function").test(extObj[prop])) {
  2773. var propValue = eval(extObj[prop]);
  2774. extObj[prop] = propValue;
  2775. } else {
  2776. //console.log(extObj[prop]);
  2777. var obj = $scope.$eval(extObj[prop]);
  2778. extObj[prop] = obj;
  2779. //console.log(obj);
  2780. }
  2781. }
  2782. } else if (new RegExp("expressionProperties").test(prop)) {
  2783. for (var p in extObj[prop]) {
  2784. if (new RegExp("function").test(extObj[prop][p])) {
  2785. var propValue = eval(extObj[prop][p]);
  2786. extObj[prop][p] = propValue;
  2787. } else {
  2788. //if(p.indexOf("'")>=0){
  2789. // var obj = $scope.$eval(extObj[prop][p]);
  2790. // extObj[prop][$scope.$eval(p)]=obj;
  2791. //}
  2792. }
  2793. }
  2794. } else if ("watcher" == prop) {
  2795. if (angular.isArray(extObj[prop])) {
  2796. angular.forEach(extObj[prop], function (item, index) {
  2797. for (var p in item) {
  2798. if (new RegExp("function").test(item[p])) {
  2799. var propValue = eval(item[p]);
  2800. extObj[prop][index][p] = propValue;
  2801. }
  2802. }
  2803. });
  2804. } else if (angular.isObject(extObj[prop])) {
  2805. for (var p in extObj[prop]) {
  2806. if (new RegExp("function").test(extObj[prop][p])) {
  2807. var propValue = eval(extObj[prop][p]);
  2808. extObj[prop][p] = propValue;
  2809. }
  2810. }
  2811. }
  2812. }
  2813. }
  2814. angular.extend(field, extObj);
  2815. delete field.extjson;
  2816. }
  2817. if (field.extjson == "") {
  2818. delete field.extjson;
  2819. }
  2820. if (angular.isDefined(field.templateOptions)) {
  2821. var templateOs = field.templateOptions;
  2822. for (var property in templateOs) {
  2823. //console.log(property);
  2824. if (
  2825. angular.isString(templateOs[property]) &&
  2826. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2827. ) {
  2828. if (new RegExp("function").test(templateOs[property])) {
  2829. var propValue = eval(templateOs[property]);
  2830. field.templateOptions[property] = propValue;
  2831. } else {
  2832. if (that.has(templateOs[property])) {
  2833. field.templateOptions[property] = that.get(
  2834. templateOs[property]
  2835. );
  2836. } else {
  2837. field.templateOptions[property] = templateOs[property];
  2838. }
  2839. }
  2840. } else if (templateOs[property] == null) {
  2841. //delete field.templateOptions[property];
  2842. } else {
  2843. }
  2844. }
  2845. }
  2846. if (
  2847. angular.isDefined(field.templateOptions) &&
  2848. angular.isDefined(field.templateOptions.extjson)
  2849. ) {
  2850. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2851. angular.extend(field.templateOptions, extObj);
  2852. delete field.templateOptions.extjson;
  2853. }
  2854. //...
  2855. if (field.templateOptions) {
  2856. //处理远程获取数据控件方法调用
  2857. if (field.templateOptions.optionsUrl) {
  2858. field.templateOptions.refresh = refreshSelectOptions;
  2859. }
  2860. //处理嵌套属性数据绑定/
  2861. if (field.templateOptions.pkey) {
  2862. var pmodel,
  2863. i = 0;
  2864. angular.forEach(
  2865. field.templateOptions.pkey.split("."),
  2866. function (p) {
  2867. if (i == 0) {
  2868. if (result.model[p] == null) {
  2869. result.model[p] = {};
  2870. }
  2871. pmodel = result.model[p];
  2872. i++;
  2873. } else {
  2874. if (pmodel[p] == null) {
  2875. pmodel[p] = {};
  2876. }
  2877. pmodel = pmodel[p];
  2878. }
  2879. }
  2880. );
  2881. if (pmodel != null) {
  2882. field.model = pmodel;
  2883. if (pmodel[field.key] == null) {
  2884. pmodel[field.key] = null;
  2885. }
  2886. }
  2887. } else {
  2888. if (result.model[field.key] == null) {
  2889. result.model[field.key] = null;
  2890. }
  2891. }
  2892. //处理弹出框组件初始化
  2893. if (field.type == "ui-input-selectmodal") {
  2894. field.templateOptions.modal = $modal;
  2895. //field.templateOptions.Restangular = Restangular;
  2896. } else if (field.type == "ui-userselect") {
  2897. field.templateOptions.modal = $modal;
  2898. //field.templateOptions.Restangular = Restangular;
  2899. } else if (field.type == "ui-multiuserselect") {
  2900. field.templateOptions.modal = $modal;
  2901. } else if (field.type == "ui-modelselect") {
  2902. field.templateOptions.modal = $modal;
  2903. //field.templateOptions.Restangular = Restangular;
  2904. } else if (field.type == "ui-dropfile") {
  2905. field.templateOptions.fileUploader = new FileUploader({
  2906. url: "/uploader",
  2907. });
  2908. field.templateOptions.taskId = $stateParams.taskId;
  2909. field.templateOptions.processInstanceId =
  2910. $stateParams.processInstanceId;
  2911. field.templateOptions.userId = $rootScope.user.id;
  2912. //field.ApiService=api_bpm_domain;
  2913. // }else if (field.type == "ui-uploadFile") {
  2914. // field.templateOptions.fileUploader = new FileUploader({
  2915. // url: '/uploader'
  2916. // });
  2917. // field.templateOptions.taskId = $stateParams.taskId;
  2918. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2919. // field.templateOptions.userId = $rootScope.user.id;
  2920. //field.ApiService=api_bpm_domain;
  2921. } else if (field.type == "ui-dropfiletable") {
  2922. if (field.templateOptions.processInstanceId) {
  2923. } else {
  2924. field.templateOptions.processInstanceId =
  2925. $stateParams.processInstanceId;
  2926. }
  2927. } else if (field.type == "ui-dropFiles") {
  2928. if (field.templateOptions.processInstanceId) {
  2929. } else {
  2930. field.templateOptions.processInstanceId =
  2931. $stateParams.processInstanceId;
  2932. }
  2933. } else if (field.type == "ui-showImgs") {
  2934. if (field.templateOptions.processInstanceId) {
  2935. } else {
  2936. field.templateOptions.processInstanceId =
  2937. $stateParams.processInstanceId;
  2938. }
  2939. } else if (field.type == "ui-repeatSection") {
  2940. var repeatForm = {
  2941. model: {},
  2942. fields: field.templateOptions.fields,
  2943. };
  2944. repeatForm.model[field.key] = [];
  2945. decodeVMTabForm(repeatForm);
  2946. }
  2947. }
  2948. // console.log(field);
  2949. //field
  2950. //result.fields.push(field);
  2951. });
  2952. });
  2953. vm.originalTabs = angular.copy(vm.form);
  2954. }
  2955. //解析自定义表单设计数据
  2956. function decodeVMForm(vmForm) {
  2957. var result = {
  2958. model: {},
  2959. tabs: [],
  2960. };
  2961. //设置模型实体数据 begin
  2962. // var mdata = vmForm.model;
  2963. //解析数据实体
  2964. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2965. angular.extend(result.model, mdata);
  2966. //设置模型实体数据 end
  2967. //解析设计数据生成表单项 begin
  2968. var fields = [];
  2969. //处理修改设计数据中展示设置
  2970. angular.forEach(vmForm.tabs, function (field) {
  2971. if (field.key == "") {
  2972. delete field.key;
  2973. }
  2974. if (angular.isDefined(field.extjson)) {
  2975. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2976. angular.extend(field.templateOptions, extObj.templateOptions);
  2977. delete extObj.templateOptions;
  2978. for (var prop in extObj) {
  2979. if (new RegExp("Expression").test(prop)) {
  2980. //var obj = $scope.$eval(extObj[prop]);
  2981. //extObj[prop] = $scope.$eval(extObj[prop]);
  2982. if (extObj[prop] != null) {
  2983. if (new RegExp("function").test(extObj[prop])) {
  2984. var propValue = eval(extObj[prop]);
  2985. extObj[prop] = propValue;
  2986. } else {
  2987. //console.log(extObj[prop]);
  2988. var obj = $scope.$eval(extObj[prop]);
  2989. extObj[prop] = obj;
  2990. //console.log(obj);
  2991. }
  2992. }
  2993. } else if (new RegExp("expressionProperties").test(prop)) {
  2994. for (var p in extObj[prop]) {
  2995. if (new RegExp("function").test(extObj[prop][p])) {
  2996. var propValue = eval(extObj[prop][p]);
  2997. extObj[prop][p] = propValue;
  2998. } else {
  2999. //if(p.indexOf("'")>=0){
  3000. // var obj = $scope.$eval(extObj[prop][p]);
  3001. // extObj[prop][$scope.$eval(p)]=obj;
  3002. //}
  3003. }
  3004. }
  3005. } else if ("watcher" == prop) {
  3006. if (angular.isArray(extObj[prop])) {
  3007. angular.forEach(extObj[prop], function (item, index) {
  3008. for (var p in item) {
  3009. if (new RegExp("function").test(item[p])) {
  3010. var propValue = eval(item[p]);
  3011. extObj[prop][index][p] = propValue;
  3012. }
  3013. }
  3014. });
  3015. } else if (angular.isObject(extObj[prop])) {
  3016. for (var p in extObj[prop]) {
  3017. if (new RegExp("function").test(extObj[prop][p])) {
  3018. var propValue = eval(extObj[prop][p]);
  3019. extObj[prop][p] = propValue;
  3020. }
  3021. }
  3022. }
  3023. }
  3024. }
  3025. angular.extend(field, extObj);
  3026. delete field.extjson;
  3027. }
  3028. if (angular.isDefined(field.templateOptions)) {
  3029. var templateOs = field.templateOptions;
  3030. for (var property in templateOs) {
  3031. //console.log(property);
  3032. if (
  3033. angular.isString(templateOs[property]) &&
  3034. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3035. ) {
  3036. if (new RegExp("function").test(templateOs[property])) {
  3037. var propValue = eval(templateOs[property]);
  3038. field.templateOptions[property] = propValue;
  3039. } else {
  3040. if (that.has(templateOs[property])) {
  3041. field.templateOptions[property] = that.get(
  3042. templateOs[property]
  3043. );
  3044. } else {
  3045. field.templateOptions[property] = templateOs[property];
  3046. }
  3047. }
  3048. } else if (templateOs[property] == null) {
  3049. //delete field.templateOptions[property];
  3050. } else {
  3051. }
  3052. }
  3053. }
  3054. if (
  3055. angular.isDefined(field.templateOptions) &&
  3056. angular.isDefined(field.templateOptions.extjson)
  3057. ) {
  3058. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3059. angular.extend(field.templateOptions, extObj);
  3060. delete field.templateOptions.extjson;
  3061. }
  3062. //...
  3063. if (field.templateOptions) {
  3064. //处理远程获取数据控件方法调用
  3065. if (field.templateOptions.optionsUrl) {
  3066. field.templateOptions.refresh = refreshSelectOptions;
  3067. }
  3068. //处理嵌套属性数据绑定/
  3069. if (field.templateOptions.pkey) {
  3070. var pmodel,
  3071. i = 0;
  3072. angular.forEach(
  3073. field.templateOptions.pkey.split("."),
  3074. function (p) {
  3075. if (i == 0) {
  3076. if (result.model[p] == null) {
  3077. result.model[p] = {};
  3078. }
  3079. pmodel = result.model[p];
  3080. i++;
  3081. } else {
  3082. if (pmodel[p] == null) {
  3083. pmodel[p] = {};
  3084. }
  3085. pmodel = pmodel[p];
  3086. }
  3087. }
  3088. );
  3089. if (pmodel != null) {
  3090. field.model = pmodel;
  3091. if (pmodel[field.key] == null) {
  3092. pmodel[field.key] = null;
  3093. }
  3094. }
  3095. } else {
  3096. if (result.model[field.key] == null) {
  3097. result.model[field.key] = null;
  3098. }
  3099. }
  3100. //处理弹出框组件初始化
  3101. if (field.type == "ui-input-selectmodal") {
  3102. field.templateOptions.modal = $modal;
  3103. //field.templateOptions.Restangular = Restangular;
  3104. } else if (field.type == "ui-userselect") {
  3105. field.templateOptions.modal = $modal;
  3106. //field.templateOptions.Restangular = Restangular;
  3107. } else if (field.type == "ui-multiuserselect") {
  3108. field.templateOptions.modal = $modal;
  3109. } else if (field.type == "ui-modelselect") {
  3110. field.templateOptions.modal = $modal;
  3111. //field.templateOptions.Restangular = Restangular;
  3112. } else if (field.type == "ui-dropfile") {
  3113. field.templateOptions.fileUploader = new FileUploader({
  3114. url: "/uploader",
  3115. });
  3116. field.templateOptions.taskId = $stateParams.taskId;
  3117. field.templateOptions.processInstanceId =
  3118. $stateParams.processInstanceId;
  3119. field.templateOptions.userId = $rootScope.user.id;
  3120. //field.ApiService=api_bpm_domain;
  3121. } else if (field.type == "ui-dropfiletable") {
  3122. if (field.templateOptions.processInstanceId) {
  3123. } else {
  3124. field.templateOptions.processInstanceId =
  3125. $stateParams.processInstanceId;
  3126. }
  3127. } else if (field.type == "ui-dropFiles") {
  3128. if (field.templateOptions.processInstanceId) {
  3129. } else {
  3130. field.templateOptions.processInstanceId =
  3131. $stateParams.processInstanceId;
  3132. }
  3133. } else if (field.type == "ui-showImgs") {
  3134. if (field.templateOptions.processInstanceId) {
  3135. } else {
  3136. field.templateOptions.processInstanceId =
  3137. $stateParams.processInstanceId;
  3138. }
  3139. } else if (field.type == "ui-repeatSection") {
  3140. var repeatForm = {
  3141. model: {},
  3142. fields: field.templateOptions.fields,
  3143. };
  3144. repeatForm.model[field.key] = [];
  3145. decodeVMForm(repeatForm);
  3146. }
  3147. }
  3148. // console.log(field);
  3149. result.fields.push(field);
  3150. });
  3151. angular.extend($scope.vm.fields, result.fields);
  3152. angular.extend($scope.vm.models, result.model);
  3153. $scope.formData = vmForm;
  3154. //console.log($scope.vm);
  3155. //解析设计数据生成表单项 end
  3156. return result;
  3157. }
  3158. //======================处理表单设计数据 结束========================
  3159. $scope.ldloading = {};
  3160. function filter(obj) {
  3161. angular.forEach(obj, function (key, value) {
  3162. if (value === "" || value === null) {
  3163. delete obj[key];
  3164. } else if (
  3165. Object.prototype.toString.call(value) === "[object Object]"
  3166. ) {
  3167. filter(value);
  3168. } else if (angular.isArray(value)) {
  3169. angular.forEach(value, function (item) {
  3170. filter(item);
  3171. });
  3172. }
  3173. });
  3174. }
  3175. function invokeOnAllFormOptions(fn) {
  3176. angular.forEach(vm.tabs, function (tab) {
  3177. if (tab.form.options && tab.form.options[fn]) {
  3178. tab.form.options[fn]();
  3179. }
  3180. });
  3181. }
  3182. function encodeCIData(data, ciId) {
  3183. /*
  3184. create/update state:未审核
  3185. create createtime:系统时间
  3186. create/update lastupdatetime : 系统时间
  3187. label:ci分类
  3188. */
  3189. if (ciId) {
  3190. var baseprop = [
  3191. "uuid",
  3192. "name",
  3193. "type",
  3194. "label",
  3195. "status",
  3196. "createtime",
  3197. "lastupdatetime",
  3198. "props",
  3199. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3200. var extraprop = "props";
  3201. data[extraprop] = {};
  3202. for (var key in data) {
  3203. console.log(data[key]);
  3204. if (_.indexOf(baseprop, key) >= 0) {
  3205. continue;
  3206. } else {
  3207. data[extraprop][key] = data[key];
  3208. delete data[key];
  3209. }
  3210. }
  3211. if ($rootScope.user) {
  3212. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3213. data[extraprop]["configperson"] = $rootScope.user.name;
  3214. var isCMAdminFlag = false;
  3215. angular.forEach($rootScope.user.role, function (roleItem) {
  3216. if (roleItem.rolecode == "cmdb charge") {
  3217. isCMAdminFlag = true;
  3218. }
  3219. });
  3220. if (!isCMAdminFlag) {
  3221. data[extraprop]["state"] = "1";
  3222. }
  3223. }
  3224. if (data.props.id) {
  3225. } else {
  3226. data.label = ciId;
  3227. }
  3228. return data;
  3229. }
  3230. return undefined;
  3231. }
  3232. function decodeCIModel(data) {
  3233. var extraprop = "props";
  3234. if (data[extraprop]) {
  3235. for (var key in data[extraprop]) {
  3236. data[key] = data[extraprop][key];
  3237. }
  3238. delete data[extraprop];
  3239. }
  3240. data["iscmadmin"] = false;
  3241. angular.forEach($rootScope.user.role, function (roleItem) {
  3242. if (roleItem.rolecode == "cmdb charge") {
  3243. data["iscmadmin"] = true;
  3244. }
  3245. });
  3246. return data;
  3247. }
  3248. vm.remove = function (data, style) {
  3249. $scope.ldloading[style.replace("-", "_")] = true;
  3250. var modalInstance = $modal.open({
  3251. templateUrl: "assets/views/delete.html",
  3252. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3253. var cidata = {
  3254. label: data.label,
  3255. id: data.id,
  3256. uuid: data.uuid,
  3257. name: data.name,
  3258. props: {},
  3259. };
  3260. if (cidata.id) {
  3261. cidata.props["removeflag"] = true;
  3262. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3263. $scope.ok = function () {
  3264. $modalInstance.close(cidata);
  3265. };
  3266. $scope.cancel = function () {
  3267. $modalInstance.dismiss("cancel");
  3268. };
  3269. }
  3270. },
  3271. size: "sm",
  3272. resolve: {
  3273. scope: function () {
  3274. return $scope;
  3275. },
  3276. },
  3277. });
  3278. modalInstance.result.then(function (selectedItem) {
  3279. if (selectedItem) {
  3280. // if (selectedItem.length > 0) {
  3281. api_cmdb
  3282. .put(selectedItem, selectedItem.id)
  3283. .then(function (response) {
  3284. if (response) {
  3285. var resData = Restangular.stripRestangular(response);
  3286. SweetAlert.swal(
  3287. {
  3288. title: "删除成功!",
  3289. confirmButtonColor: "#007AFF",
  3290. },
  3291. function () {
  3292. $state.go("app.means.list");
  3293. // $scope.refreshform();
  3294. // reinitTabForm($scope.classify);
  3295. }
  3296. );
  3297. } else {
  3298. SweetAlert.swal({
  3299. title: "系统错误",
  3300. text: "系统错误,请稍后重试!",
  3301. type: "error",
  3302. confirmButtonColor: "#DD6B55",
  3303. });
  3304. }
  3305. $scope.ldloading[style.replace("-", "_")] = false;
  3306. });
  3307. }
  3308. });
  3309. };
  3310. function formValid() {
  3311. angular.forEach(vm.tabs, function (item) {
  3312. //item.
  3313. });
  3314. }
  3315. $scope.closeModel = function () {
  3316. console.log($stateParams);
  3317. if (
  3318. angular.isDefined($stateParams.formKey) &&
  3319. $stateParams.formKey != ""
  3320. ) {
  3321. if (
  3322. $stateParams.formKey == "means_editor" ||
  3323. $stateParams.formKey == "means_edit"
  3324. ) {
  3325. $state.go("app.means.list", {});
  3326. }
  3327. event.preventDefault();
  3328. }
  3329. };
  3330. // setInterval(function() {
  3331. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3332. // cifilter_classic = $scope.model.cifilter_classic;
  3333. // $scope.refreshcmdbform(cifilter_classic);
  3334. // } else {}
  3335. // }, 100);
  3336. vm.models = (function filter(obj) {
  3337. var filtered = _.pick(obj, function (v) {
  3338. return (
  3339. angular.isDefined(v) &&
  3340. v !== null &&
  3341. (angular.isArray(v) ? v.length > 0 : true) &&
  3342. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3343. );
  3344. });
  3345. return _.cloneDeep(filtered, function (v) {
  3346. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3347. });
  3348. })(vm.models);
  3349. // setInterval(function() {
  3350. // if ($scope.model.type == 0) {
  3351. // $scope.model[$scope.options.key] = vm.models;
  3352. // }
  3353. // }, 100);
  3354. setInterval(function () {
  3355. if (vm.form && vm.form.$$parentForm.$valid) {
  3356. if (
  3357. $scope.$parent &&
  3358. $scope.$parent.$parent &&
  3359. $scope.$parent.$parent.$parent &&
  3360. $scope.$parent.$parent.$parent.model
  3361. ) {
  3362. vm.models.hw_cifilterClassic =
  3363. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3364. $scope.model[$scope.options.key] = vm.models;
  3365. }
  3366. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3367. // $scope.model[$scope.options.key] = vm.models;
  3368. }
  3369. }, 100);
  3370. vm.submit = function (data, ciId, templateitem, style) {
  3371. // $scope.ldloading[style.replace('-', '_')] = true;
  3372. console.log(vm.form.$$parentForm.$valid);
  3373. if (vm.form.$$parentForm.$valid) {
  3374. invokeOnAllFormOptions("updateInitialValue");
  3375. //alert(JSON.stringify(vm.model), null, 2);
  3376. //vm.options.updateInitialValue();
  3377. //console.log(vm.model);
  3378. var cidata = encodeCIData(vm.models, ciId);
  3379. if (cidata) {
  3380. //var cidata = ;
  3381. if (cidata.props.id) {
  3382. //修改
  3383. api_cmdb.put(cidata, ciId).then(function (response) {
  3384. if (response) {
  3385. var resData = Restangular.stripRestangular(response);
  3386. SweetAlert.swal(
  3387. {
  3388. title: "保存成功!",
  3389. confirmButtonColor: "#007AFF",
  3390. },
  3391. function () {
  3392. $scope.ldloading[style.replace("-", "_")] = false;
  3393. // $scope.refreshform();
  3394. $state.go("app.means.list");
  3395. }
  3396. );
  3397. } else {
  3398. SweetAlert.swal({
  3399. title: "系统错误",
  3400. text: "系统错误,请稍后重试!",
  3401. type: "error",
  3402. confirmButtonColor: "#DD6B55",
  3403. });
  3404. }
  3405. $scope.ldloading[style.replace("-", "_")] = false;
  3406. });
  3407. } else {
  3408. //新建
  3409. var type = 2;
  3410. api_sysinfo
  3411. .getSerialnumber(type, templateitem.id)
  3412. .then(function (data) {
  3413. if (data && data.status == 200) {
  3414. cidata.uuid = data.uuid;
  3415. api_cmdb.create(cidata).then(function (response) {
  3416. if (response) {
  3417. var resData = Restangular.stripRestangular(response);
  3418. SweetAlert.swal(
  3419. {
  3420. title: "保存成功!",
  3421. text: "内部编号:" + cidata.uuid,
  3422. confirmButtonColor: "#007AFF",
  3423. },
  3424. function () {
  3425. $state.go("app.means.list");
  3426. }
  3427. );
  3428. // if(resData.status){
  3429. // resData
  3430. // }
  3431. } else {
  3432. SweetAlert.swal({
  3433. title: "系统错误",
  3434. text: "系统错误,请稍后重试!",
  3435. type: "error",
  3436. confirmButtonColor: "#DD6B55",
  3437. });
  3438. }
  3439. $scope.ldloading[style.replace("-", "_")] = false;
  3440. });
  3441. } else {
  3442. SweetAlert.swal({
  3443. title: "系统错误",
  3444. text: "内部编号生成出错!",
  3445. type: "error",
  3446. confirmButtonColor: "#DD6B55",
  3447. });
  3448. }
  3449. });
  3450. }
  3451. } else {
  3452. SweetAlert.swal({
  3453. title: "错误",
  3454. text: "错误,请选择资产分类!",
  3455. type: "error",
  3456. confirmButtonColor: "#DD6B55",
  3457. });
  3458. }
  3459. //alert(JSON.stringify(cidata), null, 2);
  3460. $scope.ldloading[style.replace("-", "_")] = true;
  3461. return;
  3462. var _ = window._;
  3463. vm.models = (function filter(obj) {
  3464. var filtered = _.pick(obj, function (v) {
  3465. return (
  3466. angular.isDefined(v) &&
  3467. v !== null &&
  3468. (angular.isArray(v) ? v.length > 0 : true) &&
  3469. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3470. );
  3471. });
  3472. return _.cloneDeep(filtered, function (v) {
  3473. return v !== filtered && _.isPlainObject(v)
  3474. ? filter(v)
  3475. : undefined;
  3476. });
  3477. })(vm.models);
  3478. } else {
  3479. if (vm.form.$$parentForm.$error) {
  3480. SweetAlert.swal({
  3481. title: "校验错误",
  3482. text: "请填写必填项!",
  3483. type: "error",
  3484. confirmButtonColor: "#DD6B55",
  3485. });
  3486. angular.forEach(
  3487. vm.form.$$parentForm.$error.required,
  3488. function (item) {
  3489. angular.forEach(vm.tabs, function (tab) {
  3490. angular.forEach(tab.form.fields, function (f) {
  3491. if (f.name == item.$name) {
  3492. f.validation.show = true;
  3493. tab.active = true;
  3494. }
  3495. });
  3496. });
  3497. }
  3498. );
  3499. $scope.ldloading[style.replace("-", "_")] = false;
  3500. }
  3501. }
  3502. };
  3503. $scope.vm = vm;
  3504. $scope.refreshcmdbform = function (item) {
  3505. // if ($stateParams.model) {
  3506. // var modeldata = JSON.parse($stateParams.model)
  3507. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3508. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3509. var myData = Restangular.stripRestangular(data);
  3510. $scope.propTypeOptions = myData;
  3511. $scope.templateProps = myData;
  3512. $scope.vm.tabs = myData;
  3513. if ($scope.model.asset && $scope.model.asset.length != "") {
  3514. vm.models = JSON.parse($scope.model.asset);
  3515. }
  3516. decodeVMTabForm(vm.models, vm.tabs);
  3517. });
  3518. // }
  3519. };
  3520. var cifilterClassic = {};
  3521. setInterval(function () {
  3522. if (
  3523. $scope.$parent.$parent &&
  3524. $scope.$parent.$parent.$parent &&
  3525. $scope.$parent.$parent.$parent.model &&
  3526. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3527. cifilterClassic.id !=
  3528. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3529. ) {
  3530. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3531. cifilterClassic =
  3532. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3533. $scope.refreshcmdbform(cifilterClassic);
  3534. } else {
  3535. }
  3536. }, 100);
  3537. },
  3538. ],
  3539. });
  3540. //请求人信息
  3541. formlyConfigProvider.setType({
  3542. name: "ui-cmdbinformation",
  3543. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3544. wrapper: ["bootstrapHasError"],
  3545. defaultOptions: function (options, $scope) {
  3546. return {
  3547. templateOptions: {
  3548. // checkform: function(options) {
  3549. // if (options.model.requester) {
  3550. // options.value(options.model.requester);
  3551. // }
  3552. // },
  3553. },
  3554. };
  3555. },
  3556. controller: [
  3557. "$scope",
  3558. "api_user_data",
  3559. function ($scope, api_user_data) {
  3560. if ($scope.options.templateOptions.loginUser) {
  3561. if (
  3562. $scope.model[$scope.options.key] &&
  3563. $scope.model[$scope.options.key].id
  3564. ) {
  3565. } else {
  3566. $scope.model[$scope.options.key] =
  3567. $scope.options.templateOptions.loginUser;
  3568. }
  3569. $scope.options.initialValue = $scope.model[$scope.options.key];
  3570. }
  3571. },
  3572. ],
  3573. });
  3574. //资产属性
  3575. formlyConfigProvider.setType({
  3576. name: "ui-cmdbtype",
  3577. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3578. wrapper: ["bootstrapHasError"],
  3579. defaultOptions: function (options, $scope) {
  3580. return {
  3581. templateOptions: {
  3582. // checkform: function(options) {
  3583. // if (options.model.requester) {
  3584. // options.value(options.model.requester);
  3585. // }
  3586. // },
  3587. },
  3588. };
  3589. },
  3590. controller: [
  3591. "$scope",
  3592. "api_user_data",
  3593. function ($scope, api_user_data) {
  3594. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3595. $scope.property = {
  3596. hw_change: $scope.to.loginUser,
  3597. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3598. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3599. };
  3600. if ($scope.$parent.$parent.$parent.model.assets) {
  3601. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3602. }
  3603. },
  3604. ],
  3605. });
  3606. //申请单信息
  3607. formlyConfigProvider.setType({
  3608. name: "ui-cmdbformimform",
  3609. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3610. wrapper: ["bootstrapHasError"],
  3611. defaultOptions: function (options, $scope) {
  3612. return {
  3613. templateOptions: {
  3614. // checkform: function(options) {
  3615. // if (options.model.requester) {
  3616. // options.value(options.model.requester);
  3617. // }
  3618. // },
  3619. },
  3620. };
  3621. },
  3622. controller: [
  3623. "$scope",
  3624. "api_user_data",
  3625. function ($scope, api_user_data) {
  3626. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3627. $scope.getininform = {
  3628. serialNumbe:
  3629. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3630. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3631. };
  3632. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3633. $scope.getininform.types = "新资产入库";
  3634. } else if (
  3635. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3636. ) {
  3637. $scope.getininform.types = "资产归还";
  3638. }
  3639. },
  3640. ],
  3641. });
  3642. //出库单信息
  3643. formlyConfigProvider.setType({
  3644. name: "ui-outinformation",
  3645. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3646. wrapper: ["bootstrapHasError"],
  3647. defaultOptions: function (options, $scope) {
  3648. return {
  3649. templateOptions: {
  3650. // checkform: function(options) {
  3651. // if (options.model.requester) {
  3652. // options.value(options.model.requester);
  3653. // }
  3654. // },
  3655. },
  3656. };
  3657. },
  3658. controller: [
  3659. "$scope",
  3660. "api_user_data",
  3661. function ($scope, api_user_data) {
  3662. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3663. $scope.getininform = {
  3664. serialNumbe:
  3665. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3666. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3667. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3668. sourceId:
  3669. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3670. describe:
  3671. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3672. };
  3673. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3674. $scope.getininform.types = "新设备领用出库";
  3675. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3676. $scope.getininform.types = "设备更换";
  3677. }
  3678. $scope.getininform.source_id =
  3679. $scope.$parent.$parent.$parent.model.source.value;
  3680. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3681. $scope.getininform.source = "事件";
  3682. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3683. $scope.getininform.source = "变更";
  3684. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3685. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3686. $scope.getininform.source = "其它";
  3687. }
  3688. },
  3689. ],
  3690. });
  3691. //资产附件上传
  3692. formlyConfigProvider.setType({
  3693. name: "ui-cmdbuplode",
  3694. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3695. wrapper: ["bootstrapHasError"],
  3696. defaultOptions: function (options, $scope) {
  3697. return {
  3698. templateOptions: {
  3699. // checkform: function(options) {
  3700. // if (options.model.requester) {
  3701. // options.value(options.model.requester);
  3702. // }
  3703. // },
  3704. },
  3705. };
  3706. },
  3707. controller: [
  3708. "$scope",
  3709. "$rootScope",
  3710. "$http",
  3711. "SweetAlert",
  3712. "FileUploader",
  3713. "api_user_data",
  3714. "i18nService",
  3715. "$modal",
  3716. "Restangular",
  3717. "api_configure_data",
  3718. "api_cmdb",
  3719. "api_cmdb_new",
  3720. "api_wechatfile",
  3721. "api_sysinfo",
  3722. function (
  3723. $scope,
  3724. $rootScope,
  3725. $http,
  3726. SweetAlert,
  3727. FileUploader,
  3728. api_user_data,
  3729. i18nService,
  3730. $modal,
  3731. Restangular,
  3732. api_configure_data,
  3733. api_cmdb,
  3734. api_cmdb_new,
  3735. api_wechatfile,
  3736. api_sysinfo
  3737. ) {
  3738. $scope.state = 1;
  3739. $scope.myData3all = [];
  3740. $scope.myData3 = [];
  3741. $scope.memoryfilterDatahao = {
  3742. idx: 0,
  3743. sum: 10,
  3744. };
  3745. $scope.selected = {
  3746. items: [],
  3747. };
  3748. $scope.interceptMydata = function (mydate, idx, sum) {
  3749. return mydate.slice(idx * sum, (idx + 1) * sum);
  3750. };
  3751. // $scope.importnext = function() {
  3752. // $scope.state = 2;
  3753. // event.preventDefault();
  3754. // }
  3755. $scope.workspaces = [];
  3756. $scope.options.templateOptions.getpush = function (item) {
  3757. $scope.workspaces = [];
  3758. if (item.gu) {
  3759. $scope.workspaces.push({
  3760. id: 1,
  3761. name: "固定资产",
  3762. active: true,
  3763. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3764. });
  3765. }
  3766. if (item.hao) {
  3767. $scope.workspaces.push({
  3768. id: 2,
  3769. name: "耗材资产",
  3770. active: true,
  3771. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3772. });
  3773. }
  3774. };
  3775. //获取附件列表
  3776. $scope.listAttachmen = function () {
  3777. to.ApiService.listAttachment(
  3778. to.listAttachmentUrl,
  3779. to.bindType,
  3780. bindId
  3781. ).then(function (result) {
  3782. var myData = Restangular.stripRestangular(result);
  3783. // $scope.listAttachmens = myData;
  3784. $scope.attachments = myData.data;
  3785. });
  3786. };
  3787. //附件列表
  3788. if ($scope.options.templateOptions.bindType) {
  3789. if (angular.isUndefined($scope.form.dropState)) {
  3790. $scope.form.dropState = false;
  3791. }
  3792. var to = $scope.options.templateOptions;
  3793. var bindId = $scope.model[to.bindType].processInstanceId;
  3794. $scope.listAttachmen();
  3795. }
  3796. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3797. // $scope.listAttachmen();
  3798. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3799. // $scope.listAttachmen();
  3800. // }
  3801. //附件下载
  3802. $scope.download = function (token, filename) {
  3803. var downUrl = to.ApiService.downloadAttachment(
  3804. to.downUrl,
  3805. token
  3806. ).getRequestedUrl();
  3807. // window.open(downUrl);
  3808. var a = document.createElement("a");
  3809. a.href = downUrl;
  3810. a.target = "_blank";
  3811. a.download = filename;
  3812. document.body.appendChild(a);
  3813. a.click();
  3814. };
  3815. //附件预览
  3816. $scope.view = function (id, previewUrl) {
  3817. if (previewUrl) {
  3818. window.open(previewUrl);
  3819. }
  3820. };
  3821. //下载资产模版
  3822. $scope.filenum = 0;
  3823. $scope.openmeans = function () {
  3824. var modalInstance = $modal.open({
  3825. templateUrl: "assets/views/means/tpl/meansdown.html",
  3826. controller: function ($scope, scope, $modalInstance) {
  3827. $scope.item = {};
  3828. $scope.title = "选择下载模版";
  3829. $scope.lable = "资产模版下载";
  3830. function foreachdata(my_datas) {
  3831. // angular.forEach(my_datas, function(item, index) {
  3832. // if (item.children && item.children.length > 0) {
  3833. // foreachdata(item.children);
  3834. // } else {
  3835. // my_datas[index].checks = true;
  3836. // }
  3837. // })
  3838. for (var i = 0; i < my_datas.length; i++) {
  3839. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3840. foreachdata(my_datas[i].children);
  3841. console.log($scope);
  3842. } else {
  3843. my_datas[i].checks = true;
  3844. }
  3845. }
  3846. }
  3847. function foreachtree(data) {
  3848. angular.forEach(data, function (item) {
  3849. // if (item.checks != true) {
  3850. item.checks = true;
  3851. item.expanded = true;
  3852. if (item.children && item.children.length > 0) {
  3853. foreachtree(item.children);
  3854. } else {
  3855. $scope.getslowtree.push(item);
  3856. }
  3857. // }
  3858. });
  3859. }
  3860. $scope.getslowtree = [];
  3861. $scope.slowtree = function (tree) {
  3862. foreachtree(tree);
  3863. return $scope.getslowtree;
  3864. };
  3865. $scope.all = function (c, v) {
  3866. //全选
  3867. if (c == true) {
  3868. $scope.formdashboard($scope.slowtree(v));
  3869. } else {
  3870. $scope.my_data_after = [];
  3871. angular.forEach($scope.my_data, function (item, index) {
  3872. $scope.my_data[index].checks = false;
  3873. $scope.my_data[index].expanded = false;
  3874. if (item.children && item.children.length > 0) {
  3875. angular.forEach(
  3876. item.children,
  3877. function (itemone, indexone) {
  3878. $scope.my_data[index].children[
  3879. indexone
  3880. ].checks = false;
  3881. $scope.my_data[index].children[
  3882. indexone
  3883. ].expanded = false;
  3884. if (itemone.children && itemone.children.length > 0) {
  3885. angular.forEach(
  3886. itemone.children,
  3887. function (itemtwo, indextwo) {
  3888. $scope.my_data[index].children[
  3889. indexone
  3890. ].children[indextwo].checks = false;
  3891. }
  3892. );
  3893. } else {
  3894. }
  3895. }
  3896. );
  3897. } else {
  3898. }
  3899. });
  3900. $scope.mydatacate = [];
  3901. $scope.getslowtree = [];
  3902. // }
  3903. }
  3904. };
  3905. // $scope.searchone = function(search) {
  3906. // angular.forEach($scope.my_data, function(item) {
  3907. // if (item.indexOf(search) > 0) {
  3908. // }
  3909. // })
  3910. // }
  3911. $scope.checkall = function () {
  3912. angular.forEach($scope.my_data, function (item, index) {
  3913. scope.my_data[index].checks = true;
  3914. });
  3915. };
  3916. $scope.selectitem = [];
  3917. $scope.choiceitem = function (item) {
  3918. // if (item.checkeds) {
  3919. // item.checkeds = false;
  3920. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3921. // // if ($scope.selectitem[i].id == item.id) {
  3922. // // $scope.selectitem.splice(i, 1)
  3923. // // }
  3924. // // }
  3925. // for (var i = 0; i < $scope.my_data_after; i++) {
  3926. // if ($scope.my_data_after[i].id == item.id) {
  3927. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3928. // // $scope.selectitem.splice(i, 1)
  3929. // }
  3930. // }
  3931. // } else {
  3932. // item.checkeds = true;
  3933. // $scope.selectitem.push(item)
  3934. // }
  3935. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3936. if ($scope.my_data_after[i].id == item.id) {
  3937. $scope.my_data_after[i].checkeds
  3938. ? ($scope.my_data_after[i].checkeds = false)
  3939. : ($scope.my_data_after[i].checkeds = true);
  3940. }
  3941. }
  3942. };
  3943. $scope.remove = function (removeitem) {
  3944. var realdat = angular.copy($scope.my_data_after);
  3945. // angular.extend(realdat, $scope.selectitem);
  3946. $scope.my_data_after = [];
  3947. angular.forEach(realdat, function (item) {
  3948. if (!item.checkeds) {
  3949. $scope.my_data_after.push(item);
  3950. }
  3951. });
  3952. $scope.mydatacate = angular.copy($scope.my_data_after);
  3953. };
  3954. $scope.try_async_loads = function (item, search) {
  3955. var fildatas = {
  3956. idx: 0,
  3957. sum: 1000,
  3958. };
  3959. $scope.my_data = [];
  3960. // $scope.try_async_load = true;
  3961. if (item) {
  3962. angular.extend(fildatas, item);
  3963. }
  3964. api_configure_data
  3965. .fetchDataList("ciclassify", fildatas)
  3966. .then(function (response) {
  3967. if (response.status == 200) {
  3968. var data = response.list;
  3969. var objects = [];
  3970. for (var i = 0; i < data.length; i++) {
  3971. var object = {};
  3972. object.id = data[i].id;
  3973. if (search) {
  3974. delete data[i].parent;
  3975. } else {
  3976. if (data[i].parent && data[i].parent.id != 0) {
  3977. object.parent = data[i].parent.id;
  3978. }
  3979. }
  3980. angular.extend(object, data[i]);
  3981. objects.push(object);
  3982. }
  3983. $scope.my_data = convertParentToChildList(objects);
  3984. $scope.tree_data = angular.copy($scope.my_data);
  3985. if ($scope.my_data.length > 0) {
  3986. $scope.try_async_load = false;
  3987. }
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "系统错误!",
  3991. text: "请刷新重试!",
  3992. type: "error",
  3993. });
  3994. }
  3995. });
  3996. };
  3997. function convertListToTree(data, treeMap) {
  3998. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3999. var root = null; //Initially set our loop to null
  4000. //loop over data
  4001. for (var i = 0; i < data.length; i++) {
  4002. var datum = data[i];
  4003. //each node will have children, so let's give it a "children" poperty
  4004. datum.children = [];
  4005. //add an entry for this node to the map so that any future children can
  4006. //lookup the parent
  4007. idToNodeMap[datum.id] = datum;
  4008. //Does this node have a parent?
  4009. // console.log("datum="+JSON.stringify(datum))
  4010. if (
  4011. typeof datum.parent === "undefined" ||
  4012. datum.parent === null
  4013. ) {
  4014. //Doesn't look like it, so this node is the root of the tree
  4015. root = datum;
  4016. treeMap[datum.id] = root;
  4017. } else {
  4018. //This node has a parent, so let's look it up using the id
  4019. parentNode = idToNodeMap[datum.parent.id];
  4020. //We don't need this property, so let's delete it.
  4021. // delete datum.parent;
  4022. //Let's add the current node as a child of the parent node.
  4023. parentNode.children.push(datum);
  4024. }
  4025. }
  4026. return root;
  4027. }
  4028. function convertParentToChildList(data) {
  4029. var treeMap = {};
  4030. var list = [];
  4031. convertListToTree(data, treeMap);
  4032. angular.forEach(treeMap, function (item) {
  4033. list.push(item);
  4034. });
  4035. return list;
  4036. }
  4037. function convertParentToChild(datato) {
  4038. var treeMapto = {};
  4039. var listto = [];
  4040. convertListToTree(datato, treeMapto);
  4041. angular.forEach(treeMapto, function (items) {
  4042. listto.push(items);
  4043. });
  4044. return listto;
  4045. }
  4046. $scope.try_async_loads();
  4047. $scope.searchdown = function (key) {
  4048. if (key && key != "") {
  4049. $scope.try_async_loads(
  4050. {
  4051. ciclassify: {
  4052. label: key,
  4053. },
  4054. },
  4055. "search"
  4056. );
  4057. } else {
  4058. $scope.try_async_loads();
  4059. }
  4060. // var mydatacatedown = angular.copy($scope.my_data);
  4061. // $scope.my_data = [];
  4062. // var objects = [];
  4063. // angular.forEach(mydatacatedown, function(item) {
  4064. // if (item.label.match(key)) {
  4065. // objects.push(item)
  4066. // } else {
  4067. // // $scope.my_data_after.push(item)
  4068. // }
  4069. // })
  4070. // $scope.my_data = convertParentToChildList(objects);
  4071. // $scope.tree_data = angular.copy($scope.my_data);
  4072. };
  4073. $scope.mydatacate = [];
  4074. $scope.searchup = function (key) {
  4075. // var mydatacate = angular.copy($scope.my_data_after);
  4076. $scope.my_data_after = [];
  4077. angular.forEach($scope.mydatacate, function (item) {
  4078. if (item.label.match(key)) {
  4079. $scope.my_data_after.push(item);
  4080. } else {
  4081. }
  4082. });
  4083. };
  4084. //角色树
  4085. $scope.my_tree = [];
  4086. $scope.tree_data_after = [];
  4087. $scope.my_data = [];
  4088. $scope.my_data_after = [];
  4089. $scope.formdashboard = function (item) {
  4090. $scope.my_data_after = [];
  4091. angular.forEach(item, function (infox) {
  4092. if (infox.children.length == 0) {
  4093. $scope.my_data_after.push(infox);
  4094. }
  4095. });
  4096. $scope.mydatacate = angular.copy($scope.my_data_after);
  4097. };
  4098. $scope.ok = function (item) {
  4099. $modalInstance.close(item);
  4100. };
  4101. $scope.cancel = function () {
  4102. $modalInstance.dismiss("cancel");
  4103. };
  4104. },
  4105. // size: 'sm',
  4106. resolve: {
  4107. scope: function () {
  4108. return $scope;
  4109. },
  4110. },
  4111. });
  4112. modalInstance.result.then(function (selectedItem) {
  4113. // $rootScope.isMask = true;
  4114. if (selectedItem) {
  4115. var type = 1;
  4116. var fildat = {
  4117. configure: selectedItem,
  4118. };
  4119. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4120. // // if (data.errno == 0) {
  4121. // var file = new Blob([data], {
  4122. // // 'Accept': '*/*'
  4123. // type: 'application/octet-stream'
  4124. // // type: 'application/vnd.ms-excel'
  4125. // });
  4126. // //trick to download store a file having its URL
  4127. // var fileURL = URL.createObjectURL(file);
  4128. // var a = document.createElement('a');
  4129. // a.href = fileURL;
  4130. // a.target = '_blank';
  4131. // a.download = "资产导入模版.xlsx";
  4132. // document.body.appendChild(a);
  4133. // a.click();
  4134. // // }
  4135. // })
  4136. $http({
  4137. url: api_configure_data
  4138. .downModels("export/cmdb", fildat)
  4139. .getRequestedUrl(),
  4140. method: "POST",
  4141. data: JSON.stringify(fildat),
  4142. headers: {
  4143. // 'Content-type': 'application/xls',
  4144. Accept: "*/*",
  4145. },
  4146. responseType: "arraybuffer",
  4147. })
  4148. .success(function (data, status, headers, config) {
  4149. $rootScope.isMask = false;
  4150. var file = new Blob([data], {
  4151. type: "application/octet-stream",
  4152. // type : 'application/vnd.ms-excel'
  4153. });
  4154. //trick to download store a file having its URL
  4155. var fileURL = URL.createObjectURL(file);
  4156. var a = document.createElement("a");
  4157. a.href = fileURL;
  4158. a.target = "_blank";
  4159. a.download = "资产导入模版.xlsx";
  4160. document.body.appendChild(a);
  4161. a.click();
  4162. })
  4163. .error(function (data, status, headers, config) {
  4164. // console.log(data);
  4165. $rootScope.isMask = false;
  4166. });
  4167. // break;
  4168. // }
  4169. // }
  4170. // }
  4171. // })
  4172. } else {
  4173. SweetAlert.swal(
  4174. {
  4175. title: "未选择资产分类!",
  4176. text: "请选择资产分类",
  4177. type: "error",
  4178. },
  4179. function () {
  4180. $rootScope.isMask = false;
  4181. }
  4182. );
  4183. }
  4184. // }
  4185. });
  4186. };
  4187. $scope.wrongdata = [];
  4188. var uploader = ($scope.uploader =
  4189. $scope.options.templateOptions.fileUploader);
  4190. var uploadermeans = ($scope.uploadermeans =
  4191. $scope.options.templateOptions.fileUploadermeans);
  4192. $scope.importopen = function () {
  4193. //导入触发事件
  4194. if (angular.isUndefined($scope.form.dropState)) {
  4195. $scope.form.dropState = false;
  4196. }
  4197. //附件上传数据
  4198. //$scope.options.templateOptions.uploader();
  4199. // FILTERS
  4200. uploader.filters.push({
  4201. name: "customFilter",
  4202. fn: function (item /*{File|FileLikeObject}*/, options) {
  4203. return this.queue.length < 2;
  4204. },
  4205. });
  4206. // CALLBACKS
  4207. uploader.onWhenAddingFileFailed = function (
  4208. item /*{File|FileLikeObject}*/,
  4209. filter,
  4210. options
  4211. ) {
  4212. console.info("onWhenAddingFileFailed", item, filter, options);
  4213. };
  4214. uploader.onAfterAddingFile = function (fileItem) {
  4215. console.info("onAfterAddingFile", fileItem);
  4216. };
  4217. uploader.onAfterAddingAll = function (addedFileItems) {
  4218. console.info("onAfterAddingAll", addedFileItems);
  4219. };
  4220. uploader.onBeforeUploadItem = function (item) {
  4221. console.info("onBeforeUploadItem", item);
  4222. };
  4223. uploader.onProgressItem = function (fileItem, progress) {
  4224. console.info("onProgressItem", fileItem, progress);
  4225. };
  4226. uploader.onProgressAll = function (progress) {
  4227. console.info("onProgressAll", progress);
  4228. };
  4229. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4230. // console.info('onSuccessItem', fileItem, response, status, headers);
  4231. // };
  4232. uploader.onErrorItem = function (
  4233. fileItem,
  4234. response,
  4235. status,
  4236. headers
  4237. ) {
  4238. console.info("onErrorItem", fileItem, response, status, headers);
  4239. };
  4240. uploader.onCancelItem = function (
  4241. fileItem,
  4242. response,
  4243. status,
  4244. headers
  4245. ) {
  4246. console.info("onCancelItem", fileItem, response, status, headers);
  4247. };
  4248. uploader.onCompleteItem = function (
  4249. fileItem,
  4250. response,
  4251. status,
  4252. headers
  4253. ) {
  4254. console.info("onCompleteItem", fileItem, response, status, headers);
  4255. };
  4256. uploader.onCompleteAll = function () {
  4257. console.info("onCompleteAll");
  4258. };
  4259. };
  4260. // $scope.importnext = function() {
  4261. // $scope.state = 2;
  4262. // event.preventDefault();
  4263. // }
  4264. $scope.importnext = function () {
  4265. event.preventDefault();
  4266. // $rootScope.isMask = true;
  4267. $rootScope.loading = true;
  4268. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4269. uploader.onBeforeUploadItem = function (item) {
  4270. angular.extend(item.headers, $rootScope.getSession());
  4271. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4272. // if (item.index > 1) {
  4273. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4274. // }
  4275. // item.index = 1;
  4276. item.formData = [
  4277. {
  4278. filename: item.file.name,
  4279. },
  4280. ];
  4281. console.info("onBeforeUploadItem", item);
  4282. };
  4283. uploader.uploadAll();
  4284. uploader.onSuccessItem = function (
  4285. fileItem,
  4286. response,
  4287. status,
  4288. headers
  4289. ) {
  4290. if (response.status == 200) {
  4291. $scope.wrongdata = [];
  4292. $rootScope.loading = false;
  4293. if (response.abnormal) {
  4294. $scope.state = 2;
  4295. angular.forEach(response.msg, function (item) {
  4296. $scope.wrongdata.push({
  4297. name: item.assetName,
  4298. line: item.row,
  4299. cmdbname: item.name,
  4300. errotip: [
  4301. {
  4302. label: item.msg,
  4303. },
  4304. ],
  4305. });
  4306. });
  4307. } else {
  4308. $scope.state = 3;
  4309. }
  4310. } else {
  4311. $rootScope.loading = false;
  4312. $scope.state = 2;
  4313. }
  4314. };
  4315. };
  4316. $scope.clearItems = function () {
  4317. //重新选择文件时,清空队列,达到覆盖文件的效果
  4318. uploader.clearQueue();
  4319. // uploader.remove();
  4320. // uploader.cancel();
  4321. // uploader.onChange();
  4322. };
  4323. uploader.onAfterAddingFile = function (fileItem) {
  4324. $scope.fileItem = fileItem._file;
  4325. // $scope.$apply();
  4326. // $scope.fileItem = filenum;
  4327. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4328. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4329. $scope.filenum++;
  4330. };
  4331. uploader.onSuccessItem = function (
  4332. fileItem,
  4333. response,
  4334. status,
  4335. headers
  4336. ) {
  4337. $scope.uploadStatus = true; //上传成功则把状态改为true
  4338. // alert(response.path);
  4339. };
  4340. $scope.importnext = function () {
  4341. event.preventDefault();
  4342. // uploader.onChange();
  4343. $rootScope.loading = true;
  4344. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4345. uploader.onBeforeUploadItem = function (item) {
  4346. angular.extend(item.headers, $rootScope.getSession());
  4347. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4348. // if (item.index > 1) {
  4349. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4350. // }
  4351. // item.index = 1;
  4352. item.formData = [
  4353. {
  4354. filename: item.file.name,
  4355. },
  4356. ];
  4357. console.info("onBeforeUploadItem", item);
  4358. };
  4359. uploader.uploadAll();
  4360. uploader.onSuccessItem = function (
  4361. fileItem,
  4362. response,
  4363. status,
  4364. headers
  4365. ) {
  4366. if (response.status == 200) {
  4367. $scope.wrongdata = [];
  4368. // uploader.queue = [];
  4369. $rootScope.loading = false;
  4370. if (response.abnormal) {
  4371. $scope.state = 2;
  4372. uploader.clearQueue();
  4373. angular.forEach(response.msg, function (item) {
  4374. $scope.wrongdata.push({
  4375. name: item.assetName,
  4376. line: item.row,
  4377. cmdbname: item.name,
  4378. errotip: [
  4379. {
  4380. label: item.msg,
  4381. },
  4382. ],
  4383. });
  4384. });
  4385. } else {
  4386. $scope.state = 3;
  4387. }
  4388. } else {
  4389. uploader.clearQueue();
  4390. $rootScope.loading = false;
  4391. $scope.state = 2;
  4392. }
  4393. };
  4394. };
  4395. var setAllInactive = function () {
  4396. angular.forEach($scope.workspaces, function (workspace) {
  4397. workspace.active = false;
  4398. });
  4399. };
  4400. //添加
  4401. var addNewWorkspace = function (name, contentUrl) {
  4402. var id = $scope.workspaces.length + 1;
  4403. $scope.workspaces.push({
  4404. id: id,
  4405. name: name,
  4406. active: true,
  4407. contentUrl: "main/html/content.html",
  4408. });
  4409. };
  4410. //关闭
  4411. $scope.closeopen = function (closedata) {
  4412. event.preventDefault();
  4413. angular.forEach($scope.workspaces, function (item, index) {
  4414. if (closedata.id == item.id) {
  4415. if (closedata.id == 1) {
  4416. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4417. } else {
  4418. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4419. }
  4420. $scope.workspaces.splice(index, 1);
  4421. }
  4422. });
  4423. };
  4424. // $scope.workspaces = [
  4425. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4426. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4427. // ];
  4428. $scope.addWorkspace = function (contentUrl, name) {
  4429. setAllInactive();
  4430. addNewWorkspace(name, contentUrl);
  4431. };
  4432. // $rootScope.addWorkspace = $scope.addWorkspace;
  4433. $scope.close = function (idNumber) {
  4434. var index = 0; //记录当前元素下标
  4435. angular.forEach($scope.workspaces, function (workspace) {
  4436. if (workspace.id === idNumber) {
  4437. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4438. }
  4439. index++;
  4440. });
  4441. };
  4442. //grid2
  4443. $scope.langs = i18nService.getAllLangs();
  4444. $scope.lang = "zh-cn";
  4445. i18nService.setCurrentLang($scope.lang);
  4446. $scope.gridOptions2 = {};
  4447. $scope.gridOptions2.data = "myData3";
  4448. $scope.gridOptions2.enableColumnResizing = true;
  4449. $scope.gridOptions2.enableFiltering = false;
  4450. $scope.gridOptions2.enableGridMenu = false;
  4451. $scope.gridOptions2.showGridFooter = true;
  4452. $scope.gridOptions2.showColumnFooter = false;
  4453. $scope.gridOptions2.fastWatch = true;
  4454. $scope.gridOptions2.useExternalFiltering = true;
  4455. $scope.gridOptions2.useExternalPagination = true;
  4456. $scope.gridOptions2.paginationPageSizes = [10];
  4457. $scope.gridOptions2.paginationPageSize = 10;
  4458. $scope.gridOptions2.multiSelect = false;
  4459. // $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>";
  4460. $scope.gridOptions2.columnDefs = [
  4461. {
  4462. name: "item",
  4463. displayName: "序号",
  4464. width: 120,
  4465. },
  4466. {
  4467. name: "name",
  4468. displayName: "耗材名称",
  4469. width: 80,
  4470. enableFiltering: false,
  4471. },
  4472. {
  4473. name: "model",
  4474. displayName: "品牌/型号",
  4475. width: 100,
  4476. enableFiltering: false,
  4477. },
  4478. {
  4479. name: "Specifications",
  4480. displayName: "规格",
  4481. width: 150,
  4482. enableFiltering: false,
  4483. },
  4484. {
  4485. name: "sum",
  4486. displayName: "数量",
  4487. enableFiltering: false,
  4488. },
  4489. {
  4490. name: "操作",
  4491. cellTemplate:
  4492. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4493. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4494. "</div></div>",
  4495. enableFiltering: false,
  4496. },
  4497. ];
  4498. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4499. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4500. $scope.myData3all = JSON.parse(
  4501. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4502. );
  4503. for (var i = 0; i < $scope.myData3all.length; i++) {
  4504. $scope.myData3all[i]["item"] =
  4505. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4506. }
  4507. // $scope.model.consumables = $scope.myDataone;
  4508. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4509. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4510. $scope.model.applicationForm.consumables = $scope.myData3all;
  4511. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4512. $scope.options.templateOptions.getpush({
  4513. hao: true,
  4514. gu: true,
  4515. });
  4516. } else {
  4517. $scope.options.templateOptions.getpush({
  4518. hao: true,
  4519. });
  4520. }
  4521. } else {
  4522. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4523. $scope.options.templateOptions.getpush({
  4524. gu: true,
  4525. });
  4526. }
  4527. }
  4528. }
  4529. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4530. $scope.changecai = function (item) {
  4531. event.preventDefault();
  4532. var modalInstance = $modal.open({
  4533. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4534. controller: function ($scope, $modalInstance) {
  4535. $scope.title = "修改耗材数量";
  4536. $scope.consumptive = angular.copy(item);
  4537. $scope.ok = function () {
  4538. $modalInstance.close($scope.consumptive);
  4539. };
  4540. $scope.cancel = function () {
  4541. $modalInstance.dismiss("cancel");
  4542. };
  4543. },
  4544. size: "sm",
  4545. });
  4546. modalInstance.result.then(function (selectedItem) {
  4547. // angular.forEach($scope.myData3, function(items, index) {
  4548. // if (items.id == selectedItem.id) {
  4549. // $scope.myData3[index] = selectedItem;
  4550. // }
  4551. // })
  4552. // // $scope.myData3.push(selectedItem);
  4553. // $scope.model.applicationForm.consumables = $scope.myData3;
  4554. angular.forEach($scope.myData3all, function (items, index) {
  4555. if (
  4556. items.modelid == selectedItem.modelid &&
  4557. items.nameid == selectedItem.nameid &&
  4558. items.Specificationsid == selectedItem.Specificationsid
  4559. ) {
  4560. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4561. angular.extend($scope.myData3all[index], selectedItem);
  4562. }
  4563. });
  4564. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4565. $scope.myData3 = $scope.interceptMydata(
  4566. $scope.myData3all,
  4567. $scope.memoryfilterDatahao.idx,
  4568. 10
  4569. );
  4570. $scope.model.applicationForm.consumables = $scope.myData3all;
  4571. });
  4572. };
  4573. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4574. $scope.gridApi = gridApi;
  4575. gridApi.pagination.on.paginationChanged(
  4576. $scope,
  4577. function (newPage, pageSize) {
  4578. // var filtersData = $scope.memoryfilterDatahao;
  4579. // filtersData.idx = newPage - 1;
  4580. // filtersData.sum = pageSize;
  4581. // $scope.loadData(filtersData);
  4582. $scope.memoryfilterDatahao.idx = newPage - 1;
  4583. $scope.memoryfilterDatahao.sum = pageSize;
  4584. $scope.myData3 = $scope.interceptMydata(
  4585. $scope.myData3all,
  4586. $scope.memoryfilterDatahao.idx,
  4587. 10
  4588. );
  4589. }
  4590. );
  4591. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4592. $scope.selected.items = data.entity;
  4593. //console.log(data);
  4594. });
  4595. gridApi.selection.on.rowSelectionChangedBatch(
  4596. $scope,
  4597. function (data) {
  4598. $scope.selected.items = data.entity;
  4599. //console.log(data);
  4600. }
  4601. );
  4602. gridApi.core.on.filterChanged($scope, function () {
  4603. var grid = this.grid;
  4604. var filtersData = {
  4605. idx: 0,
  4606. sum: 10,
  4607. };
  4608. $scope.memoryfilterDatahao = filtersData;
  4609. // $scope.loadData(filtersData);
  4610. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4611. // $scope.memoryfilterDatahao.sum = pageSize;
  4612. $scope.myData3 = $scope.interceptMydata(
  4613. $scope.myData3all,
  4614. $scope.memoryfilterDatahao.idx,
  4615. 10
  4616. );
  4617. });
  4618. };
  4619. $scope.haocaiopen = function (items) {
  4620. event.preventDefault();
  4621. var modalInstance = $modal.open({
  4622. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4623. controller: function ($scope, $modalInstance, SweetAlert) {
  4624. $scope.consumptive = {};
  4625. $scope.title = "新增耗材";
  4626. if (items.name) {
  4627. $scope.consumptive.name = items.name.name;
  4628. }
  4629. $scope.clearNoNum = function (obj, attr) {
  4630. //先把非数字的都替换掉,除了数字和.
  4631. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4632. //必须保证第一个为数字而不是.
  4633. obj[attr] = obj[attr].replace(/^\./g, "");
  4634. //保证只有出现一个.而没有多个.
  4635. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4636. //保证.只出现一次,而不能出现两次以上
  4637. obj[attr] = obj[attr]
  4638. .replace(".", "$#$")
  4639. .replace(/\./g, "")
  4640. .replace("$#$", ".");
  4641. //小于最大值
  4642. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4643. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4644. // obj[attr] = '';
  4645. // }
  4646. };
  4647. $scope.ok = function (item) {
  4648. // if (item.name && item.model && item.Specifications && item.sum) {
  4649. if (
  4650. item.name &&
  4651. item.model &&
  4652. JSON.stringify(item.model) != "{}" &&
  4653. item.Specifications &&
  4654. JSON.stringify(item.Specifications) != "{}" &&
  4655. item.sum
  4656. ) {
  4657. $modalInstance.close(item);
  4658. } else {
  4659. SweetAlert.swal({
  4660. title: "数据填写不完整!",
  4661. text: "请检查数据然后提交!",
  4662. type: "error",
  4663. });
  4664. }
  4665. };
  4666. $scope.cancel = function () {
  4667. $modalInstance.dismiss("cancel");
  4668. };
  4669. },
  4670. size: "sm",
  4671. resolve: {
  4672. SweetAlert: function () {
  4673. return SweetAlert;
  4674. },
  4675. },
  4676. });
  4677. modalInstance.result.then(function (selectedItem) {
  4678. api_sysinfo
  4679. .addData("dictionaryTree", {
  4680. // "type": "list",
  4681. key: "haocaifenlei",
  4682. name: selectedItem.name,
  4683. parent: selectedItem.id,
  4684. value: selectedItem.name,
  4685. deleted: false,
  4686. level: 1,
  4687. })
  4688. .then(function (data) {
  4689. // $scope.haocainame.name = data.list;
  4690. api_sysinfo
  4691. .addData("dictionaryTree", {
  4692. // "type": "list",
  4693. key: "pinpai",
  4694. name: selectedItem.model,
  4695. parent: data.id,
  4696. value: selectedItem.model,
  4697. deleted: false,
  4698. level: 2,
  4699. })
  4700. .then(function (data) {
  4701. // $scope.haocainame = data.list;
  4702. });
  4703. api_sysinfo
  4704. .addData({
  4705. // "type": "list",
  4706. key: "guige",
  4707. name: selectedItem.Specifications,
  4708. parent: data.id,
  4709. value: selectedItem.Specifications,
  4710. deleted: false,
  4711. level: 2,
  4712. })
  4713. .then(function (data) {
  4714. // $scope.haocainame = data.list;
  4715. });
  4716. });
  4717. // $scope.myData3.push(selectedItem);
  4718. // for (var i = 0; i < $scope.myData3.length; i++) {
  4719. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4720. // }
  4721. // $scope.model.applicationForm.consumables = $scope.myData3;
  4722. $scope.myData3all.push(selectedItem);
  4723. for (var i = 0; i < $scope.myData3all.length; i++) {
  4724. $scope.myData3all[i]["item"] = i + 1;
  4725. }
  4726. // $scope.model.consumables = $scope.myDataone;
  4727. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4728. $scope.myData3 = $scope.interceptMydata(
  4729. $scope.myData3all,
  4730. $scope.memoryfilterDatahao.idx,
  4731. 10
  4732. );
  4733. $scope.model.applicationForm.consumables = $scope.myData3all;
  4734. });
  4735. };
  4736. $scope.haocaiadd = function () {
  4737. event.preventDefault();
  4738. var modalInstance = $modal.open({
  4739. templateUrl:
  4740. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4741. controller: function (
  4742. $scope,
  4743. scope,
  4744. $modalInstance,
  4745. api_wechatfile,
  4746. SweetAlert,
  4747. api_cmdb3
  4748. ) {
  4749. $scope.haocainame = [];
  4750. $scope.pinpai = [];
  4751. $scope.guige = [];
  4752. $scope.consumptive = {};
  4753. $scope.consumpall = {};
  4754. $scope.title = "添加耗材";
  4755. api_wechatfile
  4756. .getDictionary({
  4757. key: "haocaifenlei",
  4758. type: "tree",
  4759. })
  4760. .then(function (data) {
  4761. $scope.haocainame = data;
  4762. });
  4763. $scope.clearNoNum = function (obj, attr) {
  4764. //先把非数字的都替换掉,除了数字和.
  4765. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4766. //必须保证第一个为数字而不是.
  4767. obj[attr] = obj[attr].replace(/^\./g, "");
  4768. //保证只有出现一个.而没有多个.
  4769. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4770. //保证.只出现一次,而不能出现两次以上
  4771. obj[attr] = obj[attr]
  4772. .replace(".", "$#$")
  4773. .replace(/\./g, "")
  4774. .replace("$#$", ".");
  4775. //小于最大值
  4776. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4777. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4778. // obj[attr] = '';
  4779. // }
  4780. };
  4781. $scope.onChange = function (parent) {
  4782. $scope.consumptive.model = {};
  4783. $scope.consumptive.Specifications = {};
  4784. api_wechatfile
  4785. .getDictionaryForList({
  4786. key: "pinpai",
  4787. parent: parent.id,
  4788. })
  4789. .then(function (data) {
  4790. $scope.pinpai = data;
  4791. });
  4792. api_wechatfile
  4793. .getDictionaryForList({
  4794. key: "guige",
  4795. parent: parent.id,
  4796. })
  4797. .then(function (data) {
  4798. $scope.guige = data;
  4799. });
  4800. };
  4801. $scope.addhaocai = function () {
  4802. $modalInstance.dismiss("cancel");
  4803. scope.haocaiopen($scope.consumptive);
  4804. };
  4805. $scope.ok = function (item) {
  4806. var items = {};
  4807. var submittrue = true;
  4808. if (
  4809. item.name &&
  4810. item.model &&
  4811. JSON.stringify(item.model) != "{}" &&
  4812. item.Specifications &&
  4813. JSON.stringify(item.Specifications) != "{}" &&
  4814. item.sum
  4815. ) {
  4816. items = {
  4817. modelid: item.model.id,
  4818. nameid: item.name.id,
  4819. Specificationsid: item.Specifications.id,
  4820. name: item.name.name,
  4821. model: item.model.name,
  4822. Specifications: item.Specifications.name,
  4823. sum: item.sum,
  4824. };
  4825. angular.forEach(scope.myData3all, function (itemsdata) {
  4826. if (
  4827. item.model.id == itemsdata.modelid &&
  4828. item.name.id == itemsdata.nameid &&
  4829. item.Specifications.id == itemsdata.Specificationsid
  4830. ) {
  4831. submittrue = false;
  4832. }
  4833. });
  4834. if (submittrue) {
  4835. $modalInstance.close(items);
  4836. } else {
  4837. SweetAlert.swal({
  4838. title: "该耗材已有添加",
  4839. text: "请检查数据然后提交!",
  4840. type: "error",
  4841. });
  4842. }
  4843. } else {
  4844. SweetAlert.swal({
  4845. title: "数据填写不完整!",
  4846. text: "请检查数据然后提交!",
  4847. type: "error",
  4848. });
  4849. }
  4850. // var isold = false;
  4851. // if (item.name && item.model && item.Specifications && item.sum) {
  4852. // for (var i = 0; i < scope.myData3all.length; i++) {
  4853. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4854. // isold = true;
  4855. // }
  4856. // }
  4857. // if (isold) {
  4858. // SweetAlert.swal({
  4859. // title: "该耗材已添加!",
  4860. // text: "请不要重复添加耗材!",
  4861. // type: "error"
  4862. // });
  4863. // } else {
  4864. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4865. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4866. // $scope.consumpall.sum = item.sum;
  4867. // delete $scope.consumpall.brandModel;
  4868. // delete $scope.consumpall.specification;
  4869. // $modalInstance.close($scope.consumpall);
  4870. // }
  4871. // } else {
  4872. // SweetAlert.swal({
  4873. // title: "数据填写不完整!",
  4874. // text: "请检查数据然后提交!",
  4875. // type: "error"
  4876. // });
  4877. // }
  4878. };
  4879. $scope.cancel = function () {
  4880. $modalInstance.dismiss("cancel");
  4881. };
  4882. },
  4883. size: "sm",
  4884. resolve: {
  4885. scope: function () {
  4886. return $scope;
  4887. },
  4888. },
  4889. });
  4890. modalInstance.result.then(function (selectedItem) {
  4891. $scope.myData3all.push(selectedItem);
  4892. for (var i = 0; i < $scope.myData3all.length; i++) {
  4893. $scope.myData3all[i]["item"] = i + 1;
  4894. }
  4895. // $scope.model.consumables = $scope.myDataone;
  4896. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4897. $scope.myData3 = $scope.interceptMydata(
  4898. $scope.myData3all,
  4899. $scope.memoryfilterDatahao.idx,
  4900. 10
  4901. );
  4902. $scope.model.applicationForm.consumables = $scope.myData3all;
  4903. });
  4904. };
  4905. $scope.onDblClick = function (data, event) {
  4906. $scope.selectButtonClick(data, event);
  4907. };
  4908. // $scope.memoryfilterDatahao = {
  4909. // "idx": 0,
  4910. // "sum": 10,
  4911. // }
  4912. // $scope.loadData = function(filterData) {};
  4913. // $scope.title = title;
  4914. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4915. $scope.options.templateOptions.transform(
  4916. $scope.options,
  4917. $rootScope,
  4918. $scope
  4919. );
  4920. }
  4921. },
  4922. ],
  4923. });
  4924. //归还设备耗材tab
  4925. formlyConfigProvider.setType({
  4926. name: "ui-cmdbreturntab",
  4927. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4928. wrapper: ["bootstrapHasError"],
  4929. defaultOptions: function (options, $scope) {
  4930. return {
  4931. templateOptions: {
  4932. // checkform: function(options) {
  4933. // if (options.model.requester) {
  4934. // options.value(options.model.requester);
  4935. // }
  4936. // },
  4937. },
  4938. };
  4939. },
  4940. controller: [
  4941. "$scope",
  4942. "$modal",
  4943. "api_user_data",
  4944. "i18nService",
  4945. "api_wechatfile",
  4946. "api_cmdb3",
  4947. function (
  4948. $scope,
  4949. $modal,
  4950. api_user_data,
  4951. i18nService,
  4952. api_wechatfile,
  4953. api_cmdb3
  4954. ) {
  4955. var setAllInactive = function () {
  4956. angular.forEach($scope.workspaces, function (workspace) {
  4957. workspace.active = false;
  4958. });
  4959. };
  4960. $scope.memoryfilterData = {
  4961. idx: 0,
  4962. sum: 10,
  4963. };
  4964. //添加
  4965. var addNewWorkspace = function (name, contentUrl) {
  4966. var id = $scope.workspaces.length + 1;
  4967. $scope.workspaces.push({
  4968. id: id,
  4969. name: name,
  4970. active: true,
  4971. contentUrl: "main/html/content.html",
  4972. });
  4973. };
  4974. $scope.workspaces = [
  4975. {
  4976. id: 1,
  4977. name: "归还设备",
  4978. active: true,
  4979. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4980. },
  4981. {
  4982. id: 2,
  4983. name: "归还耗材",
  4984. active: true,
  4985. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4986. },
  4987. ];
  4988. $scope.addWorkspace = function (contentUrl, name) {
  4989. setAllInactive();
  4990. addNewWorkspace(name, contentUrl);
  4991. };
  4992. // $rootScope.addWorkspace = $scope.addWorkspace;
  4993. $scope.close = function (idNumber) {
  4994. var index = 0; //记录当前元素下标
  4995. angular.forEach($scope.workspaces, function (workspace) {
  4996. if (workspace.id === idNumber) {
  4997. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4998. }
  4999. index++;
  5000. });
  5001. };
  5002. $scope.memoryfilterDataguishe = {
  5003. idx: 0,
  5004. sum: 10,
  5005. };
  5006. //grid1
  5007. $scope.langs = i18nService.getAllLangs();
  5008. $scope.lang = "zh-cn";
  5009. i18nService.setCurrentLang($scope.lang);
  5010. $scope.gridOptions1 = {};
  5011. $scope.gridOptions1.data = "myData1";
  5012. $scope.gridOptions1.enableColumnResizing = true;
  5013. $scope.gridOptions1.enableFiltering = false;
  5014. $scope.gridOptions1.enableGridMenu = false;
  5015. $scope.gridOptions1.showGridFooter = true;
  5016. $scope.gridOptions1.showColumnFooter = false;
  5017. $scope.gridOptions1.fastWatch = true;
  5018. $scope.gridOptions1.useExternalFiltering = true;
  5019. $scope.gridOptions1.useExternalPagination = true;
  5020. $scope.gridOptions1.paginationPageSizes = [10];
  5021. $scope.gridOptions1.paginationPageSize = 10;
  5022. $scope.gridOptions1.multiSelect = false;
  5023. // $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>";
  5024. $scope.gridOptions1.columnDefs = [
  5025. {
  5026. name: "item",
  5027. displayName: "序号",
  5028. width: 120,
  5029. },
  5030. {
  5031. name: "props.hw_cifilterClassic",
  5032. displayName: "设备类型",
  5033. width: 150,
  5034. enableFiltering: false,
  5035. },
  5036. {
  5037. name: "props.hw_mingcheng",
  5038. displayName: "设备名称",
  5039. width: 180,
  5040. enableFiltering: false,
  5041. },
  5042. {
  5043. name: "uuid",
  5044. displayName: "设备编号",
  5045. width: 180,
  5046. enableFiltering: false,
  5047. },
  5048. {
  5049. name: "props.hw_state",
  5050. width: 150,
  5051. displayName: "状态",
  5052. enableFiltering: false,
  5053. },
  5054. {
  5055. name: "操作",
  5056. cellTemplate:
  5057. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5058. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5059. "</div></div>",
  5060. enableFiltering: false,
  5061. },
  5062. ];
  5063. // $scope.selectButtonClick
  5064. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5065. $scope.gridApi = gridApi;
  5066. gridApi.pagination.on.paginationChanged(
  5067. $scope,
  5068. function (newPage, pageSize) {
  5069. // var filtersData = $scope.memoryfilterData;
  5070. // filtersData.idx = newPage - 1;
  5071. // filtersData.sum = pageSize;
  5072. // $scope.loadData(filtersData);
  5073. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5074. $scope.memoryfilterDataguishe.sum = pageSize;
  5075. $scope.myData1 = $scope.interceptMydata(
  5076. $scope.myData2all,
  5077. $scope.memoryfilterDataguishe.idx,
  5078. 10
  5079. );
  5080. }
  5081. );
  5082. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5083. $scope.selected.items = data.entity;
  5084. //console.log(data);
  5085. });
  5086. gridApi.selection.on.rowSelectionChangedBatch(
  5087. $scope,
  5088. function (data) {
  5089. $scope.selected.items = data.entity;
  5090. //console.log(data);
  5091. }
  5092. );
  5093. gridApi.core.on.filterChanged($scope, function () {
  5094. // var grid = this.grid;
  5095. // var filtersData = {
  5096. // idx: 0,
  5097. // sum: 20,
  5098. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5099. // };
  5100. // angular.forEach(grid.columns, function(item) {
  5101. // if (item.enableFiltering) {
  5102. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5103. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5104. // if (angular.isUndefined(filtersData['user'])) {
  5105. // filtersData['user'] = {};
  5106. // }
  5107. // filtersData['user'][item.field] = item.filters[0].term;
  5108. // }
  5109. // }
  5110. // });
  5111. // $scope.memoryfilterData = filtersData;
  5112. // $scope.loadData(filtersData);
  5113. });
  5114. };
  5115. $scope.changegu = function (item) {
  5116. event.preventDefault();
  5117. var modalInstance = $modal.open({
  5118. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5119. controller: function ($scope, $modalInstance) {
  5120. $scope.title = "修改设备状态";
  5121. $scope.hw_state = {};
  5122. if (item.status) {
  5123. $scope.hw_state.name = item.hw_state;
  5124. }
  5125. // $scope.consumptive = item;
  5126. $scope.stateshe = [
  5127. {
  5128. id: 2,
  5129. name: "在库",
  5130. },
  5131. {
  5132. id: 4,
  5133. name: "报修",
  5134. },
  5135. {
  5136. id: 3,
  5137. name: "报废",
  5138. },
  5139. ];
  5140. $scope.ok = function (item) {
  5141. $modalInstance.close($scope.hw_state);
  5142. };
  5143. $scope.cancel = function () {
  5144. $modalInstance.dismiss("cancel");
  5145. };
  5146. },
  5147. size: "sm",
  5148. });
  5149. modalInstance.result.then(function (selectedItem) {
  5150. angular.forEach($scope.myData1, function (items, index) {
  5151. if (items.id == item.id) {
  5152. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5153. }
  5154. });
  5155. $scope.model.assets = $scope.myData1;
  5156. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5157. $scope.model.assets;
  5158. });
  5159. };
  5160. $scope.onDblClick = function (data, event) {
  5161. $scope.selectButtonClick(data, event);
  5162. };
  5163. $scope.memoryfilterData = {
  5164. idx: 0,
  5165. sum: 10,
  5166. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5167. };
  5168. // $scope.myData = {};
  5169. $scope.loadData = function (filterData) { };
  5170. // $scope.title = title;
  5171. $scope.loadData({
  5172. idx: 0,
  5173. sum: 10,
  5174. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5175. });
  5176. $scope.selected = {
  5177. items: [],
  5178. };
  5179. $scope.myData2 = [];
  5180. $scope.consumptive = {};
  5181. $scope.myDataguibeiall = [];
  5182. $scope.haocaiopen = function (items) {
  5183. event.preventDefault();
  5184. var modalInstance = $modal.open({
  5185. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5186. controller: function (
  5187. $scope,
  5188. $modalInstance,
  5189. SweetAlert,
  5190. api_wechatfile,
  5191. api_sysinfo
  5192. ) {
  5193. $scope.consumptive = {};
  5194. $scope.title = "新增耗材";
  5195. if (items.name) {
  5196. $scope.consumptive.name = items.name.name;
  5197. }
  5198. $scope.ok = function (item) {
  5199. if (
  5200. item.name &&
  5201. item.model &&
  5202. JSON.stringify(item.model) != "{}" &&
  5203. item.Specifications &&
  5204. JSON.stringify(item.Specifications) != "{}" &&
  5205. item.sum
  5206. ) {
  5207. $modalInstance.close(item);
  5208. } else {
  5209. SweetAlert.swal({
  5210. title: "数据填写不完整!",
  5211. text: "请检查数据然后提交!",
  5212. type: "error",
  5213. });
  5214. }
  5215. };
  5216. $scope.cancel = function () {
  5217. $modalInstance.dismiss("cancel");
  5218. };
  5219. },
  5220. size: "sm",
  5221. });
  5222. modalInstance.result.then(function (selectedItem) {
  5223. api_sysinfo
  5224. .addData({
  5225. type: "list",
  5226. key: "haocaifenlei",
  5227. name: selectedItem.name,
  5228. parent: selectedItem.id,
  5229. value: "1",
  5230. })
  5231. .then(function (data) {
  5232. // $scope.haocainame.name = data.list;
  5233. api_wechatfile
  5234. .addDictionary({
  5235. type: "list",
  5236. key: "pinpai",
  5237. name: selectedItem.model,
  5238. parent: data.id,
  5239. value: "1",
  5240. })
  5241. .then(function (data) {
  5242. // $scope.haocainame = data.list;
  5243. });
  5244. api_wechatfile
  5245. .addDictionary({
  5246. type: "list",
  5247. key: "guige",
  5248. name: selectedItem.Specifications,
  5249. parent: data.id,
  5250. value: "1",
  5251. })
  5252. .then(function (data) {
  5253. // $scope.haocainame = data.list;
  5254. });
  5255. });
  5256. $scope.myData2.push(selectedItem);
  5257. for (var i = 0; i < $scope.myData2.length; i++) {
  5258. $scope.myData2[i]["item"] =
  5259. i + 1 + $scope.memoryfilterData.idx * 10;
  5260. }
  5261. // $scope.model.applicationForm.consumables = $scope.myData2;
  5262. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5263. if (items.id == selectedItem.id) {
  5264. $scope.myDataguibeiall.splice(index, 1);
  5265. }
  5266. });
  5267. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5268. $scope.model.consumables = $scope.myDataguibeiall;
  5269. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5270. $scope.model.consumables;
  5271. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5272. });
  5273. };
  5274. //grid2
  5275. $scope.langs = i18nService.getAllLangs();
  5276. $scope.lang = "zh-cn";
  5277. i18nService.setCurrentLang($scope.lang);
  5278. $scope.gridOptions2 = {};
  5279. $scope.gridOptions2.data = "myData2";
  5280. $scope.gridOptions2.enableColumnResizing = true;
  5281. $scope.gridOptions2.enableFiltering = false;
  5282. $scope.gridOptions2.enableGridMenu = false;
  5283. $scope.gridOptions2.showGridFooter = true;
  5284. $scope.gridOptions2.showColumnFooter = false;
  5285. $scope.gridOptions2.fastWatch = true;
  5286. $scope.gridOptions2.useExternalFiltering = true;
  5287. $scope.gridOptions2.useExternalPagination = true;
  5288. $scope.gridOptions2.paginationPageSizes = [10];
  5289. $scope.gridOptions2.paginationPageSize = 10;
  5290. $scope.gridOptions2.multiSelect = false;
  5291. // $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>";
  5292. $scope.modelcons = {};
  5293. $scope.modelass = {};
  5294. $scope.myData2all = [];
  5295. $scope.myData1all = [];
  5296. $scope.memoryfilterDatagui = {
  5297. idx: 0,
  5298. sum: 10,
  5299. };
  5300. setInterval(function () {
  5301. if ($scope.model.assets) {
  5302. if (
  5303. $scope.model.assets != $scope.modelass &&
  5304. typeof $scope.model.assets == "string"
  5305. ) {
  5306. $scope.modelass = $scope.model.assets;
  5307. if (JSON.stringify($scope.model.assets) == "{}") {
  5308. $scope.model.assets = [];
  5309. } else {
  5310. $scope.model.assets = JSON.parse($scope.model.assets);
  5311. }
  5312. // $scope.myData1 = $scope.model.assets;
  5313. // for (var i = 0; i < $scope.myData1.length; i++) {
  5314. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5315. // }
  5316. $scope.myData1all = $scope.model.assets;
  5317. for (var i = 0; i < $scope.myData1all.length; i++) {
  5318. $scope.myData1all[i]["item"] =
  5319. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5320. }
  5321. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5322. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5323. }
  5324. }
  5325. if ($scope.model.consumables) {
  5326. if (
  5327. $scope.model.consumables != $scope.modelcons &&
  5328. typeof $scope.model.consumables == "string"
  5329. ) {
  5330. $scope.modelass = $scope.model.consumables;
  5331. if (JSON.stringify($scope.model.consumables) == "{}") {
  5332. $scope.model.consumables = [];
  5333. } else {
  5334. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5335. }
  5336. // $scope.myData2 = $scope.model.consumables;
  5337. // for (var i = 0; i < $scope.myData2.length; i++) {
  5338. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5339. // }
  5340. $scope.myData2all = $scope.model.consumables;
  5341. for (var i = 0; i < $scope.myData2all.length; i++) {
  5342. $scope.myData2all[i]["item"] =
  5343. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5344. }
  5345. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5346. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5347. // $scope.model.consumables = $scope.myData2all;
  5348. }
  5349. }
  5350. }, 100);
  5351. $scope.gridOptions2.columnDefs = [
  5352. {
  5353. name: "item",
  5354. displayName: "序号",
  5355. width: 120,
  5356. },
  5357. {
  5358. name: "name",
  5359. displayName: "耗材名称",
  5360. width: 180,
  5361. enableFiltering: false,
  5362. },
  5363. {
  5364. name: "model",
  5365. displayName: "品牌/型号",
  5366. width: 180,
  5367. enableFiltering: false,
  5368. },
  5369. {
  5370. name: "Specifications",
  5371. displayName: "规格",
  5372. width: 150,
  5373. enableFiltering: false,
  5374. },
  5375. {
  5376. name: "sum",
  5377. width: 150,
  5378. displayName: "数量",
  5379. enableFiltering: false,
  5380. },
  5381. {
  5382. name: "操作",
  5383. cellTemplate:
  5384. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5385. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5386. "</div></div>",
  5387. enableFiltering: false,
  5388. },
  5389. ];
  5390. // $scope.selectButtonClick
  5391. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5392. $scope.gridApi = gridApi;
  5393. gridApi.pagination.on.paginationChanged(
  5394. $scope,
  5395. function (newPage, pageSize) {
  5396. // var filtersData = $scope.memoryfilterDatagui;
  5397. // filtersData.idx = newPage - 1;
  5398. // filtersData.sum = pageSize;
  5399. $scope.memoryfilterDatagui.idx = newPage - 1;
  5400. $scope.memoryfilterDatagui.sum = pageSize;
  5401. $scope.myData2 = $scope.interceptMydata(
  5402. $scope.myData2all,
  5403. $scope.memoryfilterDatagui.idx,
  5404. 10
  5405. );
  5406. }
  5407. );
  5408. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5409. $scope.selected.items = data.entity;
  5410. //console.log(data);
  5411. });
  5412. gridApi.selection.on.rowSelectionChangedBatch(
  5413. $scope,
  5414. function (data) {
  5415. $scope.selected.items = data.entity;
  5416. //console.log(data);
  5417. }
  5418. );
  5419. gridApi.core.on.filterChanged($scope, function () {
  5420. var grid = this.grid;
  5421. var filtersData = {
  5422. idx: 0,
  5423. sum: 10,
  5424. };
  5425. angular.forEach(grid.columns, function (item) {
  5426. if (item.enableFiltering) {
  5427. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5428. if (
  5429. angular.isDefined(item.filters[0].term) &&
  5430. item.filters[0].term != ""
  5431. ) {
  5432. if (angular.isUndefined(filtersData["user"])) {
  5433. filtersData["user"] = {};
  5434. }
  5435. filtersData["user"][item.field] = item.filters[0].term;
  5436. }
  5437. }
  5438. });
  5439. $scope.memoryfilterData = filtersData;
  5440. $scope.loadData(filtersData);
  5441. });
  5442. };
  5443. $scope.changecai = function (item) {
  5444. event.preventDefault();
  5445. var modalInstance = $modal.open({
  5446. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5447. controller: function ($scope, $modalInstance) {
  5448. $scope.title = "修改耗材数量";
  5449. $scope.consumptive = angular.copy(item);
  5450. // $scope.consumptive = item;
  5451. $scope.maxsum = item.inventoryNum;
  5452. $scope.clearNoNum = function (obj, attr) {
  5453. //先把非数字的都替换掉,除了数字和.
  5454. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5455. //必须保证第一个为数字而不是.
  5456. obj[attr] = obj[attr].replace(/^\./g, "");
  5457. //保证只有出现一个.而没有多个.
  5458. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5459. //保证.只出现一次,而不能出现两次以上
  5460. obj[attr] = obj[attr]
  5461. .replace(".", "$#$")
  5462. .replace(/\./g, "")
  5463. .replace("$#$", ".");
  5464. //小于最大值
  5465. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5466. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5467. // obj[attr] = '';
  5468. // }
  5469. };
  5470. $scope.ok = function () {
  5471. $modalInstance.close($scope.consumptive);
  5472. };
  5473. $scope.cancel = function () {
  5474. $modalInstance.dismiss("cancel");
  5475. };
  5476. },
  5477. size: "sm",
  5478. });
  5479. modalInstance.result.then(function (selectedItem) {
  5480. angular.forEach($scope.myData2all, function (items, index) {
  5481. // if (items.id == selectedItem.id) {
  5482. if (
  5483. items.modelid == selectedItem.modelid &&
  5484. items.nameid == selectedItem.nameid &&
  5485. items.Specificationsid == selectedItem.Specificationsid
  5486. ) {
  5487. angular.extend($scope.myData2all[index], selectedItem);
  5488. }
  5489. });
  5490. // $scope.model.consumables = $scope.myData2;
  5491. // $scope.myData2 = $scope.model.consumables;
  5492. // $scope.myData2all.push(selectedItem);
  5493. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5494. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5495. // }
  5496. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5497. $scope.myData2 = $scope.interceptMydata(
  5498. $scope.myData2all,
  5499. $scope.memoryfilterDatagui.idx,
  5500. 10
  5501. );
  5502. $scope.model.consumables = $scope.myData2all;
  5503. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5504. $scope.model.consumables;
  5505. });
  5506. };
  5507. $scope.interceptMydata = function (mydate, idx, sum) {
  5508. return mydate.slice(idx * sum, (idx + 1) * sum);
  5509. };
  5510. $scope.haocaiadd = function () {
  5511. event.preventDefault();
  5512. var modalInstance = $modal.open({
  5513. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5514. controller: function (
  5515. $scope,
  5516. scope,
  5517. $modalInstance,
  5518. api_wechatfile,
  5519. SweetAlert
  5520. ) {
  5521. $scope.haocainame = [];
  5522. $scope.pinpai = [];
  5523. $scope.guige = [];
  5524. $scope.consumptive = {};
  5525. $scope.consumptiveall = {};
  5526. $scope.title = "添加耗材";
  5527. api_wechatfile
  5528. .getDictionaryForList({
  5529. key: "haocaifenlei",
  5530. })
  5531. .then(function (data) {
  5532. $scope.haocainame = data;
  5533. });
  5534. $scope.clearNoNum = function (obj, attr) {
  5535. //先把非数字的都替换掉,除了数字和.
  5536. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5537. //必须保证第一个为数字而不是.
  5538. obj[attr] = obj[attr].replace(/^\./g, "");
  5539. //保证只有出现一个.而没有多个.
  5540. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5541. //保证.只出现一次,而不能出现两次以上
  5542. obj[attr] = obj[attr]
  5543. .replace(".", "$#$")
  5544. .replace(/\./g, "")
  5545. .replace("$#$", ".");
  5546. //小于最大值
  5547. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5548. alert(
  5549. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5550. );
  5551. obj[attr] = "";
  5552. }
  5553. };
  5554. $scope.onChange = function (parent) {
  5555. $scope.consumptive.model = {};
  5556. $scope.consumptive.Specifications = {};
  5557. api_wechatfile
  5558. .getDictionaryForList({
  5559. key: "pinpai",
  5560. parent: parent.id,
  5561. })
  5562. .then(function (data) {
  5563. $scope.pinpai = data;
  5564. });
  5565. api_wechatfile
  5566. .getDictionaryForList({
  5567. key: "guige",
  5568. parent: parent.id,
  5569. })
  5570. .then(function (data) {
  5571. $scope.guige = data;
  5572. });
  5573. };
  5574. // $scope.onChangesum = function(item) {
  5575. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5576. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5577. // $scope.consumptiveall = data1;
  5578. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5579. // // if (data.list && data.list.length != 0) {
  5580. // // var myData = data.list;
  5581. // // $scope.consumptiveall = myData[0];
  5582. // // $scope.maxsum = myData[0].inventoryNum;
  5583. // // } else if (data.list && data.list.length == 0) {
  5584. // // SweetAlert.swal({
  5585. // // title: "库存数据存在问题!",
  5586. // // text: "请检查库存数据!",
  5587. // // type: "error"
  5588. // // });
  5589. // // }
  5590. // // });
  5591. // }
  5592. // }
  5593. $scope.addhaocai = function () {
  5594. $modalInstance.dismiss("cancel");
  5595. scope.haocaiopen($scope.consumptive);
  5596. };
  5597. $scope.ok = function (item) {
  5598. var submittrue = true;
  5599. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5600. var data = {
  5601. modelid: item.model.id,
  5602. nameid: item.name.id,
  5603. Specificationsid: item.Specifications.id,
  5604. name: item.name.name,
  5605. model: item.model.name,
  5606. Specifications: item.Specifications.name,
  5607. sum: item.sum,
  5608. };
  5609. if (
  5610. item.name &&
  5611. item.model &&
  5612. JSON.stringify(item.model) != "{}" &&
  5613. item.Specifications &&
  5614. JSON.stringify(item.Specifications) != "{}" &&
  5615. item.sum
  5616. ) {
  5617. // $modalInstance.close(data);
  5618. angular.forEach(scope.myData2all, function (itemsdata) {
  5619. // if (item.model.id == itemsdata.id) {
  5620. if (
  5621. item.model.id == itemsdata.modelid &&
  5622. item.name.id == itemsdata.nameid &&
  5623. item.Specifications.id == itemsdata.Specificationsid
  5624. ) {
  5625. submittrue = false;
  5626. }
  5627. });
  5628. if (submittrue) {
  5629. $modalInstance.close(data);
  5630. } else {
  5631. SweetAlert.swal({
  5632. title: "该耗材已有添加",
  5633. text: "请检查数据然后提交!",
  5634. type: "error",
  5635. });
  5636. }
  5637. } else {
  5638. SweetAlert.swal({
  5639. title: "数据填写不完整!",
  5640. text: "请检查数据然后提交!",
  5641. type: "error",
  5642. });
  5643. }
  5644. };
  5645. $scope.cancel = function () {
  5646. $modalInstance.dismiss("cancel");
  5647. };
  5648. },
  5649. size: "sm",
  5650. resolve: {
  5651. scope: function () {
  5652. return $scope;
  5653. },
  5654. },
  5655. });
  5656. modalInstance.result.then(function (selectedItem) {
  5657. // $scope.myData2.push(selectedItem);
  5658. // for (var i = 0; i < $scope.myData2.length; i++) {
  5659. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5660. // }
  5661. // $scope.model.consumables = $scope.myData2;
  5662. $scope.myData2all.push(selectedItem);
  5663. for (var i = 0; i < $scope.myData2all.length; i++) {
  5664. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5665. $scope.myData2all[i]["item"] = i + 1;
  5666. }
  5667. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5668. $scope.myData2 = $scope.interceptMydata(
  5669. $scope.myData2all,
  5670. $scope.memoryfilterDatagui.idx,
  5671. 10
  5672. );
  5673. $scope.model.consumables = $scope.myData2all;
  5674. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5675. $scope.model.consumables;
  5676. });
  5677. };
  5678. $scope.onDblClick = function (data, event) {
  5679. $scope.selectButtonClick(data, event);
  5680. };
  5681. $scope.memoryfilterData = {
  5682. idx: 0,
  5683. sum: 20,
  5684. user: {
  5685. roledata: {
  5686. rolecode: "roleset",
  5687. },
  5688. selectType: "1",
  5689. },
  5690. };
  5691. $scope.myData = {};
  5692. $scope.loadData = function (filterData) { };
  5693. // $scope.title = title;
  5694. $scope.loadData({
  5695. idx: 0,
  5696. sum: 20,
  5697. user: {
  5698. roledata: {
  5699. rolecode: "roleset",
  5700. },
  5701. selectType: "1",
  5702. },
  5703. });
  5704. $scope.selected = {
  5705. items: {},
  5706. };
  5707. },
  5708. ],
  5709. });
  5710. //tab 列表
  5711. formlyConfigProvider.setType({
  5712. name: "ui-cmdbtab",
  5713. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5714. wrapper: ["bootstrapHasError"],
  5715. defaultOptions: function (options, $scope) {
  5716. return {
  5717. templateOptions: {},
  5718. };
  5719. },
  5720. controller: [
  5721. "$scope",
  5722. "api_user_data",
  5723. "i18nService",
  5724. "$modal",
  5725. "api_cmdb",
  5726. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5727. $scope.memoryfilterDatashe = {
  5728. idx: 0,
  5729. sum: 10,
  5730. };
  5731. $scope.myDataoneall = [];
  5732. var setAllInactive = function () {
  5733. angular.forEach($scope.workspaces, function (workspace) {
  5734. workspace.active = false;
  5735. });
  5736. };
  5737. //添加
  5738. var addNewWorkspace = function (name, contentUrl) {
  5739. var id = $scope.workspaces.length + 1;
  5740. $scope.workspaces.push({
  5741. id: id,
  5742. name: name,
  5743. active: true,
  5744. contentUrl: "main/html/content.html",
  5745. });
  5746. };
  5747. //关闭
  5748. $scope.remove = function (closedata) {
  5749. event.preventDefault();
  5750. angular.forEach($scope.workspaces, function (item, index) {
  5751. if (closedata.id == item.id) {
  5752. if (closedata.id == 1) {
  5753. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5754. } else {
  5755. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5756. }
  5757. $scope.workspaces.splice(index, 1);
  5758. }
  5759. });
  5760. };
  5761. $scope.workspaces = [];
  5762. $scope.options.templateOptions.getpush = function (item) {
  5763. $scope.workspaces = [];
  5764. if (item.gu) {
  5765. $scope.workspaces.push({
  5766. id: 1,
  5767. name: "领用设备",
  5768. active: true,
  5769. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5770. });
  5771. }
  5772. if (item.hao) {
  5773. $scope.workspaces.push({
  5774. id: 2,
  5775. name: "领用耗材",
  5776. active: true,
  5777. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5778. });
  5779. }
  5780. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5781. };
  5782. $scope.addWorkspace = function (contentUrl, name) {
  5783. setAllInactive();
  5784. addNewWorkspace(name, contentUrl);
  5785. };
  5786. // $rootScope.addWorkspace = $scope.addWorkspace;
  5787. // $scope.remove = function(idNumber) {
  5788. // var index = 0; //记录当前元素下标
  5789. // angular.forEach($scope.workspaces, function(workspace) {
  5790. // if (workspace.id === idNumber.id) {
  5791. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5792. // }
  5793. // index++;
  5794. // });
  5795. // };
  5796. // setInterval(function() {
  5797. // if ($scope.model.assets) {
  5798. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5799. // $scope.modelass = $scope.model.assets;
  5800. // if (JSON.stringify($scope.model.assets) == "{}") {
  5801. // $scope.model.assets = []
  5802. // } else {
  5803. // $scope.model.assets = JSON.parse($scope.model.assets);
  5804. // }
  5805. // $scope.myDatalingbeiall = $scope.model.assets;
  5806. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5807. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5808. // }
  5809. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5810. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5811. // }
  5812. // }
  5813. // if ($scope.model.consumables) {
  5814. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5815. // $scope.modelass = $scope.model.consumables;
  5816. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5817. // $scope.model.consumables = [];
  5818. // } else {
  5819. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5820. // }
  5821. // $scope.myDatalingbeiall = $scope.model.consumables;
  5822. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5823. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5824. // }
  5825. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5826. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5827. // // $scope.model.consumables = $scope.myData2all;
  5828. // }
  5829. // }
  5830. // }, 100);
  5831. //grid1
  5832. $scope.langs = i18nService.getAllLangs();
  5833. $scope.lang = "zh-cn";
  5834. i18nService.setCurrentLang($scope.lang);
  5835. $scope.gridOptions1 = {};
  5836. $scope.gridOptions1.data = "myDatalingbei";
  5837. $scope.gridOptions1.enableColumnResizing = true;
  5838. $scope.gridOptions1.enableFiltering = false;
  5839. $scope.gridOptions1.enableGridMenu = false;
  5840. $scope.gridOptions1.showGridFooter = true;
  5841. $scope.gridOptions1.showColumnFooter = false;
  5842. $scope.gridOptions1.fastWatch = true;
  5843. $scope.gridOptions1.useExternalFiltering = true;
  5844. $scope.gridOptions1.useExternalPagination = true;
  5845. $scope.gridOptions1.paginationPageSizes = [10];
  5846. $scope.gridOptions1.paginationPageSize = 10;
  5847. $scope.gridOptions1.multiSelect = false;
  5848. // $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>";
  5849. $scope.gridOptions1.columnDefs = [
  5850. {
  5851. name: "item",
  5852. displayName: "序号",
  5853. width: 120,
  5854. },
  5855. {
  5856. name: "props.hw_cifilterClassic",
  5857. displayName: "设备类型",
  5858. width: 150,
  5859. enableFiltering: false,
  5860. },
  5861. {
  5862. name: "props.hw_mingcheng",
  5863. displayName: "设备名称",
  5864. width: 100,
  5865. enableFiltering: false,
  5866. },
  5867. {
  5868. name: "uuid",
  5869. displayName: "设备编号",
  5870. enableFiltering: false,
  5871. },
  5872. ];
  5873. $scope.myDatalingbeiall = [];
  5874. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5875. $scope.gridApi = gridApi;
  5876. gridApi.pagination.on.paginationChanged(
  5877. $scope,
  5878. function (newPage, pageSize) {
  5879. // var filtersData = $scope.memoryfilterData;
  5880. // filtersData.idx = newPage - 1;
  5881. // filtersData.sum = pageSize;
  5882. // $scope.loadData(filtersData);
  5883. $scope.memoryfilterDatashe.idx = newPage - 1;
  5884. $scope.memoryfilterDatashe.sum = pageSize;
  5885. $scope.myDatalingbei = $scope.interceptMydata(
  5886. $scope.myDatalingbeiall,
  5887. $scope.memoryfilterDatashe.idx,
  5888. 10
  5889. );
  5890. }
  5891. );
  5892. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5893. $scope.selected.items = data.entity;
  5894. //console.log(data);
  5895. });
  5896. gridApi.selection.on.rowSelectionChangedBatch(
  5897. $scope,
  5898. function (data) {
  5899. $scope.selected.items = data.entity;
  5900. //console.log(data);
  5901. }
  5902. );
  5903. gridApi.core.on.filterChanged($scope, function () {
  5904. var grid = this.grid;
  5905. var filtersData = {
  5906. idx: 0,
  5907. sum: 20,
  5908. user: {
  5909. roledata: {
  5910. rolecode: "roleset",
  5911. },
  5912. selectType: "1",
  5913. },
  5914. };
  5915. angular.forEach(grid.columns, function (item) {
  5916. if (item.enableFiltering) {
  5917. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5918. if (
  5919. angular.isDefined(item.filters[0].term) &&
  5920. item.filters[0].term != ""
  5921. ) {
  5922. if (angular.isUndefined(filtersData["user"])) {
  5923. filtersData["user"] = {};
  5924. }
  5925. filtersData["user"][item.field] = item.filters[0].term;
  5926. }
  5927. }
  5928. });
  5929. $scope.memoryfilterDatashe = filtersData;
  5930. // $scope.loadData(filtersData);
  5931. });
  5932. };
  5933. $scope.interceptMydata = function (mydate, idx, sum) {
  5934. return mydate.slice(idx * sum, (idx + 1) * sum);
  5935. };
  5936. $scope.removeshebei = function (item) {
  5937. event.preventDefault();
  5938. var modalInstance = $modal.open({
  5939. templateUrl: "assets/views/delete.html",
  5940. controller: function ($scope, $modalInstance, scope) {
  5941. $scope.title = "设备移除";
  5942. $scope.connect = "确定要移除此设备?";
  5943. $scope.consumptive = scope.selected.items;
  5944. $scope.ok = function () {
  5945. $modalInstance.close($scope.consumptive);
  5946. };
  5947. $scope.cancel = function () {
  5948. $modalInstance.dismiss("cancel");
  5949. };
  5950. },
  5951. size: "sm",
  5952. resolve: {
  5953. scope: function () {
  5954. return $scope;
  5955. },
  5956. },
  5957. });
  5958. modalInstance.result.then(function (selectedItem) {
  5959. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5960. if (items.id == selectedItem.id) {
  5961. $scope.myDatalingbeiall.splice(index, 1);
  5962. }
  5963. });
  5964. // $scope.myData3.push(selectedItem);
  5965. $scope.model.consumables = $scope.myDatalingbeiall;
  5966. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5967. $scope.myDatalingbeiall;
  5968. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5970. $scope.myDatalingbeiall[i]["item"] =
  5971. i +
  5972. 1 +
  5973. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5974. }
  5975. $scope.myDatalingbei = $scope.interceptMydata(
  5976. $scope.myDatalingbeiall,
  5977. 0,
  5978. 10
  5979. );
  5980. });
  5981. };
  5982. $scope.addshebei = function () {
  5983. event.preventDefault();
  5984. var modalInstance = $modal.open({
  5985. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5986. controller: function (
  5987. $scope,
  5988. i18nService,
  5989. $modalInstance,
  5990. items,
  5991. title,
  5992. Restangular,
  5993. APIService,
  5994. onDataCallback,
  5995. parentScope,
  5996. api_configure_data,
  5997. api_configure_form
  5998. ) {
  5999. $scope.langs = i18nService.getAllLangs();
  6000. $scope.lang = "zh-cn";
  6001. i18nService.setCurrentLang($scope.lang);
  6002. $scope.gridOptions = {};
  6003. $scope.gridOptions.data = "myDatatwo";
  6004. $scope.gridOptions.enableColumnResizing = true;
  6005. $scope.gridOptions.enableFiltering = false;
  6006. $scope.gridOptions.enableGridMenu = false;
  6007. $scope.gridOptions.showGridFooter = true;
  6008. $scope.gridOptions.showColumnFooter = false;
  6009. $scope.gridOptions.fastWatch = true;
  6010. $scope.gridOptions.useExternalFiltering = true;
  6011. $scope.gridOptions.useExternalPagination = true;
  6012. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6013. $scope.gridOptions.paginationPageSize = 10;
  6014. $scope.gridOptions.multiSelect = true;
  6015. $scope.gridOptions.rowIdentity = function (row) {
  6016. return row.id;
  6017. };
  6018. $scope.gridOptions.getRowIdentity = function (row) {
  6019. return row.id;
  6020. };
  6021. // $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>";
  6022. $scope.gridOptions.columnDefs = [
  6023. {
  6024. name: "item",
  6025. displayName: "序号",
  6026. width: 80,
  6027. enableFiltering: false,
  6028. },
  6029. {
  6030. name: "uuid",
  6031. displayName: "内部编号",
  6032. width: 175,
  6033. },
  6034. {
  6035. name: "props.hw_mingcheng",
  6036. displayName: "资产名称",
  6037. width: 120,
  6038. },
  6039. {
  6040. name: "props.hw_cifilterClassic",
  6041. displayName: "资产类型",
  6042. width: 80,
  6043. enableFiltering: false,
  6044. },
  6045. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6046. {
  6047. name: "props.hw_state",
  6048. displayName: "资产状态",
  6049. width: 150,
  6050. enableFiltering: false,
  6051. },
  6052. {
  6053. name: "props.hwnw_area",
  6054. displayName: "资产地点",
  6055. width: 130,
  6056. enableFiltering: false,
  6057. },
  6058. {
  6059. name: "createtime",
  6060. displayName: "申请时间",
  6061. enableFiltering: false,
  6062. },
  6063. ];
  6064. // $scope.selectButtonClick
  6065. var defaultFilterData = {
  6066. // "assignee":2,
  6067. // "sign":"basehwitndl",
  6068. // "applicationForm": { "hw_state": "在线" },
  6069. hw_state: "在库",
  6070. idx: 0,
  6071. sum: 10,
  6072. };
  6073. $scope.memoryfilterData = {
  6074. // "assignee":2,
  6075. // "sign":"basehwitndl",
  6076. // "applicationForm": { "hw_state": "在线" },
  6077. hw_state: "在库",
  6078. idx: 0,
  6079. sum: 10,
  6080. };
  6081. $scope.refreshData = function (style, filterData) {
  6082. if (angular.isUndefined(filterData)) {
  6083. filterData = defaultFilterData;
  6084. }
  6085. $scope.myDatatwo = [];
  6086. // $scope.gridOptions['sum']=filterData.sum;
  6087. api_cmdb.query(filterData).then(
  6088. function (data) {
  6089. // $scope.callsPending--;
  6090. var filterData = $scope.memoryfilterData;
  6091. var myDatatwo = Restangular.stripRestangular(data);
  6092. $scope.gridOptions["totalItems"] = data.total;
  6093. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6094. myDatatwo.data.node[i].createtime = moment(
  6095. myDatatwo.data.node[i].createtime
  6096. ).format("YYYY-MM-DD");
  6097. }
  6098. $scope.myDatatwo = myDatatwo.data.node;
  6099. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6100. $scope.myDatatwo[i]["item"] =
  6101. i + 1 + filterData.idx * filterData.sum;
  6102. }
  6103. },
  6104. function () { }
  6105. );
  6106. };
  6107. $scope.refreshData("expand-right", defaultFilterData);
  6108. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6109. $scope.gridApi = gridApi;
  6110. gridApi.pagination.on.paginationChanged(
  6111. $scope,
  6112. function (newPage, pageSize) {
  6113. var filtersData = $scope.memoryfilterData;
  6114. filtersData.idx = newPage - 1;
  6115. filtersData.sum = pageSize;
  6116. // $scope.loadData(filtersData);
  6117. $scope.refreshData("expand-right", filtersData);
  6118. //console.log(pageSize);
  6119. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6120. }
  6121. );
  6122. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6123. // $scope.selected.items.push(data.entity);
  6124. //console.log(data);
  6125. gridApi.selection.on.rowSelectionChanged(
  6126. $scope,
  6127. function (scope, ect) {
  6128. if (scope.isSelected) {
  6129. scope.grid.appScope.selected.items.push(scope.entity);
  6130. } else {
  6131. for (
  6132. var i = 0;
  6133. i <= scope.grid.appScope.selected.items.length;
  6134. i++
  6135. ) {
  6136. if (
  6137. scope.grid.appScope.selected.items[i].id ==
  6138. scope.entity.id
  6139. ) {
  6140. scope.grid.appScope.selected.items.splice(i, 1);
  6141. break;
  6142. }
  6143. }
  6144. }
  6145. $scope.mySelectedRows =
  6146. $scope.gridApi.selection.getSelectedRows();
  6147. }
  6148. );
  6149. // });
  6150. gridApi.selection.on.rowSelectionChangedBatch(
  6151. $scope,
  6152. function (rows) {
  6153. // $scope.selected.items = data.entity;
  6154. //console.log(data);
  6155. var selectitem = [];
  6156. selectitem = angular.copy($scope.selected.items);
  6157. for (var j = 0; j < rows.length; j++) {
  6158. if (rows[j].isSelected == true) {
  6159. selectitem.push(rows[j].entity);
  6160. } else {
  6161. delete selectitem[j];
  6162. // rows.splice(j, 1);
  6163. }
  6164. }
  6165. $scope.selected.items = [];
  6166. for (var i = 0; i < selectitem.length; i++) {
  6167. if (selectitem[i]) {
  6168. $scope.selected.items.push(selectitem[i]);
  6169. }
  6170. }
  6171. }
  6172. );
  6173. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6174. // // if (row.entity.age > 45) {
  6175. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6176. // // }
  6177. // };
  6178. gridApi.core.on.filterChanged($scope, function () {
  6179. var grid = this.grid;
  6180. var filtersData = {
  6181. idx: 0,
  6182. sum: 10,
  6183. user: {
  6184. roledata: {
  6185. rolecode: "roleset",
  6186. },
  6187. selectType: "1",
  6188. },
  6189. };
  6190. angular.forEach(grid.columns, function (item) {
  6191. if (item.enableFiltering) {
  6192. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6193. if (
  6194. angular.isDefined(item.filters[0].term) &&
  6195. item.filters[0].term != ""
  6196. ) {
  6197. if (angular.isUndefined(filtersData["user"])) {
  6198. filtersData["user"] = {};
  6199. }
  6200. filtersData["user"][item.field] = item.filters[0].term;
  6201. }
  6202. }
  6203. });
  6204. $scope.memoryfilterData = filtersData;
  6205. // $scope.loadData(filtersData);
  6206. });
  6207. };
  6208. $scope.onDblClick = function (data, event) {
  6209. // $scope.selected.items = data.entity;
  6210. $scope.selectButtonClick(data, event);
  6211. };
  6212. // $scope.loadData = function(filterData) {
  6213. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6214. // items.fetchItems(filterData, APIService).then(function(data) {
  6215. // var myDatatwo = Restangular.stripRestangular(data);
  6216. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6217. // $scope.myDatatwo = myDatatwo.list;
  6218. // });
  6219. // };
  6220. $scope.title = title;
  6221. //树形图
  6222. var apple_selected, tree, treedata_avm, treedata_geography;
  6223. $scope.my_tree_handler = function (branch) {
  6224. //var _ref;
  6225. var classify = ($scope.classify =
  6226. branch.prefix.toLowerCase() + branch.sign);
  6227. api_cmdb
  6228. .query({
  6229. sign: classify,
  6230. })
  6231. .then(function (data) {
  6232. var myDatalingbei = Restangular.stripRestangular(data);
  6233. // console.log(myData.data.node);
  6234. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6235. var ret = myDatalingbei.data;
  6236. redrawSvg(myDatalingbei);
  6237. }
  6238. });
  6239. };
  6240. $scope.my_data = [];
  6241. function convertListToTree(data, treeMap) {
  6242. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6243. var root = null; //Initially set our loop to null
  6244. var parentNode = null;
  6245. //loop over data
  6246. for (var i = 0; i < data.length; i++) {
  6247. var datum = data[i];
  6248. //each node will have children, so let's give it a "children" poperty
  6249. datum.children = [];
  6250. //add an entry for this node to the map so that any future children can
  6251. //lookup the parent
  6252. idToNodeMap[datum.id] = datum;
  6253. //Does this node have a parent?
  6254. if (
  6255. typeof datum.parent === "undefined" ||
  6256. datum.parent == null
  6257. ) {
  6258. //Doesn't look like it, so this node is the root of the tree
  6259. root = datum;
  6260. treeMap[datum.id] = root;
  6261. } else {
  6262. //This node has a parent, so let's look it up using the id
  6263. parentNode = idToNodeMap[datum.parent.id];
  6264. //We don't need this property, so let's delete it.
  6265. delete datum.parent;
  6266. //Let's add the current node as a child of the parent node.
  6267. parentNode.children.push(datum);
  6268. }
  6269. }
  6270. return root;
  6271. }
  6272. function convertParentToChildList(data) {
  6273. var treeMap = {};
  6274. var list = [];
  6275. convertListToTree(data, treeMap);
  6276. angular.forEach(treeMap, function (item) {
  6277. list.push(item);
  6278. });
  6279. return list;
  6280. }
  6281. $scope.my_tree = tree = {};
  6282. $scope.try_async_load = function () {
  6283. $scope.my_data = [];
  6284. $scope.select_treedata = [];
  6285. $scope.doing_async = true;
  6286. api_configure_data
  6287. .fetchDataList("ciclassify", {
  6288. idx: 0,
  6289. sum: 100,
  6290. })
  6291. .then(function (result) {
  6292. //console.log(result['list']);
  6293. $scope.select_treedata = $scope.my_data =
  6294. convertParentToChildList(result["list"]);
  6295. $scope.doing_async = false;
  6296. // tree.expand_all();
  6297. //console.log(treelist);
  6298. });
  6299. };
  6300. $scope.select_treedata = [];
  6301. $scope.propTypeOptions = [];
  6302. $scope.try_async_load();
  6303. $scope.onFilterremove = function (item) {
  6304. console.log(item);
  6305. };
  6306. $scope.searchdata = {};
  6307. $scope.clear = function () {
  6308. $scope.searchdata = {};
  6309. $scope.cifilter_classic = {};
  6310. $scope.try_async_load();
  6311. var fildata = {
  6312. idx: 0,
  6313. sum: 10,
  6314. hw_state: "在库",
  6315. };
  6316. $scope.memoryfilterData = fildata;
  6317. $scope.refreshData("expand-right", fildata);
  6318. };
  6319. $scope.cifilter_classic = {};
  6320. $scope.chiceIncident = function (item) {
  6321. var fildata = defaultFilterData;
  6322. // fildata.applicationForm = {};
  6323. // sign: basehwnwswt
  6324. if (item && item.id) {
  6325. var classify = item.prefix.toLowerCase() + item.sign;
  6326. fildata.sign = classify;
  6327. } else {
  6328. delete fildata.sign;
  6329. }
  6330. $scope.gridOptions.paginationCurrentPage = 1;
  6331. var transitiondata = angular.copy(item);
  6332. $scope.refreshData("expand-right", fildata);
  6333. };
  6334. $scope.applicadata = [];
  6335. $scope.onFilterCallback = function (item) {
  6336. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6337. api_configure_form
  6338. .renderTabForm(tempclassify)
  6339. .then(function (data) {
  6340. var myData = Restangular.stripRestangular(data);
  6341. $scope.applicadata = myData[0].form.fields;
  6342. });
  6343. // }
  6344. };
  6345. // $scope.loadData({
  6346. // idx: 0,
  6347. // sum: 10,
  6348. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6349. // });
  6350. $scope.selected = {
  6351. items: [],
  6352. };
  6353. $scope.ok = function () {
  6354. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6355. // onDataCallback($scope.selected.item, parentScope);
  6356. // }
  6357. $modalInstance.close($scope.selected.items);
  6358. };
  6359. $scope.cancel = function () {
  6360. $modalInstance.dismiss("cancel");
  6361. };
  6362. },
  6363. size: "lg",
  6364. resolve: {
  6365. items: function () {
  6366. return {
  6367. fetchItems: function (filterData, APIService) {
  6368. filterData = filterData || {};
  6369. if (
  6370. angular.isDefined(filterData.idx) &&
  6371. filterData.idx == null
  6372. ) {
  6373. filterData = {
  6374. idx: 0,
  6375. sum: 10,
  6376. user: {
  6377. roledata: {
  6378. rolecode: "roleset",
  6379. },
  6380. selectType: "1",
  6381. },
  6382. };
  6383. }
  6384. return $scope.options.templateOptions.fetchItems(
  6385. filterData,
  6386. APIService
  6387. );
  6388. },
  6389. };
  6390. },
  6391. title: function () {
  6392. return $scope.options.templateOptions.label;
  6393. },
  6394. Restangular: function () {
  6395. return $scope.options.templateOptions.Restangular;
  6396. },
  6397. APIService: function () {
  6398. return $scope.options.templateOptions.ApiService;
  6399. },
  6400. onDataCallback: function () {
  6401. return $scope.options.templateOptions.callback;
  6402. },
  6403. parentScope: function () {
  6404. return $scope.options.templateOptions.that;
  6405. },
  6406. },
  6407. });
  6408. modalInstance.result.then(
  6409. function (selectedItem) {
  6410. // console.log(selectedItem);
  6411. // options.value(selectedItem);
  6412. var filterData = $scope.memoryfilterDatashe;
  6413. $scope.myDatalingbeiall = selectedItem;
  6414. $scope.gridOptions1["totalItems"] =
  6415. $scope.myDatalingbeiall.length;
  6416. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6417. $scope.myDatalingbeiall[i]["item"] =
  6418. i + 1 + filterData.idx * filterData.sum;
  6419. }
  6420. $scope.myDatalingbei = $scope.interceptMydata(
  6421. $scope.myDatalingbeiall,
  6422. 0,
  6423. 10
  6424. );
  6425. $scope.model.assets = $scope.myDatalingbeiall;
  6426. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6427. $scope.myDatalingbeiall;
  6428. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6429. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6430. // }
  6431. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6432. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6433. // }
  6434. },
  6435. function () {
  6436. //console.log('Modal dismissed at: ' + new Date());
  6437. }
  6438. );
  6439. };
  6440. $scope.onDblClick = function (data, event) {
  6441. $scope.selectButtonClick(data, event);
  6442. };
  6443. // $scope.loadData = function(filterData) {};
  6444. // $scope.title = title;
  6445. // $scope.loadData({
  6446. // idx: 0,
  6447. // sum: 20,
  6448. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6449. // });
  6450. $scope.selected = {
  6451. items: [],
  6452. };
  6453. //grid2
  6454. $scope.langs = i18nService.getAllLangs();
  6455. $scope.lang = "zh-cn";
  6456. i18nService.setCurrentLang($scope.lang);
  6457. $scope.gridOptions2 = {};
  6458. $scope.gridOptions2.data = "myDataone";
  6459. $scope.gridOptions2.enableColumnResizing = true;
  6460. $scope.gridOptions2.enableFiltering = false;
  6461. $scope.gridOptions2.enableGridMenu = false;
  6462. $scope.gridOptions2.showGridFooter = true;
  6463. $scope.gridOptions2.showColumnFooter = false;
  6464. $scope.gridOptions2.fastWatch = true;
  6465. $scope.gridOptions2.useExternalFiltering = true;
  6466. $scope.gridOptions2.useExternalPagination = true;
  6467. $scope.gridOptions2.paginationPageSizes = [10];
  6468. $scope.gridOptions2.paginationPageSize = 10;
  6469. $scope.gridOptions2.multiSelect = false;
  6470. // $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>";
  6471. $scope.gridOptions2.columnDefs = [
  6472. {
  6473. name: "item",
  6474. displayName: "序号",
  6475. width: 120,
  6476. },
  6477. {
  6478. name: "name",
  6479. displayName: "耗材名称",
  6480. width: 150,
  6481. enableFiltering: false,
  6482. },
  6483. {
  6484. name: "model",
  6485. displayName: "品牌/型号",
  6486. width: 100,
  6487. enableFiltering: false,
  6488. },
  6489. {
  6490. name: "Specifications",
  6491. displayName: "规格",
  6492. width: 150,
  6493. enableFiltering: false,
  6494. },
  6495. {
  6496. name: "sum",
  6497. displayName: "领用数量",
  6498. enableFiltering: false,
  6499. },
  6500. ];
  6501. // $scope.selectButtonClick
  6502. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6503. $scope.gridApi = gridApi;
  6504. gridApi.pagination.on.paginationChanged(
  6505. $scope,
  6506. function (newPage, pageSize) {
  6507. // var filtersData = $scope.memoryfilterData;
  6508. // filtersData.idx = newPage - 1;
  6509. // filtersData.sum = pageSize;
  6510. // $scope.loadData(filtersData);
  6511. $scope.memoryfilterDatahao.idx = newPage - 1;
  6512. $scope.memoryfilterDatahao.sum = pageSize;
  6513. $scope.myDataone = $scope.interceptMydata(
  6514. $scope.myDataoneall,
  6515. $scope.memoryfilterDatahao.idx,
  6516. 10
  6517. );
  6518. }
  6519. );
  6520. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6521. $scope.selected.items.push(data.entity);
  6522. //console.log(data);
  6523. });
  6524. gridApi.selection.on.rowSelectionChangedBatch(
  6525. $scope,
  6526. function (data) {
  6527. $scope.selected.items.push(data.entity);
  6528. //console.log(data);
  6529. }
  6530. );
  6531. gridApi.core.on.filterChanged($scope, function () {
  6532. var grid = this.grid;
  6533. var filtersData = {
  6534. idx: 0,
  6535. sum: 10,
  6536. user: {
  6537. roledata: {
  6538. rolecode: "roleset",
  6539. },
  6540. selectType: "1",
  6541. },
  6542. };
  6543. angular.forEach(grid.columns, function (item) {
  6544. if (item.enableFiltering) {
  6545. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6546. if (
  6547. angular.isDefined(item.filters[0].term) &&
  6548. item.filters[0].term != ""
  6549. ) {
  6550. if (angular.isUndefined(filtersData["user"])) {
  6551. filtersData["user"] = {};
  6552. }
  6553. filtersData["user"][item.field] = item.filters[0].term;
  6554. }
  6555. }
  6556. });
  6557. $scope.memoryfilterDatahao = filtersData;
  6558. $scope.loadData(filtersData);
  6559. });
  6560. };
  6561. $scope.removehaocai = function (item) {
  6562. event.preventDefault();
  6563. // var modalInstance = $modal.open({
  6564. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6565. // controller: function($scope, $modalInstance) {
  6566. // $scope.title = "修改耗材数量";
  6567. // $scope.consumptive = item;
  6568. // $scope.ok = function() {
  6569. // $modalInstance.close($scope.consumptive);
  6570. // };
  6571. // $scope.cancel = function() {
  6572. // $modalInstance.dismiss('cancel');
  6573. // };
  6574. // },
  6575. // size: 'sm'
  6576. // });
  6577. var modalInstance = $modal.open({
  6578. templateUrl: "assets/views/delete.html",
  6579. controller: function ($scope, $modalInstance, scope) {
  6580. $scope.title = "耗材移除";
  6581. $scope.connect = "确定要移除此设备?";
  6582. $scope.consumptive = scope.selected.items[0];
  6583. $scope.ok = function () {
  6584. $modalInstance.close($scope.consumptive);
  6585. };
  6586. $scope.cancel = function () {
  6587. $modalInstance.dismiss("cancel");
  6588. };
  6589. },
  6590. size: "sm",
  6591. resolve: {
  6592. scope: function () {
  6593. return $scope;
  6594. },
  6595. },
  6596. });
  6597. modalInstance.result.then(function (selectedItem) {
  6598. // angular.forEach($scope.myData3, function(items, index) {
  6599. // if (items.id == selectedItem.id) {
  6600. // $scope.myData3[index] = selectedItem;
  6601. // }
  6602. // })
  6603. // $scope.model.applicationForm.consumables = $scope.myData3;
  6604. angular.forEach($scope.myDataoneall, function (items, index) {
  6605. if (items.id == selectedItem.id) {
  6606. $scope.myDataoneall.splice(index, 1);
  6607. }
  6608. });
  6609. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6610. $scope.myDataoneall[i]["item"] =
  6611. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6612. }
  6613. $scope.myDataone = $scope.interceptMydata(
  6614. $scope.myDataoneall,
  6615. 0,
  6616. 10
  6617. );
  6618. $scope.model.consumables = $scope.myDataoneall;
  6619. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6620. $scope.myDataoneall;
  6621. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6622. $scope.selected = {
  6623. items: [],
  6624. };
  6625. });
  6626. };
  6627. $scope.haocaiadd = function () {
  6628. event.preventDefault();
  6629. var modalInstance = $modal.open({
  6630. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6631. controller: function (
  6632. $scope,
  6633. scope,
  6634. $modalInstance,
  6635. api_wechatfile,
  6636. SweetAlert,
  6637. api_cmdb3
  6638. ) {
  6639. $scope.haocainame = [];
  6640. $scope.pinpai = [];
  6641. $scope.guige = [];
  6642. $scope.consumptive = {};
  6643. $scope.consumpall = {};
  6644. $scope.title = "添加耗材";
  6645. api_wechatfile
  6646. .getDictionaryForList({
  6647. key: "haocaifenlei",
  6648. })
  6649. .then(function (data) {
  6650. $scope.haocainame = data;
  6651. });
  6652. $scope.clearNoNum = function (obj, attr) {
  6653. //先把非数字的都替换掉,除了数字和.
  6654. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6655. //必须保证第一个为数字而不是.
  6656. obj[attr] = obj[attr].replace(/^\./g, "");
  6657. //保证只有出现一个.而没有多个.
  6658. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6659. //保证.只出现一次,而不能出现两次以上
  6660. obj[attr] = obj[attr]
  6661. .replace(".", "$#$")
  6662. .replace(/\./g, "")
  6663. .replace("$#$", ".");
  6664. //小于最大值
  6665. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6666. alert(
  6667. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6668. );
  6669. obj[attr] = "";
  6670. }
  6671. };
  6672. $scope.onChange = function (parent) {
  6673. $scope.consumptive.model = {};
  6674. $scope.consumptive.Specifications = {};
  6675. api_wechatfile
  6676. .getDictionaryForList({
  6677. key: "pinpai",
  6678. parent: parent.id,
  6679. })
  6680. .then(function (data) {
  6681. $scope.pinpai = data;
  6682. });
  6683. api_wechatfile
  6684. .getDictionaryForList({
  6685. key: "guige",
  6686. parent: parent.id,
  6687. })
  6688. .then(function (data) {
  6689. $scope.guige = data;
  6690. });
  6691. };
  6692. $scope.onChangesum = function (item) {
  6693. if (item.name && item.model.id && item.Specifications.id) {
  6694. $scope.consumptive.sum = "";
  6695. var data1 = {
  6696. idx: 0,
  6697. sum: 10,
  6698. consumable: {
  6699. name: item.name.name,
  6700. brandModel: item.model.name,
  6701. specification: item.Specifications.name,
  6702. },
  6703. };
  6704. api_cmdb3
  6705. .fetchDataList("consumable", data1)
  6706. .then(function (data) {
  6707. if (data.status == 200 && data.list.length > 0) {
  6708. var myData = data.list;
  6709. $scope.consumpall = myData[0];
  6710. $scope.maxsum = myData[0].inventoryNum;
  6711. } else {
  6712. SweetAlert.swal({
  6713. title: "不存在该耗材",
  6714. text: "请检查库存后重新填写!",
  6715. type: "error",
  6716. });
  6717. }
  6718. });
  6719. }
  6720. };
  6721. $scope.addhaocai = function () {
  6722. $modalInstance.dismiss("cancel");
  6723. scope.haocaiopen($scope.consumptive);
  6724. };
  6725. $scope.ok = function (item) {
  6726. var items = {};
  6727. // if (item.name && item.model && item.Specifications && item.sum) {
  6728. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6729. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6730. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6731. // $scope.consumpall.sum = item.sum;
  6732. // delete $scope.consumpall.brandModel;
  6733. // delete $scope.consumpall.specification;
  6734. // $modalInstance.close($scope.consumpall);
  6735. // } else {
  6736. // SweetAlert.swal({
  6737. // title: "数据填写不完整!",
  6738. // text: "请检查数据然后提交!",
  6739. // type: "error"
  6740. // });
  6741. // }
  6742. var isold = false;
  6743. if (
  6744. item.name &&
  6745. item.model &&
  6746. JSON.stringify(item.model) != "{}" &&
  6747. item.Specifications &&
  6748. JSON.stringify(item.Specifications) != "{}" &&
  6749. item.sum
  6750. ) {
  6751. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6752. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6753. isold = true;
  6754. }
  6755. }
  6756. if (isold) {
  6757. SweetAlert.swal({
  6758. title: "该耗材已添加!",
  6759. text: "请不要重复添加耗材!",
  6760. type: "error",
  6761. });
  6762. } else {
  6763. $scope.consumpall.model = $scope.consumpall.brandModel;
  6764. $scope.consumpall.Specifications =
  6765. $scope.consumpall.specification;
  6766. $scope.consumpall.sum = item.sum;
  6767. delete $scope.consumpall.brandModel;
  6768. delete $scope.consumpall.specification;
  6769. $modalInstance.close($scope.consumpall);
  6770. }
  6771. } else {
  6772. SweetAlert.swal({
  6773. title: "数据填写不完整!",
  6774. text: "请检查数据然后提交!",
  6775. type: "error",
  6776. });
  6777. }
  6778. // $modalInstance.close(item);
  6779. };
  6780. $scope.cancel = function () {
  6781. $modalInstance.dismiss("cancel");
  6782. };
  6783. },
  6784. size: "sm",
  6785. resolve: {
  6786. scope: function () {
  6787. return $scope;
  6788. },
  6789. },
  6790. });
  6791. modalInstance.result.then(function (selectedItem) {
  6792. $scope.myDataoneall.push(selectedItem);
  6793. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6794. $scope.myDataoneall[i]["item"] =
  6795. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6796. }
  6797. // $scope.model.consumables = $scope.myDataone;
  6798. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6799. $scope.myDataone = $scope.interceptMydata(
  6800. $scope.myDataoneall,
  6801. 0,
  6802. 10
  6803. );
  6804. $scope.model.consumables = $scope.myDataoneall;
  6805. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6806. $scope.myDataoneall;
  6807. });
  6808. };
  6809. $scope.onDblClick = function (data, event) {
  6810. $scope.selectButtonClick(data, event);
  6811. };
  6812. $scope.memoryfilterDatahao = {
  6813. idx: 0,
  6814. sum: 10,
  6815. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6816. };
  6817. $scope.myDataone = [];
  6818. $scope.loadData = function (filterData) { };
  6819. // $scope.title = title;
  6820. $scope.ldloading = {};
  6821. $scope.selected = {
  6822. items: [],
  6823. };
  6824. if ($scope.$parent.$parent.$parent.model.gettype) {
  6825. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6826. if ($scope.model.assets) {
  6827. if (JSON.stringify($scope.model.assets) == "{}") {
  6828. $scope.model.assets = [];
  6829. } else {
  6830. $scope.model.assets = JSON.parse($scope.model.assets);
  6831. }
  6832. $scope.myDatalingbeiall = $scope.model.assets;
  6833. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6834. $scope.myDatalingbeiall[i]["item"] =
  6835. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6836. }
  6837. $scope.gridOptions1["totalItems"] =
  6838. $scope.myDatalingbeiall.length;
  6839. $scope.myDatalingbei = $scope.interceptMydata(
  6840. $scope.myDatalingbeiall,
  6841. 0,
  6842. 10
  6843. );
  6844. }
  6845. if ($scope.model.consumables) {
  6846. if (JSON.stringify($scope.model.consumables) == "{}") {
  6847. $scope.model.consumables = [];
  6848. } else {
  6849. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6850. }
  6851. $scope.myDataoneall = $scope.model.consumables;
  6852. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6853. $scope.myDataoneall[i]["item"] =
  6854. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6855. }
  6856. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6857. $scope.myDataone = $scope.interceptMydata(
  6858. $scope.myDataoneall,
  6859. 0,
  6860. 10
  6861. );
  6862. }
  6863. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6864. $scope.options.templateOptions.getpush({
  6865. hao: true,
  6866. gu: true,
  6867. });
  6868. } else {
  6869. $scope.options.templateOptions.getpush({
  6870. hao: true,
  6871. });
  6872. }
  6873. } else {
  6874. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6875. $scope.options.templateOptions.getpush({
  6876. gu: true,
  6877. });
  6878. }
  6879. }
  6880. }
  6881. },
  6882. ],
  6883. });
  6884. formlyConfigProvider.setType({
  6885. name: "ui-panel",
  6886. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6887. });
  6888. formlyConfigProvider.setType({
  6889. name: "ui-currentuser",
  6890. extends: "input",
  6891. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6892. defaultOptions: function (options) {
  6893. return {
  6894. templateOptions: {
  6895. // link: function() {}
  6896. },
  6897. };
  6898. },
  6899. controller: [
  6900. "$scope",
  6901. function ($scope) {
  6902. if ($scope.options.templateOptions.user) {
  6903. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6904. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6905. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6906. // }
  6907. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6908. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6909. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6910. }
  6911. $scope.model[$scope.options.key] =
  6912. $scope.options.templateOptions.user;
  6913. $scope.options.initialValue = $scope.model[$scope.options.key];
  6914. }
  6915. },
  6916. ],
  6917. });
  6918. //仪表盘
  6919. //待处理变更列表
  6920. formlyConfigProvider.setType({
  6921. name: "ui-ngpchangetable",
  6922. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6923. defaultOptions: function (options) {
  6924. return {
  6925. templateOptions: {
  6926. // relationAction: function() {
  6927. // options.hideExpression = true
  6928. // }
  6929. },
  6930. };
  6931. },
  6932. controller: [
  6933. "$scope",
  6934. "$modal",
  6935. "$timeout",
  6936. "SweetAlert",
  6937. "api_bpm_domain",
  6938. "$rootScope",
  6939. "ngTableParams",
  6940. "$filter",
  6941. "$state",
  6942. function (
  6943. $scope,
  6944. $modal,
  6945. $timeout,
  6946. SweetAlert,
  6947. api_bpm_domain,
  6948. $rootScope,
  6949. ngTableParams,
  6950. $filter,
  6951. $state
  6952. ) {
  6953. // var filterData = {
  6954. // "assignee": $rootScope.user.id,
  6955. // "searchtype": "all",
  6956. // "idx": "0",
  6957. // "sum": "10"
  6958. // };
  6959. var filterData = {
  6960. idx: "0",
  6961. sum: "10",
  6962. assignee: 2,
  6963. searchType: "todo",
  6964. };
  6965. $scope.incidentprocess = function (item) {
  6966. $state.go("app.wt_change.add", {
  6967. taskId: item.taskId,
  6968. processInstanceId: item.processInstanceId,
  6969. });
  6970. };
  6971. $scope.more = function () {
  6972. $state.go("app.wt_change.list", {});
  6973. };
  6974. api_bpm_domain
  6975. .fetchtask("bpm_change", filterData)
  6976. .then(function (data) {
  6977. if (data.data) {
  6978. $scope.myData = data.data;
  6979. } else {
  6980. SweetAlert.swal({
  6981. title: "操作异常!",
  6982. text: "系统异常,请稍后重试,或者联系管理员!",
  6983. type: "error",
  6984. });
  6985. }
  6986. });
  6987. $scope.removes = function () {
  6988. var modalInstance = $modal.open({
  6989. templateUrl: "assets/views/delete.html",
  6990. controller: function ($scope, $modalInstance) {
  6991. $scope.ok = function () {
  6992. $modalInstance.close();
  6993. };
  6994. $scope.cancel = function () {
  6995. $modalInstance.dismiss("cancel");
  6996. };
  6997. },
  6998. size: "sm",
  6999. });
  7000. modalInstance.result.then(function () {
  7001. console.log($scope.$parent.$parent.$parent.$parent);
  7002. for (
  7003. var i = 0;
  7004. i <
  7005. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7006. i++
  7007. ) {
  7008. if (
  7009. $scope.fields.type ==
  7010. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7011. .type
  7012. ) {
  7013. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7014. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7015. i,
  7016. 1
  7017. );
  7018. break;
  7019. }
  7020. }
  7021. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7022. if (vmForm) {
  7023. //console.log("vmForm>>>");//console.log(vmForm);
  7024. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7025. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7026. }
  7027. });
  7028. };
  7029. },
  7030. ],
  7031. });
  7032. //待处理问题列表
  7033. formlyConfigProvider.setType({
  7034. name: "ui-ngproblemtable",
  7035. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7036. defaultOptions: function (options) {
  7037. return {
  7038. templateOptions: {
  7039. // relationAction: function() {
  7040. // options.hideExpression = true
  7041. // }
  7042. },
  7043. };
  7044. },
  7045. controller: [
  7046. "$scope",
  7047. "$modal",
  7048. "$timeout",
  7049. "SweetAlert",
  7050. "api_bpm_data",
  7051. "$rootScope",
  7052. "ngTableParams",
  7053. "$filter",
  7054. "$state",
  7055. function (
  7056. $scope,
  7057. $modal,
  7058. $timeout,
  7059. SweetAlert,
  7060. api_bpm_data,
  7061. $rootScope,
  7062. ngTableParams,
  7063. $filter,
  7064. $state
  7065. ) {
  7066. var filterData = {
  7067. assignee: $rootScope.user.id,
  7068. candidateGroups: $rootScope.user.group[0].id,
  7069. searchtype: "todo",
  7070. idx: 0,
  7071. sum: 10,
  7072. };
  7073. $scope.incidentprocess = function (item) {
  7074. $state.go("app.wt_change.add", {
  7075. taskId: item.taskId,
  7076. processInstanceId: item.processInstanceId,
  7077. });
  7078. };
  7079. $scope.more = function () {
  7080. $state.go("app.wt_change.list", {});
  7081. };
  7082. api_bpm_data
  7083. .fetchDataList("changeclassify", filterData)
  7084. .then(function (data) {
  7085. if (data.data) {
  7086. $scope.myData = data.data;
  7087. } else {
  7088. SweetAlert.swal({
  7089. title: "操作异常!",
  7090. text: "系统异常,请稍后重试,或者联系管理员!",
  7091. type: "error",
  7092. });
  7093. }
  7094. });
  7095. $scope.removes = function () {
  7096. var modalInstance = $modal.open({
  7097. templateUrl: "assets/views/delete.html",
  7098. controller: function ($scope, $modalInstance) {
  7099. $scope.ok = function () {
  7100. $modalInstance.close();
  7101. };
  7102. $scope.cancel = function () {
  7103. $modalInstance.dismiss("cancel");
  7104. };
  7105. },
  7106. size: "sm",
  7107. });
  7108. modalInstance.result.then(function () {
  7109. console.log($scope.$parent.$parent.$parent.$parent);
  7110. for (
  7111. var i = 0;
  7112. i <
  7113. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7114. i++
  7115. ) {
  7116. if (
  7117. $scope.fields.type ==
  7118. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7119. .type
  7120. ) {
  7121. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7122. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7123. i,
  7124. 1
  7125. );
  7126. break;
  7127. }
  7128. }
  7129. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7130. if (vmForm) {
  7131. //console.log("vmForm>>>");//console.log(vmForm);
  7132. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7133. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7134. }
  7135. });
  7136. };
  7137. },
  7138. ],
  7139. });
  7140. //待处理事件列表
  7141. formlyConfigProvider.setType({
  7142. name: "ui-ngtable",
  7143. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7144. defaultOptions: function (options) {
  7145. return {
  7146. templateOptions: {
  7147. // relationAction: function() {
  7148. // options.hideExpression = true
  7149. // }
  7150. },
  7151. };
  7152. },
  7153. controller: [
  7154. "$scope",
  7155. "$modal",
  7156. "$timeout",
  7157. "SweetAlert",
  7158. "api_bpm_domain",
  7159. "$rootScope",
  7160. "ngTableParams",
  7161. "$filter",
  7162. "$state",
  7163. function (
  7164. $scope,
  7165. $modal,
  7166. $timeout,
  7167. SweetAlert,
  7168. api_bpm_domain,
  7169. $rootScope,
  7170. ngTableParams,
  7171. $filter,
  7172. $state
  7173. ) {
  7174. var filterData = {
  7175. assignee: $rootScope.user.id,
  7176. candidateGroups: $rootScope.user.group[0].id,
  7177. searchtype: "done",
  7178. idx: 0,
  7179. sum: 10,
  7180. };
  7181. $scope.incidentprocess = function (item) {
  7182. $state.go("app.incident.editor", {
  7183. taskId: item.taskId,
  7184. processInstanceId: item.processInstanceId,
  7185. });
  7186. };
  7187. $scope.more = function () {
  7188. $state.go("app.incident.list", {});
  7189. };
  7190. api_bpm_domain
  7191. .fetchtask("bpm_incident", filterData)
  7192. .then(function (data) {
  7193. if (data.data) {
  7194. $scope.myData = data.data;
  7195. } else {
  7196. SweetAlert.swal({
  7197. title: "操作异常!",
  7198. text: "系统异常,请稍后重试,或者联系管理员!",
  7199. type: "error",
  7200. });
  7201. }
  7202. });
  7203. $scope.removes = function () {
  7204. var modalInstance = $modal.open({
  7205. templateUrl: "assets/views/delete.html",
  7206. controller: function ($scope, $modalInstance) {
  7207. $scope.ok = function () {
  7208. $modalInstance.close();
  7209. };
  7210. $scope.cancel = function () {
  7211. $modalInstance.dismiss("cancel");
  7212. };
  7213. },
  7214. size: "sm",
  7215. });
  7216. modalInstance.result.then(function () {
  7217. console.log($scope.$parent.$parent.$parent.$parent);
  7218. for (
  7219. var i = 0;
  7220. i <
  7221. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7222. i++
  7223. ) {
  7224. if (
  7225. $scope.fields.type ==
  7226. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7227. .type
  7228. ) {
  7229. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7230. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7231. i,
  7232. 1
  7233. );
  7234. break;
  7235. }
  7236. }
  7237. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7238. if (vmForm) {
  7239. //console.log("vmForm>>>");//console.log(vmForm);
  7240. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7241. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7242. }
  7243. });
  7244. };
  7245. },
  7246. ],
  7247. });
  7248. //知识库列表
  7249. formlyConfigProvider.setType({
  7250. name: "ui-knowledge",
  7251. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7252. defaultOptions: function (options) {
  7253. return {
  7254. templateOptions: {
  7255. // relationAction: function() {
  7256. // options.hideExpression = true
  7257. // }
  7258. },
  7259. };
  7260. },
  7261. controller: [
  7262. "$scope",
  7263. "$modal",
  7264. "$timeout",
  7265. "api_solution",
  7266. "$rootScope",
  7267. "ngTableParams",
  7268. "$filter",
  7269. "$state",
  7270. function (
  7271. $scope,
  7272. $modal,
  7273. $timeout,
  7274. api_solution,
  7275. $rootScope,
  7276. ngTableParams,
  7277. $filter,
  7278. $state
  7279. ) {
  7280. var filterData = {
  7281. key: "null",
  7282. pageIndex: 0,
  7283. pageSum: 6,
  7284. status: 0,
  7285. userId: $rootScope.user.id,
  7286. };
  7287. $scope.model.removereport = false;
  7288. $scope.removes = function () {
  7289. $scope.model.removereport = true;
  7290. };
  7291. $scope.more = function () {
  7292. $state.go("app.knowledge.manager", {});
  7293. };
  7294. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7295. if (data.status == 200) {
  7296. $scope.myData = data.list;
  7297. }
  7298. });
  7299. $scope.removes = function () {
  7300. var modalInstance = $modal.open({
  7301. templateUrl: "assets/views/delete.html",
  7302. controller: function ($scope, $modalInstance) {
  7303. $scope.ok = function () {
  7304. $modalInstance.close();
  7305. };
  7306. $scope.cancel = function () {
  7307. $modalInstance.dismiss("cancel");
  7308. };
  7309. },
  7310. size: "sm",
  7311. });
  7312. modalInstance.result.then(function () {
  7313. for (
  7314. var i = 0;
  7315. i <
  7316. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7317. i++
  7318. ) {
  7319. if (
  7320. $scope.fields.type ==
  7321. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7322. .type
  7323. ) {
  7324. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7325. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7326. i,
  7327. 1
  7328. );
  7329. break;
  7330. }
  7331. }
  7332. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7333. if (vmForm) {
  7334. //console.log("vmForm>>>");//console.log(vmForm);
  7335. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7336. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7337. }
  7338. });
  7339. };
  7340. },
  7341. ],
  7342. });
  7343. //公告列表
  7344. formlyConfigProvider.setType({
  7345. name: "ui-ngnotice",
  7346. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7347. defaultOptions: function (options) {
  7348. return {
  7349. templateOptions: {
  7350. // relationAction: function() {
  7351. // options.hideExpression = true
  7352. // }
  7353. },
  7354. };
  7355. },
  7356. controller: [
  7357. "$scope",
  7358. "$modal",
  7359. "$timeout",
  7360. "SweetAlert",
  7361. "api_user_data",
  7362. "$rootScope",
  7363. "ngTableParams",
  7364. "$filter",
  7365. "$state",
  7366. function (
  7367. $scope,
  7368. $modal,
  7369. $timeout,
  7370. SweetAlert,
  7371. api_user_data,
  7372. $rootScope,
  7373. ngTableParams,
  7374. $filter,
  7375. $state
  7376. ) {
  7377. var filterData = {
  7378. idx: 0,
  7379. sum: 10,
  7380. };
  7381. // $scope.$scope.model.className = "col-xs-12";
  7382. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7383. if (data) {
  7384. $scope.myData = data.data;
  7385. } else {
  7386. SweetAlert.swal({
  7387. title: "操作异常!",
  7388. text: "系统异常,请稍后重试,或者联系管理员!",
  7389. type: "error",
  7390. });
  7391. }
  7392. });
  7393. $scope.more = function () {
  7394. $state.go("app.system.notice.list", {});
  7395. };
  7396. $scope.removes = function () {
  7397. var modalInstance = $modal.open({
  7398. templateUrl: "assets/views/delete.html",
  7399. controller: function ($scope, $modalInstance) {
  7400. $scope.ok = function () {
  7401. $modalInstance.close();
  7402. };
  7403. $scope.cancel = function () {
  7404. $modalInstance.dismiss("cancel");
  7405. };
  7406. },
  7407. size: "sm",
  7408. });
  7409. modalInstance.result.then(function () {
  7410. for (
  7411. var i = 0;
  7412. i <
  7413. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7414. i++
  7415. ) {
  7416. if (
  7417. $scope.fields.type ==
  7418. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7419. .type
  7420. ) {
  7421. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7422. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7423. i,
  7424. 1
  7425. );
  7426. break;
  7427. }
  7428. }
  7429. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7430. if (vmForm) {
  7431. //console.log("vmForm>>>");//console.log(vmForm);
  7432. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7433. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7434. }
  7435. });
  7436. };
  7437. },
  7438. ],
  7439. });
  7440. //事件统计图
  7441. formlyConfigProvider.setType({
  7442. name: "ui-incidentreport",
  7443. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7444. defaultOptions: function (options) {
  7445. return {
  7446. templateOptions: {
  7447. // relationAction: function() {
  7448. // options.hideExpression = true
  7449. // }
  7450. },
  7451. };
  7452. },
  7453. controller: [
  7454. "$scope",
  7455. "$modal",
  7456. "moment",
  7457. "api_report",
  7458. "$cookieStore",
  7459. function ($scope, $modal, moment, api_report, $cookieStore) {
  7460. api_report.getLicenseKey().then(function (response) {
  7461. $cookieStore.put("Auth-Token", response.token);
  7462. $scope.try_async_load();
  7463. });
  7464. $scope.try_async_load = function () {
  7465. $scope.my_data = [];
  7466. api_report.list().then(function (response) {
  7467. var dataList = response;
  7468. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7469. $scope.repoRoot.name = "事件报表";
  7470. convertRepoObject($scope.repoRoot);
  7471. $scope.my_data.push($scope.repoRoot);
  7472. });
  7473. };
  7474. var workspace = {};
  7475. $scope.repoRoot = null;
  7476. function getRepoRoot(repo, path) {
  7477. angular.forEach(repo, function (value, key) {
  7478. if (value.path == path) {
  7479. $scope.repoRoot = value;
  7480. } else {
  7481. if (
  7482. $scope.repoRoot == null &&
  7483. angular.isDefined(value.repoObjects)
  7484. ) {
  7485. getRepoRoot(value.repoObjects, path);
  7486. } else {
  7487. }
  7488. }
  7489. });
  7490. }
  7491. function convertRepoObject(repo) {
  7492. if (angular.isArray(repo)) {
  7493. angular.forEach(repo, function (value, key) {
  7494. convertRepoObject(value);
  7495. });
  7496. } else {
  7497. if (angular.isDefined(repo.name)) {
  7498. if (repo.name.indexOf(".") >= 0) {
  7499. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7500. } else {
  7501. repo.label = repo.name;
  7502. }
  7503. //delete repo.name;
  7504. }
  7505. if (angular.isDefined(repo.repoObjects)) {
  7506. repo.children = [];
  7507. repo.children = repo.repoObjects;
  7508. delete repo.repoObjects;
  7509. convertRepoObject(repo.children);
  7510. }
  7511. }
  7512. }
  7513. function parseDateParameter(parameters) {
  7514. var result = undefined;
  7515. if (angular.isArray(parameters)) {
  7516. // angular.forEach(parmeters,function(param){
  7517. // param.
  7518. // })
  7519. } else {
  7520. result = {};
  7521. for (var k in parameters) {
  7522. if (k.indexOf("Date") > 0) {
  7523. if (angular.isString(parameters[k])) {
  7524. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7525. "YYYY-MM-DD"
  7526. );
  7527. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7528. }
  7529. }
  7530. }
  7531. }
  7532. return result;
  7533. }
  7534. function ConvertDateParameter(parameters) {
  7535. var result = undefined;
  7536. if (angular.isArray(parameters)) {
  7537. //
  7538. } else {
  7539. result = {};
  7540. for (var k in parameters) {
  7541. if (k.indexOf("Date") > 0) {
  7542. if (angular.isDate(parameters[k])) {
  7543. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7544. } else if (angular.isString(parameters[k])) {
  7545. result[k] = parameters[k];
  7546. }
  7547. }
  7548. }
  7549. }
  7550. return result;
  7551. }
  7552. var incidentchart =
  7553. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7554. var queryUUID;
  7555. function genUUID() {
  7556. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7557. .replace(/[xy]/g, function (c) {
  7558. var r = (Math.random() * 16) | 0,
  7559. v = c == "x" ? r : (r & 0x3) | 0x8;
  7560. return v.toString(16);
  7561. })
  7562. .toUpperCase();
  7563. return uuid;
  7564. }
  7565. queryUUID = genUUID();
  7566. var pathincidenttimekey = [];
  7567. var incidenttime = {
  7568. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7569. "YYYYMMDD"
  7570. ),
  7571. endtimes: moment(new Date()).format("YYYYMMDD"),
  7572. };
  7573. var thisday = moment(new Date().getTime() + 86400000).format(
  7574. "YYYYMMDD"
  7575. );
  7576. var thisdaymine = Date.parse(
  7577. thisday.substr(4, 2) +
  7578. "/" +
  7579. thisday.substr(6, 2) +
  7580. "/" +
  7581. thisday.substr(0, 4)
  7582. );
  7583. var averages = [
  7584. [thisdaymine - 86400000 * 14, 0],
  7585. [thisdaymine - 86400000 * 13, 0],
  7586. [thisdaymine - 86400000 * 12, 0],
  7587. [thisdaymine - 86400000 * 11, 0],
  7588. [thisdaymine - 86400000 * 10, 0],
  7589. [thisdaymine - 86400000 * 9, 0],
  7590. [thisdaymine - 86400000 * 8, 0],
  7591. [thisdaymine - 86400000 * 7, 0],
  7592. [thisdaymine - 86400000 * 6, 0],
  7593. [thisdaymine - 86400000 * 5, 0],
  7594. [thisdaymine - 86400000 * 4, 0],
  7595. [thisdaymine - 86400000 * 3, 0],
  7596. [thisdaymine - 86400000 * 2, 0],
  7597. [thisdaymine - 86400000 * 1, 0],
  7598. [thisdaymine, 0],
  7599. ];
  7600. var getreportdata = function (incidenttime, path) {
  7601. api_report.getMdx(path, queryUUID).then(function (response) {
  7602. var mdxquery = response;
  7603. workspace.query = mdxquery;
  7604. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7605. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7606. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7607. weekuser(mdxquery);
  7608. });
  7609. };
  7610. getreportdata(incidenttime, incidentchart);
  7611. var weekuser = function (mdxquery) {
  7612. var key = [];
  7613. api_report.execute(mdxquery).then(function (data) {
  7614. $scope.rheaders = [];
  7615. $scope.rRows = [];
  7616. var reportData = data;
  7617. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7618. $scope.shows = true;
  7619. $scope.empty = "数据为空!";
  7620. } else {
  7621. angular.forEach(reportData.cellset, function (item, i) {
  7622. angular.forEach(averages, function (index, j) {
  7623. // angular.forEach(averages, function(item, index) {
  7624. if (item.length > 1 && i > 0 && item[1].value != "") {
  7625. if (
  7626. index[0] ==
  7627. Date.parse(
  7628. item[0].value.substr(4, 2) +
  7629. "/" +
  7630. item[0].value.substr(6, 2) +
  7631. "/" +
  7632. item[0].value.substr(0, 4)
  7633. ) +
  7634. 86400000
  7635. ) {
  7636. index[1] = Number(item[1].value);
  7637. }
  7638. // 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)]);
  7639. }
  7640. // })
  7641. });
  7642. });
  7643. incidentchartfun(averages);
  7644. }
  7645. });
  7646. };
  7647. var incidentchartfun = function (incidentchartkey) {
  7648. // $scope.isMaskincident = false;
  7649. Highcharts.chart("incidentchart", {
  7650. title: {
  7651. text: "事件近15天趋势图",
  7652. },
  7653. xAxis: {
  7654. type: "datetime",
  7655. labels: {
  7656. align: "left",
  7657. step: 1,
  7658. },
  7659. },
  7660. yAxis: {
  7661. title: {
  7662. text: null,
  7663. },
  7664. },
  7665. tooltip: {
  7666. crosshairs: true,
  7667. shared: true,
  7668. valueSuffix: "条",
  7669. },
  7670. legend: {},
  7671. series: [
  7672. {
  7673. name: "生成事件",
  7674. data: incidentchartkey,
  7675. zIndex: 1,
  7676. marker: {
  7677. fillColor: "white",
  7678. lineWidth: 2,
  7679. lineColor: Highcharts.getOptions().colors[0],
  7680. },
  7681. },
  7682. ],
  7683. });
  7684. };
  7685. $scope.data = {
  7686. labels: [
  7687. "1号",
  7688. "2号",
  7689. "3号",
  7690. "4号",
  7691. "5号",
  7692. "6号",
  7693. "7号",
  7694. "8号",
  7695. "9号",
  7696. "10号",
  7697. "11号",
  7698. "12号",
  7699. "13号",
  7700. "14号",
  7701. "15号",
  7702. ],
  7703. datasets: [
  7704. {
  7705. label: "新增事件数量",
  7706. fillColor: "rgba(220,220,220,0.2)",
  7707. strokeColor: "rgba(220,220,220,1)",
  7708. pointColor: "rgba(220,220,220,1)",
  7709. pointStrokeColor: "#fff",
  7710. pointHighlightFill: "#fff",
  7711. pointHighlightStroke: "rgba(220,220,220,1)",
  7712. data: [
  7713. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7714. ],
  7715. },
  7716. {
  7717. label: "已解决事件数量",
  7718. fillColor: "rgba(151,187,205,0.2)",
  7719. strokeColor: "rgba(151,187,205,1)",
  7720. pointColor: "rgba(151,187,205,1)",
  7721. pointStrokeColor: "#fff",
  7722. pointHighlightFill: "#fff",
  7723. pointHighlightStroke: "rgba(151,187,205,1)",
  7724. data: [
  7725. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7726. ],
  7727. },
  7728. ],
  7729. };
  7730. $scope.removes = function () {
  7731. var modalInstance = $modal.open({
  7732. templateUrl: "assets/views/delete.html",
  7733. controller: function ($scope, $modalInstance) {
  7734. $scope.ok = function () {
  7735. $modalInstance.close();
  7736. };
  7737. $scope.cancel = function () {
  7738. $modalInstance.dismiss("cancel");
  7739. };
  7740. },
  7741. size: "sm",
  7742. });
  7743. modalInstance.result.then(function () {
  7744. for (
  7745. var i = 0;
  7746. i <
  7747. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7748. i++
  7749. ) {
  7750. if (
  7751. $scope.fields.type ==
  7752. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7753. .type
  7754. ) {
  7755. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7756. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7757. i,
  7758. 1
  7759. );
  7760. break;
  7761. }
  7762. }
  7763. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7764. if (vmForm) {
  7765. //console.log("vmForm>>>");//console.log(vmForm);
  7766. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7767. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7768. }
  7769. });
  7770. };
  7771. var addDatas = 0;
  7772. var resolve = 0;
  7773. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7774. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7775. }
  7776. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7777. resolve = resolve + $scope.data.datasets[1].data[i];
  7778. }
  7779. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7780. $scope.opt = {
  7781. maintainAspectRatio: false,
  7782. // Sets the chart to be responsive
  7783. responsive: true,
  7784. ///Boolean - Whether grid lines are shown across the chart
  7785. scaleShowGridLines: true,
  7786. //String - Colour of the grid lines
  7787. scaleGridLineColor: "rgba(0,0,0,.05)",
  7788. //Number - Width of the grid lines
  7789. scaleGridLineWidth: 1,
  7790. //Boolean - Whether the line is curved between points
  7791. bezierCurve: false,
  7792. //Number - Tension of the bezier curve between points
  7793. bezierCurveTension: 0.4,
  7794. //Boolean - Whether to show a dot for each point
  7795. pointDot: true,
  7796. //Number - Radius of each point dot in pixels
  7797. pointDotRadius: 4,
  7798. //Number - Pixel width of point dot stroke
  7799. pointDotStrokeWidth: 1,
  7800. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7801. pointHitDetectionRadius: 20,
  7802. //Boolean - Whether to show a stroke for datasets
  7803. datasetStroke: true,
  7804. //Number - Pixel width of dataset stroke
  7805. datasetStrokeWidth: 2,
  7806. //Boolean - Whether to fill the dataset with a colour
  7807. datasetFill: true,
  7808. // Function - on animation progress
  7809. onAnimationProgress: function () { },
  7810. // Function - on animation complete
  7811. onAnimationComplete: function () { },
  7812. //String - A legend template
  7813. legendTemplate:
  7814. '<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>',
  7815. };
  7816. angular.extend($scope.options, $scope.opt);
  7817. $scope.datamonth = {
  7818. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7819. datasets: [
  7820. {
  7821. label: "新增事件数量",
  7822. fillColor: "rgba(220,220,220,0.5)",
  7823. strokeColor: "rgba(220,220,220,0.8)",
  7824. highlightFill: "rgba(220,220,220,0.75)",
  7825. highlightStroke: "rgba(220,220,220,1)",
  7826. data: [65, 59, 80, 81, 56, 55],
  7827. },
  7828. {
  7829. label: "已解决事件数量",
  7830. fillColor: "rgba(151,187,205,0.5)",
  7831. strokeColor: "rgba(151,187,205,0.8)",
  7832. highlightFill: "rgba(151,187,205,0.75)",
  7833. highlightStroke: "rgba(151,187,205,1)",
  7834. data: [28, 48, 40, 19, 86, 27],
  7835. },
  7836. ],
  7837. };
  7838. // Chart.js Options
  7839. $scope.taption = {
  7840. maintainAspectRatio: false,
  7841. // Sets the chart to be responsive
  7842. responsive: true,
  7843. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7844. scaleBeginAtZero: true,
  7845. //Boolean - Whether grid lines are shown across the chart
  7846. scaleShowGridLines: true,
  7847. //String - Colour of the grid lines
  7848. scaleGridLineColor: "rgba(0,0,0,.05)",
  7849. //Number - Width of the grid lines
  7850. scaleGridLineWidth: 1,
  7851. //Boolean - If there is a stroke on each bar
  7852. barShowStroke: true,
  7853. //Number - Pixel width of the bar stroke
  7854. barStrokeWidth: 2,
  7855. //Number - Spacing between each of the X value sets
  7856. barValueSpacing: 5,
  7857. //Number - Spacing between data sets within X values
  7858. barDatasetSpacing: 1,
  7859. //String - A legend template
  7860. legendTemplate:
  7861. '<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>',
  7862. };
  7863. },
  7864. ],
  7865. });
  7866. //排版日历
  7867. formlyConfigProvider.setType({
  7868. name: "ui-dashcalendar",
  7869. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7870. defaultOptions: function (options) {
  7871. return {
  7872. templateOptions: {
  7873. // relationAction: function() {
  7874. // options.hideExpression = true
  7875. // }
  7876. },
  7877. };
  7878. },
  7879. controller: [
  7880. "$rootScope",
  7881. "$scope",
  7882. "$modal",
  7883. "$aside",
  7884. "calendarConfig",
  7885. "moment",
  7886. "SweetAlert",
  7887. "Restangular",
  7888. "api_bpm_schedule",
  7889. "api_user_data",
  7890. "$state",
  7891. function (
  7892. $rootScope,
  7893. $scope,
  7894. $modal,
  7895. $aside,
  7896. calendarConfig,
  7897. moment,
  7898. SweetAlert,
  7899. Restangular,
  7900. api_bpm_schedule,
  7901. api_user_data,
  7902. $state
  7903. ) {
  7904. var loginUser = $rootScope.user;
  7905. calendarConfig.dateFormatter = "moment";
  7906. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7907. calendarConfig.i18nStrings.timeLabel = "时间";
  7908. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7909. calendarConfig.allDateFormats = {
  7910. angular: {
  7911. date: {
  7912. hour: "ha",
  7913. day: "d MMM",
  7914. month: "MMMM",
  7915. weekDay: "EEEE",
  7916. time: "HH:mm",
  7917. datetime: "MMM d, h:mm a",
  7918. },
  7919. title: {
  7920. day: "yyyy MMMM EEEE d",
  7921. week: "{year}年第{week}周",
  7922. month: "yyyy MMMM",
  7923. year: "yyyy",
  7924. },
  7925. },
  7926. moment: {
  7927. date: {
  7928. hour: "ha",
  7929. day: "MMMDD日",
  7930. month: "MMMM",
  7931. weekDay: "dddd",
  7932. time: "HH:mm",
  7933. datetime: "MMM D, h:mm a",
  7934. },
  7935. title: {
  7936. day: "YYYY年MMMMDD日, dddd ",
  7937. week: "{year}年第{week}周",
  7938. month: "YYYY年MMMM",
  7939. year: "YYYY",
  7940. },
  7941. },
  7942. };
  7943. moment.locale("zh_cn", {
  7944. months:
  7945. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7946. "_"
  7947. ),
  7948. monthsShort:
  7949. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7950. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7951. "_"
  7952. ),
  7953. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7954. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7955. longDateFormat: {
  7956. LT: "Ah点mm分",
  7957. LTS: "Ah点m分s秒",
  7958. L: "YYYY-MM-DD",
  7959. LL: "YYYY年MMMD日",
  7960. LLL: "YYYY年MMMD日Ah点mm分",
  7961. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7962. l: "YYYY-MM-DD",
  7963. ll: "YYYY年MMMD日",
  7964. lll: "YYYY年MMMD日Ah点mm分",
  7965. llll: "YYYY年MMMD日ddddAh点mm分",
  7966. },
  7967. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7968. meridiemHour: function (hour, meridiem) {
  7969. if (hour === 12) {
  7970. hour = 0;
  7971. }
  7972. if (
  7973. meridiem === "凌晨" ||
  7974. meridiem === "早上" ||
  7975. meridiem === "上午"
  7976. ) {
  7977. return hour;
  7978. } else if (meridiem === "下午" || meridiem === "晚上") {
  7979. return hour + 12;
  7980. } else {
  7981. // '中午'
  7982. return hour >= 11 ? hour : hour + 12;
  7983. }
  7984. },
  7985. meridiem: function (hour, minute, isLower) {
  7986. var hm = hour * 100 + minute;
  7987. if (hm < 600) {
  7988. return "凌晨";
  7989. } else if (hm < 900) {
  7990. return "早上";
  7991. } else if (hm < 1130) {
  7992. return "上午";
  7993. } else if (hm < 1230) {
  7994. return "中午";
  7995. } else if (hm < 1800) {
  7996. return "下午";
  7997. } else {
  7998. return "晚上";
  7999. }
  8000. },
  8001. calendar: {
  8002. sameDay: function () {
  8003. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8004. },
  8005. nextDay: function () {
  8006. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8007. },
  8008. lastDay: function () {
  8009. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8010. },
  8011. nextWeek: function () {
  8012. var startOfWeek, prefix;
  8013. startOfWeek = moment().startOf("week");
  8014. prefix =
  8015. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8016. ? "[下]"
  8017. : "[本]";
  8018. return this.minutes() === 0
  8019. ? prefix + "dddAh点整"
  8020. : prefix + "dddAh点mm";
  8021. },
  8022. lastWeek: function () {
  8023. var startOfWeek, prefix;
  8024. startOfWeek = moment().startOf("week");
  8025. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8026. return this.minutes() === 0
  8027. ? prefix + "dddAh点整"
  8028. : prefix + "dddAh点mm";
  8029. },
  8030. sameElse: "LL",
  8031. },
  8032. ordinalParse: /\d{1,2}(日|月|周)/,
  8033. ordinal: function (number, period) {
  8034. switch (period) {
  8035. case "d":
  8036. case "D":
  8037. case "DDD":
  8038. return number + "日";
  8039. case "M":
  8040. return number + "月";
  8041. case "w":
  8042. case "W":
  8043. return number + "周";
  8044. default:
  8045. return number;
  8046. }
  8047. },
  8048. relativeTime: {
  8049. future: "%s内",
  8050. past: "%s前",
  8051. s: "几秒",
  8052. m: "1 分钟",
  8053. mm: "%d 分钟",
  8054. h: "1 小时",
  8055. hh: "%d 小时",
  8056. d: "1 天",
  8057. dd: "%d 天",
  8058. M: "1 个月",
  8059. MM: "%d 个月",
  8060. y: "1 年",
  8061. yy: "%d 年",
  8062. },
  8063. week: {
  8064. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8065. dow: 1, // Monday is the first day of the week.
  8066. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8067. },
  8068. });
  8069. var date = new Date();
  8070. var d = date.getDate();
  8071. var m = date.getMonth();
  8072. var y = date.getFullYear();
  8073. var filterData = {
  8074. userId: loginUser.id,
  8075. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8076. "YYYY-MM-DD HH:mm:ss"
  8077. ),
  8078. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8079. "YYYY-MM-DD HH:mm:ss"
  8080. ),
  8081. };
  8082. var load = ($scope.load = function (filterData) {
  8083. api_bpm_schedule
  8084. .fetchSchedule(
  8085. filterData.userId,
  8086. filterData.startTime,
  8087. filterData.endTime
  8088. )
  8089. .then(function (response) {
  8090. if (response.status == 200) {
  8091. $scope.events = [];
  8092. var myData = response.list;
  8093. angular.forEach(myData, function (item) {
  8094. var eventTemp = {};
  8095. eventTemp.title = item.description;
  8096. eventTemp.type = item.scheduleClass.code;
  8097. eventTemp.startsAt = moment(
  8098. item["scheduleOrderDTO"].startTime
  8099. ).toDate();
  8100. eventTemp.endsAtTime = moment(
  8101. item["scheduleOrderDTO"].endTime
  8102. ).toDate();
  8103. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8104. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8105. //eventTemp.ends_at = moment(item.endTime).toDate();
  8106. eventTemp.id = item.id;
  8107. eventTemp.deletable = false;
  8108. eventTemp.user = item.user;
  8109. $scope.events.push(eventTemp);
  8110. });
  8111. }
  8112. });
  8113. });
  8114. // var load = $scope.load = function(filterData){
  8115. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8116. // console.log("response="+JSON.stringify(response));
  8117. // if(response.status==200){
  8118. // $scope.events = [];
  8119. // console.log(response.list);
  8120. // var myData = response.list;
  8121. // angular.forEach(myData,function(item){
  8122. // var eventTemp = {};
  8123. // eventTemp.title = item.description;
  8124. // eventTemp.type = item.scheduleClass.code;
  8125. // eventTemp.startsAt = moment(item.startTime).toDate();
  8126. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8127. // eventTemp.startTime = item.startTime;
  8128. // eventTemp.endTime = item.endTime;
  8129. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8130. // eventTemp.id = item.id;
  8131. // eventTemp.deletable = false;
  8132. // eventTemp.users = item.users;
  8133. // $scope.events.push(eventTemp);
  8134. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8135. // })
  8136. // }
  8137. // });
  8138. // }
  8139. $scope.scheduleClass = {};
  8140. var convertEvent = function (scheduleorder) {
  8141. var eventTemp = {};
  8142. eventTemp.title = scheduleorder.description;
  8143. eventTemp.type = scheduleorder.scheduleClass.code;
  8144. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8145. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8146. eventTemp.id = scheduleorder.id;
  8147. eventTemp.user = scheduleorder.user;
  8148. eventTemp.deletable = false;
  8149. return eventTemp;
  8150. };
  8151. // var convertEvent = function(scheduleorder){
  8152. // var eventTemp = {};
  8153. // eventTemp.title = scheduleorder.description;
  8154. // eventTemp.type = scheduleorder.scheduleClass.code;
  8155. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8156. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8157. // eventTemp.id = scheduleorder.id;
  8158. // eventTemp.users = scheduleorder.users;
  8159. // eventTemp.deletable = false;
  8160. // return eventTemp;
  8161. // }
  8162. api_bpm_schedule.getScheduleClass().then(function (response) {
  8163. if (response.status == 200) {
  8164. var scheduleClassList = response.list;
  8165. angular.forEach(scheduleClassList, function (item) {
  8166. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8167. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8168. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8169. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8170. $scope.scheduleClass[item["code"]] = item;
  8171. });
  8172. }
  8173. });
  8174. $scope.events = [];
  8175. $scope.calendarView = "month";
  8176. //$scope.calendarDay = new Date();
  8177. $scope.calendarDate = moment().startOf("month").toDate();
  8178. $scope.timeLabel = "时间";
  8179. $scope.eventLabel = "描述";
  8180. function showModal(action, event) {
  8181. // console.log("action="+JSON.stringify(action))
  8182. var modalInstance = $aside.open({
  8183. templateUrl: "scheduleEvent.html",
  8184. placement: "right",
  8185. size: "sm",
  8186. backdrop: true,
  8187. controller: function (
  8188. $scope,
  8189. $modalInstance,
  8190. scheduleClass,
  8191. APIService,
  8192. MementFormat
  8193. ) {
  8194. $scope.$modalInstance = $modalInstance;
  8195. $scope.action = action;
  8196. $scope.event = event;
  8197. $scope.scheduleClassic = scheduleClass;
  8198. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8199. // if(oldvalue == newvalue) return;
  8200. // if(scheduleClass[newvalue]){
  8201. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8202. var em = MementFormat(scheduleClass[newvalue].endTime);
  8203. console.log("sm=" + JSON.stringify(sm));
  8204. event.starts_at = MementFormat(event.startTime)
  8205. .startOf("day")
  8206. .add(sm.hour(), "hour")
  8207. .add(sm.minute(), "minute")
  8208. .add(sm.second(), "second")
  8209. .toDate();
  8210. console.log(
  8211. "event.starts_at=" + JSON.stringify(event.starts_at)
  8212. );
  8213. if (sm.hour() > em.hour()) {
  8214. event.ends_at = MementFormat(event.startTime)
  8215. .startOf("day")
  8216. .add(1, "day")
  8217. .add(em.hour(), "hour")
  8218. .add(em.minute(), "minute")
  8219. .add(em.second(), "second")
  8220. .toDate();
  8221. console.log(
  8222. "event.ends_at=" + JSON.stringify(event.starts_at)
  8223. );
  8224. } else {
  8225. event.ends_at = MementFormat(event.startTime)
  8226. .startOf("day")
  8227. .add(em.hour(), "hour")
  8228. .add(em.minute(), "minute")
  8229. .add(em.second(), "second")
  8230. .toDate();
  8231. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8232. }
  8233. // }
  8234. });
  8235. // $scope.ok = function (event) {
  8236. // console.log("event="+JSON.stringify(event))
  8237. // event.action = action;
  8238. // $modalInstance.close(event);
  8239. // };
  8240. $scope.cancel = function (event) {
  8241. $modalInstance.dismiss();
  8242. };
  8243. var acUserSelect = ($scope.refreshUser = function (key) {
  8244. //for test
  8245. // $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":"管理层"}]}];
  8246. // return;
  8247. var data = {
  8248. idx: "0",
  8249. sum: "5",
  8250. };
  8251. if (key) {
  8252. data["user"] = {
  8253. name: key,
  8254. };
  8255. }
  8256. APIService.fetchDataList("user", data).then(function (
  8257. response
  8258. ) {
  8259. if (response) {
  8260. if ((response.status = 200)) {
  8261. $scope.users = response.list;
  8262. console.log($scope.users);
  8263. }
  8264. }
  8265. });
  8266. });
  8267. if (angular.isDefined(event.users) && event.users.length > 0) {
  8268. }
  8269. $scope.users = [event.user];
  8270. acUserSelect();
  8271. },
  8272. resolve: {
  8273. scheduleClass: function () {
  8274. return $scope.scheduleClass;
  8275. },
  8276. APIService: function () {
  8277. return api_user_data;
  8278. },
  8279. MementFormat: function () {
  8280. return moment;
  8281. },
  8282. },
  8283. });
  8284. modalInstance.result.then(function (selectedEvent) {
  8285. if (selectedEvent.action == "Clicked") {
  8286. // var data = {
  8287. // "scheduleorder":{
  8288. // "id":selectedEvent.id,
  8289. // "description":selectedEvent.title,
  8290. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8291. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8292. // "users":selectedEvent.users,
  8293. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8294. // }
  8295. // };
  8296. // api_bpm_schedule.update(data).then(function(response){
  8297. // if(response.status==200){
  8298. // SweetAlert.swal({
  8299. // title: "操作成功!",
  8300. // text: "排班更新成功!",
  8301. // type: "succes"
  8302. // });
  8303. // angular.forEach($scope.events,function(item){
  8304. // if(item.id==selectedEvent.id){
  8305. // item = selectedEvent;
  8306. // }
  8307. // })
  8308. // }else{
  8309. // SweetAlert.swal({
  8310. // title: "操作失败",
  8311. // text: "排班更新失败,请稍后重试!",
  8312. // type: "error"
  8313. // })
  8314. // }
  8315. // })
  8316. } else {
  8317. //
  8318. }
  8319. });
  8320. }
  8321. $scope.moment = function (string) {
  8322. return moment(string);
  8323. };
  8324. $scope.eventClicked = function (event) {
  8325. // console.log("event="+JSON.stringify(event))
  8326. showModal("Clicked", event);
  8327. };
  8328. $scope.eventEdited = function (event) {
  8329. showModal("Edited", event);
  8330. };
  8331. var updateView = function (newvalue, oldvalue) {
  8332. if (oldvalue == newvalue) return;
  8333. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8334. if ($scope.calendarView == "year") {
  8335. } else if ($scope.calendarView == "month") {
  8336. timeStart = moment(newvalue).startOf("month");
  8337. timeEnd = moment(newvalue).endOf("month");
  8338. } else if ($scope.calendarView == "week") {
  8339. timeStart = moment(newvalue).startOf("week");
  8340. timeEnd = moment(newvalue).endOf("week");
  8341. } else if ($scope.calendarView == "Day") {
  8342. timeStart = moment(newvalue).startOf("day");
  8343. timeEnd = moment(newvalue).endOf("day");
  8344. }
  8345. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8346. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8347. filterData["startTime"] = timeStartSpan;
  8348. filterData["endTime"] = timeEndSpan;
  8349. load(filterData);
  8350. };
  8351. $scope.$watch("calendarDate", updateView);
  8352. $scope.next = function () {
  8353. $scope.calendarControl.next();
  8354. };
  8355. $scope.prev = function () {
  8356. $scope.calendarControl.prev();
  8357. };
  8358. $scope.setCalendarToToday = function () {
  8359. $scope.calendarDay = new Date();
  8360. };
  8361. $scope.toggle = function ($event, field, event) {
  8362. $event.preventDefault();
  8363. $event.stopPropagation();
  8364. event[field] = !event[field];
  8365. };
  8366. $scope.load(filterData);
  8367. $scope.more = function () {
  8368. $state.go("app.scheduling.myscheduling", {});
  8369. };
  8370. $scope.removes = function () {
  8371. var modalInstance = $modal.open({
  8372. templateUrl: "assets/views/delete.html",
  8373. controller: function ($scope, $modalInstance) {
  8374. $scope.ok = function () {
  8375. $modalInstance.close();
  8376. };
  8377. $scope.cancel = function () {
  8378. $modalInstance.dismiss("cancel");
  8379. };
  8380. },
  8381. size: "sm",
  8382. });
  8383. modalInstance.result.then(function () {
  8384. for (
  8385. var i = 0;
  8386. i <
  8387. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8388. i++
  8389. ) {
  8390. if (
  8391. $scope.fields.type ==
  8392. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8393. .type
  8394. ) {
  8395. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8396. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8397. i,
  8398. 1
  8399. );
  8400. break;
  8401. }
  8402. }
  8403. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8404. if (vmForm) {
  8405. //console.log("vmForm>>>");//console.log(vmForm);
  8406. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8407. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8408. }
  8409. });
  8410. };
  8411. },
  8412. ],
  8413. });
  8414. //空格组件
  8415. formlyConfigProvider.setType({
  8416. name: "ui-black",
  8417. /*extends: 'input',*/
  8418. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8419. });
  8420. //请求人最近事件
  8421. formlyConfigProvider.setType({
  8422. name: "ui-recentIncident",
  8423. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8424. controller: [
  8425. "$scope",
  8426. "$modal",
  8427. "api_solution",
  8428. function ($scope, $modal, api_solution) {
  8429. var filterData = {
  8430. incident: {
  8431. requester: {
  8432. id: "",
  8433. },
  8434. },
  8435. idx: 0,
  8436. sum: 3,
  8437. };
  8438. setInterval(function () {
  8439. if (
  8440. filterData.incident.requester.id == "" ||
  8441. filterData.incident.requester.id != $scope.model.requester.id
  8442. ) {
  8443. var requester = $scope.model.requester;
  8444. if (requester != null && angular.isDefined(requester.id)) {
  8445. filterData.incident.requester.id = $scope.model.requester.id;
  8446. $scope.options.templateOptions
  8447. .getWorkernumber(
  8448. $scope.options.templateOptions.ApiService,
  8449. filterData
  8450. )
  8451. .then(function (result) {
  8452. var modelData =
  8453. $scope.options.templateOptions.Restangular.stripRestangular(
  8454. result
  8455. );
  8456. if (modelData.status == 200) {
  8457. $scope.lastrequst = modelData.list;
  8458. }
  8459. });
  8460. requester = null;
  8461. } else {
  8462. }
  8463. } else {
  8464. }
  8465. }, 1000);
  8466. $scope.detail = function (data) {
  8467. var modalInstance = $modal.open({
  8468. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8469. controller: function ($scope, $modalInstance) {
  8470. $scope.entity = {};
  8471. $scope.entity = data;
  8472. $scope.cancel = function () {
  8473. $modalInstance.dismiss("cancel");
  8474. };
  8475. },
  8476. size: "lg",
  8477. });
  8478. };
  8479. },
  8480. ],
  8481. });
  8482. //参数列表
  8483. formlyConfigProvider.setType({
  8484. name: "ui-listinput",
  8485. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8486. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8487. defaultOptions: function (options) {
  8488. return {
  8489. templateOptions: {},
  8490. };
  8491. },
  8492. controller: ["$scope", function ($scope) { }],
  8493. });
  8494. //时间段控件(分)
  8495. formlyConfigProvider.setType({
  8496. name: "ui-timeslot",
  8497. extends: "input",
  8498. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8499. controller: ["$scope", function ($scope) { }],
  8500. });
  8501. //优先级级联-逾期时间
  8502. formlyConfigProvider.setType({
  8503. name: "ui-overtime",
  8504. extends: "input",
  8505. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8506. controller: [
  8507. "$scope",
  8508. "api_bpm_domain",
  8509. function ($scope, api_bpm_domain) {
  8510. var filteData = {};
  8511. var datas = {};
  8512. setInterval(function () {
  8513. if (
  8514. $scope.model.priority &&
  8515. $scope.model.priority.id != null &&
  8516. filteData &&
  8517. datas != $scope.model.priority.id
  8518. ) {
  8519. filteData = "L" + $scope.model.priority.id;
  8520. datas = $scope.model.priority.id;
  8521. // console.log($scope.options.templateOptions)
  8522. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8523. // var overtime=requester.date;
  8524. if (requester.state == 200) {
  8525. // if($scope.options.key=="date"){
  8526. $scope.model[$scope.options.key] = requester.date;
  8527. // }
  8528. }
  8529. });
  8530. }
  8531. }, 1000);
  8532. },
  8533. ],
  8534. });
  8535. formlyConfigProvider.setType({
  8536. name: "ui-responsetime",
  8537. extends: "input",
  8538. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8539. controller: [
  8540. "$scope",
  8541. "api_bpm_domain",
  8542. function ($scope, api_bpm_domain) {
  8543. var filteData = {};
  8544. var datas = {};
  8545. setInterval(function () {
  8546. if (
  8547. $scope.model.priority &&
  8548. $scope.model.priority.id != null &&
  8549. filteData &&
  8550. datas != $scope.model.priority.id
  8551. ) {
  8552. filteData = "L" + $scope.model.priority.id;
  8553. datas = $scope.model.priority.id;
  8554. // console.log($scope.options.templateOptions)
  8555. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8556. // var overtime=requester.date;
  8557. if (requester.state == 200) {
  8558. var keyName = {};
  8559. // $scope.model.overdueTime = requester.date;
  8560. if ($scope.options.key == "expectIntroTime") {
  8561. keyName = "resolveTime";
  8562. } else if ($scope.options.key == "expectResponseTime") {
  8563. keyName = "responseTime";
  8564. }
  8565. $scope.model[$scope.options.key] =
  8566. requester.serviceLevelAgreement[keyName];
  8567. // }
  8568. console.log($scope.$parent.$parent.$parent.model);
  8569. }
  8570. if (requester.date1) {
  8571. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8572. requester.date;
  8573. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8574. requester.date1;
  8575. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8576. requester.serviceLevelAgreement.resolveTime;
  8577. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8578. requester.serviceLevelAgreement.responseTime;
  8579. }
  8580. });
  8581. }
  8582. }, 1000);
  8583. },
  8584. ],
  8585. });
  8586. //知识库按钮组件
  8587. formlyConfigProvider.setType({
  8588. name: "ui-discasecade",
  8589. extends: "input",
  8590. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8591. defaultOptions: function (options) {
  8592. return {
  8593. templateOptions: {
  8594. relationAction: function (fields, modelscope, item) { },
  8595. },
  8596. validators: {
  8597. required: {
  8598. expression: function (viewValue, modelValue) {
  8599. var value = modelValue || viewValue;
  8600. // return value = "true";
  8601. },
  8602. },
  8603. },
  8604. };
  8605. },
  8606. controller: [
  8607. "$scope",
  8608. "$rootScope",
  8609. "$modal",
  8610. "SweetAlert",
  8611. "api_bpm_data",
  8612. "api_solution",
  8613. "$aside",
  8614. "api_zsk",
  8615. "api_bpm_domain",
  8616. function (
  8617. $scope,
  8618. $rootScope,
  8619. $modal,
  8620. SweetAlert,
  8621. api_bpm_data,
  8622. api_solution,
  8623. $aside,
  8624. api_zsk,
  8625. api_bpm_domain
  8626. ) {
  8627. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8628. $scope.searchField = $scope.options.model[$scope.options.key];
  8629. $scope.searchData = "";
  8630. $scope.onChangeadd = function (searchData) {
  8631. $scope.searchKey = searchData.account;
  8632. // $scope.searchDataadd = searchData;
  8633. var requesdata = angular.copy(searchData);
  8634. $scope.requester = requesdata;
  8635. };
  8636. $scope.refreshUseradd = function (searchKey) {
  8637. //主题搜索
  8638. $scope.searchData = searchKey;
  8639. reashdata($scope.searchData);
  8640. };
  8641. $scope.getMydata = function (x) {
  8642. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8643. $scope.searchField = $scope.model[$scope.options.key];
  8644. };
  8645. $scope.getMydataone = function (x) {
  8646. $scope.model[$scope.options.key] = x;
  8647. $scope.searchField = $scope.model[$scope.options.key];
  8648. };
  8649. $scope.fildata = {
  8650. idx: 0,
  8651. sum: 10,
  8652. // 'incident': { 'tilte': item }
  8653. };
  8654. function reashdata(item) {
  8655. if (item && item != "") {
  8656. angular.extend($scope.fildata, {
  8657. incident: {
  8658. title: item,
  8659. },
  8660. });
  8661. } else {
  8662. delete $scope.fildata.incident;
  8663. }
  8664. api_bpm_data
  8665. .fetchDataList("incident", $scope.fildata)
  8666. .then(function (response) {
  8667. if (response) {
  8668. if ((response.status = 200)) {
  8669. var myData = response;
  8670. $scope.myData = myData.list;
  8671. }
  8672. }
  8673. });
  8674. }
  8675. function delHtmlTag(str) {
  8676. return str.replace(/<[^>]+>/g, "");
  8677. }
  8678. // reashdata();
  8679. var changedata = {};
  8680. setInterval(function () {
  8681. if (
  8682. $scope.model.category != null &&
  8683. $scope.model.category.id != changedata.id &&
  8684. $scope.model.titles != $scope.model.category
  8685. ) {
  8686. $scope.searchData = {};
  8687. changedata = angular.copy($scope.model.category);
  8688. if ($scope.options.key == "title") {
  8689. var filterData = {
  8690. idx: 0,
  8691. sum: 1000,
  8692. };
  8693. api_bpm_data
  8694. .fetchDataList("incidentcategory", filterData)
  8695. .then(function (data) {
  8696. var datalist = data.list;
  8697. angular.forEach(datalist, function (item) {
  8698. if (item.id == $scope.model.category.id) {
  8699. $scope.model[$scope.options.key] = item.category;
  8700. $scope.searchField =
  8701. $scope.options.model[$scope.options.key];
  8702. $scope.titles = item.category;
  8703. titles = $scope.model.category;
  8704. }
  8705. });
  8706. });
  8707. }
  8708. }
  8709. }, 1000);
  8710. $scope.open = function (key, options, fildata, $event, model) {
  8711. if (key && key.length > 1) {
  8712. api_zsk
  8713. .solutionData(
  8714. {
  8715. solution: {
  8716. searchWord: key,
  8717. },
  8718. idx: "0",
  8719. sum: "1000",
  8720. },
  8721. "solution"
  8722. )
  8723. .then(function (response) {
  8724. if (response && response.list.length > 0) {
  8725. $scope.dlideboxslide = true;
  8726. angular.forEach(response, function (item) {
  8727. console.log(response);
  8728. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8729. // if (response.status == 200) {
  8730. // var quote = { 'totalNum': response.totalNum }
  8731. // item = angular.extend(item, quote)
  8732. // }
  8733. // })
  8734. $scope.searchData = response.list;
  8735. console.log($scope.searchData);
  8736. });
  8737. $scope.changes = false;
  8738. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8739. // $scope.closepages = function(e) {
  8740. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8741. // event.preventDefault();
  8742. // };
  8743. $scope.shows = false;
  8744. $scope.tempData = {};
  8745. $scope.showpage = function (item) {
  8746. item.content = delHtmlTag(item.content);
  8747. $scope.shows = true;
  8748. $scope.tempData = item;
  8749. if (item.content != null) {
  8750. $scope.tempData.content = $scope.tempData.content
  8751. .replace("<p>", "")
  8752. .replace("</p>", "");
  8753. }
  8754. $scope.knowledgedata = item;
  8755. $scope.pageid = item.id;
  8756. $scope.changes = !$scope.changes;
  8757. api_bpm_domain
  8758. .listAttachments(item.id)
  8759. // api_solution.fetchDataList('file', {
  8760. // "file": {
  8761. // "solutionId": item.id
  8762. // },
  8763. // "idx": "0",
  8764. // "sum": "1000"
  8765. // })
  8766. .then(function (data) {
  8767. if (data) {
  8768. $scope.attachments = data.list;
  8769. $scope.view = function (attachmentId) {
  8770. for (
  8771. var i = 0;
  8772. i < $scope.attachments.length;
  8773. i++
  8774. ) {
  8775. if ($scope.attachments[i].id == attachmentId) {
  8776. window.open($scope.attachments[i].previewUrl);
  8777. }
  8778. }
  8779. };
  8780. $scope.download = function (contentId, filename) {
  8781. api_solution
  8782. .getSolutionDowpath(contentId)
  8783. .then(function (response) {
  8784. var file = new Blob([response], {
  8785. type: "application/octet-stream",
  8786. });
  8787. // var filename = filename;
  8788. var fileURL = URL.createObjectURL(file);
  8789. var a = document.createElement("a");
  8790. a.href = fileURL;
  8791. a.target = "_blank";
  8792. a.download = filename;
  8793. document.body.appendChild(a);
  8794. a.click();
  8795. });
  8796. };
  8797. }
  8798. });
  8799. };
  8800. $scope.related = function (item) {
  8801. if (item.content != null) {
  8802. item.content = item.content
  8803. .replace("<p>", "")
  8804. .replace("</p>", "");
  8805. }
  8806. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8807. options.model.handleDescription = item.content;
  8808. var data = {
  8809. solutionQuote: {
  8810. solutionId: item.id,
  8811. incidentsign: options.model.incidentsign,
  8812. },
  8813. };
  8814. api_zsk.solutionQuote(item.id).then(function (response) {
  8815. if (response.status == 200) {
  8816. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8817. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8818. "close";
  8819. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8820. } else {
  8821. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8822. }
  8823. });
  8824. };
  8825. $scope.close = function () {
  8826. $scope.changes = !$scope.changes;
  8827. event.preventDefault();
  8828. };
  8829. }
  8830. });
  8831. }
  8832. };
  8833. },
  8834. ],
  8835. });
  8836. //侧滑选择重复事件
  8837. formlyConfigProvider.setType({
  8838. name: "ui-repeatIncidentbtn",
  8839. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8840. defaultOptions: function (options) {
  8841. return {
  8842. templateOptions: {
  8843. relationAction: function (fields, modelscope, item) { },
  8844. },
  8845. validators: {
  8846. required: {
  8847. expression: function (viewValue, modelValue) {
  8848. // var value = modelValue || viewValue;
  8849. },
  8850. },
  8851. },
  8852. };
  8853. },
  8854. controller: [
  8855. "$scope",
  8856. "$rootScope",
  8857. "$modal",
  8858. "SweetAlert",
  8859. "api_bpm_data",
  8860. "api_solution",
  8861. "$aside",
  8862. "api_zsk",
  8863. "api_bpm_domain",
  8864. "api_webservice1",
  8865. function (
  8866. $scope,
  8867. $rootScope,
  8868. $modal,
  8869. SweetAlert,
  8870. api_bpm_data,
  8871. api_solution,
  8872. $aside,
  8873. api_zsk,
  8874. api_bpm_domain,
  8875. api_webservice1
  8876. ) {
  8877. console.log($scope);
  8878. $scope.selection = {
  8879. id: "",
  8880. };
  8881. //认证计费数据获取
  8882. $scope.sumInfo = {};
  8883. function getSumInfo() {
  8884. $scope.isHk = $rootScope.isHk;
  8885. if($rootScope.isHk){
  8886. //用户信息
  8887. api_webservice1.fetchDataList("queryUser", { "userId": $scope.model.incident.account }).then(function(response) {
  8888. // if (response.status == 200) {
  8889. if (response && response.data) {
  8890. angular.extend($scope.sumInfo, response.data[0]);
  8891. // $scope.sumInfo = response.data[0];
  8892. $scope.sumInfo.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  8893. $scope.sumInfo.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  8894. $scope.sumInfo.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  8895. } else if (response.err) {
  8896. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  8897. }
  8898. // }
  8899. })
  8900. //上网明细
  8901. api_webservice1.fetchDataList("queryOnlineDetail", { "userId": $scope.model.incident.account, "limit": "10", "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'), "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') }).then(function(response) {
  8902. // if (response.status == 200) {
  8903. if (response && response.data) {
  8904. angular.forEach(response.data, function(item, index) {
  8905. if (item.logoutTime) {
  8906. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  8907. }
  8908. if (item.loginTime) {
  8909. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  8910. }
  8911. })
  8912. $scope.logininform_sumInfo = response.data;
  8913. } else if (response.err) {
  8914. SweetAlert.swal("上网明细未取到", "该用户暂无上网明细", "error");
  8915. }
  8916. })
  8917. //黑名单
  8918. // $scope.sumInfo.blacklist = "否"
  8919. api_webservice1.fetchDataList("queryInhibit", { "userId": $scope.model.incident.account }).then(function(response) {
  8920. // if (response.status == 200) {
  8921. // $scope.loginsumInfo = response.data;
  8922. if (response) {
  8923. if (response.data || response.data != null) {
  8924. $scope.sumInfo.blacklist = "是"
  8925. } else {
  8926. if (response.err) {
  8927. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  8928. } else {
  8929. $scope.sumInfo.blacklist = "否"
  8930. }
  8931. }
  8932. }
  8933. // }
  8934. })
  8935. }else{
  8936. api_bpm_data
  8937. .sumInfo($scope.model.incident.account)
  8938. .then(function (data) {
  8939. console.log(data);
  8940. if (data) {
  8941. $scope.sumInfo = data.data || {};
  8942. }
  8943. });
  8944. }
  8945. }
  8946. getSumInfo();
  8947. // 收起重复事件侧滑框
  8948. function reashdata(item) {
  8949. var fildata = {
  8950. idx: 0,
  8951. incident: {
  8952. department: {
  8953. id: $scope.model.incident.department.id,
  8954. },
  8955. },
  8956. sum: 3,
  8957. };
  8958. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8959. console.log(data);
  8960. if (data) {
  8961. $scope.repeatData = data.list;
  8962. }
  8963. });
  8964. }
  8965. reashdata();
  8966. // 确认选中的重复事件
  8967. $scope.repeatIncidentOk = function () {
  8968. if ($scope.selection.id) {
  8969. $scope.model.incident.repeat = $scope.selection;
  8970. $scope.model.isRepeat = true; //隐藏处理信息
  8971. console.log($scope.model);
  8972. }
  8973. angular.element("#repeatIncident").removeClass("active");
  8974. };
  8975. // 取消选中的重复事件
  8976. $scope.repeatIncidentCancle = function () {
  8977. angular.element("#repeatIncident").removeClass("active");
  8978. return;
  8979. };
  8980. },
  8981. ],
  8982. });
  8983. //侧滑选择知识库查询
  8984. formlyConfigProvider.setType({
  8985. name: "ui-knowledgebtn",
  8986. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8987. defaultOptions: function (options) {
  8988. return {
  8989. templateOptions: {
  8990. relationAction: function (fields, modelscope, item) { },
  8991. },
  8992. validators: {
  8993. required: {
  8994. expression: function (viewValue, modelValue) {
  8995. // var value = modelValue || viewValue;
  8996. },
  8997. },
  8998. },
  8999. };
  9000. },
  9001. controller: [
  9002. "$scope",
  9003. "$rootScope",
  9004. "$modal",
  9005. "SweetAlert",
  9006. "api_bpm_data",
  9007. "api_solution",
  9008. "$aside",
  9009. "api_zsk",
  9010. "api_bpm_domain",
  9011. "api_wechatfile",
  9012. "up_down_file",
  9013. function (
  9014. $scope,
  9015. $rootScope,
  9016. $modal,
  9017. SweetAlert,
  9018. api_bpm_data,
  9019. api_solution,
  9020. $aside,
  9021. api_zsk,
  9022. api_bpm_domain,
  9023. api_wechatfile,
  9024. up_down_file
  9025. ) {
  9026. $scope.keypressModel = function (e, key) {
  9027. if (e.keyCode === 13) {
  9028. $scope.openModel(key);
  9029. }
  9030. };
  9031. // 引用知识库点击
  9032. $scope.searchKeyWord = "";
  9033. $scope.openModel = function (key) {
  9034. // alert(1)//重点
  9035. $scope.searchKeyWord = key;
  9036. if (key) {
  9037. api_zsk
  9038. .solutionData(
  9039. {
  9040. solution: {
  9041. threeSearch: key,
  9042. status: { id: 72 }, //已发布
  9043. selectType: "keySearch",
  9044. },
  9045. idx: "0",
  9046. sum: "1000",
  9047. },
  9048. "solution"
  9049. )
  9050. .then(function (response) {
  9051. $scope.searchData = response.list;
  9052. });
  9053. }
  9054. };
  9055. $scope.openModel($scope.model.incident.description);
  9056. // 展开/收起
  9057. $scope.showId = "";
  9058. $scope.ifshow = false;
  9059. $scope.showAll = function (id) {
  9060. $scope.attachments = [];
  9061. if ($scope.showId == id) {
  9062. $scope.ifshow = !$scope.ifshow;
  9063. } else {
  9064. $scope.ifshow = true;
  9065. }
  9066. $scope.showId = id;
  9067. // 获取附件
  9068. api_wechatfile
  9069. .listAttachments("knowledge", $scope.showId)
  9070. .then(function (data) {
  9071. $scope.attachments = data.data;
  9072. $scope.download = function (token, filename) {
  9073. var downUrl = up_down_file
  9074. .downloadAttachment("common/common/downloadAttachment", token)
  9075. .getRequestedUrl();
  9076. // window.open(downUrl);
  9077. var a = document.createElement("a");
  9078. a.href = downUrl;
  9079. a.target = "_blank";
  9080. a.download = filename;
  9081. document.body.appendChild(a);
  9082. a.click();
  9083. };
  9084. });
  9085. };
  9086. // 引用
  9087. $scope.related = function (item) {
  9088. console.log(item, "引用名");
  9089. if (item.content) {
  9090. item.content = item.content
  9091. .replace(/<p>/g, "")
  9092. .replace(/<\/p>/g, "")
  9093. .replace(/&nbsp;/g, "");
  9094. }
  9095. $scope.model.incident.handleDescription = item.content;
  9096. $scope.model.incident.title = $scope.model.incident.description =
  9097. item.title;
  9098. $scope.model.incident.category = item.category;
  9099. if (item.category) {
  9100. $scope.model.incident.priority.id = item.category.priority.id;
  9101. item.category.label = item.category.category;
  9102. }
  9103. var categoryId = item.category ? item.category.id : "";
  9104. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  9105. function getres(nodes) {
  9106. if (!nodes || nodes.length == 0) {
  9107. return;
  9108. }
  9109. nodes.forEach((e) => {
  9110. e.selected = false;
  9111. if (e.id == categoryId) {
  9112. e.selected = true;
  9113. return false;
  9114. }
  9115. getres(e.children);
  9116. });
  9117. }
  9118. var categorys = [];
  9119. $scope.fields.forEach((e, i) => {
  9120. if (e.key == "category") {
  9121. categorys = e.templateOptions.options;
  9122. if (categorys.length) {
  9123. getres(categorys);
  9124. $scope.fields[i].templateOptions.options = categorys;
  9125. $scope.$root.refreshSelectedItems();
  9126. }
  9127. return false;
  9128. }
  9129. });
  9130. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9131. $scope.model.candidateGroups = item.category
  9132. ? item.category.group
  9133. : {};
  9134. // 携带关联优先级,事件工单信息的时间
  9135. if (
  9136. $scope.model &&
  9137. $scope.model.incident &&
  9138. item.category &&
  9139. item.category.priority &&
  9140. item.category.priority.id
  9141. ) {
  9142. api_bpm_domain
  9143. .expectedTime("L" + (item.category.priority.id - 1559))
  9144. .then(function (res) {
  9145. $scope.model.incident.expectResponseTime =
  9146. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9147. res.serviceLevelAgreement.responseTime;
  9148. $scope.model.incident.expectIntroTime =
  9149. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9150. res.serviceLevelAgreement.resolveTime;
  9151. $scope.model.incident.overdueTime =
  9152. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9153. res.date;
  9154. });
  9155. }
  9156. api_zsk.solutionQuote(item.id).then(function (response) {
  9157. if (response.status == 200) {
  9158. $("#seachknowledge").removeClass("active");
  9159. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9160. $scope.$parent.$parent.$parent.model.start_code = "close";
  9161. $scope.$parent.$parent.$parent.model.directClose = 0;
  9162. console.log($scope.model);
  9163. } else {
  9164. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9165. }
  9166. });
  9167. };
  9168. },
  9169. ],
  9170. });
  9171. //下拉输入组件
  9172. formlyConfigProvider.setType({
  9173. name: "ui-selectinput",
  9174. extends: "input",
  9175. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9176. defaultOptions: function (options) {
  9177. return {
  9178. templateOptions: {
  9179. refresh: function () { },
  9180. refreshDelay: 0,
  9181. linkage: function (modelName, data) { },
  9182. },
  9183. };
  9184. },
  9185. controller: [
  9186. "$scope",
  9187. "$rootScope",
  9188. "$modal",
  9189. "SweetAlert",
  9190. "api_bpm_data",
  9191. "api_solution",
  9192. "$aside",
  9193. function (
  9194. $scope,
  9195. $rootScope,
  9196. $modal,
  9197. SweetAlert,
  9198. api_bpm_data,
  9199. api_solution,
  9200. $aside
  9201. ) {
  9202. $scope.searchData = "";
  9203. $scope.onChangeadd = function (searchData) {
  9204. // $scope.searchKey = searchData.account;
  9205. // var requesdata = angular.copy(searchData)
  9206. // $scope.requester = requesdata;
  9207. };
  9208. $scope.refreshUseradd = function (searchKey) {
  9209. //主题搜索
  9210. // $scope.searchData = searchKey;
  9211. // reashdata($scope.searchData);
  9212. };
  9213. $scope.getMydata = function (x) {
  9214. $scope.model[$scope.options.key] =
  9215. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9216. $scope.searchField = $scope.model[$scope.options.key];
  9217. };
  9218. $scope.getMydataone = function (x) {
  9219. $scope.model[$scope.options.key] = x;
  9220. $scope.searchField = $scope.model[$scope.options.key];
  9221. if (
  9222. $scope.model[$scope.options.key] &&
  9223. $scope.model[$scope.options.key] != ""
  9224. ) {
  9225. $scope.hidden = false;
  9226. } else {
  9227. $scope.hidden = true;
  9228. }
  9229. };
  9230. function reashdata(item) {
  9231. $scope.myData = $scope.options.templateOptions.mydata;
  9232. }
  9233. reashdata();
  9234. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9235. $scope.options.templateOptions.fetchItems($scope);
  9236. }
  9237. },
  9238. ],
  9239. });
  9240. //重构组件模板
  9241. //获取当前人
  9242. formlyConfigProvider.setType({
  9243. name: "ui-users",
  9244. extends: "input",
  9245. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9246. defaultOptions: function (options) {
  9247. return {
  9248. templateOptions: {
  9249. translate: "",
  9250. refreshDelay: 0,
  9251. },
  9252. };
  9253. },
  9254. controller: [
  9255. "$scope",
  9256. function ($scope) {
  9257. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9258. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9259. },
  9260. ],
  9261. });
  9262. //只读控件
  9263. formlyConfigProvider.setType({
  9264. name: "ui-label",
  9265. extends: "input",
  9266. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9267. defaultOptions: function (options) {
  9268. return {
  9269. templateOptions: {
  9270. translate: "",
  9271. refreshDelay: 0,
  9272. },
  9273. };
  9274. },
  9275. controller: [
  9276. "$scope",
  9277. "$rootScope",
  9278. function ($scope, $rootScope) {
  9279. // console.log($scope.options.templateOptions)
  9280. // console.log($scope.options,'options1122');
  9281. $scope.isSolutionLabel = false;
  9282. $scope.solutionLabelStr = "";
  9283. // console.log($scope.options.templateOptions.solotinLabel);
  9284. if ($scope.options.templateOptions.solotinLabel) {
  9285. $scope.isSolutionLabel = true;
  9286. if ($scope.model[$scope.options.key]) {
  9287. var solutionArr = $scope.model[$scope.options.key].split("/");
  9288. $scope.solutionLabelStr = solutionArr.join(" ");
  9289. }
  9290. }
  9291. var value = $scope.model[$scope.options.key];
  9292. // ----------------
  9293. // ----------------
  9294. // console.log(value, 'pppp')
  9295. function treeDesc(children, key, label) {
  9296. if (label == "") {
  9297. label = children[key];
  9298. } else {
  9299. label = children[key] + "-" + label;
  9300. }
  9301. if (angular.isDefined(children.parent)) {
  9302. treeDesc(children.parent, key, label);
  9303. } else {
  9304. return label;
  9305. }
  9306. }
  9307. if (angular.isArray(value)) {
  9308. var tempValue = "";
  9309. angular.forEach(value, function (item) {
  9310. if (tempValue != "") {
  9311. tempValue = tempValue + ",";
  9312. }
  9313. tempValue =
  9314. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9315. item;
  9316. });
  9317. $scope.options.templateOptions.translate = tempValue;
  9318. } else if (angular.isObject(value)) {
  9319. if (
  9320. angular.isDefined(value.children) ||
  9321. angular.isDefined(value.parent)
  9322. ) {
  9323. //tree
  9324. // console.log("value.parent="+JSON.stringify(value.parent))
  9325. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9326. nameLabel = treeDesc(
  9327. value.parent,
  9328. $scope.options.templateOptions.labelProp,
  9329. nameLabel
  9330. );
  9331. $scope.options.templateOptions.translate = nameLabel;
  9332. } else {
  9333. $scope.options.templateOptions.translate = value;
  9334. }
  9335. } else if (
  9336. angular.isString(value) &&
  9337. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9338. ) {
  9339. // console.log("value=" + value);
  9340. $scope.options.templateOptions.translate = value;
  9341. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9342. // console.log("value="+value);
  9343. // $scope.options.templateOptions.translate = value;
  9344. } else {
  9345. // var datasdf = JSON.parse(value);
  9346. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9347. $scope.options.templateOptions.translate = value;
  9348. }
  9349. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9350. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9351. $scope.options.templateOptions.translate =
  9352. $scope.options.templateOptions.transform(
  9353. $scope.originalModel,
  9354. value,
  9355. $rootScope,
  9356. $scope
  9357. );
  9358. }
  9359. // console.log($scope.options.templateOptions.translate,99999);
  9360. },
  9361. ],
  9362. });
  9363. //小标题组件
  9364. formlyConfigProvider.setType({
  9365. name: "ui-header",
  9366. template:
  9367. '<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>',
  9368. });
  9369. //标题组件
  9370. formlyConfigProvider.setType({
  9371. name: "ui-title",
  9372. template:
  9373. '<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>',
  9374. });
  9375. //标栏是否展示
  9376. formlyConfigProvider.setType({
  9377. name: "ui-orshow",
  9378. template:
  9379. '<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>',
  9380. controller: [
  9381. "$scope",
  9382. function ($scope) {
  9383. $scope.clickshow = function (key) {
  9384. // $scope.model[$scope.options.key] != key;
  9385. if (key == false) {
  9386. $scope.model[$scope.options.key] = true;
  9387. } else {
  9388. $scope.model[$scope.options.key] = false;
  9389. }
  9390. };
  9391. },
  9392. ],
  9393. });
  9394. //按钮组
  9395. formlyConfigProvider.setType({
  9396. name: "ui-button",
  9397. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9398. defaultOptions: function (options) {
  9399. return {
  9400. noFormControl: true,
  9401. };
  9402. },
  9403. });
  9404. //3d组link
  9405. formlyConfigProvider.setType({
  9406. name: "ui-link",
  9407. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9408. defaultOptions: function (options) {
  9409. return {
  9410. noFormControl: true,
  9411. };
  9412. },
  9413. });
  9414. //隐藏域组件
  9415. formlyConfigProvider.setType({
  9416. name: "ui-hidden",
  9417. extends: "input",
  9418. template:
  9419. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9420. defaultOptions: function (options) {
  9421. return {
  9422. // noFormControl: true
  9423. };
  9424. },
  9425. });
  9426. //文本框组件
  9427. formlyConfigProvider.setType({
  9428. name: "ui-input",
  9429. extends: "input",
  9430. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9431. defaultOptions: function (options) {
  9432. return {
  9433. templateOptions: {
  9434. transform: function (value) { },
  9435. },
  9436. };
  9437. },
  9438. controller: [
  9439. "$scope",
  9440. "$timeout",
  9441. function ($scope, $timeout) {
  9442. // console.log($scope.model[$scope.options.key]);
  9443. // console.log($scope.options)
  9444. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9445. $scope.model[$scope.options.key] =
  9446. $scope.options.templateOptions.linkData($scope.model);
  9447. }
  9448. },
  9449. ],
  9450. });
  9451. //搜索下拉框-故障地点seimin
  9452. formlyConfigProvider.setType({
  9453. name: "ui-select-search",
  9454. extends: "input",
  9455. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9456. defaultOptions: function (options) {
  9457. return {
  9458. templateOptions: {
  9459. transform: function (value) { },
  9460. },
  9461. };
  9462. },
  9463. controller: [
  9464. "$scope",
  9465. "$rootScope",
  9466. "api_search_area",
  9467. function ($scope, $rootScope, api_search_area) {
  9468. // console.log($scope.options, $scope.model)
  9469. // ----------------分割线 start-----------------
  9470. // 故障地点下拉
  9471. $scope.address_arr = []; //故障地点所有数据
  9472. $scope.addressFlag = false; //默认下拉框列表隐藏
  9473. //点击文本框
  9474. $scope.AddressClickHandle = function () {
  9475. $scope.getDepartmentList();
  9476. angular.element("#bx_address_ul").scrollTop(0);
  9477. };
  9478. //修改文字,实时监听
  9479. $scope.ksChangeHandle = _.debounce(function () {
  9480. $scope.model[$scope.options.key] =
  9481. $scope.model[$scope.options.key] === undefined
  9482. ? ""
  9483. : $scope.model[$scope.options.key];
  9484. $scope.getDepartmentList();
  9485. angular.element("#bx_address_ul").scrollTop(0);
  9486. }, 500);
  9487. //获取故障地点seimin
  9488. $scope.getDepartmentList = function () {
  9489. $scope.model[$scope.options.key] =
  9490. $scope.model[$scope.options.key] === null
  9491. ? ""
  9492. : $scope.model[$scope.options.key];
  9493. api_search_area
  9494. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9495. .then((res) => {
  9496. if (res.state == 200) {
  9497. $scope.address_arr = res.result;
  9498. $scope.addressFlag = true; //显示
  9499. }
  9500. })
  9501. .catch((err) => {
  9502. console.log(err);
  9503. });
  9504. };
  9505. // $scope.getDepartmentList();
  9506. // console.log($scope.model[$scope.options.key])
  9507. //下拉框列表选中
  9508. $scope.addressItemClick = function (obj) {
  9509. $scope.addressFlag = false; //隐藏
  9510. $scope.model[$scope.options.key] = obj.place
  9511. ? obj.area.area + obj.place
  9512. : obj.area;
  9513. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9514. $scope.model.selecthouseNumber = obj;
  9515. console.log($scope, 77777);
  9516. $scope.$root.selecthouseNumber = obj;
  9517. };
  9518. //点击空白处隐藏
  9519. angular.element(document).on("click", function (e) {
  9520. if (e.target !== angular.element("#bx_address").get(0)) {
  9521. $scope.addressFlag = false; //隐藏
  9522. //模拟placeholder
  9523. // if ($('#bx_address').val() == '') {
  9524. // $('#bx_address').val('请选择报修科室');
  9525. // }
  9526. }
  9527. });
  9528. // -----------------分割线 end----------------
  9529. },
  9530. ],
  9531. });
  9532. //知识库关键字组件
  9533. formlyConfigProvider.setType({
  9534. name: "ui-knowledgeKeywords",
  9535. extends: "input",
  9536. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9537. defaultOptions: function (options) {
  9538. return {
  9539. templateOptions: {
  9540. transform: function (value) { },
  9541. },
  9542. };
  9543. },
  9544. controller: [
  9545. "$scope",
  9546. "$timeout",
  9547. "SweetAlert",
  9548. function ($scope, $timeout, SweetAlert) {
  9549. $scope.valueLength = [
  9550. {
  9551. value: "",
  9552. },
  9553. ];
  9554. $scope.valueAll = [];
  9555. if ($scope.model[$scope.options.key]) {
  9556. var valueArr = $scope.model[$scope.options.key].split("/");
  9557. $scope.valueLength = [];
  9558. for (var i = 0; i < valueArr.length; i++) {
  9559. $scope.valueLength.push({
  9560. value: valueArr[i],
  9561. });
  9562. }
  9563. }
  9564. $scope.addIpt = function () {
  9565. if ($scope.valueLength.length < 5) {
  9566. $scope.valueLength.push({
  9567. value: "",
  9568. });
  9569. } else {
  9570. SweetAlert.swal({
  9571. title: "添加失败",
  9572. text: "关键字不能超过5个!",
  9573. type: "error",
  9574. confirmButtonColor: "#DD6B55",
  9575. });
  9576. }
  9577. };
  9578. $scope.closeIpt = function (data) {
  9579. $scope.valueLength.splice(data, 1);
  9580. };
  9581. $scope.toOption = function () {
  9582. $scope.valueAll = [];
  9583. for (var i = 0; i < $scope.valueLength.length; i++) {
  9584. if ($scope.valueLength[i].value != "") {
  9585. $scope.valueAll.push($scope.valueLength[i].value);
  9586. }
  9587. }
  9588. $scope.model.label = $scope.valueAll.join("/");
  9589. };
  9590. },
  9591. ],
  9592. });
  9593. //文本框组件
  9594. formlyConfigProvider.setType({
  9595. name: "ui-num",
  9596. extends: "input",
  9597. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9598. defaultOptions: function (options) {
  9599. return {
  9600. templateOptions: {
  9601. transform: function (value) { },
  9602. },
  9603. };
  9604. },
  9605. controller: [
  9606. "$scope",
  9607. "$timeout",
  9608. function ($scope, $timeout) {
  9609. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9610. $scope.model[$scope.options.key] =
  9611. $scope.options.templateOptions.linkData($scope.model);
  9612. }
  9613. $scope.clearNoNum = function (obj, attr) {
  9614. //先把非数字的都替换掉,除了数字和.
  9615. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9616. //必须保证第一个为数字而不是.
  9617. obj[attr] = obj[attr].replace(/^\./g, "");
  9618. //保证只有出现一个.而没有多个.
  9619. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9620. //保证.只出现一次,而不能出现两次以上
  9621. obj[attr] = obj[attr]
  9622. .replace(".", "$#$")
  9623. .replace(/\./g, "")
  9624. .replace("$#$", ".");
  9625. //小于最大值
  9626. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9627. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9628. // obj[attr] = '';
  9629. // }
  9630. };
  9631. },
  9632. ],
  9633. });
  9634. // //关联请求人文本框组件
  9635. // formlyConfigProvider.setType({
  9636. // name: 'ui-requestinput',
  9637. // extends: 'input',
  9638. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9639. // defaultOptions: function(options) {
  9640. // return {
  9641. // templateOptions: {
  9642. // transform: function(value) {},
  9643. // linkData: function(options) {}
  9644. // }
  9645. // };
  9646. // }
  9647. // });
  9648. //只读文本
  9649. formlyConfigProvider.setType({
  9650. name: "ui-disableinput",
  9651. extends: "input",
  9652. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9653. defaultOptions: function (options) {
  9654. return {
  9655. templateOptions: {
  9656. transform: function (value) {
  9657. var ret = "";
  9658. if (value) {
  9659. ret = "已删除";
  9660. } else {
  9661. ret = "正常";
  9662. }
  9663. return ret;
  9664. },
  9665. },
  9666. };
  9667. },
  9668. });
  9669. formlyConfigProvider.setType({
  9670. name: "ui-disinput",
  9671. extends: "input",
  9672. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9673. defaultOptions: function (options) {
  9674. return {
  9675. templateOptions: {},
  9676. };
  9677. },
  9678. });
  9679. //数字组件
  9680. formlyConfigProvider.setType({
  9681. name: "ui-number",
  9682. extends: "input",
  9683. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9684. defaultOptions: function (options) {
  9685. return {
  9686. templateOptions: {},
  9687. };
  9688. },
  9689. controller: ["$scope", function ($scope) { }],
  9690. });
  9691. //含有周的日期
  9692. formlyConfigProvider.setType({
  9693. name: "ui-datepickerweek",
  9694. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9695. extends: "input",
  9696. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9697. defaultOptions: {
  9698. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9699. templateOptions: {
  9700. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9701. },
  9702. },
  9703. controller: [
  9704. "$scope",
  9705. "$filter",
  9706. function ($scope, $filter) {
  9707. $scope.mindata = new Date(
  9708. $scope.options.templateOptions.transform($scope.model).getTime() +
  9709. 5 * 60 * 1000
  9710. );
  9711. if ($scope.model[$scope.options.key]) {
  9712. } else {
  9713. $scope.model[$scope.options.key] = $filter("date")(
  9714. new Date(new Date().getTime()),
  9715. $scope.options.templateOptions.datepickerPopup
  9716. );
  9717. }
  9718. $scope.options.initialValue = $scope.model[$scope.options.key];
  9719. $scope.endOpen = true;
  9720. $scope.datepicker = {};
  9721. $scope.datepicker.opened = false;
  9722. $scope.datepicker.open = function ($event) {
  9723. $scope.datepicker.opened = true;
  9724. };
  9725. },
  9726. ],
  9727. });
  9728. //lmm
  9729. //分配任务列表
  9730. formlyConfigProvider.setType({
  9731. name: "jry_taskDistributionList",
  9732. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9733. wrapper: ["bootstrapHasError"],
  9734. defaultOptions: function (options, $scope) {
  9735. return {
  9736. templateOptions: {},
  9737. };
  9738. },
  9739. controller: function (
  9740. $rootScope,
  9741. $scope,
  9742. api_user_data,
  9743. $modal,
  9744. api_doc_data,
  9745. i18nService,
  9746. SweetAlert,
  9747. api_wechatfile
  9748. ) {
  9749. // 获取状态
  9750. $scope.stateListData = {};
  9751. $scope.getStateData = function () {
  9752. //lyl
  9753. var data = {
  9754. key: "task_sub_state",
  9755. type: "list",
  9756. };
  9757. api_wechatfile.getDictionary(data).then(function (res) {
  9758. angular.forEach(res, function (v, i) {
  9759. $scope.stateListData[v.value] = v.id;
  9760. });
  9761. });
  9762. };
  9763. $scope.getStateData();
  9764. var loginUser = $rootScope.user;
  9765. $scope.langs = i18nService.getAllLangs();
  9766. $scope.lang = "zh-cn";
  9767. i18nService.setCurrentLang($scope.lang);
  9768. $scope.gridOptions = {};
  9769. $scope.gridOptions.data = "myData";
  9770. $scope.gridOptions.enableColumnResizing = true;
  9771. $scope.gridOptions.enableGridMenu = false;
  9772. $scope.gridOptions.enableRowSelection = true;
  9773. $scope.gridOptions.showGridFooter = true;
  9774. $scope.gridOptions.showColumnFooter = false;
  9775. $scope.gridOptions.fastWatch = true;
  9776. $scope.gridOptions.useExternalFiltering = true;
  9777. $scope.gridOptions.useExternalPagination = true;
  9778. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9779. $scope.gridOptions.paginationPageSize = 10;
  9780. $scope.gridOptions.multiSelect = true;
  9781. $scope.gridOptions.rowIdentity = function (row) {
  9782. return row.id;
  9783. };
  9784. $scope.gridOptions.getRowIdentity = function (row) {
  9785. return row.id;
  9786. };
  9787. // console.log($scope.model);//lmmmm
  9788. $scope.gridOptions.columnDefs = [
  9789. {
  9790. name: "item",
  9791. displayName: "序号",
  9792. width: "10%",
  9793. cellTemplate:
  9794. "<div>" +
  9795. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9796. "</div>",
  9797. },
  9798. {
  9799. name: "taskDescribe",
  9800. displayName: "任务说明",
  9801. width: "25%",
  9802. enableFiltering: false,
  9803. cellTemplate:
  9804. "<div>" +
  9805. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9806. "</div>",
  9807. },
  9808. {
  9809. name: "assign.name",
  9810. displayName: "指派人",
  9811. width: "5%",
  9812. enableFiltering: false,
  9813. cellTemplate:
  9814. "<div>" +
  9815. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9816. "</div>",
  9817. },
  9818. {
  9819. name: "startTime",
  9820. displayName: "开始时间",
  9821. width: "13%",
  9822. enableFiltering: false,
  9823. cellTemplate:
  9824. "<div>" +
  9825. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9826. "</div>",
  9827. },
  9828. {
  9829. name: "endTime",
  9830. displayName: "结束时间",
  9831. width: "13%",
  9832. enableFiltering: false,
  9833. cellTemplate:
  9834. "<div>" +
  9835. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9836. "</div>",
  9837. },
  9838. {
  9839. name: "priority.name",
  9840. displayName: "优先级",
  9841. width: "5%",
  9842. enableFiltering: false,
  9843. cellTemplate:
  9844. "<div>" +
  9845. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9846. "</div>",
  9847. },
  9848. {
  9849. name: "state.name",
  9850. displayName: "状态",
  9851. width: "5%",
  9852. enableFiltering: false,
  9853. cellTemplate:
  9854. "<div>" +
  9855. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9856. "</div>",
  9857. },
  9858. {
  9859. name: "操作", //lmmm
  9860. cellTemplate:
  9861. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9862. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9863. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9864. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9865. '<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>' +
  9866. "</div></div>",
  9867. enableFiltering: false,
  9868. },
  9869. ];
  9870. // 查看
  9871. $scope.see = function (data) {
  9872. $scope.seeData = data;
  9873. var modalInstance = $modal.open({
  9874. backdrop: false,
  9875. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9876. controller: function (
  9877. $scope,
  9878. scope,
  9879. $modalInstance,
  9880. api_doc_data,
  9881. SweetAlert,
  9882. api_user_data,
  9883. api_wechatfile
  9884. ) {
  9885. $scope.personData = {}; //指派人
  9886. $scope.priorityData = {}; //优先级
  9887. $scope.personListData = {}; //指派人下拉数据
  9888. $scope.priorityListData = {}; //优先级下拉数据
  9889. $scope.startTime = ""; //开始时间
  9890. $scope.releaseShow = "no";
  9891. $scope.subShow = "no";
  9892. $scope.onlySee = "ok";
  9893. $scope.endTime = ""; //结束时间
  9894. $scope.taskDescribe = ""; //任务描述
  9895. $scope.taskDescribe = scope.seeData.taskDescribe;
  9896. $scope.personData.data = scope.seeData.assign;
  9897. $scope.priorityData.data = scope.seeData.priority;
  9898. $scope.startTime = scope.seeData.startTime;
  9899. $scope.endTime = scope.seeData.endTime;
  9900. $scope.done = scope.seeData.done;
  9901. $scope.feedback = scope.seeData.feedback;
  9902. $scope.cancel = function () {
  9903. $modalInstance.dismiss("cancel");
  9904. };
  9905. },
  9906. size: "sm",
  9907. resolve: {
  9908. scope: function () {
  9909. return $scope;
  9910. },
  9911. },
  9912. backdrop: true,
  9913. });
  9914. };
  9915. // 编辑
  9916. $scope.edit = function (data) {
  9917. $scope.editData = data;
  9918. var modalInstance = $modal.open({
  9919. backdrop: false,
  9920. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9921. controller: function (
  9922. $scope,
  9923. scope,
  9924. $modalInstance,
  9925. api_doc_data,
  9926. SweetAlert,
  9927. api_user_data,
  9928. api_wechatfile
  9929. ) {
  9930. console.log(scope.editData);
  9931. $scope.personData = {}; //指派人
  9932. $scope.priorityData = {}; //优先级
  9933. $scope.personListData = {}; //指派人下拉数据
  9934. $scope.priorityListData = {}; //优先级下拉数据
  9935. $scope.startTime = ""; //开始时间
  9936. $scope.releaseShow = "no";
  9937. $scope.endTime = ""; //结束时间
  9938. $scope.taskDescribe = ""; //任务描述
  9939. $scope.taskDescribe = scope.editData.taskDescribe;
  9940. $scope.personData.data = scope.editData.assign;
  9941. $scope.priorityData.data = scope.editData.priority;
  9942. $scope.startTime = scope.editData.startTime;
  9943. $scope.endTime = scope.editData.endTime;
  9944. // 指派人下拉框数据
  9945. $scope.getPersonData = function () {
  9946. var data = {
  9947. idx: 0,
  9948. sum: 1000,
  9949. };
  9950. api_user_data.fetchDataList("user", data).then(function (res) {
  9951. $scope.personListData = res.list;
  9952. });
  9953. };
  9954. $scope.getPersonData();
  9955. //优先级下拉数据
  9956. $scope.getPriorityData = function () {
  9957. var data = {
  9958. key: "change_rick_level",
  9959. type: "list",
  9960. };
  9961. api_wechatfile.getDictionary(data).then(function (res) {
  9962. $scope.priorityListData = res;
  9963. });
  9964. };
  9965. $scope.getPriorityData();
  9966. // 获取状态-lmm
  9967. $scope.stateListData = {};
  9968. $scope.getStateData = function () {
  9969. //lyl
  9970. var data = {
  9971. key: "task_sub_state",
  9972. type: "list",
  9973. };
  9974. api_wechatfile.getDictionary(data).then(function (res) {
  9975. angular.forEach(res, function (v, i) {
  9976. $scope.stateListData[v.value] = v.id;
  9977. });
  9978. });
  9979. };
  9980. $scope.getStateData();
  9981. //时间控件
  9982. $scope.open = function ($event) {
  9983. $event.preventDefault();
  9984. $event.stopPropagation();
  9985. $scope.opened = !$scope.opened;
  9986. };
  9987. $scope.endOpen = function ($event) {
  9988. $event.preventDefault();
  9989. $event.stopPropagation();
  9990. $scope.startOpened = false;
  9991. $scope.endOpened = !$scope.endOpened;
  9992. };
  9993. $scope.startOpen = function ($event) {
  9994. $event.preventDefault();
  9995. $event.stopPropagation();
  9996. $scope.endOpened = false;
  9997. $scope.startOpened = !$scope.startOpened;
  9998. };
  9999. // 确定
  10000. $scope.ok = function (item) {
  10001. if (
  10002. $scope.taskDescribe &&
  10003. $scope.personData.data &&
  10004. $scope.priorityData.data &&
  10005. $scope.startTime &&
  10006. $scope.endTime
  10007. ) {
  10008. $scope.startTime = moment(
  10009. new Date($scope.startTime).getTime()
  10010. ).format("YYYY-MM-DD HH:mm:ss");
  10011. $scope.endTime = moment(
  10012. new Date($scope.endTime).getTime()
  10013. ).format("YYYY-MM-DD HH:mm:ss");
  10014. $scope.addData = {
  10015. taskSub: {
  10016. taskDescribe: $scope.taskDescribe,
  10017. assign: $scope.personData.data,
  10018. priority: $scope.priorityData.data,
  10019. startTime: $scope.startTime,
  10020. endTime: $scope.endTime,
  10021. taskMonth: {
  10022. id: scope.model.taskMonth.id,
  10023. },
  10024. id: scope.editData.id,
  10025. },
  10026. };
  10027. $scope.addData.taskSub["state"] = {
  10028. id: $scope.stateListData[1],
  10029. };
  10030. api_user_data
  10031. .updData("taskSub", $scope.addData)
  10032. .then(function (res) {
  10033. if (res.status == 200) {
  10034. SweetAlert.swal({
  10035. title: "修改成功!",
  10036. type: "success",
  10037. confirmButtonColor: "#007AFF",
  10038. });
  10039. scope.refreshData(scope.jry_filterdata);
  10040. $modalInstance.dismiss("cancel");
  10041. } else {
  10042. SweetAlert.swal({
  10043. title: "修改失败",
  10044. text: "系统错误,请重试!",
  10045. type: "error",
  10046. });
  10047. $modalInstance.dismiss("cancel");
  10048. }
  10049. });
  10050. } else {
  10051. SweetAlert.swal({
  10052. title: "修改失败",
  10053. text: "必填项不能为空!",
  10054. type: "error",
  10055. });
  10056. }
  10057. };
  10058. $scope.cancel = function () {
  10059. $modalInstance.dismiss("cancel");
  10060. };
  10061. },
  10062. size: "sm",
  10063. resolve: {
  10064. scope: function () {
  10065. return $scope;
  10066. },
  10067. },
  10068. backdrop: true,
  10069. });
  10070. };
  10071. // 发布
  10072. $scope.release = function (data) {
  10073. SweetAlert.swal(
  10074. {
  10075. title: "确认发布?",
  10076. text: "请确定发布操作!",
  10077. type: "warning",
  10078. showCancelButton: true,
  10079. confirmButtonColor: "#DD6B55",
  10080. confirmButtonText: "确定",
  10081. cancelButtonText: "取消",
  10082. closeOnConfirm: false,
  10083. closeOnCancel: false,
  10084. },
  10085. function (isConfirm) {
  10086. if (isConfirm) {
  10087. data.state.id = $scope.stateListData[2];
  10088. delete data.item;
  10089. api_user_data
  10090. .updData("taskSub", {
  10091. taskSub: data,
  10092. })
  10093. .then(function (res) {
  10094. if (res.status == 200) {
  10095. SweetAlert.swal({
  10096. title: "发布成功!",
  10097. type: "success",
  10098. confirmButtonColor: "#007AFF",
  10099. });
  10100. $scope.refreshData($scope.jry_filterdata);
  10101. } else {
  10102. SweetAlert.swal({
  10103. title: "删除失败",
  10104. text: "系统错误,请重试!",
  10105. type: "error",
  10106. });
  10107. }
  10108. });
  10109. } else {
  10110. SweetAlert.swal("操作取消", "发布取消", "error");
  10111. }
  10112. }
  10113. );
  10114. };
  10115. // 删除
  10116. $scope.remove = function (data) {
  10117. SweetAlert.swal(
  10118. {
  10119. title: "确认删除?",
  10120. text: "删除的数据不可恢复,请确认继续操作!",
  10121. type: "warning",
  10122. showCancelButton: true,
  10123. confirmButtonColor: "#DD6B55",
  10124. confirmButtonText: "继续删除",
  10125. cancelButtonText: "取消操作",
  10126. closeOnConfirm: false,
  10127. closeOnCancel: false,
  10128. },
  10129. function (isConfirm) {
  10130. if (isConfirm) {
  10131. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10132. if (res.status == 200) {
  10133. SweetAlert.swal({
  10134. title: "删除成功!",
  10135. type: "success",
  10136. confirmButtonColor: "#007AFF",
  10137. });
  10138. $scope.refreshData($scope.jry_filterdata);
  10139. } else {
  10140. SweetAlert.swal({
  10141. title: "删除失败",
  10142. text: "系统错误,请重试!",
  10143. type: "error",
  10144. });
  10145. }
  10146. });
  10147. } else {
  10148. SweetAlert.swal("操作取消", "数据安全", "error");
  10149. }
  10150. }
  10151. );
  10152. };
  10153. $scope.refreshData = function (filterData) {
  10154. // $scope.ldloading[style.replace('-', '_')] = true;
  10155. if (angular.isUndefined(filterData)) {
  10156. filterData = defaultFilterData;
  10157. }
  10158. $scope.myData = [];
  10159. $scope.memoryfilterData = filterData;
  10160. api_doc_data.fetchDataList("taskSub", filterData).then(
  10161. function (data) {
  10162. var myData = data;
  10163. $scope.gridOptions.totalItems = myData.totalNum;
  10164. $scope.removeFileNum = myData.totalNum;
  10165. if (angular.isArray(myData.list)) {
  10166. $scope.myData = myData.list;
  10167. for (var i = 0; i < $scope.myData.length; i++) {
  10168. //添加序号
  10169. $scope.myData[i]["item"] =
  10170. i + 1 + filterData.idx * filterData.sum;
  10171. $scope.myData[i].startTime = moment(
  10172. $scope.myData[i].startTime
  10173. ).format("YYYY-MM-DD HH:mm:ss");
  10174. $scope.myData[i].endTime = moment(
  10175. $scope.myData[i].endTime
  10176. ).format("YYYY-MM-DD HH:mm:ss");
  10177. }
  10178. }
  10179. },
  10180. function () {
  10181. // $scope.ldloading[style.replace('-', '_')] = false;
  10182. }
  10183. );
  10184. };
  10185. //分页控制
  10186. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10187. gridApi.pagination.on.paginationChanged(
  10188. $scope,
  10189. function (newPage, pageSize) {
  10190. $scope.jry_filterdata.idx = newPage - 1;
  10191. $scope.fenye = newPage - 1;
  10192. $scope.jry_filterdata.sum = pageSize;
  10193. $scope.refreshData($scope.jry_filterdata);
  10194. }
  10195. );
  10196. };
  10197. $scope.fenye = 0;
  10198. if ($scope.model.label == "分配任务") {
  10199. $scope.jry_filterdata = {
  10200. idx: $scope.fenye,
  10201. sum: 10,
  10202. taskSub: {
  10203. taskMonth: {
  10204. id: $scope.model.taskMonth.id,
  10205. },
  10206. userid: loginUser.id,
  10207. role: loginUser.role,
  10208. },
  10209. };
  10210. } else {
  10211. $scope.jry_filterdata = {
  10212. idx: $scope.fenye,
  10213. sum: 10,
  10214. taskSub: {
  10215. taskMonth: {
  10216. id: $scope.model.taskMonth.id,
  10217. },
  10218. userid: loginUser.id,
  10219. role: loginUser.role,
  10220. type: 1,
  10221. },
  10222. };
  10223. }
  10224. $scope.refreshData($scope.jry_filterdata);
  10225. //新增模态框
  10226. $scope.newDistribution = function () {
  10227. var modalInstance = $modal.open({
  10228. backdrop: false,
  10229. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10230. controller: function (
  10231. $scope,
  10232. scope,
  10233. $modalInstance,
  10234. api_doc_data,
  10235. SweetAlert,
  10236. api_user_data,
  10237. api_wechatfile
  10238. ) {
  10239. $scope.personData = {}; //指派人
  10240. $scope.priorityData = {}; //优先级
  10241. $scope.personListData = {}; //指派人下拉数据
  10242. $scope.priorityListData = {}; //优先级下拉数据
  10243. $scope.startTime = ""; //开始时间
  10244. $scope.endTime = ""; //结束时间
  10245. $scope.taskDescribe = ""; //任务描述
  10246. $scope.motaikuang = "";
  10247. $scope.shijian = "哈哈";
  10248. // 指派人下拉框数据
  10249. $scope.getPersonData = function () {
  10250. var data = {
  10251. idx: 0,
  10252. sum: 1000,
  10253. };
  10254. api_user_data.fetchDataList("user", data).then(function (res) {
  10255. $scope.personListData = res.list;
  10256. });
  10257. };
  10258. $scope.getPersonData();
  10259. //优先级下拉数据
  10260. $scope.getPriorityData = function () {
  10261. var data = {
  10262. key: "change_rick_level",
  10263. type: "list",
  10264. };
  10265. api_wechatfile.getDictionary(data).then(function (res) {
  10266. $scope.priorityListData = res;
  10267. });
  10268. };
  10269. // 控制结束时间的最大时间
  10270. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10271. // 控制结束时间的最小时间
  10272. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10273. $scope.$watch("startTime", function (n, o) {
  10274. if (n) {
  10275. if (n > scope.model.taskMonth.startTime) {
  10276. $scope.jryEndMinTime = n;
  10277. }
  10278. }
  10279. });
  10280. // 控制开始时间的最小时间
  10281. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10282. // 控制开始时间的最大时间
  10283. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10284. $scope.$watch("endTime", function (n, o) {
  10285. if (n) {
  10286. if (n < scope.model.taskMonth.endTime) {
  10287. $scope.jryStartMaxTime = n;
  10288. }
  10289. }
  10290. });
  10291. $scope.getPriorityData();
  10292. //时间控件
  10293. $scope.open = function ($event) {
  10294. $event.preventDefault();
  10295. $event.stopPropagation();
  10296. $scope.opened = !$scope.opened;
  10297. };
  10298. $scope.endOpen = function ($event) {
  10299. $event.preventDefault();
  10300. $event.stopPropagation();
  10301. $scope.startOpened = false;
  10302. $scope.endOpened = !$scope.endOpened;
  10303. };
  10304. $scope.startOpen = function ($event) {
  10305. $event.preventDefault();
  10306. $event.stopPropagation();
  10307. $scope.endOpened = false;
  10308. $scope.startOpened = !$scope.startOpened;
  10309. };
  10310. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10311. // 获取状态-lmm
  10312. $scope.stateListData = {};
  10313. $scope.getStateData = function () {
  10314. //lyl
  10315. var data = {
  10316. key: "task_sub_state",
  10317. type: "list",
  10318. };
  10319. api_wechatfile.getDictionary(data).then(function (res) {
  10320. angular.forEach(res, function (v, i) {
  10321. $scope.stateListData[v.value] = v.id;
  10322. });
  10323. });
  10324. };
  10325. $scope.getStateData();
  10326. // 草稿保存
  10327. $scope.ok = function (item) {
  10328. if (
  10329. $scope.taskDescribe &&
  10330. $scope.personData.data &&
  10331. $scope.priorityData.data &&
  10332. $scope.startTime &&
  10333. $scope.endTime
  10334. ) {
  10335. $scope.startTime = moment(
  10336. new Date($scope.startTime).getTime()
  10337. ).format("YYYY-MM-DD HH:mm:ss");
  10338. $scope.endTime = moment(
  10339. new Date($scope.endTime).getTime()
  10340. ).format("YYYY-MM-DD HH:mm:ss");
  10341. $scope.addData = {
  10342. taskSub: {
  10343. taskDescribe: $scope.taskDescribe,
  10344. assign: $scope.personData.data,
  10345. priority: $scope.priorityData.data,
  10346. startTime: $scope.startTime,
  10347. endTime: $scope.endTime,
  10348. taskMonth: {
  10349. id: scope.model.taskMonth.id,
  10350. },
  10351. },
  10352. };
  10353. $scope.addData.taskSub["state"] = {
  10354. id: $scope.stateListData[1],
  10355. };
  10356. api_user_data
  10357. .addData("taskSub", $scope.addData)
  10358. .then(function (res) {
  10359. if (res.status == 200) {
  10360. SweetAlert.swal({
  10361. title: "保存成功!",
  10362. type: "success",
  10363. confirmButtonColor: "#007AFF",
  10364. });
  10365. scope.refreshData(scope.jry_filterdata);
  10366. $modalInstance.dismiss("cancel");
  10367. } else {
  10368. SweetAlert.swal({
  10369. title: "保存失败",
  10370. text: "系统错误,请重试!",
  10371. type: "error",
  10372. });
  10373. $modalInstance.dismiss("cancel");
  10374. }
  10375. });
  10376. } else {
  10377. SweetAlert.swal({
  10378. title: "保存失败",
  10379. text: "必填项不能为空!",
  10380. type: "error",
  10381. });
  10382. }
  10383. };
  10384. // 发布
  10385. $scope.release = function () {
  10386. if (
  10387. $scope.taskDescribe &&
  10388. $scope.personData.data &&
  10389. $scope.priorityData.data &&
  10390. $scope.startTime &&
  10391. $scope.endTime
  10392. ) {
  10393. $scope.startTime = moment(
  10394. new Date($scope.startTime).getTime()
  10395. ).format("YYYY-MM-DD HH:mm:ss");
  10396. $scope.endTime = moment(
  10397. new Date($scope.endTime).getTime()
  10398. ).format("YYYY-MM-DD HH:mm:ss");
  10399. $scope.addData = {
  10400. taskSub: {
  10401. taskDescribe: $scope.taskDescribe,
  10402. assign: $scope.personData.data,
  10403. priority: $scope.priorityData.data,
  10404. startTime: $scope.startTime,
  10405. endTime: $scope.endTime,
  10406. taskMonth: {
  10407. id: scope.model.taskMonth.id,
  10408. },
  10409. },
  10410. };
  10411. $scope.addData.taskSub["state"] = {
  10412. id: $scope.stateListData[1],
  10413. };
  10414. api_user_data
  10415. .addData("taskSub", $scope.addData)
  10416. .then(function (res) {
  10417. if (res.status == 200) {
  10418. SweetAlert.swal({
  10419. title: "保存成功!",
  10420. type: "success",
  10421. confirmButtonColor: "#007AFF",
  10422. });
  10423. scope.refreshData(scope.jry_filterdata);
  10424. $modalInstance.dismiss("cancel");
  10425. } else {
  10426. SweetAlert.swal({
  10427. title: "保存失败",
  10428. text: "系统错误,请重试!",
  10429. type: "error",
  10430. });
  10431. $modalInstance.dismiss("cancel");
  10432. }
  10433. });
  10434. } else {
  10435. SweetAlert.swal({
  10436. title: "保存失败",
  10437. text: "必填项不能为空!",
  10438. type: "error",
  10439. });
  10440. }
  10441. };
  10442. $scope.cancel = function () {
  10443. $modalInstance.dismiss("cancel");
  10444. };
  10445. },
  10446. size: "sm",
  10447. resolve: {
  10448. scope: function () {
  10449. return $scope;
  10450. },
  10451. },
  10452. backdrop: true,
  10453. });
  10454. };
  10455. },
  10456. });
  10457. // 多次反馈文本域组件--jry
  10458. formlyConfigProvider.setType({
  10459. name: "ui-feedbacktTextarea",
  10460. extends: "textarea",
  10461. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10462. defaultOptions: function (options) {
  10463. return {
  10464. templateOptions: {
  10465. transform: function (model, value) {
  10466. return value;
  10467. },
  10468. },
  10469. validation: {
  10470. messages: {
  10471. maxlength: function (viewValue, modelValue, scope) {
  10472. if (viewValue != null) {
  10473. if (viewValue.length > scope.to.maxlength) {
  10474. return (
  10475. scope.to.label +
  10476. " 字数(" +
  10477. viewValue.length +
  10478. ")超限(" +
  10479. scope.to.maxlength +
  10480. ")"
  10481. );
  10482. } else {
  10483. return "";
  10484. }
  10485. }
  10486. },
  10487. },
  10488. },
  10489. };
  10490. },
  10491. controller: [
  10492. "$scope",
  10493. "moment",
  10494. function ($scope, moment) {
  10495. // console.log($scope);
  10496. var timeKey = $scope.options.templateOptions.time;
  10497. $scope.time = moment($scope.model[timeKey]).format(
  10498. "YYYY-MM-DD HH:mm:ss"
  10499. );
  10500. var value = $scope.model[$scope.options.key];
  10501. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10502. $scope.model[$scope.options.key] =
  10503. $scope.options.templateOptions.transform(
  10504. $scope.originalModel,
  10505. value
  10506. );
  10507. }
  10508. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10509. $scope.options.templateOptions.felditem($scope);
  10510. }
  10511. },
  10512. ],
  10513. });
  10514. //任务管理开始时间--jry
  10515. formlyConfigProvider.setType({
  10516. name: "ui-jryStartdatepicker",
  10517. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10518. extends: "input",
  10519. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10520. defaultOptions: {
  10521. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10522. templateOptions: {
  10523. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10524. },
  10525. },
  10526. controller: [
  10527. "$scope",
  10528. "$filter",
  10529. function ($scope, $filter) {
  10530. // console.log($scope.model[$scope.options.key],'lmm');
  10531. $scope.mindata = new Date(
  10532. $scope.options.templateOptions.transform($scope.model).getTime() +
  10533. 5 * 60 * 1000
  10534. );
  10535. if ($scope.model[$scope.options.key]) {
  10536. $scope.model[$scope.options.key] = $filter("date")(
  10537. $scope.model[$scope.options.key],
  10538. $scope.options.templateOptions.datepickerPopup
  10539. );
  10540. }
  10541. // console.log($scope.model[$scope.options.key],'lmm');
  10542. // console.log($scope.model,'lmm',$scope.options.key);
  10543. $scope.options.initialValue = $scope.model[$scope.options.key];
  10544. $scope.endOpen = true;
  10545. $scope.datepicker = {};
  10546. $scope.datepicker.opened = false;
  10547. $scope.datepicker.open = function ($event) {
  10548. $scope.datepicker.opened = true;
  10549. };
  10550. },
  10551. ],
  10552. });
  10553. //任务管理结束时间--jry
  10554. formlyConfigProvider.setType({
  10555. name: "ui-jryEnddatepicker",
  10556. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10557. extends: "input",
  10558. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10559. defaultOptions: {
  10560. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10561. templateOptions: {
  10562. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10563. },
  10564. },
  10565. controller: [
  10566. "$scope",
  10567. "$filter",
  10568. function ($scope, $filter) {
  10569. $scope.mindata = new Date(
  10570. $scope.options.templateOptions.transform($scope.model).getTime() +
  10571. 5 * 60 * 1000
  10572. );
  10573. if ($scope.model[$scope.options.key]) {
  10574. $scope.model[$scope.options.key] = $filter("date")(
  10575. $scope.model[$scope.options.key],
  10576. $scope.options.templateOptions.datepickerPopup
  10577. );
  10578. }
  10579. $scope.options.initialValue = $scope.model[$scope.options.key];
  10580. $scope.endOpen = true;
  10581. $scope.datepicker = {};
  10582. $scope.datepicker.opened = false;
  10583. $scope.datepicker.open = function ($event) {
  10584. $scope.datepicker.opened = true;
  10585. };
  10586. },
  10587. ],
  10588. });
  10589. //下拉多选框灵活组件--jry
  10590. formlyConfigProvider.setType({
  10591. name: "ui-jry_multiselectplus",
  10592. extends: "multiCheckbox",
  10593. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10594. defaultOptions: function (options) {
  10595. return {
  10596. templateOptions: {
  10597. refreshData: function (search, options, model, that) {
  10598. // var process = options.templateOptions.ApiService.all("");
  10599. if (search) {
  10600. } else {
  10601. }
  10602. var postData = options.templateOptions.optionsPostData;
  10603. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10604. postData = options.templateOptions.optionsPostData(
  10605. options,
  10606. model,
  10607. that
  10608. );
  10609. }
  10610. options.templateOptions.ApiService.fetchDataList(
  10611. options.templateOptions.optionsUrl,
  10612. options.templateOptions.optionsPostData
  10613. ).then(function (result) {
  10614. // if (!options.templateOptions.options) {
  10615. // options.templateOptions.options = [];
  10616. // }
  10617. if (options.templateOptions.optionsDataKey) {
  10618. options.templateOptions.options =
  10619. result[options.templateOptions.optionsDataKey];
  10620. } else {
  10621. options.templateOptions.options = result;
  10622. }
  10623. if (options.templateOptions.optionsChecked) {
  10624. // return options.value = null;
  10625. options.value(options.model[options.key]);
  10626. }
  10627. });
  10628. },
  10629. refreshDelay: 0,
  10630. // },
  10631. validators: {
  10632. required: {
  10633. expression: function (viewValue, modelValue) {
  10634. var value = modelValue || viewValue;
  10635. return value != null;
  10636. // return value.length>=1;
  10637. // if (modelValue && viewValue) {
  10638. // return value != null;
  10639. // } else {
  10640. // var value = modelValue || viewValue;
  10641. // return value.length > 0;
  10642. // }
  10643. },
  10644. },
  10645. },
  10646. },
  10647. };
  10648. },
  10649. controller: [
  10650. "$scope",
  10651. function ($scope) {
  10652. console.log($scope.to);
  10653. if (angular.isArray($scope.model[$scope.options.key])) {
  10654. } else {
  10655. $scope.model[$scope.options.key] = [];
  10656. }
  10657. },
  10658. ],
  10659. });
  10660. //下拉框组件
  10661. formlyConfigProvider.setType({
  10662. name: "ui-select",
  10663. extends: "select",
  10664. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10665. defaultOptions: function (options, scope) {
  10666. return {
  10667. templateOptions: {
  10668. // refresh: function() {},
  10669. getScope: function () {
  10670. return scope;
  10671. },
  10672. refreshDelay: 0,
  10673. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10674. //POST
  10675. console.log(model, "model");
  10676. angular.extend(data, {
  10677. idx: 0,
  10678. sum: 1000,
  10679. });
  10680. options.templateOptions.APIService.fetchDataList(
  10681. modelName,
  10682. data
  10683. ).then(function (response) {
  10684. var myData =
  10685. options.templateOptions.Restangular.stripRestangular(response);
  10686. var list = myData.list;
  10687. console.log(myData);
  10688. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10689. // console.log('balabalabala');
  10690. // console.log(res);
  10691. // })
  10692. if (list.length == 1) {
  10693. if (options.templateOptions.APIport) {
  10694. options.templateOptions.APIport.expectedTime(
  10695. "L" + list[0][key].id
  10696. ).then(function (response) {
  10697. if (response.state == "200") {
  10698. // if (model.$parent.model && model.$parent.model.incident) {
  10699. // } else {
  10700. // model.$parent.model = { 'incident': {} };
  10701. // }
  10702. var myDatas = response.serviceLevelAgreement;
  10703. //逾期
  10704. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10705. response.date;
  10706. //解决
  10707. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10708. myDatas.resolveTime;
  10709. //响应
  10710. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10711. myDatas.responseTime;
  10712. } else {
  10713. }
  10714. });
  10715. }
  10716. angular.forEach(model.fields, function (item) {
  10717. angular.forEach(model.fields, function (item) {
  10718. if (item.templateOptions.pkey == modelKey + "." + key) {
  10719. item.model.id = "";
  10720. if (key == "place") {
  10721. item.templateOptions.options = list;
  10722. } else if (key == "placeDTO") {
  10723. item.templateOptions.options = list;
  10724. } else if (key == "requester") {
  10725. } else {
  10726. item.value(list[0][key][item.key]);
  10727. }
  10728. }
  10729. });
  10730. });
  10731. } else {
  10732. if (model.fields) {
  10733. angular.forEach(model.fields, function (item) {
  10734. angular.forEach(model.fields, function (item) {
  10735. if (item.templateOptions.pkey == modelKey + "." + key) {
  10736. item.model.id = "";
  10737. if (key == "place") {
  10738. item.templateOptions.isnosearch = true;
  10739. item.templateOptions.options = list;
  10740. }
  10741. if (key == "placeDTO") {
  10742. item.templateOptions.options = list;
  10743. }
  10744. if (key == "requester") {
  10745. }
  10746. if (key == "room") {
  10747. item.templateOptions.options = list;
  10748. }
  10749. }
  10750. });
  10751. });
  10752. } else {
  10753. angular.forEach(
  10754. scope.$parent.$parent.$parent.fields,
  10755. function (item) {
  10756. angular.forEach(
  10757. scope.$parent.$parent.$parent.fields,
  10758. function (item) {
  10759. if (
  10760. item.templateOptions.pkey ==
  10761. modelKey + "." + key
  10762. ) {
  10763. if (key == "place") {
  10764. item.templateOptions.isnosearch = true;
  10765. item.templateOptions.options = list;
  10766. scope.$parent.$parent.$parent.model.incident.place =
  10767. model.incident.place;
  10768. }
  10769. if (key == "placeDTO") {
  10770. item.templateOptions.options = list;
  10771. }
  10772. if (key == "requester") {
  10773. }
  10774. }
  10775. }
  10776. );
  10777. }
  10778. );
  10779. }
  10780. }
  10781. console.log(key);
  10782. //报修科室
  10783. if (key == "dept") {
  10784. // 报修科室单选
  10785. scope.$parent.$parent.$parent.model.incident.department =
  10786. response.list[0];
  10787. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10788. response.list[0].phone;
  10789. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10790. // 选择重复事件侧滑框
  10791. scope.$parent.$parent.$parent.model[
  10792. "repeatIncidentShow"
  10793. ] = false;
  10794. setTimeout(() => {
  10795. scope.$parent.$parent.$parent.model[
  10796. "repeatIncidentShow"
  10797. ] = true;
  10798. }, 500);
  10799. }
  10800. // 报修人
  10801. if (key == "requester") {
  10802. // 报修人单选
  10803. scope.$parent.$parent.$parent.model.incident.requester =
  10804. response.list[0];
  10805. console.log(scope.$parent.$parent.$parent.model);
  10806. scope.$parent.$parent.$parent.model.incident.account =
  10807. response.list[0].account;
  10808. var selectedItem = response.list[0];
  10809. var data = {
  10810. requester: selectedItem,
  10811. };
  10812. scope.$parent.$parent.$parent.model["requestershow"] =
  10813. selectedItem;
  10814. console.log(selectedItem, "----------------------");
  10815. // if (selectedItem.dept.place.place) {
  10816. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10817. // }
  10818. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10819. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10820. scope.$parent.$parent.$parent.model.incident.area.id =
  10821. selectedItem.place ? selectedItem.place.area.id : null;
  10822. scope.$parent.$parent.$parent.model.incident.place.id =
  10823. selectedItem.place ? selectedItem.place.id : null;
  10824. console.log(scope, 89898998);
  10825. // console.log(scope.formData,'接单页面');
  10826. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10827. scope.model.selecthouseNumber = selectedItem.place
  10828. ? selectedItem.place
  10829. : {};
  10830. scope.$root.selecthouseNumber = selectedItem.place
  10831. ? selectedItem.place
  10832. : {};
  10833. // options.templateOptions.ApiService.addData(
  10834. // "requester",
  10835. // data
  10836. // ).then(function (response) {
  10837. // if (response.status == 200) {
  10838. if (scope.$parent.$parent.$parent) {
  10839. if (scope.$parent.$parent.$parent.place) {
  10840. scope.$parent.$parent.$parent.place.id = "";
  10841. }
  10842. if (scope.$parent.$parent.$parent.area) {
  10843. scope.$parent.$parent.$parent.area.id = "";
  10844. }
  10845. scope.$parent.$parent.$parent.model.incident.contacts =
  10846. selectedItem.name;
  10847. if (
  10848. selectedItem.mphone &&
  10849. selectedItem.mphone != null &&
  10850. selectedItem.mphone != ""
  10851. ) {
  10852. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10853. selectedItem.mphone;
  10854. } else {
  10855. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10856. selectedItem.telephone;
  10857. }
  10858. if (
  10859. selectedItem.requesterTypeDTO &&
  10860. selectedItem.requesterTypeDTO.id == 2
  10861. ) {
  10862. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10863. }
  10864. }
  10865. // if (!response.data.id) {
  10866. // response.data.id = selectedItem.id;
  10867. // }
  10868. console.log(scope);
  10869. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10870. // if (selectedItem.place && selectedItem.place.id) {
  10871. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10872. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10873. // };
  10874. // } else {
  10875. // if (selectedItem.place && selectedItem.place.id) {
  10876. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10877. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10878. // };
  10879. // }
  10880. // if(scope.$parent.$parent.$parent.model.incident.area){
  10881. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10882. // }
  10883. if (selectedItem.id) {
  10884. scope.$parent.$parent.$parent.model.incident.account =
  10885. selectedItem.account;
  10886. }
  10887. // 选择重复事件侧滑框
  10888. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10889. scope.$parent.$parent.$parent.model[
  10890. "repeatIncidentShow"
  10891. ] = false;
  10892. setTimeout(() => {
  10893. scope.$parent.$parent.$parent.model[
  10894. "repeatIncidentShow"
  10895. ] = true;
  10896. }, 500);
  10897. // }
  10898. // }
  10899. // });
  10900. }
  10901. //新建事件,选择派单,选择工作组查找处理人baba
  10902. if (key == "handlerUser") {
  10903. model.fields.forEach(function (v) {
  10904. if (v.templateOptions.pkey == "incident.handlerUser") {
  10905. v.templateOptions.options = list;
  10906. if (model.model.incident.handlerUser) {
  10907. if (model.model.incident.handlerUser.id) {
  10908. var flag = list.some(function (v) {
  10909. return v.id == model.model.incident.handlerUser.id;
  10910. });
  10911. if (flag) {
  10912. v.model.id = model.model.incident.handlerUser.id;
  10913. }
  10914. }
  10915. }
  10916. }
  10917. });
  10918. }
  10919. });
  10920. },
  10921. validators: {
  10922. required: {
  10923. expression: function (viewValue, modelValue) {
  10924. var value = modelValue || viewValue;
  10925. return value != null;
  10926. // return value.length>=1;
  10927. // if (modelValue && viewValue) {
  10928. // return value != null;
  10929. // } else {
  10930. // var value = modelValue || viewValue;
  10931. // return value.length > 0;
  10932. // }
  10933. },
  10934. },
  10935. },
  10936. },
  10937. controller: [
  10938. "$scope",
  10939. "$rootScope",
  10940. "api_bpm_domain",
  10941. "$stateParams",
  10942. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10943. // $scope.myFilter = function(item) {
  10944. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10945. // }
  10946. console.log($scope, "风浪");
  10947. if($scope.to.onlyKey === 'inspection.dictionary'){
  10948. //巡检列表-新增-巡检类型baba
  10949. console.log(location)
  10950. var loc = location.href.split('api_bpm_data')[1] || '';
  10951. if(loc.length <= 2){
  10952. // 新增轮询计划的时候
  10953. $scope.model.id = 1715;//默认系统默认
  10954. }
  10955. }
  10956. //工作组添加全部选项
  10957. // if($scope.options.templateOptions.label == '工作组'){
  10958. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10959. // $scope.model._group = 0;
  10960. // }
  10961. if (
  10962. $scope.options.templateOptions.pkey &&
  10963. $scope.options.templateOptions.pkey == "incident.place"
  10964. ) {
  10965. if (
  10966. $scope.$parent &&
  10967. $scope.$parent.$parent.$parent.model &&
  10968. $scope.$parent.$parent.$parent.model.incident.area &&
  10969. $scope.$parent.$parent.$parent.model.incident.area.id
  10970. ) {
  10971. $scope.options.templateOptions.linkage(
  10972. "place",
  10973. {
  10974. place: {
  10975. areaId:
  10976. $scope.$parent.$parent.$parent.model.incident.area.id,
  10977. // area:{
  10978. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  10979. // }
  10980. },
  10981. },
  10982. $scope.$parent.$parent.$parent.model,
  10983. "incident",
  10984. "place"
  10985. );
  10986. }
  10987. }
  10988. $scope.myFilter = $scope;
  10989. // console.log($scope.options.templateOptions)
  10990. console.log($scope, 77777);
  10991. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  10992. var paramsModel = JSON.parse($stateParams.model)
  10993. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  10994. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  10995. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  10996. }
  10997. }
  10998. //处理人根据事件分类自动带入baba
  10999. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  11000. console.log($scope.options.templateOptions.pkey);
  11001. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  11002. if (
  11003. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  11004. ) {
  11005. $scope.$parent.$parent.$parent.model.assignee =
  11006. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11007. $scope.options.model.id =
  11008. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11009. }
  11010. }
  11011. }
  11012. // 关闭事件页面满意度评价下拉框处理
  11013. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  11014. $scope.model.id =
  11015. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  11016. }
  11017. if ($scope.options.templateOptions.initData == 1) {
  11018. $scope.options.templateOptions.onChange(
  11019. $scope.model.id,
  11020. $scope.options,
  11021. $scope
  11022. );
  11023. }
  11024. if ($scope.options.templateOptions.transform) {
  11025. $scope.options.templateOptions.onChange(
  11026. $scope.model.id,
  11027. $scope.options,
  11028. $scope
  11029. );
  11030. }
  11031. if (angular.isFunction($scope.options.templateOptions.translate)) {
  11032. $scope.model[$scope.options.key] =
  11033. $scope.options.templateOptions.translate(
  11034. $scope.options,
  11035. $rootScope,
  11036. $scope
  11037. );
  11038. }
  11039. if (
  11040. angular.isFunction($scope.options.templateOptions.translatefunc)
  11041. ) {
  11042. $scope.model[$scope.options.key] =
  11043. $scope.options.templateOptions.translatefunc(
  11044. $scope.options,
  11045. $rootScope,
  11046. $scope
  11047. );
  11048. }
  11049. if (
  11050. angular.isFunction($scope.options.templateOptions.onlyfunction)
  11051. ) {
  11052. $scope.options.templateOptions.onlyfunction(
  11053. $scope.options,
  11054. $rootScope,
  11055. $scope
  11056. );
  11057. }
  11058. },
  11059. ],
  11060. };
  11061. },
  11062. });
  11063. //下拉框组件(巡检计划-查看)
  11064. formlyConfigProvider.setType({
  11065. name: "ui-select-xj",
  11066. extends: "select",
  11067. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11068. defaultOptions: function (options, scope) {
  11069. return {
  11070. templateOptions: {
  11071. getScope: function () {
  11072. return scope;
  11073. },
  11074. refreshDelay: 0,
  11075. validators: {
  11076. required: {
  11077. expression: function (viewValue, modelValue) {
  11078. var value = modelValue || viewValue;
  11079. return value != null;
  11080. },
  11081. },
  11082. },
  11083. },
  11084. controller: [
  11085. "$scope",
  11086. "$rootScope",
  11087. "api_bpm_domain",
  11088. "$stateParams",
  11089. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11090. $scope.model[$scope.options.key] = '0';//默认全部
  11091. var arr = [];
  11092. if($scope.model.inspection.batchNos){
  11093. arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
  11094. }
  11095. arr.unshift({value:'0',name:'全部'});
  11096. $scope.options.templateOptions.options = arr;
  11097. console.log($scope)
  11098. // ts.$parent.fields.forEach(v=>{
  11099. // if(v.templateOptions.onlyKey === "batchNos"){
  11100. // //巡检计划-批次号
  11101. // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
  11102. // v.templateOptions.getScope().refreshData(batchNos)
  11103. // }
  11104. // })
  11105. // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
  11106. // console.log($scope.options)
  11107. // console.log($scope.model)
  11108. },
  11109. ],
  11110. };
  11111. },
  11112. });
  11113. //下拉多选框组件
  11114. formlyConfigProvider.setType({
  11115. name: "ui-multiselect",
  11116. extends: "select",
  11117. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11118. defaultOptions: function (options) {
  11119. return {
  11120. templateOptions: {
  11121. refresh: function () { },
  11122. refreshDelay: 1000,
  11123. },
  11124. };
  11125. },
  11126. controller: [
  11127. "$scope",
  11128. function ($scope) {
  11129. $scope.model[$scope.options.key] = [];
  11130. },
  11131. ],
  11132. });
  11133. //下拉多选全选组件
  11134. formlyConfigProvider.setType({
  11135. name: "ui-isteven",
  11136. extends: "select",
  11137. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11138. defaultOptions: function (options,$scope) {
  11139. return {
  11140. templateOptions: {
  11141. refresh: function () {
  11142. console.log(options)
  11143. options.templateOptions
  11144. .refreshData(options.templateOptions.APIService)
  11145. .then(function (result) {
  11146. if(result.status == 200){
  11147. console.log(result.list)
  11148. //树形结构转换
  11149. function formatDataTree2(json){
  11150. var _json = JSON.parse(JSON.stringify(json));
  11151. return _json.filter(p=>{
  11152. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11153. _arr.length && (p.children = _arr);
  11154. return !p.parent;
  11155. })
  11156. }
  11157. console.log(result.list)
  11158. var list = formatDataTree2(result.list);
  11159. console.log(list)
  11160. // $scope.treeList = angular.copy(list);
  11161. var resultList = [];
  11162. //转换数据
  11163. function trasData(list,obj){
  11164. if(obj){
  11165. //有父级
  11166. list.forEach(v=>{
  11167. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11168. var i = resultList.findIndex(c=>c.type == type);
  11169. if(v.children){
  11170. resultList.splice(i+1,0,{
  11171. type: "<strong>"+ v.type +"</strong>",
  11172. msId: v.id,
  11173. msGroup: true,
  11174. },{msGroup: false})
  11175. trasData(v.children,v);
  11176. }else{
  11177. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11178. }
  11179. })
  11180. }else{
  11181. //顶级
  11182. list.forEach(v=>{
  11183. if(v.children){
  11184. resultList.push({
  11185. type: "<strong>"+ v.type +"</strong>",
  11186. msId: v.id,
  11187. msGroup: true,
  11188. },{msGroup: false})
  11189. trasData(v.children,v);
  11190. }else{
  11191. resultList.push(...v,...{ticked:false});
  11192. }
  11193. })
  11194. }
  11195. return resultList;
  11196. }
  11197. var __arr = trasData(list,null);
  11198. // console.log(__arr,options.model.typeIds.split(','))
  11199. if(options.model.typeIds){
  11200. //有巡检类型,则需要回显
  11201. __arr.forEach(w=>{
  11202. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11203. })
  11204. }
  11205. $scope.webBrowsersGrouped = __arr;
  11206. console.log($scope.webBrowsersGrouped);
  11207. }
  11208. })
  11209. },
  11210. refreshDelay: 1000,
  11211. },
  11212. };
  11213. },
  11214. controller: [
  11215. "$scope",
  11216. function ($scope) {
  11217. console.log($scope)
  11218. $scope.to.refresh();//获取列表数据
  11219. // $scope.model[$scope.options.key] = [];
  11220. //单项点击或菜单
  11221. $scope.fClick = function(data){
  11222. console.log($scope.outputBrowsers)
  11223. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11224. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11225. // if(data.id){
  11226. // //单项点击
  11227. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11228. // //有巡检类型
  11229. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11230. // if(data.ticked){
  11231. // arr.push(data.id);
  11232. // }else{
  11233. // arr = arr.filter(v=>v != data.id);
  11234. // }
  11235. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11236. // }else{
  11237. // //无巡检类型
  11238. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11239. // if(data.ticked){
  11240. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11241. // }else{
  11242. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11243. // }
  11244. // }
  11245. // }else{
  11246. // // 菜单点击
  11247. // console.log($scope.webBrowsersGrouped,data.msId);
  11248. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11249. // return v.parent?v.parent.id == data.msId:false;
  11250. // })
  11251. // if(treeResultArr.every(v=>v.ticked)){
  11252. // //全部都是true的情况下,需要移除,否则增加
  11253. // }
  11254. // console.log(treeResultArr)
  11255. // // --------------------------------------
  11256. // // var treeArr = [];
  11257. // // function findParent(treeList){
  11258. // // treeList.forEach(v=>{
  11259. // // if(v.id == data.msId){
  11260. // // treeArr = v.children;
  11261. // // }else{
  11262. // // if(v.children){
  11263. // // findParent(v.children);
  11264. // // }
  11265. // // }
  11266. // // })
  11267. // // return treeArr;
  11268. // // }
  11269. // // var treeResultArr = findParent($scope.treeList);
  11270. // // console.log(treeResultArr)
  11271. // // -----------------------------------
  11272. // }
  11273. }
  11274. // 全选
  11275. $scope.fSelectAll = function(){
  11276. // console.log($scope.webBrowsersGrouped)
  11277. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11278. // console.log(arr);
  11279. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11280. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11281. }
  11282. // 全不选
  11283. $scope.fSelectNone = function(){
  11284. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11285. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11286. }
  11287. // 配置信息
  11288. $scope.outputBrowsers = [];
  11289. $scope.localLang = {
  11290. selectAll: "全选",
  11291. selectNone: "全不选",
  11292. nothingSelected: "请选择"
  11293. }
  11294. },
  11295. ],
  11296. });
  11297. //下拉多选框灵活组件
  11298. formlyConfigProvider.setType({
  11299. name: "ui-multiselectplus",
  11300. extends: "multiCheckbox",
  11301. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11302. defaultOptions: function (options, $scope) {
  11303. return {
  11304. templateOptions: {
  11305. refreshData: function (search, options, model, that) {
  11306. console.log(search, options, model, that)
  11307. var process = options.templateOptions.ApiService.all("");
  11308. if (search) {
  11309. } else {
  11310. }
  11311. var postData = options.templateOptions.optionsPostData;
  11312. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11313. postData = options.templateOptions.optionsPostData(
  11314. options,
  11315. model,
  11316. that
  11317. );
  11318. }
  11319. if (options.templateOptions.modelreasondata) {
  11320. postData = options.templateOptions.modelreasondata;
  11321. }
  11322. process
  11323. .customPOST(postData, options.templateOptions.optionsUrl)
  11324. .then(function (result) {
  11325. // if (!options.templateOptions.options) {
  11326. // options.templateOptions.options = [];
  11327. // }
  11328. // 过滤下拉列表已选择的值
  11329. var modelVal = $scope.model[$scope.options.key];
  11330. var ides = [];
  11331. var rList = result.list || result;
  11332. if ($scope.options.key == "serviceTypeIds") {
  11333. modelVal = modelVal.map(function (v) {
  11334. if (typeof v !== 'object') {
  11335. return { id: v };
  11336. } else {
  11337. return v;
  11338. }
  11339. })
  11340. }
  11341. for (var i = 0; i < modelVal.length; i++) {
  11342. for (var j = 0; j < rList.length; j++) {
  11343. if (rList[j].id == modelVal[i].id) {
  11344. ides.push(rList[j].id);
  11345. }
  11346. }
  11347. }
  11348. ides.forEach(function (v1) {
  11349. rList.forEach(function (v2) {
  11350. if (v1 == v2.id) {
  11351. rList = rList.filter(v => v.id != v2.id);
  11352. }
  11353. })
  11354. })
  11355. options.templateOptions.options = rList;
  11356. // if (options.templateOptions.optionsDataKey) {
  11357. // options.templateOptions.options =
  11358. // result[options.templateOptions.optionsDataKey];
  11359. // } else {
  11360. // options.templateOptions.options = result;
  11361. // }
  11362. if (options.templateOptions.optionsChecked) {
  11363. // return options.value = null;
  11364. options.value(options.model[options.key]);
  11365. }
  11366. });
  11367. },
  11368. refreshDelay: 0,
  11369. // },
  11370. // validators: {
  11371. // required: {
  11372. // expression: function(viewValue, modelValue) {
  11373. // var value = modelValue || viewValue;
  11374. // // return value.length>=1;
  11375. // // if (modelValue && viewValue) {
  11376. // // return value != null;
  11377. // // } else {
  11378. // // var value = modelValue || viewValue;
  11379. // // return value.length > 0;
  11380. // // }
  11381. // }
  11382. // }
  11383. },
  11384. };
  11385. },
  11386. controller: [
  11387. "$scope",
  11388. function ($scope) {
  11389. if (angular.isArray($scope.model[$scope.options.key])) {
  11390. } else {
  11391. $scope.model[$scope.options.key] = [];
  11392. }
  11393. },
  11394. ],
  11395. });
  11396. //下拉树形多选组件
  11397. formlyConfigProvider.setType({
  11398. name: "ui-multiselect-tree",
  11399. extends: "multiCheckbox",
  11400. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11401. defaultOptions: function (options) {
  11402. return {
  11403. templateOptions: {
  11404. linkage: function (modelName, data, model, modelKey, key) {
  11405. angular.extend(data, {
  11406. idx: 0,
  11407. sum: 10,
  11408. });
  11409. options.templateOptions.APIService.fetchDataList(
  11410. modelName,
  11411. data
  11412. ).then(function (response) {
  11413. var myData =
  11414. options.templateOptions.Restangular.stripRestangular(response);
  11415. var list = myData.list;
  11416. if (list.length == 1) {
  11417. angular.forEach(model.fields, function (item) {
  11418. angular.forEach(model.fields, function (item) {
  11419. if (item.templateOptions.pkey == modelKey + "." + key) {
  11420. item.model.id = "";
  11421. if (key == "place") {
  11422. item.templateOptions.options = list;
  11423. } else {
  11424. item.value(list[0][key][item.key]);
  11425. }
  11426. }
  11427. });
  11428. });
  11429. }
  11430. });
  11431. },
  11432. // my_tree_handler : function(items) {
  11433. // },
  11434. // onFilterCallback : function(items) {
  11435. // },
  11436. // onFilterCallback : function(items) {
  11437. // },
  11438. refresh: function (items) {
  11439. var treedata = [];
  11440. function convertListToTree(data, treeMap) {
  11441. treedata = data;
  11442. for (var i = 0; i < data.length; i++) {
  11443. for (var j = 0; j < data.length; j++) {
  11444. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11445. if (data[i].pid == data[j].id) {
  11446. data[i].parent = data[j];
  11447. }
  11448. }
  11449. }
  11450. }
  11451. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11452. var root = null; //Initially set our loop to null
  11453. //loop over data
  11454. for (var i = 0; i < data.length; i++) {
  11455. var datum = data[i];
  11456. //each node will have children, so let's give it a "children" poperty
  11457. datum.children = [];
  11458. //add an entry for this node to the map so that any future children can
  11459. //lookup the parent
  11460. idToNodeMap[datum.id] = datum;
  11461. //Does this node have a parent?
  11462. if (
  11463. typeof datum.parent === "undefined" ||
  11464. datum.parent === null
  11465. ) {
  11466. //Doesn't look like it, so this node is the root of the tree
  11467. root = datum;
  11468. treeMap[datum.id] = root;
  11469. } else {
  11470. //This node has a parent, so let's look it up using the id
  11471. parentNode = idToNodeMap[datum.parent.id];
  11472. //We don't need this property, so let's delete it.
  11473. delete datum.parent;
  11474. //Let's add the current node as a child of the parent node.
  11475. parentNode.children.push(datum);
  11476. }
  11477. }
  11478. return root;
  11479. }
  11480. function convertParentToChildList(data) {
  11481. // console.log("data="+JSON.stringify(data))
  11482. var treeMap = {};
  11483. var list = [];
  11484. convertListToTree(data, treeMap);
  11485. angular.forEach(treeMap, function (item) {
  11486. list.push(item);
  11487. });
  11488. return list;
  11489. }
  11490. function selectItem(pmodel, childrens) {
  11491. if (angular.isArray(pmodel)) {
  11492. angular.forEach(pmodel, function (index) {
  11493. if (index && index.id) {
  11494. angular.forEach(childrens, function (item) {
  11495. if (item.id == index.id) {
  11496. item.selected = true;
  11497. }
  11498. if (item && item.children) {
  11499. selectItem(pmodel, item.children);
  11500. }
  11501. });
  11502. }
  11503. });
  11504. } else {
  11505. if (pmodel && pmodel.id) {
  11506. angular.forEach(childrens, function (item) {
  11507. if (item.id == pmodel.id) {
  11508. item.selected = true;
  11509. }
  11510. if (item && item.children) {
  11511. selectItem(pmodel, item.children);
  11512. }
  11513. });
  11514. }
  11515. }
  11516. }
  11517. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11518. options.templateOptions
  11519. .refreshData(options.templateOptions.APIService)
  11520. .then(function (result) {
  11521. if (result.status == 200) {
  11522. if (!options.templateOptions.options) {
  11523. options.templateOptions.options = [];
  11524. }
  11525. if (options.templateOptions.optionsDataKey) {
  11526. options.templateOptions.options = convertParentToChildList(
  11527. result[options.templateOptions.optionsDataKey]
  11528. );
  11529. } else {
  11530. options.templateOptions.options =
  11531. convertParentToChildList(result);
  11532. }
  11533. //set default value
  11534. var pmodel,
  11535. i = 0;
  11536. if (options.templateOptions.pkey) {
  11537. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11538. angular.forEach(
  11539. options.templateOptions.pkey.split("."),
  11540. function (p) {
  11541. if (i == 0) {
  11542. if (options.model[p] == null) {
  11543. options.model[p] = {};
  11544. }
  11545. pmodel = options.model[p];
  11546. i++;
  11547. } else {
  11548. if (pmodel[p] == null) {
  11549. pmodel[p] = {};
  11550. }
  11551. pmodel = pmodel[p];
  11552. }
  11553. }
  11554. );
  11555. } else {
  11556. pmodel = options.model;
  11557. }
  11558. }
  11559. if (pmodel) {
  11560. pmodel = pmodel[options.key];
  11561. } else if (options.model) {
  11562. pmodel = options.model[options.key];
  11563. } else {
  11564. pmodel = options.templateOptions.options;
  11565. }
  11566. if (angular.isArray(pmodel)) {
  11567. if (pmodel) {
  11568. // if(options.templateOptions.isMultiSelect==true){
  11569. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11570. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11571. // })
  11572. // }else{
  11573. selectItem(pmodel, options.templateOptions.options);
  11574. // }
  11575. }
  11576. } else {
  11577. if (pmodel && pmodel.id) {
  11578. selectItem(pmodel, options.templateOptions.options);
  11579. }
  11580. }
  11581. items.inputModel = options.templateOptions.options;
  11582. }
  11583. });
  11584. },
  11585. },
  11586. validators: {
  11587. required: {
  11588. expression: function (viewValue, modelValue) {
  11589. var value = modelValue || viewValue;
  11590. if (angular.isArray(value)) {
  11591. for (var i = 0; i < value.length; i++) {
  11592. value[i] = {
  11593. id: value[i].id,
  11594. };
  11595. }
  11596. return value.length > 0;
  11597. } else {
  11598. // console.log(options)
  11599. // return value = "true";
  11600. return value != null;
  11601. }
  11602. },
  11603. },
  11604. },
  11605. };
  11606. },
  11607. controller: [
  11608. "$scope",
  11609. "api_configure_form",
  11610. function ($scope, api_configure_form) {
  11611. if ($scope.options.templateOptions.isMultiSelect) {
  11612. // console.log($scope);
  11613. } else {
  11614. if ($scope.model[$scope.options.key]) {
  11615. }
  11616. }
  11617. },
  11618. ],
  11619. });
  11620. //多选下拉框组件
  11621. formlyConfigProvider.setType({
  11622. name: "ui-multi-select-tree",
  11623. extends: "input",
  11624. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11625. defaultOptions: function (options) {
  11626. return {
  11627. templateOptions: {
  11628. linkage: function (modelName, data, model, modelKey, key) {
  11629. angular.extend(data, {
  11630. idx: 0,
  11631. sum: 10,
  11632. });
  11633. options.templateOptions.APIService.fetchDataList(
  11634. modelName,
  11635. data
  11636. ).then(function (response) {
  11637. var myData =
  11638. options.templateOptions.Restangular.stripRestangular(response);
  11639. var list = myData.list;
  11640. if (list.length == 1) {
  11641. angular.forEach(model.fields, function (item) {
  11642. angular.forEach(model.fields, function (item) {
  11643. if (item.templateOptions.pkey == modelKey + "." + key) {
  11644. item.model.id = "";
  11645. if (key == "place") {
  11646. item.templateOptions.options = list;
  11647. } else {
  11648. item.value(list[0][key][item.key]);
  11649. }
  11650. }
  11651. });
  11652. });
  11653. }
  11654. });
  11655. },
  11656. getparentdata: function (items) {
  11657. // console.log(items)
  11658. },
  11659. refresh: function (items, search, fn) {
  11660. console.log(items, options);
  11661. var treedata = [];
  11662. function convertListToTree(data, treeMap) {
  11663. // console.log(data)
  11664. treedata = data;
  11665. for (var i = 0; i < data.length; i++) {
  11666. for (var j = 0; j < data.length; j++) {
  11667. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11668. if (data[i].pid == data[j].id) {
  11669. data[i].parent = data[j];
  11670. }
  11671. }
  11672. // if (data[i].id) {
  11673. // if (data[i].id== data[j].id) {
  11674. // data[i].parent = data[j];
  11675. // }
  11676. // }
  11677. }
  11678. }
  11679. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11680. var root = []; //Initially set our loop to null
  11681. if (search == "search" && items.filterKeyword) {
  11682. function transform(nodes) {
  11683. var treeConverter = {
  11684. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11685. attributeName: "id", //节点唯一标识符
  11686. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11687. transform: function (node) {
  11688. //转化递归函数,参数:一个待插入节点
  11689. if (node.parent != null) {
  11690. //该节点有父节点
  11691. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11692. if (this.needFind) {
  11693. for (var i = 0; i < newNode.children.length; i++) {
  11694. //查找要插入的node子节点是否在newNode这个父节点中存在
  11695. if (
  11696. newNode.children[i][this.attributeName] ===
  11697. node[this.attributeName]
  11698. ) {
  11699. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11700. }
  11701. }
  11702. }
  11703. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11704. // delete node.parent; //删除该节点的parent属性,如果有的话
  11705. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11706. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11707. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11708. } else if (node.parent == null) {
  11709. //该叶节点没有父节点,即为根节点
  11710. // delete node.parent; //删除该节点的parent属性,如果有的话
  11711. if (this.result == null) {
  11712. //根节点不存在
  11713. node.children = []; //给该节点增加children:[]属性
  11714. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11715. } else {
  11716. node.children = [];
  11717. // 顶级去重
  11718. for (
  11719. var i = 0;
  11720. i < this.result.children.length;
  11721. i++
  11722. ) {
  11723. if (
  11724. this.result.children[i][this.attributeName] ===
  11725. node[this.attributeName]
  11726. ) {
  11727. return this.result.children[i];
  11728. }
  11729. }
  11730. this.result.children.push(node);
  11731. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11732. }
  11733. }
  11734. },
  11735. getWhole: function (nodes, attributeName) {
  11736. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11737. var _node = {};
  11738. _node.children = [];
  11739. this.result = _node; //重置根节点
  11740. this.attributeName =
  11741. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11742. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11743. nodes.forEach((item) => {
  11744. //循环调用转化方法
  11745. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11746. this.transform(item);
  11747. });
  11748. return this.result; //返回根节点
  11749. },
  11750. };
  11751. var result = treeConverter.getWhole(nodes); //调用
  11752. return result;
  11753. }
  11754. var li = transform(data).children;
  11755. // li=[...new Set(li)]
  11756. console.log(li);
  11757. treeMap = li;
  11758. fn(li);
  11759. return li;
  11760. } else {
  11761. //loop over data
  11762. for (var i = 0; i < data.length; i++) {
  11763. var datum = data[i];
  11764. //each node will have children, so let's give it a "children" poperty
  11765. datum.children = [];
  11766. //add an entry for this node to the map so that any future children can
  11767. //lookup the parent
  11768. idToNodeMap[datum.id] = datum;
  11769. //Does this node have a parent?
  11770. if (
  11771. typeof datum.parent === "undefined" ||
  11772. datum.parent === null
  11773. ) {
  11774. //Doesn't look like it, so this node is the root of the tree
  11775. root = datum;
  11776. treeMap[datum.id] = root;
  11777. } else {
  11778. //This node has a parent, so let's look it up using the id
  11779. parentNode = idToNodeMap[datum.parent.id];
  11780. //We don't need this property, so let's delete it.
  11781. // delete datum.parent;
  11782. //Let's add the current node as a child of the parent node.
  11783. parentNode.children.push(datum);
  11784. }
  11785. }
  11786. }
  11787. return root;
  11788. }
  11789. function convertParentToChildList(data) {
  11790. var treeMap = {};
  11791. var list = [];
  11792. if (search == "search" && items.filterKeyword) {
  11793. var lis = convertListToTree(data, treeMap);
  11794. return lis;
  11795. } else {
  11796. if (data[0] && data[0].orders) {
  11797. list = data;
  11798. } else {
  11799. convertListToTree(data, treeMap);
  11800. angular.forEach(treeMap, function (item) {
  11801. // console.log("item="+JSON.stringify(item))
  11802. list.push(item);
  11803. });
  11804. }
  11805. return list;
  11806. }
  11807. }
  11808. function selectItem(pmodel, childrens) {
  11809. if (angular.isArray(pmodel)) {
  11810. angular.forEach(pmodel, function (index) {
  11811. if (index && index.id) {
  11812. angular.forEach(childrens, function (item) {
  11813. if (item.id == index.id) {
  11814. item.selected = true;
  11815. }
  11816. if (item && item.children) {
  11817. selectItem(pmodel, item.children);
  11818. }
  11819. });
  11820. // angular.forEach(treedata,function(parentdata){
  11821. // if(parentdata.id == index.id){
  11822. // if(parentdata.parent&&parentdata.parent.id){
  11823. // parentdata.parent.$
  11824. // }
  11825. // item.selected = true;
  11826. // }
  11827. // if (item && item.children) {
  11828. // selectItem(pmodel ,item.children);
  11829. // }
  11830. // });
  11831. }
  11832. });
  11833. } else {
  11834. if (pmodel && pmodel.id) {
  11835. angular.forEach(childrens, function (item, index) {
  11836. if (item.id == pmodel.id) {
  11837. item.selected = true;
  11838. // delete item.children;
  11839. }
  11840. if (item && item.children) {
  11841. selectItem(pmodel, item.children);
  11842. }
  11843. });
  11844. }
  11845. }
  11846. }
  11847. function selectItemchild(pmodel, childrens) {
  11848. if (angular.isArray(pmodel)) {
  11849. angular.forEach(pmodel, function (index) {
  11850. if (index && index.id) {
  11851. angular.forEach(childrens, function (item) {
  11852. if (item.id == index.id) {
  11853. item.selected = true;
  11854. }
  11855. if (item && item.children) {
  11856. selectItem(pmodel, item.children);
  11857. }
  11858. });
  11859. }
  11860. });
  11861. } else {
  11862. if (pmodel && pmodel.id) {
  11863. angular.forEach(childrens, function (item, index) {
  11864. if (item.id == pmodel.id) {
  11865. item.selected = true;
  11866. childrens[index].selected = true;
  11867. }
  11868. if (item && item.children) {
  11869. selectItem(pmodel, item.children);
  11870. }
  11871. });
  11872. }
  11873. }
  11874. }
  11875. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11876. if (search === "search" && items.filterKeyword) {
  11877. // bala:树形模糊搜索
  11878. options.templateOptions
  11879. .bala(options.templateOptions.APIService, items.filterKeyword)
  11880. .then(function (result) {
  11881. result.list = [...new Set(result.list)]; //去重
  11882. if (!options.templateOptions.options) {
  11883. options.templateOptions.options = [];
  11884. }
  11885. if (options.templateOptions.optionsDataKey) {
  11886. options.templateOptions.options = convertParentToChildList(
  11887. result[options.templateOptions.optionsDataKey]
  11888. );
  11889. } else {
  11890. options.templateOptions.options =
  11891. convertParentToChildList(result);
  11892. }
  11893. //set default value
  11894. var pmodel,
  11895. i = 0;
  11896. if (
  11897. options.templateOptions.pkey ||
  11898. options.templateOptions.pkey != ""
  11899. ) {
  11900. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11901. angular.forEach(
  11902. options.templateOptions.pkey.split("."),
  11903. function (p) {
  11904. if (i == 0) {
  11905. if (options.model[p] == null) {
  11906. options.model[p] = {};
  11907. }
  11908. pmodel = options.model[p];
  11909. i++;
  11910. } else {
  11911. if (pmodel[p] == null) {
  11912. pmodel[p] = {};
  11913. }
  11914. pmodel = pmodel[p];
  11915. }
  11916. }
  11917. );
  11918. } else {
  11919. pmodel = options.model;
  11920. }
  11921. }
  11922. var topdata = angular.copy(options.templateOptions.options);
  11923. if (pmodel) {
  11924. pmodel = pmodel[options.key];
  11925. } else if (options.model) {
  11926. pmodel = options.model[options.key];
  11927. }
  11928. if (angular.isArray(pmodel)) {
  11929. if (pmodel) {
  11930. items.inputModel = angular.copy(
  11931. options.templateOptions.options
  11932. );
  11933. selectItem(pmodel, options.templateOptions.options);
  11934. }
  11935. } else {
  11936. if (pmodel && pmodel.id) {
  11937. items.inputModel = angular.copy(
  11938. options.templateOptions.options
  11939. );
  11940. selectItem(pmodel, options.templateOptions.options);
  11941. } else {
  11942. // items.inputModel = options.templateOptions.options;
  11943. }
  11944. }
  11945. // items.inputModel = options.templateOptions.options;
  11946. items.selectModel = options.templateOptions.options;
  11947. // 可在此展开
  11948. if (!items.inputModel) {
  11949. items.inputModel = items.selectModel;
  11950. } else {
  11951. selectItemchild(pmodel, items.inputModel);
  11952. // for (var i = 0; i < items.inputModel.length; i++) {
  11953. // items.inputModel[i].
  11954. // for (var j = 0; j < items.selectModel.length; j++) {
  11955. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11956. // items.inputModel[i].selected = true;
  11957. // }
  11958. // }
  11959. // }
  11960. }
  11961. return items.inputModel;
  11962. // options.templateOptions.options = angular.copy(topdata);
  11963. // console.log(model);
  11964. // console.log(options);
  11965. });
  11966. } else {
  11967. options.templateOptions
  11968. .refreshData(options.templateOptions.APIService)
  11969. .then(function (result) {
  11970. //回显事件分类,带出绑定的人或组start caocao
  11971. if (options.templateOptions.onlyKey == 'cate_start' && items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  11972. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  11973. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  11974. return v.id == items.$parent.originalModel.incident.category.id;
  11975. })
  11976. console.log(item)//11615
  11977. if (item) {
  11978. items.$parent.originalModel.incident.branchType = item.branchType;
  11979. if(item.branchType == 0){
  11980. if (item.userOrGroupType === 1) {
  11981. items.$parent.originalModel.start_code = 'assignment';
  11982. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  11983. items.$parent.originalModel.directClose = true;
  11984. items.$parent.originalModel.isHandlerUser = false;
  11985. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  11986. } else if (item.userOrGroupType === 2) {
  11987. items.$parent.originalModel.start_code = 'assignment';
  11988. items.$parent.originalModel.candidateGroups = item.group;
  11989. items.$parent.originalModel.directClose = true;
  11990. items.$parent.originalModel.isHandlerUser = false;
  11991. } else {
  11992. items.$parent.originalModel.start_code = 'close';
  11993. items.$parent.originalModel.directClose = false;
  11994. items.$parent.originalModel.isHandlerUser = false;
  11995. delete items.$parent.originalModel.candidateGroups;
  11996. delete items.$parent.originalModel.incident.handlerUser
  11997. }
  11998. }else if(item.branchType == 1){
  11999. items.$parent.originalModel.incident.branchUserGroups = item.branchUserGroups;
  12000. // items.$parent.originalModel.incident.area.id
  12001. options.templateOptions.APIService.fetchData('area',items.$parent.originalModel.incident.area.id).then(res=>{
  12002. console.log(res)
  12003. if(res.status == 200){
  12004. items.$parent.originalModel.incident.branchId = res.data.branch;
  12005. // res.data.branch
  12006. var branchUserGroup=item.branchUserGroups.find(v=>v.branchId==res.data.branch)||{};
  12007. if(branchUserGroup.branchUserOrGroupType==1){
  12008. items.$parent.originalModel.start_code='assignment';
  12009. items.$parent.originalModel.incident.handlerUser={id:branchUserGroup.userId?branchUserGroup.userId:undefined};
  12010. items.$parent.originalModel.directClose=true;
  12011. items.$parent.originalModel.isHandlerUser=false;
  12012. setTimeout(function(){items.$parent.originalModel.isHandlerUser=true;},0)
  12013. }else if(branchUserGroup.branchUserOrGroupType===2){
  12014. items.$parent.originalModel.start_code='assignment';
  12015. items.$parent.originalModel.candidateGroups=branchUserGroup.groupId?branchUserGroup.groupId:undefined;
  12016. items.$parent.originalModel.directClose=true;
  12017. items.$parent.originalModel.isHandlerUser=false;
  12018. }else{
  12019. items.$parent.originalModel.start_code='close';
  12020. items.$parent.originalModel.directClose=false;
  12021. items.$parent.originalModel.isHandlerUser=false;
  12022. delete items.$parent.originalModel.candidateGroups;
  12023. delete items.$parent.originalModel.incident.handlerUser
  12024. }
  12025. }
  12026. })
  12027. }
  12028. }
  12029. }
  12030. //回显事件分类,带出绑定的人或组end
  12031. if (!options.templateOptions.options) {
  12032. options.templateOptions.options = [];
  12033. }
  12034. if (options.templateOptions.optionsDataKey) {
  12035. options.templateOptions.options = convertParentToChildList(
  12036. result[options.templateOptions.optionsDataKey]
  12037. );
  12038. } else {
  12039. options.templateOptions.options =
  12040. convertParentToChildList(result);
  12041. }
  12042. //set default value
  12043. var pmodel,
  12044. i = 0;
  12045. if (
  12046. options.templateOptions.pkey ||
  12047. options.templateOptions.pkey != ""
  12048. ) {
  12049. if (options.templateOptions.pkey.indexOf(".") > 0) {
  12050. angular.forEach(
  12051. options.templateOptions.pkey.split("."),
  12052. function (p) {
  12053. if (i == 0) {
  12054. if (options.model[p] == null) {
  12055. options.model[p] = {};
  12056. }
  12057. pmodel = options.model[p];
  12058. i++;
  12059. } else {
  12060. if (pmodel[p] == null) {
  12061. pmodel[p] = {};
  12062. }
  12063. pmodel = pmodel[p];
  12064. }
  12065. }
  12066. );
  12067. } else {
  12068. pmodel = options.model;
  12069. }
  12070. }
  12071. var topdata = angular.copy(options.templateOptions.options);
  12072. if (pmodel) {
  12073. pmodel = pmodel[options.key];
  12074. } else if (options.model) {
  12075. pmodel = options.model[options.key];
  12076. }
  12077. if (angular.isArray(pmodel)) {
  12078. if (pmodel) {
  12079. items.inputModel = angular.copy(
  12080. options.templateOptions.options
  12081. );
  12082. selectItem(pmodel, options.templateOptions.options);
  12083. }
  12084. } else {
  12085. if (pmodel && pmodel.id) {
  12086. items.inputModel = angular.copy(
  12087. options.templateOptions.options
  12088. );
  12089. selectItem(pmodel, options.templateOptions.options);//baba
  12090. } else {
  12091. // items.inputModel = options.templateOptions.options;
  12092. }
  12093. }
  12094. // items.inputModel = options.templateOptions.options;
  12095. items.selectModel = options.templateOptions.options;
  12096. if (!items.inputModel) {
  12097. items.inputModel = items.selectModel;
  12098. } else {
  12099. selectItemchild(pmodel, items.inputModel);
  12100. // for (var i = 0; i < items.inputModel.length; i++) {
  12101. // for (var j = 0; j < items.selectModel.length; j++) {
  12102. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12103. // items.inputModel[i].selected = true;
  12104. // }
  12105. // }
  12106. // }
  12107. }
  12108. // options.templateOptions.options = angular.copy(topdata);
  12109. // console.log(model);
  12110. // console.log(options);
  12111. });
  12112. }
  12113. },
  12114. },
  12115. validators: {
  12116. required: {
  12117. expression: function (viewValue, modelValue) {
  12118. var value = modelValue || viewValue;
  12119. if (angular.isArray(value)) {
  12120. return value.length > 0;
  12121. } else {
  12122. // console.log(options)
  12123. if (options.templateOptions.required && !value) {
  12124. // return value != null;
  12125. } else {
  12126. return value;
  12127. }
  12128. // return value = "true";
  12129. }
  12130. },
  12131. },
  12132. },
  12133. };
  12134. },
  12135. controller: [
  12136. "$scope",
  12137. "$rootScope",
  12138. "api_configure_form",
  12139. "api_bpm_domain",
  12140. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  12141. $rootScope.checkClicked = function (item) {
  12142. angular.forEach($scope.to.options, function (itemone) {
  12143. if (!item.parent) {
  12144. if (item.id == itemone.id) {
  12145. // itemone.isExpanded = true;
  12146. } else {
  12147. itemone.isExpanded = false;
  12148. }
  12149. } else {
  12150. if (item.parent.id == itemone.id) {
  12151. angular.forEach(itemone.children, function (itemtwo) {
  12152. if (item.id == itemtwo.id) {
  12153. } else {
  12154. itemtwo.isExpanded = false;
  12155. }
  12156. });
  12157. }
  12158. }
  12159. });
  12160. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12161. console.log($scope, "gsm");
  12162. if (
  12163. $scope.originalModel &&
  12164. $scope.originalModel.incident &&
  12165. item.category &&
  12166. (!item.children || !item.children.length) &&
  12167. item.priority &&
  12168. item.priority.id
  12169. ) {
  12170. api_bpm_domain
  12171. .expectedTime("L" + (item.priority.id - 1559))
  12172. .then(function (res) {
  12173. $scope.originalModel.incident.expectResponseTime =
  12174. res.serviceLevelAgreement.responseTime;
  12175. $scope.originalModel.incident.expectIntroTime =
  12176. res.serviceLevelAgreement.resolveTime;
  12177. $scope.originalModel.incident.overdueTime = res.date;
  12178. });
  12179. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12180. // setTimeout(() => {
  12181. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12182. // }, 500);
  12183. // console.log($scope.$parent.$parent.$parent)
  12184. }
  12185. };
  12186. if ($scope.options.templateOptions.isMultiSelect) {
  12187. // console.log($scope);
  12188. } else {
  12189. if ($scope.model[$scope.options.key]) {
  12190. }
  12191. }
  12192. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12193. // console.log(item)
  12194. // // if(){
  12195. // // }
  12196. // // $scope.model[$scope.options.key]=item.id;
  12197. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12198. // $scope.propTypeOptions = data;
  12199. // });
  12200. // }
  12201. // $scope.model[$scope.options.key]=[];
  12202. // $scope.fn
  12203. $rootScope.bala1 = function (items, fn) {
  12204. // $scope.fn = fn;
  12205. console.log(items);
  12206. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12207. $scope.options.templateOptions.refresh(items, "search", fn);
  12208. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12209. // // return res.list;
  12210. // console.log(666)
  12211. // fn(res.list)
  12212. // })
  12213. };
  12214. },
  12215. ],
  12216. });
  12217. //勾选组件
  12218. formlyConfigProvider.setType({
  12219. name: "ui-checkbox",
  12220. extends: "checkbox",
  12221. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12222. controller: [
  12223. "$scope",
  12224. function ($scope) {
  12225. console.log($scope)
  12226. if($scope.options.templateOptions.isTrue){
  12227. //是否默认打开
  12228. $scope.model[$scope.options.key] = true;
  12229. }
  12230. // 巡检生成事件,默认派单
  12231. if ($scope.model.isInspection) {
  12232. $scope.model[$scope.options.key] = true;
  12233. }
  12234. if ($scope.model[$scope.options.key] == "true") {
  12235. $scope.model[$scope.options.key] = true;
  12236. }
  12237. if ($scope.model[$scope.options.key] == "false") {
  12238. $scope.model[$scope.options.key] = false;
  12239. }
  12240. },
  12241. ],
  12242. });
  12243. //勾选组件(禁用)--yeye
  12244. formlyConfigProvider.setType({
  12245. name: "ui-checkbox-disabled",
  12246. extends: "checkbox",
  12247. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12248. controller: [
  12249. "$scope",
  12250. function ($scope) {
  12251. // 巡检生成事件,默认派单
  12252. // if ($scope.model.isInspection) {
  12253. // $scope.model[$scope.options.key] = true;
  12254. // }
  12255. // if ($scope.model[$scope.options.key] == "true") {
  12256. // $scope.model[$scope.options.key] = true;
  12257. // }
  12258. // if ($scope.model[$scope.options.key] == "false") {
  12259. // $scope.model[$scope.options.key] = false;
  12260. // }
  12261. },
  12262. ],
  12263. });
  12264. //换行组件
  12265. formlyConfigProvider.setType({
  12266. name: "ui-nextLine",
  12267. /*extends: 'input',*/
  12268. template: "<div></div>",
  12269. });
  12270. //多选框组件
  12271. formlyConfigProvider.setType({
  12272. name: "ui-checklist",
  12273. extends: "multiCheckbox",
  12274. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12275. defaultOptions: function (options) {
  12276. return {
  12277. templateOptions: {
  12278. refresh: function () { },
  12279. refreshDelay: 0,
  12280. },
  12281. };
  12282. },
  12283. });
  12284. //单选框组件
  12285. formlyConfigProvider.setType({
  12286. name: "ui-radio",
  12287. extends: "radio",
  12288. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12289. defaultOptions: function (options) {
  12290. return {
  12291. templateOptions: {
  12292. refresh: function () {},
  12293. refreshDelay: 0,
  12294. },
  12295. };
  12296. },
  12297. controller: [
  12298. "$scope",
  12299. "api_wechatfile",
  12300. function ($scope,api_wechatfile) {
  12301. // 新增巡检计划-巡检方式baba
  12302. if($scope.to.onlyKey === 'onlineType'){
  12303. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12304. $scope.to.options = result;
  12305. if(!$scope.model[$scope.options.key]){
  12306. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12307. }
  12308. });
  12309. }
  12310. // 巡检生成事件,默认派单
  12311. if ($scope.model.isInspection) {
  12312. $scope.model[$scope.options.key] = true;
  12313. // $scope.model.isHandlerUser=true;
  12314. $scope.model.start_code = "assignment";
  12315. console.log($scope.model);
  12316. }
  12317. //多次暂存配置
  12318. // console.log($scope);
  12319. if ($scope.model.saveAgain) {
  12320. if (
  12321. $scope.model.directClose == "1" ||
  12322. $scope.model.directClose == true
  12323. ) {
  12324. $scope.model[$scope.options.key] = true;
  12325. // if($scope.model.incident.handlingPersonnelUser){
  12326. // delete $scope.model.incident.handlingPersonnelUser;
  12327. // };
  12328. if ($scope.model.incident.handleDescription) {
  12329. delete $scope.model.incident.handleDescription;
  12330. }
  12331. if ($scope.model.incident.closecode) {
  12332. delete $scope.model.incident.closecode;
  12333. }
  12334. if ($scope.model.incident.degree) {
  12335. delete $scope.model.incident.degree;
  12336. }
  12337. } else {
  12338. $scope.model.incident.handlingPersonnelUser =
  12339. $scope.model.incident.acceptUser;
  12340. $scope.model[$scope.options.key] = false;
  12341. }
  12342. }
  12343. },
  12344. ],
  12345. });
  12346. //文本域组件
  12347. formlyConfigProvider.setWrapper({
  12348. name: "validation",
  12349. types: ["ui-textarea"],
  12350. template:
  12351. '<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>',
  12352. });
  12353. formlyConfigProvider.setType({
  12354. name: "ui-textarea",
  12355. extends: "textarea",
  12356. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12357. defaultOptions: function (options) {
  12358. return {
  12359. templateOptions: {
  12360. transform: function (model, value) {
  12361. return value;
  12362. },
  12363. },
  12364. validation: {
  12365. messages: {
  12366. maxlength: function (viewValue, modelValue, scope) {
  12367. if (viewValue != null) {
  12368. if (viewValue.length > scope.to.maxlength) {
  12369. return (
  12370. scope.to.label +
  12371. " 字数(" +
  12372. viewValue.length +
  12373. ")超限(" +
  12374. scope.to.maxlength +
  12375. ")"
  12376. );
  12377. } else {
  12378. return "";
  12379. }
  12380. }
  12381. },
  12382. },
  12383. },
  12384. };
  12385. },
  12386. controller: [
  12387. "$scope",
  12388. function ($scope) {
  12389. var value = $scope.model[$scope.options.key];
  12390. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12391. $scope.model[$scope.options.key] =
  12392. $scope.options.templateOptions.transform(
  12393. $scope.originalModel,
  12394. value
  12395. );
  12396. }
  12397. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12398. $scope.options.templateOptions.felditem($scope);
  12399. }
  12400. },
  12401. ],
  12402. });
  12403. // div版的textarea(展示富文本框内容用)
  12404. formlyConfigProvider.setType({
  12405. name: "ui-divTextarea",
  12406. extends: "textarea",
  12407. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12408. defaultOptions: function (options) {
  12409. return {
  12410. templateOptions: {
  12411. transform: function (model, value) {
  12412. return value;
  12413. },
  12414. },
  12415. validation: {
  12416. messages: {
  12417. // maxlength: function (viewValue, modelValue, scope) {
  12418. // if (viewValue != null) {
  12419. // if (viewValue.length > scope.to.maxlength) {
  12420. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12421. // } else {
  12422. // return "";
  12423. // }
  12424. // }
  12425. // },
  12426. },
  12427. },
  12428. };
  12429. },
  12430. controller: [
  12431. "$scope",
  12432. function ($scope) {
  12433. var value = $scope.model[$scope.options.key];
  12434. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12435. $scope.model[$scope.options.key] =
  12436. $scope.options.templateOptions.transform(
  12437. $scope.originalModel,
  12438. value
  12439. );
  12440. }
  12441. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12442. $scope.options.templateOptions.felditem($scope);
  12443. }
  12444. },
  12445. ],
  12446. });
  12447. // 带有知识库引用的textarea
  12448. formlyConfigProvider.setType({
  12449. name: "ui-textAreaKnowledge",
  12450. // extends: 'textarea',
  12451. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12452. defaultOptions: function (options) {
  12453. return {
  12454. templateOptions: {
  12455. transform: function (model, value) {
  12456. return value;
  12457. },
  12458. },
  12459. validation: {
  12460. messages: {
  12461. maxlength: function (viewValue, modelValue, scope) {
  12462. if (viewValue != null) {
  12463. if (viewValue.length > scope.to.maxlength) {
  12464. return (
  12465. scope.to.label +
  12466. " 字数(" +
  12467. viewValue.length +
  12468. ")超限(" +
  12469. scope.to.maxlength +
  12470. ")"
  12471. );
  12472. } else {
  12473. return "";
  12474. }
  12475. }
  12476. },
  12477. },
  12478. },
  12479. };
  12480. },
  12481. controller: [
  12482. "$scope",
  12483. "$rootScope",
  12484. "$modal",
  12485. "SweetAlert",
  12486. "api_bpm_data",
  12487. "api_bpm_domain",
  12488. "api_solution",
  12489. "$aside",
  12490. "api_zsk",
  12491. "up_down_file",
  12492. "api_wechatfile",
  12493. function (
  12494. $scope,
  12495. $rootScope,
  12496. $modal,
  12497. SweetAlert,
  12498. api_bpm_data,
  12499. api_bpm_domain,
  12500. api_solution,
  12501. $aside,
  12502. api_zsk,
  12503. up_down_file,
  12504. api_wechatfile
  12505. ) {
  12506. // console.log($scope);
  12507. var value = $scope.model[$scope.options.key];
  12508. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12509. $scope.model[$scope.options.key] =
  12510. $scope.options.templateOptions.transform(
  12511. $scope.originalModel,
  12512. value
  12513. );
  12514. }
  12515. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12516. $scope.options.templateOptions.felditem($scope);
  12517. }
  12518. // 引用知识库点击
  12519. $scope.openSolution = function () {
  12520. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12521. setTimeout(() => {
  12522. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12523. }, 100);
  12524. };
  12525. },
  12526. ],
  12527. });
  12528. //常用语句选择textarea
  12529. formlyConfigProvider.setType({
  12530. name: "ui-textselect",
  12531. extends: "textarea",
  12532. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12533. defaultOptions: function (options) {
  12534. return {
  12535. templateOptions: {
  12536. transform: function (model, value) {
  12537. return value;
  12538. },
  12539. },
  12540. validation: {
  12541. messages: {
  12542. maxlength: function (viewValue, modelValue, scope) {
  12543. if (viewValue != null) {
  12544. if (viewValue.length > scope.to.maxlength) {
  12545. return (
  12546. scope.to.label +
  12547. " 字数(" +
  12548. viewValue.length +
  12549. ")超限(" +
  12550. scope.to.maxlength +
  12551. ")"
  12552. );
  12553. } else {
  12554. return "";
  12555. }
  12556. }
  12557. },
  12558. },
  12559. },
  12560. };
  12561. },
  12562. controller: [
  12563. "$scope",
  12564. function ($scope) {
  12565. var value = $scope.model[$scope.options.key];
  12566. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12567. $scope.model[$scope.options.key] =
  12568. $scope.options.templateOptions.transform(
  12569. $scope.originalModel,
  12570. value
  12571. );
  12572. }
  12573. },
  12574. ],
  12575. });
  12576. //改动的组件 ckeditor封装后的组件
  12577. formlyConfigProvider.setType({
  12578. name: "ui-text-check",
  12579. extends: "textarea",
  12580. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12581. defaultOptions: function (options) {
  12582. return {
  12583. templateOptions: {
  12584. extraPlugins: "uploadimage",
  12585. uploadimageConfig: {
  12586. backend: "basic",
  12587. settings: {
  12588. uploadUrl:
  12589. options.templateOptions.APIService.upload().getRequestedUrl(),
  12590. headers: "",
  12591. downloadUrl:
  12592. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12593. },
  12594. },
  12595. refresh: function (APIService, contentId, data) {
  12596. return APIService.fetchDataList(contentId, data);
  12597. },
  12598. downloadUri: function (APIService, contentId) {
  12599. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12600. },
  12601. upload: function (APIService, contentId) {
  12602. return APIService.getSolutionDowpath(contentId);
  12603. },
  12604. view: function (attachmentId) {
  12605. // return APIService.attachmentsPreviewUrl(contentId);
  12606. },
  12607. refreshDelay: 0,
  12608. transform: function (model, value) {
  12609. return value;
  12610. },
  12611. },
  12612. validation: {
  12613. messages: {
  12614. maxlength: function (viewValue, modelValue, scope) {
  12615. if (viewValue != null) {
  12616. if (viewValue.length > scope.to.maxlength) {
  12617. return (
  12618. scope.to.label +
  12619. " 字数(" +
  12620. viewValue.length +
  12621. ")超限(" +
  12622. scope.to.maxlength +
  12623. ")"
  12624. );
  12625. } else {
  12626. return "";
  12627. }
  12628. }
  12629. },
  12630. },
  12631. },
  12632. };
  12633. },
  12634. controller: [
  12635. "$scope",
  12636. "$rootScope",
  12637. function ($scope, $rootScope) {
  12638. var value = $scope.model[$scope.options.key];
  12639. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12640. $scope.model[$scope.options.key] =
  12641. $scope.options.templateOptions.transform(
  12642. $scope.originalModel,
  12643. value
  12644. );
  12645. }
  12646. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12647. $rootScope.getSession();
  12648. //var expiry={'expiry':14804244006};
  12649. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12650. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12651. $scope.upload = function (contentId, filename) {
  12652. var filename = filename;
  12653. $scope.options.templateOptions
  12654. .upload($scope.options.templateOptions.ApiService, contentId)
  12655. .then(function (response) {
  12656. var file = new Blob([response], {
  12657. type: "application/octet-stream",
  12658. });
  12659. // var filename = filename;
  12660. var fileURL = URL.createObjectURL(file);
  12661. var a = document.createElement("a");
  12662. a.href = fileURL;
  12663. a.target = "_blank";
  12664. a.download = filename;
  12665. document.body.appendChild(a);
  12666. a.click();
  12667. });
  12668. };
  12669. },
  12670. ],
  12671. });
  12672. //改动的组件 ckeditor封装后的附文本组件
  12673. formlyConfigProvider.setType({
  12674. name: "ui-fuwenben",
  12675. extends: "textarea",
  12676. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12677. defaultOptions: function (options) {
  12678. return {
  12679. templateOptions: {
  12680. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12681. extraPlugins: "uploadimage",
  12682. uploadimageConfig: {
  12683. backend: "basic",
  12684. settings: {
  12685. uploadUrl:
  12686. options.templateOptions.APIService.upload(
  12687. -110
  12688. ).getRequestedUrl(),
  12689. headers: "",
  12690. downloadUrl:
  12691. options.templateOptions.APIService.uploadResponseUri(),
  12692. },
  12693. },
  12694. refresh: function (APIService, contentId, data) {
  12695. return APIService.fetchDataList(-110, data);
  12696. },
  12697. downloadUri: function (APIService, contentId) {
  12698. return APIService.downloadAttachment(-110).getRequestedUrl();
  12699. },
  12700. upload: function (APIService, contentId) {
  12701. return APIService.getSolutionDowpath(-110);
  12702. },
  12703. view: function (attachmentId) {
  12704. // return APIService.attachmentsPreviewUrl(contentId);
  12705. },
  12706. refreshDelay: 0,
  12707. transform: function (model, value) {
  12708. return value;
  12709. },
  12710. },
  12711. validation: {
  12712. messages: {
  12713. maxlength: function (viewValue, modelValue, scope) {
  12714. if (viewValue != null) {
  12715. if (viewValue.length > scope.to.maxlength) {
  12716. return (
  12717. scope.to.label +
  12718. " 字数(" +
  12719. viewValue.length +
  12720. ")超限(" +
  12721. scope.to.maxlength +
  12722. ")"
  12723. );
  12724. } else {
  12725. return "";
  12726. }
  12727. }
  12728. },
  12729. },
  12730. },
  12731. };
  12732. },
  12733. controller: [
  12734. "$scope",
  12735. "$rootScope",
  12736. function ($scope, $rootScope) {
  12737. var value = $scope.model[$scope.options.key];
  12738. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12739. $scope.model[$scope.options.key] =
  12740. $scope.options.templateOptions.transform(
  12741. $scope.originalModel,
  12742. value
  12743. );
  12744. }
  12745. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12746. $rootScope.getSession();
  12747. //var expiry={'expiry':14804244006};
  12748. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12749. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12750. $scope.upload = function (contentId, filename) {
  12751. var filename = filename;
  12752. $scope.options.templateOptions
  12753. .upload($scope.options.templateOptions.ApiService, -110)
  12754. .then(function (response) {
  12755. var file = new Blob([response], {
  12756. type: "application/octet-stream",
  12757. });
  12758. // var filename = filename;
  12759. var fileURL = URL.createObjectURL(file);
  12760. var a = document.createElement("a");
  12761. a.href = fileURL;
  12762. a.target = "_blank";
  12763. a.download = filename;
  12764. document.body.appendChild(a);
  12765. a.click();
  12766. });
  12767. };
  12768. },
  12769. ],
  12770. });
  12771. //ui-grid展示控件
  12772. formlyConfigProvider.setType({
  12773. name: "ui-grid-show",
  12774. extends: "multiCheckbox",
  12775. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12776. defaultOptions: function (options,scope) {
  12777. return {
  12778. templateOptions: {
  12779. linkage: function () { },
  12780. getScope: function () {
  12781. return scope;
  12782. },
  12783. },
  12784. };
  12785. },
  12786. controller: function (
  12787. $scope,
  12788. $rootScope,
  12789. i18nService,
  12790. Restangular,
  12791. api_bpm_data
  12792. ) {
  12793. var loginUser = $rootScope.user;
  12794. $scope.langs = i18nService.getAllLangs();
  12795. $scope.lang = "zh-cn";
  12796. i18nService.setCurrentLang($scope.lang);
  12797. $scope.gridOptions = {};
  12798. $scope.gridOptions.data = "myData";
  12799. $scope.gridOptions.enableColumnResizing = true;
  12800. // $scope.gridOptions.enableFiltering = true;
  12801. $scope.gridOptions.enableGridMenu = false;
  12802. $scope.gridOptions.enableRowSelection = true;
  12803. $scope.gridOptions.showGridFooter = true;
  12804. $scope.gridOptions.showColumnFooter = false;
  12805. $scope.gridOptions.fastWatch = true;
  12806. $scope.gridOptions.useExternalFiltering = true;
  12807. $scope.gridOptions.useExternalPagination = true;
  12808. $scope.gridOptions.paginationPageSizes = [10];
  12809. $scope.gridOptions.paginationPageSize = 10;
  12810. $scope.gridOptions.multiSelect = true;
  12811. $scope.gridOptions.rowIdentity = function (row) {
  12812. return row.id;
  12813. };
  12814. $scope.gridOptions.getRowIdentity = function (row) {
  12815. return row.id;
  12816. };
  12817. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12818. $scope.gridOptions.columnDefs = [
  12819. // { name:'id', width:80, enableFiltering:false},
  12820. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12821. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12822. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12823. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12824. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12825. {
  12826. name: "inspection.title",
  12827. displayName: "计划主题",
  12828. width: 120,
  12829. enableFiltering: false,
  12830. },
  12831. {
  12832. name: "sign",
  12833. displayName: "单号",
  12834. width: 140,
  12835. enableFiltering: false,
  12836. },
  12837. {
  12838. name: "inspectionType.type",
  12839. displayName: "巡检分类",
  12840. width: 200,
  12841. enableFiltering: false,
  12842. cellTemplate: '<div>' +
  12843. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12844. '</div>'
  12845. },
  12846. {
  12847. name: "stateName",
  12848. displayName: "状态",
  12849. width: 80,
  12850. enableFiltering: false,
  12851. },
  12852. {
  12853. name: "processUser.name",
  12854. displayName: "处理人/组",
  12855. width: 120,
  12856. enableFiltering: false,
  12857. cellTemplate: '<div>' +
  12858. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12859. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12860. '</div>'
  12861. },
  12862. {
  12863. name: "startDate",
  12864. displayName: "开始时间",
  12865. width: 160,
  12866. enableFiltering: false,
  12867. },
  12868. {
  12869. name: "endTime",
  12870. displayName: "结束时间",
  12871. width: 160,
  12872. enableFiltering: false,
  12873. cellTemplate: '<div>' +
  12874. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12875. '</div>'
  12876. },
  12877. // {
  12878. // name: "batchNo",
  12879. // displayName: "批次号",
  12880. // width: 160,
  12881. // enableFiltering: false,
  12882. // },
  12883. ];
  12884. var defaultFilterData = {
  12885. idx: 0,
  12886. sum: 10,
  12887. };
  12888. $scope.transferTime = function (time) {
  12889. return moment(time).format("YYYY-MM-DD HH:mm");
  12890. };
  12891. //分页控制
  12892. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12893. gridApi.pagination.on.paginationChanged(
  12894. $scope,
  12895. function (newPage, pageSize) {
  12896. var filtersData = $scope.memoryfilterData;
  12897. filtersData.idx = newPage - 1;
  12898. filtersData.sum = pageSize;
  12899. $scope.refreshData("expand-right", filtersData);
  12900. }
  12901. );
  12902. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12903. data.grid.appScope.selected.items = data.entity;
  12904. });
  12905. };
  12906. //页面获取数据
  12907. $scope.refreshData = function (style, filterData) {
  12908. // $scope.ldloading[style.replace('-', '_')] = true;
  12909. console.log(angular.isUndefined(filterData))
  12910. if (angular.isUndefined(filterData)) {
  12911. filterData = defaultFilterData;
  12912. }
  12913. $scope.myData = [];
  12914. console.log(filterData)
  12915. if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
  12916. filterData.inspectionProcessActual = {
  12917. inspectionid: $scope.model.id,
  12918. batchNo:filterData.inspectionProcessActual.batchNo
  12919. }
  12920. }else{
  12921. filterData.inspectionProcessActual = {
  12922. inspectionid: $scope.model.id
  12923. }
  12924. }
  12925. // angular.extend(filterData, {
  12926. // inspectionProcessActual: {
  12927. // inspectionid: $scope.model.id,
  12928. // },
  12929. // });
  12930. console.log(filterData)
  12931. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12932. function (data) {
  12933. var myData = Restangular.stripRestangular(data);
  12934. $scope.gridOptions.totalItems = myData.totalNum;
  12935. $scope.myData = myData.list;
  12936. for (var i = 0; i < $scope.myData.length; i++) {
  12937. //添加序号
  12938. $scope.myData[i]["item"] =
  12939. i + 1 + filterData.idx * filterData.sum;
  12940. }
  12941. // $scope.ldloading[style.replace('-', '_')] = false;
  12942. },
  12943. function () {
  12944. // $scope.ldloading[style.replace('-', '_')] = false;
  12945. }
  12946. );
  12947. };
  12948. $scope.refreshData("expand-right", defaultFilterData);
  12949. },
  12950. });
  12951. //文本框自定义选择面板组件
  12952. formlyConfigProvider.setType({
  12953. name: "ui-input-selectmodal",
  12954. extends: "input",
  12955. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  12956. defaultOptions: function (options) {
  12957. return {
  12958. templateOptions: {
  12959. openModal: function (size, options, modal) {
  12960. var modalInstance = modal.open({
  12961. templateUrl: "assets/views/customform/tpl/modal-content.html",
  12962. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  12963. size: size,
  12964. resolve: options.templateOptions.modalParam,
  12965. });
  12966. modalInstance.result.then(
  12967. function (selectedItem) {
  12968. options.value(selectedItem);
  12969. },
  12970. function () {
  12971. //console.log('Modal dismissed at: ' + new Date());
  12972. }
  12973. );
  12974. },
  12975. },
  12976. };
  12977. },
  12978. });
  12979. //日期控件
  12980. var datepicker_attr = [
  12981. "date-disabled",
  12982. "custom-class",
  12983. "show-weeks",
  12984. "starting-day",
  12985. "init-date",
  12986. "min-mode",
  12987. "max-mode",
  12988. "format-day",
  12989. "format-month",
  12990. "format-year",
  12991. "format-day-header",
  12992. "format-day-title",
  12993. "format-month-title",
  12994. "year-range",
  12995. "shortcut-propagation",
  12996. "datepicker-popup",
  12997. "show-button-bar",
  12998. "current-text",
  12999. "clear-text",
  13000. "close-text",
  13001. "close-on-date-selection",
  13002. "datepicker-append-to-body",
  13003. ];
  13004. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  13005. formlyConfigProvider.setType({
  13006. name: "ui-datetime",
  13007. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  13008. extends: "input",
  13009. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13010. defaultOptions: {
  13011. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13012. templateOptions: {
  13013. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13014. },
  13015. },
  13016. controller: [
  13017. "$scope",
  13018. "$filter",
  13019. function ($scope, $filter) {
  13020. $scope.model[$scope.options.key] = $filter("date")(
  13021. new Date(),
  13022. $scope.options.templateOptions.datepickerPopup
  13023. );
  13024. $scope.options.initialValue = $scope.model[$scope.options.key];
  13025. },
  13026. ],
  13027. });
  13028. //日期控件
  13029. formlyConfigProvider.setType({
  13030. name: "ui-datepicker",
  13031. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  13032. extends: "input",
  13033. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13034. defaultOptions: {
  13035. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13036. templateOptions: {
  13037. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13038. },
  13039. },
  13040. controller: [
  13041. "$scope",
  13042. "$filter",
  13043. function ($scope, $filter) {
  13044. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  13045. if ($scope.model[$scope.options.key]) {
  13046. } else {
  13047. $scope.model[$scope.options.key] = $filter("date")(
  13048. new Date(),
  13049. $scope.options.templateOptions.datepickerPopup
  13050. );
  13051. }
  13052. $scope.options.initialValue = $scope.model[$scope.options.key];
  13053. $scope.endOpen = true;
  13054. $scope.datepicker = {};
  13055. $scope.datepicker.opened = false;
  13056. $scope.datepicker.open = function ($event) {
  13057. $scope.datepicker.opened = true;
  13058. };
  13059. },
  13060. ],
  13061. });
  13062. //时分控件
  13063. formlyConfigProvider.setType({
  13064. name: "ui-datehourtime",
  13065. extends: "input",
  13066. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  13067. defaultOptions: function (options) {
  13068. return {
  13069. noFormControl: true,
  13070. // validators:{
  13071. // required:{
  13072. // expression:function(viewValue, modelValue){
  13073. // console.log(options)
  13074. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13075. // // var value = modelValue.getHours() || viewValue.getHours();
  13076. // return value.length>=1;
  13077. // }
  13078. // }
  13079. // }
  13080. };
  13081. },
  13082. controller: [
  13083. "$scope",
  13084. "$log",
  13085. function ($scope, $log) {
  13086. $scope.hstep = new Date(
  13087. Date.parse($scope.model[$scope.options.key])
  13088. ).getHours();
  13089. $scope.minutes = new Date(
  13090. Date.parse($scope.model[$scope.options.key])
  13091. ).getMinutes();
  13092. $scope.model[$scope.options.key] = new Date(
  13093. Date.parse($scope.model[$scope.options.key])
  13094. );
  13095. },
  13096. ],
  13097. });
  13098. //状态追踪
  13099. formlyConfigProvider.setType({
  13100. name: "ui-followStatus",
  13101. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13102. controller: [
  13103. "$scope",
  13104. "api_bpm_data",
  13105. "Restangular",
  13106. function ($scope, api_bpm_data, Restangular) {
  13107. setTimeout(function () {
  13108. var pkey = $scope.options.templateOptions.pkey;
  13109. var dataId = $scope.model.id;
  13110. if (dataId) {
  13111. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13112. if (response) {
  13113. var myData = Restangular.stripRestangular(response);
  13114. var processInstanceId = myData.data.processInstanceId;
  13115. $scope.options.templateOptions
  13116. .getData(
  13117. $scope.model,
  13118. $scope.options.templateOptions.ApiService,
  13119. processInstanceId
  13120. )
  13121. .then(function (result) {
  13122. if (result.status == 200) {
  13123. var newData = Restangular.stripRestangular(result);
  13124. $scope.followData = newData.data;
  13125. }
  13126. });
  13127. }
  13128. });
  13129. }
  13130. }, 10);
  13131. },
  13132. ],
  13133. });
  13134. //处理日志
  13135. formlyConfigProvider.setType({
  13136. name: "ui-handlerLog",
  13137. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13138. controller: [
  13139. "$scope",
  13140. "api_bpm_data",
  13141. "Restangular",
  13142. function ($scope, api_bpm_data, Restangular) {
  13143. console.log($scope, 'ui-handlerLog')
  13144. },
  13145. ],
  13146. });
  13147. //资产
  13148. formlyConfigProvider.setType({
  13149. name: "ui-zc",
  13150. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13151. controller: [
  13152. "$scope",
  13153. "api_bpm_data",
  13154. "Restangular",
  13155. function ($scope, api_bpm_data, Restangular) {
  13156. console.log($scope, 'ui-zc');
  13157. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13158. },
  13159. ],
  13160. });
  13161. //绑定的耗材
  13162. formlyConfigProvider.setType({
  13163. name: "ui-hc",
  13164. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13165. controller: [
  13166. "$scope",
  13167. "api_cmdb2",
  13168. "Restangular",
  13169. function ($scope, api_cmdb2, Restangular) {
  13170. console.log($scope, 'ui-hc')
  13171. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13172. $scope.list = [];
  13173. var sjId = $scope.model.incident.id;
  13174. api_cmdb2.getHc(sjId).then(function (response) {
  13175. console.log(response)
  13176. if (response.status == 200) {
  13177. $scope.list = response.data;
  13178. }
  13179. })
  13180. },
  13181. ],
  13182. });
  13183. //历史记录
  13184. formlyConfigProvider.setType({
  13185. name: "ui-history",
  13186. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13187. controller: [
  13188. "$scope",
  13189. "api_bpm_data",
  13190. "Restangular",
  13191. function ($scope, api_bpm_data, Restangular) {
  13192. setTimeout(function () {
  13193. var pkey = $scope.options.templateOptions.pkey;
  13194. var dataId = $scope.model.id;
  13195. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13196. if (response) {
  13197. var myData = Restangular.stripRestangular(response);
  13198. var processInstanceId = myData.data.processInstanceId;
  13199. $scope.options.templateOptions
  13200. .getData(
  13201. $scope.model,
  13202. $scope.options.templateOptions.ApiService,
  13203. processInstanceId
  13204. )
  13205. .then(function (result) {
  13206. if (result.status == 200) {
  13207. var newData = Restangular.stripRestangular(result);
  13208. var long = newData.data.length - 1;
  13209. $scope.followData = newData.data[long];
  13210. }
  13211. });
  13212. }
  13213. });
  13214. }, 10);
  13215. },
  13216. ],
  13217. });
  13218. // //请求人信息显示
  13219. // formlyConfigProvider.setType({
  13220. // name: "ui-disrequester",
  13221. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13222. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13223. // defaultOptions: function(options) {
  13224. // return {
  13225. // templateOptions: {}
  13226. // };
  13227. // },
  13228. // controller: ['$scope', function($scope) {
  13229. // $scope.options.templateOptions.that = $scope;
  13230. // }]
  13231. // });
  13232. //退回人信息显示
  13233. formlyConfigProvider.setType({
  13234. name: "ui-returnperson",
  13235. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13236. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13237. defaultOptions: function (options) {
  13238. return {
  13239. templateOptions: {},
  13240. };
  13241. },
  13242. controller: [
  13243. "$scope",
  13244. function ($scope) {
  13245. $scope.group = "";
  13246. $scope.role = "";
  13247. if (
  13248. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13249. $scope.model.handlingPersonnelUser.group.length == 1
  13250. ) {
  13251. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13252. } else {
  13253. for (
  13254. var i = 0;
  13255. i < $scope.model.handlingPersonnelUser.group.length;
  13256. i++
  13257. ) {
  13258. $scope.group +=
  13259. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13260. }
  13261. }
  13262. if (
  13263. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13264. $scope.model.handlingPersonnelUser.role.length == 1
  13265. ) {
  13266. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13267. } else {
  13268. for (
  13269. var i = 0;
  13270. i < $scope.model.handlingPersonnelUser.role.length;
  13271. i++
  13272. ) {
  13273. $scope.role +=
  13274. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13275. }
  13276. }
  13277. $scope.options.templateOptions.that = $scope;
  13278. $scope.options.templateOptions.that = $scope;
  13279. },
  13280. ],
  13281. });
  13282. //退回人信息显示(去掉工作组&角色)
  13283. formlyConfigProvider.setType({
  13284. name: "ui-returnpersonNoGroup",
  13285. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13286. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13287. defaultOptions: function (options) {
  13288. return {
  13289. templateOptions: {},
  13290. };
  13291. },
  13292. controller: [
  13293. "$scope",
  13294. function ($scope) {
  13295. $scope.group = "";
  13296. $scope.role = "";
  13297. if (
  13298. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13299. $scope.model.handlingPersonnelUser.group.length == 1
  13300. ) {
  13301. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13302. } else {
  13303. for (
  13304. var i = 0;
  13305. i < $scope.model.handlingPersonnelUser.group.length;
  13306. i++
  13307. ) {
  13308. $scope.group +=
  13309. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13310. }
  13311. }
  13312. if (
  13313. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13314. $scope.model.handlingPersonnelUser.role.length == 1
  13315. ) {
  13316. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13317. } else {
  13318. for (
  13319. var i = 0;
  13320. i < $scope.model.handlingPersonnelUser.role.length;
  13321. i++
  13322. ) {
  13323. $scope.role +=
  13324. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13325. }
  13326. }
  13327. $scope.options.templateOptions.that = $scope;
  13328. $scope.options.templateOptions.that = $scope;
  13329. },
  13330. ],
  13331. });
  13332. //指派技术人员
  13333. formlyConfigProvider.setType({
  13334. name: "ui-apiontperson",
  13335. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13336. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13337. defaultOptions: function (options) {
  13338. return {
  13339. templateOptions: {
  13340. transtlara: function (value, $scope) { },
  13341. },
  13342. };
  13343. },
  13344. controller: [
  13345. "$scope",
  13346. "api_user_data",
  13347. "Restangular",
  13348. function ($scope, api_user_data, Restangular) {
  13349. var filterData = {
  13350. idx: 0,
  13351. sum: 1000,
  13352. };
  13353. api_user_data
  13354. .fetchDataList("group", filterData)
  13355. .then(function (response) {
  13356. if (response.status == 200) {
  13357. $scope.select = {};
  13358. $scope.multipleDemo = {};
  13359. $scope.userdata = {};
  13360. var data = response.list;
  13361. var item = [];
  13362. $scope.multipleDemo = data;
  13363. $scope.multipleDemo;
  13364. }
  13365. });
  13366. $scope.options.templateOptions.onChange = function (
  13367. id,
  13368. options,
  13369. groupdata,
  13370. $event,
  13371. model
  13372. ) {
  13373. if (groupdata.option) {
  13374. $scope.model[$scope.options.key] = {};
  13375. var fildate = {
  13376. idx: 0,
  13377. sum: 1000,
  13378. user: {
  13379. roledata: {
  13380. rolecode: model.currentRole,
  13381. },
  13382. selectType: "1",
  13383. groupdata: {
  13384. id: groupdata.option.id,
  13385. },
  13386. },
  13387. };
  13388. api_user_data
  13389. .fetchDataList("user", fildate)
  13390. .then(function (response) {
  13391. if (response.status == 200) {
  13392. $scope.userdata = {};
  13393. $scope.userdata = response.list;
  13394. }
  13395. });
  13396. } else {
  13397. $scope.model[$scope.options.key] = {
  13398. id: groupdata.id.id,
  13399. };
  13400. $scope.options.templateOptions.transtlara(
  13401. $scope.model[$scope.options.key],
  13402. $scope
  13403. );
  13404. }
  13405. };
  13406. // }
  13407. },
  13408. ],
  13409. });
  13410. //请求科室信息(小蓝框) lmm
  13411. formlyConfigProvider.setType({
  13412. name: "ui-deptinformation",
  13413. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13414. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13415. return {
  13416. templateOptions: {
  13417. checkform: function (options) { },
  13418. },
  13419. };
  13420. },
  13421. controller: [
  13422. "$scope",
  13423. "api_statistic",
  13424. function ($scope, api_statistic) {
  13425. // console.log($scope)
  13426. },
  13427. ],
  13428. });
  13429. //请求人信息
  13430. formlyConfigProvider.setType({
  13431. name: "ui-requesterinformation",
  13432. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13433. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13434. return {
  13435. templateOptions: {
  13436. checkform: function (options) {
  13437. if (options.model.requester) {
  13438. options.value(options.model.requester);
  13439. }
  13440. },
  13441. addRequeter: function (size, options, modal, e) {
  13442. if (e) {
  13443. if (e.clientX === 0) {
  13444. return;
  13445. }
  13446. e.preventDefault();
  13447. }
  13448. var modalInstance = modal.open({
  13449. templateUrl:
  13450. "assets/views/customform/tpl/modal-add-callrequester.html",
  13451. controller: function (
  13452. $scope,
  13453. sco,
  13454. $rootScope,
  13455. $modalInstance,
  13456. items,
  13457. SweetAlert,
  13458. title,
  13459. Restangular,
  13460. APIService,
  13461. UserService,
  13462. api_user_data,
  13463. api_statistic,
  13464. api_wechatfile,
  13465. $stateParams
  13466. ) {
  13467. $modalInstance.SweetAlert = SweetAlert;
  13468. $scope.title = "新增报修人";
  13469. $scope.requester = {};
  13470. $scope.searchData = {};
  13471. $scope.isRoom = sessionStorage.getItem('ifRoom') == 1;
  13472. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13473. var paramsModel = JSON.parse($stateParams.model)
  13474. //来电-添加报修人-回显电话
  13475. if (paramsModel.model.incident.requester.hjzxPhone) {
  13476. $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
  13477. }
  13478. }
  13479. $scope.onChangeadd = function (searchData) {
  13480. $scope.searchKey = searchData.account;
  13481. // $scope.searchDataadd = searchData;
  13482. var requesdata = angular.copy(searchData);
  13483. if (requesdata.mphone) {
  13484. delete requesdata.mphone;
  13485. }
  13486. $scope.requester = requesdata;
  13487. console.log($scope.requester);
  13488. };
  13489. $scope.refreshUseradd = function (searchKey) {
  13490. //请求人搜索
  13491. $scope.requester.account = searchKey;
  13492. $scope.searchData = searchKey;
  13493. serchdataadd(searchKey);
  13494. };
  13495. $scope.getMydata = function (x) {
  13496. $scope.searchField = JSON.parse(x[0]).account;
  13497. $scope.requester = JSON.parse(x[0]);
  13498. console.log($scope.requester);
  13499. };
  13500. $scope.getMydataone = function (x) {
  13501. $scope.searchField = x;
  13502. $scope.requester.account = x;
  13503. };
  13504. serchdataadd();
  13505. api_wechatfile
  13506. .getDictionary({
  13507. type: "list",
  13508. key: "male",
  13509. })
  13510. .then(function (data) {
  13511. if (data.status == 200) {
  13512. requester.gender = data.list;
  13513. }
  13514. });
  13515. function serchdataadd(searchKey) {
  13516. if (searchKey) {
  13517. var filterData = {
  13518. requester: {
  13519. searchKey: searchKey,
  13520. },
  13521. idx: 0,
  13522. sum: 10,
  13523. };
  13524. } else {
  13525. var filterData = {
  13526. idx: 0,
  13527. sum: 10,
  13528. };
  13529. }
  13530. api_user_data
  13531. .fetchDataList("requester", filterData)
  13532. .then(function (response) {
  13533. var myData = response;
  13534. $scope.myData = myData.list;
  13535. });
  13536. }
  13537. api_user_data
  13538. .fetchDataList("area", {
  13539. idx: 0,
  13540. sum: 1000,
  13541. })
  13542. .then(function (response) {
  13543. if (response.status == 200) {
  13544. $scope.areas = response.list;
  13545. }
  13546. });
  13547. api_wechatfile
  13548. .getDictionary(
  13549. {
  13550. key: "requester_type",
  13551. type: "list",
  13552. },
  13553. {
  13554. idx: 0,
  13555. sum: 100,
  13556. }
  13557. )
  13558. .then(function (response) {
  13559. if (response) {
  13560. $scope.networktypes = response;
  13561. }
  13562. });
  13563. $scope.requesterAreaid = "";
  13564. $scope.onChange = function (item) {
  13565. $scope.requesterAreaid = item.id;
  13566. api_user_data
  13567. .fetchDataList("place", {
  13568. place: {
  13569. area: {
  13570. id: item.id,
  13571. },
  13572. },
  13573. idx: 0,
  13574. sum: 1000,
  13575. })
  13576. .then(function (response) {
  13577. if (response.status == 200) {
  13578. $scope.places = response.list;
  13579. delete $scope.requester.placeDTO;
  13580. }
  13581. });
  13582. };
  13583. // 修改地点
  13584. $scope.requesterPlaceid = "";
  13585. $scope.onChangePlace = function (item) {
  13586. $scope.requesterPlaceid = item.id;
  13587. api_user_data
  13588. .fetchDataList("room", {
  13589. room: {
  13590. place: {
  13591. id: item.id,
  13592. },
  13593. },
  13594. idx: 0,
  13595. sum: 1000,
  13596. })
  13597. .then(function (response) {
  13598. if (response.status == 200) {
  13599. $scope.rooms = response.list;
  13600. }
  13601. });
  13602. };
  13603. $scope.refresh = function (searchVal) {
  13604. var faildata = {};
  13605. if ($scope.requesterAreaid) {
  13606. faildata = {
  13607. idx: 0,
  13608. sum: 1000,
  13609. place: {
  13610. areaId: $scope.requesterAreaid,
  13611. place: searchVal,
  13612. selectType: "pinyin_qs",
  13613. },
  13614. };
  13615. } else {
  13616. faildata = {
  13617. idx: 0,
  13618. sum: 1000,
  13619. place: {
  13620. place: searchVal,
  13621. selectType: "pinyin_qs",
  13622. },
  13623. };
  13624. }
  13625. api_user_data
  13626. .fetchDataList("place", faildata)
  13627. .then(function (response) {
  13628. $scope.places = response.list;
  13629. delete $scope.requester.placeDTO;
  13630. });
  13631. };
  13632. // 初始化房间号
  13633. $scope.refreshPlace = function () {
  13634. var faildata = {};
  13635. if ($scope.requesterPlaceid) {
  13636. faildata = {
  13637. idx: 0,
  13638. sum: 1000,
  13639. room: {
  13640. place: {id:$scope.requesterPlaceid},
  13641. },
  13642. };
  13643. } else {
  13644. faildata = {
  13645. idx: 0,
  13646. sum: 1000,
  13647. room: {
  13648. place: {id:$scope.requesterPlaceid},
  13649. },
  13650. };
  13651. }
  13652. api_user_data
  13653. .fetchDataList("room", faildata)
  13654. .then(function (response) {
  13655. $scope.rooms = response.list;
  13656. });
  13657. };
  13658. $scope.refreshDepts = function (key) {
  13659. var filterData = {
  13660. idx: 0,
  13661. sum: 5,
  13662. dept: {
  13663. name: key,
  13664. },
  13665. };
  13666. UserService.fetchDataList("department", filterData).then(
  13667. function (response) {
  13668. if (response.status == 200) {
  13669. $scope.depts = response.list;
  13670. }
  13671. }
  13672. );
  13673. };
  13674. $scope.ok = function () {
  13675. if (
  13676. angular.isUndefined($scope.requester.account) ||
  13677. $scope.requester.account == null ||
  13678. $scope.requester.account == ""
  13679. ) {
  13680. SweetAlert.swal(
  13681. "报修人员编号未填!",
  13682. "请填写报修人员编号",
  13683. "error"
  13684. );
  13685. } else if (
  13686. angular.isUndefined($scope.requester.name) ||
  13687. $scope.requester.name == null ||
  13688. $scope.requester.name == ""
  13689. ) {
  13690. SweetAlert.swal(
  13691. "报修人姓名未填!",
  13692. "请填写报修人姓名",
  13693. "error"
  13694. );
  13695. } else if (
  13696. angular.isUndefined($scope.requester.requesterType) ||
  13697. $scope.requester.requesterType == null ||
  13698. $scope.requester.requesterTypeDTO == ""
  13699. ) {
  13700. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13701. } else if (
  13702. angular.isUndefined($scope.requester.mphone) ||
  13703. $scope.requester.mphone == null ||
  13704. $scope.requester.mphone == ""
  13705. ) {
  13706. SweetAlert.swal(
  13707. "报修人联系电话未填!",
  13708. "请填写报修人联系电话",
  13709. "error"
  13710. );
  13711. } else {
  13712. $scope.requesterId = $scope.requester.id;
  13713. var data = {
  13714. incident: {
  13715. requester: {
  13716. id: $scope.requesterId,
  13717. },
  13718. },
  13719. idx: 0,
  13720. sum: 3,
  13721. };
  13722. api_statistic
  13723. .tableData(data, "incident")
  13724. .then(function (data) {
  13725. sco.$parent.$parent.$parent.model.incident.tableList =
  13726. data.list;
  13727. });
  13728. $scope.$watch(
  13729. sco.$parent.$parent.$parent.model.incident.tableList,
  13730. function (oldObj, newObj) {
  13731. if (newObj != oldObj) {
  13732. sco.$parent.$parent.$parent.model.incident.tableList =
  13733. newObj;
  13734. }
  13735. }
  13736. );
  13737. console.log($scope.requester);
  13738. $modalInstance.close($scope.requester);
  13739. }
  13740. };
  13741. $scope.cancel = function () {
  13742. $modalInstance.dismiss("cancel");
  13743. };
  13744. },
  13745. resolve: {
  13746. items: function () {
  13747. return {
  13748. fetchItems: function (filterData, APIService) {
  13749. filterData = filterData || {};
  13750. if (!filterData.idx) {
  13751. filterData = {
  13752. idx: 0,
  13753. sum: 10,
  13754. };
  13755. }
  13756. return options.templateOptions.fetchItems(
  13757. filterData,
  13758. APIService
  13759. );
  13760. },
  13761. };
  13762. },
  13763. title: function () {
  13764. return options.templateOptions.modalTitle;
  13765. },
  13766. Restangular: function () {
  13767. return options.templateOptions.Restangular;
  13768. },
  13769. APIService: function () {
  13770. return options.templateOptions.ApiService;
  13771. },
  13772. UserService: function () {
  13773. return options.templateOptions.UserService;
  13774. },
  13775. sco: function () {
  13776. return $scope;
  13777. },
  13778. },
  13779. });
  13780. modalInstance.result.then(
  13781. function (selectedItem) {
  13782. console.log(selectedItem);
  13783. if (selectedItem) {
  13784. var data = {
  13785. requester: selectedItem,
  13786. };
  13787. $scope.searchKey = selectedItem.account;
  13788. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13789. // if (selectedItem.place && selectedItem.place.place) {
  13790. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13791. // }
  13792. options.templateOptions.UserService.addData(
  13793. "requester",
  13794. data
  13795. ).then(function (response) {
  13796. if (response.status == 200) {
  13797. if (options.model) {
  13798. options.model.requester = response.data;
  13799. $scope.$parent.$parent.$parent.model.incident.requester =
  13800. response.data;
  13801. $scope.$parent.$parent.$parent.model.requestershow =
  13802. response.data;
  13803. if (options.model.place) {
  13804. options.model.place.id = "";
  13805. }
  13806. if (options.model.area) {
  13807. options.model.area.id = "";
  13808. }
  13809. options.model.contacts = selectedItem.name;
  13810. if (
  13811. selectedItem.mphone &&
  13812. selectedItem.mphone != null &&
  13813. selectedItem.mphone != ""
  13814. ) {
  13815. options.model.contactsInformation =
  13816. selectedItem.mphone;
  13817. } else {
  13818. options.model.contactsInformation =
  13819. selectedItem.telephone;
  13820. }
  13821. if (
  13822. selectedItem.requesterTypeDTO &&
  13823. selectedItem.requesterTypeDTO.id == 2
  13824. ) {
  13825. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13826. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13827. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13828. }
  13829. }
  13830. if (!response.data.id) {
  13831. response.data.id = selectedItem.id;
  13832. }
  13833. options.value(response.data);
  13834. options.value(response.data);
  13835. console.log($scope, "0000000");
  13836. //新增报修人带入区域地点2020年4月23日19:48:15
  13837. $scope.model.selecthouseNumber = selectedItem.place
  13838. ? selectedItem.place
  13839. : {};
  13840. $scope.$root.selecthouseNumber = selectedItem.place
  13841. ? selectedItem.place
  13842. : {};
  13843. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13844. if (selectedItem.place && selectedItem.place.id) {
  13845. options.model.place.id = selectedItem.place.id;
  13846. options.model.place.area.id =
  13847. selectedItem.place.area.id;
  13848. }
  13849. } else {
  13850. if (selectedItem.place && selectedItem.place.id) {
  13851. options.model.place.id = selectedItem.place.id;
  13852. options.model.area.id = selectedItem.place.area.id;
  13853. }
  13854. }
  13855. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13856. // options.model.area.id = selectedItem.place.area.id
  13857. // }
  13858. if (selectedItem.houseNumber) {
  13859. options.model.houseNumber = selectedItem.houseNumber;
  13860. }
  13861. if (selectedItem.room) {
  13862. options.model.room.id = selectedItem.room.id;
  13863. }
  13864. // if (selectedItem.id) {
  13865. options.model.account = selectedItem.account;
  13866. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13867. var baoxiuFields =
  13868. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13869. .fields[1].fields;
  13870. var baoxiurenTo;
  13871. baoxiuFields.forEach((e, i) => {
  13872. if (e.key == "account") {
  13873. baoxiurenTo = e.templateOptions;
  13874. baoxiurenTo.APIService.fetchDataList("requester", {
  13875. idx: 0,
  13876. sum: 20,
  13877. requester: {
  13878. searchKey: selectedItem.account,
  13879. },
  13880. }).then((res) => {
  13881. baoxiurenTo.options = res.list;
  13882. options.model.account = selectedItem.account;
  13883. });
  13884. }
  13885. });
  13886. // }
  13887. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  13888. // 选择重复事件侧滑框
  13889. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  13890. $scope.$parent.$parent.$parent.model[
  13891. "repeatIncidentShow"
  13892. ] = false;
  13893. setTimeout(() => {
  13894. $scope.$parent.$parent.$parent.model[
  13895. "repeatIncidentShow"
  13896. ] = true;
  13897. }, 500);
  13898. // }
  13899. } else {
  13900. modalInstance.SweetAlert.swal({
  13901. title: "系统错误",
  13902. text: "账号重复!",
  13903. type: "error",
  13904. });
  13905. }
  13906. });
  13907. }
  13908. },
  13909. function () { }
  13910. );
  13911. },
  13912. changeRequeter: function (
  13913. size,
  13914. options,
  13915. modal,
  13916. modeldata,
  13917. $rootScope
  13918. ) {
  13919. var modalInstance = modal.open({
  13920. templateUrl:
  13921. "assets/views/customform/tpl/modal-change-requester.html",
  13922. controller: function (
  13923. $scope,
  13924. $modalInstance,
  13925. items,
  13926. SweetAlert,
  13927. title,
  13928. Restangular,
  13929. APIService,
  13930. UserService,
  13931. api_user_data,
  13932. $rootScope
  13933. ) {
  13934. $scope.title = "修改报修人";
  13935. $scope.requester = {
  13936. id: modeldata.requester.id,
  13937. account: modeldata.requester.account,
  13938. name: modeldata.requester.name,
  13939. gender: modeldata.requester.gender,
  13940. email: modeldata.requester.email,
  13941. deptName: modeldata.requester.deptName,
  13942. mphone: modeldata.requester.mphone,
  13943. telephone: modeldata.requester.telephone,
  13944. studentNo: modeldata.requester.studentNo,
  13945. areaDTO: modeldata.requester.areaDTO,
  13946. placeDTO: modeldata.requester.placeDTO,
  13947. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  13948. };
  13949. $scope.onChangeadd = function (searchData) {
  13950. console.log(searchData);
  13951. $scope.searchKey = searchData.account;
  13952. var requesdata = angular.copy(searchData);
  13953. if (requesdata.mphone) {
  13954. delete requesdata.mphone;
  13955. }
  13956. $scope.requester = requesdata;
  13957. };
  13958. $scope.refreshUseradd = function (searchKey) {
  13959. //请求人搜索
  13960. $scope.requester.account = searchKey;
  13961. $scope.searchData = searchKey;
  13962. serchdataadd(searchKey);
  13963. };
  13964. $scope.getMydata = function (x) {
  13965. $scope.searchField = JSON.parse(x[0]).account;
  13966. $scope.requester = JSON.parse(x[0]);
  13967. };
  13968. $scope.getMydataone = function (x) {
  13969. $scope.searchField = x;
  13970. $scope.requester.account = x;
  13971. };
  13972. serchdataadd();
  13973. function serchdataadd(searchKey) {
  13974. if (searchKey) {
  13975. var filterData = {
  13976. requester: {
  13977. searchKey: searchKey,
  13978. },
  13979. idx: 0,
  13980. sum: 10,
  13981. };
  13982. } else {
  13983. var filterData = {
  13984. idx: 0,
  13985. sum: 10,
  13986. };
  13987. }
  13988. api_user_data
  13989. .fetchDataList("requester", filterData)
  13990. .then(function (response) {
  13991. var myData = response;
  13992. $scope.myData = myData.list;
  13993. });
  13994. }
  13995. api_user_data
  13996. .fetchDataList("area", {
  13997. idx: 0,
  13998. sum: 1000,
  13999. })
  14000. .then(function (response) {
  14001. if (response.status == 200) {
  14002. $scope.areas = response.list;
  14003. }
  14004. });
  14005. api_user_data
  14006. .fetchDataList("requesterType", {
  14007. idx: 0,
  14008. sum: 100,
  14009. })
  14010. .then(function (response) {
  14011. if (response.status == 200) {
  14012. $scope.networktypes = response.list;
  14013. }
  14014. });
  14015. if (
  14016. $scope.requester.areaDTO &&
  14017. $scope.requester.areaDTO.id &&
  14018. $scope.requester.areaDTO.id != ""
  14019. ) {
  14020. api_user_data
  14021. .fetchDataList("place", {
  14022. place: {
  14023. areaId: $scope.requester.areaDTO.id,
  14024. },
  14025. idx: 0,
  14026. sum: 1000,
  14027. })
  14028. .then(function (response) {
  14029. if (response.status == 200) {
  14030. $scope.places = response.list;
  14031. }
  14032. });
  14033. }
  14034. $scope.onChange = function (item) {
  14035. $scope.requester.placeDTO = {};
  14036. api_user_data
  14037. .fetchDataList("place", {
  14038. place: {
  14039. areaId: item.id,
  14040. },
  14041. idx: 0,
  14042. sum: 1000,
  14043. })
  14044. .then(function (response) {
  14045. if (response.status == 200) {
  14046. $scope.places = response.list;
  14047. }
  14048. });
  14049. };
  14050. $scope.refreshDepts = function (key) {
  14051. var filterData = {
  14052. idx: 0,
  14053. sum: 5,
  14054. dept: {
  14055. name: key,
  14056. },
  14057. };
  14058. UserService.fetchDataList("department", filterData).then(
  14059. function (response) {
  14060. if (response.status == 200) {
  14061. $scope.depts = response.list;
  14062. }
  14063. }
  14064. );
  14065. };
  14066. $scope.ok = function () {
  14067. if (
  14068. $scope.requester.account == "" ||
  14069. $scope.requester.name == ""
  14070. ) {
  14071. SweetAlert.swal(
  14072. "报修人姓名或人员编号号未填!",
  14073. "请补全报修人信息",
  14074. "error"
  14075. );
  14076. } else {
  14077. $modalInstance.close($scope.requester);
  14078. }
  14079. };
  14080. $scope.cancel = function () {
  14081. $modalInstance.dismiss("cancel");
  14082. };
  14083. },
  14084. resolve: {
  14085. items: function () {
  14086. return {
  14087. fetchItems: function (filterData, APIService) {
  14088. filterData = filterData || {};
  14089. if (!filterData.idx) {
  14090. filterData = {
  14091. idx: 0,
  14092. sum: 10,
  14093. };
  14094. }
  14095. return options.templateOptions.fetchItems(
  14096. filterData,
  14097. APIService
  14098. );
  14099. },
  14100. };
  14101. },
  14102. title: function () {
  14103. return options.templateOptions.modalTitle;
  14104. },
  14105. Restangular: function () {
  14106. return options.templateOptions.Restangular;
  14107. },
  14108. APIService: function () {
  14109. return options.templateOptions.ApiService;
  14110. },
  14111. UserService: function () {
  14112. return options.templateOptions.UserService;
  14113. },
  14114. },
  14115. });
  14116. modalInstance.result.then(
  14117. function (selectedItem) {
  14118. console.log(selectedItem);
  14119. if (selectedItem) {
  14120. if (options.model) {
  14121. if (options.model.place) {
  14122. options.model.place.id = "";
  14123. }
  14124. if (options.model.area) {
  14125. options.model.area.id = "";
  14126. }
  14127. options.model.contacts = selectedItem.name;
  14128. if (
  14129. selectedItem.mphone &&
  14130. selectedItem.mphone != null &&
  14131. selectedItem.mphone != ""
  14132. ) {
  14133. options.model.contactsInformation = selectedItem.mphone;
  14134. } else {
  14135. options.model.contactsInformation =
  14136. selectedItem.telephone;
  14137. }
  14138. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14139. options.model.place.id = selectedItem.placeDTO.id;
  14140. }
  14141. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14142. options.model.area.id = selectedItem.areaDTO.id;
  14143. }
  14144. if (
  14145. selectedItem.requesterTypeDTO &&
  14146. selectedItem.requesterTypeDTO.id == 2
  14147. ) {
  14148. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14149. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14150. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14151. }
  14152. }
  14153. var data = {
  14154. requester: selectedItem,
  14155. };
  14156. options.templateOptions.UserService.addData(
  14157. "requester",
  14158. data
  14159. ).then(function (response) {
  14160. if (response.status == 200) {
  14161. $scope.$parent.$parent.$parent.model["requestershow"] =
  14162. selectedItem;
  14163. options.value(response.data);
  14164. } else {
  14165. }
  14166. });
  14167. }
  14168. },
  14169. function () { }
  14170. );
  14171. event.preventDefault();
  14172. },
  14173. },
  14174. };
  14175. },
  14176. controller: [
  14177. "$scope",
  14178. "api_user_data",
  14179. "api_statistic",
  14180. "$stateParams",
  14181. function ($scope, api_user_data, api_statistic, $stateParams) {
  14182. console.log($stateParams)
  14183. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14184. var paramsModel = JSON.parse($stateParams.model)
  14185. //来电-添加报修人
  14186. if (paramsModel.model.incident.requester.hjzxPhone) {
  14187. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14188. }
  14189. }
  14190. $scope.options.initialValue = $scope.model[$scope.options.key];
  14191. $scope.saveReqPlace = false;
  14192. $scope.model.saveReqPlace = false;
  14193. $scope.selectGradeBox = function () {
  14194. $scope.saveReqPlace = !$scope.saveReqPlace;
  14195. console.log($scope);
  14196. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14197. };
  14198. if (
  14199. $scope.model.requester &&
  14200. $scope.model.requester.requesterTypeDTO &&
  14201. $scope.model.requester.requesterTypeDTO.id == 2
  14202. ) {
  14203. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14204. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14205. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14206. }
  14207. },
  14208. ],
  14209. });
  14210. // 请求人选控件
  14211. formlyConfigProvider.setType({
  14212. name: "ui-requesterselect",
  14213. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14214. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14215. defaultOptions: function (options, $scope) {
  14216. return {
  14217. templateOptions: {
  14218. // checkform: function(options) {
  14219. // if (options.model.requestershow) {
  14220. // options.value(options.model.requestershow);
  14221. // }
  14222. // },
  14223. validators: {
  14224. required: {
  14225. expression: function (viewValue, modelValue) {
  14226. var value = modelValue || viewValue;
  14227. return value.length >= 1;
  14228. },
  14229. },
  14230. },
  14231. openModal: function (size, options, modal) {
  14232. //查找弹出框
  14233. var modelObject = options.value();
  14234. var searchModal = function (filterSearchData) {
  14235. var modalInstance = modal.open({
  14236. templateUrl:
  14237. "assets/views/customform/tpl/checktable-modal-content.html",
  14238. controller: function (
  14239. $scope,
  14240. scope,
  14241. i18nService,
  14242. $modalInstance,
  14243. items,
  14244. title,
  14245. Restangular,
  14246. APIService,
  14247. language,
  14248. searchDatas,
  14249. api_bpm_data
  14250. ) {
  14251. $scope.langs = i18nService.getAllLangs();
  14252. $scope.lang = "zh-cn";
  14253. i18nService.setCurrentLang($scope.lang);
  14254. $scope.gridOptions = {};
  14255. $scope.gridOptions.data = "myData";
  14256. $scope.gridOptions.enableColumnResizing = true;
  14257. $scope.gridOptions.enableFiltering = true;
  14258. $scope.gridOptions.enableGridMenu = false;
  14259. $scope.gridOptions.enableRowSelection = true;
  14260. $scope.gridOptions.showGridFooter = true;
  14261. $scope.gridOptions.showColumnFooter = false;
  14262. $scope.gridOptions.fastWatch = true;
  14263. $scope.gridOptions.useExternalFiltering = true;
  14264. $scope.gridOptions.useExternalPagination = true;
  14265. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14266. $scope.gridOptions.paginationPageSize = 10;
  14267. $scope.gridOptions.multiSelect = false;
  14268. $scope.gridOptions.rowIdentity = function (row) {
  14269. return row.id;
  14270. };
  14271. $scope.gridOptions.getRowIdentity = function (row) {
  14272. return row.id;
  14273. };
  14274. $scope.gridOptions.columnDefs = [
  14275. {
  14276. name: "account",
  14277. displayName: "人员编号",
  14278. width: 140,
  14279. },
  14280. {
  14281. name: "name",
  14282. displayName: "姓名",
  14283. width: 100,
  14284. },
  14285. {
  14286. name: "gender.name",
  14287. displayName: "性别",
  14288. width: 80,
  14289. enableFiltering: false,
  14290. },
  14291. {
  14292. name: "mphone",
  14293. displayName: "电话",
  14294. width: 100,
  14295. enableFiltering: false,
  14296. },
  14297. {
  14298. name: "email",
  14299. displayName: "邮件",
  14300. width: 100,
  14301. },
  14302. {
  14303. name: "areaDTO.area",
  14304. displayName: "区域",
  14305. width: 100,
  14306. enableFiltering: false,
  14307. },
  14308. {
  14309. name: "placeDTO.place",
  14310. displayName: "地点",
  14311. enableFiltering: false,
  14312. },
  14313. ];
  14314. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14315. $scope.gridApi = gridApi;
  14316. // var filtersData = $scope.memoryfilterData;
  14317. // filtersData.idx = newPage - 1;
  14318. // filtersData.sum = pageSize;
  14319. gridApi.pagination.on.paginationChanged(
  14320. $scope,
  14321. function (newPage, pageSize) {
  14322. var filtersData = $scope.memoryfilterData;
  14323. filtersData.idx = newPage - 1;
  14324. filtersData.sum = pageSize;
  14325. $scope.loadData(filtersData);
  14326. }
  14327. );
  14328. gridApi.selection.on.rowSelectionChanged(
  14329. $scope,
  14330. function (data) {
  14331. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14332. $scope.selected.item = data.entity;
  14333. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14334. }
  14335. );
  14336. gridApi.core.on.filterChanged($scope, function () {
  14337. var grid = this.grid;
  14338. var filtersData = {
  14339. idx: 0,
  14340. sum: 10,
  14341. // 'requester': { 'userType': 1 }
  14342. };
  14343. angular.forEach(grid.columns, function (item) {
  14344. if (item.enableFiltering) {
  14345. if (
  14346. angular.isDefined(item.filters[0].term) &&
  14347. item.filters[0].term != ""
  14348. ) {
  14349. if (angular.isUndefined(filtersData["requester"])) {
  14350. filtersData["requester"] = {};
  14351. }
  14352. filtersData["requester"][item.field] =
  14353. item.filters[0].term;
  14354. }
  14355. }
  14356. });
  14357. $scope.memoryfilterData = filtersData;
  14358. $scope.loadData(filtersData);
  14359. });
  14360. };
  14361. $scope.memoryfilterData = defaultFilterData = {
  14362. idx: 0,
  14363. sum: 10,
  14364. };
  14365. $scope.loadData = function (filterData) {
  14366. if (!filterData.requester) {
  14367. filterData.requester = {};
  14368. }
  14369. if (scope.roleidcode) {
  14370. angular.extend(filterData["requester"], {
  14371. userType: 1,
  14372. });
  14373. }
  14374. items
  14375. .fetchItems(filterData, APIService)
  14376. .then(function (data) {
  14377. var myData = Restangular.stripRestangular(data);
  14378. $scope.gridOptions.totalItems = myData.totalNum;
  14379. $scope.myData = myData.list;
  14380. });
  14381. };
  14382. // $scope.title = title;
  14383. if (searchDatas) {
  14384. $scope.loadData(searchDatas);
  14385. } else {
  14386. $scope.loadData({
  14387. idx: 0,
  14388. sum: 10,
  14389. });
  14390. }
  14391. $scope.selected = {
  14392. item: {},
  14393. };
  14394. $scope.ok = function () {
  14395. $modalInstance.close($scope.selected.item);
  14396. };
  14397. $scope.cancel = function () {
  14398. $modalInstance.dismiss("cancel");
  14399. };
  14400. },
  14401. size: size,
  14402. resolve: {
  14403. items: function () {
  14404. return {
  14405. fetchItems: function (filterData, APIService) {
  14406. filterData = filterData || {};
  14407. if (
  14408. angular.isUndefined(filterData.idx) ||
  14409. filterData.idx == null
  14410. ) {
  14411. filterData = {
  14412. idx: 0,
  14413. sum: 10,
  14414. };
  14415. }
  14416. return options.templateOptions.fetchItems(
  14417. filterData,
  14418. APIService
  14419. );
  14420. },
  14421. };
  14422. },
  14423. title: function () {
  14424. return options.templateOptions.modalTitle;
  14425. },
  14426. Restangular: function () {
  14427. return options.templateOptions.Restangular;
  14428. },
  14429. APIService: function () {
  14430. return options.templateOptions.ApiService;
  14431. },
  14432. language: function () {
  14433. return options.templateOptions.language;
  14434. },
  14435. searchDatas: function () {
  14436. return filterSearchData;
  14437. },
  14438. scope: function () {
  14439. return $scope;
  14440. },
  14441. },
  14442. });
  14443. modalInstance.result.then(
  14444. function (selectedItem) {
  14445. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14446. selectedItem.telephone =
  14447. $scope.model.incident.contactsInformation;
  14448. }
  14449. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14450. selectedItem;
  14451. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14452. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14453. if ($scope.model) {
  14454. if ($scope.model.incident.place) {
  14455. $scope.model.incident.place.id = "";
  14456. }
  14457. if ($scope.model.area) {
  14458. $scope.model.incident.area.id = "";
  14459. }
  14460. $scope.model.incident.contacts = selectedItem.name;
  14461. if (
  14462. selectedItem.mphone &&
  14463. selectedItem.mphone != null &&
  14464. selectedItem.mphone != ""
  14465. ) {
  14466. $scope.model.incident.contactsInformation =
  14467. selectedItem.mphone;
  14468. } else {
  14469. $scope.model.incident.contactsInformation =
  14470. selectedItem.telephone;
  14471. }
  14472. $scope.model.incident.houseNumber = "";
  14473. if (
  14474. selectedItem.requesterTypeDTO &&
  14475. selectedItem.requesterTypeDTO.id == 2
  14476. ) {
  14477. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14478. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14479. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14480. }
  14481. }
  14482. $scope.options.value(selectedItem);
  14483. $scope.searchData = selectedItem.account;
  14484. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14485. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14486. }
  14487. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14488. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14489. }
  14490. if (selectedItem.houseNumber) {
  14491. $scope.model.incident.houseNumber =
  14492. selectedItem.houseNumber;
  14493. }
  14494. if (
  14495. selectedItem.requesterTypeDTO &&
  14496. selectedItem.requesterTypeDTO.id == 2
  14497. ) {
  14498. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14499. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14500. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14501. }
  14502. if (
  14503. options.templateOptions.callback &&
  14504. angular.isFunction(options.templateOptions.callback)
  14505. ) {
  14506. options.templateOptions.callback(selectedItem, options);
  14507. }
  14508. if (!$scope.roleidcode) {
  14509. $scope.charging(selectedItem, modal);
  14510. }
  14511. $scope.recentlyincident(selectedItem);
  14512. },
  14513. function () {
  14514. //console.log('Modal dismissed at: ' + new Date());
  14515. }
  14516. );
  14517. };
  14518. searchModal();
  14519. // }
  14520. },
  14521. },
  14522. };
  14523. },
  14524. controller: [
  14525. "$rootScope",
  14526. "$scope",
  14527. "ngTableParams",
  14528. "$filter",
  14529. "SweetAlert",
  14530. "moment",
  14531. function (
  14532. $rootScope,
  14533. $scope,
  14534. ngTableParams,
  14535. $filter,
  14536. SweetAlert,
  14537. moment
  14538. ) {
  14539. $scope.isHk = $rootScope.isHk;
  14540. $scope.roleidcode = true;
  14541. // $scope.options.initialValue = undefined;
  14542. if ($rootScope.user && $rootScope.user.role) {
  14543. angular.forEach($rootScope.user.role, function (item) {
  14544. if (item.rolecode == "call center") {
  14545. $scope.roleidcode = false;
  14546. }
  14547. });
  14548. }
  14549. $scope.recently = false;
  14550. $scope.recentlyincident = function (key, model) {
  14551. //关联事件
  14552. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14553. idx: 0,
  14554. sum: 4,
  14555. incident: {
  14556. requester: {
  14557. id: key.id,
  14558. },
  14559. },
  14560. }).then(function (response) {
  14561. if (response.status == 200) {
  14562. $scope.recently = true;
  14563. $scope.recentincident = response.list;
  14564. } else {
  14565. $scope.recently = false;
  14566. }
  14567. });
  14568. $scope.bodyHeight = window.innerHeight - 100;
  14569. $(window).resize(function () {
  14570. $scope.bodyHeight = window.innerHeight - 100;
  14571. });
  14572. // $scope.shows = false;
  14573. $scope.tempData = {};
  14574. $scope.close = function () {
  14575. $scope.changes = !$scope.changes;
  14576. event.preventDefault();
  14577. };
  14578. };
  14579. $scope.charging = function (key, model) {
  14580. //计费弹出框
  14581. //用户信息
  14582. $scope.information = {};
  14583. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14584. userId: key.account,
  14585. }).then(function (response) {
  14586. // if (response.status == 200) {
  14587. if (response && response.data) {
  14588. angular.extend($scope.information, response.data[0]);
  14589. // $scope.information = response.data[0];
  14590. $scope.information.autologicDestroyTime = moment(
  14591. response.data[0].autologicDestroyTime
  14592. ).format("YYYY-MM-DD");
  14593. $scope.information.periodStartTime = moment(
  14594. response.data[0].periodStartTime
  14595. ).format("YYYY-MM-DD");
  14596. $scope.information.nextBillingTime = moment(
  14597. response.data[0].nextBillingTime
  14598. ).format("YYYY-MM-DD");
  14599. } else if (response.err) {
  14600. SweetAlert.swal(
  14601. "系统错误!",
  14602. "用户信息未取到,请刷新重试",
  14603. "error"
  14604. );
  14605. }
  14606. // }
  14607. });
  14608. //上网明细
  14609. $scope.options.templateOptions.ApiSer.fetchDataList(
  14610. "queryOnlineDetail",
  14611. {
  14612. userId: key.account,
  14613. limit: "10",
  14614. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14615. "YYYY-MM-DD HH:mm:ss"
  14616. ),
  14617. toLogoutTime: moment(new Date().getTime()).format(
  14618. "YYYY-MM-DD HH:mm:ss"
  14619. ),
  14620. }
  14621. ).then(function (response) {
  14622. // if (response.status == 200) {
  14623. if (response && response.data) {
  14624. angular.forEach(response.data, function (item, index) {
  14625. if (item.logoutTime) {
  14626. response.data[index].logoutTime = moment(
  14627. item.logoutTime
  14628. ).format("YYYY-MM-DD HH:mm:ss");
  14629. }
  14630. if (item.loginTime) {
  14631. response.data[index].loginTime = moment(
  14632. item.loginTime
  14633. ).format("YYYY-MM-DD HH:mm:ss");
  14634. }
  14635. });
  14636. $scope.logininform = response.data;
  14637. } else if (response.err) {
  14638. SweetAlert.swal(
  14639. "系统错误!",
  14640. "上网明细未取到,请刷新重试",
  14641. "error"
  14642. );
  14643. }
  14644. });
  14645. //黑名单
  14646. // $scope.information.blacklist = "否"
  14647. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14648. userId: key.account,
  14649. }).then(function (response) {
  14650. // if (response.status == 200) {
  14651. // $scope.logininformation = response.data;
  14652. if (response) {
  14653. if (response.data || response.data != null) {
  14654. $scope.information.blacklist = "是";
  14655. } else {
  14656. if (response.err) {
  14657. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14658. } else {
  14659. $scope.information.blacklist = "否";
  14660. }
  14661. }
  14662. }
  14663. // }
  14664. });
  14665. $scope.bodyHeight = window.innerHeight - 100;
  14666. $(window).resize(function () {
  14667. $scope.bodyHeight = window.innerHeight - 100;
  14668. });
  14669. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14670. // $scope.closepages = function(e) {
  14671. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14672. // event.preventDefault();
  14673. // };
  14674. // $scope.shows = false;
  14675. $scope.tempData = {};
  14676. $scope.close = function () {
  14677. $scope.changes = !$scope.changes;
  14678. event.preventDefault();
  14679. };
  14680. };
  14681. $scope.options.templateOptions.ApiService.fetchDataList(
  14682. "requesterType",
  14683. {
  14684. idx: 0,
  14685. sum: 100,
  14686. }
  14687. ).then(function (response) {
  14688. if (response.status == 200) {
  14689. $scope.networktypes = response.list;
  14690. } else {
  14691. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14692. }
  14693. });
  14694. function serchdata(searchKey) {
  14695. if (searchKey) {
  14696. var filterData = {
  14697. requester: {
  14698. searchKey: searchKey,
  14699. // 'userType': 1
  14700. },
  14701. idx: 0,
  14702. sum: 10,
  14703. };
  14704. } else {
  14705. var filterData = {
  14706. idx: 0,
  14707. requester: {},
  14708. sum: 10,
  14709. };
  14710. }
  14711. if (
  14712. $scope.model.requester &&
  14713. $scope.model.requester.requesterTypeDTO
  14714. ) {
  14715. angular.extend(filterData.requester, {
  14716. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14717. });
  14718. if (!$scope.options.model.contactsInformation) {
  14719. $scope.options.model.contactsInformation =
  14720. $scope.model.requester.mphone;
  14721. }
  14722. }
  14723. if ($scope.roleidcode) {
  14724. angular.extend(filterData["requester"], {
  14725. userType: 1,
  14726. });
  14727. }
  14728. $scope.options.templateOptions.ApiService.fetchDataList(
  14729. "requester",
  14730. filterData
  14731. ).then(function (response) {
  14732. var myData = response;
  14733. $scope.myData = myData.list;
  14734. });
  14735. }
  14736. $scope.searchData = {};
  14737. $scope.refreshUser = function (searchKey) {
  14738. //请求人搜索
  14739. if (searchKey && searchKey != "") {
  14740. serchdata(searchKey);
  14741. }
  14742. };
  14743. if (
  14744. $scope.$parent.$parent.$parent.model.incident.callID ||
  14745. $scope.$parent.$parent.$parent.model.requestershow
  14746. ) {
  14747. if (!$scope.roleidcode) {
  14748. $scope.charging(
  14749. $scope.$parent.$parent.$parent.model.incident.requester
  14750. );
  14751. }
  14752. $scope.recentlyincident(
  14753. $scope.$parent.$parent.$parent.model.incident.requester
  14754. );
  14755. }
  14756. $scope.onChange = function (searchData) {
  14757. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14758. searchData.telephone = $scope.model.incident.contactsInformation;
  14759. }
  14760. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14761. searchData;
  14762. if (!$scope.roleidcode) {
  14763. $scope.charging(searchData);
  14764. }
  14765. $scope.recentlyincident(searchData);
  14766. $scope.accountshow = false;
  14767. if ($scope.model.incident) {
  14768. if ($scope.model.incident.place) {
  14769. $scope.model.incident.place.id = "";
  14770. }
  14771. if ($scope.model.incident.area) {
  14772. $scope.model.incident.area.id = "";
  14773. }
  14774. $scope.model.incident.contacts = searchData.name;
  14775. if (
  14776. searchData.mphone &&
  14777. searchData.mphone != null &&
  14778. searchData.mphone != ""
  14779. ) {
  14780. $scope.model.incident.contactsInformation = searchData.mphone;
  14781. } else {
  14782. $scope.model.incident.contactsInformation = searchData.telephone;
  14783. }
  14784. $scope.model.incident.houseNumber = "";
  14785. if (
  14786. searchData.requesterTypeDTO &&
  14787. searchData.requesterTypeDTO.id == 2
  14788. ) {
  14789. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14790. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14791. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14792. }
  14793. }
  14794. $scope.options.value(searchData);
  14795. $scope.searchKey = searchData.account;
  14796. if (searchData.placeDTO && searchData.placeDTO.id) {
  14797. $scope.model.incident.place.id = searchData.placeDTO.id;
  14798. }
  14799. if (searchData.areaDTO && searchData.areaDTO.id) {
  14800. $scope.model.incident.area.id = searchData.areaDTO.id;
  14801. }
  14802. if (searchData.houseNumber) {
  14803. $scope.model.incident.houseNumber = searchData.houseNumber;
  14804. }
  14805. if (
  14806. searchData.requesterTypeDTO &&
  14807. searchData.requesterTypeDTO.id == 2
  14808. ) {
  14809. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14810. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14811. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14812. }
  14813. };
  14814. },
  14815. ],
  14816. });
  14817. //ui-grid-table展示控件
  14818. formlyConfigProvider.setType({
  14819. name: "ui-grid-table",
  14820. // extends: 'multiCheckbox',//去掉冒号
  14821. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  14822. defaultOptions: function (options) {
  14823. return {
  14824. templateOptions: {
  14825. linkage: function () { },
  14826. },
  14827. };
  14828. },
  14829. controller: function (
  14830. $scope,
  14831. $rootScope,
  14832. i18nService,
  14833. Restangular,
  14834. api_bpm_data,
  14835. api_statistic,
  14836. $rootScope
  14837. ) {
  14838. var loginUser = $rootScope.user;
  14839. $scope.langs = i18nService.getAllLangs();
  14840. $scope.lang = "zh-cn";
  14841. i18nService.setCurrentLang($scope.lang);
  14842. $scope.gridOptions = {};
  14843. $scope.gridOptions.data = "myData";
  14844. $scope.gridOptions.enableColumnResizing = true;
  14845. $scope.gridOptions.enableGridMenu = false;
  14846. $scope.gridOptions.enableRowSelection = true;
  14847. $scope.gridOptions.showGridFooter = false;
  14848. $scope.gridOptions.showColumnFooter = false;
  14849. $scope.gridOptions.fastWatch = true;
  14850. $scope.gridOptions.useExternalFiltering = true;
  14851. $scope.gridOptions.useExternalPagination = false;
  14852. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14853. $scope.gridOptions.paginationPageSize = 3;
  14854. $scope.gridOptions.multiSelect = false;
  14855. $scope.gridOptions.rowIdentity = function (row) {
  14856. return row.id;
  14857. };
  14858. $scope.gridOptions.getRowIdentity = function (row) {
  14859. return row.id;
  14860. };
  14861. $scope.gridOptions.columnDefs = [
  14862. {
  14863. name: "item",
  14864. displayName: "序号",
  14865. width: 80,
  14866. enableFiltering: false,
  14867. },
  14868. {
  14869. name: "incidentsign",
  14870. displayName: "单号",
  14871. width: 80,
  14872. enableFiltering: false,
  14873. },
  14874. {
  14875. name: "description",
  14876. displayName: "主题",
  14877. width: 80,
  14878. enableFiltering: false,
  14879. },
  14880. {
  14881. name: "state.name",
  14882. displayName: "状态",
  14883. width: 110,
  14884. enableFiltering: false,
  14885. },
  14886. {
  14887. name: "acceptDate",
  14888. displayName: "创建时间",
  14889. width: 160,
  14890. enableFiltering: false,
  14891. },
  14892. {
  14893. name: "requester.name",
  14894. displayName: "请求人",
  14895. width: 80,
  14896. enableFiltering: false,
  14897. },
  14898. {
  14899. name: "handlingPersonnelUser.name",
  14900. displayName: "处理人",
  14901. width: 160,
  14902. enableFiltering: false,
  14903. },
  14904. {
  14905. name: "place.place",
  14906. displayName: "区域地点",
  14907. width: 160,
  14908. enableFiltering: false,
  14909. },
  14910. ];
  14911. // var defaultFilterData = {
  14912. // "idx": 0,
  14913. // "sum": 3
  14914. // };
  14915. // // //分页控制
  14916. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14917. gridApi.pagination.on.paginationChanged(
  14918. $scope,
  14919. function (newPage, pageSize) {
  14920. var filtersData = $scope.memoryfilterData;
  14921. filtersData.idx = newPage - 1;
  14922. filtersData.sum = pageSize;
  14923. $scope.refreshData("expand-right", filtersData);
  14924. }
  14925. );
  14926. // 表格单选事件
  14927. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  14928. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  14929. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  14930. data.entity;
  14931. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  14932. data.entity.id;
  14933. var str =
  14934. data.grid.appScope.$parent.$parent.$parent.model.incident
  14935. .description || "";
  14936. str = str.split("").reverse().join("");
  14937. var del = addstr.split("").reverse().join("");
  14938. // console.log(del);
  14939. var reg = new RegExp(del);
  14940. str = str.replace(reg, "");
  14941. str = str.split("").reverse().join("");
  14942. if (
  14943. data.grid.appScope.$parent.$parent.$parent.model.incident
  14944. .associationType == "事件补充"
  14945. ) {
  14946. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  14947. null;
  14948. str += data.entity.description;
  14949. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14950. data.entity.description;
  14951. } else if (
  14952. data.grid.appScope.$parent.$parent.$parent.model.incident
  14953. .associationType == "事件已解决"
  14954. ) {
  14955. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  14956. "close";
  14957. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14958. "";
  14959. }
  14960. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  14961. str;
  14962. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  14963. data.entity.id;
  14964. });
  14965. };
  14966. // 刷新表格
  14967. setInterval(function () {
  14968. // console.log($scope.myData);
  14969. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  14970. // console.log($scope.myData);
  14971. if ($scope.myData != null) {
  14972. for (var i = 0; i < $scope.myData.length; i++) {
  14973. //添加序号
  14974. $scope.myData[i]["item"] = i + 1;
  14975. }
  14976. }
  14977. }, 1000);
  14978. },
  14979. });
  14980. //处理人信息
  14981. formlyConfigProvider.setType({
  14982. name: "ui-userinformation",
  14983. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  14984. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14985. defaultOptions: function (options) {
  14986. return {
  14987. templateOptions: {},
  14988. };
  14989. },
  14990. controller: [
  14991. "$scope",
  14992. function ($scope) {
  14993. $scope.group = "";
  14994. $scope.role = "";
  14995. if (
  14996. angular.isDefined($scope.model.handlingPersonnelUser) &&
  14997. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14998. $scope.model.handlingPersonnelUser.group.length == 1
  14999. ) {
  15000. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15001. } else {
  15002. for (
  15003. var i = 0;
  15004. i < $scope.model.handlingPersonnelUser.group.length;
  15005. i++
  15006. ) {
  15007. $scope.group +=
  15008. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15009. }
  15010. }
  15011. if (
  15012. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  15013. $scope.model.handlingPersonnelUser.role.length == 1
  15014. ) {
  15015. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  15016. } else {
  15017. for (
  15018. var i = 0;
  15019. i < $scope.model.handlingPersonnelUser.role.length;
  15020. i++
  15021. ) {
  15022. $scope.role +=
  15023. $scope.model.handlingPersonnelUser.role[i].role + ",";
  15024. }
  15025. }
  15026. $scope.options.templateOptions.that = $scope;
  15027. },
  15028. ],
  15029. });
  15030. //处理界面处理人信息
  15031. formlyConfigProvider.setType({
  15032. name: "ui-handler",
  15033. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  15034. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15035. defaultOptions: function (options) {
  15036. return {
  15037. templateOptions: {},
  15038. };
  15039. },
  15040. controller: [
  15041. "$scope",
  15042. function ($scope) {
  15043. $scope.group = "";
  15044. // $scope.role="";
  15045. if (
  15046. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15047. $scope.model.handlingPersonnelUser.group.length == 1
  15048. ) {
  15049. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15050. } else {
  15051. for (
  15052. var i = 0;
  15053. i < $scope.model.handlingPersonnelUser.group.length;
  15054. i++
  15055. ) {
  15056. $scope.group +=
  15057. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15058. }
  15059. }
  15060. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  15061. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  15062. // }else{
  15063. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  15064. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  15065. // }
  15066. // }
  15067. $scope.options.templateOptions.that = $scope;
  15068. },
  15069. ],
  15070. });
  15071. //微信事件流程
  15072. formlyConfigProvider.setType({
  15073. name: "ui-wxIncidentProcess",
  15074. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  15075. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15076. defaultOptions: function (options) {
  15077. return {
  15078. templateOptions: {},
  15079. };
  15080. },
  15081. controller: [
  15082. "$scope",
  15083. function ($scope) {
  15084. console.log($scope.model);
  15085. $scope.pingjia = false;
  15086. $scope.jiejue = false;
  15087. if ($scope.model.incidentState.value == "3") {
  15088. $scope.pingjia = true;
  15089. } else if ($scope.model.incidentState.value == "4") {
  15090. $scope.jiejue = true;
  15091. }
  15092. },
  15093. ],
  15094. });
  15095. //打电话
  15096. formlyConfigProvider.setType({
  15097. name: "ui-inputcall",
  15098. extends: "input",
  15099. templateUrl: "assets/views/customform/tpl/inputcall.html",
  15100. defaultOptions: function (options) {
  15101. return {
  15102. templateOptions: {
  15103. transform: function (value) { },
  15104. },
  15105. };
  15106. },
  15107. controller: [
  15108. "$scope",
  15109. "$rootScope",
  15110. "api_text",
  15111. "SweetAlert",
  15112. function ($scope, $rootScope, api_text, SweetAlert) {
  15113. $scope.dialout = function (teleno) {
  15114. // var gid = "@0";
  15115. // var telephone = "9" + teleno;
  15116. $rootScope.callout = 2;
  15117. // var agcount = tlwsa.tlaGetagentcount();
  15118. // var agcountFlag = false;
  15119. // console.log(teleno)
  15120. // // 查询当前话机是否签入
  15121. // for (var i = 0; i < agcount; i++) {
  15122. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15123. // agcountFlag = true;
  15124. // }
  15125. // }
  15126. if (localStorage.getItem('fenjiNumber')) {
  15127. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15128. // console.log(sessionStorage.getItem('phones'))
  15129. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15130. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15131. // console.log(isHuajihao)
  15132. // if(isHuajihao){
  15133. // tlwsa.tlaCallagc(teleno);
  15134. // }else{
  15135. // tlwsa.tlaCallout(teleno, caller, 0);
  15136. // }
  15137. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15138. $rootScope.toggle('off-sidebar');
  15139. // tlwsa.tlaCallout(teleno, caller, 0);
  15140. } else {
  15141. SweetAlert.swal({
  15142. title: "呼叫失败",
  15143. text: "请先签入呼叫中心!",
  15144. type: "error",
  15145. confirmButtonColor: "#DD6B55",
  15146. });
  15147. }
  15148. };
  15149. $scope.options.templateOptions.that = $scope;
  15150. },
  15151. ],
  15152. });
  15153. //关闭界面处理人信息
  15154. formlyConfigProvider.setType({
  15155. name: "ui-closehandler",
  15156. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15157. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15158. defaultOptions: function (options) {
  15159. return {
  15160. templateOptions: {},
  15161. };
  15162. },
  15163. controller: [
  15164. "$scope",
  15165. "$rootScope",
  15166. "api_text",
  15167. function ($scope, $rootScope, api_text) {
  15168. $scope.dialout = function (teleno) {
  15169. var gid = "@0";
  15170. var telephone = "9" + teleno;
  15171. api_text
  15172. .dialout($rootScope.takes, gid, telephone)
  15173. .then(function (data) {
  15174. if (data.errno == 0) {
  15175. $rootScope.status = 6;
  15176. }
  15177. });
  15178. };
  15179. $scope.options.templateOptions.that = $scope;
  15180. },
  15181. ],
  15182. });
  15183. //用户单选控件
  15184. formlyConfigProvider.setType({
  15185. name: "ui-userselect",
  15186. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15187. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15188. defaultOptions: function (options) {
  15189. return {
  15190. templateOptions: {
  15191. openModal: function (size, options, modal) {
  15192. var modalInstance = modal.open({
  15193. templateUrl:
  15194. "assets/views/customform/tpl/checktable-modal-content.html",
  15195. controller: function (
  15196. $scope,
  15197. i18nService,
  15198. $modalInstance,
  15199. items,
  15200. title,
  15201. Restangular,
  15202. APIService,
  15203. onDataCallback,
  15204. parentScope
  15205. ) {
  15206. $scope.langs = i18nService.getAllLangs();
  15207. $scope.lang = "zh-cn";
  15208. i18nService.setCurrentLang($scope.lang);
  15209. $scope.gridOptions = {};
  15210. $scope.gridOptions.data = "myData";
  15211. $scope.gridOptions.enableColumnResizing = true;
  15212. $scope.gridOptions.enableFiltering = true;
  15213. $scope.gridOptions.enableGridMenu = false;
  15214. $scope.gridOptions.showGridFooter = true;
  15215. $scope.gridOptions.showColumnFooter = false;
  15216. $scope.gridOptions.fastWatch = true;
  15217. $scope.gridOptions.useExternalFiltering = true;
  15218. $scope.gridOptions.useExternalPagination = true;
  15219. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15220. $scope.gridOptions.paginationPageSize = 10;
  15221. $scope.gridOptions.multiSelect = false;
  15222. $scope.gridOptions.rowIdentity = function (row) {
  15223. return row.id;
  15224. };
  15225. $scope.gridOptions.getRowIdentity = function (row) {
  15226. return row.id;
  15227. };
  15228. $scope.gridOptions.rowTemplate =
  15229. '<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>';
  15230. $scope.gridOptions.columnDefs = [
  15231. {
  15232. name: "account",
  15233. displayName: "人员编号",
  15234. width: 120,
  15235. },
  15236. {
  15237. name: "name",
  15238. displayName: "姓名",
  15239. width: 100,
  15240. cellTemplate:
  15241. "<div>" +
  15242. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15243. "</div>",
  15244. },
  15245. // {
  15246. // name: 'gender.name',
  15247. // displayName: '性别',
  15248. // width: 80,
  15249. // enableFiltering: false
  15250. // },
  15251. {
  15252. name: "phone",
  15253. displayName: "电话",
  15254. width: 230,
  15255. enableFiltering: false,
  15256. },
  15257. {
  15258. name: "email",
  15259. displayName: "邮箱",
  15260. width: 180,
  15261. enableFiltering: false,
  15262. },
  15263. {
  15264. name: "dept.dept",
  15265. displayName: "科室",
  15266. width: 130,
  15267. enableFiltering: false,
  15268. },
  15269. {
  15270. name: "taskCount",
  15271. displayName: "处理中事件数",
  15272. enableFiltering: false,
  15273. },
  15274. ];
  15275. // $scope.selectButtonClick
  15276. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15277. $scope.gridApi = gridApi;
  15278. gridApi.pagination.on.paginationChanged(
  15279. $scope,
  15280. function (newPage, pageSize) {
  15281. var filtersData = $scope.memoryfilterData;
  15282. filtersData.idx = newPage - 1;
  15283. filtersData.sum = pageSize;
  15284. $scope.loadData(filtersData);
  15285. //console.log(pageSize);
  15286. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15287. }
  15288. );
  15289. gridApi.selection.on.rowSelectionChanged(
  15290. $scope,
  15291. function (data) {
  15292. $scope.selected.items = data.entity;
  15293. //console.log(data);
  15294. }
  15295. );
  15296. gridApi.selection.on.rowSelectionChangedBatch(
  15297. $scope,
  15298. function (data) {
  15299. $scope.selected.items = data.entity;
  15300. //console.log(data);
  15301. }
  15302. );
  15303. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15304. // // if (row.entity.age > 45) {
  15305. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15306. // // }
  15307. // };
  15308. gridApi.core.on.filterChanged($scope, function () {
  15309. var grid = this.grid;
  15310. var filtersData = {
  15311. idx: 0,
  15312. sum: 10,
  15313. user: {
  15314. roledata: {
  15315. rolecode: "roleset",
  15316. },
  15317. selectType: "1",
  15318. },
  15319. };
  15320. angular.forEach(grid.columns, function (item) {
  15321. if (item.enableFiltering) {
  15322. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15323. if (
  15324. angular.isDefined(item.filters[0].term) &&
  15325. item.filters[0].term != ""
  15326. ) {
  15327. if (angular.isUndefined(filtersData["user"])) {
  15328. filtersData["user"] = {};
  15329. }
  15330. filtersData["user"][item.field] =
  15331. item.filters[0].term;
  15332. }
  15333. }
  15334. });
  15335. $scope.memoryfilterData = filtersData;
  15336. $scope.loadData(filtersData);
  15337. });
  15338. };
  15339. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15340. // if (row.entity.age > 45) {
  15341. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15342. // }
  15343. // },
  15344. $scope.onDblClick = function (data, event) {
  15345. // $scope.selected.items = data.entity;
  15346. $scope.selectButtonClick(data, event);
  15347. };
  15348. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15349. // $scope.selected.items = data.entity;
  15350. // })
  15351. // };
  15352. $scope.memoryfilterData = {
  15353. idx: 0,
  15354. sum: 10,
  15355. user: {
  15356. roledata: {
  15357. rolecode: "roleset",
  15358. },
  15359. selectType: "1",
  15360. },
  15361. };
  15362. $scope.loadData = function (filterData) {
  15363. // console.log("filtersData=111" + JSON.stringify(filterData))
  15364. items
  15365. .fetchItems(filterData, APIService)
  15366. .then(function (data) {
  15367. var myData = Restangular.stripRestangular(data);
  15368. $scope.gridOptions.totalItems = myData.totalNum;
  15369. $scope.myData = myData.list;
  15370. });
  15371. };
  15372. // $scope.title = title;
  15373. $scope.loadData({
  15374. idx: 0,
  15375. sum: 10,
  15376. user: {
  15377. roledata: {
  15378. rolecode: "roleset",
  15379. },
  15380. selectType: "1",
  15381. },
  15382. });
  15383. $scope.selected = {
  15384. items: {},
  15385. };
  15386. $scope.ok = function () {
  15387. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15388. // onDataCallback($scope.selected.item, parentScope);
  15389. // }
  15390. $modalInstance.close($scope.selected.items);
  15391. };
  15392. $scope.cancel = function () {
  15393. $modalInstance.dismiss("cancel");
  15394. };
  15395. },
  15396. size: size,
  15397. resolve: {
  15398. items: function () {
  15399. return {
  15400. fetchItems: function (filterData, APIService) {
  15401. filterData = filterData || {};
  15402. if (
  15403. angular.isDefined(filterData.idx) &&
  15404. filterData.idx == null
  15405. ) {
  15406. filterData = {
  15407. idx: 0,
  15408. sum: 10,
  15409. user: {
  15410. roledata: {
  15411. rolecode: "roleset",
  15412. },
  15413. selectType: "1",
  15414. },
  15415. };
  15416. }
  15417. return options.templateOptions.fetchItems(
  15418. filterData,
  15419. APIService
  15420. );
  15421. },
  15422. };
  15423. },
  15424. title: function () {
  15425. return options.templateOptions.label;
  15426. },
  15427. Restangular: function () {
  15428. return options.templateOptions.Restangular;
  15429. },
  15430. APIService: function () {
  15431. return options.templateOptions.ApiService;
  15432. },
  15433. onDataCallback: function () {
  15434. return options.templateOptions.callback;
  15435. },
  15436. parentScope: function () {
  15437. return options.templateOptions.that;
  15438. },
  15439. },
  15440. });
  15441. modalInstance.result.then(
  15442. function (selectedItem) {
  15443. // console.log(selectedItem);
  15444. options.value(selectedItem);
  15445. if (
  15446. options.templateOptions.callback &&
  15447. angular.isFunction(options.templateOptions.callback)
  15448. ) {
  15449. options.templateOptions.callback(
  15450. selectedItem,
  15451. options.templateOptions.that
  15452. );
  15453. }
  15454. if (
  15455. options.templateOptions.linkData &&
  15456. angular.isFunction(options.templateOptions.linkData)
  15457. ) {
  15458. options.templateOptions.linkData(
  15459. selectedItem,
  15460. options.templateOptions.that
  15461. );
  15462. }
  15463. },
  15464. function () {
  15465. //console.log('Modal dismissed at: ' + new Date());
  15466. }
  15467. );
  15468. },
  15469. },
  15470. };
  15471. },
  15472. controller: [
  15473. "$scope",
  15474. function ($scope) {
  15475. $scope.options.templateOptions.that = $scope;
  15476. // $scope.options.model[$scope.options.key] = {}
  15477. },
  15478. ],
  15479. });
  15480. //用户单选控件(dd 单选input带搜索)
  15481. formlyConfigProvider.setType({
  15482. name: "ui-userselectSearch",
  15483. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15484. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15485. defaultOptions: function (options) {
  15486. return {
  15487. templateOptions: {
  15488. openModal: function (size, options, modal) {
  15489. var modalInstance = modal.open({
  15490. templateUrl:
  15491. "assets/views/customform/tpl/checktable-modal-content.html",
  15492. controller: function (
  15493. $scope,
  15494. i18nService,
  15495. $modalInstance,
  15496. items,
  15497. title,
  15498. Restangular,
  15499. APIService,
  15500. onDataCallback,
  15501. parentScope
  15502. ) {
  15503. $scope.langs = i18nService.getAllLangs();
  15504. $scope.lang = "zh-cn";
  15505. i18nService.setCurrentLang($scope.lang);
  15506. $scope.gridOptions = {};
  15507. $scope.gridOptions.data = "myData";
  15508. $scope.gridOptions.enableColumnResizing = true;
  15509. $scope.gridOptions.enableFiltering = true;
  15510. $scope.gridOptions.enableGridMenu = false;
  15511. $scope.gridOptions.showGridFooter = true;
  15512. $scope.gridOptions.showColumnFooter = false;
  15513. $scope.gridOptions.fastWatch = true;
  15514. $scope.gridOptions.useExternalFiltering = true;
  15515. $scope.gridOptions.useExternalPagination = true;
  15516. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15517. $scope.gridOptions.paginationPageSize = 10;
  15518. $scope.gridOptions.multiSelect = false;
  15519. $scope.gridOptions.rowIdentity = function (row) {
  15520. return row.id;
  15521. };
  15522. $scope.gridOptions.getRowIdentity = function (row) {
  15523. return row.id;
  15524. };
  15525. $scope.gridOptions.rowTemplate =
  15526. '<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>';
  15527. $scope.gridOptions.columnDefs = [
  15528. {
  15529. name: "account",
  15530. displayName: "人员编号",
  15531. width: 120,
  15532. },
  15533. {
  15534. name: "name",
  15535. displayName: "姓名",
  15536. width: 100,
  15537. cellTemplate:
  15538. "<div>" +
  15539. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15540. "</div>",
  15541. },
  15542. // {
  15543. // name: 'gender.name',
  15544. // displayName: '性别',
  15545. // width: 80,
  15546. // enableFiltering: false
  15547. // },
  15548. {
  15549. name: "phone",
  15550. displayName: "电话",
  15551. width: 230,
  15552. enableFiltering: false,
  15553. },
  15554. {
  15555. name: "email",
  15556. displayName: "邮箱",
  15557. width: 180,
  15558. enableFiltering: false,
  15559. },
  15560. {
  15561. name: "dept.dept",
  15562. displayName: "科室",
  15563. width: 130,
  15564. enableFiltering: false,
  15565. },
  15566. {
  15567. name: "taskCount",
  15568. displayName: "处理中事件数",
  15569. enableFiltering: false,
  15570. },
  15571. ];
  15572. // $scope.selectButtonClick
  15573. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15574. $scope.gridApi = gridApi;
  15575. gridApi.pagination.on.paginationChanged(
  15576. $scope,
  15577. function (newPage, pageSize) {
  15578. var filtersData = $scope.memoryfilterData;
  15579. filtersData.idx = newPage - 1;
  15580. filtersData.sum = pageSize;
  15581. $scope.loadData(filtersData);
  15582. //console.log(pageSize);
  15583. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15584. }
  15585. );
  15586. gridApi.selection.on.rowSelectionChanged(
  15587. $scope,
  15588. function (data) {
  15589. $scope.selected.items = data.entity;
  15590. //console.log(data);
  15591. }
  15592. );
  15593. gridApi.selection.on.rowSelectionChangedBatch(
  15594. $scope,
  15595. function (data) {
  15596. $scope.selected.items = data.entity;
  15597. //console.log(data);
  15598. }
  15599. );
  15600. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15601. // // if (row.entity.age > 45) {
  15602. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15603. // // }
  15604. // };
  15605. gridApi.core.on.filterChanged($scope, function () {
  15606. var grid = this.grid;
  15607. var filtersData = {
  15608. idx: 0,
  15609. sum: 10,
  15610. user: {
  15611. roledata: {
  15612. rolecode: "first-line support",
  15613. },
  15614. selectType: "1",
  15615. },
  15616. };
  15617. angular.forEach(grid.columns, function (item) {
  15618. if (item.enableFiltering) {
  15619. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15620. if (
  15621. angular.isDefined(item.filters[0].term) &&
  15622. item.filters[0].term != ""
  15623. ) {
  15624. if (angular.isUndefined(filtersData["user"])) {
  15625. filtersData["user"] = {};
  15626. }
  15627. filtersData["user"][item.field] =
  15628. item.filters[0].term;
  15629. }
  15630. }
  15631. });
  15632. $scope.memoryfilterData = filtersData;
  15633. $scope.loadData(filtersData);
  15634. });
  15635. };
  15636. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15637. // if (row.entity.age > 45) {
  15638. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15639. // }
  15640. // },
  15641. $scope.onDblClick = function (data, event) {
  15642. // $scope.selected.items = data.entity;
  15643. $scope.selectButtonClick(data, event);
  15644. };
  15645. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15646. // $scope.selected.items = data.entity;
  15647. // })
  15648. // };
  15649. $scope.memoryfilterData = {
  15650. idx: 0,
  15651. sum: 10,
  15652. user: {
  15653. roledata: {
  15654. rolecode: "first-line support",
  15655. },
  15656. selectType: "1",
  15657. },
  15658. };
  15659. $scope.loadData = function (filterData) {
  15660. // console.log("filtersData=111" + JSON.stringify(filterData))
  15661. items
  15662. .fetchItems(filterData, APIService)
  15663. .then(function (data) {
  15664. var myData = Restangular.stripRestangular(data);
  15665. $scope.gridOptions.totalItems = myData.totalNum;
  15666. $scope.myData = myData.list;
  15667. });
  15668. };
  15669. $scope.title = title;
  15670. $scope.loadData({
  15671. idx: 0,
  15672. sum: 10,
  15673. user: {
  15674. roledata: {
  15675. rolecode: "first-line support",
  15676. },
  15677. selectType: "1",
  15678. },
  15679. });
  15680. $scope.selected = {
  15681. items: {},
  15682. };
  15683. $scope.ok = function () {
  15684. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15685. // onDataCallback($scope.selected.item, parentScope);
  15686. // }
  15687. $modalInstance.close($scope.selected.items);
  15688. };
  15689. $scope.cancel = function () {
  15690. $modalInstance.dismiss("cancel");
  15691. };
  15692. },
  15693. size: size,
  15694. resolve: {
  15695. items: function () {
  15696. return {
  15697. fetchItems: function (filterData, APIService) {
  15698. filterData = filterData || {};
  15699. if (
  15700. angular.isDefined(filterData.idx) &&
  15701. filterData.idx == null
  15702. ) {
  15703. filterData = {
  15704. idx: 0,
  15705. sum: 10,
  15706. user: {
  15707. roledata: {
  15708. rolecode: "first-line support",
  15709. },
  15710. selectType: "1",
  15711. },
  15712. };
  15713. }
  15714. return options.templateOptions.fetchItems(
  15715. filterData,
  15716. APIService
  15717. );
  15718. },
  15719. };
  15720. },
  15721. title: function () {
  15722. return options.templateOptions.label;
  15723. },
  15724. Restangular: function () {
  15725. return options.templateOptions.Restangular;
  15726. },
  15727. APIService: function () {
  15728. return options.templateOptions.ApiService;
  15729. },
  15730. onDataCallback: function () {
  15731. return options.templateOptions.callback;
  15732. },
  15733. parentScope: function () {
  15734. return options.templateOptions.that;
  15735. },
  15736. },
  15737. });
  15738. modalInstance.result.then(
  15739. function (selectedItem) {
  15740. // console.log(selectedItem);
  15741. options.value(selectedItem);
  15742. if (
  15743. options.templateOptions.callback &&
  15744. angular.isFunction(options.templateOptions.callback)
  15745. ) {
  15746. options.templateOptions.callback(
  15747. selectedItem,
  15748. options.templateOptions.that
  15749. );
  15750. }
  15751. if (
  15752. options.templateOptions.linkData &&
  15753. angular.isFunction(options.templateOptions.linkData)
  15754. ) {
  15755. options.templateOptions.linkData(
  15756. selectedItem,
  15757. options.templateOptions.that
  15758. );
  15759. }
  15760. },
  15761. function () {
  15762. //console.log('Modal dismissed at: ' + new Date());
  15763. }
  15764. );
  15765. },
  15766. },
  15767. };
  15768. },
  15769. controller: [
  15770. "$scope",
  15771. function ($scope) {
  15772. $scope.options.templateOptions.that = $scope;
  15773. },
  15774. ],
  15775. });
  15776. //用户多选控件
  15777. formlyConfigProvider.setType({
  15778. name: "ui-multiuserselect",
  15779. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  15780. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15781. defaultOptions: function (options) {
  15782. return {
  15783. templateOptions: {
  15784. openModal: function (size, options, modal, model) {
  15785. var modalInstance = modal.open({
  15786. templateUrl:
  15787. "assets/views/customform/tpl/checktable-modal-content.html",
  15788. controller: function (
  15789. $scope,
  15790. $modalInstance,
  15791. i18nService,
  15792. $timeout,
  15793. items,
  15794. title,
  15795. Restangular,
  15796. APIService,
  15797. selectItems
  15798. ) {
  15799. $scope.langs = i18nService.getAllLangs();
  15800. $scope.lang = "zh-cn";
  15801. i18nService.setCurrentLang($scope.lang);
  15802. $scope.gridOptions = {};
  15803. $scope.gridOptions.data = "myData";
  15804. $scope.gridOptions.enableColumnResizing = true;
  15805. $scope.gridOptions.enableFiltering = true;
  15806. $scope.gridOptions.enableGridMenu = true;
  15807. $scope.gridOptions.showGridFooter = true;
  15808. $scope.gridOptions.showColumnFooter = true;
  15809. $scope.gridOptions.fastWatch = true;
  15810. $scope.gridOptions.useExternalFiltering = true;
  15811. $scope.gridOptions.useExternalPagination = true;
  15812. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15813. $scope.gridOptions.paginationPageSize = 10;
  15814. $scope.gridOptions.multiSelect = true;
  15815. $scope.gridOptions.rowIdentity = function (row) {
  15816. return row.id;
  15817. };
  15818. $scope.gridOptions.getRowIdentity = function (row) {
  15819. return row.id;
  15820. };
  15821. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  15822. $scope.gridOptions.columnDefs = [
  15823. // { name:'id', width:80, enableFiltering:false},
  15824. {
  15825. name: "account",
  15826. displayName: "账号",
  15827. width: 140,
  15828. },
  15829. {
  15830. name: "name",
  15831. displayName: "名称",
  15832. width: 100,
  15833. },
  15834. {
  15835. name: "gender.name",
  15836. displayName: "性别",
  15837. width: 140,
  15838. enableFiltering: false,
  15839. },
  15840. {
  15841. name: "phone",
  15842. displayName: "电话",
  15843. width: 100,
  15844. enableFiltering: false,
  15845. },
  15846. {
  15847. name: "email",
  15848. displayName: "邮件",
  15849. width: 100,
  15850. enableFiltering: false,
  15851. },
  15852. {
  15853. name: "dept.dept",
  15854. displayName: "科室",
  15855. width: 100,
  15856. enableFiltering: false,
  15857. },
  15858. {
  15859. name: "group[0].groupName",
  15860. displayName: "职位",
  15861. width: 100,
  15862. enableFiltering: false,
  15863. },
  15864. ];
  15865. $scope.selected = {
  15866. items: selectItems,
  15867. };
  15868. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15869. $scope.gridApi = gridApi;
  15870. gridApi.pagination.on.paginationChanged(
  15871. $scope,
  15872. function (newPage, pageSize) {
  15873. var filtersData = $scope.memoryfilterData;
  15874. filtersData.idx = newPage - 1;
  15875. filtersData.sum = pageSize;
  15876. $scope.loadData(filtersData);
  15877. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15878. }
  15879. );
  15880. gridApi.selection.on.rowSelectionChanged(
  15881. $scope,
  15882. function (scope) {
  15883. var j = 0;
  15884. for (
  15885. var i = 0;
  15886. i <= scope.grid.appScope.selected.items.length;
  15887. i++
  15888. ) {
  15889. if (
  15890. scope.grid.appScope.selected.items[i] == scope.entity
  15891. ) {
  15892. j++;
  15893. break;
  15894. }
  15895. }
  15896. if (j == 1) {
  15897. scope.grid.appScope.selected.items.splice(i, 1);
  15898. } else {
  15899. scope.grid.appScope.selected.items.push(scope.entity);
  15900. for (
  15901. var i = 0;
  15902. i < scope.grid.appScope.selected.items.length;
  15903. i++
  15904. ) {
  15905. for (
  15906. var z = 0;
  15907. z < scope.grid.appScope.selected.items.length;
  15908. z++
  15909. ) {
  15910. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  15911. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  15912. if (
  15913. angular.isDefined(
  15914. scope.grid.appScope.selected.items
  15915. ) &&
  15916. scope.grid.appScope.selected.items[i].id ==
  15917. scope.grid.appScope.selected.items[z].id &&
  15918. i != z
  15919. ) {
  15920. scope.grid.appScope.selected.items.splice(i, 1);
  15921. }
  15922. }
  15923. }
  15924. }
  15925. }
  15926. );
  15927. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  15928. // $scope.grid.appScope.selected.items.push($scope.entity);
  15929. // });
  15930. gridApi.core.on.filterChanged($scope, function () {
  15931. var grid = this.grid;
  15932. var filtersData = {
  15933. idx: 0,
  15934. sum: 10,
  15935. user: {
  15936. roledata: {
  15937. rolecode: options.model.currentRole,
  15938. },
  15939. selectType: "1",
  15940. },
  15941. };
  15942. angular.forEach(grid.columns, function (item) {
  15943. if (item.enableFiltering) {
  15944. //console.log("filtersData="+JSON.stringify(filtersData))
  15945. if (
  15946. angular.isDefined(item.filters[0].term) &&
  15947. item.filters[0].term != ""
  15948. ) {
  15949. if (angular.isUndefined(filtersData["user"])) {
  15950. filtersData["user"] = {};
  15951. }
  15952. filtersData["user"][item.field] =
  15953. item.filters[0].term;
  15954. }
  15955. }
  15956. });
  15957. $scope.memoryfilterData = filtersData;
  15958. $scope.loadData(filtersData);
  15959. });
  15960. };
  15961. if (!options.model) {
  15962. var mouse = {
  15963. model: {
  15964. currentRole: "",
  15965. },
  15966. };
  15967. angular.extend(options, mouse);
  15968. }
  15969. $scope.memoryfilterData = {
  15970. idx: 0,
  15971. sum: 10,
  15972. user: {
  15973. roledata: {
  15974. rolecode: options.model.currentRole,
  15975. },
  15976. selectType: "1",
  15977. },
  15978. };
  15979. $scope.loadData = function (filterData) {
  15980. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  15981. items
  15982. .fetchItems(filterData, APIService)
  15983. .then(function (data) {
  15984. var myData = Restangular.stripRestangular(data);
  15985. $scope.gridOptions.totalItems = myData.totalNum;
  15986. $scope.myData = myData.list;
  15987. //console.log($scope.gridOptions.pagination.getTotalPages());
  15988. // if($scope.selected.items){
  15989. // angular.forEach($scope.selected.items,function(selectItem){
  15990. // $scope.gridApi.selection.selectRow(selectItem);
  15991. // });
  15992. // }
  15993. });
  15994. };
  15995. // $scope.title = title;
  15996. $scope.loadData({
  15997. idx: 0,
  15998. sum: 10,
  15999. user: {
  16000. roledata: {
  16001. rolecode: options.model.currentRole,
  16002. },
  16003. selectType: "1",
  16004. },
  16005. });
  16006. // $timeout(function(){
  16007. // if($scope.selected.items){
  16008. // angular.forEach($scope.selected.items,function(selectItem){
  16009. // $scope.gridApi.selection.selectRow(selectItem);
  16010. // });
  16011. // }
  16012. // },2000)
  16013. $scope.ok = function () {
  16014. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  16015. $modalInstance.close($scope.selected.items);
  16016. };
  16017. $scope.cancel = function () {
  16018. $modalInstance.dismiss("cancel");
  16019. };
  16020. },
  16021. size: size,
  16022. resolve: {
  16023. items: function () {
  16024. return {
  16025. fetchItems: function (filterData, APIService) {
  16026. filterData = filterData || {};
  16027. if (
  16028. angular.isDefined(filterData.idx) &&
  16029. filterData.idx == null
  16030. ) {
  16031. filterData = {
  16032. idx: 0,
  16033. sum: 10,
  16034. user: {
  16035. roledata: {
  16036. rolecode: options.model.incident.currentRole,
  16037. },
  16038. selectType: "1",
  16039. },
  16040. };
  16041. }
  16042. return options.templateOptions.fetchItems(
  16043. filterData,
  16044. APIService
  16045. );
  16046. },
  16047. };
  16048. },
  16049. title: function () {
  16050. return options.templateOptions.modalTitle;
  16051. },
  16052. Restangular: function () {
  16053. return options.templateOptions.Restangular;
  16054. },
  16055. APIService: function () {
  16056. return options.templateOptions.ApiService;
  16057. },
  16058. selectItems: function () {
  16059. return model || [];
  16060. },
  16061. },
  16062. });
  16063. modalInstance.result.then(
  16064. function (selectedItem) {
  16065. options.value(selectedItem);
  16066. options.formControl.$validate();
  16067. },
  16068. function () {
  16069. //console.log('Modal dismissed at: ' + new Date());
  16070. }
  16071. );
  16072. },
  16073. },
  16074. validators: {
  16075. required: {
  16076. expression: function (viewValue, modelValue) {
  16077. var value = modelValue || viewValue;
  16078. return value.length >= 1;
  16079. },
  16080. },
  16081. },
  16082. };
  16083. },
  16084. controller: [
  16085. "$scope",
  16086. function ($scope) {
  16087. $scope.model[$scope.options.key] = [];
  16088. $scope.remove = function (itemId) {
  16089. angular.forEach(
  16090. $scope.model[$scope.options.key],
  16091. function (entry, index) {
  16092. if (entry.id == itemId) {
  16093. $scope.model[$scope.options.key].splice(index, 1);
  16094. // console.log($scope.options.formControl)
  16095. $scope.options.formControl.$validate();
  16096. } else {
  16097. }
  16098. }
  16099. );
  16100. };
  16101. },
  16102. ],
  16103. });
  16104. //用户多选控件-字符串展示
  16105. formlyConfigProvider.setType({
  16106. name: "ui-stringuserselect",
  16107. extends: "input",
  16108. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  16109. defaultOptions: function (options) {
  16110. return {
  16111. templateOptions: {
  16112. translate: "",
  16113. refreshDelay: 0,
  16114. },
  16115. };
  16116. },
  16117. controller: [
  16118. "$scope",
  16119. function ($scope) {
  16120. var keydata = "";
  16121. if (angular.isArray($scope.model)) {
  16122. angular.forEach($scope.model, function (item) {
  16123. keydata = keydata + "," + item.name;
  16124. });
  16125. }
  16126. // $scope.model[$scope.options.key] = [];
  16127. },
  16128. ],
  16129. });
  16130. //重复事件
  16131. formlyConfigProvider.setType({
  16132. name: "ui-incidentmodelselect",
  16133. extends: "input",
  16134. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16135. defaultOptions: function (options) {
  16136. return {
  16137. templateOptions: {
  16138. openModal: function (size, options, modal) {
  16139. var modalInstance = modal.open({
  16140. templateUrl:
  16141. "assets/views/customform/tpl/checktable-modal-content.html",
  16142. controller: function (
  16143. $scope,
  16144. $rootScope,
  16145. $modalInstance,
  16146. items,
  16147. title,
  16148. Restangular,
  16149. APIService,
  16150. i18nService,
  16151. api_configure_data,
  16152. api_user_data,
  16153. api_bpm_data
  16154. ) {
  16155. $scope.langs = i18nService.getAllLangs();
  16156. $scope.lang = "zh-cn";
  16157. i18nService.setCurrentLang($scope.lang);
  16158. $scope.gridOptions = {};
  16159. $scope.gridOptions.data = "myData";
  16160. $scope.gridOptions.enableColumnResizing = true;
  16161. $scope.gridOptions.enableFiltering = true;
  16162. $scope.gridOptions.enableGridMenu = false;
  16163. $scope.gridOptions.enableRowSelection = true;
  16164. $scope.gridOptions.showGridFooter = true;
  16165. $scope.gridOptions.showColumnFooter = false;
  16166. $scope.gridOptions.fastWatch = true;
  16167. $scope.gridOptions.useExternalFiltering = true;
  16168. $scope.gridOptions.useExternalPagination = true;
  16169. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16170. $scope.gridOptions.paginationPageSize = 10;
  16171. $scope.gridOptions.multiSelect = false;
  16172. var mun = $scope.gridOptions.paginationPageSize;
  16173. $scope.gridOptions.rowIdentity = function (row) {
  16174. return row.id;
  16175. };
  16176. $scope.gridOptions.getRowIdentity = function (row) {
  16177. return row.id;
  16178. };
  16179. $scope.gridOptions.columnDefs = items.columnDefs();
  16180. $scope.transferTime = function (time) {
  16181. return moment(time).format("YYYY-MM-DD HH:mm");
  16182. };
  16183. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16184. $scope.gridApi = gridApi;
  16185. gridApi.pagination.on.paginationChanged(
  16186. $scope,
  16187. function (newPage, pageSize) {
  16188. // console.log(newPage);
  16189. // console.log(pageSize);
  16190. $scope.loadData({
  16191. idx: newPage - 1,
  16192. sum: pageSize,
  16193. });
  16194. }
  16195. );
  16196. gridApi.core.on.filterChanged($scope, function () {
  16197. var grid = this.grid;
  16198. var filtersData = {
  16199. idx: 0,
  16200. sum: 100,
  16201. };
  16202. angular.forEach(grid.columns, function (item) {
  16203. if (item.enableFiltering) {
  16204. if (
  16205. angular.isDefined(item.filters[0].term) &&
  16206. item.filters[0].term != ""
  16207. ) {
  16208. // console.log("filtersData="+JSON.stringify(filtersData))
  16209. if (angular.isUndefined(filtersData["incident"])) {
  16210. filtersData["incident"] = {};
  16211. }
  16212. filtersData["incident"][item.field] =
  16213. item.filters[0].term;
  16214. if (angular.isUndefined(filtersData["problem"])) {
  16215. filtersData["problem"] = {};
  16216. }
  16217. filtersData["problem"][item.field] =
  16218. item.filters[0].term;
  16219. if (angular.isUndefined(filtersData["change"])) {
  16220. filtersData["change"] = {};
  16221. }
  16222. filtersData["change"][item.field] =
  16223. item.filters[0].term;
  16224. if (angular.isUndefined(filtersData["release"])) {
  16225. filtersData["release"] = {};
  16226. }
  16227. filtersData["release"][item.field] =
  16228. item.filters[0].term;
  16229. }
  16230. }
  16231. });
  16232. $scope.loadData(filtersData);
  16233. });
  16234. gridApi.selection.on.rowSelectionChanged(
  16235. $scope,
  16236. function (data) {
  16237. $scope.selected.item = data.entity;
  16238. //console.log(data);
  16239. }
  16240. );
  16241. };
  16242. //资产
  16243. $scope.cmdb = {};
  16244. //资产状态
  16245. $scope.state_data = [
  16246. {
  16247. name: "全部状态",
  16248. value: "",
  16249. },
  16250. {
  16251. name: "在库",
  16252. value: "1",
  16253. },
  16254. {
  16255. name: "在线",
  16256. value: "2",
  16257. },
  16258. {
  16259. name: "借出",
  16260. value: "3",
  16261. },
  16262. {
  16263. name: "报修",
  16264. value: "4",
  16265. },
  16266. {
  16267. name: "报废",
  16268. value: "5",
  16269. },
  16270. {
  16271. name: "备用",
  16272. value: "6",
  16273. },
  16274. ];
  16275. //资产类型
  16276. $scope.wt_zcfl = function () {
  16277. api_configure_data
  16278. .fetchDataList("ciclassify", {
  16279. idx: 0,
  16280. sum: 100,
  16281. })
  16282. .then(function (data) {
  16283. console.log(data);
  16284. // $scope.wt_zclx = data.list;
  16285. console.log(data);
  16286. $scope.wtData = [];
  16287. if (data.status == 200) {
  16288. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16289. var root = null; //Initially set our loop to null
  16290. var parentNode = null;
  16291. //loop over data
  16292. // $scope.wtData=data.list;
  16293. data = data.list;
  16294. //知识库分类数据三级处理
  16295. for (var i = 0; i < data.length; i++) {
  16296. // console.log(data[i])
  16297. var datum = data[i];
  16298. //each node will have children, so let's give it a "children" poperty
  16299. // console.log(datum);
  16300. datum.children = [];
  16301. if (!datum.parent) {
  16302. $scope.wtData.push(datum);
  16303. // console.log($scope.wtData)
  16304. } else {
  16305. if ($scope.wtData[0]) {
  16306. if ($scope.wtData[0].id == datum.parent.id) {
  16307. $scope.wtData[0].children.push(datum);
  16308. }
  16309. for (
  16310. var j = 0;
  16311. j < $scope.wtData[0].children.length;
  16312. j++
  16313. ) {
  16314. if (
  16315. $scope.wtData[0].children[j].id ==
  16316. datum.parent.id
  16317. ) {
  16318. $scope.wtData[0].children[j].children.push(
  16319. datum
  16320. );
  16321. }
  16322. }
  16323. }
  16324. if ($scope.wtData[1]) {
  16325. if ($scope.wtData[1].id == datum.parent.id) {
  16326. $scope.wtData[1].children.push(datum);
  16327. }
  16328. for (
  16329. var j = 0;
  16330. j < $scope.wtData[1].children.length;
  16331. j++
  16332. ) {
  16333. if (
  16334. $scope.wtData[1].children[j].id ==
  16335. datum.parent.id
  16336. ) {
  16337. $scope.wtData[1].children[j].children.push(
  16338. datum
  16339. );
  16340. }
  16341. }
  16342. }
  16343. if ($scope.wtData[2]) {
  16344. if ($scope.wtData[2].id == datum.parent.id) {
  16345. $scope.wtData[2].children.push(datum);
  16346. }
  16347. for (
  16348. var j = 0;
  16349. j < $scope.wtData[2].children.length;
  16350. j++
  16351. ) {
  16352. if (
  16353. $scope.wtData[2].children[j].id ==
  16354. datum.parent.id
  16355. ) {
  16356. $scope.wtData[2].children[j].children.push(
  16357. datum
  16358. );
  16359. }
  16360. }
  16361. }
  16362. }
  16363. // console.log($scope.wtData)
  16364. idToNodeMap[datum.id] = datum;
  16365. root = datum;
  16366. // treeMap[datum.id] = root;
  16367. }
  16368. }
  16369. });
  16370. };
  16371. $scope.wt_zcfl();
  16372. //事件
  16373. //受理人,处理人
  16374. $scope.searchkeys = {};
  16375. var fieldata = {
  16376. idx: 0,
  16377. sum: 100,
  16378. flag: -1,
  16379. };
  16380. getUser(fieldata, 3);
  16381. function getUser(fieldatas, it) {
  16382. api_user_data
  16383. .fetchDataList("user", fieldatas)
  16384. .then(function (data) {
  16385. if (it == 1) {
  16386. $scope.acceptUser = data.list;
  16387. } else if (it == 2) {
  16388. $scope.handlingPersonnelUser = data.list;
  16389. } else if (it == 3) {
  16390. $scope.acceptUser = data.list;
  16391. $scope.handlingPersonnelUser = data.list;
  16392. }
  16393. });
  16394. }
  16395. //状态
  16396. $scope.othcode = {};
  16397. api_bpm_data
  16398. .fetchDataList("incidentstatus", {
  16399. idx: 0,
  16400. sum: 100,
  16401. })
  16402. .then(function (response) {
  16403. if (response) {
  16404. if ((response.status = 200)) {
  16405. $scope.state = response.list;
  16406. }
  16407. }
  16408. });
  16409. var defaultFilterData = {
  16410. assignee: $rootScope.user.id,
  16411. searchType: "todo",
  16412. idx: 0,
  16413. sum: mun,
  16414. };
  16415. var defaultFilterData1 = {
  16416. // "searchType": "todo",
  16417. idx: 0,
  16418. sum: mun,
  16419. };
  16420. //搜索
  16421. $scope.chiceIncident = function (parameters, item, stateid) {
  16422. console.log(item, stateid);
  16423. console.log($scope);
  16424. if ($scope.title == "关联资产编号") {
  16425. // alert('222222222222');
  16426. var fildata = defaultFilterData1;
  16427. $scope.gridOptions.paginationCurrentPage = 1;
  16428. var transitiondata = angular.copy(item);
  16429. angular.extend(fildata, transitiondata);
  16430. if (fildata.hw_state) {
  16431. fildata.hw_state = fildata.hw_state.name;
  16432. }
  16433. if (fildata.sign) {
  16434. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16435. fildata.sign = fildata.sign.split(";");
  16436. fildata.sign = fildata.sign.join("");
  16437. fildata.sign = fildata.sign.toLowerCase();
  16438. }
  16439. if (fildata.keys) {
  16440. fildata["searchCriteria"] = "uuid";
  16441. }
  16442. console.log(fildata);
  16443. $scope.loadData(fildata);
  16444. }
  16445. if ($scope.title == "关联事件工单") {
  16446. // alert('3333333333333333')
  16447. if (stateid && stateid.code) {
  16448. item.statusId = stateid.code;
  16449. }
  16450. var fildata = defaultFilterData;
  16451. // $scope.memoryfilterData = fildata;
  16452. if (!fildata.incident) {
  16453. fildata["incident"] = {};
  16454. }
  16455. $scope.gridOptions.paginationCurrentPage = 1;
  16456. var transitiondata = angular.copy(item);
  16457. angular.extend(fildata.incident, transitiondata);
  16458. console.log(fildata);
  16459. // $scope.loadData(fildata);
  16460. api_bpm_data
  16461. .fetchDataList("incident", fildata)
  16462. .then(function (data) {
  16463. console.log(data);
  16464. if (data) {
  16465. $scope.myData = data.list;
  16466. $scope.gridOptions.totalItems = data.totalNum;
  16467. }
  16468. });
  16469. }
  16470. };
  16471. //重置
  16472. $scope.replacement = function (
  16473. parameters,
  16474. searchkeys,
  16475. othcode
  16476. ) {
  16477. // console.log(parameters, searchkeys, othcode);
  16478. delete defaultFilterData.incident;
  16479. console.log(defaultFilterData);
  16480. $scope.parameters = null;
  16481. $scope.searchkeys = {};
  16482. $scope.othcode = {};
  16483. $scope.wt_zcfl();
  16484. };
  16485. $scope.loadData = function (filterData) {
  16486. items
  16487. .fetchItems(filterData, APIService, $rootScope)
  16488. .then(function (data) {
  16489. var myData = Restangular.stripRestangular(data);
  16490. if (myData.data && myData.data.node) {
  16491. $scope.gridOptions.totalItems = myData.total;
  16492. $scope.myData = myData.data.node;
  16493. } else {
  16494. if (myData.resultCount) {
  16495. $scope.gridOptions["totalItems"] = myData.resultCount;
  16496. } else {
  16497. $scope.gridOptions.totalItems = myData.totalNum;
  16498. }
  16499. if (myData.list) {
  16500. $scope.myData = myData.list;
  16501. } else {
  16502. $scope.myData = myData.data;
  16503. }
  16504. }
  16505. });
  16506. };
  16507. $scope.title = title;
  16508. $scope.loadData({
  16509. idx: 0,
  16510. sum: 10,
  16511. });
  16512. $scope.selected = {
  16513. item: {},
  16514. };
  16515. $scope.ok = function () {
  16516. //console.log($scope.selected.item);
  16517. $modalInstance.close($scope.selected.item);
  16518. };
  16519. $scope.cancel = function () {
  16520. $modalInstance.dismiss("cancel");
  16521. };
  16522. },
  16523. size: size,
  16524. resolve: {
  16525. items: function () {
  16526. return {
  16527. fetchItems: function (filterData, APIService, $rootScope) {
  16528. filterData = filterData || {};
  16529. // if(!filterData.idx){
  16530. if (
  16531. angular.isDefined(filterData.idx) &&
  16532. filterData.idx == null
  16533. ) {
  16534. filterData = {
  16535. idx: 0,
  16536. sum: 10,
  16537. };
  16538. }
  16539. return options.templateOptions.fetchItems(
  16540. filterData,
  16541. APIService,
  16542. $rootScope
  16543. );
  16544. },
  16545. columnDefs: function () {
  16546. return options.templateOptions.columnDefs;
  16547. },
  16548. };
  16549. },
  16550. title: function () {
  16551. return options.templateOptions.modalTitle;
  16552. },
  16553. Restangular: function () {
  16554. return options.templateOptions.Restangular;
  16555. },
  16556. APIService: function () {
  16557. return options.templateOptions.ApiService;
  16558. },
  16559. },
  16560. });
  16561. modalInstance.result.then(
  16562. function (selectedItem) {
  16563. var selectitem = {
  16564. title: selectedItem.title,
  16565. description: selectedItem.description,
  16566. };
  16567. if (options.key == "chuku") {
  16568. if (selectedItem.assets) {
  16569. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  16570. selectedItem.assets;
  16571. }
  16572. if (selectedItem.consumables) {
  16573. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  16574. selectedItem.consumables;
  16575. }
  16576. angular.extend(
  16577. $scope.$parent.$parent.$parent.model,
  16578. selectitem
  16579. );
  16580. options.value(selectedItem);
  16581. // options.model.consumables = JSON.parse(consumables);
  16582. } else if (options.templateOptions.pkey == "change") {
  16583. console.log(options);
  16584. angular.extend(options.model);
  16585. options.value(selectedItem);
  16586. } else if (options.key == "cmdbCode") {
  16587. var zc_selectitem = selectedItem.uuid;
  16588. // angular.extend(options.model,zc_selectitem);
  16589. options.model.cmdbCode = zc_selectitem;
  16590. // angular.extend(options.model,zc_selectitem);
  16591. // options.templateOptions.displayName=zc_selectitem;
  16592. options.value(selectedItem);
  16593. console.log(options.model);
  16594. } else {
  16595. angular.extend(options.model, selectitem);
  16596. options.value(selectedItem);
  16597. }
  16598. },
  16599. function () {
  16600. //console.log('Modal dismissed at: ' + new Date());
  16601. }
  16602. );
  16603. },
  16604. },
  16605. };
  16606. },
  16607. });
  16608. //选项选择控件
  16609. formlyConfigProvider.setType({
  16610. name: "ui-modelselect",
  16611. extends: "input",
  16612. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16613. defaultOptions: function (options) {
  16614. return {
  16615. templateOptions: {
  16616. openModal: function (size, options, modal) {
  16617. var modalInstance = modal.open({
  16618. templateUrl:
  16619. "assets/views/customform/tpl/checktable-modal-content.html",
  16620. controller: function (
  16621. $scope,
  16622. $modalInstance,
  16623. items,
  16624. title,
  16625. Restangular,
  16626. APIService,
  16627. i18nService
  16628. ) {
  16629. $scope.langs = i18nService.getAllLangs();
  16630. $scope.lang = "zh-cn";
  16631. i18nService.setCurrentLang($scope.lang);
  16632. $scope.gridOptions = {};
  16633. $scope.gridOptions.data = "myData";
  16634. $scope.gridOptions.enableColumnResizing = true;
  16635. $scope.gridOptions.enableFiltering = true;
  16636. $scope.gridOptions.enableGridMenu = false;
  16637. $scope.gridOptions.enableRowSelection = true;
  16638. $scope.gridOptions.showGridFooter = true;
  16639. $scope.gridOptions.showColumnFooter = true;
  16640. $scope.gridOptions.fastWatch = true;
  16641. $scope.gridOptions.useExternalFiltering = true;
  16642. $scope.gridOptions.useExternalPagination = true;
  16643. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16644. $scope.gridOptions.paginationPageSize = 10;
  16645. $scope.gridOptions.multiSelect = false;
  16646. $scope.gridOptions.rowIdentity = function (row) {
  16647. return row.id;
  16648. };
  16649. $scope.gridOptions.getRowIdentity = function (row) {
  16650. return row.id;
  16651. };
  16652. $scope.gridOptions.columnDefs = items.columnDefs();
  16653. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16654. $scope.gridApi = gridApi;
  16655. gridApi.pagination.on.paginationChanged(
  16656. $scope,
  16657. function (newPage, pageSize) {
  16658. // console.log(newPage);
  16659. // console.log(pageSize);
  16660. $scope.loadData({
  16661. idx: newPage - 1,
  16662. sum: pageSize,
  16663. });
  16664. }
  16665. );
  16666. gridApi.core.on.filterChanged($scope, function () {
  16667. var grid = this.grid;
  16668. var filtersData = {
  16669. idx: 0,
  16670. sum: 10,
  16671. };
  16672. angular.forEach(grid.columns, function (item) {
  16673. if (item.enableFiltering) {
  16674. if (
  16675. angular.isDefined(item.filters[0].term) &&
  16676. item.filters[0].term != ""
  16677. ) {
  16678. // console.log("filtersData="+JSON.stringify(filtersData))
  16679. if (angular.isUndefined(filtersData["incident"])) {
  16680. filtersData["incident"] = {};
  16681. }
  16682. filtersData["incident"][item.field] =
  16683. item.filters[0].term;
  16684. if (angular.isUndefined(filtersData["problem"])) {
  16685. filtersData["problem"] = {};
  16686. }
  16687. filtersData["problem"][item.field] =
  16688. item.filters[0].term;
  16689. if (angular.isUndefined(filtersData["change"])) {
  16690. filtersData["change"] = {};
  16691. }
  16692. filtersData["change"][item.field] =
  16693. item.filters[0].term;
  16694. if (angular.isUndefined(filtersData["release"])) {
  16695. filtersData["release"] = {};
  16696. }
  16697. filtersData["release"][item.field] =
  16698. item.filters[0].term;
  16699. }
  16700. }
  16701. });
  16702. $scope.loadData(filtersData);
  16703. });
  16704. gridApi.selection.on.rowSelectionChanged(
  16705. $scope,
  16706. function (data) {
  16707. $scope.selected.item = data.entity;
  16708. //console.log(data);
  16709. }
  16710. );
  16711. };
  16712. $scope.loadData = function (filterData) {
  16713. items
  16714. .fetchItems(filterData, APIService)
  16715. .then(function (data) {
  16716. var myData = Restangular.stripRestangular(data);
  16717. $scope.gridOptions.totalItems = myData.totalNum;
  16718. $scope.myData = myData.list;
  16719. });
  16720. };
  16721. $scope.title = title;
  16722. $scope.loadData({
  16723. idx: 0,
  16724. sum: 10,
  16725. });
  16726. $scope.selected = {
  16727. item: {},
  16728. };
  16729. $scope.ok = function () {
  16730. if ($scope.selected.item.scheduleOrder) {
  16731. $scope.selected.item.descriptionData =
  16732. "日期:" +
  16733. $scope.selected.item.watchTime +
  16734. ";" +
  16735. "班次:" +
  16736. $scope.selected.item.scheduleOrder.description +
  16737. ";" +
  16738. "值班人:" +
  16739. $scope.selected.item.scheduleOrder.users[0].name;
  16740. }
  16741. //console.log($scope.selected.item);
  16742. $modalInstance.close($scope.selected.item);
  16743. };
  16744. $scope.cancel = function () {
  16745. $modalInstance.dismiss("cancel");
  16746. };
  16747. },
  16748. size: size,
  16749. resolve: {
  16750. items: function () {
  16751. return {
  16752. fetchItems: function (filterData, APIService) {
  16753. filterData = filterData || {};
  16754. // if(!filterData.idx){
  16755. if (
  16756. angular.isDefined(filterData.idx) &&
  16757. filterData.idx == null
  16758. ) {
  16759. filterData = {
  16760. idx: 0,
  16761. sum: 10,
  16762. };
  16763. }
  16764. return options.templateOptions.fetchItems(
  16765. filterData,
  16766. APIService,
  16767. options
  16768. );
  16769. },
  16770. columnDefs: function () {
  16771. return options.templateOptions.columnDefs;
  16772. },
  16773. };
  16774. },
  16775. title: function () {
  16776. return options.templateOptions.modalTitle;
  16777. },
  16778. Restangular: function () {
  16779. return options.templateOptions.Restangular;
  16780. },
  16781. APIService: function () {
  16782. return options.templateOptions.ApiService;
  16783. },
  16784. },
  16785. });
  16786. modalInstance.result.then(
  16787. function (selectedItem) {
  16788. options.value(selectedItem);
  16789. },
  16790. function () {
  16791. //console.log('Modal dismissed at: ' + new Date());
  16792. }
  16793. );
  16794. },
  16795. },
  16796. };
  16797. },
  16798. });
  16799. formlyConfigProvider.setType({
  16800. name: "ui-requestform",
  16801. extends: "input",
  16802. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  16803. controller: [
  16804. "$scope",
  16805. function ($scope) {
  16806. setTimeout(function () {
  16807. var filterData = {
  16808. idx: 0,
  16809. sum: 5,
  16810. incident: {
  16811. requester: {
  16812. id: "",
  16813. },
  16814. },
  16815. };
  16816. $scope.options.templateOptions
  16817. .getWorkernumber(
  16818. $scope.options.templateOptions.ApiService,
  16819. filterData
  16820. )
  16821. .then(function (result) {
  16822. var modelData =
  16823. $scope.options.templateOptions.Restangular.stripRestangular(
  16824. result
  16825. );
  16826. });
  16827. }, 1000);
  16828. },
  16829. ],
  16830. });
  16831. //报修图片展示
  16832. formlyConfigProvider.setType({
  16833. name: "ui-repair-photos",
  16834. // extends: 'label',
  16835. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  16836. controller: [
  16837. "$scope",
  16838. "api_wechatfile",
  16839. "$stateParams",
  16840. function ($scope, api_wechatfile, $stateParams) {
  16841. console.log($scope);
  16842. $scope.fileUrls = [];
  16843. if ($scope.model.wxFile) {
  16844. api_wechatfile
  16845. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  16846. .then(function (res) {
  16847. $scope.fileUrls = res.data;
  16848. });
  16849. }
  16850. console.log($stateParams);
  16851. if (
  16852. $stateParams &&
  16853. $stateParams.model &&
  16854. JSON.parse($stateParams.model) &&
  16855. JSON.parse($stateParams.model).model &&
  16856. JSON.parse($stateParams.model).model.flow
  16857. ) {
  16858. api_wechatfile
  16859. .listAttachment(
  16860. "wechatRequesterIncident",
  16861. JSON.parse($stateParams.model).model.flow
  16862. )
  16863. .then(function (res) {
  16864. $scope.fileUrls = res.data;
  16865. });
  16866. }
  16867. if ($scope.model.flow) {
  16868. api_wechatfile
  16869. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  16870. .then(function (res) {
  16871. $scope.fileUrls = res.data;
  16872. });
  16873. }
  16874. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  16875. // // setTimeout(function () {
  16876. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  16877. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  16878. // // if (modelData.status == 200) {
  16879. // // $scope.model[$scope.options.key] = modelData.data;
  16880. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  16881. // // }
  16882. // // });
  16883. // // }, 1000);
  16884. // }
  16885. $scope.showBigImg = false;
  16886. $scope.showBigImgCli = function (data) {
  16887. $scope.showBigImg = true;
  16888. $scope.bigImgUrl = data;
  16889. };
  16890. $scope.closeBigImg = function () {
  16891. $scope.showBigImg = false;
  16892. };
  16893. },
  16894. ],
  16895. });
  16896. //图片展示
  16897. formlyConfigProvider.setType({
  16898. name: "ui-showImgs",
  16899. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  16900. defaultOptions: function (options) {
  16901. return {
  16902. templateOptions: {
  16903. refresh: function (APIService, processInstanceId, data) {
  16904. return APIService.listAttachments(processInstanceId);
  16905. },
  16906. downloadUri: function (APIService, contentId) {
  16907. return APIService.downloadAttachment(contentId).getRequestedUrl();
  16908. },
  16909. view: function (APIService, contentId) {
  16910. return APIService.attachmentsPreviewUrl(contentId);
  16911. },
  16912. download: function (APIService, contentId, item) {
  16913. var item = {
  16914. url: APIService.download(contentId),
  16915. headers: headers,
  16916. };
  16917. return item;
  16918. },
  16919. refreshDelay: 0,
  16920. },
  16921. };
  16922. },
  16923. controller: [
  16924. "$scope",
  16925. "$timeout",
  16926. "$modal",
  16927. "$rootScope",
  16928. "$http",
  16929. "up_down_file",
  16930. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  16931. var _refreshDelayPromise;
  16932. /**
  16933. * refresh
  16934. */
  16935. $scope._refresh = function (refreshAttr) {
  16936. $scope.attachments = [];
  16937. if (refreshAttr !== undefined) {
  16938. if (_refreshDelayPromise) {
  16939. $timeout.cancel(_refreshDelayPromise);
  16940. }
  16941. _refreshDelayPromise = $timeout(function () {
  16942. // 暂存附件
  16943. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  16944. $scope.options.templateOptions
  16945. .refresh(
  16946. $scope.options.templateOptions.ApiService,
  16947. $scope.options.templateOptions.processInstanceId,
  16948. {
  16949. idx: 0,
  16950. sum: 1000,
  16951. }
  16952. )
  16953. .then(function (response) {
  16954. var myData =
  16955. $scope.options.templateOptions.Restangular.stripRestangular(
  16956. response
  16957. );
  16958. if (myData) {
  16959. for (var i = 0; i < myData.data.length; i++) {
  16960. $scope.attachments.push(myData.data[i]);
  16961. }
  16962. }
  16963. $scope.options.templateOptions
  16964. .refresh(
  16965. $scope.options.templateOptions.ApiService,
  16966. $scope.$parent.$parent.$parent.model.save_fileId,
  16967. {
  16968. idx: 0,
  16969. sum: 1000,
  16970. }
  16971. )
  16972. .then(function (response2) {
  16973. var myData2 =
  16974. $scope.options.templateOptions.Restangular.stripRestangular(
  16975. response2
  16976. );
  16977. if (myData2) {
  16978. for (var i = 0; i < myData2.data.length; i++) {
  16979. $scope.attachments.push(myData2.data[i]);
  16980. }
  16981. }
  16982. console.log($scope.attachments);
  16983. });
  16984. });
  16985. // 正常附件
  16986. } else {
  16987. $scope.options.templateOptions
  16988. .refresh(
  16989. $scope.options.templateOptions.ApiService,
  16990. $scope.options.templateOptions.processInstanceId,
  16991. {
  16992. idx: 0,
  16993. sum: 1000,
  16994. }
  16995. )
  16996. .then(function (response) {
  16997. var myData =
  16998. $scope.options.templateOptions.Restangular.stripRestangular(
  16999. response
  17000. );
  17001. if (myData) {
  17002. $scope.attachments = [];
  17003. $scope.imgs = [];
  17004. myData.data.forEach((e) => {
  17005. if (
  17006. e.suffix == "jpeg" ||
  17007. e.suffix == "jpg" ||
  17008. e.suffix == "svg" ||
  17009. e.suffix == "png" ||
  17010. e.suffix == "bmp" ||
  17011. e.suffix == "gif" ||
  17012. e.suffix == "tif"
  17013. ) {
  17014. $scope.imgs.push(e);
  17015. }
  17016. });
  17017. $scope.imgs = $scope.imgs.splice(0, 3);
  17018. console.log($scope.imgs);
  17019. }
  17020. });
  17021. }
  17022. }, $scope.options.templateOptions.refreshDelay);
  17023. }
  17024. };
  17025. $scope._refresh({});
  17026. // $scope.attachments = $scope.model[$scope.options.key]
  17027. // 预览
  17028. $scope.preview = function (url, idx) {
  17029. var title = $scope.imgs[idx].title;
  17030. $modal.open({
  17031. backdrop: false,
  17032. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17033. controller: function ($scope, scope, $modalInstance) {
  17034. $scope.title = title;
  17035. $scope.imageurl = url;
  17036. $scope.cancel = function () {
  17037. $modalInstance.dismiss("cancel");
  17038. };
  17039. },
  17040. resolve: {
  17041. scope: function () {
  17042. return $scope;
  17043. },
  17044. },
  17045. });
  17046. };
  17047. },
  17048. ],
  17049. });
  17050. //工单/受理人控件
  17051. formlyConfigProvider.setType({
  17052. name: "ui-workernumbersign",
  17053. // extends: 'label',
  17054. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  17055. controller: [
  17056. "$scope",
  17057. function ($scope) {
  17058. // 2020年4月24日13:20:40
  17059. console.log($scope, "docu");
  17060. // 左侧事件工单区域地点填充
  17061. $scope.model.selecthouseNumber = $scope.model.place;
  17062. if (
  17063. angular.isUndefined($scope.model[$scope.options.key]) ||
  17064. $scope.model[$scope.options.key] == null
  17065. ) {
  17066. setTimeout(function () {
  17067. $scope.options.templateOptions
  17068. .getWorkernumber($scope.options.templateOptions.ApiService)
  17069. .then(function (result) {
  17070. var modelData =
  17071. $scope.options.templateOptions.Restangular.stripRestangular(
  17072. result
  17073. );
  17074. if (modelData.status == 200) {
  17075. $scope.model[$scope.options.key] = modelData.data;
  17076. $scope.options.initialValue =
  17077. $scope.model[$scope.options.key];
  17078. }
  17079. });
  17080. }, 1000);
  17081. }
  17082. if (
  17083. $scope.options.templateOptions.user &&
  17084. (angular.isUndefined($scope.model.acceptUser) ||
  17085. $scope.model.acceptUser == null)
  17086. ) {
  17087. if (angular.isFunction($scope.options.templateOptions.transform)) {
  17088. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  17089. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  17090. // }
  17091. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17092. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17093. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  17094. }
  17095. $scope.model.acceptUser = $scope.options.templateOptions.user;
  17096. // $scope.options.initialValue = $scope.model.acceptUser;
  17097. }
  17098. },
  17099. ],
  17100. });
  17101. //工单控件-only number
  17102. formlyConfigProvider.setType({
  17103. name: "ui-workernumber",
  17104. extends: "input",
  17105. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17106. controller: [
  17107. "$scope",
  17108. function ($scope) {
  17109. if (
  17110. angular.isUndefined($scope.model[$scope.options.key]) ||
  17111. $scope.model[$scope.options.key] == null
  17112. ) {
  17113. setTimeout(function () {
  17114. $scope.options.templateOptions
  17115. .getWorkernumber($scope.options.templateOptions.ApiService)
  17116. .then(function (result) {
  17117. var modelData =
  17118. $scope.options.templateOptions.Restangular.stripRestangular(
  17119. result
  17120. );
  17121. if (modelData.status == 200) {
  17122. $scope.model[$scope.options.key] = modelData.data;
  17123. $scope.options.initialValue =
  17124. $scope.model[$scope.options.key];
  17125. }
  17126. });
  17127. }, 1000);
  17128. }
  17129. },
  17130. ],
  17131. });
  17132. //cmdb工单
  17133. formlyConfigProvider.setType({
  17134. name: "ui-cmdbworkernumber",
  17135. extends: "input",
  17136. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17137. controller: [
  17138. "$scope",
  17139. function ($scope) {
  17140. if (
  17141. angular.isUndefined($scope.model[$scope.options.key]) ||
  17142. $scope.model[$scope.options.key] == null
  17143. ) {
  17144. setTimeout(function () {
  17145. $scope.options.templateOptions
  17146. .getWorkernumber(
  17147. $scope.options.templateOptions.ApiService,
  17148. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17149. .cifilter_classics.id
  17150. )
  17151. .then(function (result) {
  17152. var modelData =
  17153. $scope.options.templateOptions.Restangular.stripRestangular(
  17154. result
  17155. );
  17156. // if(modelData.status==200){
  17157. $scope.model[$scope.options.key] =
  17158. modelData[$scope.options.key];
  17159. $scope.options.initialValue = $scope.model[$scope.options.key];
  17160. // }
  17161. });
  17162. }, 1000);
  17163. }
  17164. },
  17165. ],
  17166. });
  17167. //简易上传图片组件
  17168. formlyConfigProvider.setType({
  17169. name: "ui-uploadImgs",
  17170. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17171. wrapper: ["bootstrapHasError"],
  17172. controller: [
  17173. "$scope",
  17174. "fileReader",
  17175. "$parse",
  17176. "$modal",
  17177. function ($scope, fileReader, $parse, $modal) {
  17178. $scope.imgshows = [];
  17179. $scope.uploadimgs = [];
  17180. var model = $parse("upload_img");
  17181. var modelSetter = model.assign;
  17182. var uploader = ($scope.uploader =
  17183. $scope.options.templateOptions.fileUploader);
  17184. uploader.filters.push({
  17185. name: "customFilter",
  17186. fn: function (item /*{File|FileLikeObject}*/, options) {
  17187. return this.queue.length < 10;
  17188. },
  17189. });
  17190. // 添加
  17191. $scope.change = function (event) {
  17192. var element = $(".upinp");
  17193. modelSetter($scope, element[0].files[0]);
  17194. //附件预览
  17195. $scope.imgupload = event.files[0];
  17196. getFile($scope.imgupload, $scope);
  17197. //获得预览图地址并且把file对象放入上传合集内
  17198. function getFile(imgupload, $scope) {
  17199. if (!imgupload) {
  17200. return;
  17201. }
  17202. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17203. $scope.imgshows.push(result);
  17204. var file = document.querySelector("input[type=file]").files[0];
  17205. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17206. console.log($scope.imgshows, $scope.uploadimgs);
  17207. if ($scope.imgshows.length < 3) {
  17208. $("#upup").show();
  17209. } else {
  17210. $("#upup").hide();
  17211. }
  17212. });
  17213. }
  17214. };
  17215. // 删除
  17216. $scope.uploadimg_del = function (index, imgs) {
  17217. console.log(index, imgs);
  17218. $scope.imgshows.splice(index, 1);
  17219. $scope.uploadimgs.splice(index, 1);
  17220. if ($scope.imgshows.length < 3) {
  17221. $("#upup").show();
  17222. } else {
  17223. $("#upup").hide();
  17224. }
  17225. };
  17226. // 预览
  17227. $scope.preview = function (url, idx) {
  17228. var name = $scope.uploadimgs[idx].name;
  17229. $modal.open({
  17230. backdrop: false,
  17231. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17232. controller: function ($scope, scope, $modalInstance) {
  17233. $scope.title = name;
  17234. $scope.imageurl = url;
  17235. $scope.cancel = function () {
  17236. $modalInstance.dismiss("cancel");
  17237. };
  17238. },
  17239. resolve: {
  17240. scope: function () {
  17241. return $scope;
  17242. },
  17243. },
  17244. });
  17245. };
  17246. if (uploader) {
  17247. uploader.onWhenAddingFileFailed = function (
  17248. item /*{File|FileLikeObject}*/,
  17249. filter,
  17250. options
  17251. ) {
  17252. console.info("onWhenAddingFileFailed", item, filter, options);
  17253. };
  17254. uploader.onAfterAddingFile = function (fileItem) {
  17255. console.info("onAfterAddingFile", fileItem);
  17256. };
  17257. uploader.onAfterAddingAll = function (addedFileItems) {
  17258. console.info("onAfterAddingAll", addedFileItems);
  17259. };
  17260. uploader.onBeforeUploadItem = function (item) {
  17261. console.info("onBeforeUploadItem", item);
  17262. };
  17263. uploader.onProgressItem = function (fileItem, progress) {
  17264. console.info("onProgressItem", fileItem, progress);
  17265. };
  17266. uploader.onProgressAll = function (progress) {
  17267. console.info("onProgressAll", progress);
  17268. };
  17269. uploader.onSuccessItem = function (
  17270. fileItem,
  17271. response,
  17272. status,
  17273. headers
  17274. ) {
  17275. console.info("onSuccessItem", fileItem, response, status, headers);
  17276. };
  17277. uploader.onErrorItem = function (
  17278. fileItem,
  17279. response,
  17280. status,
  17281. headers
  17282. ) {
  17283. console.info("onErrorItem", fileItem, response, status, headers);
  17284. };
  17285. uploader.onCancelItem = function (
  17286. fileItem,
  17287. response,
  17288. status,
  17289. headers
  17290. ) {
  17291. console.info("onCancelItem", fileItem, response, status, headers);
  17292. };
  17293. uploader.onCompleteItem = function (
  17294. fileItem,
  17295. response,
  17296. status,
  17297. headers
  17298. ) {
  17299. console.info("onCompleteItem", fileItem, response, status, headers);
  17300. };
  17301. uploader.onCompleteAll = function () {
  17302. console.info("onCompleteAll");
  17303. };
  17304. }
  17305. // console.log(modelSetter)
  17306. },
  17307. ],
  17308. });
  17309. //jry-上传下载一体
  17310. formlyConfigProvider.setType({
  17311. name: "ui-upDropFile",
  17312. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17313. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17314. defaultOptions: function (options) {
  17315. return {
  17316. templateOptions: {
  17317. view: function (APIService, contentId) {
  17318. return APIService.downloadAttachment(contentId);
  17319. },
  17320. // ApiService: 'api_wechatfile',
  17321. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17322. // upUrl: 'common/common/uploadAttachment',
  17323. // listAttachmentUrl: 'common/common/listAttachment',
  17324. // downUrl: 'common/common/downloadAttachment',
  17325. // bindType: 'incident',
  17326. // bindId: 2323
  17327. },
  17328. // validators: {
  17329. // required: {
  17330. // expression: function(viewValue, modelValue) {
  17331. // var value = modelValue || viewValue;
  17332. // return value.length >= 1;
  17333. // }
  17334. // }
  17335. // }
  17336. };
  17337. },
  17338. controller: [
  17339. "$scope",
  17340. "$rootScope",
  17341. "Restangular",
  17342. "up_down_file",
  17343. "$http",
  17344. "api_bpm",
  17345. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17346. console.log($scope);
  17347. $scope.showFileUp = true;
  17348. if ($scope.model.isKnowledge_detail) {
  17349. $scope.showFileUp = false;
  17350. }
  17351. if (angular.isUndefined($scope.form.dropState)) {
  17352. $scope.form.dropState = false;
  17353. }
  17354. if ($scope.model.incident) {
  17355. if ($scope.model.incident.alarm) {
  17356. console.log($scope);
  17357. if ($scope.model.incident.alarm) {
  17358. if ($scope.model.incident.alarm.alarmExtension) {
  17359. $scope.model.incident.alarm.alarmExtension =
  17360. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17361. $scope.model.incident.alarm.alarmExtension =
  17362. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17363. $scope.model.incident.description =
  17364. $scope.model.incident.alarm.alarmExtension;
  17365. console.log($scope.model.incident.description);
  17366. $scope.model.incident.description =
  17367. '"' +
  17368. "告警名称" +
  17369. '":' +
  17370. '"' +
  17371. $scope.model.incident.alarm.alarmSystem +
  17372. '",' +
  17373. '"' +
  17374. "告警状态" +
  17375. '":' +
  17376. '"' +
  17377. $scope.model.incident.alarm.alarmStatus +
  17378. '",' +
  17379. '"' +
  17380. "告警内容" +
  17381. '":' +
  17382. '"' +
  17383. $scope.model.incident.alarm.alarmContent +
  17384. '",' +
  17385. $scope.model.incident.description;
  17386. } else {
  17387. $scope.model.incident.description =
  17388. '"' +
  17389. "告警名称" +
  17390. '":' +
  17391. '"' +
  17392. $scope.model.incident.alarm.alarmSystem +
  17393. '",' +
  17394. '"' +
  17395. "告警状态" +
  17396. '":' +
  17397. '"' +
  17398. $scope.model.incident.alarm.alarmStatus +
  17399. '",' +
  17400. '"' +
  17401. "告警内容" +
  17402. '":' +
  17403. '"' +
  17404. $scope.model.incident.alarm.alarmContent +
  17405. '",';
  17406. }
  17407. $scope.model.incident.description =
  17408. $scope.model.incident.description.replace(/,/g, "\n");
  17409. console.log($scope.model.incident.description);
  17410. }
  17411. }
  17412. api_bpm
  17413. .tellCategory($scope.model.incident.category.id)
  17414. .then(function (wt_data) {
  17415. console.log(wt_data);
  17416. if (wt_data) {
  17417. $rootScope.wt_category = wt_data.data;
  17418. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  17419. $rootScope.wt_child = wt_data.child;
  17420. }
  17421. });
  17422. if ($scope.model.titleName == "接单") {
  17423. $scope.model.receive_code = "handler";
  17424. if (
  17425. $scope.model.incident.groupLeader &&
  17426. !$scope.model.incident.repeat
  17427. ) {
  17428. $scope.model.isHandlerUser = true;
  17429. }
  17430. }
  17431. if ($scope.model.titleName == "事件处理") {
  17432. console.log($scope.model.cmdbCode);
  17433. if ($scope.model.cmdbCode) {
  17434. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  17435. }
  17436. }
  17437. } else {
  17438. $rootScope.wt_category = "";
  17439. }
  17440. //附件上传数据
  17441. if ($scope.options.templateOptions.fileUploader) {
  17442. var uploader = ($scope.uploader =
  17443. $scope.options.templateOptions.fileUploader);
  17444. //$scope.options.templateOptions.uploader();
  17445. console.log(uploader);
  17446. // FILTERS
  17447. uploader.filters.push({
  17448. name: "customFilter",
  17449. fn: function (item /*{File|FileLikeObject}*/, options) {
  17450. return this.queue.length < 10;
  17451. },
  17452. });
  17453. }
  17454. var to = $scope.options.templateOptions;
  17455. // var bindType = $scope.model.bindType;
  17456. if (to.bindType == "incident") {
  17457. var bindId = $scope.model[to.bindType].processInstanceId;
  17458. } else if (to.bindType == "change") {
  17459. var bindId = $scope.model[to.bindType].processInstanceId;
  17460. } else {
  17461. var bindId = $scope.model[to.bindType].id;
  17462. }
  17463. //获取附件列表
  17464. $scope.listAttachmen = function () {
  17465. to.ApiService.listAttachment(
  17466. to.listAttachmentUrl,
  17467. to.bindType,
  17468. bindId
  17469. ).then(function (result) {
  17470. var myData = Restangular.stripRestangular(result);
  17471. // $scope.listAttachmens = myData;
  17472. $scope.attachments = myData.data;
  17473. });
  17474. };
  17475. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  17476. $scope.listAttachmen();
  17477. } else if (to.bindType && $scope.model[to.bindType].id) {
  17478. $scope.listAttachmen();
  17479. }
  17480. //附件上传
  17481. $scope.isUpfload = to.isUpfload;
  17482. $scope.dropfile = function (
  17483. APIService,
  17484. processInstanceId,
  17485. taskId,
  17486. userId
  17487. ) {
  17488. uploader.onBeforeUploadItem = function (item) {
  17489. angular.extend(item.headers, $rootScope.getSession());
  17490. item.url = to.ApiService.saveAttachments(
  17491. to.uploadUrl,
  17492. to.bindType,
  17493. bindId
  17494. ).getRequestedUrl();
  17495. item.formData.push({
  17496. filename: item.file.name,
  17497. });
  17498. };
  17499. uploader.uploadAll();
  17500. };
  17501. //附件下载
  17502. $scope.download = function (token, filename) {
  17503. var downUrl = to.ApiService.downloadAttachment(
  17504. to.downUrl,
  17505. token
  17506. ).getRequestedUrl();
  17507. // window.open(downUrl);
  17508. var a = document.createElement("a");
  17509. a.href = downUrl;
  17510. a.target = "_blank";
  17511. a.download = filename;
  17512. document.body.appendChild(a);
  17513. a.click();
  17514. };
  17515. //附件预览
  17516. $scope.view = function (id, previewUrl) {
  17517. if (previewUrl) {
  17518. window.open(previewUrl);
  17519. }
  17520. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  17521. // if (response.state == 200) {
  17522. // window.open(response.previewUrl);
  17523. // }
  17524. // })
  17525. };
  17526. // CALLBACKS
  17527. if (uploader) {
  17528. uploader.onWhenAddingFileFailed = function (
  17529. item /*{File|FileLikeObject}*/,
  17530. filter,
  17531. options
  17532. ) {
  17533. console.info("onWhenAddingFileFailed", item, filter, options);
  17534. };
  17535. uploader.onAfterAddingFile = function (fileItem) {
  17536. console.info("onAfterAddingFile", fileItem);
  17537. };
  17538. uploader.onAfterAddingAll = function (addedFileItems) {
  17539. console.info("onAfterAddingAll", addedFileItems);
  17540. };
  17541. uploader.onBeforeUploadItem = function (item) {
  17542. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17543. // // $scope.uploader.options.url();
  17544. // $scope.uploader.onBeforeUploadItem = function(item) {
  17545. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17546. // console.info('onBeforeUploadItem', item);
  17547. // };
  17548. // $scope.uploader.uploadAll();
  17549. // }
  17550. console.info("onBeforeUploadItem", item);
  17551. };
  17552. uploader.onProgressItem = function (fileItem, progress) {
  17553. console.info("onProgressItem", fileItem, progress);
  17554. };
  17555. uploader.onProgressAll = function (progress) {
  17556. console.info("onProgressAll", progress);
  17557. };
  17558. uploader.onSuccessItem = function (
  17559. fileItem,
  17560. response,
  17561. status,
  17562. headers
  17563. ) {
  17564. console.info("onSuccessItem", fileItem, response, status, headers);
  17565. if (response.status == 200) {
  17566. $scope.listAttachmen();
  17567. }
  17568. };
  17569. uploader.onErrorItem = function (
  17570. fileItem,
  17571. response,
  17572. status,
  17573. headers
  17574. ) {
  17575. console.info("onErrorItem", fileItem, response, status, headers);
  17576. };
  17577. uploader.onCancelItem = function (
  17578. fileItem,
  17579. response,
  17580. status,
  17581. headers
  17582. ) {
  17583. console.info("onCancelItem", fileItem, response, status, headers);
  17584. };
  17585. uploader.onCompleteItem = function (
  17586. fileItem,
  17587. response,
  17588. status,
  17589. headers
  17590. ) {
  17591. console.info("onCompleteItem", fileItem, response, status, headers);
  17592. };
  17593. uploader.onCompleteAll = function () {
  17594. console.info("onCompleteAll");
  17595. };
  17596. }
  17597. },
  17598. ],
  17599. });
  17600. //简易上传下载附件组件
  17601. formlyConfigProvider.setType({
  17602. name: "ui-upDownFiles",
  17603. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  17604. wrapper: ["bootstrapHasError"],
  17605. defaultOptions: function (options) {
  17606. return {
  17607. templateOptions: {
  17608. refresh: function (APIService, processInstanceId, data) {
  17609. return APIService.listAttachments(processInstanceId);
  17610. },
  17611. downloadUri: function (APIService, contentId) {
  17612. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17613. },
  17614. view: function (APIService, contentId) {
  17615. return APIService.attachmentsPreviewUrl(contentId);
  17616. },
  17617. download: function (APIService, contentId, item) {
  17618. var item = {
  17619. url: APIService.download(contentId),
  17620. headers: headers,
  17621. };
  17622. return item;
  17623. },
  17624. refreshDelay: 0,
  17625. },
  17626. };
  17627. },
  17628. controller: [
  17629. "$scope",
  17630. "$timeout",
  17631. "$modal",
  17632. "$rootScope",
  17633. "$http",
  17634. "up_down_file",
  17635. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17636. if (angular.isUndefined($scope.form.dropState)) {
  17637. $scope.form.dropState = false;
  17638. }
  17639. //附件上传数据
  17640. var uploader = ($scope.uploader =
  17641. $scope.options.templateOptions.fileUploader);
  17642. //$scope.options.templateOptions.uploader();
  17643. // FILTERS
  17644. uploader.filters.push({
  17645. name: "customFilter",
  17646. fn: function (item /*{File|FileLikeObject}*/, options) {
  17647. return this.queue.length < 10;
  17648. },
  17649. });
  17650. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  17651. // uploader.onBeforeUploadItem = function (item) {
  17652. // angular.extend(item.headers, $rootScope.getSession());
  17653. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  17654. // item.formData.push({
  17655. // 'fileName': item.file.name
  17656. // });
  17657. // console.info('onBeforeUploadItem', item);
  17658. // };
  17659. // }
  17660. // CALLBACKS
  17661. uploader.onWhenAddingFileFailed = function (
  17662. item /*{File|FileLikeObject}*/,
  17663. filter,
  17664. options
  17665. ) {
  17666. console.info("onWhenAddingFileFailed", item, filter, options);
  17667. };
  17668. uploader.onAfterAddingFile = function (fileItem) {
  17669. console.info("onAfterAddingFile", fileItem);
  17670. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17671. alert("文件过大");
  17672. fileItem.uploader.queue.pop();
  17673. console.log($scope);
  17674. }
  17675. };
  17676. uploader.onAfterAddingAll = function (addedFileItems) {
  17677. // console.info('onAfterAddingAll', addedFileItems);
  17678. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17679. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17680. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17681. // console.log(123)
  17682. };
  17683. uploader.onBeforeUploadItem = function (item) {
  17684. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17685. // // $scope.uploader.options.url();
  17686. // $scope.uploader.onBeforeUploadItem = function(item) {
  17687. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17688. // console.info('onBeforeUploadItem', item);
  17689. // };
  17690. // $scope.uploader.uploadAll();
  17691. // }
  17692. console.info("onBeforeUploadItem", item);
  17693. };
  17694. uploader.onProgressItem = function (fileItem, progress) {
  17695. console.info("onProgressItem", fileItem, progress);
  17696. };
  17697. uploader.onProgressAll = function (progress) {
  17698. console.info("onProgressAll", progress);
  17699. };
  17700. uploader.onSuccessItem = function (
  17701. fileItem,
  17702. response,
  17703. status,
  17704. headers
  17705. ) {
  17706. console.info("onSuccessItem", fileItem, response, status, headers);
  17707. };
  17708. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17709. console.info("onErrorItem", fileItem, response, status, headers);
  17710. };
  17711. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17712. console.info("onCancelItem", fileItem, response, status, headers);
  17713. };
  17714. uploader.onCompleteItem = function (
  17715. fileItem,
  17716. response,
  17717. status,
  17718. headers
  17719. ) {
  17720. console.info("onCompleteItem", fileItem, response, status, headers);
  17721. };
  17722. uploader.onCompleteAll = function () {
  17723. console.info("onCompleteAll");
  17724. };
  17725. var _refreshDelayPromise;
  17726. // 下载
  17727. $scope.download = function (contentId, filename, token) {
  17728. // console.log(contentId, filename, token)
  17729. //附件下载
  17730. var downUrl = up_down_file
  17731. .downloadAttachment("common/common/downloadAttachment", token)
  17732. .getRequestedUrl();
  17733. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17734. // console.log(downUrl)
  17735. var a = document.createElement("a");
  17736. a.href = downUrl;
  17737. a.target = "_blank";
  17738. a.download = filename;
  17739. document.body.appendChild(a);
  17740. a.click();
  17741. };
  17742. $scope._refresh = function (refreshAttr) {
  17743. $scope.attachments = [];
  17744. if (refreshAttr !== undefined) {
  17745. if (_refreshDelayPromise) {
  17746. $timeout.cancel(_refreshDelayPromise);
  17747. }
  17748. _refreshDelayPromise = $timeout(function () {
  17749. // 暂存附件
  17750. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17751. $scope.options.templateOptions
  17752. .refresh(
  17753. $scope.options.templateOptions.ApiService,
  17754. $scope.options.templateOptions.processInstanceId,
  17755. {
  17756. idx: 0,
  17757. sum: 1000,
  17758. }
  17759. )
  17760. .then(function (response) {
  17761. var myData =
  17762. $scope.options.templateOptions.Restangular.stripRestangular(
  17763. response
  17764. );
  17765. if (myData) {
  17766. for (var i = 0; i < myData.data.length; i++) {
  17767. $scope.attachments.push(myData.data[i]);
  17768. }
  17769. }
  17770. $scope.options.templateOptions
  17771. .refresh(
  17772. $scope.options.templateOptions.ApiService,
  17773. $scope.$parent.$parent.$parent.model.save_fileId,
  17774. {
  17775. idx: 0,
  17776. sum: 1000,
  17777. }
  17778. )
  17779. .then(function (response2) {
  17780. var myData2 =
  17781. $scope.options.templateOptions.Restangular.stripRestangular(
  17782. response2
  17783. );
  17784. if (myData2) {
  17785. for (var i = 0; i < myData2.data.length; i++) {
  17786. $scope.attachments.push(myData2.data[i]);
  17787. }
  17788. // 只展示除图片以外的附件
  17789. var a = [];
  17790. $scope.attachments.forEach((e) => {
  17791. if (
  17792. e.suffix == "jpeg" ||
  17793. e.suffix == "jpg" ||
  17794. e.suffix == "svg" ||
  17795. e.suffix == "png" ||
  17796. e.suffix == "bmp" ||
  17797. e.suffix == "gif" ||
  17798. e.suffix == "tif"
  17799. ) {
  17800. // $scope.imgs.push(e)
  17801. } else {
  17802. a.push(e);
  17803. }
  17804. });
  17805. $scope.attachments = a;
  17806. }
  17807. console.log($scope.attachments);
  17808. });
  17809. });
  17810. // 正常附件
  17811. } else {
  17812. $scope.options.templateOptions
  17813. .refresh(
  17814. $scope.options.templateOptions.ApiService,
  17815. $scope.options.templateOptions.processInstanceId,
  17816. {
  17817. idx: 0,
  17818. sum: 1000,
  17819. }
  17820. )
  17821. .then(function (response) {
  17822. var myData =
  17823. $scope.options.templateOptions.Restangular.stripRestangular(
  17824. response
  17825. );
  17826. if (myData) {
  17827. $scope.attachments = myData.data;
  17828. // 只展示除图片以外的附件
  17829. var a = [];
  17830. $scope.attachments.forEach((e) => {
  17831. if (
  17832. e.suffix == "jpeg" ||
  17833. e.suffix == "jpg" ||
  17834. e.suffix == "svg" ||
  17835. e.suffix == "png" ||
  17836. e.suffix == "bmp" ||
  17837. e.suffix == "gif" ||
  17838. e.suffix == "tif"
  17839. ) {
  17840. // $scope.imgs.push(e)
  17841. } else {
  17842. a.push(e);
  17843. }
  17844. });
  17845. $scope.attachments = a;
  17846. }
  17847. });
  17848. }
  17849. }, $scope.options.templateOptions.refreshDelay);
  17850. }
  17851. };
  17852. $scope._refresh({});
  17853. },
  17854. ],
  17855. });
  17856. //简易上传附件组件
  17857. formlyConfigProvider.setType({
  17858. name: "ui-uploadFiles",
  17859. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  17860. wrapper: ["bootstrapHasError"],
  17861. controller: [
  17862. "$scope",
  17863. function ($scope) {
  17864. if (angular.isUndefined($scope.form.dropState)) {
  17865. $scope.form.dropState = false;
  17866. }
  17867. //附件上传数据
  17868. var uploader = ($scope.uploader =
  17869. $scope.options.templateOptions.fileUploader);
  17870. //$scope.options.templateOptions.uploader();
  17871. // FILTERS
  17872. uploader.filters.push({
  17873. name: "customFilter",
  17874. fn: function (item /*{File|FileLikeObject}*/, options) {
  17875. return this.queue.length < 10;
  17876. },
  17877. });
  17878. $scope.dropfile = function (
  17879. APIService,
  17880. processInstanceId,
  17881. taskId,
  17882. userId
  17883. ) {
  17884. uploader.onBeforeUploadItem = function (item) {
  17885. angular.extend(item.headers, $rootScope.getSession());
  17886. item.url = APIService.saveAttachments(
  17887. processInstanceId,
  17888. taskId,
  17889. userId
  17890. ).getRequestedUrl();
  17891. item.formData.push({
  17892. fileName: item.file.name,
  17893. });
  17894. console.info("onBeforeUploadItem", item);
  17895. };
  17896. };
  17897. // CALLBACKS
  17898. uploader.onWhenAddingFileFailed = function (
  17899. item /*{File|FileLikeObject}*/,
  17900. filter,
  17901. options
  17902. ) {
  17903. console.info("onWhenAddingFileFailed", item, filter, options);
  17904. };
  17905. uploader.onAfterAddingFile = function (fileItem) {
  17906. console.info("onAfterAddingFile", fileItem);
  17907. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17908. alert("文件过大");
  17909. fileItem.uploader.queue.pop();
  17910. console.log($scope);
  17911. }
  17912. };
  17913. uploader.onAfterAddingAll = function (addedFileItems) {
  17914. // console.info('onAfterAddingAll', addedFileItems);
  17915. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17916. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17917. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17918. // console.log(123)
  17919. };
  17920. uploader.onBeforeUploadItem = function (item) {
  17921. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17922. // // $scope.uploader.options.url();
  17923. // $scope.uploader.onBeforeUploadItem = function(item) {
  17924. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17925. // console.info('onBeforeUploadItem', item);
  17926. // };
  17927. // $scope.uploader.uploadAll();
  17928. // }
  17929. console.info("onBeforeUploadItem", item);
  17930. };
  17931. uploader.onProgressItem = function (fileItem, progress) {
  17932. console.info("onProgressItem", fileItem, progress);
  17933. };
  17934. uploader.onProgressAll = function (progress) {
  17935. console.info("onProgressAll", progress);
  17936. };
  17937. uploader.onSuccessItem = function (
  17938. fileItem,
  17939. response,
  17940. status,
  17941. headers
  17942. ) {
  17943. console.info("onSuccessItem", fileItem, response, status, headers);
  17944. };
  17945. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17946. console.info("onErrorItem", fileItem, response, status, headers);
  17947. };
  17948. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17949. console.info("onCancelItem", fileItem, response, status, headers);
  17950. };
  17951. uploader.onCompleteItem = function (
  17952. fileItem,
  17953. response,
  17954. status,
  17955. headers
  17956. ) {
  17957. console.info("onCompleteItem", fileItem, response, status, headers);
  17958. };
  17959. uploader.onCompleteAll = function () {
  17960. console.info("onCompleteAll");
  17961. };
  17962. },
  17963. ],
  17964. });
  17965. //无上传按钮附件上传组件
  17966. formlyConfigProvider.setType({
  17967. name: "ui-dropfilenotup",
  17968. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17969. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17970. controller: [
  17971. "$scope",
  17972. function ($scope) {
  17973. if (angular.isUndefined($scope.form.dropState)) {
  17974. $scope.form.dropState = false;
  17975. }
  17976. //附件上传数据
  17977. var uploader = ($scope.uploader =
  17978. $scope.options.templateOptions.fileUploader);
  17979. //$scope.options.templateOptions.uploader();
  17980. // FILTERS
  17981. uploader.filters.push({
  17982. name: "customFilter",
  17983. fn: function (item /*{File|FileLikeObject}*/, options) {
  17984. return this.queue.length < 10;
  17985. },
  17986. });
  17987. $scope.dropfile = function (
  17988. APIService,
  17989. processInstanceId,
  17990. taskId,
  17991. userId
  17992. ) {
  17993. uploader.onBeforeUploadItem = function (item) {
  17994. angular.extend(item.headers, $rootScope.getSession());
  17995. item.url = APIService.saveAttachments(
  17996. processInstanceId,
  17997. taskId,
  17998. userId
  17999. ).getRequestedUrl();
  18000. item.formData.push({
  18001. fileName: item.file.name,
  18002. });
  18003. console.info("onBeforeUploadItem", item);
  18004. };
  18005. uploader.uploadAll();
  18006. };
  18007. // CALLBACKS
  18008. uploader.onWhenAddingFileFailed = function (
  18009. item /*{File|FileLikeObject}*/,
  18010. filter,
  18011. options
  18012. ) {
  18013. console.info("onWhenAddingFileFailed", item, filter, options);
  18014. };
  18015. uploader.onAfterAddingFile = function (fileItem) {
  18016. console.info("onAfterAddingFile", fileItem);
  18017. };
  18018. uploader.onAfterAddingAll = function (addedFileItems) {
  18019. console.info("onAfterAddingAll", addedFileItems);
  18020. };
  18021. uploader.onBeforeUploadItem = function (item) {
  18022. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18023. // // $scope.uploader.options.url();
  18024. // $scope.uploader.onBeforeUploadItem = function(item) {
  18025. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18026. // console.info('onBeforeUploadItem', item);
  18027. // };
  18028. // $scope.uploader.uploadAll();
  18029. // }
  18030. console.info("onBeforeUploadItem", item);
  18031. };
  18032. uploader.onProgressItem = function (fileItem, progress) {
  18033. console.info("onProgressItem", fileItem, progress);
  18034. };
  18035. uploader.onProgressAll = function (progress) {
  18036. console.info("onProgressAll", progress);
  18037. };
  18038. uploader.onSuccessItem = function (
  18039. fileItem,
  18040. response,
  18041. status,
  18042. headers
  18043. ) {
  18044. console.info("onSuccessItem", fileItem, response, status, headers);
  18045. };
  18046. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18047. console.info("onErrorItem", fileItem, response, status, headers);
  18048. };
  18049. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18050. console.info("onCancelItem", fileItem, response, status, headers);
  18051. };
  18052. uploader.onCompleteItem = function (
  18053. fileItem,
  18054. response,
  18055. status,
  18056. headers
  18057. ) {
  18058. console.info("onCompleteItem", fileItem, response, status, headers);
  18059. };
  18060. uploader.onCompleteAll = function () {
  18061. console.info("onCompleteAll");
  18062. };
  18063. },
  18064. ],
  18065. });
  18066. //无按钮知识库上传
  18067. formlyConfigProvider.setType({
  18068. name: "ui-dropfielkn",
  18069. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18070. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18071. controller: [
  18072. "$scope",
  18073. function ($scope) {
  18074. if (angular.isUndefined($scope.form.dropState)) {
  18075. $scope.form.dropState = false;
  18076. }
  18077. //附件上传数据
  18078. var uploader = ($scope.uploader =
  18079. $scope.options.templateOptions.fileUploader);
  18080. //$scope.options.templateOptions.uploader();
  18081. // FILTERS
  18082. uploader.filters.push({
  18083. name: "customFilter",
  18084. fn: function (item /*{File|FileLikeObject}*/, options) {
  18085. return this.queue.length < 10;
  18086. },
  18087. });
  18088. $scope.dropfile = function (
  18089. APIService,
  18090. processInstanceId,
  18091. taskId,
  18092. userId
  18093. ) {
  18094. uploader.onBeforeUploadItem = function (item) {
  18095. angular.extend(item.headers, $rootScope.getSession());
  18096. item.url = APIService.addFile(
  18097. processInstanceId,
  18098. taskId,
  18099. userId
  18100. ).getRequestedUrl();
  18101. item.formData.push({
  18102. fileName: item.file.name,
  18103. });
  18104. console.info("onBeforeUploadItem", item);
  18105. };
  18106. uploader.uploadAll();
  18107. };
  18108. // CALLBACKS
  18109. uploader.onWhenAddingFileFailed = function (
  18110. item /*{File|FileLikeObject}*/,
  18111. filter,
  18112. options
  18113. ) {
  18114. console.info("onWhenAddingFileFailed", item, filter, options);
  18115. };
  18116. uploader.onAfterAddingFile = function (fileItem) {
  18117. console.info("onAfterAddingFile", fileItem);
  18118. };
  18119. uploader.onAfterAddingAll = function (addedFileItems) {
  18120. console.info("onAfterAddingAll", addedFileItems);
  18121. };
  18122. uploader.onBeforeUploadItem = function (item) {
  18123. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18124. // // $scope.uploader.options.url();
  18125. // $scope.uploader.onBeforeUploadItem = function(item) {
  18126. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18127. // console.info('onBeforeUploadItem', item);
  18128. // };
  18129. // $scope.uploader.uploadAll();
  18130. // }
  18131. console.info("onBeforeUploadItem", item);
  18132. };
  18133. uploader.onProgressItem = function (fileItem, progress) {
  18134. console.info("onProgressItem", fileItem, progress);
  18135. };
  18136. uploader.onProgressAll = function (progress) {
  18137. console.info("onProgressAll", progress);
  18138. };
  18139. uploader.onSuccessItem = function (
  18140. fileItem,
  18141. response,
  18142. status,
  18143. headers
  18144. ) {
  18145. console.info("onSuccessItem", fileItem, response, status, headers);
  18146. };
  18147. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18148. console.info("onErrorItem", fileItem, response, status, headers);
  18149. };
  18150. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18151. console.info("onCancelItem", fileItem, response, status, headers);
  18152. };
  18153. uploader.onCompleteItem = function (
  18154. fileItem,
  18155. response,
  18156. status,
  18157. headers
  18158. ) {
  18159. console.info("onCompleteItem", fileItem, response, status, headers);
  18160. };
  18161. uploader.onCompleteAll = function () {
  18162. console.info("onCompleteAll");
  18163. };
  18164. },
  18165. ],
  18166. });
  18167. //附件上传列表组件
  18168. formlyConfigProvider.setType({
  18169. name: "ui-dropfile",
  18170. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18171. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18172. controller: [
  18173. "$scope",
  18174. "$rootScope",
  18175. function ($scope, $rootScope) {
  18176. if (angular.isUndefined($scope.form.dropState)) {
  18177. $scope.form.dropState = false;
  18178. }
  18179. //附件上传数据
  18180. var uploader = ($scope.uploader =
  18181. $scope.options.templateOptions.fileUploader);
  18182. //$scope.options.templateOptions.uploader();
  18183. // FILTERS
  18184. uploader.filters.push({
  18185. name: "customFilter",
  18186. fn: function (item /*{File|FileLikeObject}*/, options) {
  18187. return this.queue.length < 10;
  18188. },
  18189. });
  18190. $scope.dropfile = function (
  18191. APIService,
  18192. processInstanceId,
  18193. taskId,
  18194. userId
  18195. ) {
  18196. uploader.onBeforeUploadItem = function (item) {
  18197. angular.extend(item.headers, $rootScope.getSession());
  18198. if (
  18199. $scope.options.templateOptions.upservice &&
  18200. $scope.options.templateOptions.formname
  18201. ) {
  18202. // if ($scope.options.templateOptions.formket) {
  18203. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18204. // } else {
  18205. item.url = APIService[$scope.options.templateOptions.upservice](
  18206. $scope.model[$scope.options.templateOptions.formname].id,
  18207. taskId,
  18208. userId
  18209. ).getRequestedUrl();
  18210. // }
  18211. } else {
  18212. item.url = APIService.saveAttachments(
  18213. processInstanceId,
  18214. taskId,
  18215. userId
  18216. ).getRequestedUrl();
  18217. }
  18218. item.formData.push({
  18219. filename: item.file.name,
  18220. });
  18221. console.info("onBeforeUploadItem", item);
  18222. };
  18223. uploader.uploadAll();
  18224. };
  18225. // CALLBACKS
  18226. uploader.onWhenAddingFileFailed = function (
  18227. item /*{File|FileLikeObject}*/,
  18228. filter,
  18229. options
  18230. ) {
  18231. console.info("onWhenAddingFileFailed", item, filter, options);
  18232. };
  18233. uploader.onAfterAddingFile = function (fileItem) {
  18234. console.info("onAfterAddingFile", fileItem);
  18235. };
  18236. uploader.onAfterAddingAll = function (addedFileItems) {
  18237. console.info("onAfterAddingAll", addedFileItems);
  18238. };
  18239. uploader.onBeforeUploadItem = function (item) {
  18240. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18241. // // $scope.uploader.options.url();
  18242. // $scope.uploader.onBeforeUploadItem = function(item) {
  18243. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18244. // console.info('onBeforeUploadItem', item);
  18245. // };
  18246. // $scope.uploader.uploadAll();
  18247. // }
  18248. console.info("onBeforeUploadItem", item);
  18249. };
  18250. uploader.onProgressItem = function (fileItem, progress) {
  18251. console.info("onProgressItem", fileItem, progress);
  18252. };
  18253. uploader.onProgressAll = function (progress) {
  18254. console.info("onProgressAll", progress);
  18255. };
  18256. uploader.onSuccessItem = function (
  18257. fileItem,
  18258. response,
  18259. status,
  18260. headers
  18261. ) {
  18262. console.info("onSuccessItem", fileItem, response, status, headers);
  18263. };
  18264. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18265. console.info("onErrorItem", fileItem, response, status, headers);
  18266. };
  18267. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18268. console.info("onCancelItem", fileItem, response, status, headers);
  18269. };
  18270. uploader.onCompleteItem = function (
  18271. fileItem,
  18272. response,
  18273. status,
  18274. headers
  18275. ) {
  18276. console.info("onCompleteItem", fileItem, response, status, headers);
  18277. };
  18278. uploader.onCompleteAll = function () {
  18279. console.info("onCompleteAll");
  18280. };
  18281. },
  18282. ],
  18283. });
  18284. //简易附件展示下载列表组件
  18285. formlyConfigProvider.setType({
  18286. name: "ui-dropFiles",
  18287. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18288. defaultOptions: function (options) {
  18289. return {
  18290. templateOptions: {
  18291. refresh: function (APIService, processInstanceId, data) {
  18292. return APIService.listAttachments(processInstanceId);
  18293. },
  18294. downloadUri: function (APIService, contentId) {
  18295. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18296. },
  18297. view: function (APIService, contentId) {
  18298. return APIService.attachmentsPreviewUrl(contentId);
  18299. },
  18300. download: function (APIService, contentId, item) {
  18301. var item = {
  18302. url: APIService.download(contentId),
  18303. headers: headers,
  18304. };
  18305. return item;
  18306. },
  18307. refreshDelay: 0,
  18308. },
  18309. };
  18310. },
  18311. controller: [
  18312. "$scope",
  18313. "$timeout",
  18314. "$modal",
  18315. "$rootScope",
  18316. "$http",
  18317. "up_down_file",
  18318. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18319. var _refreshDelayPromise;
  18320. // $scope.downloadUrl = function(contentId){
  18321. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18322. // };
  18323. $scope.download = function (contentId, filename, token) {
  18324. // console.log(contentId, filename, token)
  18325. //附件下载
  18326. var downUrl = up_down_file
  18327. .downloadAttachment("common/common/downloadAttachment", token)
  18328. .getRequestedUrl();
  18329. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18330. // console.log(downUrl)
  18331. var a = document.createElement("a");
  18332. a.href = downUrl;
  18333. a.target = "_blank";
  18334. a.download = filename;
  18335. document.body.appendChild(a);
  18336. a.click();
  18337. };
  18338. $scope.view = function (contentId, token, filename, type) {
  18339. $scope.options.templateOptions
  18340. .view($scope.options.templateOptions.ApiService, contentId)
  18341. .then(function (response) {
  18342. if (response.state == 200) {
  18343. window.open(response.previewUrl);
  18344. }
  18345. });
  18346. };
  18347. /**
  18348. * refresh
  18349. */
  18350. $scope._refresh = function (refreshAttr) {
  18351. $scope.attachments = [];
  18352. if (refreshAttr !== undefined) {
  18353. if (_refreshDelayPromise) {
  18354. $timeout.cancel(_refreshDelayPromise);
  18355. }
  18356. _refreshDelayPromise = $timeout(function () {
  18357. // 暂存附件
  18358. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18359. $scope.options.templateOptions
  18360. .refresh(
  18361. $scope.options.templateOptions.ApiService,
  18362. $scope.options.templateOptions.processInstanceId,
  18363. {
  18364. idx: 0,
  18365. sum: 1000,
  18366. }
  18367. )
  18368. .then(function (response) {
  18369. var myData =
  18370. $scope.options.templateOptions.Restangular.stripRestangular(
  18371. response
  18372. );
  18373. if (myData) {
  18374. for (var i = 0; i < myData.data.length; i++) {
  18375. $scope.attachments.push(myData.data[i]);
  18376. }
  18377. }
  18378. $scope.options.templateOptions
  18379. .refresh(
  18380. $scope.options.templateOptions.ApiService,
  18381. $scope.$parent.$parent.$parent.model.save_fileId,
  18382. {
  18383. idx: 0,
  18384. sum: 1000,
  18385. }
  18386. )
  18387. .then(function (response2) {
  18388. var myData2 =
  18389. $scope.options.templateOptions.Restangular.stripRestangular(
  18390. response2
  18391. );
  18392. if (myData2) {
  18393. for (var i = 0; i < myData2.data.length; i++) {
  18394. $scope.attachments.push(myData2.data[i]);
  18395. }
  18396. // 只展示除图片以外的附件
  18397. var a = [];
  18398. $scope.attachments.forEach((e) => {
  18399. if (
  18400. e.suffix == "jpeg" ||
  18401. e.suffix == "jpg" ||
  18402. e.suffix == "svg" ||
  18403. e.suffix == "png" ||
  18404. e.suffix == "bmp" ||
  18405. e.suffix == "gif" ||
  18406. e.suffix == "tif"
  18407. ) {
  18408. // $scope.imgs.push(e)
  18409. } else {
  18410. a.push(e);
  18411. }
  18412. });
  18413. $scope.attachments = a;
  18414. }
  18415. console.log($scope.attachments);
  18416. });
  18417. });
  18418. // 正常附件
  18419. } else {
  18420. $scope.options.templateOptions
  18421. .refresh(
  18422. $scope.options.templateOptions.ApiService,
  18423. $scope.options.templateOptions.processInstanceId,
  18424. {
  18425. idx: 0,
  18426. sum: 1000,
  18427. }
  18428. )
  18429. .then(function (response) {
  18430. var myData =
  18431. $scope.options.templateOptions.Restangular.stripRestangular(
  18432. response
  18433. );
  18434. if (myData) {
  18435. $scope.attachments = myData.data;
  18436. // 只展示除图片以外的附件
  18437. var a = [];
  18438. $scope.attachments.forEach((e) => {
  18439. if (
  18440. e.suffix == "jpeg" ||
  18441. e.suffix == "jpg" ||
  18442. e.suffix == "svg" ||
  18443. e.suffix == "png" ||
  18444. e.suffix == "bmp" ||
  18445. e.suffix == "gif" ||
  18446. e.suffix == "tif"
  18447. ) {
  18448. // $scope.imgs.push(e)
  18449. } else {
  18450. a.push(e);
  18451. }
  18452. });
  18453. $scope.attachments = a;
  18454. console.log($scope.attachments);
  18455. }
  18456. });
  18457. }
  18458. }, $scope.options.templateOptions.refreshDelay);
  18459. }
  18460. };
  18461. $scope._refresh({});
  18462. // $scope.attachments = $scope.model[$scope.options.key]
  18463. },
  18464. ],
  18465. });
  18466. //知识库附件上传
  18467. formlyConfigProvider.setType({
  18468. name: "ui-dropfielknow",
  18469. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18470. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18471. controller: [
  18472. "$scope",
  18473. "$rootScope",
  18474. function ($scope, $rootScope) {
  18475. if (angular.isUndefined($scope.form.dropState)) {
  18476. $scope.form.dropState = false;
  18477. }
  18478. //附件上传数据
  18479. var uploader = ($scope.uploader =
  18480. $scope.options.templateOptions.fileUploader);
  18481. //$scope.options.templateOptions.uploader();
  18482. // FILTERS
  18483. uploader.filters.push({
  18484. name: "customFilter",
  18485. fn: function (item /*{File|FileLikeObject}*/, options) {
  18486. return this.queue.length < 10;
  18487. },
  18488. });
  18489. $scope.dropfile = function (
  18490. APIService,
  18491. processInstanceId,
  18492. taskId,
  18493. userId
  18494. ) {
  18495. uploader.onBeforeUploadItem = function (item) {
  18496. angular.extend(item.headers, $rootScope.getSession());
  18497. item.url = APIService.upload(
  18498. processInstanceId,
  18499. taskId,
  18500. userId
  18501. ).getRequestedUrl();
  18502. item.formData.push({
  18503. fileName: item.file.name,
  18504. type: "solution",
  18505. solutionId: $scope.model.knowledge.id,
  18506. });
  18507. console.info("onBeforeUploadItem", item);
  18508. };
  18509. uploader.uploadAll();
  18510. };
  18511. // CALLBACKS
  18512. uploader.onWhenAddingFileFailed = function (
  18513. item /*{File|FileLikeObject}*/,
  18514. filter,
  18515. options
  18516. ) {
  18517. console.info("onWhenAddingFileFailed", item, filter, options);
  18518. };
  18519. uploader.onAfterAddingFile = function (fileItem) {
  18520. console.info("onAfterAddingFile", fileItem);
  18521. };
  18522. uploader.onAfterAddingAll = function (addedFileItems) {
  18523. console.info("onAfterAddingAll", addedFileItems);
  18524. };
  18525. uploader.onBeforeUploadItem = function (item) {
  18526. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18527. // // $scope.uploader.options.url();
  18528. // $scope.uploader.onBeforeUploadItem = function(item) {
  18529. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18530. // console.info('onBeforeUploadItem', item);
  18531. // };
  18532. // $scope.uploader.uploadAll();
  18533. // }
  18534. console.info("onBeforeUploadItem", item);
  18535. };
  18536. uploader.onProgressItem = function (fileItem, progress) {
  18537. console.info("onProgressItem", fileItem, progress);
  18538. };
  18539. uploader.onProgressAll = function (progress) {
  18540. console.info("onProgressAll", progress);
  18541. };
  18542. uploader.onSuccessItem = function (
  18543. fileItem,
  18544. response,
  18545. status,
  18546. headers
  18547. ) {
  18548. console.info("onSuccessItem", fileItem, response, status, headers);
  18549. };
  18550. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18551. console.info("onErrorItem", fileItem, response, status, headers);
  18552. };
  18553. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18554. console.info("onCancelItem", fileItem, response, status, headers);
  18555. };
  18556. uploader.onCompleteItem = function (
  18557. fileItem,
  18558. response,
  18559. status,
  18560. headers
  18561. ) {
  18562. console.info("onCompleteItem", fileItem, response, status, headers);
  18563. };
  18564. uploader.onCompleteAll = function () {
  18565. console.info("onCompleteAll");
  18566. };
  18567. },
  18568. ],
  18569. });
  18570. //知识库附件下载列表
  18571. formlyConfigProvider.setType({
  18572. name: "ui-dropfileknowledge",
  18573. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  18574. defaultOptions: function (options) {
  18575. return {
  18576. templateOptions: {
  18577. refresh: function (APIService, contentId, data) {
  18578. return APIService.fetchDataList(contentId, data);
  18579. },
  18580. downloadUri: function (APIService, contentId) {
  18581. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18582. },
  18583. download: function (APIService, contentId) {
  18584. return APIService.getSolutionDowpath(contentId);
  18585. },
  18586. view: function (attachmentId) {
  18587. // return APIService.attachmentsPreviewUrl(contentId);
  18588. },
  18589. refreshDelay: 0,
  18590. },
  18591. };
  18592. },
  18593. controller: [
  18594. "$scope",
  18595. "$timeout",
  18596. "$modal",
  18597. "$rootScope",
  18598. "api_solution",
  18599. "$http",
  18600. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  18601. var _refreshDelayPromise;
  18602. $scope.attachments = [];
  18603. $scope.downloadUrl = function (contentId) {
  18604. return (
  18605. $scope.options.templateOptions.downloadUri(
  18606. $scope.options.templateOptions.ApiService,
  18607. contentId
  18608. ) || "#"
  18609. );
  18610. };
  18611. $scope.download = function (contentId, filename) {
  18612. $http({
  18613. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  18614. contentId
  18615. ).getRequestedUrl(),
  18616. method: "GET",
  18617. headers: {
  18618. //'Content-type' : 'application/xls',
  18619. Accept: "*/*",
  18620. },
  18621. responseType: "arraybuffer",
  18622. })
  18623. .success(function (data, status, headers, config) {
  18624. var file = new Blob([data], {
  18625. type: "application/octet-stream",
  18626. });
  18627. //trick to download store a file having its URL
  18628. var fileURL = URL.createObjectURL(file);
  18629. var a = document.createElement("a");
  18630. a.href = fileURL;
  18631. a.target = "_blank";
  18632. a.download = filename;
  18633. document.body.appendChild(a);
  18634. a.click();
  18635. })
  18636. .error(function (data, status, headers, config) {
  18637. // console.log(data);
  18638. });
  18639. };
  18640. $scope.view = function (contentId, filename, attachment) {
  18641. var index = filename.indexOf(".");
  18642. var type = filename.substring(index + 1);
  18643. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18644. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  18645. // var modalInstance = $modal.open({
  18646. // backdrop: false,
  18647. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18648. // controller: function($scope, scope, $modalInstance, filename) {
  18649. // $scope.title = filename;
  18650. // $scope.imageurl = scope.imageurl;
  18651. // $scope.cancel = function() {
  18652. // $modalInstance.dismiss('cancel');
  18653. // }
  18654. // },
  18655. // resolve: {
  18656. // scope: function() {
  18657. // return $scope;
  18658. // },
  18659. // filename: function() {
  18660. // return filename;
  18661. // }
  18662. // }
  18663. // });
  18664. // event.preventDefault();
  18665. // } else {
  18666. // for (var i = 0; i < $scope.attachments.length; i++) {
  18667. // if ($scope.attachments[i].id == attachmentId) {
  18668. window.open(attachment.previewUrl);
  18669. // }
  18670. // }
  18671. // }
  18672. };
  18673. $scope._refresh = function (refreshAttr) {
  18674. if (refreshAttr !== undefined) {
  18675. if (_refreshDelayPromise) {
  18676. $timeout.cancel(_refreshDelayPromise);
  18677. }
  18678. _refreshDelayPromise = $timeout(function () {
  18679. $scope.options.templateOptions
  18680. .refresh($scope.options.templateOptions.ApiService, "file", {
  18681. file: {
  18682. solutionId: $scope.model.knowledge.id,
  18683. },
  18684. idx: "0",
  18685. sum: "1000",
  18686. })
  18687. .then(function (response) {
  18688. var myData =
  18689. $scope.options.templateOptions.Restangular.stripRestangular(
  18690. response
  18691. );
  18692. if (myData) {
  18693. $scope.attachments = myData.list;
  18694. // $scope.view = function(attachmentId) {
  18695. // for (var i = 0; i < $scope.attachments.length; i++) {
  18696. // if ($scope.attachments[i].id == attachmentId) {
  18697. // window.open($scope.attachments[i].previewUrl);
  18698. // // var modalInstance = $modal.open({
  18699. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  18700. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  18701. // // }
  18702. // // });
  18703. // }
  18704. // }
  18705. // };
  18706. }
  18707. });
  18708. }, $scope.options.templateOptions.refreshDelay);
  18709. }
  18710. };
  18711. $scope._refresh({});
  18712. // $scope.attachments = $scope.model[$scope.options.key]
  18713. },
  18714. ],
  18715. });
  18716. //附件图片下载
  18717. formlyConfigProvider.setType({
  18718. name: "ui-downimage",
  18719. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  18720. defaultOptions: function (options) {
  18721. return {
  18722. templateOptions: {
  18723. refresh: function (APIService, processInstanceId, data) {
  18724. return APIService.listAttachments(processInstanceId, data);
  18725. },
  18726. downloadUri: function (APIService, contentId) {
  18727. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18728. },
  18729. view: function (APIService, contentId) {
  18730. return APIService.attachmentsPreviewUrl(contentId);
  18731. },
  18732. download: function (APIService, contentId, item) {
  18733. var item = {
  18734. url: APIService.download(contentId),
  18735. headers: headers,
  18736. };
  18737. return item;
  18738. },
  18739. refreshDelay: 0,
  18740. },
  18741. };
  18742. },
  18743. controller: [
  18744. "$scope",
  18745. "$timeout",
  18746. "$rootScope",
  18747. "$http",
  18748. function ($scope, $timeout, $rootScope, $http) {
  18749. var _refreshDelayPromise;
  18750. // $scope.downloadUrl = function(contentId){
  18751. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18752. // };
  18753. $scope.download = function (contentId, filename) {
  18754. // var headers=
  18755. $http({
  18756. url: $scope.options.templateOptions.ApiService.download(
  18757. contentId
  18758. ).getRequestedUrl(),
  18759. method: "GET",
  18760. headers: {
  18761. //'Content-type' : 'application/xls',
  18762. Accept: "*/*",
  18763. },
  18764. responseType: "arraybuffer",
  18765. })
  18766. .success(function (data, status, headers, config) {
  18767. var file = new Blob([data], {
  18768. type: "application/octet-stream",
  18769. });
  18770. //trick to download store a file having its URL
  18771. var fileURL = URL.createObjectURL(file);
  18772. var a = document.createElement("a");
  18773. a.href = fileURL;
  18774. a.target = "_blank";
  18775. a.download = filename;
  18776. document.body.appendChild(a);
  18777. a.click();
  18778. })
  18779. .error(function (data, status, headers, config) {
  18780. // console.log(data);
  18781. });
  18782. };
  18783. $scope.view = function (contentId) {
  18784. $scope.imageurl =
  18785. $scope.options.templateOptions.ApiService.download(
  18786. contentId
  18787. ).getRequestedUrl();
  18788. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  18789. // if (response.state == 200) {
  18790. // window.open(response.previewUrl);
  18791. // }
  18792. // })
  18793. };
  18794. /**
  18795. * refresh
  18796. */
  18797. $scope._refresh = function (refreshAttr) {
  18798. if (refreshAttr !== undefined) {
  18799. if (_refreshDelayPromise) {
  18800. $timeout.cancel(_refreshDelayPromise);
  18801. }
  18802. _refreshDelayPromise = $timeout(function () {
  18803. $scope.options.templateOptions
  18804. .refresh(
  18805. $scope.options.templateOptions.ApiService,
  18806. $scope.options.templateOptions.processInstanceId,
  18807. {
  18808. idx: 0,
  18809. sum: 1000,
  18810. }
  18811. )
  18812. .then(function (response) {
  18813. var myData =
  18814. $scope.options.templateOptions.Restangular.stripRestangular(
  18815. response
  18816. );
  18817. if (myData) {
  18818. $scope.attachments = myData.data;
  18819. }
  18820. });
  18821. }, $scope.options.templateOptions.refreshDelay);
  18822. }
  18823. };
  18824. $scope._refresh({});
  18825. // $scope.attachments = $scope.model[$scope.options.key]
  18826. },
  18827. ],
  18828. });
  18829. //附件下载列表组件
  18830. formlyConfigProvider.setType({
  18831. name: "ui-dropfiletable",
  18832. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  18833. defaultOptions: function (options) {
  18834. return {
  18835. templateOptions: {
  18836. refresh: function (APIService, processInstanceId, data) {
  18837. return APIService.listAttachments(processInstanceId, data);
  18838. },
  18839. downloadUri: function (APIService, contentId) {
  18840. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18841. },
  18842. view: function (APIService, contentId) {
  18843. return APIService.attachmentsPreviewUrl(contentId);
  18844. },
  18845. download: function (APIService, contentId, item) {
  18846. var item = {
  18847. url: APIService.download(contentId),
  18848. headers: headers,
  18849. };
  18850. return item;
  18851. },
  18852. refreshDelay: 0,
  18853. },
  18854. };
  18855. },
  18856. controller: [
  18857. "$scope",
  18858. "$timeout",
  18859. "$modal",
  18860. "$rootScope",
  18861. "$http",
  18862. function ($scope, $timeout, $modal, $rootScope, $http) {
  18863. var _refreshDelayPromise;
  18864. // $scope.downloadUrl = function(contentId){
  18865. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18866. // };
  18867. $scope.download = function (contentId, filename) {
  18868. // var headers=
  18869. $http({
  18870. url: $scope.options.templateOptions.ApiService.download(
  18871. contentId
  18872. ).getRequestedUrl(),
  18873. method: "GET",
  18874. headers: {
  18875. //'Content-type' : 'application/xls',
  18876. Accept: "*/*",
  18877. },
  18878. responseType: "arraybuffer",
  18879. })
  18880. .success(function (data, status, headers, config) {
  18881. var file = new Blob([data], {
  18882. type: "application/octet-stream",
  18883. });
  18884. //trick to download store a file having its URL
  18885. var fileURL = URL.createObjectURL(file);
  18886. var a = document.createElement("a");
  18887. a.href = fileURL;
  18888. a.target = "_blank";
  18889. a.download = filename;
  18890. document.body.appendChild(a);
  18891. a.click();
  18892. })
  18893. .error(function (data, status, headers, config) {
  18894. // console.log(data);
  18895. });
  18896. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  18897. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  18898. // var file = new Blob([response], {
  18899. // type : 'application/octet-stream'
  18900. // });
  18901. // // var filename = filename;
  18902. // //var file = new Blob([response], {type: 'application/pdf'});
  18903. // var fileURL = URL.createObjectURL(file);
  18904. // var a = document.createElement('a');
  18905. // a.href = fileURL;
  18906. // a.target = '_blank';
  18907. // a.download = filename ;
  18908. // document.body.appendChild(a);
  18909. // a.click();
  18910. // })
  18911. };
  18912. $scope.view = function (contentId, token, filename, type) {
  18913. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18914. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  18915. // var modalInstance = $modal.open({
  18916. // backdrop: false,
  18917. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18918. // controller: function($scope, scope, $modalInstance, filename) {
  18919. // $scope.title = filename;
  18920. // $scope.imageurl = scope.imageurl;
  18921. // $scope.cancel = function() {
  18922. // $modalInstance.dismiss('cancel');
  18923. // }
  18924. // },
  18925. // resolve: {
  18926. // scope: function() {
  18927. // return $scope;
  18928. // },
  18929. // filename: function() {
  18930. // return filename;
  18931. // }
  18932. // }
  18933. // });
  18934. // event.preventDefault();
  18935. // } else {
  18936. $scope.options.templateOptions
  18937. .view($scope.options.templateOptions.ApiService, contentId)
  18938. .then(function (response) {
  18939. if (response.state == 200) {
  18940. window.open(response.previewUrl);
  18941. }
  18942. });
  18943. // }
  18944. };
  18945. /**
  18946. * refresh
  18947. */
  18948. $scope._refresh = function (refreshAttr) {
  18949. if (refreshAttr !== undefined) {
  18950. if (_refreshDelayPromise) {
  18951. $timeout.cancel(_refreshDelayPromise);
  18952. }
  18953. _refreshDelayPromise = $timeout(function () {
  18954. $scope.options.templateOptions
  18955. .refresh(
  18956. $scope.options.templateOptions.ApiService,
  18957. $scope.options.templateOptions.processInstanceId,
  18958. {
  18959. idx: 0,
  18960. sum: 1000,
  18961. }
  18962. )
  18963. .then(function (response) {
  18964. var myData =
  18965. $scope.options.templateOptions.Restangular.stripRestangular(
  18966. response
  18967. );
  18968. if (myData) {
  18969. $scope.attachments = myData.data;
  18970. }
  18971. });
  18972. }, $scope.options.templateOptions.refreshDelay);
  18973. }
  18974. };
  18975. $scope._refresh({});
  18976. // $scope.attachments = $scope.model[$scope.options.key]
  18977. },
  18978. ],
  18979. });
  18980. //微信附件下载列表组件
  18981. formlyConfigProvider.setType({
  18982. name: "ui-dropfilewechat",
  18983. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  18984. defaultOptions: function (options) {
  18985. return {
  18986. templateOptions: {
  18987. // refresh: function(APIService, processInstanceId, data) {
  18988. // return APIService.listAttachments(processInstanceId, data);
  18989. // },
  18990. // downloadUri: function(APIService, contentId) {
  18991. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  18992. // },
  18993. view: function (APIService, contentId) {
  18994. // return APIService.attachmentsPreviewUrl(contentId);
  18995. return APIService.attachmentsPreviewUrl(contentId);
  18996. },
  18997. download: function (APIService, contentId, item) {
  18998. var item = {
  18999. url: APIService.download(contentId),
  19000. headers: headers,
  19001. };
  19002. return item;
  19003. },
  19004. // download: function(APIService, contentId, item) {
  19005. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  19006. // return item;
  19007. // },
  19008. refreshDelay: 0,
  19009. },
  19010. };
  19011. },
  19012. controller: [
  19013. "$scope",
  19014. "$timeout",
  19015. "$modal",
  19016. "$stateParams",
  19017. "$rootScope",
  19018. "$http",
  19019. "api_wechatfile",
  19020. function (
  19021. $scope,
  19022. $timeout,
  19023. $modal,
  19024. $stateParams,
  19025. $rootScope,
  19026. $http,
  19027. api_wechatfile
  19028. ) {
  19029. var _refreshDelayPromise;
  19030. // $scope.downloadUrl = function(contentId){
  19031. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19032. // };
  19033. $scope.attachments = {};
  19034. $scope.previewUrl = "";
  19035. $scope.download = function (token, filename) {
  19036. // var headers=
  19037. console.log($scope);
  19038. $http({
  19039. url: $scope.options.templateOptions.ApiService.jry_download(
  19040. token
  19041. ).getRequestedUrl(),
  19042. method: "GET",
  19043. headers: {
  19044. //'Content-type' : 'application/xls',
  19045. Accept: "*/*",
  19046. },
  19047. responseType: "arraybuffer",
  19048. })
  19049. .success(function (data, status, headers, config) {
  19050. var file = new Blob([data], {
  19051. type: "application/octet-stream",
  19052. });
  19053. //trick to download store a file having its URL
  19054. var fileURL = URL.createObjectURL(file);
  19055. var a = document.createElement("a");
  19056. a.href = fileURL;
  19057. a.target = "_blank";
  19058. a.download = filename;
  19059. document.body.appendChild(a);
  19060. a.click();
  19061. })
  19062. .error(function (data, status, headers, config) {
  19063. // console.log(data);
  19064. });
  19065. };
  19066. $scope.view = function (contentId, token, filename, type, previewUrl) {
  19067. // if (type) {
  19068. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  19069. // var modalInstance = $modal.open({
  19070. // backdrop: false,
  19071. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19072. // controller: function($scope, scope, $modalInstance, filename) {
  19073. // $scope.title = filename;
  19074. // $scope.imageurl = scope.imageurl;
  19075. // $scope.cancel = function() {
  19076. // $modalInstance.dismiss('cancel');
  19077. // }
  19078. // },
  19079. // resolve: {
  19080. // scope: function() {
  19081. // return $scope;
  19082. // },
  19083. // filename: function() {
  19084. // return filename;
  19085. // }
  19086. // }
  19087. // });
  19088. // event.preventDefault();
  19089. // } else {
  19090. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  19091. // if (response.state == 200) {
  19092. // window.open(response.previewUrl);
  19093. // }
  19094. // })
  19095. window.open(previewUrl);
  19096. // }
  19097. };
  19098. /**
  19099. * refresh
  19100. */
  19101. $scope._refresh = function (refreshAttr) {
  19102. if (refreshAttr !== undefined) {
  19103. if (_refreshDelayPromise) {
  19104. $timeout.cancel(_refreshDelayPromise);
  19105. }
  19106. _refreshDelayPromise = $timeout(function () {
  19107. // console.log(JSON.parse($stateParams.model))
  19108. var incidentChart = {};
  19109. if ($stateParams.model) {
  19110. incidentChart = JSON.parse($stateParams.model).model;
  19111. }
  19112. $scope.options.templateOptions
  19113. .refresh(
  19114. $scope.options.templateOptions.ApiService,
  19115. $scope.model
  19116. )
  19117. .then(function (response) {
  19118. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19119. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19120. var myData =
  19121. $scope.options.templateOptions.Restangular.stripRestangular(
  19122. response
  19123. );
  19124. if (myData) {
  19125. $scope.attachments = myData.data;
  19126. }
  19127. });
  19128. }, $scope.options.templateOptions.refreshDelay);
  19129. }
  19130. };
  19131. $scope._refresh({});
  19132. // $scope.attachments = $scope.model[$scope.options.key]
  19133. },
  19134. ],
  19135. });
  19136. formlyConfigProvider.setType({
  19137. name: "ui-paralleltask",
  19138. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19139. defaultOptions: function (options) {
  19140. return {
  19141. templateOptions: {
  19142. refresh: function (APIService, processInstanceId, data) {
  19143. //return APIService.listAttachments(processInstanceId, data);
  19144. },
  19145. refreshDelay: 0,
  19146. },
  19147. };
  19148. },
  19149. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19150. });
  19151. //repeatSection
  19152. //
  19153. formlyConfigProvider.setType({
  19154. name: "ui-repeatSection",
  19155. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19156. defaultOptions: function (options) {
  19157. return {
  19158. templateOptions: {
  19159. unique: 1,
  19160. initDisplay: false,
  19161. },
  19162. };
  19163. },
  19164. controller: function ($scope) {
  19165. //$scope.options.templateOptions.unique;
  19166. $scope.formOptions = {
  19167. formState: $scope.formState,
  19168. };
  19169. $scope.addNew = addNew;
  19170. $scope.copyFields = copyFields;
  19171. function copyFields(fields) {
  19172. fields = angular.copy(fields);
  19173. addRandomIds(fields);
  19174. return fields;
  19175. }
  19176. function addNew() {
  19177. $scope.model[$scope.options.key] =
  19178. $scope.model[$scope.options.key] || [];
  19179. var repeatsection = $scope.model[$scope.options.key];
  19180. var lastSection = repeatsection[repeatsection.length - 1];
  19181. var newsection = {};
  19182. repeatsection.push(newsection);
  19183. }
  19184. function addRandomIds(fields) {
  19185. $scope.options.templateOptions.unique++;
  19186. angular.forEach(fields, function (field, index) {
  19187. if (field.fieldGroup) {
  19188. addRandomIds(field.fieldGroup);
  19189. return; // fieldGroups don't need an ID
  19190. }
  19191. if (field.templateOptions && field.templateOptions.fields) {
  19192. addRandomIds(field.templateOptions.fields);
  19193. }
  19194. field.id =
  19195. field.id ||
  19196. field.key +
  19197. "_" +
  19198. index +
  19199. "_" +
  19200. $scope.options.templateOptions.unique +
  19201. getRandomInt(0, 9999);
  19202. });
  19203. }
  19204. function getRandomInt(min, max) {
  19205. return Math.floor(Math.random() * (max - min)) + min;
  19206. }
  19207. if ($scope.options.templateOptions.initDisplay) {
  19208. addNew();
  19209. }
  19210. },
  19211. });
  19212. //时间轴任务列表组件
  19213. //cmdb控件
  19214. formlyConfigProvider.setType({
  19215. name: "ui-cmdb",
  19216. extends: "input",
  19217. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19218. defaultOptions: function (options) {
  19219. return {
  19220. templateOptions: {
  19221. onClick: function (size, options, modal, event, model) {
  19222. var modalInstance = modal.open({
  19223. templateUrl:
  19224. "assets/views/customform/tpl/cmdb-modal-content.html",
  19225. controller: function (
  19226. $scope,
  19227. $modalInstance,
  19228. title,
  19229. Restangular,
  19230. APIService,
  19231. ConfigDataService,
  19232. ConfigFormService,
  19233. SweetAlert,
  19234. Toaster,
  19235. api_wechatfile
  19236. ) {
  19237. var width = ($scope.width = 600);
  19238. var height = ($scope.height = 400);
  19239. var tree;
  19240. var d3 = window.d3;
  19241. $scope.my_tree_handler = function (branch) {
  19242. //var _ref;
  19243. var classify = ($scope.classify =
  19244. branch.prefix.toLowerCase() + branch.sign);
  19245. APIService.query({
  19246. sign: classify,
  19247. }).then(function (data) {
  19248. var myData = Restangular.stripRestangular(data);
  19249. // console.log(myData.data.node);
  19250. if (myData.data && myData.status == 200) {
  19251. var ret = myData.data;
  19252. redrawSvg(myData);
  19253. }
  19254. });
  19255. };
  19256. $scope.my_data = [];
  19257. function convertListToTree(data, treeMap) {
  19258. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19259. var root = null; //Initially set our loop to null
  19260. var parentNode = null;
  19261. //loop over data
  19262. for (var i = 0; i < data.length; i++) {
  19263. var datum = data[i];
  19264. //each node will have children, so let's give it a "children" poperty
  19265. datum.children = [];
  19266. //add an entry for this node to the map so that any future children can
  19267. //lookup the parent
  19268. idToNodeMap[datum.id] = datum;
  19269. //Does this node have a parent?
  19270. if (
  19271. typeof datum.parent === "undefined" ||
  19272. datum.parent == null
  19273. ) {
  19274. //Doesn't look like it, so this node is the root of the tree
  19275. root = datum;
  19276. treeMap[datum.id] = root;
  19277. } else {
  19278. //This node has a parent, so let's look it up using the id
  19279. parentNode = idToNodeMap[datum.parent.id];
  19280. //We don't need this property, so let's delete it.
  19281. delete datum.parent;
  19282. //Let's add the current node as a child of the parent node.
  19283. parentNode.children.push(datum);
  19284. }
  19285. }
  19286. return root;
  19287. }
  19288. function convertParentToChildList(data) {
  19289. var treeMap = {};
  19290. var list = [];
  19291. convertListToTree(data, treeMap);
  19292. angular.forEach(treeMap, function (item) {
  19293. list.push(item);
  19294. });
  19295. return list;
  19296. }
  19297. $scope.my_tree = tree = {};
  19298. $scope.try_async_load = function () {
  19299. $scope.my_data = [];
  19300. $scope.select_treedata = [];
  19301. $scope.doing_async = true;
  19302. ConfigDataService.fetchDataList("ciclassify", {
  19303. idx: 0,
  19304. sum: 100,
  19305. }).then(function (result) {
  19306. $scope.select_treedata = $scope.my_data =
  19307. convertParentToChildList(result["list"]);
  19308. $scope.doing_async = false;
  19309. });
  19310. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19311. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19312. // $scope.doing_async = false;
  19313. // });
  19314. };
  19315. $scope.select_treedata = [];
  19316. $scope.propTypeOptions = [];
  19317. $scope.try_async_load();
  19318. $scope.onFilterCallback = function (item) {
  19319. //console.log(item);
  19320. if (
  19321. angular.isDefined(item.children) &&
  19322. item.children.length >= 1
  19323. ) {
  19324. //not valid
  19325. } else {
  19326. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19327. $scope.cifilter_classic = tempclassify;
  19328. ConfigFormService.renderTabForm(tempclassify).then(
  19329. function (data) {
  19330. var myData = Restangular.stripRestangular(data);
  19331. $scope.propTypeOptions = myData;
  19332. }
  19333. );
  19334. }
  19335. };
  19336. $scope.onPropTypeChange = function (form) {
  19337. $scope.propOptions = form.fields;
  19338. };
  19339. $scope.onPropChange = function (prop) {
  19340. $scope.cifilter_prop = prop;
  19341. };
  19342. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19343. //if(searchKey!=null&&searchKey.length>1){
  19344. var searchData = {};
  19345. if (angular.isUndefined(propObj)) {
  19346. propObj = $scope.cifilter_prop;
  19347. }
  19348. if (angular.isUndefined(ciclassify)) {
  19349. ciclassify = $scope.cifilter_classic;
  19350. }
  19351. searchData["sign"] = ciclassify;
  19352. if (angular.isDefined(propObj)) {
  19353. searchData[propObj.key] = searchKey;
  19354. }
  19355. APIService.query(searchData).then(function (response) {
  19356. var data = Restangular.stripRestangular(response);
  19357. //此处不清空nodes
  19358. var node = data.data.node;
  19359. var tempNode = [];
  19360. //nodes 或者links 要去重
  19361. for (var i = 0; i < node.length; i++) {
  19362. var tmp = 0;
  19363. for (var j = 0; j < nodes.length; j++) {
  19364. if (node[i].uuid == nodes[j].uuid) {
  19365. tmp++;
  19366. break;
  19367. }
  19368. }
  19369. if (tmp == 0) {
  19370. tempNode.push(node[i]);
  19371. }
  19372. }
  19373. for (var i = 0; i < tempNode.length; i++) {
  19374. //nodes 不清空
  19375. nodes.push(tempNode[i]);
  19376. }
  19377. restart();
  19378. });
  19379. };
  19380. $scope.refresh = function () {
  19381. nodes.length = 0;
  19382. links.length = 0;
  19383. restart();
  19384. };
  19385. $scope.traversal = function () {
  19386. if ($scope.selected_node == null) {
  19387. SweetAlert.swal({
  19388. title: "错误的操作!",
  19389. text: "没有配置项被选中!",
  19390. type: "error",
  19391. });
  19392. } else {
  19393. var uuid = $scope.selected_node.uuid;
  19394. APIService.traversal(uuid).then(function (response) {
  19395. var d = response.data;
  19396. var node = d.node;
  19397. var link = d.edge;
  19398. var tempNode = [];
  19399. var tempLink = [];
  19400. //nodes 或者links 要去重
  19401. for (var i = 0; i < node.length; i++) {
  19402. var tmp = 0;
  19403. for (var j = 0; j < nodes.length; j++) {
  19404. if (node[i].id == nodes[j].id) {
  19405. tmp++;
  19406. break;
  19407. }
  19408. }
  19409. if (tmp == 0) {
  19410. tempNode.push(node[i]);
  19411. }
  19412. }
  19413. for (var i = 0; i < link.length; i++) {
  19414. var tmp = 0;
  19415. for (var j = 0; j < links.length; j++) {
  19416. if (link[i].id == links[j].id) {
  19417. tmp++;
  19418. break;
  19419. }
  19420. }
  19421. if (tmp == 0) {
  19422. tempLink.push(link[i]);
  19423. }
  19424. }
  19425. //数据写入页面
  19426. for (var i = 0; i < tempNode.length; i++) {
  19427. //nodes 不清空
  19428. nodes.push(tempNode[i]);
  19429. }
  19430. for (var i = 0; i < tempLink.length; i++) {
  19431. //link 不清空
  19432. links.push(tempLink[i]);
  19433. }
  19434. //links转换
  19435. for (var i = 0; i < links.length; i++) {
  19436. for (var j = 0; j < nodes.length; j++) {
  19437. if (links[i].source == nodes[j].id) {
  19438. links[i].source = nodes[j];
  19439. }
  19440. if (links[i].target == nodes[j].id) {
  19441. links[i].target = nodes[j];
  19442. }
  19443. }
  19444. }
  19445. restart();
  19446. });
  19447. }
  19448. };
  19449. var svg;
  19450. var force;
  19451. var drag_line, path, circle;
  19452. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  19453. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19454. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19455. var nodes = [],
  19456. links = [];
  19457. var treeNodes = [];
  19458. //读取labels (node)
  19459. var labels = [];
  19460. function redrawSvg(json) {
  19461. nodes.length = 0; //先清空
  19462. links.length = 0;
  19463. var data = json.data;
  19464. for (var i = 0; i < data.node.length; i++) {
  19465. nodes.push(data.node[i]);
  19466. }
  19467. restart();
  19468. }
  19469. //读取status (节点 连线)
  19470. var statuses = [];
  19471. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  19472. // if (result && result.status == 200) {
  19473. // d3.select('#nodeStatus').selectAll('option')
  19474. // .data(statuses).enter()
  19475. // .append('option')
  19476. // .attr('value', function(d) { return d.code; })
  19477. // .html(function(d) { return d.desc; });
  19478. // } else {
  19479. // SweetAlert.swal({
  19480. // title: "提示!",
  19481. // text: "服务器请求异常!",
  19482. // type: "error"
  19483. // });
  19484. // }
  19485. // });
  19486. api_wechatfile
  19487. .getDictionary({
  19488. key: "cmdb_status",
  19489. type: "list",
  19490. })
  19491. .then(function (result) {
  19492. if (result) {
  19493. d3.select("#nodeStatus")
  19494. .selectAll("option")
  19495. .data(statuses)
  19496. .enter()
  19497. .append("option")
  19498. .attr("value", function (d) {
  19499. return d.code;
  19500. })
  19501. .html(function (d) {
  19502. return d.desc;
  19503. });
  19504. } else {
  19505. SweetAlert.swal({
  19506. title: "提示!",
  19507. text: "服务器请求异常!",
  19508. type: "error",
  19509. });
  19510. }
  19511. });
  19512. //查询relationship_type表 name 为表里的type,label为显示值
  19513. var linkType = [];
  19514. function fetchEdgeTypes() {
  19515. ConfigDataService.fetchDataList("ciedgetype", {
  19516. idx: 0,
  19517. sum: 100,
  19518. }).then(function (response) {
  19519. if (response) {
  19520. if (response["list"]) {
  19521. linkType = response["list"];
  19522. // d3.select('#linkName').selectAll('option')
  19523. // .data(linkType).enter()
  19524. // .append('option')
  19525. // .attr('value',function(d){return d.type;})
  19526. // .html(function(d){ return d.label;});
  19527. } else {
  19528. SweetAlert.swal({
  19529. title: "提示!",
  19530. text: "服务器请求异常!",
  19531. type: "error",
  19532. });
  19533. }
  19534. } else {
  19535. SweetAlert.swal({
  19536. title: "提示!",
  19537. text: "服务器请求异常!",
  19538. type: "error",
  19539. });
  19540. }
  19541. });
  19542. }
  19543. // fetchEdgeTypes();
  19544. /*
  19545. // init D3 force layout
  19546. var force = d3.layout.force()
  19547. .nodes(nodes)
  19548. .links(links)
  19549. .size([width, height])
  19550. .gravity(.05)
  19551. .linkDistance(150)
  19552. .linkStrength(2)
  19553. .charge(-500)
  19554. .on('tick', tick);
  19555. // define arrow markers for graph links
  19556. svg.append('svg:defs').append('svg:marker')
  19557. .attr('id', 'end-arrow')
  19558. .attr('viewBox', '0 -5 10 10')
  19559. .attr('refX', 6)
  19560. .attr('markerWidth', 3)
  19561. .attr('markerHeight', 3)
  19562. .attr('orient', 'auto')
  19563. .append('svg:path')
  19564. .attr('d', 'M0,-5L10,0L0,5')
  19565. .attr('fill', '#000');
  19566. svg.append('svg:defs').append('svg:marker')
  19567. .attr('id', 'start-arrow')
  19568. .attr('viewBox', '0 -5 10 10')
  19569. .attr('refX', 4)
  19570. .attr('markerWidth', 3)
  19571. .attr('markerHeight', 3)
  19572. .attr('orient', 'auto')
  19573. .append('svg:path')
  19574. .attr('d', 'M10,-5L0,0L10,5')
  19575. .attr('fill', '#000');
  19576. // line displayed when dragging new nodes
  19577. var drag_line = svg.append('svg:path')
  19578. .attr('class', 'link dragline hidden')
  19579. .attr('d', 'M0,0L0,0');
  19580. // handles to link and node element groups
  19581. //(1)var path = svg.append('svg:g').selectAll('g')
  19582. var path = svg.append('svg:g').selectAll('g'),
  19583. circle = svg.append('svg:g').selectAll('g');
  19584. */
  19585. // mouse event vars
  19586. var selected_node = null,
  19587. selected_link = null,
  19588. mousedown_link = null,
  19589. mousedown_node = null,
  19590. mouseup_node = null;
  19591. function resetMouseVars() {
  19592. mousedown_node = null;
  19593. mouseup_node = null;
  19594. mousedown_link = null;
  19595. }
  19596. // update force layout (called automatically each iteration)
  19597. function tick() {
  19598. // draw directed edges with proper padding from node centers
  19599. path.selectAll("path").attr("d", function (d) {
  19600. var deltaX = d.target.x - d.source.x,
  19601. deltaY = d.target.y - d.source.y,
  19602. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  19603. normX = deltaX / dist,
  19604. normY = deltaY / dist,
  19605. sourcePadding = d.left ? 27 : 22,
  19606. targetPadding = d.right ? 27 : 22,
  19607. sourceX = d.source.x + sourcePadding * normX,
  19608. sourceY = d.source.y + sourcePadding * normY,
  19609. targetX = d.target.x - targetPadding * normX,
  19610. targetY = d.target.y - targetPadding * normY;
  19611. return (
  19612. "M" +
  19613. sourceX +
  19614. "," +
  19615. sourceY +
  19616. "L" +
  19617. targetX +
  19618. "," +
  19619. targetY
  19620. );
  19621. });
  19622. circle.attr("transform", function (d) {
  19623. return "translate(" + d.x + "," + d.y + ")";
  19624. });
  19625. }
  19626. // update graph (called when needed)
  19627. function restart() {
  19628. //绑定link 数据
  19629. path.datum(links);
  19630. // path (link) group
  19631. path = path.data(links, function (d) {
  19632. return d.id;
  19633. });
  19634. var p = path.enter().append("svg:g");
  19635. //update existing links
  19636. path
  19637. .selectAll("path")
  19638. .classed("selected", function (d) {
  19639. return d === selected_link;
  19640. })
  19641. .style("marker-start", function (d) {
  19642. return d.left ? "url(#start-arrow)" : "";
  19643. })
  19644. .style("marker-end", function (d) {
  19645. return d.right ? "url(#end-arrow)" : "";
  19646. });
  19647. // add new links
  19648. p.append("svg:path")
  19649. .attr("class", "link")
  19650. .attr("id", function (d) {
  19651. return "path_" + d.id;
  19652. })
  19653. // .attr('startOffset', '0%')
  19654. .classed("selected", function (d) {
  19655. return d === selected_link;
  19656. })
  19657. .style("marker-start", function (d) {
  19658. return d.left ? "url(#start-arrow)" : "";
  19659. })
  19660. .style("marker-end", function (d) {
  19661. return d.right ? "url(#end-arrow)" : "";
  19662. })
  19663. .on("mousedown", function (d) {
  19664. if (d3.event.ctrlKey) return;
  19665. //去除没有提交的连线
  19666. for (var i = 0; i < links.length; i++) {
  19667. if (links[i].id == -1 && d.id != -1) {
  19668. links.splice(i, 1);
  19669. }
  19670. }
  19671. // select link
  19672. mousedown_link = d;
  19673. if (mousedown_link === selected_link) {
  19674. selected_link = $scope.selected_link = null;
  19675. selected_node = $scope.selected_node = null;
  19676. // d3.select("#linkDetail").attr('style','display:none');
  19677. //hideLinkForm(true);//return ;
  19678. } else {
  19679. selected_link = $scope.selected_link = mousedown_link;
  19680. selected_node = $scope.selected_node = null;
  19681. }
  19682. selected_node = $scope.selected_node = null;
  19683. restart();
  19684. });
  19685. p.append("svg:text")
  19686. .attr("x", 30)
  19687. .attr("y", 20)
  19688. .attr("class", "fontM")
  19689. .append("textPath")
  19690. .attr("xlink:xlink:href", function (d, i) {
  19691. return "#path_" + d.id;
  19692. })
  19693. .html(function (d) {
  19694. for (var i = 0; i < linkType.length; i++) {
  19695. if (linkType[i].type == d.name) {
  19696. return linkType[i].label;
  19697. }
  19698. }
  19699. });
  19700. // remove old links
  19701. path.exit().remove();
  19702. // circle (node) group
  19703. // NB: the function arg is crucial here! nodes are known by id, not by index!
  19704. circle.datum(nodes);
  19705. circle = circle.data(nodes, function (d) {
  19706. return d.id;
  19707. });
  19708. // update existing nodes (reflexive & selected visual states)
  19709. circle
  19710. .selectAll("circle")
  19711. .style("fill", function (d) {
  19712. return d === selected_node
  19713. ? d3.rgb(colors(d.label)).brighter().toString()
  19714. : colors(d.label);
  19715. })
  19716. .style("fill-opacity", 0.75) // add by xi
  19717. .classed("reflexive", function (d) {
  19718. return d.reflexive;
  19719. });
  19720. // add new nodes
  19721. var g = circle.enter().append("svg:g");
  19722. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  19723. //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');
  19724. g.append("svg:circle")
  19725. .attr("r", 24)
  19726. .style("fill", function (d) {
  19727. return d === selected_node
  19728. ? "rgb(153,153,153)"
  19729. : "rgb(255,255,255)";
  19730. })
  19731. .style("stroke", function (d) {
  19732. return d3.rgb(colors(d.label)).darker().toString();
  19733. })
  19734. .style("stroke-width", "2");
  19735. g.append("svg:circle")
  19736. .attr("class", "node")
  19737. .attr("r", 18)
  19738. .style("fill", function (d) {
  19739. return d === selected_node
  19740. ? d3.rgb(colors(d.label)).brighter().toString()
  19741. : colors(d.label);
  19742. })
  19743. .style("stroke", function (d) {
  19744. return d3.rgb(colors(d.label)).darker().toString();
  19745. })
  19746. .style("fill-opacity", 0.25) //add by xj
  19747. .style("stroke-opacity", 0.5) //add by xj
  19748. .classed("reflexive", function (d) {
  19749. return d.reflexive;
  19750. });
  19751. g.on("mouseover", function (d) {
  19752. //if(!mousedown_node || d === mousedown_node) return;
  19753. // enlarge target node
  19754. //d3.select(this).attr('transform', 'scale(1.1)');
  19755. })
  19756. .on("mouseout", function (d) {
  19757. //if(!mousedown_node || d === mousedown_node) return;
  19758. // unenlarge target node
  19759. //d3.select(this).attr('transform', '');
  19760. })
  19761. .on("mousedown", function (d) {
  19762. if (d3.event.ctrlKey) return;
  19763. //hideLinkForm(true);
  19764. //去除没有提交的连线
  19765. for (var i = 0; i < links.length; i++) {
  19766. if (links[i].id == -1) {
  19767. links.splice(i, 1);
  19768. }
  19769. }
  19770. // select node
  19771. mousedown_node = d;
  19772. if (mousedown_node === selected_node) {
  19773. selected_node = $scope.selected_node = null;
  19774. } else {
  19775. selected_node = $scope.selected_node = mousedown_node;
  19776. selected_link = $scope.selected_link = null;
  19777. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  19778. APIService.findRefById(selected_node.id).then(function (
  19779. result
  19780. ) {
  19781. var d = result.data;
  19782. var node = d.node;
  19783. var link = d.edge;
  19784. var tempNode = [];
  19785. var tempLink = [];
  19786. //nodes 或者links 要去重
  19787. for (var i = 0; i < node.length; i++) {
  19788. var tmp = 0;
  19789. for (var j = 0; j < nodes.length; j++) {
  19790. if (node[i].id == nodes[j].id) {
  19791. tmp++;
  19792. break;
  19793. }
  19794. }
  19795. if (tmp == 0) {
  19796. tempNode.push(node[i]);
  19797. }
  19798. }
  19799. for (var i = 0; i < link.length; i++) {
  19800. var tmp = 0;
  19801. for (var j = 0; j < links.length; j++) {
  19802. if (link[i].id == links[j].id) {
  19803. tmp++;
  19804. break;
  19805. }
  19806. }
  19807. if (tmp == 0) {
  19808. tempLink.push(link[i]);
  19809. }
  19810. }
  19811. //数据写入页面
  19812. for (var i = 0; i < tempNode.length; i++) {
  19813. //nodes 不清空
  19814. nodes.push(tempNode[i]);
  19815. }
  19816. for (var i = 0; i < tempLink.length; i++) {
  19817. //link 不清空
  19818. links.push(tempLink[i]);
  19819. }
  19820. //links转换
  19821. for (var i = 0; i < links.length; i++) {
  19822. for (var j = 0; j < nodes.length; j++) {
  19823. if (links[i].source == nodes[j].id) {
  19824. links[i].source = nodes[j];
  19825. }
  19826. if (links[i].target == nodes[j].id) {
  19827. links[i].target = nodes[j];
  19828. }
  19829. }
  19830. }
  19831. restart();
  19832. });
  19833. }
  19834. // reposition drag line
  19835. drag_line
  19836. .style("marker-end", "url(#end-arrow)")
  19837. .classed("hidden", false)
  19838. .attr(
  19839. "d",
  19840. "M" +
  19841. mousedown_node.x +
  19842. "," +
  19843. mousedown_node.y +
  19844. "L" +
  19845. mousedown_node.x +
  19846. "," +
  19847. mousedown_node.y
  19848. );
  19849. restart();
  19850. })
  19851. .on("mouseup", function (d) {
  19852. if (!mousedown_node) return;
  19853. });
  19854. // show node name
  19855. g.append("svg:text")
  19856. .attr("x", 0)
  19857. .attr("y", 34)
  19858. .attr("class", "id")
  19859. .text(function (d) {
  19860. return d.name;
  19861. }); //TODO 改为 d.name
  19862. //设置图片
  19863. g.append("svg:foreignObject")
  19864. .attr("width", 32)
  19865. .attr("height", 32)
  19866. .attr("x", "-16px")
  19867. .attr("y", "-11px")
  19868. .html(function (d) {
  19869. for (var i = 0; i < labels.length; i++) {
  19870. if (d.label == labels[i].sign) {
  19871. return (
  19872. '<i class="icon iconfont">' +
  19873. labels[i].iconname +
  19874. "</i>"
  19875. );
  19876. }
  19877. }
  19878. });
  19879. // remove old nodes
  19880. circle.exit().remove();
  19881. // set the graph in motion
  19882. force.start();
  19883. }
  19884. function mousedown() {
  19885. // prevent I-bar on drag
  19886. //d3.event.preventDefault();
  19887. // because :active only works in WebKit?
  19888. svg.classed("active", true);
  19889. if (mousedown_node) {
  19890. viewNode(mousedown_node);
  19891. }
  19892. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  19893. return;
  19894. restart();
  19895. }
  19896. function mousemove() {
  19897. if (!mousedown_node) return;
  19898. // update drag line
  19899. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  19900. //restart();
  19901. }
  19902. function mouseup() {
  19903. if (mousedown_node) {
  19904. // hide drag line
  19905. drag_line.classed("hidden", true).style("marker-end", "");
  19906. }
  19907. // because :active only works in WebKit?
  19908. svg.classed("active", false);
  19909. // clear mouse event vars
  19910. resetMouseVars();
  19911. }
  19912. function spliceLinksForNode(node) {
  19913. var toSplice = links.filter(function (l) {
  19914. return l.source === node || l.target === node;
  19915. });
  19916. toSplice.map(function (l) {
  19917. links.splice(links.indexOf(l), 1);
  19918. });
  19919. }
  19920. // only respond once per keydown
  19921. var lastKeyDown = -1;
  19922. function keydown() {
  19923. //d3.event.preventDefault();
  19924. if (lastKeyDown !== -1) return;
  19925. lastKeyDown = d3.event.keyCode;
  19926. // ctrl
  19927. if (d3.event.keyCode === 17) {
  19928. circle.call(force.drag);
  19929. svg.classed("ctrl", true);
  19930. }
  19931. if (!selected_node && !selected_link) return;
  19932. switch (d3.event.keyCode) {
  19933. case 8: // backspace
  19934. case 66: // B
  19935. if (selected_link) {
  19936. // set link direction to both left and right
  19937. selected_link.left = true;
  19938. selected_link.right = true;
  19939. }
  19940. restart();
  19941. break;
  19942. case 76: // L
  19943. if (selected_link) {
  19944. // set link direction to left only
  19945. selected_link.left = true;
  19946. selected_link.right = false;
  19947. }
  19948. restart();
  19949. break;
  19950. case 82: // R
  19951. if (selected_node) {
  19952. // toggle node reflexivity
  19953. selected_node.reflexive = !selected_node.reflexive;
  19954. } else if (selected_link) {
  19955. // set link direction to right only
  19956. selected_link.left = false;
  19957. selected_link.right = true;
  19958. }
  19959. restart();
  19960. break;
  19961. }
  19962. }
  19963. function keyup() {
  19964. lastKeyDown = -1;
  19965. // ctrl
  19966. if (d3.event.keyCode === 17) {
  19967. circle
  19968. .on("mousedown.drag", null)
  19969. .on("touchstart.drag", null);
  19970. svg.classed("ctrl", false);
  19971. }
  19972. }
  19973. function viewNode(node) {
  19974. // console.log(svg.attr('left'));
  19975. //var el = angular.element('div.modal-dialog')[0];
  19976. var title =
  19977. $scope.selected_node.name +
  19978. "-[" +
  19979. $scope.selected_node.uuid +
  19980. "]";
  19981. if (!$scope.selected_node.props.state) {
  19982. $scope.selected_node.props.state = "空";
  19983. } else if ($scope.selected_node.props.state) {
  19984. if ($scope.selected_node.props.state == "1") {
  19985. $scope.selected_node.props.state = "未审核";
  19986. } else if ($scope.selected_node.props.state == "2") {
  19987. $scope.selected_node.props.state = "已审核";
  19988. } else if ($scope.selected_node.props.state == "3") {
  19989. $scope.selected_node.props.state = "不匹配";
  19990. } else if ($scope.selected_node.props.state == "4") {
  19991. $scope.selected_node.props.state = "丢失";
  19992. }
  19993. }
  19994. if (!$scope.selected_node.name) {
  19995. $scope.selected_node.name = "空";
  19996. }
  19997. if (!$scope.selected_node.status) {
  19998. $scope.selected_node.statu = "空";
  19999. }
  20000. if (!$scope.selected_node.props.useradmin) {
  20001. $scope.selected_node.props.useradmin = "空";
  20002. }
  20003. Toaster.pop({
  20004. // type: 'info',
  20005. // title: title,
  20006. body:
  20007. "<br/><p>搜索代码:" +
  20008. $scope.selected_node.uuid +
  20009. "</p>" +
  20010. "<p>配置标题:" +
  20011. $scope.selected_node.name +
  20012. "</p>" +
  20013. "<p>状态:" +
  20014. $scope.selected_node.status +
  20015. "</p>" +
  20016. "<p>审核状态:" +
  20017. $scope.selected_node.props.state +
  20018. "</p>" +
  20019. "<p>维护人员:" +
  20020. $scope.selected_node.props.useradmin +
  20021. "</p>",
  20022. bodyOutputType: "trustedHtml",
  20023. timeout: 3000,
  20024. });
  20025. }
  20026. //GT 颜色与数值对照表
  20027. function colors(sign) {
  20028. //num=num>20?num%20:parseInt(num);
  20029. for (var i = 0; i < labels.length; i++) {
  20030. var entity = labels[i];
  20031. if (sign == entity.sign) {
  20032. return entity.color;
  20033. }
  20034. if (i == labels.length - 1 && sign != entity.sign) {
  20035. return "#ffeeee";
  20036. }
  20037. }
  20038. }
  20039. $scope.init = function () {
  20040. svg = d3
  20041. .select("#cmdbSVG")
  20042. .append("svg")
  20043. .attr("width", width)
  20044. .attr("height", height);
  20045. // init D3 force layout
  20046. force = d3.layout
  20047. .force()
  20048. .nodes(nodes)
  20049. .links(links)
  20050. .size([width, height])
  20051. .gravity(0.05)
  20052. .linkDistance(150)
  20053. .linkStrength(2)
  20054. .charge(-500)
  20055. .on("tick", tick);
  20056. // define arrow markers for graph links
  20057. svg
  20058. .append("svg:defs")
  20059. .append("svg:marker")
  20060. .attr("id", "end-arrow")
  20061. .attr("viewBox", "0 -5 10 10")
  20062. .attr("refX", 6)
  20063. .attr("markerWidth", 3)
  20064. .attr("markerHeight", 3)
  20065. .attr("orient", "auto")
  20066. .append("svg:path")
  20067. .attr("d", "M0,-5L10,0L0,5")
  20068. .attr("fill", "#000");
  20069. svg
  20070. .append("svg:defs")
  20071. .append("svg:marker")
  20072. .attr("id", "start-arrow")
  20073. .attr("viewBox", "0 -5 10 10")
  20074. .attr("refX", 4)
  20075. .attr("markerWidth", 3)
  20076. .attr("markerHeight", 3)
  20077. .attr("orient", "auto")
  20078. .append("svg:path")
  20079. .attr("d", "M10,-5L0,0L10,5")
  20080. .attr("fill", "#000");
  20081. // line displayed when dragging new nodes
  20082. drag_line = svg
  20083. .append("svg:path")
  20084. .attr("class", "link dragline hidden")
  20085. .attr("d", "M0,0L0,0");
  20086. // handles to link and node element groups
  20087. //(1)var path = svg.append('svg:g').selectAll('g')
  20088. path = svg.append("svg:g").selectAll("g");
  20089. circle = svg.append("svg:g").selectAll("g");
  20090. svg
  20091. .on("mousedown", mousedown)
  20092. .on("mousemove", mousemove)
  20093. .on("mouseup", mouseup);
  20094. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  20095. };
  20096. var CI = {};
  20097. window.CI = CI;
  20098. $scope.ok = function () {
  20099. $modalInstance.close($scope.selected_node);
  20100. };
  20101. $scope.cancel = function () {
  20102. $modalInstance.dismiss("cancel");
  20103. };
  20104. },
  20105. size: size,
  20106. resolve: {
  20107. title: function () {
  20108. return options.templateOptions.title;
  20109. },
  20110. Restangular: function () {
  20111. return options.templateOptions.Restangular;
  20112. },
  20113. APIService: function () {
  20114. return options.templateOptions.ApiService;
  20115. },
  20116. ConfigDataService: function () {
  20117. return options.templateOptions.ConfigDataService;
  20118. },
  20119. ConfigFormService: function () {
  20120. return options.templateOptions.ConfigFormService;
  20121. },
  20122. SweetAlert: function () {
  20123. return options.templateOptions.Alert;
  20124. },
  20125. Toaster: function () {
  20126. return options.templateOptions.toaster;
  20127. },
  20128. },
  20129. });
  20130. modalInstance.result.then(
  20131. function (selectedItem) {
  20132. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20133. },
  20134. function () {
  20135. //console.log('Modal dismissed at: ' + new Date());
  20136. }
  20137. );
  20138. },
  20139. },
  20140. };
  20141. },
  20142. controller: [
  20143. "$scope",
  20144. function ($scope) {
  20145. // setTimeout(function(){
  20146. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20147. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20148. // if(modelData.status==200){
  20149. // $scope.model[$scope.options.key] = modelData.data;
  20150. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20151. // }
  20152. // });
  20153. // },1000);
  20154. },
  20155. ],
  20156. });
  20157. });
  20158. appFormly.run(function (formlyConfig, $parse) {
  20159. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20160. var removeOnHideTransformer = function (fields, model) {
  20161. return fields.map(function (field) {
  20162. if (
  20163. field.hideExpression &&
  20164. (!field.data || !field.data.dontRemoveOnHidden)
  20165. ) {
  20166. addFieldRemoveOnHideWatcher(field);
  20167. }
  20168. if (field.type == "ui-title") {
  20169. addFieldRemoveOnHideWatcher(field);
  20170. }
  20171. return field;
  20172. });
  20173. };
  20174. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20175. function addFieldRemoveOnHideWatcher(field) {
  20176. var watcher = getWatcher();
  20177. if (field.watcher) {
  20178. if (!angular.isArray(field.watcher)) {
  20179. field.watcher = [field.watcher];
  20180. }
  20181. field.watcher.push(watcher);
  20182. } else {
  20183. field.watcher = watcher;
  20184. }
  20185. }
  20186. function getWatcher() {
  20187. return {
  20188. expression: function (field) {
  20189. return field.hide;
  20190. },
  20191. listener: function (field, newHide, oldHide, scope) {
  20192. if (field.hide) {
  20193. if (field.templateOptions.pkey) {
  20194. if (field.key == "transferuser") {
  20195. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20196. scope.model,
  20197. undefined
  20198. );
  20199. }
  20200. } else {
  20201. $parse(field.key).assign(scope.model, undefined);
  20202. }
  20203. }
  20204. if (field.type == "ui-title") {
  20205. $parse(field.key).assign(scope.model, undefined);
  20206. }
  20207. },
  20208. };
  20209. }
  20210. });
  20211. appFormly.controller("CustomformCtrl", [
  20212. "$rootScope",
  20213. "$scope",
  20214. "$parse",
  20215. "$injector",
  20216. "$http",
  20217. "$q",
  20218. "$state",
  20219. "$stateParams",
  20220. "$modal",
  20221. "$timeout",
  20222. "$interval",
  20223. "SweetAlert",
  20224. "FileUploader",
  20225. "i18nService",
  20226. "Restangular",
  20227. "UserRestangular",
  20228. "BpmRestangular",
  20229. "WechatRestangular",
  20230. "api_configure_form",
  20231. "api_bpm_domain",
  20232. "api_bpm_domain1",
  20233. "api_bpm",
  20234. "api_bpm_data",
  20235. "api_user_data",
  20236. "api_statistic",
  20237. "up_down_file",
  20238. "fileReader",
  20239. "api_wechatfile",
  20240. function (
  20241. $rootScope,
  20242. $scope,
  20243. $parse,
  20244. $injector,
  20245. $http,
  20246. $q,
  20247. $state,
  20248. $stateParams,
  20249. $modal,
  20250. $timeout,
  20251. $interval,
  20252. SweetAlert,
  20253. FileUploader,
  20254. i18nService,
  20255. Restangular,
  20256. UserRestangular,
  20257. BpmRestangular,
  20258. WechatRestangular,
  20259. api_configure_form,
  20260. api_bpm_domain,
  20261. api_bpm_domain1,
  20262. api_bpm,
  20263. api_bpm_data,
  20264. api_user_data,
  20265. api_statistic,
  20266. up_down_file,
  20267. fileReader,
  20268. api_wechatfile
  20269. ) {
  20270. //console.log($parse('Restangular')($scope));
  20271. //console.log($injector.get('Restangular'));
  20272. //console.log($stateParams);
  20273. //保存报修主体
  20274. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20275. $scope.imgUrlList = [];
  20276. $scope.uploadimg_del = function () {
  20277. console.log(123);
  20278. };
  20279. var vm = this;
  20280. vm.options = {};
  20281. vm.exampleTitle = ["expressionProperties", "model property"];
  20282. vm.fields = [];
  20283. vm.model = {};
  20284. $scope.langs = i18nService.getAllLangs();
  20285. $scope.lang = "zh-cn";
  20286. i18nService.setCurrentLang($scope.lang);
  20287. //alert($rootScope.user.id,null,2);
  20288. vm.model["loginUser"] = $rootScope.user;
  20289. var loginUser = $rootScope.user;
  20290. // console.log(vm);
  20291. var that = $injector;
  20292. var parse = $parse;
  20293. var formKey = "";
  20294. var pdKey = "";
  20295. var modelWatch = "";
  20296. // 房间号是否显示
  20297. vm.model.isRoom = sessionStorage.getItem('ifRoom') == 1;
  20298. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20299. modelWatch = JSON.parse($stateParams.model);
  20300. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20301. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20302. console.log(modelWatch, $rootScope);
  20303. // if(modelWatch.model.incident){
  20304. // if(modelWatch.model.incident.place){
  20305. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20306. // }else{
  20307. // $rootScope.selecthouseNumber = undefined;
  20308. // }
  20309. // }
  20310. // 初始化的时候判断是否是简单处理
  20311. if(modelWatch.model && modelWatch.model.incident && modelWatch.model.incident.category){
  20312. if (modelWatch.model.incident.category.hasSimple == 1) {
  20313. vm.model.isHasSimple = true;
  20314. }else{
  20315. vm.model.isHasSimple = false;
  20316. }
  20317. }
  20318. }
  20319. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20320. pdKey = $state.current.pdKey;
  20321. } else if ($stateParams.pdKey) {
  20322. pdKey = $stateParams.pdKey;
  20323. }
  20324. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20325. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20326. formKey = $stateParams.formKey;
  20327. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20328. }
  20329. if (angular.isDefined($stateParams.model)) {
  20330. var formModel = $stateParams.model;
  20331. }
  20332. //用户测试数据,后续从header的auth中获取
  20333. var userId = 2;
  20334. userId = $rootScope.user.id;
  20335. //==============处理表单设计数据 开始====================
  20336. //处理组件加载后台数据选项的方法
  20337. function refreshSelectOptions(searchVal, field) {
  20338. if (
  20339. field.templateOptions.optionsUrl &&
  20340. !field.templateOptions.isnosearch
  20341. ) {
  20342. var process = BpmRestangular.all("");
  20343. if (field.templateOptions.ApiService) {
  20344. process = UserRestangular.all("");
  20345. }
  20346. if (field.templateOptions.Apicommon) {
  20347. process = WechatRestangular.all("");
  20348. }
  20349. var datakey = {
  20350. idx: 0,
  20351. sum: 1000,
  20352. };
  20353. if (field.templateOptions.modelreasondata) {
  20354. datakey = field.templateOptions.modelreasondata;
  20355. }
  20356. process
  20357. .customPOST(datakey, field.templateOptions.optionsUrl)
  20358. .then(function (result) {
  20359. if (!field.templateOptions.options) {
  20360. field.templateOptions.options = [];
  20361. }
  20362. if (field.templateOptions.optionsDataKey) {
  20363. field.templateOptions.options =
  20364. result[field.templateOptions.optionsDataKey];
  20365. } else {
  20366. field.templateOptions.options = result;
  20367. }
  20368. });
  20369. }
  20370. }
  20371. //获取表单后数据处理
  20372. function formfield(field, result) {
  20373. // angular.forEach(fields.fields, function(field) {
  20374. if (field.key == "") {
  20375. delete field.key;
  20376. }
  20377. if (angular.isDefined(field.extjson)) {
  20378. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20379. angular.extend(field.templateOptions, extObj.templateOptions);
  20380. delete extObj.templateOptions;
  20381. for (var prop in extObj) {
  20382. if (new RegExp("Expression").test(prop)) {
  20383. //var obj = $scope.$eval(extObj[prop]);
  20384. //extObj[prop] = $scope.$eval(extObj[prop]);
  20385. if (extObj[prop] != null) {
  20386. if (new RegExp("function").test(extObj[prop])) {
  20387. var propValue = eval(extObj[prop]);
  20388. extObj[prop] = propValue;
  20389. } else {
  20390. //console.log(extObj[prop]);
  20391. var obj = $scope.$eval(extObj[prop]);
  20392. extObj[prop] = obj;
  20393. //console.log(obj);
  20394. }
  20395. }
  20396. } else if (new RegExp("expressionProperties").test(prop)) {
  20397. for (var p in extObj[prop]) {
  20398. if (new RegExp("function").test(extObj[prop][p])) {
  20399. var propValue = eval(extObj[prop][p]);
  20400. extObj[prop][p] = propValue;
  20401. } else {
  20402. //if(p.indexOf("'")>=0){
  20403. // var obj = $scope.$eval(extObj[prop][p]);
  20404. // extObj[prop][$scope.$eval(p)]=obj;
  20405. //}
  20406. }
  20407. }
  20408. } else if ("watcher" == prop) {
  20409. if (angular.isArray(extObj[prop])) {
  20410. angular.forEach(extObj[prop], function (item, index) {
  20411. for (var p in item) {
  20412. if (new RegExp("function").test(item[p])) {
  20413. var propValue = eval(item[p]);
  20414. extObj[prop][index][p] = propValue;
  20415. }
  20416. }
  20417. });
  20418. } else if (angular.isObject(extObj[prop])) {
  20419. for (var p in extObj[prop]) {
  20420. if (new RegExp("function").test(extObj[prop][p])) {
  20421. var propValue = eval(extObj[prop][p]);
  20422. extObj[prop][p] = propValue;
  20423. }
  20424. }
  20425. }
  20426. }
  20427. }
  20428. angular.extend(field, extObj);
  20429. delete field.extjson;
  20430. }
  20431. if (angular.isDefined(field.templateOptions)) {
  20432. var templateOs = field.templateOptions;
  20433. // console.log(templateOs,'come')
  20434. for (var property in templateOs) {
  20435. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  20436. if (angular.isString(templateOs[property])) {
  20437. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  20438. if (new RegExp("function").test(templateOs[property])) {
  20439. var propValue = eval(templateOs[property]);
  20440. field.templateOptions[property] = propValue;
  20441. } else {
  20442. if (that.has(templateOs[property])) {
  20443. field.templateOptions[property] = that.get(
  20444. templateOs[property]
  20445. );
  20446. } else {
  20447. field.templateOptions[property] = templateOs[property];
  20448. }
  20449. }
  20450. } else if (templateOs[property] == null) {
  20451. //delete field.templateOptions[property];
  20452. } else {
  20453. }
  20454. }
  20455. }
  20456. if (
  20457. angular.isDefined(field.templateOptions) &&
  20458. angular.isDefined(field.templateOptions.extjson)
  20459. ) {
  20460. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  20461. angular.extend(field.templateOptions, extObj);
  20462. delete field.templateOptions.extjson;
  20463. }
  20464. // ...
  20465. if (field.templateOptions) {
  20466. //处理远程获取数据控件方法调用
  20467. if (
  20468. field.templateOptions.optionsUrl &&
  20469. !field.templateOptions.refresh
  20470. ) {
  20471. // if (!field.templateOptions.isnoreash) {
  20472. field.templateOptions.refresh = refreshSelectOptions;
  20473. // }
  20474. }
  20475. //处理嵌套属性数据绑定/
  20476. if (field.templateOptions.pkey) {
  20477. var pmodel,
  20478. i = 0;
  20479. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  20480. if (i == 0) {
  20481. if (result.model[p] == null) {
  20482. result.model[p] = {};
  20483. }
  20484. pmodel = result.model[p];
  20485. i++;
  20486. } else {
  20487. if (pmodel[p] == null) {
  20488. pmodel[p] = {};
  20489. }
  20490. pmodel = pmodel[p];
  20491. }
  20492. });
  20493. if (pmodel != null) {
  20494. field.model = pmodel;
  20495. if (pmodel[field.key] == null) {
  20496. pmodel[field.key] = null;
  20497. }
  20498. }
  20499. } else {
  20500. if (result.model[field.key] == null) {
  20501. result.model[field.key] = null;
  20502. }
  20503. }
  20504. //处理弹出框组件初始化
  20505. if (field.type == "ui-input-selectmodal") {
  20506. field.templateOptions.modal = $modal;
  20507. //field.templateOptions.Restangular = Restangular;
  20508. } else if (field.type == "ui-requesterselect") {
  20509. //field.templateOptions.language = $scope.lang;
  20510. field.templateOptions.modal = $modal;
  20511. field.templateOptions.UserService = api_user_data;
  20512. } else if (field.type == "ui-deptinformation") {
  20513. field.templateOptions.modal = $modal;
  20514. field.templateOptions.UserService = api_user_data;
  20515. } else if (field.type == "ui-requesterinformation") {
  20516. field.templateOptions.modal = $modal;
  20517. field.templateOptions.UserService = api_user_data;
  20518. } else if (field.type == "ui-userselect") {
  20519. field.templateOptions.modal = $modal;
  20520. //field.templateOptions.Restangular = Restangular;
  20521. } else if (field.type == "ui-userselectSearch") {
  20522. field.templateOptions.modal = $modal;
  20523. //field.templateOptions.Restangular = Restangular;
  20524. } else if (field.type == "ui-multiuserselect") {
  20525. field.templateOptions.modal = $modal;
  20526. } else if (field.type == "ui-stringuserselect") {
  20527. field.templateOptions.modal = $modal;
  20528. } else if (field.type == "ui-search") {
  20529. field.templateOptions.modal = $modal;
  20530. } else if (field.type == "ui-modelselect") {
  20531. field.templateOptions.modal = $modal;
  20532. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20533. field.templateOptions.loginUser = $rootScope.user;
  20534. //field.templateOptions.Restangular = Restangular;
  20535. } else if (field.type == "ui-incidentmodelselect") {
  20536. field.templateOptions.modal = $modal;
  20537. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20538. field.templateOptions.loginUser = $rootScope.user;
  20539. //field.templateOptions.Restangular = Restangular;
  20540. } else if (field.type == "ui-dropfile") {
  20541. $scope.fileUploader = field.templateOptions.fileUploader =
  20542. new FileUploader({
  20543. url: "/uploader",
  20544. });
  20545. field.templateOptions.taskId = $stateParams.taskId;
  20546. field.templateOptions.processInstanceId =
  20547. $stateParams.processInstanceId;
  20548. field.templateOptions.userId = $rootScope.user.id;
  20549. } else if (field.type == "ui-dropfielknow") {
  20550. $scope.fileUploader = field.templateOptions.fileUploader =
  20551. new FileUploader({
  20552. url: "/uploader",
  20553. });
  20554. field.templateOptions.taskId = $stateParams.taskId;
  20555. field.templateOptions.processInstanceId =
  20556. $stateParams.processInstanceId;
  20557. field.templateOptions.userId = $rootScope.user.id;
  20558. } else if (field.type == "ui-upDropFile") {
  20559. $scope.fileUploader = field.templateOptions.fileUploader =
  20560. new FileUploader({
  20561. url: "/uploader",
  20562. });
  20563. field.templateOptions.taskId = $stateParams.taskId;
  20564. field.templateOptions.processInstanceId =
  20565. $stateParams.processInstanceId;
  20566. field.templateOptions.userId = $rootScope.user.id;
  20567. } else if (field.type == "ui-dropfilenotup") {
  20568. $scope.fileUploader = field.templateOptions.fileUploader =
  20569. new FileUploader({
  20570. url: "/uploader",
  20571. });
  20572. field.templateOptions.taskId = $stateParams.taskId;
  20573. field.templateOptions.processInstanceId =
  20574. $stateParams.processInstanceId;
  20575. field.templateOptions.userId = $rootScope.user.id;
  20576. //field.ApiService=api_bpm_domain;
  20577. } else if (field.type == "ui-uploadFiles") {
  20578. $scope.fileUploader = field.templateOptions.fileUploader =
  20579. new FileUploader({
  20580. url: "/uploader",
  20581. });
  20582. field.templateOptions.taskId = $stateParams.taskId;
  20583. field.templateOptions.processInstanceId =
  20584. $stateParams.processInstanceId;
  20585. field.templateOptions.userId = $rootScope.user.id;
  20586. //field.ApiService=api_bpm_domain;
  20587. } else if (field.type == "ui-upDownFiles") {
  20588. $scope.fileUploader = field.templateOptions.fileUploader =
  20589. new FileUploader({
  20590. url: "/uploader",
  20591. });
  20592. field.templateOptions.taskId = $stateParams.taskId;
  20593. field.templateOptions.processInstanceId =
  20594. $stateParams.processInstanceId;
  20595. field.templateOptions.userId = $rootScope.user.id;
  20596. //field.ApiService=api_bpm_domain;
  20597. } else if (field.type == "ui-uploadImgs") {
  20598. $scope.fileUploader = field.templateOptions.fileUploader =
  20599. new FileUploader({
  20600. url: "/uploader",
  20601. });
  20602. field.templateOptions.taskId = $stateParams.taskId;
  20603. field.templateOptions.processInstanceId =
  20604. $stateParams.processInstanceId;
  20605. field.templateOptions.userId = $rootScope.user.id;
  20606. //field.ApiService=api_bpm_domain;
  20607. } else if (field.type == "ui-dropfiletable") {
  20608. if (field.templateOptions.processInstanceId) {
  20609. } else {
  20610. field.templateOptions.processInstanceId =
  20611. $stateParams.processInstanceId;
  20612. }
  20613. } else if (field.type == "ui-dropFiles") {
  20614. if (field.templateOptions.processInstanceId) {
  20615. } else {
  20616. field.templateOptions.processInstanceId =
  20617. $stateParams.processInstanceId;
  20618. }
  20619. } else if (field.type == "ui-showImgs") {
  20620. if (field.templateOptions.processInstanceId) {
  20621. } else {
  20622. field.templateOptions.processInstanceId =
  20623. $stateParams.processInstanceId;
  20624. }
  20625. } else if (field.type == "ui-repeatSection") {
  20626. var repeatForm = {
  20627. model: {},
  20628. fields: field.templateOptions.fields,
  20629. };
  20630. repeatForm.model[field.key] = [];
  20631. decodeVMForm(repeatForm);
  20632. } else if (field.type == "ui-currentuser") {
  20633. field.templateOptions.user = vm.model["loginUser"];
  20634. } else if (field.type == "ui-workernumbersign") {
  20635. field.templateOptions.user = vm.model["loginUser"];
  20636. } else if (field.type == "ui-repair-photos") {
  20637. field.templateOptions.user = vm.model["loginUser"];
  20638. }
  20639. }
  20640. }
  20641. //解析自定义表单设计数据
  20642. $scope.oldfromtype = true;
  20643. function decodeVMForm(vmForm) {
  20644. if (vmForm.formType == "1") {
  20645. $scope.oldfromtype = false;
  20646. } else {
  20647. $scope.oldfromtype = true;
  20648. }
  20649. var result = {
  20650. model: {},
  20651. fields: [],
  20652. };
  20653. //设置模型实体数据 begin
  20654. // var mdata = vmForm.model;
  20655. //解析数据实体
  20656. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  20657. angular.extend(result.model, mdata);
  20658. if (modelWatch != null && modelWatch != "") {
  20659. //angular.extend(result.model.incident,modelWatch.incident);
  20660. //result.model.alarmType = modelWatch.alarmType;
  20661. // vmForm.cancelUrl = modelWatch.cancelUrl;
  20662. // console.log(modelWatch.cancelUrl)
  20663. for (var index in modelWatch.model) {
  20664. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  20665. if (result.model[index] != null) {
  20666. angular.extend(result.model[index], modelWatch.model[index]);
  20667. } else {
  20668. result.model[index] = modelWatch.model[index];
  20669. }
  20670. }
  20671. }
  20672. //设置模型实体数据 end
  20673. //解析设计数据生成表单项 begin
  20674. var fields = [];
  20675. //处理修改设计数据中展示设置
  20676. angular.forEach(vmForm.fields, function (fields) {
  20677. if (vmForm.formType == "1") {
  20678. angular.forEach(fields.fields, function (field) {
  20679. formfield(field, result);
  20680. });
  20681. } else {
  20682. formfield(fields, result);
  20683. }
  20684. // console.log(field);
  20685. result.fields.push(fields);
  20686. });
  20687. angular.extend($scope.vm.fields, result.fields);
  20688. angular.extend($scope.vm.model, result.model);
  20689. vm.model["loginUser"] = $rootScope.user;
  20690. //增加识别报修主体seimin
  20691. vm.model.repairType = $scope.repairMain.valueconfig;
  20692. if (vm.model.incident) {
  20693. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  20694. }
  20695. console.log(vm, "repairType"); //lmm
  20696. if (
  20697. modelWatch != null &&
  20698. modelWatch != "" &&
  20699. modelWatch.cancelUrl != null &&
  20700. modelWatch.cancelUrl != ""
  20701. ) {
  20702. vmForm.cancelUrl = modelWatch.cancelUrl;
  20703. }
  20704. $scope.formData = vmForm;
  20705. console.log($scope.formData, 4444444);
  20706. // console.log($scope.formData.url);
  20707. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  20708. if ($scope.formData.url == "start") {
  20709. $scope.Reset = true;
  20710. $scope.close = true;
  20711. $rootScope.isMask = false;
  20712. } else if ($scope.formData.url == "complete") {
  20713. $scope.Reset = false;
  20714. $scope.close = true;
  20715. }
  20716. //解析设计数据生成表单项 end
  20717. return result;
  20718. }
  20719. //======================处理表单设计数据 结束========================
  20720. $scope.ldloading = {};
  20721. function filter(obj) {
  20722. angular.forEach(obj, function (key, value) {
  20723. if (value === "" || value === null) {
  20724. delete obj[key];
  20725. } else if (
  20726. Object.prototype.toString.call(value) === "[object Object]"
  20727. ) {
  20728. filter(value);
  20729. } else if (angular.isArray(value)) {
  20730. angular.forEach(value, function (item) {
  20731. filter(item);
  20732. });
  20733. }
  20734. });
  20735. }
  20736. $scope.closeModel = function () {
  20737. // console.log($stateParams);
  20738. $state.go($scope.formData.cancelUrl, {});
  20739. event.preventDefault();
  20740. };
  20741. // console.log(vm);
  20742. // 暂存
  20743. $scope.save = function (data) {
  20744. console.log(vm);
  20745. if (vm.model.startSave) {
  20746. vm.model["initUser"] = $rootScope.user.id;
  20747. vm.model.start_code = "temporary";
  20748. //处理请求数据0327
  20749. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20750. delete data0327.repairType;
  20751. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20752. if (
  20753. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20754. .selecthouseNumber
  20755. ) {
  20756. data0327.incident.place = {
  20757. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20758. .selecthouseNumber.id,
  20759. };
  20760. }
  20761. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  20762. if (response) {
  20763. var resData = Restangular.stripRestangular(response);
  20764. if (resData) {
  20765. if (
  20766. $scope.fileUploader != null &&
  20767. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  20768. resData.id
  20769. ) {
  20770. $scope.fileUploader.onBeforeUploadItem = function (item) {
  20771. angular.extend(item.headers, $rootScope.getSession());
  20772. item.url = api_bpm_domain
  20773. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  20774. .getRequestedUrl();
  20775. item.formData.push({
  20776. fileName: item.file.name,
  20777. });
  20778. //console.log();
  20779. };
  20780. $scope.fileUploader.uploadAll();
  20781. }
  20782. }
  20783. SweetAlert.swal(
  20784. {
  20785. title: "提交成功!",
  20786. type: "success",
  20787. confirmButtonColor: "#007AFF",
  20788. },
  20789. function () {
  20790. $state.go($scope.formData.cancelUrl);
  20791. }
  20792. );
  20793. } else {
  20794. SweetAlert.swal({
  20795. title: "系统错误",
  20796. text: "系统错误,请稍后重试!",
  20797. type: "error",
  20798. confirmButtonColor: "#DD6B55",
  20799. });
  20800. }
  20801. $scope.ldloading[style.replace("-", "_")] = false;
  20802. });
  20803. event.preventDefault();
  20804. } else if (vm.model.saveAgain) {
  20805. var toData = {
  20806. incident: vm.model.incident,
  20807. };
  20808. api_user_data.updData("incident", toData).then(function (response) {
  20809. if (response) {
  20810. var resData = Restangular.stripRestangular(response);
  20811. SweetAlert.swal(
  20812. {
  20813. title: "提交成功!",
  20814. type: "success",
  20815. confirmButtonColor: "#007AFF",
  20816. },
  20817. function () {
  20818. $state.go($scope.formData.cancelUrl);
  20819. }
  20820. );
  20821. } else {
  20822. SweetAlert.swal({
  20823. title: "系统错误",
  20824. text: "系统错误,请稍后重试!",
  20825. type: "error",
  20826. confirmButtonColor: "#DD6B55",
  20827. });
  20828. }
  20829. $scope.ldloading[style.replace("-", "_")] = false;
  20830. });
  20831. event.preventDefault();
  20832. } else {
  20833. SweetAlert.swal({
  20834. title: "系统错误",
  20835. text: "系统错误,请稍后重试!",
  20836. type: "error",
  20837. confirmButtonColor: "#DD6B55",
  20838. });
  20839. }
  20840. };
  20841. // 巡检生成事件
  20842. $scope.inspectionToIncident = function () {
  20843. var userData = {
  20844. idx: 0,
  20845. sum: 10,
  20846. requester: {
  20847. name: loginUser.name,
  20848. },
  20849. };
  20850. api_user_data.fetchDataList("requester", userData).then(function (res) {
  20851. console.log(res);
  20852. var toUser = {};
  20853. if (res.list.length > 0) {
  20854. toUser = res.list[0];
  20855. } else {
  20856. toUser = loginUser;
  20857. }
  20858. console.log(vm);
  20859. var incidentDescription = "";
  20860. console.log($stateParams.formUiEdit);
  20861. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  20862. var fields = vm.fields
  20863. .filter((v) => {
  20864. v.key = (v.key || "").toString();
  20865. return v.key.indexOf("sdCheckEnable") > -1;
  20866. })
  20867. .map((v) => ({
  20868. key: v.key,
  20869. name: v.templateOptions.label,
  20870. value: vm.model[v.key],
  20871. }));
  20872. fields.forEach(v=>{
  20873. if (vm.model[v.key]) {
  20874. incidentDescription =
  20875. incidentDescription.concat(v.name);
  20876. }
  20877. })
  20878. if (vm.model.descriptionTextarea) {
  20879. incidentDescription = incidentDescription.concat(
  20880. " " + "整改意见:" + vm.model.descriptionTextarea
  20881. );
  20882. }
  20883. }
  20884. // console.log(incidentDescription)
  20885. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  20886. var formdata = {
  20887. model: {
  20888. // 'isInspection': true,
  20889. // 'start_code':'assignment',
  20890. // 'isHandlerUser':false,
  20891. incident: {
  20892. requester: bxr,
  20893. area: bxr.place.area,
  20894. place: bxr.place,
  20895. houseNumber: bxr.houseNumber,
  20896. contacts: bxr.name,
  20897. contactsInformation: bxr.mphone,
  20898. // 'category': data.wxIncidentClassifyDTO.category,
  20899. description: incidentDescription,
  20900. source: {
  20901. id: 1552,
  20902. },
  20903. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  20904. // 'sourceType': data.incident.sourceType,
  20905. // 'fileUrl': data.incident.fileUrl
  20906. },
  20907. // 'requestershow': toUser,//2020年4月27日22:29:15
  20908. // 'flow': data.incident.id
  20909. // 'assignee': loginUser.id//2020年4月27日22:29:25
  20910. },
  20911. };
  20912. // console.log(formdata,toUser,'1111');
  20913. console.log(formdata, "1111");
  20914. // return;
  20915. $state.go("app.incident.chart", {
  20916. model: JSON.stringify(formdata),
  20917. });
  20918. });
  20919. // var formdata = {
  20920. // model:$rootScope.login_requester
  20921. // };
  20922. // console.log(formdata,'00000')
  20923. // return;
  20924. // $state.go("app.incident.chart", {
  20925. // 'model': JSON.stringify(formdata)
  20926. // });
  20927. event.preventDefault();
  20928. };
  20929. // console.log(vm);
  20930. // 创建事件seimin
  20931. vm.submit = function (data, style) {
  20932. console.log(vm, 22222);
  20933. // return;
  20934. if (vm.model.handler_code == undefined) {
  20935. vm.model.handler_code = "resolve";
  20936. }
  20937. if (
  20938. vm.model.change &&
  20939. vm.model.change.requestingPerson &&
  20940. vm.model.change.requestingPerson.menu
  20941. ) {
  20942. delete vm.model.change.requestingPerson.menu;
  20943. }
  20944. // var pdKey = $stateParams.pdKey;
  20945. if (vm.form.$valid) {
  20946. if (data.incident && data.incident.synergetic) {
  20947. console.log(data.incident.synergetic);
  20948. var synergetic = [];
  20949. for (var i = 0; i < data.incident.synergetic.length; i++) {
  20950. synergetic.push({
  20951. id: data.incident.synergetic[i],
  20952. });
  20953. }
  20954. data.incident.synergetic = synergetic;
  20955. vm.model.incident.synergetic = synergetic;
  20956. }
  20957. $scope.ldloading[style.replace("-", "_")] = true;
  20958. var startsub = true;
  20959. if (pdKey == "bpm_incident") {
  20960. angular.forEach(vm.fields, function (item) {
  20961. angular.forEach(item.fields, function (index) {
  20962. if (index.templateOptions.required && !index.hide) {
  20963. if (index.model) {
  20964. if (
  20965. angular.isDefined(index.model[index.key]) &&
  20966. index.model[index.key] != null
  20967. ) {
  20968. if (
  20969. index.model[index.key].id &&
  20970. index.model[index.key].id == ""
  20971. ) {
  20972. startsub = false;
  20973. $scope.ldloading.expand_right = false;
  20974. SweetAlert.swal({
  20975. title: index.templateOptions.label + "未填",
  20976. text: "请填写此项!",
  20977. type: "error",
  20978. confirmButtonColor: "#DD6B55",
  20979. });
  20980. } else {
  20981. }
  20982. } else {
  20983. startsub = false;
  20984. $scope.ldloading.expand_right = false;
  20985. console.log(vm);
  20986. SweetAlert.swal({
  20987. title: index.templateOptions.label + "未填",
  20988. text: "请填写此项!",
  20989. type: "error",
  20990. confirmButtonColor: "#DD6B55",
  20991. });
  20992. }
  20993. } else {
  20994. if (
  20995. data[index.key] &&
  20996. data[index.key] != "" &&
  20997. data[index.key] != null
  20998. ) {
  20999. } else {
  21000. startsub = false;
  21001. $scope.ldloading.expand_right = false;
  21002. SweetAlert.swal({
  21003. title: index.templateOptions.label + "未填",
  21004. text: "请填写此项!",
  21005. type: "error",
  21006. confirmButtonColor: "#DD6B55",
  21007. });
  21008. }
  21009. }
  21010. }
  21011. });
  21012. });
  21013. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  21014. // startsub = false;
  21015. // $scope.ldloading.expand_right = false;
  21016. // SweetAlert.swal({
  21017. // title: '保修人未填',
  21018. // text: "请填写此项!",
  21019. // type: "error",
  21020. // confirmButtonColor: "#DD6B55"
  21021. // });
  21022. // }
  21023. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  21024. // } else {
  21025. // startsub = false;
  21026. // $scope.ldloading.expand_right = false;
  21027. // SweetAlert.swal({
  21028. // title: '事件分类未填',
  21029. // text: "请填写此项!",
  21030. // type: "error",
  21031. // confirmButtonColor: "#DD6B55"
  21032. // });
  21033. // }
  21034. }
  21035. if (startsub) {
  21036. $scope.ldloading[style.replace("-", "_")] = true;
  21037. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  21038. // console.log("vm.options:"+ JSON.stringify(vm.options));
  21039. vm.options.updateInitialValue();
  21040. // console.log("dfjkasdhfkhskjf ")
  21041. var _ = window._;
  21042. vm.model = (function filter(obj) {
  21043. var dateTransKeys = [];
  21044. var filtered = _.pick(obj, function (v, k, obj) {
  21045. if (_.isDate(v)) {
  21046. dateTransKeys.push(k);
  21047. }
  21048. return (
  21049. angular.isDefined(v) &&
  21050. v !== null &&
  21051. (angular.isArray(v) ? v.length > 0 : true) &&
  21052. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  21053. );
  21054. });
  21055. return _.cloneDeep(filtered, function (v, index, object) {
  21056. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  21057. angular.forEach(dateTransKeys, function (item) {
  21058. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  21059. });
  21060. dateTransKey = [];
  21061. return v;
  21062. }
  21063. return !_.isEmpty(filtered) &&
  21064. v !== filtered &&
  21065. _.isPlainObject(v)
  21066. ? filter(v)
  21067. : undefined;
  21068. });
  21069. })(vm.model);
  21070. if (pdKey != "") {
  21071. if ($scope.oprcode == "save") {
  21072. //保存
  21073. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  21074. if (response) {
  21075. var resData = Restangular.stripRestangular(response);
  21076. SweetAlert.swal(
  21077. {
  21078. title: "保存成功!",
  21079. confirmButtonColor: "#007AFF",
  21080. },
  21081. function () {
  21082. $state.go($scope.formData.cancelUri);
  21083. }
  21084. );
  21085. // if(resData.status){
  21086. // resData
  21087. // }
  21088. } else {
  21089. SweetAlert.swal({
  21090. title: "系统错误",
  21091. text: "系统错误,请稍后重试!",
  21092. type: "error",
  21093. confirmButtonColor: "#DD6B55",
  21094. });
  21095. }
  21096. $scope.ldloading[style.replace("-", "_")] = false;
  21097. });
  21098. } else {
  21099. console.log($scope.formData.url, "zzzz");
  21100. var integralMechanism = sessionStorage.getItem('integralMechanism');
  21101. switch ($scope.formData.url) {
  21102. case "start":
  21103. vm.model["initUser"] = $rootScope.user.id;
  21104. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  21105. } else {
  21106. vm.model["assignee"] = $rootScope.user.id;
  21107. }
  21108. if (
  21109. vm.model["candidateGroups"] &&
  21110. vm.model.candidateGroups.id
  21111. ) {
  21112. vm.model.candidateGroups = vm.model.candidateGroups.id;
  21113. }
  21114. if (pdKey == "bpm_service_request") {
  21115. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  21116. angular.extend(vm.model.serviceCatalogueProcessActual, {
  21117. category: {
  21118. id: $stateParams.userId,
  21119. },
  21120. });
  21121. }
  21122. if (vm.model.schedule && vm.model.schedule.initUser) {
  21123. delete vm.model.schedule.initUser.menu;
  21124. }
  21125. if (
  21126. vm.model.isHandlerUser == "true" ||
  21127. vm.model.isHandlerUser == true
  21128. ) {
  21129. delete vm.model.candidateGroups;
  21130. }
  21131. if (vm.model.start_code == "close") {
  21132. // 直接处理
  21133. vm.model.incident.handlingPersonnelUser =
  21134. vm.model.incident.acceptUser;
  21135. delete vm.model.incident.handlerUser;
  21136. delete vm.model.candidateGroups;
  21137. } else if (vm.model.start_code == "assignment") {
  21138. // 派单
  21139. delete vm.model.incident.handlingPersonnelUser;
  21140. }
  21141. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21142. $scope.jry_processInstanceId =
  21143. $stateParams.processInstanceId;
  21144. }
  21145. if ($scope.jry_processInstanceId) {
  21146. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21147. }
  21148. //事件暂存判断
  21149. if (vm.model.saveAgain) {
  21150. if (
  21151. vm.model.directClose == "1" ||
  21152. vm.model.directClose == true
  21153. ) {
  21154. vm.model.start_code = "assignment";
  21155. vm.model.temporary_code = "assignment";
  21156. } else {
  21157. vm.model.start_code = "close";
  21158. vm.model.temporary_code = "close";
  21159. }
  21160. if (
  21161. vm.model.isHandlerUser == "true" ||
  21162. vm.model.isHandlerUser == true
  21163. ) {
  21164. delete vm.model.candidateGroups;
  21165. }
  21166. }
  21167. //处理请求数据0327
  21168. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21169. delete data0327.repairType;
  21170. if (data0327.start_code == "close") {
  21171. data0327.incident.directProcess = 1;
  21172. }
  21173. console.log(vm);
  21174. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21175. var paramsModel = JSON.parse($stateParams.model)
  21176. //来电-传话机id
  21177. if (paramsModel.model.incident.sockid) {
  21178. data0327.incident.callID = paramsModel.model.incident.sockid;
  21179. }
  21180. }
  21181. // --------------------------- start----------------------------------------
  21182. // 积分机制,直接处理
  21183. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21184. $modal.open({
  21185. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21186. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope) {
  21187. console.log(incidentData,currentUserId);
  21188. $scope.flag = false;
  21189. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21190. $scope.complexityFn = function(category){
  21191. if(category.complexity){
  21192. return category.complexity.value;
  21193. }else if(category.parent){
  21194. return $scope.complexityFn(category.parent);
  21195. }else{
  21196. return $scope.list[0]?$scope.list[0].value:1;
  21197. }
  21198. }
  21199. $scope.list = [];
  21200. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21201. $scope.list = res;
  21202. $scope.complexity = $scope.complexityFn(incidentData.category);
  21203. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21204. })
  21205. $scope.onChangeComplexity = function(item){
  21206. }
  21207. $scope.ok = function () {
  21208. if (!$scope.complexityConfirm.complexity){
  21209. Alert.swal({
  21210. title: "操作失败",
  21211. text: "请选择工时!",
  21212. type: "error"
  21213. });
  21214. return;
  21215. }
  21216. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21217. Alert.swal({
  21218. title: "操作失败",
  21219. text: "请填写升级原因!",
  21220. type: "error"
  21221. });
  21222. return;
  21223. }
  21224. $modalInstance.close('success');
  21225. handlerStart();
  21226. scope.complexity = $scope.complexity;
  21227. scope.complexityConfirm = $scope.complexityConfirm;
  21228. // 暂存--后面直接处理后调用积分接口
  21229. }
  21230. $scope.cancel = function () {
  21231. scope.ldloading.expand_right = false;
  21232. $modalInstance.dismiss('cancel');
  21233. }
  21234. },
  21235. size: 'sm',
  21236. resolve: {
  21237. scope: function () {
  21238. return $scope;
  21239. },
  21240. api_bpm: function () {
  21241. return api_bpm;
  21242. },
  21243. incidentData: function () {
  21244. return data0327.incident;
  21245. },
  21246. currentUserId: function () {
  21247. return loginUser.id;
  21248. },
  21249. Alert: function () {
  21250. return SweetAlert;
  21251. },
  21252. api_user_data: function () {
  21253. return api_user_data;
  21254. },
  21255. api_wechatfile: function () {
  21256. return api_wechatfile;
  21257. }
  21258. }
  21259. });
  21260. }else{
  21261. handlerStart();
  21262. }
  21263. // -------------------------------end------------------------------------
  21264. function handlerStart(){
  21265. api_bpm_domain
  21266. .start(pdKey, data0327)
  21267. .then(function (response) {
  21268. if (response) {
  21269. var resData = Restangular.stripRestangular(response);
  21270. if (resData) {
  21271. if (resData) {
  21272. if (
  21273. $scope.fileUploader != null &&
  21274. $scope.fileUploader.getNotUploadedItems().length >
  21275. 0 &&
  21276. resData.id
  21277. ) {
  21278. $scope.fileUploader.onBeforeUploadItem =
  21279. function (item) {
  21280. angular.extend(
  21281. item.headers,
  21282. $rootScope.getSession()
  21283. );
  21284. item.url = api_bpm_domain
  21285. .uploadAttachment(
  21286. resData.id,
  21287. "00000",
  21288. $rootScope.user.id
  21289. )
  21290. .getRequestedUrl();
  21291. item.formData.push({
  21292. fileName: item.file.name,
  21293. });
  21294. //console.log();
  21295. };
  21296. $scope.fileUploader.uploadAll();
  21297. }
  21298. }
  21299. }
  21300. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21301. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21302. var auditState = res.find(v=>v.value == 0);
  21303. var postData = {
  21304. incidentIntegral: {
  21305. incidentId:resData.bussId,
  21306. auditState:auditState,
  21307. handlerUser:$rootScope.user.id,
  21308. handlerUserName:$rootScope.user.name,
  21309. sourceScore:$scope.complexity,
  21310. currentScore:$scope.complexityConfirm.complexity.value,
  21311. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21312. }
  21313. }
  21314. console.log(postData)
  21315. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21316. console.log(response)
  21317. if (response.status == 200) {
  21318. SweetAlert.swal(
  21319. {
  21320. title: "提交成功!",
  21321. type: "success",
  21322. confirmButtonColor: "#007AFF",
  21323. },
  21324. function () {
  21325. if (
  21326. vm.model.incident &&
  21327. vm.model.incident.callID &&
  21328. vm.model.incident.callID != ""
  21329. ) {
  21330. $rootScope.app.layout.isSidebarClosed = false;
  21331. if ($scope.login && !$rootScope.busy) {
  21332. $rootScope.setidle();
  21333. }
  21334. }
  21335. $state.go($scope.formData.cancelUrl);
  21336. }
  21337. );
  21338. } else {
  21339. Alert.swal({
  21340. title: "操作失败",
  21341. text: "操作失败, 请稍后再试!",
  21342. type: "error"
  21343. });
  21344. }
  21345. });
  21346. })
  21347. }else{
  21348. SweetAlert.swal(
  21349. {
  21350. title: "提交成功!",
  21351. type: "success",
  21352. confirmButtonColor: "#007AFF",
  21353. },
  21354. function () {
  21355. if (
  21356. vm.model.incident &&
  21357. vm.model.incident.callID &&
  21358. vm.model.incident.callID != ""
  21359. ) {
  21360. $rootScope.app.layout.isSidebarClosed = false;
  21361. if ($scope.login && !$rootScope.busy) {
  21362. $rootScope.setidle();
  21363. }
  21364. }
  21365. $state.go($scope.formData.cancelUrl);
  21366. }
  21367. );
  21368. }
  21369. } else {
  21370. SweetAlert.swal({
  21371. title: "系统错误",
  21372. text: "系统错误,请稍后重试!",
  21373. type: "error",
  21374. confirmButtonColor: "#DD6B55",
  21375. });
  21376. }
  21377. $scope.ldloading[style.replace("-", "_")] = false;
  21378. });
  21379. }
  21380. break;
  21381. case "complete":
  21382. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21383. //console.log("complete taskId::"+$stateParams.taskId);
  21384. if (
  21385. $scope.formData.name == "transferform" &&
  21386. vm.model.ishandlers &&
  21387. !vm.model.incident.handlerUser
  21388. ) {
  21389. SweetAlert.swal({
  21390. title: "处理人未填",
  21391. text: "请填写此项!",
  21392. type: "error",
  21393. confirmButtonColor: "#DD6B55",
  21394. });
  21395. return;
  21396. }
  21397. console.log(vm);
  21398. // 积分机制,事件状态是“处理中”
  21399. if($scope.formData.name === 'handlerform'&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21400. $modal.open({
  21401. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21402. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope) {
  21403. console.log(incidentData,currentUserId);
  21404. $scope.flag = true;
  21405. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21406. $scope.complexityFn = function(category){
  21407. if(category.complexity){
  21408. return category.complexity.value;
  21409. }else if(category.parent){
  21410. return $scope.complexityFn(category.parent);
  21411. }else{
  21412. return $scope.list[0]?$scope.list[0].value:1;
  21413. }
  21414. }
  21415. $scope.list = [];
  21416. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21417. $scope.list = res;
  21418. $scope.complexity = $scope.complexityFn(incidentData.category);
  21419. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21420. })
  21421. $scope.onChangeComplexity = function(item){
  21422. if($scope.complexityConfirm.complexity.value == $scope.complexity){
  21423. $scope.complexityConfirm.updateReason = '';
  21424. }
  21425. }
  21426. $scope.ok = function () {
  21427. if (!$scope.complexityConfirm.complexity){
  21428. Alert.swal({
  21429. title: "操作失败",
  21430. text: "请选择工时!",
  21431. type: "error"
  21432. });
  21433. return;
  21434. }
  21435. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21436. Alert.swal({
  21437. title: "操作失败",
  21438. text: "请填写升级原因!",
  21439. type: "error"
  21440. });
  21441. return;
  21442. }
  21443. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21444. var auditState = $scope.complexityConfirm.complexity.value == $scope.complexity?res.find(v=>v.value == 1):res.find(v=>v.value == 0);
  21445. var postData = {
  21446. incidentIntegral: {
  21447. incidentId:incidentData.id,
  21448. auditState:auditState,
  21449. handlerUser:$rootScope.user.id,
  21450. handlerUserName:$rootScope.user.name,
  21451. sourceScore:$scope.complexity,
  21452. currentScore:$scope.complexityConfirm.complexity.value,
  21453. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21454. }
  21455. }
  21456. console.log(postData)
  21457. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21458. console.log(response)
  21459. if (response.status == 200) {
  21460. $modalInstance.close('success');
  21461. handlerLogFn();
  21462. } else {
  21463. Alert.swal({
  21464. title: "操作失败",
  21465. text: "操作失败, 请稍后再试!",
  21466. type: "error"
  21467. });
  21468. }
  21469. });
  21470. })
  21471. }
  21472. $scope.cancel = function () {
  21473. scope.ldloading.expand_right = false;
  21474. $modalInstance.dismiss('cancel');
  21475. }
  21476. },
  21477. size: 'sm',
  21478. resolve: {
  21479. scope: function () {
  21480. return $scope;
  21481. },
  21482. api_bpm: function () {
  21483. return api_bpm;
  21484. },
  21485. incidentData: function () {
  21486. return $scope.formData.model.incident;
  21487. },
  21488. currentUserId: function () {
  21489. return loginUser.id;
  21490. },
  21491. Alert: function () {
  21492. return SweetAlert;
  21493. },
  21494. api_user_data: function () {
  21495. return api_user_data;
  21496. },
  21497. api_wechatfile: function () {
  21498. return api_wechatfile;
  21499. }
  21500. }
  21501. });
  21502. }else{
  21503. handlerLogFn();
  21504. }
  21505. function handlerLogFn(){
  21506. //处理日志
  21507. // 处理日志不为空并且事件是处理中状态
  21508. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  21509. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  21510. baseHandler();
  21511. })
  21512. } else {
  21513. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  21514. //巡检计划
  21515. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  21516. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  21517. if (response.status == 200) {
  21518. baseHandler();
  21519. } else {
  21520. Alert.swal({
  21521. title: "操作失败",
  21522. text: "操作失败, 请稍后再试!",
  21523. type: "error"
  21524. });
  21525. }
  21526. });
  21527. }else{
  21528. baseHandler();
  21529. }
  21530. }else{
  21531. baseHandler();
  21532. }
  21533. }
  21534. }
  21535. // return;
  21536. function baseHandler() {
  21537. api_bpm_domain
  21538. .complete($stateParams.taskId, userId, vm.model)
  21539. .then(function (response) {
  21540. if (response) {
  21541. var resData = Restangular.stripRestangular(response);
  21542. SweetAlert.swal(
  21543. {
  21544. title: "提交成功!",
  21545. type: "success",
  21546. confirmButtonColor: "#007AFF",
  21547. },
  21548. function () {
  21549. if (
  21550. $scope.fileUploader != null &&
  21551. $scope.fileUploader.getNotUploadedItems().length >
  21552. 0
  21553. ) {
  21554. console.log(vm);
  21555. if (vm.model.incident) {
  21556. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  21557. // angular.extend(item.headers, $rootScope.getSession());
  21558. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  21559. // item.formData.push({
  21560. // 'fileName': item.file.name
  21561. // });
  21562. // };
  21563. // $scope.fileUploader.uploadAll();
  21564. $scope.fileUploader.onBeforeUploadItem =
  21565. function (item) {
  21566. angular.extend(
  21567. item.headers,
  21568. $rootScope.getSession()
  21569. );
  21570. item.url = api_bpm_domain
  21571. .uploadAttachment(
  21572. vm.model.incident.processInstanceId,
  21573. "00000",
  21574. $rootScope.user.id
  21575. )
  21576. .getRequestedUrl();
  21577. item.formData.push({
  21578. fileName: item.file.name,
  21579. });
  21580. //console.log();
  21581. };
  21582. $scope.fileUploader.uploadAll();
  21583. } else if (vm.model.problem) {
  21584. $scope.fileUploader.onBeforeUploadItem =
  21585. function (item) {
  21586. angular.extend(
  21587. item.headers,
  21588. $rootScope.getSession()
  21589. );
  21590. item.url = api_bpm_domain
  21591. .uploadAttachmentJryModel(
  21592. "problem",
  21593. vm.model.problem.id,
  21594. "00000",
  21595. $rootScope.user.id
  21596. )
  21597. .getRequestedUrl();
  21598. item.formData.push({
  21599. fileName: item.file.name,
  21600. });
  21601. };
  21602. $scope.fileUploader.uploadAll();
  21603. } else if (vm.model.change) {
  21604. }else if(vm.model.inspectionProcessActual){
  21605. //巡检图片上传yeye
  21606. $scope.fileUploader.onBeforeUploadItem =
  21607. function (item) {
  21608. angular.extend(
  21609. item.headers,
  21610. $rootScope.getSession()
  21611. );
  21612. item.url = api_bpm_domain1
  21613. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  21614. .getRequestedUrl();
  21615. item.formData.push({
  21616. fileName: item.file.name,
  21617. });
  21618. //console.log();
  21619. };
  21620. $scope.fileUploader.uploadAll();
  21621. }
  21622. }
  21623. $state.go($scope.formData.cancelUrl);
  21624. }
  21625. );
  21626. } else {
  21627. SweetAlert.swal({
  21628. title: "系统错误",
  21629. text: "系统错误,请稍后重试!",
  21630. type: "error",
  21631. confirmButtonColor: "#DD6B55",
  21632. });
  21633. }
  21634. $scope.ldloading[style.replace("-", "_")] = false;
  21635. });
  21636. }
  21637. break;
  21638. case "back":
  21639. $state.go($scope.formData.cancelUrl);
  21640. break;
  21641. default:
  21642. $scope.ldloading[style.replace("-", "_")] = false;
  21643. break;
  21644. }
  21645. }
  21646. // var submitFunc = api_bpm_domain[$scope.formData.url]
  21647. // if(anuglar.isFunction(submitFunc)){
  21648. // submitFunc.apply(null, pdKey)
  21649. // }
  21650. }
  21651. }
  21652. } else {
  21653. // console.log(data)
  21654. // angular.forEach(vm.form.$error.required, function(item){
  21655. // var i=(item.$name).substring(item.$name.length-2)
  21656. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  21657. // for(var i=0;i<vm.fields.length;i++){
  21658. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  21659. SweetAlert.swal({
  21660. title: vm.fields[i].templateOptions.label + "未填",
  21661. text: "请填写此项!",
  21662. type: "error",
  21663. confirmButtonColor: "#DD6B55",
  21664. });
  21665. }
  21666. // }
  21667. // angular.forEach(vm.fields,function(f){
  21668. // if(f.name == item.$name){
  21669. // f.validation.show = true;
  21670. // SweetAlert.swal({
  21671. // title: f.templateOptions.label+'未填',
  21672. // text: "请填写此项!",
  21673. // type: "error",
  21674. // confirmButtonColor: "#DD6B55"
  21675. // });
  21676. // }
  21677. // });
  21678. // })
  21679. }
  21680. };
  21681. $scope.vm = vm;
  21682. console.log($stateParams, pdKey, 88888);
  21683. console.log($scope.vm, "assdfsdf");
  21684. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  21685. var processInstanceId = $stateParams.processInstanceId;
  21686. var itemId = $stateParams.dataId;
  21687. console.log($stateParams);
  21688. if (
  21689. angular.isDefined($stateParams.pdKey) &&
  21690. $stateParams.pdKey == "bpm_inspection"
  21691. ) {
  21692. api_configure_form
  21693. .renderForm(
  21694. $stateParams.formUiEdit,
  21695. userId,
  21696. processInstanceId,
  21697. itemId
  21698. )
  21699. .then(function (responseData) {
  21700. if (responseData) {
  21701. //console.log("responseData>>>");//console.log(responseData);
  21702. var vmForm = Restangular.stripRestangular(responseData);
  21703. if (vmForm) {
  21704. //console.log("vmForm>>>");//console.log(vmForm);
  21705. decodeVMForm(vmForm);
  21706. }
  21707. }
  21708. });
  21709. } else if (
  21710. angular.isDefined($stateParams.pdKey) &&
  21711. $stateParams.pdKey == "bpm_service_request"
  21712. ) {
  21713. api_configure_form
  21714. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  21715. .then(function (responseData) {
  21716. if (responseData) {
  21717. //console.log("responseData>>>");//console.log(responseData);
  21718. var vmForm = Restangular.stripRestangular(responseData);
  21719. if (vmForm) {
  21720. //console.log("vmForm>>>");//console.log(vmForm);
  21721. decodeVMForm(vmForm);
  21722. }
  21723. }
  21724. });
  21725. } else {
  21726. api_bpm_domain
  21727. .taskformkey($stateParams.taskId)
  21728. .then(function (response) {
  21729. if (response) {
  21730. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  21731. api_configure_form
  21732. .renderForm(myData.data, userId, processInstanceId, itemId)
  21733. .then(function (responseData) {
  21734. if (responseData) {
  21735. //console.log("responseData>>>");//console.log(responseData);
  21736. var vmForm = Restangular.stripRestangular(responseData);
  21737. if (vmForm) {
  21738. //console.log("vmForm>>>");//console.log(vmForm);
  21739. decodeVMForm(vmForm);
  21740. console.log(vmForm, 111111);
  21741. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  21742. console.log($scope, "今天"); //2020年4月24日11:40:55
  21743. }
  21744. }
  21745. });
  21746. }
  21747. });
  21748. }
  21749. } else {
  21750. // create process instance
  21751. if (pdKey != "") {
  21752. //for process
  21753. if (pdKey == "bpm_service_request") {
  21754. api_configure_form
  21755. .renderForm($stateParams.formUiStart, userId)
  21756. .then(function (responseData) {
  21757. if (responseData) {
  21758. var vmForm = Restangular.stripRestangular(responseData);
  21759. if (vmForm) {
  21760. decodeVMForm(vmForm);
  21761. }
  21762. }
  21763. });
  21764. } else {
  21765. api_bpm_domain.startformkey(pdKey).then(function (response) {
  21766. if (response) {
  21767. var myData = Restangular.stripRestangular(response);
  21768. //myData.data = "arrangeform";
  21769. api_configure_form
  21770. .renderForm(myData.data, userId)
  21771. .then(function (responseData) {
  21772. if (responseData) {
  21773. var vmForm = Restangular.stripRestangular(responseData);
  21774. if (vmForm) {
  21775. decodeVMForm(vmForm);
  21776. }
  21777. }
  21778. });
  21779. }
  21780. });
  21781. }
  21782. } else {
  21783. //for form
  21784. //TODO
  21785. //测试数据 开始
  21786. var testJson = {
  21787. fields: [
  21788. {
  21789. fields: [
  21790. {
  21791. className: "col-xs-12",
  21792. noFormControl: true,
  21793. key: "formtitle",
  21794. templateOptions: {
  21795. readOnly: false,
  21796. placeholder: "新建事件单",
  21797. hidden: false,
  21798. label: "事件工单",
  21799. required: false,
  21800. },
  21801. type: "ui-title",
  21802. },
  21803. ],
  21804. },
  21805. {
  21806. fields: [
  21807. {
  21808. key: "selectUser",
  21809. type: "ui-deptinformation",
  21810. className: "col-xs-12",
  21811. templateOptions: {
  21812. label: "请求人信息",
  21813. modalTitle: "请求人列表",
  21814. fetchItems: function (filterData, APIService) {
  21815. return APIService.fetchDataList("requester", filterData);
  21816. },
  21817. Restangular: Restangular,
  21818. ApiService: api_user_data,
  21819. // onClick:function(val, options, field, event , model){
  21820. // console.log(options);
  21821. // }
  21822. },
  21823. },
  21824. ],
  21825. },
  21826. {
  21827. fields: [
  21828. {
  21829. key: "first",
  21830. type: "ui-workernumber",
  21831. className: "col-xs-12",
  21832. templateOptions: {
  21833. type: "input",
  21834. label: "事件单号",
  21835. pkey: "name",
  21836. },
  21837. },
  21838. ],
  21839. },
  21840. {
  21841. fields: [
  21842. {
  21843. type: "ui-header",
  21844. key: "title",
  21845. className: "col-xs-12",
  21846. templateOptions: {
  21847. label: "报修人",
  21848. pkey: "change",
  21849. },
  21850. },
  21851. {
  21852. type: "ui-input",
  21853. key: "title",
  21854. className: "col-xs-4",
  21855. templateOptions: {
  21856. label: "报修人",
  21857. pkey: "change",
  21858. },
  21859. },
  21860. {
  21861. type: "ui-input",
  21862. key: "title",
  21863. className: "col-xs-4",
  21864. templateOptions: {
  21865. label: "联系人",
  21866. pkey: "change",
  21867. },
  21868. },
  21869. {
  21870. type: "ui-input",
  21871. key: "title",
  21872. className: "col-xs-4",
  21873. templateOptions: {
  21874. label: "联系电话",
  21875. pkey: "change",
  21876. },
  21877. },
  21878. ],
  21879. },
  21880. {
  21881. fields: [
  21882. {
  21883. type: "ui-header",
  21884. key: "title1",
  21885. className: "col-xs-12",
  21886. templateOptions: {
  21887. label: "报修人",
  21888. pkey: "change",
  21889. },
  21890. },
  21891. {
  21892. type: "ui-input",
  21893. key: "title2",
  21894. className: "col-xs-4",
  21895. templateOptions: {
  21896. label: "报修人",
  21897. pkey: "change",
  21898. },
  21899. },
  21900. {
  21901. type: "ui-input",
  21902. key: "title3",
  21903. className: "col-xs-4",
  21904. templateOptions: {
  21905. label: "联系人",
  21906. pkey: "change",
  21907. },
  21908. },
  21909. {
  21910. type: "ui-input",
  21911. key: "title4",
  21912. className: "col-xs-4",
  21913. templateOptions: {
  21914. label: "联系电话",
  21915. pkey: "change",
  21916. },
  21917. },
  21918. ],
  21919. },
  21920. ],
  21921. model: [
  21922. {
  21923. username: "robin lau",
  21924. password: "123456",
  21925. chkme: false,
  21926. start_code: 0,
  21927. formtitle: "Hey!I am title value!",
  21928. name: {
  21929. first: "robin",
  21930. last: "lau",
  21931. },
  21932. multiselectItem: [],
  21933. //date:"2015-09-15 00:00:00"
  21934. },
  21935. ],
  21936. // }
  21937. };
  21938. setTimeout(function () {
  21939. decodeVMForm(testJson);
  21940. $scope.$apply();
  21941. }, 500);
  21942. //测试数据结束
  21943. }
  21944. }
  21945. //console.log("end decode");
  21946. },
  21947. ]);