customformCtrl.js 784 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617
  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. name: "bootstrapLabel",
  85. templateUrl: "assets/views/customform/tpl/normal-label.html",
  86. });
  87. //流程图
  88. formlyConfigProvider.setType({
  89. name: "ui-process",
  90. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  91. defaultOptions: function (options) {
  92. return {
  93. templateOptions: {
  94. refresh: function () {},
  95. refreshDelay: 0,
  96. },
  97. };
  98. },
  99. controller: [
  100. "$scope",
  101. "$modal",
  102. "SweetAlert",
  103. "api_bpm_domain",
  104. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  105. $scope.processdata = [];
  106. api_bpm_domain
  107. .flowTracing($scope.model.applicationForm.processInstanceId)
  108. .then(function (data) {
  109. console.log(data);
  110. $scope.processdata = data.data;
  111. });
  112. },
  113. ],
  114. });
  115. //出库单详情
  116. formlyConfigProvider.setType({
  117. name: "ui-getoutinform",
  118. extends: "radio",
  119. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  120. defaultOptions: function (options) {
  121. return {
  122. templateOptions: {
  123. refresh: function () {},
  124. refreshDelay: 0,
  125. },
  126. };
  127. },
  128. controller: [
  129. "$scope",
  130. "$modal",
  131. "SweetAlert",
  132. "api_bpm_domain",
  133. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  134. if (
  135. angular.isDefined($scope.model.type.id) &&
  136. !$scope.model.type.name
  137. ) {
  138. if (($scope.model.type.id = 0)) {
  139. $scope.model.type.name = "新资产入库";
  140. } else if (($scope.model.type.id = 1)) {
  141. $scope.model.type.name = "新设备领用出库";
  142. } else if (($scope.model.type.id = 2)) {
  143. $scope.model.type.name = "资产归还";
  144. } else if (($scope.model.type.id = 4)) {
  145. $scope.model.type.name = "设备更换";
  146. }
  147. }
  148. },
  149. ],
  150. });
  151. //多选框组件
  152. formlyConfigProvider.setType({
  153. name: "ui-checkboxmore",
  154. extends: "radio",
  155. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  156. defaultOptions: function (options) {
  157. return {
  158. templateOptions: {
  159. refresh: function () {},
  160. refreshDelay: 0,
  161. },
  162. };
  163. },
  164. controller: [
  165. "$scope",
  166. "$modal",
  167. "SweetAlert",
  168. "api_bpm_domain",
  169. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  170. $scope.options.initialValue = $scope.model[$scope.options.key];
  171. },
  172. ],
  173. });
  174. //入库单详情
  175. formlyConfigProvider.setType({
  176. name: "ui-getininform",
  177. extends: "radio",
  178. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  179. defaultOptions: function (options) {
  180. return {
  181. templateOptions: {
  182. refresh: function () {},
  183. refreshDelay: 0,
  184. },
  185. };
  186. },
  187. controller: [
  188. "$scope",
  189. "$modal",
  190. "SweetAlert",
  191. "api_bpm_domain",
  192. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  193. if (
  194. angular.isDefined($scope.model.type.id) &&
  195. !$scope.model.type.name
  196. ) {
  197. if (($scope.model.type.id = 0)) {
  198. $scope.model.type.name = "新资产入库";
  199. } else if (($scope.model.type.id = 1)) {
  200. $scope.model.type.name = "新设备领用出库";
  201. } else if (($scope.model.type.id = 2)) {
  202. $scope.model.type.name = "资产归还";
  203. } else if (($scope.model.type.id = 4)) {
  204. $scope.model.type.name = "设备更换";
  205. }
  206. }
  207. },
  208. ],
  209. });
  210. //申请人详情
  211. formlyConfigProvider.setType({
  212. name: "ui-requsterinfom",
  213. extends: "radio",
  214. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  215. defaultOptions: function (options) {
  216. return {
  217. templateOptions: {
  218. refresh: function () {},
  219. refreshDelay: 0,
  220. },
  221. };
  222. },
  223. });
  224. //设备耗材list组件
  225. formlyConfigProvider.setType({
  226. name: "ui-uplodchange",
  227. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  228. defaultOptions: function (options) {
  229. return {
  230. templateOptions: {
  231. refresh: function () {},
  232. refreshDelay: 0,
  233. view: function (APIService, contentId) {
  234. return APIService.downloadAttachment(contentId);
  235. },
  236. },
  237. };
  238. },
  239. controller: [
  240. "$scope",
  241. "$filter",
  242. "ngTableParams",
  243. "$rootScope",
  244. "Restangular",
  245. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  246. // var data = { "haodata": [], "shedata": [] };
  247. var haodata = [];
  248. var shedata = [];
  249. if ($scope.model.consumables) {
  250. if (angular.isArray($scope.model.consumables)) {
  251. haodata = $scope.model.consumables;
  252. } else {
  253. haodata = JSON.parse($scope.model.consumables);
  254. }
  255. $scope.model.consumables = haodata;
  256. angular.forEach(haodata, function (item, index) {
  257. haodata[index].item = index + 1;
  258. });
  259. }
  260. if ($scope.model.assets) {
  261. if (angular.isArray($scope.model.assets)) {
  262. shedata = $scope.model.assets;
  263. } else {
  264. shedata = JSON.parse($scope.model.assets);
  265. }
  266. $scope.model.assets = shedata;
  267. angular.forEach(shedata, function (item, index) {
  268. shedata[index].item = index + 1;
  269. });
  270. }
  271. $scope.tableParamshao = new ngTableParams(
  272. {
  273. page: 1,
  274. count: 5,
  275. },
  276. {
  277. total: haodata.length,
  278. getData: function ($defer, params) {
  279. var orderedData = params.sorting()
  280. ? $filter("orderBy")(haodata, params.orderBy())
  281. : haodata;
  282. $defer.resolve(
  283. orderedData.slice(
  284. (params.page() - 1) * params.count(),
  285. params.page() * params.count()
  286. )
  287. );
  288. },
  289. }
  290. );
  291. $scope.tableParamsshe = new ngTableParams(
  292. {
  293. page: 1,
  294. count: 5,
  295. },
  296. {
  297. total: shedata.length,
  298. getData: function ($defer, params) {
  299. var orderedData = params.sorting()
  300. ? $filter("orderBy")(shedata, params.orderBy())
  301. : shedata;
  302. $defer.resolve(
  303. orderedData.slice(
  304. (params.page() - 1) * params.count(),
  305. params.page() * params.count()
  306. )
  307. );
  308. },
  309. }
  310. );
  311. $scope.editId = -1;
  312. $scope.setEditId = function (pid) {
  313. $scope.editId = pid;
  314. };
  315. if (angular.isUndefined($scope.form.dropState)) {
  316. $scope.form.dropState = false;
  317. }
  318. var to = $scope.options.templateOptions;
  319. var bindId = $scope.model.processInstanceId;
  320. //获取附件列表
  321. $scope.listAttachmen = function () {
  322. to.ApiService.listAttachment(
  323. to.listAttachmentUrl,
  324. to.bindType,
  325. bindId
  326. ).then(function (result) {
  327. var myData = Restangular.stripRestangular(result);
  328. // $scope.listAttachmens = myData;
  329. $scope.attachments = myData.data;
  330. });
  331. };
  332. $scope.listAttachmen();
  333. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  334. // $scope.listAttachmen();
  335. // } else if (to.bindType && $scope.model[to.bindType].id) {
  336. // $scope.listAttachmen();
  337. // }
  338. //附件下载
  339. $scope.download = function (token, filename) {
  340. var downUrl = to.ApiService.downloadAttachment(
  341. to.downUrl,
  342. token
  343. ).getRequestedUrl();
  344. // window.open(downUrl);
  345. var a = document.createElement("a");
  346. a.href = downUrl;
  347. a.target = "_blank";
  348. a.download = filename;
  349. document.body.appendChild(a);
  350. a.click();
  351. };
  352. //附件预览
  353. $scope.view = function (id, previewUrl) {
  354. if (previewUrl) {
  355. window.open(previewUrl);
  356. }
  357. };
  358. },
  359. ],
  360. });
  361. //多选框组件
  362. formlyConfigProvider.setType({
  363. name: "ui-nodataimage",
  364. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  365. defaultOptions: function (options) {
  366. return {
  367. templateOptions: {
  368. refresh: function () {},
  369. refreshDelay: 0,
  370. },
  371. };
  372. },
  373. });
  374. //ui-grid list
  375. formlyConfigProvider.setType({
  376. name: "ui-gridtwolist",
  377. // extends: 'input',
  378. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  379. defaultOptions: function (options, $scope) {
  380. return {
  381. templateOptions: {},
  382. };
  383. },
  384. controller: [
  385. "$scope",
  386. "$modal",
  387. "i18nService",
  388. "SweetAlert",
  389. function ($scope, $modal, i18nService, SweetAlert) {
  390. //gridone
  391. $scope.langs = i18nService.getAllLangs();
  392. $scope.lang = "zh-cn";
  393. i18nService.setCurrentLang($scope.lang);
  394. $scope.gridOptions = {};
  395. $scope.gridOptions.data = "myDatagrid";
  396. $scope.gridOptions.enableColumnResizing = true;
  397. $scope.gridOptions.enableFiltering = true;
  398. $scope.gridOptions.enableGridMenu = false;
  399. $scope.gridOptions.enableRowSelection = true;
  400. $scope.gridOptions.showGridFooter = true;
  401. $scope.gridOptions.showColumnFooter = false;
  402. $scope.gridOptions.fastWatch = true;
  403. $scope.gridOptions.useExternalFiltering = false;
  404. $scope.gridOptions.useExternalPagination = true;
  405. $scope.gridOptions.paginationPageSizes = [10];
  406. $scope.gridOptions.paginationPageSize = 10;
  407. $scope.gridOptions.multiSelect = false;
  408. $scope.myDatagrid = [];
  409. $scope.myDatagridall = [];
  410. $scope.selected = {
  411. item: {},
  412. };
  413. $scope.memoryfilterDatagrid = {
  414. idx: 0,
  415. sum: 10,
  416. };
  417. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  418. filterData = {
  419. idx: 0,
  420. sum: 10,
  421. };
  422. $scope.gridOptions.columnDefs =
  423. $scope.options.templateOptions.columnDefs;
  424. }
  425. $scope.gridOptions.rowIdentity = function (row) {
  426. return row.id;
  427. };
  428. $scope.gridOptions.getRowIdentity = function (row) {
  429. return row.id;
  430. };
  431. // $scope.gridOptions.columnDefs = items.columnDefs();
  432. $scope.interceptMydata = function (mydate, idx, sum) {
  433. return mydate.slice(idx * sum, (idx + 1) * sum);
  434. };
  435. $scope.gridOptions.onRegisterApi = function (gridApi) {
  436. $scope.gridApi = gridApi;
  437. gridApi.pagination.on.paginationChanged(
  438. $scope,
  439. function (newPage, pageSize) {
  440. $scope.memoryfilterDatagrid.idx = newPage - 1;
  441. $scope.memoryfilterDatagrid.sum = pageSize;
  442. $scope.myDatagrid = $scope.interceptMydata(
  443. $scope.myDatagridall,
  444. $scope.memoryfilterDatagrid.idx,
  445. 10
  446. );
  447. $scope.loadData({
  448. idx: newPage - 1,
  449. sum: pageSize,
  450. });
  451. }
  452. );
  453. gridApi.core.on.filterChanged($scope, function () {});
  454. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  455. $scope.selected.item = data.entity;
  456. //console.log(data);
  457. });
  458. };
  459. $scope.loadData = function (mydate, idx, sum) {
  460. angular.forEach($scope.myDatagrid, function (item, index) {
  461. $scope.myDatagrid[index].item = index;
  462. });
  463. $scope.gridOptions.totalItems = mydate.length;
  464. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  465. };
  466. if ($scope.model.assets) {
  467. $scope.myDatagridall = $scope.model.assets;
  468. $scope.loadData($scope.model.assets, 0, 10);
  469. }
  470. $scope.saveData = function (itemin) {
  471. event.preventDefault();
  472. var modalInstance = $modal.open({
  473. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  474. controller: function ($scope, $modalInstance, SweetAlert) {
  475. // $scope.consumptive = {};
  476. $scope.title = "填写领用设备信息";
  477. // if (items.name) {
  478. // $scope.consumptive.name = items.name.name;
  479. // }
  480. $scope.placechange = angular.copy(itemin);
  481. $scope.ok = function (item) {
  482. if (
  483. item.props &&
  484. item.props.hwnw_area &&
  485. item.props.hwnw_place &&
  486. item.props.hwnw_room &&
  487. item.props.hwnwswt_jiguihao &&
  488. item.props.hwnwswt_Ushu &&
  489. item.props.snnum
  490. ) {
  491. $modalInstance.close(item);
  492. } else {
  493. SweetAlert.swal({
  494. title: "数据填写不完整!",
  495. text: "请检查数据然后提交!",
  496. type: "error",
  497. });
  498. }
  499. };
  500. $scope.cancel = function () {
  501. $modalInstance.dismiss("cancel");
  502. };
  503. },
  504. resolve: {
  505. SweetAlert: function () {
  506. return SweetAlert;
  507. },
  508. },
  509. });
  510. modalInstance.result.then(function (selectedItem) {
  511. angular.forEach($scope.myDatagrid, function (item, index) {
  512. // $scope.myDatagrid[index].props.hw_state = "在线";
  513. if (item.id == selectedItem.id) {
  514. // $scope.myDatagrid[index] = selectedItem;
  515. angular.extend($scope.myDatagrid[index], selectedItem);
  516. }
  517. });
  518. // $scope.myData3.push(selectedItem);
  519. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  520. $scope.myDatagrid[i]["item"] =
  521. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  522. }
  523. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  524. $scope.myDatagridall;
  525. });
  526. };
  527. //gridtwo
  528. $scope.langs = i18nService.getAllLangs();
  529. $scope.lang = "zh-cn";
  530. i18nService.setCurrentLang($scope.lang);
  531. $scope.gridOptions2 = {};
  532. $scope.gridOptions2.data = "myDatagridold";
  533. $scope.gridOptions2.enableColumnResizing = true;
  534. $scope.gridOptions2.enableFiltering = true;
  535. $scope.gridOptions2.enableGridMenu = false;
  536. $scope.gridOptions2.enableRowSelection = true;
  537. $scope.gridOptions2.showGridFooter = true;
  538. $scope.gridOptions2.showColumnFooter = false;
  539. $scope.gridOptions2.fastWatch = true;
  540. $scope.gridOptions2.useExternalFiltering = false;
  541. $scope.gridOptions.useExternalPagination = true;
  542. $scope.gridOptions2.paginationPageSizes = [10];
  543. $scope.gridOptions2.paginationPageSize = 10;
  544. $scope.gridOptions2.multiSelect = false;
  545. $scope.myDatagridold = [];
  546. $scope.myDatagridoldall = [];
  547. $scope.selected = {
  548. item: {},
  549. };
  550. $scope.memoryfilterDatagridold = {
  551. idx: 0,
  552. sum: 10,
  553. };
  554. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  555. filterData = {
  556. idx: 0,
  557. sum: 10,
  558. };
  559. $scope.gridOptions2.columnDefs =
  560. $scope.options.templateOptions.columnDefstwo;
  561. }
  562. $scope.gridOptions2.rowIdentity = function (row) {
  563. return row.id;
  564. };
  565. $scope.gridOptions2.getRowIdentity = function (row) {
  566. return row.id;
  567. };
  568. // $scope.gridOptions.columnDefs = items.columnDefs();
  569. $scope.interceptMydata = function (mydate, idx, sum) {
  570. return mydate.slice(idx * sum, (idx + 1) * sum);
  571. };
  572. if ($scope.model.oldAssets) {
  573. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  574. $scope.myDatagridold = $scope.interceptMydata(
  575. $scope.myDatagridallold,
  576. $scope.memoryfilterDatagridold.idx,
  577. 10
  578. );
  579. }
  580. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  581. $scope.gridApi = gridApi;
  582. gridApi.pagination.on.paginationChanged(
  583. $scope,
  584. function (newPage, pageSize) {
  585. $scope.memoryfilterDatagridold.idx = newPage - 1;
  586. $scope.memoryfilterDatagridold.sum = pageSize;
  587. $scope.myDatagridold = $scope.interceptMydata(
  588. $scope.myDatagridallold,
  589. $scope.memoryfilterDatagridold.idx,
  590. 10
  591. );
  592. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  593. }
  594. );
  595. gridApi.core.on.filterChanged($scope, function () {});
  596. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  597. $scope.selected.item = data.entity;
  598. //console.log(data);
  599. });
  600. };
  601. // $scope.loadData = function(mydate, idx, sum) {
  602. // angular.forEach($scope.myDatagridold, function(item, index) {
  603. // $scope.myDatagridold[index].item = index;
  604. // })
  605. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  606. // }
  607. // if ($scope.model.assets) {
  608. // $scope.myDatagridallold = $scope.model.assets;
  609. // $scope.loadData($scope.model.assets, 0, 10)
  610. // }
  611. // $scope.addoldassets = function(itemin) {
  612. // event.preventDefault();
  613. // var modalInstance = $modal.open({
  614. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  615. // controller: function($scope, $modalInstance, SweetAlert) {
  616. // // $scope.consumptive = {};
  617. // $scope.title = "填写领用设备信息";
  618. // // if (items.name) {
  619. // // $scope.consumptive.name = items.name.name;
  620. // // }
  621. // $scope.placechange = itemin;
  622. // $scope.ok = function(item) {
  623. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  624. // $modalInstance.close(item);
  625. // } else {
  626. // SweetAlert.swal({
  627. // title: "数据填写不完整!",
  628. // text: "请检查数据然后提交!",
  629. // type: "error"
  630. // });
  631. // }
  632. // };
  633. // $scope.cancel = function() {
  634. // $modalInstance.dismiss('cancel');
  635. // };
  636. // },
  637. // resolve: {
  638. // SweetAlert: function() {
  639. // return SweetAlert;
  640. // }
  641. // }
  642. // });
  643. $scope.interceptMydata = function (mydate, idx, sum) {
  644. return mydate.slice(idx * sum, (idx + 1) * sum);
  645. };
  646. $scope.addshebei = function () {
  647. event.preventDefault();
  648. var modalInstance = $modal.open({
  649. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  650. controller: function (
  651. $scope,
  652. i18nService,
  653. $modalInstance,
  654. items,
  655. title,
  656. Restangular,
  657. APIService,
  658. onDataCallback,
  659. parentScope,
  660. api_configure_data,
  661. api_configure_form,
  662. api_cmdb
  663. ) {
  664. $scope.langs = i18nService.getAllLangs();
  665. $scope.lang = "zh-cn";
  666. i18nService.setCurrentLang($scope.lang);
  667. $scope.gridOptions = {};
  668. $scope.gridOptions.data = "myDatatwo";
  669. $scope.gridOptions.enableColumnResizing = true;
  670. $scope.gridOptions.enableFiltering = false;
  671. $scope.gridOptions.enableGridMenu = false;
  672. $scope.gridOptions.showGridFooter = true;
  673. $scope.gridOptions.showColumnFooter = false;
  674. $scope.gridOptions.fastWatch = true;
  675. $scope.gridOptions.useExternalFiltering = true;
  676. $scope.gridOptions.useExternalPagination = true;
  677. $scope.gridOptions.paginationPageSizes = [10];
  678. $scope.gridOptions.paginationPageSize = 10;
  679. $scope.gridOptions.multiSelect = true;
  680. $scope.gridOptions.rowIdentity = function (row) {
  681. return row.id;
  682. };
  683. $scope.gridOptions.getRowIdentity = function (row) {
  684. return row.id;
  685. };
  686. $scope.gridOptions.columnDefs = [
  687. {
  688. name: "item",
  689. displayName: "序号",
  690. width: 80,
  691. enableFiltering: false,
  692. },
  693. {
  694. name: "uuid",
  695. displayName: "内部编号",
  696. width: 150,
  697. },
  698. {
  699. name: "props.hw_mingcheng",
  700. displayName: "资产名称",
  701. width: 100,
  702. },
  703. {
  704. name: "props.hw_cifilterClassic",
  705. displayName: "资产类型",
  706. width: 120,
  707. enableFiltering: false,
  708. },
  709. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  710. {
  711. name: "props.hw_state",
  712. displayName: "资产状态",
  713. width: 150,
  714. enableFiltering: false,
  715. },
  716. {
  717. name: "props.hwnw_area",
  718. displayName: "资产地点",
  719. width: 130,
  720. enableFiltering: false,
  721. },
  722. {
  723. name: "createtime",
  724. displayName: "申请时间",
  725. enableFiltering: false,
  726. },
  727. ];
  728. // $scope.selectButtonClick
  729. var defaultFilterData = {
  730. // "assignee":2,
  731. // "applicationForm": { "hw_state": "在线" },
  732. hw_state: "在线",
  733. idx: 0,
  734. sum: 10,
  735. };
  736. $scope.memoryfilterData = {
  737. // "assignee":2,
  738. // "applicationForm": { "hw_state": "在线" },
  739. hw_state: "在线",
  740. idx: 0,
  741. sum: 10,
  742. };
  743. $scope.refreshData = function (style, filterData) {
  744. if (angular.isUndefined(filterData)) {
  745. filterData = defaultFilterData;
  746. }
  747. $scope.myDatatwo = [];
  748. // $scope.gridOptions['sum']=filterData.sum;
  749. api_cmdb.query(filterData).then(
  750. function (data) {
  751. // $scope.callsPending--;
  752. var myDatatwo = Restangular.stripRestangular(data);
  753. $scope.gridOptions["totalItems"] = data.total;
  754. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  755. myDatatwo.data.node[i].createtime = moment(
  756. myDatatwo.data.node[i].createtime
  757. ).format("YYYY-MM-DD");
  758. }
  759. $scope.myDatatwo = myDatatwo.data.node;
  760. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  761. $scope.myDatatwo[i]["item"] =
  762. i + 1 + filterData.idx * filterData.sum;
  763. }
  764. },
  765. function () {}
  766. );
  767. };
  768. $scope.refreshData("expand-right", defaultFilterData);
  769. $scope.gridOptions.onRegisterApi = function (gridApi) {
  770. $scope.gridApi = gridApi;
  771. gridApi.pagination.on.paginationChanged(
  772. $scope,
  773. function (newPage, pageSize) {
  774. var filtersData = $scope.memoryfilterData;
  775. filtersData.idx = newPage - 1;
  776. filtersData.sum = pageSize;
  777. // $scope.loadData(filtersData);
  778. $scope.refreshData("expand-right", filtersData);
  779. //console.log(pageSize);
  780. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  781. }
  782. );
  783. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  784. // $scope.selected.items.push(data.entity);
  785. //console.log(data);
  786. gridApi.selection.on.rowSelectionChanged(
  787. $scope,
  788. function (scope, ect) {
  789. if (scope.isSelected) {
  790. scope.grid.appScope.selected.items.push(scope.entity);
  791. } else {
  792. for (
  793. var i = 0;
  794. i <= scope.grid.appScope.selected.items.length;
  795. i++
  796. ) {
  797. if (
  798. scope.grid.appScope.selected.items[i].id ==
  799. scope.entity.id
  800. ) {
  801. scope.grid.appScope.selected.items.splice(i, 1);
  802. break;
  803. }
  804. }
  805. }
  806. $scope.mySelectedRows =
  807. $scope.gridApi.selection.getSelectedRows();
  808. }
  809. );
  810. // });
  811. gridApi.selection.on.rowSelectionChangedBatch(
  812. $scope,
  813. function (rows) {
  814. // $scope.selected.items = data.entity;
  815. //console.log(data);
  816. var selectitem = [];
  817. selectitem = angular.copy($scope.selected.items);
  818. for (var j = 0; j < rows.length; j++) {
  819. if (rows[j].isSelected == true) {
  820. selectitem.push(rows[j].entity);
  821. } else {
  822. delete selectitem[j];
  823. // rows.splice(j, 1);
  824. }
  825. }
  826. $scope.selected.items = [];
  827. for (var i = 0; i < selectitem.length; i++) {
  828. if (selectitem[i]) {
  829. $scope.selected.items.push(selectitem[i]);
  830. }
  831. }
  832. }
  833. );
  834. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  835. // // if (row.entity.age > 45) {
  836. // row.grid.api.selection.selectRow(row.entity); // 选中行
  837. // // }
  838. // };
  839. gridApi.core.on.filterChanged($scope, function () {
  840. var grid = this.grid;
  841. var filtersData = {
  842. idx: 0,
  843. sum: 10,
  844. user: {
  845. roledata: {
  846. rolecode: "roleset",
  847. },
  848. selectType: "1",
  849. },
  850. };
  851. angular.forEach(grid.columns, function (item) {
  852. if (item.enableFiltering) {
  853. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  854. if (
  855. angular.isDefined(item.filters[0].term) &&
  856. item.filters[0].term != ""
  857. ) {
  858. if (angular.isUndefined(filtersData["user"])) {
  859. filtersData["user"] = {};
  860. }
  861. filtersData["user"][item.field] = item.filters[0].term;
  862. }
  863. }
  864. });
  865. $scope.memoryfilterData = filtersData;
  866. // $scope.loadData(filtersData);
  867. });
  868. };
  869. $scope.onDblClick = function (data, event) {
  870. // $scope.selected.items = data.entity;
  871. $scope.selectButtonClick(data, event);
  872. };
  873. $scope.title = title;
  874. //树形图
  875. var apple_selected, tree, treedata_avm, treedata_geography;
  876. $scope.my_tree_handler = function (branch) {
  877. //var _ref;
  878. var classify = ($scope.classify =
  879. branch.prefix.toLowerCase() + branch.sign);
  880. api_cmdb
  881. .query({
  882. sign: classify,
  883. })
  884. .then(function (data) {
  885. var myDatalingbei = Restangular.stripRestangular(data);
  886. // console.log(myData.data.node);
  887. if (myDatalingbei.data && myDatalingbei.status == 200) {
  888. var ret = myDatalingbei.data;
  889. redrawSvg(myDatalingbei);
  890. }
  891. });
  892. };
  893. $scope.my_data = [];
  894. function convertListToTree(data, treeMap) {
  895. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  896. var root = null; //Initially set our loop to null
  897. var parentNode = null;
  898. //loop over data
  899. for (var i = 0; i < data.length; i++) {
  900. var datum = data[i];
  901. //each node will have children, so let's give it a "children" poperty
  902. datum.children = [];
  903. //add an entry for this node to the map so that any future children can
  904. //lookup the parent
  905. idToNodeMap[datum.id] = datum;
  906. //Does this node have a parent?
  907. if (
  908. typeof datum.parent === "undefined" ||
  909. datum.parent == null
  910. ) {
  911. //Doesn't look like it, so this node is the root of the tree
  912. root = datum;
  913. treeMap[datum.id] = root;
  914. } else {
  915. //This node has a parent, so let's look it up using the id
  916. parentNode = idToNodeMap[datum.parent.id];
  917. //We don't need this property, so let's delete it.
  918. delete datum.parent;
  919. //Let's add the current node as a child of the parent node.
  920. parentNode.children.push(datum);
  921. }
  922. }
  923. return root;
  924. }
  925. function convertParentToChildList(data) {
  926. var treeMap = {};
  927. var list = [];
  928. convertListToTree(data, treeMap);
  929. angular.forEach(treeMap, function (item) {
  930. list.push(item);
  931. });
  932. return list;
  933. }
  934. $scope.my_tree = tree = {};
  935. $scope.try_async_load = function () {
  936. $scope.my_data = [];
  937. $scope.select_treedata = [];
  938. $scope.doing_async = true;
  939. api_configure_data
  940. .fetchDataList("ciclassify", {
  941. idx: 0,
  942. sum: 100,
  943. })
  944. .then(function (result) {
  945. //console.log(result['list']);
  946. $scope.select_treedata = $scope.my_data =
  947. convertParentToChildList(result["list"]);
  948. $scope.doing_async = false;
  949. // tree.expand_all();
  950. //console.log(treelist);
  951. });
  952. };
  953. $scope.select_treedata = [];
  954. $scope.propTypeOptions = [];
  955. $scope.try_async_load();
  956. $scope.onFilterremove = function (item) {
  957. console.log(item);
  958. };
  959. $scope.searchdata = {};
  960. $scope.clear = function () {
  961. $scope.searchdata = {};
  962. $scope.cifilter_classic = {};
  963. $scope.try_async_load();
  964. var fildata = {
  965. idx: 0,
  966. sum: 10,
  967. hw_state: "在线",
  968. };
  969. $scope.memoryfilterData = fildata;
  970. $scope.refreshData("expand-right", fildata);
  971. };
  972. $scope.chiceIncident = function (item) {
  973. var fildata = $scope.memoryfilterData;
  974. // fildata.applicationForm = {};
  975. // if (item.alltitle && item.alldata) {
  976. // fildata.applicationForm[item.alltitle.key] = item.alldata
  977. // }
  978. if (item && item.id) {
  979. var classify = item.prefix.toLowerCase() + item.sign;
  980. fildata.sign = classify;
  981. }
  982. $scope.gridOptions.paginationCurrentPage = 1;
  983. var transitiondata = angular.copy(item);
  984. $scope.refreshData("expand-right", fildata);
  985. };
  986. $scope.applicadata = [];
  987. $scope.onFilterCallback = function (item) {
  988. var tempclassify = item.prefix.toLowerCase() + item.sign;
  989. api_configure_form
  990. .renderTabForm(tempclassify)
  991. .then(function (data) {
  992. var myData = Restangular.stripRestangular(data);
  993. $scope.applicadata = myData[0].form.fields;
  994. });
  995. // }
  996. };
  997. // $scope.loadData({
  998. // idx: 0,
  999. // sum: 10,
  1000. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1001. // });
  1002. $scope.selected = {
  1003. items: [],
  1004. };
  1005. $scope.ok = function () {
  1006. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1007. // onDataCallback($scope.selected.item, parentScope);
  1008. // }
  1009. $modalInstance.close($scope.selected.items);
  1010. };
  1011. $scope.cancel = function () {
  1012. $modalInstance.dismiss("cancel");
  1013. };
  1014. },
  1015. size: "lg",
  1016. resolve: {
  1017. items: function () {
  1018. return {
  1019. fetchItems: function (filterData, APIService) {
  1020. filterData = filterData || {};
  1021. if (
  1022. angular.isDefined(filterData.idx) &&
  1023. filterData.idx == null
  1024. ) {
  1025. filterData = {
  1026. idx: 0,
  1027. sum: 10,
  1028. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1029. };
  1030. }
  1031. return $scope.options.templateOptions.fetchItems(
  1032. filterData,
  1033. APIService
  1034. );
  1035. },
  1036. };
  1037. },
  1038. title: function () {
  1039. return $scope.options.templateOptions.label;
  1040. },
  1041. Restangular: function () {
  1042. return $scope.options.templateOptions.Restangular;
  1043. },
  1044. APIService: function () {
  1045. return $scope.options.templateOptions.ApiService;
  1046. },
  1047. onDataCallback: function () {
  1048. return $scope.options.templateOptions.callback;
  1049. },
  1050. parentScope: function () {
  1051. return $scope.options.templateOptions.that;
  1052. },
  1053. },
  1054. });
  1055. modalInstance.result.then(function (selectedItem) {
  1056. $scope.myDatagridoldall = selectedItem;
  1057. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1058. $scope.myDatagridoldall[i]["item"] =
  1059. i +
  1060. 1 +
  1061. $scope.memoryfilterDatagridold.idx *
  1062. $scope.memoryfilterDatagridold.sum;
  1063. }
  1064. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1065. $scope.myDatagridold = $scope.interceptMydata(
  1066. $scope.myDatagridoldall,
  1067. 0,
  1068. 10
  1069. );
  1070. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1071. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1072. $scope.myDatagridoldall;
  1073. $scope.options.initialValue = $scope.model.oldAssets;
  1074. });
  1075. // }
  1076. };
  1077. $scope.changestate = function (itemin) {
  1078. event.preventDefault();
  1079. var modalInstance = $modal.open({
  1080. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1081. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1082. $scope.title = "旧设备状态修改";
  1083. $scope.stateshe = [
  1084. {
  1085. id: 2,
  1086. name: "在库",
  1087. },
  1088. {
  1089. id: 4,
  1090. name: "报修",
  1091. },
  1092. {
  1093. id: 3,
  1094. name: "报废",
  1095. },
  1096. ];
  1097. $scope.hw_state = {};
  1098. $scope.ok = function (item) {
  1099. $modalInstance.close(item.id);
  1100. };
  1101. $scope.cancel = function () {
  1102. $modalInstance.dismiss("cancel");
  1103. };
  1104. },
  1105. size: "sm",
  1106. resolve: {
  1107. scope: function () {
  1108. return $scope;
  1109. },
  1110. },
  1111. });
  1112. modalInstance.result.then(function (selectedItem) {
  1113. if (selectedItem) {
  1114. angular.forEach($scope.myDatagridallold, function (item, index) {
  1115. if (item.id == itemin.id) {
  1116. $scope.myDatagridallold[index].props.hw_state =
  1117. selectedItem.name;
  1118. }
  1119. });
  1120. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1121. $scope.myDatagridallold[i]["item"] =
  1122. i +
  1123. 1 +
  1124. $scope.memoryfilterDatagridold.idx *
  1125. $scope.memoryfilterDatagridold.sum;
  1126. }
  1127. $scope.gridOptions2["totalItems"] =
  1128. $scope.myDatagridallold.length;
  1129. $scope.myDatagridold = $scope.interceptMydata(
  1130. $scope.myDatagridallold,
  1131. $scope.memoryfilterDatagridold.idx,
  1132. $scope.memoryfilterDatagridold.sum
  1133. );
  1134. // $scope.model.oldAssets = $scope.myDatagridallold;
  1135. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1136. $scope.myDatagridallold;
  1137. $scope.options.initialValue = $scope.model.oldAssets;
  1138. }
  1139. });
  1140. };
  1141. $scope.savedata = function (data) {
  1142. event.preventDefault();
  1143. var modalInstance = $modal.open({
  1144. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1145. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1146. $scope.title = "设备编辑";
  1147. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1148. $scope.ok = function (item) {
  1149. $modalInstance.close(item);
  1150. };
  1151. $scope.cancel = function () {
  1152. $modalInstance.dismiss("cancel");
  1153. };
  1154. },
  1155. size: "sm",
  1156. resolve: {
  1157. scope: function () {
  1158. return $scope;
  1159. },
  1160. },
  1161. });
  1162. modalInstance.result.then(function (selectedItem) {
  1163. if (selectedItem) {
  1164. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1165. if (item.id == data.id) {
  1166. $scope.myDatagridoldall[index].olddecription =
  1167. selectedItem.olddecription;
  1168. }
  1169. });
  1170. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1171. $scope.myDatagridoldall[i]["item"] =
  1172. i +
  1173. 1 +
  1174. $scope.memoryfilterDatagridold.idx *
  1175. $scope.memoryfilterDatagridold.sum;
  1176. }
  1177. $scope.gridOptions2["totalItems"] =
  1178. $scope.myDatagridoldall.length;
  1179. $scope.myDatagridold = $scope.interceptMydata(
  1180. $scope.myDatagridoldall,
  1181. 0,
  1182. 10
  1183. );
  1184. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1185. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1186. $scope.myDatagridoldall;
  1187. $scope.options.initialValue = $scope.model.oldAssets;
  1188. }
  1189. });
  1190. };
  1191. $scope.removeold = function (data) {
  1192. event.preventDefault();
  1193. var modalInstance = $modal.open({
  1194. templateUrl: "assets/views/delete.html",
  1195. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1196. $scope.title = "设备删除";
  1197. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1198. $scope.ok = function () {
  1199. $modalInstance.close(data);
  1200. };
  1201. $scope.cancel = function () {
  1202. $modalInstance.dismiss("cancel");
  1203. };
  1204. },
  1205. size: "sm",
  1206. resolve: {
  1207. scope: function () {
  1208. return $scope;
  1209. },
  1210. },
  1211. });
  1212. modalInstance.result.then(function (selectedItem) {
  1213. if (selectedItem) {
  1214. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1215. if (item.id == selectedItem.id) {
  1216. $scope.myDatagridoldall.splice(index, 1);
  1217. }
  1218. });
  1219. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1220. $scope.myDatagridoldall[i]["item"] =
  1221. i +
  1222. 1 +
  1223. $scope.memoryfilterDatagridold.idx *
  1224. $scope.memoryfilterDatagridold.sum;
  1225. }
  1226. $scope.gridOptions2["totalItems"] =
  1227. $scope.myDatagridoldall.length;
  1228. $scope.myDatagridold = $scope.interceptMydata(
  1229. $scope.myDatagridoldall,
  1230. 0,
  1231. 10
  1232. );
  1233. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1234. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1235. $scope.myDatagridoldall;
  1236. $scope.options.initialValue = $scope.model.oldAssets;
  1237. }
  1238. });
  1239. };
  1240. },
  1241. ],
  1242. });
  1243. //ui-grid list
  1244. formlyConfigProvider.setType({
  1245. name: "ui-gridlist",
  1246. extends: "input",
  1247. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1248. defaultOptions: function (options, $scope) {
  1249. return {
  1250. templateOptions: {},
  1251. };
  1252. },
  1253. controller: [
  1254. "$scope",
  1255. "$modal",
  1256. "i18nService",
  1257. "SweetAlert",
  1258. function ($scope, $modal, i18nService, SweetAlert) {
  1259. //gridone
  1260. $scope.langs = i18nService.getAllLangs();
  1261. $scope.lang = "zh-cn";
  1262. i18nService.setCurrentLang($scope.lang);
  1263. $scope.gridOptions = {};
  1264. $scope.gridOptions.data = "myDatagrid";
  1265. $scope.gridOptions.enableColumnResizing = true;
  1266. $scope.gridOptions.enableFiltering = true;
  1267. $scope.gridOptions.enableGridMenu = false;
  1268. $scope.gridOptions.enableRowSelection = true;
  1269. $scope.gridOptions.showGridFooter = true;
  1270. $scope.gridOptions.showColumnFooter = false;
  1271. $scope.gridOptions.fastWatch = true;
  1272. $scope.gridOptions.useExternalFiltering = false;
  1273. // $scope.gridOptions.useExternalPagination = true;
  1274. $scope.gridOptions.paginationPageSizes = [10];
  1275. $scope.gridOptions.paginationPageSize = 10;
  1276. $scope.gridOptions.multiSelect = false;
  1277. $scope.myDatagrid = [];
  1278. $scope.myDatagridall = [];
  1279. $scope.selected = {
  1280. item: {},
  1281. };
  1282. $scope.memoryfilterDatagrid = {
  1283. idx: 0,
  1284. sum: 10,
  1285. };
  1286. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1287. filterData = {
  1288. idx: 0,
  1289. sum: 10,
  1290. };
  1291. $scope.gridOptions.columnDefs =
  1292. $scope.options.templateOptions.columnDefs;
  1293. }
  1294. $scope.gridOptions.rowIdentity = function (row) {
  1295. return row.id;
  1296. };
  1297. $scope.gridOptions.getRowIdentity = function (row) {
  1298. return row.id;
  1299. };
  1300. // $scope.gridOptions.columnDefs = items.columnDefs();
  1301. $scope.interceptMydata = function (mydate, idx, sum) {
  1302. return mydate.slice(idx * sum, (idx + 1) * sum);
  1303. };
  1304. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1305. $scope.gridApi = gridApi;
  1306. gridApi.pagination.on.paginationChanged(
  1307. $scope,
  1308. function (newPage, pageSize) {
  1309. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1310. $scope.memoryfilterDatagrid.sum = pageSize;
  1311. $scope.myDatagrid = $scope.interceptMydata(
  1312. $scope.myDatagridall,
  1313. $scope.memoryfilterDatagrid.idx,
  1314. 10
  1315. );
  1316. $scope.loadData({
  1317. idx: newPage - 1,
  1318. sum: pageSize,
  1319. });
  1320. }
  1321. );
  1322. gridApi.core.on.filterChanged($scope, function () {});
  1323. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1324. $scope.selected.item = data.entity;
  1325. //console.log(data);
  1326. });
  1327. };
  1328. $scope.loadData = function (mydate, idx, sum) {
  1329. angular.forEach($scope.myDatagrid, function (item, index) {
  1330. $scope.myDatagrid[index].item = index;
  1331. });
  1332. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1333. };
  1334. if ($scope.model.assets) {
  1335. $scope.myDatagridall = $scope.model.assets;
  1336. $scope.loadData($scope.model.assets, 0, 10);
  1337. }
  1338. $scope.saveData = function (itemin) {
  1339. event.preventDefault();
  1340. var modalInstance = $modal.open({
  1341. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1342. controller: function ($scope, $modalInstance, SweetAlert) {
  1343. // $scope.consumptive = {};
  1344. $scope.title = "填写领用设备信息";
  1345. // if (items.name) {
  1346. // $scope.consumptive.name = items.name.name;
  1347. // }
  1348. $scope.placechange = angular.copy(itemin);
  1349. $scope.ok = function (item) {
  1350. if (
  1351. item.props &&
  1352. item.props.hwnw_area &&
  1353. item.props.hwnw_place &&
  1354. item.props.hwnw_room &&
  1355. item.props.hwnwswt_jiguihao &&
  1356. item.props.hwnwswt_Ushu &&
  1357. item.props.snnum
  1358. ) {
  1359. $modalInstance.close(item);
  1360. } else {
  1361. SweetAlert.swal({
  1362. title: "数据填写不完整!",
  1363. text: "请检查数据然后提交!",
  1364. type: "error",
  1365. });
  1366. }
  1367. };
  1368. $scope.cancel = function () {
  1369. $modalInstance.dismiss("cancel");
  1370. };
  1371. },
  1372. resolve: {
  1373. SweetAlert: function () {
  1374. return SweetAlert;
  1375. },
  1376. },
  1377. });
  1378. modalInstance.result.then(function (selectedItem) {
  1379. angular.forEach($scope.myDatagrid, function (item, index) {
  1380. if (item.id == selectedItem.id) {
  1381. angular.extend($scope.myDatagrid[index], selectedItem);
  1382. }
  1383. });
  1384. // $scope.myData3.push(selectedItem);
  1385. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1386. $scope.myDatagrid[i]["item"] =
  1387. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1388. }
  1389. // $scope.model.assets = $scope.myDatagridall;
  1390. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1391. $scope.myDatagridall;
  1392. });
  1393. };
  1394. },
  1395. ],
  1396. });
  1397. //设备耗材list组件
  1398. formlyConfigProvider.setType({
  1399. name: "ui-shehaolist",
  1400. // extends: 'radio',
  1401. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1402. defaultOptions: function (options) {
  1403. return {
  1404. templateOptions: {
  1405. refresh: function () {},
  1406. refreshDelay: 0,
  1407. },
  1408. };
  1409. },
  1410. controller: [
  1411. "$scope",
  1412. "$filter",
  1413. "ngTableParams",
  1414. function ($scope, $filter, ngTableParams) {
  1415. // var data = { "haodata": [], "shedata": [] };
  1416. var haodata = [];
  1417. var shedata = [];
  1418. if ($scope.model.consumables) {
  1419. if (angular.isArray($scope.model.consumables)) {
  1420. haodata = $scope.model.consumables;
  1421. } else {
  1422. haodata = JSON.parse($scope.model.consumables);
  1423. }
  1424. $scope.model.consumables = haodata;
  1425. angular.forEach(haodata, function (item, index) {
  1426. haodata[index].item = index + 1;
  1427. });
  1428. }
  1429. if ($scope.model.assets) {
  1430. if (angular.isArray($scope.model.assets)) {
  1431. shedata = $scope.model.assets;
  1432. } else {
  1433. shedata = JSON.parse($scope.model.assets);
  1434. }
  1435. $scope.model.assets = shedata;
  1436. angular.forEach(shedata, function (item, index) {
  1437. shedata[index].item = index + 1;
  1438. });
  1439. }
  1440. $scope.tableParamshao = new ngTableParams(
  1441. {
  1442. page: 1,
  1443. count: 5,
  1444. },
  1445. {
  1446. total: haodata.length,
  1447. getData: function ($defer, params) {
  1448. var orderedData = params.sorting()
  1449. ? $filter("orderBy")(haodata, params.orderBy())
  1450. : haodata;
  1451. $defer.resolve(
  1452. orderedData.slice(
  1453. (params.page() - 1) * params.count(),
  1454. params.page() * params.count()
  1455. )
  1456. );
  1457. },
  1458. }
  1459. );
  1460. $scope.tableParamsshe = new ngTableParams(
  1461. {
  1462. page: 1,
  1463. count: 5,
  1464. },
  1465. {
  1466. total: shedata.length,
  1467. getData: function ($defer, params) {
  1468. var orderedData = params.sorting()
  1469. ? $filter("orderBy")(shedata, params.orderBy())
  1470. : shedata;
  1471. $defer.resolve(
  1472. orderedData.slice(
  1473. (params.page() - 1) * params.count(),
  1474. params.page() * params.count()
  1475. )
  1476. );
  1477. },
  1478. }
  1479. );
  1480. $scope.editId = -1;
  1481. $scope.setEditId = function (pid) {
  1482. $scope.editId = pid;
  1483. };
  1484. if (
  1485. $scope.$parent.$parent.$parent.model.isAgree &&
  1486. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1487. ) {
  1488. $scope.isAgree = "同意";
  1489. } else if (
  1490. $scope.$parent.$parent.$parent.model.isAgree &&
  1491. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1492. ) {
  1493. $scope.isAgree = "同意";
  1494. } else if (
  1495. $scope.$parent.$parent.$parent.model.isAgree &&
  1496. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1497. ) {
  1498. $scope.isAgree = "返回修改";
  1499. }
  1500. },
  1501. ],
  1502. });
  1503. //关联资产出库
  1504. formlyConfigProvider.setType({
  1505. name: "ui-meansmodelselect",
  1506. extends: "input",
  1507. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1508. defaultOptions: function (options) {
  1509. return {
  1510. templateOptions: {},
  1511. };
  1512. },
  1513. controller: [
  1514. "$scope",
  1515. "$modal",
  1516. function ($scope, $modal) {
  1517. $scope.openModal = function (size, options, modal) {
  1518. var modalInstance = $modal.open({
  1519. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1520. controller: function (
  1521. $scope,
  1522. $rootScope,
  1523. $modalInstance,
  1524. items,
  1525. title,
  1526. Restangular,
  1527. APIService,
  1528. api_user_data,
  1529. i18nService,
  1530. api_wechatfile
  1531. ) {
  1532. $scope.langs = i18nService.getAllLangs();
  1533. $scope.lang = "zh-cn";
  1534. i18nService.setCurrentLang($scope.lang);
  1535. $scope.gridOptions = {};
  1536. $scope.gridOptions.data = "myData";
  1537. $scope.gridOptions.enableColumnResizing = true;
  1538. $scope.gridOptions.enableFiltering = false;
  1539. $scope.gridOptions.enableGridMenu = false;
  1540. $scope.gridOptions.showGridFooter = true;
  1541. $scope.gridOptions.showColumnFooter = false;
  1542. $scope.gridOptions.fastWatch = true;
  1543. $scope.gridOptions.useExternalFiltering = true;
  1544. $scope.gridOptions.useExternalPagination = true;
  1545. $scope.gridOptions.paginationPageSizes = [10];
  1546. $scope.gridOptions.paginationPageSize = 10;
  1547. $scope.gridOptions.multiSelect = false;
  1548. $scope.gridOptions.rowIdentity = function (row) {
  1549. return row.id;
  1550. };
  1551. $scope.gridOptions.getRowIdentity = function (row) {
  1552. return row.id;
  1553. };
  1554. // $scope.states = [{
  1555. // id: 0,
  1556. // name: '待批准'
  1557. // },
  1558. // {
  1559. // id: 1,
  1560. // name: '已驳回'
  1561. // },
  1562. // {
  1563. // id: 2,
  1564. // name: '待出库'
  1565. // },
  1566. // {
  1567. // id: 3,
  1568. // name: '信息更新'
  1569. // },
  1570. // {
  1571. // id: 4,
  1572. // name: '信息确认'
  1573. // },
  1574. // {
  1575. // id: 5,
  1576. // name: '已关闭'
  1577. // }
  1578. // ];
  1579. $scope.getStatesDictionary = function () {
  1580. var data = {
  1581. key: "applicationForm_status",
  1582. type: "list",
  1583. };
  1584. api_wechatfile.getDictionary(data).then(function (res) {
  1585. $scope.states = res;
  1586. });
  1587. };
  1588. $scope.getStatesDictionary();
  1589. $scope.type = [
  1590. {
  1591. id: 1,
  1592. name: "资产入库",
  1593. },
  1594. {
  1595. id: 2,
  1596. name: "资产归还",
  1597. },
  1598. {
  1599. id: 3,
  1600. name: "资产领用",
  1601. },
  1602. {
  1603. id: 4,
  1604. name: "资产更换",
  1605. },
  1606. ];
  1607. $scope.typedata = function (row) {
  1608. if (row.type == 0) {
  1609. return "资产入库";
  1610. } else if (row.type == 2) {
  1611. return "资产归还";
  1612. } else if (row.type == 1) {
  1613. return "资产领用";
  1614. } else if (row.type == 4) {
  1615. return "资产更换";
  1616. }
  1617. };
  1618. $scope.statedata = function (row) {
  1619. if (row.status == 0) {
  1620. return "待批准";
  1621. } else if (row.status == 1) {
  1622. return "已驳回";
  1623. } else if (row.status == 2) {
  1624. return "待出库";
  1625. } else if (row.status == 3) {
  1626. return "信息更新";
  1627. } else if (row.status == 4) {
  1628. return "信息确认";
  1629. } else if (row.status == 5) {
  1630. return "已关闭";
  1631. }
  1632. };
  1633. $scope.transferTime = function (time) {
  1634. return moment(time).format("YYYY-MM-DD HH:mm");
  1635. };
  1636. $scope.application = [
  1637. {
  1638. value: "serialNumbe",
  1639. name: "申请单编号",
  1640. },
  1641. // { value: "proposer", name: '申请人' },
  1642. {
  1643. value: "purpose",
  1644. name: "领用用途",
  1645. },
  1646. // { value: "cmdbsign", name: '设备编号' }
  1647. ];
  1648. $scope.parameters = null;
  1649. $scope.open = function ($event) {
  1650. $event.preventDefault();
  1651. $event.stopPropagation();
  1652. $scope.opened = !$scope.opened;
  1653. };
  1654. $scope.endOpen = function ($event) {
  1655. $event.preventDefault();
  1656. $event.stopPropagation();
  1657. $scope.startOpened = false;
  1658. $scope.endOpened = !$scope.endOpened;
  1659. };
  1660. $scope.startOpen = function ($event) {
  1661. $event.preventDefault();
  1662. $event.stopPropagation();
  1663. $scope.endOpened = false;
  1664. $scope.startOpened = !$scope.startOpened;
  1665. };
  1666. $scope.othcode = {};
  1667. $scope.searchkeys = {};
  1668. $scope.parameters = {};
  1669. $scope.memoryfilterData = {
  1670. assignee: $rootScope.user.id,
  1671. candidateGroups: $rootScope.user.group[0].id,
  1672. searchType: "todo",
  1673. idx: 0,
  1674. sum: 10,
  1675. };
  1676. $scope.clear = function () {
  1677. $scope.searchkeys = {};
  1678. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1679. // $scope.othcode = {};
  1680. $scope.parameters = {};
  1681. var fildata = {
  1682. assignee: $rootScope.user.id,
  1683. candidateGroups: $rootScope.user.group[0].id,
  1684. searchType: "todo",
  1685. idx: 0,
  1686. sum: 10,
  1687. };
  1688. // sessionStorage.removeItem("searchincident");
  1689. $scope.memoryfilterData = fildata;
  1690. $scope.loadData(fildata);
  1691. };
  1692. $scope.chiceIncident = function (parameters, item, stateid) {
  1693. var fildata = {
  1694. assignee: $rootScope.user.id,
  1695. candidateGroups: 1,
  1696. searchType: "todo",
  1697. idx: 0,
  1698. sum: 10,
  1699. };
  1700. if (item) {
  1701. fildata.applicationForm = {};
  1702. if (item.alltitle && item.alldata) {
  1703. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1704. }
  1705. if (item.linkProposer) {
  1706. fildata.applicationForm.linkProposer = item.linkProposer;
  1707. }
  1708. if (item.proposer) {
  1709. fildata.applicationForm.proposer = item.proposer;
  1710. }
  1711. if (item.status) {
  1712. fildata.applicationForm["status"] = {
  1713. id: item.status.id,
  1714. };
  1715. }
  1716. if (item.type) {
  1717. fildata.applicationForm["type"] = {
  1718. id: item.type.id,
  1719. };
  1720. }
  1721. }
  1722. $scope.gridOptions.paginationCurrentPage = 1;
  1723. if (
  1724. parameters &&
  1725. parameters.paramDateFrom &&
  1726. parameters.paramDateTo
  1727. ) {
  1728. angular.extend(fildata, {
  1729. idx: 0,
  1730. sum: $scope.gridOptions.paginationPageSize,
  1731. });
  1732. angular.extend(fildata.applicationForm, {
  1733. startDate: moment(parameters.paramDateFrom).format(
  1734. "YYYY-MM-DD HH:mm:ss"
  1735. ),
  1736. endDate: moment(parameters.paramDateTo).format(
  1737. "YYYY-MM-DD 23:59:59"
  1738. ),
  1739. });
  1740. }
  1741. var transitiondata = angular.copy(item);
  1742. // angular.extend(fildata.applicationForm, transitiondata)
  1743. $scope.loadData(fildata);
  1744. };
  1745. $scope.key = {};
  1746. api_user_data
  1747. .fetchDataList("user", {
  1748. idx: 0,
  1749. sum: 1000,
  1750. flag: -1,
  1751. })
  1752. .then(function (data) {
  1753. $scope.handlingPersonnelUser = data.list;
  1754. });
  1755. $scope.gridOptions.columnDefs = items.columnDefs();
  1756. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1757. $scope.gridApi = gridApi;
  1758. gridApi.pagination.on.paginationChanged(
  1759. $scope,
  1760. function (newPage, pageSize) {
  1761. // console.log(newPage);
  1762. // console.log(pageSize);
  1763. $scope.loadData({
  1764. idx: newPage - 1,
  1765. sum: pageSize,
  1766. });
  1767. }
  1768. );
  1769. gridApi.core.on.filterChanged($scope, function () {});
  1770. gridApi.selection.on.rowSelectionChanged(
  1771. $scope,
  1772. function (data) {
  1773. $scope.selected.item = data.entity;
  1774. //console.log(data);
  1775. }
  1776. );
  1777. };
  1778. $scope.loadData = function (filterData) {
  1779. items.fetchItems(filterData, APIService).then(function (data) {
  1780. var myData = Restangular.stripRestangular(data);
  1781. $scope.gridOptions.totalItems = myData.totalNum;
  1782. $scope.myData = myData.list;
  1783. for (var i = 0; i < $scope.myData.length; i++) {
  1784. $scope.myData[i]["item"] =
  1785. i + 1 + filterData.idx * filterData.sum;
  1786. }
  1787. });
  1788. };
  1789. $scope.title = title;
  1790. $scope.loadData({
  1791. idx: 0,
  1792. sum: 10,
  1793. assignee: $rootScope.user.id,
  1794. candidateGroups: $rootScope.user.group[0].id,
  1795. searchType: "todo",
  1796. });
  1797. $scope.selected = {
  1798. item: {},
  1799. };
  1800. $scope.ok = function () {
  1801. //console.log($scope.selected.item);
  1802. $modalInstance.close($scope.selected.item);
  1803. };
  1804. $scope.cancel = function () {
  1805. $modalInstance.dismiss("cancel");
  1806. };
  1807. },
  1808. size: "lg",
  1809. resolve: {
  1810. items: function () {
  1811. return {
  1812. fetchItems: function (filterData, APIService) {
  1813. filterData = filterData || {};
  1814. // if(!filterData.idx){
  1815. if (
  1816. angular.isDefined(filterData.idx) &&
  1817. filterData.idx == null
  1818. ) {
  1819. filterData = {
  1820. idx: 0,
  1821. sum: 10,
  1822. };
  1823. }
  1824. return options.templateOptions.fetchItems(
  1825. filterData,
  1826. APIService,
  1827. options
  1828. );
  1829. },
  1830. columnDefs: function () {
  1831. return options.templateOptions.columnDefs;
  1832. },
  1833. };
  1834. },
  1835. title: function () {
  1836. return options.templateOptions.modalTitle;
  1837. },
  1838. Restangular: function () {
  1839. return options.templateOptions.Restangular;
  1840. },
  1841. APIService: function () {
  1842. return options.templateOptions.ApiService;
  1843. },
  1844. },
  1845. });
  1846. modalInstance.result.then(
  1847. function (selectedItem) {
  1848. var selectitem = {
  1849. title: selectedItem.title,
  1850. description: selectedItem.description,
  1851. };
  1852. if (options.key == "chuku") {
  1853. if (selectedItem.assets) {
  1854. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1855. selectedItem.assets;
  1856. }
  1857. if (selectedItem.consumables) {
  1858. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1859. selectedItem.consumables;
  1860. }
  1861. angular.extend(
  1862. $scope.$parent.$parent.$parent.model,
  1863. selectitem
  1864. );
  1865. options.value(selectedItem);
  1866. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1867. } else {
  1868. angular.extend(options.model, selectitem);
  1869. options.value(selectedItem);
  1870. }
  1871. },
  1872. function () {
  1873. //console.log('Modal dismissed at: ' + new Date());
  1874. }
  1875. );
  1876. };
  1877. },
  1878. ],
  1879. });
  1880. //文本框
  1881. formlyConfigProvider.setType({
  1882. name: "ui-textcmdb",
  1883. extends: "",
  1884. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1885. defaultOptions: function (options) {
  1886. return {
  1887. templateOptions: {
  1888. transform: function (model, value) {
  1889. return value;
  1890. },
  1891. },
  1892. validation: {
  1893. messages: {
  1894. maxlength: function (viewValue, modelValue, scope) {
  1895. if (viewValue != null) {
  1896. if (viewValue.length > scope.to.maxlength) {
  1897. return (
  1898. scope.to.label +
  1899. " 字数(" +
  1900. viewValue.length +
  1901. ")超限(" +
  1902. scope.to.maxlength +
  1903. ")"
  1904. );
  1905. } else {
  1906. return "";
  1907. }
  1908. }
  1909. },
  1910. },
  1911. },
  1912. };
  1913. },
  1914. controller: [
  1915. "$scope",
  1916. function ($scope) {
  1917. var value = $scope.model[$scope.options.key];
  1918. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1919. $scope.model[$scope.options.key] =
  1920. $scope.options.templateOptions.transform(
  1921. $scope.originalModel,
  1922. value
  1923. );
  1924. }
  1925. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1926. $scope.options.templateOptions.felditem($scope);
  1927. }
  1928. },
  1929. ],
  1930. });
  1931. //设备组件
  1932. formlyConfigProvider.setType({
  1933. name: "ui-applist",
  1934. extends: "radio",
  1935. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1936. defaultOptions: function (options) {
  1937. return {
  1938. templateOptions: {
  1939. refresh: function () {},
  1940. refreshDelay: 0,
  1941. },
  1942. };
  1943. },
  1944. controller: [
  1945. "$scope",
  1946. "$filter",
  1947. "ngTableParams",
  1948. function ($scope, $filter, ngTableParams) {
  1949. var data = [];
  1950. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1951. // data = JSON.parse($scope.model.consumables);
  1952. if (angular.isArray($scope.model.consumables)) {
  1953. data = $scope.model.consumables;
  1954. } else {
  1955. data = JSON.parse($scope.model.consumables);
  1956. }
  1957. $scope.model.consumables = data;
  1958. angular.forEach(data, function (item, index) {
  1959. data[index].item = index + 1;
  1960. });
  1961. }
  1962. if ($scope.model.assets && $scope.options.key == "assets") {
  1963. if (angular.isArray($scope.model.assets)) {
  1964. data = $scope.model.assets;
  1965. } else {
  1966. data = JSON.parse($scope.model.assets);
  1967. }
  1968. // data = JSON.parse($scope.model.assets);
  1969. $scope.model.assets = data;
  1970. angular.forEach(data, function (item, index) {
  1971. data[index].item = index + 1;
  1972. });
  1973. }
  1974. $scope.tableParams = new ngTableParams(
  1975. {
  1976. page: 1,
  1977. count: 5,
  1978. },
  1979. {
  1980. total: data.length,
  1981. getData: function ($defer, params) {
  1982. var orderedData = params.sorting()
  1983. ? $filter("orderBy")(data, params.orderBy())
  1984. : data;
  1985. $defer.resolve(
  1986. orderedData.slice(
  1987. (params.page() - 1) * params.count(),
  1988. params.page() * params.count()
  1989. )
  1990. );
  1991. },
  1992. }
  1993. );
  1994. $scope.editId = -1;
  1995. $scope.setEditId = function (pid) {
  1996. $scope.editId = pid;
  1997. };
  1998. },
  1999. ],
  2000. });
  2001. //list组件
  2002. formlyConfigProvider.setType({
  2003. name: "ui-gudinglist",
  2004. extends: "radio",
  2005. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2006. defaultOptions: function (options) {
  2007. return {
  2008. templateOptions: {
  2009. refresh: function () {},
  2010. refreshDelay: 0,
  2011. },
  2012. };
  2013. },
  2014. controller: [
  2015. "$scope",
  2016. "$filter",
  2017. "ngTableParams",
  2018. function ($scope, $filter, ngTableParams) {
  2019. var data = [];
  2020. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2021. // data = JSON.parse($scope.model.consumables);
  2022. if (angular.isArray($scope.model.consumables)) {
  2023. data = $scope.model.consumables;
  2024. } else {
  2025. data = JSON.parse($scope.model.consumables);
  2026. }
  2027. $scope.model.consumables = data;
  2028. angular.forEach(data, function (item, index) {
  2029. data[index].item = index + 1;
  2030. });
  2031. }
  2032. if ($scope.model.assets && $scope.options.key == "assets") {
  2033. if (angular.isArray($scope.model.assets)) {
  2034. data = $scope.model.assets;
  2035. } else {
  2036. data = JSON.parse($scope.model.assets);
  2037. }
  2038. // data = JSON.parse($scope.model.assets);
  2039. $scope.model.assets = data;
  2040. angular.forEach(data, function (item, index) {
  2041. data[index].item = index + 1;
  2042. });
  2043. }
  2044. $scope.tableParams = new ngTableParams(
  2045. {
  2046. page: 1,
  2047. count: 5,
  2048. },
  2049. {
  2050. total: data.length,
  2051. getData: function ($defer, params) {
  2052. var orderedData = params.sorting()
  2053. ? $filter("orderBy")(data, params.orderBy())
  2054. : data;
  2055. $defer.resolve(
  2056. orderedData.slice(
  2057. (params.page() - 1) * params.count(),
  2058. params.page() * params.count()
  2059. )
  2060. );
  2061. },
  2062. }
  2063. );
  2064. $scope.editId = -1;
  2065. $scope.setEditId = function (pid) {
  2066. $scope.editId = pid;
  2067. };
  2068. },
  2069. ],
  2070. });
  2071. //other list tab组件
  2072. formlyConfigProvider.setType({
  2073. name: "ui-otherlisttab",
  2074. extends: "",
  2075. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2076. defaultOptions: function (options) {
  2077. return {
  2078. templateOptions: {
  2079. refresh: function () {},
  2080. refreshDelay: 0,
  2081. },
  2082. };
  2083. },
  2084. controller: [
  2085. "$scope",
  2086. "$filter",
  2087. "ngTableParams",
  2088. function ($scope, $filter, ngTableParams) {},
  2089. ],
  2090. });
  2091. //审核查看组件
  2092. formlyConfigProvider.setType({
  2093. name: "ui-aprovelist",
  2094. extends: "",
  2095. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2096. defaultOptions: function (options) {
  2097. return {
  2098. templateOptions: {
  2099. refresh: function () {},
  2100. refreshDelay: 0,
  2101. },
  2102. };
  2103. },
  2104. controller: [
  2105. "$scope",
  2106. "$filter",
  2107. "ngTableParams",
  2108. function ($scope, $filter, ngTableParams) {
  2109. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2110. $scope.isAgree = "同意";
  2111. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2112. $scope.isAgree = "同意";
  2113. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2114. $scope.isAgree = "返回修改";
  2115. }
  2116. },
  2117. ],
  2118. });
  2119. //other list组件
  2120. formlyConfigProvider.setType({
  2121. name: "ui-otherlist",
  2122. extends: "",
  2123. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2124. defaultOptions: function (options) {
  2125. return {
  2126. templateOptions: {
  2127. refresh: function () {},
  2128. refreshDelay: 0,
  2129. },
  2130. };
  2131. },
  2132. controller: [
  2133. "$rootScope",
  2134. "$scope",
  2135. "$parse",
  2136. "$injector",
  2137. "$http",
  2138. "$q",
  2139. "$state",
  2140. "$stateParams",
  2141. "$modal",
  2142. "$timeout",
  2143. "$interval",
  2144. "i18nService",
  2145. "SweetAlert",
  2146. "FileUploader",
  2147. "Restangular",
  2148. "UserRestangular",
  2149. "BpmRestangular",
  2150. "api_configure_form",
  2151. "api_configure_data",
  2152. "api_bpm_domain",
  2153. "api_bpm_data",
  2154. "api_user_data",
  2155. "api_cmdb",
  2156. "api_sysinfo",
  2157. function (
  2158. $rootScope,
  2159. $scope,
  2160. $parse,
  2161. $injector,
  2162. $http,
  2163. $q,
  2164. $state,
  2165. $stateParams,
  2166. $modal,
  2167. $timeout,
  2168. $interval,
  2169. i18nService,
  2170. SweetAlert,
  2171. FileUploader,
  2172. Restangular,
  2173. UserRestangular,
  2174. BpmRestangular,
  2175. api_configure_form,
  2176. api_configure_data,
  2177. api_bpm_domain,
  2178. api_bpm_data,
  2179. api_user_data,
  2180. api_cmdb,
  2181. api_sysinfo
  2182. ) {
  2183. console.log("哈哈");
  2184. console.log($scope);
  2185. $scope.langs = i18nService.getAllLangs();
  2186. $scope.lang = "zh-cn";
  2187. i18nService.setCurrentLang($scope.lang);
  2188. var vm = this;
  2189. vm.options = {};
  2190. vm.exampleTitle = ["expressionProperties", "model property"];
  2191. vm.fields = [];
  2192. vm.models = {};
  2193. // vm.models["loginUser"] = $rootScope.user;
  2194. var that = $injector;
  2195. var parse = $parse;
  2196. var formKey = "";
  2197. var pdKey = "";
  2198. if (
  2199. angular.isDefined($state.current.pdKey) &&
  2200. $state.current.pdKey != ""
  2201. ) {
  2202. pdKey = $state.current.pdKey;
  2203. //console.log("pdKey::"+$state.current.pdKey);
  2204. }
  2205. if (
  2206. angular.isDefined($stateParams.formKey) &&
  2207. $stateParams.formKey != ""
  2208. ) {
  2209. formKey = $stateParams.formKey;
  2210. //console.log("formKey::"+$stateParams.formKey);
  2211. }
  2212. //用户测试数据,后续从header的auth中获取
  2213. var userId = 2;
  2214. userId = $rootScope.user.id;
  2215. //==============处理表单设计数据 开始====================
  2216. //处理组件加载后台数据选项的方法
  2217. function refreshSelectOptions(searchVal, field) {
  2218. if (field.templateOptions.optionsUrl) {
  2219. var process = BpmRestangular.all("");
  2220. if (field.templateOptions.ApiService) {
  2221. process = UserRestangular.all("");
  2222. }
  2223. process
  2224. .customPOST(
  2225. {
  2226. idx: 0,
  2227. sum: 1000,
  2228. },
  2229. field.templateOptions.optionsUrl
  2230. )
  2231. .then(function (result) {
  2232. if (!field.templateOptions.options) {
  2233. field.templateOptions.options = [];
  2234. }
  2235. if (field.templateOptions.optionsDataKey) {
  2236. field.templateOptions.options =
  2237. result[field.templateOptions.optionsDataKey];
  2238. } else {
  2239. field.templateOptions.options = result;
  2240. }
  2241. });
  2242. }
  2243. }
  2244. function decodeVMTabForm(model, tabs) {
  2245. var result = {
  2246. model: {},
  2247. tabs: [],
  2248. };
  2249. var mdata = angular.fromJson(model);
  2250. angular.extend(result.model, mdata);
  2251. angular.forEach(tabs, function (tab) {
  2252. tab.form.model = vm.models;
  2253. angular.forEach(tab.form.fields, function (field) {
  2254. if (field.key == "") {
  2255. delete field.key;
  2256. }
  2257. field.type = "ui-otherlisttab";
  2258. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2259. var extObj = angular.fromJson(field.extjson);
  2260. angular.extend(field.templateOptions, extObj.templateOptions);
  2261. delete extObj.templateOptions;
  2262. for (var prop in extObj) {
  2263. if (new RegExp("Expression").test(prop)) {
  2264. //var obj = $scope.$eval(extObj[prop]);
  2265. //extObj[prop] = $scope.$eval(extObj[prop]);
  2266. if (extObj[prop] != null) {
  2267. if (new RegExp("function").test(extObj[prop])) {
  2268. var propValue = eval(extObj[prop]);
  2269. extObj[prop] = propValue;
  2270. } else {
  2271. //console.log(extObj[prop]);
  2272. var obj = $scope.$eval(extObj[prop]);
  2273. extObj[prop] = obj;
  2274. //console.log(obj);
  2275. }
  2276. }
  2277. } else if (new RegExp("expressionProperties").test(prop)) {
  2278. for (var p in extObj[prop]) {
  2279. if (new RegExp("function").test(extObj[prop][p])) {
  2280. var propValue = eval(extObj[prop][p]);
  2281. extObj[prop][p] = propValue;
  2282. } else {
  2283. //if(p.indexOf("'")>=0){
  2284. // var obj = $scope.$eval(extObj[prop][p]);
  2285. // extObj[prop][$scope.$eval(p)]=obj;
  2286. //}
  2287. }
  2288. }
  2289. } else if ("watcher" == prop) {
  2290. if (angular.isArray(extObj[prop])) {
  2291. angular.forEach(extObj[prop], function (item, index) {
  2292. for (var p in item) {
  2293. if (new RegExp("function").test(item[p])) {
  2294. var propValue = eval(item[p]);
  2295. extObj[prop][index][p] = propValue;
  2296. }
  2297. }
  2298. });
  2299. } else if (angular.isObject(extObj[prop])) {
  2300. for (var p in extObj[prop]) {
  2301. if (new RegExp("function").test(extObj[prop][p])) {
  2302. var propValue = eval(extObj[prop][p]);
  2303. extObj[prop][p] = propValue;
  2304. }
  2305. }
  2306. }
  2307. }
  2308. }
  2309. angular.extend(field, extObj);
  2310. delete field.extjson;
  2311. }
  2312. if (field.extjson == "") {
  2313. delete field.extjson;
  2314. }
  2315. if (angular.isDefined(field.templateOptions)) {
  2316. var templateOs = field.templateOptions;
  2317. for (var property in templateOs) {
  2318. //console.log(property);
  2319. if (
  2320. angular.isString(templateOs[property]) &&
  2321. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2322. ) {
  2323. if (new RegExp("function").test(templateOs[property])) {
  2324. var propValue = eval(templateOs[property]);
  2325. field.templateOptions[property] = propValue;
  2326. } else {
  2327. if (that.has(templateOs[property])) {
  2328. field.templateOptions[property] = that.get(
  2329. templateOs[property]
  2330. );
  2331. } else {
  2332. field.templateOptions[property] = templateOs[property];
  2333. }
  2334. }
  2335. } else if (templateOs[property] == null) {
  2336. //delete field.templateOptions[property];
  2337. } else {
  2338. }
  2339. }
  2340. }
  2341. if (
  2342. angular.isDefined(field.templateOptions) &&
  2343. angular.isDefined(field.templateOptions.extjson)
  2344. ) {
  2345. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2346. angular.extend(field.templateOptions, extObj);
  2347. delete field.templateOptions.extjson;
  2348. }
  2349. //...
  2350. if (field.templateOptions) {
  2351. //处理远程获取数据控件方法调用
  2352. if (field.templateOptions.optionsUrl) {
  2353. field.templateOptions.refresh = refreshSelectOptions;
  2354. }
  2355. //处理嵌套属性数据绑定/
  2356. if (field.templateOptions.pkey) {
  2357. var pmodel,
  2358. i = 0;
  2359. angular.forEach(
  2360. field.templateOptions.pkey.split("."),
  2361. function (p) {
  2362. if (i == 0) {
  2363. if (result.model[p] == null) {
  2364. result.model[p] = {};
  2365. }
  2366. pmodel = result.model[p];
  2367. i++;
  2368. } else {
  2369. if (pmodel[p] == null) {
  2370. pmodel[p] = {};
  2371. }
  2372. pmodel = pmodel[p];
  2373. }
  2374. }
  2375. );
  2376. if (pmodel != null) {
  2377. field.model = pmodel;
  2378. if (pmodel[field.key] == null) {
  2379. pmodel[field.key] = null;
  2380. }
  2381. }
  2382. } else {
  2383. if (result.model[field.key] == null) {
  2384. result.model[field.key] = null;
  2385. }
  2386. }
  2387. //处理弹出框组件初始化
  2388. if (field.type == "ui-input-selectmodal") {
  2389. field.templateOptions.modal = $modal;
  2390. //field.templateOptions.Restangular = Restangular;
  2391. } else if (field.type == "ui-userselect") {
  2392. field.templateOptions.modal = $modal;
  2393. //field.templateOptions.Restangular = Restangular;
  2394. } else if (field.type == "ui-multiuserselect") {
  2395. field.templateOptions.modal = $modal;
  2396. } else if (field.type == "ui-modelselect") {
  2397. field.templateOptions.modal = $modal;
  2398. //field.templateOptions.Restangular = Restangular;
  2399. } else if (field.type == "ui-cmdbuplode") {
  2400. $scope.fileUploader = field.templateOptions.fileUploader =
  2401. new FileUploader({
  2402. url: "/uploader",
  2403. queueLimit: 1, //文件个数
  2404. autoUpload: true,
  2405. });
  2406. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2407. } else if (field.type == "ui-dropfile") {
  2408. field.templateOptions.fileUploader = new FileUploader({
  2409. url: "/uploader",
  2410. });
  2411. field.templateOptions.taskId = $stateParams.taskId;
  2412. field.templateOptions.processInstanceId =
  2413. $stateParams.processInstanceId;
  2414. field.templateOptions.userId = $rootScope.user.id;
  2415. //field.ApiService=api_bpm_domain;
  2416. } else if (field.type == "ui-dropfiletable") {
  2417. if (field.templateOptions.processInstanceId) {
  2418. } else {
  2419. field.templateOptions.processInstanceId =
  2420. $stateParams.processInstanceId;
  2421. }
  2422. } else if (field.type == "ui-repeatSection") {
  2423. var repeatForm = {
  2424. model: {},
  2425. fields: field.templateOptions.fields,
  2426. };
  2427. repeatForm.model[field.key] = [];
  2428. decodeVMTabForm(repeatForm);
  2429. }
  2430. }
  2431. // console.log(field);
  2432. //field
  2433. //result.fields.push(field);
  2434. });
  2435. });
  2436. vm.originalTabs = angular.copy(vm.form);
  2437. }
  2438. //======================处理表单设计数据 结束========================
  2439. $scope.ldloading = {};
  2440. function filter(obj) {
  2441. angular.forEach(obj, function (key, value) {
  2442. if (value === "" || value === null) {
  2443. delete obj[key];
  2444. } else if (
  2445. Object.prototype.toString.call(value) === "[object Object]"
  2446. ) {
  2447. filter(value);
  2448. } else if (angular.isArray(value)) {
  2449. angular.forEach(value, function (item) {
  2450. filter(item);
  2451. });
  2452. }
  2453. });
  2454. }
  2455. function invokeOnAllFormOptions(fn) {
  2456. angular.forEach(vm.tabs, function (tab) {
  2457. if (tab.form.options && tab.form.options[fn]) {
  2458. tab.form.options[fn]();
  2459. }
  2460. });
  2461. }
  2462. function encodeCIData(data, ciId) {
  2463. /*
  2464. create/update state:未审核
  2465. create createtime:系统时间
  2466. create/update lastupdatetime : 系统时间
  2467. label:ci分类
  2468. */
  2469. if (ciId) {
  2470. var baseprop = [
  2471. "uuid",
  2472. "name",
  2473. "type",
  2474. "label",
  2475. "status",
  2476. "createtime",
  2477. "lastupdatetime",
  2478. "props",
  2479. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2480. var extraprop = "props";
  2481. data[extraprop] = {};
  2482. for (var key in data) {
  2483. console.log(data[key]);
  2484. if (_.indexOf(baseprop, key) >= 0) {
  2485. continue;
  2486. } else {
  2487. data[extraprop][key] = data[key];
  2488. delete data[key];
  2489. }
  2490. }
  2491. if ($rootScope.user) {
  2492. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2493. data[extraprop]["configperson"] = $rootScope.user.name;
  2494. var isCMAdminFlag = false;
  2495. angular.forEach($rootScope.user.role, function (roleItem) {
  2496. if (roleItem.rolecode == "cmdb charge") {
  2497. isCMAdminFlag = true;
  2498. }
  2499. });
  2500. if (!isCMAdminFlag) {
  2501. data[extraprop]["state"] = "1";
  2502. }
  2503. }
  2504. if (data.props.id) {
  2505. } else {
  2506. data.label = ciId;
  2507. }
  2508. return data;
  2509. }
  2510. return undefined;
  2511. }
  2512. function decodeCIModel(data) {
  2513. var extraprop = "props";
  2514. if (data[extraprop]) {
  2515. for (var key in data[extraprop]) {
  2516. data[key] = data[extraprop][key];
  2517. }
  2518. delete data[extraprop];
  2519. }
  2520. data["iscmadmin"] = false;
  2521. angular.forEach($rootScope.user.role, function (roleItem) {
  2522. if (roleItem.rolecode == "cmdb charge") {
  2523. data["iscmadmin"] = true;
  2524. }
  2525. });
  2526. return data;
  2527. }
  2528. function formValid() {
  2529. angular.forEach(vm.tabs, function (item) {
  2530. //item.
  2531. });
  2532. }
  2533. $scope.vm = vm;
  2534. $scope.refreshcmdbform = function (item) {
  2535. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2536. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2537. var myData = Restangular.stripRestangular(data);
  2538. $scope.propTypeOptions = myData;
  2539. $scope.templateProps = myData;
  2540. $scope.vm.tabs = myData;
  2541. if ($scope.model.assets) {
  2542. vm.models = JSON.parse($scope.model.assets);
  2543. }
  2544. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2545. if (vm.models.vtvmvtm_kaiji) {
  2546. vm.models.vtvmvtm_kaiji = "是";
  2547. } else {
  2548. vm.models.vtvmvtm_kaiji = "否";
  2549. }
  2550. }
  2551. decodeVMTabForm(vm.models, vm.tabs);
  2552. });
  2553. // }
  2554. };
  2555. var cifilterClassic = {};
  2556. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2557. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2558. $scope.refreshcmdbform(
  2559. $scope.$parent.$parent.$parent.model.cifilterClassic
  2560. );
  2561. // } else {}
  2562. },
  2563. ],
  2564. });
  2565. //固定资产下载
  2566. formlyConfigProvider.setType({
  2567. name: "ui-dropupload",
  2568. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2569. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2570. defaultOptions: function (options) {
  2571. return {
  2572. templateOptions: {
  2573. view: function (APIService, contentId) {
  2574. return APIService.downloadAttachment(contentId);
  2575. },
  2576. },
  2577. };
  2578. },
  2579. controller: [
  2580. "$scope",
  2581. "$rootScope",
  2582. "Restangular",
  2583. function ($scope, $rootScope, Restangular) {
  2584. if (angular.isUndefined($scope.form.dropState)) {
  2585. $scope.form.dropState = false;
  2586. }
  2587. var to = $scope.options.templateOptions;
  2588. var bindId = $scope.model[to.bindType].processInstanceId;
  2589. //获取附件列表
  2590. $scope.listAttachmen = function () {
  2591. to.ApiService.listAttachment(
  2592. to.listAttachmentUrl,
  2593. to.bindType,
  2594. bindId
  2595. ).then(function (result) {
  2596. var myData = Restangular.stripRestangular(result);
  2597. // $scope.listAttachmens = myData;
  2598. $scope.attachments = myData.data;
  2599. });
  2600. };
  2601. $scope.listAttachmen();
  2602. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2603. // $scope.listAttachmen();
  2604. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2605. // $scope.listAttachmen();
  2606. // }
  2607. //附件下载
  2608. $scope.download = function (token, filename) {
  2609. var downUrl = to.ApiService.downloadAttachment(
  2610. to.downUrl,
  2611. token
  2612. ).getRequestedUrl();
  2613. var a = document.createElement("a");
  2614. a.href = downUrl;
  2615. a.target = "_blank";
  2616. a.download = filename;
  2617. document.body.appendChild(a);
  2618. a.click();
  2619. };
  2620. //附件预览
  2621. $scope.view = function (id, previewUrl) {
  2622. if (previewUrl) {
  2623. window.open(previewUrl);
  2624. }
  2625. };
  2626. },
  2627. ],
  2628. });
  2629. formlyConfigProvider.setType({
  2630. name: "ui-form",
  2631. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2632. defaultOptions: function (options) {
  2633. return {
  2634. templateOptions: {
  2635. // link: function() {}
  2636. },
  2637. };
  2638. },
  2639. controller: [
  2640. "$rootScope",
  2641. "$scope",
  2642. "$parse",
  2643. "$injector",
  2644. "$http",
  2645. "$q",
  2646. "$state",
  2647. "$stateParams",
  2648. "$modal",
  2649. "$timeout",
  2650. "$interval",
  2651. "i18nService",
  2652. "SweetAlert",
  2653. "FileUploader",
  2654. "Restangular",
  2655. "UserRestangular",
  2656. "BpmRestangular",
  2657. "api_configure_form",
  2658. "api_configure_data",
  2659. "api_bpm_domain",
  2660. "api_bpm_data",
  2661. "api_user_data",
  2662. "api_cmdb",
  2663. "api_sysinfo",
  2664. function (
  2665. $rootScope,
  2666. $scope,
  2667. $parse,
  2668. $injector,
  2669. $http,
  2670. $q,
  2671. $state,
  2672. $stateParams,
  2673. $modal,
  2674. $timeout,
  2675. $interval,
  2676. i18nService,
  2677. SweetAlert,
  2678. FileUploader,
  2679. Restangular,
  2680. UserRestangular,
  2681. BpmRestangular,
  2682. api_configure_form,
  2683. api_configure_data,
  2684. api_bpm_domain,
  2685. api_bpm_data,
  2686. api_user_data,
  2687. api_cmdb,
  2688. api_sysinfo
  2689. ) {
  2690. $scope.langs = i18nService.getAllLangs();
  2691. $scope.lang = "zh-cn";
  2692. i18nService.setCurrentLang($scope.lang);
  2693. var vm = this;
  2694. vm.options = {};
  2695. vm.exampleTitle = ["expressionProperties", "model property"];
  2696. vm.fields = [];
  2697. vm.models = {};
  2698. // vm.models["loginUser"] = $rootScope.user;
  2699. var that = $injector;
  2700. var parse = $parse;
  2701. var formKey = "";
  2702. var pdKey = "";
  2703. if (
  2704. angular.isDefined($state.current.pdKey) &&
  2705. $state.current.pdKey != ""
  2706. ) {
  2707. pdKey = $state.current.pdKey;
  2708. //console.log("pdKey::"+$state.current.pdKey);
  2709. }
  2710. if (
  2711. angular.isDefined($stateParams.formKey) &&
  2712. $stateParams.formKey != ""
  2713. ) {
  2714. formKey = $stateParams.formKey;
  2715. //console.log("formKey::"+$stateParams.formKey);
  2716. }
  2717. //用户测试数据,后续从header的auth中获取
  2718. var userId = 2;
  2719. userId = $rootScope.user.id;
  2720. //==============处理表单设计数据 开始====================
  2721. //处理组件加载后台数据选项的方法
  2722. function refreshSelectOptions(searchVal, field) {
  2723. if (field.templateOptions.optionsUrl) {
  2724. var process = BpmRestangular.all("");
  2725. if (field.templateOptions.ApiService) {
  2726. process = UserRestangular.all("");
  2727. }
  2728. process
  2729. .customPOST(
  2730. {
  2731. idx: 0,
  2732. sum: 1000,
  2733. },
  2734. field.templateOptions.optionsUrl
  2735. )
  2736. .then(function (result) {
  2737. if (!field.templateOptions.options) {
  2738. field.templateOptions.options = [];
  2739. }
  2740. if (field.templateOptions.optionsDataKey) {
  2741. field.templateOptions.options =
  2742. result[field.templateOptions.optionsDataKey];
  2743. } else {
  2744. field.templateOptions.options = result;
  2745. }
  2746. });
  2747. }
  2748. }
  2749. function decodeVMTabForm(model, tabs) {
  2750. var result = {
  2751. model: {},
  2752. tabs: [],
  2753. };
  2754. var mdata = angular.fromJson(model);
  2755. angular.extend(result.model, mdata);
  2756. angular.forEach(tabs, function (tab) {
  2757. tab.form.model = vm.models;
  2758. angular.forEach(tab.form.fields, function (field) {
  2759. if (field.key == "") {
  2760. delete field.key;
  2761. }
  2762. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2763. var extObj = angular.fromJson(field.extjson);
  2764. angular.extend(field.templateOptions, extObj.templateOptions);
  2765. delete extObj.templateOptions;
  2766. for (var prop in extObj) {
  2767. if (new RegExp("Expression").test(prop)) {
  2768. //var obj = $scope.$eval(extObj[prop]);
  2769. //extObj[prop] = $scope.$eval(extObj[prop]);
  2770. if (extObj[prop] != null) {
  2771. if (new RegExp("function").test(extObj[prop])) {
  2772. var propValue = eval(extObj[prop]);
  2773. extObj[prop] = propValue;
  2774. } else {
  2775. //console.log(extObj[prop]);
  2776. var obj = $scope.$eval(extObj[prop]);
  2777. extObj[prop] = obj;
  2778. //console.log(obj);
  2779. }
  2780. }
  2781. } else if (new RegExp("expressionProperties").test(prop)) {
  2782. for (var p in extObj[prop]) {
  2783. if (new RegExp("function").test(extObj[prop][p])) {
  2784. var propValue = eval(extObj[prop][p]);
  2785. extObj[prop][p] = propValue;
  2786. } else {
  2787. //if(p.indexOf("'")>=0){
  2788. // var obj = $scope.$eval(extObj[prop][p]);
  2789. // extObj[prop][$scope.$eval(p)]=obj;
  2790. //}
  2791. }
  2792. }
  2793. } else if ("watcher" == prop) {
  2794. if (angular.isArray(extObj[prop])) {
  2795. angular.forEach(extObj[prop], function (item, index) {
  2796. for (var p in item) {
  2797. if (new RegExp("function").test(item[p])) {
  2798. var propValue = eval(item[p]);
  2799. extObj[prop][index][p] = propValue;
  2800. }
  2801. }
  2802. });
  2803. } else if (angular.isObject(extObj[prop])) {
  2804. for (var p in extObj[prop]) {
  2805. if (new RegExp("function").test(extObj[prop][p])) {
  2806. var propValue = eval(extObj[prop][p]);
  2807. extObj[prop][p] = propValue;
  2808. }
  2809. }
  2810. }
  2811. }
  2812. }
  2813. angular.extend(field, extObj);
  2814. delete field.extjson;
  2815. }
  2816. if (field.extjson == "") {
  2817. delete field.extjson;
  2818. }
  2819. if (angular.isDefined(field.templateOptions)) {
  2820. var templateOs = field.templateOptions;
  2821. for (var property in templateOs) {
  2822. //console.log(property);
  2823. if (
  2824. angular.isString(templateOs[property]) &&
  2825. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2826. ) {
  2827. if (new RegExp("function").test(templateOs[property])) {
  2828. var propValue = eval(templateOs[property]);
  2829. field.templateOptions[property] = propValue;
  2830. } else {
  2831. if (that.has(templateOs[property])) {
  2832. field.templateOptions[property] = that.get(
  2833. templateOs[property]
  2834. );
  2835. } else {
  2836. field.templateOptions[property] = templateOs[property];
  2837. }
  2838. }
  2839. } else if (templateOs[property] == null) {
  2840. //delete field.templateOptions[property];
  2841. } else {
  2842. }
  2843. }
  2844. }
  2845. if (
  2846. angular.isDefined(field.templateOptions) &&
  2847. angular.isDefined(field.templateOptions.extjson)
  2848. ) {
  2849. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2850. angular.extend(field.templateOptions, extObj);
  2851. delete field.templateOptions.extjson;
  2852. }
  2853. //...
  2854. if (field.templateOptions) {
  2855. //处理远程获取数据控件方法调用
  2856. if (field.templateOptions.optionsUrl) {
  2857. field.templateOptions.refresh = refreshSelectOptions;
  2858. }
  2859. //处理嵌套属性数据绑定/
  2860. if (field.templateOptions.pkey) {
  2861. var pmodel,
  2862. i = 0;
  2863. angular.forEach(
  2864. field.templateOptions.pkey.split("."),
  2865. function (p) {
  2866. if (i == 0) {
  2867. if (result.model[p] == null) {
  2868. result.model[p] = {};
  2869. }
  2870. pmodel = result.model[p];
  2871. i++;
  2872. } else {
  2873. if (pmodel[p] == null) {
  2874. pmodel[p] = {};
  2875. }
  2876. pmodel = pmodel[p];
  2877. }
  2878. }
  2879. );
  2880. if (pmodel != null) {
  2881. field.model = pmodel;
  2882. if (pmodel[field.key] == null) {
  2883. pmodel[field.key] = null;
  2884. }
  2885. }
  2886. } else {
  2887. if (result.model[field.key] == null) {
  2888. result.model[field.key] = null;
  2889. }
  2890. }
  2891. //处理弹出框组件初始化
  2892. if (field.type == "ui-input-selectmodal") {
  2893. field.templateOptions.modal = $modal;
  2894. //field.templateOptions.Restangular = Restangular;
  2895. } else if (field.type == "ui-userselect") {
  2896. field.templateOptions.modal = $modal;
  2897. //field.templateOptions.Restangular = Restangular;
  2898. } else if (field.type == "ui-multiuserselect") {
  2899. field.templateOptions.modal = $modal;
  2900. } else if (field.type == "ui-modelselect") {
  2901. field.templateOptions.modal = $modal;
  2902. //field.templateOptions.Restangular = Restangular;
  2903. } else if (field.type == "ui-dropfile") {
  2904. field.templateOptions.fileUploader = new FileUploader({
  2905. url: "/uploader",
  2906. });
  2907. field.templateOptions.taskId = $stateParams.taskId;
  2908. field.templateOptions.processInstanceId =
  2909. $stateParams.processInstanceId;
  2910. field.templateOptions.userId = $rootScope.user.id;
  2911. //field.ApiService=api_bpm_domain;
  2912. // }else if (field.type == "ui-uploadFile") {
  2913. // field.templateOptions.fileUploader = new FileUploader({
  2914. // url: '/uploader'
  2915. // });
  2916. // field.templateOptions.taskId = $stateParams.taskId;
  2917. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2918. // field.templateOptions.userId = $rootScope.user.id;
  2919. //field.ApiService=api_bpm_domain;
  2920. } else if (field.type == "ui-dropfiletable") {
  2921. if (field.templateOptions.processInstanceId) {
  2922. } else {
  2923. field.templateOptions.processInstanceId =
  2924. $stateParams.processInstanceId;
  2925. }
  2926. } else if (field.type == "ui-dropFiles") {
  2927. if (field.templateOptions.processInstanceId) {
  2928. } else {
  2929. field.templateOptions.processInstanceId =
  2930. $stateParams.processInstanceId;
  2931. }
  2932. } else if (field.type == "ui-showImgs") {
  2933. if (field.templateOptions.processInstanceId) {
  2934. } else {
  2935. field.templateOptions.processInstanceId =
  2936. $stateParams.processInstanceId;
  2937. }
  2938. } else if (field.type == "ui-repeatSection") {
  2939. var repeatForm = {
  2940. model: {},
  2941. fields: field.templateOptions.fields,
  2942. };
  2943. repeatForm.model[field.key] = [];
  2944. decodeVMTabForm(repeatForm);
  2945. }
  2946. }
  2947. // console.log(field);
  2948. //field
  2949. //result.fields.push(field);
  2950. });
  2951. });
  2952. vm.originalTabs = angular.copy(vm.form);
  2953. }
  2954. //解析自定义表单设计数据
  2955. function decodeVMForm(vmForm) {
  2956. var result = {
  2957. model: {},
  2958. tabs: [],
  2959. };
  2960. //设置模型实体数据 begin
  2961. // var mdata = vmForm.model;
  2962. //解析数据实体
  2963. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2964. angular.extend(result.model, mdata);
  2965. //设置模型实体数据 end
  2966. //解析设计数据生成表单项 begin
  2967. var fields = [];
  2968. //处理修改设计数据中展示设置
  2969. angular.forEach(vmForm.tabs, function (field) {
  2970. if (field.key == "") {
  2971. delete field.key;
  2972. }
  2973. if (angular.isDefined(field.extjson)) {
  2974. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2975. angular.extend(field.templateOptions, extObj.templateOptions);
  2976. delete extObj.templateOptions;
  2977. for (var prop in extObj) {
  2978. if (new RegExp("Expression").test(prop)) {
  2979. //var obj = $scope.$eval(extObj[prop]);
  2980. //extObj[prop] = $scope.$eval(extObj[prop]);
  2981. if (extObj[prop] != null) {
  2982. if (new RegExp("function").test(extObj[prop])) {
  2983. var propValue = eval(extObj[prop]);
  2984. extObj[prop] = propValue;
  2985. } else {
  2986. //console.log(extObj[prop]);
  2987. var obj = $scope.$eval(extObj[prop]);
  2988. extObj[prop] = obj;
  2989. //console.log(obj);
  2990. }
  2991. }
  2992. } else if (new RegExp("expressionProperties").test(prop)) {
  2993. for (var p in extObj[prop]) {
  2994. if (new RegExp("function").test(extObj[prop][p])) {
  2995. var propValue = eval(extObj[prop][p]);
  2996. extObj[prop][p] = propValue;
  2997. } else {
  2998. //if(p.indexOf("'")>=0){
  2999. // var obj = $scope.$eval(extObj[prop][p]);
  3000. // extObj[prop][$scope.$eval(p)]=obj;
  3001. //}
  3002. }
  3003. }
  3004. } else if ("watcher" == prop) {
  3005. if (angular.isArray(extObj[prop])) {
  3006. angular.forEach(extObj[prop], function (item, index) {
  3007. for (var p in item) {
  3008. if (new RegExp("function").test(item[p])) {
  3009. var propValue = eval(item[p]);
  3010. extObj[prop][index][p] = propValue;
  3011. }
  3012. }
  3013. });
  3014. } else if (angular.isObject(extObj[prop])) {
  3015. for (var p in extObj[prop]) {
  3016. if (new RegExp("function").test(extObj[prop][p])) {
  3017. var propValue = eval(extObj[prop][p]);
  3018. extObj[prop][p] = propValue;
  3019. }
  3020. }
  3021. }
  3022. }
  3023. }
  3024. angular.extend(field, extObj);
  3025. delete field.extjson;
  3026. }
  3027. if (angular.isDefined(field.templateOptions)) {
  3028. var templateOs = field.templateOptions;
  3029. for (var property in templateOs) {
  3030. //console.log(property);
  3031. if (
  3032. angular.isString(templateOs[property]) &&
  3033. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3034. ) {
  3035. if (new RegExp("function").test(templateOs[property])) {
  3036. var propValue = eval(templateOs[property]);
  3037. field.templateOptions[property] = propValue;
  3038. } else {
  3039. if (that.has(templateOs[property])) {
  3040. field.templateOptions[property] = that.get(
  3041. templateOs[property]
  3042. );
  3043. } else {
  3044. field.templateOptions[property] = templateOs[property];
  3045. }
  3046. }
  3047. } else if (templateOs[property] == null) {
  3048. //delete field.templateOptions[property];
  3049. } else {
  3050. }
  3051. }
  3052. }
  3053. if (
  3054. angular.isDefined(field.templateOptions) &&
  3055. angular.isDefined(field.templateOptions.extjson)
  3056. ) {
  3057. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3058. angular.extend(field.templateOptions, extObj);
  3059. delete field.templateOptions.extjson;
  3060. }
  3061. //...
  3062. if (field.templateOptions) {
  3063. //处理远程获取数据控件方法调用
  3064. if (field.templateOptions.optionsUrl) {
  3065. field.templateOptions.refresh = refreshSelectOptions;
  3066. }
  3067. //处理嵌套属性数据绑定/
  3068. if (field.templateOptions.pkey) {
  3069. var pmodel,
  3070. i = 0;
  3071. angular.forEach(
  3072. field.templateOptions.pkey.split("."),
  3073. function (p) {
  3074. if (i == 0) {
  3075. if (result.model[p] == null) {
  3076. result.model[p] = {};
  3077. }
  3078. pmodel = result.model[p];
  3079. i++;
  3080. } else {
  3081. if (pmodel[p] == null) {
  3082. pmodel[p] = {};
  3083. }
  3084. pmodel = pmodel[p];
  3085. }
  3086. }
  3087. );
  3088. if (pmodel != null) {
  3089. field.model = pmodel;
  3090. if (pmodel[field.key] == null) {
  3091. pmodel[field.key] = null;
  3092. }
  3093. }
  3094. } else {
  3095. if (result.model[field.key] == null) {
  3096. result.model[field.key] = null;
  3097. }
  3098. }
  3099. //处理弹出框组件初始化
  3100. if (field.type == "ui-input-selectmodal") {
  3101. field.templateOptions.modal = $modal;
  3102. //field.templateOptions.Restangular = Restangular;
  3103. } else if (field.type == "ui-userselect") {
  3104. field.templateOptions.modal = $modal;
  3105. //field.templateOptions.Restangular = Restangular;
  3106. } else if (field.type == "ui-multiuserselect") {
  3107. field.templateOptions.modal = $modal;
  3108. } else if (field.type == "ui-modelselect") {
  3109. field.templateOptions.modal = $modal;
  3110. //field.templateOptions.Restangular = Restangular;
  3111. } else if (field.type == "ui-dropfile") {
  3112. field.templateOptions.fileUploader = new FileUploader({
  3113. url: "/uploader",
  3114. });
  3115. field.templateOptions.taskId = $stateParams.taskId;
  3116. field.templateOptions.processInstanceId =
  3117. $stateParams.processInstanceId;
  3118. field.templateOptions.userId = $rootScope.user.id;
  3119. //field.ApiService=api_bpm_domain;
  3120. } else if (field.type == "ui-dropfiletable") {
  3121. if (field.templateOptions.processInstanceId) {
  3122. } else {
  3123. field.templateOptions.processInstanceId =
  3124. $stateParams.processInstanceId;
  3125. }
  3126. } else if (field.type == "ui-dropFiles") {
  3127. if (field.templateOptions.processInstanceId) {
  3128. } else {
  3129. field.templateOptions.processInstanceId =
  3130. $stateParams.processInstanceId;
  3131. }
  3132. } else if (field.type == "ui-showImgs") {
  3133. if (field.templateOptions.processInstanceId) {
  3134. } else {
  3135. field.templateOptions.processInstanceId =
  3136. $stateParams.processInstanceId;
  3137. }
  3138. } else if (field.type == "ui-repeatSection") {
  3139. var repeatForm = {
  3140. model: {},
  3141. fields: field.templateOptions.fields,
  3142. };
  3143. repeatForm.model[field.key] = [];
  3144. decodeVMForm(repeatForm);
  3145. }
  3146. }
  3147. // console.log(field);
  3148. result.fields.push(field);
  3149. });
  3150. angular.extend($scope.vm.fields, result.fields);
  3151. angular.extend($scope.vm.models, result.model);
  3152. $scope.formData = vmForm;
  3153. //console.log($scope.vm);
  3154. //解析设计数据生成表单项 end
  3155. return result;
  3156. }
  3157. //======================处理表单设计数据 结束========================
  3158. $scope.ldloading = {};
  3159. function filter(obj) {
  3160. angular.forEach(obj, function (key, value) {
  3161. if (value === "" || value === null) {
  3162. delete obj[key];
  3163. } else if (
  3164. Object.prototype.toString.call(value) === "[object Object]"
  3165. ) {
  3166. filter(value);
  3167. } else if (angular.isArray(value)) {
  3168. angular.forEach(value, function (item) {
  3169. filter(item);
  3170. });
  3171. }
  3172. });
  3173. }
  3174. function invokeOnAllFormOptions(fn) {
  3175. angular.forEach(vm.tabs, function (tab) {
  3176. if (tab.form.options && tab.form.options[fn]) {
  3177. tab.form.options[fn]();
  3178. }
  3179. });
  3180. }
  3181. function encodeCIData(data, ciId) {
  3182. /*
  3183. create/update state:未审核
  3184. create createtime:系统时间
  3185. create/update lastupdatetime : 系统时间
  3186. label:ci分类
  3187. */
  3188. if (ciId) {
  3189. var baseprop = [
  3190. "uuid",
  3191. "name",
  3192. "type",
  3193. "label",
  3194. "status",
  3195. "createtime",
  3196. "lastupdatetime",
  3197. "props",
  3198. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3199. var extraprop = "props";
  3200. data[extraprop] = {};
  3201. for (var key in data) {
  3202. console.log(data[key]);
  3203. if (_.indexOf(baseprop, key) >= 0) {
  3204. continue;
  3205. } else {
  3206. data[extraprop][key] = data[key];
  3207. delete data[key];
  3208. }
  3209. }
  3210. if ($rootScope.user) {
  3211. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3212. data[extraprop]["configperson"] = $rootScope.user.name;
  3213. var isCMAdminFlag = false;
  3214. angular.forEach($rootScope.user.role, function (roleItem) {
  3215. if (roleItem.rolecode == "cmdb charge") {
  3216. isCMAdminFlag = true;
  3217. }
  3218. });
  3219. if (!isCMAdminFlag) {
  3220. data[extraprop]["state"] = "1";
  3221. }
  3222. }
  3223. if (data.props.id) {
  3224. } else {
  3225. data.label = ciId;
  3226. }
  3227. return data;
  3228. }
  3229. return undefined;
  3230. }
  3231. function decodeCIModel(data) {
  3232. var extraprop = "props";
  3233. if (data[extraprop]) {
  3234. for (var key in data[extraprop]) {
  3235. data[key] = data[extraprop][key];
  3236. }
  3237. delete data[extraprop];
  3238. }
  3239. data["iscmadmin"] = false;
  3240. angular.forEach($rootScope.user.role, function (roleItem) {
  3241. if (roleItem.rolecode == "cmdb charge") {
  3242. data["iscmadmin"] = true;
  3243. }
  3244. });
  3245. return data;
  3246. }
  3247. vm.remove = function (data, style) {
  3248. $scope.ldloading[style.replace("-", "_")] = true;
  3249. var modalInstance = $modal.open({
  3250. templateUrl: "assets/views/delete.html",
  3251. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3252. var cidata = {
  3253. label: data.label,
  3254. id: data.id,
  3255. uuid: data.uuid,
  3256. name: data.name,
  3257. props: {},
  3258. };
  3259. if (cidata.id) {
  3260. cidata.props["removeflag"] = true;
  3261. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3262. $scope.ok = function () {
  3263. $modalInstance.close(cidata);
  3264. };
  3265. $scope.cancel = function () {
  3266. $modalInstance.dismiss("cancel");
  3267. };
  3268. }
  3269. },
  3270. size: "sm",
  3271. resolve: {
  3272. scope: function () {
  3273. return $scope;
  3274. },
  3275. },
  3276. });
  3277. modalInstance.result.then(function (selectedItem) {
  3278. if (selectedItem) {
  3279. // if (selectedItem.length > 0) {
  3280. api_cmdb
  3281. .put(selectedItem, selectedItem.id)
  3282. .then(function (response) {
  3283. if (response) {
  3284. var resData = Restangular.stripRestangular(response);
  3285. SweetAlert.swal(
  3286. {
  3287. title: "删除成功!",
  3288. confirmButtonColor: "#007AFF",
  3289. },
  3290. function () {
  3291. $state.go("app.means.list");
  3292. // $scope.refreshform();
  3293. // reinitTabForm($scope.classify);
  3294. }
  3295. );
  3296. } else {
  3297. SweetAlert.swal({
  3298. title: "系统错误",
  3299. text: "系统错误,请稍后重试!",
  3300. type: "error",
  3301. confirmButtonColor: "#DD6B55",
  3302. });
  3303. }
  3304. $scope.ldloading[style.replace("-", "_")] = false;
  3305. });
  3306. }
  3307. });
  3308. };
  3309. function formValid() {
  3310. angular.forEach(vm.tabs, function (item) {
  3311. //item.
  3312. });
  3313. }
  3314. $scope.closeModel = function () {
  3315. console.log($stateParams);
  3316. if (
  3317. angular.isDefined($stateParams.formKey) &&
  3318. $stateParams.formKey != ""
  3319. ) {
  3320. if (
  3321. $stateParams.formKey == "means_editor" ||
  3322. $stateParams.formKey == "means_edit"
  3323. ) {
  3324. $state.go("app.means.list", {});
  3325. }
  3326. event.preventDefault();
  3327. }
  3328. };
  3329. // setInterval(function() {
  3330. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3331. // cifilter_classic = $scope.model.cifilter_classic;
  3332. // $scope.refreshcmdbform(cifilter_classic);
  3333. // } else {}
  3334. // }, 100);
  3335. vm.models = (function filter(obj) {
  3336. var filtered = _.pick(obj, function (v) {
  3337. return (
  3338. angular.isDefined(v) &&
  3339. v !== null &&
  3340. (angular.isArray(v) ? v.length > 0 : true) &&
  3341. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3342. );
  3343. });
  3344. return _.cloneDeep(filtered, function (v) {
  3345. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3346. });
  3347. })(vm.models);
  3348. // setInterval(function() {
  3349. // if ($scope.model.type == 0) {
  3350. // $scope.model[$scope.options.key] = vm.models;
  3351. // }
  3352. // }, 100);
  3353. setInterval(function () {
  3354. if (vm.form && vm.form.$$parentForm.$valid) {
  3355. if (
  3356. $scope.$parent &&
  3357. $scope.$parent.$parent &&
  3358. $scope.$parent.$parent.$parent &&
  3359. $scope.$parent.$parent.$parent.model
  3360. ) {
  3361. vm.models.hw_cifilterClassic =
  3362. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3363. $scope.model[$scope.options.key] = vm.models;
  3364. }
  3365. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3366. // $scope.model[$scope.options.key] = vm.models;
  3367. }
  3368. }, 100);
  3369. vm.submit = function (data, ciId, templateitem, style) {
  3370. // $scope.ldloading[style.replace('-', '_')] = true;
  3371. console.log(vm.form.$$parentForm.$valid);
  3372. if (vm.form.$$parentForm.$valid) {
  3373. invokeOnAllFormOptions("updateInitialValue");
  3374. //alert(JSON.stringify(vm.model), null, 2);
  3375. //vm.options.updateInitialValue();
  3376. //console.log(vm.model);
  3377. var cidata = encodeCIData(vm.models, ciId);
  3378. if (cidata) {
  3379. //var cidata = ;
  3380. if (cidata.props.id) {
  3381. //修改
  3382. api_cmdb.put(cidata, ciId).then(function (response) {
  3383. if (response) {
  3384. var resData = Restangular.stripRestangular(response);
  3385. SweetAlert.swal(
  3386. {
  3387. title: "保存成功!",
  3388. confirmButtonColor: "#007AFF",
  3389. },
  3390. function () {
  3391. $scope.ldloading[style.replace("-", "_")] = false;
  3392. // $scope.refreshform();
  3393. $state.go("app.means.list");
  3394. }
  3395. );
  3396. } else {
  3397. SweetAlert.swal({
  3398. title: "系统错误",
  3399. text: "系统错误,请稍后重试!",
  3400. type: "error",
  3401. confirmButtonColor: "#DD6B55",
  3402. });
  3403. }
  3404. $scope.ldloading[style.replace("-", "_")] = false;
  3405. });
  3406. } else {
  3407. //新建
  3408. var type = 2;
  3409. api_sysinfo
  3410. .getSerialnumber(type, templateitem.id)
  3411. .then(function (data) {
  3412. if (data && data.status == 200) {
  3413. cidata.uuid = data.uuid;
  3414. api_cmdb.create(cidata).then(function (response) {
  3415. if (response) {
  3416. var resData = Restangular.stripRestangular(response);
  3417. SweetAlert.swal(
  3418. {
  3419. title: "保存成功!",
  3420. text: "内部编号:" + cidata.uuid,
  3421. confirmButtonColor: "#007AFF",
  3422. },
  3423. function () {
  3424. $state.go("app.means.list");
  3425. }
  3426. );
  3427. // if(resData.status){
  3428. // resData
  3429. // }
  3430. } else {
  3431. SweetAlert.swal({
  3432. title: "系统错误",
  3433. text: "系统错误,请稍后重试!",
  3434. type: "error",
  3435. confirmButtonColor: "#DD6B55",
  3436. });
  3437. }
  3438. $scope.ldloading[style.replace("-", "_")] = false;
  3439. });
  3440. } else {
  3441. SweetAlert.swal({
  3442. title: "系统错误",
  3443. text: "内部编号生成出错!",
  3444. type: "error",
  3445. confirmButtonColor: "#DD6B55",
  3446. });
  3447. }
  3448. });
  3449. }
  3450. } else {
  3451. SweetAlert.swal({
  3452. title: "错误",
  3453. text: "错误,请选择资产分类!",
  3454. type: "error",
  3455. confirmButtonColor: "#DD6B55",
  3456. });
  3457. }
  3458. //alert(JSON.stringify(cidata), null, 2);
  3459. $scope.ldloading[style.replace("-", "_")] = true;
  3460. return;
  3461. var _ = window._;
  3462. vm.models = (function filter(obj) {
  3463. var filtered = _.pick(obj, function (v) {
  3464. return (
  3465. angular.isDefined(v) &&
  3466. v !== null &&
  3467. (angular.isArray(v) ? v.length > 0 : true) &&
  3468. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3469. );
  3470. });
  3471. return _.cloneDeep(filtered, function (v) {
  3472. return v !== filtered && _.isPlainObject(v)
  3473. ? filter(v)
  3474. : undefined;
  3475. });
  3476. })(vm.models);
  3477. } else {
  3478. if (vm.form.$$parentForm.$error) {
  3479. SweetAlert.swal({
  3480. title: "校验错误",
  3481. text: "请填写必填项!",
  3482. type: "error",
  3483. confirmButtonColor: "#DD6B55",
  3484. });
  3485. angular.forEach(
  3486. vm.form.$$parentForm.$error.required,
  3487. function (item) {
  3488. angular.forEach(vm.tabs, function (tab) {
  3489. angular.forEach(tab.form.fields, function (f) {
  3490. if (f.name == item.$name) {
  3491. f.validation.show = true;
  3492. tab.active = true;
  3493. }
  3494. });
  3495. });
  3496. }
  3497. );
  3498. $scope.ldloading[style.replace("-", "_")] = false;
  3499. }
  3500. }
  3501. };
  3502. $scope.vm = vm;
  3503. $scope.refreshcmdbform = function (item) {
  3504. // if ($stateParams.model) {
  3505. // var modeldata = JSON.parse($stateParams.model)
  3506. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3507. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3508. var myData = Restangular.stripRestangular(data);
  3509. $scope.propTypeOptions = myData;
  3510. $scope.templateProps = myData;
  3511. $scope.vm.tabs = myData;
  3512. if ($scope.model.asset && $scope.model.asset.length != "") {
  3513. vm.models = JSON.parse($scope.model.asset);
  3514. }
  3515. decodeVMTabForm(vm.models, vm.tabs);
  3516. });
  3517. // }
  3518. };
  3519. var cifilterClassic = {};
  3520. setInterval(function () {
  3521. if (
  3522. $scope.$parent.$parent &&
  3523. $scope.$parent.$parent.$parent &&
  3524. $scope.$parent.$parent.$parent.model &&
  3525. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3526. cifilterClassic.id !=
  3527. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3528. ) {
  3529. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3530. cifilterClassic =
  3531. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3532. $scope.refreshcmdbform(cifilterClassic);
  3533. } else {
  3534. }
  3535. }, 100);
  3536. },
  3537. ],
  3538. });
  3539. //请求人信息
  3540. formlyConfigProvider.setType({
  3541. name: "ui-cmdbinformation",
  3542. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3543. wrapper: ["bootstrapHasError"],
  3544. defaultOptions: function (options, $scope) {
  3545. return {
  3546. templateOptions: {
  3547. // checkform: function(options) {
  3548. // if (options.model.requester) {
  3549. // options.value(options.model.requester);
  3550. // }
  3551. // },
  3552. },
  3553. };
  3554. },
  3555. controller: [
  3556. "$scope",
  3557. "api_user_data",
  3558. function ($scope, api_user_data) {
  3559. if ($scope.options.templateOptions.loginUser) {
  3560. if (
  3561. $scope.model[$scope.options.key] &&
  3562. $scope.model[$scope.options.key].id
  3563. ) {
  3564. } else {
  3565. $scope.model[$scope.options.key] =
  3566. $scope.options.templateOptions.loginUser;
  3567. }
  3568. $scope.options.initialValue = $scope.model[$scope.options.key];
  3569. }
  3570. },
  3571. ],
  3572. });
  3573. //资产属性
  3574. formlyConfigProvider.setType({
  3575. name: "ui-cmdbtype",
  3576. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3577. wrapper: ["bootstrapHasError"],
  3578. defaultOptions: function (options, $scope) {
  3579. return {
  3580. templateOptions: {
  3581. // checkform: function(options) {
  3582. // if (options.model.requester) {
  3583. // options.value(options.model.requester);
  3584. // }
  3585. // },
  3586. },
  3587. };
  3588. },
  3589. controller: [
  3590. "$scope",
  3591. "api_user_data",
  3592. function ($scope, api_user_data) {
  3593. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3594. $scope.property = {
  3595. hw_change: $scope.to.loginUser,
  3596. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3597. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3598. };
  3599. if ($scope.$parent.$parent.$parent.model.assets) {
  3600. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3601. }
  3602. },
  3603. ],
  3604. });
  3605. //申请单信息
  3606. formlyConfigProvider.setType({
  3607. name: "ui-cmdbformimform",
  3608. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3609. wrapper: ["bootstrapHasError"],
  3610. defaultOptions: function (options, $scope) {
  3611. return {
  3612. templateOptions: {
  3613. // checkform: function(options) {
  3614. // if (options.model.requester) {
  3615. // options.value(options.model.requester);
  3616. // }
  3617. // },
  3618. },
  3619. };
  3620. },
  3621. controller: [
  3622. "$scope",
  3623. "api_user_data",
  3624. function ($scope, api_user_data) {
  3625. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3626. $scope.getininform = {
  3627. serialNumbe:
  3628. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3629. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3630. };
  3631. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3632. $scope.getininform.types = "新资产入库";
  3633. } else if (
  3634. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3635. ) {
  3636. $scope.getininform.types = "资产归还";
  3637. }
  3638. },
  3639. ],
  3640. });
  3641. //出库单信息
  3642. formlyConfigProvider.setType({
  3643. name: "ui-outinformation",
  3644. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3645. wrapper: ["bootstrapHasError"],
  3646. defaultOptions: function (options, $scope) {
  3647. return {
  3648. templateOptions: {
  3649. // checkform: function(options) {
  3650. // if (options.model.requester) {
  3651. // options.value(options.model.requester);
  3652. // }
  3653. // },
  3654. },
  3655. };
  3656. },
  3657. controller: [
  3658. "$scope",
  3659. "api_user_data",
  3660. function ($scope, api_user_data) {
  3661. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3662. $scope.getininform = {
  3663. serialNumbe:
  3664. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3665. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3666. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3667. sourceId:
  3668. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3669. describe:
  3670. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3671. };
  3672. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3673. $scope.getininform.types = "新设备领用出库";
  3674. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3675. $scope.getininform.types = "设备更换";
  3676. }
  3677. $scope.getininform.source_id =
  3678. $scope.$parent.$parent.$parent.model.source.value;
  3679. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3680. $scope.getininform.source = "事件";
  3681. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3682. $scope.getininform.source = "变更";
  3683. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3684. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3685. $scope.getininform.source = "其它";
  3686. }
  3687. },
  3688. ],
  3689. });
  3690. //资产附件上传
  3691. formlyConfigProvider.setType({
  3692. name: "ui-cmdbuplode",
  3693. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3694. wrapper: ["bootstrapHasError"],
  3695. defaultOptions: function (options, $scope) {
  3696. return {
  3697. templateOptions: {
  3698. // checkform: function(options) {
  3699. // if (options.model.requester) {
  3700. // options.value(options.model.requester);
  3701. // }
  3702. // },
  3703. },
  3704. };
  3705. },
  3706. controller: [
  3707. "$scope",
  3708. "$rootScope",
  3709. "$http",
  3710. "SweetAlert",
  3711. "FileUploader",
  3712. "api_user_data",
  3713. "i18nService",
  3714. "$modal",
  3715. "Restangular",
  3716. "api_configure_data",
  3717. "api_cmdb",
  3718. "api_cmdb_new",
  3719. "api_wechatfile",
  3720. "api_sysinfo",
  3721. function (
  3722. $scope,
  3723. $rootScope,
  3724. $http,
  3725. SweetAlert,
  3726. FileUploader,
  3727. api_user_data,
  3728. i18nService,
  3729. $modal,
  3730. Restangular,
  3731. api_configure_data,
  3732. api_cmdb,
  3733. api_cmdb_new,
  3734. api_wechatfile,
  3735. api_sysinfo
  3736. ) {
  3737. $scope.state = 1;
  3738. $scope.myData3all = [];
  3739. $scope.myData3 = [];
  3740. $scope.memoryfilterDatahao = {
  3741. idx: 0,
  3742. sum: 10,
  3743. };
  3744. $scope.selected = {
  3745. items: [],
  3746. };
  3747. $scope.interceptMydata = function (mydate, idx, sum) {
  3748. return mydate.slice(idx * sum, (idx + 1) * sum);
  3749. };
  3750. // $scope.importnext = function() {
  3751. // $scope.state = 2;
  3752. // event.preventDefault();
  3753. // }
  3754. $scope.workspaces = [];
  3755. $scope.options.templateOptions.getpush = function (item) {
  3756. $scope.workspaces = [];
  3757. if (item.gu) {
  3758. $scope.workspaces.push({
  3759. id: 1,
  3760. name: "固定资产",
  3761. active: true,
  3762. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3763. });
  3764. }
  3765. if (item.hao) {
  3766. $scope.workspaces.push({
  3767. id: 2,
  3768. name: "耗材资产",
  3769. active: true,
  3770. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3771. });
  3772. }
  3773. };
  3774. //获取附件列表
  3775. $scope.listAttachmen = function () {
  3776. to.ApiService.listAttachment(
  3777. to.listAttachmentUrl,
  3778. to.bindType,
  3779. bindId
  3780. ).then(function (result) {
  3781. var myData = Restangular.stripRestangular(result);
  3782. // $scope.listAttachmens = myData;
  3783. $scope.attachments = myData.data;
  3784. });
  3785. };
  3786. //附件列表
  3787. if ($scope.options.templateOptions.bindType) {
  3788. if (angular.isUndefined($scope.form.dropState)) {
  3789. $scope.form.dropState = false;
  3790. }
  3791. var to = $scope.options.templateOptions;
  3792. var bindId = $scope.model[to.bindType].processInstanceId;
  3793. $scope.listAttachmen();
  3794. }
  3795. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3796. // $scope.listAttachmen();
  3797. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3798. // $scope.listAttachmen();
  3799. // }
  3800. //附件下载
  3801. $scope.download = function (token, filename) {
  3802. var downUrl = to.ApiService.downloadAttachment(
  3803. to.downUrl,
  3804. token
  3805. ).getRequestedUrl();
  3806. // window.open(downUrl);
  3807. var a = document.createElement("a");
  3808. a.href = downUrl;
  3809. a.target = "_blank";
  3810. a.download = filename;
  3811. document.body.appendChild(a);
  3812. a.click();
  3813. };
  3814. //附件预览
  3815. $scope.view = function (id, previewUrl) {
  3816. if (previewUrl) {
  3817. window.open(previewUrl);
  3818. }
  3819. };
  3820. //下载资产模版
  3821. $scope.filenum = 0;
  3822. $scope.openmeans = function () {
  3823. var modalInstance = $modal.open({
  3824. templateUrl: "assets/views/means/tpl/meansdown.html",
  3825. controller: function ($scope, scope, $modalInstance) {
  3826. $scope.item = {};
  3827. $scope.title = "选择下载模版";
  3828. $scope.lable = "资产模版下载";
  3829. function foreachdata(my_datas) {
  3830. // angular.forEach(my_datas, function(item, index) {
  3831. // if (item.children && item.children.length > 0) {
  3832. // foreachdata(item.children);
  3833. // } else {
  3834. // my_datas[index].checks = true;
  3835. // }
  3836. // })
  3837. for (var i = 0; i < my_datas.length; i++) {
  3838. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3839. foreachdata(my_datas[i].children);
  3840. console.log($scope);
  3841. } else {
  3842. my_datas[i].checks = true;
  3843. }
  3844. }
  3845. }
  3846. function foreachtree(data) {
  3847. angular.forEach(data, function (item) {
  3848. // if (item.checks != true) {
  3849. item.checks = true;
  3850. item.expanded = true;
  3851. if (item.children && item.children.length > 0) {
  3852. foreachtree(item.children);
  3853. } else {
  3854. $scope.getslowtree.push(item);
  3855. }
  3856. // }
  3857. });
  3858. }
  3859. $scope.getslowtree = [];
  3860. $scope.slowtree = function (tree) {
  3861. foreachtree(tree);
  3862. return $scope.getslowtree;
  3863. };
  3864. $scope.all = function (c, v) {
  3865. //全选
  3866. if (c == true) {
  3867. $scope.formdashboard($scope.slowtree(v));
  3868. } else {
  3869. $scope.my_data_after = [];
  3870. angular.forEach($scope.my_data, function (item, index) {
  3871. $scope.my_data[index].checks = false;
  3872. $scope.my_data[index].expanded = false;
  3873. if (item.children && item.children.length > 0) {
  3874. angular.forEach(
  3875. item.children,
  3876. function (itemone, indexone) {
  3877. $scope.my_data[index].children[
  3878. indexone
  3879. ].checks = false;
  3880. $scope.my_data[index].children[
  3881. indexone
  3882. ].expanded = false;
  3883. if (itemone.children && itemone.children.length > 0) {
  3884. angular.forEach(
  3885. itemone.children,
  3886. function (itemtwo, indextwo) {
  3887. $scope.my_data[index].children[
  3888. indexone
  3889. ].children[indextwo].checks = false;
  3890. }
  3891. );
  3892. } else {
  3893. }
  3894. }
  3895. );
  3896. } else {
  3897. }
  3898. });
  3899. $scope.mydatacate = [];
  3900. $scope.getslowtree = [];
  3901. // }
  3902. }
  3903. };
  3904. // $scope.searchone = function(search) {
  3905. // angular.forEach($scope.my_data, function(item) {
  3906. // if (item.indexOf(search) > 0) {
  3907. // }
  3908. // })
  3909. // }
  3910. $scope.checkall = function () {
  3911. angular.forEach($scope.my_data, function (item, index) {
  3912. scope.my_data[index].checks = true;
  3913. });
  3914. };
  3915. $scope.selectitem = [];
  3916. $scope.choiceitem = function (item) {
  3917. // if (item.checkeds) {
  3918. // item.checkeds = false;
  3919. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3920. // // if ($scope.selectitem[i].id == item.id) {
  3921. // // $scope.selectitem.splice(i, 1)
  3922. // // }
  3923. // // }
  3924. // for (var i = 0; i < $scope.my_data_after; i++) {
  3925. // if ($scope.my_data_after[i].id == item.id) {
  3926. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3927. // // $scope.selectitem.splice(i, 1)
  3928. // }
  3929. // }
  3930. // } else {
  3931. // item.checkeds = true;
  3932. // $scope.selectitem.push(item)
  3933. // }
  3934. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3935. if ($scope.my_data_after[i].id == item.id) {
  3936. $scope.my_data_after[i].checkeds
  3937. ? ($scope.my_data_after[i].checkeds = false)
  3938. : ($scope.my_data_after[i].checkeds = true);
  3939. }
  3940. }
  3941. };
  3942. $scope.remove = function (removeitem) {
  3943. var realdat = angular.copy($scope.my_data_after);
  3944. // angular.extend(realdat, $scope.selectitem);
  3945. $scope.my_data_after = [];
  3946. angular.forEach(realdat, function (item) {
  3947. if (!item.checkeds) {
  3948. $scope.my_data_after.push(item);
  3949. }
  3950. });
  3951. $scope.mydatacate = angular.copy($scope.my_data_after);
  3952. };
  3953. $scope.try_async_loads = function (item, search) {
  3954. var fildatas = {
  3955. idx: 0,
  3956. sum: 1000,
  3957. };
  3958. $scope.my_data = [];
  3959. // $scope.try_async_load = true;
  3960. if (item) {
  3961. angular.extend(fildatas, item);
  3962. }
  3963. api_configure_data
  3964. .fetchDataList("ciclassify", fildatas)
  3965. .then(function (response) {
  3966. if (response.status == 200) {
  3967. var data = response.list;
  3968. var objects = [];
  3969. for (var i = 0; i < data.length; i++) {
  3970. var object = {};
  3971. object.id = data[i].id;
  3972. if (search) {
  3973. delete data[i].parent;
  3974. } else {
  3975. if (data[i].parent && data[i].parent.id != 0) {
  3976. object.parent = data[i].parent.id;
  3977. }
  3978. }
  3979. angular.extend(object, data[i]);
  3980. objects.push(object);
  3981. }
  3982. $scope.my_data = convertParentToChildList(objects);
  3983. $scope.tree_data = angular.copy($scope.my_data);
  3984. if ($scope.my_data.length > 0) {
  3985. $scope.try_async_load = false;
  3986. }
  3987. } else {
  3988. SweetAlert.swal({
  3989. title: "系统错误!",
  3990. text: "请刷新重试!",
  3991. type: "error",
  3992. });
  3993. }
  3994. });
  3995. };
  3996. function convertListToTree(data, treeMap) {
  3997. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3998. var root = null; //Initially set our loop to null
  3999. //loop over data
  4000. for (var i = 0; i < data.length; i++) {
  4001. var datum = data[i];
  4002. //each node will have children, so let's give it a "children" poperty
  4003. datum.children = [];
  4004. //add an entry for this node to the map so that any future children can
  4005. //lookup the parent
  4006. idToNodeMap[datum.id] = datum;
  4007. //Does this node have a parent?
  4008. // console.log("datum="+JSON.stringify(datum))
  4009. if (
  4010. typeof datum.parent === "undefined" ||
  4011. datum.parent === null
  4012. ) {
  4013. //Doesn't look like it, so this node is the root of the tree
  4014. root = datum;
  4015. treeMap[datum.id] = root;
  4016. } else {
  4017. //This node has a parent, so let's look it up using the id
  4018. parentNode = idToNodeMap[datum.parent.id];
  4019. //We don't need this property, so let's delete it.
  4020. // delete datum.parent;
  4021. //Let's add the current node as a child of the parent node.
  4022. parentNode.children.push(datum);
  4023. }
  4024. }
  4025. return root;
  4026. }
  4027. function convertParentToChildList(data) {
  4028. var treeMap = {};
  4029. var list = [];
  4030. convertListToTree(data, treeMap);
  4031. angular.forEach(treeMap, function (item) {
  4032. list.push(item);
  4033. });
  4034. return list;
  4035. }
  4036. function convertParentToChild(datato) {
  4037. var treeMapto = {};
  4038. var listto = [];
  4039. convertListToTree(datato, treeMapto);
  4040. angular.forEach(treeMapto, function (items) {
  4041. listto.push(items);
  4042. });
  4043. return listto;
  4044. }
  4045. $scope.try_async_loads();
  4046. $scope.searchdown = function (key) {
  4047. if (key && key != "") {
  4048. $scope.try_async_loads(
  4049. {
  4050. ciclassify: {
  4051. label: key,
  4052. },
  4053. },
  4054. "search"
  4055. );
  4056. } else {
  4057. $scope.try_async_loads();
  4058. }
  4059. // var mydatacatedown = angular.copy($scope.my_data);
  4060. // $scope.my_data = [];
  4061. // var objects = [];
  4062. // angular.forEach(mydatacatedown, function(item) {
  4063. // if (item.label.match(key)) {
  4064. // objects.push(item)
  4065. // } else {
  4066. // // $scope.my_data_after.push(item)
  4067. // }
  4068. // })
  4069. // $scope.my_data = convertParentToChildList(objects);
  4070. // $scope.tree_data = angular.copy($scope.my_data);
  4071. };
  4072. $scope.mydatacate = [];
  4073. $scope.searchup = function (key) {
  4074. // var mydatacate = angular.copy($scope.my_data_after);
  4075. $scope.my_data_after = [];
  4076. angular.forEach($scope.mydatacate, function (item) {
  4077. if (item.label.match(key)) {
  4078. $scope.my_data_after.push(item);
  4079. } else {
  4080. }
  4081. });
  4082. };
  4083. //角色树
  4084. $scope.my_tree = [];
  4085. $scope.tree_data_after = [];
  4086. $scope.my_data = [];
  4087. $scope.my_data_after = [];
  4088. $scope.formdashboard = function (item) {
  4089. $scope.my_data_after = [];
  4090. angular.forEach(item, function (infox) {
  4091. if (infox.children.length == 0) {
  4092. $scope.my_data_after.push(infox);
  4093. }
  4094. });
  4095. $scope.mydatacate = angular.copy($scope.my_data_after);
  4096. };
  4097. $scope.ok = function (item) {
  4098. $modalInstance.close(item);
  4099. };
  4100. $scope.cancel = function () {
  4101. $modalInstance.dismiss("cancel");
  4102. };
  4103. },
  4104. // size: 'sm',
  4105. resolve: {
  4106. scope: function () {
  4107. return $scope;
  4108. },
  4109. },
  4110. });
  4111. modalInstance.result.then(function (selectedItem) {
  4112. // $rootScope.isMask = true;
  4113. if (selectedItem) {
  4114. var type = 1;
  4115. var fildat = {
  4116. configure: selectedItem,
  4117. };
  4118. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4119. // // if (data.errno == 0) {
  4120. // var file = new Blob([data], {
  4121. // // 'Accept': '*/*'
  4122. // type: 'application/octet-stream'
  4123. // // type: 'application/vnd.ms-excel'
  4124. // });
  4125. // //trick to download store a file having its URL
  4126. // var fileURL = URL.createObjectURL(file);
  4127. // var a = document.createElement('a');
  4128. // a.href = fileURL;
  4129. // a.target = '_blank';
  4130. // a.download = "资产导入模版.xlsx";
  4131. // document.body.appendChild(a);
  4132. // a.click();
  4133. // // }
  4134. // })
  4135. $http({
  4136. url: api_configure_data
  4137. .downModels("export/cmdb", fildat)
  4138. .getRequestedUrl(),
  4139. method: "POST",
  4140. data: JSON.stringify(fildat),
  4141. headers: {
  4142. // 'Content-type': 'application/xls',
  4143. Accept: "*/*",
  4144. },
  4145. responseType: "arraybuffer",
  4146. })
  4147. .success(function (data, status, headers, config) {
  4148. $rootScope.isMask = false;
  4149. var file = new Blob([data], {
  4150. type: "application/octet-stream",
  4151. // type : 'application/vnd.ms-excel'
  4152. });
  4153. //trick to download store a file having its URL
  4154. var fileURL = URL.createObjectURL(file);
  4155. var a = document.createElement("a");
  4156. a.href = fileURL;
  4157. a.target = "_blank";
  4158. a.download = "资产导入模版.xlsx";
  4159. document.body.appendChild(a);
  4160. a.click();
  4161. })
  4162. .error(function (data, status, headers, config) {
  4163. // console.log(data);
  4164. $rootScope.isMask = false;
  4165. });
  4166. // break;
  4167. // }
  4168. // }
  4169. // }
  4170. // })
  4171. } else {
  4172. SweetAlert.swal(
  4173. {
  4174. title: "未选择资产分类!",
  4175. text: "请选择资产分类",
  4176. type: "error",
  4177. },
  4178. function () {
  4179. $rootScope.isMask = false;
  4180. }
  4181. );
  4182. }
  4183. // }
  4184. });
  4185. };
  4186. $scope.wrongdata = [];
  4187. var uploader = ($scope.uploader =
  4188. $scope.options.templateOptions.fileUploader);
  4189. var uploadermeans = ($scope.uploadermeans =
  4190. $scope.options.templateOptions.fileUploadermeans);
  4191. $scope.importopen = function () {
  4192. //导入触发事件
  4193. if (angular.isUndefined($scope.form.dropState)) {
  4194. $scope.form.dropState = false;
  4195. }
  4196. //附件上传数据
  4197. //$scope.options.templateOptions.uploader();
  4198. // FILTERS
  4199. uploader.filters.push({
  4200. name: "customFilter",
  4201. fn: function (item /*{File|FileLikeObject}*/, options) {
  4202. return this.queue.length < 2;
  4203. },
  4204. });
  4205. // CALLBACKS
  4206. uploader.onWhenAddingFileFailed = function (
  4207. item /*{File|FileLikeObject}*/,
  4208. filter,
  4209. options
  4210. ) {
  4211. console.info("onWhenAddingFileFailed", item, filter, options);
  4212. };
  4213. uploader.onAfterAddingFile = function (fileItem) {
  4214. console.info("onAfterAddingFile", fileItem);
  4215. };
  4216. uploader.onAfterAddingAll = function (addedFileItems) {
  4217. console.info("onAfterAddingAll", addedFileItems);
  4218. };
  4219. uploader.onBeforeUploadItem = function (item) {
  4220. console.info("onBeforeUploadItem", item);
  4221. };
  4222. uploader.onProgressItem = function (fileItem, progress) {
  4223. console.info("onProgressItem", fileItem, progress);
  4224. };
  4225. uploader.onProgressAll = function (progress) {
  4226. console.info("onProgressAll", progress);
  4227. };
  4228. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4229. // console.info('onSuccessItem', fileItem, response, status, headers);
  4230. // };
  4231. uploader.onErrorItem = function (
  4232. fileItem,
  4233. response,
  4234. status,
  4235. headers
  4236. ) {
  4237. console.info("onErrorItem", fileItem, response, status, headers);
  4238. };
  4239. uploader.onCancelItem = function (
  4240. fileItem,
  4241. response,
  4242. status,
  4243. headers
  4244. ) {
  4245. console.info("onCancelItem", fileItem, response, status, headers);
  4246. };
  4247. uploader.onCompleteItem = function (
  4248. fileItem,
  4249. response,
  4250. status,
  4251. headers
  4252. ) {
  4253. console.info("onCompleteItem", fileItem, response, status, headers);
  4254. };
  4255. uploader.onCompleteAll = function () {
  4256. console.info("onCompleteAll");
  4257. };
  4258. };
  4259. // $scope.importnext = function() {
  4260. // $scope.state = 2;
  4261. // event.preventDefault();
  4262. // }
  4263. $scope.importnext = function () {
  4264. event.preventDefault();
  4265. // $rootScope.isMask = true;
  4266. $rootScope.loading = true;
  4267. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4268. uploader.onBeforeUploadItem = function (item) {
  4269. angular.extend(item.headers, $rootScope.getSession());
  4270. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4271. // if (item.index > 1) {
  4272. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4273. // }
  4274. // item.index = 1;
  4275. item.formData = [
  4276. {
  4277. filename: item.file.name,
  4278. },
  4279. ];
  4280. console.info("onBeforeUploadItem", item);
  4281. };
  4282. uploader.uploadAll();
  4283. uploader.onSuccessItem = function (
  4284. fileItem,
  4285. response,
  4286. status,
  4287. headers
  4288. ) {
  4289. if (response.status == 200) {
  4290. $scope.wrongdata = [];
  4291. $rootScope.loading = false;
  4292. if (response.abnormal) {
  4293. $scope.state = 2;
  4294. angular.forEach(response.msg, function (item) {
  4295. $scope.wrongdata.push({
  4296. name: item.assetName,
  4297. line: item.row,
  4298. cmdbname: item.name,
  4299. errotip: [
  4300. {
  4301. label: item.msg,
  4302. },
  4303. ],
  4304. });
  4305. });
  4306. } else {
  4307. $scope.state = 3;
  4308. }
  4309. } else {
  4310. $rootScope.loading = false;
  4311. $scope.state = 2;
  4312. }
  4313. };
  4314. };
  4315. $scope.clearItems = function () {
  4316. //重新选择文件时,清空队列,达到覆盖文件的效果
  4317. uploader.clearQueue();
  4318. // uploader.remove();
  4319. // uploader.cancel();
  4320. // uploader.onChange();
  4321. };
  4322. uploader.onAfterAddingFile = function (fileItem) {
  4323. $scope.fileItem = fileItem._file;
  4324. // $scope.$apply();
  4325. // $scope.fileItem = filenum;
  4326. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4327. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4328. $scope.filenum++;
  4329. };
  4330. uploader.onSuccessItem = function (
  4331. fileItem,
  4332. response,
  4333. status,
  4334. headers
  4335. ) {
  4336. $scope.uploadStatus = true; //上传成功则把状态改为true
  4337. // alert(response.path);
  4338. };
  4339. $scope.importnext = function () {
  4340. event.preventDefault();
  4341. // uploader.onChange();
  4342. $rootScope.loading = true;
  4343. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4344. uploader.onBeforeUploadItem = function (item) {
  4345. angular.extend(item.headers, $rootScope.getSession());
  4346. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4347. // if (item.index > 1) {
  4348. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4349. // }
  4350. // item.index = 1;
  4351. item.formData = [
  4352. {
  4353. filename: item.file.name,
  4354. },
  4355. ];
  4356. console.info("onBeforeUploadItem", item);
  4357. };
  4358. uploader.uploadAll();
  4359. uploader.onSuccessItem = function (
  4360. fileItem,
  4361. response,
  4362. status,
  4363. headers
  4364. ) {
  4365. if (response.status == 200) {
  4366. $scope.wrongdata = [];
  4367. // uploader.queue = [];
  4368. $rootScope.loading = false;
  4369. if (response.abnormal) {
  4370. $scope.state = 2;
  4371. uploader.clearQueue();
  4372. angular.forEach(response.msg, function (item) {
  4373. $scope.wrongdata.push({
  4374. name: item.assetName,
  4375. line: item.row,
  4376. cmdbname: item.name,
  4377. errotip: [
  4378. {
  4379. label: item.msg,
  4380. },
  4381. ],
  4382. });
  4383. });
  4384. } else {
  4385. $scope.state = 3;
  4386. }
  4387. } else {
  4388. uploader.clearQueue();
  4389. $rootScope.loading = false;
  4390. $scope.state = 2;
  4391. }
  4392. };
  4393. };
  4394. var setAllInactive = function () {
  4395. angular.forEach($scope.workspaces, function (workspace) {
  4396. workspace.active = false;
  4397. });
  4398. };
  4399. //添加
  4400. var addNewWorkspace = function (name, contentUrl) {
  4401. var id = $scope.workspaces.length + 1;
  4402. $scope.workspaces.push({
  4403. id: id,
  4404. name: name,
  4405. active: true,
  4406. contentUrl: "main/html/content.html",
  4407. });
  4408. };
  4409. //关闭
  4410. $scope.closeopen = function (closedata) {
  4411. event.preventDefault();
  4412. angular.forEach($scope.workspaces, function (item, index) {
  4413. if (closedata.id == item.id) {
  4414. if (closedata.id == 1) {
  4415. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4416. } else {
  4417. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4418. }
  4419. $scope.workspaces.splice(index, 1);
  4420. }
  4421. });
  4422. };
  4423. // $scope.workspaces = [
  4424. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4425. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4426. // ];
  4427. $scope.addWorkspace = function (contentUrl, name) {
  4428. setAllInactive();
  4429. addNewWorkspace(name, contentUrl);
  4430. };
  4431. // $rootScope.addWorkspace = $scope.addWorkspace;
  4432. $scope.close = function (idNumber) {
  4433. var index = 0; //记录当前元素下标
  4434. angular.forEach($scope.workspaces, function (workspace) {
  4435. if (workspace.id === idNumber) {
  4436. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4437. }
  4438. index++;
  4439. });
  4440. };
  4441. //grid2
  4442. $scope.langs = i18nService.getAllLangs();
  4443. $scope.lang = "zh-cn";
  4444. i18nService.setCurrentLang($scope.lang);
  4445. $scope.gridOptions2 = {};
  4446. $scope.gridOptions2.data = "myData3";
  4447. $scope.gridOptions2.enableColumnResizing = true;
  4448. $scope.gridOptions2.enableFiltering = false;
  4449. $scope.gridOptions2.enableGridMenu = false;
  4450. $scope.gridOptions2.showGridFooter = true;
  4451. $scope.gridOptions2.showColumnFooter = false;
  4452. $scope.gridOptions2.fastWatch = true;
  4453. $scope.gridOptions2.useExternalFiltering = true;
  4454. $scope.gridOptions2.useExternalPagination = true;
  4455. $scope.gridOptions2.paginationPageSizes = [10];
  4456. $scope.gridOptions2.paginationPageSize = 10;
  4457. $scope.gridOptions2.multiSelect = false;
  4458. // $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>";
  4459. $scope.gridOptions2.columnDefs = [
  4460. {
  4461. name: "item",
  4462. displayName: "序号",
  4463. width: 120,
  4464. },
  4465. {
  4466. name: "name",
  4467. displayName: "耗材名称",
  4468. width: 80,
  4469. enableFiltering: false,
  4470. },
  4471. {
  4472. name: "model",
  4473. displayName: "品牌/型号",
  4474. width: 100,
  4475. enableFiltering: false,
  4476. },
  4477. {
  4478. name: "Specifications",
  4479. displayName: "规格",
  4480. width: 150,
  4481. enableFiltering: false,
  4482. },
  4483. {
  4484. name: "sum",
  4485. displayName: "数量",
  4486. enableFiltering: false,
  4487. },
  4488. {
  4489. name: "操作",
  4490. cellTemplate:
  4491. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4492. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4493. "</div></div>",
  4494. enableFiltering: false,
  4495. },
  4496. ];
  4497. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4498. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4499. $scope.myData3all = JSON.parse(
  4500. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4501. );
  4502. for (var i = 0; i < $scope.myData3all.length; i++) {
  4503. $scope.myData3all[i]["item"] =
  4504. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4505. }
  4506. // $scope.model.consumables = $scope.myDataone;
  4507. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4508. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4509. $scope.model.applicationForm.consumables = $scope.myData3all;
  4510. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4511. $scope.options.templateOptions.getpush({
  4512. hao: true,
  4513. gu: true,
  4514. });
  4515. } else {
  4516. $scope.options.templateOptions.getpush({
  4517. hao: true,
  4518. });
  4519. }
  4520. } else {
  4521. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4522. $scope.options.templateOptions.getpush({
  4523. gu: true,
  4524. });
  4525. }
  4526. }
  4527. }
  4528. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4529. $scope.changecai = function (item) {
  4530. event.preventDefault();
  4531. var modalInstance = $modal.open({
  4532. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4533. controller: function ($scope, $modalInstance) {
  4534. $scope.title = "修改耗材数量";
  4535. $scope.consumptive = angular.copy(item);
  4536. $scope.ok = function () {
  4537. $modalInstance.close($scope.consumptive);
  4538. };
  4539. $scope.cancel = function () {
  4540. $modalInstance.dismiss("cancel");
  4541. };
  4542. },
  4543. size: "sm",
  4544. });
  4545. modalInstance.result.then(function (selectedItem) {
  4546. // angular.forEach($scope.myData3, function(items, index) {
  4547. // if (items.id == selectedItem.id) {
  4548. // $scope.myData3[index] = selectedItem;
  4549. // }
  4550. // })
  4551. // // $scope.myData3.push(selectedItem);
  4552. // $scope.model.applicationForm.consumables = $scope.myData3;
  4553. angular.forEach($scope.myData3all, function (items, index) {
  4554. if (
  4555. items.modelid == selectedItem.modelid &&
  4556. items.nameid == selectedItem.nameid &&
  4557. items.Specificationsid == selectedItem.Specificationsid
  4558. ) {
  4559. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4560. angular.extend($scope.myData3all[index], selectedItem);
  4561. }
  4562. });
  4563. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4564. $scope.myData3 = $scope.interceptMydata(
  4565. $scope.myData3all,
  4566. $scope.memoryfilterDatahao.idx,
  4567. 10
  4568. );
  4569. $scope.model.applicationForm.consumables = $scope.myData3all;
  4570. });
  4571. };
  4572. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4573. $scope.gridApi = gridApi;
  4574. gridApi.pagination.on.paginationChanged(
  4575. $scope,
  4576. function (newPage, pageSize) {
  4577. // var filtersData = $scope.memoryfilterDatahao;
  4578. // filtersData.idx = newPage - 1;
  4579. // filtersData.sum = pageSize;
  4580. // $scope.loadData(filtersData);
  4581. $scope.memoryfilterDatahao.idx = newPage - 1;
  4582. $scope.memoryfilterDatahao.sum = pageSize;
  4583. $scope.myData3 = $scope.interceptMydata(
  4584. $scope.myData3all,
  4585. $scope.memoryfilterDatahao.idx,
  4586. 10
  4587. );
  4588. }
  4589. );
  4590. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4591. $scope.selected.items = data.entity;
  4592. //console.log(data);
  4593. });
  4594. gridApi.selection.on.rowSelectionChangedBatch(
  4595. $scope,
  4596. function (data) {
  4597. $scope.selected.items = data.entity;
  4598. //console.log(data);
  4599. }
  4600. );
  4601. gridApi.core.on.filterChanged($scope, function () {
  4602. var grid = this.grid;
  4603. var filtersData = {
  4604. idx: 0,
  4605. sum: 10,
  4606. };
  4607. $scope.memoryfilterDatahao = filtersData;
  4608. // $scope.loadData(filtersData);
  4609. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4610. // $scope.memoryfilterDatahao.sum = pageSize;
  4611. $scope.myData3 = $scope.interceptMydata(
  4612. $scope.myData3all,
  4613. $scope.memoryfilterDatahao.idx,
  4614. 10
  4615. );
  4616. });
  4617. };
  4618. $scope.haocaiopen = function (items) {
  4619. event.preventDefault();
  4620. var modalInstance = $modal.open({
  4621. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4622. controller: function ($scope, $modalInstance, SweetAlert) {
  4623. $scope.consumptive = {};
  4624. $scope.title = "新增耗材";
  4625. if (items.name) {
  4626. $scope.consumptive.name = items.name.name;
  4627. }
  4628. $scope.clearNoNum = function (obj, attr) {
  4629. //先把非数字的都替换掉,除了数字和.
  4630. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4631. //必须保证第一个为数字而不是.
  4632. obj[attr] = obj[attr].replace(/^\./g, "");
  4633. //保证只有出现一个.而没有多个.
  4634. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4635. //保证.只出现一次,而不能出现两次以上
  4636. obj[attr] = obj[attr]
  4637. .replace(".", "$#$")
  4638. .replace(/\./g, "")
  4639. .replace("$#$", ".");
  4640. //小于最大值
  4641. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4642. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4643. // obj[attr] = '';
  4644. // }
  4645. };
  4646. $scope.ok = function (item) {
  4647. // if (item.name && item.model && item.Specifications && item.sum) {
  4648. if (
  4649. item.name &&
  4650. item.model &&
  4651. JSON.stringify(item.model) != "{}" &&
  4652. item.Specifications &&
  4653. JSON.stringify(item.Specifications) != "{}" &&
  4654. item.sum
  4655. ) {
  4656. $modalInstance.close(item);
  4657. } else {
  4658. SweetAlert.swal({
  4659. title: "数据填写不完整!",
  4660. text: "请检查数据然后提交!",
  4661. type: "error",
  4662. });
  4663. }
  4664. };
  4665. $scope.cancel = function () {
  4666. $modalInstance.dismiss("cancel");
  4667. };
  4668. },
  4669. size: "sm",
  4670. resolve: {
  4671. SweetAlert: function () {
  4672. return SweetAlert;
  4673. },
  4674. },
  4675. });
  4676. modalInstance.result.then(function (selectedItem) {
  4677. api_sysinfo
  4678. .addData("dictionaryTree", {
  4679. // "type": "list",
  4680. key: "haocaifenlei",
  4681. name: selectedItem.name,
  4682. parent: selectedItem.id,
  4683. value: selectedItem.name,
  4684. deleted: false,
  4685. level: 1,
  4686. })
  4687. .then(function (data) {
  4688. // $scope.haocainame.name = data.list;
  4689. api_sysinfo
  4690. .addData("dictionaryTree", {
  4691. // "type": "list",
  4692. key: "pinpai",
  4693. name: selectedItem.model,
  4694. parent: data.id,
  4695. value: selectedItem.model,
  4696. deleted: false,
  4697. level: 2,
  4698. })
  4699. .then(function (data) {
  4700. // $scope.haocainame = data.list;
  4701. });
  4702. api_sysinfo
  4703. .addData({
  4704. // "type": "list",
  4705. key: "guige",
  4706. name: selectedItem.Specifications,
  4707. parent: data.id,
  4708. value: selectedItem.Specifications,
  4709. deleted: false,
  4710. level: 2,
  4711. })
  4712. .then(function (data) {
  4713. // $scope.haocainame = data.list;
  4714. });
  4715. });
  4716. // $scope.myData3.push(selectedItem);
  4717. // for (var i = 0; i < $scope.myData3.length; i++) {
  4718. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4719. // }
  4720. // $scope.model.applicationForm.consumables = $scope.myData3;
  4721. $scope.myData3all.push(selectedItem);
  4722. for (var i = 0; i < $scope.myData3all.length; i++) {
  4723. $scope.myData3all[i]["item"] = i + 1;
  4724. }
  4725. // $scope.model.consumables = $scope.myDataone;
  4726. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4727. $scope.myData3 = $scope.interceptMydata(
  4728. $scope.myData3all,
  4729. $scope.memoryfilterDatahao.idx,
  4730. 10
  4731. );
  4732. $scope.model.applicationForm.consumables = $scope.myData3all;
  4733. });
  4734. };
  4735. $scope.haocaiadd = function () {
  4736. event.preventDefault();
  4737. var modalInstance = $modal.open({
  4738. templateUrl:
  4739. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4740. controller: function (
  4741. $scope,
  4742. scope,
  4743. $modalInstance,
  4744. api_wechatfile,
  4745. SweetAlert,
  4746. api_cmdb3
  4747. ) {
  4748. $scope.haocainame = [];
  4749. $scope.pinpai = [];
  4750. $scope.guige = [];
  4751. $scope.consumptive = {};
  4752. $scope.consumpall = {};
  4753. $scope.title = "添加耗材";
  4754. api_wechatfile
  4755. .getDictionary({
  4756. key: "haocaifenlei",
  4757. type: "tree",
  4758. })
  4759. .then(function (data) {
  4760. $scope.haocainame = data;
  4761. });
  4762. $scope.clearNoNum = function (obj, attr) {
  4763. //先把非数字的都替换掉,除了数字和.
  4764. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4765. //必须保证第一个为数字而不是.
  4766. obj[attr] = obj[attr].replace(/^\./g, "");
  4767. //保证只有出现一个.而没有多个.
  4768. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4769. //保证.只出现一次,而不能出现两次以上
  4770. obj[attr] = obj[attr]
  4771. .replace(".", "$#$")
  4772. .replace(/\./g, "")
  4773. .replace("$#$", ".");
  4774. //小于最大值
  4775. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4776. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4777. // obj[attr] = '';
  4778. // }
  4779. };
  4780. $scope.onChange = function (parent) {
  4781. $scope.consumptive.model = {};
  4782. $scope.consumptive.Specifications = {};
  4783. api_wechatfile
  4784. .getDictionaryForList({
  4785. key: "pinpai",
  4786. parent: parent.id,
  4787. })
  4788. .then(function (data) {
  4789. $scope.pinpai = data;
  4790. });
  4791. api_wechatfile
  4792. .getDictionaryForList({
  4793. key: "guige",
  4794. parent: parent.id,
  4795. })
  4796. .then(function (data) {
  4797. $scope.guige = data;
  4798. });
  4799. };
  4800. $scope.addhaocai = function () {
  4801. $modalInstance.dismiss("cancel");
  4802. scope.haocaiopen($scope.consumptive);
  4803. };
  4804. $scope.ok = function (item) {
  4805. var items = {};
  4806. var submittrue = true;
  4807. if (
  4808. item.name &&
  4809. item.model &&
  4810. JSON.stringify(item.model) != "{}" &&
  4811. item.Specifications &&
  4812. JSON.stringify(item.Specifications) != "{}" &&
  4813. item.sum
  4814. ) {
  4815. items = {
  4816. modelid: item.model.id,
  4817. nameid: item.name.id,
  4818. Specificationsid: item.Specifications.id,
  4819. name: item.name.name,
  4820. model: item.model.name,
  4821. Specifications: item.Specifications.name,
  4822. sum: item.sum,
  4823. };
  4824. angular.forEach(scope.myData3all, function (itemsdata) {
  4825. if (
  4826. item.model.id == itemsdata.modelid &&
  4827. item.name.id == itemsdata.nameid &&
  4828. item.Specifications.id == itemsdata.Specificationsid
  4829. ) {
  4830. submittrue = false;
  4831. }
  4832. });
  4833. if (submittrue) {
  4834. $modalInstance.close(items);
  4835. } else {
  4836. SweetAlert.swal({
  4837. title: "该耗材已有添加",
  4838. text: "请检查数据然后提交!",
  4839. type: "error",
  4840. });
  4841. }
  4842. } else {
  4843. SweetAlert.swal({
  4844. title: "数据填写不完整!",
  4845. text: "请检查数据然后提交!",
  4846. type: "error",
  4847. });
  4848. }
  4849. // var isold = false;
  4850. // if (item.name && item.model && item.Specifications && item.sum) {
  4851. // for (var i = 0; i < scope.myData3all.length; i++) {
  4852. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4853. // isold = true;
  4854. // }
  4855. // }
  4856. // if (isold) {
  4857. // SweetAlert.swal({
  4858. // title: "该耗材已添加!",
  4859. // text: "请不要重复添加耗材!",
  4860. // type: "error"
  4861. // });
  4862. // } else {
  4863. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4864. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4865. // $scope.consumpall.sum = item.sum;
  4866. // delete $scope.consumpall.brandModel;
  4867. // delete $scope.consumpall.specification;
  4868. // $modalInstance.close($scope.consumpall);
  4869. // }
  4870. // } else {
  4871. // SweetAlert.swal({
  4872. // title: "数据填写不完整!",
  4873. // text: "请检查数据然后提交!",
  4874. // type: "error"
  4875. // });
  4876. // }
  4877. };
  4878. $scope.cancel = function () {
  4879. $modalInstance.dismiss("cancel");
  4880. };
  4881. },
  4882. size: "sm",
  4883. resolve: {
  4884. scope: function () {
  4885. return $scope;
  4886. },
  4887. },
  4888. });
  4889. modalInstance.result.then(function (selectedItem) {
  4890. $scope.myData3all.push(selectedItem);
  4891. for (var i = 0; i < $scope.myData3all.length; i++) {
  4892. $scope.myData3all[i]["item"] = i + 1;
  4893. }
  4894. // $scope.model.consumables = $scope.myDataone;
  4895. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4896. $scope.myData3 = $scope.interceptMydata(
  4897. $scope.myData3all,
  4898. $scope.memoryfilterDatahao.idx,
  4899. 10
  4900. );
  4901. $scope.model.applicationForm.consumables = $scope.myData3all;
  4902. });
  4903. };
  4904. $scope.onDblClick = function (data, event) {
  4905. $scope.selectButtonClick(data, event);
  4906. };
  4907. // $scope.memoryfilterDatahao = {
  4908. // "idx": 0,
  4909. // "sum": 10,
  4910. // }
  4911. // $scope.loadData = function(filterData) {};
  4912. // $scope.title = title;
  4913. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4914. $scope.options.templateOptions.transform(
  4915. $scope.options,
  4916. $rootScope,
  4917. $scope
  4918. );
  4919. }
  4920. },
  4921. ],
  4922. });
  4923. //归还设备耗材tab
  4924. formlyConfigProvider.setType({
  4925. name: "ui-cmdbreturntab",
  4926. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4927. wrapper: ["bootstrapHasError"],
  4928. defaultOptions: function (options, $scope) {
  4929. return {
  4930. templateOptions: {
  4931. // checkform: function(options) {
  4932. // if (options.model.requester) {
  4933. // options.value(options.model.requester);
  4934. // }
  4935. // },
  4936. },
  4937. };
  4938. },
  4939. controller: [
  4940. "$scope",
  4941. "$modal",
  4942. "api_user_data",
  4943. "i18nService",
  4944. "api_wechatfile",
  4945. "api_cmdb3",
  4946. function (
  4947. $scope,
  4948. $modal,
  4949. api_user_data,
  4950. i18nService,
  4951. api_wechatfile,
  4952. api_cmdb3
  4953. ) {
  4954. var setAllInactive = function () {
  4955. angular.forEach($scope.workspaces, function (workspace) {
  4956. workspace.active = false;
  4957. });
  4958. };
  4959. $scope.memoryfilterData = {
  4960. idx: 0,
  4961. sum: 10,
  4962. };
  4963. //添加
  4964. var addNewWorkspace = function (name, contentUrl) {
  4965. var id = $scope.workspaces.length + 1;
  4966. $scope.workspaces.push({
  4967. id: id,
  4968. name: name,
  4969. active: true,
  4970. contentUrl: "main/html/content.html",
  4971. });
  4972. };
  4973. $scope.workspaces = [
  4974. {
  4975. id: 1,
  4976. name: "归还设备",
  4977. active: true,
  4978. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4979. },
  4980. {
  4981. id: 2,
  4982. name: "归还耗材",
  4983. active: true,
  4984. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4985. },
  4986. ];
  4987. $scope.addWorkspace = function (contentUrl, name) {
  4988. setAllInactive();
  4989. addNewWorkspace(name, contentUrl);
  4990. };
  4991. // $rootScope.addWorkspace = $scope.addWorkspace;
  4992. $scope.close = function (idNumber) {
  4993. var index = 0; //记录当前元素下标
  4994. angular.forEach($scope.workspaces, function (workspace) {
  4995. if (workspace.id === idNumber) {
  4996. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4997. }
  4998. index++;
  4999. });
  5000. };
  5001. $scope.memoryfilterDataguishe = {
  5002. idx: 0,
  5003. sum: 10,
  5004. };
  5005. //grid1
  5006. $scope.langs = i18nService.getAllLangs();
  5007. $scope.lang = "zh-cn";
  5008. i18nService.setCurrentLang($scope.lang);
  5009. $scope.gridOptions1 = {};
  5010. $scope.gridOptions1.data = "myData1";
  5011. $scope.gridOptions1.enableColumnResizing = true;
  5012. $scope.gridOptions1.enableFiltering = false;
  5013. $scope.gridOptions1.enableGridMenu = false;
  5014. $scope.gridOptions1.showGridFooter = true;
  5015. $scope.gridOptions1.showColumnFooter = false;
  5016. $scope.gridOptions1.fastWatch = true;
  5017. $scope.gridOptions1.useExternalFiltering = true;
  5018. $scope.gridOptions1.useExternalPagination = true;
  5019. $scope.gridOptions1.paginationPageSizes = [10];
  5020. $scope.gridOptions1.paginationPageSize = 10;
  5021. $scope.gridOptions1.multiSelect = false;
  5022. // $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>";
  5023. $scope.gridOptions1.columnDefs = [
  5024. {
  5025. name: "item",
  5026. displayName: "序号",
  5027. width: 120,
  5028. },
  5029. {
  5030. name: "props.hw_cifilterClassic",
  5031. displayName: "设备类型",
  5032. width: 150,
  5033. enableFiltering: false,
  5034. },
  5035. {
  5036. name: "props.hw_mingcheng",
  5037. displayName: "设备名称",
  5038. width: 180,
  5039. enableFiltering: false,
  5040. },
  5041. {
  5042. name: "uuid",
  5043. displayName: "设备编号",
  5044. width: 180,
  5045. enableFiltering: false,
  5046. },
  5047. {
  5048. name: "props.hw_state",
  5049. width: 150,
  5050. displayName: "状态",
  5051. enableFiltering: false,
  5052. },
  5053. {
  5054. name: "操作",
  5055. cellTemplate:
  5056. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5057. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5058. "</div></div>",
  5059. enableFiltering: false,
  5060. },
  5061. ];
  5062. // $scope.selectButtonClick
  5063. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5064. $scope.gridApi = gridApi;
  5065. gridApi.pagination.on.paginationChanged(
  5066. $scope,
  5067. function (newPage, pageSize) {
  5068. // var filtersData = $scope.memoryfilterData;
  5069. // filtersData.idx = newPage - 1;
  5070. // filtersData.sum = pageSize;
  5071. // $scope.loadData(filtersData);
  5072. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5073. $scope.memoryfilterDataguishe.sum = pageSize;
  5074. $scope.myData1 = $scope.interceptMydata(
  5075. $scope.myData2all,
  5076. $scope.memoryfilterDataguishe.idx,
  5077. 10
  5078. );
  5079. }
  5080. );
  5081. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5082. $scope.selected.items = data.entity;
  5083. //console.log(data);
  5084. });
  5085. gridApi.selection.on.rowSelectionChangedBatch(
  5086. $scope,
  5087. function (data) {
  5088. $scope.selected.items = data.entity;
  5089. //console.log(data);
  5090. }
  5091. );
  5092. gridApi.core.on.filterChanged($scope, function () {
  5093. // var grid = this.grid;
  5094. // var filtersData = {
  5095. // idx: 0,
  5096. // sum: 20,
  5097. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5098. // };
  5099. // angular.forEach(grid.columns, function(item) {
  5100. // if (item.enableFiltering) {
  5101. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5102. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5103. // if (angular.isUndefined(filtersData['user'])) {
  5104. // filtersData['user'] = {};
  5105. // }
  5106. // filtersData['user'][item.field] = item.filters[0].term;
  5107. // }
  5108. // }
  5109. // });
  5110. // $scope.memoryfilterData = filtersData;
  5111. // $scope.loadData(filtersData);
  5112. });
  5113. };
  5114. $scope.changegu = function (item) {
  5115. event.preventDefault();
  5116. var modalInstance = $modal.open({
  5117. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5118. controller: function ($scope, $modalInstance) {
  5119. $scope.title = "修改设备状态";
  5120. $scope.hw_state = {};
  5121. if (item.status) {
  5122. $scope.hw_state.name = item.hw_state;
  5123. }
  5124. // $scope.consumptive = item;
  5125. $scope.stateshe = [
  5126. {
  5127. id: 2,
  5128. name: "在库",
  5129. },
  5130. {
  5131. id: 4,
  5132. name: "报修",
  5133. },
  5134. {
  5135. id: 3,
  5136. name: "报废",
  5137. },
  5138. ];
  5139. $scope.ok = function (item) {
  5140. $modalInstance.close($scope.hw_state);
  5141. };
  5142. $scope.cancel = function () {
  5143. $modalInstance.dismiss("cancel");
  5144. };
  5145. },
  5146. size: "sm",
  5147. });
  5148. modalInstance.result.then(function (selectedItem) {
  5149. angular.forEach($scope.myData1, function (items, index) {
  5150. if (items.id == item.id) {
  5151. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5152. }
  5153. });
  5154. $scope.model.assets = $scope.myData1;
  5155. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5156. $scope.model.assets;
  5157. });
  5158. };
  5159. $scope.onDblClick = function (data, event) {
  5160. $scope.selectButtonClick(data, event);
  5161. };
  5162. $scope.memoryfilterData = {
  5163. idx: 0,
  5164. sum: 10,
  5165. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5166. };
  5167. // $scope.myData = {};
  5168. $scope.loadData = function (filterData) {};
  5169. // $scope.title = title;
  5170. $scope.loadData({
  5171. idx: 0,
  5172. sum: 10,
  5173. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5174. });
  5175. $scope.selected = {
  5176. items: [],
  5177. };
  5178. $scope.myData2 = [];
  5179. $scope.consumptive = {};
  5180. $scope.myDataguibeiall = [];
  5181. $scope.haocaiopen = function (items) {
  5182. event.preventDefault();
  5183. var modalInstance = $modal.open({
  5184. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5185. controller: function (
  5186. $scope,
  5187. $modalInstance,
  5188. SweetAlert,
  5189. api_wechatfile,
  5190. api_sysinfo
  5191. ) {
  5192. $scope.consumptive = {};
  5193. $scope.title = "新增耗材";
  5194. if (items.name) {
  5195. $scope.consumptive.name = items.name.name;
  5196. }
  5197. $scope.ok = function (item) {
  5198. if (
  5199. item.name &&
  5200. item.model &&
  5201. JSON.stringify(item.model) != "{}" &&
  5202. item.Specifications &&
  5203. JSON.stringify(item.Specifications) != "{}" &&
  5204. item.sum
  5205. ) {
  5206. $modalInstance.close(item);
  5207. } else {
  5208. SweetAlert.swal({
  5209. title: "数据填写不完整!",
  5210. text: "请检查数据然后提交!",
  5211. type: "error",
  5212. });
  5213. }
  5214. };
  5215. $scope.cancel = function () {
  5216. $modalInstance.dismiss("cancel");
  5217. };
  5218. },
  5219. size: "sm",
  5220. });
  5221. modalInstance.result.then(function (selectedItem) {
  5222. api_sysinfo
  5223. .addData({
  5224. type: "list",
  5225. key: "haocaifenlei",
  5226. name: selectedItem.name,
  5227. parent: selectedItem.id,
  5228. value: "1",
  5229. })
  5230. .then(function (data) {
  5231. // $scope.haocainame.name = data.list;
  5232. api_wechatfile
  5233. .addDictionary({
  5234. type: "list",
  5235. key: "pinpai",
  5236. name: selectedItem.model,
  5237. parent: data.id,
  5238. value: "1",
  5239. })
  5240. .then(function (data) {
  5241. // $scope.haocainame = data.list;
  5242. });
  5243. api_wechatfile
  5244. .addDictionary({
  5245. type: "list",
  5246. key: "guige",
  5247. name: selectedItem.Specifications,
  5248. parent: data.id,
  5249. value: "1",
  5250. })
  5251. .then(function (data) {
  5252. // $scope.haocainame = data.list;
  5253. });
  5254. });
  5255. $scope.myData2.push(selectedItem);
  5256. for (var i = 0; i < $scope.myData2.length; i++) {
  5257. $scope.myData2[i]["item"] =
  5258. i + 1 + $scope.memoryfilterData.idx * 10;
  5259. }
  5260. // $scope.model.applicationForm.consumables = $scope.myData2;
  5261. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5262. if (items.id == selectedItem.id) {
  5263. $scope.myDataguibeiall.splice(index, 1);
  5264. }
  5265. });
  5266. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5267. $scope.model.consumables = $scope.myDataguibeiall;
  5268. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5269. $scope.model.consumables;
  5270. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5271. });
  5272. };
  5273. //grid2
  5274. $scope.langs = i18nService.getAllLangs();
  5275. $scope.lang = "zh-cn";
  5276. i18nService.setCurrentLang($scope.lang);
  5277. $scope.gridOptions2 = {};
  5278. $scope.gridOptions2.data = "myData2";
  5279. $scope.gridOptions2.enableColumnResizing = true;
  5280. $scope.gridOptions2.enableFiltering = false;
  5281. $scope.gridOptions2.enableGridMenu = false;
  5282. $scope.gridOptions2.showGridFooter = true;
  5283. $scope.gridOptions2.showColumnFooter = false;
  5284. $scope.gridOptions2.fastWatch = true;
  5285. $scope.gridOptions2.useExternalFiltering = true;
  5286. $scope.gridOptions2.useExternalPagination = true;
  5287. $scope.gridOptions2.paginationPageSizes = [10];
  5288. $scope.gridOptions2.paginationPageSize = 10;
  5289. $scope.gridOptions2.multiSelect = false;
  5290. // $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>";
  5291. $scope.modelcons = {};
  5292. $scope.modelass = {};
  5293. $scope.myData2all = [];
  5294. $scope.myData1all = [];
  5295. $scope.memoryfilterDatagui = {
  5296. idx: 0,
  5297. sum: 10,
  5298. };
  5299. setInterval(function () {
  5300. if ($scope.model.assets) {
  5301. if (
  5302. $scope.model.assets != $scope.modelass &&
  5303. typeof $scope.model.assets == "string"
  5304. ) {
  5305. $scope.modelass = $scope.model.assets;
  5306. if (JSON.stringify($scope.model.assets) == "{}") {
  5307. $scope.model.assets = [];
  5308. } else {
  5309. $scope.model.assets = JSON.parse($scope.model.assets);
  5310. }
  5311. // $scope.myData1 = $scope.model.assets;
  5312. // for (var i = 0; i < $scope.myData1.length; i++) {
  5313. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5314. // }
  5315. $scope.myData1all = $scope.model.assets;
  5316. for (var i = 0; i < $scope.myData1all.length; i++) {
  5317. $scope.myData1all[i]["item"] =
  5318. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5319. }
  5320. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5321. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5322. }
  5323. }
  5324. if ($scope.model.consumables) {
  5325. if (
  5326. $scope.model.consumables != $scope.modelcons &&
  5327. typeof $scope.model.consumables == "string"
  5328. ) {
  5329. $scope.modelass = $scope.model.consumables;
  5330. if (JSON.stringify($scope.model.consumables) == "{}") {
  5331. $scope.model.consumables = [];
  5332. } else {
  5333. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5334. }
  5335. // $scope.myData2 = $scope.model.consumables;
  5336. // for (var i = 0; i < $scope.myData2.length; i++) {
  5337. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5338. // }
  5339. $scope.myData2all = $scope.model.consumables;
  5340. for (var i = 0; i < $scope.myData2all.length; i++) {
  5341. $scope.myData2all[i]["item"] =
  5342. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5343. }
  5344. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5345. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5346. // $scope.model.consumables = $scope.myData2all;
  5347. }
  5348. }
  5349. }, 100);
  5350. $scope.gridOptions2.columnDefs = [
  5351. {
  5352. name: "item",
  5353. displayName: "序号",
  5354. width: 120,
  5355. },
  5356. {
  5357. name: "name",
  5358. displayName: "耗材名称",
  5359. width: 180,
  5360. enableFiltering: false,
  5361. },
  5362. {
  5363. name: "model",
  5364. displayName: "品牌/型号",
  5365. width: 180,
  5366. enableFiltering: false,
  5367. },
  5368. {
  5369. name: "Specifications",
  5370. displayName: "规格",
  5371. width: 150,
  5372. enableFiltering: false,
  5373. },
  5374. {
  5375. name: "sum",
  5376. width: 150,
  5377. displayName: "数量",
  5378. enableFiltering: false,
  5379. },
  5380. {
  5381. name: "操作",
  5382. cellTemplate:
  5383. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5384. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5385. "</div></div>",
  5386. enableFiltering: false,
  5387. },
  5388. ];
  5389. // $scope.selectButtonClick
  5390. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5391. $scope.gridApi = gridApi;
  5392. gridApi.pagination.on.paginationChanged(
  5393. $scope,
  5394. function (newPage, pageSize) {
  5395. // var filtersData = $scope.memoryfilterDatagui;
  5396. // filtersData.idx = newPage - 1;
  5397. // filtersData.sum = pageSize;
  5398. $scope.memoryfilterDatagui.idx = newPage - 1;
  5399. $scope.memoryfilterDatagui.sum = pageSize;
  5400. $scope.myData2 = $scope.interceptMydata(
  5401. $scope.myData2all,
  5402. $scope.memoryfilterDatagui.idx,
  5403. 10
  5404. );
  5405. }
  5406. );
  5407. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5408. $scope.selected.items = data.entity;
  5409. //console.log(data);
  5410. });
  5411. gridApi.selection.on.rowSelectionChangedBatch(
  5412. $scope,
  5413. function (data) {
  5414. $scope.selected.items = data.entity;
  5415. //console.log(data);
  5416. }
  5417. );
  5418. gridApi.core.on.filterChanged($scope, function () {
  5419. var grid = this.grid;
  5420. var filtersData = {
  5421. idx: 0,
  5422. sum: 10,
  5423. };
  5424. angular.forEach(grid.columns, function (item) {
  5425. if (item.enableFiltering) {
  5426. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5427. if (
  5428. angular.isDefined(item.filters[0].term) &&
  5429. item.filters[0].term != ""
  5430. ) {
  5431. if (angular.isUndefined(filtersData["user"])) {
  5432. filtersData["user"] = {};
  5433. }
  5434. filtersData["user"][item.field] = item.filters[0].term;
  5435. }
  5436. }
  5437. });
  5438. $scope.memoryfilterData = filtersData;
  5439. $scope.loadData(filtersData);
  5440. });
  5441. };
  5442. $scope.changecai = function (item) {
  5443. event.preventDefault();
  5444. var modalInstance = $modal.open({
  5445. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5446. controller: function ($scope, $modalInstance) {
  5447. $scope.title = "修改耗材数量";
  5448. $scope.consumptive = angular.copy(item);
  5449. // $scope.consumptive = item;
  5450. $scope.maxsum = item.inventoryNum;
  5451. $scope.clearNoNum = function (obj, attr) {
  5452. //先把非数字的都替换掉,除了数字和.
  5453. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5454. //必须保证第一个为数字而不是.
  5455. obj[attr] = obj[attr].replace(/^\./g, "");
  5456. //保证只有出现一个.而没有多个.
  5457. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5458. //保证.只出现一次,而不能出现两次以上
  5459. obj[attr] = obj[attr]
  5460. .replace(".", "$#$")
  5461. .replace(/\./g, "")
  5462. .replace("$#$", ".");
  5463. //小于最大值
  5464. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5465. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5466. // obj[attr] = '';
  5467. // }
  5468. };
  5469. $scope.ok = function () {
  5470. $modalInstance.close($scope.consumptive);
  5471. };
  5472. $scope.cancel = function () {
  5473. $modalInstance.dismiss("cancel");
  5474. };
  5475. },
  5476. size: "sm",
  5477. });
  5478. modalInstance.result.then(function (selectedItem) {
  5479. angular.forEach($scope.myData2all, function (items, index) {
  5480. // if (items.id == selectedItem.id) {
  5481. if (
  5482. items.modelid == selectedItem.modelid &&
  5483. items.nameid == selectedItem.nameid &&
  5484. items.Specificationsid == selectedItem.Specificationsid
  5485. ) {
  5486. angular.extend($scope.myData2all[index], selectedItem);
  5487. }
  5488. });
  5489. // $scope.model.consumables = $scope.myData2;
  5490. // $scope.myData2 = $scope.model.consumables;
  5491. // $scope.myData2all.push(selectedItem);
  5492. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5493. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5494. // }
  5495. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5496. $scope.myData2 = $scope.interceptMydata(
  5497. $scope.myData2all,
  5498. $scope.memoryfilterDatagui.idx,
  5499. 10
  5500. );
  5501. $scope.model.consumables = $scope.myData2all;
  5502. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5503. $scope.model.consumables;
  5504. });
  5505. };
  5506. $scope.interceptMydata = function (mydate, idx, sum) {
  5507. return mydate.slice(idx * sum, (idx + 1) * sum);
  5508. };
  5509. $scope.haocaiadd = function () {
  5510. event.preventDefault();
  5511. var modalInstance = $modal.open({
  5512. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5513. controller: function (
  5514. $scope,
  5515. scope,
  5516. $modalInstance,
  5517. api_wechatfile,
  5518. SweetAlert
  5519. ) {
  5520. $scope.haocainame = [];
  5521. $scope.pinpai = [];
  5522. $scope.guige = [];
  5523. $scope.consumptive = {};
  5524. $scope.consumptiveall = {};
  5525. $scope.title = "添加耗材";
  5526. api_wechatfile
  5527. .getDictionaryForList({
  5528. key: "haocaifenlei",
  5529. })
  5530. .then(function (data) {
  5531. $scope.haocainame = data;
  5532. });
  5533. $scope.clearNoNum = function (obj, attr) {
  5534. //先把非数字的都替换掉,除了数字和.
  5535. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5536. //必须保证第一个为数字而不是.
  5537. obj[attr] = obj[attr].replace(/^\./g, "");
  5538. //保证只有出现一个.而没有多个.
  5539. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5540. //保证.只出现一次,而不能出现两次以上
  5541. obj[attr] = obj[attr]
  5542. .replace(".", "$#$")
  5543. .replace(/\./g, "")
  5544. .replace("$#$", ".");
  5545. //小于最大值
  5546. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5547. alert(
  5548. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5549. );
  5550. obj[attr] = "";
  5551. }
  5552. };
  5553. $scope.onChange = function (parent) {
  5554. $scope.consumptive.model = {};
  5555. $scope.consumptive.Specifications = {};
  5556. api_wechatfile
  5557. .getDictionaryForList({
  5558. key: "pinpai",
  5559. parent: parent.id,
  5560. })
  5561. .then(function (data) {
  5562. $scope.pinpai = data;
  5563. });
  5564. api_wechatfile
  5565. .getDictionaryForList({
  5566. key: "guige",
  5567. parent: parent.id,
  5568. })
  5569. .then(function (data) {
  5570. $scope.guige = data;
  5571. });
  5572. };
  5573. // $scope.onChangesum = function(item) {
  5574. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5575. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5576. // $scope.consumptiveall = data1;
  5577. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5578. // // if (data.list && data.list.length != 0) {
  5579. // // var myData = data.list;
  5580. // // $scope.consumptiveall = myData[0];
  5581. // // $scope.maxsum = myData[0].inventoryNum;
  5582. // // } else if (data.list && data.list.length == 0) {
  5583. // // SweetAlert.swal({
  5584. // // title: "库存数据存在问题!",
  5585. // // text: "请检查库存数据!",
  5586. // // type: "error"
  5587. // // });
  5588. // // }
  5589. // // });
  5590. // }
  5591. // }
  5592. $scope.addhaocai = function () {
  5593. $modalInstance.dismiss("cancel");
  5594. scope.haocaiopen($scope.consumptive);
  5595. };
  5596. $scope.ok = function (item) {
  5597. var submittrue = true;
  5598. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5599. var data = {
  5600. modelid: item.model.id,
  5601. nameid: item.name.id,
  5602. Specificationsid: item.Specifications.id,
  5603. name: item.name.name,
  5604. model: item.model.name,
  5605. Specifications: item.Specifications.name,
  5606. sum: item.sum,
  5607. };
  5608. if (
  5609. item.name &&
  5610. item.model &&
  5611. JSON.stringify(item.model) != "{}" &&
  5612. item.Specifications &&
  5613. JSON.stringify(item.Specifications) != "{}" &&
  5614. item.sum
  5615. ) {
  5616. // $modalInstance.close(data);
  5617. angular.forEach(scope.myData2all, function (itemsdata) {
  5618. // if (item.model.id == itemsdata.id) {
  5619. if (
  5620. item.model.id == itemsdata.modelid &&
  5621. item.name.id == itemsdata.nameid &&
  5622. item.Specifications.id == itemsdata.Specificationsid
  5623. ) {
  5624. submittrue = false;
  5625. }
  5626. });
  5627. if (submittrue) {
  5628. $modalInstance.close(data);
  5629. } else {
  5630. SweetAlert.swal({
  5631. title: "该耗材已有添加",
  5632. text: "请检查数据然后提交!",
  5633. type: "error",
  5634. });
  5635. }
  5636. } else {
  5637. SweetAlert.swal({
  5638. title: "数据填写不完整!",
  5639. text: "请检查数据然后提交!",
  5640. type: "error",
  5641. });
  5642. }
  5643. };
  5644. $scope.cancel = function () {
  5645. $modalInstance.dismiss("cancel");
  5646. };
  5647. },
  5648. size: "sm",
  5649. resolve: {
  5650. scope: function () {
  5651. return $scope;
  5652. },
  5653. },
  5654. });
  5655. modalInstance.result.then(function (selectedItem) {
  5656. // $scope.myData2.push(selectedItem);
  5657. // for (var i = 0; i < $scope.myData2.length; i++) {
  5658. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5659. // }
  5660. // $scope.model.consumables = $scope.myData2;
  5661. $scope.myData2all.push(selectedItem);
  5662. for (var i = 0; i < $scope.myData2all.length; i++) {
  5663. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5664. $scope.myData2all[i]["item"] = i + 1;
  5665. }
  5666. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5667. $scope.myData2 = $scope.interceptMydata(
  5668. $scope.myData2all,
  5669. $scope.memoryfilterDatagui.idx,
  5670. 10
  5671. );
  5672. $scope.model.consumables = $scope.myData2all;
  5673. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5674. $scope.model.consumables;
  5675. });
  5676. };
  5677. $scope.onDblClick = function (data, event) {
  5678. $scope.selectButtonClick(data, event);
  5679. };
  5680. $scope.memoryfilterData = {
  5681. idx: 0,
  5682. sum: 20,
  5683. user: {
  5684. roledata: {
  5685. rolecode: "roleset",
  5686. },
  5687. selectType: "1",
  5688. },
  5689. };
  5690. $scope.myData = {};
  5691. $scope.loadData = function (filterData) {};
  5692. // $scope.title = title;
  5693. $scope.loadData({
  5694. idx: 0,
  5695. sum: 20,
  5696. user: {
  5697. roledata: {
  5698. rolecode: "roleset",
  5699. },
  5700. selectType: "1",
  5701. },
  5702. });
  5703. $scope.selected = {
  5704. items: {},
  5705. };
  5706. },
  5707. ],
  5708. });
  5709. //tab 列表
  5710. formlyConfigProvider.setType({
  5711. name: "ui-cmdbtab",
  5712. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5713. wrapper: ["bootstrapHasError"],
  5714. defaultOptions: function (options, $scope) {
  5715. return {
  5716. templateOptions: {},
  5717. };
  5718. },
  5719. controller: [
  5720. "$scope",
  5721. "api_user_data",
  5722. "i18nService",
  5723. "$modal",
  5724. "api_cmdb",
  5725. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5726. $scope.memoryfilterDatashe = {
  5727. idx: 0,
  5728. sum: 10,
  5729. };
  5730. $scope.myDataoneall = [];
  5731. var setAllInactive = function () {
  5732. angular.forEach($scope.workspaces, function (workspace) {
  5733. workspace.active = false;
  5734. });
  5735. };
  5736. //添加
  5737. var addNewWorkspace = function (name, contentUrl) {
  5738. var id = $scope.workspaces.length + 1;
  5739. $scope.workspaces.push({
  5740. id: id,
  5741. name: name,
  5742. active: true,
  5743. contentUrl: "main/html/content.html",
  5744. });
  5745. };
  5746. //关闭
  5747. $scope.remove = function (closedata) {
  5748. event.preventDefault();
  5749. angular.forEach($scope.workspaces, function (item, index) {
  5750. if (closedata.id == item.id) {
  5751. if (closedata.id == 1) {
  5752. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5753. } else {
  5754. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5755. }
  5756. $scope.workspaces.splice(index, 1);
  5757. }
  5758. });
  5759. };
  5760. $scope.workspaces = [];
  5761. $scope.options.templateOptions.getpush = function (item) {
  5762. $scope.workspaces = [];
  5763. if (item.gu) {
  5764. $scope.workspaces.push({
  5765. id: 1,
  5766. name: "领用设备",
  5767. active: true,
  5768. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5769. });
  5770. }
  5771. if (item.hao) {
  5772. $scope.workspaces.push({
  5773. id: 2,
  5774. name: "领用耗材",
  5775. active: true,
  5776. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5777. });
  5778. }
  5779. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5780. };
  5781. $scope.addWorkspace = function (contentUrl, name) {
  5782. setAllInactive();
  5783. addNewWorkspace(name, contentUrl);
  5784. };
  5785. // $rootScope.addWorkspace = $scope.addWorkspace;
  5786. // $scope.remove = function(idNumber) {
  5787. // var index = 0; //记录当前元素下标
  5788. // angular.forEach($scope.workspaces, function(workspace) {
  5789. // if (workspace.id === idNumber.id) {
  5790. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5791. // }
  5792. // index++;
  5793. // });
  5794. // };
  5795. // setInterval(function() {
  5796. // if ($scope.model.assets) {
  5797. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5798. // $scope.modelass = $scope.model.assets;
  5799. // if (JSON.stringify($scope.model.assets) == "{}") {
  5800. // $scope.model.assets = []
  5801. // } else {
  5802. // $scope.model.assets = JSON.parse($scope.model.assets);
  5803. // }
  5804. // $scope.myDatalingbeiall = $scope.model.assets;
  5805. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5806. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5807. // }
  5808. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5809. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5810. // }
  5811. // }
  5812. // if ($scope.model.consumables) {
  5813. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5814. // $scope.modelass = $scope.model.consumables;
  5815. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5816. // $scope.model.consumables = [];
  5817. // } else {
  5818. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5819. // }
  5820. // $scope.myDatalingbeiall = $scope.model.consumables;
  5821. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5822. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5823. // }
  5824. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5825. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5826. // // $scope.model.consumables = $scope.myData2all;
  5827. // }
  5828. // }
  5829. // }, 100);
  5830. //grid1
  5831. $scope.langs = i18nService.getAllLangs();
  5832. $scope.lang = "zh-cn";
  5833. i18nService.setCurrentLang($scope.lang);
  5834. $scope.gridOptions1 = {};
  5835. $scope.gridOptions1.data = "myDatalingbei";
  5836. $scope.gridOptions1.enableColumnResizing = true;
  5837. $scope.gridOptions1.enableFiltering = false;
  5838. $scope.gridOptions1.enableGridMenu = false;
  5839. $scope.gridOptions1.showGridFooter = true;
  5840. $scope.gridOptions1.showColumnFooter = false;
  5841. $scope.gridOptions1.fastWatch = true;
  5842. $scope.gridOptions1.useExternalFiltering = true;
  5843. $scope.gridOptions1.useExternalPagination = true;
  5844. $scope.gridOptions1.paginationPageSizes = [10];
  5845. $scope.gridOptions1.paginationPageSize = 10;
  5846. $scope.gridOptions1.multiSelect = false;
  5847. // $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>";
  5848. $scope.gridOptions1.columnDefs = [
  5849. {
  5850. name: "item",
  5851. displayName: "序号",
  5852. width: 120,
  5853. },
  5854. {
  5855. name: "props.hw_cifilterClassic",
  5856. displayName: "设备类型",
  5857. width: 150,
  5858. enableFiltering: false,
  5859. },
  5860. {
  5861. name: "props.hw_mingcheng",
  5862. displayName: "设备名称",
  5863. width: 100,
  5864. enableFiltering: false,
  5865. },
  5866. {
  5867. name: "uuid",
  5868. displayName: "设备编号",
  5869. enableFiltering: false,
  5870. },
  5871. ];
  5872. $scope.myDatalingbeiall = [];
  5873. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5874. $scope.gridApi = gridApi;
  5875. gridApi.pagination.on.paginationChanged(
  5876. $scope,
  5877. function (newPage, pageSize) {
  5878. // var filtersData = $scope.memoryfilterData;
  5879. // filtersData.idx = newPage - 1;
  5880. // filtersData.sum = pageSize;
  5881. // $scope.loadData(filtersData);
  5882. $scope.memoryfilterDatashe.idx = newPage - 1;
  5883. $scope.memoryfilterDatashe.sum = pageSize;
  5884. $scope.myDatalingbei = $scope.interceptMydata(
  5885. $scope.myDatalingbeiall,
  5886. $scope.memoryfilterDatashe.idx,
  5887. 10
  5888. );
  5889. }
  5890. );
  5891. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5892. $scope.selected.items = data.entity;
  5893. //console.log(data);
  5894. });
  5895. gridApi.selection.on.rowSelectionChangedBatch(
  5896. $scope,
  5897. function (data) {
  5898. $scope.selected.items = data.entity;
  5899. //console.log(data);
  5900. }
  5901. );
  5902. gridApi.core.on.filterChanged($scope, function () {
  5903. var grid = this.grid;
  5904. var filtersData = {
  5905. idx: 0,
  5906. sum: 20,
  5907. user: {
  5908. roledata: {
  5909. rolecode: "roleset",
  5910. },
  5911. selectType: "1",
  5912. },
  5913. };
  5914. angular.forEach(grid.columns, function (item) {
  5915. if (item.enableFiltering) {
  5916. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5917. if (
  5918. angular.isDefined(item.filters[0].term) &&
  5919. item.filters[0].term != ""
  5920. ) {
  5921. if (angular.isUndefined(filtersData["user"])) {
  5922. filtersData["user"] = {};
  5923. }
  5924. filtersData["user"][item.field] = item.filters[0].term;
  5925. }
  5926. }
  5927. });
  5928. $scope.memoryfilterDatashe = filtersData;
  5929. // $scope.loadData(filtersData);
  5930. });
  5931. };
  5932. $scope.interceptMydata = function (mydate, idx, sum) {
  5933. return mydate.slice(idx * sum, (idx + 1) * sum);
  5934. };
  5935. $scope.removeshebei = function (item) {
  5936. event.preventDefault();
  5937. var modalInstance = $modal.open({
  5938. templateUrl: "assets/views/delete.html",
  5939. controller: function ($scope, $modalInstance, scope) {
  5940. $scope.title = "设备移除";
  5941. $scope.connect = "确定要移除此设备?";
  5942. $scope.consumptive = scope.selected.items;
  5943. $scope.ok = function () {
  5944. $modalInstance.close($scope.consumptive);
  5945. };
  5946. $scope.cancel = function () {
  5947. $modalInstance.dismiss("cancel");
  5948. };
  5949. },
  5950. size: "sm",
  5951. resolve: {
  5952. scope: function () {
  5953. return $scope;
  5954. },
  5955. },
  5956. });
  5957. modalInstance.result.then(function (selectedItem) {
  5958. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5959. if (items.id == selectedItem.id) {
  5960. $scope.myDatalingbeiall.splice(index, 1);
  5961. }
  5962. });
  5963. // $scope.myData3.push(selectedItem);
  5964. $scope.model.consumables = $scope.myDatalingbeiall;
  5965. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5966. $scope.myDatalingbeiall;
  5967. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5968. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5969. $scope.myDatalingbeiall[i]["item"] =
  5970. i +
  5971. 1 +
  5972. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5973. }
  5974. $scope.myDatalingbei = $scope.interceptMydata(
  5975. $scope.myDatalingbeiall,
  5976. 0,
  5977. 10
  5978. );
  5979. });
  5980. };
  5981. $scope.addshebei = function () {
  5982. event.preventDefault();
  5983. var modalInstance = $modal.open({
  5984. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5985. controller: function (
  5986. $scope,
  5987. i18nService,
  5988. $modalInstance,
  5989. items,
  5990. title,
  5991. Restangular,
  5992. APIService,
  5993. onDataCallback,
  5994. parentScope,
  5995. api_configure_data,
  5996. api_configure_form
  5997. ) {
  5998. $scope.langs = i18nService.getAllLangs();
  5999. $scope.lang = "zh-cn";
  6000. i18nService.setCurrentLang($scope.lang);
  6001. $scope.gridOptions = {};
  6002. $scope.gridOptions.data = "myDatatwo";
  6003. $scope.gridOptions.enableColumnResizing = true;
  6004. $scope.gridOptions.enableFiltering = false;
  6005. $scope.gridOptions.enableGridMenu = false;
  6006. $scope.gridOptions.showGridFooter = true;
  6007. $scope.gridOptions.showColumnFooter = false;
  6008. $scope.gridOptions.fastWatch = true;
  6009. $scope.gridOptions.useExternalFiltering = true;
  6010. $scope.gridOptions.useExternalPagination = true;
  6011. $scope.gridOptions.paginationPageSizes = [10];
  6012. $scope.gridOptions.paginationPageSize = 10;
  6013. $scope.gridOptions.multiSelect = true;
  6014. $scope.gridOptions.rowIdentity = function (row) {
  6015. return row.id;
  6016. };
  6017. $scope.gridOptions.getRowIdentity = function (row) {
  6018. return row.id;
  6019. };
  6020. // $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>";
  6021. $scope.gridOptions.columnDefs = [
  6022. {
  6023. name: "item",
  6024. displayName: "序号",
  6025. width: 80,
  6026. enableFiltering: false,
  6027. },
  6028. {
  6029. name: "uuid",
  6030. displayName: "内部编号",
  6031. width: 175,
  6032. },
  6033. {
  6034. name: "props.hw_mingcheng",
  6035. displayName: "资产名称",
  6036. width: 120,
  6037. },
  6038. {
  6039. name: "props.hw_cifilterClassic",
  6040. displayName: "资产类型",
  6041. width: 80,
  6042. enableFiltering: false,
  6043. },
  6044. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6045. {
  6046. name: "props.hw_state",
  6047. displayName: "资产状态",
  6048. width: 150,
  6049. enableFiltering: false,
  6050. },
  6051. {
  6052. name: "props.hwnw_area",
  6053. displayName: "资产地点",
  6054. width: 130,
  6055. enableFiltering: false,
  6056. },
  6057. {
  6058. name: "createtime",
  6059. displayName: "申请时间",
  6060. enableFiltering: false,
  6061. },
  6062. ];
  6063. // $scope.selectButtonClick
  6064. var defaultFilterData = {
  6065. // "assignee":2,
  6066. // "sign":"basehwitndl",
  6067. // "applicationForm": { "hw_state": "在线" },
  6068. hw_state: "在库",
  6069. idx: 0,
  6070. sum: 10,
  6071. };
  6072. $scope.memoryfilterData = {
  6073. // "assignee":2,
  6074. // "sign":"basehwitndl",
  6075. // "applicationForm": { "hw_state": "在线" },
  6076. hw_state: "在库",
  6077. idx: 0,
  6078. sum: 10,
  6079. };
  6080. $scope.refreshData = function (style, filterData) {
  6081. if (angular.isUndefined(filterData)) {
  6082. filterData = defaultFilterData;
  6083. }
  6084. $scope.myDatatwo = [];
  6085. // $scope.gridOptions['sum']=filterData.sum;
  6086. api_cmdb.query(filterData).then(
  6087. function (data) {
  6088. // $scope.callsPending--;
  6089. var filterData = $scope.memoryfilterData;
  6090. var myDatatwo = Restangular.stripRestangular(data);
  6091. $scope.gridOptions["totalItems"] = data.total;
  6092. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6093. myDatatwo.data.node[i].createtime = moment(
  6094. myDatatwo.data.node[i].createtime
  6095. ).format("YYYY-MM-DD");
  6096. }
  6097. $scope.myDatatwo = myDatatwo.data.node;
  6098. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6099. $scope.myDatatwo[i]["item"] =
  6100. i + 1 + filterData.idx * filterData.sum;
  6101. }
  6102. },
  6103. function () {}
  6104. );
  6105. };
  6106. $scope.refreshData("expand-right", defaultFilterData);
  6107. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6108. $scope.gridApi = gridApi;
  6109. gridApi.pagination.on.paginationChanged(
  6110. $scope,
  6111. function (newPage, pageSize) {
  6112. var filtersData = $scope.memoryfilterData;
  6113. filtersData.idx = newPage - 1;
  6114. filtersData.sum = pageSize;
  6115. // $scope.loadData(filtersData);
  6116. $scope.refreshData("expand-right", filtersData);
  6117. //console.log(pageSize);
  6118. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6119. }
  6120. );
  6121. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6122. // $scope.selected.items.push(data.entity);
  6123. //console.log(data);
  6124. gridApi.selection.on.rowSelectionChanged(
  6125. $scope,
  6126. function (scope, ect) {
  6127. if (scope.isSelected) {
  6128. scope.grid.appScope.selected.items.push(scope.entity);
  6129. } else {
  6130. for (
  6131. var i = 0;
  6132. i <= scope.grid.appScope.selected.items.length;
  6133. i++
  6134. ) {
  6135. if (
  6136. scope.grid.appScope.selected.items[i].id ==
  6137. scope.entity.id
  6138. ) {
  6139. scope.grid.appScope.selected.items.splice(i, 1);
  6140. break;
  6141. }
  6142. }
  6143. }
  6144. $scope.mySelectedRows =
  6145. $scope.gridApi.selection.getSelectedRows();
  6146. }
  6147. );
  6148. // });
  6149. gridApi.selection.on.rowSelectionChangedBatch(
  6150. $scope,
  6151. function (rows) {
  6152. // $scope.selected.items = data.entity;
  6153. //console.log(data);
  6154. var selectitem = [];
  6155. selectitem = angular.copy($scope.selected.items);
  6156. for (var j = 0; j < rows.length; j++) {
  6157. if (rows[j].isSelected == true) {
  6158. selectitem.push(rows[j].entity);
  6159. } else {
  6160. delete selectitem[j];
  6161. // rows.splice(j, 1);
  6162. }
  6163. }
  6164. $scope.selected.items = [];
  6165. for (var i = 0; i < selectitem.length; i++) {
  6166. if (selectitem[i]) {
  6167. $scope.selected.items.push(selectitem[i]);
  6168. }
  6169. }
  6170. }
  6171. );
  6172. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6173. // // if (row.entity.age > 45) {
  6174. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6175. // // }
  6176. // };
  6177. gridApi.core.on.filterChanged($scope, function () {
  6178. var grid = this.grid;
  6179. var filtersData = {
  6180. idx: 0,
  6181. sum: 10,
  6182. user: {
  6183. roledata: {
  6184. rolecode: "roleset",
  6185. },
  6186. selectType: "1",
  6187. },
  6188. };
  6189. angular.forEach(grid.columns, function (item) {
  6190. if (item.enableFiltering) {
  6191. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6192. if (
  6193. angular.isDefined(item.filters[0].term) &&
  6194. item.filters[0].term != ""
  6195. ) {
  6196. if (angular.isUndefined(filtersData["user"])) {
  6197. filtersData["user"] = {};
  6198. }
  6199. filtersData["user"][item.field] = item.filters[0].term;
  6200. }
  6201. }
  6202. });
  6203. $scope.memoryfilterData = filtersData;
  6204. // $scope.loadData(filtersData);
  6205. });
  6206. };
  6207. $scope.onDblClick = function (data, event) {
  6208. // $scope.selected.items = data.entity;
  6209. $scope.selectButtonClick(data, event);
  6210. };
  6211. // $scope.loadData = function(filterData) {
  6212. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6213. // items.fetchItems(filterData, APIService).then(function(data) {
  6214. // var myDatatwo = Restangular.stripRestangular(data);
  6215. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6216. // $scope.myDatatwo = myDatatwo.list;
  6217. // });
  6218. // };
  6219. $scope.title = title;
  6220. //树形图
  6221. var apple_selected, tree, treedata_avm, treedata_geography;
  6222. $scope.my_tree_handler = function (branch) {
  6223. //var _ref;
  6224. var classify = ($scope.classify =
  6225. branch.prefix.toLowerCase() + branch.sign);
  6226. api_cmdb
  6227. .query({
  6228. sign: classify,
  6229. })
  6230. .then(function (data) {
  6231. var myDatalingbei = Restangular.stripRestangular(data);
  6232. // console.log(myData.data.node);
  6233. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6234. var ret = myDatalingbei.data;
  6235. redrawSvg(myDatalingbei);
  6236. }
  6237. });
  6238. };
  6239. $scope.my_data = [];
  6240. function convertListToTree(data, treeMap) {
  6241. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6242. var root = null; //Initially set our loop to null
  6243. var parentNode = null;
  6244. //loop over data
  6245. for (var i = 0; i < data.length; i++) {
  6246. var datum = data[i];
  6247. //each node will have children, so let's give it a "children" poperty
  6248. datum.children = [];
  6249. //add an entry for this node to the map so that any future children can
  6250. //lookup the parent
  6251. idToNodeMap[datum.id] = datum;
  6252. //Does this node have a parent?
  6253. if (
  6254. typeof datum.parent === "undefined" ||
  6255. datum.parent == null
  6256. ) {
  6257. //Doesn't look like it, so this node is the root of the tree
  6258. root = datum;
  6259. treeMap[datum.id] = root;
  6260. } else {
  6261. //This node has a parent, so let's look it up using the id
  6262. parentNode = idToNodeMap[datum.parent.id];
  6263. //We don't need this property, so let's delete it.
  6264. delete datum.parent;
  6265. //Let's add the current node as a child of the parent node.
  6266. parentNode.children.push(datum);
  6267. }
  6268. }
  6269. return root;
  6270. }
  6271. function convertParentToChildList(data) {
  6272. var treeMap = {};
  6273. var list = [];
  6274. convertListToTree(data, treeMap);
  6275. angular.forEach(treeMap, function (item) {
  6276. list.push(item);
  6277. });
  6278. return list;
  6279. }
  6280. $scope.my_tree = tree = {};
  6281. $scope.try_async_load = function () {
  6282. $scope.my_data = [];
  6283. $scope.select_treedata = [];
  6284. $scope.doing_async = true;
  6285. api_configure_data
  6286. .fetchDataList("ciclassify", {
  6287. idx: 0,
  6288. sum: 100,
  6289. })
  6290. .then(function (result) {
  6291. //console.log(result['list']);
  6292. $scope.select_treedata = $scope.my_data =
  6293. convertParentToChildList(result["list"]);
  6294. $scope.doing_async = false;
  6295. // tree.expand_all();
  6296. //console.log(treelist);
  6297. });
  6298. };
  6299. $scope.select_treedata = [];
  6300. $scope.propTypeOptions = [];
  6301. $scope.try_async_load();
  6302. $scope.onFilterremove = function (item) {
  6303. console.log(item);
  6304. };
  6305. $scope.searchdata = {};
  6306. $scope.clear = function () {
  6307. $scope.searchdata = {};
  6308. $scope.cifilter_classic = {};
  6309. $scope.try_async_load();
  6310. var fildata = {
  6311. idx: 0,
  6312. sum: 10,
  6313. hw_state: "在库",
  6314. };
  6315. $scope.memoryfilterData = fildata;
  6316. $scope.refreshData("expand-right", fildata);
  6317. };
  6318. $scope.cifilter_classic = {};
  6319. $scope.chiceIncident = function (item) {
  6320. var fildata = defaultFilterData;
  6321. // fildata.applicationForm = {};
  6322. // sign: basehwnwswt
  6323. if (item && item.id) {
  6324. var classify = item.prefix.toLowerCase() + item.sign;
  6325. fildata.sign = classify;
  6326. } else {
  6327. delete fildata.sign;
  6328. }
  6329. $scope.gridOptions.paginationCurrentPage = 1;
  6330. var transitiondata = angular.copy(item);
  6331. $scope.refreshData("expand-right", fildata);
  6332. };
  6333. $scope.applicadata = [];
  6334. $scope.onFilterCallback = function (item) {
  6335. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6336. api_configure_form
  6337. .renderTabForm(tempclassify)
  6338. .then(function (data) {
  6339. var myData = Restangular.stripRestangular(data);
  6340. $scope.applicadata = myData[0].form.fields;
  6341. });
  6342. // }
  6343. };
  6344. // $scope.loadData({
  6345. // idx: 0,
  6346. // sum: 10,
  6347. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6348. // });
  6349. $scope.selected = {
  6350. items: [],
  6351. };
  6352. $scope.ok = function () {
  6353. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6354. // onDataCallback($scope.selected.item, parentScope);
  6355. // }
  6356. $modalInstance.close($scope.selected.items);
  6357. };
  6358. $scope.cancel = function () {
  6359. $modalInstance.dismiss("cancel");
  6360. };
  6361. },
  6362. size: "lg",
  6363. resolve: {
  6364. items: function () {
  6365. return {
  6366. fetchItems: function (filterData, APIService) {
  6367. filterData = filterData || {};
  6368. if (
  6369. angular.isDefined(filterData.idx) &&
  6370. filterData.idx == null
  6371. ) {
  6372. filterData = {
  6373. idx: 0,
  6374. sum: 10,
  6375. user: {
  6376. roledata: {
  6377. rolecode: "roleset",
  6378. },
  6379. selectType: "1",
  6380. },
  6381. };
  6382. }
  6383. return $scope.options.templateOptions.fetchItems(
  6384. filterData,
  6385. APIService
  6386. );
  6387. },
  6388. };
  6389. },
  6390. title: function () {
  6391. return $scope.options.templateOptions.label;
  6392. },
  6393. Restangular: function () {
  6394. return $scope.options.templateOptions.Restangular;
  6395. },
  6396. APIService: function () {
  6397. return $scope.options.templateOptions.ApiService;
  6398. },
  6399. onDataCallback: function () {
  6400. return $scope.options.templateOptions.callback;
  6401. },
  6402. parentScope: function () {
  6403. return $scope.options.templateOptions.that;
  6404. },
  6405. },
  6406. });
  6407. modalInstance.result.then(
  6408. function (selectedItem) {
  6409. // console.log(selectedItem);
  6410. // options.value(selectedItem);
  6411. var filterData = $scope.memoryfilterDatashe;
  6412. $scope.myDatalingbeiall = selectedItem;
  6413. $scope.gridOptions1["totalItems"] =
  6414. $scope.myDatalingbeiall.length;
  6415. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6416. $scope.myDatalingbeiall[i]["item"] =
  6417. i + 1 + filterData.idx * filterData.sum;
  6418. }
  6419. $scope.myDatalingbei = $scope.interceptMydata(
  6420. $scope.myDatalingbeiall,
  6421. 0,
  6422. 10
  6423. );
  6424. $scope.model.assets = $scope.myDatalingbeiall;
  6425. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6426. $scope.myDatalingbeiall;
  6427. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6428. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6429. // }
  6430. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6431. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6432. // }
  6433. },
  6434. function () {
  6435. //console.log('Modal dismissed at: ' + new Date());
  6436. }
  6437. );
  6438. };
  6439. $scope.onDblClick = function (data, event) {
  6440. $scope.selectButtonClick(data, event);
  6441. };
  6442. // $scope.loadData = function(filterData) {};
  6443. // $scope.title = title;
  6444. // $scope.loadData({
  6445. // idx: 0,
  6446. // sum: 20,
  6447. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6448. // });
  6449. $scope.selected = {
  6450. items: [],
  6451. };
  6452. //grid2
  6453. $scope.langs = i18nService.getAllLangs();
  6454. $scope.lang = "zh-cn";
  6455. i18nService.setCurrentLang($scope.lang);
  6456. $scope.gridOptions2 = {};
  6457. $scope.gridOptions2.data = "myDataone";
  6458. $scope.gridOptions2.enableColumnResizing = true;
  6459. $scope.gridOptions2.enableFiltering = false;
  6460. $scope.gridOptions2.enableGridMenu = false;
  6461. $scope.gridOptions2.showGridFooter = true;
  6462. $scope.gridOptions2.showColumnFooter = false;
  6463. $scope.gridOptions2.fastWatch = true;
  6464. $scope.gridOptions2.useExternalFiltering = true;
  6465. $scope.gridOptions2.useExternalPagination = true;
  6466. $scope.gridOptions2.paginationPageSizes = [10];
  6467. $scope.gridOptions2.paginationPageSize = 10;
  6468. $scope.gridOptions2.multiSelect = false;
  6469. // $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>";
  6470. $scope.gridOptions2.columnDefs = [
  6471. {
  6472. name: "item",
  6473. displayName: "序号",
  6474. width: 120,
  6475. },
  6476. {
  6477. name: "name",
  6478. displayName: "耗材名称",
  6479. width: 150,
  6480. enableFiltering: false,
  6481. },
  6482. {
  6483. name: "model",
  6484. displayName: "品牌/型号",
  6485. width: 100,
  6486. enableFiltering: false,
  6487. },
  6488. {
  6489. name: "Specifications",
  6490. displayName: "规格",
  6491. width: 150,
  6492. enableFiltering: false,
  6493. },
  6494. {
  6495. name: "sum",
  6496. displayName: "领用数量",
  6497. enableFiltering: false,
  6498. },
  6499. ];
  6500. // $scope.selectButtonClick
  6501. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6502. $scope.gridApi = gridApi;
  6503. gridApi.pagination.on.paginationChanged(
  6504. $scope,
  6505. function (newPage, pageSize) {
  6506. // var filtersData = $scope.memoryfilterData;
  6507. // filtersData.idx = newPage - 1;
  6508. // filtersData.sum = pageSize;
  6509. // $scope.loadData(filtersData);
  6510. $scope.memoryfilterDatahao.idx = newPage - 1;
  6511. $scope.memoryfilterDatahao.sum = pageSize;
  6512. $scope.myDataone = $scope.interceptMydata(
  6513. $scope.myDataoneall,
  6514. $scope.memoryfilterDatahao.idx,
  6515. 10
  6516. );
  6517. }
  6518. );
  6519. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6520. $scope.selected.items.push(data.entity);
  6521. //console.log(data);
  6522. });
  6523. gridApi.selection.on.rowSelectionChangedBatch(
  6524. $scope,
  6525. function (data) {
  6526. $scope.selected.items.push(data.entity);
  6527. //console.log(data);
  6528. }
  6529. );
  6530. gridApi.core.on.filterChanged($scope, function () {
  6531. var grid = this.grid;
  6532. var filtersData = {
  6533. idx: 0,
  6534. sum: 10,
  6535. user: {
  6536. roledata: {
  6537. rolecode: "roleset",
  6538. },
  6539. selectType: "1",
  6540. },
  6541. };
  6542. angular.forEach(grid.columns, function (item) {
  6543. if (item.enableFiltering) {
  6544. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6545. if (
  6546. angular.isDefined(item.filters[0].term) &&
  6547. item.filters[0].term != ""
  6548. ) {
  6549. if (angular.isUndefined(filtersData["user"])) {
  6550. filtersData["user"] = {};
  6551. }
  6552. filtersData["user"][item.field] = item.filters[0].term;
  6553. }
  6554. }
  6555. });
  6556. $scope.memoryfilterDatahao = filtersData;
  6557. $scope.loadData(filtersData);
  6558. });
  6559. };
  6560. $scope.removehaocai = function (item) {
  6561. event.preventDefault();
  6562. // var modalInstance = $modal.open({
  6563. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6564. // controller: function($scope, $modalInstance) {
  6565. // $scope.title = "修改耗材数量";
  6566. // $scope.consumptive = item;
  6567. // $scope.ok = function() {
  6568. // $modalInstance.close($scope.consumptive);
  6569. // };
  6570. // $scope.cancel = function() {
  6571. // $modalInstance.dismiss('cancel');
  6572. // };
  6573. // },
  6574. // size: 'sm'
  6575. // });
  6576. var modalInstance = $modal.open({
  6577. templateUrl: "assets/views/delete.html",
  6578. controller: function ($scope, $modalInstance, scope) {
  6579. $scope.title = "耗材移除";
  6580. $scope.connect = "确定要移除此设备?";
  6581. $scope.consumptive = scope.selected.items[0];
  6582. $scope.ok = function () {
  6583. $modalInstance.close($scope.consumptive);
  6584. };
  6585. $scope.cancel = function () {
  6586. $modalInstance.dismiss("cancel");
  6587. };
  6588. },
  6589. size: "sm",
  6590. resolve: {
  6591. scope: function () {
  6592. return $scope;
  6593. },
  6594. },
  6595. });
  6596. modalInstance.result.then(function (selectedItem) {
  6597. // angular.forEach($scope.myData3, function(items, index) {
  6598. // if (items.id == selectedItem.id) {
  6599. // $scope.myData3[index] = selectedItem;
  6600. // }
  6601. // })
  6602. // $scope.model.applicationForm.consumables = $scope.myData3;
  6603. angular.forEach($scope.myDataoneall, function (items, index) {
  6604. if (items.id == selectedItem.id) {
  6605. $scope.myDataoneall.splice(index, 1);
  6606. }
  6607. });
  6608. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6609. $scope.myDataoneall[i]["item"] =
  6610. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6611. }
  6612. $scope.myDataone = $scope.interceptMydata(
  6613. $scope.myDataoneall,
  6614. 0,
  6615. 10
  6616. );
  6617. $scope.model.consumables = $scope.myDataoneall;
  6618. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6619. $scope.myDataoneall;
  6620. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6621. $scope.selected = {
  6622. items: [],
  6623. };
  6624. });
  6625. };
  6626. $scope.haocaiadd = function () {
  6627. event.preventDefault();
  6628. var modalInstance = $modal.open({
  6629. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6630. controller: function (
  6631. $scope,
  6632. scope,
  6633. $modalInstance,
  6634. api_wechatfile,
  6635. SweetAlert,
  6636. api_cmdb3
  6637. ) {
  6638. $scope.haocainame = [];
  6639. $scope.pinpai = [];
  6640. $scope.guige = [];
  6641. $scope.consumptive = {};
  6642. $scope.consumpall = {};
  6643. $scope.title = "添加耗材";
  6644. api_wechatfile
  6645. .getDictionaryForList({
  6646. key: "haocaifenlei",
  6647. })
  6648. .then(function (data) {
  6649. $scope.haocainame = data;
  6650. });
  6651. $scope.clearNoNum = function (obj, attr) {
  6652. //先把非数字的都替换掉,除了数字和.
  6653. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6654. //必须保证第一个为数字而不是.
  6655. obj[attr] = obj[attr].replace(/^\./g, "");
  6656. //保证只有出现一个.而没有多个.
  6657. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6658. //保证.只出现一次,而不能出现两次以上
  6659. obj[attr] = obj[attr]
  6660. .replace(".", "$#$")
  6661. .replace(/\./g, "")
  6662. .replace("$#$", ".");
  6663. //小于最大值
  6664. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6665. alert(
  6666. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6667. );
  6668. obj[attr] = "";
  6669. }
  6670. };
  6671. $scope.onChange = function (parent) {
  6672. $scope.consumptive.model = {};
  6673. $scope.consumptive.Specifications = {};
  6674. api_wechatfile
  6675. .getDictionaryForList({
  6676. key: "pinpai",
  6677. parent: parent.id,
  6678. })
  6679. .then(function (data) {
  6680. $scope.pinpai = data;
  6681. });
  6682. api_wechatfile
  6683. .getDictionaryForList({
  6684. key: "guige",
  6685. parent: parent.id,
  6686. })
  6687. .then(function (data) {
  6688. $scope.guige = data;
  6689. });
  6690. };
  6691. $scope.onChangesum = function (item) {
  6692. if (item.name && item.model.id && item.Specifications.id) {
  6693. $scope.consumptive.sum = "";
  6694. var data1 = {
  6695. idx: 0,
  6696. sum: 10,
  6697. consumable: {
  6698. name: item.name.name,
  6699. brandModel: item.model.name,
  6700. specification: item.Specifications.name,
  6701. },
  6702. };
  6703. api_cmdb3
  6704. .fetchDataList("consumable", data1)
  6705. .then(function (data) {
  6706. if (data.status == 200 && data.list.length > 0) {
  6707. var myData = data.list;
  6708. $scope.consumpall = myData[0];
  6709. $scope.maxsum = myData[0].inventoryNum;
  6710. } else {
  6711. SweetAlert.swal({
  6712. title: "不存在该耗材",
  6713. text: "请检查库存后重新填写!",
  6714. type: "error",
  6715. });
  6716. }
  6717. });
  6718. }
  6719. };
  6720. $scope.addhaocai = function () {
  6721. $modalInstance.dismiss("cancel");
  6722. scope.haocaiopen($scope.consumptive);
  6723. };
  6724. $scope.ok = function (item) {
  6725. var items = {};
  6726. // if (item.name && item.model && item.Specifications && item.sum) {
  6727. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6728. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6729. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6730. // $scope.consumpall.sum = item.sum;
  6731. // delete $scope.consumpall.brandModel;
  6732. // delete $scope.consumpall.specification;
  6733. // $modalInstance.close($scope.consumpall);
  6734. // } else {
  6735. // SweetAlert.swal({
  6736. // title: "数据填写不完整!",
  6737. // text: "请检查数据然后提交!",
  6738. // type: "error"
  6739. // });
  6740. // }
  6741. var isold = false;
  6742. if (
  6743. item.name &&
  6744. item.model &&
  6745. JSON.stringify(item.model) != "{}" &&
  6746. item.Specifications &&
  6747. JSON.stringify(item.Specifications) != "{}" &&
  6748. item.sum
  6749. ) {
  6750. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6751. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6752. isold = true;
  6753. }
  6754. }
  6755. if (isold) {
  6756. SweetAlert.swal({
  6757. title: "该耗材已添加!",
  6758. text: "请不要重复添加耗材!",
  6759. type: "error",
  6760. });
  6761. } else {
  6762. $scope.consumpall.model = $scope.consumpall.brandModel;
  6763. $scope.consumpall.Specifications =
  6764. $scope.consumpall.specification;
  6765. $scope.consumpall.sum = item.sum;
  6766. delete $scope.consumpall.brandModel;
  6767. delete $scope.consumpall.specification;
  6768. $modalInstance.close($scope.consumpall);
  6769. }
  6770. } else {
  6771. SweetAlert.swal({
  6772. title: "数据填写不完整!",
  6773. text: "请检查数据然后提交!",
  6774. type: "error",
  6775. });
  6776. }
  6777. // $modalInstance.close(item);
  6778. };
  6779. $scope.cancel = function () {
  6780. $modalInstance.dismiss("cancel");
  6781. };
  6782. },
  6783. size: "sm",
  6784. resolve: {
  6785. scope: function () {
  6786. return $scope;
  6787. },
  6788. },
  6789. });
  6790. modalInstance.result.then(function (selectedItem) {
  6791. $scope.myDataoneall.push(selectedItem);
  6792. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6793. $scope.myDataoneall[i]["item"] =
  6794. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6795. }
  6796. // $scope.model.consumables = $scope.myDataone;
  6797. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6798. $scope.myDataone = $scope.interceptMydata(
  6799. $scope.myDataoneall,
  6800. 0,
  6801. 10
  6802. );
  6803. $scope.model.consumables = $scope.myDataoneall;
  6804. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6805. $scope.myDataoneall;
  6806. });
  6807. };
  6808. $scope.onDblClick = function (data, event) {
  6809. $scope.selectButtonClick(data, event);
  6810. };
  6811. $scope.memoryfilterDatahao = {
  6812. idx: 0,
  6813. sum: 10,
  6814. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6815. };
  6816. $scope.myDataone = [];
  6817. $scope.loadData = function (filterData) {};
  6818. // $scope.title = title;
  6819. $scope.ldloading = {};
  6820. $scope.selected = {
  6821. items: [],
  6822. };
  6823. if ($scope.$parent.$parent.$parent.model.gettype) {
  6824. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6825. if ($scope.model.assets) {
  6826. if (JSON.stringify($scope.model.assets) == "{}") {
  6827. $scope.model.assets = [];
  6828. } else {
  6829. $scope.model.assets = JSON.parse($scope.model.assets);
  6830. }
  6831. $scope.myDatalingbeiall = $scope.model.assets;
  6832. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6833. $scope.myDatalingbeiall[i]["item"] =
  6834. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6835. }
  6836. $scope.gridOptions1["totalItems"] =
  6837. $scope.myDatalingbeiall.length;
  6838. $scope.myDatalingbei = $scope.interceptMydata(
  6839. $scope.myDatalingbeiall,
  6840. 0,
  6841. 10
  6842. );
  6843. }
  6844. if ($scope.model.consumables) {
  6845. if (JSON.stringify($scope.model.consumables) == "{}") {
  6846. $scope.model.consumables = [];
  6847. } else {
  6848. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6849. }
  6850. $scope.myDataoneall = $scope.model.consumables;
  6851. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6852. $scope.myDataoneall[i]["item"] =
  6853. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6854. }
  6855. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6856. $scope.myDataone = $scope.interceptMydata(
  6857. $scope.myDataoneall,
  6858. 0,
  6859. 10
  6860. );
  6861. }
  6862. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6863. $scope.options.templateOptions.getpush({
  6864. hao: true,
  6865. gu: true,
  6866. });
  6867. } else {
  6868. $scope.options.templateOptions.getpush({
  6869. hao: true,
  6870. });
  6871. }
  6872. } else {
  6873. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6874. $scope.options.templateOptions.getpush({
  6875. gu: true,
  6876. });
  6877. }
  6878. }
  6879. }
  6880. },
  6881. ],
  6882. });
  6883. formlyConfigProvider.setType({
  6884. name: "ui-panel",
  6885. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6886. });
  6887. formlyConfigProvider.setType({
  6888. name: "ui-currentuser",
  6889. extends: "input",
  6890. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6891. defaultOptions: function (options) {
  6892. return {
  6893. templateOptions: {
  6894. // link: function() {}
  6895. },
  6896. };
  6897. },
  6898. controller: [
  6899. "$scope",
  6900. function ($scope) {
  6901. if ($scope.options.templateOptions.user) {
  6902. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6903. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6904. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6905. // }
  6906. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6907. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6908. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6909. }
  6910. $scope.model[$scope.options.key] =
  6911. $scope.options.templateOptions.user;
  6912. $scope.options.initialValue = $scope.model[$scope.options.key];
  6913. }
  6914. },
  6915. ],
  6916. });
  6917. //仪表盘
  6918. //待处理变更列表
  6919. formlyConfigProvider.setType({
  6920. name: "ui-ngpchangetable",
  6921. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6922. defaultOptions: function (options) {
  6923. return {
  6924. templateOptions: {
  6925. // relationAction: function() {
  6926. // options.hideExpression = true
  6927. // }
  6928. },
  6929. };
  6930. },
  6931. controller: [
  6932. "$scope",
  6933. "$modal",
  6934. "$timeout",
  6935. "SweetAlert",
  6936. "api_bpm_domain",
  6937. "$rootScope",
  6938. "ngTableParams",
  6939. "$filter",
  6940. "$state",
  6941. function (
  6942. $scope,
  6943. $modal,
  6944. $timeout,
  6945. SweetAlert,
  6946. api_bpm_domain,
  6947. $rootScope,
  6948. ngTableParams,
  6949. $filter,
  6950. $state
  6951. ) {
  6952. // var filterData = {
  6953. // "assignee": $rootScope.user.id,
  6954. // "searchtype": "all",
  6955. // "idx": "0",
  6956. // "sum": "10"
  6957. // };
  6958. var filterData = {
  6959. idx: "0",
  6960. sum: "10",
  6961. assignee: 2,
  6962. searchType: "todo",
  6963. };
  6964. $scope.incidentprocess = function (item) {
  6965. $state.go("app.wt_change.add", {
  6966. taskId: item.taskId,
  6967. processInstanceId: item.processInstanceId,
  6968. });
  6969. };
  6970. $scope.more = function () {
  6971. $state.go("app.wt_change.list", {});
  6972. };
  6973. api_bpm_domain
  6974. .fetchtask("bpm_change", filterData)
  6975. .then(function (data) {
  6976. if (data.data) {
  6977. $scope.myData = data.data;
  6978. } else {
  6979. SweetAlert.swal({
  6980. title: "操作异常!",
  6981. text: "系统异常,请稍后重试,或者联系管理员!",
  6982. type: "error",
  6983. });
  6984. }
  6985. });
  6986. $scope.removes = function () {
  6987. var modalInstance = $modal.open({
  6988. templateUrl: "assets/views/delete.html",
  6989. controller: function ($scope, $modalInstance) {
  6990. $scope.ok = function () {
  6991. $modalInstance.close();
  6992. };
  6993. $scope.cancel = function () {
  6994. $modalInstance.dismiss("cancel");
  6995. };
  6996. },
  6997. size: "sm",
  6998. });
  6999. modalInstance.result.then(function () {
  7000. console.log($scope.$parent.$parent.$parent.$parent);
  7001. for (
  7002. var i = 0;
  7003. i <
  7004. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7005. i++
  7006. ) {
  7007. if (
  7008. $scope.fields.type ==
  7009. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7010. .type
  7011. ) {
  7012. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7013. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7014. i,
  7015. 1
  7016. );
  7017. break;
  7018. }
  7019. }
  7020. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7021. if (vmForm) {
  7022. //console.log("vmForm>>>");//console.log(vmForm);
  7023. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7024. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7025. }
  7026. });
  7027. };
  7028. },
  7029. ],
  7030. });
  7031. //待处理问题列表
  7032. formlyConfigProvider.setType({
  7033. name: "ui-ngproblemtable",
  7034. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7035. defaultOptions: function (options) {
  7036. return {
  7037. templateOptions: {
  7038. // relationAction: function() {
  7039. // options.hideExpression = true
  7040. // }
  7041. },
  7042. };
  7043. },
  7044. controller: [
  7045. "$scope",
  7046. "$modal",
  7047. "$timeout",
  7048. "SweetAlert",
  7049. "api_bpm_data",
  7050. "$rootScope",
  7051. "ngTableParams",
  7052. "$filter",
  7053. "$state",
  7054. function (
  7055. $scope,
  7056. $modal,
  7057. $timeout,
  7058. SweetAlert,
  7059. api_bpm_data,
  7060. $rootScope,
  7061. ngTableParams,
  7062. $filter,
  7063. $state
  7064. ) {
  7065. var filterData = {
  7066. assignee: $rootScope.user.id,
  7067. candidateGroups: $rootScope.user.group[0].id,
  7068. searchtype: "todo",
  7069. idx: 0,
  7070. sum: 10,
  7071. };
  7072. $scope.incidentprocess = function (item) {
  7073. $state.go("app.wt_change.add", {
  7074. taskId: item.taskId,
  7075. processInstanceId: item.processInstanceId,
  7076. });
  7077. };
  7078. $scope.more = function () {
  7079. $state.go("app.wt_change.list", {});
  7080. };
  7081. api_bpm_data
  7082. .fetchDataList("changeclassify", filterData)
  7083. .then(function (data) {
  7084. if (data.data) {
  7085. $scope.myData = data.data;
  7086. } else {
  7087. SweetAlert.swal({
  7088. title: "操作异常!",
  7089. text: "系统异常,请稍后重试,或者联系管理员!",
  7090. type: "error",
  7091. });
  7092. }
  7093. });
  7094. $scope.removes = function () {
  7095. var modalInstance = $modal.open({
  7096. templateUrl: "assets/views/delete.html",
  7097. controller: function ($scope, $modalInstance) {
  7098. $scope.ok = function () {
  7099. $modalInstance.close();
  7100. };
  7101. $scope.cancel = function () {
  7102. $modalInstance.dismiss("cancel");
  7103. };
  7104. },
  7105. size: "sm",
  7106. });
  7107. modalInstance.result.then(function () {
  7108. console.log($scope.$parent.$parent.$parent.$parent);
  7109. for (
  7110. var i = 0;
  7111. i <
  7112. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7113. i++
  7114. ) {
  7115. if (
  7116. $scope.fields.type ==
  7117. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7118. .type
  7119. ) {
  7120. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7121. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7122. i,
  7123. 1
  7124. );
  7125. break;
  7126. }
  7127. }
  7128. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7129. if (vmForm) {
  7130. //console.log("vmForm>>>");//console.log(vmForm);
  7131. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7132. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7133. }
  7134. });
  7135. };
  7136. },
  7137. ],
  7138. });
  7139. //待处理事件列表
  7140. formlyConfigProvider.setType({
  7141. name: "ui-ngtable",
  7142. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7143. defaultOptions: function (options) {
  7144. return {
  7145. templateOptions: {
  7146. // relationAction: function() {
  7147. // options.hideExpression = true
  7148. // }
  7149. },
  7150. };
  7151. },
  7152. controller: [
  7153. "$scope",
  7154. "$modal",
  7155. "$timeout",
  7156. "SweetAlert",
  7157. "api_bpm_domain",
  7158. "$rootScope",
  7159. "ngTableParams",
  7160. "$filter",
  7161. "$state",
  7162. function (
  7163. $scope,
  7164. $modal,
  7165. $timeout,
  7166. SweetAlert,
  7167. api_bpm_domain,
  7168. $rootScope,
  7169. ngTableParams,
  7170. $filter,
  7171. $state
  7172. ) {
  7173. var filterData = {
  7174. assignee: $rootScope.user.id,
  7175. candidateGroups: $rootScope.user.group[0].id,
  7176. searchtype: "done",
  7177. idx: 0,
  7178. sum: 10,
  7179. };
  7180. $scope.incidentprocess = function (item) {
  7181. $state.go("app.incident.editor", {
  7182. taskId: item.taskId,
  7183. processInstanceId: item.processInstanceId,
  7184. });
  7185. };
  7186. $scope.more = function () {
  7187. $state.go("app.incident.list", {});
  7188. };
  7189. api_bpm_domain
  7190. .fetchtask("bpm_incident", filterData)
  7191. .then(function (data) {
  7192. if (data.data) {
  7193. $scope.myData = data.data;
  7194. } else {
  7195. SweetAlert.swal({
  7196. title: "操作异常!",
  7197. text: "系统异常,请稍后重试,或者联系管理员!",
  7198. type: "error",
  7199. });
  7200. }
  7201. });
  7202. $scope.removes = function () {
  7203. var modalInstance = $modal.open({
  7204. templateUrl: "assets/views/delete.html",
  7205. controller: function ($scope, $modalInstance) {
  7206. $scope.ok = function () {
  7207. $modalInstance.close();
  7208. };
  7209. $scope.cancel = function () {
  7210. $modalInstance.dismiss("cancel");
  7211. };
  7212. },
  7213. size: "sm",
  7214. });
  7215. modalInstance.result.then(function () {
  7216. console.log($scope.$parent.$parent.$parent.$parent);
  7217. for (
  7218. var i = 0;
  7219. i <
  7220. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7221. i++
  7222. ) {
  7223. if (
  7224. $scope.fields.type ==
  7225. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7226. .type
  7227. ) {
  7228. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7229. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7230. i,
  7231. 1
  7232. );
  7233. break;
  7234. }
  7235. }
  7236. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7237. if (vmForm) {
  7238. //console.log("vmForm>>>");//console.log(vmForm);
  7239. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7240. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7241. }
  7242. });
  7243. };
  7244. },
  7245. ],
  7246. });
  7247. //知识库列表
  7248. formlyConfigProvider.setType({
  7249. name: "ui-knowledge",
  7250. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7251. defaultOptions: function (options) {
  7252. return {
  7253. templateOptions: {
  7254. // relationAction: function() {
  7255. // options.hideExpression = true
  7256. // }
  7257. },
  7258. };
  7259. },
  7260. controller: [
  7261. "$scope",
  7262. "$modal",
  7263. "$timeout",
  7264. "api_solution",
  7265. "$rootScope",
  7266. "ngTableParams",
  7267. "$filter",
  7268. "$state",
  7269. function (
  7270. $scope,
  7271. $modal,
  7272. $timeout,
  7273. api_solution,
  7274. $rootScope,
  7275. ngTableParams,
  7276. $filter,
  7277. $state
  7278. ) {
  7279. var filterData = {
  7280. key: "null",
  7281. pageIndex: 0,
  7282. pageSum: 6,
  7283. status: 0,
  7284. userId: $rootScope.user.id,
  7285. };
  7286. $scope.model.removereport = false;
  7287. $scope.removes = function () {
  7288. $scope.model.removereport = true;
  7289. };
  7290. $scope.more = function () {
  7291. $state.go("app.knowledge.manager", {});
  7292. };
  7293. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7294. if (data.status == 200) {
  7295. $scope.myData = data.list;
  7296. }
  7297. });
  7298. $scope.removes = function () {
  7299. var modalInstance = $modal.open({
  7300. templateUrl: "assets/views/delete.html",
  7301. controller: function ($scope, $modalInstance) {
  7302. $scope.ok = function () {
  7303. $modalInstance.close();
  7304. };
  7305. $scope.cancel = function () {
  7306. $modalInstance.dismiss("cancel");
  7307. };
  7308. },
  7309. size: "sm",
  7310. });
  7311. modalInstance.result.then(function () {
  7312. for (
  7313. var i = 0;
  7314. i <
  7315. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7316. i++
  7317. ) {
  7318. if (
  7319. $scope.fields.type ==
  7320. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7321. .type
  7322. ) {
  7323. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7324. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7325. i,
  7326. 1
  7327. );
  7328. break;
  7329. }
  7330. }
  7331. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7332. if (vmForm) {
  7333. //console.log("vmForm>>>");//console.log(vmForm);
  7334. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7335. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7336. }
  7337. });
  7338. };
  7339. },
  7340. ],
  7341. });
  7342. //公告列表
  7343. formlyConfigProvider.setType({
  7344. name: "ui-ngnotice",
  7345. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7346. defaultOptions: function (options) {
  7347. return {
  7348. templateOptions: {
  7349. // relationAction: function() {
  7350. // options.hideExpression = true
  7351. // }
  7352. },
  7353. };
  7354. },
  7355. controller: [
  7356. "$scope",
  7357. "$modal",
  7358. "$timeout",
  7359. "SweetAlert",
  7360. "api_user_data",
  7361. "$rootScope",
  7362. "ngTableParams",
  7363. "$filter",
  7364. "$state",
  7365. function (
  7366. $scope,
  7367. $modal,
  7368. $timeout,
  7369. SweetAlert,
  7370. api_user_data,
  7371. $rootScope,
  7372. ngTableParams,
  7373. $filter,
  7374. $state
  7375. ) {
  7376. var filterData = {
  7377. idx: 0,
  7378. sum: 10,
  7379. };
  7380. // $scope.$scope.model.className = "col-xs-12";
  7381. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7382. if (data) {
  7383. $scope.myData = data.data;
  7384. } else {
  7385. SweetAlert.swal({
  7386. title: "操作异常!",
  7387. text: "系统异常,请稍后重试,或者联系管理员!",
  7388. type: "error",
  7389. });
  7390. }
  7391. });
  7392. $scope.more = function () {
  7393. $state.go("app.system.notice.list", {});
  7394. };
  7395. $scope.removes = function () {
  7396. var modalInstance = $modal.open({
  7397. templateUrl: "assets/views/delete.html",
  7398. controller: function ($scope, $modalInstance) {
  7399. $scope.ok = function () {
  7400. $modalInstance.close();
  7401. };
  7402. $scope.cancel = function () {
  7403. $modalInstance.dismiss("cancel");
  7404. };
  7405. },
  7406. size: "sm",
  7407. });
  7408. modalInstance.result.then(function () {
  7409. for (
  7410. var i = 0;
  7411. i <
  7412. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7413. i++
  7414. ) {
  7415. if (
  7416. $scope.fields.type ==
  7417. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7418. .type
  7419. ) {
  7420. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7421. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7422. i,
  7423. 1
  7424. );
  7425. break;
  7426. }
  7427. }
  7428. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7429. if (vmForm) {
  7430. //console.log("vmForm>>>");//console.log(vmForm);
  7431. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7432. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7433. }
  7434. });
  7435. };
  7436. },
  7437. ],
  7438. });
  7439. //事件统计图
  7440. formlyConfigProvider.setType({
  7441. name: "ui-incidentreport",
  7442. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7443. defaultOptions: function (options) {
  7444. return {
  7445. templateOptions: {
  7446. // relationAction: function() {
  7447. // options.hideExpression = true
  7448. // }
  7449. },
  7450. };
  7451. },
  7452. controller: [
  7453. "$scope",
  7454. "$modal",
  7455. "moment",
  7456. "api_report",
  7457. "$cookieStore",
  7458. function ($scope, $modal, moment, api_report, $cookieStore) {
  7459. api_report.getLicenseKey().then(function (response) {
  7460. $cookieStore.put("Auth-Token", response.token);
  7461. $scope.try_async_load();
  7462. });
  7463. $scope.try_async_load = function () {
  7464. $scope.my_data = [];
  7465. api_report.list().then(function (response) {
  7466. var dataList = response;
  7467. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7468. $scope.repoRoot.name = "事件报表";
  7469. convertRepoObject($scope.repoRoot);
  7470. $scope.my_data.push($scope.repoRoot);
  7471. });
  7472. };
  7473. var workspace = {};
  7474. $scope.repoRoot = null;
  7475. function getRepoRoot(repo, path) {
  7476. angular.forEach(repo, function (value, key) {
  7477. if (value.path == path) {
  7478. $scope.repoRoot = value;
  7479. } else {
  7480. if (
  7481. $scope.repoRoot == null &&
  7482. angular.isDefined(value.repoObjects)
  7483. ) {
  7484. getRepoRoot(value.repoObjects, path);
  7485. } else {
  7486. }
  7487. }
  7488. });
  7489. }
  7490. function convertRepoObject(repo) {
  7491. if (angular.isArray(repo)) {
  7492. angular.forEach(repo, function (value, key) {
  7493. convertRepoObject(value);
  7494. });
  7495. } else {
  7496. if (angular.isDefined(repo.name)) {
  7497. if (repo.name.indexOf(".") >= 0) {
  7498. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7499. } else {
  7500. repo.label = repo.name;
  7501. }
  7502. //delete repo.name;
  7503. }
  7504. if (angular.isDefined(repo.repoObjects)) {
  7505. repo.children = [];
  7506. repo.children = repo.repoObjects;
  7507. delete repo.repoObjects;
  7508. convertRepoObject(repo.children);
  7509. }
  7510. }
  7511. }
  7512. function parseDateParameter(parameters) {
  7513. var result = undefined;
  7514. if (angular.isArray(parameters)) {
  7515. // angular.forEach(parmeters,function(param){
  7516. // param.
  7517. // })
  7518. } else {
  7519. result = {};
  7520. for (var k in parameters) {
  7521. if (k.indexOf("Date") > 0) {
  7522. if (angular.isString(parameters[k])) {
  7523. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7524. "YYYY-MM-DD"
  7525. );
  7526. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7527. }
  7528. }
  7529. }
  7530. }
  7531. return result;
  7532. }
  7533. function ConvertDateParameter(parameters) {
  7534. var result = undefined;
  7535. if (angular.isArray(parameters)) {
  7536. //
  7537. } else {
  7538. result = {};
  7539. for (var k in parameters) {
  7540. if (k.indexOf("Date") > 0) {
  7541. if (angular.isDate(parameters[k])) {
  7542. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7543. } else if (angular.isString(parameters[k])) {
  7544. result[k] = parameters[k];
  7545. }
  7546. }
  7547. }
  7548. }
  7549. return result;
  7550. }
  7551. var incidentchart =
  7552. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7553. var queryUUID;
  7554. function genUUID() {
  7555. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7556. .replace(/[xy]/g, function (c) {
  7557. var r = (Math.random() * 16) | 0,
  7558. v = c == "x" ? r : (r & 0x3) | 0x8;
  7559. return v.toString(16);
  7560. })
  7561. .toUpperCase();
  7562. return uuid;
  7563. }
  7564. queryUUID = genUUID();
  7565. var pathincidenttimekey = [];
  7566. var incidenttime = {
  7567. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7568. "YYYYMMDD"
  7569. ),
  7570. endtimes: moment(new Date()).format("YYYYMMDD"),
  7571. };
  7572. var thisday = moment(new Date().getTime() + 86400000).format(
  7573. "YYYYMMDD"
  7574. );
  7575. var thisdaymine = Date.parse(
  7576. thisday.substr(4, 2) +
  7577. "/" +
  7578. thisday.substr(6, 2) +
  7579. "/" +
  7580. thisday.substr(0, 4)
  7581. );
  7582. var averages = [
  7583. [thisdaymine - 86400000 * 14, 0],
  7584. [thisdaymine - 86400000 * 13, 0],
  7585. [thisdaymine - 86400000 * 12, 0],
  7586. [thisdaymine - 86400000 * 11, 0],
  7587. [thisdaymine - 86400000 * 10, 0],
  7588. [thisdaymine - 86400000 * 9, 0],
  7589. [thisdaymine - 86400000 * 8, 0],
  7590. [thisdaymine - 86400000 * 7, 0],
  7591. [thisdaymine - 86400000 * 6, 0],
  7592. [thisdaymine - 86400000 * 5, 0],
  7593. [thisdaymine - 86400000 * 4, 0],
  7594. [thisdaymine - 86400000 * 3, 0],
  7595. [thisdaymine - 86400000 * 2, 0],
  7596. [thisdaymine - 86400000 * 1, 0],
  7597. [thisdaymine, 0],
  7598. ];
  7599. var getreportdata = function (incidenttime, path) {
  7600. api_report.getMdx(path, queryUUID).then(function (response) {
  7601. var mdxquery = response;
  7602. workspace.query = mdxquery;
  7603. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7604. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7605. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7606. weekuser(mdxquery);
  7607. });
  7608. };
  7609. getreportdata(incidenttime, incidentchart);
  7610. var weekuser = function (mdxquery) {
  7611. var key = [];
  7612. api_report.execute(mdxquery).then(function (data) {
  7613. $scope.rheaders = [];
  7614. $scope.rRows = [];
  7615. var reportData = data;
  7616. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7617. $scope.shows = true;
  7618. $scope.empty = "数据为空!";
  7619. } else {
  7620. angular.forEach(reportData.cellset, function (item, i) {
  7621. angular.forEach(averages, function (index, j) {
  7622. // angular.forEach(averages, function(item, index) {
  7623. if (item.length > 1 && i > 0 && item[1].value != "") {
  7624. if (
  7625. index[0] ==
  7626. Date.parse(
  7627. item[0].value.substr(4, 2) +
  7628. "/" +
  7629. item[0].value.substr(6, 2) +
  7630. "/" +
  7631. item[0].value.substr(0, 4)
  7632. ) +
  7633. 86400000
  7634. ) {
  7635. index[1] = Number(item[1].value);
  7636. }
  7637. // 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)]);
  7638. }
  7639. // })
  7640. });
  7641. });
  7642. incidentchartfun(averages);
  7643. }
  7644. });
  7645. };
  7646. var incidentchartfun = function (incidentchartkey) {
  7647. // $scope.isMaskincident = false;
  7648. Highcharts.chart("incidentchart", {
  7649. title: {
  7650. text: "事件近15天趋势图",
  7651. },
  7652. xAxis: {
  7653. type: "datetime",
  7654. labels: {
  7655. align: "left",
  7656. step: 1,
  7657. },
  7658. },
  7659. yAxis: {
  7660. title: {
  7661. text: null,
  7662. },
  7663. },
  7664. tooltip: {
  7665. crosshairs: true,
  7666. shared: true,
  7667. valueSuffix: "条",
  7668. },
  7669. legend: {},
  7670. series: [
  7671. {
  7672. name: "生成事件",
  7673. data: incidentchartkey,
  7674. zIndex: 1,
  7675. marker: {
  7676. fillColor: "white",
  7677. lineWidth: 2,
  7678. lineColor: Highcharts.getOptions().colors[0],
  7679. },
  7680. },
  7681. ],
  7682. });
  7683. };
  7684. $scope.data = {
  7685. labels: [
  7686. "1号",
  7687. "2号",
  7688. "3号",
  7689. "4号",
  7690. "5号",
  7691. "6号",
  7692. "7号",
  7693. "8号",
  7694. "9号",
  7695. "10号",
  7696. "11号",
  7697. "12号",
  7698. "13号",
  7699. "14号",
  7700. "15号",
  7701. ],
  7702. datasets: [
  7703. {
  7704. label: "新增事件数量",
  7705. fillColor: "rgba(220,220,220,0.2)",
  7706. strokeColor: "rgba(220,220,220,1)",
  7707. pointColor: "rgba(220,220,220,1)",
  7708. pointStrokeColor: "#fff",
  7709. pointHighlightFill: "#fff",
  7710. pointHighlightStroke: "rgba(220,220,220,1)",
  7711. data: [
  7712. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7713. ],
  7714. },
  7715. {
  7716. label: "已解决事件数量",
  7717. fillColor: "rgba(151,187,205,0.2)",
  7718. strokeColor: "rgba(151,187,205,1)",
  7719. pointColor: "rgba(151,187,205,1)",
  7720. pointStrokeColor: "#fff",
  7721. pointHighlightFill: "#fff",
  7722. pointHighlightStroke: "rgba(151,187,205,1)",
  7723. data: [
  7724. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7725. ],
  7726. },
  7727. ],
  7728. };
  7729. $scope.removes = function () {
  7730. var modalInstance = $modal.open({
  7731. templateUrl: "assets/views/delete.html",
  7732. controller: function ($scope, $modalInstance) {
  7733. $scope.ok = function () {
  7734. $modalInstance.close();
  7735. };
  7736. $scope.cancel = function () {
  7737. $modalInstance.dismiss("cancel");
  7738. };
  7739. },
  7740. size: "sm",
  7741. });
  7742. modalInstance.result.then(function () {
  7743. for (
  7744. var i = 0;
  7745. i <
  7746. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7747. i++
  7748. ) {
  7749. if (
  7750. $scope.fields.type ==
  7751. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7752. .type
  7753. ) {
  7754. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7755. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7756. i,
  7757. 1
  7758. );
  7759. break;
  7760. }
  7761. }
  7762. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7763. if (vmForm) {
  7764. //console.log("vmForm>>>");//console.log(vmForm);
  7765. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7766. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7767. }
  7768. });
  7769. };
  7770. var addDatas = 0;
  7771. var resolve = 0;
  7772. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7773. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7774. }
  7775. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7776. resolve = resolve + $scope.data.datasets[1].data[i];
  7777. }
  7778. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7779. $scope.opt = {
  7780. maintainAspectRatio: false,
  7781. // Sets the chart to be responsive
  7782. responsive: true,
  7783. ///Boolean - Whether grid lines are shown across the chart
  7784. scaleShowGridLines: true,
  7785. //String - Colour of the grid lines
  7786. scaleGridLineColor: "rgba(0,0,0,.05)",
  7787. //Number - Width of the grid lines
  7788. scaleGridLineWidth: 1,
  7789. //Boolean - Whether the line is curved between points
  7790. bezierCurve: false,
  7791. //Number - Tension of the bezier curve between points
  7792. bezierCurveTension: 0.4,
  7793. //Boolean - Whether to show a dot for each point
  7794. pointDot: true,
  7795. //Number - Radius of each point dot in pixels
  7796. pointDotRadius: 4,
  7797. //Number - Pixel width of point dot stroke
  7798. pointDotStrokeWidth: 1,
  7799. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7800. pointHitDetectionRadius: 20,
  7801. //Boolean - Whether to show a stroke for datasets
  7802. datasetStroke: true,
  7803. //Number - Pixel width of dataset stroke
  7804. datasetStrokeWidth: 2,
  7805. //Boolean - Whether to fill the dataset with a colour
  7806. datasetFill: true,
  7807. // Function - on animation progress
  7808. onAnimationProgress: function () {},
  7809. // Function - on animation complete
  7810. onAnimationComplete: function () {},
  7811. //String - A legend template
  7812. legendTemplate:
  7813. '<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>',
  7814. };
  7815. angular.extend($scope.options, $scope.opt);
  7816. $scope.datamonth = {
  7817. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7818. datasets: [
  7819. {
  7820. label: "新增事件数量",
  7821. fillColor: "rgba(220,220,220,0.5)",
  7822. strokeColor: "rgba(220,220,220,0.8)",
  7823. highlightFill: "rgba(220,220,220,0.75)",
  7824. highlightStroke: "rgba(220,220,220,1)",
  7825. data: [65, 59, 80, 81, 56, 55],
  7826. },
  7827. {
  7828. label: "已解决事件数量",
  7829. fillColor: "rgba(151,187,205,0.5)",
  7830. strokeColor: "rgba(151,187,205,0.8)",
  7831. highlightFill: "rgba(151,187,205,0.75)",
  7832. highlightStroke: "rgba(151,187,205,1)",
  7833. data: [28, 48, 40, 19, 86, 27],
  7834. },
  7835. ],
  7836. };
  7837. // Chart.js Options
  7838. $scope.taption = {
  7839. maintainAspectRatio: false,
  7840. // Sets the chart to be responsive
  7841. responsive: true,
  7842. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7843. scaleBeginAtZero: true,
  7844. //Boolean - Whether grid lines are shown across the chart
  7845. scaleShowGridLines: true,
  7846. //String - Colour of the grid lines
  7847. scaleGridLineColor: "rgba(0,0,0,.05)",
  7848. //Number - Width of the grid lines
  7849. scaleGridLineWidth: 1,
  7850. //Boolean - If there is a stroke on each bar
  7851. barShowStroke: true,
  7852. //Number - Pixel width of the bar stroke
  7853. barStrokeWidth: 2,
  7854. //Number - Spacing between each of the X value sets
  7855. barValueSpacing: 5,
  7856. //Number - Spacing between data sets within X values
  7857. barDatasetSpacing: 1,
  7858. //String - A legend template
  7859. legendTemplate:
  7860. '<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>',
  7861. };
  7862. },
  7863. ],
  7864. });
  7865. //排版日历
  7866. formlyConfigProvider.setType({
  7867. name: "ui-dashcalendar",
  7868. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7869. defaultOptions: function (options) {
  7870. return {
  7871. templateOptions: {
  7872. // relationAction: function() {
  7873. // options.hideExpression = true
  7874. // }
  7875. },
  7876. };
  7877. },
  7878. controller: [
  7879. "$rootScope",
  7880. "$scope",
  7881. "$modal",
  7882. "$aside",
  7883. "calendarConfig",
  7884. "moment",
  7885. "SweetAlert",
  7886. "Restangular",
  7887. "api_bpm_schedule",
  7888. "api_user_data",
  7889. "$state",
  7890. function (
  7891. $rootScope,
  7892. $scope,
  7893. $modal,
  7894. $aside,
  7895. calendarConfig,
  7896. moment,
  7897. SweetAlert,
  7898. Restangular,
  7899. api_bpm_schedule,
  7900. api_user_data,
  7901. $state
  7902. ) {
  7903. var loginUser = $rootScope.user;
  7904. calendarConfig.dateFormatter = "moment";
  7905. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7906. calendarConfig.i18nStrings.timeLabel = "时间";
  7907. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7908. calendarConfig.allDateFormats = {
  7909. angular: {
  7910. date: {
  7911. hour: "ha",
  7912. day: "d MMM",
  7913. month: "MMMM",
  7914. weekDay: "EEEE",
  7915. time: "HH:mm",
  7916. datetime: "MMM d, h:mm a",
  7917. },
  7918. title: {
  7919. day: "yyyy MMMM EEEE d",
  7920. week: "{year}年第{week}周",
  7921. month: "yyyy MMMM",
  7922. year: "yyyy",
  7923. },
  7924. },
  7925. moment: {
  7926. date: {
  7927. hour: "ha",
  7928. day: "MMMDD日",
  7929. month: "MMMM",
  7930. weekDay: "dddd",
  7931. time: "HH:mm",
  7932. datetime: "MMM D, h:mm a",
  7933. },
  7934. title: {
  7935. day: "YYYY年MMMMDD日, dddd ",
  7936. week: "{year}年第{week}周",
  7937. month: "YYYY年MMMM",
  7938. year: "YYYY",
  7939. },
  7940. },
  7941. };
  7942. moment.locale("zh_cn", {
  7943. months:
  7944. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7945. "_"
  7946. ),
  7947. monthsShort:
  7948. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7949. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7950. "_"
  7951. ),
  7952. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7953. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7954. longDateFormat: {
  7955. LT: "Ah点mm分",
  7956. LTS: "Ah点m分s秒",
  7957. L: "YYYY-MM-DD",
  7958. LL: "YYYY年MMMD日",
  7959. LLL: "YYYY年MMMD日Ah点mm分",
  7960. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7961. l: "YYYY-MM-DD",
  7962. ll: "YYYY年MMMD日",
  7963. lll: "YYYY年MMMD日Ah点mm分",
  7964. llll: "YYYY年MMMD日ddddAh点mm分",
  7965. },
  7966. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7967. meridiemHour: function (hour, meridiem) {
  7968. if (hour === 12) {
  7969. hour = 0;
  7970. }
  7971. if (
  7972. meridiem === "凌晨" ||
  7973. meridiem === "早上" ||
  7974. meridiem === "上午"
  7975. ) {
  7976. return hour;
  7977. } else if (meridiem === "下午" || meridiem === "晚上") {
  7978. return hour + 12;
  7979. } else {
  7980. // '中午'
  7981. return hour >= 11 ? hour : hour + 12;
  7982. }
  7983. },
  7984. meridiem: function (hour, minute, isLower) {
  7985. var hm = hour * 100 + minute;
  7986. if (hm < 600) {
  7987. return "凌晨";
  7988. } else if (hm < 900) {
  7989. return "早上";
  7990. } else if (hm < 1130) {
  7991. return "上午";
  7992. } else if (hm < 1230) {
  7993. return "中午";
  7994. } else if (hm < 1800) {
  7995. return "下午";
  7996. } else {
  7997. return "晚上";
  7998. }
  7999. },
  8000. calendar: {
  8001. sameDay: function () {
  8002. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8003. },
  8004. nextDay: function () {
  8005. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8006. },
  8007. lastDay: function () {
  8008. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8009. },
  8010. nextWeek: function () {
  8011. var startOfWeek, prefix;
  8012. startOfWeek = moment().startOf("week");
  8013. prefix =
  8014. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8015. ? "[下]"
  8016. : "[本]";
  8017. return this.minutes() === 0
  8018. ? prefix + "dddAh点整"
  8019. : prefix + "dddAh点mm";
  8020. },
  8021. lastWeek: function () {
  8022. var startOfWeek, prefix;
  8023. startOfWeek = moment().startOf("week");
  8024. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8025. return this.minutes() === 0
  8026. ? prefix + "dddAh点整"
  8027. : prefix + "dddAh点mm";
  8028. },
  8029. sameElse: "LL",
  8030. },
  8031. ordinalParse: /\d{1,2}(日|月|周)/,
  8032. ordinal: function (number, period) {
  8033. switch (period) {
  8034. case "d":
  8035. case "D":
  8036. case "DDD":
  8037. return number + "日";
  8038. case "M":
  8039. return number + "月";
  8040. case "w":
  8041. case "W":
  8042. return number + "周";
  8043. default:
  8044. return number;
  8045. }
  8046. },
  8047. relativeTime: {
  8048. future: "%s内",
  8049. past: "%s前",
  8050. s: "几秒",
  8051. m: "1 分钟",
  8052. mm: "%d 分钟",
  8053. h: "1 小时",
  8054. hh: "%d 小时",
  8055. d: "1 天",
  8056. dd: "%d 天",
  8057. M: "1 个月",
  8058. MM: "%d 个月",
  8059. y: "1 年",
  8060. yy: "%d 年",
  8061. },
  8062. week: {
  8063. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8064. dow: 1, // Monday is the first day of the week.
  8065. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8066. },
  8067. });
  8068. var date = new Date();
  8069. var d = date.getDate();
  8070. var m = date.getMonth();
  8071. var y = date.getFullYear();
  8072. var filterData = {
  8073. userId: loginUser.id,
  8074. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8075. "YYYY-MM-DD HH:mm:ss"
  8076. ),
  8077. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8078. "YYYY-MM-DD HH:mm:ss"
  8079. ),
  8080. };
  8081. var load = ($scope.load = function (filterData) {
  8082. api_bpm_schedule
  8083. .fetchSchedule(
  8084. filterData.userId,
  8085. filterData.startTime,
  8086. filterData.endTime
  8087. )
  8088. .then(function (response) {
  8089. if (response.status == 200) {
  8090. $scope.events = [];
  8091. var myData = response.list;
  8092. angular.forEach(myData, function (item) {
  8093. var eventTemp = {};
  8094. eventTemp.title = item.description;
  8095. eventTemp.type = item.scheduleClass.code;
  8096. eventTemp.startsAt = moment(
  8097. item["scheduleOrderDTO"].startTime
  8098. ).toDate();
  8099. eventTemp.endsAtTime = moment(
  8100. item["scheduleOrderDTO"].endTime
  8101. ).toDate();
  8102. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8103. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8104. //eventTemp.ends_at = moment(item.endTime).toDate();
  8105. eventTemp.id = item.id;
  8106. eventTemp.deletable = false;
  8107. eventTemp.user = item.user;
  8108. $scope.events.push(eventTemp);
  8109. });
  8110. }
  8111. });
  8112. });
  8113. // var load = $scope.load = function(filterData){
  8114. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8115. // console.log("response="+JSON.stringify(response));
  8116. // if(response.status==200){
  8117. // $scope.events = [];
  8118. // console.log(response.list);
  8119. // var myData = response.list;
  8120. // angular.forEach(myData,function(item){
  8121. // var eventTemp = {};
  8122. // eventTemp.title = item.description;
  8123. // eventTemp.type = item.scheduleClass.code;
  8124. // eventTemp.startsAt = moment(item.startTime).toDate();
  8125. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8126. // eventTemp.startTime = item.startTime;
  8127. // eventTemp.endTime = item.endTime;
  8128. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8129. // eventTemp.id = item.id;
  8130. // eventTemp.deletable = false;
  8131. // eventTemp.users = item.users;
  8132. // $scope.events.push(eventTemp);
  8133. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8134. // })
  8135. // }
  8136. // });
  8137. // }
  8138. $scope.scheduleClass = {};
  8139. var convertEvent = function (scheduleorder) {
  8140. var eventTemp = {};
  8141. eventTemp.title = scheduleorder.description;
  8142. eventTemp.type = scheduleorder.scheduleClass.code;
  8143. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8144. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8145. eventTemp.id = scheduleorder.id;
  8146. eventTemp.user = scheduleorder.user;
  8147. eventTemp.deletable = false;
  8148. return eventTemp;
  8149. };
  8150. // var convertEvent = function(scheduleorder){
  8151. // var eventTemp = {};
  8152. // eventTemp.title = scheduleorder.description;
  8153. // eventTemp.type = scheduleorder.scheduleClass.code;
  8154. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8155. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8156. // eventTemp.id = scheduleorder.id;
  8157. // eventTemp.users = scheduleorder.users;
  8158. // eventTemp.deletable = false;
  8159. // return eventTemp;
  8160. // }
  8161. api_bpm_schedule.getScheduleClass().then(function (response) {
  8162. if (response.status == 200) {
  8163. var scheduleClassList = response.list;
  8164. angular.forEach(scheduleClassList, function (item) {
  8165. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8166. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8167. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8168. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8169. $scope.scheduleClass[item["code"]] = item;
  8170. });
  8171. }
  8172. });
  8173. $scope.events = [];
  8174. $scope.calendarView = "month";
  8175. //$scope.calendarDay = new Date();
  8176. $scope.calendarDate = moment().startOf("month").toDate();
  8177. $scope.timeLabel = "时间";
  8178. $scope.eventLabel = "描述";
  8179. function showModal(action, event) {
  8180. // console.log("action="+JSON.stringify(action))
  8181. var modalInstance = $aside.open({
  8182. templateUrl: "scheduleEvent.html",
  8183. placement: "right",
  8184. size: "sm",
  8185. backdrop: true,
  8186. controller: function (
  8187. $scope,
  8188. $modalInstance,
  8189. scheduleClass,
  8190. APIService,
  8191. MementFormat
  8192. ) {
  8193. $scope.$modalInstance = $modalInstance;
  8194. $scope.action = action;
  8195. $scope.event = event;
  8196. $scope.scheduleClassic = scheduleClass;
  8197. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8198. // if(oldvalue == newvalue) return;
  8199. // if(scheduleClass[newvalue]){
  8200. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8201. var em = MementFormat(scheduleClass[newvalue].endTime);
  8202. console.log("sm=" + JSON.stringify(sm));
  8203. event.starts_at = MementFormat(event.startTime)
  8204. .startOf("day")
  8205. .add(sm.hour(), "hour")
  8206. .add(sm.minute(), "minute")
  8207. .add(sm.second(), "second")
  8208. .toDate();
  8209. console.log(
  8210. "event.starts_at=" + JSON.stringify(event.starts_at)
  8211. );
  8212. if (sm.hour() > em.hour()) {
  8213. event.ends_at = MementFormat(event.startTime)
  8214. .startOf("day")
  8215. .add(1, "day")
  8216. .add(em.hour(), "hour")
  8217. .add(em.minute(), "minute")
  8218. .add(em.second(), "second")
  8219. .toDate();
  8220. console.log(
  8221. "event.ends_at=" + JSON.stringify(event.starts_at)
  8222. );
  8223. } else {
  8224. event.ends_at = MementFormat(event.startTime)
  8225. .startOf("day")
  8226. .add(em.hour(), "hour")
  8227. .add(em.minute(), "minute")
  8228. .add(em.second(), "second")
  8229. .toDate();
  8230. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8231. }
  8232. // }
  8233. });
  8234. // $scope.ok = function (event) {
  8235. // console.log("event="+JSON.stringify(event))
  8236. // event.action = action;
  8237. // $modalInstance.close(event);
  8238. // };
  8239. $scope.cancel = function (event) {
  8240. $modalInstance.dismiss();
  8241. };
  8242. var acUserSelect = ($scope.refreshUser = function (key) {
  8243. //for test
  8244. // $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":"管理层"}]}];
  8245. // return;
  8246. var data = {
  8247. idx: "0",
  8248. sum: "5",
  8249. };
  8250. if (key) {
  8251. data["user"] = {
  8252. name: key,
  8253. };
  8254. }
  8255. APIService.fetchDataList("user", data).then(function (
  8256. response
  8257. ) {
  8258. if (response) {
  8259. if ((response.status = 200)) {
  8260. $scope.users = response.list;
  8261. console.log($scope.users);
  8262. }
  8263. }
  8264. });
  8265. });
  8266. if (angular.isDefined(event.users) && event.users.length > 0) {
  8267. }
  8268. $scope.users = [event.user];
  8269. acUserSelect();
  8270. },
  8271. resolve: {
  8272. scheduleClass: function () {
  8273. return $scope.scheduleClass;
  8274. },
  8275. APIService: function () {
  8276. return api_user_data;
  8277. },
  8278. MementFormat: function () {
  8279. return moment;
  8280. },
  8281. },
  8282. });
  8283. modalInstance.result.then(function (selectedEvent) {
  8284. if (selectedEvent.action == "Clicked") {
  8285. // var data = {
  8286. // "scheduleorder":{
  8287. // "id":selectedEvent.id,
  8288. // "description":selectedEvent.title,
  8289. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8290. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8291. // "users":selectedEvent.users,
  8292. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8293. // }
  8294. // };
  8295. // api_bpm_schedule.update(data).then(function(response){
  8296. // if(response.status==200){
  8297. // SweetAlert.swal({
  8298. // title: "操作成功!",
  8299. // text: "排班更新成功!",
  8300. // type: "succes"
  8301. // });
  8302. // angular.forEach($scope.events,function(item){
  8303. // if(item.id==selectedEvent.id){
  8304. // item = selectedEvent;
  8305. // }
  8306. // })
  8307. // }else{
  8308. // SweetAlert.swal({
  8309. // title: "操作失败",
  8310. // text: "排班更新失败,请稍后重试!",
  8311. // type: "error"
  8312. // })
  8313. // }
  8314. // })
  8315. } else {
  8316. //
  8317. }
  8318. });
  8319. }
  8320. $scope.moment = function (string) {
  8321. return moment(string);
  8322. };
  8323. $scope.eventClicked = function (event) {
  8324. // console.log("event="+JSON.stringify(event))
  8325. showModal("Clicked", event);
  8326. };
  8327. $scope.eventEdited = function (event) {
  8328. showModal("Edited", event);
  8329. };
  8330. var updateView = function (newvalue, oldvalue) {
  8331. if (oldvalue == newvalue) return;
  8332. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8333. if ($scope.calendarView == "year") {
  8334. } else if ($scope.calendarView == "month") {
  8335. timeStart = moment(newvalue).startOf("month");
  8336. timeEnd = moment(newvalue).endOf("month");
  8337. } else if ($scope.calendarView == "week") {
  8338. timeStart = moment(newvalue).startOf("week");
  8339. timeEnd = moment(newvalue).endOf("week");
  8340. } else if ($scope.calendarView == "Day") {
  8341. timeStart = moment(newvalue).startOf("day");
  8342. timeEnd = moment(newvalue).endOf("day");
  8343. }
  8344. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8345. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8346. filterData["startTime"] = timeStartSpan;
  8347. filterData["endTime"] = timeEndSpan;
  8348. load(filterData);
  8349. };
  8350. $scope.$watch("calendarDate", updateView);
  8351. $scope.next = function () {
  8352. $scope.calendarControl.next();
  8353. };
  8354. $scope.prev = function () {
  8355. $scope.calendarControl.prev();
  8356. };
  8357. $scope.setCalendarToToday = function () {
  8358. $scope.calendarDay = new Date();
  8359. };
  8360. $scope.toggle = function ($event, field, event) {
  8361. $event.preventDefault();
  8362. $event.stopPropagation();
  8363. event[field] = !event[field];
  8364. };
  8365. $scope.load(filterData);
  8366. $scope.more = function () {
  8367. $state.go("app.scheduling.myscheduling", {});
  8368. };
  8369. $scope.removes = function () {
  8370. var modalInstance = $modal.open({
  8371. templateUrl: "assets/views/delete.html",
  8372. controller: function ($scope, $modalInstance) {
  8373. $scope.ok = function () {
  8374. $modalInstance.close();
  8375. };
  8376. $scope.cancel = function () {
  8377. $modalInstance.dismiss("cancel");
  8378. };
  8379. },
  8380. size: "sm",
  8381. });
  8382. modalInstance.result.then(function () {
  8383. for (
  8384. var i = 0;
  8385. i <
  8386. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8387. i++
  8388. ) {
  8389. if (
  8390. $scope.fields.type ==
  8391. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8392. .type
  8393. ) {
  8394. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8395. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8396. i,
  8397. 1
  8398. );
  8399. break;
  8400. }
  8401. }
  8402. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8403. if (vmForm) {
  8404. //console.log("vmForm>>>");//console.log(vmForm);
  8405. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8406. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8407. }
  8408. });
  8409. };
  8410. },
  8411. ],
  8412. });
  8413. //空格组件
  8414. formlyConfigProvider.setType({
  8415. name: "ui-black",
  8416. /*extends: 'input',*/
  8417. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8418. });
  8419. //请求人最近事件
  8420. formlyConfigProvider.setType({
  8421. name: "ui-recentIncident",
  8422. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8423. controller: [
  8424. "$scope",
  8425. "$modal",
  8426. "api_solution",
  8427. function ($scope, $modal, api_solution) {
  8428. var filterData = {
  8429. incident: {
  8430. requester: {
  8431. id: "",
  8432. },
  8433. },
  8434. idx: 0,
  8435. sum: 3,
  8436. };
  8437. setInterval(function () {
  8438. if (
  8439. filterData.incident.requester.id == "" ||
  8440. filterData.incident.requester.id != $scope.model.requester.id
  8441. ) {
  8442. var requester = $scope.model.requester;
  8443. if (requester != null && angular.isDefined(requester.id)) {
  8444. filterData.incident.requester.id = $scope.model.requester.id;
  8445. $scope.options.templateOptions
  8446. .getWorkernumber(
  8447. $scope.options.templateOptions.ApiService,
  8448. filterData
  8449. )
  8450. .then(function (result) {
  8451. var modelData =
  8452. $scope.options.templateOptions.Restangular.stripRestangular(
  8453. result
  8454. );
  8455. if (modelData.status == 200) {
  8456. $scope.lastrequst = modelData.list;
  8457. }
  8458. });
  8459. requester = null;
  8460. } else {
  8461. }
  8462. } else {
  8463. }
  8464. }, 1000);
  8465. $scope.detail = function (data) {
  8466. var modalInstance = $modal.open({
  8467. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8468. controller: function ($scope, $modalInstance) {
  8469. $scope.entity = {};
  8470. $scope.entity = data;
  8471. $scope.cancel = function () {
  8472. $modalInstance.dismiss("cancel");
  8473. };
  8474. },
  8475. size: "lg",
  8476. });
  8477. };
  8478. },
  8479. ],
  8480. });
  8481. //参数列表
  8482. formlyConfigProvider.setType({
  8483. name: "ui-listinput",
  8484. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8485. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8486. defaultOptions: function (options) {
  8487. return {
  8488. templateOptions: {},
  8489. };
  8490. },
  8491. controller: ["$scope", function ($scope) {}],
  8492. });
  8493. //时间段控件(分)
  8494. formlyConfigProvider.setType({
  8495. name: "ui-timeslot",
  8496. extends: "input",
  8497. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8498. controller: ["$scope", function ($scope) {}],
  8499. });
  8500. //优先级级联-逾期时间
  8501. formlyConfigProvider.setType({
  8502. name: "ui-overtime",
  8503. extends: "input",
  8504. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8505. controller: [
  8506. "$scope",
  8507. "api_bpm_domain",
  8508. function ($scope, api_bpm_domain) {
  8509. var filteData = {};
  8510. var datas = {};
  8511. setInterval(function () {
  8512. if (
  8513. $scope.model.priority &&
  8514. $scope.model.priority.id != null &&
  8515. filteData &&
  8516. datas != $scope.model.priority.id
  8517. ) {
  8518. filteData = "L" + $scope.model.priority.id;
  8519. datas = $scope.model.priority.id;
  8520. // console.log($scope.options.templateOptions)
  8521. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8522. // var overtime=requester.date;
  8523. if (requester.state == 200) {
  8524. // if($scope.options.key=="date"){
  8525. $scope.model[$scope.options.key] = requester.date;
  8526. // }
  8527. }
  8528. });
  8529. }
  8530. }, 1000);
  8531. },
  8532. ],
  8533. });
  8534. formlyConfigProvider.setType({
  8535. name: "ui-responsetime",
  8536. extends: "input",
  8537. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8538. controller: [
  8539. "$scope",
  8540. "api_bpm_domain",
  8541. function ($scope, api_bpm_domain) {
  8542. var filteData = {};
  8543. var datas = {};
  8544. setInterval(function () {
  8545. if (
  8546. $scope.model.priority &&
  8547. $scope.model.priority.id != null &&
  8548. filteData &&
  8549. datas != $scope.model.priority.id
  8550. ) {
  8551. filteData = "L" + $scope.model.priority.id;
  8552. datas = $scope.model.priority.id;
  8553. // console.log($scope.options.templateOptions)
  8554. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8555. // var overtime=requester.date;
  8556. if (requester.state == 200) {
  8557. var keyName = {};
  8558. // $scope.model.overdueTime = requester.date;
  8559. if ($scope.options.key == "expectIntroTime") {
  8560. keyName = "resolveTime";
  8561. } else if ($scope.options.key == "expectResponseTime") {
  8562. keyName = "responseTime";
  8563. }
  8564. $scope.model[$scope.options.key] =
  8565. requester.serviceLevelAgreement[keyName];
  8566. // }
  8567. console.log($scope.$parent.$parent.$parent.model);
  8568. }
  8569. if (requester.date1) {
  8570. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8571. requester.date;
  8572. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8573. requester.date1;
  8574. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8575. requester.serviceLevelAgreement.resolveTime;
  8576. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8577. requester.serviceLevelAgreement.responseTime;
  8578. }
  8579. });
  8580. }
  8581. }, 1000);
  8582. },
  8583. ],
  8584. });
  8585. //知识库按钮组件
  8586. formlyConfigProvider.setType({
  8587. name: "ui-discasecade",
  8588. extends: "input",
  8589. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8590. defaultOptions: function (options) {
  8591. return {
  8592. templateOptions: {
  8593. relationAction: function (fields, modelscope, item) {},
  8594. },
  8595. validators: {
  8596. required: {
  8597. expression: function (viewValue, modelValue) {
  8598. var value = modelValue || viewValue;
  8599. // return value = "true";
  8600. },
  8601. },
  8602. },
  8603. };
  8604. },
  8605. controller: [
  8606. "$scope",
  8607. "$rootScope",
  8608. "$modal",
  8609. "SweetAlert",
  8610. "api_bpm_data",
  8611. "api_solution",
  8612. "$aside",
  8613. "api_zsk",
  8614. "api_bpm_domain",
  8615. function (
  8616. $scope,
  8617. $rootScope,
  8618. $modal,
  8619. SweetAlert,
  8620. api_bpm_data,
  8621. api_solution,
  8622. $aside,
  8623. api_zsk,
  8624. api_bpm_domain
  8625. ) {
  8626. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8627. $scope.searchField = $scope.options.model[$scope.options.key];
  8628. $scope.searchData = "";
  8629. $scope.onChangeadd = function (searchData) {
  8630. $scope.searchKey = searchData.account;
  8631. // $scope.searchDataadd = searchData;
  8632. var requesdata = angular.copy(searchData);
  8633. $scope.requester = requesdata;
  8634. };
  8635. $scope.refreshUseradd = function (searchKey) {
  8636. //主题搜索
  8637. $scope.searchData = searchKey;
  8638. reashdata($scope.searchData);
  8639. };
  8640. $scope.getMydata = function (x) {
  8641. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8642. $scope.searchField = $scope.model[$scope.options.key];
  8643. };
  8644. $scope.getMydataone = function (x) {
  8645. $scope.model[$scope.options.key] = x;
  8646. $scope.searchField = $scope.model[$scope.options.key];
  8647. };
  8648. $scope.fildata = {
  8649. idx: 0,
  8650. sum: 10,
  8651. // 'incident': { 'tilte': item }
  8652. };
  8653. function reashdata(item) {
  8654. if (item && item != "") {
  8655. angular.extend($scope.fildata, {
  8656. incident: {
  8657. title: item,
  8658. },
  8659. });
  8660. } else {
  8661. delete $scope.fildata.incident;
  8662. }
  8663. api_bpm_data
  8664. .fetchDataList("incident", $scope.fildata)
  8665. .then(function (response) {
  8666. if (response) {
  8667. if ((response.status = 200)) {
  8668. var myData = response;
  8669. $scope.myData = myData.list;
  8670. }
  8671. }
  8672. });
  8673. }
  8674. function delHtmlTag(str) {
  8675. return str.replace(/<[^>]+>/g, "");
  8676. }
  8677. // reashdata();
  8678. var changedata = {};
  8679. setInterval(function () {
  8680. if (
  8681. $scope.model.category != null &&
  8682. $scope.model.category.id != changedata.id &&
  8683. $scope.model.titles != $scope.model.category
  8684. ) {
  8685. $scope.searchData = {};
  8686. changedata = angular.copy($scope.model.category);
  8687. if ($scope.options.key == "title") {
  8688. var filterData = {
  8689. idx: 0,
  8690. sum: 1000,
  8691. };
  8692. api_bpm_data
  8693. .fetchDataList("incidentcategory", filterData)
  8694. .then(function (data) {
  8695. var datalist = data.list;
  8696. angular.forEach(datalist, function (item) {
  8697. if (item.id == $scope.model.category.id) {
  8698. $scope.model[$scope.options.key] = item.category;
  8699. $scope.searchField =
  8700. $scope.options.model[$scope.options.key];
  8701. $scope.titles = item.category;
  8702. titles = $scope.model.category;
  8703. }
  8704. });
  8705. });
  8706. }
  8707. }
  8708. }, 1000);
  8709. $scope.open = function (key, options, fildata, $event, model) {
  8710. if (key && key.length > 1) {
  8711. api_zsk
  8712. .solutionData(
  8713. {
  8714. solution: {
  8715. searchWord: key,
  8716. },
  8717. idx: "0",
  8718. sum: "1000",
  8719. },
  8720. "solution"
  8721. )
  8722. .then(function (response) {
  8723. if (response && response.list.length > 0) {
  8724. $scope.dlideboxslide = true;
  8725. angular.forEach(response, function (item) {
  8726. console.log(response);
  8727. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8728. // if (response.status == 200) {
  8729. // var quote = { 'totalNum': response.totalNum }
  8730. // item = angular.extend(item, quote)
  8731. // }
  8732. // })
  8733. $scope.searchData = response.list;
  8734. console.log($scope.searchData);
  8735. });
  8736. $scope.changes = false;
  8737. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8738. // $scope.closepages = function(e) {
  8739. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8740. // event.preventDefault();
  8741. // };
  8742. $scope.shows = false;
  8743. $scope.tempData = {};
  8744. $scope.showpage = function (item) {
  8745. item.content = delHtmlTag(item.content);
  8746. $scope.shows = true;
  8747. $scope.tempData = item;
  8748. if (item.content != null) {
  8749. $scope.tempData.content = $scope.tempData.content
  8750. .replace("<p>", "")
  8751. .replace("</p>", "");
  8752. }
  8753. $scope.knowledgedata = item;
  8754. $scope.pageid = item.id;
  8755. $scope.changes = !$scope.changes;
  8756. api_bpm_domain
  8757. .listAttachments(item.id)
  8758. // api_solution.fetchDataList('file', {
  8759. // "file": {
  8760. // "solutionId": item.id
  8761. // },
  8762. // "idx": "0",
  8763. // "sum": "1000"
  8764. // })
  8765. .then(function (data) {
  8766. if (data) {
  8767. $scope.attachments = data.list;
  8768. $scope.view = function (attachmentId) {
  8769. for (
  8770. var i = 0;
  8771. i < $scope.attachments.length;
  8772. i++
  8773. ) {
  8774. if ($scope.attachments[i].id == attachmentId) {
  8775. window.open($scope.attachments[i].previewUrl);
  8776. }
  8777. }
  8778. };
  8779. $scope.download = function (contentId, filename) {
  8780. api_solution
  8781. .getSolutionDowpath(contentId)
  8782. .then(function (response) {
  8783. var file = new Blob([response], {
  8784. type: "application/octet-stream",
  8785. });
  8786. // var filename = filename;
  8787. var fileURL = URL.createObjectURL(file);
  8788. var a = document.createElement("a");
  8789. a.href = fileURL;
  8790. a.target = "_blank";
  8791. a.download = filename;
  8792. document.body.appendChild(a);
  8793. a.click();
  8794. });
  8795. };
  8796. }
  8797. });
  8798. };
  8799. $scope.related = function (item) {
  8800. if (item.content != null) {
  8801. item.content = item.content
  8802. .replace("<p>", "")
  8803. .replace("</p>", "");
  8804. }
  8805. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8806. options.model.handleDescription = item.content;
  8807. var data = {
  8808. solutionQuote: {
  8809. solutionId: item.id,
  8810. incidentsign: options.model.incidentsign,
  8811. },
  8812. };
  8813. api_zsk.solutionQuote(item.id).then(function (response) {
  8814. if (response.status == 200) {
  8815. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8816. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8817. "close";
  8818. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8819. } else {
  8820. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8821. }
  8822. });
  8823. };
  8824. $scope.close = function () {
  8825. $scope.changes = !$scope.changes;
  8826. event.preventDefault();
  8827. };
  8828. }
  8829. });
  8830. }
  8831. };
  8832. },
  8833. ],
  8834. });
  8835. //侧滑选择重复事件
  8836. formlyConfigProvider.setType({
  8837. name: "ui-repeatIncidentbtn",
  8838. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8839. defaultOptions: function (options) {
  8840. return {
  8841. templateOptions: {
  8842. relationAction: function (fields, modelscope, item) {},
  8843. },
  8844. validators: {
  8845. required: {
  8846. expression: function (viewValue, modelValue) {
  8847. // var value = modelValue || viewValue;
  8848. },
  8849. },
  8850. },
  8851. };
  8852. },
  8853. controller: [
  8854. "$scope",
  8855. "$rootScope",
  8856. "$modal",
  8857. "SweetAlert",
  8858. "api_bpm_data",
  8859. "api_solution",
  8860. "$aside",
  8861. "api_zsk",
  8862. "api_bpm_domain",
  8863. function (
  8864. $scope,
  8865. $rootScope,
  8866. $modal,
  8867. SweetAlert,
  8868. api_bpm_data,
  8869. api_solution,
  8870. $aside,
  8871. api_zsk,
  8872. api_bpm_domain
  8873. ) {
  8874. console.log($scope);
  8875. $scope.selection = {
  8876. id: "",
  8877. };
  8878. //认证计费数据获取
  8879. $scope.sumInfo = {};
  8880. function getSumInfo() {
  8881. api_bpm_data
  8882. .sumInfo($scope.model.incident.account)
  8883. .then(function (data) {
  8884. console.log(data);
  8885. if (data) {
  8886. $scope.sumInfo = data.data || {};
  8887. }
  8888. });
  8889. }
  8890. getSumInfo();
  8891. // 收起重复事件侧滑框
  8892. function reashdata(item) {
  8893. var fildata = {
  8894. idx: 0,
  8895. incident: {
  8896. department: {
  8897. id: $scope.model.incident.department.id,
  8898. },
  8899. },
  8900. sum: 3,
  8901. };
  8902. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8903. console.log(data);
  8904. if (data) {
  8905. $scope.repeatData = data.list;
  8906. }
  8907. });
  8908. }
  8909. reashdata();
  8910. // 确认选中的重复事件
  8911. $scope.repeatIncidentOk = function () {
  8912. if ($scope.selection.id) {
  8913. $scope.model.incident.repeat = $scope.selection;
  8914. $scope.model.isRepeat = true; //隐藏处理信息
  8915. console.log($scope.model);
  8916. }
  8917. angular.element("#repeatIncident").removeClass("active");
  8918. };
  8919. // 取消选中的重复事件
  8920. $scope.repeatIncidentCancle = function () {
  8921. angular.element("#repeatIncident").removeClass("active");
  8922. return;
  8923. };
  8924. },
  8925. ],
  8926. });
  8927. //侧滑选择知识库查询
  8928. formlyConfigProvider.setType({
  8929. name: "ui-knowledgebtn",
  8930. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8931. defaultOptions: function (options) {
  8932. return {
  8933. templateOptions: {
  8934. relationAction: function (fields, modelscope, item) {},
  8935. },
  8936. validators: {
  8937. required: {
  8938. expression: function (viewValue, modelValue) {
  8939. // var value = modelValue || viewValue;
  8940. },
  8941. },
  8942. },
  8943. };
  8944. },
  8945. controller: [
  8946. "$scope",
  8947. "$rootScope",
  8948. "$modal",
  8949. "SweetAlert",
  8950. "api_bpm_data",
  8951. "api_solution",
  8952. "$aside",
  8953. "api_zsk",
  8954. "api_bpm_domain",
  8955. "api_wechatfile",
  8956. "up_down_file",
  8957. function (
  8958. $scope,
  8959. $rootScope,
  8960. $modal,
  8961. SweetAlert,
  8962. api_bpm_data,
  8963. api_solution,
  8964. $aside,
  8965. api_zsk,
  8966. api_bpm_domain,
  8967. api_wechatfile,
  8968. up_down_file
  8969. ) {
  8970. $scope.keypressModel = function (e, key) {
  8971. if (e.keyCode === 13) {
  8972. $scope.openModel(key);
  8973. }
  8974. };
  8975. // 引用知识库点击
  8976. $scope.searchKeyWord = "";
  8977. $scope.openModel = function (key) {
  8978. // alert(1)//重点
  8979. $scope.searchKeyWord = key;
  8980. if (key) {
  8981. api_zsk
  8982. .solutionData(
  8983. {
  8984. solution: {
  8985. threeSearch: key,
  8986. status: { id: 72 }, //已发布
  8987. selectType: "keySearch",
  8988. },
  8989. idx: "0",
  8990. sum: "1000",
  8991. },
  8992. "solution"
  8993. )
  8994. .then(function (response) {
  8995. $scope.searchData = response.list;
  8996. });
  8997. }
  8998. };
  8999. $scope.openModel($scope.model.incident.description);
  9000. // 展开/收起
  9001. $scope.showId = "";
  9002. $scope.ifshow = false;
  9003. $scope.showAll = function (id) {
  9004. $scope.attachments = [];
  9005. if ($scope.showId == id) {
  9006. $scope.ifshow = !$scope.ifshow;
  9007. } else {
  9008. $scope.ifshow = true;
  9009. }
  9010. $scope.showId = id;
  9011. // 获取附件
  9012. api_wechatfile
  9013. .listAttachments("knowledge", $scope.showId)
  9014. .then(function (data) {
  9015. $scope.attachments = data.data;
  9016. $scope.download = function (token, filename) {
  9017. var downUrl = up_down_file
  9018. .downloadAttachment("common/common/downloadAttachment", token)
  9019. .getRequestedUrl();
  9020. // window.open(downUrl);
  9021. var a = document.createElement("a");
  9022. a.href = downUrl;
  9023. a.target = "_blank";
  9024. a.download = filename;
  9025. document.body.appendChild(a);
  9026. a.click();
  9027. };
  9028. });
  9029. };
  9030. // 引用
  9031. $scope.related = function (item) {
  9032. console.log(item, "引用名");
  9033. if (item.content) {
  9034. item.content = item.content
  9035. .replace(/<p>/g, "")
  9036. .replace(/<\/p>/g, "")
  9037. .replace(/&nbsp;/g, "");
  9038. }
  9039. $scope.model.incident.handleDescription = item.content;
  9040. $scope.model.incident.title = $scope.model.incident.description =
  9041. item.title;
  9042. $scope.model.incident.category = item.category;
  9043. if (item.category) {
  9044. $scope.model.incident.priority.id = item.category.priority.id;
  9045. item.category.label = item.category.category;
  9046. }
  9047. var categoryId = item.category ? item.category.id : "";
  9048. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  9049. function getres(nodes) {
  9050. if (!nodes || nodes.length == 0) {
  9051. return;
  9052. }
  9053. nodes.forEach((e) => {
  9054. e.selected = false;
  9055. if (e.id == categoryId) {
  9056. e.selected = true;
  9057. return false;
  9058. }
  9059. getres(e.children);
  9060. });
  9061. }
  9062. var categorys = [];
  9063. $scope.fields.forEach((e, i) => {
  9064. if (e.key == "category") {
  9065. categorys = e.templateOptions.options;
  9066. if (categorys.length) {
  9067. getres(categorys);
  9068. $scope.fields[i].templateOptions.options = categorys;
  9069. $scope.$root.refreshSelectedItems();
  9070. }
  9071. return false;
  9072. }
  9073. });
  9074. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9075. $scope.model.candidateGroups = item.category
  9076. ? item.category.group
  9077. : {};
  9078. // 携带关联优先级,事件工单信息的时间
  9079. if (
  9080. $scope.model &&
  9081. $scope.model.incident &&
  9082. item.category &&
  9083. item.category.priority &&
  9084. item.category.priority.id
  9085. ) {
  9086. api_bpm_domain
  9087. .expectedTime("L" + (item.category.priority.id - 1559))
  9088. .then(function (res) {
  9089. $scope.model.incident.expectResponseTime =
  9090. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9091. res.serviceLevelAgreement.responseTime;
  9092. $scope.model.incident.expectIntroTime =
  9093. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9094. res.serviceLevelAgreement.resolveTime;
  9095. $scope.model.incident.overdueTime =
  9096. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9097. res.date;
  9098. });
  9099. }
  9100. api_zsk.solutionQuote(item.id).then(function (response) {
  9101. if (response.status == 200) {
  9102. $("#seachknowledge").removeClass("active");
  9103. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9104. $scope.$parent.$parent.$parent.model.start_code = "close";
  9105. $scope.$parent.$parent.$parent.model.directClose = 0;
  9106. console.log($scope.model);
  9107. } else {
  9108. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9109. }
  9110. });
  9111. };
  9112. },
  9113. ],
  9114. });
  9115. //下拉输入组件
  9116. formlyConfigProvider.setType({
  9117. name: "ui-selectinput",
  9118. extends: "input",
  9119. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9120. defaultOptions: function (options) {
  9121. return {
  9122. templateOptions: {
  9123. refresh: function () {},
  9124. refreshDelay: 0,
  9125. linkage: function (modelName, data) {},
  9126. },
  9127. };
  9128. },
  9129. controller: [
  9130. "$scope",
  9131. "$rootScope",
  9132. "$modal",
  9133. "SweetAlert",
  9134. "api_bpm_data",
  9135. "api_solution",
  9136. "$aside",
  9137. function (
  9138. $scope,
  9139. $rootScope,
  9140. $modal,
  9141. SweetAlert,
  9142. api_bpm_data,
  9143. api_solution,
  9144. $aside
  9145. ) {
  9146. $scope.searchData = "";
  9147. $scope.onChangeadd = function (searchData) {
  9148. // $scope.searchKey = searchData.account;
  9149. // var requesdata = angular.copy(searchData)
  9150. // $scope.requester = requesdata;
  9151. };
  9152. $scope.refreshUseradd = function (searchKey) {
  9153. //主题搜索
  9154. // $scope.searchData = searchKey;
  9155. // reashdata($scope.searchData);
  9156. };
  9157. $scope.getMydata = function (x) {
  9158. $scope.model[$scope.options.key] =
  9159. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9160. $scope.searchField = $scope.model[$scope.options.key];
  9161. };
  9162. $scope.getMydataone = function (x) {
  9163. $scope.model[$scope.options.key] = x;
  9164. $scope.searchField = $scope.model[$scope.options.key];
  9165. if (
  9166. $scope.model[$scope.options.key] &&
  9167. $scope.model[$scope.options.key] != ""
  9168. ) {
  9169. $scope.hidden = false;
  9170. } else {
  9171. $scope.hidden = true;
  9172. }
  9173. };
  9174. function reashdata(item) {
  9175. $scope.myData = $scope.options.templateOptions.mydata;
  9176. }
  9177. reashdata();
  9178. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9179. $scope.options.templateOptions.fetchItems($scope);
  9180. }
  9181. },
  9182. ],
  9183. });
  9184. //重构组件模板
  9185. //获取当前人
  9186. formlyConfigProvider.setType({
  9187. name: "ui-users",
  9188. extends: "input",
  9189. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9190. defaultOptions: function (options) {
  9191. return {
  9192. templateOptions: {
  9193. translate: "",
  9194. refreshDelay: 0,
  9195. },
  9196. };
  9197. },
  9198. controller: [
  9199. "$scope",
  9200. function ($scope) {
  9201. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9202. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9203. },
  9204. ],
  9205. });
  9206. //只读控件
  9207. formlyConfigProvider.setType({
  9208. name: "ui-label",
  9209. extends: "input",
  9210. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9211. defaultOptions: function (options) {
  9212. return {
  9213. templateOptions: {
  9214. translate: "",
  9215. refreshDelay: 0,
  9216. },
  9217. };
  9218. },
  9219. controller: [
  9220. "$scope",
  9221. "$rootScope",
  9222. function ($scope, $rootScope) {
  9223. // console.log($scope.options.templateOptions)
  9224. // console.log($scope.options,'options1122');
  9225. $scope.isSolutionLabel = false;
  9226. $scope.solutionLabelStr = "";
  9227. // console.log($scope.options.templateOptions.solotinLabel);
  9228. if ($scope.options.templateOptions.solotinLabel) {
  9229. $scope.isSolutionLabel = true;
  9230. if ($scope.model[$scope.options.key]) {
  9231. var solutionArr = $scope.model[$scope.options.key].split("/");
  9232. $scope.solutionLabelStr = solutionArr.join(" ");
  9233. }
  9234. }
  9235. var value = $scope.model[$scope.options.key];
  9236. // ----------------
  9237. // ----------------
  9238. // console.log(value, 'pppp')
  9239. function treeDesc(children, key, label) {
  9240. if (label == "") {
  9241. label = children[key];
  9242. } else {
  9243. label = children[key] + "-" + label;
  9244. }
  9245. if (angular.isDefined(children.parent)) {
  9246. treeDesc(children.parent, key, label);
  9247. } else {
  9248. return label;
  9249. }
  9250. }
  9251. if (angular.isArray(value)) {
  9252. var tempValue = "";
  9253. angular.forEach(value, function (item) {
  9254. if (tempValue != "") {
  9255. tempValue = tempValue + ",";
  9256. }
  9257. tempValue =
  9258. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9259. item;
  9260. });
  9261. $scope.options.templateOptions.translate = tempValue;
  9262. } else if (angular.isObject(value)) {
  9263. if (
  9264. angular.isDefined(value.children) ||
  9265. angular.isDefined(value.parent)
  9266. ) {
  9267. //tree
  9268. // console.log("value.parent="+JSON.stringify(value.parent))
  9269. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9270. nameLabel = treeDesc(
  9271. value.parent,
  9272. $scope.options.templateOptions.labelProp,
  9273. nameLabel
  9274. );
  9275. $scope.options.templateOptions.translate = nameLabel;
  9276. } else {
  9277. $scope.options.templateOptions.translate = value;
  9278. }
  9279. } else if (
  9280. angular.isString(value) &&
  9281. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9282. ) {
  9283. // console.log("value=" + value);
  9284. $scope.options.templateOptions.translate = value;
  9285. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9286. // console.log("value="+value);
  9287. // $scope.options.templateOptions.translate = value;
  9288. } else {
  9289. // var datasdf = JSON.parse(value);
  9290. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9291. $scope.options.templateOptions.translate = value;
  9292. }
  9293. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9294. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9295. $scope.options.templateOptions.translate =
  9296. $scope.options.templateOptions.transform(
  9297. $scope.originalModel,
  9298. value,
  9299. $rootScope,
  9300. $scope
  9301. );
  9302. }
  9303. // console.log($scope.options.templateOptions.translate,99999);
  9304. },
  9305. ],
  9306. });
  9307. //小标题组件
  9308. formlyConfigProvider.setType({
  9309. name: "ui-header",
  9310. template:
  9311. '<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>',
  9312. });
  9313. //标题组件
  9314. formlyConfigProvider.setType({
  9315. name: "ui-title",
  9316. template:
  9317. '<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>',
  9318. });
  9319. //标栏是否展示
  9320. formlyConfigProvider.setType({
  9321. name: "ui-orshow",
  9322. template:
  9323. '<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>',
  9324. controller: [
  9325. "$scope",
  9326. function ($scope) {
  9327. $scope.clickshow = function (key) {
  9328. // $scope.model[$scope.options.key] != key;
  9329. if (key == false) {
  9330. $scope.model[$scope.options.key] = true;
  9331. } else {
  9332. $scope.model[$scope.options.key] = false;
  9333. }
  9334. };
  9335. },
  9336. ],
  9337. });
  9338. //按钮组
  9339. formlyConfigProvider.setType({
  9340. name: "ui-button",
  9341. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9342. defaultOptions: function (options) {
  9343. return {
  9344. noFormControl: true,
  9345. };
  9346. },
  9347. });
  9348. //3d组link
  9349. formlyConfigProvider.setType({
  9350. name: "ui-link",
  9351. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9352. defaultOptions: function (options) {
  9353. return {
  9354. noFormControl: true,
  9355. };
  9356. },
  9357. });
  9358. //隐藏域组件
  9359. formlyConfigProvider.setType({
  9360. name: "ui-hidden",
  9361. extends: "input",
  9362. template:
  9363. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9364. defaultOptions: function (options) {
  9365. return {
  9366. // noFormControl: true
  9367. };
  9368. },
  9369. });
  9370. //文本框组件
  9371. formlyConfigProvider.setType({
  9372. name: "ui-input",
  9373. extends: "input",
  9374. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9375. defaultOptions: function (options) {
  9376. return {
  9377. templateOptions: {
  9378. transform: function (value) {},
  9379. },
  9380. };
  9381. },
  9382. controller: [
  9383. "$scope",
  9384. "$timeout",
  9385. function ($scope, $timeout) {
  9386. // console.log($scope.model[$scope.options.key]);
  9387. // console.log($scope.options)
  9388. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9389. $scope.model[$scope.options.key] =
  9390. $scope.options.templateOptions.linkData($scope.model);
  9391. }
  9392. },
  9393. ],
  9394. });
  9395. //搜索下拉框-故障地点seimin
  9396. formlyConfigProvider.setType({
  9397. name: "ui-select-search",
  9398. extends: "input",
  9399. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9400. defaultOptions: function (options) {
  9401. return {
  9402. templateOptions: {
  9403. transform: function (value) {},
  9404. },
  9405. };
  9406. },
  9407. controller: [
  9408. "$scope",
  9409. "$rootScope",
  9410. "api_search_area",
  9411. function ($scope, $rootScope, api_search_area) {
  9412. // console.log($scope.options, $scope.model)
  9413. // ----------------分割线 start-----------------
  9414. // 故障地点下拉
  9415. $scope.address_arr = []; //故障地点所有数据
  9416. $scope.addressFlag = false; //默认下拉框列表隐藏
  9417. //点击文本框
  9418. $scope.AddressClickHandle = function () {
  9419. $scope.getDepartmentList();
  9420. angular.element("#bx_address_ul").scrollTop(0);
  9421. };
  9422. //修改文字,实时监听
  9423. $scope.ksChangeHandle = _.debounce(function () {
  9424. $scope.model[$scope.options.key] =
  9425. $scope.model[$scope.options.key] === undefined
  9426. ? ""
  9427. : $scope.model[$scope.options.key];
  9428. $scope.getDepartmentList();
  9429. angular.element("#bx_address_ul").scrollTop(0);
  9430. }, 500);
  9431. //获取故障地点seimin
  9432. $scope.getDepartmentList = function () {
  9433. $scope.model[$scope.options.key] =
  9434. $scope.model[$scope.options.key] === null
  9435. ? ""
  9436. : $scope.model[$scope.options.key];
  9437. api_search_area
  9438. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9439. .then((res) => {
  9440. if (res.state == 200) {
  9441. $scope.address_arr = res.result;
  9442. $scope.addressFlag = true; //显示
  9443. }
  9444. })
  9445. .catch((err) => {
  9446. console.log(err);
  9447. });
  9448. };
  9449. // $scope.getDepartmentList();
  9450. // console.log($scope.model[$scope.options.key])
  9451. //下拉框列表选中
  9452. $scope.addressItemClick = function (obj) {
  9453. $scope.addressFlag = false; //隐藏
  9454. $scope.model[$scope.options.key] = obj.place
  9455. ? obj.area.area + obj.place
  9456. : obj.area;
  9457. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9458. $scope.model.selecthouseNumber = obj;
  9459. console.log($scope, 77777);
  9460. $scope.$root.selecthouseNumber = obj;
  9461. };
  9462. //点击空白处隐藏
  9463. angular.element(document).on("click", function (e) {
  9464. if (e.target !== angular.element("#bx_address").get(0)) {
  9465. $scope.addressFlag = false; //隐藏
  9466. //模拟placeholder
  9467. // if ($('#bx_address').val() == '') {
  9468. // $('#bx_address').val('请选择报修科室');
  9469. // }
  9470. }
  9471. });
  9472. // -----------------分割线 end----------------
  9473. },
  9474. ],
  9475. });
  9476. //知识库关键字组件
  9477. formlyConfigProvider.setType({
  9478. name: "ui-knowledgeKeywords",
  9479. extends: "input",
  9480. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9481. defaultOptions: function (options) {
  9482. return {
  9483. templateOptions: {
  9484. transform: function (value) {},
  9485. },
  9486. };
  9487. },
  9488. controller: [
  9489. "$scope",
  9490. "$timeout",
  9491. "SweetAlert",
  9492. function ($scope, $timeout, SweetAlert) {
  9493. $scope.valueLength = [
  9494. {
  9495. value: "",
  9496. },
  9497. ];
  9498. $scope.valueAll = [];
  9499. if ($scope.model[$scope.options.key]) {
  9500. var valueArr = $scope.model[$scope.options.key].split("/");
  9501. $scope.valueLength = [];
  9502. for (var i = 0; i < valueArr.length; i++) {
  9503. $scope.valueLength.push({
  9504. value: valueArr[i],
  9505. });
  9506. }
  9507. }
  9508. $scope.addIpt = function () {
  9509. if ($scope.valueLength.length < 5) {
  9510. $scope.valueLength.push({
  9511. value: "",
  9512. });
  9513. } else {
  9514. SweetAlert.swal({
  9515. title: "添加失败",
  9516. text: "关键字不能超过5个!",
  9517. type: "error",
  9518. confirmButtonColor: "#DD6B55",
  9519. });
  9520. }
  9521. };
  9522. $scope.closeIpt = function (data) {
  9523. $scope.valueLength.splice(data, 1);
  9524. };
  9525. $scope.toOption = function () {
  9526. $scope.valueAll = [];
  9527. for (var i = 0; i < $scope.valueLength.length; i++) {
  9528. if ($scope.valueLength[i].value != "") {
  9529. $scope.valueAll.push($scope.valueLength[i].value);
  9530. }
  9531. }
  9532. $scope.model.label = $scope.valueAll.join("/");
  9533. };
  9534. },
  9535. ],
  9536. });
  9537. //文本框组件
  9538. formlyConfigProvider.setType({
  9539. name: "ui-num",
  9540. extends: "input",
  9541. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9542. defaultOptions: function (options) {
  9543. return {
  9544. templateOptions: {
  9545. transform: function (value) {},
  9546. },
  9547. };
  9548. },
  9549. controller: [
  9550. "$scope",
  9551. "$timeout",
  9552. function ($scope, $timeout) {
  9553. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9554. $scope.model[$scope.options.key] =
  9555. $scope.options.templateOptions.linkData($scope.model);
  9556. }
  9557. $scope.clearNoNum = function (obj, attr) {
  9558. //先把非数字的都替换掉,除了数字和.
  9559. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9560. //必须保证第一个为数字而不是.
  9561. obj[attr] = obj[attr].replace(/^\./g, "");
  9562. //保证只有出现一个.而没有多个.
  9563. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9564. //保证.只出现一次,而不能出现两次以上
  9565. obj[attr] = obj[attr]
  9566. .replace(".", "$#$")
  9567. .replace(/\./g, "")
  9568. .replace("$#$", ".");
  9569. //小于最大值
  9570. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9571. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9572. // obj[attr] = '';
  9573. // }
  9574. };
  9575. },
  9576. ],
  9577. });
  9578. // //关联请求人文本框组件
  9579. // formlyConfigProvider.setType({
  9580. // name: 'ui-requestinput',
  9581. // extends: 'input',
  9582. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9583. // defaultOptions: function(options) {
  9584. // return {
  9585. // templateOptions: {
  9586. // transform: function(value) {},
  9587. // linkData: function(options) {}
  9588. // }
  9589. // };
  9590. // }
  9591. // });
  9592. //只读文本
  9593. formlyConfigProvider.setType({
  9594. name: "ui-disableinput",
  9595. extends: "input",
  9596. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9597. defaultOptions: function (options) {
  9598. return {
  9599. templateOptions: {
  9600. transform: function (value) {
  9601. var ret = "";
  9602. if (value) {
  9603. ret = "已删除";
  9604. } else {
  9605. ret = "正常";
  9606. }
  9607. return ret;
  9608. },
  9609. },
  9610. };
  9611. },
  9612. });
  9613. formlyConfigProvider.setType({
  9614. name: "ui-disinput",
  9615. extends: "input",
  9616. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9617. defaultOptions: function (options) {
  9618. return {
  9619. templateOptions: {},
  9620. };
  9621. },
  9622. });
  9623. //数字组件
  9624. formlyConfigProvider.setType({
  9625. name: "ui-number",
  9626. extends: "input",
  9627. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9628. defaultOptions: function (options) {
  9629. return {
  9630. templateOptions: {},
  9631. };
  9632. },
  9633. controller: ["$scope", function ($scope) {}],
  9634. });
  9635. //含有周的日期
  9636. formlyConfigProvider.setType({
  9637. name: "ui-datepickerweek",
  9638. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9639. extends: "input",
  9640. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9641. defaultOptions: {
  9642. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9643. templateOptions: {
  9644. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9645. },
  9646. },
  9647. controller: [
  9648. "$scope",
  9649. "$filter",
  9650. function ($scope, $filter) {
  9651. $scope.mindata = new Date(
  9652. $scope.options.templateOptions.transform($scope.model).getTime() +
  9653. 5 * 60 * 1000
  9654. );
  9655. if ($scope.model[$scope.options.key]) {
  9656. } else {
  9657. $scope.model[$scope.options.key] = $filter("date")(
  9658. new Date(new Date().getTime()),
  9659. $scope.options.templateOptions.datepickerPopup
  9660. );
  9661. }
  9662. $scope.options.initialValue = $scope.model[$scope.options.key];
  9663. $scope.endOpen = true;
  9664. $scope.datepicker = {};
  9665. $scope.datepicker.opened = false;
  9666. $scope.datepicker.open = function ($event) {
  9667. $scope.datepicker.opened = true;
  9668. };
  9669. },
  9670. ],
  9671. });
  9672. //lmm
  9673. //分配任务列表
  9674. formlyConfigProvider.setType({
  9675. name: "jry_taskDistributionList",
  9676. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9677. wrapper: ["bootstrapHasError"],
  9678. defaultOptions: function (options, $scope) {
  9679. return {
  9680. templateOptions: {},
  9681. };
  9682. },
  9683. controller: function (
  9684. $rootScope,
  9685. $scope,
  9686. api_user_data,
  9687. $modal,
  9688. api_doc_data,
  9689. i18nService,
  9690. SweetAlert,
  9691. api_wechatfile
  9692. ) {
  9693. // 获取状态
  9694. $scope.stateListData = {};
  9695. $scope.getStateData = function () {
  9696. //lyl
  9697. var data = {
  9698. key: "task_sub_state",
  9699. type: "list",
  9700. };
  9701. api_wechatfile.getDictionary(data).then(function (res) {
  9702. angular.forEach(res, function (v, i) {
  9703. $scope.stateListData[v.value] = v.id;
  9704. });
  9705. });
  9706. };
  9707. $scope.getStateData();
  9708. var loginUser = $rootScope.user;
  9709. $scope.langs = i18nService.getAllLangs();
  9710. $scope.lang = "zh-cn";
  9711. i18nService.setCurrentLang($scope.lang);
  9712. $scope.gridOptions = {};
  9713. $scope.gridOptions.data = "myData";
  9714. $scope.gridOptions.enableColumnResizing = true;
  9715. $scope.gridOptions.enableGridMenu = false;
  9716. $scope.gridOptions.enableRowSelection = true;
  9717. $scope.gridOptions.showGridFooter = true;
  9718. $scope.gridOptions.showColumnFooter = false;
  9719. $scope.gridOptions.fastWatch = true;
  9720. $scope.gridOptions.useExternalFiltering = true;
  9721. $scope.gridOptions.useExternalPagination = true;
  9722. $scope.gridOptions.paginationPageSizes = [10];
  9723. $scope.gridOptions.paginationPageSize = 10;
  9724. $scope.gridOptions.multiSelect = true;
  9725. $scope.gridOptions.rowIdentity = function (row) {
  9726. return row.id;
  9727. };
  9728. $scope.gridOptions.getRowIdentity = function (row) {
  9729. return row.id;
  9730. };
  9731. // console.log($scope.model);//lmmmm
  9732. $scope.gridOptions.columnDefs = [
  9733. {
  9734. name: "item",
  9735. displayName: "序号",
  9736. width: "10%",
  9737. cellTemplate:
  9738. "<div>" +
  9739. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9740. "</div>",
  9741. },
  9742. {
  9743. name: "taskDescribe",
  9744. displayName: "任务说明",
  9745. width: "25%",
  9746. enableFiltering: false,
  9747. cellTemplate:
  9748. "<div>" +
  9749. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9750. "</div>",
  9751. },
  9752. {
  9753. name: "assign.name",
  9754. displayName: "指派人",
  9755. width: "5%",
  9756. enableFiltering: false,
  9757. cellTemplate:
  9758. "<div>" +
  9759. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9760. "</div>",
  9761. },
  9762. {
  9763. name: "startTime",
  9764. displayName: "开始时间",
  9765. width: "13%",
  9766. enableFiltering: false,
  9767. cellTemplate:
  9768. "<div>" +
  9769. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9770. "</div>",
  9771. },
  9772. {
  9773. name: "endTime",
  9774. displayName: "结束时间",
  9775. width: "13%",
  9776. enableFiltering: false,
  9777. cellTemplate:
  9778. "<div>" +
  9779. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9780. "</div>",
  9781. },
  9782. {
  9783. name: "priority.name",
  9784. displayName: "优先级",
  9785. width: "5%",
  9786. enableFiltering: false,
  9787. cellTemplate:
  9788. "<div>" +
  9789. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9790. "</div>",
  9791. },
  9792. {
  9793. name: "state.name",
  9794. displayName: "状态",
  9795. width: "5%",
  9796. enableFiltering: false,
  9797. cellTemplate:
  9798. "<div>" +
  9799. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9800. "</div>",
  9801. },
  9802. {
  9803. name: "操作", //lmmm
  9804. cellTemplate:
  9805. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9806. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9807. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9808. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9809. '<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>' +
  9810. "</div></div>",
  9811. enableFiltering: false,
  9812. },
  9813. ];
  9814. // 查看
  9815. $scope.see = function (data) {
  9816. $scope.seeData = data;
  9817. var modalInstance = $modal.open({
  9818. backdrop: false,
  9819. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9820. controller: function (
  9821. $scope,
  9822. scope,
  9823. $modalInstance,
  9824. api_doc_data,
  9825. SweetAlert,
  9826. api_user_data,
  9827. api_wechatfile
  9828. ) {
  9829. $scope.personData = {}; //指派人
  9830. $scope.priorityData = {}; //优先级
  9831. $scope.personListData = {}; //指派人下拉数据
  9832. $scope.priorityListData = {}; //优先级下拉数据
  9833. $scope.startTime = ""; //开始时间
  9834. $scope.releaseShow = "no";
  9835. $scope.subShow = "no";
  9836. $scope.onlySee = "ok";
  9837. $scope.endTime = ""; //结束时间
  9838. $scope.taskDescribe = ""; //任务描述
  9839. $scope.taskDescribe = scope.seeData.taskDescribe;
  9840. $scope.personData.data = scope.seeData.assign;
  9841. $scope.priorityData.data = scope.seeData.priority;
  9842. $scope.startTime = scope.seeData.startTime;
  9843. $scope.endTime = scope.seeData.endTime;
  9844. $scope.done = scope.seeData.done;
  9845. $scope.feedback = scope.seeData.feedback;
  9846. $scope.cancel = function () {
  9847. $modalInstance.dismiss("cancel");
  9848. };
  9849. },
  9850. size: "sm",
  9851. resolve: {
  9852. scope: function () {
  9853. return $scope;
  9854. },
  9855. },
  9856. backdrop: true,
  9857. });
  9858. };
  9859. // 编辑
  9860. $scope.edit = function (data) {
  9861. $scope.editData = data;
  9862. var modalInstance = $modal.open({
  9863. backdrop: false,
  9864. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9865. controller: function (
  9866. $scope,
  9867. scope,
  9868. $modalInstance,
  9869. api_doc_data,
  9870. SweetAlert,
  9871. api_user_data,
  9872. api_wechatfile
  9873. ) {
  9874. console.log(scope.editData);
  9875. $scope.personData = {}; //指派人
  9876. $scope.priorityData = {}; //优先级
  9877. $scope.personListData = {}; //指派人下拉数据
  9878. $scope.priorityListData = {}; //优先级下拉数据
  9879. $scope.startTime = ""; //开始时间
  9880. $scope.releaseShow = "no";
  9881. $scope.endTime = ""; //结束时间
  9882. $scope.taskDescribe = ""; //任务描述
  9883. $scope.taskDescribe = scope.editData.taskDescribe;
  9884. $scope.personData.data = scope.editData.assign;
  9885. $scope.priorityData.data = scope.editData.priority;
  9886. $scope.startTime = scope.editData.startTime;
  9887. $scope.endTime = scope.editData.endTime;
  9888. // 指派人下拉框数据
  9889. $scope.getPersonData = function () {
  9890. var data = {
  9891. idx: 0,
  9892. sum: 1000,
  9893. };
  9894. api_user_data.fetchDataList("user", data).then(function (res) {
  9895. $scope.personListData = res.list;
  9896. });
  9897. };
  9898. $scope.getPersonData();
  9899. //优先级下拉数据
  9900. $scope.getPriorityData = function () {
  9901. var data = {
  9902. key: "change_rick_level",
  9903. type: "list",
  9904. };
  9905. api_wechatfile.getDictionary(data).then(function (res) {
  9906. $scope.priorityListData = res;
  9907. });
  9908. };
  9909. $scope.getPriorityData();
  9910. // 获取状态-lmm
  9911. $scope.stateListData = {};
  9912. $scope.getStateData = function () {
  9913. //lyl
  9914. var data = {
  9915. key: "task_sub_state",
  9916. type: "list",
  9917. };
  9918. api_wechatfile.getDictionary(data).then(function (res) {
  9919. angular.forEach(res, function (v, i) {
  9920. $scope.stateListData[v.value] = v.id;
  9921. });
  9922. });
  9923. };
  9924. $scope.getStateData();
  9925. //时间控件
  9926. $scope.open = function ($event) {
  9927. $event.preventDefault();
  9928. $event.stopPropagation();
  9929. $scope.opened = !$scope.opened;
  9930. };
  9931. $scope.endOpen = function ($event) {
  9932. $event.preventDefault();
  9933. $event.stopPropagation();
  9934. $scope.startOpened = false;
  9935. $scope.endOpened = !$scope.endOpened;
  9936. };
  9937. $scope.startOpen = function ($event) {
  9938. $event.preventDefault();
  9939. $event.stopPropagation();
  9940. $scope.endOpened = false;
  9941. $scope.startOpened = !$scope.startOpened;
  9942. };
  9943. // 确定
  9944. $scope.ok = function (item) {
  9945. if (
  9946. $scope.taskDescribe &&
  9947. $scope.personData.data &&
  9948. $scope.priorityData.data &&
  9949. $scope.startTime &&
  9950. $scope.endTime
  9951. ) {
  9952. $scope.startTime = moment(
  9953. new Date($scope.startTime).getTime()
  9954. ).format("YYYY-MM-DD HH:mm:ss");
  9955. $scope.endTime = moment(
  9956. new Date($scope.endTime).getTime()
  9957. ).format("YYYY-MM-DD HH:mm:ss");
  9958. $scope.addData = {
  9959. taskSub: {
  9960. taskDescribe: $scope.taskDescribe,
  9961. assign: $scope.personData.data,
  9962. priority: $scope.priorityData.data,
  9963. startTime: $scope.startTime,
  9964. endTime: $scope.endTime,
  9965. taskMonth: {
  9966. id: scope.model.taskMonth.id,
  9967. },
  9968. id: scope.editData.id,
  9969. },
  9970. };
  9971. $scope.addData.taskSub["state"] = {
  9972. id: $scope.stateListData[1],
  9973. };
  9974. api_user_data
  9975. .updData("taskSub", $scope.addData)
  9976. .then(function (res) {
  9977. if (res.status == 200) {
  9978. SweetAlert.swal({
  9979. title: "修改成功!",
  9980. type: "success",
  9981. confirmButtonColor: "#007AFF",
  9982. });
  9983. scope.refreshData(scope.jry_filterdata);
  9984. $modalInstance.dismiss("cancel");
  9985. } else {
  9986. SweetAlert.swal({
  9987. title: "修改失败",
  9988. text: "系统错误,请重试!",
  9989. type: "error",
  9990. });
  9991. $modalInstance.dismiss("cancel");
  9992. }
  9993. });
  9994. } else {
  9995. SweetAlert.swal({
  9996. title: "修改失败",
  9997. text: "必填项不能为空!",
  9998. type: "error",
  9999. });
  10000. }
  10001. };
  10002. $scope.cancel = function () {
  10003. $modalInstance.dismiss("cancel");
  10004. };
  10005. },
  10006. size: "sm",
  10007. resolve: {
  10008. scope: function () {
  10009. return $scope;
  10010. },
  10011. },
  10012. backdrop: true,
  10013. });
  10014. };
  10015. // 发布
  10016. $scope.release = function (data) {
  10017. SweetAlert.swal(
  10018. {
  10019. title: "确认发布?",
  10020. text: "请确定发布操作!",
  10021. type: "warning",
  10022. showCancelButton: true,
  10023. confirmButtonColor: "#DD6B55",
  10024. confirmButtonText: "确定",
  10025. cancelButtonText: "取消",
  10026. closeOnConfirm: false,
  10027. closeOnCancel: false,
  10028. },
  10029. function (isConfirm) {
  10030. if (isConfirm) {
  10031. data.state.id = $scope.stateListData[2];
  10032. delete data.item;
  10033. api_user_data
  10034. .updData("taskSub", {
  10035. taskSub: data,
  10036. })
  10037. .then(function (res) {
  10038. if (res.status == 200) {
  10039. SweetAlert.swal({
  10040. title: "发布成功!",
  10041. type: "success",
  10042. confirmButtonColor: "#007AFF",
  10043. });
  10044. $scope.refreshData($scope.jry_filterdata);
  10045. } else {
  10046. SweetAlert.swal({
  10047. title: "删除失败",
  10048. text: "系统错误,请重试!",
  10049. type: "error",
  10050. });
  10051. }
  10052. });
  10053. } else {
  10054. SweetAlert.swal("操作取消", "发布取消", "error");
  10055. }
  10056. }
  10057. );
  10058. };
  10059. // 删除
  10060. $scope.remove = function (data) {
  10061. SweetAlert.swal(
  10062. {
  10063. title: "确认删除?",
  10064. text: "删除的数据不可恢复,请确认继续操作!",
  10065. type: "warning",
  10066. showCancelButton: true,
  10067. confirmButtonColor: "#DD6B55",
  10068. confirmButtonText: "继续删除",
  10069. cancelButtonText: "取消操作",
  10070. closeOnConfirm: false,
  10071. closeOnCancel: false,
  10072. },
  10073. function (isConfirm) {
  10074. if (isConfirm) {
  10075. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10076. if (res.status == 200) {
  10077. SweetAlert.swal({
  10078. title: "删除成功!",
  10079. type: "success",
  10080. confirmButtonColor: "#007AFF",
  10081. });
  10082. $scope.refreshData($scope.jry_filterdata);
  10083. } else {
  10084. SweetAlert.swal({
  10085. title: "删除失败",
  10086. text: "系统错误,请重试!",
  10087. type: "error",
  10088. });
  10089. }
  10090. });
  10091. } else {
  10092. SweetAlert.swal("操作取消", "数据安全", "error");
  10093. }
  10094. }
  10095. );
  10096. };
  10097. $scope.refreshData = function (filterData) {
  10098. // $scope.ldloading[style.replace('-', '_')] = true;
  10099. if (angular.isUndefined(filterData)) {
  10100. filterData = defaultFilterData;
  10101. }
  10102. $scope.myData = [];
  10103. $scope.memoryfilterData = filterData;
  10104. api_doc_data.fetchDataList("taskSub", filterData).then(
  10105. function (data) {
  10106. var myData = data;
  10107. $scope.gridOptions.totalItems = myData.totalNum;
  10108. $scope.removeFileNum = myData.totalNum;
  10109. if (angular.isArray(myData.list)) {
  10110. $scope.myData = myData.list;
  10111. for (var i = 0; i < $scope.myData.length; i++) {
  10112. //添加序号
  10113. $scope.myData[i]["item"] =
  10114. i + 1 + filterData.idx * filterData.sum;
  10115. $scope.myData[i].startTime = moment(
  10116. $scope.myData[i].startTime
  10117. ).format("YYYY-MM-DD HH:mm:ss");
  10118. $scope.myData[i].endTime = moment(
  10119. $scope.myData[i].endTime
  10120. ).format("YYYY-MM-DD HH:mm:ss");
  10121. }
  10122. }
  10123. },
  10124. function () {
  10125. // $scope.ldloading[style.replace('-', '_')] = false;
  10126. }
  10127. );
  10128. };
  10129. //分页控制
  10130. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10131. gridApi.pagination.on.paginationChanged(
  10132. $scope,
  10133. function (newPage, pageSize) {
  10134. $scope.jry_filterdata.idx = newPage - 1;
  10135. $scope.fenye = newPage - 1;
  10136. $scope.jry_filterdata.sum = pageSize;
  10137. $scope.refreshData($scope.jry_filterdata);
  10138. }
  10139. );
  10140. };
  10141. $scope.fenye = 0;
  10142. if ($scope.model.label == "分配任务") {
  10143. $scope.jry_filterdata = {
  10144. idx: $scope.fenye,
  10145. sum: 10,
  10146. taskSub: {
  10147. taskMonth: {
  10148. id: $scope.model.taskMonth.id,
  10149. },
  10150. userid: loginUser.id,
  10151. role: loginUser.role,
  10152. },
  10153. };
  10154. } else {
  10155. $scope.jry_filterdata = {
  10156. idx: $scope.fenye,
  10157. sum: 10,
  10158. taskSub: {
  10159. taskMonth: {
  10160. id: $scope.model.taskMonth.id,
  10161. },
  10162. userid: loginUser.id,
  10163. role: loginUser.role,
  10164. type: 1,
  10165. },
  10166. };
  10167. }
  10168. $scope.refreshData($scope.jry_filterdata);
  10169. //新增模态框
  10170. $scope.newDistribution = function () {
  10171. var modalInstance = $modal.open({
  10172. backdrop: false,
  10173. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10174. controller: function (
  10175. $scope,
  10176. scope,
  10177. $modalInstance,
  10178. api_doc_data,
  10179. SweetAlert,
  10180. api_user_data,
  10181. api_wechatfile
  10182. ) {
  10183. $scope.personData = {}; //指派人
  10184. $scope.priorityData = {}; //优先级
  10185. $scope.personListData = {}; //指派人下拉数据
  10186. $scope.priorityListData = {}; //优先级下拉数据
  10187. $scope.startTime = ""; //开始时间
  10188. $scope.endTime = ""; //结束时间
  10189. $scope.taskDescribe = ""; //任务描述
  10190. $scope.motaikuang = "";
  10191. $scope.shijian = "哈哈";
  10192. // 指派人下拉框数据
  10193. $scope.getPersonData = function () {
  10194. var data = {
  10195. idx: 0,
  10196. sum: 1000,
  10197. };
  10198. api_user_data.fetchDataList("user", data).then(function (res) {
  10199. $scope.personListData = res.list;
  10200. });
  10201. };
  10202. $scope.getPersonData();
  10203. //优先级下拉数据
  10204. $scope.getPriorityData = function () {
  10205. var data = {
  10206. key: "change_rick_level",
  10207. type: "list",
  10208. };
  10209. api_wechatfile.getDictionary(data).then(function (res) {
  10210. $scope.priorityListData = res;
  10211. });
  10212. };
  10213. // 控制结束时间的最大时间
  10214. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10215. // 控制结束时间的最小时间
  10216. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10217. $scope.$watch("startTime", function (n, o) {
  10218. if (n) {
  10219. if (n > scope.model.taskMonth.startTime) {
  10220. $scope.jryEndMinTime = n;
  10221. }
  10222. }
  10223. });
  10224. // 控制开始时间的最小时间
  10225. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10226. // 控制开始时间的最大时间
  10227. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10228. $scope.$watch("endTime", function (n, o) {
  10229. if (n) {
  10230. if (n < scope.model.taskMonth.endTime) {
  10231. $scope.jryStartMaxTime = n;
  10232. }
  10233. }
  10234. });
  10235. $scope.getPriorityData();
  10236. //时间控件
  10237. $scope.open = function ($event) {
  10238. $event.preventDefault();
  10239. $event.stopPropagation();
  10240. $scope.opened = !$scope.opened;
  10241. };
  10242. $scope.endOpen = function ($event) {
  10243. $event.preventDefault();
  10244. $event.stopPropagation();
  10245. $scope.startOpened = false;
  10246. $scope.endOpened = !$scope.endOpened;
  10247. };
  10248. $scope.startOpen = function ($event) {
  10249. $event.preventDefault();
  10250. $event.stopPropagation();
  10251. $scope.endOpened = false;
  10252. $scope.startOpened = !$scope.startOpened;
  10253. };
  10254. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10255. // 获取状态-lmm
  10256. $scope.stateListData = {};
  10257. $scope.getStateData = function () {
  10258. //lyl
  10259. var data = {
  10260. key: "task_sub_state",
  10261. type: "list",
  10262. };
  10263. api_wechatfile.getDictionary(data).then(function (res) {
  10264. angular.forEach(res, function (v, i) {
  10265. $scope.stateListData[v.value] = v.id;
  10266. });
  10267. });
  10268. };
  10269. $scope.getStateData();
  10270. // 草稿保存
  10271. $scope.ok = function (item) {
  10272. if (
  10273. $scope.taskDescribe &&
  10274. $scope.personData.data &&
  10275. $scope.priorityData.data &&
  10276. $scope.startTime &&
  10277. $scope.endTime
  10278. ) {
  10279. $scope.startTime = moment(
  10280. new Date($scope.startTime).getTime()
  10281. ).format("YYYY-MM-DD HH:mm:ss");
  10282. $scope.endTime = moment(
  10283. new Date($scope.endTime).getTime()
  10284. ).format("YYYY-MM-DD HH:mm:ss");
  10285. $scope.addData = {
  10286. taskSub: {
  10287. taskDescribe: $scope.taskDescribe,
  10288. assign: $scope.personData.data,
  10289. priority: $scope.priorityData.data,
  10290. startTime: $scope.startTime,
  10291. endTime: $scope.endTime,
  10292. taskMonth: {
  10293. id: scope.model.taskMonth.id,
  10294. },
  10295. },
  10296. };
  10297. $scope.addData.taskSub["state"] = {
  10298. id: $scope.stateListData[1],
  10299. };
  10300. api_user_data
  10301. .addData("taskSub", $scope.addData)
  10302. .then(function (res) {
  10303. if (res.status == 200) {
  10304. SweetAlert.swal({
  10305. title: "保存成功!",
  10306. type: "success",
  10307. confirmButtonColor: "#007AFF",
  10308. });
  10309. scope.refreshData(scope.jry_filterdata);
  10310. $modalInstance.dismiss("cancel");
  10311. } else {
  10312. SweetAlert.swal({
  10313. title: "保存失败",
  10314. text: "系统错误,请重试!",
  10315. type: "error",
  10316. });
  10317. $modalInstance.dismiss("cancel");
  10318. }
  10319. });
  10320. } else {
  10321. SweetAlert.swal({
  10322. title: "保存失败",
  10323. text: "必填项不能为空!",
  10324. type: "error",
  10325. });
  10326. }
  10327. };
  10328. // 发布
  10329. $scope.release = function () {
  10330. if (
  10331. $scope.taskDescribe &&
  10332. $scope.personData.data &&
  10333. $scope.priorityData.data &&
  10334. $scope.startTime &&
  10335. $scope.endTime
  10336. ) {
  10337. $scope.startTime = moment(
  10338. new Date($scope.startTime).getTime()
  10339. ).format("YYYY-MM-DD HH:mm:ss");
  10340. $scope.endTime = moment(
  10341. new Date($scope.endTime).getTime()
  10342. ).format("YYYY-MM-DD HH:mm:ss");
  10343. $scope.addData = {
  10344. taskSub: {
  10345. taskDescribe: $scope.taskDescribe,
  10346. assign: $scope.personData.data,
  10347. priority: $scope.priorityData.data,
  10348. startTime: $scope.startTime,
  10349. endTime: $scope.endTime,
  10350. taskMonth: {
  10351. id: scope.model.taskMonth.id,
  10352. },
  10353. },
  10354. };
  10355. $scope.addData.taskSub["state"] = {
  10356. id: $scope.stateListData[1],
  10357. };
  10358. api_user_data
  10359. .addData("taskSub", $scope.addData)
  10360. .then(function (res) {
  10361. if (res.status == 200) {
  10362. SweetAlert.swal({
  10363. title: "保存成功!",
  10364. type: "success",
  10365. confirmButtonColor: "#007AFF",
  10366. });
  10367. scope.refreshData(scope.jry_filterdata);
  10368. $modalInstance.dismiss("cancel");
  10369. } else {
  10370. SweetAlert.swal({
  10371. title: "保存失败",
  10372. text: "系统错误,请重试!",
  10373. type: "error",
  10374. });
  10375. $modalInstance.dismiss("cancel");
  10376. }
  10377. });
  10378. } else {
  10379. SweetAlert.swal({
  10380. title: "保存失败",
  10381. text: "必填项不能为空!",
  10382. type: "error",
  10383. });
  10384. }
  10385. };
  10386. $scope.cancel = function () {
  10387. $modalInstance.dismiss("cancel");
  10388. };
  10389. },
  10390. size: "sm",
  10391. resolve: {
  10392. scope: function () {
  10393. return $scope;
  10394. },
  10395. },
  10396. backdrop: true,
  10397. });
  10398. };
  10399. },
  10400. });
  10401. // 多次反馈文本域组件--jry
  10402. formlyConfigProvider.setType({
  10403. name: "ui-feedbacktTextarea",
  10404. extends: "textarea",
  10405. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10406. defaultOptions: function (options) {
  10407. return {
  10408. templateOptions: {
  10409. transform: function (model, value) {
  10410. return value;
  10411. },
  10412. },
  10413. validation: {
  10414. messages: {
  10415. maxlength: function (viewValue, modelValue, scope) {
  10416. if (viewValue != null) {
  10417. if (viewValue.length > scope.to.maxlength) {
  10418. return (
  10419. scope.to.label +
  10420. " 字数(" +
  10421. viewValue.length +
  10422. ")超限(" +
  10423. scope.to.maxlength +
  10424. ")"
  10425. );
  10426. } else {
  10427. return "";
  10428. }
  10429. }
  10430. },
  10431. },
  10432. },
  10433. };
  10434. },
  10435. controller: [
  10436. "$scope",
  10437. "moment",
  10438. function ($scope, moment) {
  10439. // console.log($scope);
  10440. var timeKey = $scope.options.templateOptions.time;
  10441. $scope.time = moment($scope.model[timeKey]).format(
  10442. "YYYY-MM-DD HH:mm:ss"
  10443. );
  10444. var value = $scope.model[$scope.options.key];
  10445. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10446. $scope.model[$scope.options.key] =
  10447. $scope.options.templateOptions.transform(
  10448. $scope.originalModel,
  10449. value
  10450. );
  10451. }
  10452. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10453. $scope.options.templateOptions.felditem($scope);
  10454. }
  10455. },
  10456. ],
  10457. });
  10458. //任务管理开始时间--jry
  10459. formlyConfigProvider.setType({
  10460. name: "ui-jryStartdatepicker",
  10461. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10462. extends: "input",
  10463. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10464. defaultOptions: {
  10465. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10466. templateOptions: {
  10467. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10468. },
  10469. },
  10470. controller: [
  10471. "$scope",
  10472. "$filter",
  10473. function ($scope, $filter) {
  10474. // console.log($scope.model[$scope.options.key],'lmm');
  10475. $scope.mindata = new Date(
  10476. $scope.options.templateOptions.transform($scope.model).getTime() +
  10477. 5 * 60 * 1000
  10478. );
  10479. if ($scope.model[$scope.options.key]) {
  10480. $scope.model[$scope.options.key] = $filter("date")(
  10481. $scope.model[$scope.options.key],
  10482. $scope.options.templateOptions.datepickerPopup
  10483. );
  10484. }
  10485. // console.log($scope.model[$scope.options.key],'lmm');
  10486. // console.log($scope.model,'lmm',$scope.options.key);
  10487. $scope.options.initialValue = $scope.model[$scope.options.key];
  10488. $scope.endOpen = true;
  10489. $scope.datepicker = {};
  10490. $scope.datepicker.opened = false;
  10491. $scope.datepicker.open = function ($event) {
  10492. $scope.datepicker.opened = true;
  10493. };
  10494. },
  10495. ],
  10496. });
  10497. //任务管理结束时间--jry
  10498. formlyConfigProvider.setType({
  10499. name: "ui-jryEnddatepicker",
  10500. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10501. extends: "input",
  10502. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10503. defaultOptions: {
  10504. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10505. templateOptions: {
  10506. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10507. },
  10508. },
  10509. controller: [
  10510. "$scope",
  10511. "$filter",
  10512. function ($scope, $filter) {
  10513. $scope.mindata = new Date(
  10514. $scope.options.templateOptions.transform($scope.model).getTime() +
  10515. 5 * 60 * 1000
  10516. );
  10517. if ($scope.model[$scope.options.key]) {
  10518. $scope.model[$scope.options.key] = $filter("date")(
  10519. $scope.model[$scope.options.key],
  10520. $scope.options.templateOptions.datepickerPopup
  10521. );
  10522. }
  10523. $scope.options.initialValue = $scope.model[$scope.options.key];
  10524. $scope.endOpen = true;
  10525. $scope.datepicker = {};
  10526. $scope.datepicker.opened = false;
  10527. $scope.datepicker.open = function ($event) {
  10528. $scope.datepicker.opened = true;
  10529. };
  10530. },
  10531. ],
  10532. });
  10533. //下拉多选框灵活组件--jry
  10534. formlyConfigProvider.setType({
  10535. name: "ui-jry_multiselectplus",
  10536. extends: "multiCheckbox",
  10537. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10538. defaultOptions: function (options) {
  10539. return {
  10540. templateOptions: {
  10541. refreshData: function (search, options, model, that) {
  10542. // var process = options.templateOptions.ApiService.all("");
  10543. if (search) {
  10544. } else {
  10545. }
  10546. var postData = options.templateOptions.optionsPostData;
  10547. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10548. postData = options.templateOptions.optionsPostData(
  10549. options,
  10550. model,
  10551. that
  10552. );
  10553. }
  10554. options.templateOptions.ApiService.fetchDataList(
  10555. options.templateOptions.optionsUrl,
  10556. options.templateOptions.optionsPostData
  10557. ).then(function (result) {
  10558. // if (!options.templateOptions.options) {
  10559. // options.templateOptions.options = [];
  10560. // }
  10561. if (options.templateOptions.optionsDataKey) {
  10562. options.templateOptions.options =
  10563. result[options.templateOptions.optionsDataKey];
  10564. } else {
  10565. options.templateOptions.options = result;
  10566. }
  10567. if (options.templateOptions.optionsChecked) {
  10568. // return options.value = null;
  10569. options.value(options.model[options.key]);
  10570. }
  10571. });
  10572. },
  10573. refreshDelay: 0,
  10574. // },
  10575. validators: {
  10576. required: {
  10577. expression: function (viewValue, modelValue) {
  10578. var value = modelValue || viewValue;
  10579. return value != null;
  10580. // return value.length>=1;
  10581. // if (modelValue && viewValue) {
  10582. // return value != null;
  10583. // } else {
  10584. // var value = modelValue || viewValue;
  10585. // return value.length > 0;
  10586. // }
  10587. },
  10588. },
  10589. },
  10590. },
  10591. };
  10592. },
  10593. controller: [
  10594. "$scope",
  10595. function ($scope) {
  10596. console.log($scope.to);
  10597. if (angular.isArray($scope.model[$scope.options.key])) {
  10598. } else {
  10599. $scope.model[$scope.options.key] = [];
  10600. }
  10601. },
  10602. ],
  10603. });
  10604. //下拉框组件
  10605. formlyConfigProvider.setType({
  10606. name: "ui-select",
  10607. extends: "select",
  10608. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10609. defaultOptions: function (options, scope) {
  10610. return {
  10611. templateOptions: {
  10612. // refresh: function() {},
  10613. getScope: function () {
  10614. return scope;
  10615. },
  10616. refreshDelay: 0,
  10617. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10618. //POST
  10619. console.log(model, "model");
  10620. angular.extend(data, {
  10621. idx: 0,
  10622. sum: 1000,
  10623. });
  10624. options.templateOptions.APIService.fetchDataList(
  10625. modelName,
  10626. data
  10627. ).then(function (response) {
  10628. var myData =
  10629. options.templateOptions.Restangular.stripRestangular(response);
  10630. var list = myData.list;
  10631. console.log(myData);
  10632. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10633. // console.log('balabalabala');
  10634. // console.log(res);
  10635. // })
  10636. if (list.length == 1) {
  10637. if (options.templateOptions.APIport) {
  10638. options.templateOptions.APIport.expectedTime(
  10639. "L" + list[0][key].id
  10640. ).then(function (response) {
  10641. if (response.state == "200") {
  10642. // if (model.$parent.model && model.$parent.model.incident) {
  10643. // } else {
  10644. // model.$parent.model = { 'incident': {} };
  10645. // }
  10646. var myDatas = response.serviceLevelAgreement;
  10647. //逾期
  10648. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10649. response.date;
  10650. //解决
  10651. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10652. myDatas.resolveTime;
  10653. //响应
  10654. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10655. myDatas.responseTime;
  10656. } else {
  10657. }
  10658. });
  10659. }
  10660. angular.forEach(model.fields, function (item) {
  10661. angular.forEach(model.fields, function (item) {
  10662. if (item.templateOptions.pkey == modelKey + "." + key) {
  10663. item.model.id = "";
  10664. if (key == "place") {
  10665. item.templateOptions.options = list;
  10666. } else if (key == "placeDTO") {
  10667. item.templateOptions.options = list;
  10668. } else if (key == "requester") {
  10669. } else {
  10670. item.value(list[0][key][item.key]);
  10671. }
  10672. }
  10673. });
  10674. });
  10675. } else {
  10676. if (model.fields) {
  10677. angular.forEach(model.fields, function (item) {
  10678. angular.forEach(model.fields, function (item) {
  10679. if (item.templateOptions.pkey == modelKey + "." + key) {
  10680. item.model.id = "";
  10681. if (key == "place") {
  10682. item.templateOptions.isnosearch = true;
  10683. item.templateOptions.options = list;
  10684. }
  10685. if (key == "placeDTO") {
  10686. item.templateOptions.options = list;
  10687. }
  10688. if (key == "requester") {
  10689. }
  10690. }
  10691. });
  10692. });
  10693. } else {
  10694. angular.forEach(
  10695. scope.$parent.$parent.$parent.fields,
  10696. function (item) {
  10697. angular.forEach(
  10698. scope.$parent.$parent.$parent.fields,
  10699. function (item) {
  10700. if (
  10701. item.templateOptions.pkey ==
  10702. modelKey + "." + key
  10703. ) {
  10704. if (key == "place") {
  10705. item.templateOptions.isnosearch = true;
  10706. item.templateOptions.options = list;
  10707. scope.$parent.$parent.$parent.model.incident.place =
  10708. model.incident.place;
  10709. }
  10710. if (key == "placeDTO") {
  10711. item.templateOptions.options = list;
  10712. }
  10713. if (key == "requester") {
  10714. }
  10715. }
  10716. }
  10717. );
  10718. }
  10719. );
  10720. }
  10721. }
  10722. console.log(key);
  10723. //报修科室
  10724. if (key == "dept") {
  10725. // 报修科室单选
  10726. scope.$parent.$parent.$parent.model.incident.department =
  10727. response.list[0];
  10728. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10729. response.list[0].phone;
  10730. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10731. // 选择重复事件侧滑框
  10732. scope.$parent.$parent.$parent.model[
  10733. "repeatIncidentShow"
  10734. ] = false;
  10735. setTimeout(() => {
  10736. scope.$parent.$parent.$parent.model[
  10737. "repeatIncidentShow"
  10738. ] = true;
  10739. }, 500);
  10740. }
  10741. // 报修人
  10742. if (key == "requester") {
  10743. // 报修人单选
  10744. scope.$parent.$parent.$parent.model.incident.requester =
  10745. response.list[0];
  10746. console.log(scope.$parent.$parent.$parent.model);
  10747. scope.$parent.$parent.$parent.model.incident.account =
  10748. response.list[0].account;
  10749. var selectedItem = response.list[0];
  10750. var data = {
  10751. requester: selectedItem,
  10752. };
  10753. scope.$parent.$parent.$parent.model["requestershow"] =
  10754. selectedItem;
  10755. console.log(selectedItem, "----------------------");
  10756. // if (selectedItem.dept.place.place) {
  10757. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10758. // }
  10759. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10760. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10761. scope.$parent.$parent.$parent.model.incident.area.id =
  10762. selectedItem.place ? selectedItem.place.area.id : null;
  10763. scope.$parent.$parent.$parent.model.incident.place.id =
  10764. selectedItem.place ? selectedItem.place.id : null;
  10765. console.log(scope, 89898998);
  10766. // console.log(scope.formData,'接单页面');
  10767. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10768. scope.model.selecthouseNumber = selectedItem.place
  10769. ? selectedItem.place
  10770. : {};
  10771. scope.$root.selecthouseNumber = selectedItem.place
  10772. ? selectedItem.place
  10773. : {};
  10774. options.templateOptions.ApiService.addData(
  10775. "requester",
  10776. data
  10777. ).then(function (response) {
  10778. if (response.status == 200) {
  10779. if (scope.$parent.$parent.$parent) {
  10780. if (scope.$parent.$parent.$parent.place) {
  10781. scope.$parent.$parent.$parent.place.id = "";
  10782. }
  10783. if (scope.$parent.$parent.$parent.area) {
  10784. scope.$parent.$parent.$parent.area.id = "";
  10785. }
  10786. scope.$parent.$parent.$parent.model.incident.contacts =
  10787. selectedItem.name;
  10788. if (
  10789. selectedItem.mphone &&
  10790. selectedItem.mphone != null &&
  10791. selectedItem.mphone != ""
  10792. ) {
  10793. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10794. selectedItem.mphone;
  10795. } else {
  10796. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10797. selectedItem.telephone;
  10798. }
  10799. if (
  10800. selectedItem.requesterTypeDTO &&
  10801. selectedItem.requesterTypeDTO.id == 2
  10802. ) {
  10803. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10804. }
  10805. }
  10806. if (!response.data.id) {
  10807. response.data.id = selectedItem.id;
  10808. }
  10809. console.log(scope);
  10810. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10811. // if (selectedItem.place && selectedItem.place.id) {
  10812. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10813. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10814. // };
  10815. // } else {
  10816. // if (selectedItem.place && selectedItem.place.id) {
  10817. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10818. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10819. // };
  10820. // }
  10821. // if(scope.$parent.$parent.$parent.model.incident.area){
  10822. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10823. // }
  10824. if (selectedItem.id) {
  10825. scope.$parent.$parent.$parent.model.incident.account =
  10826. selectedItem.account;
  10827. }
  10828. // 选择重复事件侧滑框
  10829. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10830. scope.$parent.$parent.$parent.model[
  10831. "repeatIncidentShow"
  10832. ] = false;
  10833. setTimeout(() => {
  10834. scope.$parent.$parent.$parent.model[
  10835. "repeatIncidentShow"
  10836. ] = true;
  10837. }, 500);
  10838. // }
  10839. }
  10840. });
  10841. }
  10842. //新建事件,选择派单,选择工作组查找处理人baba
  10843. if (key == "handlerUser") {
  10844. model.fields.forEach(function (v) {
  10845. if (v.templateOptions.pkey == "incident.handlerUser") {
  10846. v.templateOptions.options = list;
  10847. if (model.model.incident.handlerUser) {
  10848. if (model.model.incident.handlerUser.id) {
  10849. var flag = list.some(function (v) {
  10850. return v.id == model.model.incident.handlerUser.id;
  10851. });
  10852. if (flag) {
  10853. v.model.id = model.model.incident.handlerUser.id;
  10854. }
  10855. }
  10856. }
  10857. }
  10858. });
  10859. }
  10860. });
  10861. },
  10862. validators: {
  10863. required: {
  10864. expression: function (viewValue, modelValue) {
  10865. var value = modelValue || viewValue;
  10866. return value != null;
  10867. // return value.length>=1;
  10868. // if (modelValue && viewValue) {
  10869. // return value != null;
  10870. // } else {
  10871. // var value = modelValue || viewValue;
  10872. // return value.length > 0;
  10873. // }
  10874. },
  10875. },
  10876. },
  10877. },
  10878. controller: [
  10879. "$scope",
  10880. "$rootScope",
  10881. "api_bpm_domain",
  10882. function ($scope, $rootScope, api_bpm_domain) {
  10883. // $scope.myFilter = function(item) {
  10884. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10885. // }
  10886. console.log($scope, "风浪");
  10887. //工作组添加全部选项
  10888. // if($scope.options.templateOptions.label == '工作组'){
  10889. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10890. // $scope.model._group = 0;
  10891. // }
  10892. if (
  10893. $scope.options.templateOptions.pkey &&
  10894. $scope.options.templateOptions.pkey == "incident.place"
  10895. ) {
  10896. if (
  10897. $scope.$parent &&
  10898. $scope.$parent.$parent.$parent.model &&
  10899. $scope.$parent.$parent.$parent.model.incident.area &&
  10900. $scope.$parent.$parent.$parent.model.incident.area.id
  10901. ) {
  10902. $scope.options.templateOptions.linkage(
  10903. "place",
  10904. {
  10905. place: {
  10906. areaId:
  10907. $scope.$parent.$parent.$parent.model.incident.area.id,
  10908. // area:{
  10909. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  10910. // }
  10911. },
  10912. },
  10913. $scope.$parent.$parent.$parent.model,
  10914. "incident",
  10915. "place"
  10916. );
  10917. }
  10918. }
  10919. $scope.myFilter = $scope;
  10920. // console.log($scope.options.templateOptions)
  10921. console.log($scope, 77777);
  10922. //处理人根据事件分类自动带入baba
  10923. if ($scope.options.templateOptions.pkey == "incident.handlerUser") {
  10924. console.log($scope.options.templateOptions.pkey);
  10925. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  10926. if (
  10927. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  10928. ) {
  10929. $scope.options.model.id =
  10930. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10931. }
  10932. }
  10933. }
  10934. // 关闭事件页面满意度评价下拉框处理
  10935. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  10936. $scope.model.id =
  10937. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  10938. }
  10939. if ($scope.options.templateOptions.initData == 1) {
  10940. $scope.options.templateOptions.onChange(
  10941. $scope.model.id,
  10942. $scope.options,
  10943. $scope
  10944. );
  10945. }
  10946. if ($scope.options.templateOptions.transform) {
  10947. $scope.options.templateOptions.onChange(
  10948. $scope.model.id,
  10949. $scope.options,
  10950. $scope
  10951. );
  10952. }
  10953. if (angular.isFunction($scope.options.templateOptions.translate)) {
  10954. $scope.model[$scope.options.key] =
  10955. $scope.options.templateOptions.translate(
  10956. $scope.options,
  10957. $rootScope,
  10958. $scope
  10959. );
  10960. }
  10961. if (
  10962. angular.isFunction($scope.options.templateOptions.translatefunc)
  10963. ) {
  10964. $scope.model[$scope.options.key] =
  10965. $scope.options.templateOptions.translatefunc(
  10966. $scope.options,
  10967. $rootScope,
  10968. $scope
  10969. );
  10970. }
  10971. if (
  10972. angular.isFunction($scope.options.templateOptions.onlyfunction)
  10973. ) {
  10974. $scope.options.templateOptions.onlyfunction(
  10975. $scope.options,
  10976. $rootScope,
  10977. $scope
  10978. );
  10979. }
  10980. },
  10981. ],
  10982. };
  10983. },
  10984. });
  10985. //下拉多选框组件
  10986. formlyConfigProvider.setType({
  10987. name: "ui-multiselect",
  10988. extends: "select",
  10989. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  10990. defaultOptions: function (options) {
  10991. return {
  10992. templateOptions: {
  10993. refresh: function () {},
  10994. refreshDelay: 1000,
  10995. },
  10996. };
  10997. },
  10998. controller: [
  10999. "$scope",
  11000. function ($scope) {
  11001. $scope.model[$scope.options.key] = [];
  11002. },
  11003. ],
  11004. });
  11005. //下拉多选框灵活组件
  11006. formlyConfigProvider.setType({
  11007. name: "ui-multiselectplus",
  11008. extends: "multiCheckbox",
  11009. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11010. defaultOptions: function (options, $scope) {
  11011. return {
  11012. templateOptions: {
  11013. refreshData: function (search, options, model, that) {
  11014. var process = options.templateOptions.ApiService.all("");
  11015. if (search) {
  11016. } else {
  11017. }
  11018. var postData = options.templateOptions.optionsPostData;
  11019. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11020. postData = options.templateOptions.optionsPostData(
  11021. options,
  11022. model,
  11023. that
  11024. );
  11025. }
  11026. if (options.templateOptions.modelreasondata) {
  11027. postData = options.templateOptions.modelreasondata;
  11028. }
  11029. process
  11030. .customPOST(postData, options.templateOptions.optionsUrl)
  11031. .then(function (result) {
  11032. // if (!options.templateOptions.options) {
  11033. // options.templateOptions.options = [];
  11034. // }
  11035. // 过滤下拉列表已选择的值
  11036. var modelVal = $scope.model[$scope.options.key];
  11037. for (var i = 0; i < modelVal.length; i++) {
  11038. for (var j = 0; j < result.list.length; j++) {
  11039. if (result.list[j].id == modelVal[i].id) {
  11040. result.list.splice(j, 1);
  11041. }
  11042. }
  11043. }
  11044. if (options.templateOptions.optionsDataKey) {
  11045. options.templateOptions.options =
  11046. result[options.templateOptions.optionsDataKey];
  11047. } else {
  11048. options.templateOptions.options = result;
  11049. }
  11050. if (options.templateOptions.optionsChecked) {
  11051. // return options.value = null;
  11052. options.value(options.model[options.key]);
  11053. }
  11054. });
  11055. },
  11056. refreshDelay: 0,
  11057. // },
  11058. // validators: {
  11059. // required: {
  11060. // expression: function(viewValue, modelValue) {
  11061. // var value = modelValue || viewValue;
  11062. // // return value.length>=1;
  11063. // // if (modelValue && viewValue) {
  11064. // // return value != null;
  11065. // // } else {
  11066. // // var value = modelValue || viewValue;
  11067. // // return value.length > 0;
  11068. // // }
  11069. // }
  11070. // }
  11071. },
  11072. };
  11073. },
  11074. controller: [
  11075. "$scope",
  11076. function ($scope) {
  11077. if (angular.isArray($scope.model[$scope.options.key])) {
  11078. } else {
  11079. $scope.model[$scope.options.key] = [];
  11080. }
  11081. },
  11082. ],
  11083. });
  11084. //下拉树形多选组件
  11085. formlyConfigProvider.setType({
  11086. name: "ui-multiselect-tree",
  11087. extends: "multiCheckbox",
  11088. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11089. defaultOptions: function (options) {
  11090. return {
  11091. templateOptions: {
  11092. linkage: function (modelName, data, model, modelKey, key) {
  11093. angular.extend(data, {
  11094. idx: 0,
  11095. sum: 10,
  11096. });
  11097. options.templateOptions.APIService.fetchDataList(
  11098. modelName,
  11099. data
  11100. ).then(function (response) {
  11101. var myData =
  11102. options.templateOptions.Restangular.stripRestangular(response);
  11103. var list = myData.list;
  11104. if (list.length == 1) {
  11105. angular.forEach(model.fields, function (item) {
  11106. angular.forEach(model.fields, function (item) {
  11107. if (item.templateOptions.pkey == modelKey + "." + key) {
  11108. item.model.id = "";
  11109. if (key == "place") {
  11110. item.templateOptions.options = list;
  11111. } else {
  11112. item.value(list[0][key][item.key]);
  11113. }
  11114. }
  11115. });
  11116. });
  11117. }
  11118. });
  11119. },
  11120. // my_tree_handler : function(items) {
  11121. // },
  11122. // onFilterCallback : function(items) {
  11123. // },
  11124. // onFilterCallback : function(items) {
  11125. // },
  11126. refresh: function (items) {
  11127. var treedata = [];
  11128. function convertListToTree(data, treeMap) {
  11129. treedata = data;
  11130. for (var i = 0; i < data.length; i++) {
  11131. for (var j = 0; j < data.length; j++) {
  11132. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11133. if (data[i].pid == data[j].id) {
  11134. data[i].parent = data[j];
  11135. }
  11136. }
  11137. }
  11138. }
  11139. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11140. var root = null; //Initially set our loop to null
  11141. //loop over data
  11142. for (var i = 0; i < data.length; i++) {
  11143. var datum = data[i];
  11144. //each node will have children, so let's give it a "children" poperty
  11145. datum.children = [];
  11146. //add an entry for this node to the map so that any future children can
  11147. //lookup the parent
  11148. idToNodeMap[datum.id] = datum;
  11149. //Does this node have a parent?
  11150. if (
  11151. typeof datum.parent === "undefined" ||
  11152. datum.parent === null
  11153. ) {
  11154. //Doesn't look like it, so this node is the root of the tree
  11155. root = datum;
  11156. treeMap[datum.id] = root;
  11157. } else {
  11158. //This node has a parent, so let's look it up using the id
  11159. parentNode = idToNodeMap[datum.parent.id];
  11160. //We don't need this property, so let's delete it.
  11161. delete datum.parent;
  11162. //Let's add the current node as a child of the parent node.
  11163. parentNode.children.push(datum);
  11164. }
  11165. }
  11166. return root;
  11167. }
  11168. function convertParentToChildList(data) {
  11169. // console.log("data="+JSON.stringify(data))
  11170. var treeMap = {};
  11171. var list = [];
  11172. convertListToTree(data, treeMap);
  11173. angular.forEach(treeMap, function (item) {
  11174. list.push(item);
  11175. });
  11176. return list;
  11177. }
  11178. function selectItem(pmodel, childrens) {
  11179. if (angular.isArray(pmodel)) {
  11180. angular.forEach(pmodel, function (index) {
  11181. if (index && index.id) {
  11182. angular.forEach(childrens, function (item) {
  11183. if (item.id == index.id) {
  11184. item.selected = true;
  11185. }
  11186. if (item && item.children) {
  11187. selectItem(pmodel, item.children);
  11188. }
  11189. });
  11190. }
  11191. });
  11192. } else {
  11193. if (pmodel && pmodel.id) {
  11194. angular.forEach(childrens, function (item) {
  11195. if (item.id == pmodel.id) {
  11196. item.selected = true;
  11197. }
  11198. if (item && item.children) {
  11199. selectItem(pmodel, item.children);
  11200. }
  11201. });
  11202. }
  11203. }
  11204. }
  11205. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11206. options.templateOptions
  11207. .refreshData(options.templateOptions.APIService)
  11208. .then(function (result) {
  11209. if (result.status == 200) {
  11210. if (!options.templateOptions.options) {
  11211. options.templateOptions.options = [];
  11212. }
  11213. if (options.templateOptions.optionsDataKey) {
  11214. options.templateOptions.options = convertParentToChildList(
  11215. result[options.templateOptions.optionsDataKey]
  11216. );
  11217. } else {
  11218. options.templateOptions.options =
  11219. convertParentToChildList(result);
  11220. }
  11221. //set default value
  11222. var pmodel,
  11223. i = 0;
  11224. if (options.templateOptions.pkey) {
  11225. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11226. angular.forEach(
  11227. options.templateOptions.pkey.split("."),
  11228. function (p) {
  11229. if (i == 0) {
  11230. if (options.model[p] == null) {
  11231. options.model[p] = {};
  11232. }
  11233. pmodel = options.model[p];
  11234. i++;
  11235. } else {
  11236. if (pmodel[p] == null) {
  11237. pmodel[p] = {};
  11238. }
  11239. pmodel = pmodel[p];
  11240. }
  11241. }
  11242. );
  11243. } else {
  11244. pmodel = options.model;
  11245. }
  11246. }
  11247. if (pmodel) {
  11248. pmodel = pmodel[options.key];
  11249. } else if (options.model) {
  11250. pmodel = options.model[options.key];
  11251. } else {
  11252. pmodel = options.templateOptions.options;
  11253. }
  11254. if (angular.isArray(pmodel)) {
  11255. if (pmodel) {
  11256. // if(options.templateOptions.isMultiSelect==true){
  11257. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11258. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11259. // })
  11260. // }else{
  11261. selectItem(pmodel, options.templateOptions.options);
  11262. // }
  11263. }
  11264. } else {
  11265. if (pmodel && pmodel.id) {
  11266. selectItem(pmodel, options.templateOptions.options);
  11267. }
  11268. }
  11269. items.inputModel = options.templateOptions.options;
  11270. }
  11271. });
  11272. },
  11273. },
  11274. validators: {
  11275. required: {
  11276. expression: function (viewValue, modelValue) {
  11277. var value = modelValue || viewValue;
  11278. if (angular.isArray(value)) {
  11279. for (var i = 0; i < value.length; i++) {
  11280. value[i] = {
  11281. id: value[i].id,
  11282. };
  11283. }
  11284. return value.length > 0;
  11285. } else {
  11286. // console.log(options)
  11287. // return value = "true";
  11288. return value != null;
  11289. }
  11290. },
  11291. },
  11292. },
  11293. };
  11294. },
  11295. controller: [
  11296. "$scope",
  11297. "api_configure_form",
  11298. function ($scope, api_configure_form) {
  11299. if ($scope.options.templateOptions.isMultiSelect) {
  11300. // console.log($scope);
  11301. } else {
  11302. if ($scope.model[$scope.options.key]) {
  11303. }
  11304. }
  11305. },
  11306. ],
  11307. });
  11308. //多选下拉框组件
  11309. formlyConfigProvider.setType({
  11310. name: "ui-multi-select-tree",
  11311. extends: "input",
  11312. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11313. defaultOptions: function (options) {
  11314. return {
  11315. templateOptions: {
  11316. linkage: function (modelName, data, model, modelKey, key) {
  11317. angular.extend(data, {
  11318. idx: 0,
  11319. sum: 10,
  11320. });
  11321. options.templateOptions.APIService.fetchDataList(
  11322. modelName,
  11323. data
  11324. ).then(function (response) {
  11325. var myData =
  11326. options.templateOptions.Restangular.stripRestangular(response);
  11327. var list = myData.list;
  11328. if (list.length == 1) {
  11329. angular.forEach(model.fields, function (item) {
  11330. angular.forEach(model.fields, function (item) {
  11331. if (item.templateOptions.pkey == modelKey + "." + key) {
  11332. item.model.id = "";
  11333. if (key == "place") {
  11334. item.templateOptions.options = list;
  11335. } else {
  11336. item.value(list[0][key][item.key]);
  11337. }
  11338. }
  11339. });
  11340. });
  11341. }
  11342. });
  11343. },
  11344. getparentdata: function (items) {
  11345. // console.log(items)
  11346. },
  11347. refresh: function (items, search, fn) {
  11348. console.log(items);
  11349. var treedata = [];
  11350. function convertListToTree(data, treeMap) {
  11351. // console.log(data)
  11352. treedata = data;
  11353. for (var i = 0; i < data.length; i++) {
  11354. for (var j = 0; j < data.length; j++) {
  11355. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11356. if (data[i].pid == data[j].id) {
  11357. data[i].parent = data[j];
  11358. }
  11359. }
  11360. // if (data[i].id) {
  11361. // if (data[i].id== data[j].id) {
  11362. // data[i].parent = data[j];
  11363. // }
  11364. // }
  11365. }
  11366. }
  11367. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11368. var root = []; //Initially set our loop to null
  11369. if (search == "search" && items.filterKeyword) {
  11370. function transform(nodes) {
  11371. var treeConverter = {
  11372. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11373. attributeName: "id", //节点唯一标识符
  11374. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11375. transform: function (node) {
  11376. //转化递归函数,参数:一个待插入节点
  11377. if (node.parent != null) {
  11378. //该节点有父节点
  11379. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11380. if (this.needFind) {
  11381. for (var i = 0; i < newNode.children.length; i++) {
  11382. //查找要插入的node子节点是否在newNode这个父节点中存在
  11383. if (
  11384. newNode.children[i][this.attributeName] ===
  11385. node[this.attributeName]
  11386. ) {
  11387. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11388. }
  11389. }
  11390. }
  11391. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11392. // delete node.parent; //删除该节点的parent属性,如果有的话
  11393. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11394. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11395. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11396. } else if (node.parent == null) {
  11397. //该叶节点没有父节点,即为根节点
  11398. // delete node.parent; //删除该节点的parent属性,如果有的话
  11399. if (this.result == null) {
  11400. //根节点不存在
  11401. node.children = []; //给该节点增加children:[]属性
  11402. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11403. } else {
  11404. node.children = [];
  11405. // 顶级去重
  11406. for (
  11407. var i = 0;
  11408. i < this.result.children.length;
  11409. i++
  11410. ) {
  11411. if (
  11412. this.result.children[i][this.attributeName] ===
  11413. node[this.attributeName]
  11414. ) {
  11415. return this.result.children[i];
  11416. }
  11417. }
  11418. this.result.children.push(node);
  11419. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11420. }
  11421. }
  11422. },
  11423. getWhole: function (nodes, attributeName) {
  11424. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11425. var _node = {};
  11426. _node.children = [];
  11427. this.result = _node; //重置根节点
  11428. this.attributeName =
  11429. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11430. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11431. nodes.forEach((item) => {
  11432. //循环调用转化方法
  11433. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11434. this.transform(item);
  11435. });
  11436. return this.result; //返回根节点
  11437. },
  11438. };
  11439. var result = treeConverter.getWhole(nodes); //调用
  11440. return result;
  11441. }
  11442. var li = transform(data).children;
  11443. // li=[...new Set(li)]
  11444. console.log(li);
  11445. treeMap = li;
  11446. fn(li);
  11447. return li;
  11448. } else {
  11449. //loop over data
  11450. for (var i = 0; i < data.length; i++) {
  11451. var datum = data[i];
  11452. //each node will have children, so let's give it a "children" poperty
  11453. datum.children = [];
  11454. //add an entry for this node to the map so that any future children can
  11455. //lookup the parent
  11456. idToNodeMap[datum.id] = datum;
  11457. //Does this node have a parent?
  11458. if (
  11459. typeof datum.parent === "undefined" ||
  11460. datum.parent === null
  11461. ) {
  11462. //Doesn't look like it, so this node is the root of the tree
  11463. root = datum;
  11464. treeMap[datum.id] = root;
  11465. } else {
  11466. //This node has a parent, so let's look it up using the id
  11467. parentNode = idToNodeMap[datum.parent.id];
  11468. //We don't need this property, so let's delete it.
  11469. // delete datum.parent;
  11470. //Let's add the current node as a child of the parent node.
  11471. parentNode.children.push(datum);
  11472. }
  11473. }
  11474. }
  11475. return root;
  11476. }
  11477. function convertParentToChildList(data) {
  11478. var treeMap = {};
  11479. var list = [];
  11480. if (search == "search" && items.filterKeyword) {
  11481. var lis = convertListToTree(data, treeMap);
  11482. return lis;
  11483. } else {
  11484. if (data[0] && data[0].orders) {
  11485. list = data;
  11486. } else {
  11487. convertListToTree(data, treeMap);
  11488. angular.forEach(treeMap, function (item) {
  11489. // console.log("item="+JSON.stringify(item))
  11490. list.push(item);
  11491. });
  11492. }
  11493. return list;
  11494. }
  11495. }
  11496. function selectItem(pmodel, childrens) {
  11497. if (angular.isArray(pmodel)) {
  11498. angular.forEach(pmodel, function (index) {
  11499. if (index && index.id) {
  11500. angular.forEach(childrens, function (item) {
  11501. if (item.id == index.id) {
  11502. item.selected = true;
  11503. }
  11504. if (item && item.children) {
  11505. selectItem(pmodel, item.children);
  11506. }
  11507. });
  11508. // angular.forEach(treedata,function(parentdata){
  11509. // if(parentdata.id == index.id){
  11510. // if(parentdata.parent&&parentdata.parent.id){
  11511. // parentdata.parent.$
  11512. // }
  11513. // item.selected = true;
  11514. // }
  11515. // if (item && item.children) {
  11516. // selectItem(pmodel ,item.children);
  11517. // }
  11518. // });
  11519. }
  11520. });
  11521. } else {
  11522. if (pmodel && pmodel.id) {
  11523. angular.forEach(childrens, function (item, index) {
  11524. if (item.id == pmodel.id) {
  11525. item.selected = true;
  11526. delete item.children;
  11527. }
  11528. if (item && item.children) {
  11529. selectItem(pmodel, item.children);
  11530. }
  11531. });
  11532. }
  11533. }
  11534. }
  11535. function selectItemchild(pmodel, childrens) {
  11536. if (angular.isArray(pmodel)) {
  11537. angular.forEach(pmodel, function (index) {
  11538. if (index && index.id) {
  11539. angular.forEach(childrens, function (item) {
  11540. if (item.id == index.id) {
  11541. item.selected = true;
  11542. }
  11543. if (item && item.children) {
  11544. selectItem(pmodel, item.children);
  11545. }
  11546. });
  11547. }
  11548. });
  11549. } else {
  11550. if (pmodel && pmodel.id) {
  11551. angular.forEach(childrens, function (item, index) {
  11552. if (item.id == pmodel.id) {
  11553. item.selected = true;
  11554. childrens[index].selected = true;
  11555. }
  11556. if (item && item.children) {
  11557. selectItem(pmodel, item.children);
  11558. }
  11559. });
  11560. }
  11561. }
  11562. }
  11563. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11564. if (search === "search" && items.filterKeyword) {
  11565. // bala:树形模糊搜索
  11566. options.templateOptions
  11567. .bala(options.templateOptions.APIService, items.filterKeyword)
  11568. .then(function (result) {
  11569. result.list = [...new Set(result.list)]; //去重
  11570. if (!options.templateOptions.options) {
  11571. options.templateOptions.options = [];
  11572. }
  11573. if (options.templateOptions.optionsDataKey) {
  11574. options.templateOptions.options = convertParentToChildList(
  11575. result[options.templateOptions.optionsDataKey]
  11576. );
  11577. } else {
  11578. options.templateOptions.options =
  11579. convertParentToChildList(result);
  11580. }
  11581. //set default value
  11582. var pmodel,
  11583. i = 0;
  11584. if (
  11585. options.templateOptions.pkey ||
  11586. options.templateOptions.pkey != ""
  11587. ) {
  11588. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11589. angular.forEach(
  11590. options.templateOptions.pkey.split("."),
  11591. function (p) {
  11592. if (i == 0) {
  11593. if (options.model[p] == null) {
  11594. options.model[p] = {};
  11595. }
  11596. pmodel = options.model[p];
  11597. i++;
  11598. } else {
  11599. if (pmodel[p] == null) {
  11600. pmodel[p] = {};
  11601. }
  11602. pmodel = pmodel[p];
  11603. }
  11604. }
  11605. );
  11606. } else {
  11607. pmodel = options.model;
  11608. }
  11609. }
  11610. var topdata = angular.copy(options.templateOptions.options);
  11611. if (pmodel) {
  11612. pmodel = pmodel[options.key];
  11613. } else if (options.model) {
  11614. pmodel = options.model[options.key];
  11615. }
  11616. if (angular.isArray(pmodel)) {
  11617. if (pmodel) {
  11618. items.inputModel = angular.copy(
  11619. options.templateOptions.options
  11620. );
  11621. selectItem(pmodel, options.templateOptions.options);
  11622. }
  11623. } else {
  11624. if (pmodel && pmodel.id) {
  11625. items.inputModel = angular.copy(
  11626. options.templateOptions.options
  11627. );
  11628. selectItem(pmodel, options.templateOptions.options);
  11629. } else {
  11630. // items.inputModel = options.templateOptions.options;
  11631. }
  11632. }
  11633. // items.inputModel = options.templateOptions.options;
  11634. items.selectModel = options.templateOptions.options;
  11635. // 可在此展开
  11636. if (!items.inputModel) {
  11637. items.inputModel = items.selectModel;
  11638. } else {
  11639. selectItemchild(pmodel, items.inputModel);
  11640. // for (var i = 0; i < items.inputModel.length; i++) {
  11641. // items.inputModel[i].
  11642. // for (var j = 0; j < items.selectModel.length; j++) {
  11643. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11644. // items.inputModel[i].selected = true;
  11645. // }
  11646. // }
  11647. // }
  11648. }
  11649. return items.inputModel;
  11650. // options.templateOptions.options = angular.copy(topdata);
  11651. // console.log(model);
  11652. // console.log(options);
  11653. });
  11654. } else {
  11655. options.templateOptions
  11656. .refreshData(options.templateOptions.APIService)
  11657. .then(function (result) {
  11658. if (!options.templateOptions.options) {
  11659. options.templateOptions.options = [];
  11660. }
  11661. if (options.templateOptions.optionsDataKey) {
  11662. options.templateOptions.options = convertParentToChildList(
  11663. result[options.templateOptions.optionsDataKey]
  11664. );
  11665. } else {
  11666. options.templateOptions.options =
  11667. convertParentToChildList(result);
  11668. }
  11669. //set default value
  11670. var pmodel,
  11671. i = 0;
  11672. if (
  11673. options.templateOptions.pkey ||
  11674. options.templateOptions.pkey != ""
  11675. ) {
  11676. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11677. angular.forEach(
  11678. options.templateOptions.pkey.split("."),
  11679. function (p) {
  11680. if (i == 0) {
  11681. if (options.model[p] == null) {
  11682. options.model[p] = {};
  11683. }
  11684. pmodel = options.model[p];
  11685. i++;
  11686. } else {
  11687. if (pmodel[p] == null) {
  11688. pmodel[p] = {};
  11689. }
  11690. pmodel = pmodel[p];
  11691. }
  11692. }
  11693. );
  11694. } else {
  11695. pmodel = options.model;
  11696. }
  11697. }
  11698. var topdata = angular.copy(options.templateOptions.options);
  11699. if (pmodel) {
  11700. pmodel = pmodel[options.key];
  11701. } else if (options.model) {
  11702. pmodel = options.model[options.key];
  11703. }
  11704. if (angular.isArray(pmodel)) {
  11705. if (pmodel) {
  11706. items.inputModel = angular.copy(
  11707. options.templateOptions.options
  11708. );
  11709. selectItem(pmodel, options.templateOptions.options);
  11710. }
  11711. } else {
  11712. if (pmodel && pmodel.id) {
  11713. items.inputModel = angular.copy(
  11714. options.templateOptions.options
  11715. );
  11716. selectItem(pmodel, options.templateOptions.options);
  11717. } else {
  11718. // items.inputModel = options.templateOptions.options;
  11719. }
  11720. }
  11721. // items.inputModel = options.templateOptions.options;
  11722. items.selectModel = options.templateOptions.options;
  11723. if (!items.inputModel) {
  11724. items.inputModel = items.selectModel;
  11725. } else {
  11726. selectItemchild(pmodel, items.inputModel);
  11727. // for (var i = 0; i < items.inputModel.length; i++) {
  11728. // for (var j = 0; j < items.selectModel.length; j++) {
  11729. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11730. // items.inputModel[i].selected = true;
  11731. // }
  11732. // }
  11733. // }
  11734. }
  11735. // options.templateOptions.options = angular.copy(topdata);
  11736. // console.log(model);
  11737. // console.log(options);
  11738. });
  11739. }
  11740. },
  11741. },
  11742. validators: {
  11743. required: {
  11744. expression: function (viewValue, modelValue) {
  11745. var value = modelValue || viewValue;
  11746. if (angular.isArray(value)) {
  11747. return value.length > 0;
  11748. } else {
  11749. // console.log(options)
  11750. if (options.templateOptions.required && !value) {
  11751. // return value != null;
  11752. } else {
  11753. return value;
  11754. }
  11755. // return value = "true";
  11756. }
  11757. },
  11758. },
  11759. },
  11760. };
  11761. },
  11762. controller: [
  11763. "$scope",
  11764. "$rootScope",
  11765. "api_configure_form",
  11766. "api_bpm_domain",
  11767. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  11768. $rootScope.checkClicked = function (item) {
  11769. angular.forEach($scope.to.options, function (itemone) {
  11770. if (!item.parent) {
  11771. if (item.id == itemone.id) {
  11772. // itemone.isExpanded = true;
  11773. } else {
  11774. itemone.isExpanded = false;
  11775. }
  11776. } else {
  11777. if (item.parent.id == itemone.id) {
  11778. angular.forEach(itemone.children, function (itemtwo) {
  11779. if (item.id == itemtwo.id) {
  11780. } else {
  11781. itemtwo.isExpanded = false;
  11782. }
  11783. });
  11784. }
  11785. }
  11786. });
  11787. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  11788. console.log($scope, "gsm");
  11789. if (
  11790. $scope.originalModel &&
  11791. $scope.originalModel.incident &&
  11792. item.category &&
  11793. (!item.children || !item.children.length) &&
  11794. item.priority &&
  11795. item.priority.id
  11796. ) {
  11797. api_bpm_domain
  11798. .expectedTime("L" + (item.priority.id - 1559))
  11799. .then(function (res) {
  11800. $scope.originalModel.incident.expectResponseTime =
  11801. res.serviceLevelAgreement.responseTime;
  11802. $scope.originalModel.incident.expectIntroTime =
  11803. res.serviceLevelAgreement.resolveTime;
  11804. $scope.originalModel.incident.overdueTime = res.date;
  11805. });
  11806. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  11807. // setTimeout(() => {
  11808. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  11809. // }, 500);
  11810. // console.log($scope.$parent.$parent.$parent)
  11811. }
  11812. };
  11813. if ($scope.options.templateOptions.isMultiSelect) {
  11814. // console.log($scope);
  11815. } else {
  11816. if ($scope.model[$scope.options.key]) {
  11817. }
  11818. }
  11819. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  11820. // console.log(item)
  11821. // // if(){
  11822. // // }
  11823. // // $scope.model[$scope.options.key]=item.id;
  11824. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  11825. // $scope.propTypeOptions = data;
  11826. // });
  11827. // }
  11828. // $scope.model[$scope.options.key]=[];
  11829. // $scope.fn
  11830. $rootScope.bala1 = function (items, fn) {
  11831. // $scope.fn = fn;
  11832. console.log(items);
  11833. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  11834. $scope.options.templateOptions.refresh(items, "search", fn);
  11835. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  11836. // // return res.list;
  11837. // console.log(666)
  11838. // fn(res.list)
  11839. // })
  11840. };
  11841. },
  11842. ],
  11843. });
  11844. //勾选组件
  11845. formlyConfigProvider.setType({
  11846. name: "ui-checkbox",
  11847. extends: "checkbox",
  11848. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  11849. controller: [
  11850. "$scope",
  11851. function ($scope) {
  11852. // 巡检生成事件,默认派单
  11853. if ($scope.model.isInspection) {
  11854. $scope.model[$scope.options.key] = true;
  11855. }
  11856. if ($scope.model[$scope.options.key] == "true") {
  11857. $scope.model[$scope.options.key] = true;
  11858. }
  11859. if ($scope.model[$scope.options.key] == "false") {
  11860. $scope.model[$scope.options.key] = false;
  11861. }
  11862. },
  11863. ],
  11864. });
  11865. //换行组件
  11866. formlyConfigProvider.setType({
  11867. name: "ui-nextLine",
  11868. /*extends: 'input',*/
  11869. template: "<div></div>",
  11870. });
  11871. //多选框组件
  11872. formlyConfigProvider.setType({
  11873. name: "ui-checklist",
  11874. extends: "multiCheckbox",
  11875. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  11876. defaultOptions: function (options) {
  11877. return {
  11878. templateOptions: {
  11879. refresh: function () {},
  11880. refreshDelay: 0,
  11881. },
  11882. };
  11883. },
  11884. });
  11885. //单选框组件
  11886. formlyConfigProvider.setType({
  11887. name: "ui-radio",
  11888. extends: "radio",
  11889. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  11890. defaultOptions: function (options) {
  11891. return {
  11892. templateOptions: {
  11893. refresh: function () {},
  11894. refreshDelay: 0,
  11895. },
  11896. };
  11897. },
  11898. controller: [
  11899. "$scope",
  11900. function ($scope) {
  11901. // 巡检生成事件,默认派单
  11902. if ($scope.model.isInspection) {
  11903. $scope.model[$scope.options.key] = true;
  11904. // $scope.model.isHandlerUser=true;
  11905. $scope.model.start_code = "assignment";
  11906. console.log($scope.model);
  11907. }
  11908. //多次暂存配置
  11909. // console.log($scope);
  11910. if ($scope.model.saveAgain) {
  11911. if (
  11912. $scope.model.directClose == "1" ||
  11913. $scope.model.directClose == true
  11914. ) {
  11915. $scope.model[$scope.options.key] = true;
  11916. // if($scope.model.incident.handlingPersonnelUser){
  11917. // delete $scope.model.incident.handlingPersonnelUser;
  11918. // };
  11919. if ($scope.model.incident.handleDescription) {
  11920. delete $scope.model.incident.handleDescription;
  11921. }
  11922. if ($scope.model.incident.closecode) {
  11923. delete $scope.model.incident.closecode;
  11924. }
  11925. if ($scope.model.incident.degree) {
  11926. delete $scope.model.incident.degree;
  11927. }
  11928. } else {
  11929. $scope.model.incident.handlingPersonnelUser =
  11930. $scope.model.incident.acceptUser;
  11931. $scope.model[$scope.options.key] = false;
  11932. }
  11933. }
  11934. },
  11935. ],
  11936. });
  11937. //文本域组件
  11938. formlyConfigProvider.setWrapper({
  11939. name: "validation",
  11940. types: ["ui-textarea"],
  11941. template:
  11942. '<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>',
  11943. });
  11944. formlyConfigProvider.setType({
  11945. name: "ui-textarea",
  11946. extends: "textarea",
  11947. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  11948. defaultOptions: function (options) {
  11949. return {
  11950. templateOptions: {
  11951. transform: function (model, value) {
  11952. return value;
  11953. },
  11954. },
  11955. validation: {
  11956. messages: {
  11957. maxlength: function (viewValue, modelValue, scope) {
  11958. if (viewValue != null) {
  11959. if (viewValue.length > scope.to.maxlength) {
  11960. return (
  11961. scope.to.label +
  11962. " 字数(" +
  11963. viewValue.length +
  11964. ")超限(" +
  11965. scope.to.maxlength +
  11966. ")"
  11967. );
  11968. } else {
  11969. return "";
  11970. }
  11971. }
  11972. },
  11973. },
  11974. },
  11975. };
  11976. },
  11977. controller: [
  11978. "$scope",
  11979. function ($scope) {
  11980. var value = $scope.model[$scope.options.key];
  11981. if (angular.isFunction($scope.options.templateOptions.transform)) {
  11982. $scope.model[$scope.options.key] =
  11983. $scope.options.templateOptions.transform(
  11984. $scope.originalModel,
  11985. value
  11986. );
  11987. }
  11988. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  11989. $scope.options.templateOptions.felditem($scope);
  11990. }
  11991. },
  11992. ],
  11993. });
  11994. // div版的textarea(展示富文本框内容用)
  11995. formlyConfigProvider.setType({
  11996. name: "ui-divTextarea",
  11997. extends: "textarea",
  11998. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  11999. defaultOptions: function (options) {
  12000. return {
  12001. templateOptions: {
  12002. transform: function (model, value) {
  12003. return value;
  12004. },
  12005. },
  12006. validation: {
  12007. messages: {
  12008. // maxlength: function (viewValue, modelValue, scope) {
  12009. // if (viewValue != null) {
  12010. // if (viewValue.length > scope.to.maxlength) {
  12011. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12012. // } else {
  12013. // return "";
  12014. // }
  12015. // }
  12016. // },
  12017. },
  12018. },
  12019. };
  12020. },
  12021. controller: [
  12022. "$scope",
  12023. function ($scope) {
  12024. var value = $scope.model[$scope.options.key];
  12025. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12026. $scope.model[$scope.options.key] =
  12027. $scope.options.templateOptions.transform(
  12028. $scope.originalModel,
  12029. value
  12030. );
  12031. }
  12032. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12033. $scope.options.templateOptions.felditem($scope);
  12034. }
  12035. },
  12036. ],
  12037. });
  12038. // 带有知识库引用的textarea
  12039. formlyConfigProvider.setType({
  12040. name: "ui-textAreaKnowledge",
  12041. // extends: 'textarea',
  12042. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12043. defaultOptions: function (options) {
  12044. return {
  12045. templateOptions: {
  12046. transform: function (model, value) {
  12047. return value;
  12048. },
  12049. },
  12050. validation: {
  12051. messages: {
  12052. maxlength: function (viewValue, modelValue, scope) {
  12053. if (viewValue != null) {
  12054. if (viewValue.length > scope.to.maxlength) {
  12055. return (
  12056. scope.to.label +
  12057. " 字数(" +
  12058. viewValue.length +
  12059. ")超限(" +
  12060. scope.to.maxlength +
  12061. ")"
  12062. );
  12063. } else {
  12064. return "";
  12065. }
  12066. }
  12067. },
  12068. },
  12069. },
  12070. };
  12071. },
  12072. controller: [
  12073. "$scope",
  12074. "$rootScope",
  12075. "$modal",
  12076. "SweetAlert",
  12077. "api_bpm_data",
  12078. "api_bpm_domain",
  12079. "api_solution",
  12080. "$aside",
  12081. "api_zsk",
  12082. "up_down_file",
  12083. "api_wechatfile",
  12084. function (
  12085. $scope,
  12086. $rootScope,
  12087. $modal,
  12088. SweetAlert,
  12089. api_bpm_data,
  12090. api_bpm_domain,
  12091. api_solution,
  12092. $aside,
  12093. api_zsk,
  12094. up_down_file,
  12095. api_wechatfile
  12096. ) {
  12097. // console.log($scope);
  12098. var value = $scope.model[$scope.options.key];
  12099. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12100. $scope.model[$scope.options.key] =
  12101. $scope.options.templateOptions.transform(
  12102. $scope.originalModel,
  12103. value
  12104. );
  12105. }
  12106. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12107. $scope.options.templateOptions.felditem($scope);
  12108. }
  12109. // 引用知识库点击
  12110. $scope.openSolution = function () {
  12111. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12112. setTimeout(() => {
  12113. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12114. }, 100);
  12115. };
  12116. },
  12117. ],
  12118. });
  12119. //常用语句选择textarea
  12120. formlyConfigProvider.setType({
  12121. name: "ui-textselect",
  12122. extends: "textarea",
  12123. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12124. defaultOptions: function (options) {
  12125. return {
  12126. templateOptions: {
  12127. transform: function (model, value) {
  12128. return value;
  12129. },
  12130. },
  12131. validation: {
  12132. messages: {
  12133. maxlength: function (viewValue, modelValue, scope) {
  12134. if (viewValue != null) {
  12135. if (viewValue.length > scope.to.maxlength) {
  12136. return (
  12137. scope.to.label +
  12138. " 字数(" +
  12139. viewValue.length +
  12140. ")超限(" +
  12141. scope.to.maxlength +
  12142. ")"
  12143. );
  12144. } else {
  12145. return "";
  12146. }
  12147. }
  12148. },
  12149. },
  12150. },
  12151. };
  12152. },
  12153. controller: [
  12154. "$scope",
  12155. function ($scope) {
  12156. var value = $scope.model[$scope.options.key];
  12157. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12158. $scope.model[$scope.options.key] =
  12159. $scope.options.templateOptions.transform(
  12160. $scope.originalModel,
  12161. value
  12162. );
  12163. }
  12164. },
  12165. ],
  12166. });
  12167. //改动的组件 ckeditor封装后的组件
  12168. formlyConfigProvider.setType({
  12169. name: "ui-text-check",
  12170. extends: "textarea",
  12171. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12172. defaultOptions: function (options) {
  12173. return {
  12174. templateOptions: {
  12175. extraPlugins: "uploadimage",
  12176. uploadimageConfig: {
  12177. backend: "basic",
  12178. settings: {
  12179. uploadUrl:
  12180. options.templateOptions.APIService.upload().getRequestedUrl(),
  12181. headers: "",
  12182. downloadUrl:
  12183. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12184. },
  12185. },
  12186. refresh: function (APIService, contentId, data) {
  12187. return APIService.fetchDataList(contentId, data);
  12188. },
  12189. downloadUri: function (APIService, contentId) {
  12190. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12191. },
  12192. upload: function (APIService, contentId) {
  12193. return APIService.getSolutionDowpath(contentId);
  12194. },
  12195. view: function (attachmentId) {
  12196. // return APIService.attachmentsPreviewUrl(contentId);
  12197. },
  12198. refreshDelay: 0,
  12199. transform: function (model, value) {
  12200. return value;
  12201. },
  12202. },
  12203. validation: {
  12204. messages: {
  12205. maxlength: function (viewValue, modelValue, scope) {
  12206. if (viewValue != null) {
  12207. if (viewValue.length > scope.to.maxlength) {
  12208. return (
  12209. scope.to.label +
  12210. " 字数(" +
  12211. viewValue.length +
  12212. ")超限(" +
  12213. scope.to.maxlength +
  12214. ")"
  12215. );
  12216. } else {
  12217. return "";
  12218. }
  12219. }
  12220. },
  12221. },
  12222. },
  12223. };
  12224. },
  12225. controller: [
  12226. "$scope",
  12227. "$rootScope",
  12228. function ($scope, $rootScope) {
  12229. var value = $scope.model[$scope.options.key];
  12230. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12231. $scope.model[$scope.options.key] =
  12232. $scope.options.templateOptions.transform(
  12233. $scope.originalModel,
  12234. value
  12235. );
  12236. }
  12237. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12238. $rootScope.getSession();
  12239. //var expiry={'expiry':14804244006};
  12240. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12241. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12242. $scope.upload = function (contentId, filename) {
  12243. var filename = filename;
  12244. $scope.options.templateOptions
  12245. .upload($scope.options.templateOptions.ApiService, contentId)
  12246. .then(function (response) {
  12247. var file = new Blob([response], {
  12248. type: "application/octet-stream",
  12249. });
  12250. // var filename = filename;
  12251. var fileURL = URL.createObjectURL(file);
  12252. var a = document.createElement("a");
  12253. a.href = fileURL;
  12254. a.target = "_blank";
  12255. a.download = filename;
  12256. document.body.appendChild(a);
  12257. a.click();
  12258. });
  12259. };
  12260. },
  12261. ],
  12262. });
  12263. //改动的组件 ckeditor封装后的附文本组件
  12264. formlyConfigProvider.setType({
  12265. name: "ui-fuwenben",
  12266. extends: "textarea",
  12267. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12268. defaultOptions: function (options) {
  12269. return {
  12270. templateOptions: {
  12271. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12272. extraPlugins: "uploadimage",
  12273. uploadimageConfig: {
  12274. backend: "basic",
  12275. settings: {
  12276. uploadUrl:
  12277. options.templateOptions.APIService.upload(
  12278. -110
  12279. ).getRequestedUrl(),
  12280. headers: "",
  12281. downloadUrl:
  12282. options.templateOptions.APIService.uploadResponseUri(),
  12283. },
  12284. },
  12285. refresh: function (APIService, contentId, data) {
  12286. return APIService.fetchDataList(-110, data);
  12287. },
  12288. downloadUri: function (APIService, contentId) {
  12289. return APIService.downloadAttachment(-110).getRequestedUrl();
  12290. },
  12291. upload: function (APIService, contentId) {
  12292. return APIService.getSolutionDowpath(-110);
  12293. },
  12294. view: function (attachmentId) {
  12295. // return APIService.attachmentsPreviewUrl(contentId);
  12296. },
  12297. refreshDelay: 0,
  12298. transform: function (model, value) {
  12299. return value;
  12300. },
  12301. },
  12302. validation: {
  12303. messages: {
  12304. maxlength: function (viewValue, modelValue, scope) {
  12305. if (viewValue != null) {
  12306. if (viewValue.length > scope.to.maxlength) {
  12307. return (
  12308. scope.to.label +
  12309. " 字数(" +
  12310. viewValue.length +
  12311. ")超限(" +
  12312. scope.to.maxlength +
  12313. ")"
  12314. );
  12315. } else {
  12316. return "";
  12317. }
  12318. }
  12319. },
  12320. },
  12321. },
  12322. };
  12323. },
  12324. controller: [
  12325. "$scope",
  12326. "$rootScope",
  12327. function ($scope, $rootScope) {
  12328. var value = $scope.model[$scope.options.key];
  12329. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12330. $scope.model[$scope.options.key] =
  12331. $scope.options.templateOptions.transform(
  12332. $scope.originalModel,
  12333. value
  12334. );
  12335. }
  12336. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12337. $rootScope.getSession();
  12338. //var expiry={'expiry':14804244006};
  12339. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12340. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12341. $scope.upload = function (contentId, filename) {
  12342. var filename = filename;
  12343. $scope.options.templateOptions
  12344. .upload($scope.options.templateOptions.ApiService, -110)
  12345. .then(function (response) {
  12346. var file = new Blob([response], {
  12347. type: "application/octet-stream",
  12348. });
  12349. // var filename = filename;
  12350. var fileURL = URL.createObjectURL(file);
  12351. var a = document.createElement("a");
  12352. a.href = fileURL;
  12353. a.target = "_blank";
  12354. a.download = filename;
  12355. document.body.appendChild(a);
  12356. a.click();
  12357. });
  12358. };
  12359. },
  12360. ],
  12361. });
  12362. //ui-grid展示控件
  12363. formlyConfigProvider.setType({
  12364. name: "ui-grid-show",
  12365. extends: "multiCheckbox",
  12366. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12367. defaultOptions: function (options) {
  12368. return {
  12369. templateOptions: {
  12370. linkage: function () {},
  12371. },
  12372. };
  12373. },
  12374. controller: function (
  12375. $scope,
  12376. $rootScope,
  12377. i18nService,
  12378. Restangular,
  12379. api_bpm_data
  12380. ) {
  12381. var loginUser = $rootScope.user;
  12382. $scope.langs = i18nService.getAllLangs();
  12383. $scope.lang = "zh-cn";
  12384. i18nService.setCurrentLang($scope.lang);
  12385. $scope.gridOptions = {};
  12386. $scope.gridOptions.data = "myData";
  12387. $scope.gridOptions.enableColumnResizing = true;
  12388. // $scope.gridOptions.enableFiltering = true;
  12389. $scope.gridOptions.enableGridMenu = false;
  12390. $scope.gridOptions.enableRowSelection = true;
  12391. $scope.gridOptions.showGridFooter = true;
  12392. $scope.gridOptions.showColumnFooter = false;
  12393. $scope.gridOptions.fastWatch = true;
  12394. $scope.gridOptions.useExternalFiltering = true;
  12395. $scope.gridOptions.useExternalPagination = true;
  12396. $scope.gridOptions.paginationPageSizes = [10];
  12397. $scope.gridOptions.paginationPageSize = 10;
  12398. $scope.gridOptions.multiSelect = true;
  12399. $scope.gridOptions.rowIdentity = function (row) {
  12400. return row.id;
  12401. };
  12402. $scope.gridOptions.getRowIdentity = function (row) {
  12403. return row.id;
  12404. };
  12405. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12406. $scope.gridOptions.columnDefs = [
  12407. // { name:'id', width:80, enableFiltering:false},
  12408. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12409. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12410. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12411. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12412. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12413. {
  12414. name: "inspection.title",
  12415. displayName: "计划主题",
  12416. width: 120,
  12417. enableFiltering: false,
  12418. },
  12419. {
  12420. name: "stateName",
  12421. displayName: "状态",
  12422. width: 80,
  12423. enableFiltering: false,
  12424. },
  12425. {
  12426. name: "processUser.name",
  12427. displayName: "处理人",
  12428. width: 80,
  12429. enableFiltering: false,
  12430. },
  12431. {
  12432. name: "startDate",
  12433. displayName: "开始时间",
  12434. width: 160,
  12435. enableFiltering: false,
  12436. },
  12437. {
  12438. name: "overdueTime",
  12439. displayName: "逾期时间",
  12440. width: 160,
  12441. enableFiltering: false,
  12442. },
  12443. ];
  12444. var defaultFilterData = {
  12445. idx: 0,
  12446. sum: 10,
  12447. };
  12448. //分页控制
  12449. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12450. gridApi.pagination.on.paginationChanged(
  12451. $scope,
  12452. function (newPage, pageSize) {
  12453. var filtersData = $scope.memoryfilterData;
  12454. filtersData.idx = newPage - 1;
  12455. filtersData.sum = pageSize;
  12456. $scope.refreshData("expand-right", filtersData);
  12457. }
  12458. );
  12459. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12460. data.grid.appScope.selected.items = data.entity;
  12461. });
  12462. };
  12463. //页面获取数据
  12464. $scope.refreshData = function (style, filterData) {
  12465. // $scope.ldloading[style.replace('-', '_')] = true;
  12466. if (angular.isUndefined(filterData)) {
  12467. filterData = defaultFilterData;
  12468. }
  12469. $scope.myData = [];
  12470. angular.extend(filterData, {
  12471. inspectionProcessActual: {
  12472. inspectionid: $scope.model.id,
  12473. },
  12474. });
  12475. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12476. function (data) {
  12477. var myData = Restangular.stripRestangular(data);
  12478. $scope.gridOptions.totalItems = myData.totalNum;
  12479. $scope.myData = myData.list;
  12480. for (var i = 0; i < $scope.myData.length; i++) {
  12481. //添加序号
  12482. $scope.myData[i]["item"] =
  12483. i + 1 + filterData.idx * filterData.sum;
  12484. }
  12485. // $scope.ldloading[style.replace('-', '_')] = false;
  12486. },
  12487. function () {
  12488. // $scope.ldloading[style.replace('-', '_')] = false;
  12489. }
  12490. );
  12491. };
  12492. $scope.refreshData("expand-right", defaultFilterData);
  12493. },
  12494. });
  12495. //文本框自定义选择面板组件
  12496. formlyConfigProvider.setType({
  12497. name: "ui-input-selectmodal",
  12498. extends: "input",
  12499. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  12500. defaultOptions: function (options) {
  12501. return {
  12502. templateOptions: {
  12503. openModal: function (size, options, modal) {
  12504. var modalInstance = modal.open({
  12505. templateUrl: "assets/views/customform/tpl/modal-content.html",
  12506. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  12507. size: size,
  12508. resolve: options.templateOptions.modalParam,
  12509. });
  12510. modalInstance.result.then(
  12511. function (selectedItem) {
  12512. options.value(selectedItem);
  12513. },
  12514. function () {
  12515. //console.log('Modal dismissed at: ' + new Date());
  12516. }
  12517. );
  12518. },
  12519. },
  12520. };
  12521. },
  12522. });
  12523. //日期控件
  12524. var datepicker_attr = [
  12525. "date-disabled",
  12526. "custom-class",
  12527. "show-weeks",
  12528. "starting-day",
  12529. "init-date",
  12530. "min-mode",
  12531. "max-mode",
  12532. "format-day",
  12533. "format-month",
  12534. "format-year",
  12535. "format-day-header",
  12536. "format-day-title",
  12537. "format-month-title",
  12538. "year-range",
  12539. "shortcut-propagation",
  12540. "datepicker-popup",
  12541. "show-button-bar",
  12542. "current-text",
  12543. "clear-text",
  12544. "close-text",
  12545. "close-on-date-selection",
  12546. "datepicker-append-to-body",
  12547. ];
  12548. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  12549. formlyConfigProvider.setType({
  12550. name: "ui-datetime",
  12551. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  12552. extends: "input",
  12553. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12554. defaultOptions: {
  12555. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12556. templateOptions: {
  12557. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12558. },
  12559. },
  12560. controller: [
  12561. "$scope",
  12562. "$filter",
  12563. function ($scope, $filter) {
  12564. $scope.model[$scope.options.key] = $filter("date")(
  12565. new Date(),
  12566. $scope.options.templateOptions.datepickerPopup
  12567. );
  12568. $scope.options.initialValue = $scope.model[$scope.options.key];
  12569. },
  12570. ],
  12571. });
  12572. //日期控件
  12573. formlyConfigProvider.setType({
  12574. name: "ui-datepicker",
  12575. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  12576. extends: "input",
  12577. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12578. defaultOptions: {
  12579. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12580. templateOptions: {
  12581. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12582. },
  12583. },
  12584. controller: [
  12585. "$scope",
  12586. "$filter",
  12587. function ($scope, $filter) {
  12588. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  12589. if ($scope.model[$scope.options.key]) {
  12590. } else {
  12591. $scope.model[$scope.options.key] = $filter("date")(
  12592. new Date(),
  12593. $scope.options.templateOptions.datepickerPopup
  12594. );
  12595. }
  12596. $scope.options.initialValue = $scope.model[$scope.options.key];
  12597. $scope.endOpen = true;
  12598. $scope.datepicker = {};
  12599. $scope.datepicker.opened = false;
  12600. $scope.datepicker.open = function ($event) {
  12601. $scope.datepicker.opened = true;
  12602. };
  12603. },
  12604. ],
  12605. });
  12606. //时分控件
  12607. formlyConfigProvider.setType({
  12608. name: "ui-datehourtime",
  12609. extends: "input",
  12610. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  12611. defaultOptions: function (options) {
  12612. return {
  12613. noFormControl: true,
  12614. // validators:{
  12615. // required:{
  12616. // expression:function(viewValue, modelValue){
  12617. // console.log(options)
  12618. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  12619. // // var value = modelValue.getHours() || viewValue.getHours();
  12620. // return value.length>=1;
  12621. // }
  12622. // }
  12623. // }
  12624. };
  12625. },
  12626. controller: [
  12627. "$scope",
  12628. "$log",
  12629. function ($scope, $log) {
  12630. $scope.hstep = new Date(
  12631. Date.parse($scope.model[$scope.options.key])
  12632. ).getHours();
  12633. $scope.minutes = new Date(
  12634. Date.parse($scope.model[$scope.options.key])
  12635. ).getMinutes();
  12636. $scope.model[$scope.options.key] = new Date(
  12637. Date.parse($scope.model[$scope.options.key])
  12638. );
  12639. },
  12640. ],
  12641. });
  12642. //状态追踪
  12643. formlyConfigProvider.setType({
  12644. name: "ui-followStatus",
  12645. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  12646. controller: [
  12647. "$scope",
  12648. "api_bpm_data",
  12649. "Restangular",
  12650. function ($scope, api_bpm_data, Restangular) {
  12651. setTimeout(function () {
  12652. var pkey = $scope.options.templateOptions.pkey;
  12653. var dataId = $scope.model.id;
  12654. if (dataId) {
  12655. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  12656. if (response) {
  12657. var myData = Restangular.stripRestangular(response);
  12658. var processInstanceId = myData.data.processInstanceId;
  12659. $scope.options.templateOptions
  12660. .getData(
  12661. $scope.model,
  12662. $scope.options.templateOptions.ApiService,
  12663. processInstanceId
  12664. )
  12665. .then(function (result) {
  12666. if (result.status == 200) {
  12667. var newData = Restangular.stripRestangular(result);
  12668. $scope.followData = newData.data;
  12669. }
  12670. });
  12671. }
  12672. });
  12673. }
  12674. }, 10);
  12675. },
  12676. ],
  12677. });
  12678. //历史记录
  12679. formlyConfigProvider.setType({
  12680. name: "ui-history",
  12681. templateUrl: "assets/views/customform/tpl/ui-history.html",
  12682. controller: [
  12683. "$scope",
  12684. "api_bpm_data",
  12685. "Restangular",
  12686. function ($scope, api_bpm_data, Restangular) {
  12687. setTimeout(function () {
  12688. var pkey = $scope.options.templateOptions.pkey;
  12689. var dataId = $scope.model.id;
  12690. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  12691. if (response) {
  12692. var myData = Restangular.stripRestangular(response);
  12693. var processInstanceId = myData.data.processInstanceId;
  12694. $scope.options.templateOptions
  12695. .getData(
  12696. $scope.model,
  12697. $scope.options.templateOptions.ApiService,
  12698. processInstanceId
  12699. )
  12700. .then(function (result) {
  12701. if (result.status == 200) {
  12702. var newData = Restangular.stripRestangular(result);
  12703. var long = newData.data.length - 1;
  12704. $scope.followData = newData.data[long];
  12705. }
  12706. });
  12707. }
  12708. });
  12709. }, 10);
  12710. },
  12711. ],
  12712. });
  12713. // //请求人信息显示
  12714. // formlyConfigProvider.setType({
  12715. // name: "ui-disrequester",
  12716. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  12717. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12718. // defaultOptions: function(options) {
  12719. // return {
  12720. // templateOptions: {}
  12721. // };
  12722. // },
  12723. // controller: ['$scope', function($scope) {
  12724. // $scope.options.templateOptions.that = $scope;
  12725. // }]
  12726. // });
  12727. //退回人信息显示
  12728. formlyConfigProvider.setType({
  12729. name: "ui-returnperson",
  12730. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  12731. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12732. defaultOptions: function (options) {
  12733. return {
  12734. templateOptions: {},
  12735. };
  12736. },
  12737. controller: [
  12738. "$scope",
  12739. function ($scope) {
  12740. $scope.group = "";
  12741. $scope.role = "";
  12742. if (
  12743. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  12744. $scope.model.handlingPersonnelUser.group.length == 1
  12745. ) {
  12746. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  12747. } else {
  12748. for (
  12749. var i = 0;
  12750. i < $scope.model.handlingPersonnelUser.group.length;
  12751. i++
  12752. ) {
  12753. $scope.group +=
  12754. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  12755. }
  12756. }
  12757. if (
  12758. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  12759. $scope.model.handlingPersonnelUser.role.length == 1
  12760. ) {
  12761. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  12762. } else {
  12763. for (
  12764. var i = 0;
  12765. i < $scope.model.handlingPersonnelUser.role.length;
  12766. i++
  12767. ) {
  12768. $scope.role +=
  12769. $scope.model.handlingPersonnelUser.role[i].role + ",";
  12770. }
  12771. }
  12772. $scope.options.templateOptions.that = $scope;
  12773. $scope.options.templateOptions.that = $scope;
  12774. },
  12775. ],
  12776. });
  12777. //退回人信息显示(去掉工作组&角色)
  12778. formlyConfigProvider.setType({
  12779. name: "ui-returnpersonNoGroup",
  12780. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  12781. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12782. defaultOptions: function (options) {
  12783. return {
  12784. templateOptions: {},
  12785. };
  12786. },
  12787. controller: [
  12788. "$scope",
  12789. function ($scope) {
  12790. $scope.group = "";
  12791. $scope.role = "";
  12792. if (
  12793. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  12794. $scope.model.handlingPersonnelUser.group.length == 1
  12795. ) {
  12796. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  12797. } else {
  12798. for (
  12799. var i = 0;
  12800. i < $scope.model.handlingPersonnelUser.group.length;
  12801. i++
  12802. ) {
  12803. $scope.group +=
  12804. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  12805. }
  12806. }
  12807. if (
  12808. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  12809. $scope.model.handlingPersonnelUser.role.length == 1
  12810. ) {
  12811. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  12812. } else {
  12813. for (
  12814. var i = 0;
  12815. i < $scope.model.handlingPersonnelUser.role.length;
  12816. i++
  12817. ) {
  12818. $scope.role +=
  12819. $scope.model.handlingPersonnelUser.role[i].role + ",";
  12820. }
  12821. }
  12822. $scope.options.templateOptions.that = $scope;
  12823. $scope.options.templateOptions.that = $scope;
  12824. },
  12825. ],
  12826. });
  12827. //指派技术人员
  12828. formlyConfigProvider.setType({
  12829. name: "ui-apiontperson",
  12830. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  12831. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12832. defaultOptions: function (options) {
  12833. return {
  12834. templateOptions: {
  12835. transtlara: function (value, $scope) {},
  12836. },
  12837. };
  12838. },
  12839. controller: [
  12840. "$scope",
  12841. "api_user_data",
  12842. "Restangular",
  12843. function ($scope, api_user_data, Restangular) {
  12844. var filterData = {
  12845. idx: 0,
  12846. sum: 1000,
  12847. };
  12848. api_user_data
  12849. .fetchDataList("group", filterData)
  12850. .then(function (response) {
  12851. if (response.status == 200) {
  12852. $scope.select = {};
  12853. $scope.multipleDemo = {};
  12854. $scope.userdata = {};
  12855. var data = response.list;
  12856. var item = [];
  12857. $scope.multipleDemo = data;
  12858. $scope.multipleDemo;
  12859. }
  12860. });
  12861. $scope.options.templateOptions.onChange = function (
  12862. id,
  12863. options,
  12864. groupdata,
  12865. $event,
  12866. model
  12867. ) {
  12868. if (groupdata.option) {
  12869. $scope.model[$scope.options.key] = {};
  12870. var fildate = {
  12871. idx: 0,
  12872. sum: 1000,
  12873. user: {
  12874. roledata: {
  12875. rolecode: model.currentRole,
  12876. },
  12877. selectType: "1",
  12878. groupdata: {
  12879. id: groupdata.option.id,
  12880. },
  12881. },
  12882. };
  12883. api_user_data
  12884. .fetchDataList("user", fildate)
  12885. .then(function (response) {
  12886. if (response.status == 200) {
  12887. $scope.userdata = {};
  12888. $scope.userdata = response.list;
  12889. }
  12890. });
  12891. } else {
  12892. $scope.model[$scope.options.key] = {
  12893. id: groupdata.id.id,
  12894. };
  12895. $scope.options.templateOptions.transtlara(
  12896. $scope.model[$scope.options.key],
  12897. $scope
  12898. );
  12899. }
  12900. };
  12901. // }
  12902. },
  12903. ],
  12904. });
  12905. //请求科室信息(小蓝框) lmm
  12906. formlyConfigProvider.setType({
  12907. name: "ui-deptinformation",
  12908. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  12909. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  12910. return {
  12911. templateOptions: {
  12912. checkform: function (options) {},
  12913. },
  12914. };
  12915. },
  12916. controller: [
  12917. "$scope",
  12918. "api_statistic",
  12919. function ($scope, api_statistic) {
  12920. // console.log($scope)
  12921. },
  12922. ],
  12923. });
  12924. //请求人信息
  12925. formlyConfigProvider.setType({
  12926. name: "ui-requesterinformation",
  12927. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  12928. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  12929. return {
  12930. templateOptions: {
  12931. checkform: function (options) {
  12932. if (options.model.requester) {
  12933. options.value(options.model.requester);
  12934. }
  12935. },
  12936. addRequeter: function (size, options, modal, e) {
  12937. if (e.clientX === 0) {
  12938. return;
  12939. }
  12940. e.preventDefault();
  12941. var modalInstance = modal.open({
  12942. templateUrl:
  12943. "assets/views/customform/tpl/modal-add-callrequester.html",
  12944. controller: function (
  12945. $scope,
  12946. sco,
  12947. $rootScope,
  12948. $modalInstance,
  12949. items,
  12950. SweetAlert,
  12951. title,
  12952. Restangular,
  12953. APIService,
  12954. UserService,
  12955. api_user_data,
  12956. api_statistic,
  12957. api_wechatfile
  12958. ) {
  12959. $modalInstance.SweetAlert = SweetAlert;
  12960. $scope.title = "新增报修人";
  12961. $scope.requester = {};
  12962. $scope.searchData = {};
  12963. $scope.onChangeadd = function (searchData) {
  12964. $scope.searchKey = searchData.account;
  12965. // $scope.searchDataadd = searchData;
  12966. var requesdata = angular.copy(searchData);
  12967. if (requesdata.mphone) {
  12968. delete requesdata.mphone;
  12969. }
  12970. $scope.requester = requesdata;
  12971. console.log($scope.requester);
  12972. };
  12973. $scope.refreshUseradd = function (searchKey) {
  12974. //请求人搜索
  12975. $scope.requester.account = searchKey;
  12976. $scope.searchData = searchKey;
  12977. serchdataadd(searchKey);
  12978. };
  12979. $scope.getMydata = function (x) {
  12980. $scope.searchField = JSON.parse(x[0]).account;
  12981. $scope.requester = JSON.parse(x[0]);
  12982. console.log($scope.requester);
  12983. };
  12984. $scope.getMydataone = function (x) {
  12985. $scope.searchField = x;
  12986. $scope.requester.account = x;
  12987. };
  12988. serchdataadd();
  12989. api_wechatfile
  12990. .getDictionary({
  12991. type: "list",
  12992. key: "male",
  12993. })
  12994. .then(function (data) {
  12995. if (data.status == 200) {
  12996. requester.gender = data.list;
  12997. }
  12998. });
  12999. function serchdataadd(searchKey) {
  13000. if (searchKey) {
  13001. var filterData = {
  13002. requester: {
  13003. searchKey: searchKey,
  13004. },
  13005. idx: 0,
  13006. sum: 10,
  13007. };
  13008. } else {
  13009. var filterData = {
  13010. idx: 0,
  13011. sum: 10,
  13012. };
  13013. }
  13014. api_user_data
  13015. .fetchDataList("requester", filterData)
  13016. .then(function (response) {
  13017. var myData = response;
  13018. $scope.myData = myData.list;
  13019. });
  13020. }
  13021. api_user_data
  13022. .fetchDataList("area", {
  13023. idx: 0,
  13024. sum: 1000,
  13025. })
  13026. .then(function (response) {
  13027. if (response.status == 200) {
  13028. $scope.areas = response.list;
  13029. }
  13030. });
  13031. api_wechatfile
  13032. .getDictionary(
  13033. {
  13034. key: "requester_type",
  13035. type: "list",
  13036. },
  13037. {
  13038. idx: 0,
  13039. sum: 100,
  13040. }
  13041. )
  13042. .then(function (response) {
  13043. if (response) {
  13044. $scope.networktypes = response;
  13045. }
  13046. });
  13047. $scope.requesterAreaid = "";
  13048. $scope.onChange = function (item) {
  13049. $scope.requesterAreaid = item.id;
  13050. api_user_data
  13051. .fetchDataList("place", {
  13052. place: {
  13053. area: {
  13054. id: item.id,
  13055. },
  13056. },
  13057. idx: 0,
  13058. sum: 1000,
  13059. })
  13060. .then(function (response) {
  13061. if (response.status == 200) {
  13062. $scope.places = response.list;
  13063. delete $scope.requester.placeDTO;
  13064. }
  13065. });
  13066. };
  13067. $scope.refresh = function (searchVal) {
  13068. var faildata = {};
  13069. if ($scope.requesterAreaid) {
  13070. faildata = {
  13071. idx: 0,
  13072. sum: 1000,
  13073. place: {
  13074. areaId: $scope.requesterAreaid,
  13075. place: searchVal,
  13076. selectType: "pinyin_qs",
  13077. },
  13078. };
  13079. } else {
  13080. faildata = {
  13081. idx: 0,
  13082. sum: 1000,
  13083. place: {
  13084. place: searchVal,
  13085. selectType: "pinyin_qs",
  13086. },
  13087. };
  13088. }
  13089. api_user_data
  13090. .fetchDataList("place", faildata)
  13091. .then(function (response) {
  13092. $scope.places = response.list;
  13093. delete $scope.requester.placeDTO;
  13094. });
  13095. };
  13096. $scope.refreshDepts = function (key) {
  13097. var filterData = {
  13098. idx: 0,
  13099. sum: 5,
  13100. dept: {
  13101. name: key,
  13102. },
  13103. };
  13104. UserService.fetchDataList("department", filterData).then(
  13105. function (response) {
  13106. if (response.status == 200) {
  13107. $scope.depts = response.list;
  13108. }
  13109. }
  13110. );
  13111. };
  13112. $scope.ok = function () {
  13113. if (
  13114. angular.isUndefined($scope.requester.account) ||
  13115. $scope.requester.account == null ||
  13116. $scope.requester.account == ""
  13117. ) {
  13118. SweetAlert.swal(
  13119. "报修人员编号未填!",
  13120. "请填写报修人员编号",
  13121. "error"
  13122. );
  13123. } else if (
  13124. angular.isUndefined($scope.requester.name) ||
  13125. $scope.requester.name == null ||
  13126. $scope.requester.name == ""
  13127. ) {
  13128. SweetAlert.swal(
  13129. "报修人姓名未填!",
  13130. "请填写报修人姓名",
  13131. "error"
  13132. );
  13133. } else if (
  13134. angular.isUndefined($scope.requester.requesterType) ||
  13135. $scope.requester.requesterType == null ||
  13136. $scope.requester.requesterTypeDTO == ""
  13137. ) {
  13138. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13139. } else if (
  13140. angular.isUndefined($scope.requester.mphone) ||
  13141. $scope.requester.mphone == null ||
  13142. $scope.requester.mphone == ""
  13143. ) {
  13144. SweetAlert.swal(
  13145. "报修人联系电话未填!",
  13146. "请填写报修人联系电话",
  13147. "error"
  13148. );
  13149. } else {
  13150. $scope.requesterId = $scope.requester.id;
  13151. var data = {
  13152. incident: {
  13153. requester: {
  13154. id: $scope.requesterId,
  13155. },
  13156. },
  13157. idx: 0,
  13158. sum: 3,
  13159. };
  13160. api_statistic
  13161. .tableData(data, "incident")
  13162. .then(function (data) {
  13163. sco.$parent.$parent.$parent.model.incident.tableList =
  13164. data.list;
  13165. });
  13166. $scope.$watch(
  13167. sco.$parent.$parent.$parent.model.incident.tableList,
  13168. function (oldObj, newObj) {
  13169. if (newObj != oldObj) {
  13170. sco.$parent.$parent.$parent.model.incident.tableList =
  13171. newObj;
  13172. }
  13173. }
  13174. ); //lmm
  13175. console.log($scope.requester);
  13176. $modalInstance.close($scope.requester);
  13177. }
  13178. };
  13179. $scope.cancel = function () {
  13180. $modalInstance.dismiss("cancel");
  13181. };
  13182. },
  13183. resolve: {
  13184. items: function () {
  13185. return {
  13186. fetchItems: function (filterData, APIService) {
  13187. filterData = filterData || {};
  13188. if (!filterData.idx) {
  13189. filterData = {
  13190. idx: 0,
  13191. sum: 10,
  13192. };
  13193. }
  13194. return options.templateOptions.fetchItems(
  13195. filterData,
  13196. APIService
  13197. );
  13198. },
  13199. };
  13200. },
  13201. title: function () {
  13202. return options.templateOptions.modalTitle;
  13203. },
  13204. Restangular: function () {
  13205. return options.templateOptions.Restangular;
  13206. },
  13207. APIService: function () {
  13208. return options.templateOptions.ApiService;
  13209. },
  13210. UserService: function () {
  13211. return options.templateOptions.UserService;
  13212. },
  13213. sco: function () {
  13214. return $scope;
  13215. },
  13216. },
  13217. });
  13218. modalInstance.result.then(
  13219. function (selectedItem) {
  13220. console.log(selectedItem);
  13221. if (selectedItem) {
  13222. var data = {
  13223. requester: selectedItem,
  13224. };
  13225. $scope.searchKey = selectedItem.account;
  13226. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13227. // if (selectedItem.place && selectedItem.place.place) {
  13228. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13229. // }
  13230. options.templateOptions.UserService.addData(
  13231. "requester",
  13232. data
  13233. ).then(function (response) {
  13234. if (response.status == 200) {
  13235. if (options.model) {
  13236. options.model.requester = response.data;
  13237. $scope.$parent.$parent.$parent.model.incident.requester =
  13238. response.data;
  13239. $scope.$parent.$parent.$parent.model.requestershow =
  13240. response.data;
  13241. if (options.model.place) {
  13242. options.model.place.id = "";
  13243. }
  13244. if (options.model.area) {
  13245. options.model.area.id = "";
  13246. }
  13247. options.model.contacts = selectedItem.name;
  13248. if (
  13249. selectedItem.mphone &&
  13250. selectedItem.mphone != null &&
  13251. selectedItem.mphone != ""
  13252. ) {
  13253. options.model.contactsInformation =
  13254. selectedItem.mphone;
  13255. } else {
  13256. options.model.contactsInformation =
  13257. selectedItem.telephone;
  13258. }
  13259. if (
  13260. selectedItem.requesterTypeDTO &&
  13261. selectedItem.requesterTypeDTO.id == 2
  13262. ) {
  13263. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13264. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13265. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13266. }
  13267. }
  13268. if (!response.data.id) {
  13269. response.data.id = selectedItem.id;
  13270. }
  13271. options.value(response.data);
  13272. options.value(response.data);
  13273. console.log($scope, "0000000");
  13274. //新增报修人带入区域地点2020年4月23日19:48:15
  13275. $scope.model.selecthouseNumber = selectedItem.place
  13276. ? selectedItem.place
  13277. : {};
  13278. $scope.$root.selecthouseNumber = selectedItem.place
  13279. ? selectedItem.place
  13280. : {};
  13281. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13282. if (selectedItem.place && selectedItem.place.id) {
  13283. options.model.place.id = selectedItem.place.id;
  13284. options.model.place.area.id =
  13285. selectedItem.place.area.id;
  13286. }
  13287. } else {
  13288. if (selectedItem.place && selectedItem.place.id) {
  13289. options.model.place.id = selectedItem.place.id;
  13290. options.model.area.id = selectedItem.place.area.id;
  13291. }
  13292. }
  13293. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13294. // options.model.area.id = selectedItem.place.area.id
  13295. // }
  13296. if (selectedItem.houseNumber) {
  13297. options.model.houseNumber = selectedItem.houseNumber;
  13298. }
  13299. // if (selectedItem.id) {
  13300. options.model.account = selectedItem.account;
  13301. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13302. var baoxiuFields =
  13303. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13304. .fields[1].fields;
  13305. var baoxiurenTo;
  13306. baoxiuFields.forEach((e, i) => {
  13307. if (e.key == "account") {
  13308. baoxiurenTo = e.templateOptions;
  13309. baoxiurenTo.APIService.fetchDataList("requester", {
  13310. idx: 0,
  13311. sum: 20,
  13312. requester: {
  13313. searchKey: selectedItem.account,
  13314. },
  13315. }).then((res) => {
  13316. baoxiurenTo.options = res.list;
  13317. options.model.account = selectedItem.account;
  13318. });
  13319. }
  13320. });
  13321. // }
  13322. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  13323. // 选择重复事件侧滑框
  13324. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  13325. $scope.$parent.$parent.$parent.model[
  13326. "repeatIncidentShow"
  13327. ] = false;
  13328. setTimeout(() => {
  13329. $scope.$parent.$parent.$parent.model[
  13330. "repeatIncidentShow"
  13331. ] = true;
  13332. }, 500);
  13333. // }
  13334. } else {
  13335. modalInstance.SweetAlert.swal({
  13336. title: "系统错误",
  13337. text: "账号重复!",
  13338. type: "error",
  13339. });
  13340. }
  13341. });
  13342. }
  13343. },
  13344. function () {}
  13345. );
  13346. },
  13347. changeRequeter: function (
  13348. size,
  13349. options,
  13350. modal,
  13351. modeldata,
  13352. $rootScope
  13353. ) {
  13354. var modalInstance = modal.open({
  13355. templateUrl:
  13356. "assets/views/customform/tpl/modal-change-requester.html",
  13357. controller: function (
  13358. $scope,
  13359. $modalInstance,
  13360. items,
  13361. SweetAlert,
  13362. title,
  13363. Restangular,
  13364. APIService,
  13365. UserService,
  13366. api_user_data,
  13367. $rootScope
  13368. ) {
  13369. $scope.title = "修改报修人";
  13370. $scope.requester = {
  13371. id: modeldata.requester.id,
  13372. account: modeldata.requester.account,
  13373. name: modeldata.requester.name,
  13374. gender: modeldata.requester.gender,
  13375. email: modeldata.requester.email,
  13376. deptName: modeldata.requester.deptName,
  13377. mphone: modeldata.requester.mphone,
  13378. telephone: modeldata.requester.telephone,
  13379. studentNo: modeldata.requester.studentNo,
  13380. areaDTO: modeldata.requester.areaDTO,
  13381. placeDTO: modeldata.requester.placeDTO,
  13382. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  13383. };
  13384. $scope.onChangeadd = function (searchData) {
  13385. console.log(searchData);
  13386. $scope.searchKey = searchData.account;
  13387. var requesdata = angular.copy(searchData);
  13388. if (requesdata.mphone) {
  13389. delete requesdata.mphone;
  13390. }
  13391. $scope.requester = requesdata;
  13392. };
  13393. $scope.refreshUseradd = function (searchKey) {
  13394. //请求人搜索
  13395. $scope.requester.account = searchKey;
  13396. $scope.searchData = searchKey;
  13397. serchdataadd(searchKey);
  13398. };
  13399. $scope.getMydata = function (x) {
  13400. $scope.searchField = JSON.parse(x[0]).account;
  13401. $scope.requester = JSON.parse(x[0]);
  13402. };
  13403. $scope.getMydataone = function (x) {
  13404. $scope.searchField = x;
  13405. $scope.requester.account = x;
  13406. };
  13407. serchdataadd();
  13408. function serchdataadd(searchKey) {
  13409. if (searchKey) {
  13410. var filterData = {
  13411. requester: {
  13412. searchKey: searchKey,
  13413. },
  13414. idx: 0,
  13415. sum: 10,
  13416. };
  13417. } else {
  13418. var filterData = {
  13419. idx: 0,
  13420. sum: 10,
  13421. };
  13422. }
  13423. api_user_data
  13424. .fetchDataList("requester", filterData)
  13425. .then(function (response) {
  13426. var myData = response;
  13427. $scope.myData = myData.list;
  13428. });
  13429. }
  13430. api_user_data
  13431. .fetchDataList("area", {
  13432. idx: 0,
  13433. sum: 1000,
  13434. })
  13435. .then(function (response) {
  13436. if (response.status == 200) {
  13437. $scope.areas = response.list;
  13438. }
  13439. });
  13440. api_user_data
  13441. .fetchDataList("requesterType", {
  13442. idx: 0,
  13443. sum: 100,
  13444. })
  13445. .then(function (response) {
  13446. if (response.status == 200) {
  13447. $scope.networktypes = response.list;
  13448. }
  13449. });
  13450. if (
  13451. $scope.requester.areaDTO &&
  13452. $scope.requester.areaDTO.id &&
  13453. $scope.requester.areaDTO.id != ""
  13454. ) {
  13455. api_user_data
  13456. .fetchDataList("place", {
  13457. place: {
  13458. areaId: $scope.requester.areaDTO.id,
  13459. },
  13460. idx: 0,
  13461. sum: 1000,
  13462. })
  13463. .then(function (response) {
  13464. if (response.status == 200) {
  13465. $scope.places = response.list;
  13466. }
  13467. });
  13468. }
  13469. $scope.onChange = function (item) {
  13470. $scope.requester.placeDTO = {};
  13471. api_user_data
  13472. .fetchDataList("place", {
  13473. place: {
  13474. areaId: item.id,
  13475. },
  13476. idx: 0,
  13477. sum: 1000,
  13478. })
  13479. .then(function (response) {
  13480. if (response.status == 200) {
  13481. $scope.places = response.list;
  13482. }
  13483. });
  13484. };
  13485. $scope.refreshDepts = function (key) {
  13486. var filterData = {
  13487. idx: 0,
  13488. sum: 5,
  13489. dept: {
  13490. name: key,
  13491. },
  13492. };
  13493. UserService.fetchDataList("department", filterData).then(
  13494. function (response) {
  13495. if (response.status == 200) {
  13496. $scope.depts = response.list;
  13497. }
  13498. }
  13499. );
  13500. };
  13501. $scope.ok = function () {
  13502. if (
  13503. $scope.requester.account == "" ||
  13504. $scope.requester.name == ""
  13505. ) {
  13506. SweetAlert.swal(
  13507. "报修人姓名或人员编号号未填!",
  13508. "请补全报修人信息",
  13509. "error"
  13510. );
  13511. } else {
  13512. $modalInstance.close($scope.requester);
  13513. }
  13514. };
  13515. $scope.cancel = function () {
  13516. $modalInstance.dismiss("cancel");
  13517. };
  13518. },
  13519. resolve: {
  13520. items: function () {
  13521. return {
  13522. fetchItems: function (filterData, APIService) {
  13523. filterData = filterData || {};
  13524. if (!filterData.idx) {
  13525. filterData = {
  13526. idx: 0,
  13527. sum: 10,
  13528. };
  13529. }
  13530. return options.templateOptions.fetchItems(
  13531. filterData,
  13532. APIService
  13533. );
  13534. },
  13535. };
  13536. },
  13537. title: function () {
  13538. return options.templateOptions.modalTitle;
  13539. },
  13540. Restangular: function () {
  13541. return options.templateOptions.Restangular;
  13542. },
  13543. APIService: function () {
  13544. return options.templateOptions.ApiService;
  13545. },
  13546. UserService: function () {
  13547. return options.templateOptions.UserService;
  13548. },
  13549. },
  13550. });
  13551. modalInstance.result.then(
  13552. function (selectedItem) {
  13553. console.log(selectedItem);
  13554. if (selectedItem) {
  13555. if (options.model) {
  13556. if (options.model.place) {
  13557. options.model.place.id = "";
  13558. }
  13559. if (options.model.area) {
  13560. options.model.area.id = "";
  13561. }
  13562. options.model.contacts = selectedItem.name;
  13563. if (
  13564. selectedItem.mphone &&
  13565. selectedItem.mphone != null &&
  13566. selectedItem.mphone != ""
  13567. ) {
  13568. options.model.contactsInformation = selectedItem.mphone;
  13569. } else {
  13570. options.model.contactsInformation =
  13571. selectedItem.telephone;
  13572. }
  13573. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  13574. options.model.place.id = selectedItem.placeDTO.id;
  13575. }
  13576. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  13577. options.model.area.id = selectedItem.areaDTO.id;
  13578. }
  13579. if (
  13580. selectedItem.requesterTypeDTO &&
  13581. selectedItem.requesterTypeDTO.id == 2
  13582. ) {
  13583. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13584. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13585. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13586. }
  13587. }
  13588. var data = {
  13589. requester: selectedItem,
  13590. };
  13591. options.templateOptions.UserService.addData(
  13592. "requester",
  13593. data
  13594. ).then(function (response) {
  13595. if (response.status == 200) {
  13596. $scope.$parent.$parent.$parent.model["requestershow"] =
  13597. selectedItem;
  13598. options.value(response.data);
  13599. } else {
  13600. }
  13601. });
  13602. }
  13603. },
  13604. function () {}
  13605. );
  13606. event.preventDefault();
  13607. },
  13608. },
  13609. };
  13610. },
  13611. controller: [
  13612. "$scope",
  13613. "api_user_data",
  13614. "api_statistic",
  13615. function ($scope, api_user_data, api_statistic) {
  13616. $scope.options.initialValue = $scope.model[$scope.options.key];
  13617. $scope.saveReqPlace = false;
  13618. $scope.model.saveReqPlace = false;
  13619. $scope.selectGradeBox = function () {
  13620. $scope.saveReqPlace = !$scope.saveReqPlace;
  13621. console.log($scope);
  13622. $scope.model.saveReqPlace = $scope.saveReqPlace;
  13623. };
  13624. if (
  13625. $scope.model.requester &&
  13626. $scope.model.requester.requesterTypeDTO &&
  13627. $scope.model.requester.requesterTypeDTO.id == 2
  13628. ) {
  13629. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13630. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13631. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13632. }
  13633. },
  13634. ],
  13635. });
  13636. // 请求人选控件
  13637. formlyConfigProvider.setType({
  13638. name: "ui-requesterselect",
  13639. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  13640. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13641. defaultOptions: function (options, $scope) {
  13642. return {
  13643. templateOptions: {
  13644. // checkform: function(options) {
  13645. // if (options.model.requestershow) {
  13646. // options.value(options.model.requestershow);
  13647. // }
  13648. // },
  13649. validators: {
  13650. required: {
  13651. expression: function (viewValue, modelValue) {
  13652. var value = modelValue || viewValue;
  13653. return value.length >= 1;
  13654. },
  13655. },
  13656. },
  13657. openModal: function (size, options, modal) {
  13658. //查找弹出框
  13659. var modelObject = options.value();
  13660. var searchModal = function (filterSearchData) {
  13661. var modalInstance = modal.open({
  13662. templateUrl:
  13663. "assets/views/customform/tpl/checktable-modal-content.html",
  13664. controller: function (
  13665. $scope,
  13666. scope,
  13667. i18nService,
  13668. $modalInstance,
  13669. items,
  13670. title,
  13671. Restangular,
  13672. APIService,
  13673. language,
  13674. searchDatas,
  13675. api_bpm_data
  13676. ) {
  13677. $scope.langs = i18nService.getAllLangs();
  13678. $scope.lang = "zh-cn";
  13679. i18nService.setCurrentLang($scope.lang);
  13680. $scope.gridOptions = {};
  13681. $scope.gridOptions.data = "myData";
  13682. $scope.gridOptions.enableColumnResizing = true;
  13683. $scope.gridOptions.enableFiltering = true;
  13684. $scope.gridOptions.enableGridMenu = false;
  13685. $scope.gridOptions.enableRowSelection = true;
  13686. $scope.gridOptions.showGridFooter = true;
  13687. $scope.gridOptions.showColumnFooter = false;
  13688. $scope.gridOptions.fastWatch = true;
  13689. $scope.gridOptions.useExternalFiltering = true;
  13690. $scope.gridOptions.useExternalPagination = true;
  13691. $scope.gridOptions.paginationPageSizes = [10];
  13692. $scope.gridOptions.paginationPageSize = 10;
  13693. $scope.gridOptions.multiSelect = false;
  13694. $scope.gridOptions.rowIdentity = function (row) {
  13695. return row.id;
  13696. };
  13697. $scope.gridOptions.getRowIdentity = function (row) {
  13698. return row.id;
  13699. };
  13700. $scope.gridOptions.columnDefs = [
  13701. {
  13702. name: "account",
  13703. displayName: "人员编号",
  13704. width: 140,
  13705. },
  13706. {
  13707. name: "name",
  13708. displayName: "姓名",
  13709. width: 100,
  13710. },
  13711. {
  13712. name: "gender.name",
  13713. displayName: "性别",
  13714. width: 80,
  13715. enableFiltering: false,
  13716. },
  13717. {
  13718. name: "mphone",
  13719. displayName: "电话",
  13720. width: 100,
  13721. enableFiltering: false,
  13722. },
  13723. {
  13724. name: "email",
  13725. displayName: "邮件",
  13726. width: 100,
  13727. },
  13728. {
  13729. name: "areaDTO.area",
  13730. displayName: "区域",
  13731. width: 100,
  13732. enableFiltering: false,
  13733. },
  13734. {
  13735. name: "placeDTO.place",
  13736. displayName: "地点",
  13737. enableFiltering: false,
  13738. },
  13739. ];
  13740. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13741. $scope.gridApi = gridApi;
  13742. // var filtersData = $scope.memoryfilterData;
  13743. // filtersData.idx = newPage - 1;
  13744. // filtersData.sum = pageSize;
  13745. gridApi.pagination.on.paginationChanged(
  13746. $scope,
  13747. function (newPage, pageSize) {
  13748. var filtersData = $scope.memoryfilterData;
  13749. filtersData.idx = newPage - 1;
  13750. filtersData.sum = pageSize;
  13751. $scope.loadData(filtersData);
  13752. }
  13753. );
  13754. gridApi.selection.on.rowSelectionChanged(
  13755. $scope,
  13756. function (data) {
  13757. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  13758. $scope.selected.item = data.entity;
  13759. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  13760. }
  13761. );
  13762. gridApi.core.on.filterChanged($scope, function () {
  13763. var grid = this.grid;
  13764. var filtersData = {
  13765. idx: 0,
  13766. sum: 10,
  13767. // 'requester': { 'userType': 1 }
  13768. };
  13769. angular.forEach(grid.columns, function (item) {
  13770. if (item.enableFiltering) {
  13771. if (
  13772. angular.isDefined(item.filters[0].term) &&
  13773. item.filters[0].term != ""
  13774. ) {
  13775. if (angular.isUndefined(filtersData["requester"])) {
  13776. filtersData["requester"] = {};
  13777. }
  13778. filtersData["requester"][item.field] =
  13779. item.filters[0].term;
  13780. }
  13781. }
  13782. });
  13783. $scope.memoryfilterData = filtersData;
  13784. $scope.loadData(filtersData);
  13785. });
  13786. };
  13787. $scope.memoryfilterData = defaultFilterData = {
  13788. idx: 0,
  13789. sum: 10,
  13790. };
  13791. $scope.loadData = function (filterData) {
  13792. if (!filterData.requester) {
  13793. filterData.requester = {};
  13794. }
  13795. if (scope.roleidcode) {
  13796. angular.extend(filterData["requester"], {
  13797. userType: 1,
  13798. });
  13799. }
  13800. items
  13801. .fetchItems(filterData, APIService)
  13802. .then(function (data) {
  13803. var myData = Restangular.stripRestangular(data);
  13804. $scope.gridOptions.totalItems = myData.totalNum;
  13805. $scope.myData = myData.list;
  13806. });
  13807. };
  13808. // $scope.title = title;
  13809. if (searchDatas) {
  13810. $scope.loadData(searchDatas);
  13811. } else {
  13812. $scope.loadData({
  13813. idx: 0,
  13814. sum: 10,
  13815. });
  13816. }
  13817. $scope.selected = {
  13818. item: {},
  13819. };
  13820. $scope.ok = function () {
  13821. $modalInstance.close($scope.selected.item);
  13822. };
  13823. $scope.cancel = function () {
  13824. $modalInstance.dismiss("cancel");
  13825. };
  13826. },
  13827. size: size,
  13828. resolve: {
  13829. items: function () {
  13830. return {
  13831. fetchItems: function (filterData, APIService) {
  13832. filterData = filterData || {};
  13833. if (
  13834. angular.isUndefined(filterData.idx) ||
  13835. filterData.idx == null
  13836. ) {
  13837. filterData = {
  13838. idx: 0,
  13839. sum: 10,
  13840. };
  13841. }
  13842. return options.templateOptions.fetchItems(
  13843. filterData,
  13844. APIService
  13845. );
  13846. },
  13847. };
  13848. },
  13849. title: function () {
  13850. return options.templateOptions.modalTitle;
  13851. },
  13852. Restangular: function () {
  13853. return options.templateOptions.Restangular;
  13854. },
  13855. APIService: function () {
  13856. return options.templateOptions.ApiService;
  13857. },
  13858. language: function () {
  13859. return options.templateOptions.language;
  13860. },
  13861. searchDatas: function () {
  13862. return filterSearchData;
  13863. },
  13864. scope: function () {
  13865. return $scope;
  13866. },
  13867. },
  13868. });
  13869. modalInstance.result.then(
  13870. function (selectedItem) {
  13871. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  13872. selectedItem.telephone =
  13873. $scope.model.incident.contactsInformation;
  13874. }
  13875. $scope.$parent.$parent.$parent.model.incident["requester"] =
  13876. selectedItem;
  13877. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  13878. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  13879. if ($scope.model) {
  13880. if ($scope.model.incident.place) {
  13881. $scope.model.incident.place.id = "";
  13882. }
  13883. if ($scope.model.area) {
  13884. $scope.model.incident.area.id = "";
  13885. }
  13886. $scope.model.incident.contacts = selectedItem.name;
  13887. if (
  13888. selectedItem.mphone &&
  13889. selectedItem.mphone != null &&
  13890. selectedItem.mphone != ""
  13891. ) {
  13892. $scope.model.incident.contactsInformation =
  13893. selectedItem.mphone;
  13894. } else {
  13895. $scope.model.incident.contactsInformation =
  13896. selectedItem.telephone;
  13897. }
  13898. $scope.model.incident.houseNumber = "";
  13899. if (
  13900. selectedItem.requesterTypeDTO &&
  13901. selectedItem.requesterTypeDTO.id == 2
  13902. ) {
  13903. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13904. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13905. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13906. }
  13907. }
  13908. $scope.options.value(selectedItem);
  13909. $scope.searchData = selectedItem.account;
  13910. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  13911. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  13912. }
  13913. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  13914. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  13915. }
  13916. if (selectedItem.houseNumber) {
  13917. $scope.model.incident.houseNumber =
  13918. selectedItem.houseNumber;
  13919. }
  13920. if (
  13921. selectedItem.requesterTypeDTO &&
  13922. selectedItem.requesterTypeDTO.id == 2
  13923. ) {
  13924. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13925. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13926. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13927. }
  13928. if (
  13929. options.templateOptions.callback &&
  13930. angular.isFunction(options.templateOptions.callback)
  13931. ) {
  13932. options.templateOptions.callback(selectedItem, options);
  13933. }
  13934. if (!$scope.roleidcode) {
  13935. $scope.charging(selectedItem, modal);
  13936. }
  13937. $scope.recentlyincident(selectedItem);
  13938. },
  13939. function () {
  13940. //console.log('Modal dismissed at: ' + new Date());
  13941. }
  13942. );
  13943. };
  13944. searchModal();
  13945. // }
  13946. },
  13947. },
  13948. };
  13949. },
  13950. controller: [
  13951. "$rootScope",
  13952. "$scope",
  13953. "ngTableParams",
  13954. "$filter",
  13955. "SweetAlert",
  13956. "moment",
  13957. function (
  13958. $rootScope,
  13959. $scope,
  13960. ngTableParams,
  13961. $filter,
  13962. SweetAlert,
  13963. moment
  13964. ) {
  13965. $scope.roleidcode = true;
  13966. // $scope.options.initialValue = undefined;
  13967. if ($rootScope.user && $rootScope.user.role) {
  13968. angular.forEach($rootScope.user.role, function (item) {
  13969. if (item.rolecode == "call center") {
  13970. $scope.roleidcode = false;
  13971. }
  13972. });
  13973. }
  13974. $scope.recently = false;
  13975. $scope.recentlyincident = function (key, model) {
  13976. //关联事件
  13977. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  13978. idx: 0,
  13979. sum: 4,
  13980. incident: {
  13981. requester: {
  13982. id: key.id,
  13983. },
  13984. },
  13985. }).then(function (response) {
  13986. if (response.status == 200) {
  13987. $scope.recently = true;
  13988. $scope.recentincident = response.list;
  13989. } else {
  13990. $scope.recently = false;
  13991. }
  13992. });
  13993. $scope.bodyHeight = window.innerHeight - 100;
  13994. $(window).resize(function () {
  13995. $scope.bodyHeight = window.innerHeight - 100;
  13996. });
  13997. // $scope.shows = false;
  13998. $scope.tempData = {};
  13999. $scope.close = function () {
  14000. $scope.changes = !$scope.changes;
  14001. event.preventDefault();
  14002. };
  14003. };
  14004. $scope.charging = function (key, model) {
  14005. //计费弹出框
  14006. //用户信息
  14007. $scope.information = {};
  14008. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14009. userId: key.account,
  14010. }).then(function (response) {
  14011. // if (response.status == 200) {
  14012. if (response && response.data) {
  14013. angular.extend($scope.information, response.data[0]);
  14014. // $scope.information = response.data[0];
  14015. $scope.information.autologicDestroyTime = moment(
  14016. response.data[0].autologicDestroyTime
  14017. ).format("YYYY-MM-DD");
  14018. $scope.information.periodStartTime = moment(
  14019. response.data[0].periodStartTime
  14020. ).format("YYYY-MM-DD");
  14021. $scope.information.nextBillingTime = moment(
  14022. response.data[0].nextBillingTime
  14023. ).format("YYYY-MM-DD");
  14024. } else if (response.err) {
  14025. SweetAlert.swal(
  14026. "系统错误!",
  14027. "用户信息未取到,请刷新重试",
  14028. "error"
  14029. );
  14030. }
  14031. // }
  14032. });
  14033. //上网明细
  14034. $scope.options.templateOptions.ApiSer.fetchDataList(
  14035. "queryOnlineDetail",
  14036. {
  14037. userId: key.account,
  14038. limit: "10",
  14039. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14040. "YYYY-MM-DD HH:mm:ss"
  14041. ),
  14042. toLogoutTime: moment(new Date().getTime()).format(
  14043. "YYYY-MM-DD HH:mm:ss"
  14044. ),
  14045. }
  14046. ).then(function (response) {
  14047. // if (response.status == 200) {
  14048. if (response && response.data) {
  14049. angular.forEach(response.data, function (item, index) {
  14050. if (item.logoutTime) {
  14051. response.data[index].logoutTime = moment(
  14052. item.logoutTime
  14053. ).format("YYYY-MM-DD HH:mm:ss");
  14054. }
  14055. if (item.loginTime) {
  14056. response.data[index].loginTime = moment(
  14057. item.loginTime
  14058. ).format("YYYY-MM-DD HH:mm:ss");
  14059. }
  14060. });
  14061. $scope.logininform = response.data;
  14062. } else if (response.err) {
  14063. SweetAlert.swal(
  14064. "系统错误!",
  14065. "上网明细未取到,请刷新重试",
  14066. "error"
  14067. );
  14068. }
  14069. });
  14070. //黑名单
  14071. // $scope.information.blacklist = "否"
  14072. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14073. userId: key.account,
  14074. }).then(function (response) {
  14075. // if (response.status == 200) {
  14076. // $scope.logininformation = response.data;
  14077. if (response) {
  14078. if (response.data || response.data != null) {
  14079. $scope.information.blacklist = "是";
  14080. } else {
  14081. if (response.err) {
  14082. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14083. } else {
  14084. $scope.information.blacklist = "否";
  14085. }
  14086. }
  14087. }
  14088. // }
  14089. });
  14090. $scope.bodyHeight = window.innerHeight - 100;
  14091. $(window).resize(function () {
  14092. $scope.bodyHeight = window.innerHeight - 100;
  14093. });
  14094. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14095. // $scope.closepages = function(e) {
  14096. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14097. // event.preventDefault();
  14098. // };
  14099. // $scope.shows = false;
  14100. $scope.tempData = {};
  14101. $scope.close = function () {
  14102. $scope.changes = !$scope.changes;
  14103. event.preventDefault();
  14104. };
  14105. };
  14106. $scope.options.templateOptions.ApiService.fetchDataList(
  14107. "requesterType",
  14108. {
  14109. idx: 0,
  14110. sum: 100,
  14111. }
  14112. ).then(function (response) {
  14113. if (response.status == 200) {
  14114. $scope.networktypes = response.list;
  14115. } else {
  14116. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14117. }
  14118. });
  14119. function serchdata(searchKey) {
  14120. if (searchKey) {
  14121. var filterData = {
  14122. requester: {
  14123. searchKey: searchKey,
  14124. // 'userType': 1
  14125. },
  14126. idx: 0,
  14127. sum: 10,
  14128. };
  14129. } else {
  14130. var filterData = {
  14131. idx: 0,
  14132. requester: {},
  14133. sum: 10,
  14134. };
  14135. }
  14136. if (
  14137. $scope.model.requester &&
  14138. $scope.model.requester.requesterTypeDTO
  14139. ) {
  14140. angular.extend(filterData.requester, {
  14141. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14142. });
  14143. if (!$scope.options.model.contactsInformation) {
  14144. $scope.options.model.contactsInformation =
  14145. $scope.model.requester.mphone;
  14146. }
  14147. }
  14148. if ($scope.roleidcode) {
  14149. angular.extend(filterData["requester"], {
  14150. userType: 1,
  14151. });
  14152. }
  14153. $scope.options.templateOptions.ApiService.fetchDataList(
  14154. "requester",
  14155. filterData
  14156. ).then(function (response) {
  14157. var myData = response;
  14158. $scope.myData = myData.list;
  14159. });
  14160. }
  14161. $scope.searchData = {};
  14162. $scope.refreshUser = function (searchKey) {
  14163. //请求人搜索
  14164. if (searchKey && searchKey != "") {
  14165. serchdata(searchKey);
  14166. }
  14167. };
  14168. if (
  14169. $scope.$parent.$parent.$parent.model.incident.callID ||
  14170. $scope.$parent.$parent.$parent.model.requestershow
  14171. ) {
  14172. if (!$scope.roleidcode) {
  14173. $scope.charging(
  14174. $scope.$parent.$parent.$parent.model.incident.requester
  14175. );
  14176. }
  14177. $scope.recentlyincident(
  14178. $scope.$parent.$parent.$parent.model.incident.requester
  14179. );
  14180. }
  14181. $scope.onChange = function (searchData) {
  14182. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14183. searchData.telephone = $scope.model.incident.contactsInformation;
  14184. }
  14185. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14186. searchData;
  14187. if (!$scope.roleidcode) {
  14188. $scope.charging(searchData);
  14189. }
  14190. $scope.recentlyincident(searchData);
  14191. $scope.accountshow = false;
  14192. if ($scope.model.incident) {
  14193. if ($scope.model.incident.place) {
  14194. $scope.model.incident.place.id = "";
  14195. }
  14196. if ($scope.model.incident.area) {
  14197. $scope.model.incident.area.id = "";
  14198. }
  14199. $scope.model.incident.contacts = searchData.name;
  14200. if (
  14201. searchData.mphone &&
  14202. searchData.mphone != null &&
  14203. searchData.mphone != ""
  14204. ) {
  14205. $scope.model.incident.contactsInformation = searchData.mphone;
  14206. } else {
  14207. $scope.model.incident.contactsInformation = searchData.telephone;
  14208. }
  14209. $scope.model.incident.houseNumber = "";
  14210. if (
  14211. searchData.requesterTypeDTO &&
  14212. searchData.requesterTypeDTO.id == 2
  14213. ) {
  14214. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14215. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14216. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14217. }
  14218. }
  14219. $scope.options.value(searchData);
  14220. $scope.searchKey = searchData.account;
  14221. if (searchData.placeDTO && searchData.placeDTO.id) {
  14222. $scope.model.incident.place.id = searchData.placeDTO.id;
  14223. }
  14224. if (searchData.areaDTO && searchData.areaDTO.id) {
  14225. $scope.model.incident.area.id = searchData.areaDTO.id;
  14226. }
  14227. if (searchData.houseNumber) {
  14228. $scope.model.incident.houseNumber = searchData.houseNumber;
  14229. }
  14230. if (
  14231. searchData.requesterTypeDTO &&
  14232. searchData.requesterTypeDTO.id == 2
  14233. ) {
  14234. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14235. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14236. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14237. }
  14238. };
  14239. },
  14240. ],
  14241. });
  14242. //ui-grid-table展示控件
  14243. formlyConfigProvider.setType({
  14244. name: "ui-grid-table",
  14245. // extends: 'multiCheckbox',//去掉冒号
  14246. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  14247. defaultOptions: function (options) {
  14248. return {
  14249. templateOptions: {
  14250. linkage: function () {},
  14251. },
  14252. };
  14253. },
  14254. controller: function (
  14255. $scope,
  14256. $rootScope,
  14257. i18nService,
  14258. Restangular,
  14259. api_bpm_data,
  14260. api_statistic,
  14261. $rootScope
  14262. ) {
  14263. var loginUser = $rootScope.user;
  14264. $scope.langs = i18nService.getAllLangs();
  14265. $scope.lang = "zh-cn";
  14266. i18nService.setCurrentLang($scope.lang);
  14267. $scope.gridOptions = {};
  14268. $scope.gridOptions.data = "myData";
  14269. $scope.gridOptions.enableColumnResizing = true;
  14270. $scope.gridOptions.enableGridMenu = false;
  14271. $scope.gridOptions.enableRowSelection = true;
  14272. $scope.gridOptions.showGridFooter = false;
  14273. $scope.gridOptions.showColumnFooter = false;
  14274. $scope.gridOptions.fastWatch = true;
  14275. $scope.gridOptions.useExternalFiltering = true;
  14276. $scope.gridOptions.useExternalPagination = false;
  14277. $scope.gridOptions.paginationPageSizes = [10];
  14278. $scope.gridOptions.paginationPageSize = 3;
  14279. $scope.gridOptions.multiSelect = false;
  14280. $scope.gridOptions.rowIdentity = function (row) {
  14281. return row.id;
  14282. };
  14283. $scope.gridOptions.getRowIdentity = function (row) {
  14284. return row.id;
  14285. };
  14286. $scope.gridOptions.columnDefs = [
  14287. {
  14288. name: "item",
  14289. displayName: "序号",
  14290. width: 80,
  14291. enableFiltering: false,
  14292. },
  14293. {
  14294. name: "incidentsign",
  14295. displayName: "单号",
  14296. width: 80,
  14297. enableFiltering: false,
  14298. },
  14299. {
  14300. name: "description",
  14301. displayName: "主题",
  14302. width: 80,
  14303. enableFiltering: false,
  14304. },
  14305. {
  14306. name: "state.name",
  14307. displayName: "状态",
  14308. width: 110,
  14309. enableFiltering: false,
  14310. },
  14311. {
  14312. name: "acceptDate",
  14313. displayName: "创建时间",
  14314. width: 160,
  14315. enableFiltering: false,
  14316. },
  14317. {
  14318. name: "requester.name",
  14319. displayName: "请求人",
  14320. width: 80,
  14321. enableFiltering: false,
  14322. },
  14323. {
  14324. name: "handlingPersonnelUser.name",
  14325. displayName: "处理人",
  14326. width: 160,
  14327. enableFiltering: false,
  14328. },
  14329. {
  14330. name: "place.place",
  14331. displayName: "区域地点",
  14332. width: 160,
  14333. enableFiltering: false,
  14334. },
  14335. ];
  14336. // var defaultFilterData = {
  14337. // "idx": 0,
  14338. // "sum": 3
  14339. // };
  14340. // // //分页控制
  14341. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14342. gridApi.pagination.on.paginationChanged(
  14343. $scope,
  14344. function (newPage, pageSize) {
  14345. var filtersData = $scope.memoryfilterData;
  14346. filtersData.idx = newPage - 1;
  14347. filtersData.sum = pageSize;
  14348. $scope.refreshData("expand-right", filtersData);
  14349. }
  14350. );
  14351. // 表格单选事件
  14352. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  14353. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  14354. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  14355. data.entity;
  14356. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  14357. data.entity.id;
  14358. var str =
  14359. data.grid.appScope.$parent.$parent.$parent.model.incident
  14360. .description || "";
  14361. str = str.split("").reverse().join("");
  14362. var del = addstr.split("").reverse().join("");
  14363. // console.log(del);
  14364. var reg = new RegExp(del);
  14365. str = str.replace(reg, "");
  14366. str = str.split("").reverse().join("");
  14367. if (
  14368. data.grid.appScope.$parent.$parent.$parent.model.incident
  14369. .associationType == "事件补充"
  14370. ) {
  14371. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  14372. null;
  14373. str += data.entity.description;
  14374. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14375. data.entity.description;
  14376. } else if (
  14377. data.grid.appScope.$parent.$parent.$parent.model.incident
  14378. .associationType == "事件已解决"
  14379. ) {
  14380. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  14381. "close";
  14382. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14383. "";
  14384. }
  14385. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  14386. str;
  14387. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  14388. data.entity.id;
  14389. });
  14390. };
  14391. // 刷新表格
  14392. setInterval(function () {
  14393. // console.log($scope.myData);
  14394. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  14395. // console.log($scope.myData);
  14396. if ($scope.myData != null) {
  14397. for (var i = 0; i < $scope.myData.length; i++) {
  14398. //添加序号
  14399. $scope.myData[i]["item"] = i + 1;
  14400. }
  14401. }
  14402. }, 1000);
  14403. },
  14404. });
  14405. //处理人信息
  14406. formlyConfigProvider.setType({
  14407. name: "ui-userinformation",
  14408. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  14409. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14410. defaultOptions: function (options) {
  14411. return {
  14412. templateOptions: {},
  14413. };
  14414. },
  14415. controller: [
  14416. "$scope",
  14417. function ($scope) {
  14418. $scope.group = "";
  14419. $scope.role = "";
  14420. if (
  14421. angular.isDefined($scope.model.handlingPersonnelUser) &&
  14422. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14423. $scope.model.handlingPersonnelUser.group.length == 1
  14424. ) {
  14425. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14426. } else {
  14427. for (
  14428. var i = 0;
  14429. i < $scope.model.handlingPersonnelUser.group.length;
  14430. i++
  14431. ) {
  14432. $scope.group +=
  14433. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14434. }
  14435. }
  14436. if (
  14437. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  14438. $scope.model.handlingPersonnelUser.role.length == 1
  14439. ) {
  14440. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  14441. } else {
  14442. for (
  14443. var i = 0;
  14444. i < $scope.model.handlingPersonnelUser.role.length;
  14445. i++
  14446. ) {
  14447. $scope.role +=
  14448. $scope.model.handlingPersonnelUser.role[i].role + ",";
  14449. }
  14450. }
  14451. $scope.options.templateOptions.that = $scope;
  14452. },
  14453. ],
  14454. });
  14455. //处理界面处理人信息
  14456. formlyConfigProvider.setType({
  14457. name: "ui-handler",
  14458. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  14459. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14460. defaultOptions: function (options) {
  14461. return {
  14462. templateOptions: {},
  14463. };
  14464. },
  14465. controller: [
  14466. "$scope",
  14467. function ($scope) {
  14468. $scope.group = "";
  14469. // $scope.role="";
  14470. if (
  14471. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14472. $scope.model.handlingPersonnelUser.group.length == 1
  14473. ) {
  14474. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14475. } else {
  14476. for (
  14477. var i = 0;
  14478. i < $scope.model.handlingPersonnelUser.group.length;
  14479. i++
  14480. ) {
  14481. $scope.group +=
  14482. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14483. }
  14484. }
  14485. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  14486. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  14487. // }else{
  14488. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  14489. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  14490. // }
  14491. // }
  14492. $scope.options.templateOptions.that = $scope;
  14493. },
  14494. ],
  14495. });
  14496. //微信事件流程
  14497. formlyConfigProvider.setType({
  14498. name: "ui-wxIncidentProcess",
  14499. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  14500. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14501. defaultOptions: function (options) {
  14502. return {
  14503. templateOptions: {},
  14504. };
  14505. },
  14506. controller: [
  14507. "$scope",
  14508. function ($scope) {
  14509. console.log($scope.model);
  14510. $scope.pingjia = false;
  14511. $scope.jiejue = false;
  14512. if ($scope.model.incidentState.value == "3") {
  14513. $scope.pingjia = true;
  14514. } else if ($scope.model.incidentState.value == "4") {
  14515. $scope.jiejue = true;
  14516. }
  14517. },
  14518. ],
  14519. });
  14520. //打电话
  14521. formlyConfigProvider.setType({
  14522. name: "ui-inputcall",
  14523. extends: "input",
  14524. templateUrl: "assets/views/customform/tpl/inputcall.html",
  14525. defaultOptions: function (options) {
  14526. return {
  14527. templateOptions: {
  14528. transform: function (value) {},
  14529. },
  14530. };
  14531. },
  14532. controller: [
  14533. "$scope",
  14534. "$rootScope",
  14535. "api_text",
  14536. "SweetAlert",
  14537. function ($scope, $rootScope, api_text, SweetAlert) {
  14538. $scope.dialout = function (teleno) {
  14539. var gid = "@0";
  14540. var telephone = "9" + teleno;
  14541. $rootScope.callout = 2;
  14542. if ($rootScope.takes) {
  14543. api_text
  14544. .dialout($rootScope.takes, gid, telephone)
  14545. .then(function (data) {
  14546. if (data.errno == 0) {
  14547. $rootScope.status = 6;
  14548. }
  14549. });
  14550. } else {
  14551. SweetAlert.swal({
  14552. title: "呼叫失败",
  14553. text: "请先签入呼叫中心!",
  14554. type: "error",
  14555. confirmButtonColor: "#DD6B55",
  14556. });
  14557. }
  14558. };
  14559. $scope.options.templateOptions.that = $scope;
  14560. },
  14561. ],
  14562. });
  14563. //关闭界面处理人信息
  14564. formlyConfigProvider.setType({
  14565. name: "ui-closehandler",
  14566. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  14567. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14568. defaultOptions: function (options) {
  14569. return {
  14570. templateOptions: {},
  14571. };
  14572. },
  14573. controller: [
  14574. "$scope",
  14575. "$rootScope",
  14576. "api_text",
  14577. function ($scope, $rootScope, api_text) {
  14578. $scope.dialout = function (teleno) {
  14579. var gid = "@0";
  14580. var telephone = "9" + teleno;
  14581. api_text
  14582. .dialout($rootScope.takes, gid, telephone)
  14583. .then(function (data) {
  14584. if (data.errno == 0) {
  14585. $rootScope.status = 6;
  14586. }
  14587. });
  14588. };
  14589. $scope.options.templateOptions.that = $scope;
  14590. },
  14591. ],
  14592. });
  14593. //用户单选控件
  14594. formlyConfigProvider.setType({
  14595. name: "ui-userselect",
  14596. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  14597. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14598. defaultOptions: function (options) {
  14599. return {
  14600. templateOptions: {
  14601. openModal: function (size, options, modal) {
  14602. var modalInstance = modal.open({
  14603. templateUrl:
  14604. "assets/views/customform/tpl/checktable-modal-content.html",
  14605. controller: function (
  14606. $scope,
  14607. i18nService,
  14608. $modalInstance,
  14609. items,
  14610. title,
  14611. Restangular,
  14612. APIService,
  14613. onDataCallback,
  14614. parentScope
  14615. ) {
  14616. $scope.langs = i18nService.getAllLangs();
  14617. $scope.lang = "zh-cn";
  14618. i18nService.setCurrentLang($scope.lang);
  14619. $scope.gridOptions = {};
  14620. $scope.gridOptions.data = "myData";
  14621. $scope.gridOptions.enableColumnResizing = true;
  14622. $scope.gridOptions.enableFiltering = true;
  14623. $scope.gridOptions.enableGridMenu = false;
  14624. $scope.gridOptions.showGridFooter = true;
  14625. $scope.gridOptions.showColumnFooter = false;
  14626. $scope.gridOptions.fastWatch = true;
  14627. $scope.gridOptions.useExternalFiltering = true;
  14628. $scope.gridOptions.useExternalPagination = true;
  14629. $scope.gridOptions.paginationPageSizes = [10];
  14630. $scope.gridOptions.paginationPageSize = 10;
  14631. $scope.gridOptions.multiSelect = false;
  14632. $scope.gridOptions.rowIdentity = function (row) {
  14633. return row.id;
  14634. };
  14635. $scope.gridOptions.getRowIdentity = function (row) {
  14636. return row.id;
  14637. };
  14638. $scope.gridOptions.rowTemplate =
  14639. '<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>';
  14640. $scope.gridOptions.columnDefs = [
  14641. {
  14642. name: "account",
  14643. displayName: "人员编号",
  14644. width: 120,
  14645. },
  14646. {
  14647. name: "name",
  14648. displayName: "姓名",
  14649. width: 100,
  14650. cellTemplate:
  14651. "<div>" +
  14652. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  14653. "</div>",
  14654. },
  14655. // {
  14656. // name: 'gender.name',
  14657. // displayName: '性别',
  14658. // width: 80,
  14659. // enableFiltering: false
  14660. // },
  14661. {
  14662. name: "phone",
  14663. displayName: "电话",
  14664. width: 230,
  14665. enableFiltering: false,
  14666. },
  14667. {
  14668. name: "email",
  14669. displayName: "邮箱",
  14670. width: 180,
  14671. enableFiltering: false,
  14672. },
  14673. {
  14674. name: "dept.dept",
  14675. displayName: "科室",
  14676. width: 130,
  14677. enableFiltering: false,
  14678. },
  14679. {
  14680. name: "taskCount",
  14681. displayName: "处理中事件数",
  14682. enableFiltering: false,
  14683. },
  14684. ];
  14685. // $scope.selectButtonClick
  14686. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14687. $scope.gridApi = gridApi;
  14688. gridApi.pagination.on.paginationChanged(
  14689. $scope,
  14690. function (newPage, pageSize) {
  14691. var filtersData = $scope.memoryfilterData;
  14692. filtersData.idx = newPage - 1;
  14693. filtersData.sum = pageSize;
  14694. $scope.loadData(filtersData);
  14695. //console.log(pageSize);
  14696. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  14697. }
  14698. );
  14699. gridApi.selection.on.rowSelectionChanged(
  14700. $scope,
  14701. function (data) {
  14702. $scope.selected.items = data.entity;
  14703. //console.log(data);
  14704. }
  14705. );
  14706. gridApi.selection.on.rowSelectionChangedBatch(
  14707. $scope,
  14708. function (data) {
  14709. $scope.selected.items = data.entity;
  14710. //console.log(data);
  14711. }
  14712. );
  14713. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  14714. // // if (row.entity.age > 45) {
  14715. // row.grid.api.selection.selectRow(row.entity); // 选中行
  14716. // // }
  14717. // };
  14718. gridApi.core.on.filterChanged($scope, function () {
  14719. var grid = this.grid;
  14720. var filtersData = {
  14721. idx: 0,
  14722. sum: 10,
  14723. user: {
  14724. roledata: {
  14725. rolecode: "roleset",
  14726. },
  14727. selectType: "1",
  14728. },
  14729. };
  14730. angular.forEach(grid.columns, function (item) {
  14731. if (item.enableFiltering) {
  14732. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  14733. if (
  14734. angular.isDefined(item.filters[0].term) &&
  14735. item.filters[0].term != ""
  14736. ) {
  14737. if (angular.isUndefined(filtersData["user"])) {
  14738. filtersData["user"] = {};
  14739. }
  14740. filtersData["user"][item.field] =
  14741. item.filters[0].term;
  14742. }
  14743. }
  14744. });
  14745. $scope.memoryfilterData = filtersData;
  14746. $scope.loadData(filtersData);
  14747. });
  14748. };
  14749. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  14750. // if (row.entity.age > 45) {
  14751. // row.grid.api.selection.selectRow(row.entity); // 选中行
  14752. // }
  14753. // },
  14754. $scope.onDblClick = function (data, event) {
  14755. // $scope.selected.items = data.entity;
  14756. $scope.selectButtonClick(data, event);
  14757. };
  14758. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  14759. // $scope.selected.items = data.entity;
  14760. // })
  14761. // };
  14762. $scope.memoryfilterData = {
  14763. idx: 0,
  14764. sum: 10,
  14765. user: {
  14766. roledata: {
  14767. rolecode: "roleset",
  14768. },
  14769. selectType: "1",
  14770. },
  14771. };
  14772. $scope.loadData = function (filterData) {
  14773. // console.log("filtersData=111" + JSON.stringify(filterData))
  14774. items
  14775. .fetchItems(filterData, APIService)
  14776. .then(function (data) {
  14777. var myData = Restangular.stripRestangular(data);
  14778. $scope.gridOptions.totalItems = myData.totalNum;
  14779. $scope.myData = myData.list;
  14780. });
  14781. };
  14782. // $scope.title = title;
  14783. $scope.loadData({
  14784. idx: 0,
  14785. sum: 10,
  14786. user: {
  14787. roledata: {
  14788. rolecode: "roleset",
  14789. },
  14790. selectType: "1",
  14791. },
  14792. });
  14793. $scope.selected = {
  14794. items: {},
  14795. };
  14796. $scope.ok = function () {
  14797. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  14798. // onDataCallback($scope.selected.item, parentScope);
  14799. // }
  14800. $modalInstance.close($scope.selected.items);
  14801. };
  14802. $scope.cancel = function () {
  14803. $modalInstance.dismiss("cancel");
  14804. };
  14805. },
  14806. size: size,
  14807. resolve: {
  14808. items: function () {
  14809. return {
  14810. fetchItems: function (filterData, APIService) {
  14811. filterData = filterData || {};
  14812. if (
  14813. angular.isDefined(filterData.idx) &&
  14814. filterData.idx == null
  14815. ) {
  14816. filterData = {
  14817. idx: 0,
  14818. sum: 10,
  14819. user: {
  14820. roledata: {
  14821. rolecode: "roleset",
  14822. },
  14823. selectType: "1",
  14824. },
  14825. };
  14826. }
  14827. return options.templateOptions.fetchItems(
  14828. filterData,
  14829. APIService
  14830. );
  14831. },
  14832. };
  14833. },
  14834. title: function () {
  14835. return options.templateOptions.label;
  14836. },
  14837. Restangular: function () {
  14838. return options.templateOptions.Restangular;
  14839. },
  14840. APIService: function () {
  14841. return options.templateOptions.ApiService;
  14842. },
  14843. onDataCallback: function () {
  14844. return options.templateOptions.callback;
  14845. },
  14846. parentScope: function () {
  14847. return options.templateOptions.that;
  14848. },
  14849. },
  14850. });
  14851. modalInstance.result.then(
  14852. function (selectedItem) {
  14853. // console.log(selectedItem);
  14854. options.value(selectedItem);
  14855. if (
  14856. options.templateOptions.callback &&
  14857. angular.isFunction(options.templateOptions.callback)
  14858. ) {
  14859. options.templateOptions.callback(
  14860. selectedItem,
  14861. options.templateOptions.that
  14862. );
  14863. }
  14864. if (
  14865. options.templateOptions.linkData &&
  14866. angular.isFunction(options.templateOptions.linkData)
  14867. ) {
  14868. options.templateOptions.linkData(
  14869. selectedItem,
  14870. options.templateOptions.that
  14871. );
  14872. }
  14873. },
  14874. function () {
  14875. //console.log('Modal dismissed at: ' + new Date());
  14876. }
  14877. );
  14878. },
  14879. },
  14880. };
  14881. },
  14882. controller: [
  14883. "$scope",
  14884. function ($scope) {
  14885. $scope.options.templateOptions.that = $scope;
  14886. // $scope.options.model[$scope.options.key] = {}
  14887. },
  14888. ],
  14889. });
  14890. //用户单选控件(dd 单选input带搜索)
  14891. formlyConfigProvider.setType({
  14892. name: "ui-userselectSearch",
  14893. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  14894. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14895. defaultOptions: function (options) {
  14896. return {
  14897. templateOptions: {
  14898. openModal: function (size, options, modal) {
  14899. var modalInstance = modal.open({
  14900. templateUrl:
  14901. "assets/views/customform/tpl/checktable-modal-content.html",
  14902. controller: function (
  14903. $scope,
  14904. i18nService,
  14905. $modalInstance,
  14906. items,
  14907. title,
  14908. Restangular,
  14909. APIService,
  14910. onDataCallback,
  14911. parentScope
  14912. ) {
  14913. $scope.langs = i18nService.getAllLangs();
  14914. $scope.lang = "zh-cn";
  14915. i18nService.setCurrentLang($scope.lang);
  14916. $scope.gridOptions = {};
  14917. $scope.gridOptions.data = "myData";
  14918. $scope.gridOptions.enableColumnResizing = true;
  14919. $scope.gridOptions.enableFiltering = true;
  14920. $scope.gridOptions.enableGridMenu = false;
  14921. $scope.gridOptions.showGridFooter = true;
  14922. $scope.gridOptions.showColumnFooter = false;
  14923. $scope.gridOptions.fastWatch = true;
  14924. $scope.gridOptions.useExternalFiltering = true;
  14925. $scope.gridOptions.useExternalPagination = true;
  14926. $scope.gridOptions.paginationPageSizes = [10];
  14927. $scope.gridOptions.paginationPageSize = 10;
  14928. $scope.gridOptions.multiSelect = false;
  14929. $scope.gridOptions.rowIdentity = function (row) {
  14930. return row.id;
  14931. };
  14932. $scope.gridOptions.getRowIdentity = function (row) {
  14933. return row.id;
  14934. };
  14935. $scope.gridOptions.rowTemplate =
  14936. '<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>';
  14937. $scope.gridOptions.columnDefs = [
  14938. {
  14939. name: "account",
  14940. displayName: "人员编号",
  14941. width: 120,
  14942. },
  14943. {
  14944. name: "name",
  14945. displayName: "姓名",
  14946. width: 100,
  14947. cellTemplate:
  14948. "<div>" +
  14949. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  14950. "</div>",
  14951. },
  14952. // {
  14953. // name: 'gender.name',
  14954. // displayName: '性别',
  14955. // width: 80,
  14956. // enableFiltering: false
  14957. // },
  14958. {
  14959. name: "phone",
  14960. displayName: "电话",
  14961. width: 230,
  14962. enableFiltering: false,
  14963. },
  14964. {
  14965. name: "email",
  14966. displayName: "邮箱",
  14967. width: 180,
  14968. enableFiltering: false,
  14969. },
  14970. {
  14971. name: "dept.dept",
  14972. displayName: "科室",
  14973. width: 130,
  14974. enableFiltering: false,
  14975. },
  14976. {
  14977. name: "taskCount",
  14978. displayName: "处理中事件数",
  14979. enableFiltering: false,
  14980. },
  14981. ];
  14982. // $scope.selectButtonClick
  14983. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14984. $scope.gridApi = gridApi;
  14985. gridApi.pagination.on.paginationChanged(
  14986. $scope,
  14987. function (newPage, pageSize) {
  14988. var filtersData = $scope.memoryfilterData;
  14989. filtersData.idx = newPage - 1;
  14990. filtersData.sum = pageSize;
  14991. $scope.loadData(filtersData);
  14992. //console.log(pageSize);
  14993. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  14994. }
  14995. );
  14996. gridApi.selection.on.rowSelectionChanged(
  14997. $scope,
  14998. function (data) {
  14999. $scope.selected.items = data.entity;
  15000. //console.log(data);
  15001. }
  15002. );
  15003. gridApi.selection.on.rowSelectionChangedBatch(
  15004. $scope,
  15005. function (data) {
  15006. $scope.selected.items = data.entity;
  15007. //console.log(data);
  15008. }
  15009. );
  15010. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15011. // // if (row.entity.age > 45) {
  15012. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15013. // // }
  15014. // };
  15015. gridApi.core.on.filterChanged($scope, function () {
  15016. var grid = this.grid;
  15017. var filtersData = {
  15018. idx: 0,
  15019. sum: 10,
  15020. user: {
  15021. roledata: {
  15022. rolecode: "first-line support",
  15023. },
  15024. selectType: "1",
  15025. },
  15026. };
  15027. angular.forEach(grid.columns, function (item) {
  15028. if (item.enableFiltering) {
  15029. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15030. if (
  15031. angular.isDefined(item.filters[0].term) &&
  15032. item.filters[0].term != ""
  15033. ) {
  15034. if (angular.isUndefined(filtersData["user"])) {
  15035. filtersData["user"] = {};
  15036. }
  15037. filtersData["user"][item.field] =
  15038. item.filters[0].term;
  15039. }
  15040. }
  15041. });
  15042. $scope.memoryfilterData = filtersData;
  15043. $scope.loadData(filtersData);
  15044. });
  15045. };
  15046. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15047. // if (row.entity.age > 45) {
  15048. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15049. // }
  15050. // },
  15051. $scope.onDblClick = function (data, event) {
  15052. // $scope.selected.items = data.entity;
  15053. $scope.selectButtonClick(data, event);
  15054. };
  15055. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15056. // $scope.selected.items = data.entity;
  15057. // })
  15058. // };
  15059. $scope.memoryfilterData = {
  15060. idx: 0,
  15061. sum: 10,
  15062. user: {
  15063. roledata: {
  15064. rolecode: "first-line support",
  15065. },
  15066. selectType: "1",
  15067. },
  15068. };
  15069. $scope.loadData = function (filterData) {
  15070. // console.log("filtersData=111" + JSON.stringify(filterData))
  15071. items
  15072. .fetchItems(filterData, APIService)
  15073. .then(function (data) {
  15074. var myData = Restangular.stripRestangular(data);
  15075. $scope.gridOptions.totalItems = myData.totalNum;
  15076. $scope.myData = myData.list;
  15077. });
  15078. };
  15079. $scope.title = title;
  15080. $scope.loadData({
  15081. idx: 0,
  15082. sum: 10,
  15083. user: {
  15084. roledata: {
  15085. rolecode: "first-line support",
  15086. },
  15087. selectType: "1",
  15088. },
  15089. });
  15090. $scope.selected = {
  15091. items: {},
  15092. };
  15093. $scope.ok = function () {
  15094. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15095. // onDataCallback($scope.selected.item, parentScope);
  15096. // }
  15097. $modalInstance.close($scope.selected.items);
  15098. };
  15099. $scope.cancel = function () {
  15100. $modalInstance.dismiss("cancel");
  15101. };
  15102. },
  15103. size: size,
  15104. resolve: {
  15105. items: function () {
  15106. return {
  15107. fetchItems: function (filterData, APIService) {
  15108. filterData = filterData || {};
  15109. if (
  15110. angular.isDefined(filterData.idx) &&
  15111. filterData.idx == null
  15112. ) {
  15113. filterData = {
  15114. idx: 0,
  15115. sum: 10,
  15116. user: {
  15117. roledata: {
  15118. rolecode: "first-line support",
  15119. },
  15120. selectType: "1",
  15121. },
  15122. };
  15123. }
  15124. return options.templateOptions.fetchItems(
  15125. filterData,
  15126. APIService
  15127. );
  15128. },
  15129. };
  15130. },
  15131. title: function () {
  15132. return options.templateOptions.label;
  15133. },
  15134. Restangular: function () {
  15135. return options.templateOptions.Restangular;
  15136. },
  15137. APIService: function () {
  15138. return options.templateOptions.ApiService;
  15139. },
  15140. onDataCallback: function () {
  15141. return options.templateOptions.callback;
  15142. },
  15143. parentScope: function () {
  15144. return options.templateOptions.that;
  15145. },
  15146. },
  15147. });
  15148. modalInstance.result.then(
  15149. function (selectedItem) {
  15150. // console.log(selectedItem);
  15151. options.value(selectedItem);
  15152. if (
  15153. options.templateOptions.callback &&
  15154. angular.isFunction(options.templateOptions.callback)
  15155. ) {
  15156. options.templateOptions.callback(
  15157. selectedItem,
  15158. options.templateOptions.that
  15159. );
  15160. }
  15161. if (
  15162. options.templateOptions.linkData &&
  15163. angular.isFunction(options.templateOptions.linkData)
  15164. ) {
  15165. options.templateOptions.linkData(
  15166. selectedItem,
  15167. options.templateOptions.that
  15168. );
  15169. }
  15170. },
  15171. function () {
  15172. //console.log('Modal dismissed at: ' + new Date());
  15173. }
  15174. );
  15175. },
  15176. },
  15177. };
  15178. },
  15179. controller: [
  15180. "$scope",
  15181. function ($scope) {
  15182. $scope.options.templateOptions.that = $scope;
  15183. },
  15184. ],
  15185. });
  15186. //用户多选控件
  15187. formlyConfigProvider.setType({
  15188. name: "ui-multiuserselect",
  15189. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  15190. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15191. defaultOptions: function (options) {
  15192. return {
  15193. templateOptions: {
  15194. openModal: function (size, options, modal, model) {
  15195. var modalInstance = modal.open({
  15196. templateUrl:
  15197. "assets/views/customform/tpl/checktable-modal-content.html",
  15198. controller: function (
  15199. $scope,
  15200. $modalInstance,
  15201. i18nService,
  15202. $timeout,
  15203. items,
  15204. title,
  15205. Restangular,
  15206. APIService,
  15207. selectItems
  15208. ) {
  15209. $scope.langs = i18nService.getAllLangs();
  15210. $scope.lang = "zh-cn";
  15211. i18nService.setCurrentLang($scope.lang);
  15212. $scope.gridOptions = {};
  15213. $scope.gridOptions.data = "myData";
  15214. $scope.gridOptions.enableColumnResizing = true;
  15215. $scope.gridOptions.enableFiltering = true;
  15216. $scope.gridOptions.enableGridMenu = true;
  15217. $scope.gridOptions.showGridFooter = true;
  15218. $scope.gridOptions.showColumnFooter = true;
  15219. $scope.gridOptions.fastWatch = true;
  15220. $scope.gridOptions.useExternalFiltering = true;
  15221. $scope.gridOptions.useExternalPagination = true;
  15222. $scope.gridOptions.paginationPageSizes = [10];
  15223. $scope.gridOptions.paginationPageSize = 10;
  15224. $scope.gridOptions.multiSelect = true;
  15225. $scope.gridOptions.rowIdentity = function (row) {
  15226. return row.id;
  15227. };
  15228. $scope.gridOptions.getRowIdentity = function (row) {
  15229. return row.id;
  15230. };
  15231. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  15232. $scope.gridOptions.columnDefs = [
  15233. // { name:'id', width:80, enableFiltering:false},
  15234. {
  15235. name: "account",
  15236. displayName: "账号",
  15237. width: 140,
  15238. },
  15239. {
  15240. name: "name",
  15241. displayName: "名称",
  15242. width: 100,
  15243. },
  15244. {
  15245. name: "gender.name",
  15246. displayName: "性别",
  15247. width: 140,
  15248. enableFiltering: false,
  15249. },
  15250. {
  15251. name: "phone",
  15252. displayName: "电话",
  15253. width: 100,
  15254. enableFiltering: false,
  15255. },
  15256. {
  15257. name: "email",
  15258. displayName: "邮件",
  15259. width: 100,
  15260. enableFiltering: false,
  15261. },
  15262. {
  15263. name: "dept.dept",
  15264. displayName: "科室",
  15265. width: 100,
  15266. enableFiltering: false,
  15267. },
  15268. {
  15269. name: "group[0].groupName",
  15270. displayName: "职位",
  15271. width: 100,
  15272. enableFiltering: false,
  15273. },
  15274. ];
  15275. $scope.selected = {
  15276. items: selectItems,
  15277. };
  15278. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15279. $scope.gridApi = gridApi;
  15280. gridApi.pagination.on.paginationChanged(
  15281. $scope,
  15282. function (newPage, pageSize) {
  15283. var filtersData = $scope.memoryfilterData;
  15284. filtersData.idx = newPage - 1;
  15285. filtersData.sum = pageSize;
  15286. $scope.loadData(filtersData);
  15287. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15288. }
  15289. );
  15290. gridApi.selection.on.rowSelectionChanged(
  15291. $scope,
  15292. function (scope) {
  15293. var j = 0;
  15294. for (
  15295. var i = 0;
  15296. i <= scope.grid.appScope.selected.items.length;
  15297. i++
  15298. ) {
  15299. if (
  15300. scope.grid.appScope.selected.items[i] == scope.entity
  15301. ) {
  15302. j++;
  15303. break;
  15304. }
  15305. }
  15306. if (j == 1) {
  15307. scope.grid.appScope.selected.items.splice(i, 1);
  15308. } else {
  15309. scope.grid.appScope.selected.items.push(scope.entity);
  15310. for (
  15311. var i = 0;
  15312. i < scope.grid.appScope.selected.items.length;
  15313. i++
  15314. ) {
  15315. for (
  15316. var z = 0;
  15317. z < scope.grid.appScope.selected.items.length;
  15318. z++
  15319. ) {
  15320. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  15321. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  15322. if (
  15323. angular.isDefined(
  15324. scope.grid.appScope.selected.items
  15325. ) &&
  15326. scope.grid.appScope.selected.items[i].id ==
  15327. scope.grid.appScope.selected.items[z].id &&
  15328. i != z
  15329. ) {
  15330. scope.grid.appScope.selected.items.splice(i, 1);
  15331. }
  15332. }
  15333. }
  15334. }
  15335. }
  15336. );
  15337. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  15338. // $scope.grid.appScope.selected.items.push($scope.entity);
  15339. // });
  15340. gridApi.core.on.filterChanged($scope, function () {
  15341. var grid = this.grid;
  15342. var filtersData = {
  15343. idx: 0,
  15344. sum: 10,
  15345. user: {
  15346. roledata: {
  15347. rolecode: options.model.currentRole,
  15348. },
  15349. selectType: "1",
  15350. },
  15351. };
  15352. angular.forEach(grid.columns, function (item) {
  15353. if (item.enableFiltering) {
  15354. //console.log("filtersData="+JSON.stringify(filtersData))
  15355. if (
  15356. angular.isDefined(item.filters[0].term) &&
  15357. item.filters[0].term != ""
  15358. ) {
  15359. if (angular.isUndefined(filtersData["user"])) {
  15360. filtersData["user"] = {};
  15361. }
  15362. filtersData["user"][item.field] =
  15363. item.filters[0].term;
  15364. }
  15365. }
  15366. });
  15367. $scope.memoryfilterData = filtersData;
  15368. $scope.loadData(filtersData);
  15369. });
  15370. };
  15371. if (!options.model) {
  15372. var mouse = {
  15373. model: {
  15374. currentRole: "",
  15375. },
  15376. };
  15377. angular.extend(options, mouse);
  15378. }
  15379. $scope.memoryfilterData = {
  15380. idx: 0,
  15381. sum: 10,
  15382. user: {
  15383. roledata: {
  15384. rolecode: options.model.currentRole,
  15385. },
  15386. selectType: "1",
  15387. },
  15388. };
  15389. $scope.loadData = function (filterData) {
  15390. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  15391. items
  15392. .fetchItems(filterData, APIService)
  15393. .then(function (data) {
  15394. var myData = Restangular.stripRestangular(data);
  15395. $scope.gridOptions.totalItems = myData.totalNum;
  15396. $scope.myData = myData.list;
  15397. //console.log($scope.gridOptions.pagination.getTotalPages());
  15398. // if($scope.selected.items){
  15399. // angular.forEach($scope.selected.items,function(selectItem){
  15400. // $scope.gridApi.selection.selectRow(selectItem);
  15401. // });
  15402. // }
  15403. });
  15404. };
  15405. // $scope.title = title;
  15406. $scope.loadData({
  15407. idx: 0,
  15408. sum: 10,
  15409. user: {
  15410. roledata: {
  15411. rolecode: options.model.currentRole,
  15412. },
  15413. selectType: "1",
  15414. },
  15415. });
  15416. // $timeout(function(){
  15417. // if($scope.selected.items){
  15418. // angular.forEach($scope.selected.items,function(selectItem){
  15419. // $scope.gridApi.selection.selectRow(selectItem);
  15420. // });
  15421. // }
  15422. // },2000)
  15423. $scope.ok = function () {
  15424. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  15425. $modalInstance.close($scope.selected.items);
  15426. };
  15427. $scope.cancel = function () {
  15428. $modalInstance.dismiss("cancel");
  15429. };
  15430. },
  15431. size: size,
  15432. resolve: {
  15433. items: function () {
  15434. return {
  15435. fetchItems: function (filterData, APIService) {
  15436. filterData = filterData || {};
  15437. if (
  15438. angular.isDefined(filterData.idx) &&
  15439. filterData.idx == null
  15440. ) {
  15441. filterData = {
  15442. idx: 0,
  15443. sum: 10,
  15444. user: {
  15445. roledata: {
  15446. rolecode: options.model.incident.currentRole,
  15447. },
  15448. selectType: "1",
  15449. },
  15450. };
  15451. }
  15452. return options.templateOptions.fetchItems(
  15453. filterData,
  15454. APIService
  15455. );
  15456. },
  15457. };
  15458. },
  15459. title: function () {
  15460. return options.templateOptions.modalTitle;
  15461. },
  15462. Restangular: function () {
  15463. return options.templateOptions.Restangular;
  15464. },
  15465. APIService: function () {
  15466. return options.templateOptions.ApiService;
  15467. },
  15468. selectItems: function () {
  15469. return model || [];
  15470. },
  15471. },
  15472. });
  15473. modalInstance.result.then(
  15474. function (selectedItem) {
  15475. options.value(selectedItem);
  15476. options.formControl.$validate();
  15477. },
  15478. function () {
  15479. //console.log('Modal dismissed at: ' + new Date());
  15480. }
  15481. );
  15482. },
  15483. },
  15484. validators: {
  15485. required: {
  15486. expression: function (viewValue, modelValue) {
  15487. var value = modelValue || viewValue;
  15488. return value.length >= 1;
  15489. },
  15490. },
  15491. },
  15492. };
  15493. },
  15494. controller: [
  15495. "$scope",
  15496. function ($scope) {
  15497. $scope.model[$scope.options.key] = [];
  15498. $scope.remove = function (itemId) {
  15499. angular.forEach(
  15500. $scope.model[$scope.options.key],
  15501. function (entry, index) {
  15502. if (entry.id == itemId) {
  15503. $scope.model[$scope.options.key].splice(index, 1);
  15504. // console.log($scope.options.formControl)
  15505. $scope.options.formControl.$validate();
  15506. } else {
  15507. }
  15508. }
  15509. );
  15510. };
  15511. },
  15512. ],
  15513. });
  15514. //用户多选控件-字符串展示
  15515. formlyConfigProvider.setType({
  15516. name: "ui-stringuserselect",
  15517. extends: "input",
  15518. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  15519. defaultOptions: function (options) {
  15520. return {
  15521. templateOptions: {
  15522. translate: "",
  15523. refreshDelay: 0,
  15524. },
  15525. };
  15526. },
  15527. controller: [
  15528. "$scope",
  15529. function ($scope) {
  15530. var keydata = "";
  15531. if (angular.isArray($scope.model)) {
  15532. angular.forEach($scope.model, function (item) {
  15533. keydata = keydata + "," + item.name;
  15534. });
  15535. }
  15536. // $scope.model[$scope.options.key] = [];
  15537. },
  15538. ],
  15539. });
  15540. //重复事件
  15541. formlyConfigProvider.setType({
  15542. name: "ui-incidentmodelselect",
  15543. extends: "input",
  15544. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  15545. defaultOptions: function (options) {
  15546. return {
  15547. templateOptions: {
  15548. openModal: function (size, options, modal) {
  15549. var modalInstance = modal.open({
  15550. templateUrl:
  15551. "assets/views/customform/tpl/checktable-modal-content.html",
  15552. controller: function (
  15553. $scope,
  15554. $rootScope,
  15555. $modalInstance,
  15556. items,
  15557. title,
  15558. Restangular,
  15559. APIService,
  15560. i18nService,
  15561. api_configure_data,
  15562. api_user_data,
  15563. api_bpm_data
  15564. ) {
  15565. $scope.langs = i18nService.getAllLangs();
  15566. $scope.lang = "zh-cn";
  15567. i18nService.setCurrentLang($scope.lang);
  15568. $scope.gridOptions = {};
  15569. $scope.gridOptions.data = "myData";
  15570. $scope.gridOptions.enableColumnResizing = true;
  15571. $scope.gridOptions.enableFiltering = true;
  15572. $scope.gridOptions.enableGridMenu = false;
  15573. $scope.gridOptions.enableRowSelection = true;
  15574. $scope.gridOptions.showGridFooter = true;
  15575. $scope.gridOptions.showColumnFooter = false;
  15576. $scope.gridOptions.fastWatch = true;
  15577. $scope.gridOptions.useExternalFiltering = true;
  15578. $scope.gridOptions.useExternalPagination = true;
  15579. $scope.gridOptions.paginationPageSizes = [10];
  15580. $scope.gridOptions.paginationPageSize = 10;
  15581. $scope.gridOptions.multiSelect = false;
  15582. var mun = $scope.gridOptions.paginationPageSize;
  15583. $scope.gridOptions.rowIdentity = function (row) {
  15584. return row.id;
  15585. };
  15586. $scope.gridOptions.getRowIdentity = function (row) {
  15587. return row.id;
  15588. };
  15589. $scope.gridOptions.columnDefs = items.columnDefs();
  15590. $scope.transferTime = function (time) {
  15591. return moment(time).format("YYYY-MM-DD HH:mm");
  15592. };
  15593. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15594. $scope.gridApi = gridApi;
  15595. gridApi.pagination.on.paginationChanged(
  15596. $scope,
  15597. function (newPage, pageSize) {
  15598. // console.log(newPage);
  15599. // console.log(pageSize);
  15600. $scope.loadData({
  15601. idx: newPage - 1,
  15602. sum: pageSize,
  15603. });
  15604. }
  15605. );
  15606. gridApi.core.on.filterChanged($scope, function () {
  15607. var grid = this.grid;
  15608. var filtersData = {
  15609. idx: 0,
  15610. sum: 100,
  15611. };
  15612. angular.forEach(grid.columns, function (item) {
  15613. if (item.enableFiltering) {
  15614. if (
  15615. angular.isDefined(item.filters[0].term) &&
  15616. item.filters[0].term != ""
  15617. ) {
  15618. // console.log("filtersData="+JSON.stringify(filtersData))
  15619. if (angular.isUndefined(filtersData["incident"])) {
  15620. filtersData["incident"] = {};
  15621. }
  15622. filtersData["incident"][item.field] =
  15623. item.filters[0].term;
  15624. if (angular.isUndefined(filtersData["problem"])) {
  15625. filtersData["problem"] = {};
  15626. }
  15627. filtersData["problem"][item.field] =
  15628. item.filters[0].term;
  15629. if (angular.isUndefined(filtersData["change"])) {
  15630. filtersData["change"] = {};
  15631. }
  15632. filtersData["change"][item.field] =
  15633. item.filters[0].term;
  15634. if (angular.isUndefined(filtersData["release"])) {
  15635. filtersData["release"] = {};
  15636. }
  15637. filtersData["release"][item.field] =
  15638. item.filters[0].term;
  15639. }
  15640. }
  15641. });
  15642. $scope.loadData(filtersData);
  15643. });
  15644. gridApi.selection.on.rowSelectionChanged(
  15645. $scope,
  15646. function (data) {
  15647. $scope.selected.item = data.entity;
  15648. //console.log(data);
  15649. }
  15650. );
  15651. };
  15652. //资产
  15653. $scope.cmdb = {};
  15654. //资产状态
  15655. $scope.state_data = [
  15656. {
  15657. name: "全部状态",
  15658. value: "",
  15659. },
  15660. {
  15661. name: "在库",
  15662. value: "1",
  15663. },
  15664. {
  15665. name: "在线",
  15666. value: "2",
  15667. },
  15668. {
  15669. name: "借出",
  15670. value: "3",
  15671. },
  15672. {
  15673. name: "报修",
  15674. value: "4",
  15675. },
  15676. {
  15677. name: "报废",
  15678. value: "5",
  15679. },
  15680. {
  15681. name: "备用",
  15682. value: "6",
  15683. },
  15684. ];
  15685. //资产类型
  15686. $scope.wt_zcfl = function () {
  15687. api_configure_data
  15688. .fetchDataList("ciclassify", {
  15689. idx: 0,
  15690. sum: 100,
  15691. })
  15692. .then(function (data) {
  15693. console.log(data);
  15694. // $scope.wt_zclx = data.list;
  15695. console.log(data);
  15696. $scope.wtData = [];
  15697. if (data.status == 200) {
  15698. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  15699. var root = null; //Initially set our loop to null
  15700. var parentNode = null;
  15701. //loop over data
  15702. // $scope.wtData=data.list;
  15703. data = data.list;
  15704. //知识库分类数据三级处理
  15705. for (var i = 0; i < data.length; i++) {
  15706. // console.log(data[i])
  15707. var datum = data[i];
  15708. //each node will have children, so let's give it a "children" poperty
  15709. // console.log(datum);
  15710. datum.children = [];
  15711. if (!datum.parent) {
  15712. $scope.wtData.push(datum);
  15713. // console.log($scope.wtData)
  15714. } else {
  15715. if ($scope.wtData[0]) {
  15716. if ($scope.wtData[0].id == datum.parent.id) {
  15717. $scope.wtData[0].children.push(datum);
  15718. }
  15719. for (
  15720. var j = 0;
  15721. j < $scope.wtData[0].children.length;
  15722. j++
  15723. ) {
  15724. if (
  15725. $scope.wtData[0].children[j].id ==
  15726. datum.parent.id
  15727. ) {
  15728. $scope.wtData[0].children[j].children.push(
  15729. datum
  15730. );
  15731. }
  15732. }
  15733. }
  15734. if ($scope.wtData[1]) {
  15735. if ($scope.wtData[1].id == datum.parent.id) {
  15736. $scope.wtData[1].children.push(datum);
  15737. }
  15738. for (
  15739. var j = 0;
  15740. j < $scope.wtData[1].children.length;
  15741. j++
  15742. ) {
  15743. if (
  15744. $scope.wtData[1].children[j].id ==
  15745. datum.parent.id
  15746. ) {
  15747. $scope.wtData[1].children[j].children.push(
  15748. datum
  15749. );
  15750. }
  15751. }
  15752. }
  15753. if ($scope.wtData[2]) {
  15754. if ($scope.wtData[2].id == datum.parent.id) {
  15755. $scope.wtData[2].children.push(datum);
  15756. }
  15757. for (
  15758. var j = 0;
  15759. j < $scope.wtData[2].children.length;
  15760. j++
  15761. ) {
  15762. if (
  15763. $scope.wtData[2].children[j].id ==
  15764. datum.parent.id
  15765. ) {
  15766. $scope.wtData[2].children[j].children.push(
  15767. datum
  15768. );
  15769. }
  15770. }
  15771. }
  15772. }
  15773. // console.log($scope.wtData)
  15774. idToNodeMap[datum.id] = datum;
  15775. root = datum;
  15776. // treeMap[datum.id] = root;
  15777. }
  15778. }
  15779. });
  15780. };
  15781. $scope.wt_zcfl();
  15782. //事件
  15783. //受理人,处理人
  15784. $scope.searchkeys = {};
  15785. var fieldata = {
  15786. idx: 0,
  15787. sum: 100,
  15788. flag: -1,
  15789. };
  15790. getUser(fieldata, 3);
  15791. function getUser(fieldatas, it) {
  15792. api_user_data
  15793. .fetchDataList("user", fieldatas)
  15794. .then(function (data) {
  15795. if (it == 1) {
  15796. $scope.acceptUser = data.list;
  15797. } else if (it == 2) {
  15798. $scope.handlingPersonnelUser = data.list;
  15799. } else if (it == 3) {
  15800. $scope.acceptUser = data.list;
  15801. $scope.handlingPersonnelUser = data.list;
  15802. }
  15803. });
  15804. }
  15805. //状态
  15806. $scope.othcode = {};
  15807. api_bpm_data
  15808. .fetchDataList("incidentstatus", {
  15809. idx: 0,
  15810. sum: 100,
  15811. })
  15812. .then(function (response) {
  15813. if (response) {
  15814. if ((response.status = 200)) {
  15815. $scope.state = response.list;
  15816. }
  15817. }
  15818. });
  15819. var defaultFilterData = {
  15820. assignee: $rootScope.user.id,
  15821. searchType: "todo",
  15822. idx: 0,
  15823. sum: mun,
  15824. };
  15825. var defaultFilterData1 = {
  15826. // "searchType": "todo",
  15827. idx: 0,
  15828. sum: mun,
  15829. };
  15830. //搜索
  15831. $scope.chiceIncident = function (parameters, item, stateid) {
  15832. console.log(item, stateid);
  15833. console.log($scope);
  15834. if ($scope.title == "关联资产编号") {
  15835. // alert('222222222222');
  15836. var fildata = defaultFilterData1;
  15837. $scope.gridOptions.paginationCurrentPage = 1;
  15838. var transitiondata = angular.copy(item);
  15839. angular.extend(fildata, transitiondata);
  15840. if (fildata.hw_state) {
  15841. fildata.hw_state = fildata.hw_state.name;
  15842. }
  15843. if (fildata.sign) {
  15844. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  15845. fildata.sign = fildata.sign.split(";");
  15846. fildata.sign = fildata.sign.join("");
  15847. fildata.sign = fildata.sign.toLowerCase();
  15848. }
  15849. if (fildata.keys) {
  15850. fildata["searchCriteria"] = "uuid";
  15851. }
  15852. console.log(fildata);
  15853. $scope.loadData(fildata);
  15854. }
  15855. if ($scope.title == "关联事件工单") {
  15856. // alert('3333333333333333')
  15857. if (stateid && stateid.code) {
  15858. item.statusId = stateid.code;
  15859. }
  15860. var fildata = defaultFilterData;
  15861. // $scope.memoryfilterData = fildata;
  15862. if (!fildata.incident) {
  15863. fildata["incident"] = {};
  15864. }
  15865. $scope.gridOptions.paginationCurrentPage = 1;
  15866. var transitiondata = angular.copy(item);
  15867. angular.extend(fildata.incident, transitiondata);
  15868. console.log(fildata);
  15869. // $scope.loadData(fildata);
  15870. api_bpm_data
  15871. .fetchDataList("incident", fildata)
  15872. .then(function (data) {
  15873. console.log(data);
  15874. if (data) {
  15875. $scope.myData = data.list;
  15876. $scope.gridOptions.totalItems = data.totalNum;
  15877. }
  15878. });
  15879. }
  15880. };
  15881. //重置
  15882. $scope.replacement = function (
  15883. parameters,
  15884. searchkeys,
  15885. othcode
  15886. ) {
  15887. // console.log(parameters, searchkeys, othcode);
  15888. delete defaultFilterData.incident;
  15889. console.log(defaultFilterData);
  15890. $scope.parameters = null;
  15891. $scope.searchkeys = {};
  15892. $scope.othcode = {};
  15893. $scope.wt_zcfl();
  15894. };
  15895. $scope.loadData = function (filterData) {
  15896. items
  15897. .fetchItems(filterData, APIService, $rootScope)
  15898. .then(function (data) {
  15899. var myData = Restangular.stripRestangular(data);
  15900. if (myData.data && myData.data.node) {
  15901. $scope.gridOptions.totalItems = myData.total;
  15902. $scope.myData = myData.data.node;
  15903. } else {
  15904. if (myData.resultCount) {
  15905. $scope.gridOptions["totalItems"] = myData.resultCount;
  15906. } else {
  15907. $scope.gridOptions.totalItems = myData.totalNum;
  15908. }
  15909. if (myData.list) {
  15910. $scope.myData = myData.list;
  15911. } else {
  15912. $scope.myData = myData.data;
  15913. }
  15914. }
  15915. });
  15916. };
  15917. $scope.title = title;
  15918. $scope.loadData({
  15919. idx: 0,
  15920. sum: 10,
  15921. });
  15922. $scope.selected = {
  15923. item: {},
  15924. };
  15925. $scope.ok = function () {
  15926. //console.log($scope.selected.item);
  15927. $modalInstance.close($scope.selected.item);
  15928. };
  15929. $scope.cancel = function () {
  15930. $modalInstance.dismiss("cancel");
  15931. };
  15932. },
  15933. size: size,
  15934. resolve: {
  15935. items: function () {
  15936. return {
  15937. fetchItems: function (filterData, APIService, $rootScope) {
  15938. filterData = filterData || {};
  15939. // if(!filterData.idx){
  15940. if (
  15941. angular.isDefined(filterData.idx) &&
  15942. filterData.idx == null
  15943. ) {
  15944. filterData = {
  15945. idx: 0,
  15946. sum: 10,
  15947. };
  15948. }
  15949. return options.templateOptions.fetchItems(
  15950. filterData,
  15951. APIService,
  15952. $rootScope
  15953. );
  15954. },
  15955. columnDefs: function () {
  15956. return options.templateOptions.columnDefs;
  15957. },
  15958. };
  15959. },
  15960. title: function () {
  15961. return options.templateOptions.modalTitle;
  15962. },
  15963. Restangular: function () {
  15964. return options.templateOptions.Restangular;
  15965. },
  15966. APIService: function () {
  15967. return options.templateOptions.ApiService;
  15968. },
  15969. },
  15970. });
  15971. modalInstance.result.then(
  15972. function (selectedItem) {
  15973. var selectitem = {
  15974. title: selectedItem.title,
  15975. description: selectedItem.description,
  15976. };
  15977. if (options.key == "chuku") {
  15978. if (selectedItem.assets) {
  15979. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  15980. selectedItem.assets;
  15981. }
  15982. if (selectedItem.consumables) {
  15983. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  15984. selectedItem.consumables;
  15985. }
  15986. angular.extend(
  15987. $scope.$parent.$parent.$parent.model,
  15988. selectitem
  15989. );
  15990. options.value(selectedItem);
  15991. // options.model.consumables = JSON.parse(consumables);
  15992. } else if (options.templateOptions.pkey == "change") {
  15993. console.log(options);
  15994. angular.extend(options.model);
  15995. options.value(selectedItem);
  15996. } else if (options.key == "cmdbCode") {
  15997. var zc_selectitem = selectedItem.uuid;
  15998. // angular.extend(options.model,zc_selectitem);
  15999. options.model.cmdbCode = zc_selectitem;
  16000. // angular.extend(options.model,zc_selectitem);
  16001. // options.templateOptions.displayName=zc_selectitem;
  16002. options.value(selectedItem);
  16003. console.log(options.model);
  16004. } else {
  16005. angular.extend(options.model, selectitem);
  16006. options.value(selectedItem);
  16007. }
  16008. },
  16009. function () {
  16010. //console.log('Modal dismissed at: ' + new Date());
  16011. }
  16012. );
  16013. },
  16014. },
  16015. };
  16016. },
  16017. });
  16018. //选项选择控件
  16019. formlyConfigProvider.setType({
  16020. name: "ui-modelselect",
  16021. extends: "input",
  16022. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16023. defaultOptions: function (options) {
  16024. return {
  16025. templateOptions: {
  16026. openModal: function (size, options, modal) {
  16027. var modalInstance = modal.open({
  16028. templateUrl:
  16029. "assets/views/customform/tpl/checktable-modal-content.html",
  16030. controller: function (
  16031. $scope,
  16032. $modalInstance,
  16033. items,
  16034. title,
  16035. Restangular,
  16036. APIService,
  16037. i18nService
  16038. ) {
  16039. $scope.langs = i18nService.getAllLangs();
  16040. $scope.lang = "zh-cn";
  16041. i18nService.setCurrentLang($scope.lang);
  16042. $scope.gridOptions = {};
  16043. $scope.gridOptions.data = "myData";
  16044. $scope.gridOptions.enableColumnResizing = true;
  16045. $scope.gridOptions.enableFiltering = true;
  16046. $scope.gridOptions.enableGridMenu = false;
  16047. $scope.gridOptions.enableRowSelection = true;
  16048. $scope.gridOptions.showGridFooter = true;
  16049. $scope.gridOptions.showColumnFooter = true;
  16050. $scope.gridOptions.fastWatch = true;
  16051. $scope.gridOptions.useExternalFiltering = true;
  16052. $scope.gridOptions.useExternalPagination = true;
  16053. $scope.gridOptions.paginationPageSizes = [10];
  16054. $scope.gridOptions.paginationPageSize = 10;
  16055. $scope.gridOptions.multiSelect = false;
  16056. $scope.gridOptions.rowIdentity = function (row) {
  16057. return row.id;
  16058. };
  16059. $scope.gridOptions.getRowIdentity = function (row) {
  16060. return row.id;
  16061. };
  16062. $scope.gridOptions.columnDefs = items.columnDefs();
  16063. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16064. $scope.gridApi = gridApi;
  16065. gridApi.pagination.on.paginationChanged(
  16066. $scope,
  16067. function (newPage, pageSize) {
  16068. // console.log(newPage);
  16069. // console.log(pageSize);
  16070. $scope.loadData({
  16071. idx: newPage - 1,
  16072. sum: pageSize,
  16073. });
  16074. }
  16075. );
  16076. gridApi.core.on.filterChanged($scope, function () {
  16077. var grid = this.grid;
  16078. var filtersData = {
  16079. idx: 0,
  16080. sum: 10,
  16081. };
  16082. angular.forEach(grid.columns, function (item) {
  16083. if (item.enableFiltering) {
  16084. if (
  16085. angular.isDefined(item.filters[0].term) &&
  16086. item.filters[0].term != ""
  16087. ) {
  16088. // console.log("filtersData="+JSON.stringify(filtersData))
  16089. if (angular.isUndefined(filtersData["incident"])) {
  16090. filtersData["incident"] = {};
  16091. }
  16092. filtersData["incident"][item.field] =
  16093. item.filters[0].term;
  16094. if (angular.isUndefined(filtersData["problem"])) {
  16095. filtersData["problem"] = {};
  16096. }
  16097. filtersData["problem"][item.field] =
  16098. item.filters[0].term;
  16099. if (angular.isUndefined(filtersData["change"])) {
  16100. filtersData["change"] = {};
  16101. }
  16102. filtersData["change"][item.field] =
  16103. item.filters[0].term;
  16104. if (angular.isUndefined(filtersData["release"])) {
  16105. filtersData["release"] = {};
  16106. }
  16107. filtersData["release"][item.field] =
  16108. item.filters[0].term;
  16109. }
  16110. }
  16111. });
  16112. $scope.loadData(filtersData);
  16113. });
  16114. gridApi.selection.on.rowSelectionChanged(
  16115. $scope,
  16116. function (data) {
  16117. $scope.selected.item = data.entity;
  16118. //console.log(data);
  16119. }
  16120. );
  16121. };
  16122. $scope.loadData = function (filterData) {
  16123. items
  16124. .fetchItems(filterData, APIService)
  16125. .then(function (data) {
  16126. var myData = Restangular.stripRestangular(data);
  16127. $scope.gridOptions.totalItems = myData.totalNum;
  16128. $scope.myData = myData.list;
  16129. });
  16130. };
  16131. $scope.title = title;
  16132. $scope.loadData({
  16133. idx: 0,
  16134. sum: 10,
  16135. });
  16136. $scope.selected = {
  16137. item: {},
  16138. };
  16139. $scope.ok = function () {
  16140. if ($scope.selected.item.scheduleOrder) {
  16141. $scope.selected.item.descriptionData =
  16142. "日期:" +
  16143. $scope.selected.item.watchTime +
  16144. ";" +
  16145. "班次:" +
  16146. $scope.selected.item.scheduleOrder.description +
  16147. ";" +
  16148. "值班人:" +
  16149. $scope.selected.item.scheduleOrder.users[0].name;
  16150. }
  16151. //console.log($scope.selected.item);
  16152. $modalInstance.close($scope.selected.item);
  16153. };
  16154. $scope.cancel = function () {
  16155. $modalInstance.dismiss("cancel");
  16156. };
  16157. },
  16158. size: size,
  16159. resolve: {
  16160. items: function () {
  16161. return {
  16162. fetchItems: function (filterData, APIService) {
  16163. filterData = filterData || {};
  16164. // if(!filterData.idx){
  16165. if (
  16166. angular.isDefined(filterData.idx) &&
  16167. filterData.idx == null
  16168. ) {
  16169. filterData = {
  16170. idx: 0,
  16171. sum: 10,
  16172. };
  16173. }
  16174. return options.templateOptions.fetchItems(
  16175. filterData,
  16176. APIService,
  16177. options
  16178. );
  16179. },
  16180. columnDefs: function () {
  16181. return options.templateOptions.columnDefs;
  16182. },
  16183. };
  16184. },
  16185. title: function () {
  16186. return options.templateOptions.modalTitle;
  16187. },
  16188. Restangular: function () {
  16189. return options.templateOptions.Restangular;
  16190. },
  16191. APIService: function () {
  16192. return options.templateOptions.ApiService;
  16193. },
  16194. },
  16195. });
  16196. modalInstance.result.then(
  16197. function (selectedItem) {
  16198. options.value(selectedItem);
  16199. },
  16200. function () {
  16201. //console.log('Modal dismissed at: ' + new Date());
  16202. }
  16203. );
  16204. },
  16205. },
  16206. };
  16207. },
  16208. });
  16209. formlyConfigProvider.setType({
  16210. name: "ui-requestform",
  16211. extends: "input",
  16212. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  16213. controller: [
  16214. "$scope",
  16215. function ($scope) {
  16216. setTimeout(function () {
  16217. var filterData = {
  16218. idx: 0,
  16219. sum: 5,
  16220. incident: {
  16221. requester: {
  16222. id: "",
  16223. },
  16224. },
  16225. };
  16226. $scope.options.templateOptions
  16227. .getWorkernumber(
  16228. $scope.options.templateOptions.ApiService,
  16229. filterData
  16230. )
  16231. .then(function (result) {
  16232. var modelData =
  16233. $scope.options.templateOptions.Restangular.stripRestangular(
  16234. result
  16235. );
  16236. });
  16237. }, 1000);
  16238. },
  16239. ],
  16240. });
  16241. //报修图片展示
  16242. formlyConfigProvider.setType({
  16243. name: "ui-repair-photos",
  16244. // extends: 'label',
  16245. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  16246. controller: [
  16247. "$scope",
  16248. "api_wechatfile",
  16249. "$stateParams",
  16250. function ($scope, api_wechatfile, $stateParams) {
  16251. console.log($scope);
  16252. $scope.fileUrls = [];
  16253. if ($scope.model.wxFile) {
  16254. api_wechatfile
  16255. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  16256. .then(function (res) {
  16257. $scope.fileUrls = res.data;
  16258. });
  16259. }
  16260. console.log($stateParams);
  16261. if (
  16262. $stateParams &&
  16263. $stateParams.model &&
  16264. JSON.parse($stateParams.model) &&
  16265. JSON.parse($stateParams.model).model &&
  16266. JSON.parse($stateParams.model).model.flow
  16267. ) {
  16268. api_wechatfile
  16269. .listAttachment(
  16270. "wechatRequesterIncident",
  16271. JSON.parse($stateParams.model).model.flow
  16272. )
  16273. .then(function (res) {
  16274. $scope.fileUrls = res.data;
  16275. });
  16276. }
  16277. if ($scope.model.flow) {
  16278. api_wechatfile
  16279. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  16280. .then(function (res) {
  16281. $scope.fileUrls = res.data;
  16282. });
  16283. }
  16284. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  16285. // // setTimeout(function () {
  16286. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  16287. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  16288. // // if (modelData.status == 200) {
  16289. // // $scope.model[$scope.options.key] = modelData.data;
  16290. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  16291. // // }
  16292. // // });
  16293. // // }, 1000);
  16294. // }
  16295. $scope.showBigImg = false;
  16296. $scope.showBigImgCli = function (data) {
  16297. $scope.showBigImg = true;
  16298. $scope.bigImgUrl = data;
  16299. };
  16300. $scope.closeBigImg = function () {
  16301. $scope.showBigImg = false;
  16302. };
  16303. },
  16304. ],
  16305. });
  16306. //图片展示
  16307. formlyConfigProvider.setType({
  16308. name: "ui-showImgs",
  16309. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  16310. defaultOptions: function (options) {
  16311. return {
  16312. templateOptions: {
  16313. refresh: function (APIService, processInstanceId, data) {
  16314. return APIService.listAttachments(processInstanceId);
  16315. },
  16316. downloadUri: function (APIService, contentId) {
  16317. return APIService.downloadAttachment(contentId).getRequestedUrl();
  16318. },
  16319. view: function (APIService, contentId) {
  16320. return APIService.attachmentsPreviewUrl(contentId);
  16321. },
  16322. download: function (APIService, contentId, item) {
  16323. var item = {
  16324. url: APIService.download(contentId),
  16325. headers: headers,
  16326. };
  16327. return item;
  16328. },
  16329. refreshDelay: 0,
  16330. },
  16331. };
  16332. },
  16333. controller: [
  16334. "$scope",
  16335. "$timeout",
  16336. "$modal",
  16337. "$rootScope",
  16338. "$http",
  16339. "up_down_file",
  16340. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  16341. var _refreshDelayPromise;
  16342. /**
  16343. * refresh
  16344. */
  16345. $scope._refresh = function (refreshAttr) {
  16346. $scope.attachments = [];
  16347. if (refreshAttr !== undefined) {
  16348. if (_refreshDelayPromise) {
  16349. $timeout.cancel(_refreshDelayPromise);
  16350. }
  16351. _refreshDelayPromise = $timeout(function () {
  16352. // 暂存附件
  16353. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  16354. $scope.options.templateOptions
  16355. .refresh(
  16356. $scope.options.templateOptions.ApiService,
  16357. $scope.options.templateOptions.processInstanceId,
  16358. {
  16359. idx: 0,
  16360. sum: 1000,
  16361. }
  16362. )
  16363. .then(function (response) {
  16364. var myData =
  16365. $scope.options.templateOptions.Restangular.stripRestangular(
  16366. response
  16367. );
  16368. if (myData) {
  16369. for (var i = 0; i < myData.data.length; i++) {
  16370. $scope.attachments.push(myData.data[i]);
  16371. }
  16372. }
  16373. $scope.options.templateOptions
  16374. .refresh(
  16375. $scope.options.templateOptions.ApiService,
  16376. $scope.$parent.$parent.$parent.model.save_fileId,
  16377. {
  16378. idx: 0,
  16379. sum: 1000,
  16380. }
  16381. )
  16382. .then(function (response2) {
  16383. var myData2 =
  16384. $scope.options.templateOptions.Restangular.stripRestangular(
  16385. response2
  16386. );
  16387. if (myData2) {
  16388. for (var i = 0; i < myData2.data.length; i++) {
  16389. $scope.attachments.push(myData2.data[i]);
  16390. }
  16391. }
  16392. console.log($scope.attachments);
  16393. });
  16394. });
  16395. // 正常附件
  16396. } else {
  16397. $scope.options.templateOptions
  16398. .refresh(
  16399. $scope.options.templateOptions.ApiService,
  16400. $scope.options.templateOptions.processInstanceId,
  16401. {
  16402. idx: 0,
  16403. sum: 1000,
  16404. }
  16405. )
  16406. .then(function (response) {
  16407. var myData =
  16408. $scope.options.templateOptions.Restangular.stripRestangular(
  16409. response
  16410. );
  16411. if (myData) {
  16412. $scope.attachments = [];
  16413. $scope.imgs = [];
  16414. myData.data.forEach((e) => {
  16415. if (
  16416. e.suffix == "jpeg" ||
  16417. e.suffix == "jpg" ||
  16418. e.suffix == "svg" ||
  16419. e.suffix == "png" ||
  16420. e.suffix == "bmp" ||
  16421. e.suffix == "gif" ||
  16422. e.suffix == "tif"
  16423. ) {
  16424. $scope.imgs.push(e);
  16425. }
  16426. });
  16427. $scope.imgs = $scope.imgs.splice(0, 3);
  16428. console.log($scope.imgs);
  16429. }
  16430. });
  16431. }
  16432. }, $scope.options.templateOptions.refreshDelay);
  16433. }
  16434. };
  16435. $scope._refresh({});
  16436. // $scope.attachments = $scope.model[$scope.options.key]
  16437. // 预览
  16438. $scope.preview = function (url, idx) {
  16439. var title = $scope.imgs[idx].title;
  16440. $modal.open({
  16441. backdrop: false,
  16442. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16443. controller: function ($scope, scope, $modalInstance) {
  16444. $scope.title = title;
  16445. $scope.imageurl = url;
  16446. $scope.cancel = function () {
  16447. $modalInstance.dismiss("cancel");
  16448. };
  16449. },
  16450. resolve: {
  16451. scope: function () {
  16452. return $scope;
  16453. },
  16454. },
  16455. });
  16456. };
  16457. },
  16458. ],
  16459. });
  16460. //工单/受理人控件
  16461. formlyConfigProvider.setType({
  16462. name: "ui-workernumbersign",
  16463. // extends: 'label',
  16464. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  16465. controller: [
  16466. "$scope",
  16467. function ($scope) {
  16468. // 2020年4月24日13:20:40
  16469. console.log($scope, "docu");
  16470. // 左侧事件工单区域地点填充
  16471. $scope.model.selecthouseNumber = $scope.model.place;
  16472. if (
  16473. angular.isUndefined($scope.model[$scope.options.key]) ||
  16474. $scope.model[$scope.options.key] == null
  16475. ) {
  16476. setTimeout(function () {
  16477. $scope.options.templateOptions
  16478. .getWorkernumber($scope.options.templateOptions.ApiService)
  16479. .then(function (result) {
  16480. var modelData =
  16481. $scope.options.templateOptions.Restangular.stripRestangular(
  16482. result
  16483. );
  16484. if (modelData.status == 200) {
  16485. $scope.model[$scope.options.key] = modelData.data;
  16486. $scope.options.initialValue =
  16487. $scope.model[$scope.options.key];
  16488. }
  16489. });
  16490. }, 1000);
  16491. }
  16492. if (
  16493. $scope.options.templateOptions.user &&
  16494. (angular.isUndefined($scope.model.acceptUser) ||
  16495. $scope.model.acceptUser == null)
  16496. ) {
  16497. if (angular.isFunction($scope.options.templateOptions.transform)) {
  16498. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  16499. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  16500. // }
  16501. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16502. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16503. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  16504. }
  16505. $scope.model.acceptUser = $scope.options.templateOptions.user;
  16506. // $scope.options.initialValue = $scope.model.acceptUser;
  16507. }
  16508. },
  16509. ],
  16510. });
  16511. //工单控件-only number
  16512. formlyConfigProvider.setType({
  16513. name: "ui-workernumber",
  16514. extends: "input",
  16515. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16516. controller: [
  16517. "$scope",
  16518. function ($scope) {
  16519. if (
  16520. angular.isUndefined($scope.model[$scope.options.key]) ||
  16521. $scope.model[$scope.options.key] == null
  16522. ) {
  16523. setTimeout(function () {
  16524. $scope.options.templateOptions
  16525. .getWorkernumber($scope.options.templateOptions.ApiService)
  16526. .then(function (result) {
  16527. var modelData =
  16528. $scope.options.templateOptions.Restangular.stripRestangular(
  16529. result
  16530. );
  16531. if (modelData.status == 200) {
  16532. $scope.model[$scope.options.key] = modelData.data;
  16533. $scope.options.initialValue =
  16534. $scope.model[$scope.options.key];
  16535. }
  16536. });
  16537. }, 1000);
  16538. }
  16539. },
  16540. ],
  16541. });
  16542. //cmdb工单
  16543. formlyConfigProvider.setType({
  16544. name: "ui-cmdbworkernumber",
  16545. extends: "input",
  16546. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16547. controller: [
  16548. "$scope",
  16549. function ($scope) {
  16550. if (
  16551. angular.isUndefined($scope.model[$scope.options.key]) ||
  16552. $scope.model[$scope.options.key] == null
  16553. ) {
  16554. setTimeout(function () {
  16555. $scope.options.templateOptions
  16556. .getWorkernumber(
  16557. $scope.options.templateOptions.ApiService,
  16558. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  16559. .cifilter_classics.id
  16560. )
  16561. .then(function (result) {
  16562. var modelData =
  16563. $scope.options.templateOptions.Restangular.stripRestangular(
  16564. result
  16565. );
  16566. // if(modelData.status==200){
  16567. $scope.model[$scope.options.key] =
  16568. modelData[$scope.options.key];
  16569. $scope.options.initialValue = $scope.model[$scope.options.key];
  16570. // }
  16571. });
  16572. }, 1000);
  16573. }
  16574. },
  16575. ],
  16576. });
  16577. //简易上传图片组件
  16578. formlyConfigProvider.setType({
  16579. name: "ui-uploadImgs",
  16580. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  16581. wrapper: ["bootstrapHasError"],
  16582. controller: [
  16583. "$scope",
  16584. "fileReader",
  16585. "$parse",
  16586. "$modal",
  16587. function ($scope, fileReader, $parse, $modal) {
  16588. $scope.imgshows = [];
  16589. $scope.uploadimgs = [];
  16590. var model = $parse("upload_img");
  16591. var modelSetter = model.assign;
  16592. var uploader = ($scope.uploader =
  16593. $scope.options.templateOptions.fileUploader);
  16594. uploader.filters.push({
  16595. name: "customFilter",
  16596. fn: function (item /*{File|FileLikeObject}*/, options) {
  16597. return this.queue.length < 10;
  16598. },
  16599. });
  16600. // 添加
  16601. $scope.change = function (event) {
  16602. var element = $(".upinp");
  16603. modelSetter($scope, element[0].files[0]);
  16604. //附件预览
  16605. $scope.imgupload = event.files[0];
  16606. getFile($scope.imgupload, $scope);
  16607. //获得预览图地址并且把file对象放入上传合集内
  16608. function getFile(imgupload, $scope) {
  16609. if (!imgupload) {
  16610. return;
  16611. }
  16612. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  16613. $scope.imgshows.push(result);
  16614. var file = document.querySelector("input[type=file]").files[0];
  16615. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  16616. console.log($scope.imgshows, $scope.uploadimgs);
  16617. if ($scope.imgshows.length < 3) {
  16618. $("#upup").show();
  16619. } else {
  16620. $("#upup").hide();
  16621. }
  16622. });
  16623. }
  16624. };
  16625. // 删除
  16626. $scope.uploadimg_del = function (index, imgs) {
  16627. console.log(index, imgs);
  16628. $scope.imgshows.splice(index, 1);
  16629. $scope.uploadimgs.splice(index, 1);
  16630. if ($scope.imgshows.length < 3) {
  16631. $("#upup").show();
  16632. } else {
  16633. $("#upup").hide();
  16634. }
  16635. };
  16636. // 预览
  16637. $scope.preview = function (url, idx) {
  16638. var name = $scope.uploadimgs[idx].name;
  16639. $modal.open({
  16640. backdrop: false,
  16641. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16642. controller: function ($scope, scope, $modalInstance) {
  16643. $scope.title = name;
  16644. $scope.imageurl = url;
  16645. $scope.cancel = function () {
  16646. $modalInstance.dismiss("cancel");
  16647. };
  16648. },
  16649. resolve: {
  16650. scope: function () {
  16651. return $scope;
  16652. },
  16653. },
  16654. });
  16655. };
  16656. if (uploader) {
  16657. uploader.onWhenAddingFileFailed = function (
  16658. item /*{File|FileLikeObject}*/,
  16659. filter,
  16660. options
  16661. ) {
  16662. console.info("onWhenAddingFileFailed", item, filter, options);
  16663. };
  16664. uploader.onAfterAddingFile = function (fileItem) {
  16665. console.info("onAfterAddingFile", fileItem);
  16666. };
  16667. uploader.onAfterAddingAll = function (addedFileItems) {
  16668. console.info("onAfterAddingAll", addedFileItems);
  16669. };
  16670. uploader.onBeforeUploadItem = function (item) {
  16671. console.info("onBeforeUploadItem", item);
  16672. };
  16673. uploader.onProgressItem = function (fileItem, progress) {
  16674. console.info("onProgressItem", fileItem, progress);
  16675. };
  16676. uploader.onProgressAll = function (progress) {
  16677. console.info("onProgressAll", progress);
  16678. };
  16679. uploader.onSuccessItem = function (
  16680. fileItem,
  16681. response,
  16682. status,
  16683. headers
  16684. ) {
  16685. console.info("onSuccessItem", fileItem, response, status, headers);
  16686. };
  16687. uploader.onErrorItem = function (
  16688. fileItem,
  16689. response,
  16690. status,
  16691. headers
  16692. ) {
  16693. console.info("onErrorItem", fileItem, response, status, headers);
  16694. };
  16695. uploader.onCancelItem = function (
  16696. fileItem,
  16697. response,
  16698. status,
  16699. headers
  16700. ) {
  16701. console.info("onCancelItem", fileItem, response, status, headers);
  16702. };
  16703. uploader.onCompleteItem = function (
  16704. fileItem,
  16705. response,
  16706. status,
  16707. headers
  16708. ) {
  16709. console.info("onCompleteItem", fileItem, response, status, headers);
  16710. };
  16711. uploader.onCompleteAll = function () {
  16712. console.info("onCompleteAll");
  16713. };
  16714. }
  16715. // console.log(modelSetter)
  16716. },
  16717. ],
  16718. });
  16719. //jry-上传下载一体
  16720. formlyConfigProvider.setType({
  16721. name: "ui-upDropFile",
  16722. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  16723. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16724. defaultOptions: function (options) {
  16725. return {
  16726. templateOptions: {
  16727. view: function (APIService, contentId) {
  16728. return APIService.downloadAttachment(contentId);
  16729. },
  16730. // ApiService: 'api_wechatfile',
  16731. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  16732. // upUrl: 'common/common/uploadAttachment',
  16733. // listAttachmentUrl: 'common/common/listAttachment',
  16734. // downUrl: 'common/common/downloadAttachment',
  16735. // bindType: 'incident',
  16736. // bindId: 2323
  16737. },
  16738. // validators: {
  16739. // required: {
  16740. // expression: function(viewValue, modelValue) {
  16741. // var value = modelValue || viewValue;
  16742. // return value.length >= 1;
  16743. // }
  16744. // }
  16745. // }
  16746. };
  16747. },
  16748. controller: [
  16749. "$scope",
  16750. "$rootScope",
  16751. "Restangular",
  16752. "up_down_file",
  16753. "$http",
  16754. "api_bpm",
  16755. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  16756. console.log($scope);
  16757. $scope.showFileUp = true;
  16758. if ($scope.model.isKnowledge_detail) {
  16759. $scope.showFileUp = false;
  16760. }
  16761. if (angular.isUndefined($scope.form.dropState)) {
  16762. $scope.form.dropState = false;
  16763. }
  16764. if ($scope.model.incident) {
  16765. if ($scope.model.incident.alarm) {
  16766. console.log($scope);
  16767. if ($scope.model.incident.alarm) {
  16768. if ($scope.model.incident.alarm.alarmExtension) {
  16769. $scope.model.incident.alarm.alarmExtension =
  16770. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  16771. $scope.model.incident.alarm.alarmExtension =
  16772. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  16773. $scope.model.incident.description =
  16774. $scope.model.incident.alarm.alarmExtension;
  16775. console.log($scope.model.incident.description);
  16776. $scope.model.incident.description =
  16777. '"' +
  16778. "告警名称" +
  16779. '":' +
  16780. '"' +
  16781. $scope.model.incident.alarm.alarmSystem +
  16782. '",' +
  16783. '"' +
  16784. "告警状态" +
  16785. '":' +
  16786. '"' +
  16787. $scope.model.incident.alarm.alarmStatus +
  16788. '",' +
  16789. '"' +
  16790. "告警内容" +
  16791. '":' +
  16792. '"' +
  16793. $scope.model.incident.alarm.alarmContent +
  16794. '",' +
  16795. $scope.model.incident.description;
  16796. } else {
  16797. $scope.model.incident.description =
  16798. '"' +
  16799. "告警名称" +
  16800. '":' +
  16801. '"' +
  16802. $scope.model.incident.alarm.alarmSystem +
  16803. '",' +
  16804. '"' +
  16805. "告警状态" +
  16806. '":' +
  16807. '"' +
  16808. $scope.model.incident.alarm.alarmStatus +
  16809. '",' +
  16810. '"' +
  16811. "告警内容" +
  16812. '":' +
  16813. '"' +
  16814. $scope.model.incident.alarm.alarmContent +
  16815. '",';
  16816. }
  16817. $scope.model.incident.description =
  16818. $scope.model.incident.description.replace(/,/g, "\n");
  16819. console.log($scope.model.incident.description);
  16820. }
  16821. }
  16822. api_bpm
  16823. .tellCategory($scope.model.incident.category.id)
  16824. .then(function (wt_data) {
  16825. console.log(wt_data);
  16826. if (wt_data) {
  16827. $rootScope.wt_category = wt_data.data;
  16828. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  16829. $rootScope.wt_child = wt_data.child;
  16830. }
  16831. });
  16832. if ($scope.model.titleName == "接单") {
  16833. $scope.model.receive_code = "handler";
  16834. if (
  16835. $scope.model.incident.groupLeader &&
  16836. !$scope.model.incident.repeat
  16837. ) {
  16838. $scope.model.isHandlerUser = true;
  16839. }
  16840. }
  16841. if ($scope.model.titleName == "事件处理") {
  16842. console.log($scope.model.cmdbCode);
  16843. if ($scope.model.cmdbCode) {
  16844. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  16845. }
  16846. }
  16847. } else {
  16848. $rootScope.wt_category = "";
  16849. }
  16850. //附件上传数据
  16851. if ($scope.options.templateOptions.fileUploader) {
  16852. var uploader = ($scope.uploader =
  16853. $scope.options.templateOptions.fileUploader);
  16854. //$scope.options.templateOptions.uploader();
  16855. console.log(uploader);
  16856. // FILTERS
  16857. uploader.filters.push({
  16858. name: "customFilter",
  16859. fn: function (item /*{File|FileLikeObject}*/, options) {
  16860. return this.queue.length < 10;
  16861. },
  16862. });
  16863. }
  16864. var to = $scope.options.templateOptions;
  16865. // var bindType = $scope.model.bindType;
  16866. if (to.bindType == "incident") {
  16867. var bindId = $scope.model[to.bindType].processInstanceId;
  16868. } else if (to.bindType == "change") {
  16869. var bindId = $scope.model[to.bindType].processInstanceId;
  16870. } else {
  16871. var bindId = $scope.model[to.bindType].id;
  16872. }
  16873. //获取附件列表
  16874. $scope.listAttachmen = function () {
  16875. to.ApiService.listAttachment(
  16876. to.listAttachmentUrl,
  16877. to.bindType,
  16878. bindId
  16879. ).then(function (result) {
  16880. var myData = Restangular.stripRestangular(result);
  16881. // $scope.listAttachmens = myData;
  16882. $scope.attachments = myData.data;
  16883. });
  16884. };
  16885. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  16886. $scope.listAttachmen();
  16887. } else if (to.bindType && $scope.model[to.bindType].id) {
  16888. $scope.listAttachmen();
  16889. }
  16890. //附件上传
  16891. $scope.isUpfload = to.isUpfload;
  16892. $scope.dropfile = function (
  16893. APIService,
  16894. processInstanceId,
  16895. taskId,
  16896. userId
  16897. ) {
  16898. uploader.onBeforeUploadItem = function (item) {
  16899. angular.extend(item.headers, $rootScope.getSession());
  16900. item.url = to.ApiService.saveAttachments(
  16901. to.uploadUrl,
  16902. to.bindType,
  16903. bindId
  16904. ).getRequestedUrl();
  16905. item.formData.push({
  16906. filename: item.file.name,
  16907. });
  16908. };
  16909. uploader.uploadAll();
  16910. };
  16911. //附件下载
  16912. $scope.download = function (token, filename) {
  16913. var downUrl = to.ApiService.downloadAttachment(
  16914. to.downUrl,
  16915. token
  16916. ).getRequestedUrl();
  16917. // window.open(downUrl);
  16918. var a = document.createElement("a");
  16919. a.href = downUrl;
  16920. a.target = "_blank";
  16921. a.download = filename;
  16922. document.body.appendChild(a);
  16923. a.click();
  16924. };
  16925. //附件预览
  16926. $scope.view = function (id, previewUrl) {
  16927. if (previewUrl) {
  16928. window.open(previewUrl);
  16929. }
  16930. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  16931. // if (response.state == 200) {
  16932. // window.open(response.previewUrl);
  16933. // }
  16934. // })
  16935. };
  16936. // CALLBACKS
  16937. if (uploader) {
  16938. uploader.onWhenAddingFileFailed = function (
  16939. item /*{File|FileLikeObject}*/,
  16940. filter,
  16941. options
  16942. ) {
  16943. console.info("onWhenAddingFileFailed", item, filter, options);
  16944. };
  16945. uploader.onAfterAddingFile = function (fileItem) {
  16946. console.info("onAfterAddingFile", fileItem);
  16947. };
  16948. uploader.onAfterAddingAll = function (addedFileItems) {
  16949. console.info("onAfterAddingAll", addedFileItems);
  16950. };
  16951. uploader.onBeforeUploadItem = function (item) {
  16952. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  16953. // // $scope.uploader.options.url();
  16954. // $scope.uploader.onBeforeUploadItem = function(item) {
  16955. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  16956. // console.info('onBeforeUploadItem', item);
  16957. // };
  16958. // $scope.uploader.uploadAll();
  16959. // }
  16960. console.info("onBeforeUploadItem", item);
  16961. };
  16962. uploader.onProgressItem = function (fileItem, progress) {
  16963. console.info("onProgressItem", fileItem, progress);
  16964. };
  16965. uploader.onProgressAll = function (progress) {
  16966. console.info("onProgressAll", progress);
  16967. };
  16968. uploader.onSuccessItem = function (
  16969. fileItem,
  16970. response,
  16971. status,
  16972. headers
  16973. ) {
  16974. console.info("onSuccessItem", fileItem, response, status, headers);
  16975. if (response.status == 200) {
  16976. $scope.listAttachmen();
  16977. }
  16978. };
  16979. uploader.onErrorItem = function (
  16980. fileItem,
  16981. response,
  16982. status,
  16983. headers
  16984. ) {
  16985. console.info("onErrorItem", fileItem, response, status, headers);
  16986. };
  16987. uploader.onCancelItem = function (
  16988. fileItem,
  16989. response,
  16990. status,
  16991. headers
  16992. ) {
  16993. console.info("onCancelItem", fileItem, response, status, headers);
  16994. };
  16995. uploader.onCompleteItem = function (
  16996. fileItem,
  16997. response,
  16998. status,
  16999. headers
  17000. ) {
  17001. console.info("onCompleteItem", fileItem, response, status, headers);
  17002. };
  17003. uploader.onCompleteAll = function () {
  17004. console.info("onCompleteAll");
  17005. };
  17006. }
  17007. },
  17008. ],
  17009. });
  17010. //简易上传下载附件组件
  17011. formlyConfigProvider.setType({
  17012. name: "ui-upDownFiles",
  17013. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  17014. wrapper: ["bootstrapHasError"],
  17015. defaultOptions: function (options) {
  17016. return {
  17017. templateOptions: {
  17018. refresh: function (APIService, processInstanceId, data) {
  17019. return APIService.listAttachments(processInstanceId);
  17020. },
  17021. downloadUri: function (APIService, contentId) {
  17022. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17023. },
  17024. view: function (APIService, contentId) {
  17025. return APIService.attachmentsPreviewUrl(contentId);
  17026. },
  17027. download: function (APIService, contentId, item) {
  17028. var item = {
  17029. url: APIService.download(contentId),
  17030. headers: headers,
  17031. };
  17032. return item;
  17033. },
  17034. refreshDelay: 0,
  17035. },
  17036. };
  17037. },
  17038. controller: [
  17039. "$scope",
  17040. "$timeout",
  17041. "$modal",
  17042. "$rootScope",
  17043. "$http",
  17044. "up_down_file",
  17045. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17046. if (angular.isUndefined($scope.form.dropState)) {
  17047. $scope.form.dropState = false;
  17048. }
  17049. //附件上传数据
  17050. var uploader = ($scope.uploader =
  17051. $scope.options.templateOptions.fileUploader);
  17052. //$scope.options.templateOptions.uploader();
  17053. // FILTERS
  17054. uploader.filters.push({
  17055. name: "customFilter",
  17056. fn: function (item /*{File|FileLikeObject}*/, options) {
  17057. return this.queue.length < 10;
  17058. },
  17059. });
  17060. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  17061. // uploader.onBeforeUploadItem = function (item) {
  17062. // angular.extend(item.headers, $rootScope.getSession());
  17063. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  17064. // item.formData.push({
  17065. // 'fileName': item.file.name
  17066. // });
  17067. // console.info('onBeforeUploadItem', item);
  17068. // };
  17069. // }
  17070. // CALLBACKS
  17071. uploader.onWhenAddingFileFailed = function (
  17072. item /*{File|FileLikeObject}*/,
  17073. filter,
  17074. options
  17075. ) {
  17076. console.info("onWhenAddingFileFailed", item, filter, options);
  17077. };
  17078. uploader.onAfterAddingFile = function (fileItem) {
  17079. console.info("onAfterAddingFile", fileItem);
  17080. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17081. alert("文件过大");
  17082. fileItem.uploader.queue.pop();
  17083. console.log($scope);
  17084. }
  17085. };
  17086. uploader.onAfterAddingAll = function (addedFileItems) {
  17087. // console.info('onAfterAddingAll', addedFileItems);
  17088. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17089. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17090. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17091. // console.log(123)
  17092. };
  17093. uploader.onBeforeUploadItem = function (item) {
  17094. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17095. // // $scope.uploader.options.url();
  17096. // $scope.uploader.onBeforeUploadItem = function(item) {
  17097. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17098. // console.info('onBeforeUploadItem', item);
  17099. // };
  17100. // $scope.uploader.uploadAll();
  17101. // }
  17102. console.info("onBeforeUploadItem", item);
  17103. };
  17104. uploader.onProgressItem = function (fileItem, progress) {
  17105. console.info("onProgressItem", fileItem, progress);
  17106. };
  17107. uploader.onProgressAll = function (progress) {
  17108. console.info("onProgressAll", progress);
  17109. };
  17110. uploader.onSuccessItem = function (
  17111. fileItem,
  17112. response,
  17113. status,
  17114. headers
  17115. ) {
  17116. console.info("onSuccessItem", fileItem, response, status, headers);
  17117. };
  17118. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17119. console.info("onErrorItem", fileItem, response, status, headers);
  17120. };
  17121. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17122. console.info("onCancelItem", fileItem, response, status, headers);
  17123. };
  17124. uploader.onCompleteItem = function (
  17125. fileItem,
  17126. response,
  17127. status,
  17128. headers
  17129. ) {
  17130. console.info("onCompleteItem", fileItem, response, status, headers);
  17131. };
  17132. uploader.onCompleteAll = function () {
  17133. console.info("onCompleteAll");
  17134. };
  17135. var _refreshDelayPromise;
  17136. // 下载
  17137. $scope.download = function (contentId, filename, token) {
  17138. // console.log(contentId, filename, token)
  17139. //附件下载
  17140. var downUrl = up_down_file
  17141. .downloadAttachment("common/common/downloadAttachment", token)
  17142. .getRequestedUrl();
  17143. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17144. // console.log(downUrl)
  17145. var a = document.createElement("a");
  17146. a.href = downUrl;
  17147. a.target = "_blank";
  17148. a.download = filename;
  17149. document.body.appendChild(a);
  17150. a.click();
  17151. };
  17152. $scope._refresh = function (refreshAttr) {
  17153. $scope.attachments = [];
  17154. if (refreshAttr !== undefined) {
  17155. if (_refreshDelayPromise) {
  17156. $timeout.cancel(_refreshDelayPromise);
  17157. }
  17158. _refreshDelayPromise = $timeout(function () {
  17159. // 暂存附件
  17160. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17161. $scope.options.templateOptions
  17162. .refresh(
  17163. $scope.options.templateOptions.ApiService,
  17164. $scope.options.templateOptions.processInstanceId,
  17165. {
  17166. idx: 0,
  17167. sum: 1000,
  17168. }
  17169. )
  17170. .then(function (response) {
  17171. var myData =
  17172. $scope.options.templateOptions.Restangular.stripRestangular(
  17173. response
  17174. );
  17175. if (myData) {
  17176. for (var i = 0; i < myData.data.length; i++) {
  17177. $scope.attachments.push(myData.data[i]);
  17178. }
  17179. }
  17180. $scope.options.templateOptions
  17181. .refresh(
  17182. $scope.options.templateOptions.ApiService,
  17183. $scope.$parent.$parent.$parent.model.save_fileId,
  17184. {
  17185. idx: 0,
  17186. sum: 1000,
  17187. }
  17188. )
  17189. .then(function (response2) {
  17190. var myData2 =
  17191. $scope.options.templateOptions.Restangular.stripRestangular(
  17192. response2
  17193. );
  17194. if (myData2) {
  17195. for (var i = 0; i < myData2.data.length; i++) {
  17196. $scope.attachments.push(myData2.data[i]);
  17197. }
  17198. // 只展示除图片以外的附件
  17199. var a = [];
  17200. $scope.attachments.forEach((e) => {
  17201. if (
  17202. e.suffix == "jpeg" ||
  17203. e.suffix == "jpg" ||
  17204. e.suffix == "svg" ||
  17205. e.suffix == "png" ||
  17206. e.suffix == "bmp" ||
  17207. e.suffix == "gif" ||
  17208. e.suffix == "tif"
  17209. ) {
  17210. // $scope.imgs.push(e)
  17211. } else {
  17212. a.push(e);
  17213. }
  17214. });
  17215. $scope.attachments = a;
  17216. }
  17217. console.log($scope.attachments);
  17218. });
  17219. });
  17220. // 正常附件
  17221. } else {
  17222. $scope.options.templateOptions
  17223. .refresh(
  17224. $scope.options.templateOptions.ApiService,
  17225. $scope.options.templateOptions.processInstanceId,
  17226. {
  17227. idx: 0,
  17228. sum: 1000,
  17229. }
  17230. )
  17231. .then(function (response) {
  17232. var myData =
  17233. $scope.options.templateOptions.Restangular.stripRestangular(
  17234. response
  17235. );
  17236. if (myData) {
  17237. $scope.attachments = myData.data;
  17238. // 只展示除图片以外的附件
  17239. var a = [];
  17240. $scope.attachments.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. } else {
  17252. a.push(e);
  17253. }
  17254. });
  17255. $scope.attachments = a;
  17256. }
  17257. });
  17258. }
  17259. }, $scope.options.templateOptions.refreshDelay);
  17260. }
  17261. };
  17262. $scope._refresh({});
  17263. },
  17264. ],
  17265. });
  17266. //简易上传附件组件
  17267. formlyConfigProvider.setType({
  17268. name: "ui-uploadFiles",
  17269. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  17270. wrapper: ["bootstrapHasError"],
  17271. controller: [
  17272. "$scope",
  17273. function ($scope) {
  17274. if (angular.isUndefined($scope.form.dropState)) {
  17275. $scope.form.dropState = false;
  17276. }
  17277. //附件上传数据
  17278. var uploader = ($scope.uploader =
  17279. $scope.options.templateOptions.fileUploader);
  17280. //$scope.options.templateOptions.uploader();
  17281. // FILTERS
  17282. uploader.filters.push({
  17283. name: "customFilter",
  17284. fn: function (item /*{File|FileLikeObject}*/, options) {
  17285. return this.queue.length < 10;
  17286. },
  17287. });
  17288. $scope.dropfile = function (
  17289. APIService,
  17290. processInstanceId,
  17291. taskId,
  17292. userId
  17293. ) {
  17294. uploader.onBeforeUploadItem = function (item) {
  17295. angular.extend(item.headers, $rootScope.getSession());
  17296. item.url = APIService.saveAttachments(
  17297. processInstanceId,
  17298. taskId,
  17299. userId
  17300. ).getRequestedUrl();
  17301. item.formData.push({
  17302. fileName: item.file.name,
  17303. });
  17304. console.info("onBeforeUploadItem", item);
  17305. };
  17306. };
  17307. // CALLBACKS
  17308. uploader.onWhenAddingFileFailed = function (
  17309. item /*{File|FileLikeObject}*/,
  17310. filter,
  17311. options
  17312. ) {
  17313. console.info("onWhenAddingFileFailed", item, filter, options);
  17314. };
  17315. uploader.onAfterAddingFile = function (fileItem) {
  17316. console.info("onAfterAddingFile", fileItem);
  17317. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17318. alert("文件过大");
  17319. fileItem.uploader.queue.pop();
  17320. console.log($scope);
  17321. }
  17322. };
  17323. uploader.onAfterAddingAll = function (addedFileItems) {
  17324. // console.info('onAfterAddingAll', addedFileItems);
  17325. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17326. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17327. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17328. // console.log(123)
  17329. };
  17330. uploader.onBeforeUploadItem = function (item) {
  17331. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17332. // // $scope.uploader.options.url();
  17333. // $scope.uploader.onBeforeUploadItem = function(item) {
  17334. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17335. // console.info('onBeforeUploadItem', item);
  17336. // };
  17337. // $scope.uploader.uploadAll();
  17338. // }
  17339. console.info("onBeforeUploadItem", item);
  17340. };
  17341. uploader.onProgressItem = function (fileItem, progress) {
  17342. console.info("onProgressItem", fileItem, progress);
  17343. };
  17344. uploader.onProgressAll = function (progress) {
  17345. console.info("onProgressAll", progress);
  17346. };
  17347. uploader.onSuccessItem = function (
  17348. fileItem,
  17349. response,
  17350. status,
  17351. headers
  17352. ) {
  17353. console.info("onSuccessItem", fileItem, response, status, headers);
  17354. };
  17355. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17356. console.info("onErrorItem", fileItem, response, status, headers);
  17357. };
  17358. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17359. console.info("onCancelItem", fileItem, response, status, headers);
  17360. };
  17361. uploader.onCompleteItem = function (
  17362. fileItem,
  17363. response,
  17364. status,
  17365. headers
  17366. ) {
  17367. console.info("onCompleteItem", fileItem, response, status, headers);
  17368. };
  17369. uploader.onCompleteAll = function () {
  17370. console.info("onCompleteAll");
  17371. };
  17372. },
  17373. ],
  17374. });
  17375. //无上传按钮附件上传组件
  17376. formlyConfigProvider.setType({
  17377. name: "ui-dropfilenotup",
  17378. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17379. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17380. controller: [
  17381. "$scope",
  17382. function ($scope) {
  17383. if (angular.isUndefined($scope.form.dropState)) {
  17384. $scope.form.dropState = false;
  17385. }
  17386. //附件上传数据
  17387. var uploader = ($scope.uploader =
  17388. $scope.options.templateOptions.fileUploader);
  17389. //$scope.options.templateOptions.uploader();
  17390. // FILTERS
  17391. uploader.filters.push({
  17392. name: "customFilter",
  17393. fn: function (item /*{File|FileLikeObject}*/, options) {
  17394. return this.queue.length < 10;
  17395. },
  17396. });
  17397. $scope.dropfile = function (
  17398. APIService,
  17399. processInstanceId,
  17400. taskId,
  17401. userId
  17402. ) {
  17403. uploader.onBeforeUploadItem = function (item) {
  17404. angular.extend(item.headers, $rootScope.getSession());
  17405. item.url = APIService.saveAttachments(
  17406. processInstanceId,
  17407. taskId,
  17408. userId
  17409. ).getRequestedUrl();
  17410. item.formData.push({
  17411. fileName: item.file.name,
  17412. });
  17413. console.info("onBeforeUploadItem", item);
  17414. };
  17415. uploader.uploadAll();
  17416. };
  17417. // CALLBACKS
  17418. uploader.onWhenAddingFileFailed = function (
  17419. item /*{File|FileLikeObject}*/,
  17420. filter,
  17421. options
  17422. ) {
  17423. console.info("onWhenAddingFileFailed", item, filter, options);
  17424. };
  17425. uploader.onAfterAddingFile = function (fileItem) {
  17426. console.info("onAfterAddingFile", fileItem);
  17427. };
  17428. uploader.onAfterAddingAll = function (addedFileItems) {
  17429. console.info("onAfterAddingAll", addedFileItems);
  17430. };
  17431. uploader.onBeforeUploadItem = function (item) {
  17432. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17433. // // $scope.uploader.options.url();
  17434. // $scope.uploader.onBeforeUploadItem = function(item) {
  17435. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17436. // console.info('onBeforeUploadItem', item);
  17437. // };
  17438. // $scope.uploader.uploadAll();
  17439. // }
  17440. console.info("onBeforeUploadItem", item);
  17441. };
  17442. uploader.onProgressItem = function (fileItem, progress) {
  17443. console.info("onProgressItem", fileItem, progress);
  17444. };
  17445. uploader.onProgressAll = function (progress) {
  17446. console.info("onProgressAll", progress);
  17447. };
  17448. uploader.onSuccessItem = function (
  17449. fileItem,
  17450. response,
  17451. status,
  17452. headers
  17453. ) {
  17454. console.info("onSuccessItem", fileItem, response, status, headers);
  17455. };
  17456. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17457. console.info("onErrorItem", fileItem, response, status, headers);
  17458. };
  17459. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17460. console.info("onCancelItem", fileItem, response, status, headers);
  17461. };
  17462. uploader.onCompleteItem = function (
  17463. fileItem,
  17464. response,
  17465. status,
  17466. headers
  17467. ) {
  17468. console.info("onCompleteItem", fileItem, response, status, headers);
  17469. };
  17470. uploader.onCompleteAll = function () {
  17471. console.info("onCompleteAll");
  17472. };
  17473. },
  17474. ],
  17475. });
  17476. //无按钮知识库上传
  17477. formlyConfigProvider.setType({
  17478. name: "ui-dropfielkn",
  17479. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17480. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17481. controller: [
  17482. "$scope",
  17483. function ($scope) {
  17484. if (angular.isUndefined($scope.form.dropState)) {
  17485. $scope.form.dropState = false;
  17486. }
  17487. //附件上传数据
  17488. var uploader = ($scope.uploader =
  17489. $scope.options.templateOptions.fileUploader);
  17490. //$scope.options.templateOptions.uploader();
  17491. // FILTERS
  17492. uploader.filters.push({
  17493. name: "customFilter",
  17494. fn: function (item /*{File|FileLikeObject}*/, options) {
  17495. return this.queue.length < 10;
  17496. },
  17497. });
  17498. $scope.dropfile = function (
  17499. APIService,
  17500. processInstanceId,
  17501. taskId,
  17502. userId
  17503. ) {
  17504. uploader.onBeforeUploadItem = function (item) {
  17505. angular.extend(item.headers, $rootScope.getSession());
  17506. item.url = APIService.addFile(
  17507. processInstanceId,
  17508. taskId,
  17509. userId
  17510. ).getRequestedUrl();
  17511. item.formData.push({
  17512. fileName: item.file.name,
  17513. });
  17514. console.info("onBeforeUploadItem", item);
  17515. };
  17516. uploader.uploadAll();
  17517. };
  17518. // CALLBACKS
  17519. uploader.onWhenAddingFileFailed = function (
  17520. item /*{File|FileLikeObject}*/,
  17521. filter,
  17522. options
  17523. ) {
  17524. console.info("onWhenAddingFileFailed", item, filter, options);
  17525. };
  17526. uploader.onAfterAddingFile = function (fileItem) {
  17527. console.info("onAfterAddingFile", fileItem);
  17528. };
  17529. uploader.onAfterAddingAll = function (addedFileItems) {
  17530. console.info("onAfterAddingAll", addedFileItems);
  17531. };
  17532. uploader.onBeforeUploadItem = function (item) {
  17533. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17534. // // $scope.uploader.options.url();
  17535. // $scope.uploader.onBeforeUploadItem = function(item) {
  17536. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17537. // console.info('onBeforeUploadItem', item);
  17538. // };
  17539. // $scope.uploader.uploadAll();
  17540. // }
  17541. console.info("onBeforeUploadItem", item);
  17542. };
  17543. uploader.onProgressItem = function (fileItem, progress) {
  17544. console.info("onProgressItem", fileItem, progress);
  17545. };
  17546. uploader.onProgressAll = function (progress) {
  17547. console.info("onProgressAll", progress);
  17548. };
  17549. uploader.onSuccessItem = function (
  17550. fileItem,
  17551. response,
  17552. status,
  17553. headers
  17554. ) {
  17555. console.info("onSuccessItem", fileItem, response, status, headers);
  17556. };
  17557. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17558. console.info("onErrorItem", fileItem, response, status, headers);
  17559. };
  17560. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17561. console.info("onCancelItem", fileItem, response, status, headers);
  17562. };
  17563. uploader.onCompleteItem = function (
  17564. fileItem,
  17565. response,
  17566. status,
  17567. headers
  17568. ) {
  17569. console.info("onCompleteItem", fileItem, response, status, headers);
  17570. };
  17571. uploader.onCompleteAll = function () {
  17572. console.info("onCompleteAll");
  17573. };
  17574. },
  17575. ],
  17576. });
  17577. //附件上传列表组件
  17578. formlyConfigProvider.setType({
  17579. name: "ui-dropfile",
  17580. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  17581. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17582. controller: [
  17583. "$scope",
  17584. "$rootScope",
  17585. function ($scope, $rootScope) {
  17586. if (angular.isUndefined($scope.form.dropState)) {
  17587. $scope.form.dropState = false;
  17588. }
  17589. //附件上传数据
  17590. var uploader = ($scope.uploader =
  17591. $scope.options.templateOptions.fileUploader);
  17592. //$scope.options.templateOptions.uploader();
  17593. // FILTERS
  17594. uploader.filters.push({
  17595. name: "customFilter",
  17596. fn: function (item /*{File|FileLikeObject}*/, options) {
  17597. return this.queue.length < 10;
  17598. },
  17599. });
  17600. $scope.dropfile = function (
  17601. APIService,
  17602. processInstanceId,
  17603. taskId,
  17604. userId
  17605. ) {
  17606. uploader.onBeforeUploadItem = function (item) {
  17607. angular.extend(item.headers, $rootScope.getSession());
  17608. if (
  17609. $scope.options.templateOptions.upservice &&
  17610. $scope.options.templateOptions.formname
  17611. ) {
  17612. // if ($scope.options.templateOptions.formket) {
  17613. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  17614. // } else {
  17615. item.url = APIService[$scope.options.templateOptions.upservice](
  17616. $scope.model[$scope.options.templateOptions.formname].id,
  17617. taskId,
  17618. userId
  17619. ).getRequestedUrl();
  17620. // }
  17621. } else {
  17622. item.url = APIService.saveAttachments(
  17623. processInstanceId,
  17624. taskId,
  17625. userId
  17626. ).getRequestedUrl();
  17627. }
  17628. item.formData.push({
  17629. filename: item.file.name,
  17630. });
  17631. console.info("onBeforeUploadItem", item);
  17632. };
  17633. uploader.uploadAll();
  17634. };
  17635. // CALLBACKS
  17636. uploader.onWhenAddingFileFailed = function (
  17637. item /*{File|FileLikeObject}*/,
  17638. filter,
  17639. options
  17640. ) {
  17641. console.info("onWhenAddingFileFailed", item, filter, options);
  17642. };
  17643. uploader.onAfterAddingFile = function (fileItem) {
  17644. console.info("onAfterAddingFile", fileItem);
  17645. };
  17646. uploader.onAfterAddingAll = function (addedFileItems) {
  17647. console.info("onAfterAddingAll", addedFileItems);
  17648. };
  17649. uploader.onBeforeUploadItem = function (item) {
  17650. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17651. // // $scope.uploader.options.url();
  17652. // $scope.uploader.onBeforeUploadItem = function(item) {
  17653. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17654. // console.info('onBeforeUploadItem', item);
  17655. // };
  17656. // $scope.uploader.uploadAll();
  17657. // }
  17658. console.info("onBeforeUploadItem", item);
  17659. };
  17660. uploader.onProgressItem = function (fileItem, progress) {
  17661. console.info("onProgressItem", fileItem, progress);
  17662. };
  17663. uploader.onProgressAll = function (progress) {
  17664. console.info("onProgressAll", progress);
  17665. };
  17666. uploader.onSuccessItem = function (
  17667. fileItem,
  17668. response,
  17669. status,
  17670. headers
  17671. ) {
  17672. console.info("onSuccessItem", fileItem, response, status, headers);
  17673. };
  17674. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17675. console.info("onErrorItem", fileItem, response, status, headers);
  17676. };
  17677. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17678. console.info("onCancelItem", fileItem, response, status, headers);
  17679. };
  17680. uploader.onCompleteItem = function (
  17681. fileItem,
  17682. response,
  17683. status,
  17684. headers
  17685. ) {
  17686. console.info("onCompleteItem", fileItem, response, status, headers);
  17687. };
  17688. uploader.onCompleteAll = function () {
  17689. console.info("onCompleteAll");
  17690. };
  17691. },
  17692. ],
  17693. });
  17694. //简易附件展示下载列表组件
  17695. formlyConfigProvider.setType({
  17696. name: "ui-dropFiles",
  17697. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  17698. defaultOptions: function (options) {
  17699. return {
  17700. templateOptions: {
  17701. refresh: function (APIService, processInstanceId, data) {
  17702. return APIService.listAttachments(processInstanceId);
  17703. },
  17704. downloadUri: function (APIService, contentId) {
  17705. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17706. },
  17707. view: function (APIService, contentId) {
  17708. return APIService.attachmentsPreviewUrl(contentId);
  17709. },
  17710. download: function (APIService, contentId, item) {
  17711. var item = {
  17712. url: APIService.download(contentId),
  17713. headers: headers,
  17714. };
  17715. return item;
  17716. },
  17717. refreshDelay: 0,
  17718. },
  17719. };
  17720. },
  17721. controller: [
  17722. "$scope",
  17723. "$timeout",
  17724. "$modal",
  17725. "$rootScope",
  17726. "$http",
  17727. "up_down_file",
  17728. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17729. var _refreshDelayPromise;
  17730. // $scope.downloadUrl = function(contentId){
  17731. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  17732. // };
  17733. $scope.download = function (contentId, filename, token) {
  17734. // console.log(contentId, filename, token)
  17735. //附件下载
  17736. var downUrl = up_down_file
  17737. .downloadAttachment("common/common/downloadAttachment", token)
  17738. .getRequestedUrl();
  17739. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17740. // console.log(downUrl)
  17741. var a = document.createElement("a");
  17742. a.href = downUrl;
  17743. a.target = "_blank";
  17744. a.download = filename;
  17745. document.body.appendChild(a);
  17746. a.click();
  17747. };
  17748. $scope.view = function (contentId, token, filename, type) {
  17749. $scope.options.templateOptions
  17750. .view($scope.options.templateOptions.ApiService, contentId)
  17751. .then(function (response) {
  17752. if (response.state == 200) {
  17753. window.open(response.previewUrl);
  17754. }
  17755. });
  17756. };
  17757. /**
  17758. * refresh
  17759. */
  17760. $scope._refresh = function (refreshAttr) {
  17761. $scope.attachments = [];
  17762. if (refreshAttr !== undefined) {
  17763. if (_refreshDelayPromise) {
  17764. $timeout.cancel(_refreshDelayPromise);
  17765. }
  17766. _refreshDelayPromise = $timeout(function () {
  17767. // 暂存附件
  17768. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17769. $scope.options.templateOptions
  17770. .refresh(
  17771. $scope.options.templateOptions.ApiService,
  17772. $scope.options.templateOptions.processInstanceId,
  17773. {
  17774. idx: 0,
  17775. sum: 1000,
  17776. }
  17777. )
  17778. .then(function (response) {
  17779. var myData =
  17780. $scope.options.templateOptions.Restangular.stripRestangular(
  17781. response
  17782. );
  17783. if (myData) {
  17784. for (var i = 0; i < myData.data.length; i++) {
  17785. $scope.attachments.push(myData.data[i]);
  17786. }
  17787. }
  17788. $scope.options.templateOptions
  17789. .refresh(
  17790. $scope.options.templateOptions.ApiService,
  17791. $scope.$parent.$parent.$parent.model.save_fileId,
  17792. {
  17793. idx: 0,
  17794. sum: 1000,
  17795. }
  17796. )
  17797. .then(function (response2) {
  17798. var myData2 =
  17799. $scope.options.templateOptions.Restangular.stripRestangular(
  17800. response2
  17801. );
  17802. if (myData2) {
  17803. for (var i = 0; i < myData2.data.length; i++) {
  17804. $scope.attachments.push(myData2.data[i]);
  17805. }
  17806. // 只展示除图片以外的附件
  17807. var a = [];
  17808. $scope.attachments.forEach((e) => {
  17809. if (
  17810. e.suffix == "jpeg" ||
  17811. e.suffix == "jpg" ||
  17812. e.suffix == "svg" ||
  17813. e.suffix == "png" ||
  17814. e.suffix == "bmp" ||
  17815. e.suffix == "gif" ||
  17816. e.suffix == "tif"
  17817. ) {
  17818. // $scope.imgs.push(e)
  17819. } else {
  17820. a.push(e);
  17821. }
  17822. });
  17823. $scope.attachments = a;
  17824. }
  17825. console.log($scope.attachments);
  17826. });
  17827. });
  17828. // 正常附件
  17829. } else {
  17830. $scope.options.templateOptions
  17831. .refresh(
  17832. $scope.options.templateOptions.ApiService,
  17833. $scope.options.templateOptions.processInstanceId,
  17834. {
  17835. idx: 0,
  17836. sum: 1000,
  17837. }
  17838. )
  17839. .then(function (response) {
  17840. var myData =
  17841. $scope.options.templateOptions.Restangular.stripRestangular(
  17842. response
  17843. );
  17844. if (myData) {
  17845. $scope.attachments = myData.data;
  17846. // 只展示除图片以外的附件
  17847. var a = [];
  17848. $scope.attachments.forEach((e) => {
  17849. if (
  17850. e.suffix == "jpeg" ||
  17851. e.suffix == "jpg" ||
  17852. e.suffix == "svg" ||
  17853. e.suffix == "png" ||
  17854. e.suffix == "bmp" ||
  17855. e.suffix == "gif" ||
  17856. e.suffix == "tif"
  17857. ) {
  17858. // $scope.imgs.push(e)
  17859. } else {
  17860. a.push(e);
  17861. }
  17862. });
  17863. $scope.attachments = a;
  17864. console.log($scope.attachments);
  17865. }
  17866. });
  17867. }
  17868. }, $scope.options.templateOptions.refreshDelay);
  17869. }
  17870. };
  17871. $scope._refresh({});
  17872. // $scope.attachments = $scope.model[$scope.options.key]
  17873. },
  17874. ],
  17875. });
  17876. //知识库附件上传
  17877. formlyConfigProvider.setType({
  17878. name: "ui-dropfielknow",
  17879. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  17880. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17881. controller: [
  17882. "$scope",
  17883. "$rootScope",
  17884. function ($scope, $rootScope) {
  17885. if (angular.isUndefined($scope.form.dropState)) {
  17886. $scope.form.dropState = false;
  17887. }
  17888. //附件上传数据
  17889. var uploader = ($scope.uploader =
  17890. $scope.options.templateOptions.fileUploader);
  17891. //$scope.options.templateOptions.uploader();
  17892. // FILTERS
  17893. uploader.filters.push({
  17894. name: "customFilter",
  17895. fn: function (item /*{File|FileLikeObject}*/, options) {
  17896. return this.queue.length < 10;
  17897. },
  17898. });
  17899. $scope.dropfile = function (
  17900. APIService,
  17901. processInstanceId,
  17902. taskId,
  17903. userId
  17904. ) {
  17905. uploader.onBeforeUploadItem = function (item) {
  17906. angular.extend(item.headers, $rootScope.getSession());
  17907. item.url = APIService.upload(
  17908. processInstanceId,
  17909. taskId,
  17910. userId
  17911. ).getRequestedUrl();
  17912. item.formData.push({
  17913. fileName: item.file.name,
  17914. type: "solution",
  17915. solutionId: $scope.model.knowledge.id,
  17916. });
  17917. console.info("onBeforeUploadItem", item);
  17918. };
  17919. uploader.uploadAll();
  17920. };
  17921. // CALLBACKS
  17922. uploader.onWhenAddingFileFailed = function (
  17923. item /*{File|FileLikeObject}*/,
  17924. filter,
  17925. options
  17926. ) {
  17927. console.info("onWhenAddingFileFailed", item, filter, options);
  17928. };
  17929. uploader.onAfterAddingFile = function (fileItem) {
  17930. console.info("onAfterAddingFile", fileItem);
  17931. };
  17932. uploader.onAfterAddingAll = function (addedFileItems) {
  17933. console.info("onAfterAddingAll", addedFileItems);
  17934. };
  17935. uploader.onBeforeUploadItem = function (item) {
  17936. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17937. // // $scope.uploader.options.url();
  17938. // $scope.uploader.onBeforeUploadItem = function(item) {
  17939. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17940. // console.info('onBeforeUploadItem', item);
  17941. // };
  17942. // $scope.uploader.uploadAll();
  17943. // }
  17944. console.info("onBeforeUploadItem", item);
  17945. };
  17946. uploader.onProgressItem = function (fileItem, progress) {
  17947. console.info("onProgressItem", fileItem, progress);
  17948. };
  17949. uploader.onProgressAll = function (progress) {
  17950. console.info("onProgressAll", progress);
  17951. };
  17952. uploader.onSuccessItem = function (
  17953. fileItem,
  17954. response,
  17955. status,
  17956. headers
  17957. ) {
  17958. console.info("onSuccessItem", fileItem, response, status, headers);
  17959. };
  17960. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17961. console.info("onErrorItem", fileItem, response, status, headers);
  17962. };
  17963. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17964. console.info("onCancelItem", fileItem, response, status, headers);
  17965. };
  17966. uploader.onCompleteItem = function (
  17967. fileItem,
  17968. response,
  17969. status,
  17970. headers
  17971. ) {
  17972. console.info("onCompleteItem", fileItem, response, status, headers);
  17973. };
  17974. uploader.onCompleteAll = function () {
  17975. console.info("onCompleteAll");
  17976. };
  17977. },
  17978. ],
  17979. });
  17980. //知识库附件下载列表
  17981. formlyConfigProvider.setType({
  17982. name: "ui-dropfileknowledge",
  17983. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  17984. defaultOptions: function (options) {
  17985. return {
  17986. templateOptions: {
  17987. refresh: function (APIService, contentId, data) {
  17988. return APIService.fetchDataList(contentId, data);
  17989. },
  17990. downloadUri: function (APIService, contentId) {
  17991. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17992. },
  17993. download: function (APIService, contentId) {
  17994. return APIService.getSolutionDowpath(contentId);
  17995. },
  17996. view: function (attachmentId) {
  17997. // return APIService.attachmentsPreviewUrl(contentId);
  17998. },
  17999. refreshDelay: 0,
  18000. },
  18001. };
  18002. },
  18003. controller: [
  18004. "$scope",
  18005. "$timeout",
  18006. "$modal",
  18007. "$rootScope",
  18008. "api_solution",
  18009. "$http",
  18010. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  18011. var _refreshDelayPromise;
  18012. $scope.attachments = [];
  18013. $scope.downloadUrl = function (contentId) {
  18014. return (
  18015. $scope.options.templateOptions.downloadUri(
  18016. $scope.options.templateOptions.ApiService,
  18017. contentId
  18018. ) || "#"
  18019. );
  18020. };
  18021. $scope.download = function (contentId, filename) {
  18022. $http({
  18023. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  18024. contentId
  18025. ).getRequestedUrl(),
  18026. method: "GET",
  18027. headers: {
  18028. //'Content-type' : 'application/xls',
  18029. Accept: "*/*",
  18030. },
  18031. responseType: "arraybuffer",
  18032. })
  18033. .success(function (data, status, headers, config) {
  18034. var file = new Blob([data], {
  18035. type: "application/octet-stream",
  18036. });
  18037. //trick to download store a file having its URL
  18038. var fileURL = URL.createObjectURL(file);
  18039. var a = document.createElement("a");
  18040. a.href = fileURL;
  18041. a.target = "_blank";
  18042. a.download = filename;
  18043. document.body.appendChild(a);
  18044. a.click();
  18045. })
  18046. .error(function (data, status, headers, config) {
  18047. // console.log(data);
  18048. });
  18049. };
  18050. $scope.view = function (contentId, filename, attachment) {
  18051. var index = filename.indexOf(".");
  18052. var type = filename.substring(index + 1);
  18053. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18054. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  18055. // var modalInstance = $modal.open({
  18056. // backdrop: false,
  18057. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18058. // controller: function($scope, scope, $modalInstance, filename) {
  18059. // $scope.title = filename;
  18060. // $scope.imageurl = scope.imageurl;
  18061. // $scope.cancel = function() {
  18062. // $modalInstance.dismiss('cancel');
  18063. // }
  18064. // },
  18065. // resolve: {
  18066. // scope: function() {
  18067. // return $scope;
  18068. // },
  18069. // filename: function() {
  18070. // return filename;
  18071. // }
  18072. // }
  18073. // });
  18074. // event.preventDefault();
  18075. // } else {
  18076. // for (var i = 0; i < $scope.attachments.length; i++) {
  18077. // if ($scope.attachments[i].id == attachmentId) {
  18078. window.open(attachment.previewUrl);
  18079. // }
  18080. // }
  18081. // }
  18082. };
  18083. $scope._refresh = function (refreshAttr) {
  18084. if (refreshAttr !== undefined) {
  18085. if (_refreshDelayPromise) {
  18086. $timeout.cancel(_refreshDelayPromise);
  18087. }
  18088. _refreshDelayPromise = $timeout(function () {
  18089. $scope.options.templateOptions
  18090. .refresh($scope.options.templateOptions.ApiService, "file", {
  18091. file: {
  18092. solutionId: $scope.model.knowledge.id,
  18093. },
  18094. idx: "0",
  18095. sum: "1000",
  18096. })
  18097. .then(function (response) {
  18098. var myData =
  18099. $scope.options.templateOptions.Restangular.stripRestangular(
  18100. response
  18101. );
  18102. if (myData) {
  18103. $scope.attachments = myData.list;
  18104. // $scope.view = function(attachmentId) {
  18105. // for (var i = 0; i < $scope.attachments.length; i++) {
  18106. // if ($scope.attachments[i].id == attachmentId) {
  18107. // window.open($scope.attachments[i].previewUrl);
  18108. // // var modalInstance = $modal.open({
  18109. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  18110. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  18111. // // }
  18112. // // });
  18113. // }
  18114. // }
  18115. // };
  18116. }
  18117. });
  18118. }, $scope.options.templateOptions.refreshDelay);
  18119. }
  18120. };
  18121. $scope._refresh({});
  18122. // $scope.attachments = $scope.model[$scope.options.key]
  18123. },
  18124. ],
  18125. });
  18126. //附件图片下载
  18127. formlyConfigProvider.setType({
  18128. name: "ui-downimage",
  18129. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  18130. defaultOptions: function (options) {
  18131. return {
  18132. templateOptions: {
  18133. refresh: function (APIService, processInstanceId, data) {
  18134. return APIService.listAttachments(processInstanceId, data);
  18135. },
  18136. downloadUri: function (APIService, contentId) {
  18137. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18138. },
  18139. view: function (APIService, contentId) {
  18140. return APIService.attachmentsPreviewUrl(contentId);
  18141. },
  18142. download: function (APIService, contentId, item) {
  18143. var item = {
  18144. url: APIService.download(contentId),
  18145. headers: headers,
  18146. };
  18147. return item;
  18148. },
  18149. refreshDelay: 0,
  18150. },
  18151. };
  18152. },
  18153. controller: [
  18154. "$scope",
  18155. "$timeout",
  18156. "$rootScope",
  18157. "$http",
  18158. function ($scope, $timeout, $rootScope, $http) {
  18159. var _refreshDelayPromise;
  18160. // $scope.downloadUrl = function(contentId){
  18161. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18162. // };
  18163. $scope.download = function (contentId, filename) {
  18164. // var headers=
  18165. $http({
  18166. url: $scope.options.templateOptions.ApiService.download(
  18167. contentId
  18168. ).getRequestedUrl(),
  18169. method: "GET",
  18170. headers: {
  18171. //'Content-type' : 'application/xls',
  18172. Accept: "*/*",
  18173. },
  18174. responseType: "arraybuffer",
  18175. })
  18176. .success(function (data, status, headers, config) {
  18177. var file = new Blob([data], {
  18178. type: "application/octet-stream",
  18179. });
  18180. //trick to download store a file having its URL
  18181. var fileURL = URL.createObjectURL(file);
  18182. var a = document.createElement("a");
  18183. a.href = fileURL;
  18184. a.target = "_blank";
  18185. a.download = filename;
  18186. document.body.appendChild(a);
  18187. a.click();
  18188. })
  18189. .error(function (data, status, headers, config) {
  18190. // console.log(data);
  18191. });
  18192. };
  18193. $scope.view = function (contentId) {
  18194. $scope.imageurl =
  18195. $scope.options.templateOptions.ApiService.download(
  18196. contentId
  18197. ).getRequestedUrl();
  18198. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  18199. // if (response.state == 200) {
  18200. // window.open(response.previewUrl);
  18201. // }
  18202. // })
  18203. };
  18204. /**
  18205. * refresh
  18206. */
  18207. $scope._refresh = function (refreshAttr) {
  18208. if (refreshAttr !== undefined) {
  18209. if (_refreshDelayPromise) {
  18210. $timeout.cancel(_refreshDelayPromise);
  18211. }
  18212. _refreshDelayPromise = $timeout(function () {
  18213. $scope.options.templateOptions
  18214. .refresh(
  18215. $scope.options.templateOptions.ApiService,
  18216. $scope.options.templateOptions.processInstanceId,
  18217. {
  18218. idx: 0,
  18219. sum: 1000,
  18220. }
  18221. )
  18222. .then(function (response) {
  18223. var myData =
  18224. $scope.options.templateOptions.Restangular.stripRestangular(
  18225. response
  18226. );
  18227. if (myData) {
  18228. $scope.attachments = myData.data;
  18229. }
  18230. });
  18231. }, $scope.options.templateOptions.refreshDelay);
  18232. }
  18233. };
  18234. $scope._refresh({});
  18235. // $scope.attachments = $scope.model[$scope.options.key]
  18236. },
  18237. ],
  18238. });
  18239. //附件下载列表组件
  18240. formlyConfigProvider.setType({
  18241. name: "ui-dropfiletable",
  18242. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  18243. defaultOptions: function (options) {
  18244. return {
  18245. templateOptions: {
  18246. refresh: function (APIService, processInstanceId, data) {
  18247. return APIService.listAttachments(processInstanceId, data);
  18248. },
  18249. downloadUri: function (APIService, contentId) {
  18250. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18251. },
  18252. view: function (APIService, contentId) {
  18253. return APIService.attachmentsPreviewUrl(contentId);
  18254. },
  18255. download: function (APIService, contentId, item) {
  18256. var item = {
  18257. url: APIService.download(contentId),
  18258. headers: headers,
  18259. };
  18260. return item;
  18261. },
  18262. refreshDelay: 0,
  18263. },
  18264. };
  18265. },
  18266. controller: [
  18267. "$scope",
  18268. "$timeout",
  18269. "$modal",
  18270. "$rootScope",
  18271. "$http",
  18272. function ($scope, $timeout, $modal, $rootScope, $http) {
  18273. var _refreshDelayPromise;
  18274. // $scope.downloadUrl = function(contentId){
  18275. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18276. // };
  18277. $scope.download = function (contentId, filename) {
  18278. // var headers=
  18279. $http({
  18280. url: $scope.options.templateOptions.ApiService.download(
  18281. contentId
  18282. ).getRequestedUrl(),
  18283. method: "GET",
  18284. headers: {
  18285. //'Content-type' : 'application/xls',
  18286. Accept: "*/*",
  18287. },
  18288. responseType: "arraybuffer",
  18289. })
  18290. .success(function (data, status, headers, config) {
  18291. var file = new Blob([data], {
  18292. type: "application/octet-stream",
  18293. });
  18294. //trick to download store a file having its URL
  18295. var fileURL = URL.createObjectURL(file);
  18296. var a = document.createElement("a");
  18297. a.href = fileURL;
  18298. a.target = "_blank";
  18299. a.download = filename;
  18300. document.body.appendChild(a);
  18301. a.click();
  18302. })
  18303. .error(function (data, status, headers, config) {
  18304. // console.log(data);
  18305. });
  18306. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  18307. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  18308. // var file = new Blob([response], {
  18309. // type : 'application/octet-stream'
  18310. // });
  18311. // // var filename = filename;
  18312. // //var file = new Blob([response], {type: 'application/pdf'});
  18313. // var fileURL = URL.createObjectURL(file);
  18314. // var a = document.createElement('a');
  18315. // a.href = fileURL;
  18316. // a.target = '_blank';
  18317. // a.download = filename ;
  18318. // document.body.appendChild(a);
  18319. // a.click();
  18320. // })
  18321. };
  18322. $scope.view = function (contentId, token, filename, type) {
  18323. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18324. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  18325. // var modalInstance = $modal.open({
  18326. // backdrop: false,
  18327. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18328. // controller: function($scope, scope, $modalInstance, filename) {
  18329. // $scope.title = filename;
  18330. // $scope.imageurl = scope.imageurl;
  18331. // $scope.cancel = function() {
  18332. // $modalInstance.dismiss('cancel');
  18333. // }
  18334. // },
  18335. // resolve: {
  18336. // scope: function() {
  18337. // return $scope;
  18338. // },
  18339. // filename: function() {
  18340. // return filename;
  18341. // }
  18342. // }
  18343. // });
  18344. // event.preventDefault();
  18345. // } else {
  18346. $scope.options.templateOptions
  18347. .view($scope.options.templateOptions.ApiService, contentId)
  18348. .then(function (response) {
  18349. if (response.state == 200) {
  18350. window.open(response.previewUrl);
  18351. }
  18352. });
  18353. // }
  18354. };
  18355. /**
  18356. * refresh
  18357. */
  18358. $scope._refresh = function (refreshAttr) {
  18359. if (refreshAttr !== undefined) {
  18360. if (_refreshDelayPromise) {
  18361. $timeout.cancel(_refreshDelayPromise);
  18362. }
  18363. _refreshDelayPromise = $timeout(function () {
  18364. $scope.options.templateOptions
  18365. .refresh(
  18366. $scope.options.templateOptions.ApiService,
  18367. $scope.options.templateOptions.processInstanceId,
  18368. {
  18369. idx: 0,
  18370. sum: 1000,
  18371. }
  18372. )
  18373. .then(function (response) {
  18374. var myData =
  18375. $scope.options.templateOptions.Restangular.stripRestangular(
  18376. response
  18377. );
  18378. if (myData) {
  18379. $scope.attachments = myData.data;
  18380. }
  18381. });
  18382. }, $scope.options.templateOptions.refreshDelay);
  18383. }
  18384. };
  18385. $scope._refresh({});
  18386. // $scope.attachments = $scope.model[$scope.options.key]
  18387. },
  18388. ],
  18389. });
  18390. //微信附件下载列表组件
  18391. formlyConfigProvider.setType({
  18392. name: "ui-dropfilewechat",
  18393. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  18394. defaultOptions: function (options) {
  18395. return {
  18396. templateOptions: {
  18397. // refresh: function(APIService, processInstanceId, data) {
  18398. // return APIService.listAttachments(processInstanceId, data);
  18399. // },
  18400. // downloadUri: function(APIService, contentId) {
  18401. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  18402. // },
  18403. view: function (APIService, contentId) {
  18404. // return APIService.attachmentsPreviewUrl(contentId);
  18405. return APIService.attachmentsPreviewUrl(contentId);
  18406. },
  18407. download: function (APIService, contentId, item) {
  18408. var item = {
  18409. url: APIService.download(contentId),
  18410. headers: headers,
  18411. };
  18412. return item;
  18413. },
  18414. // download: function(APIService, contentId, item) {
  18415. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  18416. // return item;
  18417. // },
  18418. refreshDelay: 0,
  18419. },
  18420. };
  18421. },
  18422. controller: [
  18423. "$scope",
  18424. "$timeout",
  18425. "$modal",
  18426. "$stateParams",
  18427. "$rootScope",
  18428. "$http",
  18429. "api_wechatfile",
  18430. function (
  18431. $scope,
  18432. $timeout,
  18433. $modal,
  18434. $stateParams,
  18435. $rootScope,
  18436. $http,
  18437. api_wechatfile
  18438. ) {
  18439. var _refreshDelayPromise;
  18440. // $scope.downloadUrl = function(contentId){
  18441. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18442. // };
  18443. $scope.attachments = {};
  18444. $scope.previewUrl = "";
  18445. $scope.download = function (token, filename) {
  18446. // var headers=
  18447. console.log($scope);
  18448. $http({
  18449. url: $scope.options.templateOptions.ApiService.jry_download(
  18450. token
  18451. ).getRequestedUrl(),
  18452. method: "GET",
  18453. headers: {
  18454. //'Content-type' : 'application/xls',
  18455. Accept: "*/*",
  18456. },
  18457. responseType: "arraybuffer",
  18458. })
  18459. .success(function (data, status, headers, config) {
  18460. var file = new Blob([data], {
  18461. type: "application/octet-stream",
  18462. });
  18463. //trick to download store a file having its URL
  18464. var fileURL = URL.createObjectURL(file);
  18465. var a = document.createElement("a");
  18466. a.href = fileURL;
  18467. a.target = "_blank";
  18468. a.download = filename;
  18469. document.body.appendChild(a);
  18470. a.click();
  18471. })
  18472. .error(function (data, status, headers, config) {
  18473. // console.log(data);
  18474. });
  18475. };
  18476. $scope.view = function (contentId, token, filename, type, previewUrl) {
  18477. // if (type) {
  18478. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  18479. // var modalInstance = $modal.open({
  18480. // backdrop: false,
  18481. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18482. // controller: function($scope, scope, $modalInstance, filename) {
  18483. // $scope.title = filename;
  18484. // $scope.imageurl = scope.imageurl;
  18485. // $scope.cancel = function() {
  18486. // $modalInstance.dismiss('cancel');
  18487. // }
  18488. // },
  18489. // resolve: {
  18490. // scope: function() {
  18491. // return $scope;
  18492. // },
  18493. // filename: function() {
  18494. // return filename;
  18495. // }
  18496. // }
  18497. // });
  18498. // event.preventDefault();
  18499. // } else {
  18500. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  18501. // if (response.state == 200) {
  18502. // window.open(response.previewUrl);
  18503. // }
  18504. // })
  18505. window.open(previewUrl);
  18506. // }
  18507. };
  18508. /**
  18509. * refresh
  18510. */
  18511. $scope._refresh = function (refreshAttr) {
  18512. if (refreshAttr !== undefined) {
  18513. if (_refreshDelayPromise) {
  18514. $timeout.cancel(_refreshDelayPromise);
  18515. }
  18516. _refreshDelayPromise = $timeout(function () {
  18517. // console.log(JSON.parse($stateParams.model))
  18518. var incidentChart = {};
  18519. if ($stateParams.model) {
  18520. incidentChart = JSON.parse($stateParams.model).model;
  18521. }
  18522. $scope.options.templateOptions
  18523. .refresh(
  18524. $scope.options.templateOptions.ApiService,
  18525. $scope.model
  18526. )
  18527. .then(function (response) {
  18528. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  18529. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  18530. var myData =
  18531. $scope.options.templateOptions.Restangular.stripRestangular(
  18532. response
  18533. );
  18534. if (myData) {
  18535. $scope.attachments = myData.data;
  18536. }
  18537. });
  18538. }, $scope.options.templateOptions.refreshDelay);
  18539. }
  18540. };
  18541. $scope._refresh({});
  18542. // $scope.attachments = $scope.model[$scope.options.key]
  18543. },
  18544. ],
  18545. });
  18546. formlyConfigProvider.setType({
  18547. name: "ui-paralleltask",
  18548. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  18549. defaultOptions: function (options) {
  18550. return {
  18551. templateOptions: {
  18552. refresh: function (APIService, processInstanceId, data) {
  18553. //return APIService.listAttachments(processInstanceId, data);
  18554. },
  18555. refreshDelay: 0,
  18556. },
  18557. };
  18558. },
  18559. controller: ["$scope", "$timeout", function ($scope, $timeout) {}],
  18560. });
  18561. //repeatSection
  18562. //
  18563. formlyConfigProvider.setType({
  18564. name: "ui-repeatSection",
  18565. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  18566. defaultOptions: function (options) {
  18567. return {
  18568. templateOptions: {
  18569. unique: 1,
  18570. initDisplay: false,
  18571. },
  18572. };
  18573. },
  18574. controller: function ($scope) {
  18575. //$scope.options.templateOptions.unique;
  18576. $scope.formOptions = {
  18577. formState: $scope.formState,
  18578. };
  18579. $scope.addNew = addNew;
  18580. $scope.copyFields = copyFields;
  18581. function copyFields(fields) {
  18582. fields = angular.copy(fields);
  18583. addRandomIds(fields);
  18584. return fields;
  18585. }
  18586. function addNew() {
  18587. $scope.model[$scope.options.key] =
  18588. $scope.model[$scope.options.key] || [];
  18589. var repeatsection = $scope.model[$scope.options.key];
  18590. var lastSection = repeatsection[repeatsection.length - 1];
  18591. var newsection = {};
  18592. repeatsection.push(newsection);
  18593. }
  18594. function addRandomIds(fields) {
  18595. $scope.options.templateOptions.unique++;
  18596. angular.forEach(fields, function (field, index) {
  18597. if (field.fieldGroup) {
  18598. addRandomIds(field.fieldGroup);
  18599. return; // fieldGroups don't need an ID
  18600. }
  18601. if (field.templateOptions && field.templateOptions.fields) {
  18602. addRandomIds(field.templateOptions.fields);
  18603. }
  18604. field.id =
  18605. field.id ||
  18606. field.key +
  18607. "_" +
  18608. index +
  18609. "_" +
  18610. $scope.options.templateOptions.unique +
  18611. getRandomInt(0, 9999);
  18612. });
  18613. }
  18614. function getRandomInt(min, max) {
  18615. return Math.floor(Math.random() * (max - min)) + min;
  18616. }
  18617. if ($scope.options.templateOptions.initDisplay) {
  18618. addNew();
  18619. }
  18620. },
  18621. });
  18622. //时间轴任务列表组件
  18623. //cmdb控件
  18624. formlyConfigProvider.setType({
  18625. name: "ui-cmdb",
  18626. extends: "input",
  18627. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  18628. defaultOptions: function (options) {
  18629. return {
  18630. templateOptions: {
  18631. onClick: function (size, options, modal, event, model) {
  18632. var modalInstance = modal.open({
  18633. templateUrl:
  18634. "assets/views/customform/tpl/cmdb-modal-content.html",
  18635. controller: function (
  18636. $scope,
  18637. $modalInstance,
  18638. title,
  18639. Restangular,
  18640. APIService,
  18641. ConfigDataService,
  18642. ConfigFormService,
  18643. SweetAlert,
  18644. Toaster,
  18645. api_wechatfile
  18646. ) {
  18647. var width = ($scope.width = 600);
  18648. var height = ($scope.height = 400);
  18649. var tree;
  18650. var d3 = window.d3;
  18651. $scope.my_tree_handler = function (branch) {
  18652. //var _ref;
  18653. var classify = ($scope.classify =
  18654. branch.prefix.toLowerCase() + branch.sign);
  18655. APIService.query({
  18656. sign: classify,
  18657. }).then(function (data) {
  18658. var myData = Restangular.stripRestangular(data);
  18659. // console.log(myData.data.node);
  18660. if (myData.data && myData.status == 200) {
  18661. var ret = myData.data;
  18662. redrawSvg(myData);
  18663. }
  18664. });
  18665. };
  18666. $scope.my_data = [];
  18667. function convertListToTree(data, treeMap) {
  18668. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  18669. var root = null; //Initially set our loop to null
  18670. var parentNode = null;
  18671. //loop over data
  18672. for (var i = 0; i < data.length; i++) {
  18673. var datum = data[i];
  18674. //each node will have children, so let's give it a "children" poperty
  18675. datum.children = [];
  18676. //add an entry for this node to the map so that any future children can
  18677. //lookup the parent
  18678. idToNodeMap[datum.id] = datum;
  18679. //Does this node have a parent?
  18680. if (
  18681. typeof datum.parent === "undefined" ||
  18682. datum.parent == null
  18683. ) {
  18684. //Doesn't look like it, so this node is the root of the tree
  18685. root = datum;
  18686. treeMap[datum.id] = root;
  18687. } else {
  18688. //This node has a parent, so let's look it up using the id
  18689. parentNode = idToNodeMap[datum.parent.id];
  18690. //We don't need this property, so let's delete it.
  18691. delete datum.parent;
  18692. //Let's add the current node as a child of the parent node.
  18693. parentNode.children.push(datum);
  18694. }
  18695. }
  18696. return root;
  18697. }
  18698. function convertParentToChildList(data) {
  18699. var treeMap = {};
  18700. var list = [];
  18701. convertListToTree(data, treeMap);
  18702. angular.forEach(treeMap, function (item) {
  18703. list.push(item);
  18704. });
  18705. return list;
  18706. }
  18707. $scope.my_tree = tree = {};
  18708. $scope.try_async_load = function () {
  18709. $scope.my_data = [];
  18710. $scope.select_treedata = [];
  18711. $scope.doing_async = true;
  18712. ConfigDataService.fetchDataList("ciclassify", {
  18713. idx: 0,
  18714. sum: 100,
  18715. }).then(function (result) {
  18716. $scope.select_treedata = $scope.my_data =
  18717. convertParentToChildList(result["list"]);
  18718. $scope.doing_async = false;
  18719. });
  18720. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  18721. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  18722. // $scope.doing_async = false;
  18723. // });
  18724. };
  18725. $scope.select_treedata = [];
  18726. $scope.propTypeOptions = [];
  18727. $scope.try_async_load();
  18728. $scope.onFilterCallback = function (item) {
  18729. //console.log(item);
  18730. if (
  18731. angular.isDefined(item.children) &&
  18732. item.children.length >= 1
  18733. ) {
  18734. //not valid
  18735. } else {
  18736. var tempclassify = item.prefix.toLowerCase() + item.sign;
  18737. $scope.cifilter_classic = tempclassify;
  18738. ConfigFormService.renderTabForm(tempclassify).then(
  18739. function (data) {
  18740. var myData = Restangular.stripRestangular(data);
  18741. $scope.propTypeOptions = myData;
  18742. }
  18743. );
  18744. }
  18745. };
  18746. $scope.onPropTypeChange = function (form) {
  18747. $scope.propOptions = form.fields;
  18748. };
  18749. $scope.onPropChange = function (prop) {
  18750. $scope.cifilter_prop = prop;
  18751. };
  18752. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  18753. //if(searchKey!=null&&searchKey.length>1){
  18754. var searchData = {};
  18755. if (angular.isUndefined(propObj)) {
  18756. propObj = $scope.cifilter_prop;
  18757. }
  18758. if (angular.isUndefined(ciclassify)) {
  18759. ciclassify = $scope.cifilter_classic;
  18760. }
  18761. searchData["sign"] = ciclassify;
  18762. if (angular.isDefined(propObj)) {
  18763. searchData[propObj.key] = searchKey;
  18764. }
  18765. APIService.query(searchData).then(function (response) {
  18766. var data = Restangular.stripRestangular(response);
  18767. //此处不清空nodes
  18768. var node = data.data.node;
  18769. var tempNode = [];
  18770. //nodes 或者links 要去重
  18771. for (var i = 0; i < node.length; i++) {
  18772. var tmp = 0;
  18773. for (var j = 0; j < nodes.length; j++) {
  18774. if (node[i].uuid == nodes[j].uuid) {
  18775. tmp++;
  18776. break;
  18777. }
  18778. }
  18779. if (tmp == 0) {
  18780. tempNode.push(node[i]);
  18781. }
  18782. }
  18783. for (var i = 0; i < tempNode.length; i++) {
  18784. //nodes 不清空
  18785. nodes.push(tempNode[i]);
  18786. }
  18787. restart();
  18788. });
  18789. };
  18790. $scope.refresh = function () {
  18791. nodes.length = 0;
  18792. links.length = 0;
  18793. restart();
  18794. };
  18795. $scope.traversal = function () {
  18796. if ($scope.selected_node == null) {
  18797. SweetAlert.swal({
  18798. title: "错误的操作!",
  18799. text: "没有配置项被选中!",
  18800. type: "error",
  18801. });
  18802. } else {
  18803. var uuid = $scope.selected_node.uuid;
  18804. APIService.traversal(uuid).then(function (response) {
  18805. var d = response.data;
  18806. var node = d.node;
  18807. var link = d.edge;
  18808. var tempNode = [];
  18809. var tempLink = [];
  18810. //nodes 或者links 要去重
  18811. for (var i = 0; i < node.length; i++) {
  18812. var tmp = 0;
  18813. for (var j = 0; j < nodes.length; j++) {
  18814. if (node[i].id == nodes[j].id) {
  18815. tmp++;
  18816. break;
  18817. }
  18818. }
  18819. if (tmp == 0) {
  18820. tempNode.push(node[i]);
  18821. }
  18822. }
  18823. for (var i = 0; i < link.length; i++) {
  18824. var tmp = 0;
  18825. for (var j = 0; j < links.length; j++) {
  18826. if (link[i].id == links[j].id) {
  18827. tmp++;
  18828. break;
  18829. }
  18830. }
  18831. if (tmp == 0) {
  18832. tempLink.push(link[i]);
  18833. }
  18834. }
  18835. //数据写入页面
  18836. for (var i = 0; i < tempNode.length; i++) {
  18837. //nodes 不清空
  18838. nodes.push(tempNode[i]);
  18839. }
  18840. for (var i = 0; i < tempLink.length; i++) {
  18841. //link 不清空
  18842. links.push(tempLink[i]);
  18843. }
  18844. //links转换
  18845. for (var i = 0; i < links.length; i++) {
  18846. for (var j = 0; j < nodes.length; j++) {
  18847. if (links[i].source == nodes[j].id) {
  18848. links[i].source = nodes[j];
  18849. }
  18850. if (links[i].target == nodes[j].id) {
  18851. links[i].target = nodes[j];
  18852. }
  18853. }
  18854. }
  18855. restart();
  18856. });
  18857. }
  18858. };
  18859. var svg;
  18860. var force;
  18861. var drag_line, path, circle;
  18862. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  18863. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  18864. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  18865. var nodes = [],
  18866. links = [];
  18867. var treeNodes = [];
  18868. //读取labels (node)
  18869. var labels = [];
  18870. function redrawSvg(json) {
  18871. nodes.length = 0; //先清空
  18872. links.length = 0;
  18873. var data = json.data;
  18874. for (var i = 0; i < data.node.length; i++) {
  18875. nodes.push(data.node[i]);
  18876. }
  18877. restart();
  18878. }
  18879. //读取status (节点 连线)
  18880. var statuses = [];
  18881. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  18882. // if (result && result.status == 200) {
  18883. // d3.select('#nodeStatus').selectAll('option')
  18884. // .data(statuses).enter()
  18885. // .append('option')
  18886. // .attr('value', function(d) { return d.code; })
  18887. // .html(function(d) { return d.desc; });
  18888. // } else {
  18889. // SweetAlert.swal({
  18890. // title: "提示!",
  18891. // text: "服务器请求异常!",
  18892. // type: "error"
  18893. // });
  18894. // }
  18895. // });
  18896. api_wechatfile
  18897. .getDictionary({
  18898. key: "cmdb_status",
  18899. type: "list",
  18900. })
  18901. .then(function (result) {
  18902. if (result) {
  18903. d3.select("#nodeStatus")
  18904. .selectAll("option")
  18905. .data(statuses)
  18906. .enter()
  18907. .append("option")
  18908. .attr("value", function (d) {
  18909. return d.code;
  18910. })
  18911. .html(function (d) {
  18912. return d.desc;
  18913. });
  18914. } else {
  18915. SweetAlert.swal({
  18916. title: "提示!",
  18917. text: "服务器请求异常!",
  18918. type: "error",
  18919. });
  18920. }
  18921. });
  18922. //查询relationship_type表 name 为表里的type,label为显示值
  18923. var linkType = [];
  18924. function fetchEdgeTypes() {
  18925. ConfigDataService.fetchDataList("ciedgetype", {
  18926. idx: 0,
  18927. sum: 100,
  18928. }).then(function (response) {
  18929. if (response) {
  18930. if (response["list"]) {
  18931. linkType = response["list"];
  18932. // d3.select('#linkName').selectAll('option')
  18933. // .data(linkType).enter()
  18934. // .append('option')
  18935. // .attr('value',function(d){return d.type;})
  18936. // .html(function(d){ return d.label;});
  18937. } else {
  18938. SweetAlert.swal({
  18939. title: "提示!",
  18940. text: "服务器请求异常!",
  18941. type: "error",
  18942. });
  18943. }
  18944. } else {
  18945. SweetAlert.swal({
  18946. title: "提示!",
  18947. text: "服务器请求异常!",
  18948. type: "error",
  18949. });
  18950. }
  18951. });
  18952. }
  18953. // fetchEdgeTypes();
  18954. /*
  18955. // init D3 force layout
  18956. var force = d3.layout.force()
  18957. .nodes(nodes)
  18958. .links(links)
  18959. .size([width, height])
  18960. .gravity(.05)
  18961. .linkDistance(150)
  18962. .linkStrength(2)
  18963. .charge(-500)
  18964. .on('tick', tick);
  18965. // define arrow markers for graph links
  18966. svg.append('svg:defs').append('svg:marker')
  18967. .attr('id', 'end-arrow')
  18968. .attr('viewBox', '0 -5 10 10')
  18969. .attr('refX', 6)
  18970. .attr('markerWidth', 3)
  18971. .attr('markerHeight', 3)
  18972. .attr('orient', 'auto')
  18973. .append('svg:path')
  18974. .attr('d', 'M0,-5L10,0L0,5')
  18975. .attr('fill', '#000');
  18976. svg.append('svg:defs').append('svg:marker')
  18977. .attr('id', 'start-arrow')
  18978. .attr('viewBox', '0 -5 10 10')
  18979. .attr('refX', 4)
  18980. .attr('markerWidth', 3)
  18981. .attr('markerHeight', 3)
  18982. .attr('orient', 'auto')
  18983. .append('svg:path')
  18984. .attr('d', 'M10,-5L0,0L10,5')
  18985. .attr('fill', '#000');
  18986. // line displayed when dragging new nodes
  18987. var drag_line = svg.append('svg:path')
  18988. .attr('class', 'link dragline hidden')
  18989. .attr('d', 'M0,0L0,0');
  18990. // handles to link and node element groups
  18991. //(1)var path = svg.append('svg:g').selectAll('g')
  18992. var path = svg.append('svg:g').selectAll('g'),
  18993. circle = svg.append('svg:g').selectAll('g');
  18994. */
  18995. // mouse event vars
  18996. var selected_node = null,
  18997. selected_link = null,
  18998. mousedown_link = null,
  18999. mousedown_node = null,
  19000. mouseup_node = null;
  19001. function resetMouseVars() {
  19002. mousedown_node = null;
  19003. mouseup_node = null;
  19004. mousedown_link = null;
  19005. }
  19006. // update force layout (called automatically each iteration)
  19007. function tick() {
  19008. // draw directed edges with proper padding from node centers
  19009. path.selectAll("path").attr("d", function (d) {
  19010. var deltaX = d.target.x - d.source.x,
  19011. deltaY = d.target.y - d.source.y,
  19012. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  19013. normX = deltaX / dist,
  19014. normY = deltaY / dist,
  19015. sourcePadding = d.left ? 27 : 22,
  19016. targetPadding = d.right ? 27 : 22,
  19017. sourceX = d.source.x + sourcePadding * normX,
  19018. sourceY = d.source.y + sourcePadding * normY,
  19019. targetX = d.target.x - targetPadding * normX,
  19020. targetY = d.target.y - targetPadding * normY;
  19021. return (
  19022. "M" +
  19023. sourceX +
  19024. "," +
  19025. sourceY +
  19026. "L" +
  19027. targetX +
  19028. "," +
  19029. targetY
  19030. );
  19031. });
  19032. circle.attr("transform", function (d) {
  19033. return "translate(" + d.x + "," + d.y + ")";
  19034. });
  19035. }
  19036. // update graph (called when needed)
  19037. function restart() {
  19038. //绑定link 数据
  19039. path.datum(links);
  19040. // path (link) group
  19041. path = path.data(links, function (d) {
  19042. return d.id;
  19043. });
  19044. var p = path.enter().append("svg:g");
  19045. //update existing links
  19046. path
  19047. .selectAll("path")
  19048. .classed("selected", function (d) {
  19049. return d === selected_link;
  19050. })
  19051. .style("marker-start", function (d) {
  19052. return d.left ? "url(#start-arrow)" : "";
  19053. })
  19054. .style("marker-end", function (d) {
  19055. return d.right ? "url(#end-arrow)" : "";
  19056. });
  19057. // add new links
  19058. p.append("svg:path")
  19059. .attr("class", "link")
  19060. .attr("id", function (d) {
  19061. return "path_" + d.id;
  19062. })
  19063. // .attr('startOffset', '0%')
  19064. .classed("selected", function (d) {
  19065. return d === selected_link;
  19066. })
  19067. .style("marker-start", function (d) {
  19068. return d.left ? "url(#start-arrow)" : "";
  19069. })
  19070. .style("marker-end", function (d) {
  19071. return d.right ? "url(#end-arrow)" : "";
  19072. })
  19073. .on("mousedown", function (d) {
  19074. if (d3.event.ctrlKey) return;
  19075. //去除没有提交的连线
  19076. for (var i = 0; i < links.length; i++) {
  19077. if (links[i].id == -1 && d.id != -1) {
  19078. links.splice(i, 1);
  19079. }
  19080. }
  19081. // select link
  19082. mousedown_link = d;
  19083. if (mousedown_link === selected_link) {
  19084. selected_link = $scope.selected_link = null;
  19085. selected_node = $scope.selected_node = null;
  19086. // d3.select("#linkDetail").attr('style','display:none');
  19087. //hideLinkForm(true);//return ;
  19088. } else {
  19089. selected_link = $scope.selected_link = mousedown_link;
  19090. selected_node = $scope.selected_node = null;
  19091. }
  19092. selected_node = $scope.selected_node = null;
  19093. restart();
  19094. });
  19095. p.append("svg:text")
  19096. .attr("x", 30)
  19097. .attr("y", 20)
  19098. .attr("class", "fontM")
  19099. .append("textPath")
  19100. .attr("xlink:xlink:href", function (d, i) {
  19101. return "#path_" + d.id;
  19102. })
  19103. .html(function (d) {
  19104. for (var i = 0; i < linkType.length; i++) {
  19105. if (linkType[i].type == d.name) {
  19106. return linkType[i].label;
  19107. }
  19108. }
  19109. });
  19110. // remove old links
  19111. path.exit().remove();
  19112. // circle (node) group
  19113. // NB: the function arg is crucial here! nodes are known by id, not by index!
  19114. circle.datum(nodes);
  19115. circle = circle.data(nodes, function (d) {
  19116. return d.id;
  19117. });
  19118. // update existing nodes (reflexive & selected visual states)
  19119. circle
  19120. .selectAll("circle")
  19121. .style("fill", function (d) {
  19122. return d === selected_node
  19123. ? d3.rgb(colors(d.label)).brighter().toString()
  19124. : colors(d.label);
  19125. })
  19126. .style("fill-opacity", 0.75) // add by xi
  19127. .classed("reflexive", function (d) {
  19128. return d.reflexive;
  19129. });
  19130. // add new nodes
  19131. var g = circle.enter().append("svg:g");
  19132. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  19133. //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');
  19134. g.append("svg:circle")
  19135. .attr("r", 24)
  19136. .style("fill", function (d) {
  19137. return d === selected_node
  19138. ? "rgb(153,153,153)"
  19139. : "rgb(255,255,255)";
  19140. })
  19141. .style("stroke", function (d) {
  19142. return d3.rgb(colors(d.label)).darker().toString();
  19143. })
  19144. .style("stroke-width", "2");
  19145. g.append("svg:circle")
  19146. .attr("class", "node")
  19147. .attr("r", 18)
  19148. .style("fill", function (d) {
  19149. return d === selected_node
  19150. ? d3.rgb(colors(d.label)).brighter().toString()
  19151. : colors(d.label);
  19152. })
  19153. .style("stroke", function (d) {
  19154. return d3.rgb(colors(d.label)).darker().toString();
  19155. })
  19156. .style("fill-opacity", 0.25) //add by xj
  19157. .style("stroke-opacity", 0.5) //add by xj
  19158. .classed("reflexive", function (d) {
  19159. return d.reflexive;
  19160. });
  19161. g.on("mouseover", function (d) {
  19162. //if(!mousedown_node || d === mousedown_node) return;
  19163. // enlarge target node
  19164. //d3.select(this).attr('transform', 'scale(1.1)');
  19165. })
  19166. .on("mouseout", function (d) {
  19167. //if(!mousedown_node || d === mousedown_node) return;
  19168. // unenlarge target node
  19169. //d3.select(this).attr('transform', '');
  19170. })
  19171. .on("mousedown", function (d) {
  19172. if (d3.event.ctrlKey) return;
  19173. //hideLinkForm(true);
  19174. //去除没有提交的连线
  19175. for (var i = 0; i < links.length; i++) {
  19176. if (links[i].id == -1) {
  19177. links.splice(i, 1);
  19178. }
  19179. }
  19180. // select node
  19181. mousedown_node = d;
  19182. if (mousedown_node === selected_node) {
  19183. selected_node = $scope.selected_node = null;
  19184. } else {
  19185. selected_node = $scope.selected_node = mousedown_node;
  19186. selected_link = $scope.selected_link = null;
  19187. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  19188. APIService.findRefById(selected_node.id).then(function (
  19189. result
  19190. ) {
  19191. var d = result.data;
  19192. var node = d.node;
  19193. var link = d.edge;
  19194. var tempNode = [];
  19195. var tempLink = [];
  19196. //nodes 或者links 要去重
  19197. for (var i = 0; i < node.length; i++) {
  19198. var tmp = 0;
  19199. for (var j = 0; j < nodes.length; j++) {
  19200. if (node[i].id == nodes[j].id) {
  19201. tmp++;
  19202. break;
  19203. }
  19204. }
  19205. if (tmp == 0) {
  19206. tempNode.push(node[i]);
  19207. }
  19208. }
  19209. for (var i = 0; i < link.length; i++) {
  19210. var tmp = 0;
  19211. for (var j = 0; j < links.length; j++) {
  19212. if (link[i].id == links[j].id) {
  19213. tmp++;
  19214. break;
  19215. }
  19216. }
  19217. if (tmp == 0) {
  19218. tempLink.push(link[i]);
  19219. }
  19220. }
  19221. //数据写入页面
  19222. for (var i = 0; i < tempNode.length; i++) {
  19223. //nodes 不清空
  19224. nodes.push(tempNode[i]);
  19225. }
  19226. for (var i = 0; i < tempLink.length; i++) {
  19227. //link 不清空
  19228. links.push(tempLink[i]);
  19229. }
  19230. //links转换
  19231. for (var i = 0; i < links.length; i++) {
  19232. for (var j = 0; j < nodes.length; j++) {
  19233. if (links[i].source == nodes[j].id) {
  19234. links[i].source = nodes[j];
  19235. }
  19236. if (links[i].target == nodes[j].id) {
  19237. links[i].target = nodes[j];
  19238. }
  19239. }
  19240. }
  19241. restart();
  19242. });
  19243. }
  19244. // reposition drag line
  19245. drag_line
  19246. .style("marker-end", "url(#end-arrow)")
  19247. .classed("hidden", false)
  19248. .attr(
  19249. "d",
  19250. "M" +
  19251. mousedown_node.x +
  19252. "," +
  19253. mousedown_node.y +
  19254. "L" +
  19255. mousedown_node.x +
  19256. "," +
  19257. mousedown_node.y
  19258. );
  19259. restart();
  19260. })
  19261. .on("mouseup", function (d) {
  19262. if (!mousedown_node) return;
  19263. });
  19264. // show node name
  19265. g.append("svg:text")
  19266. .attr("x", 0)
  19267. .attr("y", 34)
  19268. .attr("class", "id")
  19269. .text(function (d) {
  19270. return d.name;
  19271. }); //TODO 改为 d.name
  19272. //设置图片
  19273. g.append("svg:foreignObject")
  19274. .attr("width", 32)
  19275. .attr("height", 32)
  19276. .attr("x", "-16px")
  19277. .attr("y", "-11px")
  19278. .html(function (d) {
  19279. for (var i = 0; i < labels.length; i++) {
  19280. if (d.label == labels[i].sign) {
  19281. return (
  19282. '<i class="icon iconfont">' +
  19283. labels[i].iconname +
  19284. "</i>"
  19285. );
  19286. }
  19287. }
  19288. });
  19289. // remove old nodes
  19290. circle.exit().remove();
  19291. // set the graph in motion
  19292. force.start();
  19293. }
  19294. function mousedown() {
  19295. // prevent I-bar on drag
  19296. //d3.event.preventDefault();
  19297. // because :active only works in WebKit?
  19298. svg.classed("active", true);
  19299. if (mousedown_node) {
  19300. viewNode(mousedown_node);
  19301. }
  19302. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  19303. return;
  19304. restart();
  19305. }
  19306. function mousemove() {
  19307. if (!mousedown_node) return;
  19308. // update drag line
  19309. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  19310. //restart();
  19311. }
  19312. function mouseup() {
  19313. if (mousedown_node) {
  19314. // hide drag line
  19315. drag_line.classed("hidden", true).style("marker-end", "");
  19316. }
  19317. // because :active only works in WebKit?
  19318. svg.classed("active", false);
  19319. // clear mouse event vars
  19320. resetMouseVars();
  19321. }
  19322. function spliceLinksForNode(node) {
  19323. var toSplice = links.filter(function (l) {
  19324. return l.source === node || l.target === node;
  19325. });
  19326. toSplice.map(function (l) {
  19327. links.splice(links.indexOf(l), 1);
  19328. });
  19329. }
  19330. // only respond once per keydown
  19331. var lastKeyDown = -1;
  19332. function keydown() {
  19333. //d3.event.preventDefault();
  19334. if (lastKeyDown !== -1) return;
  19335. lastKeyDown = d3.event.keyCode;
  19336. // ctrl
  19337. if (d3.event.keyCode === 17) {
  19338. circle.call(force.drag);
  19339. svg.classed("ctrl", true);
  19340. }
  19341. if (!selected_node && !selected_link) return;
  19342. switch (d3.event.keyCode) {
  19343. case 8: // backspace
  19344. case 66: // B
  19345. if (selected_link) {
  19346. // set link direction to both left and right
  19347. selected_link.left = true;
  19348. selected_link.right = true;
  19349. }
  19350. restart();
  19351. break;
  19352. case 76: // L
  19353. if (selected_link) {
  19354. // set link direction to left only
  19355. selected_link.left = true;
  19356. selected_link.right = false;
  19357. }
  19358. restart();
  19359. break;
  19360. case 82: // R
  19361. if (selected_node) {
  19362. // toggle node reflexivity
  19363. selected_node.reflexive = !selected_node.reflexive;
  19364. } else if (selected_link) {
  19365. // set link direction to right only
  19366. selected_link.left = false;
  19367. selected_link.right = true;
  19368. }
  19369. restart();
  19370. break;
  19371. }
  19372. }
  19373. function keyup() {
  19374. lastKeyDown = -1;
  19375. // ctrl
  19376. if (d3.event.keyCode === 17) {
  19377. circle
  19378. .on("mousedown.drag", null)
  19379. .on("touchstart.drag", null);
  19380. svg.classed("ctrl", false);
  19381. }
  19382. }
  19383. function viewNode(node) {
  19384. // console.log(svg.attr('left'));
  19385. //var el = angular.element('div.modal-dialog')[0];
  19386. var title =
  19387. $scope.selected_node.name +
  19388. "-[" +
  19389. $scope.selected_node.uuid +
  19390. "]";
  19391. if (!$scope.selected_node.props.state) {
  19392. $scope.selected_node.props.state = "空";
  19393. } else if ($scope.selected_node.props.state) {
  19394. if ($scope.selected_node.props.state == "1") {
  19395. $scope.selected_node.props.state = "未审核";
  19396. } else if ($scope.selected_node.props.state == "2") {
  19397. $scope.selected_node.props.state = "已审核";
  19398. } else if ($scope.selected_node.props.state == "3") {
  19399. $scope.selected_node.props.state = "不匹配";
  19400. } else if ($scope.selected_node.props.state == "4") {
  19401. $scope.selected_node.props.state = "丢失";
  19402. }
  19403. }
  19404. if (!$scope.selected_node.name) {
  19405. $scope.selected_node.name = "空";
  19406. }
  19407. if (!$scope.selected_node.status) {
  19408. $scope.selected_node.statu = "空";
  19409. }
  19410. if (!$scope.selected_node.props.useradmin) {
  19411. $scope.selected_node.props.useradmin = "空";
  19412. }
  19413. Toaster.pop({
  19414. // type: 'info',
  19415. // title: title,
  19416. body:
  19417. "<br/><p>搜索代码:" +
  19418. $scope.selected_node.uuid +
  19419. "</p>" +
  19420. "<p>配置标题:" +
  19421. $scope.selected_node.name +
  19422. "</p>" +
  19423. "<p>状态:" +
  19424. $scope.selected_node.status +
  19425. "</p>" +
  19426. "<p>审核状态:" +
  19427. $scope.selected_node.props.state +
  19428. "</p>" +
  19429. "<p>维护人员:" +
  19430. $scope.selected_node.props.useradmin +
  19431. "</p>",
  19432. bodyOutputType: "trustedHtml",
  19433. timeout: 3000,
  19434. });
  19435. }
  19436. //GT 颜色与数值对照表
  19437. function colors(sign) {
  19438. //num=num>20?num%20:parseInt(num);
  19439. for (var i = 0; i < labels.length; i++) {
  19440. var entity = labels[i];
  19441. if (sign == entity.sign) {
  19442. return entity.color;
  19443. }
  19444. if (i == labels.length - 1 && sign != entity.sign) {
  19445. return "#ffeeee";
  19446. }
  19447. }
  19448. }
  19449. $scope.init = function () {
  19450. svg = d3
  19451. .select("#cmdbSVG")
  19452. .append("svg")
  19453. .attr("width", width)
  19454. .attr("height", height);
  19455. // init D3 force layout
  19456. force = d3.layout
  19457. .force()
  19458. .nodes(nodes)
  19459. .links(links)
  19460. .size([width, height])
  19461. .gravity(0.05)
  19462. .linkDistance(150)
  19463. .linkStrength(2)
  19464. .charge(-500)
  19465. .on("tick", tick);
  19466. // define arrow markers for graph links
  19467. svg
  19468. .append("svg:defs")
  19469. .append("svg:marker")
  19470. .attr("id", "end-arrow")
  19471. .attr("viewBox", "0 -5 10 10")
  19472. .attr("refX", 6)
  19473. .attr("markerWidth", 3)
  19474. .attr("markerHeight", 3)
  19475. .attr("orient", "auto")
  19476. .append("svg:path")
  19477. .attr("d", "M0,-5L10,0L0,5")
  19478. .attr("fill", "#000");
  19479. svg
  19480. .append("svg:defs")
  19481. .append("svg:marker")
  19482. .attr("id", "start-arrow")
  19483. .attr("viewBox", "0 -5 10 10")
  19484. .attr("refX", 4)
  19485. .attr("markerWidth", 3)
  19486. .attr("markerHeight", 3)
  19487. .attr("orient", "auto")
  19488. .append("svg:path")
  19489. .attr("d", "M10,-5L0,0L10,5")
  19490. .attr("fill", "#000");
  19491. // line displayed when dragging new nodes
  19492. drag_line = svg
  19493. .append("svg:path")
  19494. .attr("class", "link dragline hidden")
  19495. .attr("d", "M0,0L0,0");
  19496. // handles to link and node element groups
  19497. //(1)var path = svg.append('svg:g').selectAll('g')
  19498. path = svg.append("svg:g").selectAll("g");
  19499. circle = svg.append("svg:g").selectAll("g");
  19500. svg
  19501. .on("mousedown", mousedown)
  19502. .on("mousemove", mousemove)
  19503. .on("mouseup", mouseup);
  19504. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  19505. };
  19506. var CI = {};
  19507. window.CI = CI;
  19508. $scope.ok = function () {
  19509. $modalInstance.close($scope.selected_node);
  19510. };
  19511. $scope.cancel = function () {
  19512. $modalInstance.dismiss("cancel");
  19513. };
  19514. },
  19515. size: size,
  19516. resolve: {
  19517. title: function () {
  19518. return options.templateOptions.title;
  19519. },
  19520. Restangular: function () {
  19521. return options.templateOptions.Restangular;
  19522. },
  19523. APIService: function () {
  19524. return options.templateOptions.ApiService;
  19525. },
  19526. ConfigDataService: function () {
  19527. return options.templateOptions.ConfigDataService;
  19528. },
  19529. ConfigFormService: function () {
  19530. return options.templateOptions.ConfigFormService;
  19531. },
  19532. SweetAlert: function () {
  19533. return options.templateOptions.Alert;
  19534. },
  19535. Toaster: function () {
  19536. return options.templateOptions.toaster;
  19537. },
  19538. },
  19539. });
  19540. modalInstance.result.then(
  19541. function (selectedItem) {
  19542. options.value(selectedItem.name + "-" + selectedItem.uuid);
  19543. },
  19544. function () {
  19545. //console.log('Modal dismissed at: ' + new Date());
  19546. }
  19547. );
  19548. },
  19549. },
  19550. };
  19551. },
  19552. controller: [
  19553. "$scope",
  19554. function ($scope) {
  19555. // setTimeout(function(){
  19556. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  19557. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  19558. // if(modelData.status==200){
  19559. // $scope.model[$scope.options.key] = modelData.data;
  19560. // $scope.options.initialValue = $scope.model[$scope.options.key];
  19561. // }
  19562. // });
  19563. // },1000);
  19564. },
  19565. ],
  19566. });
  19567. });
  19568. appFormly.run(function (formlyConfig, $parse) {
  19569. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  19570. var removeOnHideTransformer = function (fields, model) {
  19571. return fields.map(function (field) {
  19572. if (
  19573. field.hideExpression &&
  19574. (!field.data || !field.data.dontRemoveOnHidden)
  19575. ) {
  19576. addFieldRemoveOnHideWatcher(field);
  19577. }
  19578. if (field.type == "ui-title") {
  19579. addFieldRemoveOnHideWatcher(field);
  19580. }
  19581. return field;
  19582. });
  19583. };
  19584. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  19585. function addFieldRemoveOnHideWatcher(field) {
  19586. var watcher = getWatcher();
  19587. if (field.watcher) {
  19588. if (!angular.isArray(field.watcher)) {
  19589. field.watcher = [field.watcher];
  19590. }
  19591. field.watcher.push(watcher);
  19592. } else {
  19593. field.watcher = watcher;
  19594. }
  19595. }
  19596. function getWatcher() {
  19597. return {
  19598. expression: function (field) {
  19599. return field.hide;
  19600. },
  19601. listener: function (field, newHide, oldHide, scope) {
  19602. if (field.hide) {
  19603. if (field.templateOptions.pkey) {
  19604. if (field.key == "transferuser") {
  19605. $parse(field.templateOptions.pkey + "." + field.key).assign(
  19606. scope.model,
  19607. undefined
  19608. );
  19609. }
  19610. } else {
  19611. $parse(field.key).assign(scope.model, undefined);
  19612. }
  19613. }
  19614. if (field.type == "ui-title") {
  19615. $parse(field.key).assign(scope.model, undefined);
  19616. }
  19617. },
  19618. };
  19619. }
  19620. });
  19621. appFormly.controller("CustomformCtrl", [
  19622. "$rootScope",
  19623. "$scope",
  19624. "$parse",
  19625. "$injector",
  19626. "$http",
  19627. "$q",
  19628. "$state",
  19629. "$stateParams",
  19630. "$modal",
  19631. "$timeout",
  19632. "$interval",
  19633. "SweetAlert",
  19634. "FileUploader",
  19635. "i18nService",
  19636. "Restangular",
  19637. "UserRestangular",
  19638. "BpmRestangular",
  19639. "WechatRestangular",
  19640. "api_configure_form",
  19641. "api_bpm_domain",
  19642. "api_bpm_data",
  19643. "api_user_data",
  19644. "api_statistic",
  19645. "up_down_file",
  19646. "fileReader",
  19647. function (
  19648. $rootScope,
  19649. $scope,
  19650. $parse,
  19651. $injector,
  19652. $http,
  19653. $q,
  19654. $state,
  19655. $stateParams,
  19656. $modal,
  19657. $timeout,
  19658. $interval,
  19659. SweetAlert,
  19660. FileUploader,
  19661. i18nService,
  19662. Restangular,
  19663. UserRestangular,
  19664. BpmRestangular,
  19665. WechatRestangular,
  19666. api_configure_form,
  19667. api_bpm_domain,
  19668. api_bpm_data,
  19669. api_user_data,
  19670. api_statistic,
  19671. up_down_file,
  19672. fileReader
  19673. ) {
  19674. //console.log($parse('Restangular')($scope));
  19675. //console.log($injector.get('Restangular'));
  19676. //console.log($stateParams);
  19677. //保存报修主体
  19678. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  19679. $scope.imgUrlList = [];
  19680. $scope.uploadimg_del = function () {
  19681. console.log(123);
  19682. };
  19683. var vm = this;
  19684. vm.options = {};
  19685. vm.exampleTitle = ["expressionProperties", "model property"];
  19686. vm.fields = [];
  19687. vm.model = {};
  19688. $scope.langs = i18nService.getAllLangs();
  19689. $scope.lang = "zh-cn";
  19690. i18nService.setCurrentLang($scope.lang);
  19691. //alert($rootScope.user.id,null,2);
  19692. vm.model["loginUser"] = $rootScope.user;
  19693. var loginUser = $rootScope.user;
  19694. // console.log(vm);
  19695. var that = $injector;
  19696. var parse = $parse;
  19697. var formKey = "";
  19698. var pdKey = "";
  19699. var modelWatch = "";
  19700. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  19701. modelWatch = JSON.parse($stateParams.model);
  19702. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  19703. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  19704. console.log(modelWatch, $rootScope);
  19705. // if(modelWatch.model.incident){
  19706. // if(modelWatch.model.incident.place){
  19707. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  19708. // }else{
  19709. // $rootScope.selecthouseNumber = undefined;
  19710. // }
  19711. // }
  19712. }
  19713. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  19714. pdKey = $state.current.pdKey;
  19715. } else if ($stateParams.pdKey) {
  19716. pdKey = $stateParams.pdKey;
  19717. }
  19718. // console.log("pdKey::" + JSON.stringify($state.current.title));
  19719. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  19720. formKey = $stateParams.formKey;
  19721. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  19722. }
  19723. if (angular.isDefined($stateParams.model)) {
  19724. var formModel = $stateParams.model;
  19725. }
  19726. //用户测试数据,后续从header的auth中获取
  19727. var userId = 2;
  19728. userId = $rootScope.user.id;
  19729. //==============处理表单设计数据 开始====================
  19730. //处理组件加载后台数据选项的方法
  19731. function refreshSelectOptions(searchVal, field) {
  19732. if (
  19733. field.templateOptions.optionsUrl &&
  19734. !field.templateOptions.isnosearch
  19735. ) {
  19736. var process = BpmRestangular.all("");
  19737. if (field.templateOptions.ApiService) {
  19738. process = UserRestangular.all("");
  19739. }
  19740. if (field.templateOptions.Apicommon) {
  19741. process = WechatRestangular.all("");
  19742. }
  19743. var datakey = {
  19744. idx: 0,
  19745. sum: 1000,
  19746. };
  19747. if (field.templateOptions.modelreasondata) {
  19748. datakey = field.templateOptions.modelreasondata;
  19749. }
  19750. process
  19751. .customPOST(datakey, field.templateOptions.optionsUrl)
  19752. .then(function (result) {
  19753. if (!field.templateOptions.options) {
  19754. field.templateOptions.options = [];
  19755. }
  19756. if (field.templateOptions.optionsDataKey) {
  19757. field.templateOptions.options =
  19758. result[field.templateOptions.optionsDataKey];
  19759. } else {
  19760. field.templateOptions.options = result;
  19761. }
  19762. });
  19763. }
  19764. }
  19765. //获取表单后数据处理
  19766. function formfield(field, result) {
  19767. // angular.forEach(fields.fields, function(field) {
  19768. if (field.key == "") {
  19769. delete field.key;
  19770. }
  19771. if (angular.isDefined(field.extjson)) {
  19772. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  19773. angular.extend(field.templateOptions, extObj.templateOptions);
  19774. delete extObj.templateOptions;
  19775. for (var prop in extObj) {
  19776. if (new RegExp("Expression").test(prop)) {
  19777. //var obj = $scope.$eval(extObj[prop]);
  19778. //extObj[prop] = $scope.$eval(extObj[prop]);
  19779. if (extObj[prop] != null) {
  19780. if (new RegExp("function").test(extObj[prop])) {
  19781. var propValue = eval(extObj[prop]);
  19782. extObj[prop] = propValue;
  19783. } else {
  19784. //console.log(extObj[prop]);
  19785. var obj = $scope.$eval(extObj[prop]);
  19786. extObj[prop] = obj;
  19787. //console.log(obj);
  19788. }
  19789. }
  19790. } else if (new RegExp("expressionProperties").test(prop)) {
  19791. for (var p in extObj[prop]) {
  19792. if (new RegExp("function").test(extObj[prop][p])) {
  19793. var propValue = eval(extObj[prop][p]);
  19794. extObj[prop][p] = propValue;
  19795. } else {
  19796. //if(p.indexOf("'")>=0){
  19797. // var obj = $scope.$eval(extObj[prop][p]);
  19798. // extObj[prop][$scope.$eval(p)]=obj;
  19799. //}
  19800. }
  19801. }
  19802. } else if ("watcher" == prop) {
  19803. if (angular.isArray(extObj[prop])) {
  19804. angular.forEach(extObj[prop], function (item, index) {
  19805. for (var p in item) {
  19806. if (new RegExp("function").test(item[p])) {
  19807. var propValue = eval(item[p]);
  19808. extObj[prop][index][p] = propValue;
  19809. }
  19810. }
  19811. });
  19812. } else if (angular.isObject(extObj[prop])) {
  19813. for (var p in extObj[prop]) {
  19814. if (new RegExp("function").test(extObj[prop][p])) {
  19815. var propValue = eval(extObj[prop][p]);
  19816. extObj[prop][p] = propValue;
  19817. }
  19818. }
  19819. }
  19820. }
  19821. }
  19822. angular.extend(field, extObj);
  19823. delete field.extjson;
  19824. }
  19825. if (angular.isDefined(field.templateOptions)) {
  19826. var templateOs = field.templateOptions;
  19827. // console.log(templateOs,'come')
  19828. for (var property in templateOs) {
  19829. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  19830. if (angular.isString(templateOs[property])) {
  19831. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  19832. if (new RegExp("function").test(templateOs[property])) {
  19833. var propValue = eval(templateOs[property]);
  19834. field.templateOptions[property] = propValue;
  19835. } else {
  19836. if (that.has(templateOs[property])) {
  19837. field.templateOptions[property] = that.get(
  19838. templateOs[property]
  19839. );
  19840. } else {
  19841. field.templateOptions[property] = templateOs[property];
  19842. }
  19843. }
  19844. } else if (templateOs[property] == null) {
  19845. //delete field.templateOptions[property];
  19846. } else {
  19847. }
  19848. }
  19849. }
  19850. if (
  19851. angular.isDefined(field.templateOptions) &&
  19852. angular.isDefined(field.templateOptions.extjson)
  19853. ) {
  19854. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  19855. angular.extend(field.templateOptions, extObj);
  19856. delete field.templateOptions.extjson;
  19857. }
  19858. // ...
  19859. if (field.templateOptions) {
  19860. //处理远程获取数据控件方法调用
  19861. if (
  19862. field.templateOptions.optionsUrl &&
  19863. !field.templateOptions.refresh
  19864. ) {
  19865. // if (!field.templateOptions.isnoreash) {
  19866. field.templateOptions.refresh = refreshSelectOptions;
  19867. // }
  19868. }
  19869. //处理嵌套属性数据绑定/
  19870. if (field.templateOptions.pkey) {
  19871. var pmodel,
  19872. i = 0;
  19873. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  19874. if (i == 0) {
  19875. if (result.model[p] == null) {
  19876. result.model[p] = {};
  19877. }
  19878. pmodel = result.model[p];
  19879. i++;
  19880. } else {
  19881. if (pmodel[p] == null) {
  19882. pmodel[p] = {};
  19883. }
  19884. pmodel = pmodel[p];
  19885. }
  19886. });
  19887. if (pmodel != null) {
  19888. field.model = pmodel;
  19889. if (pmodel[field.key] == null) {
  19890. pmodel[field.key] = null;
  19891. }
  19892. }
  19893. } else {
  19894. if (result.model[field.key] == null) {
  19895. result.model[field.key] = null;
  19896. }
  19897. }
  19898. //处理弹出框组件初始化
  19899. if (field.type == "ui-input-selectmodal") {
  19900. field.templateOptions.modal = $modal;
  19901. //field.templateOptions.Restangular = Restangular;
  19902. } else if (field.type == "ui-requesterselect") {
  19903. //field.templateOptions.language = $scope.lang;
  19904. field.templateOptions.modal = $modal;
  19905. field.templateOptions.UserService = api_user_data;
  19906. } else if (field.type == "ui-deptinformation") {
  19907. field.templateOptions.modal = $modal;
  19908. field.templateOptions.UserService = api_user_data;
  19909. } else if (field.type == "ui-requesterinformation") {
  19910. field.templateOptions.modal = $modal;
  19911. field.templateOptions.UserService = api_user_data;
  19912. } else if (field.type == "ui-userselect") {
  19913. field.templateOptions.modal = $modal;
  19914. //field.templateOptions.Restangular = Restangular;
  19915. } else if (field.type == "ui-userselectSearch") {
  19916. field.templateOptions.modal = $modal;
  19917. //field.templateOptions.Restangular = Restangular;
  19918. } else if (field.type == "ui-multiuserselect") {
  19919. field.templateOptions.modal = $modal;
  19920. } else if (field.type == "ui-stringuserselect") {
  19921. field.templateOptions.modal = $modal;
  19922. } else if (field.type == "ui-search") {
  19923. field.templateOptions.modal = $modal;
  19924. } else if (field.type == "ui-modelselect") {
  19925. field.templateOptions.modal = $modal;
  19926. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  19927. field.templateOptions.loginUser = $rootScope.user;
  19928. //field.templateOptions.Restangular = Restangular;
  19929. } else if (field.type == "ui-incidentmodelselect") {
  19930. field.templateOptions.modal = $modal;
  19931. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  19932. field.templateOptions.loginUser = $rootScope.user;
  19933. //field.templateOptions.Restangular = Restangular;
  19934. } else if (field.type == "ui-dropfile") {
  19935. $scope.fileUploader = field.templateOptions.fileUploader =
  19936. new FileUploader({
  19937. url: "/uploader",
  19938. });
  19939. field.templateOptions.taskId = $stateParams.taskId;
  19940. field.templateOptions.processInstanceId =
  19941. $stateParams.processInstanceId;
  19942. field.templateOptions.userId = $rootScope.user.id;
  19943. } else if (field.type == "ui-dropfielknow") {
  19944. $scope.fileUploader = field.templateOptions.fileUploader =
  19945. new FileUploader({
  19946. url: "/uploader",
  19947. });
  19948. field.templateOptions.taskId = $stateParams.taskId;
  19949. field.templateOptions.processInstanceId =
  19950. $stateParams.processInstanceId;
  19951. field.templateOptions.userId = $rootScope.user.id;
  19952. } else if (field.type == "ui-upDropFile") {
  19953. $scope.fileUploader = field.templateOptions.fileUploader =
  19954. new FileUploader({
  19955. url: "/uploader",
  19956. });
  19957. field.templateOptions.taskId = $stateParams.taskId;
  19958. field.templateOptions.processInstanceId =
  19959. $stateParams.processInstanceId;
  19960. field.templateOptions.userId = $rootScope.user.id;
  19961. } else if (field.type == "ui-dropfilenotup") {
  19962. $scope.fileUploader = field.templateOptions.fileUploader =
  19963. new FileUploader({
  19964. url: "/uploader",
  19965. });
  19966. field.templateOptions.taskId = $stateParams.taskId;
  19967. field.templateOptions.processInstanceId =
  19968. $stateParams.processInstanceId;
  19969. field.templateOptions.userId = $rootScope.user.id;
  19970. //field.ApiService=api_bpm_domain;
  19971. } else if (field.type == "ui-uploadFiles") {
  19972. $scope.fileUploader = field.templateOptions.fileUploader =
  19973. new FileUploader({
  19974. url: "/uploader",
  19975. });
  19976. field.templateOptions.taskId = $stateParams.taskId;
  19977. field.templateOptions.processInstanceId =
  19978. $stateParams.processInstanceId;
  19979. field.templateOptions.userId = $rootScope.user.id;
  19980. //field.ApiService=api_bpm_domain;
  19981. } else if (field.type == "ui-upDownFiles") {
  19982. $scope.fileUploader = field.templateOptions.fileUploader =
  19983. new FileUploader({
  19984. url: "/uploader",
  19985. });
  19986. field.templateOptions.taskId = $stateParams.taskId;
  19987. field.templateOptions.processInstanceId =
  19988. $stateParams.processInstanceId;
  19989. field.templateOptions.userId = $rootScope.user.id;
  19990. //field.ApiService=api_bpm_domain;
  19991. } else if (field.type == "ui-uploadImgs") {
  19992. $scope.fileUploader = field.templateOptions.fileUploader =
  19993. new FileUploader({
  19994. url: "/uploader",
  19995. });
  19996. field.templateOptions.taskId = $stateParams.taskId;
  19997. field.templateOptions.processInstanceId =
  19998. $stateParams.processInstanceId;
  19999. field.templateOptions.userId = $rootScope.user.id;
  20000. //field.ApiService=api_bpm_domain;
  20001. } else if (field.type == "ui-dropfiletable") {
  20002. if (field.templateOptions.processInstanceId) {
  20003. } else {
  20004. field.templateOptions.processInstanceId =
  20005. $stateParams.processInstanceId;
  20006. }
  20007. } else if (field.type == "ui-dropFiles") {
  20008. if (field.templateOptions.processInstanceId) {
  20009. } else {
  20010. field.templateOptions.processInstanceId =
  20011. $stateParams.processInstanceId;
  20012. }
  20013. } else if (field.type == "ui-showImgs") {
  20014. if (field.templateOptions.processInstanceId) {
  20015. } else {
  20016. field.templateOptions.processInstanceId =
  20017. $stateParams.processInstanceId;
  20018. }
  20019. } else if (field.type == "ui-repeatSection") {
  20020. var repeatForm = {
  20021. model: {},
  20022. fields: field.templateOptions.fields,
  20023. };
  20024. repeatForm.model[field.key] = [];
  20025. decodeVMForm(repeatForm);
  20026. } else if (field.type == "ui-currentuser") {
  20027. field.templateOptions.user = vm.model["loginUser"];
  20028. } else if (field.type == "ui-workernumbersign") {
  20029. field.templateOptions.user = vm.model["loginUser"];
  20030. } else if (field.type == "ui-repair-photos") {
  20031. field.templateOptions.user = vm.model["loginUser"];
  20032. }
  20033. }
  20034. }
  20035. //解析自定义表单设计数据
  20036. $scope.oldfromtype = true;
  20037. function decodeVMForm(vmForm) {
  20038. if (vmForm.formType == "1") {
  20039. $scope.oldfromtype = false;
  20040. } else {
  20041. $scope.oldfromtype = true;
  20042. }
  20043. var result = {
  20044. model: {},
  20045. fields: [],
  20046. };
  20047. //设置模型实体数据 begin
  20048. // var mdata = vmForm.model;
  20049. //解析数据实体
  20050. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  20051. angular.extend(result.model, mdata);
  20052. if (modelWatch != null && modelWatch != "") {
  20053. //angular.extend(result.model.incident,modelWatch.incident);
  20054. //result.model.alarmType = modelWatch.alarmType;
  20055. // vmForm.cancelUrl = modelWatch.cancelUrl;
  20056. // console.log(modelWatch.cancelUrl)
  20057. for (var index in modelWatch.model) {
  20058. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  20059. if (result.model[index] != null) {
  20060. angular.extend(result.model[index], modelWatch.model[index]);
  20061. } else {
  20062. result.model[index] = modelWatch.model[index];
  20063. }
  20064. }
  20065. }
  20066. //设置模型实体数据 end
  20067. //解析设计数据生成表单项 begin
  20068. var fields = [];
  20069. //处理修改设计数据中展示设置
  20070. angular.forEach(vmForm.fields, function (fields) {
  20071. if (vmForm.formType == "1") {
  20072. angular.forEach(fields.fields, function (field) {
  20073. formfield(field, result);
  20074. });
  20075. } else {
  20076. formfield(fields, result);
  20077. }
  20078. // console.log(field);
  20079. result.fields.push(fields);
  20080. });
  20081. angular.extend($scope.vm.fields, result.fields);
  20082. angular.extend($scope.vm.model, result.model);
  20083. vm.model["loginUser"] = $rootScope.user;
  20084. //增加识别报修主体seimin
  20085. vm.model.repairType = $scope.repairMain.valueconfig;
  20086. if (vm.model.incident) {
  20087. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  20088. }
  20089. console.log(vm, "repairType"); //lmm
  20090. if (
  20091. modelWatch != null &&
  20092. modelWatch != "" &&
  20093. modelWatch.cancelUrl != null &&
  20094. modelWatch.cancelUrl != ""
  20095. ) {
  20096. vmForm.cancelUrl = modelWatch.cancelUrl;
  20097. }
  20098. $scope.formData = vmForm;
  20099. console.log($scope.formData, 4444444);
  20100. // console.log($scope.formData.url);
  20101. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  20102. if ($scope.formData.url == "start") {
  20103. $scope.Reset = true;
  20104. $scope.close = true;
  20105. $rootScope.isMask = false;
  20106. } else if ($scope.formData.url == "complete") {
  20107. $scope.Reset = false;
  20108. $scope.close = true;
  20109. }
  20110. //解析设计数据生成表单项 end
  20111. return result;
  20112. }
  20113. //======================处理表单设计数据 结束========================
  20114. $scope.ldloading = {};
  20115. function filter(obj) {
  20116. angular.forEach(obj, function (key, value) {
  20117. if (value === "" || value === null) {
  20118. delete obj[key];
  20119. } else if (
  20120. Object.prototype.toString.call(value) === "[object Object]"
  20121. ) {
  20122. filter(value);
  20123. } else if (angular.isArray(value)) {
  20124. angular.forEach(value, function (item) {
  20125. filter(item);
  20126. });
  20127. }
  20128. });
  20129. }
  20130. $scope.closeModel = function () {
  20131. // console.log($stateParams);
  20132. $state.go($scope.formData.cancelUrl, {});
  20133. event.preventDefault();
  20134. };
  20135. // console.log(vm);
  20136. // 暂存
  20137. $scope.save = function (data) {
  20138. console.log(vm);
  20139. if (vm.model.startSave) {
  20140. vm.model["initUser"] = $rootScope.user.id;
  20141. vm.model.start_code = "temporary";
  20142. //处理请求数据0327
  20143. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20144. delete data0327.repairType;
  20145. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20146. if (
  20147. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20148. .selecthouseNumber
  20149. ) {
  20150. data0327.incident.place = {
  20151. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20152. .selecthouseNumber.id,
  20153. };
  20154. }
  20155. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  20156. if (response) {
  20157. var resData = Restangular.stripRestangular(response);
  20158. if (resData) {
  20159. if (
  20160. $scope.fileUploader != null &&
  20161. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  20162. resData.id
  20163. ) {
  20164. $scope.fileUploader.onBeforeUploadItem = function (item) {
  20165. angular.extend(item.headers, $rootScope.getSession());
  20166. item.url = api_bpm_domain
  20167. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  20168. .getRequestedUrl();
  20169. item.formData.push({
  20170. fileName: item.file.name,
  20171. });
  20172. //console.log();
  20173. };
  20174. $scope.fileUploader.uploadAll();
  20175. }
  20176. }
  20177. SweetAlert.swal(
  20178. {
  20179. title: "提交成功!",
  20180. type: "success",
  20181. confirmButtonColor: "#007AFF",
  20182. },
  20183. function () {
  20184. $state.go($scope.formData.cancelUrl);
  20185. }
  20186. );
  20187. } else {
  20188. SweetAlert.swal({
  20189. title: "系统错误",
  20190. text: "系统错误,请稍后重试!",
  20191. type: "error",
  20192. confirmButtonColor: "#DD6B55",
  20193. });
  20194. }
  20195. $scope.ldloading[style.replace("-", "_")] = false;
  20196. });
  20197. event.preventDefault();
  20198. } else if (vm.model.saveAgain) {
  20199. var toData = {
  20200. incident: vm.model.incident,
  20201. };
  20202. api_user_data.updData("incident", toData).then(function (response) {
  20203. if (response) {
  20204. var resData = Restangular.stripRestangular(response);
  20205. SweetAlert.swal(
  20206. {
  20207. title: "提交成功!",
  20208. type: "success",
  20209. confirmButtonColor: "#007AFF",
  20210. },
  20211. function () {
  20212. $state.go($scope.formData.cancelUrl);
  20213. }
  20214. );
  20215. } else {
  20216. SweetAlert.swal({
  20217. title: "系统错误",
  20218. text: "系统错误,请稍后重试!",
  20219. type: "error",
  20220. confirmButtonColor: "#DD6B55",
  20221. });
  20222. }
  20223. $scope.ldloading[style.replace("-", "_")] = false;
  20224. });
  20225. event.preventDefault();
  20226. } else {
  20227. SweetAlert.swal({
  20228. title: "系统错误",
  20229. text: "系统错误,请稍后重试!",
  20230. type: "error",
  20231. confirmButtonColor: "#DD6B55",
  20232. });
  20233. }
  20234. };
  20235. // 巡检生成事件
  20236. $scope.inspectionToIncident = function () {
  20237. var userData = {
  20238. idx: 0,
  20239. sum: 10,
  20240. requester: {
  20241. name: loginUser.name,
  20242. },
  20243. };
  20244. api_user_data.fetchDataList("requester", userData).then(function (res) {
  20245. console.log(res);
  20246. var toUser = {};
  20247. if (res.list.length > 0) {
  20248. toUser = res.list[0];
  20249. } else {
  20250. toUser = loginUser;
  20251. }
  20252. console.log(vm);
  20253. var incidentDescription = "";
  20254. console.log($stateParams.formUiEdit);
  20255. if ($stateParams.formUiEdit == "inspection_confirm") {
  20256. if (vm.model.wnCheckEnable) {
  20257. incidentDescription =
  20258. incidentDescription.concat(" 机房温度检查异常");
  20259. }
  20260. if (vm.model.sdCheckEnable) {
  20261. incidentDescription =
  20262. incidentDescription.concat(" 机房湿度检查异常");
  20263. }
  20264. if (vm.model.xfjCheckEnable) {
  20265. incidentDescription = incidentDescription.concat(" 新风机检查异常");
  20266. }
  20267. if (vm.model.lsCheckEnable) {
  20268. incidentDescription = incidentDescription.concat(" 漏水检查异常");
  20269. }
  20270. if (vm.model.xfCheckEnable) {
  20271. incidentDescription = incidentDescription.concat(" 消防检查异常");
  20272. }
  20273. if (vm.model.upsCheckEnable) {
  20274. incidentDescription =
  20275. incidentDescription.concat(" UPS供电检查异常");
  20276. }
  20277. if (vm.model.dcCheckEnable) {
  20278. incidentDescription =
  20279. incidentDescription.concat(" 电池连接检查异常");
  20280. }
  20281. if (vm.model.plCheckEnable) {
  20282. incidentDescription =
  20283. incidentDescription.concat(" 旁路供电检查异常");
  20284. }
  20285. if (vm.model.wjtdCheckEnable) {
  20286. incidentDescription =
  20287. incidentDescription.concat(" 外机通道检查异常");
  20288. }
  20289. if (vm.model.descriptionTextarea) {
  20290. incidentDescription = incidentDescription.concat(
  20291. " " + "备注:" + vm.model.descriptionTextarea
  20292. );
  20293. }
  20294. }
  20295. // console.log(incidentDescription)
  20296. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  20297. var formdata = {
  20298. model: {
  20299. // 'isInspection': true,
  20300. // 'start_code':'assignment',
  20301. // 'isHandlerUser':false,
  20302. incident: {
  20303. requester: bxr,
  20304. area: bxr.place.area,
  20305. place: bxr.place,
  20306. houseNumber: bxr.houseNumber,
  20307. contacts: bxr.name,
  20308. contactsInformation: bxr.mphone,
  20309. // 'category': data.wxIncidentClassifyDTO.category,
  20310. description: incidentDescription,
  20311. source: {
  20312. id: 1552,
  20313. },
  20314. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  20315. // 'sourceType': data.incident.sourceType,
  20316. // 'fileUrl': data.incident.fileUrl
  20317. },
  20318. // 'requestershow': toUser,//2020年4月27日22:29:15
  20319. // 'flow': data.incident.id
  20320. // 'assignee': loginUser.id//2020年4月27日22:29:25
  20321. },
  20322. };
  20323. // console.log(formdata,toUser,'1111');
  20324. console.log(formdata, "1111");
  20325. // return;
  20326. $state.go("app.incident.chart", {
  20327. model: JSON.stringify(formdata),
  20328. });
  20329. });
  20330. // var formdata = {
  20331. // model:$rootScope.login_requester
  20332. // };
  20333. // console.log(formdata,'00000')
  20334. // return;
  20335. // $state.go("app.incident.chart", {
  20336. // 'model': JSON.stringify(formdata)
  20337. // });
  20338. event.preventDefault();
  20339. };
  20340. // console.log(vm);
  20341. // 创建事件seimin
  20342. vm.submit = function (data, style) {
  20343. console.log(vm, 22222);
  20344. // return;
  20345. if (vm.model.handler_code == undefined) {
  20346. vm.model.handler_code = "resolve";
  20347. }
  20348. if (
  20349. vm.model.change &&
  20350. vm.model.change.requestingPerson &&
  20351. vm.model.change.requestingPerson.menu
  20352. ) {
  20353. delete vm.model.change.requestingPerson.menu;
  20354. }
  20355. // var pdKey = $stateParams.pdKey;
  20356. if (vm.form.$valid) {
  20357. if (data.incident && data.incident.synergetic) {
  20358. console.log(data.incident.synergetic);
  20359. var synergetic = [];
  20360. for (var i = 0; i < data.incident.synergetic.length; i++) {
  20361. synergetic.push({
  20362. id: data.incident.synergetic[i],
  20363. });
  20364. }
  20365. data.incident.synergetic = synergetic;
  20366. vm.model.incident.synergetic = synergetic;
  20367. }
  20368. $scope.ldloading[style.replace("-", "_")] = true;
  20369. var startsub = true;
  20370. if (pdKey == "bpm_incident") {
  20371. angular.forEach(vm.fields, function (item) {
  20372. angular.forEach(item.fields, function (index) {
  20373. if (index.templateOptions.required && !index.hide) {
  20374. if (index.model) {
  20375. if (
  20376. angular.isDefined(index.model[index.key]) &&
  20377. index.model[index.key] != null
  20378. ) {
  20379. if (
  20380. index.model[index.key].id &&
  20381. index.model[index.key].id == ""
  20382. ) {
  20383. startsub = false;
  20384. $scope.ldloading.expand_right = false;
  20385. SweetAlert.swal({
  20386. title: index.templateOptions.label + "未填",
  20387. text: "请填写此项!",
  20388. type: "error",
  20389. confirmButtonColor: "#DD6B55",
  20390. });
  20391. } else {
  20392. }
  20393. } else {
  20394. startsub = false;
  20395. $scope.ldloading.expand_right = false;
  20396. console.log(vm);
  20397. SweetAlert.swal({
  20398. title: index.templateOptions.label + "未填2",
  20399. text: "请填写此项!",
  20400. type: "error",
  20401. confirmButtonColor: "#DD6B55",
  20402. });
  20403. }
  20404. } else {
  20405. if (
  20406. data[index.key] &&
  20407. data[index.key] != "" &&
  20408. data[index.key] != null
  20409. ) {
  20410. } else {
  20411. startsub = false;
  20412. $scope.ldloading.expand_right = false;
  20413. SweetAlert.swal({
  20414. title: index.templateOptions.label + "未填",
  20415. text: "请填写此项!",
  20416. type: "error",
  20417. confirmButtonColor: "#DD6B55",
  20418. });
  20419. }
  20420. }
  20421. }
  20422. });
  20423. });
  20424. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  20425. // startsub = false;
  20426. // $scope.ldloading.expand_right = false;
  20427. // SweetAlert.swal({
  20428. // title: '保修人未填',
  20429. // text: "请填写此项!",
  20430. // type: "error",
  20431. // confirmButtonColor: "#DD6B55"
  20432. // });
  20433. // }
  20434. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  20435. // } else {
  20436. // startsub = false;
  20437. // $scope.ldloading.expand_right = false;
  20438. // SweetAlert.swal({
  20439. // title: '事件分类未填',
  20440. // text: "请填写此项!",
  20441. // type: "error",
  20442. // confirmButtonColor: "#DD6B55"
  20443. // });
  20444. // }
  20445. }
  20446. if (startsub) {
  20447. $scope.ldloading[style.replace("-", "_")] = true;
  20448. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  20449. // console.log("vm.options:"+ JSON.stringify(vm.options));
  20450. vm.options.updateInitialValue();
  20451. // console.log("dfjkasdhfkhskjf ")
  20452. var _ = window._;
  20453. vm.model = (function filter(obj) {
  20454. var dateTransKeys = [];
  20455. var filtered = _.pick(obj, function (v, k, obj) {
  20456. if (_.isDate(v)) {
  20457. dateTransKeys.push(k);
  20458. }
  20459. return (
  20460. angular.isDefined(v) &&
  20461. v !== null &&
  20462. (angular.isArray(v) ? v.length > 0 : true) &&
  20463. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  20464. );
  20465. });
  20466. return _.cloneDeep(filtered, function (v, index, object) {
  20467. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  20468. angular.forEach(dateTransKeys, function (item) {
  20469. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  20470. });
  20471. dateTransKey = [];
  20472. return v;
  20473. }
  20474. return !_.isEmpty(filtered) &&
  20475. v !== filtered &&
  20476. _.isPlainObject(v)
  20477. ? filter(v)
  20478. : undefined;
  20479. });
  20480. })(vm.model);
  20481. if (pdKey != "") {
  20482. if ($scope.oprcode == "save") {
  20483. //保存
  20484. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  20485. if (response) {
  20486. var resData = Restangular.stripRestangular(response);
  20487. SweetAlert.swal(
  20488. {
  20489. title: "保存成功!",
  20490. confirmButtonColor: "#007AFF",
  20491. },
  20492. function () {
  20493. $state.go($scope.formData.cancelUri);
  20494. }
  20495. );
  20496. // if(resData.status){
  20497. // resData
  20498. // }
  20499. } else {
  20500. SweetAlert.swal({
  20501. title: "系统错误",
  20502. text: "系统错误,请稍后重试!",
  20503. type: "error",
  20504. confirmButtonColor: "#DD6B55",
  20505. });
  20506. }
  20507. $scope.ldloading[style.replace("-", "_")] = false;
  20508. });
  20509. } else {
  20510. console.log($scope.formData.url, "zzzz");
  20511. switch ($scope.formData.url) {
  20512. case "start":
  20513. vm.model["initUser"] = $rootScope.user.id;
  20514. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  20515. } else {
  20516. vm.model["assignee"] = $rootScope.user.id;
  20517. }
  20518. if (
  20519. vm.model["candidateGroups"] &&
  20520. vm.model.candidateGroups.id
  20521. ) {
  20522. vm.model.candidateGroups = vm.model.candidateGroups.id;
  20523. }
  20524. if (pdKey == "bpm_service_request") {
  20525. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  20526. angular.extend(vm.model.serviceCatalogueProcessActual, {
  20527. category: {
  20528. id: $stateParams.userId,
  20529. },
  20530. });
  20531. }
  20532. if (vm.model.schedule && vm.model.schedule.initUser) {
  20533. delete vm.model.schedule.initUser.menu;
  20534. }
  20535. if (
  20536. vm.model.isHandlerUser == "true" ||
  20537. vm.model.isHandlerUser == true
  20538. ) {
  20539. delete vm.model.candidateGroups;
  20540. }
  20541. if (vm.model.start_code == "close") {
  20542. // 直接处理
  20543. vm.model.incident.handlingPersonnelUser =
  20544. vm.model.incident.acceptUser;
  20545. delete vm.model.incident.handlerUser;
  20546. delete vm.model.candidateGroups;
  20547. } else if (vm.model.start_code == "assignment") {
  20548. // 派单
  20549. delete vm.model.incident.handlingPersonnelUser;
  20550. }
  20551. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  20552. $scope.jry_processInstanceId =
  20553. $stateParams.processInstanceId;
  20554. }
  20555. if ($scope.jry_processInstanceId) {
  20556. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  20557. }
  20558. //事件暂存判断
  20559. if (vm.model.saveAgain) {
  20560. if (
  20561. vm.model.directClose == "1" ||
  20562. vm.model.directClose == true
  20563. ) {
  20564. vm.model.start_code = "assignment";
  20565. vm.model.temporary_code = "assignment";
  20566. } else {
  20567. vm.model.start_code = "close";
  20568. vm.model.temporary_code = "close";
  20569. }
  20570. if (
  20571. vm.model.isHandlerUser == "true" ||
  20572. vm.model.isHandlerUser == true
  20573. ) {
  20574. delete vm.model.candidateGroups;
  20575. }
  20576. }
  20577. //处理请求数据0327
  20578. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20579. delete data0327.repairType;
  20580. // 增加地点的请求参数2020年4月24日10:44:36
  20581. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20582. // if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  20583. // data0327.incident.place = {
  20584. // id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  20585. // }
  20586. // }
  20587. if (data0327.start_code == "close") {
  20588. data0327.incident.directProcess = 1;
  20589. }
  20590. console.log(vm);
  20591. api_bpm_domain
  20592. .start(pdKey, data0327)
  20593. .then(function (response) {
  20594. // console.log("response="+JSON.stringify(response));
  20595. if (response) {
  20596. var resData = Restangular.stripRestangular(response);
  20597. if (resData) {
  20598. if (resData) {
  20599. if (
  20600. $scope.fileUploader != null &&
  20601. $scope.fileUploader.getNotUploadedItems().length >
  20602. 0 &&
  20603. resData.id
  20604. ) {
  20605. $scope.fileUploader.onBeforeUploadItem =
  20606. function (item) {
  20607. angular.extend(
  20608. item.headers,
  20609. $rootScope.getSession()
  20610. );
  20611. item.url = api_bpm_domain
  20612. .uploadAttachment(
  20613. resData.id,
  20614. "00000",
  20615. $rootScope.user.id
  20616. )
  20617. .getRequestedUrl();
  20618. item.formData.push({
  20619. fileName: item.file.name,
  20620. });
  20621. //console.log();
  20622. };
  20623. $scope.fileUploader.uploadAll();
  20624. }
  20625. }
  20626. }
  20627. SweetAlert.swal(
  20628. {
  20629. title: "提交成功!",
  20630. type: "success",
  20631. confirmButtonColor: "#007AFF",
  20632. },
  20633. function () {
  20634. if (
  20635. vm.model.incident &&
  20636. vm.model.incident.callID &&
  20637. vm.model.incident.callID != ""
  20638. ) {
  20639. $rootScope.app.layout.isSidebarClosed = false;
  20640. if ($scope.login && !$rootScope.busy) {
  20641. $rootScope.setidle();
  20642. }
  20643. }
  20644. $state.go($scope.formData.cancelUrl);
  20645. }
  20646. );
  20647. } else {
  20648. SweetAlert.swal({
  20649. title: "系统错误",
  20650. text: "系统错误,请稍后重试!",
  20651. type: "error",
  20652. confirmButtonColor: "#DD6B55",
  20653. });
  20654. }
  20655. $scope.ldloading[style.replace("-", "_")] = false;
  20656. });
  20657. break;
  20658. case "complete":
  20659. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  20660. //console.log("complete taskId::"+$stateParams.taskId);
  20661. if (
  20662. $scope.formData.name == "transferform" &&
  20663. vm.model.ishandlers &&
  20664. !vm.model.incident.handlerUser
  20665. ) {
  20666. SweetAlert.swal({
  20667. title: "处理人未填",
  20668. text: "请填写此项!",
  20669. type: "error",
  20670. confirmButtonColor: "#DD6B55",
  20671. });
  20672. return;
  20673. }
  20674. api_bpm_domain
  20675. .complete($stateParams.taskId, userId, vm.model)
  20676. .then(function (response) {
  20677. if (response) {
  20678. var resData = Restangular.stripRestangular(response);
  20679. SweetAlert.swal(
  20680. {
  20681. title: "提交成功!",
  20682. type: "success",
  20683. confirmButtonColor: "#007AFF",
  20684. },
  20685. function () {
  20686. if (
  20687. $scope.fileUploader != null &&
  20688. $scope.fileUploader.getNotUploadedItems().length >
  20689. 0
  20690. ) {
  20691. console.log(vm);
  20692. if (vm.model.incident) {
  20693. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  20694. // angular.extend(item.headers, $rootScope.getSession());
  20695. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  20696. // item.formData.push({
  20697. // 'fileName': item.file.name
  20698. // });
  20699. // };
  20700. // $scope.fileUploader.uploadAll();
  20701. $scope.fileUploader.onBeforeUploadItem =
  20702. function (item) {
  20703. angular.extend(
  20704. item.headers,
  20705. $rootScope.getSession()
  20706. );
  20707. item.url = api_bpm_domain
  20708. .uploadAttachment(
  20709. vm.model.incident.processInstanceId,
  20710. "00000",
  20711. $rootScope.user.id
  20712. )
  20713. .getRequestedUrl();
  20714. item.formData.push({
  20715. fileName: item.file.name,
  20716. });
  20717. //console.log();
  20718. };
  20719. $scope.fileUploader.uploadAll();
  20720. } else if (vm.model.problem) {
  20721. $scope.fileUploader.onBeforeUploadItem =
  20722. function (item) {
  20723. angular.extend(
  20724. item.headers,
  20725. $rootScope.getSession()
  20726. );
  20727. item.url = api_bpm_domain
  20728. .uploadAttachmentJryModel(
  20729. "problem",
  20730. vm.model.problem.id,
  20731. "00000",
  20732. $rootScope.user.id
  20733. )
  20734. .getRequestedUrl();
  20735. item.formData.push({
  20736. fileName: item.file.name,
  20737. });
  20738. };
  20739. $scope.fileUploader.uploadAll();
  20740. } else if (vm.model.change) {
  20741. }
  20742. }
  20743. $state.go($scope.formData.cancelUrl);
  20744. }
  20745. );
  20746. } else {
  20747. SweetAlert.swal({
  20748. title: "系统错误",
  20749. text: "系统错误,请稍后重试!",
  20750. type: "error",
  20751. confirmButtonColor: "#DD6B55",
  20752. });
  20753. }
  20754. $scope.ldloading[style.replace("-", "_")] = false;
  20755. });
  20756. break;
  20757. case "back":
  20758. $state.go($scope.formData.cancelUrl);
  20759. break;
  20760. default:
  20761. $scope.ldloading[style.replace("-", "_")] = false;
  20762. break;
  20763. }
  20764. }
  20765. // var submitFunc = api_bpm_domain[$scope.formData.url]
  20766. // if(anuglar.isFunction(submitFunc)){
  20767. // submitFunc.apply(null, pdKey)
  20768. // }
  20769. }
  20770. }
  20771. } else {
  20772. // console.log(data)
  20773. // angular.forEach(vm.form.$error.required, function(item){
  20774. // var i=(item.$name).substring(item.$name.length-2)
  20775. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  20776. // for(var i=0;i<vm.fields.length;i++){
  20777. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  20778. SweetAlert.swal({
  20779. title: vm.fields[i].templateOptions.label + "未填",
  20780. text: "请填写此项!",
  20781. type: "error",
  20782. confirmButtonColor: "#DD6B55",
  20783. });
  20784. }
  20785. // }
  20786. // angular.forEach(vm.fields,function(f){
  20787. // if(f.name == item.$name){
  20788. // f.validation.show = true;
  20789. // SweetAlert.swal({
  20790. // title: f.templateOptions.label+'未填',
  20791. // text: "请填写此项!",
  20792. // type: "error",
  20793. // confirmButtonColor: "#DD6B55"
  20794. // });
  20795. // }
  20796. // });
  20797. // })
  20798. }
  20799. };
  20800. $scope.vm = vm;
  20801. console.log($stateParams, pdKey, 88888);
  20802. console.log($scope.vm, "assdfsdf");
  20803. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  20804. var processInstanceId = $stateParams.processInstanceId;
  20805. var itemId = $stateParams.dataId;
  20806. console.log($stateParams);
  20807. if (
  20808. angular.isDefined($stateParams.pdKey) &&
  20809. $stateParams.pdKey == "bpm_inspection"
  20810. ) {
  20811. api_configure_form
  20812. .renderForm(
  20813. $stateParams.formUiEdit,
  20814. userId,
  20815. processInstanceId,
  20816. itemId
  20817. )
  20818. .then(function (responseData) {
  20819. if (responseData) {
  20820. //console.log("responseData>>>");//console.log(responseData);
  20821. var vmForm = Restangular.stripRestangular(responseData);
  20822. if (vmForm) {
  20823. //console.log("vmForm>>>");//console.log(vmForm);
  20824. decodeVMForm(vmForm);
  20825. }
  20826. }
  20827. });
  20828. } else if (
  20829. angular.isDefined($stateParams.pdKey) &&
  20830. $stateParams.pdKey == "bpm_service_request"
  20831. ) {
  20832. api_configure_form
  20833. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  20834. .then(function (responseData) {
  20835. if (responseData) {
  20836. //console.log("responseData>>>");//console.log(responseData);
  20837. var vmForm = Restangular.stripRestangular(responseData);
  20838. if (vmForm) {
  20839. //console.log("vmForm>>>");//console.log(vmForm);
  20840. decodeVMForm(vmForm);
  20841. }
  20842. }
  20843. });
  20844. } else {
  20845. api_bpm_domain
  20846. .taskformkey($stateParams.taskId)
  20847. .then(function (response) {
  20848. if (response) {
  20849. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  20850. api_configure_form
  20851. .renderForm(myData.data, userId, processInstanceId, itemId)
  20852. .then(function (responseData) {
  20853. if (responseData) {
  20854. //console.log("responseData>>>");//console.log(responseData);
  20855. var vmForm = Restangular.stripRestangular(responseData);
  20856. if (vmForm) {
  20857. //console.log("vmForm>>>");//console.log(vmForm);
  20858. decodeVMForm(vmForm);
  20859. console.log(vmForm, 111111);
  20860. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  20861. console.log($scope, "今天"); //2020年4月24日11:40:55
  20862. }
  20863. }
  20864. });
  20865. }
  20866. });
  20867. }
  20868. } else {
  20869. // create process instance
  20870. if (pdKey != "") {
  20871. //for process
  20872. if (pdKey == "bpm_service_request") {
  20873. api_configure_form
  20874. .renderForm($stateParams.formUiStart, userId)
  20875. .then(function (responseData) {
  20876. if (responseData) {
  20877. var vmForm = Restangular.stripRestangular(responseData);
  20878. if (vmForm) {
  20879. decodeVMForm(vmForm);
  20880. }
  20881. }
  20882. });
  20883. } else {
  20884. api_bpm_domain.startformkey(pdKey).then(function (response) {
  20885. if (response) {
  20886. var myData = Restangular.stripRestangular(response);
  20887. //myData.data = "arrangeform";
  20888. api_configure_form
  20889. .renderForm(myData.data, userId)
  20890. .then(function (responseData) {
  20891. if (responseData) {
  20892. var vmForm = Restangular.stripRestangular(responseData);
  20893. if (vmForm) {
  20894. decodeVMForm(vmForm);
  20895. }
  20896. }
  20897. });
  20898. }
  20899. });
  20900. }
  20901. } else {
  20902. //for form
  20903. //TODO
  20904. //测试数据 开始
  20905. var testJson = {
  20906. fields: [
  20907. {
  20908. fields: [
  20909. {
  20910. className: "col-xs-12",
  20911. noFormControl: true,
  20912. key: "formtitle",
  20913. templateOptions: {
  20914. readOnly: false,
  20915. placeholder: "新建事件单",
  20916. hidden: false,
  20917. label: "事件工单",
  20918. required: false,
  20919. },
  20920. type: "ui-title",
  20921. },
  20922. ],
  20923. },
  20924. {
  20925. fields: [
  20926. {
  20927. key: "selectUser",
  20928. type: "ui-deptinformation",
  20929. className: "col-xs-12",
  20930. templateOptions: {
  20931. label: "请求人信息",
  20932. modalTitle: "请求人列表",
  20933. fetchItems: function (filterData, APIService) {
  20934. return APIService.fetchDataList("requester", filterData);
  20935. },
  20936. Restangular: Restangular,
  20937. ApiService: api_user_data,
  20938. // onClick:function(val, options, field, event , model){
  20939. // console.log(options);
  20940. // }
  20941. },
  20942. },
  20943. ],
  20944. },
  20945. {
  20946. fields: [
  20947. {
  20948. key: "first",
  20949. type: "ui-workernumber",
  20950. className: "col-xs-12",
  20951. templateOptions: {
  20952. type: "input",
  20953. label: "事件单号",
  20954. pkey: "name",
  20955. },
  20956. },
  20957. ],
  20958. },
  20959. {
  20960. fields: [
  20961. {
  20962. type: "ui-header",
  20963. key: "title",
  20964. className: "col-xs-12",
  20965. templateOptions: {
  20966. label: "报修人",
  20967. pkey: "change",
  20968. },
  20969. },
  20970. {
  20971. type: "ui-input",
  20972. key: "title",
  20973. className: "col-xs-4",
  20974. templateOptions: {
  20975. label: "报修人",
  20976. pkey: "change",
  20977. },
  20978. },
  20979. {
  20980. type: "ui-input",
  20981. key: "title",
  20982. className: "col-xs-4",
  20983. templateOptions: {
  20984. label: "联系人",
  20985. pkey: "change",
  20986. },
  20987. },
  20988. {
  20989. type: "ui-input",
  20990. key: "title",
  20991. className: "col-xs-4",
  20992. templateOptions: {
  20993. label: "联系电话",
  20994. pkey: "change",
  20995. },
  20996. },
  20997. ],
  20998. },
  20999. {
  21000. fields: [
  21001. {
  21002. type: "ui-header",
  21003. key: "title1",
  21004. className: "col-xs-12",
  21005. templateOptions: {
  21006. label: "报修人",
  21007. pkey: "change",
  21008. },
  21009. },
  21010. {
  21011. type: "ui-input",
  21012. key: "title2",
  21013. className: "col-xs-4",
  21014. templateOptions: {
  21015. label: "报修人",
  21016. pkey: "change",
  21017. },
  21018. },
  21019. {
  21020. type: "ui-input",
  21021. key: "title3",
  21022. className: "col-xs-4",
  21023. templateOptions: {
  21024. label: "联系人",
  21025. pkey: "change",
  21026. },
  21027. },
  21028. {
  21029. type: "ui-input",
  21030. key: "title4",
  21031. className: "col-xs-4",
  21032. templateOptions: {
  21033. label: "联系电话",
  21034. pkey: "change",
  21035. },
  21036. },
  21037. ],
  21038. },
  21039. ],
  21040. model: [
  21041. {
  21042. username: "robin lau",
  21043. password: "123456",
  21044. chkme: false,
  21045. start_code: 0,
  21046. formtitle: "Hey!I am title value!",
  21047. name: {
  21048. first: "robin",
  21049. last: "lau",
  21050. },
  21051. multiselectItem: [],
  21052. //date:"2015-09-15 00:00:00"
  21053. },
  21054. ],
  21055. // }
  21056. };
  21057. setTimeout(function () {
  21058. decodeVMForm(testJson);
  21059. $scope.$apply();
  21060. }, 500);
  21061. //测试数据结束
  21062. }
  21063. }
  21064. //console.log("end decode");
  21065. },
  21066. ]);