customformCtrl.js 841 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783
  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 if (key == "area") {
  10726. item.templateOptions.options = list;
  10727. } else {
  10728. item.value(list[0][key][item.key]);
  10729. }
  10730. }
  10731. });
  10732. });
  10733. } else {
  10734. if (model.fields) {
  10735. angular.forEach(model.fields, function (item) {
  10736. angular.forEach(model.fields, function (item) {
  10737. if (item.templateOptions.pkey == modelKey + "." + key) {
  10738. item.model.id = "";
  10739. if (key == "place") {
  10740. item.templateOptions.isnosearch = true;
  10741. item.templateOptions.options = list;
  10742. }
  10743. if (key == "placeDTO") {
  10744. item.templateOptions.options = list;
  10745. }
  10746. if (key == "requester") {
  10747. }
  10748. if (key == "room") {
  10749. item.templateOptions.options = list;
  10750. }
  10751. if (key == "area") {
  10752. item.templateOptions.options = list;
  10753. }
  10754. }
  10755. });
  10756. });
  10757. } else {
  10758. angular.forEach(
  10759. scope.$parent.$parent.$parent.fields,
  10760. function (item) {
  10761. angular.forEach(
  10762. scope.$parent.$parent.$parent.fields,
  10763. function (item) {
  10764. if (
  10765. item.templateOptions.pkey ==
  10766. modelKey + "." + key
  10767. ) {
  10768. if (key == "place") {
  10769. item.templateOptions.isnosearch = true;
  10770. item.templateOptions.options = list;
  10771. scope.$parent.$parent.$parent.model.incident.place =
  10772. model.incident.place;
  10773. }
  10774. if (key == "placeDTO") {
  10775. item.templateOptions.options = list;
  10776. }
  10777. if (key == "requester") {
  10778. }
  10779. }
  10780. }
  10781. );
  10782. }
  10783. );
  10784. }
  10785. }
  10786. console.log(key);
  10787. //报修科室
  10788. if (key == "dept") {
  10789. // 报修科室单选
  10790. scope.$parent.$parent.$parent.model.incident.department =
  10791. response.list[0];
  10792. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10793. response.list[0].phone;
  10794. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10795. // 选择重复事件侧滑框
  10796. scope.$parent.$parent.$parent.model[
  10797. "repeatIncidentShow"
  10798. ] = false;
  10799. setTimeout(() => {
  10800. scope.$parent.$parent.$parent.model[
  10801. "repeatIncidentShow"
  10802. ] = true;
  10803. }, 500);
  10804. }
  10805. // 报修人
  10806. if (key == "requester") {
  10807. // 报修人单选
  10808. scope.$parent.$parent.$parent.model.incident.requester =
  10809. response.list[0];
  10810. console.log(scope.$parent.$parent.$parent.model);
  10811. scope.$parent.$parent.$parent.model.incident.account =
  10812. response.list[0].account;
  10813. var selectedItem = response.list[0];
  10814. var data = {
  10815. requester: selectedItem,
  10816. };
  10817. scope.$parent.$parent.$parent.model["requestershow"] =
  10818. selectedItem;
  10819. console.log(selectedItem, "----------------------");
  10820. // if (selectedItem.dept.place.place) {
  10821. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10822. // }
  10823. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10824. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10825. scope.$parent.$parent.$parent.model.incident.branch.id =
  10826. selectedItem.branch ? selectedItem.branch.id : null;
  10827. scope.$parent.$parent.$parent.model.incident.area.id =
  10828. selectedItem.place ? selectedItem.place.area.id : null;
  10829. scope.$parent.$parent.$parent.model.incident.place.id =
  10830. selectedItem.place ? selectedItem.place.id : null;
  10831. if(scope.$parent.$parent.$parent.model.incident.branch.id){
  10832. options.templateOptions.APIService.fetchDataList(
  10833. 'area',
  10834. {"area":{"branch":scope.$parent.$parent.$parent.model.incident.branch.id},"idx":0,"sum":1000}
  10835. ).then(function (response1) {
  10836. for (var i = 0; i < scope.fields.length; i++) {
  10837. if(scope.fields[i].templateOptions.onlyKey == 'area_start'){
  10838. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10839. }
  10840. }
  10841. })
  10842. }else{
  10843. for (var i = 0; i < scope.fields.length; i++) {
  10844. if(scope.fields[i].templateOptions.onlyKey == 'area_start'){
  10845. scope.fields[i].templateOptions.options = [];
  10846. }
  10847. }
  10848. }
  10849. if(scope.$parent.$parent.$parent.model.incident.area.id){
  10850. options.templateOptions.APIService.fetchDataList(
  10851. 'place',
  10852. {"place":{"areaId":scope.$parent.$parent.$parent.model.incident.area.id},"idx":0,"sum":1000}
  10853. ).then(function (response1) {
  10854. for (var i = 0; i < scope.fields.length; i++) {
  10855. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10856. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10857. }
  10858. }
  10859. })
  10860. }else{
  10861. for (var i = 0; i < scope.fields.length; i++) {
  10862. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10863. scope.fields[i].templateOptions.options = [];
  10864. }
  10865. }
  10866. }
  10867. console.log(scope, 89898998);
  10868. // console.log(scope.formData,'接单页面');
  10869. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10870. scope.model.selecthouseNumber = selectedItem.place
  10871. ? selectedItem.place
  10872. : {};
  10873. scope.$root.selecthouseNumber = selectedItem.place
  10874. ? selectedItem.place
  10875. : {};
  10876. // options.templateOptions.ApiService.addData(
  10877. // "requester",
  10878. // data
  10879. // ).then(function (response) {
  10880. // if (response.status == 200) {
  10881. if (scope.$parent.$parent.$parent) {
  10882. if (scope.$parent.$parent.$parent.place) {
  10883. scope.$parent.$parent.$parent.place.id = "";
  10884. }
  10885. if (scope.$parent.$parent.$parent.area) {
  10886. scope.$parent.$parent.$parent.area.id = "";
  10887. }
  10888. scope.$parent.$parent.$parent.model.incident.contacts =
  10889. selectedItem.name;
  10890. if (
  10891. selectedItem.mphone &&
  10892. selectedItem.mphone != null &&
  10893. selectedItem.mphone != ""
  10894. ) {
  10895. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10896. selectedItem.mphone;
  10897. } else {
  10898. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10899. selectedItem.telephone;
  10900. }
  10901. if (
  10902. selectedItem.requesterTypeDTO &&
  10903. selectedItem.requesterTypeDTO.id == 2
  10904. ) {
  10905. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10906. }
  10907. }
  10908. // if (!response.data.id) {
  10909. // response.data.id = selectedItem.id;
  10910. // }
  10911. console.log(scope);
  10912. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10913. // if (selectedItem.place && selectedItem.place.id) {
  10914. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10915. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10916. // };
  10917. // } else {
  10918. // if (selectedItem.place && selectedItem.place.id) {
  10919. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10920. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10921. // };
  10922. // }
  10923. // if(scope.$parent.$parent.$parent.model.incident.area){
  10924. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10925. // }
  10926. if (selectedItem.id) {
  10927. scope.$parent.$parent.$parent.model.incident.account =
  10928. selectedItem.account;
  10929. }
  10930. // 选择重复事件侧滑框
  10931. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10932. scope.$parent.$parent.$parent.model[
  10933. "repeatIncidentShow"
  10934. ] = false;
  10935. setTimeout(() => {
  10936. scope.$parent.$parent.$parent.model[
  10937. "repeatIncidentShow"
  10938. ] = true;
  10939. }, 500);
  10940. // }
  10941. // }
  10942. // });
  10943. }
  10944. //新建事件,选择派单,选择工作组查找处理人baba
  10945. if (key == "handlerUser") {
  10946. model.fields.forEach(function (v) {
  10947. if (v.templateOptions.pkey == "incident.handlerUser") {
  10948. v.templateOptions.options = list;
  10949. if (model.model.incident.handlerUser) {
  10950. if (model.model.incident.handlerUser.id) {
  10951. var flag = list.some(function (v) {
  10952. return v.id == model.model.incident.handlerUser.id;
  10953. });
  10954. if (flag) {
  10955. v.model.id = model.model.incident.handlerUser.id;
  10956. }
  10957. }
  10958. }
  10959. }
  10960. });
  10961. }
  10962. });
  10963. },
  10964. validators: {
  10965. required: {
  10966. expression: function (viewValue, modelValue) {
  10967. var value = modelValue || viewValue;
  10968. return value != null;
  10969. // return value.length>=1;
  10970. // if (modelValue && viewValue) {
  10971. // return value != null;
  10972. // } else {
  10973. // var value = modelValue || viewValue;
  10974. // return value.length > 0;
  10975. // }
  10976. },
  10977. },
  10978. },
  10979. },
  10980. controller: [
  10981. "$scope",
  10982. "$rootScope",
  10983. "api_bpm_domain",
  10984. "$stateParams",
  10985. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10986. // $scope.myFilter = function(item) {
  10987. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10988. // }
  10989. console.log($scope, "风浪");
  10990. if($scope.to.onlyKey === 'inspection.dictionary'){
  10991. //巡检列表-新增-巡检类型baba
  10992. console.log(location)
  10993. var loc = location.href.split('api_bpm_data')[1] || '';
  10994. if(loc.length <= 2){
  10995. // 新增轮询计划的时候
  10996. $scope.model.id = 1715;//默认系统默认
  10997. }
  10998. }
  10999. //工作组添加全部选项
  11000. // if($scope.options.templateOptions.label == '工作组'){
  11001. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  11002. // $scope.model._group = 0;
  11003. // }
  11004. if (
  11005. $scope.options.templateOptions.pkey &&
  11006. $scope.options.templateOptions.pkey == "incident.place"
  11007. ) {
  11008. if (
  11009. $scope.$parent &&
  11010. $scope.$parent.$parent.$parent.model &&
  11011. $scope.$parent.$parent.$parent.model.incident.area &&
  11012. $scope.$parent.$parent.$parent.model.incident.area.id
  11013. ) {
  11014. $scope.options.templateOptions.linkage(
  11015. "place",
  11016. {
  11017. place: {
  11018. areaId:
  11019. $scope.$parent.$parent.$parent.model.incident.area.id,
  11020. // area:{
  11021. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  11022. // }
  11023. },
  11024. },
  11025. $scope.$parent.$parent.$parent.model,
  11026. "incident",
  11027. "place"
  11028. );
  11029. }
  11030. }
  11031. $scope.myFilter = $scope;
  11032. // console.log($scope.options.templateOptions)
  11033. console.log($scope, 77777);
  11034. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  11035. var paramsModel = JSON.parse($stateParams.model)
  11036. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  11037. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  11038. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  11039. }
  11040. }
  11041. //处理人根据事件分类自动带入baba
  11042. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  11043. console.log($scope.options.templateOptions.pkey);
  11044. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  11045. if (
  11046. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  11047. ) {
  11048. $scope.$parent.$parent.$parent.model.assignee =
  11049. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11050. $scope.options.model.id =
  11051. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11052. }else{
  11053. $scope.$parent.$parent.$parent.model.assignee = null;
  11054. $scope.options.model.id = null;
  11055. }
  11056. }else{
  11057. $scope.$parent.$parent.$parent.model.assignee = null;
  11058. $scope.options.model.id = null;
  11059. }
  11060. }
  11061. // 关闭事件页面满意度评价下拉框处理
  11062. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  11063. $scope.model.id =
  11064. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  11065. }
  11066. if ($scope.options.templateOptions.initData == 1) {
  11067. $scope.options.templateOptions.onChange(
  11068. $scope.model.id,
  11069. $scope.options,
  11070. $scope
  11071. );
  11072. }
  11073. if ($scope.options.templateOptions.transform) {
  11074. $scope.options.templateOptions.onChange(
  11075. $scope.model.id,
  11076. $scope.options,
  11077. $scope
  11078. );
  11079. }
  11080. if (angular.isFunction($scope.options.templateOptions.translate)) {
  11081. $scope.model[$scope.options.key] =
  11082. $scope.options.templateOptions.translate(
  11083. $scope.options,
  11084. $rootScope,
  11085. $scope
  11086. );
  11087. }
  11088. if (
  11089. angular.isFunction($scope.options.templateOptions.translatefunc)
  11090. ) {
  11091. $scope.model[$scope.options.key] =
  11092. $scope.options.templateOptions.translatefunc(
  11093. $scope.options,
  11094. $rootScope,
  11095. $scope
  11096. );
  11097. }
  11098. if (
  11099. angular.isFunction($scope.options.templateOptions.onlyfunction)
  11100. ) {
  11101. $scope.options.templateOptions.onlyfunction(
  11102. $scope.options,
  11103. $rootScope,
  11104. $scope
  11105. );
  11106. }
  11107. },
  11108. ],
  11109. };
  11110. },
  11111. });
  11112. //下拉框组件(巡检计划-查看)
  11113. formlyConfigProvider.setType({
  11114. name: "ui-select-xj",
  11115. extends: "select",
  11116. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11117. defaultOptions: function (options, scope) {
  11118. return {
  11119. templateOptions: {
  11120. getScope: function () {
  11121. return scope;
  11122. },
  11123. refreshDelay: 0,
  11124. validators: {
  11125. required: {
  11126. expression: function (viewValue, modelValue) {
  11127. var value = modelValue || viewValue;
  11128. return value != null;
  11129. },
  11130. },
  11131. },
  11132. },
  11133. controller: [
  11134. "$scope",
  11135. "$rootScope",
  11136. "api_bpm_domain",
  11137. "$stateParams",
  11138. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11139. $scope.model[$scope.options.key] = '0';//默认全部
  11140. var arr = [];
  11141. if($scope.model.inspection.batchNos){
  11142. arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
  11143. }
  11144. arr.unshift({value:'0',name:'全部'});
  11145. $scope.options.templateOptions.options = arr;
  11146. console.log($scope)
  11147. // ts.$parent.fields.forEach(v=>{
  11148. // if(v.templateOptions.onlyKey === "batchNos"){
  11149. // //巡检计划-批次号
  11150. // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
  11151. // v.templateOptions.getScope().refreshData(batchNos)
  11152. // }
  11153. // })
  11154. // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
  11155. // console.log($scope.options)
  11156. // console.log($scope.model)
  11157. },
  11158. ],
  11159. };
  11160. },
  11161. });
  11162. //下拉多选框组件
  11163. formlyConfigProvider.setType({
  11164. name: "ui-multiselect",
  11165. extends: "select",
  11166. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11167. defaultOptions: function (options) {
  11168. return {
  11169. templateOptions: {
  11170. refresh: function () { },
  11171. refreshDelay: 1000,
  11172. },
  11173. };
  11174. },
  11175. controller: [
  11176. "$scope",
  11177. function ($scope) {
  11178. $scope.model[$scope.options.key] = [];
  11179. },
  11180. ],
  11181. });
  11182. //下拉多选全选组件
  11183. formlyConfigProvider.setType({
  11184. name: "ui-isteven",
  11185. extends: "select",
  11186. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11187. defaultOptions: function (options,$scope) {
  11188. return {
  11189. templateOptions: {
  11190. refresh: function () {
  11191. console.log(options)
  11192. options.templateOptions
  11193. .refreshData(options.templateOptions.APIService)
  11194. .then(function (result) {
  11195. if(result.status == 200){
  11196. console.log(result.list)
  11197. //树形结构转换
  11198. function formatDataTree2(json){
  11199. var _json = JSON.parse(JSON.stringify(json));
  11200. return _json.filter(p=>{
  11201. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11202. _arr.length && (p.children = _arr);
  11203. return !p.parent;
  11204. })
  11205. }
  11206. console.log(result.list)
  11207. var list = formatDataTree2(result.list);
  11208. console.log(list)
  11209. // $scope.treeList = angular.copy(list);
  11210. var resultList = [];
  11211. //转换数据
  11212. function trasData(list,obj){
  11213. if(obj){
  11214. //有父级
  11215. list.forEach(v=>{
  11216. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11217. var i = resultList.findIndex(c=>c.type == type);
  11218. if(v.children){
  11219. resultList.splice(i+1,0,{
  11220. type: "<strong>"+ v.type +"</strong>",
  11221. msId: v.id,
  11222. msGroup: true,
  11223. },{msGroup: false})
  11224. trasData(v.children,v);
  11225. }else{
  11226. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11227. }
  11228. })
  11229. }else{
  11230. //顶级
  11231. list.forEach(v=>{
  11232. if(v.children){
  11233. resultList.push({
  11234. type: "<strong>"+ v.type +"</strong>",
  11235. msId: v.id,
  11236. msGroup: true,
  11237. },{msGroup: false})
  11238. trasData(v.children,v);
  11239. }else{
  11240. resultList.push(...v,...{ticked:false});
  11241. }
  11242. })
  11243. }
  11244. return resultList;
  11245. }
  11246. var __arr = trasData(list,null);
  11247. // console.log(__arr,options.model.typeIds.split(','))
  11248. if(options.model.typeIds){
  11249. //有巡检类型,则需要回显
  11250. __arr.forEach(w=>{
  11251. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11252. })
  11253. }
  11254. $scope.webBrowsersGrouped = __arr;
  11255. console.log($scope.webBrowsersGrouped);
  11256. }
  11257. })
  11258. },
  11259. refreshDelay: 1000,
  11260. },
  11261. };
  11262. },
  11263. controller: [
  11264. "$scope",
  11265. function ($scope) {
  11266. console.log($scope)
  11267. $scope.to.refresh();//获取列表数据
  11268. // $scope.model[$scope.options.key] = [];
  11269. //单项点击或菜单
  11270. $scope.fClick = function(data){
  11271. console.log($scope.outputBrowsers)
  11272. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11273. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11274. // if(data.id){
  11275. // //单项点击
  11276. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11277. // //有巡检类型
  11278. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11279. // if(data.ticked){
  11280. // arr.push(data.id);
  11281. // }else{
  11282. // arr = arr.filter(v=>v != data.id);
  11283. // }
  11284. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11285. // }else{
  11286. // //无巡检类型
  11287. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11288. // if(data.ticked){
  11289. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11290. // }else{
  11291. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11292. // }
  11293. // }
  11294. // }else{
  11295. // // 菜单点击
  11296. // console.log($scope.webBrowsersGrouped,data.msId);
  11297. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11298. // return v.parent?v.parent.id == data.msId:false;
  11299. // })
  11300. // if(treeResultArr.every(v=>v.ticked)){
  11301. // //全部都是true的情况下,需要移除,否则增加
  11302. // }
  11303. // console.log(treeResultArr)
  11304. // // --------------------------------------
  11305. // // var treeArr = [];
  11306. // // function findParent(treeList){
  11307. // // treeList.forEach(v=>{
  11308. // // if(v.id == data.msId){
  11309. // // treeArr = v.children;
  11310. // // }else{
  11311. // // if(v.children){
  11312. // // findParent(v.children);
  11313. // // }
  11314. // // }
  11315. // // })
  11316. // // return treeArr;
  11317. // // }
  11318. // // var treeResultArr = findParent($scope.treeList);
  11319. // // console.log(treeResultArr)
  11320. // // -----------------------------------
  11321. // }
  11322. }
  11323. // 全选
  11324. $scope.fSelectAll = function(){
  11325. // console.log($scope.webBrowsersGrouped)
  11326. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11327. // console.log(arr);
  11328. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11329. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11330. }
  11331. // 全不选
  11332. $scope.fSelectNone = function(){
  11333. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11334. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11335. }
  11336. // 配置信息
  11337. $scope.outputBrowsers = [];
  11338. $scope.localLang = {
  11339. selectAll: "全选",
  11340. selectNone: "全不选",
  11341. nothingSelected: "请选择"
  11342. }
  11343. },
  11344. ],
  11345. });
  11346. //下拉多选框灵活组件
  11347. formlyConfigProvider.setType({
  11348. name: "ui-multiselectplus",
  11349. extends: "multiCheckbox",
  11350. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11351. defaultOptions: function (options, $scope) {
  11352. return {
  11353. templateOptions: {
  11354. refreshData: function (search, options, model, that) {
  11355. console.log(search, options, model, that)
  11356. var process = options.templateOptions.ApiService.all("");
  11357. if (search) {
  11358. } else {
  11359. }
  11360. var postData = options.templateOptions.optionsPostData;
  11361. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11362. postData = options.templateOptions.optionsPostData(
  11363. options,
  11364. model,
  11365. that
  11366. );
  11367. }
  11368. if (options.templateOptions.modelreasondata) {
  11369. postData = options.templateOptions.modelreasondata;
  11370. }
  11371. process
  11372. .customPOST(postData, options.templateOptions.optionsUrl)
  11373. .then(function (result) {
  11374. // if (!options.templateOptions.options) {
  11375. // options.templateOptions.options = [];
  11376. // }
  11377. // 过滤下拉列表已选择的值
  11378. var modelVal = $scope.model[$scope.options.key];
  11379. var ides = [];
  11380. var rList = result.list || result;
  11381. if ($scope.options.key == "serviceTypeIds") {
  11382. modelVal = modelVal.map(function (v) {
  11383. if (typeof v !== 'object') {
  11384. return { id: v };
  11385. } else {
  11386. return v;
  11387. }
  11388. })
  11389. }
  11390. for (var i = 0; i < modelVal.length; i++) {
  11391. for (var j = 0; j < rList.length; j++) {
  11392. if (rList[j].id == modelVal[i].id) {
  11393. ides.push(rList[j].id);
  11394. }
  11395. }
  11396. }
  11397. ides.forEach(function (v1) {
  11398. rList.forEach(function (v2) {
  11399. if (v1 == v2.id) {
  11400. rList = rList.filter(v => v.id != v2.id);
  11401. }
  11402. })
  11403. })
  11404. options.templateOptions.options = rList;
  11405. // if (options.templateOptions.optionsDataKey) {
  11406. // options.templateOptions.options =
  11407. // result[options.templateOptions.optionsDataKey];
  11408. // } else {
  11409. // options.templateOptions.options = result;
  11410. // }
  11411. if (options.templateOptions.optionsChecked) {
  11412. // return options.value = null;
  11413. options.value(options.model[options.key]);
  11414. }
  11415. });
  11416. },
  11417. refreshDelay: 0,
  11418. // },
  11419. // validators: {
  11420. // required: {
  11421. // expression: function(viewValue, modelValue) {
  11422. // var value = modelValue || viewValue;
  11423. // // return value.length>=1;
  11424. // // if (modelValue && viewValue) {
  11425. // // return value != null;
  11426. // // } else {
  11427. // // var value = modelValue || viewValue;
  11428. // // return value.length > 0;
  11429. // // }
  11430. // }
  11431. // }
  11432. },
  11433. };
  11434. },
  11435. controller: [
  11436. "$scope",
  11437. function ($scope) {
  11438. if (angular.isArray($scope.model[$scope.options.key])) {
  11439. } else {
  11440. $scope.model[$scope.options.key] = [];
  11441. }
  11442. },
  11443. ],
  11444. });
  11445. //下拉树形多选组件
  11446. formlyConfigProvider.setType({
  11447. name: "ui-multiselect-tree",
  11448. extends: "multiCheckbox",
  11449. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11450. defaultOptions: function (options) {
  11451. return {
  11452. templateOptions: {
  11453. linkage: function (modelName, data, model, modelKey, key) {
  11454. angular.extend(data, {
  11455. idx: 0,
  11456. sum: 10,
  11457. });
  11458. options.templateOptions.APIService.fetchDataList(
  11459. modelName,
  11460. data
  11461. ).then(function (response) {
  11462. var myData =
  11463. options.templateOptions.Restangular.stripRestangular(response);
  11464. var list = myData.list;
  11465. if (list.length == 1) {
  11466. angular.forEach(model.fields, function (item) {
  11467. angular.forEach(model.fields, function (item) {
  11468. if (item.templateOptions.pkey == modelKey + "." + key) {
  11469. item.model.id = "";
  11470. if (key == "place") {
  11471. item.templateOptions.options = list;
  11472. } else {
  11473. item.value(list[0][key][item.key]);
  11474. }
  11475. }
  11476. });
  11477. });
  11478. }
  11479. });
  11480. },
  11481. // my_tree_handler : function(items) {
  11482. // },
  11483. // onFilterCallback : function(items) {
  11484. // },
  11485. // onFilterCallback : function(items) {
  11486. // },
  11487. refresh: function (items) {
  11488. var treedata = [];
  11489. function convertListToTree(data, treeMap) {
  11490. treedata = data;
  11491. for (var i = 0; i < data.length; i++) {
  11492. for (var j = 0; j < data.length; j++) {
  11493. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11494. if (data[i].pid == data[j].id) {
  11495. data[i].parent = data[j];
  11496. }
  11497. }
  11498. }
  11499. }
  11500. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11501. var root = null; //Initially set our loop to null
  11502. //loop over data
  11503. for (var i = 0; i < data.length; i++) {
  11504. var datum = data[i];
  11505. //each node will have children, so let's give it a "children" poperty
  11506. datum.children = [];
  11507. //add an entry for this node to the map so that any future children can
  11508. //lookup the parent
  11509. idToNodeMap[datum.id] = datum;
  11510. //Does this node have a parent?
  11511. if (
  11512. typeof datum.parent === "undefined" ||
  11513. datum.parent === null
  11514. ) {
  11515. //Doesn't look like it, so this node is the root of the tree
  11516. root = datum;
  11517. treeMap[datum.id] = root;
  11518. } else {
  11519. //This node has a parent, so let's look it up using the id
  11520. parentNode = idToNodeMap[datum.parent.id];
  11521. //We don't need this property, so let's delete it.
  11522. delete datum.parent;
  11523. //Let's add the current node as a child of the parent node.
  11524. parentNode.children.push(datum);
  11525. }
  11526. }
  11527. return root;
  11528. }
  11529. function convertParentToChildList(data) {
  11530. // console.log("data="+JSON.stringify(data))
  11531. var treeMap = {};
  11532. var list = [];
  11533. convertListToTree(data, treeMap);
  11534. angular.forEach(treeMap, function (item) {
  11535. list.push(item);
  11536. });
  11537. return list;
  11538. }
  11539. function selectItem(pmodel, childrens) {
  11540. if (angular.isArray(pmodel)) {
  11541. angular.forEach(pmodel, function (index) {
  11542. if (index && index.id) {
  11543. angular.forEach(childrens, function (item) {
  11544. if (item.id == index.id) {
  11545. item.selected = true;
  11546. }
  11547. if (item && item.children) {
  11548. selectItem(pmodel, item.children);
  11549. }
  11550. });
  11551. }
  11552. });
  11553. } else {
  11554. if (pmodel && pmodel.id) {
  11555. angular.forEach(childrens, function (item) {
  11556. if (item.id == pmodel.id) {
  11557. item.selected = true;
  11558. }
  11559. if (item && item.children) {
  11560. selectItem(pmodel, item.children);
  11561. }
  11562. });
  11563. }
  11564. }
  11565. }
  11566. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11567. options.templateOptions
  11568. .refreshData(options.templateOptions.APIService)
  11569. .then(function (result) {
  11570. if (result.status == 200) {
  11571. if (!options.templateOptions.options) {
  11572. options.templateOptions.options = [];
  11573. }
  11574. if (options.templateOptions.optionsDataKey) {
  11575. options.templateOptions.options = convertParentToChildList(
  11576. result[options.templateOptions.optionsDataKey]
  11577. );
  11578. } else {
  11579. options.templateOptions.options =
  11580. convertParentToChildList(result);
  11581. }
  11582. //set default value
  11583. var pmodel,
  11584. i = 0;
  11585. if (options.templateOptions.pkey) {
  11586. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11587. angular.forEach(
  11588. options.templateOptions.pkey.split("."),
  11589. function (p) {
  11590. if (i == 0) {
  11591. if (options.model[p] == null) {
  11592. options.model[p] = {};
  11593. }
  11594. pmodel = options.model[p];
  11595. i++;
  11596. } else {
  11597. if (pmodel[p] == null) {
  11598. pmodel[p] = {};
  11599. }
  11600. pmodel = pmodel[p];
  11601. }
  11602. }
  11603. );
  11604. } else {
  11605. pmodel = options.model;
  11606. }
  11607. }
  11608. if (pmodel) {
  11609. pmodel = pmodel[options.key];
  11610. } else if (options.model) {
  11611. pmodel = options.model[options.key];
  11612. } else {
  11613. pmodel = options.templateOptions.options;
  11614. }
  11615. if (angular.isArray(pmodel)) {
  11616. if (pmodel) {
  11617. // if(options.templateOptions.isMultiSelect==true){
  11618. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11619. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11620. // })
  11621. // }else{
  11622. selectItem(pmodel, options.templateOptions.options);
  11623. // }
  11624. }
  11625. } else {
  11626. if (pmodel && pmodel.id) {
  11627. selectItem(pmodel, options.templateOptions.options);
  11628. }
  11629. }
  11630. items.inputModel = options.templateOptions.options;
  11631. }
  11632. });
  11633. },
  11634. },
  11635. validators: {
  11636. required: {
  11637. expression: function (viewValue, modelValue) {
  11638. var value = modelValue || viewValue;
  11639. if (angular.isArray(value)) {
  11640. for (var i = 0; i < value.length; i++) {
  11641. value[i] = {
  11642. id: value[i].id,
  11643. };
  11644. }
  11645. return value.length > 0;
  11646. } else {
  11647. // console.log(options)
  11648. // return value = "true";
  11649. return value != null;
  11650. }
  11651. },
  11652. },
  11653. },
  11654. };
  11655. },
  11656. controller: [
  11657. "$scope",
  11658. "api_configure_form",
  11659. function ($scope, api_configure_form) {
  11660. if ($scope.options.templateOptions.isMultiSelect) {
  11661. // console.log($scope);
  11662. } else {
  11663. if ($scope.model[$scope.options.key]) {
  11664. }
  11665. }
  11666. },
  11667. ],
  11668. });
  11669. //多选下拉框组件
  11670. formlyConfigProvider.setType({
  11671. name: "ui-multi-select-tree",
  11672. extends: "input",
  11673. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11674. defaultOptions: function (options) {
  11675. return {
  11676. templateOptions: {
  11677. linkage: function (modelName, data, model, modelKey, key) {
  11678. angular.extend(data, {
  11679. idx: 0,
  11680. sum: 10,
  11681. });
  11682. options.templateOptions.APIService.fetchDataList(
  11683. modelName,
  11684. data
  11685. ).then(function (response) {
  11686. var myData =
  11687. options.templateOptions.Restangular.stripRestangular(response);
  11688. var list = myData.list;
  11689. if (list.length == 1) {
  11690. angular.forEach(model.fields, function (item) {
  11691. angular.forEach(model.fields, function (item) {
  11692. if (item.templateOptions.pkey == modelKey + "." + key) {
  11693. item.model.id = "";
  11694. if (key == "place") {
  11695. item.templateOptions.options = list;
  11696. } else {
  11697. item.value(list[0][key][item.key]);
  11698. }
  11699. }
  11700. });
  11701. });
  11702. }
  11703. });
  11704. },
  11705. getparentdata: function (items) {
  11706. // console.log(items)
  11707. },
  11708. refresh: function (items, search, fn) {
  11709. console.log(items, options);
  11710. var treedata = [];
  11711. function convertListToTree(data, treeMap) {
  11712. // console.log(data)
  11713. treedata = data;
  11714. for (var i = 0; i < data.length; i++) {
  11715. for (var j = 0; j < data.length; j++) {
  11716. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11717. if (data[i].pid == data[j].id) {
  11718. data[i].parent = data[j];
  11719. }
  11720. }
  11721. // if (data[i].id) {
  11722. // if (data[i].id== data[j].id) {
  11723. // data[i].parent = data[j];
  11724. // }
  11725. // }
  11726. }
  11727. }
  11728. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11729. var root = []; //Initially set our loop to null
  11730. if (search == "search" && items.filterKeyword) {
  11731. function transform(nodes) {
  11732. var treeConverter = {
  11733. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11734. attributeName: "id", //节点唯一标识符
  11735. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11736. transform: function (node) {
  11737. //转化递归函数,参数:一个待插入节点
  11738. if (node.parent != null) {
  11739. //该节点有父节点
  11740. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11741. if (this.needFind) {
  11742. for (var i = 0; i < newNode.children.length; i++) {
  11743. //查找要插入的node子节点是否在newNode这个父节点中存在
  11744. if (
  11745. newNode.children[i][this.attributeName] ===
  11746. node[this.attributeName]
  11747. ) {
  11748. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11749. }
  11750. }
  11751. }
  11752. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11753. // delete node.parent; //删除该节点的parent属性,如果有的话
  11754. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11755. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11756. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11757. } else if (node.parent == null) {
  11758. //该叶节点没有父节点,即为根节点
  11759. // delete node.parent; //删除该节点的parent属性,如果有的话
  11760. if (this.result == null) {
  11761. //根节点不存在
  11762. node.children = []; //给该节点增加children:[]属性
  11763. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11764. } else {
  11765. node.children = [];
  11766. // 顶级去重
  11767. for (
  11768. var i = 0;
  11769. i < this.result.children.length;
  11770. i++
  11771. ) {
  11772. if (
  11773. this.result.children[i][this.attributeName] ===
  11774. node[this.attributeName]
  11775. ) {
  11776. return this.result.children[i];
  11777. }
  11778. }
  11779. this.result.children.push(node);
  11780. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11781. }
  11782. }
  11783. },
  11784. getWhole: function (nodes, attributeName) {
  11785. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11786. var _node = {};
  11787. _node.children = [];
  11788. this.result = _node; //重置根节点
  11789. this.attributeName =
  11790. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11791. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11792. nodes.forEach((item) => {
  11793. //循环调用转化方法
  11794. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11795. this.transform(item);
  11796. });
  11797. return this.result; //返回根节点
  11798. },
  11799. };
  11800. var result = treeConverter.getWhole(nodes); //调用
  11801. return result;
  11802. }
  11803. var li = transform(data).children;
  11804. // li=[...new Set(li)]
  11805. console.log(li);
  11806. treeMap = li;
  11807. fn(li);
  11808. return li;
  11809. } else {
  11810. //loop over data
  11811. for (var i = 0; i < data.length; i++) {
  11812. var datum = data[i];
  11813. //each node will have children, so let's give it a "children" poperty
  11814. datum.children = [];
  11815. //add an entry for this node to the map so that any future children can
  11816. //lookup the parent
  11817. idToNodeMap[datum.id] = datum;
  11818. //Does this node have a parent?
  11819. if (
  11820. typeof datum.parent === "undefined" ||
  11821. datum.parent === null
  11822. ) {
  11823. //Doesn't look like it, so this node is the root of the tree
  11824. root = datum;
  11825. treeMap[datum.id] = root;
  11826. } else {
  11827. //This node has a parent, so let's look it up using the id
  11828. parentNode = idToNodeMap[datum.parent.id];
  11829. //We don't need this property, so let's delete it.
  11830. // delete datum.parent;
  11831. //Let's add the current node as a child of the parent node.
  11832. parentNode.children.push(datum);
  11833. }
  11834. }
  11835. }
  11836. return root;
  11837. }
  11838. function convertParentToChildList(data) {
  11839. var treeMap = {};
  11840. var list = [];
  11841. if (search == "search" && items.filterKeyword) {
  11842. var lis = convertListToTree(data, treeMap);
  11843. return lis;
  11844. } else {
  11845. if (data[0] && data[0].orders) {
  11846. list = data;
  11847. } else {
  11848. convertListToTree(data, treeMap);
  11849. angular.forEach(treeMap, function (item) {
  11850. // console.log("item="+JSON.stringify(item))
  11851. list.push(item);
  11852. });
  11853. }
  11854. return list;
  11855. }
  11856. }
  11857. function selectItem(pmodel, childrens) {
  11858. if (angular.isArray(pmodel)) {
  11859. angular.forEach(pmodel, function (index) {
  11860. if (index && index.id) {
  11861. angular.forEach(childrens, function (item) {
  11862. if (item.id == index.id) {
  11863. item.selected = true;
  11864. }
  11865. if (item && item.children) {
  11866. selectItem(pmodel, item.children);
  11867. }
  11868. });
  11869. // angular.forEach(treedata,function(parentdata){
  11870. // if(parentdata.id == index.id){
  11871. // if(parentdata.parent&&parentdata.parent.id){
  11872. // parentdata.parent.$
  11873. // }
  11874. // item.selected = true;
  11875. // }
  11876. // if (item && item.children) {
  11877. // selectItem(pmodel ,item.children);
  11878. // }
  11879. // });
  11880. }
  11881. });
  11882. } else {
  11883. if (pmodel && pmodel.id) {
  11884. angular.forEach(childrens, function (item, index) {
  11885. if (item.id == pmodel.id) {
  11886. item.selected = true;
  11887. // delete item.children;
  11888. }
  11889. if (item && item.children) {
  11890. selectItem(pmodel, item.children);
  11891. }
  11892. });
  11893. }
  11894. }
  11895. }
  11896. function selectItemchild(pmodel, childrens) {
  11897. if (angular.isArray(pmodel)) {
  11898. angular.forEach(pmodel, function (index) {
  11899. if (index && index.id) {
  11900. angular.forEach(childrens, function (item) {
  11901. if (item.id == index.id) {
  11902. item.selected = true;
  11903. }
  11904. if (item && item.children) {
  11905. selectItem(pmodel, item.children);
  11906. }
  11907. });
  11908. }
  11909. });
  11910. } else {
  11911. if (pmodel && pmodel.id) {
  11912. angular.forEach(childrens, function (item, index) {
  11913. if (item.id == pmodel.id) {
  11914. item.selected = true;
  11915. childrens[index].selected = true;
  11916. }
  11917. if (item && item.children) {
  11918. selectItem(pmodel, item.children);
  11919. }
  11920. });
  11921. }
  11922. }
  11923. }
  11924. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11925. if (search === "search" && items.filterKeyword) {
  11926. // bala:树形模糊搜索
  11927. options.templateOptions
  11928. .bala(options.templateOptions.APIService, items.filterKeyword)
  11929. .then(function (result) {
  11930. result.list = [...new Set(result.list)]; //去重
  11931. if (!options.templateOptions.options) {
  11932. options.templateOptions.options = [];
  11933. }
  11934. if (options.templateOptions.optionsDataKey) {
  11935. options.templateOptions.options = convertParentToChildList(
  11936. result[options.templateOptions.optionsDataKey]
  11937. );
  11938. } else {
  11939. options.templateOptions.options =
  11940. convertParentToChildList(result);
  11941. }
  11942. //set default value
  11943. var pmodel,
  11944. i = 0;
  11945. if (
  11946. options.templateOptions.pkey ||
  11947. options.templateOptions.pkey != ""
  11948. ) {
  11949. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11950. angular.forEach(
  11951. options.templateOptions.pkey.split("."),
  11952. function (p) {
  11953. if (i == 0) {
  11954. if (options.model[p] == null) {
  11955. options.model[p] = {};
  11956. }
  11957. pmodel = options.model[p];
  11958. i++;
  11959. } else {
  11960. if (pmodel[p] == null) {
  11961. pmodel[p] = {};
  11962. }
  11963. pmodel = pmodel[p];
  11964. }
  11965. }
  11966. );
  11967. } else {
  11968. pmodel = options.model;
  11969. }
  11970. }
  11971. var topdata = angular.copy(options.templateOptions.options);
  11972. if (pmodel) {
  11973. pmodel = pmodel[options.key];
  11974. } else if (options.model) {
  11975. pmodel = options.model[options.key];
  11976. }
  11977. if (angular.isArray(pmodel)) {
  11978. if (pmodel) {
  11979. items.inputModel = angular.copy(
  11980. options.templateOptions.options
  11981. );
  11982. selectItem(pmodel, options.templateOptions.options);
  11983. }
  11984. } else {
  11985. if (pmodel && pmodel.id) {
  11986. items.inputModel = angular.copy(
  11987. options.templateOptions.options
  11988. );
  11989. selectItem(pmodel, options.templateOptions.options);
  11990. } else {
  11991. // items.inputModel = options.templateOptions.options;
  11992. }
  11993. }
  11994. // items.inputModel = options.templateOptions.options;
  11995. items.selectModel = options.templateOptions.options;
  11996. // 可在此展开
  11997. if (!items.inputModel) {
  11998. items.inputModel = items.selectModel;
  11999. } else {
  12000. selectItemchild(pmodel, items.inputModel);
  12001. // for (var i = 0; i < items.inputModel.length; i++) {
  12002. // items.inputModel[i].
  12003. // for (var j = 0; j < items.selectModel.length; j++) {
  12004. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12005. // items.inputModel[i].selected = true;
  12006. // }
  12007. // }
  12008. // }
  12009. }
  12010. return items.inputModel;
  12011. // options.templateOptions.options = angular.copy(topdata);
  12012. // console.log(model);
  12013. // console.log(options);
  12014. });
  12015. } else {
  12016. options.templateOptions
  12017. .refreshData(options.templateOptions.APIService)
  12018. .then(function (result) {
  12019. //回显事件分类,带出绑定的人或组start caocao
  12020. if (options.templateOptions.onlyKey == 'cate_start' && items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  12021. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  12022. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  12023. return v.id == items.$parent.originalModel.incident.category.id;
  12024. })
  12025. console.log(item)//11615
  12026. if (item) {
  12027. items.$parent.originalModel.incident.branchType = item.branchType;
  12028. if(item.branchType == 0){
  12029. if (item.userOrGroupType === 1) {
  12030. items.$parent.originalModel.start_code = 'assignment';
  12031. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  12032. items.$parent.originalModel.directClose = true;
  12033. items.$parent.originalModel.isHandlerUser = false;
  12034. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  12035. } else if (item.userOrGroupType === 2) {
  12036. items.$parent.originalModel.start_code = 'assignment';
  12037. items.$parent.originalModel.candidateGroups = item.group;
  12038. items.$parent.originalModel.directClose = true;
  12039. items.$parent.originalModel.isHandlerUser = false;
  12040. } else {
  12041. items.$parent.originalModel.start_code = 'close';
  12042. items.$parent.originalModel.directClose = false;
  12043. items.$parent.originalModel.isHandlerUser = false;
  12044. delete items.$parent.originalModel.candidateGroups;
  12045. delete items.$parent.originalModel.incident.handlerUser
  12046. }
  12047. }else if(item.branchType == 1){
  12048. items.$parent.originalModel.incident.branchUserGroups = item.branchUserGroups;
  12049. // items.$parent.originalModel.incident.area.id
  12050. options.templateOptions.APIService.fetchData('area',items.$parent.originalModel.incident.area.id).then(res=>{
  12051. console.log(res)
  12052. if(res.status == 200){
  12053. items.$parent.originalModel.incident.branchId = res.data.branch;
  12054. // res.data.branch
  12055. var branchUserGroup=item.branchUserGroups.find(v=>v.branchId==res.data.branch)||{};
  12056. if(branchUserGroup.branchUserOrGroupType==1){
  12057. items.$parent.originalModel.start_code='assignment';
  12058. items.$parent.originalModel.incident.handlerUser={id:branchUserGroup.userId?branchUserGroup.userId:undefined};
  12059. items.$parent.originalModel.directClose=true;
  12060. items.$parent.originalModel.isHandlerUser=false;
  12061. setTimeout(function(){items.$parent.originalModel.isHandlerUser=true;},0)
  12062. }else if(branchUserGroup.branchUserOrGroupType===2){
  12063. items.$parent.originalModel.start_code='assignment';
  12064. items.$parent.originalModel.candidateGroups=branchUserGroup.groupId?branchUserGroup.groupId:undefined;
  12065. items.$parent.originalModel.directClose=true;
  12066. items.$parent.originalModel.isHandlerUser=false;
  12067. }else{
  12068. items.$parent.originalModel.start_code='close';
  12069. items.$parent.originalModel.directClose=false;
  12070. items.$parent.originalModel.isHandlerUser=false;
  12071. delete items.$parent.originalModel.candidateGroups;
  12072. delete items.$parent.originalModel.incident.handlerUser
  12073. }
  12074. }
  12075. })
  12076. }
  12077. }
  12078. }
  12079. //回显事件分类,带出绑定的人或组end
  12080. if (!options.templateOptions.options) {
  12081. options.templateOptions.options = [];
  12082. }
  12083. if (options.templateOptions.optionsDataKey) {
  12084. options.templateOptions.options = convertParentToChildList(
  12085. result[options.templateOptions.optionsDataKey]
  12086. );
  12087. } else {
  12088. options.templateOptions.options =
  12089. convertParentToChildList(result);
  12090. }
  12091. //set default value
  12092. var pmodel,
  12093. i = 0;
  12094. if (
  12095. options.templateOptions.pkey ||
  12096. options.templateOptions.pkey != ""
  12097. ) {
  12098. if (options.templateOptions.pkey.indexOf(".") > 0) {
  12099. angular.forEach(
  12100. options.templateOptions.pkey.split("."),
  12101. function (p) {
  12102. if (i == 0) {
  12103. if (options.model[p] == null) {
  12104. options.model[p] = {};
  12105. }
  12106. pmodel = options.model[p];
  12107. i++;
  12108. } else {
  12109. if (pmodel[p] == null) {
  12110. pmodel[p] = {};
  12111. }
  12112. pmodel = pmodel[p];
  12113. }
  12114. }
  12115. );
  12116. } else {
  12117. pmodel = options.model;
  12118. }
  12119. }
  12120. var topdata = angular.copy(options.templateOptions.options);
  12121. if (pmodel) {
  12122. pmodel = pmodel[options.key];
  12123. } else if (options.model) {
  12124. pmodel = options.model[options.key];
  12125. }
  12126. if (angular.isArray(pmodel)) {
  12127. if (pmodel) {
  12128. items.inputModel = angular.copy(
  12129. options.templateOptions.options
  12130. );
  12131. selectItem(pmodel, options.templateOptions.options);
  12132. }
  12133. } else {
  12134. if (pmodel && pmodel.id) {
  12135. items.inputModel = angular.copy(
  12136. options.templateOptions.options
  12137. );
  12138. selectItem(pmodel, options.templateOptions.options);//baba
  12139. } else {
  12140. // items.inputModel = options.templateOptions.options;
  12141. }
  12142. }
  12143. // items.inputModel = options.templateOptions.options;
  12144. items.selectModel = options.templateOptions.options;
  12145. if (!items.inputModel) {
  12146. items.inputModel = items.selectModel;
  12147. } else {
  12148. selectItemchild(pmodel, items.inputModel);
  12149. // for (var i = 0; i < items.inputModel.length; i++) {
  12150. // for (var j = 0; j < items.selectModel.length; j++) {
  12151. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12152. // items.inputModel[i].selected = true;
  12153. // }
  12154. // }
  12155. // }
  12156. }
  12157. // options.templateOptions.options = angular.copy(topdata);
  12158. // console.log(model);
  12159. // console.log(options);
  12160. });
  12161. }
  12162. },
  12163. },
  12164. validators: {
  12165. required: {
  12166. expression: function (viewValue, modelValue) {
  12167. var value = modelValue || viewValue;
  12168. if (angular.isArray(value)) {
  12169. return value.length > 0;
  12170. } else {
  12171. // console.log(options)
  12172. if (options.templateOptions.required && !value) {
  12173. // return value != null;
  12174. } else {
  12175. return value;
  12176. }
  12177. // return value = "true";
  12178. }
  12179. },
  12180. },
  12181. },
  12182. };
  12183. },
  12184. controller: [
  12185. "$scope",
  12186. "$rootScope",
  12187. "api_configure_form",
  12188. "api_bpm_domain",
  12189. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  12190. $rootScope.checkClicked = function (item) {
  12191. angular.forEach($scope.to.options, function (itemone) {
  12192. if (!item.parent) {
  12193. if (item.id == itemone.id) {
  12194. // itemone.isExpanded = true;
  12195. } else {
  12196. itemone.isExpanded = false;
  12197. }
  12198. } else {
  12199. if (item.parent.id == itemone.id) {
  12200. angular.forEach(itemone.children, function (itemtwo) {
  12201. if (item.id == itemtwo.id) {
  12202. } else {
  12203. itemtwo.isExpanded = false;
  12204. }
  12205. });
  12206. }
  12207. }
  12208. });
  12209. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12210. console.log($scope, "gsm");
  12211. if (
  12212. $scope.originalModel &&
  12213. $scope.originalModel.incident &&
  12214. item.category &&
  12215. (!item.children || !item.children.length) &&
  12216. item.priority &&
  12217. item.priority.id
  12218. ) {
  12219. api_bpm_domain
  12220. .expectedTime("L" + (item.priority.id - 1559))
  12221. .then(function (res) {
  12222. $scope.originalModel.incident.expectResponseTime =
  12223. res.serviceLevelAgreement.responseTime;
  12224. $scope.originalModel.incident.expectIntroTime =
  12225. res.serviceLevelAgreement.resolveTime;
  12226. $scope.originalModel.incident.overdueTime = res.date;
  12227. });
  12228. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12229. // setTimeout(() => {
  12230. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12231. // }, 500);
  12232. // console.log($scope.$parent.$parent.$parent)
  12233. }
  12234. };
  12235. if ($scope.options.templateOptions.isMultiSelect) {
  12236. // console.log($scope);
  12237. } else {
  12238. if ($scope.model[$scope.options.key]) {
  12239. }
  12240. }
  12241. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12242. // console.log(item)
  12243. // // if(){
  12244. // // }
  12245. // // $scope.model[$scope.options.key]=item.id;
  12246. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12247. // $scope.propTypeOptions = data;
  12248. // });
  12249. // }
  12250. // $scope.model[$scope.options.key]=[];
  12251. // $scope.fn
  12252. $rootScope.bala1 = function (items, fn) {
  12253. // $scope.fn = fn;
  12254. console.log(items);
  12255. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12256. $scope.options.templateOptions.refresh(items, "search", fn);
  12257. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12258. // // return res.list;
  12259. // console.log(666)
  12260. // fn(res.list)
  12261. // })
  12262. };
  12263. },
  12264. ],
  12265. });
  12266. //勾选组件
  12267. formlyConfigProvider.setType({
  12268. name: "ui-checkbox",
  12269. extends: "checkbox",
  12270. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12271. controller: [
  12272. "$scope",
  12273. function ($scope) {
  12274. console.log($scope)
  12275. if($scope.options.templateOptions.isTrue){
  12276. //是否默认打开
  12277. $scope.model[$scope.options.key] = true;
  12278. }
  12279. // 巡检生成事件,默认派单
  12280. if ($scope.model.isInspection) {
  12281. $scope.model[$scope.options.key] = true;
  12282. }
  12283. if ($scope.model[$scope.options.key] == "true") {
  12284. $scope.model[$scope.options.key] = true;
  12285. }
  12286. if ($scope.model[$scope.options.key] == "false") {
  12287. $scope.model[$scope.options.key] = false;
  12288. }
  12289. },
  12290. ],
  12291. });
  12292. //勾选组件(禁用)--yeye
  12293. formlyConfigProvider.setType({
  12294. name: "ui-checkbox-disabled",
  12295. extends: "checkbox",
  12296. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12297. controller: [
  12298. "$scope",
  12299. function ($scope) {
  12300. // 巡检生成事件,默认派单
  12301. // if ($scope.model.isInspection) {
  12302. // $scope.model[$scope.options.key] = true;
  12303. // }
  12304. // if ($scope.model[$scope.options.key] == "true") {
  12305. // $scope.model[$scope.options.key] = true;
  12306. // }
  12307. // if ($scope.model[$scope.options.key] == "false") {
  12308. // $scope.model[$scope.options.key] = false;
  12309. // }
  12310. },
  12311. ],
  12312. });
  12313. //换行组件
  12314. formlyConfigProvider.setType({
  12315. name: "ui-nextLine",
  12316. /*extends: 'input',*/
  12317. template: "<div></div>",
  12318. });
  12319. //多选框组件
  12320. formlyConfigProvider.setType({
  12321. name: "ui-checklist",
  12322. extends: "multiCheckbox",
  12323. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12324. defaultOptions: function (options) {
  12325. return {
  12326. templateOptions: {
  12327. refresh: function () { },
  12328. refreshDelay: 0,
  12329. },
  12330. };
  12331. },
  12332. });
  12333. //单选框组件
  12334. formlyConfigProvider.setType({
  12335. name: "ui-radio",
  12336. extends: "radio",
  12337. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12338. defaultOptions: function (options) {
  12339. return {
  12340. templateOptions: {
  12341. refresh: function () {},
  12342. refreshDelay: 0,
  12343. },
  12344. };
  12345. },
  12346. controller: [
  12347. "$scope",
  12348. "api_wechatfile",
  12349. function ($scope,api_wechatfile) {
  12350. // 新增巡检计划-巡检方式baba
  12351. if($scope.to.onlyKey === 'onlineType'){
  12352. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12353. $scope.to.options = result;
  12354. if(!$scope.model[$scope.options.key]){
  12355. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12356. }
  12357. });
  12358. }
  12359. // 巡检生成事件,默认派单
  12360. if ($scope.model.isInspection) {
  12361. $scope.model[$scope.options.key] = true;
  12362. // $scope.model.isHandlerUser=true;
  12363. $scope.model.start_code = "assignment";
  12364. console.log($scope.model);
  12365. }
  12366. //多次暂存配置
  12367. // console.log($scope);
  12368. if ($scope.model.saveAgain) {
  12369. if (
  12370. $scope.model.directClose == "1" ||
  12371. $scope.model.directClose == true
  12372. ) {
  12373. $scope.model[$scope.options.key] = true;
  12374. // if($scope.model.incident.handlingPersonnelUser){
  12375. // delete $scope.model.incident.handlingPersonnelUser;
  12376. // };
  12377. if ($scope.model.incident.handleDescription) {
  12378. delete $scope.model.incident.handleDescription;
  12379. }
  12380. if ($scope.model.incident.closecode) {
  12381. delete $scope.model.incident.closecode;
  12382. }
  12383. if ($scope.model.incident.degree) {
  12384. delete $scope.model.incident.degree;
  12385. }
  12386. } else {
  12387. $scope.model.incident.handlingPersonnelUser =
  12388. $scope.model.incident.acceptUser;
  12389. $scope.model[$scope.options.key] = false;
  12390. }
  12391. }
  12392. },
  12393. ],
  12394. });
  12395. //文本域组件
  12396. formlyConfigProvider.setWrapper({
  12397. name: "validation",
  12398. types: ["ui-textarea"],
  12399. template:
  12400. '<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>',
  12401. });
  12402. formlyConfigProvider.setType({
  12403. name: "ui-textarea",
  12404. extends: "textarea",
  12405. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12406. defaultOptions: function (options) {
  12407. return {
  12408. templateOptions: {
  12409. transform: function (model, value) {
  12410. return value;
  12411. },
  12412. },
  12413. validation: {
  12414. messages: {
  12415. maxlength: function (viewValue, modelValue, scope) {
  12416. if (viewValue != null) {
  12417. if (viewValue.length > scope.to.maxlength) {
  12418. return (
  12419. scope.to.label +
  12420. " 字数(" +
  12421. viewValue.length +
  12422. ")超限(" +
  12423. scope.to.maxlength +
  12424. ")"
  12425. );
  12426. } else {
  12427. return "";
  12428. }
  12429. }
  12430. },
  12431. },
  12432. },
  12433. };
  12434. },
  12435. controller: [
  12436. "$scope",
  12437. function ($scope) {
  12438. var value = $scope.model[$scope.options.key];
  12439. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12440. $scope.model[$scope.options.key] =
  12441. $scope.options.templateOptions.transform(
  12442. $scope.originalModel,
  12443. value
  12444. );
  12445. }
  12446. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12447. $scope.options.templateOptions.felditem($scope);
  12448. }
  12449. },
  12450. ],
  12451. });
  12452. // div版的textarea(展示富文本框内容用)
  12453. formlyConfigProvider.setType({
  12454. name: "ui-divTextarea",
  12455. extends: "textarea",
  12456. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12457. defaultOptions: function (options) {
  12458. return {
  12459. templateOptions: {
  12460. transform: function (model, value) {
  12461. return value;
  12462. },
  12463. },
  12464. validation: {
  12465. messages: {
  12466. // maxlength: function (viewValue, modelValue, scope) {
  12467. // if (viewValue != null) {
  12468. // if (viewValue.length > scope.to.maxlength) {
  12469. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12470. // } else {
  12471. // return "";
  12472. // }
  12473. // }
  12474. // },
  12475. },
  12476. },
  12477. };
  12478. },
  12479. controller: [
  12480. "$scope",
  12481. function ($scope) {
  12482. var value = $scope.model[$scope.options.key];
  12483. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12484. $scope.model[$scope.options.key] =
  12485. $scope.options.templateOptions.transform(
  12486. $scope.originalModel,
  12487. value
  12488. );
  12489. }
  12490. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12491. $scope.options.templateOptions.felditem($scope);
  12492. }
  12493. },
  12494. ],
  12495. });
  12496. // 带有知识库引用的textarea
  12497. formlyConfigProvider.setType({
  12498. name: "ui-textAreaKnowledge",
  12499. // extends: 'textarea',
  12500. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12501. defaultOptions: function (options) {
  12502. return {
  12503. templateOptions: {
  12504. transform: function (model, value) {
  12505. return value;
  12506. },
  12507. },
  12508. validation: {
  12509. messages: {
  12510. maxlength: function (viewValue, modelValue, scope) {
  12511. if (viewValue != null) {
  12512. if (viewValue.length > scope.to.maxlength) {
  12513. return (
  12514. scope.to.label +
  12515. " 字数(" +
  12516. viewValue.length +
  12517. ")超限(" +
  12518. scope.to.maxlength +
  12519. ")"
  12520. );
  12521. } else {
  12522. return "";
  12523. }
  12524. }
  12525. },
  12526. },
  12527. },
  12528. };
  12529. },
  12530. controller: [
  12531. "$scope",
  12532. "$rootScope",
  12533. "$modal",
  12534. "SweetAlert",
  12535. "api_bpm_data",
  12536. "api_bpm_domain",
  12537. "api_solution",
  12538. "$aside",
  12539. "api_zsk",
  12540. "up_down_file",
  12541. "api_wechatfile",
  12542. function (
  12543. $scope,
  12544. $rootScope,
  12545. $modal,
  12546. SweetAlert,
  12547. api_bpm_data,
  12548. api_bpm_domain,
  12549. api_solution,
  12550. $aside,
  12551. api_zsk,
  12552. up_down_file,
  12553. api_wechatfile
  12554. ) {
  12555. // console.log($scope);
  12556. var value = $scope.model[$scope.options.key];
  12557. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12558. $scope.model[$scope.options.key] =
  12559. $scope.options.templateOptions.transform(
  12560. $scope.originalModel,
  12561. value
  12562. );
  12563. }
  12564. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12565. $scope.options.templateOptions.felditem($scope);
  12566. }
  12567. // 引用知识库点击
  12568. $scope.openSolution = function () {
  12569. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12570. setTimeout(() => {
  12571. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12572. }, 100);
  12573. };
  12574. },
  12575. ],
  12576. });
  12577. //常用语句选择textarea
  12578. formlyConfigProvider.setType({
  12579. name: "ui-textselect",
  12580. extends: "textarea",
  12581. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12582. defaultOptions: function (options) {
  12583. return {
  12584. templateOptions: {
  12585. transform: function (model, value) {
  12586. return value;
  12587. },
  12588. },
  12589. validation: {
  12590. messages: {
  12591. maxlength: function (viewValue, modelValue, scope) {
  12592. if (viewValue != null) {
  12593. if (viewValue.length > scope.to.maxlength) {
  12594. return (
  12595. scope.to.label +
  12596. " 字数(" +
  12597. viewValue.length +
  12598. ")超限(" +
  12599. scope.to.maxlength +
  12600. ")"
  12601. );
  12602. } else {
  12603. return "";
  12604. }
  12605. }
  12606. },
  12607. },
  12608. },
  12609. };
  12610. },
  12611. controller: [
  12612. "$scope",
  12613. function ($scope) {
  12614. var value = $scope.model[$scope.options.key];
  12615. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12616. $scope.model[$scope.options.key] =
  12617. $scope.options.templateOptions.transform(
  12618. $scope.originalModel,
  12619. value
  12620. );
  12621. }
  12622. },
  12623. ],
  12624. });
  12625. //改动的组件 ckeditor封装后的组件
  12626. formlyConfigProvider.setType({
  12627. name: "ui-text-check",
  12628. extends: "textarea",
  12629. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12630. defaultOptions: function (options) {
  12631. return {
  12632. templateOptions: {
  12633. extraPlugins: "uploadimage",
  12634. uploadimageConfig: {
  12635. backend: "basic",
  12636. settings: {
  12637. uploadUrl:
  12638. options.templateOptions.APIService.upload().getRequestedUrl(),
  12639. headers: "",
  12640. downloadUrl:
  12641. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12642. },
  12643. },
  12644. refresh: function (APIService, contentId, data) {
  12645. return APIService.fetchDataList(contentId, data);
  12646. },
  12647. downloadUri: function (APIService, contentId) {
  12648. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12649. },
  12650. upload: function (APIService, contentId) {
  12651. return APIService.getSolutionDowpath(contentId);
  12652. },
  12653. view: function (attachmentId) {
  12654. // return APIService.attachmentsPreviewUrl(contentId);
  12655. },
  12656. refreshDelay: 0,
  12657. transform: function (model, value) {
  12658. return value;
  12659. },
  12660. },
  12661. validation: {
  12662. messages: {
  12663. maxlength: function (viewValue, modelValue, scope) {
  12664. if (viewValue != null) {
  12665. if (viewValue.length > scope.to.maxlength) {
  12666. return (
  12667. scope.to.label +
  12668. " 字数(" +
  12669. viewValue.length +
  12670. ")超限(" +
  12671. scope.to.maxlength +
  12672. ")"
  12673. );
  12674. } else {
  12675. return "";
  12676. }
  12677. }
  12678. },
  12679. },
  12680. },
  12681. };
  12682. },
  12683. controller: [
  12684. "$scope",
  12685. "$rootScope",
  12686. function ($scope, $rootScope) {
  12687. var value = $scope.model[$scope.options.key];
  12688. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12689. $scope.model[$scope.options.key] =
  12690. $scope.options.templateOptions.transform(
  12691. $scope.originalModel,
  12692. value
  12693. );
  12694. }
  12695. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12696. $rootScope.getSession();
  12697. //var expiry={'expiry':14804244006};
  12698. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12699. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12700. $scope.upload = function (contentId, filename) {
  12701. var filename = filename;
  12702. $scope.options.templateOptions
  12703. .upload($scope.options.templateOptions.ApiService, contentId)
  12704. .then(function (response) {
  12705. var file = new Blob([response], {
  12706. type: "application/octet-stream",
  12707. });
  12708. // var filename = filename;
  12709. var fileURL = URL.createObjectURL(file);
  12710. var a = document.createElement("a");
  12711. a.href = fileURL;
  12712. a.target = "_blank";
  12713. a.download = filename;
  12714. document.body.appendChild(a);
  12715. a.click();
  12716. });
  12717. };
  12718. },
  12719. ],
  12720. });
  12721. //改动的组件 ckeditor封装后的附文本组件
  12722. formlyConfigProvider.setType({
  12723. name: "ui-fuwenben",
  12724. extends: "textarea",
  12725. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12726. defaultOptions: function (options) {
  12727. return {
  12728. templateOptions: {
  12729. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12730. extraPlugins: "uploadimage",
  12731. uploadimageConfig: {
  12732. backend: "basic",
  12733. settings: {
  12734. uploadUrl:
  12735. options.templateOptions.APIService.upload(
  12736. -110
  12737. ).getRequestedUrl(),
  12738. headers: "",
  12739. downloadUrl:
  12740. options.templateOptions.APIService.uploadResponseUri(),
  12741. },
  12742. },
  12743. refresh: function (APIService, contentId, data) {
  12744. return APIService.fetchDataList(-110, data);
  12745. },
  12746. downloadUri: function (APIService, contentId) {
  12747. return APIService.downloadAttachment(-110).getRequestedUrl();
  12748. },
  12749. upload: function (APIService, contentId) {
  12750. return APIService.getSolutionDowpath(-110);
  12751. },
  12752. view: function (attachmentId) {
  12753. // return APIService.attachmentsPreviewUrl(contentId);
  12754. },
  12755. refreshDelay: 0,
  12756. transform: function (model, value) {
  12757. return value;
  12758. },
  12759. },
  12760. validation: {
  12761. messages: {
  12762. maxlength: function (viewValue, modelValue, scope) {
  12763. if (viewValue != null) {
  12764. if (viewValue.length > scope.to.maxlength) {
  12765. return (
  12766. scope.to.label +
  12767. " 字数(" +
  12768. viewValue.length +
  12769. ")超限(" +
  12770. scope.to.maxlength +
  12771. ")"
  12772. );
  12773. } else {
  12774. return "";
  12775. }
  12776. }
  12777. },
  12778. },
  12779. },
  12780. };
  12781. },
  12782. controller: [
  12783. "$scope",
  12784. "$rootScope",
  12785. function ($scope, $rootScope) {
  12786. var value = $scope.model[$scope.options.key];
  12787. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12788. $scope.model[$scope.options.key] =
  12789. $scope.options.templateOptions.transform(
  12790. $scope.originalModel,
  12791. value
  12792. );
  12793. }
  12794. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12795. $rootScope.getSession();
  12796. //var expiry={'expiry':14804244006};
  12797. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12798. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12799. $scope.upload = function (contentId, filename) {
  12800. var filename = filename;
  12801. $scope.options.templateOptions
  12802. .upload($scope.options.templateOptions.ApiService, -110)
  12803. .then(function (response) {
  12804. var file = new Blob([response], {
  12805. type: "application/octet-stream",
  12806. });
  12807. // var filename = filename;
  12808. var fileURL = URL.createObjectURL(file);
  12809. var a = document.createElement("a");
  12810. a.href = fileURL;
  12811. a.target = "_blank";
  12812. a.download = filename;
  12813. document.body.appendChild(a);
  12814. a.click();
  12815. });
  12816. };
  12817. },
  12818. ],
  12819. });
  12820. //ui-grid展示控件
  12821. formlyConfigProvider.setType({
  12822. name: "ui-grid-show",
  12823. extends: "multiCheckbox",
  12824. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12825. defaultOptions: function (options,scope) {
  12826. return {
  12827. templateOptions: {
  12828. linkage: function () { },
  12829. getScope: function () {
  12830. return scope;
  12831. },
  12832. },
  12833. };
  12834. },
  12835. controller: function (
  12836. $scope,
  12837. $rootScope,
  12838. i18nService,
  12839. Restangular,
  12840. api_bpm_data
  12841. ) {
  12842. var loginUser = $rootScope.user;
  12843. $scope.langs = i18nService.getAllLangs();
  12844. $scope.lang = "zh-cn";
  12845. i18nService.setCurrentLang($scope.lang);
  12846. $scope.gridOptions = {};
  12847. $scope.gridOptions.data = "myData";
  12848. $scope.gridOptions.enableColumnResizing = true;
  12849. // $scope.gridOptions.enableFiltering = true;
  12850. $scope.gridOptions.enableGridMenu = false;
  12851. $scope.gridOptions.enableRowSelection = true;
  12852. $scope.gridOptions.showGridFooter = true;
  12853. $scope.gridOptions.showColumnFooter = false;
  12854. $scope.gridOptions.fastWatch = true;
  12855. $scope.gridOptions.useExternalFiltering = true;
  12856. $scope.gridOptions.useExternalPagination = true;
  12857. $scope.gridOptions.paginationPageSizes = [10];
  12858. $scope.gridOptions.paginationPageSize = 10;
  12859. $scope.gridOptions.multiSelect = true;
  12860. $scope.gridOptions.rowIdentity = function (row) {
  12861. return row.id;
  12862. };
  12863. $scope.gridOptions.getRowIdentity = function (row) {
  12864. return row.id;
  12865. };
  12866. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12867. $scope.gridOptions.columnDefs = [
  12868. // { name:'id', width:80, enableFiltering:false},
  12869. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12870. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12871. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12872. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12873. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12874. {
  12875. name: "inspection.title",
  12876. displayName: "计划主题",
  12877. width: 120,
  12878. enableFiltering: false,
  12879. },
  12880. {
  12881. name: "sign",
  12882. displayName: "单号",
  12883. width: 140,
  12884. enableFiltering: false,
  12885. },
  12886. {
  12887. name: "inspectionType.type",
  12888. displayName: "巡检分类",
  12889. width: 200,
  12890. enableFiltering: false,
  12891. cellTemplate: '<div>' +
  12892. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12893. '</div>'
  12894. },
  12895. {
  12896. name: "stateName",
  12897. displayName: "状态",
  12898. width: 80,
  12899. enableFiltering: false,
  12900. },
  12901. {
  12902. name: "processUser.name",
  12903. displayName: "处理人/组",
  12904. width: 120,
  12905. enableFiltering: false,
  12906. cellTemplate: '<div>' +
  12907. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12908. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12909. '</div>'
  12910. },
  12911. {
  12912. name: "startDate",
  12913. displayName: "开始时间",
  12914. width: 160,
  12915. enableFiltering: false,
  12916. },
  12917. {
  12918. name: "endTime",
  12919. displayName: "结束时间",
  12920. width: 160,
  12921. enableFiltering: false,
  12922. cellTemplate: '<div>' +
  12923. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12924. '</div>'
  12925. },
  12926. // {
  12927. // name: "batchNo",
  12928. // displayName: "批次号",
  12929. // width: 160,
  12930. // enableFiltering: false,
  12931. // },
  12932. ];
  12933. var defaultFilterData = {
  12934. idx: 0,
  12935. sum: 10,
  12936. };
  12937. $scope.transferTime = function (time) {
  12938. return moment(time).format("YYYY-MM-DD HH:mm");
  12939. };
  12940. //分页控制
  12941. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12942. gridApi.pagination.on.paginationChanged(
  12943. $scope,
  12944. function (newPage, pageSize) {
  12945. var filtersData = $scope.memoryfilterData;
  12946. filtersData.idx = newPage - 1;
  12947. filtersData.sum = pageSize;
  12948. $scope.refreshData("expand-right", filtersData);
  12949. }
  12950. );
  12951. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12952. data.grid.appScope.selected.items = data.entity;
  12953. });
  12954. };
  12955. //页面获取数据
  12956. $scope.refreshData = function (style, filterData) {
  12957. // $scope.ldloading[style.replace('-', '_')] = true;
  12958. console.log(angular.isUndefined(filterData))
  12959. if (angular.isUndefined(filterData)) {
  12960. filterData = defaultFilterData;
  12961. }
  12962. $scope.myData = [];
  12963. console.log(filterData)
  12964. if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
  12965. filterData.inspectionProcessActual = {
  12966. inspectionid: $scope.model.id,
  12967. batchNo:filterData.inspectionProcessActual.batchNo
  12968. }
  12969. }else{
  12970. filterData.inspectionProcessActual = {
  12971. inspectionid: $scope.model.id
  12972. }
  12973. }
  12974. // angular.extend(filterData, {
  12975. // inspectionProcessActual: {
  12976. // inspectionid: $scope.model.id,
  12977. // },
  12978. // });
  12979. console.log(filterData)
  12980. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12981. function (data) {
  12982. var myData = Restangular.stripRestangular(data);
  12983. $scope.gridOptions.totalItems = myData.totalNum;
  12984. $scope.myData = myData.list;
  12985. for (var i = 0; i < $scope.myData.length; i++) {
  12986. //添加序号
  12987. $scope.myData[i]["item"] =
  12988. i + 1 + filterData.idx * filterData.sum;
  12989. }
  12990. // $scope.ldloading[style.replace('-', '_')] = false;
  12991. },
  12992. function () {
  12993. // $scope.ldloading[style.replace('-', '_')] = false;
  12994. }
  12995. );
  12996. };
  12997. $scope.refreshData("expand-right", defaultFilterData);
  12998. },
  12999. });
  13000. //文本框自定义选择面板组件
  13001. formlyConfigProvider.setType({
  13002. name: "ui-input-selectmodal",
  13003. extends: "input",
  13004. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  13005. defaultOptions: function (options) {
  13006. return {
  13007. templateOptions: {
  13008. openModal: function (size, options, modal) {
  13009. var modalInstance = modal.open({
  13010. templateUrl: "assets/views/customform/tpl/modal-content.html",
  13011. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  13012. size: size,
  13013. resolve: options.templateOptions.modalParam,
  13014. });
  13015. modalInstance.result.then(
  13016. function (selectedItem) {
  13017. options.value(selectedItem);
  13018. },
  13019. function () {
  13020. //console.log('Modal dismissed at: ' + new Date());
  13021. }
  13022. );
  13023. },
  13024. },
  13025. };
  13026. },
  13027. });
  13028. //日期控件
  13029. var datepicker_attr = [
  13030. "date-disabled",
  13031. "custom-class",
  13032. "show-weeks",
  13033. "starting-day",
  13034. "init-date",
  13035. "min-mode",
  13036. "max-mode",
  13037. "format-day",
  13038. "format-month",
  13039. "format-year",
  13040. "format-day-header",
  13041. "format-day-title",
  13042. "format-month-title",
  13043. "year-range",
  13044. "shortcut-propagation",
  13045. "datepicker-popup",
  13046. "show-button-bar",
  13047. "current-text",
  13048. "clear-text",
  13049. "close-text",
  13050. "close-on-date-selection",
  13051. "datepicker-append-to-body",
  13052. ];
  13053. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  13054. formlyConfigProvider.setType({
  13055. name: "ui-datetime",
  13056. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  13057. extends: "input",
  13058. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13059. defaultOptions: {
  13060. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13061. templateOptions: {
  13062. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13063. },
  13064. },
  13065. controller: [
  13066. "$scope",
  13067. "$filter",
  13068. function ($scope, $filter) {
  13069. $scope.model[$scope.options.key] = $filter("date")(
  13070. new Date(),
  13071. $scope.options.templateOptions.datepickerPopup
  13072. );
  13073. $scope.options.initialValue = $scope.model[$scope.options.key];
  13074. },
  13075. ],
  13076. });
  13077. //日期控件
  13078. formlyConfigProvider.setType({
  13079. name: "ui-datepicker",
  13080. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  13081. extends: "input",
  13082. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13083. defaultOptions: {
  13084. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13085. templateOptions: {
  13086. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13087. },
  13088. },
  13089. controller: [
  13090. "$scope",
  13091. "$filter",
  13092. function ($scope, $filter) {
  13093. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  13094. if ($scope.model[$scope.options.key]) {
  13095. } else {
  13096. $scope.model[$scope.options.key] = $filter("date")(
  13097. new Date(),
  13098. $scope.options.templateOptions.datepickerPopup
  13099. );
  13100. }
  13101. $scope.options.initialValue = $scope.model[$scope.options.key];
  13102. $scope.endOpen = true;
  13103. $scope.datepicker = {};
  13104. $scope.datepicker.opened = false;
  13105. $scope.datepicker.open = function ($event) {
  13106. $scope.datepicker.opened = true;
  13107. };
  13108. },
  13109. ],
  13110. });
  13111. //时分控件
  13112. formlyConfigProvider.setType({
  13113. name: "ui-datehourtime",
  13114. extends: "input",
  13115. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  13116. defaultOptions: function (options) {
  13117. return {
  13118. noFormControl: true,
  13119. // validators:{
  13120. // required:{
  13121. // expression:function(viewValue, modelValue){
  13122. // console.log(options)
  13123. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13124. // // var value = modelValue.getHours() || viewValue.getHours();
  13125. // return value.length>=1;
  13126. // }
  13127. // }
  13128. // }
  13129. };
  13130. },
  13131. controller: [
  13132. "$scope",
  13133. "$log",
  13134. function ($scope, $log) {
  13135. $scope.hstep = new Date(
  13136. Date.parse($scope.model[$scope.options.key])
  13137. ).getHours();
  13138. $scope.minutes = new Date(
  13139. Date.parse($scope.model[$scope.options.key])
  13140. ).getMinutes();
  13141. $scope.model[$scope.options.key] = new Date(
  13142. Date.parse($scope.model[$scope.options.key])
  13143. );
  13144. },
  13145. ],
  13146. });
  13147. //状态追踪
  13148. formlyConfigProvider.setType({
  13149. name: "ui-followStatus",
  13150. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13151. controller: [
  13152. "$scope",
  13153. "api_bpm_data",
  13154. "Restangular",
  13155. function ($scope, api_bpm_data, Restangular) {
  13156. setTimeout(function () {
  13157. var pkey = $scope.options.templateOptions.pkey;
  13158. var dataId = $scope.model.id;
  13159. if (dataId) {
  13160. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13161. if (response) {
  13162. var myData = Restangular.stripRestangular(response);
  13163. var processInstanceId = myData.data.processInstanceId;
  13164. $scope.options.templateOptions
  13165. .getData(
  13166. $scope.model,
  13167. $scope.options.templateOptions.ApiService,
  13168. processInstanceId
  13169. )
  13170. .then(function (result) {
  13171. if (result.status == 200) {
  13172. var newData = Restangular.stripRestangular(result);
  13173. $scope.followData = newData.data;
  13174. }
  13175. });
  13176. }
  13177. });
  13178. }
  13179. }, 10);
  13180. },
  13181. ],
  13182. });
  13183. //沟通记录
  13184. formlyConfigProvider.setType({
  13185. name: "ui-handlerLog",
  13186. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13187. controller: [
  13188. "$scope",
  13189. "$rootScope",
  13190. "$modal",
  13191. "api_bpm_data",
  13192. "Restangular",
  13193. function ($scope, $rootScope, $modal, api_bpm_data, Restangular) {
  13194. console.log($scope, 'ui-handlerLog');
  13195. //录音
  13196. $scope.recordcall = function(data) {
  13197. var modalInstance = $modal.open({
  13198. backdrop: "static",
  13199. templateUrl: 'assets/views/incident/tpl/audio.html',
  13200. controller: function($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
  13201. $scope.audioUrl=$sce.trustAsResourceUrl(callIp+data.recordingFileName);
  13202. // $scope.audioUrl=$sce.trustAsResourceUrl('https://www.runoob.com/try/demo_source/horse.ogg');//暂时写死
  13203. $scope.cancel = function() {
  13204. $modalInstance.dismiss('cancel');
  13205. };
  13206. $modalInstance.close();
  13207. }
  13208. });
  13209. modalInstance.result.then(function(result) {}, function(reason) {
  13210. $rootScope.setidle();
  13211. });
  13212. };
  13213. },
  13214. ],
  13215. });
  13216. //资产
  13217. formlyConfigProvider.setType({
  13218. name: "ui-zc",
  13219. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13220. controller: [
  13221. "$scope",
  13222. "api_bpm_data",
  13223. "Restangular",
  13224. function ($scope, api_bpm_data, Restangular) {
  13225. console.log($scope, 'ui-zc');
  13226. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13227. },
  13228. ],
  13229. });
  13230. //绑定的耗材
  13231. formlyConfigProvider.setType({
  13232. name: "ui-hc",
  13233. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13234. controller: [
  13235. "$scope",
  13236. "api_cmdb2",
  13237. "Restangular",
  13238. function ($scope, api_cmdb2, Restangular) {
  13239. console.log($scope, 'ui-hc')
  13240. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13241. $scope.list = [];
  13242. var sjId = $scope.model.incident.id;
  13243. api_cmdb2.getHc(sjId).then(function (response) {
  13244. console.log(response)
  13245. if (response.status == 200) {
  13246. $scope.list = response.data;
  13247. }
  13248. })
  13249. },
  13250. ],
  13251. });
  13252. //历史记录
  13253. formlyConfigProvider.setType({
  13254. name: "ui-history",
  13255. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13256. controller: [
  13257. "$scope",
  13258. "api_bpm_data",
  13259. "Restangular",
  13260. function ($scope, api_bpm_data, Restangular) {
  13261. setTimeout(function () {
  13262. var pkey = $scope.options.templateOptions.pkey;
  13263. var dataId = $scope.model.id;
  13264. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13265. if (response) {
  13266. var myData = Restangular.stripRestangular(response);
  13267. var processInstanceId = myData.data.processInstanceId;
  13268. $scope.options.templateOptions
  13269. .getData(
  13270. $scope.model,
  13271. $scope.options.templateOptions.ApiService,
  13272. processInstanceId
  13273. )
  13274. .then(function (result) {
  13275. if (result.status == 200) {
  13276. var newData = Restangular.stripRestangular(result);
  13277. var long = newData.data.length - 1;
  13278. $scope.followData = newData.data[long];
  13279. }
  13280. });
  13281. }
  13282. });
  13283. }, 10);
  13284. },
  13285. ],
  13286. });
  13287. // //请求人信息显示
  13288. // formlyConfigProvider.setType({
  13289. // name: "ui-disrequester",
  13290. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13291. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13292. // defaultOptions: function(options) {
  13293. // return {
  13294. // templateOptions: {}
  13295. // };
  13296. // },
  13297. // controller: ['$scope', function($scope) {
  13298. // $scope.options.templateOptions.that = $scope;
  13299. // }]
  13300. // });
  13301. //退回人信息显示
  13302. formlyConfigProvider.setType({
  13303. name: "ui-returnperson",
  13304. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13305. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13306. defaultOptions: function (options) {
  13307. return {
  13308. templateOptions: {},
  13309. };
  13310. },
  13311. controller: [
  13312. "$scope",
  13313. function ($scope) {
  13314. $scope.group = "";
  13315. $scope.role = "";
  13316. if (
  13317. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13318. $scope.model.handlingPersonnelUser.group.length == 1
  13319. ) {
  13320. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13321. } else {
  13322. for (
  13323. var i = 0;
  13324. i < $scope.model.handlingPersonnelUser.group.length;
  13325. i++
  13326. ) {
  13327. $scope.group +=
  13328. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13329. }
  13330. }
  13331. if (
  13332. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13333. $scope.model.handlingPersonnelUser.role.length == 1
  13334. ) {
  13335. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13336. } else {
  13337. for (
  13338. var i = 0;
  13339. i < $scope.model.handlingPersonnelUser.role.length;
  13340. i++
  13341. ) {
  13342. $scope.role +=
  13343. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13344. }
  13345. }
  13346. $scope.options.templateOptions.that = $scope;
  13347. $scope.options.templateOptions.that = $scope;
  13348. },
  13349. ],
  13350. });
  13351. //退回人信息显示(去掉工作组&角色)
  13352. formlyConfigProvider.setType({
  13353. name: "ui-returnpersonNoGroup",
  13354. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13355. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13356. defaultOptions: function (options) {
  13357. return {
  13358. templateOptions: {},
  13359. };
  13360. },
  13361. controller: [
  13362. "$scope",
  13363. function ($scope) {
  13364. $scope.group = "";
  13365. $scope.role = "";
  13366. if (
  13367. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13368. $scope.model.handlingPersonnelUser.group.length == 1
  13369. ) {
  13370. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13371. } else {
  13372. for (
  13373. var i = 0;
  13374. i < $scope.model.handlingPersonnelUser.group.length;
  13375. i++
  13376. ) {
  13377. $scope.group +=
  13378. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13379. }
  13380. }
  13381. if (
  13382. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13383. $scope.model.handlingPersonnelUser.role.length == 1
  13384. ) {
  13385. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13386. } else {
  13387. for (
  13388. var i = 0;
  13389. i < $scope.model.handlingPersonnelUser.role.length;
  13390. i++
  13391. ) {
  13392. $scope.role +=
  13393. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13394. }
  13395. }
  13396. $scope.options.templateOptions.that = $scope;
  13397. $scope.options.templateOptions.that = $scope;
  13398. },
  13399. ],
  13400. });
  13401. //指派技术人员
  13402. formlyConfigProvider.setType({
  13403. name: "ui-apiontperson",
  13404. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13405. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13406. defaultOptions: function (options) {
  13407. return {
  13408. templateOptions: {
  13409. transtlara: function (value, $scope) { },
  13410. },
  13411. };
  13412. },
  13413. controller: [
  13414. "$scope",
  13415. "api_user_data",
  13416. "Restangular",
  13417. function ($scope, api_user_data, Restangular) {
  13418. var filterData = {
  13419. idx: 0,
  13420. sum: 1000,
  13421. };
  13422. api_user_data
  13423. .fetchDataList("group", filterData)
  13424. .then(function (response) {
  13425. if (response.status == 200) {
  13426. $scope.select = {};
  13427. $scope.multipleDemo = {};
  13428. $scope.userdata = {};
  13429. var data = response.list;
  13430. var item = [];
  13431. $scope.multipleDemo = data;
  13432. $scope.multipleDemo;
  13433. }
  13434. });
  13435. $scope.options.templateOptions.onChange = function (
  13436. id,
  13437. options,
  13438. groupdata,
  13439. $event,
  13440. model
  13441. ) {
  13442. if (groupdata.option) {
  13443. $scope.model[$scope.options.key] = {};
  13444. var fildate = {
  13445. idx: 0,
  13446. sum: 1000,
  13447. user: {
  13448. roledata: {
  13449. rolecode: model.currentRole,
  13450. },
  13451. selectType: "1",
  13452. groupdata: {
  13453. id: groupdata.option.id,
  13454. },
  13455. },
  13456. };
  13457. api_user_data
  13458. .fetchDataList("user", fildate)
  13459. .then(function (response) {
  13460. if (response.status == 200) {
  13461. $scope.userdata = {};
  13462. $scope.userdata = response.list;
  13463. }
  13464. });
  13465. } else {
  13466. $scope.model[$scope.options.key] = {
  13467. id: groupdata.id.id,
  13468. };
  13469. $scope.options.templateOptions.transtlara(
  13470. $scope.model[$scope.options.key],
  13471. $scope
  13472. );
  13473. }
  13474. };
  13475. // }
  13476. },
  13477. ],
  13478. });
  13479. //请求科室信息(小蓝框) lmm
  13480. formlyConfigProvider.setType({
  13481. name: "ui-deptinformation",
  13482. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13483. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13484. return {
  13485. templateOptions: {
  13486. checkform: function (options) { },
  13487. },
  13488. };
  13489. },
  13490. controller: [
  13491. "$scope",
  13492. "api_statistic",
  13493. function ($scope, api_statistic) {
  13494. // console.log($scope)
  13495. },
  13496. ],
  13497. });
  13498. //请求人信息
  13499. formlyConfigProvider.setType({
  13500. name: "ui-requesterinformation",
  13501. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13502. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13503. return {
  13504. templateOptions: {
  13505. checkform: function (options) {
  13506. if (options.model.requester) {
  13507. options.value(options.model.requester);
  13508. }
  13509. },
  13510. addRequeter: function (size, options, modal, e) {
  13511. if (e) {
  13512. if (e.clientX === 0) {
  13513. return;
  13514. }
  13515. e.preventDefault();
  13516. }
  13517. var modalInstance = modal.open({
  13518. templateUrl:
  13519. "assets/views/customform/tpl/modal-add-callrequester.html",
  13520. controller: function (
  13521. $scope,
  13522. sco,
  13523. $rootScope,
  13524. $modalInstance,
  13525. items,
  13526. SweetAlert,
  13527. title,
  13528. Restangular,
  13529. APIService,
  13530. UserService,
  13531. api_user_data,
  13532. api_statistic,
  13533. api_wechatfile,
  13534. $stateParams
  13535. ) {
  13536. $modalInstance.SweetAlert = SweetAlert;
  13537. $scope.title = "新增报修人";
  13538. $scope.requester = {};
  13539. $scope.searchData = {};
  13540. $scope.isRoom = sessionStorage.getItem('ifRoom') == 1;
  13541. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13542. var paramsModel = JSON.parse($stateParams.model)
  13543. //来电-添加报修人-回显电话
  13544. if (paramsModel.model.incident.requester.hjzxPhone) {
  13545. $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
  13546. }
  13547. }
  13548. $scope.onChangeadd = function (searchData) {
  13549. $scope.searchKey = searchData.account;
  13550. // $scope.searchDataadd = searchData;
  13551. var requesdata = angular.copy(searchData);
  13552. if (requesdata.mphone) {
  13553. delete requesdata.mphone;
  13554. }
  13555. $scope.requester = requesdata;
  13556. console.log($scope.requester);
  13557. };
  13558. $scope.refreshUseradd = function (searchKey) {
  13559. //请求人搜索
  13560. $scope.requester.account = searchKey;
  13561. $scope.searchData = searchKey;
  13562. serchdataadd(searchKey);
  13563. };
  13564. $scope.getMydata = function (x) {
  13565. // $scope.searchField = JSON.parse(x[0]).account;
  13566. // $scope.requester = JSON.parse(x[0]);
  13567. // console.log($scope.requester);
  13568. // $scope.refreshArea('');
  13569. // $scope.refresh('');
  13570. var reqestdatap = JSON.parse(x[0]);
  13571. if ($scope.requester.telephone) {
  13572. delete reqestdatap.telephone;
  13573. }
  13574. $scope.searchField = JSON.parse(x[0]).account;
  13575. angular.extend($scope.requester, reqestdatap);
  13576. // $scope.searchField = JSON.parse(x[0]).account;
  13577. // $scope.requester = JSON.parse(x[0]);
  13578. console.log($scope.requester);
  13579. $scope.refreshArea('');
  13580. $scope.refresh('');
  13581. };
  13582. $scope.getMydataone = function (x) {
  13583. $scope.searchField = x;
  13584. $scope.requester.account = x;
  13585. };
  13586. serchdataadd();
  13587. api_wechatfile
  13588. .getDictionary({
  13589. type: "list",
  13590. key: "male",
  13591. })
  13592. .then(function (data) {
  13593. if (data.status == 200) {
  13594. requester.gender = data.list;
  13595. }
  13596. });
  13597. function serchdataadd(searchKey) {
  13598. if (searchKey) {
  13599. var filterData = {
  13600. requester: {
  13601. searchKey: searchKey,
  13602. },
  13603. idx: 0,
  13604. sum: 10,
  13605. };
  13606. } else {
  13607. var filterData = {
  13608. idx: 0,
  13609. sum: 10,
  13610. };
  13611. }
  13612. api_user_data
  13613. .fetchDataList("requester", filterData)
  13614. .then(function (response) {
  13615. var myData = response;
  13616. $scope.myData = myData.list;
  13617. });
  13618. }
  13619. api_user_data
  13620. .fetchDataList("branch", {
  13621. idx: 0,
  13622. sum: 1000,
  13623. })
  13624. .then(function (response) {
  13625. if (response.status == 200) {
  13626. $scope.branchs = response.list;
  13627. }
  13628. });
  13629. // api_user_data
  13630. // .fetchDataList("area", {
  13631. // idx: 0,
  13632. // sum: 1000,
  13633. // })
  13634. // .then(function (response) {
  13635. // if (response.status == 200) {
  13636. // $scope.areas = response.list;
  13637. // }
  13638. // });
  13639. api_wechatfile
  13640. .getDictionary(
  13641. {
  13642. key: "requester_type",
  13643. type: "list",
  13644. },
  13645. {
  13646. idx: 0,
  13647. sum: 100,
  13648. }
  13649. )
  13650. .then(function (response) {
  13651. if (response) {
  13652. $scope.networktypes = response;
  13653. }
  13654. });
  13655. $scope.onChangeBranch = function (item) {
  13656. delete $scope.requester.place;
  13657. console.log($scope.requester, 'changeArea');
  13658. api_user_data
  13659. .fetchDataList("area", {
  13660. area: {
  13661. branch: item.id,
  13662. },
  13663. idx: 0,
  13664. sum: 1000,
  13665. })
  13666. .then(function (response) {
  13667. if (response.status == 200) {
  13668. $scope.areas = response.list;
  13669. }
  13670. });
  13671. };
  13672. $scope.onChange = function (item) {
  13673. $scope.requester.place = {area: $scope.requester.place.area};
  13674. console.log($scope.requester, 'changeArea');
  13675. api_user_data
  13676. .fetchDataList("place", {
  13677. place: {
  13678. area: {
  13679. id: item.id,
  13680. },
  13681. },
  13682. idx: 0,
  13683. sum: 1000,
  13684. })
  13685. .then(function (response) {
  13686. if (response.status == 200) {
  13687. $scope.places = response.list;
  13688. delete $scope.requester.placeDTO;
  13689. }
  13690. });
  13691. };
  13692. // 修改地点
  13693. $scope.requesterPlaceid = "";
  13694. $scope.onChangePlace = function (item) {
  13695. $scope.requesterPlaceid = item.id;
  13696. console.log($scope.requester, 'changePlace');
  13697. api_user_data
  13698. .fetchDataList("room", {
  13699. room: {
  13700. place: {
  13701. id: item.id,
  13702. },
  13703. },
  13704. idx: 0,
  13705. sum: 1000,
  13706. })
  13707. .then(function (response) {
  13708. if (response.status == 200) {
  13709. $scope.rooms = response.list;
  13710. }
  13711. });
  13712. };
  13713. $scope.refreshArea = function (searchVal) {
  13714. console.log($scope.requester, 'area');
  13715. var faildata = {};
  13716. if ($scope.requester.branch) {
  13717. faildata = {
  13718. idx: 0,
  13719. sum: 1000,
  13720. area: {
  13721. branch: $scope.requester.branch.id,
  13722. area: searchVal,
  13723. selectType: "pinyin_qs",
  13724. },
  13725. };
  13726. } else {
  13727. return;
  13728. }
  13729. api_user_data
  13730. .fetchDataList("area", faildata)
  13731. .then(function (response) {
  13732. $scope.areas = response.list;
  13733. delete $scope.requester.areaDTO;
  13734. });
  13735. };
  13736. $scope.refresh = function (searchVal) {
  13737. console.log($scope.requester, 'place');
  13738. var faildata = {};
  13739. if ($scope.requester.place && $scope.requester.place.area) {
  13740. faildata = {
  13741. idx: 0,
  13742. sum: 1000,
  13743. place: {
  13744. areaId: $scope.requester.place.area.id,
  13745. place: searchVal,
  13746. selectType: "pinyin_qs",
  13747. },
  13748. };
  13749. } else {
  13750. return;
  13751. }
  13752. api_user_data
  13753. .fetchDataList("place", faildata)
  13754. .then(function (response) {
  13755. $scope.places = response.list;
  13756. delete $scope.requester.placeDTO;
  13757. });
  13758. };
  13759. // 初始化房间号
  13760. $scope.refreshRoom = function () {
  13761. var faildata = {};
  13762. if ($scope.requesterPlaceid) {
  13763. faildata = {
  13764. idx: 0,
  13765. sum: 1000,
  13766. room: {
  13767. place: {id:$scope.requesterPlaceid},
  13768. },
  13769. };
  13770. } else {
  13771. faildata = {
  13772. idx: 0,
  13773. sum: 1000,
  13774. room: {
  13775. place: {id:$scope.requesterPlaceid},
  13776. },
  13777. };
  13778. }
  13779. api_user_data
  13780. .fetchDataList("room", faildata)
  13781. .then(function (response) {
  13782. $scope.rooms = response.list;
  13783. });
  13784. };
  13785. $scope.refreshDepts = function (key) {
  13786. var filterData = {
  13787. idx: 0,
  13788. sum: 5,
  13789. dept: {
  13790. name: key,
  13791. },
  13792. };
  13793. UserService.fetchDataList("department", filterData).then(
  13794. function (response) {
  13795. if (response.status == 200) {
  13796. $scope.depts = response.list;
  13797. }
  13798. }
  13799. );
  13800. };
  13801. $scope.ok = function () {
  13802. if (
  13803. angular.isUndefined($scope.requester.account) ||
  13804. $scope.requester.account == null ||
  13805. $scope.requester.account == ""
  13806. ) {
  13807. SweetAlert.swal(
  13808. "报修人员编号未填!",
  13809. "请填写报修人员编号",
  13810. "error"
  13811. );
  13812. } else if (
  13813. angular.isUndefined($scope.requester.name) ||
  13814. $scope.requester.name == null ||
  13815. $scope.requester.name == ""
  13816. ) {
  13817. SweetAlert.swal(
  13818. "报修人姓名未填!",
  13819. "请填写报修人姓名",
  13820. "error"
  13821. );
  13822. } else if (
  13823. angular.isUndefined($scope.requester.requesterType) ||
  13824. $scope.requester.requesterType == null ||
  13825. $scope.requester.requesterTypeDTO == ""
  13826. ) {
  13827. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13828. } else if (
  13829. angular.isUndefined($scope.requester.mphone) ||
  13830. $scope.requester.mphone == null ||
  13831. $scope.requester.mphone == ""
  13832. ) {
  13833. SweetAlert.swal(
  13834. "报修人联系电话未填!",
  13835. "请填写报修人联系电话",
  13836. "error"
  13837. );
  13838. } else {
  13839. $scope.requesterId = $scope.requester.id;
  13840. var data = {
  13841. incident: {
  13842. requester: {
  13843. id: $scope.requesterId,
  13844. },
  13845. },
  13846. idx: 0,
  13847. sum: 3,
  13848. };
  13849. api_statistic
  13850. .tableData(data, "incident")
  13851. .then(function (data) {
  13852. sco.$parent.$parent.$parent.model.incident.tableList =
  13853. data.list;
  13854. });
  13855. $scope.$watch(
  13856. sco.$parent.$parent.$parent.model.incident.tableList,
  13857. function (oldObj, newObj) {
  13858. if (newObj != oldObj) {
  13859. sco.$parent.$parent.$parent.model.incident.tableList =
  13860. newObj;
  13861. }
  13862. }
  13863. );
  13864. console.log($scope.requester);
  13865. $modalInstance.close($scope.requester);
  13866. }
  13867. };
  13868. $scope.cancel = function () {
  13869. $modalInstance.dismiss("cancel");
  13870. };
  13871. },
  13872. resolve: {
  13873. items: function () {
  13874. return {
  13875. fetchItems: function (filterData, APIService) {
  13876. filterData = filterData || {};
  13877. if (!filterData.idx) {
  13878. filterData = {
  13879. idx: 0,
  13880. sum: 10,
  13881. };
  13882. }
  13883. return options.templateOptions.fetchItems(
  13884. filterData,
  13885. APIService
  13886. );
  13887. },
  13888. };
  13889. },
  13890. title: function () {
  13891. return options.templateOptions.modalTitle;
  13892. },
  13893. Restangular: function () {
  13894. return options.templateOptions.Restangular;
  13895. },
  13896. APIService: function () {
  13897. return options.templateOptions.ApiService;
  13898. },
  13899. UserService: function () {
  13900. return options.templateOptions.UserService;
  13901. },
  13902. sco: function () {
  13903. return $scope;
  13904. },
  13905. },
  13906. });
  13907. modalInstance.result.then(
  13908. function (selectedItem) {
  13909. console.log(selectedItem);
  13910. if (selectedItem) {
  13911. var data = {
  13912. requester: selectedItem,
  13913. };
  13914. $scope.searchKey = selectedItem.account;
  13915. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13916. // if (selectedItem.place && selectedItem.place.place) {
  13917. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13918. // }
  13919. options.templateOptions.UserService.addData(
  13920. "requester",
  13921. data
  13922. ).then(function (response) {
  13923. if (response.status == 200) {
  13924. if (options.model) {
  13925. options.model.requester = response.data;
  13926. $scope.$parent.$parent.$parent.model.incident.requester =
  13927. response.data;
  13928. $scope.$parent.$parent.$parent.model.requestershow =
  13929. response.data;
  13930. if (options.model.place) {
  13931. options.model.place.id = "";
  13932. }
  13933. if (options.model.area) {
  13934. options.model.area.id = "";
  13935. }
  13936. options.model.contacts = selectedItem.name;
  13937. if (
  13938. selectedItem.mphone &&
  13939. selectedItem.mphone != null &&
  13940. selectedItem.mphone != ""
  13941. ) {
  13942. options.model.contactsInformation =
  13943. selectedItem.mphone;
  13944. } else {
  13945. options.model.contactsInformation =
  13946. selectedItem.telephone;
  13947. }
  13948. if (
  13949. selectedItem.requesterTypeDTO &&
  13950. selectedItem.requesterTypeDTO.id == 2
  13951. ) {
  13952. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13953. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13954. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13955. }
  13956. }
  13957. if (!response.data.id) {
  13958. response.data.id = selectedItem.id;
  13959. }
  13960. options.value(response.data);
  13961. options.value(response.data);
  13962. console.log($scope, "0000000");
  13963. //新增报修人带入区域地点2020年4月23日19:48:15
  13964. $scope.model.selecthouseNumber = selectedItem.place
  13965. ? selectedItem.place
  13966. : {};
  13967. $scope.$root.selecthouseNumber = selectedItem.place
  13968. ? selectedItem.place
  13969. : {};
  13970. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13971. if (selectedItem.place && selectedItem.place.id) {
  13972. options.model.place.id = selectedItem.place.id;
  13973. options.model.place.area.id = selectedItem.place.area.id;
  13974. if(selectedItem.branch && selectedItem.branch.id){
  13975. options.model.branch.id = selectedItem.branch.id;
  13976. console.log($scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields);
  13977. let fields = $scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields;
  13978. for (let i = 0; i < fields.length; i++) {
  13979. if(fields[i].templateOptions.onlyKey == 'area_start'){
  13980. // 如果是区域
  13981. options.templateOptions.UserService.fetchDataList('area', { idx: 0, sum: 1000, area:{branch:options.model.branch.id} }).then(function(response) {
  13982. if (response.status == 200) {
  13983. fields[i].templateOptions.options = response.list;
  13984. }
  13985. })
  13986. }else if(fields[i].templateOptions.onlyKey == 'place_start'){
  13987. // 如果是地点
  13988. options.templateOptions.UserService.fetchDataList('place', { idx: 0, sum: 1000, place:{area:{id:options.model.area.id}} }).then(function(response) {
  13989. if (response.status == 200) {
  13990. fields[i].templateOptions.options = response.list;
  13991. }
  13992. })
  13993. }
  13994. }
  13995. }
  13996. }
  13997. } else {
  13998. if (selectedItem.place && selectedItem.place.id) {
  13999. options.model.place.id = selectedItem.place.id;
  14000. options.model.area.id = selectedItem.place.area.id;
  14001. if(selectedItem.branch && selectedItem.branch.id){
  14002. options.model.branch.id = selectedItem.branch.id;
  14003. console.log($scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields);
  14004. let fields = $scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields;
  14005. for (let i = 0; i < fields.length; i++) {
  14006. if(fields[i].templateOptions.onlyKey == 'area_start'){
  14007. // 如果是区域
  14008. options.templateOptions.UserService.fetchDataList('area', { idx: 0, sum: 1000, area:{branch:options.model.branch.id} }).then(function(response) {
  14009. if (response.status == 200) {
  14010. fields[i].templateOptions.options = response.list;
  14011. }
  14012. })
  14013. }else if(fields[i].templateOptions.onlyKey == 'place_start'){
  14014. // 如果是地点
  14015. options.templateOptions.UserService.fetchDataList('place', { idx: 0, sum: 1000, place:{area:{id:options.model.area.id}} }).then(function(response) {
  14016. if (response.status == 200) {
  14017. fields[i].templateOptions.options = response.list;
  14018. }
  14019. })
  14020. }
  14021. }
  14022. }
  14023. }
  14024. }
  14025. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  14026. // options.model.area.id = selectedItem.place.area.id
  14027. // }
  14028. if (selectedItem.houseNumber) {
  14029. options.model.houseNumber = selectedItem.houseNumber;
  14030. }
  14031. if (selectedItem.room) {
  14032. options.model.room.id = selectedItem.room.id;
  14033. }
  14034. // if (selectedItem.id) {
  14035. options.model.account = selectedItem.account;
  14036. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  14037. var baoxiuFields =
  14038. $scope.$parent.$parent.$parent.$parent.$parent.vm
  14039. .fields[1].fields;
  14040. var baoxiurenTo;
  14041. baoxiuFields.forEach((e, i) => {
  14042. if (e.key == "account") {
  14043. baoxiurenTo = e.templateOptions;
  14044. baoxiurenTo.APIService.fetchDataList("requester", {
  14045. idx: 0,
  14046. sum: 20,
  14047. requester: {
  14048. searchKey: selectedItem.account,
  14049. },
  14050. }).then((res) => {
  14051. baoxiurenTo.options = res.list;
  14052. options.model.account = selectedItem.account;
  14053. });
  14054. }
  14055. });
  14056. // }
  14057. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  14058. // 选择重复事件侧滑框
  14059. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  14060. $scope.$parent.$parent.$parent.model[
  14061. "repeatIncidentShow"
  14062. ] = false;
  14063. setTimeout(() => {
  14064. $scope.$parent.$parent.$parent.model[
  14065. "repeatIncidentShow"
  14066. ] = true;
  14067. }, 500);
  14068. // }
  14069. } else {
  14070. modalInstance.SweetAlert.swal({
  14071. title: "系统错误",
  14072. text: "账号重复!",
  14073. type: "error",
  14074. });
  14075. }
  14076. });
  14077. }
  14078. },
  14079. function () { }
  14080. );
  14081. },
  14082. changeRequeter: function (
  14083. size,
  14084. options,
  14085. modal,
  14086. modeldata,
  14087. $rootScope
  14088. ) {
  14089. var modalInstance = modal.open({
  14090. templateUrl:
  14091. "assets/views/customform/tpl/modal-change-requester.html",
  14092. controller: function (
  14093. $scope,
  14094. $modalInstance,
  14095. items,
  14096. SweetAlert,
  14097. title,
  14098. Restangular,
  14099. APIService,
  14100. UserService,
  14101. api_user_data,
  14102. $rootScope
  14103. ) {
  14104. $scope.title = "修改报修人";
  14105. $scope.requester = {
  14106. id: modeldata.requester.id,
  14107. account: modeldata.requester.account,
  14108. name: modeldata.requester.name,
  14109. gender: modeldata.requester.gender,
  14110. email: modeldata.requester.email,
  14111. deptName: modeldata.requester.deptName,
  14112. mphone: modeldata.requester.mphone,
  14113. telephone: modeldata.requester.telephone,
  14114. studentNo: modeldata.requester.studentNo,
  14115. areaDTO: modeldata.requester.areaDTO,
  14116. placeDTO: modeldata.requester.placeDTO,
  14117. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  14118. };
  14119. $scope.onChangeadd = function (searchData) {
  14120. console.log(searchData);
  14121. $scope.searchKey = searchData.account;
  14122. var requesdata = angular.copy(searchData);
  14123. if (requesdata.mphone) {
  14124. delete requesdata.mphone;
  14125. }
  14126. $scope.requester = requesdata;
  14127. };
  14128. $scope.refreshUseradd = function (searchKey) {
  14129. //请求人搜索
  14130. $scope.requester.account = searchKey;
  14131. $scope.searchData = searchKey;
  14132. serchdataadd(searchKey);
  14133. };
  14134. $scope.getMydata = function (x) {
  14135. $scope.searchField = JSON.parse(x[0]).account;
  14136. $scope.requester = JSON.parse(x[0]);
  14137. };
  14138. $scope.getMydataone = function (x) {
  14139. $scope.searchField = x;
  14140. $scope.requester.account = x;
  14141. };
  14142. serchdataadd();
  14143. function serchdataadd(searchKey) {
  14144. if (searchKey) {
  14145. var filterData = {
  14146. requester: {
  14147. searchKey: searchKey,
  14148. },
  14149. idx: 0,
  14150. sum: 10,
  14151. };
  14152. } else {
  14153. var filterData = {
  14154. idx: 0,
  14155. sum: 10,
  14156. };
  14157. }
  14158. api_user_data
  14159. .fetchDataList("requester", filterData)
  14160. .then(function (response) {
  14161. var myData = response;
  14162. $scope.myData = myData.list;
  14163. });
  14164. }
  14165. api_user_data
  14166. .fetchDataList("area", {
  14167. idx: 0,
  14168. sum: 1000,
  14169. })
  14170. .then(function (response) {
  14171. if (response.status == 200) {
  14172. $scope.areas = response.list;
  14173. }
  14174. });
  14175. api_user_data
  14176. .fetchDataList("requesterType", {
  14177. idx: 0,
  14178. sum: 100,
  14179. })
  14180. .then(function (response) {
  14181. if (response.status == 200) {
  14182. $scope.networktypes = response.list;
  14183. }
  14184. });
  14185. if (
  14186. $scope.requester.areaDTO &&
  14187. $scope.requester.areaDTO.id &&
  14188. $scope.requester.areaDTO.id != ""
  14189. ) {
  14190. api_user_data
  14191. .fetchDataList("place", {
  14192. place: {
  14193. areaId: $scope.requester.areaDTO.id,
  14194. },
  14195. idx: 0,
  14196. sum: 1000,
  14197. })
  14198. .then(function (response) {
  14199. if (response.status == 200) {
  14200. $scope.places = response.list;
  14201. }
  14202. });
  14203. }
  14204. $scope.onChange = function (item) {
  14205. $scope.requester.placeDTO = {};
  14206. api_user_data
  14207. .fetchDataList("place", {
  14208. place: {
  14209. areaId: item.id,
  14210. },
  14211. idx: 0,
  14212. sum: 1000,
  14213. })
  14214. .then(function (response) {
  14215. if (response.status == 200) {
  14216. $scope.places = response.list;
  14217. }
  14218. });
  14219. };
  14220. $scope.refreshDepts = function (key) {
  14221. var filterData = {
  14222. idx: 0,
  14223. sum: 5,
  14224. dept: {
  14225. name: key,
  14226. },
  14227. };
  14228. UserService.fetchDataList("department", filterData).then(
  14229. function (response) {
  14230. if (response.status == 200) {
  14231. $scope.depts = response.list;
  14232. }
  14233. }
  14234. );
  14235. };
  14236. $scope.ok = function () {
  14237. if (
  14238. $scope.requester.account == "" ||
  14239. $scope.requester.name == ""
  14240. ) {
  14241. SweetAlert.swal(
  14242. "报修人姓名或人员编号号未填!",
  14243. "请补全报修人信息",
  14244. "error"
  14245. );
  14246. } else {
  14247. $modalInstance.close($scope.requester);
  14248. }
  14249. };
  14250. $scope.cancel = function () {
  14251. $modalInstance.dismiss("cancel");
  14252. };
  14253. },
  14254. resolve: {
  14255. items: function () {
  14256. return {
  14257. fetchItems: function (filterData, APIService) {
  14258. filterData = filterData || {};
  14259. if (!filterData.idx) {
  14260. filterData = {
  14261. idx: 0,
  14262. sum: 10,
  14263. };
  14264. }
  14265. return options.templateOptions.fetchItems(
  14266. filterData,
  14267. APIService
  14268. );
  14269. },
  14270. };
  14271. },
  14272. title: function () {
  14273. return options.templateOptions.modalTitle;
  14274. },
  14275. Restangular: function () {
  14276. return options.templateOptions.Restangular;
  14277. },
  14278. APIService: function () {
  14279. return options.templateOptions.ApiService;
  14280. },
  14281. UserService: function () {
  14282. return options.templateOptions.UserService;
  14283. },
  14284. },
  14285. });
  14286. modalInstance.result.then(
  14287. function (selectedItem) {
  14288. console.log(selectedItem);
  14289. if (selectedItem) {
  14290. if (options.model) {
  14291. if (options.model.place) {
  14292. options.model.place.id = "";
  14293. }
  14294. if (options.model.area) {
  14295. options.model.area.id = "";
  14296. }
  14297. options.model.contacts = selectedItem.name;
  14298. if (
  14299. selectedItem.mphone &&
  14300. selectedItem.mphone != null &&
  14301. selectedItem.mphone != ""
  14302. ) {
  14303. options.model.contactsInformation = selectedItem.mphone;
  14304. } else {
  14305. options.model.contactsInformation =
  14306. selectedItem.telephone;
  14307. }
  14308. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14309. options.model.place.id = selectedItem.placeDTO.id;
  14310. }
  14311. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14312. options.model.area.id = selectedItem.areaDTO.id;
  14313. }
  14314. if (
  14315. selectedItem.requesterTypeDTO &&
  14316. selectedItem.requesterTypeDTO.id == 2
  14317. ) {
  14318. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14319. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14320. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14321. }
  14322. }
  14323. var data = {
  14324. requester: selectedItem,
  14325. };
  14326. options.templateOptions.UserService.addData(
  14327. "requester",
  14328. data
  14329. ).then(function (response) {
  14330. if (response.status == 200) {
  14331. $scope.$parent.$parent.$parent.model["requestershow"] =
  14332. selectedItem;
  14333. options.value(response.data);
  14334. } else {
  14335. }
  14336. });
  14337. }
  14338. },
  14339. function () { }
  14340. );
  14341. event.preventDefault();
  14342. },
  14343. },
  14344. };
  14345. },
  14346. controller: [
  14347. "$scope",
  14348. "api_user_data",
  14349. "api_statistic",
  14350. "$stateParams",
  14351. "api_bpm_data",
  14352. function ($scope, api_user_data, api_statistic, $stateParams,api_bpm_data) {
  14353. console.log($stateParams)
  14354. // 一键复制
  14355. $scope.quickCopy = function(model){
  14356. // 姓名,工号,来电电话,地点,详细地址,事件描述 liaomingming
  14357. console.log(model);
  14358. var text = '';
  14359. if(model.place.id){
  14360. api_bpm_data.fetchData("place", model.place.id)
  14361. .then(function (response) {
  14362. if (response.status == 200) {
  14363. text = `姓名:${model.requester?model.requester.name:''}\r\n工号:${model.requester?model.requester.account:''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${response.data.place||''}\r\n详细地址:${model.houseNumber||''}\r\n事件描述:${model.description||''}`;
  14364. var textarea = document.createElement('textarea');
  14365. document.body.appendChild(textarea);
  14366. // 隐藏此输入框
  14367. textarea.style.position = 'fixed';
  14368. textarea.style.clip = 'rect(0 0 0 0)';
  14369. textarea.style.top = '10px';
  14370. // 赋值
  14371. textarea.value = text;
  14372. // 选中
  14373. textarea.select();
  14374. // 复制
  14375. document.execCommand('copy', true);
  14376. // 移除输入框
  14377. document.body.removeChild(textarea);
  14378. }
  14379. });
  14380. }else{
  14381. text = `姓名:${model.contacts||''}\r\n工号:${model.account||''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${''}\r\n详细地址:${model.houseNumber||''}\r\n事件描述:${model.description||''}`;
  14382. var textarea = document.createElement('textarea');
  14383. document.body.appendChild(textarea);
  14384. // 隐藏此输入框
  14385. textarea.style.position = 'fixed';
  14386. textarea.style.clip = 'rect(0 0 0 0)';
  14387. textarea.style.top = '10px';
  14388. // 赋值
  14389. textarea.value = text;
  14390. // 选中
  14391. textarea.select();
  14392. // 复制
  14393. document.execCommand('copy', true);
  14394. // 移除输入框
  14395. document.body.removeChild(textarea);
  14396. }
  14397. event.preventDefault();
  14398. //提示
  14399. alert('复制成功');
  14400. }
  14401. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14402. var paramsModel = JSON.parse($stateParams.model)
  14403. //来电-添加报修人
  14404. if (paramsModel.model.incident.requester.hjzxPhone) {
  14405. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14406. }
  14407. }
  14408. $scope.options.initialValue = $scope.model[$scope.options.key];
  14409. $scope.saveReqPlace = false;
  14410. $scope.model.saveReqPlace = false;
  14411. $scope.selectGradeBox = function () {
  14412. $scope.saveReqPlace = !$scope.saveReqPlace;
  14413. console.log($scope);
  14414. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14415. };
  14416. if (
  14417. $scope.model.requester &&
  14418. $scope.model.requester.requesterTypeDTO &&
  14419. $scope.model.requester.requesterTypeDTO.id == 2
  14420. ) {
  14421. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14422. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14423. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14424. }
  14425. },
  14426. ],
  14427. });
  14428. // 请求人选控件
  14429. formlyConfigProvider.setType({
  14430. name: "ui-requesterselect",
  14431. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14432. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14433. defaultOptions: function (options, $scope) {
  14434. return {
  14435. templateOptions: {
  14436. // checkform: function(options) {
  14437. // if (options.model.requestershow) {
  14438. // options.value(options.model.requestershow);
  14439. // }
  14440. // },
  14441. validators: {
  14442. required: {
  14443. expression: function (viewValue, modelValue) {
  14444. var value = modelValue || viewValue;
  14445. return value.length >= 1;
  14446. },
  14447. },
  14448. },
  14449. openModal: function (size, options, modal) {
  14450. //查找弹出框
  14451. var modelObject = options.value();
  14452. var searchModal = function (filterSearchData) {
  14453. var modalInstance = modal.open({
  14454. templateUrl:
  14455. "assets/views/customform/tpl/checktable-modal-content.html",
  14456. controller: function (
  14457. $scope,
  14458. scope,
  14459. i18nService,
  14460. $modalInstance,
  14461. items,
  14462. title,
  14463. Restangular,
  14464. APIService,
  14465. language,
  14466. searchDatas,
  14467. api_bpm_data
  14468. ) {
  14469. $scope.langs = i18nService.getAllLangs();
  14470. $scope.lang = "zh-cn";
  14471. i18nService.setCurrentLang($scope.lang);
  14472. $scope.gridOptions = {};
  14473. $scope.gridOptions.data = "myData";
  14474. $scope.gridOptions.enableColumnResizing = true;
  14475. $scope.gridOptions.enableFiltering = true;
  14476. $scope.gridOptions.enableGridMenu = false;
  14477. $scope.gridOptions.enableRowSelection = true;
  14478. $scope.gridOptions.showGridFooter = true;
  14479. $scope.gridOptions.showColumnFooter = false;
  14480. $scope.gridOptions.fastWatch = true;
  14481. $scope.gridOptions.useExternalFiltering = true;
  14482. $scope.gridOptions.useExternalPagination = true;
  14483. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14484. $scope.gridOptions.paginationPageSize = 10;
  14485. $scope.gridOptions.multiSelect = false;
  14486. $scope.gridOptions.rowIdentity = function (row) {
  14487. return row.id;
  14488. };
  14489. $scope.gridOptions.getRowIdentity = function (row) {
  14490. return row.id;
  14491. };
  14492. $scope.gridOptions.columnDefs = [
  14493. {
  14494. name: "account",
  14495. displayName: "人员编号",
  14496. width: 140,
  14497. },
  14498. {
  14499. name: "name",
  14500. displayName: "姓名",
  14501. width: 100,
  14502. },
  14503. {
  14504. name: "gender.name",
  14505. displayName: "性别",
  14506. width: 80,
  14507. enableFiltering: false,
  14508. },
  14509. {
  14510. name: "mphone",
  14511. displayName: "电话",
  14512. width: 100,
  14513. enableFiltering: false,
  14514. },
  14515. {
  14516. name: "email",
  14517. displayName: "邮件",
  14518. width: 100,
  14519. },
  14520. {
  14521. name: "areaDTO.area",
  14522. displayName: "区域",
  14523. width: 100,
  14524. enableFiltering: false,
  14525. },
  14526. {
  14527. name: "placeDTO.place",
  14528. displayName: "地点",
  14529. enableFiltering: false,
  14530. },
  14531. ];
  14532. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14533. $scope.gridApi = gridApi;
  14534. // var filtersData = $scope.memoryfilterData;
  14535. // filtersData.idx = newPage - 1;
  14536. // filtersData.sum = pageSize;
  14537. gridApi.pagination.on.paginationChanged(
  14538. $scope,
  14539. function (newPage, pageSize) {
  14540. var filtersData = $scope.memoryfilterData;
  14541. filtersData.idx = newPage - 1;
  14542. filtersData.sum = pageSize;
  14543. $scope.loadData(filtersData);
  14544. }
  14545. );
  14546. gridApi.selection.on.rowSelectionChanged(
  14547. $scope,
  14548. function (data) {
  14549. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14550. $scope.selected.item = data.entity;
  14551. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14552. }
  14553. );
  14554. gridApi.core.on.filterChanged($scope, function () {
  14555. var grid = this.grid;
  14556. var filtersData = {
  14557. idx: 0,
  14558. sum: 10,
  14559. // 'requester': { 'userType': 1 }
  14560. };
  14561. angular.forEach(grid.columns, function (item) {
  14562. if (item.enableFiltering) {
  14563. if (
  14564. angular.isDefined(item.filters[0].term) &&
  14565. item.filters[0].term != ""
  14566. ) {
  14567. if (angular.isUndefined(filtersData["requester"])) {
  14568. filtersData["requester"] = {};
  14569. }
  14570. filtersData["requester"][item.field] =
  14571. item.filters[0].term;
  14572. }
  14573. }
  14574. });
  14575. $scope.memoryfilterData = filtersData;
  14576. $scope.loadData(filtersData);
  14577. });
  14578. };
  14579. $scope.memoryfilterData = defaultFilterData = {
  14580. idx: 0,
  14581. sum: 10,
  14582. };
  14583. $scope.loadData = function (filterData) {
  14584. if (!filterData.requester) {
  14585. filterData.requester = {};
  14586. }
  14587. if (scope.roleidcode) {
  14588. angular.extend(filterData["requester"], {
  14589. userType: 1,
  14590. });
  14591. }
  14592. items
  14593. .fetchItems(filterData, APIService)
  14594. .then(function (data) {
  14595. var myData = Restangular.stripRestangular(data);
  14596. $scope.gridOptions.totalItems = myData.totalNum;
  14597. $scope.myData = myData.list;
  14598. });
  14599. };
  14600. // $scope.title = title;
  14601. if (searchDatas) {
  14602. $scope.loadData(searchDatas);
  14603. } else {
  14604. $scope.loadData({
  14605. idx: 0,
  14606. sum: 10,
  14607. });
  14608. }
  14609. $scope.selected = {
  14610. item: {},
  14611. };
  14612. $scope.ok = function () {
  14613. $modalInstance.close($scope.selected.item);
  14614. };
  14615. $scope.cancel = function () {
  14616. $modalInstance.dismiss("cancel");
  14617. };
  14618. },
  14619. size: size,
  14620. resolve: {
  14621. items: function () {
  14622. return {
  14623. fetchItems: function (filterData, APIService) {
  14624. filterData = filterData || {};
  14625. if (
  14626. angular.isUndefined(filterData.idx) ||
  14627. filterData.idx == null
  14628. ) {
  14629. filterData = {
  14630. idx: 0,
  14631. sum: 10,
  14632. };
  14633. }
  14634. return options.templateOptions.fetchItems(
  14635. filterData,
  14636. APIService
  14637. );
  14638. },
  14639. };
  14640. },
  14641. title: function () {
  14642. return options.templateOptions.modalTitle;
  14643. },
  14644. Restangular: function () {
  14645. return options.templateOptions.Restangular;
  14646. },
  14647. APIService: function () {
  14648. return options.templateOptions.ApiService;
  14649. },
  14650. language: function () {
  14651. return options.templateOptions.language;
  14652. },
  14653. searchDatas: function () {
  14654. return filterSearchData;
  14655. },
  14656. scope: function () {
  14657. return $scope;
  14658. },
  14659. },
  14660. });
  14661. modalInstance.result.then(
  14662. function (selectedItem) {
  14663. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14664. selectedItem.telephone =
  14665. $scope.model.incident.contactsInformation;
  14666. }
  14667. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14668. selectedItem;
  14669. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14670. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14671. if ($scope.model) {
  14672. if ($scope.model.incident.place) {
  14673. $scope.model.incident.place.id = "";
  14674. }
  14675. if ($scope.model.area) {
  14676. $scope.model.incident.area.id = "";
  14677. }
  14678. $scope.model.incident.contacts = selectedItem.name;
  14679. if (
  14680. selectedItem.mphone &&
  14681. selectedItem.mphone != null &&
  14682. selectedItem.mphone != ""
  14683. ) {
  14684. $scope.model.incident.contactsInformation =
  14685. selectedItem.mphone;
  14686. } else {
  14687. $scope.model.incident.contactsInformation =
  14688. selectedItem.telephone;
  14689. }
  14690. $scope.model.incident.houseNumber = "";
  14691. if (
  14692. selectedItem.requesterTypeDTO &&
  14693. selectedItem.requesterTypeDTO.id == 2
  14694. ) {
  14695. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14696. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14697. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14698. }
  14699. }
  14700. $scope.options.value(selectedItem);
  14701. $scope.searchData = selectedItem.account;
  14702. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14703. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14704. }
  14705. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14706. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14707. }
  14708. if (selectedItem.houseNumber) {
  14709. $scope.model.incident.houseNumber =
  14710. selectedItem.houseNumber;
  14711. }
  14712. if (
  14713. selectedItem.requesterTypeDTO &&
  14714. selectedItem.requesterTypeDTO.id == 2
  14715. ) {
  14716. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14717. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14718. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14719. }
  14720. if (
  14721. options.templateOptions.callback &&
  14722. angular.isFunction(options.templateOptions.callback)
  14723. ) {
  14724. options.templateOptions.callback(selectedItem, options);
  14725. }
  14726. if (!$scope.roleidcode) {
  14727. $scope.charging(selectedItem, modal);
  14728. }
  14729. $scope.recentlyincident(selectedItem);
  14730. },
  14731. function () {
  14732. //console.log('Modal dismissed at: ' + new Date());
  14733. }
  14734. );
  14735. };
  14736. searchModal();
  14737. // }
  14738. },
  14739. },
  14740. };
  14741. },
  14742. controller: [
  14743. "$rootScope",
  14744. "$scope",
  14745. "ngTableParams",
  14746. "$filter",
  14747. "SweetAlert",
  14748. "moment",
  14749. function (
  14750. $rootScope,
  14751. $scope,
  14752. ngTableParams,
  14753. $filter,
  14754. SweetAlert,
  14755. moment
  14756. ) {
  14757. $scope.isHk = $rootScope.isHk;
  14758. $scope.roleidcode = true;
  14759. // $scope.options.initialValue = undefined;
  14760. if ($rootScope.user && $rootScope.user.role) {
  14761. angular.forEach($rootScope.user.role, function (item) {
  14762. if (item.rolecode == "call center") {
  14763. $scope.roleidcode = false;
  14764. }
  14765. });
  14766. }
  14767. $scope.recently = false;
  14768. $scope.recentlyincident = function (key, model) {
  14769. //关联事件
  14770. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14771. idx: 0,
  14772. sum: 4,
  14773. incident: {
  14774. requester: {
  14775. id: key.id,
  14776. },
  14777. },
  14778. }).then(function (response) {
  14779. if (response.status == 200) {
  14780. $scope.recently = true;
  14781. $scope.recentincident = response.list;
  14782. } else {
  14783. $scope.recently = false;
  14784. }
  14785. });
  14786. $scope.bodyHeight = window.innerHeight - 100;
  14787. $(window).resize(function () {
  14788. $scope.bodyHeight = window.innerHeight - 100;
  14789. });
  14790. // $scope.shows = false;
  14791. $scope.tempData = {};
  14792. $scope.close = function () {
  14793. $scope.changes = !$scope.changes;
  14794. event.preventDefault();
  14795. };
  14796. };
  14797. $scope.charging = function (key, model) {
  14798. //计费弹出框
  14799. //用户信息
  14800. $scope.information = {};
  14801. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14802. userId: key.account,
  14803. }).then(function (response) {
  14804. // if (response.status == 200) {
  14805. if (response && response.data) {
  14806. angular.extend($scope.information, response.data[0]);
  14807. // $scope.information = response.data[0];
  14808. $scope.information.autologicDestroyTime = moment(
  14809. response.data[0].autologicDestroyTime
  14810. ).format("YYYY-MM-DD");
  14811. $scope.information.periodStartTime = moment(
  14812. response.data[0].periodStartTime
  14813. ).format("YYYY-MM-DD");
  14814. $scope.information.nextBillingTime = moment(
  14815. response.data[0].nextBillingTime
  14816. ).format("YYYY-MM-DD");
  14817. } else if (response.err) {
  14818. SweetAlert.swal(
  14819. "系统错误!",
  14820. "用户信息未取到,请刷新重试",
  14821. "error"
  14822. );
  14823. }
  14824. // }
  14825. });
  14826. //上网明细
  14827. $scope.options.templateOptions.ApiSer.fetchDataList(
  14828. "queryOnlineDetail",
  14829. {
  14830. userId: key.account,
  14831. limit: "10",
  14832. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14833. "YYYY-MM-DD HH:mm:ss"
  14834. ),
  14835. toLogoutTime: moment(new Date().getTime()).format(
  14836. "YYYY-MM-DD HH:mm:ss"
  14837. ),
  14838. }
  14839. ).then(function (response) {
  14840. // if (response.status == 200) {
  14841. if (response && response.data) {
  14842. angular.forEach(response.data, function (item, index) {
  14843. if (item.logoutTime) {
  14844. response.data[index].logoutTime = moment(
  14845. item.logoutTime
  14846. ).format("YYYY-MM-DD HH:mm:ss");
  14847. }
  14848. if (item.loginTime) {
  14849. response.data[index].loginTime = moment(
  14850. item.loginTime
  14851. ).format("YYYY-MM-DD HH:mm:ss");
  14852. }
  14853. });
  14854. $scope.logininform = response.data;
  14855. } else if (response.err) {
  14856. SweetAlert.swal(
  14857. "系统错误!",
  14858. "上网明细未取到,请刷新重试",
  14859. "error"
  14860. );
  14861. }
  14862. });
  14863. //黑名单
  14864. // $scope.information.blacklist = "否"
  14865. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14866. userId: key.account,
  14867. }).then(function (response) {
  14868. // if (response.status == 200) {
  14869. // $scope.logininformation = response.data;
  14870. if (response) {
  14871. if (response.data || response.data != null) {
  14872. $scope.information.blacklist = "是";
  14873. } else {
  14874. if (response.err) {
  14875. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14876. } else {
  14877. $scope.information.blacklist = "否";
  14878. }
  14879. }
  14880. }
  14881. // }
  14882. });
  14883. $scope.bodyHeight = window.innerHeight - 100;
  14884. $(window).resize(function () {
  14885. $scope.bodyHeight = window.innerHeight - 100;
  14886. });
  14887. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14888. // $scope.closepages = function(e) {
  14889. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14890. // event.preventDefault();
  14891. // };
  14892. // $scope.shows = false;
  14893. $scope.tempData = {};
  14894. $scope.close = function () {
  14895. $scope.changes = !$scope.changes;
  14896. event.preventDefault();
  14897. };
  14898. };
  14899. $scope.options.templateOptions.ApiService.fetchDataList(
  14900. "requesterType",
  14901. {
  14902. idx: 0,
  14903. sum: 100,
  14904. }
  14905. ).then(function (response) {
  14906. if (response.status == 200) {
  14907. $scope.networktypes = response.list;
  14908. } else {
  14909. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14910. }
  14911. });
  14912. function serchdata(searchKey) {
  14913. if (searchKey) {
  14914. var filterData = {
  14915. requester: {
  14916. searchKey: searchKey,
  14917. // 'userType': 1
  14918. },
  14919. idx: 0,
  14920. sum: 10,
  14921. };
  14922. } else {
  14923. var filterData = {
  14924. idx: 0,
  14925. requester: {},
  14926. sum: 10,
  14927. };
  14928. }
  14929. if (
  14930. $scope.model.requester &&
  14931. $scope.model.requester.requesterTypeDTO
  14932. ) {
  14933. angular.extend(filterData.requester, {
  14934. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14935. });
  14936. if (!$scope.options.model.contactsInformation) {
  14937. $scope.options.model.contactsInformation =
  14938. $scope.model.requester.mphone;
  14939. }
  14940. }
  14941. if ($scope.roleidcode) {
  14942. angular.extend(filterData["requester"], {
  14943. userType: 1,
  14944. });
  14945. }
  14946. $scope.options.templateOptions.ApiService.fetchDataList(
  14947. "requester",
  14948. filterData
  14949. ).then(function (response) {
  14950. var myData = response;
  14951. $scope.myData = myData.list;
  14952. });
  14953. }
  14954. $scope.searchData = {};
  14955. $scope.refreshUser = function (searchKey) {
  14956. //请求人搜索
  14957. if (searchKey && searchKey != "") {
  14958. serchdata(searchKey);
  14959. }
  14960. };
  14961. if (
  14962. $scope.$parent.$parent.$parent.model.incident.callID ||
  14963. $scope.$parent.$parent.$parent.model.requestershow
  14964. ) {
  14965. if (!$scope.roleidcode) {
  14966. $scope.charging(
  14967. $scope.$parent.$parent.$parent.model.incident.requester
  14968. );
  14969. }
  14970. $scope.recentlyincident(
  14971. $scope.$parent.$parent.$parent.model.incident.requester
  14972. );
  14973. }
  14974. $scope.onChange = function (searchData) {
  14975. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14976. searchData.telephone = $scope.model.incident.contactsInformation;
  14977. }
  14978. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14979. searchData;
  14980. if (!$scope.roleidcode) {
  14981. $scope.charging(searchData);
  14982. }
  14983. $scope.recentlyincident(searchData);
  14984. $scope.accountshow = false;
  14985. if ($scope.model.incident) {
  14986. if ($scope.model.incident.place) {
  14987. $scope.model.incident.place.id = "";
  14988. }
  14989. if ($scope.model.incident.area) {
  14990. $scope.model.incident.area.id = "";
  14991. }
  14992. $scope.model.incident.contacts = searchData.name;
  14993. if (
  14994. searchData.mphone &&
  14995. searchData.mphone != null &&
  14996. searchData.mphone != ""
  14997. ) {
  14998. $scope.model.incident.contactsInformation = searchData.mphone;
  14999. } else {
  15000. $scope.model.incident.contactsInformation = searchData.telephone;
  15001. }
  15002. $scope.model.incident.houseNumber = "";
  15003. if (
  15004. searchData.requesterTypeDTO &&
  15005. searchData.requesterTypeDTO.id == 2
  15006. ) {
  15007. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  15008. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  15009. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  15010. }
  15011. }
  15012. $scope.options.value(searchData);
  15013. $scope.searchKey = searchData.account;
  15014. if (searchData.placeDTO && searchData.placeDTO.id) {
  15015. $scope.model.incident.place.id = searchData.placeDTO.id;
  15016. }
  15017. if (searchData.areaDTO && searchData.areaDTO.id) {
  15018. $scope.model.incident.area.id = searchData.areaDTO.id;
  15019. }
  15020. if (searchData.houseNumber) {
  15021. $scope.model.incident.houseNumber = searchData.houseNumber;
  15022. }
  15023. if (
  15024. searchData.requesterTypeDTO &&
  15025. searchData.requesterTypeDTO.id == 2
  15026. ) {
  15027. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  15028. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  15029. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  15030. }
  15031. };
  15032. },
  15033. ],
  15034. });
  15035. //ui-grid-table展示控件
  15036. formlyConfigProvider.setType({
  15037. name: "ui-grid-table",
  15038. // extends: 'multiCheckbox',//去掉冒号
  15039. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  15040. defaultOptions: function (options) {
  15041. return {
  15042. templateOptions: {
  15043. linkage: function () { },
  15044. },
  15045. };
  15046. },
  15047. controller: function (
  15048. $scope,
  15049. $rootScope,
  15050. i18nService,
  15051. Restangular,
  15052. api_bpm_data,
  15053. api_statistic,
  15054. $rootScope
  15055. ) {
  15056. var loginUser = $rootScope.user;
  15057. $scope.langs = i18nService.getAllLangs();
  15058. $scope.lang = "zh-cn";
  15059. i18nService.setCurrentLang($scope.lang);
  15060. $scope.gridOptions = {};
  15061. $scope.gridOptions.data = "myData";
  15062. $scope.gridOptions.enableColumnResizing = true;
  15063. $scope.gridOptions.enableGridMenu = false;
  15064. $scope.gridOptions.enableRowSelection = true;
  15065. $scope.gridOptions.showGridFooter = false;
  15066. $scope.gridOptions.showColumnFooter = false;
  15067. $scope.gridOptions.fastWatch = true;
  15068. $scope.gridOptions.useExternalFiltering = true;
  15069. $scope.gridOptions.useExternalPagination = false;
  15070. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15071. $scope.gridOptions.paginationPageSize = 3;
  15072. $scope.gridOptions.multiSelect = false;
  15073. $scope.gridOptions.rowIdentity = function (row) {
  15074. return row.id;
  15075. };
  15076. $scope.gridOptions.getRowIdentity = function (row) {
  15077. return row.id;
  15078. };
  15079. $scope.gridOptions.columnDefs = [
  15080. {
  15081. name: "item",
  15082. displayName: "序号",
  15083. width: 80,
  15084. enableFiltering: false,
  15085. },
  15086. {
  15087. name: "incidentsign",
  15088. displayName: "单号",
  15089. width: 80,
  15090. enableFiltering: false,
  15091. },
  15092. {
  15093. name: "description",
  15094. displayName: "主题",
  15095. width: 80,
  15096. enableFiltering: false,
  15097. },
  15098. {
  15099. name: "state.name",
  15100. displayName: "状态",
  15101. width: 110,
  15102. enableFiltering: false,
  15103. },
  15104. {
  15105. name: "acceptDate",
  15106. displayName: "创建时间",
  15107. width: 160,
  15108. enableFiltering: false,
  15109. },
  15110. {
  15111. name: "requester.name",
  15112. displayName: "请求人",
  15113. width: 80,
  15114. enableFiltering: false,
  15115. },
  15116. {
  15117. name: "handlingPersonnelUser.name",
  15118. displayName: "处理人",
  15119. width: 160,
  15120. enableFiltering: false,
  15121. },
  15122. {
  15123. name: "place.place",
  15124. displayName: "区域地点",
  15125. width: 160,
  15126. enableFiltering: false,
  15127. },
  15128. ];
  15129. // var defaultFilterData = {
  15130. // "idx": 0,
  15131. // "sum": 3
  15132. // };
  15133. // // //分页控制
  15134. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15135. gridApi.pagination.on.paginationChanged(
  15136. $scope,
  15137. function (newPage, pageSize) {
  15138. var filtersData = $scope.memoryfilterData;
  15139. filtersData.idx = newPage - 1;
  15140. filtersData.sum = pageSize;
  15141. $scope.refreshData("expand-right", filtersData);
  15142. }
  15143. );
  15144. // 表格单选事件
  15145. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  15146. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  15147. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  15148. data.entity;
  15149. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  15150. data.entity.id;
  15151. var str =
  15152. data.grid.appScope.$parent.$parent.$parent.model.incident
  15153. .description || "";
  15154. str = str.split("").reverse().join("");
  15155. var del = addstr.split("").reverse().join("");
  15156. // console.log(del);
  15157. var reg = new RegExp(del);
  15158. str = str.replace(reg, "");
  15159. str = str.split("").reverse().join("");
  15160. if (
  15161. data.grid.appScope.$parent.$parent.$parent.model.incident
  15162. .associationType == "事件补充"
  15163. ) {
  15164. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  15165. null;
  15166. str += data.entity.description;
  15167. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15168. data.entity.description;
  15169. } else if (
  15170. data.grid.appScope.$parent.$parent.$parent.model.incident
  15171. .associationType == "事件已解决"
  15172. ) {
  15173. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  15174. "close";
  15175. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15176. "";
  15177. }
  15178. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  15179. str;
  15180. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  15181. data.entity.id;
  15182. });
  15183. };
  15184. // 刷新表格
  15185. setInterval(function () {
  15186. // console.log($scope.myData);
  15187. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  15188. // console.log($scope.myData);
  15189. if ($scope.myData != null) {
  15190. for (var i = 0; i < $scope.myData.length; i++) {
  15191. //添加序号
  15192. $scope.myData[i]["item"] = i + 1;
  15193. }
  15194. }
  15195. }, 1000);
  15196. },
  15197. });
  15198. //处理人信息
  15199. formlyConfigProvider.setType({
  15200. name: "ui-userinformation",
  15201. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  15202. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15203. defaultOptions: function (options) {
  15204. return {
  15205. templateOptions: {},
  15206. };
  15207. },
  15208. controller: [
  15209. "$scope",
  15210. function ($scope) {
  15211. $scope.group = "";
  15212. $scope.role = "";
  15213. if (
  15214. angular.isDefined($scope.model.handlingPersonnelUser) &&
  15215. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15216. $scope.model.handlingPersonnelUser.group.length == 1
  15217. ) {
  15218. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15219. } else {
  15220. for (
  15221. var i = 0;
  15222. i < $scope.model.handlingPersonnelUser.group.length;
  15223. i++
  15224. ) {
  15225. $scope.group +=
  15226. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15227. }
  15228. }
  15229. if (
  15230. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  15231. $scope.model.handlingPersonnelUser.role.length == 1
  15232. ) {
  15233. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  15234. } else {
  15235. for (
  15236. var i = 0;
  15237. i < $scope.model.handlingPersonnelUser.role.length;
  15238. i++
  15239. ) {
  15240. $scope.role +=
  15241. $scope.model.handlingPersonnelUser.role[i].role + ",";
  15242. }
  15243. }
  15244. $scope.options.templateOptions.that = $scope;
  15245. },
  15246. ],
  15247. });
  15248. //处理界面处理人信息
  15249. formlyConfigProvider.setType({
  15250. name: "ui-handler",
  15251. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  15252. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15253. defaultOptions: function (options) {
  15254. return {
  15255. templateOptions: {},
  15256. };
  15257. },
  15258. controller: [
  15259. "$scope",
  15260. function ($scope) {
  15261. $scope.group = "";
  15262. // $scope.role="";
  15263. if (
  15264. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15265. $scope.model.handlingPersonnelUser.group.length == 1
  15266. ) {
  15267. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15268. } else {
  15269. for (
  15270. var i = 0;
  15271. i < $scope.model.handlingPersonnelUser.group.length;
  15272. i++
  15273. ) {
  15274. $scope.group +=
  15275. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15276. }
  15277. }
  15278. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  15279. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  15280. // }else{
  15281. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  15282. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  15283. // }
  15284. // }
  15285. $scope.options.templateOptions.that = $scope;
  15286. },
  15287. ],
  15288. });
  15289. //微信事件流程
  15290. formlyConfigProvider.setType({
  15291. name: "ui-wxIncidentProcess",
  15292. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  15293. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15294. defaultOptions: function (options) {
  15295. return {
  15296. templateOptions: {},
  15297. };
  15298. },
  15299. controller: [
  15300. "$scope",
  15301. function ($scope) {
  15302. console.log($scope.model);
  15303. $scope.pingjia = false;
  15304. $scope.jiejue = false;
  15305. if ($scope.model.incidentState.value == "3") {
  15306. $scope.pingjia = true;
  15307. } else if ($scope.model.incidentState.value == "4") {
  15308. $scope.jiejue = true;
  15309. }
  15310. },
  15311. ],
  15312. });
  15313. //打电话
  15314. formlyConfigProvider.setType({
  15315. name: "ui-inputcall",
  15316. extends: "input",
  15317. templateUrl: "assets/views/customform/tpl/inputcall.html",
  15318. defaultOptions: function (options) {
  15319. return {
  15320. templateOptions: {
  15321. transform: function (value) { },
  15322. },
  15323. };
  15324. },
  15325. controller: [
  15326. "$scope",
  15327. "$rootScope",
  15328. "api_text",
  15329. "SweetAlert",
  15330. function ($scope, $rootScope, api_text, SweetAlert) {
  15331. $scope.dialout = function (teleno) {
  15332. // var gid = "@0";
  15333. // var telephone = "9" + teleno;
  15334. $rootScope.callout = 2;
  15335. // var agcount = tlwsa.tlaGetagentcount();
  15336. // var agcountFlag = false;
  15337. // console.log(teleno)
  15338. // // 查询当前话机是否签入
  15339. // for (var i = 0; i < agcount; i++) {
  15340. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15341. // agcountFlag = true;
  15342. // }
  15343. // }
  15344. if (localStorage.getItem('fenjiNumber')) {
  15345. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15346. // console.log(sessionStorage.getItem('phones'))
  15347. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15348. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15349. // console.log(isHuajihao)
  15350. // if(isHuajihao){
  15351. // tlwsa.tlaCallagc(teleno);
  15352. // }else{
  15353. // tlwsa.tlaCallout(teleno, caller, 0);
  15354. // }
  15355. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15356. $rootScope.toggle('off-sidebar');
  15357. // tlwsa.tlaCallout(teleno, caller, 0);
  15358. }else if(localStorage.getItem('hk_phone')){
  15359. var gid = "@0"
  15360. var telephone = '9' + teleno
  15361. $rootScope.callout = 2;
  15362. if ($rootScope.takes) {
  15363. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  15364. if (data.errno == 0) {
  15365. $rootScope.status = 6;
  15366. }
  15367. })
  15368. } else {
  15369. SweetAlert.swal({
  15370. title: "呼叫失败",
  15371. text: "请先签入呼叫中心!",
  15372. type: "error",
  15373. confirmButtonColor: "#DD6B55"
  15374. });
  15375. }
  15376. } else {
  15377. SweetAlert.swal({
  15378. title: "呼叫失败",
  15379. text: "请先签入呼叫中心!",
  15380. type: "error",
  15381. confirmButtonColor: "#DD6B55",
  15382. });
  15383. }
  15384. };
  15385. $scope.options.templateOptions.that = $scope;
  15386. },
  15387. ],
  15388. });
  15389. //关闭界面处理人信息
  15390. formlyConfigProvider.setType({
  15391. name: "ui-closehandler",
  15392. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15393. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15394. defaultOptions: function (options) {
  15395. return {
  15396. templateOptions: {},
  15397. };
  15398. },
  15399. controller: [
  15400. "$scope",
  15401. "$rootScope",
  15402. "api_text",
  15403. function ($scope, $rootScope, api_text) {
  15404. $scope.dialout = function (teleno) {
  15405. var gid = "@0";
  15406. var telephone = "9" + teleno;
  15407. api_text
  15408. .dialout($rootScope.takes, gid, telephone)
  15409. .then(function (data) {
  15410. if (data.errno == 0) {
  15411. $rootScope.status = 6;
  15412. }
  15413. });
  15414. };
  15415. $scope.options.templateOptions.that = $scope;
  15416. },
  15417. ],
  15418. });
  15419. //用户单选控件
  15420. formlyConfigProvider.setType({
  15421. name: "ui-userselect",
  15422. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15423. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15424. defaultOptions: function (options) {
  15425. return {
  15426. templateOptions: {
  15427. openModal: function (size, options, modal) {
  15428. var modalInstance = modal.open({
  15429. templateUrl:
  15430. "assets/views/customform/tpl/checktable-modal-content.html",
  15431. controller: function (
  15432. $scope,
  15433. i18nService,
  15434. $modalInstance,
  15435. items,
  15436. title,
  15437. Restangular,
  15438. APIService,
  15439. onDataCallback,
  15440. parentScope
  15441. ) {
  15442. $scope.langs = i18nService.getAllLangs();
  15443. $scope.lang = "zh-cn";
  15444. i18nService.setCurrentLang($scope.lang);
  15445. $scope.gridOptions = {};
  15446. $scope.gridOptions.data = "myData";
  15447. $scope.gridOptions.enableColumnResizing = true;
  15448. $scope.gridOptions.enableFiltering = true;
  15449. $scope.gridOptions.enableGridMenu = false;
  15450. $scope.gridOptions.showGridFooter = true;
  15451. $scope.gridOptions.showColumnFooter = false;
  15452. $scope.gridOptions.fastWatch = true;
  15453. $scope.gridOptions.useExternalFiltering = true;
  15454. $scope.gridOptions.useExternalPagination = true;
  15455. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15456. $scope.gridOptions.paginationPageSize = 10;
  15457. $scope.gridOptions.multiSelect = false;
  15458. $scope.gridOptions.rowIdentity = function (row) {
  15459. return row.id;
  15460. };
  15461. $scope.gridOptions.getRowIdentity = function (row) {
  15462. return row.id;
  15463. };
  15464. $scope.gridOptions.rowTemplate =
  15465. '<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>';
  15466. $scope.gridOptions.columnDefs = [
  15467. {
  15468. name: "account",
  15469. displayName: "人员编号",
  15470. width: 120,
  15471. },
  15472. {
  15473. name: "name",
  15474. displayName: "姓名",
  15475. width: 100,
  15476. cellTemplate:
  15477. "<div>" +
  15478. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15479. "</div>",
  15480. },
  15481. // {
  15482. // name: 'gender.name',
  15483. // displayName: '性别',
  15484. // width: 80,
  15485. // enableFiltering: false
  15486. // },
  15487. {
  15488. name: "phone",
  15489. displayName: "电话",
  15490. width: 230,
  15491. enableFiltering: false,
  15492. },
  15493. {
  15494. name: "email",
  15495. displayName: "邮箱",
  15496. width: 180,
  15497. enableFiltering: false,
  15498. },
  15499. {
  15500. name: "dept.dept",
  15501. displayName: "科室",
  15502. width: 130,
  15503. enableFiltering: false,
  15504. },
  15505. {
  15506. name: "taskCount",
  15507. displayName: "处理中事件数",
  15508. enableFiltering: false,
  15509. },
  15510. ];
  15511. // $scope.selectButtonClick
  15512. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15513. $scope.gridApi = gridApi;
  15514. gridApi.pagination.on.paginationChanged(
  15515. $scope,
  15516. function (newPage, pageSize) {
  15517. var filtersData = $scope.memoryfilterData;
  15518. filtersData.idx = newPage - 1;
  15519. filtersData.sum = pageSize;
  15520. $scope.loadData(filtersData);
  15521. //console.log(pageSize);
  15522. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15523. }
  15524. );
  15525. gridApi.selection.on.rowSelectionChanged(
  15526. $scope,
  15527. function (data) {
  15528. $scope.selected.items = data.entity;
  15529. //console.log(data);
  15530. }
  15531. );
  15532. gridApi.selection.on.rowSelectionChangedBatch(
  15533. $scope,
  15534. function (data) {
  15535. $scope.selected.items = data.entity;
  15536. //console.log(data);
  15537. }
  15538. );
  15539. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15540. // // if (row.entity.age > 45) {
  15541. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15542. // // }
  15543. // };
  15544. gridApi.core.on.filterChanged($scope, function () {
  15545. var grid = this.grid;
  15546. var filtersData = {
  15547. idx: 0,
  15548. sum: 10,
  15549. user: {
  15550. roledata: {
  15551. rolecode: "roleset",
  15552. },
  15553. selectType: "1",
  15554. },
  15555. };
  15556. angular.forEach(grid.columns, function (item) {
  15557. if (item.enableFiltering) {
  15558. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15559. if (
  15560. angular.isDefined(item.filters[0].term) &&
  15561. item.filters[0].term != ""
  15562. ) {
  15563. if (angular.isUndefined(filtersData["user"])) {
  15564. filtersData["user"] = {};
  15565. }
  15566. filtersData["user"][item.field] =
  15567. item.filters[0].term;
  15568. }
  15569. }
  15570. });
  15571. $scope.memoryfilterData = filtersData;
  15572. $scope.loadData(filtersData);
  15573. });
  15574. };
  15575. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15576. // if (row.entity.age > 45) {
  15577. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15578. // }
  15579. // },
  15580. $scope.onDblClick = function (data, event) {
  15581. // $scope.selected.items = data.entity;
  15582. $scope.selectButtonClick(data, event);
  15583. };
  15584. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15585. // $scope.selected.items = data.entity;
  15586. // })
  15587. // };
  15588. $scope.memoryfilterData = {
  15589. idx: 0,
  15590. sum: 10,
  15591. user: {
  15592. roledata: {
  15593. rolecode: "roleset",
  15594. },
  15595. selectType: "1",
  15596. },
  15597. };
  15598. $scope.loadData = function (filterData) {
  15599. // console.log("filtersData=111" + JSON.stringify(filterData))
  15600. items
  15601. .fetchItems(filterData, APIService)
  15602. .then(function (data) {
  15603. var myData = Restangular.stripRestangular(data);
  15604. $scope.gridOptions.totalItems = myData.totalNum;
  15605. $scope.myData = myData.list;
  15606. });
  15607. };
  15608. // $scope.title = title;
  15609. $scope.loadData({
  15610. idx: 0,
  15611. sum: 10,
  15612. user: {
  15613. roledata: {
  15614. rolecode: "roleset",
  15615. },
  15616. selectType: "1",
  15617. },
  15618. });
  15619. $scope.selected = {
  15620. items: {},
  15621. };
  15622. $scope.ok = function () {
  15623. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15624. // onDataCallback($scope.selected.item, parentScope);
  15625. // }
  15626. $modalInstance.close($scope.selected.items);
  15627. };
  15628. $scope.cancel = function () {
  15629. $modalInstance.dismiss("cancel");
  15630. };
  15631. },
  15632. size: size,
  15633. resolve: {
  15634. items: function () {
  15635. return {
  15636. fetchItems: function (filterData, APIService) {
  15637. filterData = filterData || {};
  15638. if (
  15639. angular.isDefined(filterData.idx) &&
  15640. filterData.idx == null
  15641. ) {
  15642. filterData = {
  15643. idx: 0,
  15644. sum: 10,
  15645. user: {
  15646. roledata: {
  15647. rolecode: "roleset",
  15648. },
  15649. selectType: "1",
  15650. },
  15651. };
  15652. }
  15653. return options.templateOptions.fetchItems(
  15654. filterData,
  15655. APIService
  15656. );
  15657. },
  15658. };
  15659. },
  15660. title: function () {
  15661. return options.templateOptions.label;
  15662. },
  15663. Restangular: function () {
  15664. return options.templateOptions.Restangular;
  15665. },
  15666. APIService: function () {
  15667. return options.templateOptions.ApiService;
  15668. },
  15669. onDataCallback: function () {
  15670. return options.templateOptions.callback;
  15671. },
  15672. parentScope: function () {
  15673. return options.templateOptions.that;
  15674. },
  15675. },
  15676. });
  15677. modalInstance.result.then(
  15678. function (selectedItem) {
  15679. // console.log(selectedItem);
  15680. options.value(selectedItem);
  15681. if (
  15682. options.templateOptions.callback &&
  15683. angular.isFunction(options.templateOptions.callback)
  15684. ) {
  15685. options.templateOptions.callback(
  15686. selectedItem,
  15687. options.templateOptions.that
  15688. );
  15689. }
  15690. if (
  15691. options.templateOptions.linkData &&
  15692. angular.isFunction(options.templateOptions.linkData)
  15693. ) {
  15694. options.templateOptions.linkData(
  15695. selectedItem,
  15696. options.templateOptions.that
  15697. );
  15698. }
  15699. },
  15700. function () {
  15701. //console.log('Modal dismissed at: ' + new Date());
  15702. }
  15703. );
  15704. },
  15705. },
  15706. };
  15707. },
  15708. controller: [
  15709. "$scope",
  15710. function ($scope) {
  15711. $scope.options.templateOptions.that = $scope;
  15712. // $scope.options.model[$scope.options.key] = {}
  15713. },
  15714. ],
  15715. });
  15716. //用户单选控件(dd 单选input带搜索)
  15717. formlyConfigProvider.setType({
  15718. name: "ui-userselectSearch",
  15719. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15720. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15721. defaultOptions: function (options) {
  15722. return {
  15723. templateOptions: {
  15724. openModal: function (size, options, modal) {
  15725. var modalInstance = modal.open({
  15726. templateUrl:
  15727. "assets/views/customform/tpl/checktable-modal-content.html",
  15728. controller: function (
  15729. $scope,
  15730. i18nService,
  15731. $modalInstance,
  15732. items,
  15733. title,
  15734. Restangular,
  15735. APIService,
  15736. onDataCallback,
  15737. parentScope
  15738. ) {
  15739. $scope.langs = i18nService.getAllLangs();
  15740. $scope.lang = "zh-cn";
  15741. i18nService.setCurrentLang($scope.lang);
  15742. $scope.gridOptions = {};
  15743. $scope.gridOptions.data = "myData";
  15744. $scope.gridOptions.enableColumnResizing = true;
  15745. $scope.gridOptions.enableFiltering = true;
  15746. $scope.gridOptions.enableGridMenu = false;
  15747. $scope.gridOptions.showGridFooter = true;
  15748. $scope.gridOptions.showColumnFooter = false;
  15749. $scope.gridOptions.fastWatch = true;
  15750. $scope.gridOptions.useExternalFiltering = true;
  15751. $scope.gridOptions.useExternalPagination = true;
  15752. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15753. $scope.gridOptions.paginationPageSize = 10;
  15754. $scope.gridOptions.multiSelect = false;
  15755. $scope.gridOptions.rowIdentity = function (row) {
  15756. return row.id;
  15757. };
  15758. $scope.gridOptions.getRowIdentity = function (row) {
  15759. return row.id;
  15760. };
  15761. $scope.gridOptions.rowTemplate =
  15762. '<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>';
  15763. $scope.gridOptions.columnDefs = [
  15764. {
  15765. name: "account",
  15766. displayName: "人员编号",
  15767. width: 120,
  15768. },
  15769. {
  15770. name: "name",
  15771. displayName: "姓名",
  15772. width: 100,
  15773. cellTemplate:
  15774. "<div>" +
  15775. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15776. "</div>",
  15777. },
  15778. // {
  15779. // name: 'gender.name',
  15780. // displayName: '性别',
  15781. // width: 80,
  15782. // enableFiltering: false
  15783. // },
  15784. {
  15785. name: "phone",
  15786. displayName: "电话",
  15787. width: 230,
  15788. enableFiltering: false,
  15789. },
  15790. {
  15791. name: "email",
  15792. displayName: "邮箱",
  15793. width: 180,
  15794. enableFiltering: false,
  15795. },
  15796. {
  15797. name: "dept.dept",
  15798. displayName: "科室",
  15799. width: 130,
  15800. enableFiltering: false,
  15801. },
  15802. {
  15803. name: "taskCount",
  15804. displayName: "处理中事件数",
  15805. enableFiltering: false,
  15806. },
  15807. ];
  15808. // $scope.selectButtonClick
  15809. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15810. $scope.gridApi = gridApi;
  15811. gridApi.pagination.on.paginationChanged(
  15812. $scope,
  15813. function (newPage, pageSize) {
  15814. var filtersData = $scope.memoryfilterData;
  15815. filtersData.idx = newPage - 1;
  15816. filtersData.sum = pageSize;
  15817. $scope.loadData(filtersData);
  15818. //console.log(pageSize);
  15819. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15820. }
  15821. );
  15822. gridApi.selection.on.rowSelectionChanged(
  15823. $scope,
  15824. function (data) {
  15825. $scope.selected.items = data.entity;
  15826. //console.log(data);
  15827. }
  15828. );
  15829. gridApi.selection.on.rowSelectionChangedBatch(
  15830. $scope,
  15831. function (data) {
  15832. $scope.selected.items = data.entity;
  15833. //console.log(data);
  15834. }
  15835. );
  15836. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15837. // // if (row.entity.age > 45) {
  15838. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15839. // // }
  15840. // };
  15841. gridApi.core.on.filterChanged($scope, function () {
  15842. var grid = this.grid;
  15843. var filtersData = {
  15844. idx: 0,
  15845. sum: 10,
  15846. user: {
  15847. roledata: {
  15848. rolecode: "first-line support",
  15849. },
  15850. selectType: "1",
  15851. },
  15852. };
  15853. angular.forEach(grid.columns, function (item) {
  15854. if (item.enableFiltering) {
  15855. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15856. if (
  15857. angular.isDefined(item.filters[0].term) &&
  15858. item.filters[0].term != ""
  15859. ) {
  15860. if (angular.isUndefined(filtersData["user"])) {
  15861. filtersData["user"] = {};
  15862. }
  15863. filtersData["user"][item.field] =
  15864. item.filters[0].term;
  15865. }
  15866. }
  15867. });
  15868. $scope.memoryfilterData = filtersData;
  15869. $scope.loadData(filtersData);
  15870. });
  15871. };
  15872. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15873. // if (row.entity.age > 45) {
  15874. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15875. // }
  15876. // },
  15877. $scope.onDblClick = function (data, event) {
  15878. // $scope.selected.items = data.entity;
  15879. $scope.selectButtonClick(data, event);
  15880. };
  15881. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15882. // $scope.selected.items = data.entity;
  15883. // })
  15884. // };
  15885. $scope.memoryfilterData = {
  15886. idx: 0,
  15887. sum: 10,
  15888. user: {
  15889. roledata: {
  15890. rolecode: "first-line support",
  15891. },
  15892. selectType: "1",
  15893. },
  15894. };
  15895. $scope.loadData = function (filterData) {
  15896. // console.log("filtersData=111" + JSON.stringify(filterData))
  15897. items
  15898. .fetchItems(filterData, APIService)
  15899. .then(function (data) {
  15900. var myData = Restangular.stripRestangular(data);
  15901. $scope.gridOptions.totalItems = myData.totalNum;
  15902. $scope.myData = myData.list;
  15903. });
  15904. };
  15905. $scope.title = title;
  15906. $scope.loadData({
  15907. idx: 0,
  15908. sum: 10,
  15909. user: {
  15910. roledata: {
  15911. rolecode: "first-line support",
  15912. },
  15913. selectType: "1",
  15914. },
  15915. });
  15916. $scope.selected = {
  15917. items: {},
  15918. };
  15919. $scope.ok = function () {
  15920. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15921. // onDataCallback($scope.selected.item, parentScope);
  15922. // }
  15923. $modalInstance.close($scope.selected.items);
  15924. };
  15925. $scope.cancel = function () {
  15926. $modalInstance.dismiss("cancel");
  15927. };
  15928. },
  15929. size: size,
  15930. resolve: {
  15931. items: function () {
  15932. return {
  15933. fetchItems: function (filterData, APIService) {
  15934. filterData = filterData || {};
  15935. if (
  15936. angular.isDefined(filterData.idx) &&
  15937. filterData.idx == null
  15938. ) {
  15939. filterData = {
  15940. idx: 0,
  15941. sum: 10,
  15942. user: {
  15943. roledata: {
  15944. rolecode: "first-line support",
  15945. },
  15946. selectType: "1",
  15947. },
  15948. };
  15949. }
  15950. return options.templateOptions.fetchItems(
  15951. filterData,
  15952. APIService
  15953. );
  15954. },
  15955. };
  15956. },
  15957. title: function () {
  15958. return options.templateOptions.label;
  15959. },
  15960. Restangular: function () {
  15961. return options.templateOptions.Restangular;
  15962. },
  15963. APIService: function () {
  15964. return options.templateOptions.ApiService;
  15965. },
  15966. onDataCallback: function () {
  15967. return options.templateOptions.callback;
  15968. },
  15969. parentScope: function () {
  15970. return options.templateOptions.that;
  15971. },
  15972. },
  15973. });
  15974. modalInstance.result.then(
  15975. function (selectedItem) {
  15976. // console.log(selectedItem);
  15977. options.value(selectedItem);
  15978. if (
  15979. options.templateOptions.callback &&
  15980. angular.isFunction(options.templateOptions.callback)
  15981. ) {
  15982. options.templateOptions.callback(
  15983. selectedItem,
  15984. options.templateOptions.that
  15985. );
  15986. }
  15987. if (
  15988. options.templateOptions.linkData &&
  15989. angular.isFunction(options.templateOptions.linkData)
  15990. ) {
  15991. options.templateOptions.linkData(
  15992. selectedItem,
  15993. options.templateOptions.that
  15994. );
  15995. }
  15996. },
  15997. function () {
  15998. //console.log('Modal dismissed at: ' + new Date());
  15999. }
  16000. );
  16001. },
  16002. },
  16003. };
  16004. },
  16005. controller: [
  16006. "$scope",
  16007. function ($scope) {
  16008. $scope.options.templateOptions.that = $scope;
  16009. },
  16010. ],
  16011. });
  16012. //用户多选控件
  16013. formlyConfigProvider.setType({
  16014. name: "ui-multiuserselect",
  16015. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  16016. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16017. defaultOptions: function (options) {
  16018. return {
  16019. templateOptions: {
  16020. openModal: function (size, options, modal, model) {
  16021. var modalInstance = modal.open({
  16022. templateUrl:
  16023. "assets/views/customform/tpl/checktable-modal-content.html",
  16024. controller: function (
  16025. $scope,
  16026. $modalInstance,
  16027. i18nService,
  16028. $timeout,
  16029. items,
  16030. title,
  16031. Restangular,
  16032. APIService,
  16033. selectItems
  16034. ) {
  16035. $scope.langs = i18nService.getAllLangs();
  16036. $scope.lang = "zh-cn";
  16037. i18nService.setCurrentLang($scope.lang);
  16038. $scope.gridOptions = {};
  16039. $scope.gridOptions.data = "myData";
  16040. $scope.gridOptions.enableColumnResizing = true;
  16041. $scope.gridOptions.enableFiltering = true;
  16042. $scope.gridOptions.enableGridMenu = true;
  16043. $scope.gridOptions.showGridFooter = true;
  16044. $scope.gridOptions.showColumnFooter = true;
  16045. $scope.gridOptions.fastWatch = true;
  16046. $scope.gridOptions.useExternalFiltering = true;
  16047. $scope.gridOptions.useExternalPagination = true;
  16048. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16049. $scope.gridOptions.paginationPageSize = 10;
  16050. $scope.gridOptions.multiSelect = true;
  16051. $scope.gridOptions.rowIdentity = function (row) {
  16052. return row.id;
  16053. };
  16054. $scope.gridOptions.getRowIdentity = function (row) {
  16055. return row.id;
  16056. };
  16057. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  16058. $scope.gridOptions.columnDefs = [
  16059. // { name:'id', width:80, enableFiltering:false},
  16060. {
  16061. name: "account",
  16062. displayName: "账号",
  16063. width: 140,
  16064. },
  16065. {
  16066. name: "name",
  16067. displayName: "名称",
  16068. width: 100,
  16069. },
  16070. {
  16071. name: "gender.name",
  16072. displayName: "性别",
  16073. width: 140,
  16074. enableFiltering: false,
  16075. },
  16076. {
  16077. name: "phone",
  16078. displayName: "电话",
  16079. width: 100,
  16080. enableFiltering: false,
  16081. },
  16082. {
  16083. name: "email",
  16084. displayName: "邮件",
  16085. width: 100,
  16086. enableFiltering: false,
  16087. },
  16088. {
  16089. name: "dept.dept",
  16090. displayName: "科室",
  16091. width: 100,
  16092. enableFiltering: false,
  16093. },
  16094. {
  16095. name: "group[0].groupName",
  16096. displayName: "职位",
  16097. width: 100,
  16098. enableFiltering: false,
  16099. },
  16100. ];
  16101. $scope.selected = {
  16102. items: selectItems,
  16103. };
  16104. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16105. $scope.gridApi = gridApi;
  16106. gridApi.pagination.on.paginationChanged(
  16107. $scope,
  16108. function (newPage, pageSize) {
  16109. var filtersData = $scope.memoryfilterData;
  16110. filtersData.idx = newPage - 1;
  16111. filtersData.sum = pageSize;
  16112. $scope.loadData(filtersData);
  16113. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  16114. }
  16115. );
  16116. gridApi.selection.on.rowSelectionChanged(
  16117. $scope,
  16118. function (scope) {
  16119. var j = 0;
  16120. for (
  16121. var i = 0;
  16122. i <= scope.grid.appScope.selected.items.length;
  16123. i++
  16124. ) {
  16125. if (
  16126. scope.grid.appScope.selected.items[i] == scope.entity
  16127. ) {
  16128. j++;
  16129. break;
  16130. }
  16131. }
  16132. if (j == 1) {
  16133. scope.grid.appScope.selected.items.splice(i, 1);
  16134. } else {
  16135. scope.grid.appScope.selected.items.push(scope.entity);
  16136. for (
  16137. var i = 0;
  16138. i < scope.grid.appScope.selected.items.length;
  16139. i++
  16140. ) {
  16141. for (
  16142. var z = 0;
  16143. z < scope.grid.appScope.selected.items.length;
  16144. z++
  16145. ) {
  16146. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  16147. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  16148. if (
  16149. angular.isDefined(
  16150. scope.grid.appScope.selected.items
  16151. ) &&
  16152. scope.grid.appScope.selected.items[i].id ==
  16153. scope.grid.appScope.selected.items[z].id &&
  16154. i != z
  16155. ) {
  16156. scope.grid.appScope.selected.items.splice(i, 1);
  16157. }
  16158. }
  16159. }
  16160. }
  16161. }
  16162. );
  16163. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  16164. // $scope.grid.appScope.selected.items.push($scope.entity);
  16165. // });
  16166. gridApi.core.on.filterChanged($scope, function () {
  16167. var grid = this.grid;
  16168. var filtersData = {
  16169. idx: 0,
  16170. sum: 10,
  16171. user: {
  16172. roledata: {
  16173. rolecode: options.model.currentRole,
  16174. },
  16175. selectType: "1",
  16176. },
  16177. };
  16178. angular.forEach(grid.columns, function (item) {
  16179. if (item.enableFiltering) {
  16180. //console.log("filtersData="+JSON.stringify(filtersData))
  16181. if (
  16182. angular.isDefined(item.filters[0].term) &&
  16183. item.filters[0].term != ""
  16184. ) {
  16185. if (angular.isUndefined(filtersData["user"])) {
  16186. filtersData["user"] = {};
  16187. }
  16188. filtersData["user"][item.field] =
  16189. item.filters[0].term;
  16190. }
  16191. }
  16192. });
  16193. $scope.memoryfilterData = filtersData;
  16194. $scope.loadData(filtersData);
  16195. });
  16196. };
  16197. if (!options.model) {
  16198. var mouse = {
  16199. model: {
  16200. currentRole: "",
  16201. },
  16202. };
  16203. angular.extend(options, mouse);
  16204. }
  16205. $scope.memoryfilterData = {
  16206. idx: 0,
  16207. sum: 10,
  16208. user: {
  16209. roledata: {
  16210. rolecode: options.model.currentRole,
  16211. },
  16212. selectType: "1",
  16213. },
  16214. };
  16215. $scope.loadData = function (filterData) {
  16216. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  16217. items
  16218. .fetchItems(filterData, APIService)
  16219. .then(function (data) {
  16220. var myData = Restangular.stripRestangular(data);
  16221. $scope.gridOptions.totalItems = myData.totalNum;
  16222. $scope.myData = myData.list;
  16223. //console.log($scope.gridOptions.pagination.getTotalPages());
  16224. // if($scope.selected.items){
  16225. // angular.forEach($scope.selected.items,function(selectItem){
  16226. // $scope.gridApi.selection.selectRow(selectItem);
  16227. // });
  16228. // }
  16229. });
  16230. };
  16231. // $scope.title = title;
  16232. $scope.loadData({
  16233. idx: 0,
  16234. sum: 10,
  16235. user: {
  16236. roledata: {
  16237. rolecode: options.model.currentRole,
  16238. },
  16239. selectType: "1",
  16240. },
  16241. });
  16242. // $timeout(function(){
  16243. // if($scope.selected.items){
  16244. // angular.forEach($scope.selected.items,function(selectItem){
  16245. // $scope.gridApi.selection.selectRow(selectItem);
  16246. // });
  16247. // }
  16248. // },2000)
  16249. $scope.ok = function () {
  16250. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  16251. $modalInstance.close($scope.selected.items);
  16252. };
  16253. $scope.cancel = function () {
  16254. $modalInstance.dismiss("cancel");
  16255. };
  16256. },
  16257. size: size,
  16258. resolve: {
  16259. items: function () {
  16260. return {
  16261. fetchItems: function (filterData, APIService) {
  16262. filterData = filterData || {};
  16263. if (
  16264. angular.isDefined(filterData.idx) &&
  16265. filterData.idx == null
  16266. ) {
  16267. filterData = {
  16268. idx: 0,
  16269. sum: 10,
  16270. user: {
  16271. roledata: {
  16272. rolecode: options.model.incident.currentRole,
  16273. },
  16274. selectType: "1",
  16275. },
  16276. };
  16277. }
  16278. return options.templateOptions.fetchItems(
  16279. filterData,
  16280. APIService
  16281. );
  16282. },
  16283. };
  16284. },
  16285. title: function () {
  16286. return options.templateOptions.modalTitle;
  16287. },
  16288. Restangular: function () {
  16289. return options.templateOptions.Restangular;
  16290. },
  16291. APIService: function () {
  16292. return options.templateOptions.ApiService;
  16293. },
  16294. selectItems: function () {
  16295. return model || [];
  16296. },
  16297. },
  16298. });
  16299. modalInstance.result.then(
  16300. function (selectedItem) {
  16301. options.value(selectedItem);
  16302. options.formControl.$validate();
  16303. },
  16304. function () {
  16305. //console.log('Modal dismissed at: ' + new Date());
  16306. }
  16307. );
  16308. },
  16309. },
  16310. validators: {
  16311. required: {
  16312. expression: function (viewValue, modelValue) {
  16313. var value = modelValue || viewValue;
  16314. return value.length >= 1;
  16315. },
  16316. },
  16317. },
  16318. };
  16319. },
  16320. controller: [
  16321. "$scope",
  16322. function ($scope) {
  16323. $scope.model[$scope.options.key] = [];
  16324. $scope.remove = function (itemId) {
  16325. angular.forEach(
  16326. $scope.model[$scope.options.key],
  16327. function (entry, index) {
  16328. if (entry.id == itemId) {
  16329. $scope.model[$scope.options.key].splice(index, 1);
  16330. // console.log($scope.options.formControl)
  16331. $scope.options.formControl.$validate();
  16332. } else {
  16333. }
  16334. }
  16335. );
  16336. };
  16337. },
  16338. ],
  16339. });
  16340. //用户多选控件-字符串展示
  16341. formlyConfigProvider.setType({
  16342. name: "ui-stringuserselect",
  16343. extends: "input",
  16344. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  16345. defaultOptions: function (options) {
  16346. return {
  16347. templateOptions: {
  16348. translate: "",
  16349. refreshDelay: 0,
  16350. },
  16351. };
  16352. },
  16353. controller: [
  16354. "$scope",
  16355. function ($scope) {
  16356. var keydata = "";
  16357. if (angular.isArray($scope.model)) {
  16358. angular.forEach($scope.model, function (item) {
  16359. keydata = keydata + "," + item.name;
  16360. });
  16361. }
  16362. // $scope.model[$scope.options.key] = [];
  16363. },
  16364. ],
  16365. });
  16366. //重复事件
  16367. formlyConfigProvider.setType({
  16368. name: "ui-incidentmodelselect",
  16369. extends: "input",
  16370. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16371. defaultOptions: function (options) {
  16372. return {
  16373. templateOptions: {
  16374. openModal: function (size, options, modal) {
  16375. var modalInstance = modal.open({
  16376. templateUrl:
  16377. "assets/views/customform/tpl/checktable-modal-content.html",
  16378. controller: function (
  16379. $scope,
  16380. $rootScope,
  16381. $modalInstance,
  16382. items,
  16383. title,
  16384. Restangular,
  16385. APIService,
  16386. i18nService,
  16387. api_configure_data,
  16388. api_user_data,
  16389. api_bpm_data
  16390. ) {
  16391. $scope.langs = i18nService.getAllLangs();
  16392. $scope.lang = "zh-cn";
  16393. i18nService.setCurrentLang($scope.lang);
  16394. $scope.gridOptions = {};
  16395. $scope.gridOptions.data = "myData";
  16396. $scope.gridOptions.enableColumnResizing = true;
  16397. $scope.gridOptions.enableFiltering = true;
  16398. $scope.gridOptions.enableGridMenu = false;
  16399. $scope.gridOptions.enableRowSelection = true;
  16400. $scope.gridOptions.showGridFooter = true;
  16401. $scope.gridOptions.showColumnFooter = false;
  16402. $scope.gridOptions.fastWatch = true;
  16403. $scope.gridOptions.useExternalFiltering = true;
  16404. $scope.gridOptions.useExternalPagination = true;
  16405. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16406. $scope.gridOptions.paginationPageSize = 10;
  16407. $scope.gridOptions.multiSelect = false;
  16408. var mun = $scope.gridOptions.paginationPageSize;
  16409. $scope.gridOptions.rowIdentity = function (row) {
  16410. return row.id;
  16411. };
  16412. $scope.gridOptions.getRowIdentity = function (row) {
  16413. return row.id;
  16414. };
  16415. $scope.gridOptions.columnDefs = items.columnDefs();
  16416. $scope.transferTime = function (time) {
  16417. return moment(time).format("YYYY-MM-DD HH:mm");
  16418. };
  16419. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16420. $scope.gridApi = gridApi;
  16421. gridApi.pagination.on.paginationChanged(
  16422. $scope,
  16423. function (newPage, pageSize) {
  16424. // console.log(newPage);
  16425. // console.log(pageSize);
  16426. $scope.loadData({
  16427. idx: newPage - 1,
  16428. sum: pageSize,
  16429. });
  16430. }
  16431. );
  16432. gridApi.core.on.filterChanged($scope, function () {
  16433. var grid = this.grid;
  16434. var filtersData = {
  16435. idx: 0,
  16436. sum: 100,
  16437. };
  16438. angular.forEach(grid.columns, function (item) {
  16439. if (item.enableFiltering) {
  16440. if (
  16441. angular.isDefined(item.filters[0].term) &&
  16442. item.filters[0].term != ""
  16443. ) {
  16444. // console.log("filtersData="+JSON.stringify(filtersData))
  16445. if (angular.isUndefined(filtersData["incident"])) {
  16446. filtersData["incident"] = {};
  16447. }
  16448. filtersData["incident"][item.field] =
  16449. item.filters[0].term;
  16450. if (angular.isUndefined(filtersData["problem"])) {
  16451. filtersData["problem"] = {};
  16452. }
  16453. filtersData["problem"][item.field] =
  16454. item.filters[0].term;
  16455. if (angular.isUndefined(filtersData["change"])) {
  16456. filtersData["change"] = {};
  16457. }
  16458. filtersData["change"][item.field] =
  16459. item.filters[0].term;
  16460. if (angular.isUndefined(filtersData["release"])) {
  16461. filtersData["release"] = {};
  16462. }
  16463. filtersData["release"][item.field] =
  16464. item.filters[0].term;
  16465. }
  16466. }
  16467. });
  16468. $scope.loadData(filtersData);
  16469. });
  16470. gridApi.selection.on.rowSelectionChanged(
  16471. $scope,
  16472. function (data) {
  16473. $scope.selected.item = data.entity;
  16474. //console.log(data);
  16475. }
  16476. );
  16477. };
  16478. //资产
  16479. $scope.cmdb = {};
  16480. //资产状态
  16481. $scope.state_data = [
  16482. {
  16483. name: "全部状态",
  16484. value: "",
  16485. },
  16486. {
  16487. name: "在库",
  16488. value: "1",
  16489. },
  16490. {
  16491. name: "在线",
  16492. value: "2",
  16493. },
  16494. {
  16495. name: "借出",
  16496. value: "3",
  16497. },
  16498. {
  16499. name: "报修",
  16500. value: "4",
  16501. },
  16502. {
  16503. name: "报废",
  16504. value: "5",
  16505. },
  16506. {
  16507. name: "备用",
  16508. value: "6",
  16509. },
  16510. ];
  16511. //资产类型
  16512. $scope.wt_zcfl = function () {
  16513. api_configure_data
  16514. .fetchDataList("ciclassify", {
  16515. idx: 0,
  16516. sum: 100,
  16517. })
  16518. .then(function (data) {
  16519. console.log(data);
  16520. // $scope.wt_zclx = data.list;
  16521. console.log(data);
  16522. $scope.wtData = [];
  16523. if (data.status == 200) {
  16524. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16525. var root = null; //Initially set our loop to null
  16526. var parentNode = null;
  16527. //loop over data
  16528. // $scope.wtData=data.list;
  16529. data = data.list;
  16530. //知识库分类数据三级处理
  16531. for (var i = 0; i < data.length; i++) {
  16532. // console.log(data[i])
  16533. var datum = data[i];
  16534. //each node will have children, so let's give it a "children" poperty
  16535. // console.log(datum);
  16536. datum.children = [];
  16537. if (!datum.parent) {
  16538. $scope.wtData.push(datum);
  16539. // console.log($scope.wtData)
  16540. } else {
  16541. if ($scope.wtData[0]) {
  16542. if ($scope.wtData[0].id == datum.parent.id) {
  16543. $scope.wtData[0].children.push(datum);
  16544. }
  16545. for (
  16546. var j = 0;
  16547. j < $scope.wtData[0].children.length;
  16548. j++
  16549. ) {
  16550. if (
  16551. $scope.wtData[0].children[j].id ==
  16552. datum.parent.id
  16553. ) {
  16554. $scope.wtData[0].children[j].children.push(
  16555. datum
  16556. );
  16557. }
  16558. }
  16559. }
  16560. if ($scope.wtData[1]) {
  16561. if ($scope.wtData[1].id == datum.parent.id) {
  16562. $scope.wtData[1].children.push(datum);
  16563. }
  16564. for (
  16565. var j = 0;
  16566. j < $scope.wtData[1].children.length;
  16567. j++
  16568. ) {
  16569. if (
  16570. $scope.wtData[1].children[j].id ==
  16571. datum.parent.id
  16572. ) {
  16573. $scope.wtData[1].children[j].children.push(
  16574. datum
  16575. );
  16576. }
  16577. }
  16578. }
  16579. if ($scope.wtData[2]) {
  16580. if ($scope.wtData[2].id == datum.parent.id) {
  16581. $scope.wtData[2].children.push(datum);
  16582. }
  16583. for (
  16584. var j = 0;
  16585. j < $scope.wtData[2].children.length;
  16586. j++
  16587. ) {
  16588. if (
  16589. $scope.wtData[2].children[j].id ==
  16590. datum.parent.id
  16591. ) {
  16592. $scope.wtData[2].children[j].children.push(
  16593. datum
  16594. );
  16595. }
  16596. }
  16597. }
  16598. }
  16599. // console.log($scope.wtData)
  16600. idToNodeMap[datum.id] = datum;
  16601. root = datum;
  16602. // treeMap[datum.id] = root;
  16603. }
  16604. }
  16605. });
  16606. };
  16607. $scope.wt_zcfl();
  16608. //事件
  16609. //受理人,处理人
  16610. $scope.searchkeys = {};
  16611. var fieldata = {
  16612. idx: 0,
  16613. sum: 100,
  16614. flag: -1,
  16615. };
  16616. getUser(fieldata, 3);
  16617. function getUser(fieldatas, it) {
  16618. api_user_data
  16619. .fetchDataList("user", fieldatas)
  16620. .then(function (data) {
  16621. if (it == 1) {
  16622. $scope.acceptUser = data.list;
  16623. } else if (it == 2) {
  16624. $scope.handlingPersonnelUser = data.list;
  16625. } else if (it == 3) {
  16626. $scope.acceptUser = data.list;
  16627. $scope.handlingPersonnelUser = data.list;
  16628. }
  16629. });
  16630. }
  16631. //状态
  16632. $scope.othcode = {};
  16633. api_bpm_data
  16634. .fetchDataList("incidentstatus", {
  16635. idx: 0,
  16636. sum: 100,
  16637. })
  16638. .then(function (response) {
  16639. if (response) {
  16640. if ((response.status = 200)) {
  16641. $scope.state = response.list;
  16642. }
  16643. }
  16644. });
  16645. var defaultFilterData = {
  16646. assignee: $rootScope.user.id,
  16647. searchType: "todo",
  16648. idx: 0,
  16649. sum: mun,
  16650. };
  16651. var defaultFilterData1 = {
  16652. // "searchType": "todo",
  16653. idx: 0,
  16654. sum: mun,
  16655. };
  16656. //搜索
  16657. $scope.chiceIncident = function (parameters, item, stateid) {
  16658. console.log(item, stateid);
  16659. console.log($scope);
  16660. if ($scope.title == "关联资产编号") {
  16661. // alert('222222222222');
  16662. var fildata = defaultFilterData1;
  16663. $scope.gridOptions.paginationCurrentPage = 1;
  16664. var transitiondata = angular.copy(item);
  16665. angular.extend(fildata, transitiondata);
  16666. if (fildata.hw_state) {
  16667. fildata.hw_state = fildata.hw_state.name;
  16668. }
  16669. if (fildata.sign) {
  16670. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16671. fildata.sign = fildata.sign.split(";");
  16672. fildata.sign = fildata.sign.join("");
  16673. fildata.sign = fildata.sign.toLowerCase();
  16674. }
  16675. if (fildata.keys) {
  16676. fildata["searchCriteria"] = "uuid";
  16677. }
  16678. console.log(fildata);
  16679. $scope.loadData(fildata);
  16680. }
  16681. if ($scope.title == "关联事件工单") {
  16682. // alert('3333333333333333')
  16683. if (stateid && stateid.code) {
  16684. item.statusId = stateid.code;
  16685. }
  16686. var fildata = defaultFilterData;
  16687. // $scope.memoryfilterData = fildata;
  16688. if (!fildata.incident) {
  16689. fildata["incident"] = {};
  16690. }
  16691. $scope.gridOptions.paginationCurrentPage = 1;
  16692. var transitiondata = angular.copy(item);
  16693. angular.extend(fildata.incident, transitiondata);
  16694. console.log(fildata);
  16695. // $scope.loadData(fildata);
  16696. api_bpm_data
  16697. .fetchDataList("incident", fildata)
  16698. .then(function (data) {
  16699. console.log(data);
  16700. if (data) {
  16701. $scope.myData = data.list;
  16702. $scope.gridOptions.totalItems = data.totalNum;
  16703. }
  16704. });
  16705. }
  16706. };
  16707. //重置
  16708. $scope.replacement = function (
  16709. parameters,
  16710. searchkeys,
  16711. othcode
  16712. ) {
  16713. // console.log(parameters, searchkeys, othcode);
  16714. delete defaultFilterData.incident;
  16715. console.log(defaultFilterData);
  16716. $scope.parameters = null;
  16717. $scope.searchkeys = {};
  16718. $scope.othcode = {};
  16719. $scope.wt_zcfl();
  16720. };
  16721. $scope.loadData = function (filterData) {
  16722. items
  16723. .fetchItems(filterData, APIService, $rootScope)
  16724. .then(function (data) {
  16725. var myData = Restangular.stripRestangular(data);
  16726. if (myData.data && myData.data.node) {
  16727. $scope.gridOptions.totalItems = myData.total;
  16728. $scope.myData = myData.data.node;
  16729. } else {
  16730. if (myData.resultCount) {
  16731. $scope.gridOptions["totalItems"] = myData.resultCount;
  16732. } else {
  16733. $scope.gridOptions.totalItems = myData.totalNum;
  16734. }
  16735. if (myData.list) {
  16736. $scope.myData = myData.list;
  16737. } else {
  16738. $scope.myData = myData.data;
  16739. }
  16740. }
  16741. });
  16742. };
  16743. $scope.title = title;
  16744. $scope.loadData({
  16745. idx: 0,
  16746. sum: 10,
  16747. });
  16748. $scope.selected = {
  16749. item: {},
  16750. };
  16751. $scope.ok = function () {
  16752. //console.log($scope.selected.item);
  16753. $modalInstance.close($scope.selected.item);
  16754. };
  16755. $scope.cancel = function () {
  16756. $modalInstance.dismiss("cancel");
  16757. };
  16758. },
  16759. size: size,
  16760. resolve: {
  16761. items: function () {
  16762. return {
  16763. fetchItems: function (filterData, APIService, $rootScope) {
  16764. filterData = filterData || {};
  16765. // if(!filterData.idx){
  16766. if (
  16767. angular.isDefined(filterData.idx) &&
  16768. filterData.idx == null
  16769. ) {
  16770. filterData = {
  16771. idx: 0,
  16772. sum: 10,
  16773. };
  16774. }
  16775. return options.templateOptions.fetchItems(
  16776. filterData,
  16777. APIService,
  16778. $rootScope
  16779. );
  16780. },
  16781. columnDefs: function () {
  16782. return options.templateOptions.columnDefs;
  16783. },
  16784. };
  16785. },
  16786. title: function () {
  16787. return options.templateOptions.modalTitle;
  16788. },
  16789. Restangular: function () {
  16790. return options.templateOptions.Restangular;
  16791. },
  16792. APIService: function () {
  16793. return options.templateOptions.ApiService;
  16794. },
  16795. },
  16796. });
  16797. modalInstance.result.then(
  16798. function (selectedItem) {
  16799. var selectitem = {
  16800. title: selectedItem.title,
  16801. description: selectedItem.description,
  16802. };
  16803. if (options.key == "chuku") {
  16804. if (selectedItem.assets) {
  16805. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  16806. selectedItem.assets;
  16807. }
  16808. if (selectedItem.consumables) {
  16809. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  16810. selectedItem.consumables;
  16811. }
  16812. angular.extend(
  16813. $scope.$parent.$parent.$parent.model,
  16814. selectitem
  16815. );
  16816. options.value(selectedItem);
  16817. // options.model.consumables = JSON.parse(consumables);
  16818. } else if (options.templateOptions.pkey == "change") {
  16819. console.log(options);
  16820. angular.extend(options.model);
  16821. options.value(selectedItem);
  16822. } else if (options.key == "cmdbCode") {
  16823. var zc_selectitem = selectedItem.uuid;
  16824. // angular.extend(options.model,zc_selectitem);
  16825. options.model.cmdbCode = zc_selectitem;
  16826. // angular.extend(options.model,zc_selectitem);
  16827. // options.templateOptions.displayName=zc_selectitem;
  16828. options.value(selectedItem);
  16829. console.log(options.model);
  16830. } else {
  16831. angular.extend(options.model, selectitem);
  16832. options.value(selectedItem);
  16833. }
  16834. },
  16835. function () {
  16836. //console.log('Modal dismissed at: ' + new Date());
  16837. }
  16838. );
  16839. },
  16840. },
  16841. };
  16842. },
  16843. });
  16844. //选项选择控件
  16845. formlyConfigProvider.setType({
  16846. name: "ui-modelselect",
  16847. extends: "input",
  16848. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16849. defaultOptions: function (options) {
  16850. return {
  16851. templateOptions: {
  16852. openModal: function (size, options, modal) {
  16853. var modalInstance = modal.open({
  16854. templateUrl:
  16855. "assets/views/customform/tpl/checktable-modal-content.html",
  16856. controller: function (
  16857. $scope,
  16858. $modalInstance,
  16859. items,
  16860. title,
  16861. Restangular,
  16862. APIService,
  16863. i18nService
  16864. ) {
  16865. $scope.langs = i18nService.getAllLangs();
  16866. $scope.lang = "zh-cn";
  16867. i18nService.setCurrentLang($scope.lang);
  16868. $scope.gridOptions = {};
  16869. $scope.gridOptions.data = "myData";
  16870. $scope.gridOptions.enableColumnResizing = true;
  16871. $scope.gridOptions.enableFiltering = true;
  16872. $scope.gridOptions.enableGridMenu = false;
  16873. $scope.gridOptions.enableRowSelection = true;
  16874. $scope.gridOptions.showGridFooter = true;
  16875. $scope.gridOptions.showColumnFooter = true;
  16876. $scope.gridOptions.fastWatch = true;
  16877. $scope.gridOptions.useExternalFiltering = true;
  16878. $scope.gridOptions.useExternalPagination = true;
  16879. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16880. $scope.gridOptions.paginationPageSize = 10;
  16881. $scope.gridOptions.multiSelect = false;
  16882. $scope.gridOptions.rowIdentity = function (row) {
  16883. return row.id;
  16884. };
  16885. $scope.gridOptions.getRowIdentity = function (row) {
  16886. return row.id;
  16887. };
  16888. $scope.gridOptions.columnDefs = items.columnDefs();
  16889. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16890. $scope.gridApi = gridApi;
  16891. gridApi.pagination.on.paginationChanged(
  16892. $scope,
  16893. function (newPage, pageSize) {
  16894. // console.log(newPage);
  16895. // console.log(pageSize);
  16896. $scope.loadData({
  16897. idx: newPage - 1,
  16898. sum: pageSize,
  16899. });
  16900. }
  16901. );
  16902. gridApi.core.on.filterChanged($scope, function () {
  16903. var grid = this.grid;
  16904. var filtersData = {
  16905. idx: 0,
  16906. sum: 10,
  16907. };
  16908. angular.forEach(grid.columns, function (item) {
  16909. if (item.enableFiltering) {
  16910. if (
  16911. angular.isDefined(item.filters[0].term) &&
  16912. item.filters[0].term != ""
  16913. ) {
  16914. // console.log("filtersData="+JSON.stringify(filtersData))
  16915. if (angular.isUndefined(filtersData["incident"])) {
  16916. filtersData["incident"] = {};
  16917. }
  16918. filtersData["incident"][item.field] =
  16919. item.filters[0].term;
  16920. if (angular.isUndefined(filtersData["problem"])) {
  16921. filtersData["problem"] = {};
  16922. }
  16923. filtersData["problem"][item.field] =
  16924. item.filters[0].term;
  16925. if (angular.isUndefined(filtersData["change"])) {
  16926. filtersData["change"] = {};
  16927. }
  16928. filtersData["change"][item.field] =
  16929. item.filters[0].term;
  16930. if (angular.isUndefined(filtersData["release"])) {
  16931. filtersData["release"] = {};
  16932. }
  16933. filtersData["release"][item.field] =
  16934. item.filters[0].term;
  16935. }
  16936. }
  16937. });
  16938. $scope.loadData(filtersData);
  16939. });
  16940. gridApi.selection.on.rowSelectionChanged(
  16941. $scope,
  16942. function (data) {
  16943. $scope.selected.item = data.entity;
  16944. //console.log(data);
  16945. }
  16946. );
  16947. };
  16948. $scope.loadData = function (filterData) {
  16949. items
  16950. .fetchItems(filterData, APIService)
  16951. .then(function (data) {
  16952. var myData = Restangular.stripRestangular(data);
  16953. $scope.gridOptions.totalItems = myData.totalNum;
  16954. $scope.myData = myData.list;
  16955. });
  16956. };
  16957. $scope.title = title;
  16958. $scope.loadData({
  16959. idx: 0,
  16960. sum: 10,
  16961. });
  16962. $scope.selected = {
  16963. item: {},
  16964. };
  16965. $scope.ok = function () {
  16966. if ($scope.selected.item.scheduleOrder) {
  16967. $scope.selected.item.descriptionData =
  16968. "日期:" +
  16969. $scope.selected.item.watchTime +
  16970. ";" +
  16971. "班次:" +
  16972. $scope.selected.item.scheduleOrder.description +
  16973. ";" +
  16974. "值班人:" +
  16975. $scope.selected.item.scheduleOrder.users[0].name;
  16976. }
  16977. //console.log($scope.selected.item);
  16978. $modalInstance.close($scope.selected.item);
  16979. };
  16980. $scope.cancel = function () {
  16981. $modalInstance.dismiss("cancel");
  16982. };
  16983. },
  16984. size: size,
  16985. resolve: {
  16986. items: function () {
  16987. return {
  16988. fetchItems: function (filterData, APIService) {
  16989. filterData = filterData || {};
  16990. // if(!filterData.idx){
  16991. if (
  16992. angular.isDefined(filterData.idx) &&
  16993. filterData.idx == null
  16994. ) {
  16995. filterData = {
  16996. idx: 0,
  16997. sum: 10,
  16998. };
  16999. }
  17000. return options.templateOptions.fetchItems(
  17001. filterData,
  17002. APIService,
  17003. options
  17004. );
  17005. },
  17006. columnDefs: function () {
  17007. return options.templateOptions.columnDefs;
  17008. },
  17009. };
  17010. },
  17011. title: function () {
  17012. return options.templateOptions.modalTitle;
  17013. },
  17014. Restangular: function () {
  17015. return options.templateOptions.Restangular;
  17016. },
  17017. APIService: function () {
  17018. return options.templateOptions.ApiService;
  17019. },
  17020. },
  17021. });
  17022. modalInstance.result.then(
  17023. function (selectedItem) {
  17024. options.value(selectedItem);
  17025. },
  17026. function () {
  17027. //console.log('Modal dismissed at: ' + new Date());
  17028. }
  17029. );
  17030. },
  17031. },
  17032. };
  17033. },
  17034. });
  17035. formlyConfigProvider.setType({
  17036. name: "ui-requestform",
  17037. extends: "input",
  17038. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  17039. controller: [
  17040. "$scope",
  17041. function ($scope) {
  17042. setTimeout(function () {
  17043. var filterData = {
  17044. idx: 0,
  17045. sum: 5,
  17046. incident: {
  17047. requester: {
  17048. id: "",
  17049. },
  17050. },
  17051. };
  17052. $scope.options.templateOptions
  17053. .getWorkernumber(
  17054. $scope.options.templateOptions.ApiService,
  17055. filterData
  17056. )
  17057. .then(function (result) {
  17058. var modelData =
  17059. $scope.options.templateOptions.Restangular.stripRestangular(
  17060. result
  17061. );
  17062. });
  17063. }, 1000);
  17064. },
  17065. ],
  17066. });
  17067. //报修图片展示
  17068. formlyConfigProvider.setType({
  17069. name: "ui-repair-photos",
  17070. // extends: 'label',
  17071. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  17072. controller: [
  17073. "$scope",
  17074. "api_wechatfile",
  17075. "$stateParams",
  17076. function ($scope, api_wechatfile, $stateParams) {
  17077. console.log($scope);
  17078. $scope.fileUrls = [];
  17079. if ($scope.model.wxFile) {
  17080. api_wechatfile
  17081. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  17082. .then(function (res) {
  17083. $scope.fileUrls = res.data;
  17084. });
  17085. }
  17086. console.log($stateParams);
  17087. if (
  17088. $stateParams &&
  17089. $stateParams.model &&
  17090. JSON.parse($stateParams.model) &&
  17091. JSON.parse($stateParams.model).model &&
  17092. JSON.parse($stateParams.model).model.flow
  17093. ) {
  17094. api_wechatfile
  17095. .listAttachment(
  17096. "wechatRequesterIncident",
  17097. JSON.parse($stateParams.model).model.flow
  17098. )
  17099. .then(function (res) {
  17100. $scope.fileUrls = res.data;
  17101. });
  17102. }
  17103. if ($scope.model.flow) {
  17104. api_wechatfile
  17105. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  17106. .then(function (res) {
  17107. $scope.fileUrls = res.data;
  17108. });
  17109. }
  17110. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  17111. // // setTimeout(function () {
  17112. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  17113. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  17114. // // if (modelData.status == 200) {
  17115. // // $scope.model[$scope.options.key] = modelData.data;
  17116. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  17117. // // }
  17118. // // });
  17119. // // }, 1000);
  17120. // }
  17121. $scope.showBigImg = false;
  17122. $scope.showBigImgCli = function (data) {
  17123. $scope.showBigImg = true;
  17124. $scope.bigImgUrl = data;
  17125. };
  17126. $scope.closeBigImg = function () {
  17127. $scope.showBigImg = false;
  17128. };
  17129. },
  17130. ],
  17131. });
  17132. //图片展示
  17133. formlyConfigProvider.setType({
  17134. name: "ui-showImgs",
  17135. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  17136. defaultOptions: function (options) {
  17137. return {
  17138. templateOptions: {
  17139. refresh: function (APIService, processInstanceId, data) {
  17140. return APIService.listAttachments(processInstanceId);
  17141. },
  17142. downloadUri: function (APIService, contentId) {
  17143. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17144. },
  17145. view: function (APIService, contentId) {
  17146. return APIService.attachmentsPreviewUrl(contentId);
  17147. },
  17148. download: function (APIService, contentId, item) {
  17149. var item = {
  17150. url: APIService.download(contentId),
  17151. headers: headers,
  17152. };
  17153. return item;
  17154. },
  17155. refreshDelay: 0,
  17156. },
  17157. };
  17158. },
  17159. controller: [
  17160. "$scope",
  17161. "$timeout",
  17162. "$modal",
  17163. "$rootScope",
  17164. "$http",
  17165. "up_down_file",
  17166. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17167. var _refreshDelayPromise;
  17168. /**
  17169. * refresh
  17170. */
  17171. $scope._refresh = function (refreshAttr) {
  17172. $scope.attachments = [];
  17173. if (refreshAttr !== undefined) {
  17174. if (_refreshDelayPromise) {
  17175. $timeout.cancel(_refreshDelayPromise);
  17176. }
  17177. _refreshDelayPromise = $timeout(function () {
  17178. // 暂存附件
  17179. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17180. $scope.options.templateOptions
  17181. .refresh(
  17182. $scope.options.templateOptions.ApiService,
  17183. $scope.options.templateOptions.processInstanceId,
  17184. {
  17185. idx: 0,
  17186. sum: 1000,
  17187. }
  17188. )
  17189. .then(function (response) {
  17190. var myData =
  17191. $scope.options.templateOptions.Restangular.stripRestangular(
  17192. response
  17193. );
  17194. if (myData) {
  17195. for (var i = 0; i < myData.data.length; i++) {
  17196. $scope.attachments.push(myData.data[i]);
  17197. }
  17198. }
  17199. $scope.options.templateOptions
  17200. .refresh(
  17201. $scope.options.templateOptions.ApiService,
  17202. $scope.$parent.$parent.$parent.model.save_fileId,
  17203. {
  17204. idx: 0,
  17205. sum: 1000,
  17206. }
  17207. )
  17208. .then(function (response2) {
  17209. var myData2 =
  17210. $scope.options.templateOptions.Restangular.stripRestangular(
  17211. response2
  17212. );
  17213. if (myData2) {
  17214. for (var i = 0; i < myData2.data.length; i++) {
  17215. $scope.attachments.push(myData2.data[i]);
  17216. }
  17217. }
  17218. console.log($scope.attachments);
  17219. });
  17220. });
  17221. // 正常附件
  17222. } else {
  17223. $scope.options.templateOptions
  17224. .refresh(
  17225. $scope.options.templateOptions.ApiService,
  17226. $scope.options.templateOptions.processInstanceId,
  17227. {
  17228. idx: 0,
  17229. sum: 1000,
  17230. }
  17231. )
  17232. .then(function (response) {
  17233. var myData =
  17234. $scope.options.templateOptions.Restangular.stripRestangular(
  17235. response
  17236. );
  17237. if (myData) {
  17238. $scope.attachments = [];
  17239. $scope.imgs = [];
  17240. myData.data.forEach((e) => {
  17241. if (
  17242. e.suffix == "jpeg" ||
  17243. e.suffix == "jpg" ||
  17244. e.suffix == "svg" ||
  17245. e.suffix == "png" ||
  17246. e.suffix == "bmp" ||
  17247. e.suffix == "gif" ||
  17248. e.suffix == "tif"
  17249. ) {
  17250. $scope.imgs.push(e);
  17251. }
  17252. });
  17253. $scope.imgs = $scope.imgs.splice(0, 3);
  17254. console.log($scope.imgs);
  17255. }
  17256. });
  17257. }
  17258. }, $scope.options.templateOptions.refreshDelay);
  17259. }
  17260. };
  17261. $scope._refresh({});
  17262. // $scope.attachments = $scope.model[$scope.options.key]
  17263. // 预览
  17264. $scope.preview = function (url, idx) {
  17265. var title = $scope.imgs[idx].title;
  17266. $modal.open({
  17267. backdrop: false,
  17268. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17269. controller: function ($scope, scope, $modalInstance) {
  17270. $scope.title = title;
  17271. $scope.imageurl = url;
  17272. $scope.cancel = function () {
  17273. $modalInstance.dismiss("cancel");
  17274. };
  17275. },
  17276. resolve: {
  17277. scope: function () {
  17278. return $scope;
  17279. },
  17280. },
  17281. });
  17282. };
  17283. },
  17284. ],
  17285. });
  17286. //工单/受理人控件
  17287. formlyConfigProvider.setType({
  17288. name: "ui-workernumbersign",
  17289. // extends: 'label',
  17290. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  17291. controller: [
  17292. "$scope",
  17293. function ($scope) {
  17294. // 2020年4月24日13:20:40
  17295. console.log($scope, "docu");
  17296. // 左侧事件工单区域地点填充
  17297. $scope.model.selecthouseNumber = $scope.model.place;
  17298. if (
  17299. angular.isUndefined($scope.model[$scope.options.key]) ||
  17300. $scope.model[$scope.options.key] == null
  17301. ) {
  17302. setTimeout(function () {
  17303. $scope.options.templateOptions
  17304. .getWorkernumber($scope.options.templateOptions.ApiService)
  17305. .then(function (result) {
  17306. var modelData =
  17307. $scope.options.templateOptions.Restangular.stripRestangular(
  17308. result
  17309. );
  17310. if (modelData.status == 200) {
  17311. $scope.model[$scope.options.key] = modelData.data;
  17312. $scope.options.initialValue =
  17313. $scope.model[$scope.options.key];
  17314. }
  17315. });
  17316. }, 1000);
  17317. }
  17318. if (
  17319. $scope.options.templateOptions.user &&
  17320. (angular.isUndefined($scope.model.acceptUser) ||
  17321. $scope.model.acceptUser == null)
  17322. ) {
  17323. if (angular.isFunction($scope.options.templateOptions.transform)) {
  17324. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  17325. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  17326. // }
  17327. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17328. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17329. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  17330. }
  17331. $scope.model.acceptUser = $scope.options.templateOptions.user;
  17332. // $scope.options.initialValue = $scope.model.acceptUser;
  17333. }
  17334. },
  17335. ],
  17336. });
  17337. //工单控件-only number
  17338. formlyConfigProvider.setType({
  17339. name: "ui-workernumber",
  17340. extends: "input",
  17341. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17342. controller: [
  17343. "$scope",
  17344. function ($scope) {
  17345. if (
  17346. angular.isUndefined($scope.model[$scope.options.key]) ||
  17347. $scope.model[$scope.options.key] == null
  17348. ) {
  17349. setTimeout(function () {
  17350. $scope.options.templateOptions
  17351. .getWorkernumber($scope.options.templateOptions.ApiService)
  17352. .then(function (result) {
  17353. var modelData =
  17354. $scope.options.templateOptions.Restangular.stripRestangular(
  17355. result
  17356. );
  17357. if (modelData.status == 200) {
  17358. $scope.model[$scope.options.key] = modelData.data;
  17359. $scope.options.initialValue =
  17360. $scope.model[$scope.options.key];
  17361. }
  17362. });
  17363. }, 1000);
  17364. }
  17365. },
  17366. ],
  17367. });
  17368. //cmdb工单
  17369. formlyConfigProvider.setType({
  17370. name: "ui-cmdbworkernumber",
  17371. extends: "input",
  17372. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17373. controller: [
  17374. "$scope",
  17375. function ($scope) {
  17376. if (
  17377. angular.isUndefined($scope.model[$scope.options.key]) ||
  17378. $scope.model[$scope.options.key] == null
  17379. ) {
  17380. setTimeout(function () {
  17381. $scope.options.templateOptions
  17382. .getWorkernumber(
  17383. $scope.options.templateOptions.ApiService,
  17384. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17385. .cifilter_classics.id
  17386. )
  17387. .then(function (result) {
  17388. var modelData =
  17389. $scope.options.templateOptions.Restangular.stripRestangular(
  17390. result
  17391. );
  17392. // if(modelData.status==200){
  17393. $scope.model[$scope.options.key] =
  17394. modelData[$scope.options.key];
  17395. $scope.options.initialValue = $scope.model[$scope.options.key];
  17396. // }
  17397. });
  17398. }, 1000);
  17399. }
  17400. },
  17401. ],
  17402. });
  17403. //简易上传图片组件
  17404. formlyConfigProvider.setType({
  17405. name: "ui-uploadImgs",
  17406. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17407. wrapper: ["bootstrapHasError"],
  17408. controller: [
  17409. "$scope",
  17410. "fileReader",
  17411. "$parse",
  17412. "$modal",
  17413. function ($scope, fileReader, $parse, $modal) {
  17414. $scope.imgshows = [];
  17415. $scope.uploadimgs = [];
  17416. var model = $parse("upload_img");
  17417. var modelSetter = model.assign;
  17418. var uploader = ($scope.uploader =
  17419. $scope.options.templateOptions.fileUploader);
  17420. uploader.filters.push({
  17421. name: "customFilter",
  17422. fn: function (item /*{File|FileLikeObject}*/, options) {
  17423. return this.queue.length < 10;
  17424. },
  17425. });
  17426. // 添加
  17427. $scope.change = function (event) {
  17428. var element = $(".upinp");
  17429. modelSetter($scope, element[0].files[0]);
  17430. //附件预览
  17431. $scope.imgupload = event.files[0];
  17432. getFile($scope.imgupload, $scope);
  17433. //获得预览图地址并且把file对象放入上传合集内
  17434. function getFile(imgupload, $scope) {
  17435. if (!imgupload) {
  17436. return;
  17437. }
  17438. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17439. $scope.imgshows.push(result);
  17440. var file = document.querySelector("input[type=file]").files[0];
  17441. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17442. console.log($scope.imgshows, $scope.uploadimgs);
  17443. if ($scope.imgshows.length < 3) {
  17444. $("#upup").show();
  17445. } else {
  17446. $("#upup").hide();
  17447. }
  17448. });
  17449. }
  17450. };
  17451. // 删除
  17452. $scope.uploadimg_del = function (index, imgs) {
  17453. console.log(index, imgs);
  17454. $scope.imgshows.splice(index, 1);
  17455. $scope.uploadimgs.splice(index, 1);
  17456. if ($scope.imgshows.length < 3) {
  17457. $("#upup").show();
  17458. } else {
  17459. $("#upup").hide();
  17460. }
  17461. };
  17462. // 预览
  17463. $scope.preview = function (url, idx) {
  17464. var name = $scope.uploadimgs[idx].name;
  17465. $modal.open({
  17466. backdrop: false,
  17467. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17468. controller: function ($scope, scope, $modalInstance) {
  17469. $scope.title = name;
  17470. $scope.imageurl = url;
  17471. $scope.cancel = function () {
  17472. $modalInstance.dismiss("cancel");
  17473. };
  17474. },
  17475. resolve: {
  17476. scope: function () {
  17477. return $scope;
  17478. },
  17479. },
  17480. });
  17481. };
  17482. if (uploader) {
  17483. uploader.onWhenAddingFileFailed = function (
  17484. item /*{File|FileLikeObject}*/,
  17485. filter,
  17486. options
  17487. ) {
  17488. console.info("onWhenAddingFileFailed", item, filter, options);
  17489. };
  17490. uploader.onAfterAddingFile = function (fileItem) {
  17491. console.info("onAfterAddingFile", fileItem);
  17492. };
  17493. uploader.onAfterAddingAll = function (addedFileItems) {
  17494. console.info("onAfterAddingAll", addedFileItems);
  17495. };
  17496. uploader.onBeforeUploadItem = function (item) {
  17497. console.info("onBeforeUploadItem", item);
  17498. };
  17499. uploader.onProgressItem = function (fileItem, progress) {
  17500. console.info("onProgressItem", fileItem, progress);
  17501. };
  17502. uploader.onProgressAll = function (progress) {
  17503. console.info("onProgressAll", progress);
  17504. };
  17505. uploader.onSuccessItem = function (
  17506. fileItem,
  17507. response,
  17508. status,
  17509. headers
  17510. ) {
  17511. console.info("onSuccessItem", fileItem, response, status, headers);
  17512. };
  17513. uploader.onErrorItem = function (
  17514. fileItem,
  17515. response,
  17516. status,
  17517. headers
  17518. ) {
  17519. console.info("onErrorItem", fileItem, response, status, headers);
  17520. };
  17521. uploader.onCancelItem = function (
  17522. fileItem,
  17523. response,
  17524. status,
  17525. headers
  17526. ) {
  17527. console.info("onCancelItem", fileItem, response, status, headers);
  17528. };
  17529. uploader.onCompleteItem = function (
  17530. fileItem,
  17531. response,
  17532. status,
  17533. headers
  17534. ) {
  17535. console.info("onCompleteItem", fileItem, response, status, headers);
  17536. };
  17537. uploader.onCompleteAll = function () {
  17538. console.info("onCompleteAll");
  17539. };
  17540. }
  17541. // console.log(modelSetter)
  17542. },
  17543. ],
  17544. });
  17545. //jry-上传下载一体
  17546. formlyConfigProvider.setType({
  17547. name: "ui-upDropFile",
  17548. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17549. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17550. defaultOptions: function (options) {
  17551. return {
  17552. templateOptions: {
  17553. view: function (APIService, contentId) {
  17554. return APIService.downloadAttachment(contentId);
  17555. },
  17556. // ApiService: 'api_wechatfile',
  17557. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17558. // upUrl: 'common/common/uploadAttachment',
  17559. // listAttachmentUrl: 'common/common/listAttachment',
  17560. // downUrl: 'common/common/downloadAttachment',
  17561. // bindType: 'incident',
  17562. // bindId: 2323
  17563. },
  17564. // validators: {
  17565. // required: {
  17566. // expression: function(viewValue, modelValue) {
  17567. // var value = modelValue || viewValue;
  17568. // return value.length >= 1;
  17569. // }
  17570. // }
  17571. // }
  17572. };
  17573. },
  17574. controller: [
  17575. "$scope",
  17576. "$rootScope",
  17577. "Restangular",
  17578. "up_down_file",
  17579. "$http",
  17580. "api_bpm",
  17581. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17582. console.log($scope);
  17583. $scope.showFileUp = true;
  17584. if ($scope.model.isKnowledge_detail) {
  17585. $scope.showFileUp = false;
  17586. }
  17587. if (angular.isUndefined($scope.form.dropState)) {
  17588. $scope.form.dropState = false;
  17589. }
  17590. if ($scope.model.incident) {
  17591. if ($scope.model.incident.alarm) {
  17592. console.log($scope);
  17593. if ($scope.model.incident.alarm) {
  17594. if ($scope.model.incident.alarm.alarmExtension) {
  17595. $scope.model.incident.alarm.alarmExtension =
  17596. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17597. $scope.model.incident.alarm.alarmExtension =
  17598. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17599. $scope.model.incident.description =
  17600. $scope.model.incident.alarm.alarmExtension;
  17601. console.log($scope.model.incident.description);
  17602. $scope.model.incident.description =
  17603. '"' +
  17604. "告警名称" +
  17605. '":' +
  17606. '"' +
  17607. $scope.model.incident.alarm.alarmSystem +
  17608. '",' +
  17609. '"' +
  17610. "告警状态" +
  17611. '":' +
  17612. '"' +
  17613. $scope.model.incident.alarm.alarmStatus +
  17614. '",' +
  17615. '"' +
  17616. "告警内容" +
  17617. '":' +
  17618. '"' +
  17619. $scope.model.incident.alarm.alarmContent +
  17620. '",' +
  17621. $scope.model.incident.description;
  17622. } else {
  17623. $scope.model.incident.description =
  17624. '"' +
  17625. "告警名称" +
  17626. '":' +
  17627. '"' +
  17628. $scope.model.incident.alarm.alarmSystem +
  17629. '",' +
  17630. '"' +
  17631. "告警状态" +
  17632. '":' +
  17633. '"' +
  17634. $scope.model.incident.alarm.alarmStatus +
  17635. '",' +
  17636. '"' +
  17637. "告警内容" +
  17638. '":' +
  17639. '"' +
  17640. $scope.model.incident.alarm.alarmContent +
  17641. '",';
  17642. }
  17643. $scope.model.incident.description =
  17644. $scope.model.incident.description.replace(/,/g, "\n");
  17645. console.log($scope.model.incident.description);
  17646. }
  17647. }
  17648. api_bpm
  17649. .tellCategory($scope.model.incident.category.id)
  17650. .then(function (wt_data) {
  17651. console.log(wt_data);
  17652. if (wt_data) {
  17653. $rootScope.wt_category = wt_data.data;
  17654. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  17655. $rootScope.wt_child = wt_data.child;
  17656. }
  17657. });
  17658. if ($scope.model.titleName == "接单") {
  17659. $scope.model.receive_code = "handler";
  17660. if (
  17661. $scope.model.incident.groupLeader &&
  17662. !$scope.model.incident.repeat
  17663. ) {
  17664. $scope.model.isHandlerUser = true;
  17665. }
  17666. }
  17667. if ($scope.model.titleName == "事件处理") {
  17668. console.log($scope.model.cmdbCode);
  17669. if ($scope.model.cmdbCode) {
  17670. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  17671. }
  17672. }
  17673. } else {
  17674. $rootScope.wt_category = "";
  17675. }
  17676. //附件上传数据
  17677. if ($scope.options.templateOptions.fileUploader) {
  17678. var uploader = ($scope.uploader =
  17679. $scope.options.templateOptions.fileUploader);
  17680. //$scope.options.templateOptions.uploader();
  17681. console.log(uploader);
  17682. // FILTERS
  17683. uploader.filters.push({
  17684. name: "customFilter",
  17685. fn: function (item /*{File|FileLikeObject}*/, options) {
  17686. return this.queue.length < 10;
  17687. },
  17688. });
  17689. }
  17690. var to = $scope.options.templateOptions;
  17691. // var bindType = $scope.model.bindType;
  17692. if (to.bindType == "incident") {
  17693. var bindId = $scope.model[to.bindType].processInstanceId;
  17694. } else if (to.bindType == "change") {
  17695. var bindId = $scope.model[to.bindType].processInstanceId;
  17696. } else {
  17697. var bindId = $scope.model[to.bindType].id;
  17698. }
  17699. //获取附件列表
  17700. $scope.listAttachmen = function () {
  17701. to.ApiService.listAttachment(
  17702. to.listAttachmentUrl,
  17703. to.bindType,
  17704. bindId
  17705. ).then(function (result) {
  17706. var myData = Restangular.stripRestangular(result);
  17707. // $scope.listAttachmens = myData;
  17708. $scope.attachments = myData.data;
  17709. });
  17710. };
  17711. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  17712. $scope.listAttachmen();
  17713. } else if (to.bindType && $scope.model[to.bindType].id) {
  17714. $scope.listAttachmen();
  17715. }
  17716. //附件上传
  17717. $scope.isUpfload = to.isUpfload;
  17718. $scope.dropfile = function (
  17719. APIService,
  17720. processInstanceId,
  17721. taskId,
  17722. userId
  17723. ) {
  17724. uploader.onBeforeUploadItem = function (item) {
  17725. angular.extend(item.headers, $rootScope.getSession());
  17726. item.url = to.ApiService.saveAttachments(
  17727. to.uploadUrl,
  17728. to.bindType,
  17729. bindId
  17730. ).getRequestedUrl();
  17731. item.formData.push({
  17732. filename: item.file.name,
  17733. });
  17734. };
  17735. uploader.uploadAll();
  17736. };
  17737. //附件下载
  17738. $scope.download = function (attachment) {
  17739. // $scope.download = function (token, filename) {
  17740. var downUrl = attachment.previewUrl;
  17741. // var downUrl = to.ApiService.downloadAttachment(
  17742. // to.downUrl,
  17743. // token
  17744. // ).getRequestedUrl();
  17745. // window.open(downUrl);
  17746. var a = document.createElement("a");
  17747. a.href = downUrl;
  17748. a.target = "_blank";
  17749. a.download = attachment.name;
  17750. document.body.appendChild(a);
  17751. a.click();
  17752. };
  17753. //附件预览
  17754. $scope.view = function (id, previewUrl) {
  17755. if (previewUrl) {
  17756. window.open(previewUrl);
  17757. }
  17758. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  17759. // if (response.state == 200) {
  17760. // window.open(response.previewUrl);
  17761. // }
  17762. // })
  17763. };
  17764. // CALLBACKS
  17765. if (uploader) {
  17766. uploader.onWhenAddingFileFailed = function (
  17767. item /*{File|FileLikeObject}*/,
  17768. filter,
  17769. options
  17770. ) {
  17771. console.info("onWhenAddingFileFailed", item, filter, options);
  17772. };
  17773. uploader.onAfterAddingFile = function (fileItem) {
  17774. console.info("onAfterAddingFile", fileItem);
  17775. };
  17776. uploader.onAfterAddingAll = function (addedFileItems) {
  17777. console.info("onAfterAddingAll", addedFileItems);
  17778. };
  17779. uploader.onBeforeUploadItem = function (item) {
  17780. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17781. // // $scope.uploader.options.url();
  17782. // $scope.uploader.onBeforeUploadItem = function(item) {
  17783. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17784. // console.info('onBeforeUploadItem', item);
  17785. // };
  17786. // $scope.uploader.uploadAll();
  17787. // }
  17788. console.info("onBeforeUploadItem", item);
  17789. };
  17790. uploader.onProgressItem = function (fileItem, progress) {
  17791. console.info("onProgressItem", fileItem, progress);
  17792. };
  17793. uploader.onProgressAll = function (progress) {
  17794. console.info("onProgressAll", progress);
  17795. };
  17796. uploader.onSuccessItem = function (
  17797. fileItem,
  17798. response,
  17799. status,
  17800. headers
  17801. ) {
  17802. console.info("onSuccessItem", fileItem, response, status, headers);
  17803. if (response.status == 200) {
  17804. $scope.listAttachmen();
  17805. }
  17806. };
  17807. uploader.onErrorItem = function (
  17808. fileItem,
  17809. response,
  17810. status,
  17811. headers
  17812. ) {
  17813. console.info("onErrorItem", fileItem, response, status, headers);
  17814. };
  17815. uploader.onCancelItem = function (
  17816. fileItem,
  17817. response,
  17818. status,
  17819. headers
  17820. ) {
  17821. console.info("onCancelItem", fileItem, response, status, headers);
  17822. };
  17823. uploader.onCompleteItem = function (
  17824. fileItem,
  17825. response,
  17826. status,
  17827. headers
  17828. ) {
  17829. console.info("onCompleteItem", fileItem, response, status, headers);
  17830. };
  17831. uploader.onCompleteAll = function () {
  17832. console.info("onCompleteAll");
  17833. };
  17834. }
  17835. },
  17836. ],
  17837. });
  17838. //简易上传下载附件组件
  17839. formlyConfigProvider.setType({
  17840. name: "ui-upDownFiles",
  17841. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  17842. wrapper: ["bootstrapHasError"],
  17843. defaultOptions: function (options) {
  17844. return {
  17845. templateOptions: {
  17846. refresh: function (APIService, processInstanceId, data) {
  17847. return APIService.listAttachments(processInstanceId);
  17848. },
  17849. downloadUri: function (APIService, contentId) {
  17850. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17851. },
  17852. view: function (APIService, contentId) {
  17853. return APIService.attachmentsPreviewUrl(contentId);
  17854. },
  17855. download: function (APIService, contentId, item) {
  17856. var item = {
  17857. url: APIService.download(contentId),
  17858. headers: headers,
  17859. };
  17860. return item;
  17861. },
  17862. refreshDelay: 0,
  17863. },
  17864. };
  17865. },
  17866. controller: [
  17867. "$scope",
  17868. "$timeout",
  17869. "$modal",
  17870. "$rootScope",
  17871. "$http",
  17872. "up_down_file",
  17873. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17874. if (angular.isUndefined($scope.form.dropState)) {
  17875. $scope.form.dropState = false;
  17876. }
  17877. //附件上传数据
  17878. var uploader = ($scope.uploader =
  17879. $scope.options.templateOptions.fileUploader);
  17880. //$scope.options.templateOptions.uploader();
  17881. // FILTERS
  17882. uploader.filters.push({
  17883. name: "customFilter",
  17884. fn: function (item /*{File|FileLikeObject}*/, options) {
  17885. return this.queue.length < 10;
  17886. },
  17887. });
  17888. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  17889. // uploader.onBeforeUploadItem = function (item) {
  17890. // angular.extend(item.headers, $rootScope.getSession());
  17891. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  17892. // item.formData.push({
  17893. // 'fileName': item.file.name
  17894. // });
  17895. // console.info('onBeforeUploadItem', item);
  17896. // };
  17897. // }
  17898. // CALLBACKS
  17899. uploader.onWhenAddingFileFailed = function (
  17900. item /*{File|FileLikeObject}*/,
  17901. filter,
  17902. options
  17903. ) {
  17904. console.info("onWhenAddingFileFailed", item, filter, options);
  17905. };
  17906. uploader.onAfterAddingFile = function (fileItem) {
  17907. console.info("onAfterAddingFile", fileItem);
  17908. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17909. alert("文件过大");
  17910. fileItem.uploader.queue.pop();
  17911. console.log($scope);
  17912. }
  17913. };
  17914. uploader.onAfterAddingAll = function (addedFileItems) {
  17915. // console.info('onAfterAddingAll', addedFileItems);
  17916. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17917. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17918. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17919. // console.log(123)
  17920. };
  17921. uploader.onBeforeUploadItem = function (item) {
  17922. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17923. // // $scope.uploader.options.url();
  17924. // $scope.uploader.onBeforeUploadItem = function(item) {
  17925. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17926. // console.info('onBeforeUploadItem', item);
  17927. // };
  17928. // $scope.uploader.uploadAll();
  17929. // }
  17930. console.info("onBeforeUploadItem", item);
  17931. };
  17932. uploader.onProgressItem = function (fileItem, progress) {
  17933. console.info("onProgressItem", fileItem, progress);
  17934. };
  17935. uploader.onProgressAll = function (progress) {
  17936. console.info("onProgressAll", progress);
  17937. };
  17938. uploader.onSuccessItem = function (
  17939. fileItem,
  17940. response,
  17941. status,
  17942. headers
  17943. ) {
  17944. console.info("onSuccessItem", fileItem, response, status, headers);
  17945. };
  17946. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17947. console.info("onErrorItem", fileItem, response, status, headers);
  17948. };
  17949. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17950. console.info("onCancelItem", fileItem, response, status, headers);
  17951. };
  17952. uploader.onCompleteItem = function (
  17953. fileItem,
  17954. response,
  17955. status,
  17956. headers
  17957. ) {
  17958. console.info("onCompleteItem", fileItem, response, status, headers);
  17959. };
  17960. uploader.onCompleteAll = function () {
  17961. console.info("onCompleteAll");
  17962. };
  17963. var _refreshDelayPromise;
  17964. // 下载
  17965. $scope.download = function (contentId, filename, token) {
  17966. // console.log(contentId, filename, token)
  17967. //附件下载
  17968. var downUrl = up_down_file
  17969. .downloadAttachment("common/common/downloadAttachment", token)
  17970. .getRequestedUrl();
  17971. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17972. // console.log(downUrl)
  17973. var a = document.createElement("a");
  17974. a.href = downUrl;
  17975. a.target = "_blank";
  17976. a.download = filename;
  17977. document.body.appendChild(a);
  17978. a.click();
  17979. };
  17980. $scope._refresh = function (refreshAttr) {
  17981. $scope.attachments = [];
  17982. if (refreshAttr !== undefined) {
  17983. if (_refreshDelayPromise) {
  17984. $timeout.cancel(_refreshDelayPromise);
  17985. }
  17986. _refreshDelayPromise = $timeout(function () {
  17987. // 暂存附件
  17988. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17989. $scope.options.templateOptions
  17990. .refresh(
  17991. $scope.options.templateOptions.ApiService,
  17992. $scope.options.templateOptions.processInstanceId,
  17993. {
  17994. idx: 0,
  17995. sum: 1000,
  17996. }
  17997. )
  17998. .then(function (response) {
  17999. var myData =
  18000. $scope.options.templateOptions.Restangular.stripRestangular(
  18001. response
  18002. );
  18003. if (myData) {
  18004. for (var i = 0; i < myData.data.length; i++) {
  18005. $scope.attachments.push(myData.data[i]);
  18006. }
  18007. }
  18008. $scope.options.templateOptions
  18009. .refresh(
  18010. $scope.options.templateOptions.ApiService,
  18011. $scope.$parent.$parent.$parent.model.save_fileId,
  18012. {
  18013. idx: 0,
  18014. sum: 1000,
  18015. }
  18016. )
  18017. .then(function (response2) {
  18018. var myData2 =
  18019. $scope.options.templateOptions.Restangular.stripRestangular(
  18020. response2
  18021. );
  18022. if (myData2) {
  18023. for (var i = 0; i < myData2.data.length; i++) {
  18024. $scope.attachments.push(myData2.data[i]);
  18025. }
  18026. // 只展示除图片以外的附件
  18027. var a = [];
  18028. $scope.attachments.forEach((e) => {
  18029. if (
  18030. e.suffix == "jpeg" ||
  18031. e.suffix == "jpg" ||
  18032. e.suffix == "svg" ||
  18033. e.suffix == "png" ||
  18034. e.suffix == "bmp" ||
  18035. e.suffix == "gif" ||
  18036. e.suffix == "tif"
  18037. ) {
  18038. // $scope.imgs.push(e)
  18039. } else {
  18040. a.push(e);
  18041. }
  18042. });
  18043. $scope.attachments = a;
  18044. }
  18045. console.log($scope.attachments);
  18046. });
  18047. });
  18048. // 正常附件
  18049. } else {
  18050. $scope.options.templateOptions
  18051. .refresh(
  18052. $scope.options.templateOptions.ApiService,
  18053. $scope.options.templateOptions.processInstanceId,
  18054. {
  18055. idx: 0,
  18056. sum: 1000,
  18057. }
  18058. )
  18059. .then(function (response) {
  18060. var myData =
  18061. $scope.options.templateOptions.Restangular.stripRestangular(
  18062. response
  18063. );
  18064. if (myData) {
  18065. $scope.attachments = myData.data;
  18066. // 只展示除图片以外的附件
  18067. var a = [];
  18068. $scope.attachments.forEach((e) => {
  18069. if (
  18070. e.suffix == "jpeg" ||
  18071. e.suffix == "jpg" ||
  18072. e.suffix == "svg" ||
  18073. e.suffix == "png" ||
  18074. e.suffix == "bmp" ||
  18075. e.suffix == "gif" ||
  18076. e.suffix == "tif"
  18077. ) {
  18078. // $scope.imgs.push(e)
  18079. } else {
  18080. a.push(e);
  18081. }
  18082. });
  18083. $scope.attachments = a;
  18084. }
  18085. });
  18086. }
  18087. }, $scope.options.templateOptions.refreshDelay);
  18088. }
  18089. };
  18090. $scope._refresh({});
  18091. },
  18092. ],
  18093. });
  18094. //简易上传附件组件
  18095. formlyConfigProvider.setType({
  18096. name: "ui-uploadFiles",
  18097. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  18098. wrapper: ["bootstrapHasError"],
  18099. controller: [
  18100. "$scope",
  18101. function ($scope) {
  18102. if (angular.isUndefined($scope.form.dropState)) {
  18103. $scope.form.dropState = false;
  18104. }
  18105. //附件上传数据
  18106. var uploader = ($scope.uploader =
  18107. $scope.options.templateOptions.fileUploader);
  18108. //$scope.options.templateOptions.uploader();
  18109. // FILTERS
  18110. uploader.filters.push({
  18111. name: "customFilter",
  18112. fn: function (item /*{File|FileLikeObject}*/, options) {
  18113. return this.queue.length < 10;
  18114. },
  18115. });
  18116. $scope.dropfile = function (
  18117. APIService,
  18118. processInstanceId,
  18119. taskId,
  18120. userId
  18121. ) {
  18122. uploader.onBeforeUploadItem = function (item) {
  18123. angular.extend(item.headers, $rootScope.getSession());
  18124. item.url = APIService.saveAttachments(
  18125. processInstanceId,
  18126. taskId,
  18127. userId
  18128. ).getRequestedUrl();
  18129. item.formData.push({
  18130. fileName: item.file.name,
  18131. });
  18132. console.info("onBeforeUploadItem", item);
  18133. };
  18134. };
  18135. // CALLBACKS
  18136. uploader.onWhenAddingFileFailed = function (
  18137. item /*{File|FileLikeObject}*/,
  18138. filter,
  18139. options
  18140. ) {
  18141. console.info("onWhenAddingFileFailed", item, filter, options);
  18142. };
  18143. uploader.onAfterAddingFile = function (fileItem) {
  18144. console.info("onAfterAddingFile", fileItem);
  18145. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18146. alert("文件过大");
  18147. fileItem.uploader.queue.pop();
  18148. console.log($scope);
  18149. }
  18150. };
  18151. uploader.onAfterAddingAll = function (addedFileItems) {
  18152. // console.info('onAfterAddingAll', addedFileItems);
  18153. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18154. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18155. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18156. // console.log(123)
  18157. };
  18158. uploader.onBeforeUploadItem = function (item) {
  18159. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18160. // // $scope.uploader.options.url();
  18161. // $scope.uploader.onBeforeUploadItem = function(item) {
  18162. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18163. // console.info('onBeforeUploadItem', item);
  18164. // };
  18165. // $scope.uploader.uploadAll();
  18166. // }
  18167. console.info("onBeforeUploadItem", item);
  18168. };
  18169. uploader.onProgressItem = function (fileItem, progress) {
  18170. console.info("onProgressItem", fileItem, progress);
  18171. };
  18172. uploader.onProgressAll = function (progress) {
  18173. console.info("onProgressAll", progress);
  18174. };
  18175. uploader.onSuccessItem = function (
  18176. fileItem,
  18177. response,
  18178. status,
  18179. headers
  18180. ) {
  18181. console.info("onSuccessItem", fileItem, response, status, headers);
  18182. };
  18183. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18184. console.info("onErrorItem", fileItem, response, status, headers);
  18185. };
  18186. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18187. console.info("onCancelItem", fileItem, response, status, headers);
  18188. };
  18189. uploader.onCompleteItem = function (
  18190. fileItem,
  18191. response,
  18192. status,
  18193. headers
  18194. ) {
  18195. console.info("onCompleteItem", fileItem, response, status, headers);
  18196. };
  18197. uploader.onCompleteAll = function () {
  18198. console.info("onCompleteAll");
  18199. };
  18200. },
  18201. ],
  18202. });
  18203. //无上传按钮附件上传组件
  18204. formlyConfigProvider.setType({
  18205. name: "ui-dropfilenotup",
  18206. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18207. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18208. controller: [
  18209. "$scope",
  18210. function ($scope) {
  18211. if (angular.isUndefined($scope.form.dropState)) {
  18212. $scope.form.dropState = false;
  18213. }
  18214. //附件上传数据
  18215. var uploader = ($scope.uploader =
  18216. $scope.options.templateOptions.fileUploader);
  18217. //$scope.options.templateOptions.uploader();
  18218. // FILTERS
  18219. uploader.filters.push({
  18220. name: "customFilter",
  18221. fn: function (item /*{File|FileLikeObject}*/, options) {
  18222. return this.queue.length < 10;
  18223. },
  18224. });
  18225. $scope.dropfile = function (
  18226. APIService,
  18227. processInstanceId,
  18228. taskId,
  18229. userId
  18230. ) {
  18231. uploader.onBeforeUploadItem = function (item) {
  18232. angular.extend(item.headers, $rootScope.getSession());
  18233. item.url = APIService.saveAttachments(
  18234. processInstanceId,
  18235. taskId,
  18236. userId
  18237. ).getRequestedUrl();
  18238. item.formData.push({
  18239. fileName: item.file.name,
  18240. });
  18241. console.info("onBeforeUploadItem", item);
  18242. };
  18243. uploader.uploadAll();
  18244. };
  18245. // CALLBACKS
  18246. uploader.onWhenAddingFileFailed = function (
  18247. item /*{File|FileLikeObject}*/,
  18248. filter,
  18249. options
  18250. ) {
  18251. console.info("onWhenAddingFileFailed", item, filter, options);
  18252. };
  18253. uploader.onAfterAddingFile = function (fileItem) {
  18254. console.info("onAfterAddingFile", fileItem);
  18255. };
  18256. uploader.onAfterAddingAll = function (addedFileItems) {
  18257. console.info("onAfterAddingAll", addedFileItems);
  18258. };
  18259. uploader.onBeforeUploadItem = function (item) {
  18260. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18261. // // $scope.uploader.options.url();
  18262. // $scope.uploader.onBeforeUploadItem = function(item) {
  18263. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18264. // console.info('onBeforeUploadItem', item);
  18265. // };
  18266. // $scope.uploader.uploadAll();
  18267. // }
  18268. console.info("onBeforeUploadItem", item);
  18269. };
  18270. uploader.onProgressItem = function (fileItem, progress) {
  18271. console.info("onProgressItem", fileItem, progress);
  18272. };
  18273. uploader.onProgressAll = function (progress) {
  18274. console.info("onProgressAll", progress);
  18275. };
  18276. uploader.onSuccessItem = function (
  18277. fileItem,
  18278. response,
  18279. status,
  18280. headers
  18281. ) {
  18282. console.info("onSuccessItem", fileItem, response, status, headers);
  18283. };
  18284. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18285. console.info("onErrorItem", fileItem, response, status, headers);
  18286. };
  18287. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18288. console.info("onCancelItem", fileItem, response, status, headers);
  18289. };
  18290. uploader.onCompleteItem = function (
  18291. fileItem,
  18292. response,
  18293. status,
  18294. headers
  18295. ) {
  18296. console.info("onCompleteItem", fileItem, response, status, headers);
  18297. };
  18298. uploader.onCompleteAll = function () {
  18299. console.info("onCompleteAll");
  18300. };
  18301. },
  18302. ],
  18303. });
  18304. //无按钮知识库上传
  18305. formlyConfigProvider.setType({
  18306. name: "ui-dropfielkn",
  18307. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18308. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18309. controller: [
  18310. "$scope",
  18311. function ($scope) {
  18312. if (angular.isUndefined($scope.form.dropState)) {
  18313. $scope.form.dropState = false;
  18314. }
  18315. //附件上传数据
  18316. var uploader = ($scope.uploader =
  18317. $scope.options.templateOptions.fileUploader);
  18318. //$scope.options.templateOptions.uploader();
  18319. // FILTERS
  18320. uploader.filters.push({
  18321. name: "customFilter",
  18322. fn: function (item /*{File|FileLikeObject}*/, options) {
  18323. return this.queue.length < 10;
  18324. },
  18325. });
  18326. $scope.dropfile = function (
  18327. APIService,
  18328. processInstanceId,
  18329. taskId,
  18330. userId
  18331. ) {
  18332. uploader.onBeforeUploadItem = function (item) {
  18333. angular.extend(item.headers, $rootScope.getSession());
  18334. item.url = APIService.addFile(
  18335. processInstanceId,
  18336. taskId,
  18337. userId
  18338. ).getRequestedUrl();
  18339. item.formData.push({
  18340. fileName: item.file.name,
  18341. });
  18342. console.info("onBeforeUploadItem", item);
  18343. };
  18344. uploader.uploadAll();
  18345. };
  18346. // CALLBACKS
  18347. uploader.onWhenAddingFileFailed = function (
  18348. item /*{File|FileLikeObject}*/,
  18349. filter,
  18350. options
  18351. ) {
  18352. console.info("onWhenAddingFileFailed", item, filter, options);
  18353. };
  18354. uploader.onAfterAddingFile = function (fileItem) {
  18355. console.info("onAfterAddingFile", fileItem);
  18356. };
  18357. uploader.onAfterAddingAll = function (addedFileItems) {
  18358. console.info("onAfterAddingAll", addedFileItems);
  18359. };
  18360. uploader.onBeforeUploadItem = function (item) {
  18361. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18362. // // $scope.uploader.options.url();
  18363. // $scope.uploader.onBeforeUploadItem = function(item) {
  18364. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18365. // console.info('onBeforeUploadItem', item);
  18366. // };
  18367. // $scope.uploader.uploadAll();
  18368. // }
  18369. console.info("onBeforeUploadItem", item);
  18370. };
  18371. uploader.onProgressItem = function (fileItem, progress) {
  18372. console.info("onProgressItem", fileItem, progress);
  18373. };
  18374. uploader.onProgressAll = function (progress) {
  18375. console.info("onProgressAll", progress);
  18376. };
  18377. uploader.onSuccessItem = function (
  18378. fileItem,
  18379. response,
  18380. status,
  18381. headers
  18382. ) {
  18383. console.info("onSuccessItem", fileItem, response, status, headers);
  18384. };
  18385. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18386. console.info("onErrorItem", fileItem, response, status, headers);
  18387. };
  18388. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18389. console.info("onCancelItem", fileItem, response, status, headers);
  18390. };
  18391. uploader.onCompleteItem = function (
  18392. fileItem,
  18393. response,
  18394. status,
  18395. headers
  18396. ) {
  18397. console.info("onCompleteItem", fileItem, response, status, headers);
  18398. };
  18399. uploader.onCompleteAll = function () {
  18400. console.info("onCompleteAll");
  18401. };
  18402. },
  18403. ],
  18404. });
  18405. //附件上传列表组件
  18406. formlyConfigProvider.setType({
  18407. name: "ui-dropfile",
  18408. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18409. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18410. controller: [
  18411. "$scope",
  18412. "$rootScope",
  18413. function ($scope, $rootScope) {
  18414. if (angular.isUndefined($scope.form.dropState)) {
  18415. $scope.form.dropState = false;
  18416. }
  18417. //附件上传数据
  18418. var uploader = ($scope.uploader =
  18419. $scope.options.templateOptions.fileUploader);
  18420. //$scope.options.templateOptions.uploader();
  18421. // FILTERS
  18422. uploader.filters.push({
  18423. name: "customFilter",
  18424. fn: function (item /*{File|FileLikeObject}*/, options) {
  18425. return this.queue.length < 10;
  18426. },
  18427. });
  18428. $scope.dropfile = function (
  18429. APIService,
  18430. processInstanceId,
  18431. taskId,
  18432. userId
  18433. ) {
  18434. uploader.onBeforeUploadItem = function (item) {
  18435. angular.extend(item.headers, $rootScope.getSession());
  18436. if (
  18437. $scope.options.templateOptions.upservice &&
  18438. $scope.options.templateOptions.formname
  18439. ) {
  18440. // if ($scope.options.templateOptions.formket) {
  18441. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18442. // } else {
  18443. item.url = APIService[$scope.options.templateOptions.upservice](
  18444. $scope.model[$scope.options.templateOptions.formname].id,
  18445. taskId,
  18446. userId
  18447. ).getRequestedUrl();
  18448. // }
  18449. } else {
  18450. item.url = APIService.saveAttachments(
  18451. processInstanceId,
  18452. taskId,
  18453. userId
  18454. ).getRequestedUrl();
  18455. }
  18456. item.formData.push({
  18457. filename: item.file.name,
  18458. });
  18459. console.info("onBeforeUploadItem", item);
  18460. };
  18461. uploader.uploadAll();
  18462. };
  18463. // CALLBACKS
  18464. uploader.onWhenAddingFileFailed = function (
  18465. item /*{File|FileLikeObject}*/,
  18466. filter,
  18467. options
  18468. ) {
  18469. console.info("onWhenAddingFileFailed", item, filter, options);
  18470. };
  18471. uploader.onAfterAddingFile = function (fileItem) {
  18472. console.info("onAfterAddingFile", fileItem);
  18473. };
  18474. uploader.onAfterAddingAll = function (addedFileItems) {
  18475. console.info("onAfterAddingAll", addedFileItems);
  18476. };
  18477. uploader.onBeforeUploadItem = function (item) {
  18478. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18479. // // $scope.uploader.options.url();
  18480. // $scope.uploader.onBeforeUploadItem = function(item) {
  18481. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18482. // console.info('onBeforeUploadItem', item);
  18483. // };
  18484. // $scope.uploader.uploadAll();
  18485. // }
  18486. console.info("onBeforeUploadItem", item);
  18487. };
  18488. uploader.onProgressItem = function (fileItem, progress) {
  18489. console.info("onProgressItem", fileItem, progress);
  18490. };
  18491. uploader.onProgressAll = function (progress) {
  18492. console.info("onProgressAll", progress);
  18493. };
  18494. uploader.onSuccessItem = function (
  18495. fileItem,
  18496. response,
  18497. status,
  18498. headers
  18499. ) {
  18500. console.info("onSuccessItem", fileItem, response, status, headers);
  18501. };
  18502. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18503. console.info("onErrorItem", fileItem, response, status, headers);
  18504. };
  18505. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18506. console.info("onCancelItem", fileItem, response, status, headers);
  18507. };
  18508. uploader.onCompleteItem = function (
  18509. fileItem,
  18510. response,
  18511. status,
  18512. headers
  18513. ) {
  18514. console.info("onCompleteItem", fileItem, response, status, headers);
  18515. };
  18516. uploader.onCompleteAll = function () {
  18517. console.info("onCompleteAll");
  18518. };
  18519. },
  18520. ],
  18521. });
  18522. //简易附件展示下载列表组件
  18523. formlyConfigProvider.setType({
  18524. name: "ui-dropFiles",
  18525. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18526. defaultOptions: function (options) {
  18527. return {
  18528. templateOptions: {
  18529. refresh: function (APIService, processInstanceId, data) {
  18530. return APIService.listAttachments(processInstanceId);
  18531. },
  18532. downloadUri: function (APIService, contentId) {
  18533. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18534. },
  18535. view: function (APIService, contentId) {
  18536. return APIService.attachmentsPreviewUrl(contentId);
  18537. },
  18538. download: function (APIService, contentId, item) {
  18539. var item = {
  18540. url: APIService.download(contentId),
  18541. headers: headers,
  18542. };
  18543. return item;
  18544. },
  18545. refreshDelay: 0,
  18546. },
  18547. };
  18548. },
  18549. controller: [
  18550. "$scope",
  18551. "$timeout",
  18552. "$modal",
  18553. "$rootScope",
  18554. "$http",
  18555. "up_down_file",
  18556. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18557. var _refreshDelayPromise;
  18558. // $scope.downloadUrl = function(contentId){
  18559. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18560. // };
  18561. $scope.download = function (contentId, filename, token) {
  18562. // console.log(contentId, filename, token)
  18563. //附件下载
  18564. var downUrl = up_down_file
  18565. .downloadAttachment("common/common/downloadAttachment", token)
  18566. .getRequestedUrl();
  18567. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18568. // console.log(downUrl)
  18569. var a = document.createElement("a");
  18570. a.href = downUrl;
  18571. a.target = "_blank";
  18572. a.download = filename;
  18573. document.body.appendChild(a);
  18574. a.click();
  18575. };
  18576. $scope.view = function (contentId, token, filename, type) {
  18577. $scope.options.templateOptions
  18578. .view($scope.options.templateOptions.ApiService, contentId)
  18579. .then(function (response) {
  18580. if (response.state == 200) {
  18581. window.open(response.previewUrl);
  18582. }
  18583. });
  18584. };
  18585. /**
  18586. * refresh
  18587. */
  18588. $scope._refresh = function (refreshAttr) {
  18589. $scope.attachments = [];
  18590. if (refreshAttr !== undefined) {
  18591. if (_refreshDelayPromise) {
  18592. $timeout.cancel(_refreshDelayPromise);
  18593. }
  18594. _refreshDelayPromise = $timeout(function () {
  18595. // 暂存附件
  18596. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18597. $scope.options.templateOptions
  18598. .refresh(
  18599. $scope.options.templateOptions.ApiService,
  18600. $scope.options.templateOptions.processInstanceId,
  18601. {
  18602. idx: 0,
  18603. sum: 1000,
  18604. }
  18605. )
  18606. .then(function (response) {
  18607. var myData =
  18608. $scope.options.templateOptions.Restangular.stripRestangular(
  18609. response
  18610. );
  18611. if (myData) {
  18612. for (var i = 0; i < myData.data.length; i++) {
  18613. $scope.attachments.push(myData.data[i]);
  18614. }
  18615. }
  18616. $scope.options.templateOptions
  18617. .refresh(
  18618. $scope.options.templateOptions.ApiService,
  18619. $scope.$parent.$parent.$parent.model.save_fileId,
  18620. {
  18621. idx: 0,
  18622. sum: 1000,
  18623. }
  18624. )
  18625. .then(function (response2) {
  18626. var myData2 =
  18627. $scope.options.templateOptions.Restangular.stripRestangular(
  18628. response2
  18629. );
  18630. if (myData2) {
  18631. for (var i = 0; i < myData2.data.length; i++) {
  18632. $scope.attachments.push(myData2.data[i]);
  18633. }
  18634. // 只展示除图片以外的附件
  18635. var a = [];
  18636. $scope.attachments.forEach((e) => {
  18637. if (
  18638. e.suffix == "jpeg" ||
  18639. e.suffix == "jpg" ||
  18640. e.suffix == "svg" ||
  18641. e.suffix == "png" ||
  18642. e.suffix == "bmp" ||
  18643. e.suffix == "gif" ||
  18644. e.suffix == "tif"
  18645. ) {
  18646. // $scope.imgs.push(e)
  18647. } else {
  18648. a.push(e);
  18649. }
  18650. });
  18651. $scope.attachments = a;
  18652. }
  18653. console.log($scope.attachments);
  18654. });
  18655. });
  18656. // 正常附件
  18657. } else {
  18658. $scope.options.templateOptions
  18659. .refresh(
  18660. $scope.options.templateOptions.ApiService,
  18661. $scope.options.templateOptions.processInstanceId,
  18662. {
  18663. idx: 0,
  18664. sum: 1000,
  18665. }
  18666. )
  18667. .then(function (response) {
  18668. var myData =
  18669. $scope.options.templateOptions.Restangular.stripRestangular(
  18670. response
  18671. );
  18672. if (myData) {
  18673. $scope.attachments = myData.data;
  18674. // 只展示除图片以外的附件
  18675. var a = [];
  18676. $scope.attachments.forEach((e) => {
  18677. if (
  18678. e.suffix == "jpeg" ||
  18679. e.suffix == "jpg" ||
  18680. e.suffix == "svg" ||
  18681. e.suffix == "png" ||
  18682. e.suffix == "bmp" ||
  18683. e.suffix == "gif" ||
  18684. e.suffix == "tif"
  18685. ) {
  18686. // $scope.imgs.push(e)
  18687. } else {
  18688. a.push(e);
  18689. }
  18690. });
  18691. $scope.attachments = a;
  18692. console.log($scope.attachments);
  18693. }
  18694. });
  18695. }
  18696. }, $scope.options.templateOptions.refreshDelay);
  18697. }
  18698. };
  18699. $scope._refresh({});
  18700. // $scope.attachments = $scope.model[$scope.options.key]
  18701. },
  18702. ],
  18703. });
  18704. //知识库附件上传
  18705. formlyConfigProvider.setType({
  18706. name: "ui-dropfielknow",
  18707. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18708. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18709. controller: [
  18710. "$scope",
  18711. "$rootScope",
  18712. function ($scope, $rootScope) {
  18713. if (angular.isUndefined($scope.form.dropState)) {
  18714. $scope.form.dropState = false;
  18715. }
  18716. //附件上传数据
  18717. var uploader = ($scope.uploader =
  18718. $scope.options.templateOptions.fileUploader);
  18719. //$scope.options.templateOptions.uploader();
  18720. // FILTERS
  18721. uploader.filters.push({
  18722. name: "customFilter",
  18723. fn: function (item /*{File|FileLikeObject}*/, options) {
  18724. return this.queue.length < 10;
  18725. },
  18726. });
  18727. $scope.dropfile = function (
  18728. APIService,
  18729. processInstanceId,
  18730. taskId,
  18731. userId
  18732. ) {
  18733. uploader.onBeforeUploadItem = function (item) {
  18734. angular.extend(item.headers, $rootScope.getSession());
  18735. item.url = APIService.upload(
  18736. processInstanceId,
  18737. taskId,
  18738. userId
  18739. ).getRequestedUrl();
  18740. item.formData.push({
  18741. fileName: item.file.name,
  18742. type: "solution",
  18743. solutionId: $scope.model.knowledge.id,
  18744. });
  18745. console.info("onBeforeUploadItem", item);
  18746. };
  18747. uploader.uploadAll();
  18748. };
  18749. // CALLBACKS
  18750. uploader.onWhenAddingFileFailed = function (
  18751. item /*{File|FileLikeObject}*/,
  18752. filter,
  18753. options
  18754. ) {
  18755. console.info("onWhenAddingFileFailed", item, filter, options);
  18756. };
  18757. uploader.onAfterAddingFile = function (fileItem) {
  18758. console.info("onAfterAddingFile", fileItem);
  18759. };
  18760. uploader.onAfterAddingAll = function (addedFileItems) {
  18761. console.info("onAfterAddingAll", addedFileItems);
  18762. };
  18763. uploader.onBeforeUploadItem = function (item) {
  18764. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18765. // // $scope.uploader.options.url();
  18766. // $scope.uploader.onBeforeUploadItem = function(item) {
  18767. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18768. // console.info('onBeforeUploadItem', item);
  18769. // };
  18770. // $scope.uploader.uploadAll();
  18771. // }
  18772. console.info("onBeforeUploadItem", item);
  18773. };
  18774. uploader.onProgressItem = function (fileItem, progress) {
  18775. console.info("onProgressItem", fileItem, progress);
  18776. };
  18777. uploader.onProgressAll = function (progress) {
  18778. console.info("onProgressAll", progress);
  18779. };
  18780. uploader.onSuccessItem = function (
  18781. fileItem,
  18782. response,
  18783. status,
  18784. headers
  18785. ) {
  18786. console.info("onSuccessItem", fileItem, response, status, headers);
  18787. };
  18788. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18789. console.info("onErrorItem", fileItem, response, status, headers);
  18790. };
  18791. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18792. console.info("onCancelItem", fileItem, response, status, headers);
  18793. };
  18794. uploader.onCompleteItem = function (
  18795. fileItem,
  18796. response,
  18797. status,
  18798. headers
  18799. ) {
  18800. console.info("onCompleteItem", fileItem, response, status, headers);
  18801. };
  18802. uploader.onCompleteAll = function () {
  18803. console.info("onCompleteAll");
  18804. };
  18805. },
  18806. ],
  18807. });
  18808. //知识库附件下载列表
  18809. formlyConfigProvider.setType({
  18810. name: "ui-dropfileknowledge",
  18811. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  18812. defaultOptions: function (options) {
  18813. return {
  18814. templateOptions: {
  18815. refresh: function (APIService, contentId, data) {
  18816. return APIService.fetchDataList(contentId, data);
  18817. },
  18818. downloadUri: function (APIService, contentId) {
  18819. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18820. },
  18821. download: function (APIService, contentId) {
  18822. return APIService.getSolutionDowpath(contentId);
  18823. },
  18824. view: function (attachmentId) {
  18825. // return APIService.attachmentsPreviewUrl(contentId);
  18826. },
  18827. refreshDelay: 0,
  18828. },
  18829. };
  18830. },
  18831. controller: [
  18832. "$scope",
  18833. "$timeout",
  18834. "$modal",
  18835. "$rootScope",
  18836. "api_solution",
  18837. "$http",
  18838. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  18839. var _refreshDelayPromise;
  18840. $scope.attachments = [];
  18841. $scope.downloadUrl = function (contentId) {
  18842. return (
  18843. $scope.options.templateOptions.downloadUri(
  18844. $scope.options.templateOptions.ApiService,
  18845. contentId
  18846. ) || "#"
  18847. );
  18848. };
  18849. $scope.download = function (contentId, filename) {
  18850. $http({
  18851. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  18852. contentId
  18853. ).getRequestedUrl(),
  18854. method: "GET",
  18855. headers: {
  18856. //'Content-type' : 'application/xls',
  18857. Accept: "*/*",
  18858. },
  18859. responseType: "arraybuffer",
  18860. })
  18861. .success(function (data, status, headers, config) {
  18862. var file = new Blob([data], {
  18863. type: "application/octet-stream",
  18864. });
  18865. //trick to download store a file having its URL
  18866. var fileURL = URL.createObjectURL(file);
  18867. var a = document.createElement("a");
  18868. a.href = fileURL;
  18869. a.target = "_blank";
  18870. a.download = filename;
  18871. document.body.appendChild(a);
  18872. a.click();
  18873. })
  18874. .error(function (data, status, headers, config) {
  18875. // console.log(data);
  18876. });
  18877. };
  18878. $scope.view = function (contentId, filename, attachment) {
  18879. var index = filename.indexOf(".");
  18880. var type = filename.substring(index + 1);
  18881. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18882. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  18883. // var modalInstance = $modal.open({
  18884. // backdrop: false,
  18885. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18886. // controller: function($scope, scope, $modalInstance, filename) {
  18887. // $scope.title = filename;
  18888. // $scope.imageurl = scope.imageurl;
  18889. // $scope.cancel = function() {
  18890. // $modalInstance.dismiss('cancel');
  18891. // }
  18892. // },
  18893. // resolve: {
  18894. // scope: function() {
  18895. // return $scope;
  18896. // },
  18897. // filename: function() {
  18898. // return filename;
  18899. // }
  18900. // }
  18901. // });
  18902. // event.preventDefault();
  18903. // } else {
  18904. // for (var i = 0; i < $scope.attachments.length; i++) {
  18905. // if ($scope.attachments[i].id == attachmentId) {
  18906. window.open(attachment.previewUrl);
  18907. // }
  18908. // }
  18909. // }
  18910. };
  18911. $scope._refresh = function (refreshAttr) {
  18912. if (refreshAttr !== undefined) {
  18913. if (_refreshDelayPromise) {
  18914. $timeout.cancel(_refreshDelayPromise);
  18915. }
  18916. _refreshDelayPromise = $timeout(function () {
  18917. $scope.options.templateOptions
  18918. .refresh($scope.options.templateOptions.ApiService, "file", {
  18919. file: {
  18920. solutionId: $scope.model.knowledge.id,
  18921. },
  18922. idx: "0",
  18923. sum: "1000",
  18924. })
  18925. .then(function (response) {
  18926. var myData =
  18927. $scope.options.templateOptions.Restangular.stripRestangular(
  18928. response
  18929. );
  18930. if (myData) {
  18931. $scope.attachments = myData.list;
  18932. // $scope.view = function(attachmentId) {
  18933. // for (var i = 0; i < $scope.attachments.length; i++) {
  18934. // if ($scope.attachments[i].id == attachmentId) {
  18935. // window.open($scope.attachments[i].previewUrl);
  18936. // // var modalInstance = $modal.open({
  18937. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  18938. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  18939. // // }
  18940. // // });
  18941. // }
  18942. // }
  18943. // };
  18944. }
  18945. });
  18946. }, $scope.options.templateOptions.refreshDelay);
  18947. }
  18948. };
  18949. $scope._refresh({});
  18950. // $scope.attachments = $scope.model[$scope.options.key]
  18951. },
  18952. ],
  18953. });
  18954. //附件图片下载
  18955. formlyConfigProvider.setType({
  18956. name: "ui-downimage",
  18957. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  18958. defaultOptions: function (options) {
  18959. return {
  18960. templateOptions: {
  18961. refresh: function (APIService, processInstanceId, data) {
  18962. return APIService.listAttachments(processInstanceId, data);
  18963. },
  18964. downloadUri: function (APIService, contentId) {
  18965. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18966. },
  18967. view: function (APIService, contentId) {
  18968. return APIService.attachmentsPreviewUrl(contentId);
  18969. },
  18970. download: function (APIService, contentId, item) {
  18971. var item = {
  18972. url: APIService.download(contentId),
  18973. headers: headers,
  18974. };
  18975. return item;
  18976. },
  18977. refreshDelay: 0,
  18978. },
  18979. };
  18980. },
  18981. controller: [
  18982. "$scope",
  18983. "$timeout",
  18984. "$rootScope",
  18985. "$http",
  18986. function ($scope, $timeout, $rootScope, $http) {
  18987. var _refreshDelayPromise;
  18988. // $scope.downloadUrl = function(contentId){
  18989. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18990. // };
  18991. $scope.download = function (contentId, filename) {
  18992. // var headers=
  18993. $http({
  18994. url: $scope.options.templateOptions.ApiService.download(
  18995. contentId
  18996. ).getRequestedUrl(),
  18997. method: "GET",
  18998. headers: {
  18999. //'Content-type' : 'application/xls',
  19000. Accept: "*/*",
  19001. },
  19002. responseType: "arraybuffer",
  19003. })
  19004. .success(function (data, status, headers, config) {
  19005. var file = new Blob([data], {
  19006. type: "application/octet-stream",
  19007. });
  19008. //trick to download store a file having its URL
  19009. var fileURL = URL.createObjectURL(file);
  19010. var a = document.createElement("a");
  19011. a.href = fileURL;
  19012. a.target = "_blank";
  19013. a.download = filename;
  19014. document.body.appendChild(a);
  19015. a.click();
  19016. })
  19017. .error(function (data, status, headers, config) {
  19018. // console.log(data);
  19019. });
  19020. };
  19021. $scope.view = function (contentId) {
  19022. $scope.imageurl =
  19023. $scope.options.templateOptions.ApiService.download(
  19024. contentId
  19025. ).getRequestedUrl();
  19026. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  19027. // if (response.state == 200) {
  19028. // window.open(response.previewUrl);
  19029. // }
  19030. // })
  19031. };
  19032. /**
  19033. * refresh
  19034. */
  19035. $scope._refresh = function (refreshAttr) {
  19036. if (refreshAttr !== undefined) {
  19037. if (_refreshDelayPromise) {
  19038. $timeout.cancel(_refreshDelayPromise);
  19039. }
  19040. _refreshDelayPromise = $timeout(function () {
  19041. $scope.options.templateOptions
  19042. .refresh(
  19043. $scope.options.templateOptions.ApiService,
  19044. $scope.options.templateOptions.processInstanceId,
  19045. {
  19046. idx: 0,
  19047. sum: 1000,
  19048. }
  19049. )
  19050. .then(function (response) {
  19051. var myData =
  19052. $scope.options.templateOptions.Restangular.stripRestangular(
  19053. response
  19054. );
  19055. if (myData) {
  19056. $scope.attachments = myData.data;
  19057. }
  19058. });
  19059. }, $scope.options.templateOptions.refreshDelay);
  19060. }
  19061. };
  19062. $scope._refresh({});
  19063. // $scope.attachments = $scope.model[$scope.options.key]
  19064. },
  19065. ],
  19066. });
  19067. //附件下载列表组件
  19068. formlyConfigProvider.setType({
  19069. name: "ui-dropfiletable",
  19070. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  19071. defaultOptions: function (options) {
  19072. return {
  19073. templateOptions: {
  19074. refresh: function (APIService, processInstanceId, data) {
  19075. return APIService.listAttachments(processInstanceId, data);
  19076. },
  19077. downloadUri: function (APIService, contentId) {
  19078. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19079. },
  19080. view: function (APIService, contentId) {
  19081. return APIService.attachmentsPreviewUrl(contentId);
  19082. },
  19083. download: function (APIService, contentId, item) {
  19084. var item = {
  19085. url: APIService.download(contentId),
  19086. headers: headers,
  19087. };
  19088. return item;
  19089. },
  19090. refreshDelay: 0,
  19091. },
  19092. };
  19093. },
  19094. controller: [
  19095. "$scope",
  19096. "$timeout",
  19097. "$modal",
  19098. "$rootScope",
  19099. "$http",
  19100. function ($scope, $timeout, $modal, $rootScope, $http) {
  19101. var _refreshDelayPromise;
  19102. // $scope.downloadUrl = function(contentId){
  19103. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19104. // };
  19105. $scope.download = function (contentId, filename) {
  19106. // var headers=
  19107. $http({
  19108. url: $scope.options.templateOptions.ApiService.download(
  19109. contentId
  19110. ).getRequestedUrl(),
  19111. method: "GET",
  19112. headers: {
  19113. //'Content-type' : 'application/xls',
  19114. Accept: "*/*",
  19115. },
  19116. responseType: "arraybuffer",
  19117. })
  19118. .success(function (data, status, headers, config) {
  19119. var file = new Blob([data], {
  19120. type: "application/octet-stream",
  19121. });
  19122. //trick to download store a file having its URL
  19123. var fileURL = URL.createObjectURL(file);
  19124. var a = document.createElement("a");
  19125. a.href = fileURL;
  19126. a.target = "_blank";
  19127. a.download = filename;
  19128. document.body.appendChild(a);
  19129. a.click();
  19130. })
  19131. .error(function (data, status, headers, config) {
  19132. // console.log(data);
  19133. });
  19134. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  19135. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  19136. // var file = new Blob([response], {
  19137. // type : 'application/octet-stream'
  19138. // });
  19139. // // var filename = filename;
  19140. // //var file = new Blob([response], {type: 'application/pdf'});
  19141. // var fileURL = URL.createObjectURL(file);
  19142. // var a = document.createElement('a');
  19143. // a.href = fileURL;
  19144. // a.target = '_blank';
  19145. // a.download = filename ;
  19146. // document.body.appendChild(a);
  19147. // a.click();
  19148. // })
  19149. };
  19150. $scope.view = function (contentId, token, filename, type) {
  19151. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19152. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  19153. // var modalInstance = $modal.open({
  19154. // backdrop: false,
  19155. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19156. // controller: function($scope, scope, $modalInstance, filename) {
  19157. // $scope.title = filename;
  19158. // $scope.imageurl = scope.imageurl;
  19159. // $scope.cancel = function() {
  19160. // $modalInstance.dismiss('cancel');
  19161. // }
  19162. // },
  19163. // resolve: {
  19164. // scope: function() {
  19165. // return $scope;
  19166. // },
  19167. // filename: function() {
  19168. // return filename;
  19169. // }
  19170. // }
  19171. // });
  19172. // event.preventDefault();
  19173. // } else {
  19174. $scope.options.templateOptions
  19175. .view($scope.options.templateOptions.ApiService, contentId)
  19176. .then(function (response) {
  19177. if (response.state == 200) {
  19178. window.open(response.previewUrl);
  19179. }
  19180. });
  19181. // }
  19182. };
  19183. /**
  19184. * refresh
  19185. */
  19186. $scope._refresh = function (refreshAttr) {
  19187. if (refreshAttr !== undefined) {
  19188. if (_refreshDelayPromise) {
  19189. $timeout.cancel(_refreshDelayPromise);
  19190. }
  19191. _refreshDelayPromise = $timeout(function () {
  19192. $scope.options.templateOptions
  19193. .refresh(
  19194. $scope.options.templateOptions.ApiService,
  19195. $scope.options.templateOptions.processInstanceId,
  19196. {
  19197. idx: 0,
  19198. sum: 1000,
  19199. }
  19200. )
  19201. .then(function (response) {
  19202. var myData =
  19203. $scope.options.templateOptions.Restangular.stripRestangular(
  19204. response
  19205. );
  19206. if (myData) {
  19207. $scope.attachments = myData.data;
  19208. }
  19209. });
  19210. }, $scope.options.templateOptions.refreshDelay);
  19211. }
  19212. };
  19213. $scope._refresh({});
  19214. // $scope.attachments = $scope.model[$scope.options.key]
  19215. },
  19216. ],
  19217. });
  19218. //微信附件下载列表组件
  19219. formlyConfigProvider.setType({
  19220. name: "ui-dropfilewechat",
  19221. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  19222. defaultOptions: function (options) {
  19223. return {
  19224. templateOptions: {
  19225. // refresh: function(APIService, processInstanceId, data) {
  19226. // return APIService.listAttachments(processInstanceId, data);
  19227. // },
  19228. // downloadUri: function(APIService, contentId) {
  19229. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  19230. // },
  19231. view: function (APIService, contentId) {
  19232. // return APIService.attachmentsPreviewUrl(contentId);
  19233. return APIService.attachmentsPreviewUrl(contentId);
  19234. },
  19235. download: function (APIService, contentId, item) {
  19236. var item = {
  19237. url: APIService.download(contentId),
  19238. headers: headers,
  19239. };
  19240. return item;
  19241. },
  19242. // download: function(APIService, contentId, item) {
  19243. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  19244. // return item;
  19245. // },
  19246. refreshDelay: 0,
  19247. },
  19248. };
  19249. },
  19250. controller: [
  19251. "$scope",
  19252. "$timeout",
  19253. "$modal",
  19254. "$stateParams",
  19255. "$rootScope",
  19256. "$http",
  19257. "api_wechatfile",
  19258. function (
  19259. $scope,
  19260. $timeout,
  19261. $modal,
  19262. $stateParams,
  19263. $rootScope,
  19264. $http,
  19265. api_wechatfile
  19266. ) {
  19267. var _refreshDelayPromise;
  19268. // $scope.downloadUrl = function(contentId){
  19269. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19270. // };
  19271. $scope.attachments = {};
  19272. $scope.previewUrl = "";
  19273. $scope.download = function (token, filename) {
  19274. // var headers=
  19275. console.log($scope);
  19276. $http({
  19277. url: $scope.options.templateOptions.ApiService.jry_download(
  19278. token
  19279. ).getRequestedUrl(),
  19280. method: "GET",
  19281. headers: {
  19282. //'Content-type' : 'application/xls',
  19283. Accept: "*/*",
  19284. },
  19285. responseType: "arraybuffer",
  19286. })
  19287. .success(function (data, status, headers, config) {
  19288. var file = new Blob([data], {
  19289. type: "application/octet-stream",
  19290. });
  19291. //trick to download store a file having its URL
  19292. var fileURL = URL.createObjectURL(file);
  19293. var a = document.createElement("a");
  19294. a.href = fileURL;
  19295. a.target = "_blank";
  19296. a.download = filename;
  19297. document.body.appendChild(a);
  19298. a.click();
  19299. })
  19300. .error(function (data, status, headers, config) {
  19301. // console.log(data);
  19302. });
  19303. };
  19304. $scope.view = function (contentId, token, filename, type, previewUrl) {
  19305. // if (type) {
  19306. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  19307. // var modalInstance = $modal.open({
  19308. // backdrop: false,
  19309. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19310. // controller: function($scope, scope, $modalInstance, filename) {
  19311. // $scope.title = filename;
  19312. // $scope.imageurl = scope.imageurl;
  19313. // $scope.cancel = function() {
  19314. // $modalInstance.dismiss('cancel');
  19315. // }
  19316. // },
  19317. // resolve: {
  19318. // scope: function() {
  19319. // return $scope;
  19320. // },
  19321. // filename: function() {
  19322. // return filename;
  19323. // }
  19324. // }
  19325. // });
  19326. // event.preventDefault();
  19327. // } else {
  19328. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  19329. // if (response.state == 200) {
  19330. // window.open(response.previewUrl);
  19331. // }
  19332. // })
  19333. window.open(previewUrl);
  19334. // }
  19335. };
  19336. /**
  19337. * refresh
  19338. */
  19339. $scope._refresh = function (refreshAttr) {
  19340. if (refreshAttr !== undefined) {
  19341. if (_refreshDelayPromise) {
  19342. $timeout.cancel(_refreshDelayPromise);
  19343. }
  19344. _refreshDelayPromise = $timeout(function () {
  19345. // console.log(JSON.parse($stateParams.model))
  19346. var incidentChart = {};
  19347. if ($stateParams.model) {
  19348. incidentChart = JSON.parse($stateParams.model).model;
  19349. }
  19350. $scope.options.templateOptions
  19351. .refresh(
  19352. $scope.options.templateOptions.ApiService,
  19353. $scope.model
  19354. )
  19355. .then(function (response) {
  19356. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19357. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19358. var myData =
  19359. $scope.options.templateOptions.Restangular.stripRestangular(
  19360. response
  19361. );
  19362. if (myData) {
  19363. $scope.attachments = myData.data;
  19364. }
  19365. });
  19366. }, $scope.options.templateOptions.refreshDelay);
  19367. }
  19368. };
  19369. $scope._refresh({});
  19370. // $scope.attachments = $scope.model[$scope.options.key]
  19371. },
  19372. ],
  19373. });
  19374. formlyConfigProvider.setType({
  19375. name: "ui-paralleltask",
  19376. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19377. defaultOptions: function (options) {
  19378. return {
  19379. templateOptions: {
  19380. refresh: function (APIService, processInstanceId, data) {
  19381. //return APIService.listAttachments(processInstanceId, data);
  19382. },
  19383. refreshDelay: 0,
  19384. },
  19385. };
  19386. },
  19387. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19388. });
  19389. //repeatSection
  19390. //
  19391. formlyConfigProvider.setType({
  19392. name: "ui-repeatSection",
  19393. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19394. defaultOptions: function (options) {
  19395. return {
  19396. templateOptions: {
  19397. unique: 1,
  19398. initDisplay: false,
  19399. },
  19400. };
  19401. },
  19402. controller: function ($scope) {
  19403. //$scope.options.templateOptions.unique;
  19404. $scope.formOptions = {
  19405. formState: $scope.formState,
  19406. };
  19407. $scope.addNew = addNew;
  19408. $scope.copyFields = copyFields;
  19409. function copyFields(fields) {
  19410. fields = angular.copy(fields);
  19411. addRandomIds(fields);
  19412. return fields;
  19413. }
  19414. function addNew() {
  19415. $scope.model[$scope.options.key] =
  19416. $scope.model[$scope.options.key] || [];
  19417. var repeatsection = $scope.model[$scope.options.key];
  19418. var lastSection = repeatsection[repeatsection.length - 1];
  19419. var newsection = {};
  19420. repeatsection.push(newsection);
  19421. }
  19422. function addRandomIds(fields) {
  19423. $scope.options.templateOptions.unique++;
  19424. angular.forEach(fields, function (field, index) {
  19425. if (field.fieldGroup) {
  19426. addRandomIds(field.fieldGroup);
  19427. return; // fieldGroups don't need an ID
  19428. }
  19429. if (field.templateOptions && field.templateOptions.fields) {
  19430. addRandomIds(field.templateOptions.fields);
  19431. }
  19432. field.id =
  19433. field.id ||
  19434. field.key +
  19435. "_" +
  19436. index +
  19437. "_" +
  19438. $scope.options.templateOptions.unique +
  19439. getRandomInt(0, 9999);
  19440. });
  19441. }
  19442. function getRandomInt(min, max) {
  19443. return Math.floor(Math.random() * (max - min)) + min;
  19444. }
  19445. if ($scope.options.templateOptions.initDisplay) {
  19446. addNew();
  19447. }
  19448. },
  19449. });
  19450. //时间轴任务列表组件
  19451. //cmdb控件
  19452. formlyConfigProvider.setType({
  19453. name: "ui-cmdb",
  19454. extends: "input",
  19455. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19456. defaultOptions: function (options) {
  19457. return {
  19458. templateOptions: {
  19459. onClick: function (size, options, modal, event, model) {
  19460. var modalInstance = modal.open({
  19461. templateUrl:
  19462. "assets/views/customform/tpl/cmdb-modal-content.html",
  19463. controller: function (
  19464. $scope,
  19465. $modalInstance,
  19466. title,
  19467. Restangular,
  19468. APIService,
  19469. ConfigDataService,
  19470. ConfigFormService,
  19471. SweetAlert,
  19472. Toaster,
  19473. api_wechatfile
  19474. ) {
  19475. var width = ($scope.width = 600);
  19476. var height = ($scope.height = 400);
  19477. var tree;
  19478. var d3 = window.d3;
  19479. $scope.my_tree_handler = function (branch) {
  19480. //var _ref;
  19481. var classify = ($scope.classify =
  19482. branch.prefix.toLowerCase() + branch.sign);
  19483. APIService.query({
  19484. sign: classify,
  19485. }).then(function (data) {
  19486. var myData = Restangular.stripRestangular(data);
  19487. // console.log(myData.data.node);
  19488. if (myData.data && myData.status == 200) {
  19489. var ret = myData.data;
  19490. redrawSvg(myData);
  19491. }
  19492. });
  19493. };
  19494. $scope.my_data = [];
  19495. function convertListToTree(data, treeMap) {
  19496. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19497. var root = null; //Initially set our loop to null
  19498. var parentNode = null;
  19499. //loop over data
  19500. for (var i = 0; i < data.length; i++) {
  19501. var datum = data[i];
  19502. //each node will have children, so let's give it a "children" poperty
  19503. datum.children = [];
  19504. //add an entry for this node to the map so that any future children can
  19505. //lookup the parent
  19506. idToNodeMap[datum.id] = datum;
  19507. //Does this node have a parent?
  19508. if (
  19509. typeof datum.parent === "undefined" ||
  19510. datum.parent == null
  19511. ) {
  19512. //Doesn't look like it, so this node is the root of the tree
  19513. root = datum;
  19514. treeMap[datum.id] = root;
  19515. } else {
  19516. //This node has a parent, so let's look it up using the id
  19517. parentNode = idToNodeMap[datum.parent.id];
  19518. //We don't need this property, so let's delete it.
  19519. delete datum.parent;
  19520. //Let's add the current node as a child of the parent node.
  19521. parentNode.children.push(datum);
  19522. }
  19523. }
  19524. return root;
  19525. }
  19526. function convertParentToChildList(data) {
  19527. var treeMap = {};
  19528. var list = [];
  19529. convertListToTree(data, treeMap);
  19530. angular.forEach(treeMap, function (item) {
  19531. list.push(item);
  19532. });
  19533. return list;
  19534. }
  19535. $scope.my_tree = tree = {};
  19536. $scope.try_async_load = function () {
  19537. $scope.my_data = [];
  19538. $scope.select_treedata = [];
  19539. $scope.doing_async = true;
  19540. ConfigDataService.fetchDataList("ciclassify", {
  19541. idx: 0,
  19542. sum: 100,
  19543. }).then(function (result) {
  19544. $scope.select_treedata = $scope.my_data =
  19545. convertParentToChildList(result["list"]);
  19546. $scope.doing_async = false;
  19547. });
  19548. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19549. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19550. // $scope.doing_async = false;
  19551. // });
  19552. };
  19553. $scope.select_treedata = [];
  19554. $scope.propTypeOptions = [];
  19555. $scope.try_async_load();
  19556. $scope.onFilterCallback = function (item) {
  19557. //console.log(item);
  19558. if (
  19559. angular.isDefined(item.children) &&
  19560. item.children.length >= 1
  19561. ) {
  19562. //not valid
  19563. } else {
  19564. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19565. $scope.cifilter_classic = tempclassify;
  19566. ConfigFormService.renderTabForm(tempclassify).then(
  19567. function (data) {
  19568. var myData = Restangular.stripRestangular(data);
  19569. $scope.propTypeOptions = myData;
  19570. }
  19571. );
  19572. }
  19573. };
  19574. $scope.onPropTypeChange = function (form) {
  19575. $scope.propOptions = form.fields;
  19576. };
  19577. $scope.onPropChange = function (prop) {
  19578. $scope.cifilter_prop = prop;
  19579. };
  19580. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19581. //if(searchKey!=null&&searchKey.length>1){
  19582. var searchData = {};
  19583. if (angular.isUndefined(propObj)) {
  19584. propObj = $scope.cifilter_prop;
  19585. }
  19586. if (angular.isUndefined(ciclassify)) {
  19587. ciclassify = $scope.cifilter_classic;
  19588. }
  19589. searchData["sign"] = ciclassify;
  19590. if (angular.isDefined(propObj)) {
  19591. searchData[propObj.key] = searchKey;
  19592. }
  19593. APIService.query(searchData).then(function (response) {
  19594. var data = Restangular.stripRestangular(response);
  19595. //此处不清空nodes
  19596. var node = data.data.node;
  19597. var tempNode = [];
  19598. //nodes 或者links 要去重
  19599. for (var i = 0; i < node.length; i++) {
  19600. var tmp = 0;
  19601. for (var j = 0; j < nodes.length; j++) {
  19602. if (node[i].uuid == nodes[j].uuid) {
  19603. tmp++;
  19604. break;
  19605. }
  19606. }
  19607. if (tmp == 0) {
  19608. tempNode.push(node[i]);
  19609. }
  19610. }
  19611. for (var i = 0; i < tempNode.length; i++) {
  19612. //nodes 不清空
  19613. nodes.push(tempNode[i]);
  19614. }
  19615. restart();
  19616. });
  19617. };
  19618. $scope.refresh = function () {
  19619. nodes.length = 0;
  19620. links.length = 0;
  19621. restart();
  19622. };
  19623. $scope.traversal = function () {
  19624. if ($scope.selected_node == null) {
  19625. SweetAlert.swal({
  19626. title: "错误的操作!",
  19627. text: "没有配置项被选中!",
  19628. type: "error",
  19629. });
  19630. } else {
  19631. var uuid = $scope.selected_node.uuid;
  19632. APIService.traversal(uuid).then(function (response) {
  19633. var d = response.data;
  19634. var node = d.node;
  19635. var link = d.edge;
  19636. var tempNode = [];
  19637. var tempLink = [];
  19638. //nodes 或者links 要去重
  19639. for (var i = 0; i < node.length; i++) {
  19640. var tmp = 0;
  19641. for (var j = 0; j < nodes.length; j++) {
  19642. if (node[i].id == nodes[j].id) {
  19643. tmp++;
  19644. break;
  19645. }
  19646. }
  19647. if (tmp == 0) {
  19648. tempNode.push(node[i]);
  19649. }
  19650. }
  19651. for (var i = 0; i < link.length; i++) {
  19652. var tmp = 0;
  19653. for (var j = 0; j < links.length; j++) {
  19654. if (link[i].id == links[j].id) {
  19655. tmp++;
  19656. break;
  19657. }
  19658. }
  19659. if (tmp == 0) {
  19660. tempLink.push(link[i]);
  19661. }
  19662. }
  19663. //数据写入页面
  19664. for (var i = 0; i < tempNode.length; i++) {
  19665. //nodes 不清空
  19666. nodes.push(tempNode[i]);
  19667. }
  19668. for (var i = 0; i < tempLink.length; i++) {
  19669. //link 不清空
  19670. links.push(tempLink[i]);
  19671. }
  19672. //links转换
  19673. for (var i = 0; i < links.length; i++) {
  19674. for (var j = 0; j < nodes.length; j++) {
  19675. if (links[i].source == nodes[j].id) {
  19676. links[i].source = nodes[j];
  19677. }
  19678. if (links[i].target == nodes[j].id) {
  19679. links[i].target = nodes[j];
  19680. }
  19681. }
  19682. }
  19683. restart();
  19684. });
  19685. }
  19686. };
  19687. var svg;
  19688. var force;
  19689. var drag_line, path, circle;
  19690. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  19691. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19692. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19693. var nodes = [],
  19694. links = [];
  19695. var treeNodes = [];
  19696. //读取labels (node)
  19697. var labels = [];
  19698. function redrawSvg(json) {
  19699. nodes.length = 0; //先清空
  19700. links.length = 0;
  19701. var data = json.data;
  19702. for (var i = 0; i < data.node.length; i++) {
  19703. nodes.push(data.node[i]);
  19704. }
  19705. restart();
  19706. }
  19707. //读取status (节点 连线)
  19708. var statuses = [];
  19709. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  19710. // if (result && result.status == 200) {
  19711. // d3.select('#nodeStatus').selectAll('option')
  19712. // .data(statuses).enter()
  19713. // .append('option')
  19714. // .attr('value', function(d) { return d.code; })
  19715. // .html(function(d) { return d.desc; });
  19716. // } else {
  19717. // SweetAlert.swal({
  19718. // title: "提示!",
  19719. // text: "服务器请求异常!",
  19720. // type: "error"
  19721. // });
  19722. // }
  19723. // });
  19724. api_wechatfile
  19725. .getDictionary({
  19726. key: "cmdb_status",
  19727. type: "list",
  19728. })
  19729. .then(function (result) {
  19730. if (result) {
  19731. d3.select("#nodeStatus")
  19732. .selectAll("option")
  19733. .data(statuses)
  19734. .enter()
  19735. .append("option")
  19736. .attr("value", function (d) {
  19737. return d.code;
  19738. })
  19739. .html(function (d) {
  19740. return d.desc;
  19741. });
  19742. } else {
  19743. SweetAlert.swal({
  19744. title: "提示!",
  19745. text: "服务器请求异常!",
  19746. type: "error",
  19747. });
  19748. }
  19749. });
  19750. //查询relationship_type表 name 为表里的type,label为显示值
  19751. var linkType = [];
  19752. function fetchEdgeTypes() {
  19753. ConfigDataService.fetchDataList("ciedgetype", {
  19754. idx: 0,
  19755. sum: 100,
  19756. }).then(function (response) {
  19757. if (response) {
  19758. if (response["list"]) {
  19759. linkType = response["list"];
  19760. // d3.select('#linkName').selectAll('option')
  19761. // .data(linkType).enter()
  19762. // .append('option')
  19763. // .attr('value',function(d){return d.type;})
  19764. // .html(function(d){ return d.label;});
  19765. } else {
  19766. SweetAlert.swal({
  19767. title: "提示!",
  19768. text: "服务器请求异常!",
  19769. type: "error",
  19770. });
  19771. }
  19772. } else {
  19773. SweetAlert.swal({
  19774. title: "提示!",
  19775. text: "服务器请求异常!",
  19776. type: "error",
  19777. });
  19778. }
  19779. });
  19780. }
  19781. // fetchEdgeTypes();
  19782. /*
  19783. // init D3 force layout
  19784. var force = d3.layout.force()
  19785. .nodes(nodes)
  19786. .links(links)
  19787. .size([width, height])
  19788. .gravity(.05)
  19789. .linkDistance(150)
  19790. .linkStrength(2)
  19791. .charge(-500)
  19792. .on('tick', tick);
  19793. // define arrow markers for graph links
  19794. svg.append('svg:defs').append('svg:marker')
  19795. .attr('id', 'end-arrow')
  19796. .attr('viewBox', '0 -5 10 10')
  19797. .attr('refX', 6)
  19798. .attr('markerWidth', 3)
  19799. .attr('markerHeight', 3)
  19800. .attr('orient', 'auto')
  19801. .append('svg:path')
  19802. .attr('d', 'M0,-5L10,0L0,5')
  19803. .attr('fill', '#000');
  19804. svg.append('svg:defs').append('svg:marker')
  19805. .attr('id', 'start-arrow')
  19806. .attr('viewBox', '0 -5 10 10')
  19807. .attr('refX', 4)
  19808. .attr('markerWidth', 3)
  19809. .attr('markerHeight', 3)
  19810. .attr('orient', 'auto')
  19811. .append('svg:path')
  19812. .attr('d', 'M10,-5L0,0L10,5')
  19813. .attr('fill', '#000');
  19814. // line displayed when dragging new nodes
  19815. var drag_line = svg.append('svg:path')
  19816. .attr('class', 'link dragline hidden')
  19817. .attr('d', 'M0,0L0,0');
  19818. // handles to link and node element groups
  19819. //(1)var path = svg.append('svg:g').selectAll('g')
  19820. var path = svg.append('svg:g').selectAll('g'),
  19821. circle = svg.append('svg:g').selectAll('g');
  19822. */
  19823. // mouse event vars
  19824. var selected_node = null,
  19825. selected_link = null,
  19826. mousedown_link = null,
  19827. mousedown_node = null,
  19828. mouseup_node = null;
  19829. function resetMouseVars() {
  19830. mousedown_node = null;
  19831. mouseup_node = null;
  19832. mousedown_link = null;
  19833. }
  19834. // update force layout (called automatically each iteration)
  19835. function tick() {
  19836. // draw directed edges with proper padding from node centers
  19837. path.selectAll("path").attr("d", function (d) {
  19838. var deltaX = d.target.x - d.source.x,
  19839. deltaY = d.target.y - d.source.y,
  19840. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  19841. normX = deltaX / dist,
  19842. normY = deltaY / dist,
  19843. sourcePadding = d.left ? 27 : 22,
  19844. targetPadding = d.right ? 27 : 22,
  19845. sourceX = d.source.x + sourcePadding * normX,
  19846. sourceY = d.source.y + sourcePadding * normY,
  19847. targetX = d.target.x - targetPadding * normX,
  19848. targetY = d.target.y - targetPadding * normY;
  19849. return (
  19850. "M" +
  19851. sourceX +
  19852. "," +
  19853. sourceY +
  19854. "L" +
  19855. targetX +
  19856. "," +
  19857. targetY
  19858. );
  19859. });
  19860. circle.attr("transform", function (d) {
  19861. return "translate(" + d.x + "," + d.y + ")";
  19862. });
  19863. }
  19864. // update graph (called when needed)
  19865. function restart() {
  19866. //绑定link 数据
  19867. path.datum(links);
  19868. // path (link) group
  19869. path = path.data(links, function (d) {
  19870. return d.id;
  19871. });
  19872. var p = path.enter().append("svg:g");
  19873. //update existing links
  19874. path
  19875. .selectAll("path")
  19876. .classed("selected", function (d) {
  19877. return d === selected_link;
  19878. })
  19879. .style("marker-start", function (d) {
  19880. return d.left ? "url(#start-arrow)" : "";
  19881. })
  19882. .style("marker-end", function (d) {
  19883. return d.right ? "url(#end-arrow)" : "";
  19884. });
  19885. // add new links
  19886. p.append("svg:path")
  19887. .attr("class", "link")
  19888. .attr("id", function (d) {
  19889. return "path_" + d.id;
  19890. })
  19891. // .attr('startOffset', '0%')
  19892. .classed("selected", function (d) {
  19893. return d === selected_link;
  19894. })
  19895. .style("marker-start", function (d) {
  19896. return d.left ? "url(#start-arrow)" : "";
  19897. })
  19898. .style("marker-end", function (d) {
  19899. return d.right ? "url(#end-arrow)" : "";
  19900. })
  19901. .on("mousedown", function (d) {
  19902. if (d3.event.ctrlKey) return;
  19903. //去除没有提交的连线
  19904. for (var i = 0; i < links.length; i++) {
  19905. if (links[i].id == -1 && d.id != -1) {
  19906. links.splice(i, 1);
  19907. }
  19908. }
  19909. // select link
  19910. mousedown_link = d;
  19911. if (mousedown_link === selected_link) {
  19912. selected_link = $scope.selected_link = null;
  19913. selected_node = $scope.selected_node = null;
  19914. // d3.select("#linkDetail").attr('style','display:none');
  19915. //hideLinkForm(true);//return ;
  19916. } else {
  19917. selected_link = $scope.selected_link = mousedown_link;
  19918. selected_node = $scope.selected_node = null;
  19919. }
  19920. selected_node = $scope.selected_node = null;
  19921. restart();
  19922. });
  19923. p.append("svg:text")
  19924. .attr("x", 30)
  19925. .attr("y", 20)
  19926. .attr("class", "fontM")
  19927. .append("textPath")
  19928. .attr("xlink:xlink:href", function (d, i) {
  19929. return "#path_" + d.id;
  19930. })
  19931. .html(function (d) {
  19932. for (var i = 0; i < linkType.length; i++) {
  19933. if (linkType[i].type == d.name) {
  19934. return linkType[i].label;
  19935. }
  19936. }
  19937. });
  19938. // remove old links
  19939. path.exit().remove();
  19940. // circle (node) group
  19941. // NB: the function arg is crucial here! nodes are known by id, not by index!
  19942. circle.datum(nodes);
  19943. circle = circle.data(nodes, function (d) {
  19944. return d.id;
  19945. });
  19946. // update existing nodes (reflexive & selected visual states)
  19947. circle
  19948. .selectAll("circle")
  19949. .style("fill", function (d) {
  19950. return d === selected_node
  19951. ? d3.rgb(colors(d.label)).brighter().toString()
  19952. : colors(d.label);
  19953. })
  19954. .style("fill-opacity", 0.75) // add by xi
  19955. .classed("reflexive", function (d) {
  19956. return d.reflexive;
  19957. });
  19958. // add new nodes
  19959. var g = circle.enter().append("svg:g");
  19960. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  19961. //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');
  19962. g.append("svg:circle")
  19963. .attr("r", 24)
  19964. .style("fill", function (d) {
  19965. return d === selected_node
  19966. ? "rgb(153,153,153)"
  19967. : "rgb(255,255,255)";
  19968. })
  19969. .style("stroke", function (d) {
  19970. return d3.rgb(colors(d.label)).darker().toString();
  19971. })
  19972. .style("stroke-width", "2");
  19973. g.append("svg:circle")
  19974. .attr("class", "node")
  19975. .attr("r", 18)
  19976. .style("fill", function (d) {
  19977. return d === selected_node
  19978. ? d3.rgb(colors(d.label)).brighter().toString()
  19979. : colors(d.label);
  19980. })
  19981. .style("stroke", function (d) {
  19982. return d3.rgb(colors(d.label)).darker().toString();
  19983. })
  19984. .style("fill-opacity", 0.25) //add by xj
  19985. .style("stroke-opacity", 0.5) //add by xj
  19986. .classed("reflexive", function (d) {
  19987. return d.reflexive;
  19988. });
  19989. g.on("mouseover", function (d) {
  19990. //if(!mousedown_node || d === mousedown_node) return;
  19991. // enlarge target node
  19992. //d3.select(this).attr('transform', 'scale(1.1)');
  19993. })
  19994. .on("mouseout", function (d) {
  19995. //if(!mousedown_node || d === mousedown_node) return;
  19996. // unenlarge target node
  19997. //d3.select(this).attr('transform', '');
  19998. })
  19999. .on("mousedown", function (d) {
  20000. if (d3.event.ctrlKey) return;
  20001. //hideLinkForm(true);
  20002. //去除没有提交的连线
  20003. for (var i = 0; i < links.length; i++) {
  20004. if (links[i].id == -1) {
  20005. links.splice(i, 1);
  20006. }
  20007. }
  20008. // select node
  20009. mousedown_node = d;
  20010. if (mousedown_node === selected_node) {
  20011. selected_node = $scope.selected_node = null;
  20012. } else {
  20013. selected_node = $scope.selected_node = mousedown_node;
  20014. selected_link = $scope.selected_link = null;
  20015. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  20016. APIService.findRefById(selected_node.id).then(function (
  20017. result
  20018. ) {
  20019. var d = result.data;
  20020. var node = d.node;
  20021. var link = d.edge;
  20022. var tempNode = [];
  20023. var tempLink = [];
  20024. //nodes 或者links 要去重
  20025. for (var i = 0; i < node.length; i++) {
  20026. var tmp = 0;
  20027. for (var j = 0; j < nodes.length; j++) {
  20028. if (node[i].id == nodes[j].id) {
  20029. tmp++;
  20030. break;
  20031. }
  20032. }
  20033. if (tmp == 0) {
  20034. tempNode.push(node[i]);
  20035. }
  20036. }
  20037. for (var i = 0; i < link.length; i++) {
  20038. var tmp = 0;
  20039. for (var j = 0; j < links.length; j++) {
  20040. if (link[i].id == links[j].id) {
  20041. tmp++;
  20042. break;
  20043. }
  20044. }
  20045. if (tmp == 0) {
  20046. tempLink.push(link[i]);
  20047. }
  20048. }
  20049. //数据写入页面
  20050. for (var i = 0; i < tempNode.length; i++) {
  20051. //nodes 不清空
  20052. nodes.push(tempNode[i]);
  20053. }
  20054. for (var i = 0; i < tempLink.length; i++) {
  20055. //link 不清空
  20056. links.push(tempLink[i]);
  20057. }
  20058. //links转换
  20059. for (var i = 0; i < links.length; i++) {
  20060. for (var j = 0; j < nodes.length; j++) {
  20061. if (links[i].source == nodes[j].id) {
  20062. links[i].source = nodes[j];
  20063. }
  20064. if (links[i].target == nodes[j].id) {
  20065. links[i].target = nodes[j];
  20066. }
  20067. }
  20068. }
  20069. restart();
  20070. });
  20071. }
  20072. // reposition drag line
  20073. drag_line
  20074. .style("marker-end", "url(#end-arrow)")
  20075. .classed("hidden", false)
  20076. .attr(
  20077. "d",
  20078. "M" +
  20079. mousedown_node.x +
  20080. "," +
  20081. mousedown_node.y +
  20082. "L" +
  20083. mousedown_node.x +
  20084. "," +
  20085. mousedown_node.y
  20086. );
  20087. restart();
  20088. })
  20089. .on("mouseup", function (d) {
  20090. if (!mousedown_node) return;
  20091. });
  20092. // show node name
  20093. g.append("svg:text")
  20094. .attr("x", 0)
  20095. .attr("y", 34)
  20096. .attr("class", "id")
  20097. .text(function (d) {
  20098. return d.name;
  20099. }); //TODO 改为 d.name
  20100. //设置图片
  20101. g.append("svg:foreignObject")
  20102. .attr("width", 32)
  20103. .attr("height", 32)
  20104. .attr("x", "-16px")
  20105. .attr("y", "-11px")
  20106. .html(function (d) {
  20107. for (var i = 0; i < labels.length; i++) {
  20108. if (d.label == labels[i].sign) {
  20109. return (
  20110. '<i class="icon iconfont">' +
  20111. labels[i].iconname +
  20112. "</i>"
  20113. );
  20114. }
  20115. }
  20116. });
  20117. // remove old nodes
  20118. circle.exit().remove();
  20119. // set the graph in motion
  20120. force.start();
  20121. }
  20122. function mousedown() {
  20123. // prevent I-bar on drag
  20124. //d3.event.preventDefault();
  20125. // because :active only works in WebKit?
  20126. svg.classed("active", true);
  20127. if (mousedown_node) {
  20128. viewNode(mousedown_node);
  20129. }
  20130. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  20131. return;
  20132. restart();
  20133. }
  20134. function mousemove() {
  20135. if (!mousedown_node) return;
  20136. // update drag line
  20137. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  20138. //restart();
  20139. }
  20140. function mouseup() {
  20141. if (mousedown_node) {
  20142. // hide drag line
  20143. drag_line.classed("hidden", true).style("marker-end", "");
  20144. }
  20145. // because :active only works in WebKit?
  20146. svg.classed("active", false);
  20147. // clear mouse event vars
  20148. resetMouseVars();
  20149. }
  20150. function spliceLinksForNode(node) {
  20151. var toSplice = links.filter(function (l) {
  20152. return l.source === node || l.target === node;
  20153. });
  20154. toSplice.map(function (l) {
  20155. links.splice(links.indexOf(l), 1);
  20156. });
  20157. }
  20158. // only respond once per keydown
  20159. var lastKeyDown = -1;
  20160. function keydown() {
  20161. //d3.event.preventDefault();
  20162. if (lastKeyDown !== -1) return;
  20163. lastKeyDown = d3.event.keyCode;
  20164. // ctrl
  20165. if (d3.event.keyCode === 17) {
  20166. circle.call(force.drag);
  20167. svg.classed("ctrl", true);
  20168. }
  20169. if (!selected_node && !selected_link) return;
  20170. switch (d3.event.keyCode) {
  20171. case 8: // backspace
  20172. case 66: // B
  20173. if (selected_link) {
  20174. // set link direction to both left and right
  20175. selected_link.left = true;
  20176. selected_link.right = true;
  20177. }
  20178. restart();
  20179. break;
  20180. case 76: // L
  20181. if (selected_link) {
  20182. // set link direction to left only
  20183. selected_link.left = true;
  20184. selected_link.right = false;
  20185. }
  20186. restart();
  20187. break;
  20188. case 82: // R
  20189. if (selected_node) {
  20190. // toggle node reflexivity
  20191. selected_node.reflexive = !selected_node.reflexive;
  20192. } else if (selected_link) {
  20193. // set link direction to right only
  20194. selected_link.left = false;
  20195. selected_link.right = true;
  20196. }
  20197. restart();
  20198. break;
  20199. }
  20200. }
  20201. function keyup() {
  20202. lastKeyDown = -1;
  20203. // ctrl
  20204. if (d3.event.keyCode === 17) {
  20205. circle
  20206. .on("mousedown.drag", null)
  20207. .on("touchstart.drag", null);
  20208. svg.classed("ctrl", false);
  20209. }
  20210. }
  20211. function viewNode(node) {
  20212. // console.log(svg.attr('left'));
  20213. //var el = angular.element('div.modal-dialog')[0];
  20214. var title =
  20215. $scope.selected_node.name +
  20216. "-[" +
  20217. $scope.selected_node.uuid +
  20218. "]";
  20219. if (!$scope.selected_node.props.state) {
  20220. $scope.selected_node.props.state = "空";
  20221. } else if ($scope.selected_node.props.state) {
  20222. if ($scope.selected_node.props.state == "1") {
  20223. $scope.selected_node.props.state = "未审核";
  20224. } else if ($scope.selected_node.props.state == "2") {
  20225. $scope.selected_node.props.state = "已审核";
  20226. } else if ($scope.selected_node.props.state == "3") {
  20227. $scope.selected_node.props.state = "不匹配";
  20228. } else if ($scope.selected_node.props.state == "4") {
  20229. $scope.selected_node.props.state = "丢失";
  20230. }
  20231. }
  20232. if (!$scope.selected_node.name) {
  20233. $scope.selected_node.name = "空";
  20234. }
  20235. if (!$scope.selected_node.status) {
  20236. $scope.selected_node.statu = "空";
  20237. }
  20238. if (!$scope.selected_node.props.useradmin) {
  20239. $scope.selected_node.props.useradmin = "空";
  20240. }
  20241. Toaster.pop({
  20242. // type: 'info',
  20243. // title: title,
  20244. body:
  20245. "<br/><p>搜索代码:" +
  20246. $scope.selected_node.uuid +
  20247. "</p>" +
  20248. "<p>配置标题:" +
  20249. $scope.selected_node.name +
  20250. "</p>" +
  20251. "<p>状态:" +
  20252. $scope.selected_node.status +
  20253. "</p>" +
  20254. "<p>审核状态:" +
  20255. $scope.selected_node.props.state +
  20256. "</p>" +
  20257. "<p>维护人员:" +
  20258. $scope.selected_node.props.useradmin +
  20259. "</p>",
  20260. bodyOutputType: "trustedHtml",
  20261. timeout: 3000,
  20262. });
  20263. }
  20264. //GT 颜色与数值对照表
  20265. function colors(sign) {
  20266. //num=num>20?num%20:parseInt(num);
  20267. for (var i = 0; i < labels.length; i++) {
  20268. var entity = labels[i];
  20269. if (sign == entity.sign) {
  20270. return entity.color;
  20271. }
  20272. if (i == labels.length - 1 && sign != entity.sign) {
  20273. return "#ffeeee";
  20274. }
  20275. }
  20276. }
  20277. $scope.init = function () {
  20278. svg = d3
  20279. .select("#cmdbSVG")
  20280. .append("svg")
  20281. .attr("width", width)
  20282. .attr("height", height);
  20283. // init D3 force layout
  20284. force = d3.layout
  20285. .force()
  20286. .nodes(nodes)
  20287. .links(links)
  20288. .size([width, height])
  20289. .gravity(0.05)
  20290. .linkDistance(150)
  20291. .linkStrength(2)
  20292. .charge(-500)
  20293. .on("tick", tick);
  20294. // define arrow markers for graph links
  20295. svg
  20296. .append("svg:defs")
  20297. .append("svg:marker")
  20298. .attr("id", "end-arrow")
  20299. .attr("viewBox", "0 -5 10 10")
  20300. .attr("refX", 6)
  20301. .attr("markerWidth", 3)
  20302. .attr("markerHeight", 3)
  20303. .attr("orient", "auto")
  20304. .append("svg:path")
  20305. .attr("d", "M0,-5L10,0L0,5")
  20306. .attr("fill", "#000");
  20307. svg
  20308. .append("svg:defs")
  20309. .append("svg:marker")
  20310. .attr("id", "start-arrow")
  20311. .attr("viewBox", "0 -5 10 10")
  20312. .attr("refX", 4)
  20313. .attr("markerWidth", 3)
  20314. .attr("markerHeight", 3)
  20315. .attr("orient", "auto")
  20316. .append("svg:path")
  20317. .attr("d", "M10,-5L0,0L10,5")
  20318. .attr("fill", "#000");
  20319. // line displayed when dragging new nodes
  20320. drag_line = svg
  20321. .append("svg:path")
  20322. .attr("class", "link dragline hidden")
  20323. .attr("d", "M0,0L0,0");
  20324. // handles to link and node element groups
  20325. //(1)var path = svg.append('svg:g').selectAll('g')
  20326. path = svg.append("svg:g").selectAll("g");
  20327. circle = svg.append("svg:g").selectAll("g");
  20328. svg
  20329. .on("mousedown", mousedown)
  20330. .on("mousemove", mousemove)
  20331. .on("mouseup", mouseup);
  20332. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  20333. };
  20334. var CI = {};
  20335. window.CI = CI;
  20336. $scope.ok = function () {
  20337. $modalInstance.close($scope.selected_node);
  20338. };
  20339. $scope.cancel = function () {
  20340. $modalInstance.dismiss("cancel");
  20341. };
  20342. },
  20343. size: size,
  20344. resolve: {
  20345. title: function () {
  20346. return options.templateOptions.title;
  20347. },
  20348. Restangular: function () {
  20349. return options.templateOptions.Restangular;
  20350. },
  20351. APIService: function () {
  20352. return options.templateOptions.ApiService;
  20353. },
  20354. ConfigDataService: function () {
  20355. return options.templateOptions.ConfigDataService;
  20356. },
  20357. ConfigFormService: function () {
  20358. return options.templateOptions.ConfigFormService;
  20359. },
  20360. SweetAlert: function () {
  20361. return options.templateOptions.Alert;
  20362. },
  20363. Toaster: function () {
  20364. return options.templateOptions.toaster;
  20365. },
  20366. },
  20367. });
  20368. modalInstance.result.then(
  20369. function (selectedItem) {
  20370. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20371. },
  20372. function () {
  20373. //console.log('Modal dismissed at: ' + new Date());
  20374. }
  20375. );
  20376. },
  20377. },
  20378. };
  20379. },
  20380. controller: [
  20381. "$scope",
  20382. function ($scope) {
  20383. // setTimeout(function(){
  20384. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20385. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20386. // if(modelData.status==200){
  20387. // $scope.model[$scope.options.key] = modelData.data;
  20388. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20389. // }
  20390. // });
  20391. // },1000);
  20392. },
  20393. ],
  20394. });
  20395. });
  20396. appFormly.run(function (formlyConfig, $parse) {
  20397. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20398. var removeOnHideTransformer = function (fields, model) {
  20399. return fields.map(function (field) {
  20400. if (
  20401. field.hideExpression &&
  20402. (!field.data || !field.data.dontRemoveOnHidden)
  20403. ) {
  20404. addFieldRemoveOnHideWatcher(field);
  20405. }
  20406. if (field.type == "ui-title") {
  20407. addFieldRemoveOnHideWatcher(field);
  20408. }
  20409. return field;
  20410. });
  20411. };
  20412. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20413. function addFieldRemoveOnHideWatcher(field) {
  20414. var watcher = getWatcher();
  20415. if (field.watcher) {
  20416. if (!angular.isArray(field.watcher)) {
  20417. field.watcher = [field.watcher];
  20418. }
  20419. field.watcher.push(watcher);
  20420. } else {
  20421. field.watcher = watcher;
  20422. }
  20423. }
  20424. function getWatcher() {
  20425. return {
  20426. expression: function (field) {
  20427. return field.hide;
  20428. },
  20429. listener: function (field, newHide, oldHide, scope) {
  20430. if (field.hide) {
  20431. if (field.templateOptions.pkey) {
  20432. if (field.key == "transferuser") {
  20433. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20434. scope.model,
  20435. undefined
  20436. );
  20437. }
  20438. } else if(typeof field.key =='string') {
  20439. $parse(field.key).assign(scope.model, undefined);
  20440. }
  20441. }
  20442. if (field.type == "ui-title") {
  20443. $parse(field.key).assign(scope.model, undefined);
  20444. }
  20445. },
  20446. };
  20447. }
  20448. });
  20449. appFormly.controller("CustomformCtrl", [
  20450. "$rootScope",
  20451. "$scope",
  20452. "$parse",
  20453. "$injector",
  20454. "$http",
  20455. "$q",
  20456. "$state",
  20457. "$stateParams",
  20458. "$modal",
  20459. "$timeout",
  20460. "$interval",
  20461. "SweetAlert",
  20462. "FileUploader",
  20463. "i18nService",
  20464. "Restangular",
  20465. "UserRestangular",
  20466. "BpmRestangular",
  20467. "WechatRestangular",
  20468. "api_configure_form",
  20469. "api_bpm_domain",
  20470. "api_bpm_domain1",
  20471. "api_bpm",
  20472. "api_bpm_data",
  20473. "api_user_data",
  20474. "api_statistic",
  20475. "up_down_file",
  20476. "fileReader",
  20477. "api_wechatfile",
  20478. function (
  20479. $rootScope,
  20480. $scope,
  20481. $parse,
  20482. $injector,
  20483. $http,
  20484. $q,
  20485. $state,
  20486. $stateParams,
  20487. $modal,
  20488. $timeout,
  20489. $interval,
  20490. SweetAlert,
  20491. FileUploader,
  20492. i18nService,
  20493. Restangular,
  20494. UserRestangular,
  20495. BpmRestangular,
  20496. WechatRestangular,
  20497. api_configure_form,
  20498. api_bpm_domain,
  20499. api_bpm_domain1,
  20500. api_bpm,
  20501. api_bpm_data,
  20502. api_user_data,
  20503. api_statistic,
  20504. up_down_file,
  20505. fileReader,
  20506. api_wechatfile
  20507. ) {
  20508. //console.log($parse('Restangular')($scope));
  20509. //console.log($injector.get('Restangular'));
  20510. //console.log($stateParams);
  20511. //保存报修主体
  20512. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20513. $scope.imgUrlList = [];
  20514. $scope.uploadimg_del = function () {
  20515. console.log(123);
  20516. };
  20517. var vm = this;
  20518. vm.options = {};
  20519. vm.exampleTitle = ["expressionProperties", "model property"];
  20520. vm.fields = [];
  20521. vm.model = {};
  20522. $scope.langs = i18nService.getAllLangs();
  20523. $scope.lang = "zh-cn";
  20524. i18nService.setCurrentLang($scope.lang);
  20525. //alert($rootScope.user.id,null,2);
  20526. vm.model["loginUser"] = $rootScope.user;
  20527. var loginUser = $rootScope.user;
  20528. // console.log(vm);
  20529. var that = $injector;
  20530. var parse = $parse;
  20531. var formKey = "";
  20532. var pdKey = "";
  20533. var modelWatch = "";
  20534. // 房间号是否显示
  20535. vm.model.isRoom = sessionStorage.getItem('ifRoom') == 1;
  20536. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20537. modelWatch = JSON.parse($stateParams.model);
  20538. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20539. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20540. console.log(modelWatch, $rootScope);
  20541. // if(modelWatch.model.incident){
  20542. // if(modelWatch.model.incident.place){
  20543. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20544. // }else{
  20545. // $rootScope.selecthouseNumber = undefined;
  20546. // }
  20547. // }
  20548. // 初始化的时候判断是否是简单处理
  20549. if(modelWatch.model && modelWatch.model.incident && modelWatch.model.incident.category){
  20550. if (modelWatch.model.incident.category.hasSimple == 1) {
  20551. vm.model.isHasSimple = true;
  20552. }else{
  20553. vm.model.isHasSimple = false;
  20554. }
  20555. }
  20556. }
  20557. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20558. pdKey = $state.current.pdKey;
  20559. } else if ($stateParams.pdKey) {
  20560. pdKey = $stateParams.pdKey;
  20561. }
  20562. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20563. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20564. formKey = $stateParams.formKey;
  20565. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20566. }
  20567. if (angular.isDefined($stateParams.model)) {
  20568. var formModel = $stateParams.model;
  20569. }
  20570. //用户测试数据,后续从header的auth中获取
  20571. var userId = 2;
  20572. userId = $rootScope.user.id;
  20573. //==============处理表单设计数据 开始====================
  20574. //处理组件加载后台数据选项的方法
  20575. function refreshSelectOptions(searchVal, field) {
  20576. if (
  20577. field.templateOptions.optionsUrl &&
  20578. !field.templateOptions.isnosearch
  20579. ) {
  20580. var process = BpmRestangular.all("");
  20581. if (field.templateOptions.ApiService) {
  20582. process = UserRestangular.all("");
  20583. }
  20584. if (field.templateOptions.Apicommon) {
  20585. process = WechatRestangular.all("");
  20586. }
  20587. var datakey = {
  20588. idx: 0,
  20589. sum: 1000,
  20590. };
  20591. if (field.templateOptions.modelreasondata) {
  20592. datakey = field.templateOptions.modelreasondata;
  20593. }
  20594. process
  20595. .customPOST(datakey, field.templateOptions.optionsUrl)
  20596. .then(function (result) {
  20597. if (!field.templateOptions.options) {
  20598. field.templateOptions.options = [];
  20599. }
  20600. if (field.templateOptions.optionsDataKey) {
  20601. field.templateOptions.options =
  20602. result[field.templateOptions.optionsDataKey];
  20603. } else {
  20604. field.templateOptions.options = result;
  20605. }
  20606. });
  20607. }
  20608. }
  20609. //获取表单后数据处理
  20610. function formfield(field, result) {
  20611. // angular.forEach(fields.fields, function(field) {
  20612. if (field.key == "") {
  20613. delete field.key;
  20614. }
  20615. if (angular.isDefined(field.extjson)) {
  20616. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20617. angular.extend(field.templateOptions, extObj.templateOptions);
  20618. delete extObj.templateOptions;
  20619. for (var prop in extObj) {
  20620. if (new RegExp("Expression").test(prop)) {
  20621. //var obj = $scope.$eval(extObj[prop]);
  20622. //extObj[prop] = $scope.$eval(extObj[prop]);
  20623. if (extObj[prop] != null) {
  20624. if (new RegExp("function").test(extObj[prop])) {
  20625. var propValue = eval(extObj[prop]);
  20626. extObj[prop] = propValue;
  20627. } else {
  20628. //console.log(extObj[prop]);
  20629. var obj = $scope.$eval(extObj[prop]);
  20630. extObj[prop] = obj;
  20631. //console.log(obj);
  20632. }
  20633. }
  20634. } else if (new RegExp("expressionProperties").test(prop)) {
  20635. for (var p in extObj[prop]) {
  20636. if (new RegExp("function").test(extObj[prop][p])) {
  20637. var propValue = eval(extObj[prop][p]);
  20638. extObj[prop][p] = propValue;
  20639. } else {
  20640. //if(p.indexOf("'")>=0){
  20641. // var obj = $scope.$eval(extObj[prop][p]);
  20642. // extObj[prop][$scope.$eval(p)]=obj;
  20643. //}
  20644. }
  20645. }
  20646. } else if ("watcher" == prop) {
  20647. if (angular.isArray(extObj[prop])) {
  20648. angular.forEach(extObj[prop], function (item, index) {
  20649. for (var p in item) {
  20650. if (new RegExp("function").test(item[p])) {
  20651. var propValue = eval(item[p]);
  20652. extObj[prop][index][p] = propValue;
  20653. }
  20654. }
  20655. });
  20656. } else if (angular.isObject(extObj[prop])) {
  20657. for (var p in extObj[prop]) {
  20658. if (new RegExp("function").test(extObj[prop][p])) {
  20659. var propValue = eval(extObj[prop][p]);
  20660. extObj[prop][p] = propValue;
  20661. }
  20662. }
  20663. }
  20664. }
  20665. }
  20666. angular.extend(field, extObj);
  20667. delete field.extjson;
  20668. }
  20669. if (angular.isDefined(field.templateOptions)) {
  20670. var templateOs = field.templateOptions;
  20671. // console.log(templateOs,'come')
  20672. for (var property in templateOs) {
  20673. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  20674. if (angular.isString(templateOs[property])) {
  20675. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  20676. if (new RegExp("function").test(templateOs[property])) {
  20677. var propValue = eval(templateOs[property]);
  20678. field.templateOptions[property] = propValue;
  20679. } else {
  20680. if (that.has(templateOs[property])) {
  20681. field.templateOptions[property] = that.get(
  20682. templateOs[property]
  20683. );
  20684. } else {
  20685. field.templateOptions[property] = templateOs[property];
  20686. }
  20687. }
  20688. } else if (templateOs[property] == null) {
  20689. //delete field.templateOptions[property];
  20690. } else {
  20691. }
  20692. }
  20693. }
  20694. if (
  20695. angular.isDefined(field.templateOptions) &&
  20696. angular.isDefined(field.templateOptions.extjson)
  20697. ) {
  20698. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  20699. angular.extend(field.templateOptions, extObj);
  20700. delete field.templateOptions.extjson;
  20701. }
  20702. // ...
  20703. if (field.templateOptions) {
  20704. //处理远程获取数据控件方法调用
  20705. if (
  20706. field.templateOptions.optionsUrl &&
  20707. !field.templateOptions.refresh
  20708. ) {
  20709. // if (!field.templateOptions.isnoreash) {
  20710. field.templateOptions.refresh = refreshSelectOptions;
  20711. // }
  20712. }
  20713. //处理嵌套属性数据绑定/
  20714. if (field.templateOptions.pkey) {
  20715. var pmodel,
  20716. i = 0;
  20717. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  20718. if (i == 0) {
  20719. if (result.model[p] == null) {
  20720. result.model[p] = {};
  20721. }
  20722. pmodel = result.model[p];
  20723. i++;
  20724. } else {
  20725. if (pmodel[p] == null) {
  20726. pmodel[p] = {};
  20727. }
  20728. pmodel = pmodel[p];
  20729. }
  20730. });
  20731. if (pmodel != null) {
  20732. field.model = pmodel;
  20733. if (pmodel[field.key] == null) {
  20734. pmodel[field.key] = null;
  20735. }
  20736. }
  20737. } else {
  20738. if (result.model[field.key] == null) {
  20739. result.model[field.key] = null;
  20740. }
  20741. }
  20742. //处理弹出框组件初始化
  20743. if (field.type == "ui-input-selectmodal") {
  20744. field.templateOptions.modal = $modal;
  20745. //field.templateOptions.Restangular = Restangular;
  20746. } else if (field.type == "ui-requesterselect") {
  20747. //field.templateOptions.language = $scope.lang;
  20748. field.templateOptions.modal = $modal;
  20749. field.templateOptions.UserService = api_user_data;
  20750. } else if (field.type == "ui-deptinformation") {
  20751. field.templateOptions.modal = $modal;
  20752. field.templateOptions.UserService = api_user_data;
  20753. } else if (field.type == "ui-requesterinformation") {
  20754. field.templateOptions.modal = $modal;
  20755. field.templateOptions.UserService = api_user_data;
  20756. } else if (field.type == "ui-userselect") {
  20757. field.templateOptions.modal = $modal;
  20758. //field.templateOptions.Restangular = Restangular;
  20759. } else if (field.type == "ui-userselectSearch") {
  20760. field.templateOptions.modal = $modal;
  20761. //field.templateOptions.Restangular = Restangular;
  20762. } else if (field.type == "ui-multiuserselect") {
  20763. field.templateOptions.modal = $modal;
  20764. } else if (field.type == "ui-stringuserselect") {
  20765. field.templateOptions.modal = $modal;
  20766. } else if (field.type == "ui-search") {
  20767. field.templateOptions.modal = $modal;
  20768. } else if (field.type == "ui-modelselect") {
  20769. field.templateOptions.modal = $modal;
  20770. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20771. field.templateOptions.loginUser = $rootScope.user;
  20772. //field.templateOptions.Restangular = Restangular;
  20773. } else if (field.type == "ui-incidentmodelselect") {
  20774. field.templateOptions.modal = $modal;
  20775. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20776. field.templateOptions.loginUser = $rootScope.user;
  20777. //field.templateOptions.Restangular = Restangular;
  20778. } else if (field.type == "ui-dropfile") {
  20779. $scope.fileUploader = field.templateOptions.fileUploader =
  20780. new FileUploader({
  20781. url: "/uploader",
  20782. });
  20783. field.templateOptions.taskId = $stateParams.taskId;
  20784. field.templateOptions.processInstanceId =
  20785. $stateParams.processInstanceId;
  20786. field.templateOptions.userId = $rootScope.user.id;
  20787. } else if (field.type == "ui-dropfielknow") {
  20788. $scope.fileUploader = field.templateOptions.fileUploader =
  20789. new FileUploader({
  20790. url: "/uploader",
  20791. });
  20792. field.templateOptions.taskId = $stateParams.taskId;
  20793. field.templateOptions.processInstanceId =
  20794. $stateParams.processInstanceId;
  20795. field.templateOptions.userId = $rootScope.user.id;
  20796. } else if (field.type == "ui-upDropFile") {
  20797. $scope.fileUploader = field.templateOptions.fileUploader =
  20798. new FileUploader({
  20799. url: "/uploader",
  20800. });
  20801. field.templateOptions.taskId = $stateParams.taskId;
  20802. field.templateOptions.processInstanceId =
  20803. $stateParams.processInstanceId;
  20804. field.templateOptions.userId = $rootScope.user.id;
  20805. } else if (field.type == "ui-dropfilenotup") {
  20806. $scope.fileUploader = field.templateOptions.fileUploader =
  20807. new FileUploader({
  20808. url: "/uploader",
  20809. });
  20810. field.templateOptions.taskId = $stateParams.taskId;
  20811. field.templateOptions.processInstanceId =
  20812. $stateParams.processInstanceId;
  20813. field.templateOptions.userId = $rootScope.user.id;
  20814. //field.ApiService=api_bpm_domain;
  20815. } else if (field.type == "ui-uploadFiles") {
  20816. $scope.fileUploader = field.templateOptions.fileUploader =
  20817. new FileUploader({
  20818. url: "/uploader",
  20819. });
  20820. field.templateOptions.taskId = $stateParams.taskId;
  20821. field.templateOptions.processInstanceId =
  20822. $stateParams.processInstanceId;
  20823. field.templateOptions.userId = $rootScope.user.id;
  20824. //field.ApiService=api_bpm_domain;
  20825. } else if (field.type == "ui-upDownFiles") {
  20826. $scope.fileUploader = field.templateOptions.fileUploader =
  20827. new FileUploader({
  20828. url: "/uploader",
  20829. });
  20830. field.templateOptions.taskId = $stateParams.taskId;
  20831. field.templateOptions.processInstanceId =
  20832. $stateParams.processInstanceId;
  20833. field.templateOptions.userId = $rootScope.user.id;
  20834. //field.ApiService=api_bpm_domain;
  20835. } else if (field.type == "ui-uploadImgs") {
  20836. $scope.fileUploader = field.templateOptions.fileUploader =
  20837. new FileUploader({
  20838. url: "/uploader",
  20839. });
  20840. field.templateOptions.taskId = $stateParams.taskId;
  20841. field.templateOptions.processInstanceId =
  20842. $stateParams.processInstanceId;
  20843. field.templateOptions.userId = $rootScope.user.id;
  20844. //field.ApiService=api_bpm_domain;
  20845. } else if (field.type == "ui-dropfiletable") {
  20846. if (field.templateOptions.processInstanceId) {
  20847. } else {
  20848. field.templateOptions.processInstanceId =
  20849. $stateParams.processInstanceId;
  20850. }
  20851. } else if (field.type == "ui-dropFiles") {
  20852. if (field.templateOptions.processInstanceId) {
  20853. } else {
  20854. field.templateOptions.processInstanceId =
  20855. $stateParams.processInstanceId;
  20856. }
  20857. } else if (field.type == "ui-showImgs") {
  20858. if (field.templateOptions.processInstanceId) {
  20859. } else {
  20860. field.templateOptions.processInstanceId =
  20861. $stateParams.processInstanceId;
  20862. }
  20863. } else if (field.type == "ui-repeatSection") {
  20864. var repeatForm = {
  20865. model: {},
  20866. fields: field.templateOptions.fields,
  20867. };
  20868. repeatForm.model[field.key] = [];
  20869. decodeVMForm(repeatForm);
  20870. } else if (field.type == "ui-currentuser") {
  20871. field.templateOptions.user = vm.model["loginUser"];
  20872. } else if (field.type == "ui-workernumbersign") {
  20873. field.templateOptions.user = vm.model["loginUser"];
  20874. } else if (field.type == "ui-repair-photos") {
  20875. field.templateOptions.user = vm.model["loginUser"];
  20876. }
  20877. }
  20878. }
  20879. //解析自定义表单设计数据
  20880. $scope.oldfromtype = true;
  20881. function decodeVMForm(vmForm) {
  20882. if (vmForm.formType == "1") {
  20883. $scope.oldfromtype = false;
  20884. } else {
  20885. $scope.oldfromtype = true;
  20886. }
  20887. var result = {
  20888. model: {},
  20889. fields: [],
  20890. };
  20891. //设置模型实体数据 begin
  20892. // var mdata = vmForm.model;
  20893. //解析数据实体
  20894. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  20895. angular.extend(result.model, mdata);
  20896. if (modelWatch != null && modelWatch != "") {
  20897. //angular.extend(result.model.incident,modelWatch.incident);
  20898. //result.model.alarmType = modelWatch.alarmType;
  20899. // vmForm.cancelUrl = modelWatch.cancelUrl;
  20900. // console.log(modelWatch.cancelUrl)
  20901. for (var index in modelWatch.model) {
  20902. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  20903. if (result.model[index] != null) {
  20904. angular.extend(result.model[index], modelWatch.model[index]);
  20905. } else {
  20906. result.model[index] = modelWatch.model[index];
  20907. }
  20908. }
  20909. }
  20910. //设置模型实体数据 end
  20911. //解析设计数据生成表单项 begin
  20912. var fields = [];
  20913. //处理修改设计数据中展示设置
  20914. angular.forEach(vmForm.fields, function (fields) {
  20915. if (vmForm.formType == "1") {
  20916. angular.forEach(fields.fields, function (field) {
  20917. formfield(field, result);
  20918. });
  20919. } else {
  20920. formfield(fields, result);
  20921. }
  20922. // console.log(field);
  20923. result.fields.push(fields);
  20924. });
  20925. angular.extend($scope.vm.fields, result.fields);
  20926. angular.extend($scope.vm.model, result.model);
  20927. vm.model["loginUser"] = $rootScope.user;
  20928. //增加识别报修主体seimin
  20929. vm.model.repairType = $scope.repairMain.valueconfig;
  20930. if (vm.model.incident) {
  20931. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  20932. }
  20933. console.log(vm, "repairType"); //lmm
  20934. if (
  20935. modelWatch != null &&
  20936. modelWatch != "" &&
  20937. modelWatch.cancelUrl != null &&
  20938. modelWatch.cancelUrl != ""
  20939. ) {
  20940. vmForm.cancelUrl = modelWatch.cancelUrl;
  20941. }
  20942. $scope.formData = vmForm;
  20943. console.log($scope.formData, 4444444);
  20944. // console.log($scope.formData.url);
  20945. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  20946. if ($scope.formData.url == "start") {
  20947. $scope.Reset = true;
  20948. $scope.close = true;
  20949. $rootScope.isMask = false;
  20950. } else if ($scope.formData.url == "complete") {
  20951. $scope.Reset = false;
  20952. $scope.close = true;
  20953. }
  20954. //解析设计数据生成表单项 end
  20955. return result;
  20956. }
  20957. //======================处理表单设计数据 结束========================
  20958. $scope.ldloading = {};
  20959. function filter(obj) {
  20960. angular.forEach(obj, function (key, value) {
  20961. if (value === "" || value === null) {
  20962. delete obj[key];
  20963. } else if (
  20964. Object.prototype.toString.call(value) === "[object Object]"
  20965. ) {
  20966. filter(value);
  20967. } else if (angular.isArray(value)) {
  20968. angular.forEach(value, function (item) {
  20969. filter(item);
  20970. });
  20971. }
  20972. });
  20973. }
  20974. $scope.closeModel = function () {
  20975. // console.log($stateParams);
  20976. $state.go($scope.formData.cancelUrl, {});
  20977. event.preventDefault();
  20978. };
  20979. // console.log(vm);
  20980. // 暂存
  20981. $scope.save = function (data) {
  20982. console.log(vm);
  20983. if (vm.model.startSave) {
  20984. vm.model["initUser"] = $rootScope.user.id;
  20985. vm.model.start_code = "temporary";
  20986. //处理请求数据0327
  20987. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20988. delete data0327.repairType;
  20989. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20990. if (
  20991. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20992. .selecthouseNumber
  20993. ) {
  20994. data0327.incident.place = {
  20995. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20996. .selecthouseNumber.id,
  20997. };
  20998. }
  20999. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  21000. if (response) {
  21001. var resData = Restangular.stripRestangular(response);
  21002. if (resData) {
  21003. if (
  21004. $scope.fileUploader != null &&
  21005. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  21006. resData.id
  21007. ) {
  21008. $scope.fileUploader.onBeforeUploadItem = function (item) {
  21009. angular.extend(item.headers, $rootScope.getSession());
  21010. item.url = api_bpm_domain
  21011. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  21012. .getRequestedUrl();
  21013. item.formData.push({
  21014. fileName: item.file.name,
  21015. });
  21016. //console.log();
  21017. };
  21018. $scope.fileUploader.uploadAll();
  21019. }
  21020. }
  21021. SweetAlert.swal(
  21022. {
  21023. title: "提交成功!",
  21024. type: "success",
  21025. confirmButtonColor: "#007AFF",
  21026. },
  21027. function () {
  21028. $state.go($scope.formData.cancelUrl);
  21029. }
  21030. );
  21031. } else {
  21032. SweetAlert.swal({
  21033. title: "系统错误",
  21034. text: "系统错误,请稍后重试!",
  21035. type: "error",
  21036. confirmButtonColor: "#DD6B55",
  21037. });
  21038. }
  21039. $scope.ldloading[style.replace("-", "_")] = false;
  21040. });
  21041. event.preventDefault();
  21042. } else if (vm.model.saveAgain) {
  21043. var toData = {
  21044. incident: vm.model.incident,
  21045. };
  21046. api_user_data.updData("incident", toData).then(function (response) {
  21047. if (response) {
  21048. var resData = Restangular.stripRestangular(response);
  21049. SweetAlert.swal(
  21050. {
  21051. title: "提交成功!",
  21052. type: "success",
  21053. confirmButtonColor: "#007AFF",
  21054. },
  21055. function () {
  21056. $state.go($scope.formData.cancelUrl);
  21057. }
  21058. );
  21059. } else {
  21060. SweetAlert.swal({
  21061. title: "系统错误",
  21062. text: "系统错误,请稍后重试!",
  21063. type: "error",
  21064. confirmButtonColor: "#DD6B55",
  21065. });
  21066. }
  21067. $scope.ldloading[style.replace("-", "_")] = false;
  21068. });
  21069. event.preventDefault();
  21070. } else {
  21071. SweetAlert.swal({
  21072. title: "系统错误",
  21073. text: "系统错误,请稍后重试!",
  21074. type: "error",
  21075. confirmButtonColor: "#DD6B55",
  21076. });
  21077. }
  21078. };
  21079. // 巡检生成事件
  21080. $scope.inspectionToIncident = function () {
  21081. var userData = {
  21082. idx: 0,
  21083. sum: 10,
  21084. requester: {
  21085. name: loginUser.name,
  21086. },
  21087. };
  21088. api_user_data.fetchDataList("requester", userData).then(function (res) {
  21089. console.log(res);
  21090. var toUser = {};
  21091. if (res.list.length > 0) {
  21092. toUser = res.list[0];
  21093. } else {
  21094. toUser = loginUser;
  21095. }
  21096. console.log(vm);
  21097. var incidentDescription = "";
  21098. console.log($stateParams.formUiEdit);
  21099. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  21100. var fields = vm.fields
  21101. .filter((v) => {
  21102. v.key = (v.key || "").toString();
  21103. return v.key.indexOf("sdCheckEnable") > -1;
  21104. })
  21105. .map((v) => ({
  21106. key: v.key,
  21107. name: v.templateOptions.label,
  21108. value: vm.model[v.key],
  21109. }));
  21110. fields.forEach(v=>{
  21111. if (vm.model[v.key]) {
  21112. incidentDescription =
  21113. incidentDescription.concat(v.name);
  21114. }
  21115. })
  21116. if (vm.model.descriptionTextarea) {
  21117. incidentDescription = incidentDescription.concat(
  21118. " " + "整改意见:" + vm.model.descriptionTextarea
  21119. );
  21120. }
  21121. }
  21122. // console.log(incidentDescription)
  21123. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  21124. var formdata = {
  21125. model: {
  21126. // 'isInspection': true,
  21127. // 'start_code':'assignment',
  21128. // 'isHandlerUser':false,
  21129. incident: {
  21130. requester: bxr,
  21131. area: bxr.place.area,
  21132. place: bxr.place,
  21133. houseNumber: bxr.houseNumber,
  21134. contacts: bxr.name,
  21135. contactsInformation: bxr.mphone,
  21136. // 'category': data.wxIncidentClassifyDTO.category,
  21137. description: incidentDescription,
  21138. source: {
  21139. id: 1552,
  21140. },
  21141. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  21142. // 'sourceType': data.incident.sourceType,
  21143. // 'fileUrl': data.incident.fileUrl
  21144. },
  21145. // 'requestershow': toUser,//2020年4月27日22:29:15
  21146. // 'flow': data.incident.id
  21147. // 'assignee': loginUser.id//2020年4月27日22:29:25
  21148. },
  21149. };
  21150. // console.log(formdata,toUser,'1111');
  21151. console.log(formdata, "1111");
  21152. // return;
  21153. $state.go("app.incident.chart", {
  21154. model: JSON.stringify(formdata),
  21155. });
  21156. });
  21157. // var formdata = {
  21158. // model:$rootScope.login_requester
  21159. // };
  21160. // console.log(formdata,'00000')
  21161. // return;
  21162. // $state.go("app.incident.chart", {
  21163. // 'model': JSON.stringify(formdata)
  21164. // });
  21165. event.preventDefault();
  21166. };
  21167. // console.log(vm);
  21168. // 创建事件seimin
  21169. vm.submit = function (data, style) {
  21170. console.log(vm, 22222);
  21171. // return;
  21172. if (vm.model.handler_code == undefined) {
  21173. vm.model.handler_code = "resolve";
  21174. }
  21175. if (
  21176. vm.model.change &&
  21177. vm.model.change.requestingPerson &&
  21178. vm.model.change.requestingPerson.menu
  21179. ) {
  21180. delete vm.model.change.requestingPerson.menu;
  21181. }
  21182. // var pdKey = $stateParams.pdKey;
  21183. if (vm.form.$valid) {
  21184. if (data.incident && data.incident.synergetic) {
  21185. console.log(data.incident.synergetic);
  21186. var synergetic = [];
  21187. for (var i = 0; i < data.incident.synergetic.length; i++) {
  21188. synergetic.push({
  21189. id: data.incident.synergetic[i],
  21190. });
  21191. }
  21192. data.incident.synergetic = synergetic;
  21193. vm.model.incident.synergetic = synergetic;
  21194. }
  21195. $scope.ldloading[style.replace("-", "_")] = true;
  21196. var startsub = true;
  21197. if (pdKey == "bpm_incident") {
  21198. angular.forEach(vm.fields, function (item) {
  21199. angular.forEach(item.fields, function (index) {
  21200. if (index.templateOptions.required && !index.hide) {
  21201. if (index.model) {
  21202. if (
  21203. angular.isDefined(index.model[index.key]) &&
  21204. index.model[index.key] != null
  21205. ) {
  21206. if (
  21207. index.model[index.key].id &&
  21208. index.model[index.key].id == ""
  21209. ) {
  21210. startsub = false;
  21211. $scope.ldloading.expand_right = false;
  21212. SweetAlert.swal({
  21213. title: index.templateOptions.label + "未填",
  21214. text: "请填写此项!",
  21215. type: "error",
  21216. confirmButtonColor: "#DD6B55",
  21217. });
  21218. } else {
  21219. }
  21220. } else {
  21221. startsub = false;
  21222. $scope.ldloading.expand_right = false;
  21223. console.log(vm);
  21224. SweetAlert.swal({
  21225. title: index.templateOptions.label + "未填",
  21226. text: "请填写此项!",
  21227. type: "error",
  21228. confirmButtonColor: "#DD6B55",
  21229. });
  21230. }
  21231. } else {
  21232. if (
  21233. data[index.key] &&
  21234. data[index.key] != "" &&
  21235. data[index.key] != null
  21236. ) {
  21237. } else {
  21238. startsub = false;
  21239. $scope.ldloading.expand_right = false;
  21240. SweetAlert.swal({
  21241. title: index.templateOptions.label + "未填",
  21242. text: "请填写此项!",
  21243. type: "error",
  21244. confirmButtonColor: "#DD6B55",
  21245. });
  21246. }
  21247. }
  21248. }
  21249. });
  21250. });
  21251. if (vm.model.incident){
  21252. if(!vm.model.incident.branch.id){
  21253. startsub = false;
  21254. $scope.ldloading.expand_right = false;
  21255. SweetAlert.swal({
  21256. title: '请填写校区',
  21257. text: "请填写此项!",
  21258. type: "error",
  21259. confirmButtonColor: "#DD6B55"
  21260. });
  21261. }
  21262. }
  21263. // if (vm.model.incident){
  21264. // if(vm.model.incident.branch.id && vm.model.incident.place.id){
  21265. // }else if(vm.model.incident.branch.id || vm.model.incident.place.id){
  21266. // startsub = false;
  21267. // $scope.ldloading.expand_right = false;
  21268. // SweetAlert.swal({
  21269. // title: '请填写完整的校区区域地点',
  21270. // text: "请填写此项!",
  21271. // type: "error",
  21272. // confirmButtonColor: "#DD6B55"
  21273. // });
  21274. // }
  21275. // }
  21276. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  21277. // startsub = false;
  21278. // $scope.ldloading.expand_right = false;
  21279. // SweetAlert.swal({
  21280. // title: '保修人未填',
  21281. // text: "请填写此项!",
  21282. // type: "error",
  21283. // confirmButtonColor: "#DD6B55"
  21284. // });
  21285. // }
  21286. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  21287. // } else {
  21288. // startsub = false;
  21289. // $scope.ldloading.expand_right = false;
  21290. // SweetAlert.swal({
  21291. // title: '事件分类未填',
  21292. // text: "请填写此项!",
  21293. // type: "error",
  21294. // confirmButtonColor: "#DD6B55"
  21295. // });
  21296. // }
  21297. }
  21298. if (startsub) {
  21299. $scope.ldloading[style.replace("-", "_")] = true;
  21300. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  21301. // console.log("vm.options:"+ JSON.stringify(vm.options));
  21302. vm.options.updateInitialValue();
  21303. // console.log("dfjkasdhfkhskjf ")
  21304. var _ = window._;
  21305. vm.model = (function filter(obj) {
  21306. var dateTransKeys = [];
  21307. var filtered = _.pick(obj, function (v, k, obj) {
  21308. if (_.isDate(v)) {
  21309. dateTransKeys.push(k);
  21310. }
  21311. return (
  21312. angular.isDefined(v) &&
  21313. v !== null &&
  21314. (angular.isArray(v) ? v.length > 0 : true) &&
  21315. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  21316. );
  21317. });
  21318. return _.cloneDeep(filtered, function (v, index, object) {
  21319. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  21320. angular.forEach(dateTransKeys, function (item) {
  21321. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  21322. });
  21323. dateTransKey = [];
  21324. return v;
  21325. }
  21326. return !_.isEmpty(filtered) &&
  21327. v !== filtered &&
  21328. _.isPlainObject(v)
  21329. ? filter(v)
  21330. : undefined;
  21331. });
  21332. })(vm.model);
  21333. if (pdKey != "") {
  21334. if ($scope.oprcode == "save") {
  21335. //保存
  21336. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  21337. if (response) {
  21338. var resData = Restangular.stripRestangular(response);
  21339. SweetAlert.swal(
  21340. {
  21341. title: "保存成功!",
  21342. confirmButtonColor: "#007AFF",
  21343. },
  21344. function () {
  21345. $state.go($scope.formData.cancelUri);
  21346. }
  21347. );
  21348. // if(resData.status){
  21349. // resData
  21350. // }
  21351. } else {
  21352. SweetAlert.swal({
  21353. title: "系统错误",
  21354. text: "系统错误,请稍后重试!",
  21355. type: "error",
  21356. confirmButtonColor: "#DD6B55",
  21357. });
  21358. }
  21359. $scope.ldloading[style.replace("-", "_")] = false;
  21360. });
  21361. } else {
  21362. console.log($scope.formData.url, "zzzz");
  21363. var integralMechanism = sessionStorage.getItem('integralMechanism');
  21364. switch ($scope.formData.url) {
  21365. case "start":
  21366. vm.model["initUser"] = $rootScope.user.id;
  21367. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  21368. } else {
  21369. vm.model["assignee"] = $rootScope.user.id;
  21370. }
  21371. if (
  21372. vm.model["candidateGroups"] &&
  21373. vm.model.candidateGroups.id
  21374. ) {
  21375. vm.model.candidateGroups = vm.model.candidateGroups.id;
  21376. }
  21377. if (pdKey == "bpm_service_request") {
  21378. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  21379. angular.extend(vm.model.serviceCatalogueProcessActual, {
  21380. category: {
  21381. id: $stateParams.userId,
  21382. },
  21383. });
  21384. }
  21385. if (vm.model.schedule && vm.model.schedule.initUser) {
  21386. delete vm.model.schedule.initUser.menu;
  21387. }
  21388. if (
  21389. vm.model.isHandlerUser == "true" ||
  21390. vm.model.isHandlerUser == true
  21391. ) {
  21392. delete vm.model.candidateGroups;
  21393. }
  21394. if (vm.model.start_code == "close") {
  21395. // 直接处理
  21396. vm.model.incident.handlingPersonnelUser =
  21397. vm.model.incident.acceptUser;
  21398. delete vm.model.incident.handlerUser;
  21399. delete vm.model.candidateGroups;
  21400. } else if (vm.model.start_code == "assignment") {
  21401. // 派单
  21402. delete vm.model.incident.handlingPersonnelUser;
  21403. }
  21404. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21405. $scope.jry_processInstanceId =
  21406. $stateParams.processInstanceId;
  21407. }
  21408. if ($scope.jry_processInstanceId) {
  21409. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21410. }
  21411. //事件暂存判断
  21412. if (vm.model.saveAgain) {
  21413. if (
  21414. vm.model.directClose == "1" ||
  21415. vm.model.directClose == true
  21416. ) {
  21417. vm.model.start_code = "assignment";
  21418. vm.model.temporary_code = "assignment";
  21419. } else {
  21420. vm.model.start_code = "close";
  21421. vm.model.temporary_code = "close";
  21422. }
  21423. if (
  21424. vm.model.isHandlerUser == "true" ||
  21425. vm.model.isHandlerUser == true
  21426. ) {
  21427. delete vm.model.candidateGroups;
  21428. }
  21429. }
  21430. //处理请求数据0327
  21431. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21432. delete data0327.repairType;
  21433. if (data0327.start_code == "close") {
  21434. data0327.incident.directProcess = 1;
  21435. }
  21436. console.log(vm);
  21437. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21438. var paramsModel = JSON.parse($stateParams.model)
  21439. //来电-传话机id
  21440. if (paramsModel.model.incident.sockid) {
  21441. data0327.incident.callID = paramsModel.model.incident.sockid;
  21442. }
  21443. }
  21444. // --------------------------- start----------------------------------------
  21445. // 积分机制,直接处理
  21446. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21447. $modal.open({
  21448. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21449. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21450. console.log(incidentData,currentUserId);
  21451. $scope.flag = false;
  21452. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21453. $scope.complexityFn = function(category){
  21454. if(category.complexity){
  21455. return category.complexity.value;
  21456. }else if(category.parent){
  21457. return $scope.complexityFn(category.parent);
  21458. }else{
  21459. return $scope.list[0]?$scope.list[0].value:1;
  21460. }
  21461. }
  21462. $scope.list = [];
  21463. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21464. $scope.list = res;
  21465. if(incidentData.category && incidentData.category.id){
  21466. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21467. if(result.status == 200){
  21468. $scope.complexity = $scope.complexityFn(result.data);
  21469. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21470. }
  21471. })
  21472. }
  21473. })
  21474. $scope.onChangeComplexity = function(item){
  21475. }
  21476. $scope.ok = function () {
  21477. if (!$scope.complexityConfirm.complexity){
  21478. Alert.swal({
  21479. title: "操作失败",
  21480. text: "请选择工时!",
  21481. type: "error"
  21482. });
  21483. return;
  21484. }
  21485. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21486. Alert.swal({
  21487. title: "操作失败",
  21488. text: "请填写升级原因!",
  21489. type: "error"
  21490. });
  21491. return;
  21492. }
  21493. $modalInstance.close('success');
  21494. handlerStart();
  21495. scope.complexity = $scope.complexity;
  21496. scope.complexityConfirm = $scope.complexityConfirm;
  21497. // 暂存--后面直接处理后调用积分接口
  21498. }
  21499. $scope.cancel = function () {
  21500. scope.ldloading.expand_right = false;
  21501. $modalInstance.dismiss('cancel');
  21502. }
  21503. },
  21504. size: 'sm',
  21505. resolve: {
  21506. scope: function () {
  21507. return $scope;
  21508. },
  21509. api_bpm: function () {
  21510. return api_bpm;
  21511. },
  21512. incidentData: function () {
  21513. return data0327.incident;
  21514. },
  21515. currentUserId: function () {
  21516. return loginUser.id;
  21517. },
  21518. Alert: function () {
  21519. return SweetAlert;
  21520. },
  21521. api_user_data: function () {
  21522. return api_user_data;
  21523. },
  21524. api_wechatfile: function () {
  21525. return api_wechatfile;
  21526. }
  21527. }
  21528. });
  21529. }else{
  21530. handlerStart();
  21531. }
  21532. // -------------------------------end------------------------------------
  21533. function handlerStart(){
  21534. api_bpm_domain
  21535. .start(pdKey, data0327)
  21536. .then(function (response) {
  21537. if (response) {
  21538. var resData = Restangular.stripRestangular(response);
  21539. if (resData) {
  21540. if (resData) {
  21541. if (
  21542. $scope.fileUploader != null &&
  21543. $scope.fileUploader.getNotUploadedItems().length >
  21544. 0 &&
  21545. resData.id
  21546. ) {
  21547. $scope.fileUploader.onBeforeUploadItem =
  21548. function (item) {
  21549. angular.extend(
  21550. item.headers,
  21551. $rootScope.getSession()
  21552. );
  21553. item.url = api_bpm_domain
  21554. .uploadAttachment(
  21555. resData.id,
  21556. "00000",
  21557. $rootScope.user.id
  21558. )
  21559. .getRequestedUrl();
  21560. item.formData.push({
  21561. fileName: item.file.name,
  21562. });
  21563. //console.log();
  21564. };
  21565. $scope.fileUploader.uploadAll();
  21566. }
  21567. }
  21568. }
  21569. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21570. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21571. var auditState = res.find(v=>v.value == 0);
  21572. var postData = {
  21573. incidentIntegral: {
  21574. incidentId:resData.bussId,
  21575. auditState:auditState,
  21576. handlerUser:$rootScope.user.id,
  21577. handlerUserName:$rootScope.user.name,
  21578. sourceScore:$scope.complexity,
  21579. currentScore:$scope.complexityConfirm.complexity.value,
  21580. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21581. }
  21582. }
  21583. console.log(postData)
  21584. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21585. console.log(response)
  21586. if (response.status == 200) {
  21587. SweetAlert.swal(
  21588. {
  21589. title: "提交成功!",
  21590. type: "success",
  21591. confirmButtonColor: "#007AFF",
  21592. },
  21593. function () {
  21594. if (
  21595. vm.model.incident &&
  21596. vm.model.incident.callID &&
  21597. vm.model.incident.callID != ""
  21598. ) {
  21599. $rootScope.app.layout.isSidebarClosed = false;
  21600. if ($scope.login && !$rootScope.busy) {
  21601. $rootScope.setidle();
  21602. }
  21603. }
  21604. $state.go($scope.formData.cancelUrl);
  21605. }
  21606. );
  21607. } else {
  21608. Alert.swal({
  21609. title: "操作失败",
  21610. text: "操作失败, 请稍后再试!",
  21611. type: "error"
  21612. });
  21613. }
  21614. });
  21615. })
  21616. }else{
  21617. SweetAlert.swal(
  21618. {
  21619. title: "提交成功!",
  21620. type: "success",
  21621. confirmButtonColor: "#007AFF",
  21622. },
  21623. function () {
  21624. if (
  21625. vm.model.incident &&
  21626. vm.model.incident.callID &&
  21627. vm.model.incident.callID != ""
  21628. ) {
  21629. $rootScope.app.layout.isSidebarClosed = false;
  21630. if ($scope.login && !$rootScope.busy) {
  21631. $rootScope.setidle();
  21632. }
  21633. }
  21634. $state.go($scope.formData.cancelUrl);
  21635. }
  21636. );
  21637. }
  21638. } else {
  21639. SweetAlert.swal({
  21640. title: "系统错误",
  21641. text: "系统错误,请稍后重试!",
  21642. type: "error",
  21643. confirmButtonColor: "#DD6B55",
  21644. });
  21645. }
  21646. $scope.ldloading[style.replace("-", "_")] = false;
  21647. });
  21648. }
  21649. break;
  21650. case "complete":
  21651. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21652. //console.log("complete taskId::"+$stateParams.taskId);
  21653. if (
  21654. $scope.formData.name == "transferform" &&
  21655. vm.model.ishandlers &&
  21656. !vm.model.incident.handlerUser
  21657. ) {
  21658. SweetAlert.swal({
  21659. title: "处理人未填",
  21660. text: "请填写此项!",
  21661. type: "error",
  21662. confirmButtonColor: "#DD6B55",
  21663. });
  21664. return;
  21665. }
  21666. console.log(vm);
  21667. // 积分机制,事件状态是“处理中”
  21668. if($scope.formData.name === 'handlerform'&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21669. $modal.open({
  21670. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21671. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21672. console.log(incidentData,currentUserId);
  21673. $scope.flag = true;
  21674. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21675. $scope.complexityFn = function(category){
  21676. if(category.complexity){
  21677. return category.complexity.value;
  21678. }else if(category.parent){
  21679. return $scope.complexityFn(category.parent);
  21680. }else{
  21681. return $scope.list[0]?$scope.list[0].value:1;
  21682. }
  21683. }
  21684. $scope.list = [];
  21685. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21686. $scope.list = res;
  21687. if(incidentData.category && incidentData.category.id){
  21688. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21689. if(result.status == 200){
  21690. $scope.complexity = $scope.complexityFn(result.data);
  21691. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21692. }
  21693. })
  21694. }
  21695. })
  21696. $scope.onChangeComplexity = function(item){
  21697. if($scope.complexityConfirm.complexity.value == $scope.complexity){
  21698. $scope.complexityConfirm.updateReason = '';
  21699. }
  21700. }
  21701. $scope.ok = function () {
  21702. if (!$scope.complexityConfirm.complexity){
  21703. Alert.swal({
  21704. title: "操作失败",
  21705. text: "请选择工时!",
  21706. type: "error"
  21707. });
  21708. return;
  21709. }
  21710. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21711. Alert.swal({
  21712. title: "操作失败",
  21713. text: "请填写升级原因!",
  21714. type: "error"
  21715. });
  21716. return;
  21717. }
  21718. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21719. // var auditState = $scope.complexityConfirm.complexity.value == $scope.complexity?res.find(v=>v.value == 1):res.find(v=>v.value == 0);
  21720. var auditState = res.find(v=>v.value == 0);
  21721. var postData = {
  21722. incidentIntegral: {
  21723. incidentId:incidentData.id,
  21724. auditState:auditState,
  21725. handlerUser:$rootScope.user.id,
  21726. handlerUserName:$rootScope.user.name,
  21727. sourceScore:$scope.complexity,
  21728. currentScore:$scope.complexityConfirm.complexity.value,
  21729. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21730. }
  21731. }
  21732. console.log(postData)
  21733. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21734. console.log(response)
  21735. if (response.status == 200) {
  21736. $modalInstance.close('success');
  21737. handlerLogFn();
  21738. } else {
  21739. Alert.swal({
  21740. title: "操作失败",
  21741. text: "操作失败, 请稍后再试!",
  21742. type: "error"
  21743. });
  21744. }
  21745. });
  21746. })
  21747. }
  21748. $scope.cancel = function () {
  21749. scope.ldloading.expand_right = false;
  21750. $modalInstance.dismiss('cancel');
  21751. }
  21752. },
  21753. size: 'sm',
  21754. resolve: {
  21755. scope: function () {
  21756. return $scope;
  21757. },
  21758. api_bpm: function () {
  21759. return api_bpm;
  21760. },
  21761. incidentData: function () {
  21762. return $scope.formData.model.incident;
  21763. },
  21764. currentUserId: function () {
  21765. return loginUser.id;
  21766. },
  21767. Alert: function () {
  21768. return SweetAlert;
  21769. },
  21770. api_user_data: function () {
  21771. return api_user_data;
  21772. },
  21773. api_wechatfile: function () {
  21774. return api_wechatfile;
  21775. }
  21776. }
  21777. });
  21778. }else{
  21779. handlerLogFn();
  21780. }
  21781. function handlerLogFn(){
  21782. //沟通记录
  21783. // 沟通记录不为空并且事件是处理中状态
  21784. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  21785. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  21786. baseHandler();
  21787. })
  21788. } else {
  21789. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  21790. //巡检计划
  21791. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  21792. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  21793. if (response.status == 200) {
  21794. baseHandler();
  21795. } else {
  21796. Alert.swal({
  21797. title: "操作失败",
  21798. text: "操作失败, 请稍后再试!",
  21799. type: "error"
  21800. });
  21801. }
  21802. });
  21803. }else{
  21804. baseHandler();
  21805. }
  21806. }else{
  21807. baseHandler();
  21808. }
  21809. }
  21810. }
  21811. // return;
  21812. function baseHandler() {
  21813. api_bpm_domain
  21814. .complete($stateParams.taskId, userId, vm.model)
  21815. .then(function (response) {
  21816. if (response) {
  21817. var resData = Restangular.stripRestangular(response);
  21818. SweetAlert.swal(
  21819. {
  21820. title: "提交成功!",
  21821. type: "success",
  21822. confirmButtonColor: "#007AFF",
  21823. },
  21824. function () {
  21825. if (
  21826. $scope.fileUploader != null &&
  21827. $scope.fileUploader.getNotUploadedItems().length >
  21828. 0
  21829. ) {
  21830. console.log(vm);
  21831. if (vm.model.incident) {
  21832. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  21833. // angular.extend(item.headers, $rootScope.getSession());
  21834. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  21835. // item.formData.push({
  21836. // 'fileName': item.file.name
  21837. // });
  21838. // };
  21839. // $scope.fileUploader.uploadAll();
  21840. $scope.fileUploader.onBeforeUploadItem =
  21841. function (item) {
  21842. angular.extend(
  21843. item.headers,
  21844. $rootScope.getSession()
  21845. );
  21846. item.url = api_bpm_domain
  21847. .uploadAttachment(
  21848. vm.model.incident.processInstanceId,
  21849. "00000",
  21850. $rootScope.user.id
  21851. )
  21852. .getRequestedUrl();
  21853. item.formData.push({
  21854. fileName: item.file.name,
  21855. });
  21856. //console.log();
  21857. };
  21858. $scope.fileUploader.uploadAll();
  21859. } else if (vm.model.problem) {
  21860. $scope.fileUploader.onBeforeUploadItem =
  21861. function (item) {
  21862. angular.extend(
  21863. item.headers,
  21864. $rootScope.getSession()
  21865. );
  21866. item.url = api_bpm_domain
  21867. .uploadAttachmentJryModel(
  21868. "problem",
  21869. vm.model.problem.id,
  21870. "00000",
  21871. $rootScope.user.id
  21872. )
  21873. .getRequestedUrl();
  21874. item.formData.push({
  21875. fileName: item.file.name,
  21876. });
  21877. };
  21878. $scope.fileUploader.uploadAll();
  21879. } else if (vm.model.change) {
  21880. }else if(vm.model.inspectionProcessActual){
  21881. //巡检图片上传yeye
  21882. $scope.fileUploader.onBeforeUploadItem =
  21883. function (item) {
  21884. angular.extend(
  21885. item.headers,
  21886. $rootScope.getSession()
  21887. );
  21888. item.url = api_bpm_domain1
  21889. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  21890. .getRequestedUrl();
  21891. item.formData.push({
  21892. fileName: item.file.name,
  21893. });
  21894. //console.log();
  21895. };
  21896. $scope.fileUploader.uploadAll();
  21897. }
  21898. }
  21899. $state.go($scope.formData.cancelUrl);
  21900. }
  21901. );
  21902. } else {
  21903. SweetAlert.swal({
  21904. title: "系统错误",
  21905. text: "系统错误,请稍后重试!",
  21906. type: "error",
  21907. confirmButtonColor: "#DD6B55",
  21908. });
  21909. }
  21910. $scope.ldloading[style.replace("-", "_")] = false;
  21911. });
  21912. }
  21913. break;
  21914. case "back":
  21915. $state.go($scope.formData.cancelUrl);
  21916. break;
  21917. default:
  21918. $scope.ldloading[style.replace("-", "_")] = false;
  21919. break;
  21920. }
  21921. }
  21922. // var submitFunc = api_bpm_domain[$scope.formData.url]
  21923. // if(anuglar.isFunction(submitFunc)){
  21924. // submitFunc.apply(null, pdKey)
  21925. // }
  21926. }
  21927. }
  21928. } else {
  21929. // console.log(data)
  21930. // angular.forEach(vm.form.$error.required, function(item){
  21931. // var i=(item.$name).substring(item.$name.length-2)
  21932. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  21933. // for(var i=0;i<vm.fields.length;i++){
  21934. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  21935. SweetAlert.swal({
  21936. title: vm.fields[i].templateOptions.label + "未填",
  21937. text: "请填写此项!",
  21938. type: "error",
  21939. confirmButtonColor: "#DD6B55",
  21940. });
  21941. }
  21942. // }
  21943. // angular.forEach(vm.fields,function(f){
  21944. // if(f.name == item.$name){
  21945. // f.validation.show = true;
  21946. // SweetAlert.swal({
  21947. // title: f.templateOptions.label+'未填',
  21948. // text: "请填写此项!",
  21949. // type: "error",
  21950. // confirmButtonColor: "#DD6B55"
  21951. // });
  21952. // }
  21953. // });
  21954. // })
  21955. }
  21956. };
  21957. $scope.vm = vm;
  21958. console.log($stateParams, pdKey, 88888);
  21959. console.log($scope.vm, "assdfsdf");
  21960. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  21961. var processInstanceId = $stateParams.processInstanceId;
  21962. var itemId = $stateParams.dataId;
  21963. console.log($stateParams);
  21964. if (
  21965. angular.isDefined($stateParams.pdKey) &&
  21966. $stateParams.pdKey == "bpm_inspection"
  21967. ) {
  21968. api_configure_form
  21969. .renderForm(
  21970. $stateParams.formUiEdit,
  21971. userId,
  21972. processInstanceId,
  21973. itemId
  21974. )
  21975. .then(function (responseData) {
  21976. if (responseData) {
  21977. //console.log("responseData>>>");//console.log(responseData);
  21978. var vmForm = Restangular.stripRestangular(responseData);
  21979. if (vmForm) {
  21980. //console.log("vmForm>>>");//console.log(vmForm);
  21981. decodeVMForm(vmForm);
  21982. }
  21983. }
  21984. });
  21985. } else if (
  21986. angular.isDefined($stateParams.pdKey) &&
  21987. $stateParams.pdKey == "bpm_service_request"
  21988. ) {
  21989. api_configure_form
  21990. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  21991. .then(function (responseData) {
  21992. if (responseData) {
  21993. //console.log("responseData>>>");//console.log(responseData);
  21994. var vmForm = Restangular.stripRestangular(responseData);
  21995. if (vmForm) {
  21996. //console.log("vmForm>>>");//console.log(vmForm);
  21997. decodeVMForm(vmForm);
  21998. }
  21999. }
  22000. });
  22001. } else {
  22002. api_bpm_domain
  22003. .taskformkey($stateParams.taskId)
  22004. .then(function (response) {
  22005. if (response) {
  22006. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  22007. api_configure_form
  22008. .renderForm(myData.data, userId, processInstanceId, itemId)
  22009. .then(function (responseData) {
  22010. if (responseData) {
  22011. //console.log("responseData>>>");//console.log(responseData);
  22012. var vmForm = Restangular.stripRestangular(responseData);
  22013. if (vmForm) {
  22014. //console.log("vmForm>>>");//console.log(vmForm);
  22015. decodeVMForm(vmForm);
  22016. console.log(vmForm, 111111);
  22017. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  22018. console.log($scope, "今天"); //2020年4月24日11:40:55
  22019. }
  22020. }
  22021. });
  22022. }
  22023. });
  22024. }
  22025. } else {
  22026. // create process instance
  22027. if (pdKey != "") {
  22028. //for process
  22029. if (pdKey == "bpm_service_request") {
  22030. api_configure_form
  22031. .renderForm($stateParams.formUiStart, userId)
  22032. .then(function (responseData) {
  22033. if (responseData) {
  22034. var vmForm = Restangular.stripRestangular(responseData);
  22035. if (vmForm) {
  22036. decodeVMForm(vmForm);
  22037. }
  22038. }
  22039. });
  22040. } else {
  22041. api_bpm_domain.startformkey(pdKey).then(function (response) {
  22042. if (response) {
  22043. var myData = Restangular.stripRestangular(response);
  22044. //myData.data = "arrangeform";
  22045. api_configure_form
  22046. .renderForm(myData.data, userId)
  22047. .then(function (responseData) {
  22048. if (responseData) {
  22049. var vmForm = Restangular.stripRestangular(responseData);
  22050. if (vmForm) {
  22051. decodeVMForm(vmForm);
  22052. }
  22053. }
  22054. });
  22055. }
  22056. });
  22057. }
  22058. } else {
  22059. //for form
  22060. //TODO
  22061. //测试数据 开始
  22062. var testJson = {
  22063. fields: [
  22064. {
  22065. fields: [
  22066. {
  22067. className: "col-xs-12",
  22068. noFormControl: true,
  22069. key: "formtitle",
  22070. templateOptions: {
  22071. readOnly: false,
  22072. placeholder: "新建事件单",
  22073. hidden: false,
  22074. label: "事件工单",
  22075. required: false,
  22076. },
  22077. type: "ui-title",
  22078. },
  22079. ],
  22080. },
  22081. {
  22082. fields: [
  22083. {
  22084. key: "selectUser",
  22085. type: "ui-deptinformation",
  22086. className: "col-xs-12",
  22087. templateOptions: {
  22088. label: "请求人信息",
  22089. modalTitle: "请求人列表",
  22090. fetchItems: function (filterData, APIService) {
  22091. return APIService.fetchDataList("requester", filterData);
  22092. },
  22093. Restangular: Restangular,
  22094. ApiService: api_user_data,
  22095. // onClick:function(val, options, field, event , model){
  22096. // console.log(options);
  22097. // }
  22098. },
  22099. },
  22100. ],
  22101. },
  22102. {
  22103. fields: [
  22104. {
  22105. key: "first",
  22106. type: "ui-workernumber",
  22107. className: "col-xs-12",
  22108. templateOptions: {
  22109. type: "input",
  22110. label: "事件单号",
  22111. pkey: "name",
  22112. },
  22113. },
  22114. ],
  22115. },
  22116. {
  22117. fields: [
  22118. {
  22119. type: "ui-header",
  22120. key: "title",
  22121. className: "col-xs-12",
  22122. templateOptions: {
  22123. label: "报修人",
  22124. pkey: "change",
  22125. },
  22126. },
  22127. {
  22128. type: "ui-input",
  22129. key: "title",
  22130. className: "col-xs-4",
  22131. templateOptions: {
  22132. label: "报修人",
  22133. pkey: "change",
  22134. },
  22135. },
  22136. {
  22137. type: "ui-input",
  22138. key: "title",
  22139. className: "col-xs-4",
  22140. templateOptions: {
  22141. label: "联系人",
  22142. pkey: "change",
  22143. },
  22144. },
  22145. {
  22146. type: "ui-input",
  22147. key: "title",
  22148. className: "col-xs-4",
  22149. templateOptions: {
  22150. label: "联系电话",
  22151. pkey: "change",
  22152. },
  22153. },
  22154. ],
  22155. },
  22156. {
  22157. fields: [
  22158. {
  22159. type: "ui-header",
  22160. key: "title1",
  22161. className: "col-xs-12",
  22162. templateOptions: {
  22163. label: "报修人",
  22164. pkey: "change",
  22165. },
  22166. },
  22167. {
  22168. type: "ui-input",
  22169. key: "title2",
  22170. className: "col-xs-4",
  22171. templateOptions: {
  22172. label: "报修人",
  22173. pkey: "change",
  22174. },
  22175. },
  22176. {
  22177. type: "ui-input",
  22178. key: "title3",
  22179. className: "col-xs-4",
  22180. templateOptions: {
  22181. label: "联系人",
  22182. pkey: "change",
  22183. },
  22184. },
  22185. {
  22186. type: "ui-input",
  22187. key: "title4",
  22188. className: "col-xs-4",
  22189. templateOptions: {
  22190. label: "联系电话",
  22191. pkey: "change",
  22192. },
  22193. },
  22194. ],
  22195. },
  22196. ],
  22197. model: [
  22198. {
  22199. username: "robin lau",
  22200. password: "123456",
  22201. chkme: false,
  22202. start_code: 0,
  22203. formtitle: "Hey!I am title value!",
  22204. name: {
  22205. first: "robin",
  22206. last: "lau",
  22207. },
  22208. multiselectItem: [],
  22209. //date:"2015-09-15 00:00:00"
  22210. },
  22211. ],
  22212. // }
  22213. };
  22214. setTimeout(function () {
  22215. decodeVMForm(testJson);
  22216. $scope.$apply();
  22217. }, 500);
  22218. //测试数据结束
  22219. }
  22220. }
  22221. //console.log("end decode");
  22222. },
  22223. ]);